f2-all.js 667 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["F2"] = factory();
  8. else
  9. root["F2"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 252);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. "use strict";
  80. var _interopRequireWildcard = __webpack_require__(49);
  81. exports.__esModule = true;
  82. var _exportNames = {
  83. isObjectValueEqual: true,
  84. parsePadding: true,
  85. directionEnabled: true,
  86. upperFirst: true,
  87. lowerFirst: true,
  88. isString: true,
  89. isNumber: true,
  90. isBoolean: true,
  91. isFunction: true,
  92. isDate: true,
  93. isArray: true,
  94. isNil: true,
  95. isObject: true,
  96. isPlainObject: true,
  97. isEqual: true,
  98. deepMix: true,
  99. mix: true,
  100. each: true,
  101. uniq: true,
  102. find: true,
  103. Array: true
  104. };
  105. exports.isObjectValueEqual = isObjectValueEqual;
  106. exports.parsePadding = parsePadding;
  107. exports.directionEnabled = directionEnabled;
  108. exports.Array = void 0;
  109. var _util = __webpack_require__(20);
  110. exports.upperFirst = _util.upperFirst;
  111. exports.lowerFirst = _util.lowerFirst;
  112. exports.isString = _util.isString;
  113. exports.isNumber = _util.isNumber;
  114. exports.isBoolean = _util.isBoolean;
  115. exports.isFunction = _util.isFunction;
  116. exports.isDate = _util.isDate;
  117. exports.isArray = _util.isArray;
  118. exports.isNil = _util.isNil;
  119. exports.isObject = _util.isObject;
  120. exports.isPlainObject = _util.isPlainObject;
  121. exports.isEqual = _util.isEqual;
  122. exports.deepMix = _util.deepMix;
  123. exports.mix = _util.mix;
  124. exports.each = _util.each;
  125. exports.uniq = _util.uniq;
  126. exports.find = _util.find;
  127. var ArrayUtil = _interopRequireWildcard(__webpack_require__(75));
  128. exports.Array = ArrayUtil;
  129. var _dom = __webpack_require__(62);
  130. Object.keys(_dom).forEach(function (key) {
  131. if (key === "default" || key === "__esModule") return;
  132. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  133. exports[key] = _dom[key];
  134. });
  135. /**
  136. * @fileOverview Utility for F2
  137. * @author dxq613 @gmail.com
  138. * @author sima.zhang1990@gmail.com
  139. */
  140. function isObjectValueEqual(a, b) {
  141. // for vue.js
  142. a = Object.assign({}, a);
  143. b = Object.assign({}, b);
  144. var aProps = Object.getOwnPropertyNames(a);
  145. var bProps = Object.getOwnPropertyNames(b);
  146. if (aProps.length !== bProps.length) {
  147. return false;
  148. }
  149. for (var i = 0, len = aProps.length; i < len; i++) {
  150. var propName = aProps[i];
  151. if (a[propName] !== b[propName]) {
  152. return false;
  153. }
  154. }
  155. return true;
  156. }
  157. function parsePadding(padding) {
  158. var top;
  159. var right;
  160. var bottom;
  161. var left;
  162. if ((0, _util.isNumber)(padding) || (0, _util.isString)(padding)) {
  163. top = bottom = left = right = padding;
  164. } else if ((0, _util.isArray)(padding)) {
  165. top = padding[0];
  166. right = !(0, _util.isNil)(padding[1]) ? padding[1] : padding[0];
  167. bottom = !(0, _util.isNil)(padding[2]) ? padding[2] : padding[0];
  168. left = !(0, _util.isNil)(padding[3]) ? padding[3] : right;
  169. }
  170. return [top, right, bottom, left];
  171. }
  172. function directionEnabled(mode, dir) {
  173. if (mode === undefined) {
  174. return true;
  175. } else if (typeof mode === 'string') {
  176. return mode.indexOf(dir) !== -1;
  177. }
  178. return false;
  179. }
  180. /***/ }),
  181. /* 1 */
  182. /***/ (function(module, exports) {
  183. function _interopRequireDefault(obj) {
  184. return obj && obj.__esModule ? obj : {
  185. "default": obj
  186. };
  187. }
  188. module.exports = _interopRequireDefault;
  189. /***/ }),
  190. /* 2 */
  191. /***/ (function(module, exports, __webpack_require__) {
  192. var _typeof = __webpack_require__(50);
  193. var assertThisInitialized = __webpack_require__(22);
  194. function _possibleConstructorReturn(self, call) {
  195. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  196. return call;
  197. }
  198. return assertThisInitialized(self);
  199. }
  200. module.exports = _possibleConstructorReturn;
  201. /***/ }),
  202. /* 3 */
  203. /***/ (function(module, exports) {
  204. function _getPrototypeOf(o) {
  205. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  206. return o.__proto__ || Object.getPrototypeOf(o);
  207. };
  208. return _getPrototypeOf(o);
  209. }
  210. module.exports = _getPrototypeOf;
  211. /***/ }),
  212. /* 4 */
  213. /***/ (function(module, exports) {
  214. function _inheritsLoose(subClass, superClass) {
  215. subClass.prototype = Object.create(superClass.prototype);
  216. subClass.prototype.constructor = subClass;
  217. subClass.__proto__ = superClass;
  218. }
  219. module.exports = _inheritsLoose;
  220. /***/ }),
  221. /* 5 */
  222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  223. "use strict";
  224. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  225. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  226. return Array.isArray ? Array.isArray(value) : Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Array');
  227. });
  228. /***/ }),
  229. /* 6 */
  230. /***/ (function(module, exports, __webpack_require__) {
  231. "use strict";
  232. var Theme = __webpack_require__(78);
  233. var Util = __webpack_require__(0);
  234. var Global = {
  235. version: '3.6.3',
  236. scales: {},
  237. widthRatio: {
  238. column: 1 / 2,
  239. rose: 0.999999,
  240. multiplePie: 3 / 4
  241. },
  242. lineDash: [4, 4]
  243. };
  244. Global.setTheme = function (theme) {
  245. Util.deepMix(this, theme);
  246. };
  247. Global.setTheme(Theme);
  248. module.exports = Global;
  249. /***/ }),
  250. /* 7 */
  251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  252. "use strict";
  253. var isArrayLike = function (value) {
  254. /**
  255. * isArrayLike([1, 2, 3]) => true
  256. * isArrayLike(document.body.children) => true
  257. * isArrayLike('abc') => true
  258. * isArrayLike(Function) => false
  259. */
  260. return value !== null && typeof value !== 'function' && isFinite(value.length);
  261. };
  262. /* harmony default export */ __webpack_exports__["a"] = (isArrayLike);
  263. /***/ }),
  264. /* 8 */
  265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  266. "use strict";
  267. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  268. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_object__ = __webpack_require__(29);
  269. function each(elements, func) {
  270. if (!elements) {
  271. return;
  272. }
  273. var rst;
  274. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(elements)) {
  275. for (var i = 0, len = elements.length; i < len; i++) {
  276. rst = func(elements[i], i);
  277. if (rst === false) {
  278. break;
  279. }
  280. }
  281. } else if (Object(__WEBPACK_IMPORTED_MODULE_1__is_object__["a" /* default */])(elements)) {
  282. for (var k in elements) {
  283. if (elements.hasOwnProperty(k)) {
  284. rst = func(elements[k], k);
  285. if (rst === false) {
  286. break;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. /* harmony default export */ __webpack_exports__["a"] = (each);
  293. /***/ }),
  294. /* 9 */
  295. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  296. "use strict";
  297. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  298. /**
  299. * 是否为函数
  300. * @param {*} fn 对象
  301. * @return {Boolean} 是否函数
  302. */
  303. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  304. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Function');
  305. });
  306. /***/ }),
  307. /* 10 */
  308. /***/ (function(module, exports, __webpack_require__) {
  309. "use strict";
  310. var _interopRequireDefault = __webpack_require__(1);
  311. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  312. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  313. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  314. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  315. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  316. var Util = __webpack_require__(0);
  317. var Element = __webpack_require__(46);
  318. var Shape = /*#__PURE__*/function (_Element) {
  319. (0, _inheritsLoose2["default"])(Shape, _Element);
  320. var _super = _createSuper(Shape);
  321. function Shape() {
  322. return _Element.apply(this, arguments) || this;
  323. }
  324. var _proto = Shape.prototype;
  325. _proto._initProperties = function _initProperties() {
  326. this._attrs = {
  327. zIndex: 0,
  328. visible: true,
  329. destroyed: false,
  330. isShape: true,
  331. attrs: {}
  332. };
  333. };
  334. _proto.getType = function getType() {
  335. return this._attrs.type;
  336. };
  337. _proto.drawInner = function drawInner(context) {
  338. var self = this;
  339. var attrs = self.get('attrs');
  340. self.createPath(context);
  341. var originOpacity = context.globalAlpha;
  342. if (self.hasFill()) {
  343. var fillOpacity = attrs.fillOpacity;
  344. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  345. context.globalAlpha = fillOpacity;
  346. context.fill();
  347. context.globalAlpha = originOpacity;
  348. } else {
  349. context.fill();
  350. }
  351. }
  352. if (self.hasStroke()) {
  353. var lineWidth = attrs.lineWidth;
  354. if (lineWidth > 0) {
  355. var strokeOpacity = attrs.strokeOpacity;
  356. if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
  357. context.globalAlpha = strokeOpacity;
  358. }
  359. context.stroke();
  360. }
  361. }
  362. };
  363. _proto.getBBox = function getBBox() {
  364. var bbox = this._attrs.bbox;
  365. if (!bbox) {
  366. bbox = this.calculateBox();
  367. if (bbox) {
  368. bbox.x = bbox.minX;
  369. bbox.y = bbox.minY;
  370. bbox.width = bbox.maxX - bbox.minX;
  371. bbox.height = bbox.maxY - bbox.minY;
  372. }
  373. this._attrs.bbox = bbox;
  374. }
  375. return bbox;
  376. };
  377. _proto.calculateBox = function calculateBox() {
  378. return null;
  379. };
  380. _proto.createPath = function createPath() {};
  381. return Shape;
  382. }(Element);
  383. module.exports = Shape;
  384. /***/ }),
  385. /* 11 */
  386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  387. "use strict";
  388. var toString = {}.toString;
  389. var isType = function (value, type) {
  390. return toString.call(value) === '[object ' + type + ']';
  391. };
  392. /* harmony default export */ __webpack_exports__["a"] = (isType);
  393. /***/ }),
  394. /* 12 */
  395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  396. "use strict";
  397. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  398. /**
  399. * 判断是否数字
  400. * @return {Boolean} 是否数字
  401. */
  402. var isNumber = function (value) {
  403. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Number');
  404. };
  405. /* harmony default export */ __webpack_exports__["a"] = (isNumber);
  406. /***/ }),
  407. /* 13 */
  408. /***/ (function(module, exports, __webpack_require__) {
  409. "use strict";
  410. /**
  411. * 2 Dimensional Vector
  412. * @module vector2
  413. */
  414. module.exports = {
  415. /**
  416. * Creates a new, empty vector2
  417. *
  418. * @return {vector2} a new 2D vector
  419. */
  420. create: function create() {
  421. return [0, 0];
  422. },
  423. /**
  424. * Calculates the length of a vector2
  425. *
  426. * @param {vector2} v vector to calculate length of
  427. * @return {Number} length of v
  428. */
  429. length: function length(v) {
  430. var x = v[0];
  431. var y = v[1];
  432. return Math.sqrt(x * x + y * y);
  433. },
  434. /**
  435. * Normalize a vector2
  436. *
  437. * @param {vector2} out the receiving vector
  438. * @param {vector2} v vector to normalize
  439. * @return {vector2} out
  440. */
  441. normalize: function normalize(out, v) {
  442. var len = this.length(v);
  443. if (len === 0) {
  444. out[0] = 0;
  445. out[1] = 0;
  446. } else {
  447. out[0] = v[0] / len;
  448. out[1] = v[1] / len;
  449. }
  450. return out;
  451. },
  452. /**
  453. * Adds two vector2's
  454. *
  455. * @param {vector2} out the receiving vector
  456. * @param {vector2} v1 the first operand
  457. * @param {vector2} v2 the second operand
  458. * @return {vector2} out
  459. */
  460. add: function add(out, v1, v2) {
  461. out[0] = v1[0] + v2[0];
  462. out[1] = v1[1] + v2[1];
  463. return out;
  464. },
  465. /**
  466. * Subtracts vector v2 from vector v1
  467. *
  468. * @param {vector2} out the receiving vector
  469. * @param {vector2} v1 the first operand
  470. * @param {vector2} v2 the second operand
  471. * @return {vector2} out
  472. */
  473. sub: function sub(out, v1, v2) {
  474. out[0] = v1[0] - v2[0];
  475. out[1] = v1[1] - v2[1];
  476. return out;
  477. },
  478. /**
  479. * Scales a vector2 by a scalar number
  480. *
  481. * @param {vector2} out the receiving vector
  482. * @param {vector2} v the vector to scale
  483. * @param {Number} s amount to scale the vector by
  484. * @return {vector2} out
  485. */
  486. scale: function scale(out, v, s) {
  487. out[0] = v[0] * s;
  488. out[1] = v[1] * s;
  489. return out;
  490. },
  491. /**
  492. * Calculates the dot product of two vector2's
  493. *
  494. * @param {vector2} v1 the first operand
  495. * @param {vector2} v2 the second operand
  496. * @return {Number} dot product of v1 and v2
  497. */
  498. dot: function dot(v1, v2) {
  499. return v1[0] * v2[0] + v1[1] * v2[1];
  500. },
  501. /**
  502. * Calculates the direction of two vector2's
  503. *
  504. * @param {vector2} v1 the first operand
  505. * @param {vector2} v2 the second operand
  506. * @return {Boolean} the direction of v1 and v2
  507. */
  508. direction: function direction(v1, v2) {
  509. return v1[0] * v2[1] - v2[0] * v1[1];
  510. },
  511. /**
  512. * Calculates the angle of two vector2's
  513. *
  514. * @param {vector2} v1 the first operand
  515. * @param {vector2} v2 the second operand
  516. * @return {Number} angle of v1 and v2
  517. */
  518. angle: function angle(v1, v2) {
  519. var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
  520. return Math.acos(theta);
  521. },
  522. /**
  523. * Calculates the angle of two vector2's with direction
  524. *
  525. * @param {vector2} v1 the first operand
  526. * @param {vector2} v2 the second operand
  527. * @param {Boolean} direction the direction of two vector2's
  528. * @return {Number} angle of v1 and v2
  529. */
  530. angleTo: function angleTo(v1, v2, direction) {
  531. var angle = this.angle(v1, v2);
  532. var angleLargeThanPI = this.direction(v1, v2) >= 0;
  533. if (direction) {
  534. if (angleLargeThanPI) {
  535. return Math.PI * 2 - angle;
  536. }
  537. return angle;
  538. }
  539. if (angleLargeThanPI) {
  540. return angle;
  541. }
  542. return Math.PI * 2 - angle;
  543. },
  544. /**
  545. * whether a vector2 is zero vector
  546. *
  547. * @param {vector2} v vector to calculate
  548. * @return {Boolean} is or not a zero vector
  549. */
  550. zero: function zero(v) {
  551. return v[0] === 0 && v[1] === 0;
  552. },
  553. /**
  554. * Calculates the euclidian distance between two vector2's
  555. *
  556. * @param {vector2} v1 the first operand
  557. * @param {vector2} v2 the second operand
  558. * @return {Number} distance between a and b
  559. */
  560. distance: function distance(v1, v2) {
  561. var x = v2[0] - v1[0];
  562. var y = v2[1] - v1[1];
  563. return Math.sqrt(x * x + y * y);
  564. },
  565. /**
  566. * Creates a new vector2 initialized with values from an existing vector
  567. *
  568. * @param {vector2} v vector to clone
  569. * @return {Array} a new 2D vector
  570. */
  571. clone: function clone(v) {
  572. return [v[0], v[1]];
  573. },
  574. /**
  575. * Return the minimum of two vector2's
  576. *
  577. * @param {vector2} out the receiving vector
  578. * @param {vector2} v1 the first operand
  579. * @param {vector2} v2 the second operand
  580. * @return {vector2} out
  581. */
  582. min: function min(out, v1, v2) {
  583. out[0] = Math.min(v1[0], v2[0]);
  584. out[1] = Math.min(v1[1], v2[1]);
  585. return out;
  586. },
  587. /**
  588. * Return the maximum of two vector2's
  589. *
  590. * @param {vector2} out the receiving vector
  591. * @param {vector2} v1 the first operand
  592. * @param {vector2} v2 the second operand
  593. * @return {vector2} out
  594. */
  595. max: function max(out, v1, v2) {
  596. out[0] = Math.max(v1[0], v2[0]);
  597. out[1] = Math.max(v1[1], v2[1]);
  598. return out;
  599. },
  600. /**
  601. * Transforms the vector2 with a mat2d
  602. *
  603. * @param {vector2} out the receiving vector
  604. * @param {vector2} v the vector to transform
  605. * @param {mat2d} m matrix to transform with
  606. * @return {vector2} out
  607. */
  608. transformMat2d: function transformMat2d(out, v, m) {
  609. var x = v[0];
  610. var y = v[1];
  611. out[0] = m[0] * x + m[2] * y + m[4];
  612. out[1] = m[1] * x + m[3] * y + m[5];
  613. return out;
  614. }
  615. };
  616. /***/ }),
  617. /* 14 */
  618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  619. "use strict";
  620. // isFinite,
  621. var isNil = function (value) {
  622. /**
  623. * isNil(null) => true
  624. * isNil() => true
  625. */
  626. return value === null || value === undefined;
  627. };
  628. /* harmony default export */ __webpack_exports__["a"] = (isNil);
  629. /***/ }),
  630. /* 15 */
  631. /***/ (function(module, exports, __webpack_require__) {
  632. var isObject = __webpack_require__(44);
  633. var isArray = __webpack_require__(34);
  634. var each = function each(elements, func) {
  635. if (!elements) {
  636. return;
  637. }
  638. var rst = void 0;
  639. if (isArray(elements)) {
  640. for (var i = 0, len = elements.length; i < len; i++) {
  641. rst = func(elements[i], i);
  642. if (rst === false) {
  643. break;
  644. }
  645. }
  646. } else if (isObject(elements)) {
  647. for (var k in elements) {
  648. if (elements.hasOwnProperty(k)) {
  649. rst = func(elements[k], k);
  650. if (rst === false) {
  651. break;
  652. }
  653. }
  654. }
  655. }
  656. };
  657. module.exports = each;
  658. /***/ }),
  659. /* 16 */
  660. /***/ (function(module, exports, __webpack_require__) {
  661. "use strict";
  662. var G = {
  663. Canvas: __webpack_require__(176),
  664. Group: __webpack_require__(67),
  665. Shape: __webpack_require__(10),
  666. Matrix: __webpack_require__(31),
  667. Vector2: __webpack_require__(13)
  668. };
  669. __webpack_require__(180);
  670. __webpack_require__(181);
  671. __webpack_require__(182);
  672. __webpack_require__(183);
  673. __webpack_require__(184);
  674. __webpack_require__(185);
  675. __webpack_require__(186);
  676. __webpack_require__(187);
  677. __webpack_require__(189);
  678. module.exports = G;
  679. /***/ }),
  680. /* 17 */
  681. /***/ (function(module, exports, __webpack_require__) {
  682. "use strict";
  683. var _interopRequireWildcard = __webpack_require__(49);
  684. var _interopRequireDefault = __webpack_require__(1);
  685. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  686. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  687. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  688. var Attr = _interopRequireWildcard(__webpack_require__(161));
  689. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  690. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  691. var Util = __webpack_require__(0);
  692. var Base = __webpack_require__(63);
  693. var GROUP_ATTRS = ['color', 'size', 'shape'];
  694. var FIELD_ORIGIN = '_origin';
  695. var FIELD_ORIGIN_Y = '_originY';
  696. var Global = __webpack_require__(6);
  697. var GeometryShape = __webpack_require__(19);
  698. var Adjust = __webpack_require__(33);
  699. function parseFields(field) {
  700. if (Util.isArray(field)) {
  701. return field;
  702. }
  703. if (Util.isString(field)) {
  704. return field.split('*');
  705. }
  706. return [field];
  707. }
  708. /**
  709. * The parent class for Geometry
  710. * @class Geom
  711. */
  712. var Geom = /*#__PURE__*/function (_Base) {
  713. (0, _inheritsLoose2["default"])(Geom, _Base);
  714. var _super = _createSuper(Geom);
  715. function Geom() {
  716. return _Base.apply(this, arguments) || this;
  717. }
  718. var _proto = Geom.prototype;
  719. _proto.getDefaultCfg = function getDefaultCfg() {
  720. return {
  721. /**
  722. * geometry type
  723. * @type {String}
  724. */
  725. type: null,
  726. /**
  727. * the data of geometry
  728. * @type {Array}
  729. */
  730. data: null,
  731. /**
  732. * the attrs of geo,etry
  733. * @type {Object}
  734. */
  735. attrs: {},
  736. scales: {},
  737. /**
  738. * group for storing the shapes
  739. * @type {Canvas}
  740. */
  741. container: null,
  742. /**
  743. * style options
  744. * @type {Object}
  745. */
  746. styleOptions: null,
  747. chart: null,
  748. shapeType: '',
  749. /**
  750. * wether to generate key points for each shape
  751. * @protected
  752. * @type {Boolean}
  753. */
  754. generatePoints: false,
  755. attrOptions: {},
  756. sortable: false,
  757. startOnZero: true,
  758. visible: true,
  759. connectNulls: false,
  760. // 是否丢弃没有值的分组。
  761. ignoreEmptyGroup: false
  762. };
  763. };
  764. _proto.init = function init() {
  765. var self = this;
  766. self._initAttrs();
  767. self._processData();
  768. };
  769. _proto._getGroupScales = function _getGroupScales() {
  770. var self = this;
  771. var scales = [];
  772. Util.each(GROUP_ATTRS, function (attrName) {
  773. var attr = self.getAttr(attrName);
  774. if (attr) {
  775. var attrScales = attr.scales;
  776. Util.each(attrScales, function (scale) {
  777. if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
  778. scales.push(scale);
  779. }
  780. });
  781. }
  782. });
  783. return scales;
  784. };
  785. _proto._groupData = function _groupData(data) {
  786. var self = this;
  787. var colDefs = self.get('colDefs');
  788. var groupScales = self._getGroupScales();
  789. if (groupScales.length) {
  790. var appendConditions = {};
  791. var names = [];
  792. Util.each(groupScales, function (scale) {
  793. var field = scale.field;
  794. names.push(field);
  795. if (colDefs && colDefs[field] && colDefs[field].values) {
  796. // users have defined
  797. appendConditions[scale.field] = colDefs[field].values;
  798. }
  799. });
  800. return Util.Array.group(data, names, appendConditions);
  801. }
  802. return [data];
  803. };
  804. _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
  805. var options = this.get('attrOptions');
  806. options[attrName] = attrCfg;
  807. var attrs = this.get('attrs'); // 说明已经初始化过了
  808. if (Object.keys(attrs).length) {
  809. this._createAttr(attrName, attrCfg);
  810. }
  811. };
  812. _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
  813. var attrCfg = {};
  814. attrCfg.field = field;
  815. if (cfg) {
  816. if (Util.isFunction(cfg)) {
  817. attrCfg.callback = cfg;
  818. } else {
  819. attrCfg.values = cfg;
  820. }
  821. } else {
  822. attrCfg.values = defaultValues;
  823. }
  824. this._setAttrOptions(attrName, attrCfg);
  825. };
  826. _proto._createAttr = function _createAttr(type, option) {
  827. var self = this;
  828. var attrs = self.get('attrs');
  829. var coord = self.get('coord');
  830. var className = Util.upperFirst(type);
  831. var fields = parseFields(option.field);
  832. if (type === 'position') {
  833. option.coord = coord;
  834. }
  835. var scales = [];
  836. for (var i = 0, len = fields.length; i < len; i++) {
  837. var field = fields[i];
  838. var scale = self._createScale(field);
  839. scales.push(scale);
  840. }
  841. if (type === 'position') {
  842. var yScale = scales[1]; // 饼图的处理,但是还不知道为啥
  843. if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
  844. if (yScale.values.length) {
  845. yScale.change({
  846. nice: false,
  847. min: 0,
  848. max: Math.max.apply(null, yScale.values)
  849. });
  850. }
  851. }
  852. }
  853. option.scales = scales;
  854. var attr = new Attr[className](option);
  855. attrs[type] = attr;
  856. return attr;
  857. };
  858. _proto._initAttrs = function _initAttrs() {
  859. var self = this;
  860. var attrOptions = self.get('attrOptions');
  861. for (var type in attrOptions) {
  862. if (attrOptions.hasOwnProperty(type)) {
  863. this._createAttr(type, attrOptions[type]);
  864. }
  865. }
  866. };
  867. _proto._createScale = function _createScale(field) {
  868. var scales = this.get('scales');
  869. var scale = scales[field];
  870. if (!scale) {
  871. scale = this.get('chart').createScale(field);
  872. scales[field] = scale;
  873. }
  874. return scale;
  875. };
  876. _proto._processData = function _processData() {
  877. var self = this;
  878. var data = this.get('data');
  879. var dataArray = [];
  880. var groupedArray = this._groupData(data);
  881. if (this.get('ignoreEmptyGroup')) {
  882. var yScale = this.getYScale();
  883. groupedArray = groupedArray.filter(function (group) {
  884. return group.some(function (item) {
  885. return typeof item[yScale.field] !== 'undefined';
  886. });
  887. });
  888. }
  889. for (var i = 0, len = groupedArray.length; i < len; i++) {
  890. var subData = groupedArray[i];
  891. var tempData = self._saveOrigin(subData);
  892. if (this.hasAdjust('dodge')) {
  893. self._numberic(tempData);
  894. }
  895. dataArray.push(tempData);
  896. }
  897. if (self.get('adjust')) {
  898. self._adjustData(dataArray);
  899. }
  900. if (self.get('sortable')) {
  901. self._sort(dataArray);
  902. }
  903. self.set('dataArray', dataArray);
  904. return dataArray;
  905. };
  906. _proto._saveOrigin = function _saveOrigin(data) {
  907. var rst = [];
  908. for (var i = 0, len = data.length; i < len; i++) {
  909. var origin = data[i];
  910. var obj = {};
  911. for (var k in origin) {
  912. obj[k] = origin[k];
  913. }
  914. obj[FIELD_ORIGIN] = origin;
  915. rst.push(obj);
  916. }
  917. return rst;
  918. };
  919. _proto._numberic = function _numberic(data) {
  920. var positionAttr = this.getAttr('position');
  921. var scales = positionAttr.scales;
  922. for (var j = 0, len = data.length; j < len; j++) {
  923. var obj = data[j];
  924. var count = Math.min(2, scales.length);
  925. for (var i = 0; i < count; i++) {
  926. var scale = scales[i];
  927. if (scale.isCategory) {
  928. var field = scale.field;
  929. obj[field] = scale.translate(obj[field]);
  930. }
  931. }
  932. }
  933. };
  934. _proto._adjustData = function _adjustData(dataArray) {
  935. var self = this;
  936. var adjust = self.get('adjust');
  937. if (adjust) {
  938. var adjustType = Util.upperFirst(adjust.type);
  939. if (!Adjust[adjustType]) {
  940. throw new Error('not support such adjust : ' + adjust);
  941. }
  942. var xScale = self.getXScale();
  943. var yScale = self.getYScale();
  944. var cfg = Util.mix({
  945. xField: xScale.field,
  946. yField: yScale.field
  947. }, adjust);
  948. var adjustObject = new Adjust[adjustType](cfg);
  949. adjustObject.processAdjust(dataArray);
  950. if (adjustType === 'Stack') {
  951. self._updateStackRange(yScale.field, yScale, dataArray);
  952. }
  953. }
  954. };
  955. _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
  956. var mergeArray = Util.Array.merge(dataArray);
  957. var min = scale.min;
  958. var max = scale.max;
  959. for (var i = 0, len = mergeArray.length; i < len; i++) {
  960. var obj = mergeArray[i];
  961. var tmpMin = Math.min.apply(null, obj[field]);
  962. var tmpMax = Math.max.apply(null, obj[field]);
  963. if (tmpMin < min) {
  964. min = tmpMin;
  965. }
  966. if (tmpMax > max) {
  967. max = tmpMax;
  968. }
  969. }
  970. if (min < scale.min || max > scale.max) {
  971. scale.change({
  972. min: min,
  973. max: max
  974. });
  975. }
  976. };
  977. _proto._sort = function _sort(mappedArray) {
  978. var self = this;
  979. var xScale = self.getXScale();
  980. var field = xScale.field,
  981. type = xScale.type;
  982. if (type !== 'identity' && xScale.values.length > 1) {
  983. Util.each(mappedArray, function (itemArr) {
  984. itemArr.sort(function (obj1, obj2) {
  985. if (type === 'timeCat') {
  986. return xScale._toTimeStamp(obj1[FIELD_ORIGIN][field]) - xScale._toTimeStamp(obj2[FIELD_ORIGIN][field]);
  987. }
  988. return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
  989. });
  990. });
  991. }
  992. self.set('hasSorted', true);
  993. self.set('dataArray', mappedArray);
  994. };
  995. _proto.paint = function paint() {
  996. var self = this;
  997. var dataArray = self.get('dataArray');
  998. var mappedArray = [];
  999. var shapeFactory = self.getShapeFactory();
  1000. shapeFactory.setCoord(self.get('coord'));
  1001. self._beforeMapping(dataArray);
  1002. for (var i = 0, len = dataArray.length; i < len; i++) {
  1003. var data = dataArray[i];
  1004. if (data.length) {
  1005. data = self._mapping(data);
  1006. mappedArray.push(data);
  1007. self.draw(data, shapeFactory);
  1008. }
  1009. }
  1010. self.set('dataArray', mappedArray);
  1011. };
  1012. _proto.getShapeFactory = function getShapeFactory() {
  1013. var shapeFactory = this.get('shapeFactory');
  1014. if (!shapeFactory) {
  1015. var shapeType = this.get('shapeType');
  1016. shapeFactory = GeometryShape.getShapeFactory(shapeType);
  1017. this.set('shapeFactory', shapeFactory);
  1018. }
  1019. return shapeFactory;
  1020. };
  1021. _proto._mapping = function _mapping(data) {
  1022. var self = this;
  1023. var attrs = self.get('attrs');
  1024. var yField = self.getYScale().field; // 用来缓存转换的值,减少mapping耗时
  1025. var mappedCache = {};
  1026. for (var k in attrs) {
  1027. if (attrs.hasOwnProperty(k)) {
  1028. var attr = attrs[k];
  1029. var names = attr.names;
  1030. var scales = attr.scales;
  1031. for (var i = 0, len = data.length; i < len; i++) {
  1032. var record = data[i];
  1033. record[FIELD_ORIGIN_Y] = record[yField]; // 获取视觉属性对应的value值
  1034. // 位置的缓存命中率低,还是每次单独计算
  1035. if (attr.type === 'position') {
  1036. var values = self._getAttrValues(attr, record);
  1037. for (var j = 0, _len = values.length; j < _len; j++) {
  1038. var val = values[j];
  1039. var name = names[j];
  1040. record[name] = Util.isArray(val) && val.length === 1 ? val[0] : val;
  1041. }
  1042. } else {
  1043. // 除了position其他都只有一项
  1044. var _name = names[0];
  1045. var field = scales[0].field;
  1046. var value = record[field];
  1047. var key = "" + _name + value;
  1048. var _values = mappedCache[key];
  1049. if (!_values) {
  1050. _values = self._getAttrValues(attr, record);
  1051. mappedCache[key] = _values;
  1052. }
  1053. record[_name] = _values[0];
  1054. }
  1055. }
  1056. }
  1057. }
  1058. return data;
  1059. };
  1060. _proto._getAttrValues = function _getAttrValues(attr, record) {
  1061. var scales = attr.scales;
  1062. var params = [];
  1063. for (var i = 0, len = scales.length; i < len; i++) {
  1064. var scale = scales[i];
  1065. var field = scale.field;
  1066. if (scale.type === 'identity') {
  1067. params.push(scale.value);
  1068. } else {
  1069. params.push(record[field]);
  1070. }
  1071. }
  1072. var values = attr.mapping.apply(attr, params);
  1073. return values;
  1074. };
  1075. _proto.getAttrValue = function getAttrValue(attrName, record) {
  1076. var attr = this.getAttr(attrName);
  1077. var rst = null;
  1078. if (attr) {
  1079. var values = this._getAttrValues(attr, record);
  1080. rst = values[0];
  1081. }
  1082. return rst;
  1083. };
  1084. _proto._beforeMapping = function _beforeMapping(dataArray) {
  1085. var self = this;
  1086. if (self.get('generatePoints')) {
  1087. self._generatePoints(dataArray);
  1088. }
  1089. };
  1090. _proto.isInCircle = function isInCircle() {
  1091. var coord = this.get('coord');
  1092. return coord && coord.isPolar;
  1093. };
  1094. _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
  1095. if (!fields) {
  1096. return cfg;
  1097. }
  1098. var tmpCfg = {};
  1099. var params = fields.map(function (field) {
  1100. return origin[field];
  1101. });
  1102. Util.each(cfg, function (v, k) {
  1103. if (Util.isFunction(v)) {
  1104. tmpCfg[k] = v.apply(null, params);
  1105. } else {
  1106. tmpCfg[k] = v;
  1107. }
  1108. });
  1109. return tmpCfg;
  1110. };
  1111. _proto.getDrawCfg = function getDrawCfg(obj) {
  1112. var self = this;
  1113. var isInCircle = self.isInCircle();
  1114. var cfg = {
  1115. origin: obj,
  1116. x: obj.x,
  1117. y: obj.y,
  1118. color: obj.color,
  1119. size: obj.size,
  1120. shape: obj.shape,
  1121. isInCircle: isInCircle,
  1122. opacity: obj.opacity
  1123. };
  1124. var styleOptions = self.get('styleOptions');
  1125. if (styleOptions && styleOptions.style) {
  1126. cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
  1127. }
  1128. if (self.get('generatePoints')) {
  1129. cfg.points = obj.points;
  1130. cfg.nextPoints = obj.nextPoints;
  1131. }
  1132. if (isInCircle) {
  1133. cfg.center = self.get('coord').center;
  1134. }
  1135. return cfg;
  1136. };
  1137. _proto.draw = function draw(data, shapeFactory) {
  1138. var self = this;
  1139. var container = self.get('container');
  1140. var yScale = self.getYScale();
  1141. Util.each(data, function (obj, index) {
  1142. if (yScale && Util.isNil(obj._origin[yScale.field])) {
  1143. return;
  1144. }
  1145. obj.index = index;
  1146. var cfg = self.getDrawCfg(obj);
  1147. var shape = obj.shape;
  1148. self.drawShape(shape, obj, cfg, container, shapeFactory);
  1149. });
  1150. };
  1151. _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
  1152. var gShape = shapeFactory.drawShape(shape, cfg, container);
  1153. if (gShape) {
  1154. Util.each([].concat(gShape), function (s) {
  1155. s.set('origin', shapeData);
  1156. });
  1157. }
  1158. };
  1159. _proto._generatePoints = function _generatePoints(dataArray) {
  1160. var self = this;
  1161. var shapeFactory = self.getShapeFactory();
  1162. var shapeAttr = self.getAttr('shape');
  1163. Util.each(dataArray, function (data) {
  1164. for (var i = 0, len = data.length; i < len; i++) {
  1165. var obj = data[i];
  1166. var cfg = self.createShapePointsCfg(obj);
  1167. var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
  1168. var points = shapeFactory.getShapePoints(shape, cfg);
  1169. obj.points = points;
  1170. }
  1171. }); // 添加nextPoints
  1172. Util.each(dataArray, function (data, index) {
  1173. var nextData = dataArray[index + 1];
  1174. if (nextData) {
  1175. data[0].nextPoints = nextData[0].points;
  1176. }
  1177. });
  1178. }
  1179. /**
  1180. * get the info of each shape
  1181. * @protected
  1182. * @param {Object} obj the data item
  1183. * @return {Object} cfg return the result
  1184. */
  1185. ;
  1186. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  1187. var xScale = this.getXScale();
  1188. var yScale = this.getYScale();
  1189. var x = this._normalizeValues(obj[xScale.field], xScale);
  1190. var y;
  1191. if (yScale) {
  1192. y = this._normalizeValues(obj[yScale.field], yScale);
  1193. } else {
  1194. y = obj.y ? obj.y : 0.1;
  1195. }
  1196. return {
  1197. x: x,
  1198. y: y,
  1199. y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
  1200. };
  1201. };
  1202. _proto.getYMinValue = function getYMinValue() {
  1203. var yScale = this.getYScale();
  1204. var min = yScale.min,
  1205. max = yScale.max;
  1206. var value;
  1207. if (this.get('startOnZero')) {
  1208. if (max <= 0 && min <= 0) {
  1209. value = max;
  1210. } else {
  1211. value = min >= 0 ? min : 0;
  1212. }
  1213. } else {
  1214. value = min;
  1215. }
  1216. return value;
  1217. };
  1218. _proto._normalizeValues = function _normalizeValues(values, scale) {
  1219. var rst = [];
  1220. if (Util.isArray(values)) {
  1221. for (var i = 0, len = values.length; i < len; i++) {
  1222. var v = values[i];
  1223. rst.push(scale.scale(v));
  1224. }
  1225. } else {
  1226. rst = scale.scale(values);
  1227. }
  1228. return rst;
  1229. };
  1230. _proto.getAttr = function getAttr(name) {
  1231. return this.get('attrs')[name];
  1232. };
  1233. _proto.getXScale = function getXScale() {
  1234. return this.getAttr('position').scales[0];
  1235. };
  1236. _proto.getYScale = function getYScale() {
  1237. return this.getAttr('position').scales[1];
  1238. };
  1239. _proto.hasAdjust = function hasAdjust(adjust) {
  1240. return this.get('adjust') && this.get('adjust').type === adjust;
  1241. };
  1242. _proto._getSnap = function _getSnap(scale, item, arr) {
  1243. var i = 0;
  1244. var values;
  1245. var yField = this.getYScale().field; // 叠加的维度
  1246. if (this.hasAdjust('stack') && scale.field === yField) {
  1247. values = [];
  1248. arr.forEach(function (obj) {
  1249. values.push(obj[FIELD_ORIGIN_Y]);
  1250. });
  1251. for (var len = values.length; i < len; i++) {
  1252. if (values[0][0] > item) {
  1253. break;
  1254. }
  1255. if (values[values.length - 1][1] <= item) {
  1256. i = values.length - 1;
  1257. break;
  1258. }
  1259. if (values[i][0] <= item && values[i][1] > item) {
  1260. break;
  1261. }
  1262. }
  1263. } else {
  1264. values = scale.values;
  1265. values.sort(function (a, b) {
  1266. return a - b;
  1267. });
  1268. for (var _len2 = values.length; i < _len2; i++) {
  1269. // 如果只有1个点直接返回第1个点
  1270. if (_len2 <= 1) {
  1271. break;
  1272. } // 第1个点和第2个点之间
  1273. if ((values[0] + values[1]) / 2 > item) {
  1274. break;
  1275. } // 中间的点
  1276. if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
  1277. break;
  1278. } // 最后2个点
  1279. if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
  1280. i = values.length - 1;
  1281. break;
  1282. }
  1283. }
  1284. }
  1285. var result = values[i];
  1286. return result;
  1287. };
  1288. _proto.getSnapRecords = function getSnapRecords(point) {
  1289. var self = this;
  1290. var coord = self.get('coord');
  1291. var xScale = self.getXScale();
  1292. var yScale = self.getYScale();
  1293. var xfield = xScale.field;
  1294. var dataArray = self.get('dataArray');
  1295. if (!this.get('hasSorted')) {
  1296. this._sort(dataArray);
  1297. }
  1298. var rst = [];
  1299. var invertPoint = coord.invertPoint(point);
  1300. var invertPointX = invertPoint.x;
  1301. if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
  1302. invertPointX = xScale.rangeMin();
  1303. }
  1304. var xValue = xScale.invert(invertPointX);
  1305. if (!xScale.isCategory) {
  1306. xValue = self._getSnap(xScale, xValue);
  1307. }
  1308. var tmp = [];
  1309. dataArray.forEach(function (data) {
  1310. data.forEach(function (obj) {
  1311. var originValue = Util.isNil(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
  1312. if (self._isEqual(originValue, xValue, xScale)) {
  1313. tmp.push(obj);
  1314. }
  1315. });
  1316. }); // special for pie chart
  1317. if (this.hasAdjust('stack') && coord.isPolar && coord.transposed) {
  1318. if (invertPointX >= 0 && invertPointX <= 1) {
  1319. var yValue = yScale.invert(invertPoint.y);
  1320. yValue = self._getSnap(yScale, yValue, tmp);
  1321. tmp.forEach(function (obj) {
  1322. if (Util.isArray(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
  1323. rst.push(obj);
  1324. }
  1325. });
  1326. }
  1327. } else {
  1328. rst = tmp;
  1329. }
  1330. return rst;
  1331. };
  1332. _proto._isEqual = function _isEqual(originValue, value, scale) {
  1333. if (scale.type === 'timeCat') {
  1334. return scale._toTimeStamp(originValue) === value;
  1335. }
  1336. return value === originValue;
  1337. };
  1338. _proto.position = function position(field) {
  1339. this._setAttrOptions('position', {
  1340. field: field
  1341. });
  1342. return this;
  1343. };
  1344. _proto.color = function color(field, values) {
  1345. this._createAttrOption('color', field, values, Global.colors);
  1346. return this;
  1347. };
  1348. _proto.size = function size(field, values) {
  1349. this._createAttrOption('size', field, values, Global.sizes);
  1350. return this;
  1351. };
  1352. _proto.shape = function shape(field, values) {
  1353. var type = this.get('type');
  1354. var shapes = Global.shapes[type] || [];
  1355. this._createAttrOption('shape', field, values, shapes);
  1356. return this;
  1357. };
  1358. _proto.style = function style(field, cfg) {
  1359. var styleOptions = this.get('styleOptions');
  1360. if (!styleOptions) {
  1361. styleOptions = {};
  1362. this.set('styleOptions', styleOptions);
  1363. }
  1364. if (Util.isObject(field)) {
  1365. cfg = field;
  1366. field = null;
  1367. }
  1368. var fields;
  1369. if (field) {
  1370. fields = parseFields(field);
  1371. }
  1372. styleOptions.fields = fields;
  1373. styleOptions.style = cfg;
  1374. return this;
  1375. };
  1376. _proto.adjust = function adjust(type) {
  1377. if (Util.isString(type)) {
  1378. type = {
  1379. type: type
  1380. };
  1381. }
  1382. this.set('adjust', type);
  1383. return this;
  1384. };
  1385. _proto.animate = function animate(cfg) {
  1386. this.set('animateCfg', cfg);
  1387. return this;
  1388. };
  1389. _proto.changeData = function changeData(data) {
  1390. this.set('data', data); // 改变数据后,情况度量,因为需要重新实例化
  1391. this.set('scales', {});
  1392. this.init();
  1393. };
  1394. _proto.clearInner = function clearInner() {
  1395. var container = this.get('container');
  1396. if (container) {
  1397. container.clear(); // container.setMatrix([ 1, 0, 0, 1, 0, 0 ]);
  1398. }
  1399. };
  1400. _proto.reset = function reset() {
  1401. this.set('attrs', {});
  1402. this.set('attrOptions', {});
  1403. this.set('adjust', null);
  1404. this.clearInner();
  1405. };
  1406. _proto.clear = function clear() {
  1407. this.clearInner();
  1408. };
  1409. _proto.destroy = function destroy() {
  1410. this.clear();
  1411. _Base.prototype.destroy.call(this);
  1412. };
  1413. _proto._display = function _display(visible) {
  1414. this.set('visible', visible);
  1415. var container = this.get('container');
  1416. var canvas = container.get('canvas');
  1417. container.set('visible', visible);
  1418. canvas.draw();
  1419. };
  1420. _proto.show = function show() {
  1421. this._display(true);
  1422. };
  1423. _proto.hide = function hide() {
  1424. this._display(false);
  1425. };
  1426. return Geom;
  1427. }(Base);
  1428. module.exports = Geom;
  1429. /***/ }),
  1430. /* 18 */
  1431. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1432. "use strict";
  1433. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  1434. /* harmony default export */ __webpack_exports__["a"] = (function (str) {
  1435. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(str, 'String');
  1436. });
  1437. /***/ }),
  1438. /* 19 */
  1439. /***/ (function(module, exports, __webpack_require__) {
  1440. "use strict";
  1441. var Util = __webpack_require__(0);
  1442. var Global = __webpack_require__(6);
  1443. var Shape = {};
  1444. var ShapeBase = {
  1445. _coord: null,
  1446. /**
  1447. * draw the shape
  1448. * @param {Object} cfg options
  1449. * @param {Object} container container to store the shapes
  1450. */
  1451. draw: function draw(cfg, container) {
  1452. if (this.drawShape) {
  1453. this.drawShape(cfg, container);
  1454. }
  1455. },
  1456. /**
  1457. * set the coordinate instance
  1458. * @param {Coord} coord coordinate instance
  1459. */
  1460. setCoord: function setCoord(coord) {
  1461. this._coord = coord;
  1462. },
  1463. /**
  1464. * convert the normalized value to the canvas position
  1465. * @param {point} point the point to convert
  1466. * @return {point} point return the result
  1467. */
  1468. parsePoint: function parsePoint(point) {
  1469. var coord = this._coord;
  1470. if (coord.isPolar) {
  1471. if (point.x === 1) point.x = 0.9999999;
  1472. if (point.y === 1) point.y = 0.9999999;
  1473. }
  1474. return coord.convertPoint(point);
  1475. },
  1476. /**
  1477. * convert the normalized value to the canvas position
  1478. * @param {points} points the array that store the points
  1479. * @return {points} points return the result
  1480. */
  1481. parsePoints: function parsePoints(points) {
  1482. if (!points) return false;
  1483. var self = this;
  1484. var rst = [];
  1485. points.forEach(function (point) {
  1486. rst.push(self.parsePoint(point));
  1487. });
  1488. return rst;
  1489. }
  1490. };
  1491. var ShapeFactoryBase = {
  1492. defaultShapeType: null,
  1493. setCoord: function setCoord(coord) {
  1494. this._coord = coord;
  1495. },
  1496. getShape: function getShape(type) {
  1497. var self = this;
  1498. if (Util.isArray(type)) {
  1499. type = type[0];
  1500. }
  1501. var shape = self[type] || self[self.defaultShapeType];
  1502. shape._coord = self._coord;
  1503. return shape;
  1504. },
  1505. getShapePoints: function getShapePoints(type, cfg) {
  1506. var shape = this.getShape(type);
  1507. var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
  1508. var points = fn(cfg);
  1509. return points;
  1510. },
  1511. getDefaultPoints: function getDefaultPoints()
  1512. /* cfg */
  1513. {
  1514. return [];
  1515. },
  1516. drawShape: function drawShape(type, cfg, container) {
  1517. var shape = this.getShape(type);
  1518. if (!cfg.color) {
  1519. cfg.color = Global.colors[0];
  1520. }
  1521. return shape.draw(cfg, container);
  1522. }
  1523. };
  1524. Shape.registerFactory = function (factoryName, cfg) {
  1525. var className = Util.upperFirst(factoryName);
  1526. var geomObj = Util.mix({}, ShapeFactoryBase, cfg);
  1527. Shape[className] = geomObj;
  1528. geomObj.name = factoryName;
  1529. return geomObj;
  1530. };
  1531. Shape.registerShape = function (factoryName, shapeType, cfg) {
  1532. var className = Util.upperFirst(factoryName);
  1533. var factory = Shape[className];
  1534. var shapeObj = Util.mix({}, ShapeBase, cfg);
  1535. factory[shapeType] = shapeObj;
  1536. return shapeObj;
  1537. };
  1538. Shape.registShape = Shape.registerShape;
  1539. Shape.getShapeFactory = function (factoryName) {
  1540. var self = this;
  1541. factoryName = factoryName || 'point';
  1542. var className = Util.upperFirst(factoryName);
  1543. return self[className];
  1544. };
  1545. module.exports = Shape;
  1546. /***/ }),
  1547. /* 20 */
  1548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1549. "use strict";
  1550. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  1551. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
  1552. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return __WEBPACK_IMPORTED_MODULE_0__contains__["a"]; });
  1553. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "includes", function() { return __WEBPACK_IMPORTED_MODULE_0__contains__["a"]; });
  1554. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__difference__ = __webpack_require__(79);
  1555. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "difference", function() { return __WEBPACK_IMPORTED_MODULE_1__difference__["a"]; });
  1556. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__find__ = __webpack_require__(80);
  1557. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "find", function() { return __WEBPACK_IMPORTED_MODULE_2__find__["a"]; });
  1558. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__find_index__ = __webpack_require__(81);
  1559. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findIndex", function() { return __WEBPACK_IMPORTED_MODULE_3__find_index__["a"]; });
  1560. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__first_value__ = __webpack_require__(82);
  1561. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "firstValue", function() { return __WEBPACK_IMPORTED_MODULE_4__first_value__["a"]; });
  1562. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__flatten__ = __webpack_require__(83);
  1563. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return __WEBPACK_IMPORTED_MODULE_5__flatten__["a"]; });
  1564. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__flatten_deep__ = __webpack_require__(84);
  1565. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "flattenDeep", function() { return __WEBPACK_IMPORTED_MODULE_6__flatten_deep__["a"]; });
  1566. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__get_range__ = __webpack_require__(85);
  1567. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getRange", function() { return __WEBPACK_IMPORTED_MODULE_7__get_range__["a"]; });
  1568. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__pull__ = __webpack_require__(86);
  1569. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pull", function() { return __WEBPACK_IMPORTED_MODULE_8__pull__["a"]; });
  1570. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__pull_at__ = __webpack_require__(53);
  1571. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pullAt", function() { return __WEBPACK_IMPORTED_MODULE_9__pull_at__["a"]; });
  1572. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__reduce__ = __webpack_require__(87);
  1573. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "reduce", function() { return __WEBPACK_IMPORTED_MODULE_10__reduce__["a"]; });
  1574. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__remove__ = __webpack_require__(88);
  1575. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "remove", function() { return __WEBPACK_IMPORTED_MODULE_11__remove__["a"]; });
  1576. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__sort_by__ = __webpack_require__(89);
  1577. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sortBy", function() { return __WEBPACK_IMPORTED_MODULE_12__sort_by__["a"]; });
  1578. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__union__ = __webpack_require__(90);
  1579. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "union", function() { return __WEBPACK_IMPORTED_MODULE_13__union__["a"]; });
  1580. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__uniq__ = __webpack_require__(54);
  1581. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniq", function() { return __WEBPACK_IMPORTED_MODULE_14__uniq__["a"]; });
  1582. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__values_of_key__ = __webpack_require__(91);
  1583. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "valuesOfKey", function() { return __WEBPACK_IMPORTED_MODULE_15__values_of_key__["a"]; });
  1584. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__head__ = __webpack_require__(92);
  1585. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "head", function() { return __WEBPACK_IMPORTED_MODULE_16__head__["a"]; });
  1586. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__last__ = __webpack_require__(93);
  1587. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "last", function() { return __WEBPACK_IMPORTED_MODULE_17__last__["a"]; });
  1588. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__starts_with__ = __webpack_require__(94);
  1589. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "startsWith", function() { return __WEBPACK_IMPORTED_MODULE_18__starts_with__["a"]; });
  1590. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__ends_with__ = __webpack_require__(95);
  1591. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "endsWith", function() { return __WEBPACK_IMPORTED_MODULE_19__ends_with__["a"]; });
  1592. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__filter__ = __webpack_require__(39);
  1593. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "filter", function() { return __WEBPACK_IMPORTED_MODULE_20__filter__["a"]; });
  1594. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__every__ = __webpack_require__(96);
  1595. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "every", function() { return __WEBPACK_IMPORTED_MODULE_21__every__["a"]; });
  1596. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__some__ = __webpack_require__(97);
  1597. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "some", function() { return __WEBPACK_IMPORTED_MODULE_22__some__["a"]; });
  1598. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__group__ = __webpack_require__(98);
  1599. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "group", function() { return __WEBPACK_IMPORTED_MODULE_23__group__["a"]; });
  1600. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__group_by__ = __webpack_require__(56);
  1601. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "groupBy", function() { return __WEBPACK_IMPORTED_MODULE_24__group_by__["a"]; });
  1602. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__group_to_map__ = __webpack_require__(55);
  1603. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "groupToMap", function() { return __WEBPACK_IMPORTED_MODULE_25__group_to_map__["a"]; });
  1604. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__get_wrap_behavior__ = __webpack_require__(99);
  1605. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getWrapBehavior", function() { return __WEBPACK_IMPORTED_MODULE_26__get_wrap_behavior__["a"]; });
  1606. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__wrap_behavior__ = __webpack_require__(100);
  1607. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "wrapBehavior", function() { return __WEBPACK_IMPORTED_MODULE_27__wrap_behavior__["a"]; });
  1608. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__number2color__ = __webpack_require__(101);
  1609. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "number2color", function() { return __WEBPACK_IMPORTED_MODULE_28__number2color__["a"]; });
  1610. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__parse_radius__ = __webpack_require__(102);
  1611. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "parseRadius", function() { return __WEBPACK_IMPORTED_MODULE_29__parse_radius__["a"]; });
  1612. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__clamp__ = __webpack_require__(103);
  1613. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clamp", function() { return __WEBPACK_IMPORTED_MODULE_30__clamp__["a"]; });
  1614. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__fixed_base__ = __webpack_require__(104);
  1615. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "fixedBase", function() { return __WEBPACK_IMPORTED_MODULE_31__fixed_base__["a"]; });
  1616. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__is_decimal__ = __webpack_require__(105);
  1617. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDecimal", function() { return __WEBPACK_IMPORTED_MODULE_32__is_decimal__["a"]; });
  1618. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__is_even__ = __webpack_require__(106);
  1619. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEven", function() { return __WEBPACK_IMPORTED_MODULE_33__is_even__["a"]; });
  1620. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__is_integer__ = __webpack_require__(107);
  1621. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return __WEBPACK_IMPORTED_MODULE_34__is_integer__["a"]; });
  1622. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_35__is_negative__ = __webpack_require__(108);
  1623. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNegative", function() { return __WEBPACK_IMPORTED_MODULE_35__is_negative__["a"]; });
  1624. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__is_number_equal__ = __webpack_require__(109);
  1625. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNumberEqual", function() { return __WEBPACK_IMPORTED_MODULE_36__is_number_equal__["a"]; });
  1626. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__is_odd__ = __webpack_require__(110);
  1627. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isOdd", function() { return __WEBPACK_IMPORTED_MODULE_37__is_odd__["a"]; });
  1628. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__is_positive__ = __webpack_require__(111);
  1629. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPositive", function() { return __WEBPACK_IMPORTED_MODULE_38__is_positive__["a"]; });
  1630. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__max_by__ = __webpack_require__(112);
  1631. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "maxBy", function() { return __WEBPACK_IMPORTED_MODULE_39__max_by__["a"]; });
  1632. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__min_by__ = __webpack_require__(113);
  1633. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "minBy", function() { return __WEBPACK_IMPORTED_MODULE_40__min_by__["a"]; });
  1634. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__mod__ = __webpack_require__(114);
  1635. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mod", function() { return __WEBPACK_IMPORTED_MODULE_41__mod__["a"]; });
  1636. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__to_degree__ = __webpack_require__(115);
  1637. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toDegree", function() { return __WEBPACK_IMPORTED_MODULE_42__to_degree__["a"]; });
  1638. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__to_integer__ = __webpack_require__(116);
  1639. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toInteger", function() { return __WEBPACK_IMPORTED_MODULE_43__to_integer__["a"]; });
  1640. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__to_radian__ = __webpack_require__(117);
  1641. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toRadian", function() { return __WEBPACK_IMPORTED_MODULE_44__to_radian__["a"]; });
  1642. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__for_in__ = __webpack_require__(118);
  1643. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "forIn", function() { return __WEBPACK_IMPORTED_MODULE_45__for_in__["a"]; });
  1644. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__has__ = __webpack_require__(57);
  1645. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "has", function() { return __WEBPACK_IMPORTED_MODULE_46__has__["a"]; });
  1646. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_47__has_key__ = __webpack_require__(119);
  1647. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "hasKey", function() { return __WEBPACK_IMPORTED_MODULE_47__has_key__["a"]; });
  1648. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__has_value__ = __webpack_require__(120);
  1649. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "hasValue", function() { return __WEBPACK_IMPORTED_MODULE_48__has_value__["a"]; });
  1650. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_49__keys__ = __webpack_require__(52);
  1651. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "keys", function() { return __WEBPACK_IMPORTED_MODULE_49__keys__["a"]; });
  1652. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__is_match__ = __webpack_require__(51);
  1653. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isMatch", function() { return __WEBPACK_IMPORTED_MODULE_50__is_match__["a"]; });
  1654. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__values__ = __webpack_require__(58);
  1655. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "values", function() { return __WEBPACK_IMPORTED_MODULE_51__values__["a"]; });
  1656. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_52__lower_case__ = __webpack_require__(121);
  1657. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "lowerCase", function() { return __WEBPACK_IMPORTED_MODULE_52__lower_case__["a"]; });
  1658. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__lower_first__ = __webpack_require__(122);
  1659. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "lowerFirst", function() { return __WEBPACK_IMPORTED_MODULE_53__lower_first__["a"]; });
  1660. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__substitute__ = __webpack_require__(123);
  1661. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "substitute", function() { return __WEBPACK_IMPORTED_MODULE_54__substitute__["a"]; });
  1662. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__upper_case__ = __webpack_require__(124);
  1663. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperCase", function() { return __WEBPACK_IMPORTED_MODULE_55__upper_case__["a"]; });
  1664. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__upper_first__ = __webpack_require__(125);
  1665. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperFirst", function() { return __WEBPACK_IMPORTED_MODULE_56__upper_first__["a"]; });
  1666. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__get_type__ = __webpack_require__(59);
  1667. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getType", function() { return __WEBPACK_IMPORTED_MODULE_57__get_type__["a"]; });
  1668. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__is_arguments__ = __webpack_require__(126);
  1669. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArguments", function() { return __WEBPACK_IMPORTED_MODULE_58__is_arguments__["a"]; });
  1670. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__is_array__ = __webpack_require__(5);
  1671. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArray", function() { return __WEBPACK_IMPORTED_MODULE_59__is_array__["a"]; });
  1672. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__is_array_like__ = __webpack_require__(7);
  1673. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArrayLike", function() { return __WEBPACK_IMPORTED_MODULE_60__is_array_like__["a"]; });
  1674. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_61__is_boolean__ = __webpack_require__(127);
  1675. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isBoolean", function() { return __WEBPACK_IMPORTED_MODULE_61__is_boolean__["a"]; });
  1676. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_62__is_date__ = __webpack_require__(128);
  1677. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDate", function() { return __WEBPACK_IMPORTED_MODULE_62__is_date__["a"]; });
  1678. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_63__is_error__ = __webpack_require__(129);
  1679. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isError", function() { return __WEBPACK_IMPORTED_MODULE_63__is_error__["a"]; });
  1680. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_64__is_function__ = __webpack_require__(9);
  1681. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return __WEBPACK_IMPORTED_MODULE_64__is_function__["a"]; });
  1682. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_65__is_finite__ = __webpack_require__(130);
  1683. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFinite", function() { return __WEBPACK_IMPORTED_MODULE_65__is_finite__["a"]; });
  1684. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_66__is_nil__ = __webpack_require__(14);
  1685. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNil", function() { return __WEBPACK_IMPORTED_MODULE_66__is_nil__["a"]; });
  1686. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_67__is_null__ = __webpack_require__(131);
  1687. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNull", function() { return __WEBPACK_IMPORTED_MODULE_67__is_null__["a"]; });
  1688. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_68__is_number__ = __webpack_require__(12);
  1689. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNumber", function() { return __WEBPACK_IMPORTED_MODULE_68__is_number__["a"]; });
  1690. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_69__is_object__ = __webpack_require__(29);
  1691. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return __WEBPACK_IMPORTED_MODULE_69__is_object__["a"]; });
  1692. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_70__is_object_like__ = __webpack_require__(40);
  1693. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isObjectLike", function() { return __WEBPACK_IMPORTED_MODULE_70__is_object_like__["a"]; });
  1694. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_71__is_plain_object__ = __webpack_require__(24);
  1695. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPlainObject", function() { return __WEBPACK_IMPORTED_MODULE_71__is_plain_object__["a"]; });
  1696. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_72__is_prototype__ = __webpack_require__(60);
  1697. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPrototype", function() { return __WEBPACK_IMPORTED_MODULE_72__is_prototype__["a"]; });
  1698. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__is_reg_exp__ = __webpack_require__(132);
  1699. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isRegExp", function() { return __WEBPACK_IMPORTED_MODULE_73__is_reg_exp__["a"]; });
  1700. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_74__is_string__ = __webpack_require__(18);
  1701. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return __WEBPACK_IMPORTED_MODULE_74__is_string__["a"]; });
  1702. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_75__is_type__ = __webpack_require__(11);
  1703. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isType", function() { return __WEBPACK_IMPORTED_MODULE_75__is_type__["a"]; });
  1704. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_76__is_undefined__ = __webpack_require__(133);
  1705. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isUndefined", function() { return __WEBPACK_IMPORTED_MODULE_76__is_undefined__["a"]; });
  1706. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_77__is_element__ = __webpack_require__(134);
  1707. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isElement", function() { return __WEBPACK_IMPORTED_MODULE_77__is_element__["a"]; });
  1708. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_78__request_animation_frame__ = __webpack_require__(135);
  1709. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "requestAnimationFrame", function() { return __WEBPACK_IMPORTED_MODULE_78__request_animation_frame__["a"]; });
  1710. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_79__clear_animation_frame__ = __webpack_require__(136);
  1711. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clearAnimationFrame", function() { return __WEBPACK_IMPORTED_MODULE_79__clear_animation_frame__["a"]; });
  1712. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_80__augment__ = __webpack_require__(137);
  1713. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "augment", function() { return __WEBPACK_IMPORTED_MODULE_80__augment__["a"]; });
  1714. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_81__clone__ = __webpack_require__(138);
  1715. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return __WEBPACK_IMPORTED_MODULE_81__clone__["a"]; });
  1716. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_82__debounce__ = __webpack_require__(139);
  1717. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return __WEBPACK_IMPORTED_MODULE_82__debounce__["a"]; });
  1718. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_83__memoize__ = __webpack_require__(140);
  1719. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "memoize", function() { return __WEBPACK_IMPORTED_MODULE_83__memoize__["a"]; });
  1720. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_84__deep_mix__ = __webpack_require__(141);
  1721. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "deepMix", function() { return __WEBPACK_IMPORTED_MODULE_84__deep_mix__["a"]; });
  1722. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_85__each__ = __webpack_require__(8);
  1723. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "each", function() { return __WEBPACK_IMPORTED_MODULE_85__each__["a"]; });
  1724. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_86__extend__ = __webpack_require__(142);
  1725. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "extend", function() { return __WEBPACK_IMPORTED_MODULE_86__extend__["a"]; });
  1726. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_87__index_of__ = __webpack_require__(143);
  1727. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "indexOf", function() { return __WEBPACK_IMPORTED_MODULE_87__index_of__["a"]; });
  1728. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_88__is_empty__ = __webpack_require__(144);
  1729. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return __WEBPACK_IMPORTED_MODULE_88__is_empty__["a"]; });
  1730. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_89__is_equal__ = __webpack_require__(61);
  1731. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEqual", function() { return __WEBPACK_IMPORTED_MODULE_89__is_equal__["a"]; });
  1732. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_90__is_equal_with__ = __webpack_require__(145);
  1733. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEqualWith", function() { return __WEBPACK_IMPORTED_MODULE_90__is_equal_with__["a"]; });
  1734. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_91__map__ = __webpack_require__(146);
  1735. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "map", function() { return __WEBPACK_IMPORTED_MODULE_91__map__["a"]; });
  1736. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_92__map_values__ = __webpack_require__(147);
  1737. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mapValues", function() { return __WEBPACK_IMPORTED_MODULE_92__map_values__["a"]; });
  1738. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_93__mix__ = __webpack_require__(41);
  1739. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mix", function() { return __WEBPACK_IMPORTED_MODULE_93__mix__["a"]; });
  1740. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "assign", function() { return __WEBPACK_IMPORTED_MODULE_93__mix__["a"]; });
  1741. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_94__get__ = __webpack_require__(148);
  1742. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "get", function() { return __WEBPACK_IMPORTED_MODULE_94__get__["a"]; });
  1743. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_95__set__ = __webpack_require__(149);
  1744. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return __WEBPACK_IMPORTED_MODULE_95__set__["a"]; });
  1745. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_96__pick__ = __webpack_require__(150);
  1746. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pick", function() { return __WEBPACK_IMPORTED_MODULE_96__pick__["a"]; });
  1747. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_97__throttle__ = __webpack_require__(151);
  1748. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return __WEBPACK_IMPORTED_MODULE_97__throttle__["a"]; });
  1749. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_98__to_array__ = __webpack_require__(152);
  1750. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toArray", function() { return __WEBPACK_IMPORTED_MODULE_98__to_array__["a"]; });
  1751. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_99__to_string__ = __webpack_require__(25);
  1752. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toString", function() { return __WEBPACK_IMPORTED_MODULE_99__to_string__["a"]; });
  1753. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_100__unique_id__ = __webpack_require__(153);
  1754. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniqueId", function() { return __WEBPACK_IMPORTED_MODULE_100__unique_id__["a"]; });
  1755. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_101__noop__ = __webpack_require__(154);
  1756. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "noop", function() { return __WEBPACK_IMPORTED_MODULE_101__noop__["a"]; });
  1757. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_102__identity__ = __webpack_require__(155);
  1758. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return __WEBPACK_IMPORTED_MODULE_102__identity__["a"]; });
  1759. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_103__size__ = __webpack_require__(156);
  1760. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "size", function() { return __WEBPACK_IMPORTED_MODULE_103__size__["a"]; });
  1761. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_104__cache__ = __webpack_require__(157);
  1762. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Cache", function() { return __WEBPACK_IMPORTED_MODULE_104__cache__["a"]; });
  1763. // array
  1764. // event
  1765. // format
  1766. // math
  1767. // object
  1768. // string
  1769. // type
  1770. // other
  1771. // 不知道为什么,需要把这个 export,不然 ts 会报类型错误
  1772. /***/ }),
  1773. /* 21 */
  1774. /***/ (function(module, exports, __webpack_require__) {
  1775. "use strict";
  1776. var Vector2 = __webpack_require__(13);
  1777. var start = Vector2.create();
  1778. var end = Vector2.create();
  1779. var extremity = Vector2.create();
  1780. function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
  1781. var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
  1782. var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
  1783. return {
  1784. x: x,
  1785. y: y
  1786. };
  1787. } // cubic helper formula at T distance
  1788. function CubicN(T, a, b, c, d) {
  1789. var t2 = T * T;
  1790. var t3 = t2 * T;
  1791. return a + (-a * 3 + T * (3 * a - a * T)) * T + (3 * b + T * (-6 * b + b * 3 * T)) * T + (c * 3 - c * 3 * T) * t2 + d * t3;
  1792. }
  1793. function cubicBezierBounds(c) {
  1794. var minX = Infinity;
  1795. var maxX = -Infinity;
  1796. var minY = Infinity;
  1797. var maxY = -Infinity;
  1798. var s = {
  1799. x: c[0],
  1800. y: c[1]
  1801. };
  1802. var c1 = {
  1803. x: c[2],
  1804. y: c[3]
  1805. };
  1806. var c2 = {
  1807. x: c[4],
  1808. y: c[5]
  1809. };
  1810. var e = {
  1811. x: c[6],
  1812. y: c[7]
  1813. };
  1814. for (var t = 0; t < 100; t++) {
  1815. var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
  1816. if (pt.x < minX) {
  1817. minX = pt.x;
  1818. }
  1819. if (pt.x > maxX) {
  1820. maxX = pt.x;
  1821. }
  1822. if (pt.y < minY) {
  1823. minY = pt.y;
  1824. }
  1825. if (pt.y > maxY) {
  1826. maxY = pt.y;
  1827. }
  1828. }
  1829. return {
  1830. minX: minX,
  1831. minY: minY,
  1832. maxX: maxX,
  1833. maxY: maxY
  1834. };
  1835. }
  1836. module.exports = {
  1837. getBBoxFromPoints: function getBBoxFromPoints(points, lineWidth) {
  1838. if (points.length === 0) {
  1839. return;
  1840. }
  1841. var p = points[0];
  1842. var left = p.x;
  1843. var right = p.x;
  1844. var top = p.y;
  1845. var bottom = p.y;
  1846. var len = points.length;
  1847. for (var i = 1; i < len; i++) {
  1848. p = points[i];
  1849. left = Math.min(left, p.x);
  1850. right = Math.max(right, p.x);
  1851. top = Math.min(top, p.y);
  1852. bottom = Math.max(bottom, p.y);
  1853. }
  1854. lineWidth = lineWidth / 2 || 0;
  1855. return {
  1856. minX: left - lineWidth,
  1857. minY: top - lineWidth,
  1858. maxX: right + lineWidth,
  1859. maxY: bottom + lineWidth
  1860. };
  1861. },
  1862. getBBoxFromLine: function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
  1863. lineWidth = lineWidth / 2 || 0;
  1864. return {
  1865. minX: Math.min(x0, x1) - lineWidth,
  1866. minY: Math.min(y0, y1) - lineWidth,
  1867. maxX: Math.max(x0, x1) + lineWidth,
  1868. maxY: Math.max(y0, y1) + lineWidth
  1869. };
  1870. },
  1871. getBBoxFromArc: function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
  1872. var diff = Math.abs(startAngle - endAngle);
  1873. if (diff % (Math.PI * 2) < 1e-4 && diff > 1e-4) {
  1874. // Is a circle
  1875. return {
  1876. minX: x - r,
  1877. minY: y - r,
  1878. maxX: x + r,
  1879. maxY: y + r
  1880. };
  1881. }
  1882. start[0] = Math.cos(startAngle) * r + x;
  1883. start[1] = Math.sin(startAngle) * r + y;
  1884. end[0] = Math.cos(endAngle) * r + x;
  1885. end[1] = Math.sin(endAngle) * r + y;
  1886. var min = [0, 0];
  1887. var max = [0, 0];
  1888. Vector2.min(min, start, end);
  1889. Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]
  1890. startAngle = startAngle % (Math.PI * 2);
  1891. if (startAngle < 0) {
  1892. startAngle = startAngle + Math.PI * 2;
  1893. }
  1894. endAngle = endAngle % (Math.PI * 2);
  1895. if (endAngle < 0) {
  1896. endAngle = endAngle + Math.PI * 2;
  1897. }
  1898. if (startAngle > endAngle && !anticlockwise) {
  1899. endAngle += Math.PI * 2;
  1900. } else if (startAngle < endAngle && anticlockwise) {
  1901. startAngle += Math.PI * 2;
  1902. }
  1903. if (anticlockwise) {
  1904. var tmp = endAngle;
  1905. endAngle = startAngle;
  1906. startAngle = tmp;
  1907. }
  1908. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  1909. if (angle > startAngle) {
  1910. extremity[0] = Math.cos(angle) * r + x;
  1911. extremity[1] = Math.sin(angle) * r + y;
  1912. Vector2.min(min, extremity, min);
  1913. Vector2.max(max, extremity, max);
  1914. }
  1915. }
  1916. return {
  1917. minX: min[0],
  1918. minY: min[1],
  1919. maxX: max[0],
  1920. maxY: max[1]
  1921. };
  1922. },
  1923. getBBoxFromBezierGroup: function getBBoxFromBezierGroup(points, lineWidth) {
  1924. var minX = Infinity;
  1925. var maxX = -Infinity;
  1926. var minY = Infinity;
  1927. var maxY = -Infinity;
  1928. for (var i = 0, len = points.length; i < len; i++) {
  1929. var bbox = cubicBezierBounds(points[i]);
  1930. if (bbox.minX < minX) {
  1931. minX = bbox.minX;
  1932. }
  1933. if (bbox.maxX > maxX) {
  1934. maxX = bbox.maxX;
  1935. }
  1936. if (bbox.minY < minY) {
  1937. minY = bbox.minY;
  1938. }
  1939. if (bbox.maxY > maxY) {
  1940. maxY = bbox.maxY;
  1941. }
  1942. }
  1943. lineWidth = lineWidth / 2 || 0;
  1944. return {
  1945. minX: minX - lineWidth,
  1946. minY: minY - lineWidth,
  1947. maxX: maxX + lineWidth,
  1948. maxY: maxY + lineWidth
  1949. };
  1950. }
  1951. };
  1952. /***/ }),
  1953. /* 22 */
  1954. /***/ (function(module, exports) {
  1955. function _assertThisInitialized(self) {
  1956. if (self === void 0) {
  1957. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1958. }
  1959. return self;
  1960. }
  1961. module.exports = _assertThisInitialized;
  1962. /***/ }),
  1963. /* 23 */
  1964. /***/ (function(module, exports, __webpack_require__) {
  1965. "use strict";
  1966. var Util = __webpack_require__(0);
  1967. var KEYWORDS_PERCENT = {
  1968. min: 0,
  1969. median: 0.5,
  1970. max: 1
  1971. };
  1972. var GuideBase = /*#__PURE__*/function () {
  1973. var _proto = GuideBase.prototype;
  1974. _proto._initDefaultCfg = function _initDefaultCfg() {};
  1975. function GuideBase(cfg) {
  1976. this._initDefaultCfg();
  1977. Util.deepMix(this, cfg);
  1978. }
  1979. _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
  1980. var rst;
  1981. if (Util.isNil(KEYWORDS_PERCENT[val])) {
  1982. rst = scale.scale(val);
  1983. } else {
  1984. rst = KEYWORDS_PERCENT[val];
  1985. }
  1986. return rst;
  1987. };
  1988. _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
  1989. var xPercent = parseFloat(position[0]) / 100;
  1990. var yPercent = parseFloat(position[1]) / 100;
  1991. var start = coord.start;
  1992. var end = coord.end;
  1993. var width = Math.abs(start.x - end.x);
  1994. var height = Math.abs(start.y - end.y);
  1995. var x = width * xPercent + Math.min(start.x, end.x);
  1996. var y = height * yPercent + Math.min(start.y, end.y);
  1997. return {
  1998. x: x,
  1999. y: y
  2000. };
  2001. };
  2002. _proto.parsePoint = function parsePoint(coord, position) {
  2003. var self = this;
  2004. var xScale = self.xScale;
  2005. var yScales = self.yScales;
  2006. if (Util.isFunction(position)) {
  2007. position = position(xScale, yScales); // position 必须是对象
  2008. } // 如果数据格式是 ['50%', '50%'] 的格式
  2009. // fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590
  2010. if (Util.isString(position[0]) && position[0].indexOf('%') !== -1 && !isNaN(position[0].slice(0, -1))) {
  2011. return this.parsePercentPoint(coord, position);
  2012. }
  2013. var x = self._getNormalizedValue(position[0], xScale);
  2014. var y = self._getNormalizedValue(position[1], yScales[0]);
  2015. var point = coord.convertPoint({
  2016. x: x,
  2017. y: y
  2018. });
  2019. if (self.limitInPlot) {
  2020. // limit in chart plotRange
  2021. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  2022. return point;
  2023. }
  2024. return null;
  2025. }
  2026. return point;
  2027. }
  2028. /**
  2029. * render the guide component
  2030. * @param {Coord} coord coordinate instance
  2031. * @param {Canvas.Group} group the container
  2032. */
  2033. ;
  2034. _proto.render = function render()
  2035. /* coord,group */
  2036. {};
  2037. _proto.repaint = function repaint() {
  2038. this.remove();
  2039. var coord = this.coord,
  2040. container = this.container,
  2041. canvas = this.canvas;
  2042. if (container && !container.isDestroyed()) {
  2043. this.render(coord, container);
  2044. canvas.draw();
  2045. }
  2046. };
  2047. _proto.remove = function remove() {
  2048. var element = this.element;
  2049. element && element.remove(true);
  2050. };
  2051. _proto.changeVisible = function changeVisible(visible) {
  2052. var self = this;
  2053. self.visible = visible;
  2054. var element = self.element;
  2055. if (!element) return;
  2056. if (element.set) {
  2057. element.set('visible', visible);
  2058. } else {
  2059. element.style.display = visible ? '' : 'none';
  2060. }
  2061. };
  2062. return GuideBase;
  2063. }();
  2064. module.exports = GuideBase;
  2065. /***/ }),
  2066. /* 24 */
  2067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2068. "use strict";
  2069. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object_like__ = __webpack_require__(40);
  2070. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_type__ = __webpack_require__(11);
  2071. var isPlainObject = function (value) {
  2072. /**
  2073. * isObjectLike(new Foo) => false
  2074. * isObjectLike([1, 2, 3]) => false
  2075. * isObjectLike({ x: 0, y: 0 }) => true
  2076. * isObjectLike(Object.create(null)) => true
  2077. */
  2078. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(value) || !Object(__WEBPACK_IMPORTED_MODULE_1__is_type__["a" /* default */])(value, 'Object')) {
  2079. return false;
  2080. }
  2081. if (Object.getPrototypeOf(value) === null) {
  2082. return true;
  2083. }
  2084. var proto = value;
  2085. while (Object.getPrototypeOf(proto) !== null) {
  2086. proto = Object.getPrototypeOf(proto);
  2087. }
  2088. return Object.getPrototypeOf(value) === proto;
  2089. };
  2090. /* harmony default export */ __webpack_exports__["a"] = (isPlainObject);
  2091. /***/ }),
  2092. /* 25 */
  2093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2094. "use strict";
  2095. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  2096. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  2097. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) return '';
  2098. return value.toString();
  2099. });
  2100. /***/ }),
  2101. /* 26 */
  2102. /***/ (function(module, exports, __webpack_require__) {
  2103. var mix = __webpack_require__(64);
  2104. var each = __webpack_require__(15);
  2105. var isObject = __webpack_require__(44);
  2106. var isNil = __webpack_require__(35);
  2107. var Scale = /*#__PURE__*/function () {
  2108. var _proto = Scale.prototype;
  2109. _proto._initDefaultCfg = function _initDefaultCfg() {
  2110. this.type = 'base';
  2111. /**
  2112. * 格式化函数,输出文本或者tick时的格式化函数
  2113. * @type {Function}
  2114. */
  2115. this.formatter = null;
  2116. /**
  2117. * 输出的值域
  2118. * @type {Array}
  2119. */
  2120. this.range = [0, 1];
  2121. /**
  2122. * 度量的标记
  2123. * @type {Array}
  2124. */
  2125. this.ticks = null;
  2126. /**
  2127. * 参与度量计算的值,可选项
  2128. * @type {Array}
  2129. */
  2130. this.values = [];
  2131. };
  2132. function Scale(cfg) {
  2133. this._initDefaultCfg();
  2134. mix(this, cfg);
  2135. this.init();
  2136. }
  2137. /**
  2138. * 度量初始化
  2139. * @protected
  2140. */
  2141. _proto.init = function init() {}
  2142. /**
  2143. * 获取该度量的ticks,返回的是多个对象,
  2144. * - text: tick 的文本
  2145. * - value: 对应的度量转换后的值
  2146. * <code>
  2147. * [
  2148. * {text: 0,value:0}
  2149. * {text: 1,value:0.2}
  2150. * {text: 2,value:0.4}
  2151. * {text: 3,value:0.6}
  2152. * {text: 4,value:0.8}
  2153. * {text: 5,value:1}
  2154. * ]
  2155. * </code>
  2156. * @param {Number} count 输出tick的个数的近似值,默认是 10
  2157. * @return {Array} 返回 ticks 数组
  2158. */
  2159. ;
  2160. _proto.getTicks = function getTicks() {
  2161. var self = this;
  2162. var ticks = self.ticks;
  2163. var rst = [];
  2164. each(ticks, function (tick) {
  2165. var obj;
  2166. if (isObject(tick)) {
  2167. obj = tick;
  2168. } else {
  2169. obj = {
  2170. text: self.getText(tick),
  2171. tickValue: tick,
  2172. value: self.scale(tick)
  2173. };
  2174. }
  2175. rst.push(obj);
  2176. });
  2177. return rst;
  2178. }
  2179. /**
  2180. * 获取格式化后的文本
  2181. * @param {*} value 输入的数据
  2182. * @param {*} key 字段的 key
  2183. * @return {String} 格式化的文本
  2184. */
  2185. ;
  2186. _proto.getText = function getText(value, key) {
  2187. var formatter = this.formatter;
  2188. value = formatter ? formatter(value, key) : value;
  2189. if (isNil(value) || !value.toString) {
  2190. value = '';
  2191. }
  2192. return value.toString();
  2193. }
  2194. /**
  2195. * 输出的值域最小值
  2196. * @protected
  2197. * @return {Number} 返回最小的值
  2198. */
  2199. ;
  2200. _proto.rangeMin = function rangeMin() {
  2201. return this.range[0];
  2202. }
  2203. /**
  2204. * 输出的值域最大值
  2205. * @protected
  2206. * @return {Number} 返回最大的值
  2207. */
  2208. ;
  2209. _proto.rangeMax = function rangeMax() {
  2210. var range = this.range;
  2211. return range[range.length - 1];
  2212. }
  2213. /**
  2214. * 度量转换后的结果,翻转回输入域
  2215. * @param {Number} value 需要翻转的数值
  2216. * @return {*} 度量的输入值
  2217. */
  2218. ;
  2219. _proto.invert = function invert(value) {
  2220. return value;
  2221. }
  2222. /**
  2223. * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
  2224. * @param {*} value 传入的值
  2225. * @return {Number} 转换的值
  2226. */
  2227. ;
  2228. _proto.translate = function translate(value) {
  2229. return value;
  2230. }
  2231. /**
  2232. * 进行度量转换
  2233. * @param {*} value 输入值
  2234. * @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
  2235. */
  2236. ;
  2237. _proto.scale = function scale(value) {
  2238. return value;
  2239. }
  2240. /**
  2241. * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
  2242. * @return {Scale} 克隆的度量
  2243. */
  2244. ;
  2245. _proto.clone = function clone() {
  2246. var self = this;
  2247. var constr = self.constructor;
  2248. var cfg = {};
  2249. each(self, function (v, k) {
  2250. cfg[k] = self[k];
  2251. });
  2252. return new constr(cfg);
  2253. }
  2254. /**
  2255. * 更改度量的属性信息
  2256. * @param {Object} info 属性信息
  2257. * @chainable
  2258. * @return {Scale} 返回自身的引用
  2259. */
  2260. ;
  2261. _proto.change = function change(info) {
  2262. this.ticks = null;
  2263. mix(this, info);
  2264. this.init();
  2265. return this;
  2266. };
  2267. return Scale;
  2268. }();
  2269. module.exports = Scale;
  2270. /***/ }),
  2271. /* 27 */
  2272. /***/ (function(module, exports) {
  2273. var toString = {}.toString;
  2274. var isType = function isType(value, type) {
  2275. return toString.call(value) === '[object ' + type + ']';
  2276. };
  2277. module.exports = isType;
  2278. /***/ }),
  2279. /* 28 */
  2280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2281. "use strict";
  2282. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  2283. var contains = function (arr, value) {
  2284. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
  2285. return false;
  2286. }
  2287. return arr.indexOf(value) > -1;
  2288. };
  2289. /* harmony default export */ __webpack_exports__["a"] = (contains);
  2290. /***/ }),
  2291. /* 29 */
  2292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2293. "use strict";
  2294. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  2295. /**
  2296. * isObject({}) => true
  2297. * isObject([1, 2, 3]) => true
  2298. * isObject(Function) => true
  2299. * isObject(null) => false
  2300. */
  2301. var type = typeof value;
  2302. return value !== null && type === 'object' || type === 'function';
  2303. });
  2304. /***/ }),
  2305. /* 30 */
  2306. /***/ (function(module, exports, __webpack_require__) {
  2307. "use strict";
  2308. var _interopRequireDefault = __webpack_require__(1);
  2309. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  2310. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  2311. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  2312. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  2313. var _const = __webpack_require__(47);
  2314. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  2315. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  2316. var Base = __webpack_require__(63);
  2317. var Plot = __webpack_require__(158);
  2318. var Util = __webpack_require__(0);
  2319. var Coord = __webpack_require__(159);
  2320. var Geom = __webpack_require__(17);
  2321. var ScaleController = __webpack_require__(167);
  2322. var AxisController = __webpack_require__(173);
  2323. var Global = __webpack_require__(6);
  2324. var _require = __webpack_require__(16),
  2325. Canvas = _require.Canvas;
  2326. var Helper = __webpack_require__(37);
  2327. function compare(a, b) {
  2328. return a - b;
  2329. }
  2330. function _isScaleExist(scales, compareScale) {
  2331. var flag = false;
  2332. Util.each(scales, function (scale) {
  2333. var scaleValues = [].concat(scale.values);
  2334. var compareScaleValues = [].concat(compareScale.values);
  2335. if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
  2336. flag = true;
  2337. return;
  2338. }
  2339. });
  2340. return flag;
  2341. }
  2342. var Chart = /*#__PURE__*/function (_Base) {
  2343. (0, _inheritsLoose2["default"])(Chart, _Base);
  2344. var _super = _createSuper(Chart);
  2345. Chart.initPlugins = function initPlugins() {
  2346. return {
  2347. _plugins: [],
  2348. _cacheId: 0,
  2349. register: function register(plugins) {
  2350. var p = this._plugins;
  2351. [].concat(plugins).forEach(function (plugin) {
  2352. if (p.indexOf(plugin) === -1) {
  2353. p.push(plugin);
  2354. }
  2355. });
  2356. this._cacheId++;
  2357. },
  2358. unregister: function unregister(plugins) {
  2359. var p = this._plugins;
  2360. [].concat(plugins).forEach(function (plugin) {
  2361. var idx = p.indexOf(plugin);
  2362. if (idx !== -1) {
  2363. p.splice(idx, 1);
  2364. }
  2365. });
  2366. this._cacheId++;
  2367. },
  2368. clear: function clear() {
  2369. this._plugins = [];
  2370. this._cacheId++;
  2371. },
  2372. count: function count() {
  2373. return this._plugins.length;
  2374. },
  2375. getAll: function getAll() {
  2376. return this._plugins;
  2377. },
  2378. notify: function notify(chart, hook, args) {
  2379. var descriptors = this.descriptors(chart);
  2380. var ilen = descriptors.length;
  2381. var i;
  2382. var descriptor;
  2383. var plugin;
  2384. var params;
  2385. var method;
  2386. for (i = 0; i < ilen; ++i) {
  2387. descriptor = descriptors[i];
  2388. plugin = descriptor.plugin;
  2389. method = plugin[hook];
  2390. if (typeof method === 'function') {
  2391. params = [chart].concat(args || []);
  2392. if (method.apply(plugin, params) === false) {
  2393. return false;
  2394. }
  2395. }
  2396. }
  2397. return true;
  2398. },
  2399. descriptors: function descriptors(chart) {
  2400. var cache = chart._plugins || (chart._plugins = {});
  2401. if (cache.id === this._cacheId) {
  2402. return cache.descriptors;
  2403. }
  2404. var plugins = [];
  2405. var descriptors = [];
  2406. this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
  2407. var idx = plugins.indexOf(plugin);
  2408. if (idx !== -1) {
  2409. return;
  2410. }
  2411. plugins.push(plugin);
  2412. descriptors.push({
  2413. plugin: plugin
  2414. });
  2415. });
  2416. cache.descriptors = descriptors;
  2417. cache.id = this._cacheId;
  2418. return descriptors;
  2419. }
  2420. };
  2421. };
  2422. var _proto = Chart.prototype;
  2423. _proto.getDefaultCfg = function getDefaultCfg() {
  2424. return {
  2425. /**
  2426. * the id of canvas
  2427. * @type {String}
  2428. */
  2429. id: null,
  2430. rendered: false,
  2431. /**
  2432. * padding
  2433. * @type {Array|Number}
  2434. */
  2435. padding: Global.padding,
  2436. /**
  2437. * data
  2438. * @type {Array}
  2439. */
  2440. data: null,
  2441. /**
  2442. * scales of chart
  2443. * @type {Object}
  2444. */
  2445. scales: {},
  2446. /**
  2447. * @private
  2448. * geometry instances
  2449. * @type {Array}
  2450. */
  2451. geoms: [],
  2452. /**
  2453. * scale configuration
  2454. * @type {Object}
  2455. */
  2456. colDefs: null,
  2457. pixelRatio: Global.pixelRatio,
  2458. /**
  2459. * filter options
  2460. * @type {Object}
  2461. */
  2462. filters: null,
  2463. appendPadding: Global.appendPadding
  2464. };
  2465. };
  2466. _proto._syncYScales = function _syncYScales() {
  2467. var syncY = this.get('syncY');
  2468. if (!syncY) {
  2469. return;
  2470. }
  2471. var geoms = this.get('geoms');
  2472. var syncScales = [];
  2473. var min = [];
  2474. var max = [];
  2475. Util.each(geoms, function (geom) {
  2476. var yScale = geom.getYScale();
  2477. if (yScale.isLinear) {
  2478. syncScales.push(yScale);
  2479. min.push(yScale.min);
  2480. max.push(yScale.max);
  2481. }
  2482. });
  2483. min = Math.min.apply(null, min);
  2484. max = Math.max.apply(null, max);
  2485. Util.each(syncScales, function (scale) {
  2486. scale.change({
  2487. min: min
  2488. });
  2489. scale.change({
  2490. max: max
  2491. });
  2492. });
  2493. };
  2494. _proto._getFieldsForLegend = function _getFieldsForLegend() {
  2495. var fields = [];
  2496. var geoms = this.get('geoms');
  2497. Util.each(geoms, function (geom) {
  2498. var attrOptions = geom.get('attrOptions');
  2499. var attrCfg = attrOptions.color;
  2500. if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
  2501. var arr = attrCfg.field.split('*');
  2502. Util.each(arr, function (item) {
  2503. if (fields.indexOf(item) === -1) {
  2504. fields.push(item);
  2505. }
  2506. });
  2507. }
  2508. });
  2509. return fields;
  2510. };
  2511. _proto._getScaleData = function _getScaleData(field) {
  2512. var data = this.get('data');
  2513. var filteredData = this.get('filteredData');
  2514. if (filteredData.length) {
  2515. var legendFields = this._getFieldsForLegend();
  2516. if (legendFields.indexOf(field) === -1) {
  2517. data = filteredData;
  2518. }
  2519. }
  2520. return data;
  2521. } // _updateScales() {
  2522. // const scaleController = this.get('scaleController');
  2523. // scaleController.updateScales();
  2524. // this._adjustScale();
  2525. // }
  2526. ;
  2527. _proto._adjustScale = function _adjustScale() {
  2528. var self = this;
  2529. var scaleController = self.get('scaleController'); // 看起来是为了让柱状图最小或最大都默认从0开始
  2530. var geoms = this.get('geoms');
  2531. for (var i = 0; i < geoms.length; i++) {
  2532. var geom = geoms[i];
  2533. if (geom.get('type') === 'interval') {
  2534. var yScale = geom.getYScale();
  2535. scaleController.adjustStartZero(yScale);
  2536. }
  2537. }
  2538. };
  2539. _proto._removeGeoms = function _removeGeoms() {
  2540. var geoms = this.get('geoms');
  2541. while (geoms.length > 0) {
  2542. var geom = geoms.shift();
  2543. geom.destroy();
  2544. }
  2545. };
  2546. _proto._clearGeoms = function _clearGeoms() {
  2547. var geoms = this.get('geoms');
  2548. for (var i = 0, length = geoms.length; i < length; i++) {
  2549. var geom = geoms[i];
  2550. geom.clear();
  2551. }
  2552. };
  2553. _proto._clearInner = function _clearInner() {
  2554. this._clearGeoms();
  2555. Chart.plugins.notify(this, 'clearInner');
  2556. this.get('axisController') && this.get('axisController').clear();
  2557. };
  2558. _proto._initFilteredData = function _initFilteredData() {
  2559. var filters = this.get('filters');
  2560. var data = this.get('data') || [];
  2561. if (filters) {
  2562. data = data.filter(function (obj) {
  2563. var rst = true;
  2564. Util.each(filters, function (fn, k) {
  2565. if (fn) {
  2566. rst = fn(obj[k], obj);
  2567. if (!rst) {
  2568. return false;
  2569. }
  2570. }
  2571. });
  2572. return rst;
  2573. });
  2574. }
  2575. this.set('filteredData', data);
  2576. };
  2577. _proto._changeGeomsData = function _changeGeomsData() {
  2578. var geoms = this.get('geoms');
  2579. var data = this.get('filteredData');
  2580. for (var i = 0, length = geoms.length; i < length; i++) {
  2581. var geom = geoms[i];
  2582. geom.changeData(data);
  2583. }
  2584. };
  2585. _proto._initGeom = function _initGeom(geom) {
  2586. var coord = this.get('coord');
  2587. var data = this.get('filteredData');
  2588. var colDefs = this.get('colDefs');
  2589. var middlePlot = this.get('middlePlot');
  2590. geom.set('chart', this);
  2591. geom.set('container', middlePlot.addGroup());
  2592. geom.set('data', data);
  2593. geom.set('coord', coord);
  2594. geom.set('colDefs', colDefs);
  2595. geom.init();
  2596. this.emit(_const.EVENT_AFTER_GEOM_INIT, geom);
  2597. };
  2598. _proto._initGeoms = function _initGeoms() {
  2599. var geoms = this.get('geoms');
  2600. for (var i = 0, length = geoms.length; i < length; i++) {
  2601. this._initGeom(geoms[i]);
  2602. }
  2603. };
  2604. _proto._initCoord = function _initCoord() {
  2605. var plot = this.get('plotRange');
  2606. var coordCfg = Util.mix({
  2607. type: 'cartesian'
  2608. }, this.get('coordCfg'), {
  2609. plot: plot
  2610. });
  2611. var type = coordCfg.type;
  2612. var C = Coord[Util.upperFirst(type)];
  2613. var coord = new C(coordCfg);
  2614. this.set('coord', coord);
  2615. };
  2616. _proto._initLayout = function _initLayout() {
  2617. var padding = this.get('_padding');
  2618. if (!padding) {
  2619. padding = this.get('margin') || this.get('padding');
  2620. padding = Util.parsePadding(padding);
  2621. }
  2622. var top = padding[0] === 'auto' ? 0 : padding[0];
  2623. var right = padding[1] === 'auto' ? 0 : padding[1];
  2624. var bottom = padding[2] === 'auto' ? 0 : padding[2];
  2625. var left = padding[3] === 'auto' ? 0 : padding[3];
  2626. var width = this.get('width');
  2627. var height = this.get('height');
  2628. var start = {
  2629. x: left,
  2630. y: top
  2631. };
  2632. var end = {
  2633. x: width - right,
  2634. y: height - bottom
  2635. };
  2636. var plot = this.get('plot');
  2637. if (plot) {
  2638. plot.reset(start, end);
  2639. return;
  2640. }
  2641. var newPlot = new Plot({
  2642. start: start,
  2643. end: end
  2644. });
  2645. this.set('plotRange', newPlot);
  2646. this.set('plot', newPlot);
  2647. };
  2648. _proto._initCanvas = function _initCanvas() {
  2649. var self = this;
  2650. try {
  2651. var canvas = new Canvas({
  2652. el: self.get('el') || self.get('id'),
  2653. context: self.get('context'),
  2654. pixelRatio: self.get('pixelRatio'),
  2655. width: self.get('width'),
  2656. height: self.get('height'),
  2657. fontFamily: Global.fontFamily
  2658. });
  2659. self.set('canvas', canvas);
  2660. self.set('el', canvas.get('el'));
  2661. self.set('width', canvas.get('width'));
  2662. self.set('height', canvas.get('height'));
  2663. } catch (error) {
  2664. throw error;
  2665. }
  2666. Chart.plugins.notify(self, 'afterCanvasInit');
  2667. };
  2668. _proto._initLayers = function _initLayers() {
  2669. var canvas = this.get('canvas');
  2670. this.set('backPlot', canvas.addGroup());
  2671. this.set('middlePlot', canvas.addGroup({
  2672. zIndex: 10
  2673. }));
  2674. this.set('frontPlot', canvas.addGroup({
  2675. zIndex: 20
  2676. }));
  2677. };
  2678. _proto._initEvents = function _initEvents() {
  2679. var _this2 = this;
  2680. // 数据更新后的一些更新
  2681. this.on(_const.EVENT_AFTER_DATA_CHANGE, function () {
  2682. // 数据更新后,重新设置filterdata
  2683. _this2._initFilteredData(); // 更新geoms里的数据
  2684. _this2._changeGeomsData();
  2685. _this2._adjustScale();
  2686. }); // 大小变化后的一些更新
  2687. this.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
  2688. _this2._initLayout(); // layout变化后,坐标轴也需要做相应的变化
  2689. var coord = _this2.get('coord');
  2690. if (coord) {
  2691. coord.reset(_this2.get('plot'));
  2692. }
  2693. });
  2694. };
  2695. _proto._initScaleController = function _initScaleController() {
  2696. var scaleController = new ScaleController({
  2697. chart: this
  2698. }); // 让colDefs 和 scaleController.defs 用同一个对象,这样就不用考虑同步的问题
  2699. this.set('colDefs', scaleController.defs); // 已经实例化的scales 也保持统一个对象
  2700. this.set('scales', scaleController.scales);
  2701. this.set('scaleController', scaleController);
  2702. };
  2703. _proto._clearScaleController = function _clearScaleController() {
  2704. var scaleController = this.get('scaleController');
  2705. scaleController.clear();
  2706. };
  2707. _proto._init = function _init() {
  2708. var self = this;
  2709. self._initCanvas();
  2710. self._initLayout();
  2711. self._initLayers();
  2712. self._initEvents();
  2713. self._initScaleController();
  2714. self.set('axisController', new AxisController({
  2715. frontPlot: self.get('frontPlot').addGroup({
  2716. className: 'axisContainer'
  2717. }),
  2718. backPlot: self.get('backPlot').addGroup({
  2719. className: 'axisContainer'
  2720. }),
  2721. chart: self
  2722. }));
  2723. Chart.plugins.notify(self, 'init');
  2724. };
  2725. function Chart(cfg) {
  2726. var _this;
  2727. _this = _Base.call(this, cfg) || this;
  2728. var self = (0, _assertThisInitialized2["default"])(_this);
  2729. Util.each(Geom, function (geomConstructor, className) {
  2730. var methodName = Util.lowerFirst(className);
  2731. self[methodName] = function (cfg) {
  2732. var geom = new geomConstructor(cfg);
  2733. self.addGeom(geom);
  2734. return geom;
  2735. };
  2736. });
  2737. self._init();
  2738. return _this;
  2739. }
  2740. _proto.init = function init() {
  2741. // 初始filterData
  2742. this._initFilteredData(); // initialization coordinate instance
  2743. this._initCoord();
  2744. Chart.plugins.notify(this, 'beforeGeomInit'); // init all geometry instances
  2745. this._initGeoms(); // 多 Y 轴的情况时,统一 Y 轴的数值范围。
  2746. this._syncYScales(); // do some adjust for data
  2747. this._adjustScale();
  2748. this.emit(_const.EVENT_AFTER_INIT);
  2749. }
  2750. /**
  2751. * set data and some scale configuration
  2752. * @chainable
  2753. * @param {Array} data the dataset to visualize
  2754. * @param {Object} colDefs the configuration for scales
  2755. * @return {Chart} return the chart instance
  2756. */
  2757. ;
  2758. _proto.source = function source(data, colDefs) {
  2759. this.set('data', data);
  2760. if (colDefs) {
  2761. this.scale(colDefs);
  2762. }
  2763. return this;
  2764. };
  2765. _proto.scale = function scale(field, cfg) {
  2766. var scaleController = this.get('scaleController');
  2767. scaleController.setFieldDef(field, cfg);
  2768. return this;
  2769. }
  2770. /**
  2771. * configure the axis
  2772. * @chainable
  2773. * @param {String|Boolean} field the field name of data
  2774. * @param {Object} cfg configuration for axis
  2775. * @return {Chart} return the chart instance
  2776. */
  2777. ;
  2778. _proto.axis = function axis(field, cfg) {
  2779. var axisController = this.get('axisController');
  2780. if (!field) {
  2781. axisController.axisCfg = null;
  2782. } else {
  2783. axisController.axisCfg = axisController.axisCfg || {};
  2784. axisController.axisCfg[field] = cfg;
  2785. }
  2786. return this;
  2787. }
  2788. /**
  2789. * configure the coordinate
  2790. * @chainable
  2791. * @param {String} type set the type of coodinate
  2792. * @param {Object} cfg configuration for coordinate
  2793. * @return {Chart} return the chart instance
  2794. */
  2795. ;
  2796. _proto.coord = function coord(type, cfg) {
  2797. var coordCfg;
  2798. if (Util.isObject(type)) {
  2799. coordCfg = type;
  2800. } else {
  2801. coordCfg = cfg || {};
  2802. coordCfg.type = type || 'cartesian';
  2803. }
  2804. this.set('coordCfg', coordCfg);
  2805. return this;
  2806. };
  2807. _proto.filter = function filter(field, condition) {
  2808. var filters = this.get('filters') || {};
  2809. filters[field] = condition;
  2810. this.set('filters', filters); // 如果已经render过,则再重新触发一次change
  2811. if (this.get('rendered')) {
  2812. this.emit(_const.EVENT_AFTER_DATA_CHANGE, this.get('data'));
  2813. }
  2814. }
  2815. /**
  2816. * render the chart
  2817. * @chainable
  2818. * @return {Chart} return the chart instance
  2819. */
  2820. ;
  2821. _proto.render = function render() {
  2822. var rendered = this.get('rendered');
  2823. var canvas = this.get('canvas');
  2824. var geoms = this.get('geoms');
  2825. if (!rendered) {
  2826. this.init();
  2827. this.set('rendered', true);
  2828. }
  2829. this.emit(_const.EVENT_BEFORE_RENDER);
  2830. Chart.plugins.notify(this, 'beforeGeomDraw');
  2831. this._renderAxis();
  2832. var middlePlot = this.get('middlePlot');
  2833. if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
  2834. var coord = this.get('coord');
  2835. var clip = Helper.getClip(coord);
  2836. clip.set('canvas', middlePlot.get('canvas'));
  2837. middlePlot.attr('clip', clip);
  2838. }
  2839. for (var i = 0, length = geoms.length; i < length; i++) {
  2840. var geom = geoms[i];
  2841. geom.paint();
  2842. }
  2843. Chart.plugins.notify(this, 'afterGeomDraw');
  2844. canvas.sort();
  2845. this.get('frontPlot').sort();
  2846. Chart.plugins.notify(this, 'beforeCanvasDraw');
  2847. canvas.draw();
  2848. this.emit(_const.EVENT_AFTER_RENDER);
  2849. return this;
  2850. }
  2851. /**
  2852. * clear the chart, include geometris and all the shapes
  2853. * @chainable
  2854. * @return {Chart} return the chart
  2855. */
  2856. ;
  2857. _proto.clear = function clear() {
  2858. Chart.plugins.notify(this, 'clear');
  2859. this._clearInner();
  2860. this._removeGeoms();
  2861. this._clearScaleController();
  2862. this.set('legendItems', null);
  2863. this.set('filters', null);
  2864. this.set('isUpdate', false);
  2865. this.set('_padding', null);
  2866. this.set('rendered', false);
  2867. var canvas = this.get('canvas');
  2868. canvas.draw();
  2869. return this;
  2870. };
  2871. _proto.repaint = function repaint() {
  2872. // 如果在没有render之前就repaint的,就直接return退出
  2873. var rendered = this.get('rendered');
  2874. if (!rendered) {
  2875. return;
  2876. }
  2877. this.set('isUpdate', true);
  2878. this.set('legendItems', null);
  2879. Chart.plugins.notify(this, 'repaint');
  2880. this._clearInner();
  2881. this.render();
  2882. };
  2883. _proto.changeData = function changeData(data) {
  2884. this.emit(_const.EVENT_BEFORE_DATA_CHANGE, data);
  2885. this.set('data', data);
  2886. Chart.plugins.notify(this, 'changeData');
  2887. this.emit(_const.EVENT_AFTER_DATA_CHANGE, data);
  2888. this.set('_padding', null);
  2889. this.repaint();
  2890. };
  2891. _proto.changeSize = function changeSize(width, height) {
  2892. if (width) {
  2893. this.set('width', width);
  2894. } else {
  2895. width = this.get('width');
  2896. }
  2897. if (height) {
  2898. this.set('height', height);
  2899. } else {
  2900. height = this.get('height');
  2901. }
  2902. var canvas = this.get('canvas');
  2903. canvas.changeSize(width, height);
  2904. this.emit(_const.EVENT_AFTER_SIZE_CHANGE, {
  2905. width: width,
  2906. height: height
  2907. });
  2908. this.repaint();
  2909. return this;
  2910. };
  2911. _proto.destroy = function destroy() {
  2912. this.clear();
  2913. var canvas = this.get('canvas');
  2914. canvas.destroy();
  2915. Chart.plugins.notify(this, 'afterCanvasDestroyed');
  2916. if (this._interactions) {
  2917. Util.each(this._interactions, function (interaction) {
  2918. interaction.destroy();
  2919. });
  2920. }
  2921. _Base.prototype.destroy.call(this);
  2922. }
  2923. /**
  2924. * calculate dataset's position on canvas
  2925. * @param {Object} record the dataset
  2926. * @return {Object} return the position
  2927. */
  2928. ;
  2929. _proto.getPosition = function getPosition(record) {
  2930. var self = this;
  2931. var coord = self.get('coord');
  2932. var xScale = self.getXScale();
  2933. var yScale = self.getYScales()[0];
  2934. var xField = xScale.field;
  2935. var x = xScale.scale(record[xField]);
  2936. var yField = yScale.field;
  2937. var y = yScale.scale(record[yField]);
  2938. return coord.convertPoint({
  2939. x: x,
  2940. y: y
  2941. });
  2942. }
  2943. /**
  2944. * get the data item of the point
  2945. * @param {Object} point canvas position
  2946. * @return {Object} return the data item
  2947. */
  2948. ;
  2949. _proto.getRecord = function getRecord(point) {
  2950. var self = this;
  2951. var coord = self.get('coord');
  2952. var xScale = self.getXScale();
  2953. var yScale = self.getYScales()[0];
  2954. var invertPoint = coord.invertPoint(point);
  2955. var record = {};
  2956. record[xScale.field] = xScale.invert(invertPoint.x);
  2957. record[yScale.field] = yScale.invert(invertPoint.y);
  2958. return record;
  2959. }
  2960. /**
  2961. * get the dataset of the point
  2962. * @param {Object} point canvas position
  2963. * @return {Array} return the dataset
  2964. **/
  2965. ;
  2966. _proto.getSnapRecords = function getSnapRecords(point) {
  2967. var geom = this.get('geoms')[0];
  2968. var data = [];
  2969. if (geom) {
  2970. // need to judge
  2971. data = geom.getSnapRecords(point);
  2972. }
  2973. return data;
  2974. }
  2975. /**
  2976. * creat scale instances
  2977. * @param {String} field field name of data
  2978. * @return {Scale} return the scale
  2979. */
  2980. ;
  2981. _proto.createScale = function createScale(field) {
  2982. var data = this._getScaleData(field);
  2983. var scaleController = this.get('scaleController');
  2984. return scaleController.createScale(field, data);
  2985. }
  2986. /**
  2987. * @protected
  2988. * add geometry instance to geoms
  2989. * @param {Geom} geom geometry instance
  2990. */
  2991. ;
  2992. _proto.addGeom = function addGeom(geom) {
  2993. var rendered = this.get('rendered');
  2994. var geoms = this.get('geoms');
  2995. geoms.push(geom); // 如果图表已经渲染过了,则直接初始化geom
  2996. if (rendered) {
  2997. this._initGeom(geom);
  2998. }
  2999. }
  3000. /**
  3001. * get the scale of x axis
  3002. * @return {Scale} return the scale
  3003. */
  3004. ;
  3005. _proto.getXScale = function getXScale() {
  3006. var self = this;
  3007. var geoms = self.get('geoms');
  3008. var xScale = geoms[0].getXScale();
  3009. return xScale;
  3010. }
  3011. /**
  3012. * get the scale of y axis
  3013. * @return {Array} return the scale
  3014. */
  3015. ;
  3016. _proto.getYScales = function getYScales() {
  3017. var geoms = this.get('geoms');
  3018. var rst = [];
  3019. Util.each(geoms, function (geom) {
  3020. var yScale = geom.getYScale();
  3021. if (rst.indexOf(yScale) === -1) {
  3022. rst.push(yScale);
  3023. }
  3024. });
  3025. return rst;
  3026. };
  3027. _proto.getLegendItems = function getLegendItems() {
  3028. if (this.get('legendItems')) {
  3029. return this.get('legendItems');
  3030. }
  3031. var legendItems = {};
  3032. var scales = [];
  3033. var geoms = this.get('geoms');
  3034. Util.each(geoms, function (geom) {
  3035. var colorAttr = geom.getAttr('color');
  3036. if (colorAttr) {
  3037. var scale = colorAttr.getScale('color'); // 只支持分类图例
  3038. if (scale.isCategory && !_isScaleExist(scales, scale)) {
  3039. scales.push(scale);
  3040. var field = scale.field;
  3041. var ticks = scale.getTicks();
  3042. var items = [];
  3043. Util.each(ticks, function (tick) {
  3044. var text = tick.text;
  3045. var name = text;
  3046. var scaleValue = tick.value;
  3047. var value = scale.invert(scaleValue);
  3048. var color = colorAttr.mapping(value).join('') || Global.defaultColor;
  3049. var marker = {
  3050. fill: color,
  3051. radius: 3,
  3052. symbol: 'circle',
  3053. stroke: '#fff'
  3054. };
  3055. items.push({
  3056. name: name,
  3057. // for display
  3058. dataValue: value,
  3059. // the origin value
  3060. checked: true,
  3061. marker: marker
  3062. });
  3063. });
  3064. legendItems[field] = items;
  3065. }
  3066. }
  3067. });
  3068. this.set('legendItems', legendItems);
  3069. return legendItems;
  3070. } // register the plugins
  3071. ;
  3072. _proto.registerPlugins = function registerPlugins(plugins) {
  3073. var self = this;
  3074. var chartPlugins = self.get('plugins') || [];
  3075. if (!Util.isArray(chartPlugins)) {
  3076. chartPlugins = [chartPlugins];
  3077. }
  3078. [].concat(plugins).forEach(function (plugin) {
  3079. if (chartPlugins.indexOf(plugin) === -1) {
  3080. plugin.init && plugin.init(self); // init
  3081. chartPlugins.push(plugin);
  3082. }
  3083. });
  3084. Chart.plugins._cacheId++;
  3085. self.set('plugins', chartPlugins);
  3086. };
  3087. _proto._renderAxis = function _renderAxis() {
  3088. var axisController = this.get('axisController');
  3089. var xScale = this.getXScale();
  3090. var yScales = this.getYScales();
  3091. var coord = this.get('coord');
  3092. Chart.plugins.notify(this, 'beforeRenderAxis');
  3093. axisController.createAxis(coord, xScale, yScales);
  3094. };
  3095. _proto._isAutoPadding = function _isAutoPadding() {
  3096. if (this.get('_padding')) {
  3097. return false;
  3098. }
  3099. var padding = this.get('padding');
  3100. if (Util.isArray(padding)) {
  3101. return padding.indexOf('auto') !== -1;
  3102. }
  3103. return padding === 'auto';
  3104. };
  3105. _proto._updateLayout = function _updateLayout(padding) {
  3106. var width = this.get('width');
  3107. var height = this.get('height');
  3108. var start = {
  3109. x: padding[3],
  3110. y: padding[0]
  3111. };
  3112. var end = {
  3113. x: width - padding[1],
  3114. y: height - padding[2]
  3115. };
  3116. var plot = this.get('plot');
  3117. var coord = this.get('coord');
  3118. plot.reset(start, end);
  3119. coord.reset(plot);
  3120. };
  3121. return Chart;
  3122. }(Base);
  3123. Chart.plugins = Chart.initPlugins();
  3124. module.exports = Chart;
  3125. /***/ }),
  3126. /* 31 */
  3127. /***/ (function(module, exports, __webpack_require__) {
  3128. "use strict";
  3129. var Matrix = {
  3130. multiply: function multiply(m1, m2) {
  3131. var m11 = m1[0] * m2[0] + m1[2] * m2[1];
  3132. var m12 = m1[1] * m2[0] + m1[3] * m2[1];
  3133. var m21 = m1[0] * m2[2] + m1[2] * m2[3];
  3134. var m22 = m1[1] * m2[2] + m1[3] * m2[3];
  3135. var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  3136. var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  3137. return [m11, m12, m21, m22, dx, dy];
  3138. },
  3139. scale: function scale(out, m, v) {
  3140. out[0] = m[0] * v[0];
  3141. out[1] = m[1] * v[0];
  3142. out[2] = m[2] * v[1];
  3143. out[3] = m[3] * v[1];
  3144. out[4] = m[4];
  3145. out[5] = m[5];
  3146. return out;
  3147. },
  3148. rotate: function rotate(out, m, radian) {
  3149. var c = Math.cos(radian);
  3150. var s = Math.sin(radian);
  3151. var m11 = m[0] * c + m[2] * s;
  3152. var m12 = m[1] * c + m[3] * s;
  3153. var m21 = m[0] * -s + m[2] * c;
  3154. var m22 = m[1] * -s + m[3] * c;
  3155. out[0] = m11;
  3156. out[1] = m12;
  3157. out[2] = m21;
  3158. out[3] = m22;
  3159. out[4] = m[4];
  3160. out[5] = m[5];
  3161. return out;
  3162. },
  3163. translate: function translate(out, m, v) {
  3164. out[0] = m[0];
  3165. out[1] = m[1];
  3166. out[2] = m[2];
  3167. out[3] = m[3];
  3168. out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
  3169. out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
  3170. return out;
  3171. },
  3172. transform: function transform(m, actions) {
  3173. var out = [].concat(m);
  3174. for (var i = 0, len = actions.length; i < len; i++) {
  3175. var action = actions[i];
  3176. switch (action[0]) {
  3177. case 't':
  3178. Matrix.translate(out, out, [action[1], action[2]]);
  3179. break;
  3180. case 's':
  3181. Matrix.scale(out, out, [action[1], action[2]]);
  3182. break;
  3183. case 'r':
  3184. Matrix.rotate(out, out, action[1]);
  3185. break;
  3186. default:
  3187. break;
  3188. }
  3189. }
  3190. return out;
  3191. }
  3192. };
  3193. module.exports = Matrix;
  3194. /***/ }),
  3195. /* 32 */
  3196. /***/ (function(module, exports, __webpack_require__) {
  3197. "use strict";
  3198. exports.__esModule = true;
  3199. exports["default"] = void 0;
  3200. var _util = __webpack_require__(20);
  3201. /**
  3202. * @fileOverview the Attribute base class
  3203. */
  3204. function toScaleString(scale, value) {
  3205. if ((0, _util.isString)(value)) {
  3206. return value;
  3207. }
  3208. return scale.invert(scale.scale(value));
  3209. }
  3210. /**
  3211. * 所有视觉通道属性的基类
  3212. * @class Attr
  3213. */
  3214. var AttributeBase = /*#__PURE__*/function () {
  3215. function AttributeBase(cfg) {
  3216. var _this = this;
  3217. /**
  3218. * 属性的类型
  3219. * @type {String}
  3220. */
  3221. this.type = 'base';
  3222. /**
  3223. * 属性的名称
  3224. * @type {String}
  3225. */
  3226. this.name = null;
  3227. /**
  3228. * 回调函数
  3229. * @type {Function}
  3230. */
  3231. this.method = null;
  3232. /**
  3233. * 备选的值数组
  3234. * @type {Array}
  3235. */
  3236. this.values = [];
  3237. /**
  3238. * 属性内部的度量
  3239. * @type {Array}
  3240. */
  3241. this.scales = [];
  3242. /**
  3243. * 是否通过线性取值, 如果未指定,则根据数值的类型判定
  3244. * @type {Boolean}
  3245. */
  3246. this.linear = null;
  3247. /**
  3248. * 当用户设置的 callback 返回 null 时, 应该返回默认 callback 中的值
  3249. */
  3250. var mixedCallback = null;
  3251. var defaultCallback = this.callback;
  3252. if (cfg.callback) {
  3253. var userCallback = cfg.callback;
  3254. mixedCallback = function mixedCallback() {
  3255. for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
  3256. params[_key] = arguments[_key];
  3257. }
  3258. var ret = userCallback.apply(void 0, params);
  3259. if ((0, _util.isNil)(ret)) {
  3260. ret = defaultCallback.apply(_this, params);
  3261. }
  3262. return ret;
  3263. };
  3264. }
  3265. (0, _util.mix)(this, cfg);
  3266. if (mixedCallback) {
  3267. (0, _util.mix)(this, {
  3268. callback: mixedCallback
  3269. });
  3270. }
  3271. } // 获取属性值,将值映射到视觉通道
  3272. var _proto = AttributeBase.prototype;
  3273. _proto._getAttrValue = function _getAttrValue(scale, value) {
  3274. var values = this.values;
  3275. if (scale.isCategory && !this.linear) {
  3276. var index = scale.translate(value);
  3277. return values[index % values.length];
  3278. }
  3279. var percent = scale.scale(value);
  3280. return this.getLinearValue(percent);
  3281. }
  3282. /**
  3283. * 如果进行线性映射,返回对应的映射值
  3284. * @protected
  3285. * @param {Number} percent 百分比
  3286. * @return {*} 颜色值、形状、大小等
  3287. */
  3288. ;
  3289. _proto.getLinearValue = function getLinearValue(percent) {
  3290. var values = this.values;
  3291. var steps = values.length - 1;
  3292. var step = Math.floor(steps * percent);
  3293. var leftPercent = steps * percent - step;
  3294. var start = values[step];
  3295. var end = step === steps ? start : values[step + 1];
  3296. var rstValue = start + (end - start) * leftPercent;
  3297. return rstValue;
  3298. }
  3299. /**
  3300. * 默认的回调函数
  3301. * @param {*} value 回调函数的值
  3302. * @type {Function}
  3303. * @return {Array} 返回映射后的值
  3304. */
  3305. ;
  3306. _proto.callback = function callback(value) {
  3307. var self = this;
  3308. var scale = self.scales[0];
  3309. var rstValue = null;
  3310. if (scale.type === 'identity') {
  3311. rstValue = scale.value;
  3312. } else {
  3313. rstValue = self._getAttrValue(scale, value);
  3314. }
  3315. return rstValue;
  3316. }
  3317. /**
  3318. * 根据度量获取属性名
  3319. * @return {Array} dims of this Attribute
  3320. */
  3321. ;
  3322. _proto.getNames = function getNames() {
  3323. var scales = this.scales;
  3324. var names = this.names;
  3325. var length = Math.min(scales.length, names.length);
  3326. var rst = [];
  3327. for (var i = 0; i < length; i++) {
  3328. rst.push(names[i]);
  3329. }
  3330. return rst;
  3331. }
  3332. /**
  3333. * 根据度量获取维度名
  3334. * @return {Array} dims of this Attribute
  3335. */
  3336. ;
  3337. _proto.getFields = function getFields() {
  3338. var scales = this.scales;
  3339. var rst = [];
  3340. (0, _util.each)(scales, function (scale) {
  3341. rst.push(scale.field);
  3342. });
  3343. return rst;
  3344. }
  3345. /**
  3346. * 根据名称获取度量
  3347. * @param {String} name the name of scale
  3348. * @return {Scale} scale
  3349. */
  3350. ;
  3351. _proto.getScale = function getScale(name) {
  3352. var scales = this.scales;
  3353. var names = this.names;
  3354. var index = names.indexOf(name);
  3355. return scales[index];
  3356. }
  3357. /**
  3358. * 映射数据
  3359. * @param {*} param1...paramn 多个数值
  3360. * @return {Array} 映射的值组成的数组
  3361. */
  3362. ;
  3363. _proto.mapping = function mapping() {
  3364. var scales = this.scales;
  3365. var callback = this.callback;
  3366. for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3367. params[_key2] = arguments[_key2];
  3368. }
  3369. var values = params;
  3370. if (callback) {
  3371. for (var i = 0, len = params.length; i < len; i++) {
  3372. params[i] = this._toOriginParam(params[i], scales[i]);
  3373. }
  3374. values = callback.apply(this, params);
  3375. }
  3376. values = [].concat(values);
  3377. return values;
  3378. } // 原始的参数
  3379. ;
  3380. _proto._toOriginParam = function _toOriginParam(param, scale) {
  3381. var rst = param;
  3382. if (!scale.isLinear) {
  3383. if ((0, _util.isArray)(param)) {
  3384. rst = [];
  3385. for (var i = 0, len = param.length; i < len; i++) {
  3386. rst.push(toScaleString(scale, param[i]));
  3387. }
  3388. } else {
  3389. rst = toScaleString(scale, param);
  3390. }
  3391. }
  3392. return rst;
  3393. };
  3394. return AttributeBase;
  3395. }();
  3396. var _default = AttributeBase;
  3397. exports["default"] = _default;
  3398. /***/ }),
  3399. /* 33 */
  3400. /***/ (function(module, exports, __webpack_require__) {
  3401. var mix = __webpack_require__(64);
  3402. var Adjust = /*#__PURE__*/function () {
  3403. var _proto = Adjust.prototype;
  3404. _proto._initDefaultCfg = function _initDefaultCfg() {
  3405. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  3406. };
  3407. function Adjust(cfg) {
  3408. this._initDefaultCfg();
  3409. mix(this, cfg);
  3410. }
  3411. /**
  3412. * @override
  3413. */
  3414. _proto.processAdjust = function processAdjust()
  3415. /* dataArray */
  3416. {};
  3417. return Adjust;
  3418. }();
  3419. module.exports = Adjust;
  3420. /***/ }),
  3421. /* 34 */
  3422. /***/ (function(module, exports, __webpack_require__) {
  3423. var isType = __webpack_require__(27);
  3424. var isArray = Array.isArray ? Array.isArray : function (value) {
  3425. return isType(value, 'Array');
  3426. };
  3427. module.exports = isArray;
  3428. /***/ }),
  3429. /* 35 */
  3430. /***/ (function(module, exports) {
  3431. // isFinite,
  3432. var isNil = function isNil(value) {
  3433. /**
  3434. * isNil(null) => true
  3435. * isNil() => true
  3436. */
  3437. return value === null || value === undefined;
  3438. };
  3439. module.exports = isNil;
  3440. /***/ }),
  3441. /* 36 */
  3442. /***/ (function(module, exports, __webpack_require__) {
  3443. /**
  3444. * 判断是否数字
  3445. * @return {Boolean} 是否数字
  3446. */
  3447. var isType = __webpack_require__(27);
  3448. var isNumber = function isNumber(value) {
  3449. return isType(value, 'Number');
  3450. };
  3451. module.exports = isNumber;
  3452. /***/ }),
  3453. /* 37 */
  3454. /***/ (function(module, exports, __webpack_require__) {
  3455. "use strict";
  3456. exports.__esModule = true;
  3457. exports.getClip = getClip;
  3458. exports.isPointInPlot = isPointInPlot;
  3459. var _require = __webpack_require__(16),
  3460. Shape = _require.Shape;
  3461. function getClip(coord) {
  3462. var start = coord.start;
  3463. var end = coord.end;
  3464. var width = end.x - start.x;
  3465. var height = Math.abs(end.y - start.y);
  3466. var margin = 10;
  3467. var clip;
  3468. if (coord.isPolar) {
  3469. var circleRadius = coord.circleRadius,
  3470. center = coord.center,
  3471. startAngle = coord.startAngle,
  3472. endAngle = coord.endAngle;
  3473. clip = new Shape.Sector({
  3474. attrs: {
  3475. x: center.x,
  3476. y: center.y,
  3477. r: circleRadius,
  3478. r0: 0,
  3479. startAngle: startAngle,
  3480. endAngle: endAngle
  3481. }
  3482. });
  3483. } else {
  3484. clip = new Shape.Rect({
  3485. attrs: {
  3486. x: start.x,
  3487. y: end.y - margin,
  3488. width: width,
  3489. height: height + 2 * margin
  3490. }
  3491. });
  3492. }
  3493. clip.isClip = true;
  3494. return clip;
  3495. }
  3496. function isPointInPlot(point, plot) {
  3497. var x = point.x,
  3498. y = point.y;
  3499. var tl = plot.tl,
  3500. tr = plot.tr,
  3501. br = plot.br;
  3502. return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
  3503. }
  3504. /***/ }),
  3505. /* 38 */
  3506. /***/ (function(module, exports, __webpack_require__) {
  3507. "use strict";
  3508. /**
  3509. * @fileOverview shape util
  3510. * @author dxq613@gmail.com
  3511. */
  3512. var Util = __webpack_require__(0);
  3513. var ShapeUtil = {
  3514. splitPoints: function splitPoints(obj) {
  3515. var points = [];
  3516. var x = obj.x;
  3517. var y = obj.y;
  3518. y = Util.isArray(y) ? y : [y];
  3519. y.forEach(function (yItem, index) {
  3520. var point = {
  3521. x: Util.isArray(x) ? x[index] : x,
  3522. y: yItem
  3523. };
  3524. points.push(point);
  3525. });
  3526. return points;
  3527. },
  3528. splitArray: function splitArray(data, yField, connectNulls) {
  3529. if (!data.length) return [];
  3530. var arr = [];
  3531. var tmp = [];
  3532. var yValue;
  3533. Util.each(data, function (obj) {
  3534. yValue = obj._origin ? obj._origin[yField] : obj[yField];
  3535. if (connectNulls) {
  3536. if (!Util.isNil(yValue)) {
  3537. tmp.push(obj);
  3538. }
  3539. } else {
  3540. if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
  3541. if (tmp.length) {
  3542. arr.push(tmp);
  3543. tmp = [];
  3544. }
  3545. } else {
  3546. tmp.push(obj);
  3547. }
  3548. }
  3549. });
  3550. if (tmp.length) {
  3551. arr.push(tmp);
  3552. }
  3553. return arr;
  3554. }
  3555. };
  3556. module.exports = ShapeUtil;
  3557. /***/ }),
  3558. /* 39 */
  3559. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3560. "use strict";
  3561. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  3562. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
  3563. var filter = function (arr, func) {
  3564. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(arr)) {
  3565. return arr;
  3566. }
  3567. var result = [];
  3568. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (value, index) {
  3569. if (func(value, index)) {
  3570. result.push(value);
  3571. }
  3572. });
  3573. return result;
  3574. };
  3575. /* harmony default export */ __webpack_exports__["a"] = (filter);
  3576. /***/ }),
  3577. /* 40 */
  3578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3579. "use strict";
  3580. var isObjectLike = function (value) {
  3581. /**
  3582. * isObjectLike({}) => true
  3583. * isObjectLike([1, 2, 3]) => true
  3584. * isObjectLike(Function) => false
  3585. * isObjectLike(null) => false
  3586. */
  3587. return typeof value === 'object' && value !== null;
  3588. };
  3589. /* harmony default export */ __webpack_exports__["a"] = (isObjectLike);
  3590. /***/ }),
  3591. /* 41 */
  3592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3593. "use strict";
  3594. /* harmony export (immutable) */ __webpack_exports__["a"] = mix;
  3595. // FIXME: Mutable param should be forbidden in static lang.
  3596. function _mix(dist, obj) {
  3597. for (var key in obj) {
  3598. if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
  3599. dist[key] = obj[key];
  3600. }
  3601. }
  3602. }
  3603. function mix(dist, src1, src2, src3) {
  3604. if (src1) _mix(dist, src1);
  3605. if (src2) _mix(dist, src2);
  3606. if (src3) _mix(dist, src3);
  3607. return dist;
  3608. }
  3609. /***/ }),
  3610. /* 42 */
  3611. /***/ (function(module, exports, __webpack_require__) {
  3612. "use strict";
  3613. exports.__esModule = true;
  3614. exports["default"] = void 0;
  3615. var _common = __webpack_require__(0);
  3616. // 实现简单的事件机制
  3617. var EventEmit = /*#__PURE__*/function () {
  3618. function EventEmit() {
  3619. this.__events = {};
  3620. }
  3621. var _proto = EventEmit.prototype;
  3622. _proto.on = function on(type, listener) {
  3623. if (!type || !listener) {
  3624. return;
  3625. }
  3626. var events = this.__events[type] || [];
  3627. events.push(listener);
  3628. this.__events[type] = events;
  3629. };
  3630. _proto.emit = function emit(type, e) {
  3631. var _this = this;
  3632. if ((0, _common.isObject)(type)) {
  3633. e = type;
  3634. type = e && e.type;
  3635. }
  3636. if (!type) {
  3637. return;
  3638. }
  3639. var events = this.__events[type];
  3640. if (!events || !events.length) {
  3641. return;
  3642. }
  3643. events.forEach(function (listener) {
  3644. listener.call(_this, e);
  3645. });
  3646. };
  3647. _proto.off = function off(type, listener) {
  3648. var __events = this.__events;
  3649. var events = __events[type];
  3650. if (!events || !events.length) {
  3651. return;
  3652. } // 如果没有指定方法,则删除所有项
  3653. if (!listener) {
  3654. delete __events[type];
  3655. return;
  3656. } // 删除指定的 listener
  3657. for (var i = 0, len = events.length; i < len; i++) {
  3658. if (events[i] === listener) {
  3659. events.splice(i, 1);
  3660. }
  3661. }
  3662. };
  3663. return EventEmit;
  3664. }();
  3665. var _default = EventEmit;
  3666. exports["default"] = _default;
  3667. /***/ }),
  3668. /* 43 */
  3669. /***/ (function(module, exports, __webpack_require__) {
  3670. "use strict";
  3671. var Util = __webpack_require__(0);
  3672. var MatrixUtil = __webpack_require__(31);
  3673. var Vector2 = __webpack_require__(13);
  3674. var defaultMatrix = [1, 0, 0, 1, 0, 0];
  3675. var Base = /*#__PURE__*/function () {
  3676. var _proto = Base.prototype;
  3677. _proto._initDefaultCfg = function _initDefaultCfg() {};
  3678. function Base(cfg) {
  3679. this._initDefaultCfg();
  3680. Util.mix(this, cfg);
  3681. var start;
  3682. var end;
  3683. if (this.plot) {
  3684. start = this.plot.bl;
  3685. end = this.plot.tr;
  3686. this.start = start;
  3687. this.end = end;
  3688. } else {
  3689. start = this.start;
  3690. end = this.end;
  3691. }
  3692. this.init(start, end);
  3693. }
  3694. _proto._scale = function _scale(s1, s2) {
  3695. var matrix = this.matrix;
  3696. var center = this.center;
  3697. MatrixUtil.translate(matrix, matrix, [center.x, center.y]);
  3698. MatrixUtil.scale(matrix, matrix, [s1, s2]);
  3699. MatrixUtil.translate(matrix, matrix, [-center.x, -center.y]);
  3700. };
  3701. _proto.init = function init(start, end) {
  3702. this.matrix = [].concat(defaultMatrix); // 设置中心点
  3703. this.center = {
  3704. x: (end.x - start.x) / 2 + start.x,
  3705. y: (end.y - start.y) / 2 + start.y
  3706. };
  3707. if (this.scale) {
  3708. this._scale(this.scale[0], this.scale[1]);
  3709. }
  3710. };
  3711. _proto.convertPoint = function convertPoint(point) {
  3712. var _this$_convertPoint = this._convertPoint(point),
  3713. x = _this$_convertPoint.x,
  3714. y = _this$_convertPoint.y;
  3715. var vector = [x, y];
  3716. Vector2.transformMat2d(vector, vector, this.matrix);
  3717. return {
  3718. x: vector[0],
  3719. y: vector[1]
  3720. };
  3721. };
  3722. _proto.invertPoint = function invertPoint(point) {
  3723. return this._invertPoint(point);
  3724. };
  3725. _proto._convertPoint = function _convertPoint(point) {
  3726. return point;
  3727. };
  3728. _proto._invertPoint = function _invertPoint(point) {
  3729. return point;
  3730. };
  3731. _proto.reset = function reset(plot) {
  3732. this.plot = plot;
  3733. var bl = plot.bl,
  3734. tr = plot.tr;
  3735. this.start = bl;
  3736. this.end = tr;
  3737. this.init(bl, tr);
  3738. };
  3739. return Base;
  3740. }();
  3741. module.exports = Base;
  3742. /***/ }),
  3743. /* 44 */
  3744. /***/ (function(module, exports) {
  3745. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  3746. return typeof obj;
  3747. } : function (obj) {
  3748. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3749. };
  3750. var isObject = function isObject(value) {
  3751. /**
  3752. * isObject({}) => true
  3753. * isObject([1, 2, 3]) => true
  3754. * isObject(Function) => true
  3755. * isObject(null) => false
  3756. */
  3757. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  3758. return value !== null && type === 'object' || type === 'function';
  3759. };
  3760. module.exports = isObject;
  3761. /***/ }),
  3762. /* 45 */
  3763. /***/ (function(module, exports, __webpack_require__) {
  3764. "use strict";
  3765. var Util = __webpack_require__(0);
  3766. var Global = __webpack_require__(6);
  3767. var Vector2 = __webpack_require__(13);
  3768. var Abastract = /*#__PURE__*/function () {
  3769. var _proto = Abastract.prototype;
  3770. _proto._initDefaultCfg = function _initDefaultCfg() {
  3771. /**
  3772. * ticks
  3773. * @type {Array}
  3774. */
  3775. this.ticks = [];
  3776. /**
  3777. * the configuration for tickLine
  3778. * @type {Object}
  3779. */
  3780. this.tickLine = {};
  3781. /**
  3782. * the direction of ticks, 1 means clockwise
  3783. * @type {Number}
  3784. */
  3785. this.offsetFactor = 1;
  3786. /**
  3787. * the top container
  3788. * @type {container}
  3789. */
  3790. this.frontContainer = null;
  3791. /**
  3792. * the back container
  3793. * @type {[type]}
  3794. */
  3795. this.backContainer = null;
  3796. /**
  3797. * points for draw grid line
  3798. * @type {Array}
  3799. */
  3800. this.gridPoints = [];
  3801. };
  3802. function Abastract(cfg) {
  3803. this._initDefaultCfg();
  3804. Util.mix(this, cfg);
  3805. this.draw();
  3806. }
  3807. _proto.draw = function draw() {
  3808. var line = this.line,
  3809. tickLine = this.tickLine,
  3810. label = this.label,
  3811. grid = this.grid;
  3812. grid && this.drawGrid(grid); // draw the grid lines
  3813. tickLine && this.drawTicks(tickLine); // draw the tickLine
  3814. line && this.drawLine(line); // draw axis line
  3815. label && this.drawLabels(); // draw ticks
  3816. };
  3817. _proto.drawTicks = function drawTicks(tickCfg) {
  3818. var self = this;
  3819. var ticks = self.ticks;
  3820. var length = tickCfg.length;
  3821. var container = self.getContainer(tickCfg.top);
  3822. Util.each(ticks, function (tick) {
  3823. var start = self.getOffsetPoint(tick.value);
  3824. var end = self.getSidePoint(start, length);
  3825. var shape = container.addShape('line', {
  3826. className: 'axis-tick',
  3827. attrs: Util.mix({
  3828. x1: start.x,
  3829. y1: start.y,
  3830. x2: end.x,
  3831. y2: end.y
  3832. }, tickCfg)
  3833. });
  3834. shape._id = self._id + '-ticks';
  3835. });
  3836. };
  3837. _proto.drawLabels = function drawLabels() {
  3838. var self = this;
  3839. var labelOffset = self.labelOffset;
  3840. var labels = self.labels;
  3841. Util.each(labels, function (labelShape) {
  3842. var container = self.getContainer(labelShape.get('top'));
  3843. var start = self.getOffsetPoint(labelShape.get('value'));
  3844. var _self$getSidePoint = self.getSidePoint(start, labelOffset),
  3845. x = _self$getSidePoint.x,
  3846. y = _self$getSidePoint.y;
  3847. labelShape.attr(Util.mix({
  3848. x: x,
  3849. y: y
  3850. }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
  3851. labelShape._id = self._id + '-' + labelShape.attr('text');
  3852. container.add(labelShape);
  3853. });
  3854. };
  3855. _proto.drawLine = function drawLine() {};
  3856. _proto.drawGrid = function drawGrid(grid) {
  3857. var self = this;
  3858. var gridPoints = self.gridPoints,
  3859. ticks = self.ticks;
  3860. var gridCfg = grid;
  3861. var count = gridPoints.length;
  3862. Util.each(gridPoints, function (subPoints, index) {
  3863. if (Util.isFunction(grid)) {
  3864. var tick = ticks[index] || {};
  3865. var executedGrid = grid(tick.text, index, count);
  3866. gridCfg = executedGrid ? Util.mix({}, Global._defaultAxis.grid, executedGrid) : null;
  3867. }
  3868. if (gridCfg) {
  3869. var type = gridCfg.type; // has two types: 'line' and 'arc'
  3870. var points = subPoints.points;
  3871. var container = self.getContainer(gridCfg.top);
  3872. var shape;
  3873. if (type === 'arc') {
  3874. var center = self.center,
  3875. startAngle = self.startAngle,
  3876. endAngle = self.endAngle;
  3877. var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
  3878. shape = container.addShape('Arc', {
  3879. className: 'axis-grid',
  3880. attrs: Util.mix({
  3881. x: center.x,
  3882. y: center.y,
  3883. startAngle: startAngle,
  3884. endAngle: endAngle,
  3885. r: radius
  3886. }, gridCfg)
  3887. });
  3888. } else {
  3889. shape = container.addShape('Polyline', {
  3890. className: 'axis-grid',
  3891. attrs: Util.mix({
  3892. points: points
  3893. }, gridCfg)
  3894. });
  3895. }
  3896. shape._id = subPoints._id;
  3897. }
  3898. });
  3899. };
  3900. _proto.getOffsetPoint = function getOffsetPoint() {};
  3901. _proto.getAxisVector = function getAxisVector() {};
  3902. _proto.getOffsetVector = function getOffsetVector(point, offset) {
  3903. var self = this;
  3904. var axisVector = self.getAxisVector(point);
  3905. var normal = Vector2.normalize([], axisVector);
  3906. var factor = self.offsetFactor;
  3907. var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
  3908. return Vector2.scale([], verticalVector, offset);
  3909. };
  3910. _proto.getSidePoint = function getSidePoint(point, offset) {
  3911. var self = this;
  3912. var offsetVector = self.getOffsetVector(point, offset);
  3913. return {
  3914. x: point.x + offsetVector[0],
  3915. y: point.y + offsetVector[1]
  3916. };
  3917. };
  3918. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  3919. var self = this;
  3920. var offsetVector = self.getOffsetVector(point, offset);
  3921. var align;
  3922. var baseLine;
  3923. if (offsetVector[0] > 0) {
  3924. align = 'left';
  3925. } else if (offsetVector[0] < 0) {
  3926. align = 'right';
  3927. } else {
  3928. align = 'center';
  3929. }
  3930. if (offsetVector[1] > 0) {
  3931. baseLine = 'top';
  3932. } else if (offsetVector[1] < 0) {
  3933. baseLine = 'bottom';
  3934. } else {
  3935. baseLine = 'middle';
  3936. }
  3937. return {
  3938. textAlign: align,
  3939. textBaseline: baseLine
  3940. };
  3941. };
  3942. _proto.getContainer = function getContainer(isTop) {
  3943. var frontContainer = this.frontContainer,
  3944. backContainer = this.backContainer;
  3945. return isTop ? frontContainer : backContainer;
  3946. };
  3947. return Abastract;
  3948. }();
  3949. module.exports = Abastract;
  3950. /***/ }),
  3951. /* 46 */
  3952. /***/ (function(module, exports, __webpack_require__) {
  3953. "use strict";
  3954. var Util = __webpack_require__(0);
  3955. var MatrixUtil = __webpack_require__(31);
  3956. var Vector2 = __webpack_require__(13);
  3957. var StyleUtil = __webpack_require__(179);
  3958. function isUnchanged(m) {
  3959. return m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
  3960. }
  3961. var ALIAS_ATTRS_MAP = {
  3962. stroke: 'strokeStyle',
  3963. fill: 'fillStyle',
  3964. opacity: 'globalAlpha'
  3965. };
  3966. var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'shadow' // 兼容支付宝小程序
  3967. ];
  3968. var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
  3969. var Element = /*#__PURE__*/function () {
  3970. var _proto = Element.prototype;
  3971. _proto._initProperties = function _initProperties() {
  3972. this._attrs = {
  3973. zIndex: 0,
  3974. visible: true,
  3975. destroyed: false
  3976. };
  3977. };
  3978. function Element(cfg) {
  3979. this._initProperties();
  3980. Util.mix(this._attrs, cfg);
  3981. var attrs = this._attrs.attrs;
  3982. if (attrs) {
  3983. this.initAttrs(attrs);
  3984. }
  3985. this.initTransform();
  3986. }
  3987. _proto.get = function get(name) {
  3988. return this._attrs[name];
  3989. };
  3990. _proto.set = function set(name, value) {
  3991. this._attrs[name] = value;
  3992. };
  3993. _proto.isGroup = function isGroup() {
  3994. return this.get('isGroup');
  3995. };
  3996. _proto.isShape = function isShape() {
  3997. return this.get('isShape');
  3998. };
  3999. _proto.initAttrs = function initAttrs(attrs) {
  4000. this.attr(Util.mix(this.getDefaultAttrs(), attrs));
  4001. };
  4002. _proto.getDefaultAttrs = function getDefaultAttrs() {
  4003. return {};
  4004. };
  4005. _proto._setAttr = function _setAttr(name, value) {
  4006. var attrs = this._attrs.attrs;
  4007. if (name === 'clip') {
  4008. value = this._setAttrClip(value);
  4009. } else {
  4010. var alias = ALIAS_ATTRS_MAP[name];
  4011. if (alias) {
  4012. attrs[alias] = value;
  4013. }
  4014. }
  4015. attrs[name] = value;
  4016. };
  4017. _proto._getAttr = function _getAttr(name) {
  4018. return this._attrs.attrs[name];
  4019. } // _afterAttrsSet() {}
  4020. ;
  4021. _proto._setAttrClip = function _setAttrClip(clip) {
  4022. if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
  4023. if (clip.get('canvas') === null) {
  4024. clip = Object.assign({}, clip);
  4025. }
  4026. clip.set('parent', this.get('parent'));
  4027. clip.set('context', this.get('context'));
  4028. return clip;
  4029. }
  4030. return null;
  4031. };
  4032. _proto.attr = function attr(name, value) {
  4033. var self = this;
  4034. if (self.get('destroyed')) return null;
  4035. var argumentsLen = arguments.length;
  4036. if (argumentsLen === 0) {
  4037. return self._attrs.attrs;
  4038. }
  4039. if (Util.isObject(name)) {
  4040. this._attrs.bbox = null;
  4041. for (var k in name) {
  4042. self._setAttr(k, name[k]);
  4043. }
  4044. if (self._afterAttrsSet) {
  4045. self._afterAttrsSet();
  4046. }
  4047. return self;
  4048. }
  4049. if (argumentsLen === 2) {
  4050. this._attrs.bbox = null;
  4051. self._setAttr(name, value);
  4052. if (self._afterAttrsSet) {
  4053. self._afterAttrsSet();
  4054. }
  4055. return self;
  4056. }
  4057. return self._getAttr(name);
  4058. };
  4059. _proto.getParent = function getParent() {
  4060. return this.get('parent');
  4061. };
  4062. _proto.draw = function draw(context) {
  4063. if (this.get('destroyed')) {
  4064. return;
  4065. }
  4066. if (this.get('visible')) {
  4067. this.setContext(context);
  4068. this.drawInner(context);
  4069. this.restoreContext(context);
  4070. }
  4071. };
  4072. _proto.setContext = function setContext(context) {
  4073. var clip = this._attrs.attrs.clip;
  4074. context.save();
  4075. if (clip) {
  4076. clip.resetTransform(context);
  4077. clip.createPath(context);
  4078. context.clip();
  4079. }
  4080. this.resetContext(context);
  4081. this.resetTransform(context);
  4082. };
  4083. _proto.restoreContext = function restoreContext(context) {
  4084. context.restore();
  4085. };
  4086. _proto.resetContext = function resetContext(context) {
  4087. var elAttrs = this._attrs.attrs;
  4088. if (!this._attrs.isGroup) {
  4089. for (var k in elAttrs) {
  4090. if (SHAPE_ATTRS.indexOf(k) > -1) {
  4091. var v = elAttrs[k];
  4092. if (k === 'fillStyle' || k === 'strokeStyle') {
  4093. v = StyleUtil.parseStyle(v, this, context);
  4094. }
  4095. if (k === 'lineDash' && context.setLineDash && Util.isArray(v)) {
  4096. context.setLineDash(v);
  4097. } else {
  4098. context[k] = v;
  4099. }
  4100. }
  4101. }
  4102. }
  4103. };
  4104. _proto.hasFill = function hasFill() {
  4105. return this.get('canFill') && this._attrs.attrs.fillStyle;
  4106. };
  4107. _proto.hasStroke = function hasStroke() {
  4108. return this.get('canStroke') && this._attrs.attrs.strokeStyle;
  4109. };
  4110. _proto.drawInner = function drawInner()
  4111. /* context */
  4112. {};
  4113. _proto.show = function show() {
  4114. this.set('visible', true);
  4115. return this;
  4116. };
  4117. _proto.hide = function hide() {
  4118. this.set('visible', false);
  4119. return this;
  4120. };
  4121. _proto.isVisible = function isVisible() {
  4122. return this.get('visible');
  4123. };
  4124. _proto._removeFromParent = function _removeFromParent() {
  4125. var parent = this.get('parent');
  4126. if (parent) {
  4127. var children = parent.get('children');
  4128. Util.Array.remove(children, this);
  4129. }
  4130. return this;
  4131. };
  4132. _proto.remove = function remove(destroy) {
  4133. if (destroy) {
  4134. this.destroy();
  4135. } else {
  4136. this._removeFromParent();
  4137. }
  4138. };
  4139. _proto.destroy = function destroy() {
  4140. var destroyed = this.get('destroyed');
  4141. if (destroyed) {
  4142. return null;
  4143. }
  4144. this._removeFromParent();
  4145. this._attrs = {};
  4146. this.set('destroyed', true);
  4147. };
  4148. _proto.getBBox = function getBBox() {
  4149. return {
  4150. minX: 0,
  4151. maxX: 0,
  4152. minY: 0,
  4153. maxY: 0,
  4154. width: 0,
  4155. height: 0
  4156. };
  4157. };
  4158. _proto.initTransform = function initTransform() {
  4159. var attrs = this._attrs.attrs || {};
  4160. if (!attrs.matrix) {
  4161. attrs.matrix = [1, 0, 0, 1, 0, 0];
  4162. }
  4163. this._attrs.attrs = attrs;
  4164. };
  4165. _proto.getMatrix = function getMatrix() {
  4166. return this._attrs.attrs.matrix;
  4167. };
  4168. _proto.setMatrix = function setMatrix(m) {
  4169. this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
  4170. };
  4171. _proto.transform = function transform(actions) {
  4172. var matrix = this._attrs.attrs.matrix;
  4173. this._attrs.attrs.matrix = MatrixUtil.transform(matrix, actions);
  4174. return this;
  4175. };
  4176. _proto.setTransform = function setTransform(actions) {
  4177. this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
  4178. return this.transform(actions);
  4179. };
  4180. _proto.translate = function translate(x, y) {
  4181. var matrix = this._attrs.attrs.matrix;
  4182. MatrixUtil.translate(matrix, matrix, [x, y]);
  4183. };
  4184. _proto.rotate = function rotate(rad) {
  4185. var matrix = this._attrs.attrs.matrix;
  4186. MatrixUtil.rotate(matrix, matrix, rad);
  4187. };
  4188. _proto.scale = function scale(sx, sy) {
  4189. var matrix = this._attrs.attrs.matrix;
  4190. MatrixUtil.scale(matrix, matrix, [sx, sy]);
  4191. };
  4192. _proto.moveTo = function moveTo(x, y) {
  4193. var cx = this._attrs.x || 0;
  4194. var cy = this._attrs.y || 0;
  4195. this.translate(x - cx, y - cy);
  4196. this.set('x', x);
  4197. this.set('y', y);
  4198. };
  4199. _proto.apply = function apply(v) {
  4200. var m = this._attrs.attrs.matrix;
  4201. Vector2.transformMat2d(v, v, m);
  4202. return this;
  4203. };
  4204. _proto.resetTransform = function resetTransform(context) {
  4205. var mo = this._attrs.attrs.matrix;
  4206. if (!isUnchanged(mo)) {
  4207. context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
  4208. }
  4209. };
  4210. _proto.isDestroyed = function isDestroyed() {
  4211. return this.get('destroyed');
  4212. };
  4213. return Element;
  4214. }();
  4215. module.exports = Element;
  4216. /***/ }),
  4217. /* 47 */
  4218. /***/ (function(module, exports, __webpack_require__) {
  4219. "use strict";
  4220. exports.__esModule = true;
  4221. exports.EVENT_AFTER_GEOM_INIT = exports.EVENT_AFTER_SIZE_CHANGE = exports.EVENT_AFTER_DATA_CHANGE = exports.EVENT_BEFORE_DATA_CHANGE = exports.EVENT_AFTER_RENDER = exports.EVENT_BEFORE_RENDER = exports.EVENT_AFTER_INIT = void 0;
  4222. var EVENT_AFTER_INIT = 'afterinit';
  4223. exports.EVENT_AFTER_INIT = EVENT_AFTER_INIT;
  4224. var EVENT_BEFORE_RENDER = 'beforerender';
  4225. exports.EVENT_BEFORE_RENDER = EVENT_BEFORE_RENDER;
  4226. var EVENT_AFTER_RENDER = 'afterrender';
  4227. exports.EVENT_AFTER_RENDER = EVENT_AFTER_RENDER;
  4228. var EVENT_BEFORE_DATA_CHANGE = 'beforedatachange';
  4229. exports.EVENT_BEFORE_DATA_CHANGE = EVENT_BEFORE_DATA_CHANGE;
  4230. var EVENT_AFTER_DATA_CHANGE = 'afterdatachange';
  4231. exports.EVENT_AFTER_DATA_CHANGE = EVENT_AFTER_DATA_CHANGE;
  4232. var EVENT_AFTER_SIZE_CHANGE = '_aftersizechange';
  4233. exports.EVENT_AFTER_SIZE_CHANGE = EVENT_AFTER_SIZE_CHANGE;
  4234. var EVENT_AFTER_GEOM_INIT = '_aftergeominit';
  4235. exports.EVENT_AFTER_GEOM_INIT = EVENT_AFTER_GEOM_INIT;
  4236. /***/ }),
  4237. /* 48 */
  4238. /***/ (function(module, exports, __webpack_require__) {
  4239. var isType = __webpack_require__(27);
  4240. var isString = function isString(str) {
  4241. return isType(str, 'String');
  4242. };
  4243. module.exports = isString;
  4244. /***/ }),
  4245. /* 49 */
  4246. /***/ (function(module, exports, __webpack_require__) {
  4247. var _typeof = __webpack_require__(50);
  4248. function _getRequireWildcardCache() {
  4249. if (typeof WeakMap !== "function") return null;
  4250. var cache = new WeakMap();
  4251. _getRequireWildcardCache = function _getRequireWildcardCache() {
  4252. return cache;
  4253. };
  4254. return cache;
  4255. }
  4256. function _interopRequireWildcard(obj) {
  4257. if (obj && obj.__esModule) {
  4258. return obj;
  4259. }
  4260. if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
  4261. return {
  4262. "default": obj
  4263. };
  4264. }
  4265. var cache = _getRequireWildcardCache();
  4266. if (cache && cache.has(obj)) {
  4267. return cache.get(obj);
  4268. }
  4269. var newObj = {};
  4270. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  4271. for (var key in obj) {
  4272. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  4273. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  4274. if (desc && (desc.get || desc.set)) {
  4275. Object.defineProperty(newObj, key, desc);
  4276. } else {
  4277. newObj[key] = obj[key];
  4278. }
  4279. }
  4280. }
  4281. newObj["default"] = obj;
  4282. if (cache) {
  4283. cache.set(obj, newObj);
  4284. }
  4285. return newObj;
  4286. }
  4287. module.exports = _interopRequireWildcard;
  4288. /***/ }),
  4289. /* 50 */
  4290. /***/ (function(module, exports) {
  4291. function _typeof(obj) {
  4292. "@babel/helpers - typeof";
  4293. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  4294. module.exports = _typeof = function _typeof(obj) {
  4295. return typeof obj;
  4296. };
  4297. } else {
  4298. module.exports = _typeof = function _typeof(obj) {
  4299. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  4300. };
  4301. }
  4302. return _typeof(obj);
  4303. }
  4304. module.exports = _typeof;
  4305. /***/ }),
  4306. /* 51 */
  4307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4308. "use strict";
  4309. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  4310. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__keys__ = __webpack_require__(52);
  4311. function isMatch(obj, attrs) {
  4312. var _keys = Object(__WEBPACK_IMPORTED_MODULE_1__keys__["a" /* default */])(attrs);
  4313. var length = _keys.length;
  4314. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(obj)) return !length;
  4315. for (var i = 0; i < length; i += 1) {
  4316. var key = _keys[i];
  4317. if (attrs[key] !== obj[key] || !(key in obj)) {
  4318. return false;
  4319. }
  4320. }
  4321. return true;
  4322. }
  4323. /* harmony default export */ __webpack_exports__["a"] = (isMatch);
  4324. /***/ }),
  4325. /* 52 */
  4326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4327. "use strict";
  4328. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  4329. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
  4330. var keys = Object.keys ? function (obj) {
  4331. return Object.keys(obj);
  4332. } : function (obj) {
  4333. var result = [];
  4334. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(obj, function (value, key) {
  4335. if (!(Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj) && key === 'prototype')) {
  4336. result.push(key);
  4337. }
  4338. });
  4339. return result;
  4340. };
  4341. /* harmony default export */ __webpack_exports__["a"] = (keys);
  4342. /***/ }),
  4343. /* 53 */
  4344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4345. "use strict";
  4346. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  4347. var splice = Array.prototype.splice;
  4348. var pullAt = function pullAt(arr, indexes) {
  4349. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
  4350. return [];
  4351. }
  4352. var length = arr ? indexes.length : 0;
  4353. var last = length - 1;
  4354. while (length--) {
  4355. var previous = void 0;
  4356. var index = indexes[length];
  4357. if (length === last || index !== previous) {
  4358. previous = index;
  4359. splice.call(arr, index, 1);
  4360. }
  4361. }
  4362. return arr;
  4363. };
  4364. /* harmony default export */ __webpack_exports__["a"] = (pullAt);
  4365. /***/ }),
  4366. /* 54 */
  4367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4368. "use strict";
  4369. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
  4370. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each__ = __webpack_require__(8);
  4371. var uniq = function (arr) {
  4372. var resultArr = [];
  4373. Object(__WEBPACK_IMPORTED_MODULE_1__each__["a" /* default */])(arr, function (item) {
  4374. if (!Object(__WEBPACK_IMPORTED_MODULE_0__contains__["a" /* default */])(resultArr, item)) {
  4375. resultArr.push(item);
  4376. }
  4377. });
  4378. return resultArr;
  4379. };
  4380. /* harmony default export */ __webpack_exports__["a"] = (uniq);
  4381. /***/ }),
  4382. /* 55 */
  4383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4384. "use strict";
  4385. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  4386. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
  4387. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__group_by__ = __webpack_require__(56);
  4388. var groupToMap = function (data, condition) {
  4389. if (!condition) {
  4390. return {
  4391. 0: data
  4392. };
  4393. }
  4394. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(condition)) {
  4395. var paramsCondition_1 = Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(condition) ? condition : condition.replace(/\s+/g, '').split('*');
  4396. condition = function (row) {
  4397. var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
  4398. for (var i = 0, l = paramsCondition_1.length; i < l; i++) {
  4399. unique += row[paramsCondition_1[i]] && row[paramsCondition_1[i]].toString();
  4400. }
  4401. return unique;
  4402. };
  4403. }
  4404. var groups = Object(__WEBPACK_IMPORTED_MODULE_2__group_by__["a" /* default */])(data, condition);
  4405. return groups;
  4406. };
  4407. /* harmony default export */ __webpack_exports__["a"] = (groupToMap);
  4408. /***/ }),
  4409. /* 56 */
  4410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4411. "use strict";
  4412. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  4413. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  4414. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
  4415. var hasOwnProperty = Object.prototype.hasOwnProperty;
  4416. function groupBy(data, condition) {
  4417. if (!condition || !Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(data)) {
  4418. return {};
  4419. }
  4420. var result = {}; // 兼容方法和 字符串的写法
  4421. var predicate = Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(condition) ? condition : function (item) {
  4422. return item[condition];
  4423. };
  4424. var key;
  4425. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(data, function (item) {
  4426. key = predicate(item);
  4427. if (hasOwnProperty.call(result, key)) {
  4428. result[key].push(item);
  4429. } else {
  4430. result[key] = [item];
  4431. }
  4432. });
  4433. return result;
  4434. }
  4435. /* harmony default export */ __webpack_exports__["a"] = (groupBy);
  4436. /***/ }),
  4437. /* 57 */
  4438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4439. "use strict";
  4440. /* harmony default export */ __webpack_exports__["a"] = (function (obj, key) {
  4441. return obj.hasOwnProperty(key);
  4442. });
  4443. /***/ }),
  4444. /* 58 */
  4445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4446. "use strict";
  4447. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  4448. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
  4449. // @ts-ignore
  4450. var values = Object.values ? function (obj) {
  4451. return Object.values(obj);
  4452. } : function (obj) {
  4453. var result = [];
  4454. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(obj, function (value, key) {
  4455. if (!(Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj) && key === 'prototype')) {
  4456. result.push(value);
  4457. }
  4458. });
  4459. return result;
  4460. };
  4461. /* harmony default export */ __webpack_exports__["a"] = (values);
  4462. /***/ }),
  4463. /* 59 */
  4464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4465. "use strict";
  4466. var toString = {}.toString;
  4467. var getType = function (value) {
  4468. return toString.call(value).replace(/^\[object /, '').replace(/]$/, '');
  4469. };
  4470. /* harmony default export */ __webpack_exports__["a"] = (getType);
  4471. /***/ }),
  4472. /* 60 */
  4473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4474. "use strict";
  4475. var objectProto = Object.prototype;
  4476. var isPrototype = function (value) {
  4477. var Ctor = value && value.constructor;
  4478. var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
  4479. return value === proto;
  4480. };
  4481. /* harmony default export */ __webpack_exports__["a"] = (isPrototype);
  4482. /***/ }),
  4483. /* 61 */
  4484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4485. "use strict";
  4486. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object_like__ = __webpack_require__(40);
  4487. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
  4488. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_string__ = __webpack_require__(18);
  4489. var isEqual = function (value, other) {
  4490. if (value === other) {
  4491. return true;
  4492. }
  4493. if (!value || !other) {
  4494. return false;
  4495. }
  4496. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_string__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_2__is_string__["a" /* default */])(other)) {
  4497. return false;
  4498. }
  4499. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(other)) {
  4500. if (value.length !== other.length) {
  4501. return false;
  4502. }
  4503. var rst = true;
  4504. for (var i = 0; i < value.length; i++) {
  4505. rst = isEqual(value[i], other[i]);
  4506. if (!rst) {
  4507. break;
  4508. }
  4509. }
  4510. return rst;
  4511. }
  4512. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(other)) {
  4513. var valueKeys = Object.keys(value);
  4514. var otherKeys = Object.keys(other);
  4515. if (valueKeys.length !== otherKeys.length) {
  4516. return false;
  4517. }
  4518. var rst = true;
  4519. for (var i = 0; i < valueKeys.length; i++) {
  4520. rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]);
  4521. if (!rst) {
  4522. break;
  4523. }
  4524. }
  4525. return rst;
  4526. }
  4527. return false;
  4528. };
  4529. /* harmony default export */ __webpack_exports__["a"] = (isEqual);
  4530. /***/ }),
  4531. /* 62 */
  4532. /***/ (function(module, exports, __webpack_require__) {
  4533. "use strict";
  4534. exports.__esModule = true;
  4535. exports.isCanvasElement = isCanvasElement;
  4536. exports.getPixelRatio = getPixelRatio;
  4537. exports.getStyle = getStyle;
  4538. exports.getWidth = getWidth;
  4539. exports.getHeight = getHeight;
  4540. exports.getDomById = getDomById;
  4541. exports.getRelativePosition = getRelativePosition;
  4542. exports.addEventListener = addEventListener;
  4543. exports.removeEventListener = removeEventListener;
  4544. exports.createEvent = createEvent;
  4545. exports.measureText = measureText;
  4546. exports.isBrowser = exports.isNode = exports.isMy = exports.isWx = void 0;
  4547. /**
  4548. * Detects support for options object argument in addEventListener.
  4549. * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  4550. * @private
  4551. */
  4552. var supportsEventListenerOptions = function () {
  4553. var supports = false;
  4554. try {
  4555. var options = Object.defineProperty({}, 'passive', {
  4556. get: function get() {
  4557. supports = true;
  4558. }
  4559. });
  4560. window.addEventListener('e', null, options);
  4561. } catch (e) {// continue regardless of error
  4562. }
  4563. return supports;
  4564. }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
  4565. // https://github.com/chartjs/Chart.js/issues/4287
  4566. var eventListenerOptions = supportsEventListenerOptions ? {
  4567. passive: true
  4568. } : false;
  4569. /* global wx, my */
  4570. // weixin miniprogram
  4571. var isWx = typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function'; // ant miniprogram
  4572. exports.isWx = isWx;
  4573. var isMy = typeof my === 'object' && typeof my.getSystemInfoSync === 'function'; // in node
  4574. exports.isMy = isMy;
  4575. var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined'; // in browser
  4576. exports.isNode = isNode;
  4577. var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined';
  4578. exports.isBrowser = isBrowser;
  4579. function isCanvasElement(el) {
  4580. if (!el || typeof el !== 'object') return false;
  4581. if (el.nodeType === 1 && el.nodeName) {
  4582. // HTMLCanvasElement
  4583. return true;
  4584. } // CanvasElement
  4585. return !!el.isCanvasElement;
  4586. }
  4587. function getPixelRatio() {
  4588. return window && window.devicePixelRatio || 1;
  4589. }
  4590. function getStyle(el, property) {
  4591. return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
  4592. }
  4593. function getWidth(el) {
  4594. var width = getStyle(el, 'width');
  4595. if (width === 'auto') {
  4596. width = el.offsetWidth;
  4597. }
  4598. return parseFloat(width);
  4599. }
  4600. function getHeight(el) {
  4601. var height = getStyle(el, 'height');
  4602. if (height === 'auto') {
  4603. height = el.offsetHeight;
  4604. }
  4605. return parseFloat(height);
  4606. }
  4607. function getDomById(id) {
  4608. if (!id) {
  4609. return null;
  4610. }
  4611. return document.getElementById(id);
  4612. }
  4613. function getRelativePosition(point, canvas) {
  4614. var canvasDom = canvas.get('el');
  4615. if (!canvasDom) return point;
  4616. var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
  4617. top = _canvasDom$getBoundin.top,
  4618. right = _canvasDom$getBoundin.right,
  4619. bottom = _canvasDom$getBoundin.bottom,
  4620. left = _canvasDom$getBoundin.left;
  4621. var paddingLeft = parseFloat(getStyle(canvasDom, 'padding-left'));
  4622. var paddingTop = parseFloat(getStyle(canvasDom, 'padding-top'));
  4623. var paddingRight = parseFloat(getStyle(canvasDom, 'padding-right'));
  4624. var paddingBottom = parseFloat(getStyle(canvasDom, 'padding-bottom'));
  4625. var width = right - left - paddingLeft - paddingRight;
  4626. var height = bottom - top - paddingTop - paddingBottom;
  4627. var pixelRatio = canvas.get('pixelRatio');
  4628. var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
  4629. var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
  4630. return {
  4631. x: mouseX,
  4632. y: mouseY
  4633. };
  4634. }
  4635. function addEventListener(source, type, listener) {
  4636. source.addEventListener(type, listener, eventListenerOptions);
  4637. }
  4638. function removeEventListener(source, type, listener) {
  4639. source.removeEventListener(type, listener, eventListenerOptions);
  4640. }
  4641. function createEventObj(type, chart, x, y, nativeEvent) {
  4642. return {
  4643. type: type,
  4644. chart: chart,
  4645. "native": nativeEvent || null,
  4646. x: x !== undefined ? x : null,
  4647. y: y !== undefined ? y : null
  4648. };
  4649. }
  4650. function createEvent(event, chart) {
  4651. var type = event.type;
  4652. var clientPoint; // 说明是touch相关事件
  4653. if (event.touches) {
  4654. // https://developer.mozilla.org/zh-CN/docs/Web/API/TouchEvent/changedTouches
  4655. // 这里直接拿changedTouches就可以了,不管是touchstart, touchmove, touchend changedTouches 都是有的
  4656. // 为了以防万一,做个空判断
  4657. var touch = event.changedTouches[0] || {}; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
  4658. var x = touch.x,
  4659. y = touch.y,
  4660. clientX = touch.clientX,
  4661. clientY = touch.clientY; // 小程序环境会有x,y,这里就直接返回
  4662. if (x && y) {
  4663. return createEventObj(type, chart, x, y, event);
  4664. }
  4665. clientPoint = {
  4666. x: clientX,
  4667. y: clientY
  4668. };
  4669. } else {
  4670. // mouse相关事件
  4671. clientPoint = {
  4672. x: event.clientX,
  4673. y: event.clientY
  4674. };
  4675. } // 理论上应该是只有有在浏览器环境才会走到这里
  4676. var canvas = chart.get('canvas'); // 通过clientX, clientY 计算x, y
  4677. var point = getRelativePosition(clientPoint, canvas);
  4678. return createEventObj(type, chart, point.x, point.y, event);
  4679. }
  4680. function measureText(text, font, ctx) {
  4681. if (!ctx) {
  4682. ctx = document.createElement('canvas').getContext('2d');
  4683. }
  4684. ctx.font = font || '12px sans-serif';
  4685. return ctx.measureText(text);
  4686. }
  4687. /***/ }),
  4688. /* 63 */
  4689. /***/ (function(module, exports, __webpack_require__) {
  4690. "use strict";
  4691. var _interopRequireDefault = __webpack_require__(1);
  4692. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  4693. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  4694. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  4695. var _emit = _interopRequireDefault(__webpack_require__(42));
  4696. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  4697. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  4698. var Util = __webpack_require__(0);
  4699. var Base = /*#__PURE__*/function (_Emit) {
  4700. (0, _inheritsLoose2["default"])(Base, _Emit);
  4701. var _super = _createSuper(Base);
  4702. var _proto = Base.prototype;
  4703. _proto.getDefaultCfg = function getDefaultCfg() {
  4704. return {};
  4705. };
  4706. function Base(cfg) {
  4707. var _this;
  4708. _this = _Emit.call(this) || this;
  4709. var attrs = {};
  4710. var defaultCfg = _this.getDefaultCfg();
  4711. _this._attrs = attrs;
  4712. Util.mix(attrs, defaultCfg, cfg);
  4713. return _this;
  4714. }
  4715. _proto.get = function get(name) {
  4716. return this._attrs[name];
  4717. };
  4718. _proto.set = function set(name, value) {
  4719. this._attrs[name] = value;
  4720. };
  4721. _proto.destroy = function destroy() {
  4722. this._attrs = {};
  4723. this.destroyed = true;
  4724. };
  4725. return Base;
  4726. }(_emit["default"]);
  4727. module.exports = Base;
  4728. /***/ }),
  4729. /* 64 */
  4730. /***/ (function(module, exports) {
  4731. function _mix(dist, obj) {
  4732. for (var key in obj) {
  4733. if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
  4734. dist[key] = obj[key];
  4735. }
  4736. }
  4737. }
  4738. var mix = function mix(dist, src1, src2, src3) {
  4739. if (src1) _mix(dist, src1);
  4740. if (src2) _mix(dist, src2);
  4741. if (src3) _mix(dist, src3);
  4742. return dist;
  4743. };
  4744. module.exports = mix;
  4745. /***/ }),
  4746. /* 65 */
  4747. /***/ (function(module, exports, __webpack_require__) {
  4748. /**
  4749. * @fileOverview 计算分类的的坐标点
  4750. * @author dxq613@gmail.com
  4751. */
  4752. var each = __webpack_require__(15);
  4753. var MAX_COUNT = 8;
  4754. var SUB_COUNT = 4; // 控制个数不能过小
  4755. function getSimpleArray(data) {
  4756. var arr = [];
  4757. each(data, function (sub) {
  4758. arr = arr.concat(sub);
  4759. });
  4760. return arr;
  4761. }
  4762. function getGreatestFactor(count, number) {
  4763. var i;
  4764. for (i = number; i > 0; i--) {
  4765. if (count % i === 0) {
  4766. break;
  4767. }
  4768. } // 如果是素数,没有可以整除的数字
  4769. if (i === 1) {
  4770. for (i = number; i > 0; i--) {
  4771. if ((count - 1) % i === 0) {
  4772. break;
  4773. }
  4774. }
  4775. }
  4776. return i;
  4777. }
  4778. module.exports = function (info) {
  4779. var rst = {};
  4780. var ticks = [];
  4781. var isRounding = info.isRounding;
  4782. var categories = getSimpleArray(info.data);
  4783. var length = categories.length;
  4784. var maxCount = info.maxCount || MAX_COUNT;
  4785. var tickCount;
  4786. if (isRounding) {
  4787. // 取整操作
  4788. tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
  4789. if (tickCount === 2) {
  4790. tickCount = maxCount;
  4791. } else if (tickCount < maxCount - SUB_COUNT) {
  4792. tickCount = maxCount - SUB_COUNT;
  4793. }
  4794. } else {
  4795. tickCount = maxCount;
  4796. }
  4797. if (!isRounding && length <= tickCount + tickCount / 2) {
  4798. ticks = [].concat(categories);
  4799. } else {
  4800. var step = parseInt(length / (tickCount - 1), 10);
  4801. var groups = categories.map(function (e, i) {
  4802. return i % step === 0 ? categories.slice(i, i + step) : null;
  4803. }).filter(function (e) {
  4804. return e;
  4805. });
  4806. for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
  4807. ticks.push(groups[i][0]);
  4808. }
  4809. if (categories.length) {
  4810. ticks.unshift(categories[0]);
  4811. var last = categories[length - 1];
  4812. if (ticks.indexOf(last) === -1) {
  4813. ticks.push(last);
  4814. }
  4815. }
  4816. }
  4817. rst.categories = categories;
  4818. rst.ticks = ticks;
  4819. return rst;
  4820. };
  4821. /***/ }),
  4822. /* 66 */
  4823. /***/ (function(module, exports, __webpack_require__) {
  4824. "use strict";
  4825. var Util = __webpack_require__(0);
  4826. var Shape = __webpack_require__(10);
  4827. var SHAPE_MAP = {};
  4828. var INDEX = '_INDEX';
  4829. function getComparer(compare) {
  4830. return function (left, right) {
  4831. var result = compare(left, right);
  4832. return result === 0 ? left[INDEX] - right[INDEX] : result;
  4833. };
  4834. }
  4835. module.exports = {
  4836. getGroupClass: function getGroupClass() {},
  4837. getChildren: function getChildren() {
  4838. return this.get('children');
  4839. },
  4840. addShape: function addShape(type, cfg) {
  4841. if (cfg === void 0) {
  4842. cfg = {};
  4843. }
  4844. var canvas = this.get('canvas');
  4845. var shapeType = SHAPE_MAP[type];
  4846. if (!shapeType) {
  4847. shapeType = Util.upperFirst(type);
  4848. SHAPE_MAP[type] = shapeType;
  4849. }
  4850. cfg.canvas = canvas;
  4851. if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
  4852. cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
  4853. }
  4854. var shape = new Shape[shapeType](cfg);
  4855. this.add(shape);
  4856. return shape;
  4857. },
  4858. addGroup: function addGroup(cfg) {
  4859. var canvas = this.get('canvas');
  4860. var groupClass = this.getGroupClass();
  4861. cfg = Util.mix({}, cfg);
  4862. cfg.canvas = canvas;
  4863. cfg.parent = this;
  4864. var rst = new groupClass(cfg);
  4865. this.add(rst);
  4866. return rst;
  4867. },
  4868. contain: function contain(item) {
  4869. var children = this.get('children');
  4870. return children.indexOf(item) > -1;
  4871. },
  4872. sort: function sort() {
  4873. var children = this.get('children');
  4874. for (var i = 0, len = children.length; i < len; i++) {
  4875. var child = children[i];
  4876. child[INDEX] = i;
  4877. }
  4878. children.sort(getComparer(function (obj1, obj2) {
  4879. return obj1.get('zIndex') - obj2.get('zIndex');
  4880. }));
  4881. return this;
  4882. },
  4883. clear: function clear() {
  4884. var children = this.get('children');
  4885. while (children.length !== 0) {
  4886. children[children.length - 1].remove(true);
  4887. }
  4888. return this;
  4889. },
  4890. add: function add(items) {
  4891. var self = this;
  4892. var children = self.get('children');
  4893. if (!Util.isArray(items)) {
  4894. items = [items];
  4895. }
  4896. for (var i = 0, len = items.length; i < len; i++) {
  4897. var item = items[i];
  4898. var parent = item.get('parent');
  4899. if (parent) {
  4900. var descendants = parent.get('children');
  4901. Util.Array.remove(descendants, item);
  4902. }
  4903. self._setEvn(item);
  4904. children.push(item);
  4905. }
  4906. return self;
  4907. },
  4908. _setEvn: function _setEvn(item) {
  4909. var self = this;
  4910. item._attrs.parent = self;
  4911. item._attrs.context = self._attrs.context;
  4912. item._attrs.canvas = self._attrs.canvas;
  4913. var clip = item._attrs.attrs.clip;
  4914. if (clip) {
  4915. clip.set('parent', self);
  4916. clip.set('context', self.get('context'));
  4917. }
  4918. if (item._attrs.isGroup) {
  4919. var children = item._attrs.children;
  4920. for (var i = 0, len = children.length; i < len; i++) {
  4921. item._setEvn(children[i]);
  4922. }
  4923. }
  4924. }
  4925. };
  4926. /***/ }),
  4927. /* 67 */
  4928. /***/ (function(module, exports, __webpack_require__) {
  4929. "use strict";
  4930. var _interopRequireDefault = __webpack_require__(1);
  4931. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  4932. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  4933. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  4934. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  4935. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  4936. var Util = __webpack_require__(0);
  4937. var Element = __webpack_require__(46);
  4938. var Container = __webpack_require__(66);
  4939. var Vector2 = __webpack_require__(13);
  4940. var Group = /*#__PURE__*/function (_Element) {
  4941. (0, _inheritsLoose2["default"])(Group, _Element);
  4942. var _super = _createSuper(Group);
  4943. function Group() {
  4944. return _Element.apply(this, arguments) || this;
  4945. }
  4946. var _proto = Group.prototype;
  4947. _proto._initProperties = function _initProperties() {
  4948. this._attrs = {
  4949. zIndex: 0,
  4950. visible: true,
  4951. destroyed: false,
  4952. isGroup: true,
  4953. children: []
  4954. };
  4955. };
  4956. _proto.drawInner = function drawInner(context) {
  4957. var children = this.get('children');
  4958. for (var i = 0, len = children.length; i < len; i++) {
  4959. var child = children[i];
  4960. child.draw(context);
  4961. }
  4962. return this;
  4963. };
  4964. _proto.getBBox = function getBBox() {
  4965. var self = this;
  4966. var minX = Infinity;
  4967. var maxX = -Infinity;
  4968. var minY = Infinity;
  4969. var maxY = -Infinity;
  4970. var children = self.get('children');
  4971. for (var i = 0, length = children.length; i < length; i++) {
  4972. var child = children[i];
  4973. if (child.get('visible')) {
  4974. var box = child.getBBox();
  4975. if (!box) {
  4976. continue;
  4977. }
  4978. var leftTop = [box.minX, box.minY];
  4979. var leftBottom = [box.minX, box.maxY];
  4980. var rightTop = [box.maxX, box.minY];
  4981. var rightBottom = [box.maxX, box.maxY];
  4982. var matrix = child.attr('matrix');
  4983. Vector2.transformMat2d(leftTop, leftTop, matrix);
  4984. Vector2.transformMat2d(leftBottom, leftBottom, matrix);
  4985. Vector2.transformMat2d(rightTop, rightTop, matrix);
  4986. Vector2.transformMat2d(rightBottom, rightBottom, matrix);
  4987. minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
  4988. maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
  4989. minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
  4990. maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
  4991. }
  4992. }
  4993. return {
  4994. minX: minX,
  4995. minY: minY,
  4996. maxX: maxX,
  4997. maxY: maxY,
  4998. x: minX,
  4999. y: minY,
  5000. width: maxX - minX,
  5001. height: maxY - minY
  5002. };
  5003. };
  5004. _proto.destroy = function destroy() {
  5005. if (this.get('destroyed')) {
  5006. return;
  5007. }
  5008. this.clear();
  5009. _Element.prototype.destroy.call(this);
  5010. };
  5011. return Group;
  5012. }(Element);
  5013. Util.mix(Group.prototype, Container, {
  5014. getGroupClass: function getGroupClass() {
  5015. return Group;
  5016. }
  5017. });
  5018. module.exports = Group;
  5019. /***/ }),
  5020. /* 68 */
  5021. /***/ (function(module, exports, __webpack_require__) {
  5022. "use strict";
  5023. var Util = __webpack_require__(0);
  5024. var Shape = __webpack_require__(19);
  5025. var ShapeUtil = __webpack_require__(38);
  5026. var Global = __webpack_require__(6); // register line geom
  5027. var Line = Shape.registerFactory('line', {
  5028. defaultShapeType: 'line'
  5029. });
  5030. function getStyle(cfg) {
  5031. var style = {
  5032. strokeStyle: cfg.color
  5033. };
  5034. if (cfg.size >= 0) {
  5035. style.lineWidth = cfg.size;
  5036. }
  5037. Util.mix(style, cfg.style);
  5038. return Util.mix({}, Global.shape.line, style);
  5039. }
  5040. function drawLines(cfg, container, style, smooth) {
  5041. var points = cfg.points;
  5042. if (points.length && Util.isArray(points[0].y)) {
  5043. var topPoints = [];
  5044. var bottomPoints = [];
  5045. for (var i = 0, len = points.length; i < len; i++) {
  5046. var point = points[i];
  5047. var tmp = ShapeUtil.splitPoints(point);
  5048. bottomPoints.push(tmp[0]);
  5049. topPoints.push(tmp[1]);
  5050. }
  5051. if (cfg.isInCircle) {
  5052. topPoints.push(topPoints[0]);
  5053. bottomPoints.push(bottomPoints[0]);
  5054. }
  5055. if (cfg.isStack) {
  5056. return container.addShape('Polyline', {
  5057. className: 'line',
  5058. attrs: Util.mix({
  5059. points: topPoints,
  5060. smooth: smooth
  5061. }, style)
  5062. });
  5063. }
  5064. var topShape = container.addShape('Polyline', {
  5065. className: 'line',
  5066. attrs: Util.mix({
  5067. points: topPoints,
  5068. smooth: smooth
  5069. }, style)
  5070. });
  5071. var bottomShape = container.addShape('Polyline', {
  5072. className: 'line',
  5073. attrs: Util.mix({
  5074. points: bottomPoints,
  5075. smooth: smooth
  5076. }, style)
  5077. });
  5078. return [topShape, bottomShape];
  5079. }
  5080. if (cfg.isInCircle) {
  5081. points.push(points[0]);
  5082. }
  5083. return container.addShape('Polyline', {
  5084. className: 'line',
  5085. attrs: Util.mix({
  5086. points: points,
  5087. smooth: smooth
  5088. }, style)
  5089. });
  5090. }
  5091. var SHAPES = ['line', 'smooth', 'dash'];
  5092. Util.each(SHAPES, function (shapeType) {
  5093. Shape.registerShape('line', shapeType, {
  5094. draw: function draw(cfg, container) {
  5095. var smooth = shapeType === 'smooth';
  5096. var style = getStyle(cfg);
  5097. if (shapeType === 'dash') {
  5098. style.lineDash = Global.lineDash;
  5099. }
  5100. return drawLines(cfg, container, style, smooth);
  5101. }
  5102. });
  5103. });
  5104. module.exports = Line;
  5105. /***/ }),
  5106. /* 69 */
  5107. /***/ (function(module, exports, __webpack_require__) {
  5108. function _inheritsLoose(subClass, superClass) {
  5109. subClass.prototype = Object.create(superClass.prototype);
  5110. subClass.prototype.constructor = subClass;
  5111. subClass.__proto__ = superClass;
  5112. }
  5113. var Base = __webpack_require__(26);
  5114. var catAuto = __webpack_require__(65);
  5115. var each = __webpack_require__(15);
  5116. var isNumber = __webpack_require__(36);
  5117. var isString = __webpack_require__(48);
  5118. var Category = /*#__PURE__*/function (_Base) {
  5119. _inheritsLoose(Category, _Base);
  5120. function Category() {
  5121. return _Base.apply(this, arguments) || this;
  5122. }
  5123. var _proto = Category.prototype;
  5124. _proto._initDefaultCfg = function _initDefaultCfg() {
  5125. _Base.prototype._initDefaultCfg.call(this);
  5126. this.type = 'cat';
  5127. /**
  5128. * 是否分类度量
  5129. * @type {Boolean}
  5130. */
  5131. this.isCategory = true;
  5132. this.isRounding = true; // 是否进行取整操作
  5133. }
  5134. /**
  5135. * @override
  5136. */
  5137. ;
  5138. _proto.init = function init() {
  5139. var self = this;
  5140. var values = self.values;
  5141. var tickCount = self.tickCount;
  5142. each(values, function (v, i) {
  5143. values[i] = v.toString();
  5144. });
  5145. if (!self.ticks) {
  5146. var ticks = values;
  5147. if (tickCount) {
  5148. var temp = catAuto({
  5149. maxCount: tickCount,
  5150. data: values,
  5151. isRounding: self.isRounding
  5152. });
  5153. ticks = temp.ticks;
  5154. }
  5155. this.ticks = ticks;
  5156. }
  5157. }
  5158. /**
  5159. * @override
  5160. */
  5161. ;
  5162. _proto.getText = function getText(value) {
  5163. if (this.values.indexOf(value) === -1 && isNumber(value)) {
  5164. value = this.values[Math.round(value)];
  5165. }
  5166. return _Base.prototype.getText.call(this, value);
  5167. }
  5168. /**
  5169. * @override
  5170. */
  5171. ;
  5172. _proto.translate = function translate(value) {
  5173. var index = this.values.indexOf(value);
  5174. if (index === -1 && isNumber(value)) {
  5175. index = value;
  5176. } else if (index === -1) {
  5177. index = NaN;
  5178. }
  5179. return index;
  5180. }
  5181. /**
  5182. * @override
  5183. */
  5184. ;
  5185. _proto.scale = function scale(value) {
  5186. var rangeMin = this.rangeMin();
  5187. var rangeMax = this.rangeMax();
  5188. var percent;
  5189. if (isString(value) || this.values.indexOf(value) !== -1) {
  5190. value = this.translate(value);
  5191. }
  5192. if (this.values.length > 1) {
  5193. percent = value / (this.values.length - 1);
  5194. } else {
  5195. percent = value;
  5196. }
  5197. return rangeMin + percent * (rangeMax - rangeMin);
  5198. }
  5199. /**
  5200. * @override
  5201. */
  5202. ;
  5203. _proto.invert = function invert(value) {
  5204. if (isString(value)) {
  5205. // 如果已经是字符串
  5206. return value;
  5207. }
  5208. var min = this.rangeMin();
  5209. var max = this.rangeMax(); // 归一到 范围内
  5210. if (value < min) {
  5211. value = min;
  5212. }
  5213. if (value > max) {
  5214. value = max;
  5215. }
  5216. var percent = (value - min) / (max - min);
  5217. var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
  5218. index = index || 0;
  5219. return this.values[index];
  5220. };
  5221. return Category;
  5222. }(Base);
  5223. Base.Cat = Category;
  5224. module.exports = Category;
  5225. /***/ }),
  5226. /* 70 */
  5227. /***/ (function(module, exports, __webpack_require__) {
  5228. "use strict";
  5229. module.exports = {
  5230. requestAnimationFrame: typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
  5231. return setTimeout(fn, 16);
  5232. }
  5233. };
  5234. /***/ }),
  5235. /* 71 */
  5236. /***/ (function(module, exports, __webpack_require__) {
  5237. "use strict";
  5238. /**
  5239. * @fileOverview convert the line to curve
  5240. * @author dxq613@gmail.com
  5241. */
  5242. var Vector2 = __webpack_require__(13);
  5243. function getPoint(v) {
  5244. return [v.x, v.y];
  5245. }
  5246. function smoothBezier(points, smooth, isLoop, constraint) {
  5247. var cps = [];
  5248. var prevPoint;
  5249. var nextPoint;
  5250. var hasConstraint = !!constraint;
  5251. var min;
  5252. var max;
  5253. var point;
  5254. var len;
  5255. var l;
  5256. var i;
  5257. if (hasConstraint) {
  5258. min = [Infinity, Infinity];
  5259. max = [-Infinity, -Infinity];
  5260. for (i = 0, l = points.length; i < l; i++) {
  5261. point = getPoint(points[i]);
  5262. Vector2.min(min, min, point);
  5263. Vector2.max(max, max, point);
  5264. }
  5265. Vector2.min(min, min, constraint[0]);
  5266. Vector2.max(max, max, constraint[1]);
  5267. }
  5268. for (i = 0, len = points.length; i < len; i++) {
  5269. point = getPoint(points[i]);
  5270. if (isLoop) {
  5271. prevPoint = getPoint(points[i ? i - 1 : len - 1]);
  5272. nextPoint = getPoint(points[(i + 1) % len]);
  5273. } else {
  5274. if (i === 0 || i === len - 1) {
  5275. cps.push([point[0], point[1]]);
  5276. continue;
  5277. } else {
  5278. prevPoint = getPoint(points[i - 1]);
  5279. nextPoint = getPoint(points[i + 1]);
  5280. }
  5281. }
  5282. var v = Vector2.sub([], nextPoint, prevPoint);
  5283. Vector2.scale(v, v, smooth);
  5284. var d0 = Vector2.distance(point, prevPoint);
  5285. var d1 = Vector2.distance(point, nextPoint);
  5286. var sum = d0 + d1;
  5287. if (sum !== 0) {
  5288. d0 /= sum;
  5289. d1 /= sum;
  5290. }
  5291. var v1 = Vector2.scale([], v, -d0);
  5292. var v2 = Vector2.scale([], v, d1);
  5293. var cp0 = Vector2.add([], point, v1);
  5294. var cp1 = Vector2.add([], point, v2);
  5295. if (hasConstraint) {
  5296. Vector2.max(cp0, cp0, min);
  5297. Vector2.min(cp0, cp0, max);
  5298. Vector2.max(cp1, cp1, min);
  5299. Vector2.min(cp1, cp1, max);
  5300. }
  5301. cps.push([cp0[0], cp0[1]]);
  5302. cps.push([cp1[0], cp1[1]]);
  5303. }
  5304. if (isLoop) {
  5305. cps.push(cps.shift());
  5306. }
  5307. return cps;
  5308. }
  5309. function catmullRom2bezier(pointList, z, constraint) {
  5310. var isLoop = !!z;
  5311. var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
  5312. var len = pointList.length;
  5313. var d1 = [];
  5314. var cp1;
  5315. var cp2;
  5316. var p;
  5317. for (var i = 0; i < len - 1; i++) {
  5318. cp1 = controlPointList[i * 2];
  5319. cp2 = controlPointList[i * 2 + 1];
  5320. p = pointList[i + 1];
  5321. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  5322. }
  5323. if (isLoop) {
  5324. cp1 = controlPointList[len];
  5325. cp2 = controlPointList[len + 1];
  5326. p = pointList[0];
  5327. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  5328. }
  5329. return d1;
  5330. }
  5331. module.exports = {
  5332. smooth: catmullRom2bezier
  5333. };
  5334. /***/ }),
  5335. /* 72 */
  5336. /***/ (function(module, exports, __webpack_require__) {
  5337. "use strict";
  5338. var _interopRequireDefault = __webpack_require__(1);
  5339. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  5340. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  5341. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  5342. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  5343. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5344. var Geom = __webpack_require__(17);
  5345. var ShapeUtil = __webpack_require__(38);
  5346. var Util = __webpack_require__(0);
  5347. __webpack_require__(68);
  5348. var Path = /*#__PURE__*/function (_Geom) {
  5349. (0, _inheritsLoose2["default"])(Path, _Geom);
  5350. var _super = _createSuper(Path);
  5351. function Path() {
  5352. return _Geom.apply(this, arguments) || this;
  5353. }
  5354. var _proto = Path.prototype;
  5355. _proto.getDefaultCfg = function getDefaultCfg() {
  5356. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  5357. cfg.type = 'path';
  5358. cfg.shapeType = 'line';
  5359. return cfg;
  5360. };
  5361. _proto.getDrawCfg = function getDrawCfg(obj) {
  5362. var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
  5363. cfg.isStack = this.hasAdjust('stack');
  5364. return cfg;
  5365. };
  5366. _proto.draw = function draw(data, shapeFactory) {
  5367. var self = this;
  5368. var container = self.get('container');
  5369. var yScale = self.getYScale();
  5370. var connectNulls = self.get('connectNulls');
  5371. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  5372. var cfg = this.getDrawCfg(data[0]);
  5373. cfg.origin = data;
  5374. Util.each(splitArray, function (subData, splitedIndex) {
  5375. cfg.splitedIndex = splitedIndex;
  5376. cfg.points = subData;
  5377. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  5378. });
  5379. };
  5380. return Path;
  5381. }(Geom);
  5382. Geom.Path = Path;
  5383. module.exports = Path;
  5384. /***/ }),
  5385. /* 73 */
  5386. /***/ (function(module, exports, __webpack_require__) {
  5387. "use strict";
  5388. var _const = __webpack_require__(47);
  5389. /**
  5390. * @fileOverview Utility for calculate the with ratui in x axis
  5391. * @author sima.zhang1990@gmail.com
  5392. * @author dxq613@gmail.com
  5393. */
  5394. var Global = __webpack_require__(6);
  5395. var Util = __webpack_require__(0);
  5396. var SizeMixin = {
  5397. initEvent: function initEvent() {
  5398. var _this = this;
  5399. var chart = this.get('chart');
  5400. if (!chart) {
  5401. return;
  5402. }
  5403. chart.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
  5404. _this.set('_width', null);
  5405. });
  5406. },
  5407. getDefalutSize: function getDefalutSize() {
  5408. var defaultSize = this.get('defaultSize');
  5409. if (!defaultSize) {
  5410. var coord = this.get('coord');
  5411. var xScale = this.getXScale();
  5412. var dataArray = this.get('dataArray');
  5413. var values = Util.uniq(xScale.values);
  5414. var count = values.length;
  5415. var range = xScale.range;
  5416. var normalizeSize = 1 / count;
  5417. var widthRatio = 1;
  5418. if (coord && coord.isPolar) {
  5419. if (coord.transposed && count > 1) {
  5420. widthRatio = Global.widthRatio.multiplePie;
  5421. } else {
  5422. widthRatio = Global.widthRatio.rose;
  5423. }
  5424. } else {
  5425. if (xScale.isLinear) {
  5426. normalizeSize *= range[1] - range[0];
  5427. }
  5428. widthRatio = Global.widthRatio.column;
  5429. }
  5430. normalizeSize *= widthRatio;
  5431. if (this.hasAdjust('dodge')) {
  5432. normalizeSize = normalizeSize / dataArray.length;
  5433. }
  5434. defaultSize = normalizeSize;
  5435. this.set('defaultSize', defaultSize);
  5436. }
  5437. return defaultSize;
  5438. },
  5439. getDimWidth: function getDimWidth(dimName) {
  5440. var coord = this.get('coord');
  5441. var start = coord.convertPoint({
  5442. x: 0,
  5443. y: 0
  5444. });
  5445. var end = coord.convertPoint({
  5446. x: dimName === 'x' ? 1 : 0,
  5447. y: dimName === 'x' ? 0 : 1
  5448. });
  5449. var width = 0;
  5450. if (start && end) {
  5451. width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
  5452. }
  5453. return width;
  5454. },
  5455. _getWidth: function _getWidth() {
  5456. var width = this.get('_width');
  5457. if (!width) {
  5458. var coord = this.get('coord');
  5459. if (coord && coord.isPolar && !coord.transposed) {
  5460. width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
  5461. } else {
  5462. width = this.getDimWidth('x');
  5463. }
  5464. this.set('_width', width);
  5465. }
  5466. return width;
  5467. },
  5468. _toNormalizedSize: function _toNormalizedSize(size) {
  5469. var width = this._getWidth();
  5470. return size / width;
  5471. },
  5472. _toCoordSize: function _toCoordSize(normalizeSize) {
  5473. var width = this._getWidth();
  5474. return width * normalizeSize;
  5475. },
  5476. getNormalizedSize: function getNormalizedSize(obj) {
  5477. var size = this.getAttrValue('size', obj);
  5478. if (Util.isNil(size)) {
  5479. size = this.getDefalutSize();
  5480. } else {
  5481. size = this._toNormalizedSize(size);
  5482. }
  5483. return size;
  5484. },
  5485. getSize: function getSize(obj) {
  5486. var size = this.getAttrValue('size', obj);
  5487. if (Util.isNil(size)) {
  5488. var normalizeSize = this.getDefalutSize();
  5489. size = this._toCoordSize(normalizeSize);
  5490. }
  5491. return size;
  5492. }
  5493. };
  5494. module.exports = SizeMixin;
  5495. /***/ }),
  5496. /* 74 */
  5497. /***/ (function(module, exports, __webpack_require__) {
  5498. "use strict";
  5499. __webpack_require__(241);
  5500. /**
  5501. * The parent class of interaction
  5502. * @author sima.zhang1990@gmail.com
  5503. */
  5504. var Util = __webpack_require__(0);
  5505. var Hammer;
  5506. if (!Util.isWx && !Util.isMy) {
  5507. Hammer = __webpack_require__(259);
  5508. }
  5509. var TOUCH_EVENTS = ['touchstart', 'touchmove', 'touchend'];
  5510. var Interaction = /*#__PURE__*/function () {
  5511. var _proto = Interaction.prototype;
  5512. _proto.getDefaultCfg = function getDefaultCfg() {
  5513. return {
  5514. startEvent: TOUCH_EVENTS[0],
  5515. processEvent: TOUCH_EVENTS[1],
  5516. endEvent: TOUCH_EVENTS[2],
  5517. resetEvent: null
  5518. };
  5519. };
  5520. // override
  5521. _proto.start = function start() {} // override
  5522. ;
  5523. _proto.process = function process() {} // override
  5524. ;
  5525. _proto.end = function end() {} // override
  5526. ;
  5527. _proto.reset = function reset() {};
  5528. function Interaction(cfg, chart) {
  5529. var _this = this;
  5530. this._start = function (ev) {
  5531. _this.preStart && _this.preStart(ev);
  5532. _this.start(ev);
  5533. _this.onStart && _this.onStart(ev);
  5534. };
  5535. this._process = function (ev) {
  5536. _this.preProcess && _this.preProcess(ev);
  5537. _this.process(ev);
  5538. _this.onProcess && _this.onProcess(ev);
  5539. };
  5540. this._end = function (ev) {
  5541. _this.preEnd && _this.preEnd(ev);
  5542. _this.end(ev);
  5543. _this.onEnd && _this.onEnd(ev);
  5544. };
  5545. this._reset = function (ev) {
  5546. _this.preReset && _this.preReset(ev);
  5547. _this.reset(ev);
  5548. _this.onReset && _this.onReset(ev);
  5549. };
  5550. var defaultCfg = this.getDefaultCfg();
  5551. Util.deepMix(this, defaultCfg, cfg);
  5552. this.chart = chart;
  5553. this.canvas = chart.get('canvas');
  5554. this.el = chart.get('canvas').get('el');
  5555. this._bindEvents();
  5556. }
  5557. _proto._bindEvents = function _bindEvents() {
  5558. this._clearEvents(); // clear events
  5559. var startEvent = this.startEvent,
  5560. processEvent = this.processEvent,
  5561. endEvent = this.endEvent,
  5562. resetEvent = this.resetEvent,
  5563. el = this.el;
  5564. if (Hammer) {
  5565. this.hammer = new Hammer(el);
  5566. }
  5567. this._bindEvent(startEvent, this._start);
  5568. this._bindEvent(processEvent, this._process);
  5569. this._bindEvent(endEvent, this._end);
  5570. this._bindEvent(resetEvent, this._reset);
  5571. };
  5572. _proto._clearEvents = function _clearEvents() {
  5573. var startEvent = this.startEvent,
  5574. processEvent = this.processEvent,
  5575. endEvent = this.endEvent,
  5576. resetEvent = this.resetEvent;
  5577. if (this.hammer) {
  5578. this.hammer.destroy();
  5579. this.hammer = null;
  5580. }
  5581. this._clearTouchEvent(startEvent, this._start);
  5582. this._clearTouchEvent(processEvent, this._process);
  5583. this._clearTouchEvent(endEvent, this._end);
  5584. this._clearTouchEvent(resetEvent, this._reset);
  5585. };
  5586. _proto._bindEvent = function _bindEvent(eventName, method) {
  5587. var el = this.el;
  5588. if (eventName) {
  5589. if (TOUCH_EVENTS.indexOf(eventName) !== -1) {
  5590. Util.addEventListener(el, eventName, method);
  5591. } else if (this.hammer) {
  5592. this.hammer.on(eventName, method);
  5593. }
  5594. }
  5595. };
  5596. _proto._clearTouchEvent = function _clearTouchEvent(eventName, method) {
  5597. var el = this.el;
  5598. if (eventName && TOUCH_EVENTS.indexOf(eventName) !== -1) {
  5599. Util.removeEventListener(el, eventName, method);
  5600. }
  5601. };
  5602. _proto.destroy = function destroy() {
  5603. this._clearEvents();
  5604. };
  5605. return Interaction;
  5606. }();
  5607. module.exports = Interaction;
  5608. /***/ }),
  5609. /* 75 */
  5610. /***/ (function(module, exports, __webpack_require__) {
  5611. "use strict";
  5612. exports.__esModule = true;
  5613. exports.merge = merge;
  5614. exports.values = values;
  5615. exports.firstValue = firstValue;
  5616. exports.group = group;
  5617. exports.groupToMap = groupToMap;
  5618. exports.remove = remove;
  5619. exports.getRange = getRange;
  5620. var _util = __webpack_require__(20);
  5621. function merge(dataArray) {
  5622. var rst = [];
  5623. for (var i = 0, len = dataArray.length; i < len; i++) {
  5624. rst = rst.concat(dataArray[i]);
  5625. }
  5626. return rst;
  5627. }
  5628. function values(data, name) {
  5629. var rst = [];
  5630. var tmpMap = {};
  5631. for (var i = 0, len = data.length; i < len; i++) {
  5632. var obj = data[i];
  5633. var value = obj[name];
  5634. if (!(0, _util.isNil)(value)) {
  5635. if (!(0, _util.isArray)(value)) {
  5636. if (!tmpMap[value]) {
  5637. rst.push(value);
  5638. tmpMap[value] = true;
  5639. }
  5640. } else {
  5641. (0, _util.each)(value, function (val) {
  5642. if (!tmpMap[val]) {
  5643. rst.push(val);
  5644. tmpMap[val] = true;
  5645. }
  5646. });
  5647. }
  5648. }
  5649. }
  5650. return rst;
  5651. }
  5652. function firstValue(data, name) {
  5653. var rst = null;
  5654. for (var i = 0, len = data.length; i < len; i++) {
  5655. var obj = data[i];
  5656. var value = obj[name];
  5657. if (!(0, _util.isNil)(value)) {
  5658. if ((0, _util.isArray)(value)) {
  5659. rst = value[0];
  5660. } else {
  5661. rst = value;
  5662. }
  5663. break;
  5664. }
  5665. }
  5666. return rst;
  5667. }
  5668. function groupToMap(data, fields) {
  5669. if (!fields) {
  5670. return {
  5671. 0: data
  5672. };
  5673. }
  5674. var callback = function callback(row) {
  5675. var unique = '_';
  5676. for (var i = 0, l = fields.length; i < l; i++) {
  5677. unique += row[fields[i]] && row[fields[i]].toString();
  5678. }
  5679. return unique;
  5680. };
  5681. var groups = {};
  5682. for (var i = 0, len = data.length; i < len; i++) {
  5683. var row = data[i];
  5684. var key = callback(row);
  5685. if (groups[key]) {
  5686. groups[key].push(row);
  5687. } else {
  5688. groups[key] = [row];
  5689. }
  5690. }
  5691. return groups;
  5692. }
  5693. function group(data, fields, appendConditions) {
  5694. if (appendConditions === void 0) {
  5695. appendConditions = {};
  5696. }
  5697. if (!fields) {
  5698. return [data];
  5699. }
  5700. var groups = groupToMap(data, fields);
  5701. var array = [];
  5702. if (fields.length === 1 && appendConditions[fields[0]]) {
  5703. var _values = appendConditions[fields[0]];
  5704. (0, _util.each)(_values, function (value) {
  5705. value = '_' + value;
  5706. array.push(groups[value]);
  5707. });
  5708. } else {
  5709. for (var i in groups) {
  5710. array.push(groups[i]);
  5711. }
  5712. }
  5713. return array;
  5714. }
  5715. function remove(arr, obj) {
  5716. if (!arr) {
  5717. return;
  5718. }
  5719. var index = arr.indexOf(obj);
  5720. if (index !== -1) {
  5721. arr.splice(index, 1);
  5722. }
  5723. }
  5724. function getRange(values) {
  5725. if (!values.length) {
  5726. return {
  5727. min: 0,
  5728. max: 0
  5729. };
  5730. }
  5731. var max = Math.max.apply(null, values);
  5732. var min = Math.min.apply(null, values);
  5733. return {
  5734. min: min,
  5735. max: max
  5736. };
  5737. }
  5738. /***/ }),
  5739. /* 76 */
  5740. /***/ (function(module, exports, __webpack_require__) {
  5741. "use strict";
  5742. var _interopRequireDefault = __webpack_require__(1);
  5743. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  5744. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  5745. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  5746. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  5747. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5748. /**
  5749. * marker shapes,used for tooltip and legend
  5750. */
  5751. var Util = __webpack_require__(0);
  5752. var _require = __webpack_require__(16),
  5753. Shape = _require.Shape;
  5754. var SYMBOLS = {
  5755. circle: function circle(x, y, r, ctx) {
  5756. ctx.arc(x, y, r, 0, Math.PI * 2, false);
  5757. },
  5758. square: function square(x, y, r, ctx) {
  5759. ctx.moveTo(x - r, y - r);
  5760. ctx.lineTo(x + r, y - r);
  5761. ctx.lineTo(x + r, y + r);
  5762. ctx.lineTo(x - r, y + r);
  5763. ctx.closePath();
  5764. }
  5765. };
  5766. var Marker = /*#__PURE__*/function (_Shape) {
  5767. (0, _inheritsLoose2["default"])(Marker, _Shape);
  5768. var _super = _createSuper(Marker);
  5769. function Marker() {
  5770. return _Shape.apply(this, arguments) || this;
  5771. }
  5772. var _proto = Marker.prototype;
  5773. _proto._initProperties = function _initProperties() {
  5774. _Shape.prototype._initProperties.call(this);
  5775. this._attrs.canFill = true;
  5776. this._attrs.canStroke = true;
  5777. this._attrs.type = 'marker';
  5778. };
  5779. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5780. return {
  5781. x: 0,
  5782. y: 0,
  5783. lineWidth: 0
  5784. };
  5785. };
  5786. _proto.createPath = function createPath(context) {
  5787. var attrs = this.get('attrs');
  5788. var x = attrs.x,
  5789. y = attrs.y,
  5790. radius = attrs.radius;
  5791. var symbol = attrs.symbol || 'circle';
  5792. var method;
  5793. if (Util.isFunction(symbol)) {
  5794. method = symbol;
  5795. } else {
  5796. method = SYMBOLS[symbol];
  5797. }
  5798. context.beginPath();
  5799. method(x, y, radius, context, this);
  5800. };
  5801. _proto.calculateBox = function calculateBox() {
  5802. var attrs = this.get('attrs');
  5803. var x = attrs.x,
  5804. y = attrs.y,
  5805. radius = attrs.radius;
  5806. return {
  5807. minX: x - radius,
  5808. minY: y - radius,
  5809. maxX: x + radius,
  5810. maxY: y + radius
  5811. };
  5812. };
  5813. return Marker;
  5814. }(Shape);
  5815. module.exports = Marker;
  5816. /***/ }),
  5817. /* 77 */
  5818. /***/ (function(module, exports, __webpack_require__) {
  5819. "use strict";
  5820. var Core = {};
  5821. var Global = __webpack_require__(6);
  5822. Core.Global = Global;
  5823. Core.version = Global.version;
  5824. Core.Chart = __webpack_require__(30);
  5825. Core.Shape = __webpack_require__(19);
  5826. Core.G = __webpack_require__(16);
  5827. Core.Util = __webpack_require__(0);
  5828. Core.Helper = __webpack_require__(37); // Core.track = function(enable) {
  5829. // Global.trackable = enable;
  5830. // };
  5831. // require('./track');
  5832. // 2018-12-27 关闭打点
  5833. Core.track = function () {
  5834. return null;
  5835. };
  5836. module.exports = Core;
  5837. /***/ }),
  5838. /* 78 */
  5839. /***/ (function(module, exports, __webpack_require__) {
  5840. "use strict";
  5841. /**
  5842. * @fileOverview default theme
  5843. * @author dxq613@gail.com
  5844. */
  5845. var Util = __webpack_require__(0);
  5846. var color1 = '#E8E8E8'; // color of axis-line and axis-grid
  5847. var color2 = '#808080'; // color of axis label
  5848. var defaultAxis = {
  5849. label: {
  5850. fill: color2,
  5851. fontSize: 10
  5852. },
  5853. line: {
  5854. stroke: color1,
  5855. lineWidth: 1
  5856. },
  5857. grid: {
  5858. type: 'line',
  5859. stroke: color1,
  5860. lineWidth: 1,
  5861. lineDash: [2]
  5862. },
  5863. tickLine: null,
  5864. labelOffset: 7.5
  5865. };
  5866. var Theme = {
  5867. fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
  5868. defaultColor: '#1890FF',
  5869. pixelRatio: 1,
  5870. padding: 'auto',
  5871. appendPadding: 15,
  5872. colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
  5873. shapes: {
  5874. line: ['line', 'dash'],
  5875. point: ['circle', 'hollowCircle']
  5876. },
  5877. sizes: [4, 10],
  5878. axis: {
  5879. common: defaultAxis,
  5880. // common axis configuration
  5881. bottom: Util.mix({}, defaultAxis, {
  5882. grid: null
  5883. }),
  5884. left: Util.mix({}, defaultAxis, {
  5885. line: null
  5886. }),
  5887. right: Util.mix({}, defaultAxis, {
  5888. line: null
  5889. }),
  5890. circle: Util.mix({}, defaultAxis, {
  5891. line: null
  5892. }),
  5893. radius: Util.mix({}, defaultAxis, {
  5894. labelOffset: 4
  5895. })
  5896. },
  5897. shape: {
  5898. line: {
  5899. lineWidth: 2,
  5900. lineJoin: 'round',
  5901. lineCap: 'round'
  5902. },
  5903. point: {
  5904. lineWidth: 0,
  5905. size: 3
  5906. },
  5907. area: {
  5908. fillOpacity: 0.1
  5909. }
  5910. },
  5911. _defaultAxis: defaultAxis
  5912. };
  5913. module.exports = Theme;
  5914. /***/ }),
  5915. /* 79 */
  5916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5917. "use strict";
  5918. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__filter__ = __webpack_require__(39);
  5919. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__contains__ = __webpack_require__(28);
  5920. /**
  5921. * Flattens `array` a single level deep.
  5922. *
  5923. * @param {Array} arr The array to inspect.
  5924. * @param {Array} values The values to exclude.
  5925. * @return {Array} Returns the new array of filtered values.
  5926. * @example
  5927. * difference([2, 1], [2, 3]); // => [1]
  5928. */
  5929. var difference = function (arr, values) {
  5930. if (values === void 0) {
  5931. values = [];
  5932. }
  5933. return Object(__WEBPACK_IMPORTED_MODULE_0__filter__["a" /* default */])(arr, function (value) {
  5934. return !Object(__WEBPACK_IMPORTED_MODULE_1__contains__["a" /* default */])(values, value);
  5935. });
  5936. };
  5937. /* harmony default export */ __webpack_exports__["a"] = (difference);
  5938. /***/ }),
  5939. /* 80 */
  5940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5941. "use strict";
  5942. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
  5943. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_match__ = __webpack_require__(51);
  5944. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_array__ = __webpack_require__(5);
  5945. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__is_plain_object__ = __webpack_require__(24);
  5946. function find(arr, predicate) {
  5947. if (!Object(__WEBPACK_IMPORTED_MODULE_2__is_array__["a" /* default */])(arr)) return null;
  5948. var _predicate;
  5949. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(predicate)) {
  5950. _predicate = predicate;
  5951. }
  5952. if (Object(__WEBPACK_IMPORTED_MODULE_3__is_plain_object__["a" /* default */])(predicate)) {
  5953. _predicate = function (a) {
  5954. return Object(__WEBPACK_IMPORTED_MODULE_1__is_match__["a" /* default */])(a, predicate);
  5955. };
  5956. }
  5957. if (_predicate) {
  5958. for (var i = 0; i < arr.length; i += 1) {
  5959. if (_predicate(arr[i])) {
  5960. return arr[i];
  5961. }
  5962. }
  5963. }
  5964. return null;
  5965. }
  5966. /* harmony default export */ __webpack_exports__["a"] = (find);
  5967. /***/ }),
  5968. /* 81 */
  5969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5970. "use strict";
  5971. function findIndex(arr, predicate, fromIndex) {
  5972. if (fromIndex === void 0) {
  5973. fromIndex = 0;
  5974. }
  5975. for (var i = fromIndex; i < arr.length; i++) {
  5976. if (predicate(arr[i], i)) {
  5977. // 找到终止循环
  5978. return i;
  5979. }
  5980. }
  5981. return -1;
  5982. }
  5983. /* harmony default export */ __webpack_exports__["a"] = (findIndex);
  5984. /***/ }),
  5985. /* 82 */
  5986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5987. "use strict";
  5988. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  5989. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  5990. var firstValue = function (data, name) {
  5991. var rst = null;
  5992. for (var i = 0; i < data.length; i++) {
  5993. var obj = data[i];
  5994. var value = obj[name];
  5995. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) {
  5996. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(value)) {
  5997. rst = value[0]; // todo 这里是否应该使用递归,调用 firstValue @绝云
  5998. } else {
  5999. rst = value;
  6000. }
  6001. break;
  6002. }
  6003. }
  6004. return rst;
  6005. };
  6006. /* harmony default export */ __webpack_exports__["a"] = (firstValue);
  6007. /***/ }),
  6008. /* 83 */
  6009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6010. "use strict";
  6011. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6012. /**
  6013. * Flattens `array` a single level deep.
  6014. *
  6015. * @param {Array} arr The array to flatten.
  6016. * @return {Array} Returns the new flattened array.
  6017. * @example
  6018. *
  6019. * flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
  6020. */
  6021. var flatten = function (arr) {
  6022. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr)) {
  6023. return [];
  6024. }
  6025. var rst = [];
  6026. for (var i = 0; i < arr.length; i++) {
  6027. rst = rst.concat(arr[i]);
  6028. }
  6029. return rst;
  6030. };
  6031. /* harmony default export */ __webpack_exports__["a"] = (flatten);
  6032. /***/ }),
  6033. /* 84 */
  6034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6035. "use strict";
  6036. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6037. /**
  6038. * Flattens `array` a single level deep.
  6039. *
  6040. * @param {Array} arr The array to flatten.
  6041. * @param {Array} result The array to return.
  6042. * @return {Array} Returns the new flattened array.
  6043. * @example
  6044. *
  6045. * flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
  6046. */
  6047. var flattenDeep = function (arr, result) {
  6048. if (result === void 0) {
  6049. result = [];
  6050. }
  6051. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr)) {
  6052. result.push(arr);
  6053. } else {
  6054. for (var i = 0; i < arr.length; i += 1) {
  6055. flattenDeep(arr[i], result);
  6056. }
  6057. }
  6058. return result;
  6059. };
  6060. /* harmony default export */ __webpack_exports__["a"] = (flattenDeep);
  6061. /***/ }),
  6062. /* 85 */
  6063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6064. "use strict";
  6065. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6066. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__filter__ = __webpack_require__(39);
  6067. var getRange = function (values) {
  6068. // 存在 NaN 时,min,max 判定会出问题
  6069. values = Object(__WEBPACK_IMPORTED_MODULE_1__filter__["a" /* default */])(values, function (v) {
  6070. return !isNaN(v);
  6071. });
  6072. if (!values.length) {
  6073. // 如果没有数值则直接返回0
  6074. return {
  6075. min: 0,
  6076. max: 0
  6077. };
  6078. }
  6079. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(values[0])) {
  6080. var tmp = [];
  6081. for (var i = 0; i < values.length; i++) {
  6082. tmp = tmp.concat(values[i]);
  6083. }
  6084. values = tmp;
  6085. }
  6086. var max = Math.max.apply(null, values);
  6087. var min = Math.min.apply(null, values);
  6088. return {
  6089. min: min,
  6090. max: max
  6091. };
  6092. };
  6093. /* harmony default export */ __webpack_exports__["a"] = (getRange);
  6094. /***/ }),
  6095. /* 86 */
  6096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6097. "use strict";
  6098. var arrPrototype = Array.prototype;
  6099. var splice = arrPrototype.splice;
  6100. var indexOf = arrPrototype.indexOf;
  6101. var pull = function (arr) {
  6102. var values = [];
  6103. for (var _i = 1; _i < arguments.length; _i++) {
  6104. values[_i - 1] = arguments[_i];
  6105. }
  6106. for (var i = 0; i < values.length; i++) {
  6107. var value = values[i];
  6108. var fromIndex = -1;
  6109. while ((fromIndex = indexOf.call(arr, value)) > -1) {
  6110. splice.call(arr, fromIndex, 1);
  6111. }
  6112. }
  6113. return arr;
  6114. };
  6115. /* harmony default export */ __webpack_exports__["a"] = (pull);
  6116. /***/ }),
  6117. /* 87 */
  6118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6119. "use strict";
  6120. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  6121. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  6122. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_plain_object__ = __webpack_require__(24);
  6123. var reduce = function (arr, fn, init) {
  6124. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr) && !Object(__WEBPACK_IMPORTED_MODULE_2__is_plain_object__["a" /* default */])(arr)) {
  6125. return arr;
  6126. }
  6127. var result = init;
  6128. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (data, i) {
  6129. result = fn(result, data, i);
  6130. });
  6131. return result;
  6132. };
  6133. /* harmony default export */ __webpack_exports__["a"] = (reduce);
  6134. /***/ }),
  6135. /* 88 */
  6136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6137. "use strict";
  6138. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  6139. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__pull_at__ = __webpack_require__(53);
  6140. var remove = function (arr, predicate) {
  6141. /**
  6142. * const arr = [1, 2, 3, 4]
  6143. * const evens = remove(arr, n => n % 2 == 0)
  6144. * console.log(arr) // => [1, 3]
  6145. * console.log(evens) // => [2, 4]
  6146. */
  6147. var result = [];
  6148. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
  6149. return result;
  6150. }
  6151. var i = -1;
  6152. var indexes = [];
  6153. var length = arr.length;
  6154. while (++i < length) {
  6155. var value = arr[i];
  6156. if (predicate(value, i, arr)) {
  6157. result.push(value);
  6158. indexes.push(i);
  6159. }
  6160. }
  6161. Object(__WEBPACK_IMPORTED_MODULE_1__pull_at__["a" /* default */])(arr, indexes);
  6162. return result;
  6163. };
  6164. /* harmony default export */ __webpack_exports__["a"] = (remove);
  6165. /***/ }),
  6166. /* 89 */
  6167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6168. "use strict";
  6169. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6170. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
  6171. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
  6172. function sortBy(arr, key) {
  6173. var comparer;
  6174. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(key)) {
  6175. comparer = function (a, b) {
  6176. return key(a) - key(b);
  6177. };
  6178. } else {
  6179. var keys_1 = [];
  6180. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(key)) {
  6181. keys_1.push(key);
  6182. } else if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(key)) {
  6183. keys_1 = key;
  6184. }
  6185. comparer = function (a, b) {
  6186. for (var i = 0; i < keys_1.length; i += 1) {
  6187. var prop = keys_1[i];
  6188. if (a[prop] > b[prop]) {
  6189. return 1;
  6190. }
  6191. if (a[prop] < b[prop]) {
  6192. return -1;
  6193. }
  6194. }
  6195. return 0;
  6196. };
  6197. }
  6198. arr.sort(comparer);
  6199. return arr;
  6200. }
  6201. /* harmony default export */ __webpack_exports__["a"] = (sortBy);
  6202. /***/ }),
  6203. /* 90 */
  6204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6205. "use strict";
  6206. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__uniq__ = __webpack_require__(54);
  6207. var union = function () {
  6208. var sources = [];
  6209. for (var _i = 0; _i < arguments.length; _i++) {
  6210. sources[_i] = arguments[_i];
  6211. }
  6212. return Object(__WEBPACK_IMPORTED_MODULE_0__uniq__["a" /* default */])([].concat.apply([], sources));
  6213. };
  6214. /* harmony default export */ __webpack_exports__["a"] = (union);
  6215. /***/ }),
  6216. /* 91 */
  6217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6218. "use strict";
  6219. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  6220. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  6221. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_nil__ = __webpack_require__(14);
  6222. /* harmony default export */ __webpack_exports__["a"] = (function (data, name) {
  6223. var rst = [];
  6224. var tmpMap = {};
  6225. data.forEach(function (obj) {
  6226. var value = obj[name];
  6227. if (!Object(__WEBPACK_IMPORTED_MODULE_2__is_nil__["a" /* default */])(value)) {
  6228. // flatten
  6229. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(value)) {
  6230. value = [value];
  6231. }
  6232. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(value, function (val) {
  6233. // unique
  6234. if (!tmpMap[val]) {
  6235. rst.push(val);
  6236. tmpMap[val] = true;
  6237. }
  6238. });
  6239. }
  6240. });
  6241. return rst;
  6242. });
  6243. /***/ }),
  6244. /* 92 */
  6245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6246. "use strict";
  6247. /* harmony export (immutable) */ __webpack_exports__["a"] = head;
  6248. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  6249. function head(o) {
  6250. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(o)) {
  6251. return o[0];
  6252. }
  6253. return undefined;
  6254. }
  6255. /***/ }),
  6256. /* 93 */
  6257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6258. "use strict";
  6259. /* harmony export (immutable) */ __webpack_exports__["a"] = last;
  6260. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  6261. function last(o) {
  6262. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(o)) {
  6263. var arr = o;
  6264. return arr[arr.length - 1];
  6265. }
  6266. return undefined;
  6267. }
  6268. /***/ }),
  6269. /* 94 */
  6270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6271. "use strict";
  6272. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6273. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
  6274. function startsWith(arr, e) {
  6275. return Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr) || Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(arr) ? arr[0] === e : false;
  6276. }
  6277. /* harmony default export */ __webpack_exports__["a"] = (startsWith);
  6278. /***/ }),
  6279. /* 95 */
  6280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6281. "use strict";
  6282. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6283. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
  6284. function endsWith(arr, e) {
  6285. return Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr) || Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(arr) ? arr[arr.length - 1] === e : false;
  6286. }
  6287. /* harmony default export */ __webpack_exports__["a"] = (endsWith);
  6288. /***/ }),
  6289. /* 96 */
  6290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6291. "use strict";
  6292. /**
  6293. * 只要有一个不满足条件就返回 false
  6294. * @param arr
  6295. * @param func
  6296. */
  6297. var every = function (arr, func) {
  6298. for (var i = 0; i < arr.length; i++) {
  6299. if (!func(arr[i], i)) return false;
  6300. }
  6301. return true;
  6302. };
  6303. /* harmony default export */ __webpack_exports__["a"] = (every);
  6304. /***/ }),
  6305. /* 97 */
  6306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6307. "use strict";
  6308. /**
  6309. * 只要有一个满足条件就返回 true
  6310. * @param arr
  6311. * @param func
  6312. */
  6313. var some = function (arr, func) {
  6314. for (var i = 0; i < arr.length; i++) {
  6315. if (func(arr[i], i)) return true;
  6316. }
  6317. return false;
  6318. };
  6319. /* harmony default export */ __webpack_exports__["a"] = (some);
  6320. /***/ }),
  6321. /* 98 */
  6322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6323. "use strict";
  6324. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__group_to_map__ = __webpack_require__(55);
  6325. /* harmony default export */ __webpack_exports__["a"] = (function (data, condition) {
  6326. if (!condition) {
  6327. // 没有条件,则自身改成数组
  6328. return [data];
  6329. }
  6330. var groups = Object(__WEBPACK_IMPORTED_MODULE_0__group_to_map__["a" /* default */])(data, condition);
  6331. var array = [];
  6332. for (var i in groups) {
  6333. array.push(groups[i]);
  6334. }
  6335. return array;
  6336. });
  6337. /***/ }),
  6338. /* 99 */
  6339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6340. "use strict";
  6341. /**
  6342. * 获取封装的事件
  6343. * @protected
  6344. * @param {Object} obj 对象
  6345. * @param {String} action 事件名称
  6346. * @return {Function} 返回事件处理函数
  6347. */
  6348. function getWrapBehavior(obj, action) {
  6349. return obj['_wrap_' + action];
  6350. }
  6351. /* harmony default export */ __webpack_exports__["a"] = (getWrapBehavior);
  6352. /***/ }),
  6353. /* 100 */
  6354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6355. "use strict";
  6356. /**
  6357. * 封装事件,便于使用上下文this,和便于解除事件时使用
  6358. * @protected
  6359. * @param {Object} obj 对象
  6360. * @param {String} action 事件名称
  6361. * @return {Function} 返回事件处理函数
  6362. */
  6363. function wrapBehavior(obj, action) {
  6364. if (obj['_wrap_' + action]) {
  6365. return obj['_wrap_' + action];
  6366. }
  6367. var method = function (e) {
  6368. obj[action](e);
  6369. };
  6370. obj['_wrap_' + action] = method;
  6371. return method;
  6372. }
  6373. /* harmony default export */ __webpack_exports__["a"] = (wrapBehavior);
  6374. /***/ }),
  6375. /* 101 */
  6376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6377. "use strict";
  6378. var numColorCache = {};
  6379. function numberToColor(num) {
  6380. // 增加缓存
  6381. var color = numColorCache[num];
  6382. if (!color) {
  6383. var str = num.toString(16);
  6384. for (var i = str.length; i < 6; i++) {
  6385. str = '0' + str;
  6386. }
  6387. color = '#' + str;
  6388. numColorCache[num] = color;
  6389. }
  6390. return color;
  6391. }
  6392. /* harmony default export */ __webpack_exports__["a"] = (numberToColor);
  6393. /***/ }),
  6394. /* 102 */
  6395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6396. "use strict";
  6397. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6398. function parseRadius(radius) {
  6399. var r1 = 0,
  6400. r2 = 0,
  6401. r3 = 0,
  6402. r4 = 0;
  6403. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(radius)) {
  6404. if (radius.length === 1) {
  6405. r1 = r2 = r3 = r4 = radius[0];
  6406. } else if (radius.length === 2) {
  6407. r1 = r3 = radius[0];
  6408. r2 = r4 = radius[1];
  6409. } else if (radius.length === 3) {
  6410. r1 = radius[0];
  6411. r2 = r4 = radius[1];
  6412. r3 = radius[2];
  6413. } else {
  6414. r1 = radius[0];
  6415. r2 = radius[1];
  6416. r3 = radius[2];
  6417. r4 = radius[3];
  6418. }
  6419. } else {
  6420. r1 = r2 = r3 = r4 = radius;
  6421. }
  6422. return {
  6423. r1: r1,
  6424. r2: r2,
  6425. r3: r3,
  6426. r4: r4
  6427. };
  6428. }
  6429. /* harmony default export */ __webpack_exports__["a"] = (parseRadius);
  6430. /***/ }),
  6431. /* 103 */
  6432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6433. "use strict";
  6434. var clamp = function (a, min, max) {
  6435. if (a < min) {
  6436. return min;
  6437. } else if (a > max) {
  6438. return max;
  6439. }
  6440. return a;
  6441. };
  6442. /* harmony default export */ __webpack_exports__["a"] = (clamp);
  6443. /***/ }),
  6444. /* 104 */
  6445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6446. "use strict";
  6447. var fixedBase = function (v, base) {
  6448. var str = base.toString();
  6449. var index = str.indexOf('.');
  6450. if (index === -1) {
  6451. return Math.round(v);
  6452. }
  6453. var length = str.substr(index + 1).length;
  6454. if (length > 20) {
  6455. length = 20;
  6456. }
  6457. return parseFloat(v.toFixed(length));
  6458. };
  6459. /* harmony default export */ __webpack_exports__["a"] = (fixedBase);
  6460. /***/ }),
  6461. /* 105 */
  6462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6463. "use strict";
  6464. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6465. var isDecimal = function (num) {
  6466. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 1 !== 0;
  6467. };
  6468. /* harmony default export */ __webpack_exports__["a"] = (isDecimal);
  6469. /***/ }),
  6470. /* 106 */
  6471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6472. "use strict";
  6473. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6474. var isEven = function (num) {
  6475. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 2 === 0;
  6476. };
  6477. /* harmony default export */ __webpack_exports__["a"] = (isEven);
  6478. /***/ }),
  6479. /* 107 */
  6480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6481. "use strict";
  6482. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6483. var isInteger = Number.isInteger ? Number.isInteger : function (num) {
  6484. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 1 === 0;
  6485. };
  6486. /* harmony default export */ __webpack_exports__["a"] = (isInteger);
  6487. /***/ }),
  6488. /* 108 */
  6489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6490. "use strict";
  6491. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6492. var isNegative = function (num) {
  6493. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num < 0;
  6494. };
  6495. /* harmony default export */ __webpack_exports__["a"] = (isNegative);
  6496. /***/ }),
  6497. /* 109 */
  6498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6499. "use strict";
  6500. /* harmony export (immutable) */ __webpack_exports__["a"] = isNumberEqual;
  6501. var PRECISION = 0.00001; // numbers less than this is considered as 0
  6502. function isNumberEqual(a, b, precision) {
  6503. if (precision === void 0) {
  6504. precision = PRECISION;
  6505. }
  6506. return Math.abs(a - b) < precision;
  6507. }
  6508. ;
  6509. /***/ }),
  6510. /* 110 */
  6511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6512. "use strict";
  6513. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6514. var isOdd = function (num) {
  6515. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 2 !== 0;
  6516. };
  6517. /* harmony default export */ __webpack_exports__["a"] = (isOdd);
  6518. /***/ }),
  6519. /* 111 */
  6520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6521. "use strict";
  6522. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6523. var isPositive = function (num) {
  6524. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num > 0;
  6525. };
  6526. /* harmony default export */ __webpack_exports__["a"] = (isPositive);
  6527. /***/ }),
  6528. /* 112 */
  6529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6530. "use strict";
  6531. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  6532. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  6533. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
  6534. /**
  6535. * @param {Array} arr The array to iterate over.
  6536. * @param {Function} [fn] The iteratee invoked per element.
  6537. * @return {*} Returns the maximum value.
  6538. * @example
  6539. *
  6540. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  6541. *
  6542. * maxBy(objects, function(o) { return o.n; });
  6543. * // => { 'n': 2 }
  6544. *
  6545. * maxBy(objects, 'n');
  6546. * // => { 'n': 2 }
  6547. */
  6548. /* harmony default export */ __webpack_exports__["a"] = (function (arr, fn) {
  6549. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr)) {
  6550. return undefined;
  6551. }
  6552. var max = arr[0];
  6553. var maxData;
  6554. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
  6555. maxData = fn(arr[0]);
  6556. } else {
  6557. maxData = arr[0][fn];
  6558. }
  6559. var data;
  6560. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (val) {
  6561. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
  6562. data = fn(val);
  6563. } else {
  6564. data = val[fn];
  6565. }
  6566. if (data > maxData) {
  6567. max = val;
  6568. maxData = data;
  6569. }
  6570. });
  6571. return max;
  6572. });
  6573. /***/ }),
  6574. /* 113 */
  6575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6576. "use strict";
  6577. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  6578. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
  6579. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
  6580. /**
  6581. * @param {Array} arr The array to iterate over.
  6582. * @param {Function} [fn] The iteratee invoked per element.
  6583. * @return {*} Returns the minimum value.
  6584. * @example
  6585. *
  6586. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  6587. *
  6588. * minBy(objects, function(o) { return o.n; });
  6589. * // => { 'n': 1 }
  6590. *
  6591. * minBy(objects, 'n');
  6592. * // => { 'n': 1 }
  6593. */
  6594. /* harmony default export */ __webpack_exports__["a"] = (function (arr, fn) {
  6595. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr)) {
  6596. return undefined;
  6597. }
  6598. var min = arr[0];
  6599. var minData;
  6600. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
  6601. minData = fn(arr[0]);
  6602. } else {
  6603. minData = arr[0][fn];
  6604. }
  6605. var data;
  6606. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (val) {
  6607. if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
  6608. data = fn(val);
  6609. } else {
  6610. data = val[fn];
  6611. }
  6612. if (data < minData) {
  6613. min = val;
  6614. minData = data;
  6615. }
  6616. });
  6617. return min;
  6618. });
  6619. /***/ }),
  6620. /* 114 */
  6621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6622. "use strict";
  6623. var mod = function (n, m) {
  6624. return (n % m + m) % m;
  6625. };
  6626. /* harmony default export */ __webpack_exports__["a"] = (mod);
  6627. /***/ }),
  6628. /* 115 */
  6629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6630. "use strict";
  6631. var DEGREE = 180 / Math.PI;
  6632. var toDegree = function (radian) {
  6633. return DEGREE * radian;
  6634. };
  6635. /* harmony default export */ __webpack_exports__["a"] = (toDegree);
  6636. /***/ }),
  6637. /* 116 */
  6638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6639. "use strict";
  6640. /* harmony default export */ __webpack_exports__["a"] = (parseInt);
  6641. /***/ }),
  6642. /* 117 */
  6643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6644. "use strict";
  6645. var RADIAN = Math.PI / 180;
  6646. var toRadian = function (degree) {
  6647. return RADIAN * degree;
  6648. };
  6649. /* harmony default export */ __webpack_exports__["a"] = (toRadian);
  6650. /***/ }),
  6651. /* 118 */
  6652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6653. "use strict";
  6654. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  6655. /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */]);
  6656. /***/ }),
  6657. /* 119 */
  6658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6659. "use strict";
  6660. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__has__ = __webpack_require__(57);
  6661. /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__has__["a" /* default */]);
  6662. /***/ }),
  6663. /* 120 */
  6664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6665. "use strict";
  6666. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
  6667. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__values__ = __webpack_require__(58);
  6668. /* harmony default export */ __webpack_exports__["a"] = (function (obj, value) {
  6669. return Object(__WEBPACK_IMPORTED_MODULE_0__contains__["a" /* default */])(Object(__WEBPACK_IMPORTED_MODULE_1__values__["a" /* default */])(obj), value);
  6670. });
  6671. /***/ }),
  6672. /* 121 */
  6673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6674. "use strict";
  6675. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
  6676. var lowerCase = function (str) {
  6677. return Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(str).toLowerCase();
  6678. };
  6679. /* harmony default export */ __webpack_exports__["a"] = (lowerCase);
  6680. /***/ }),
  6681. /* 122 */
  6682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6683. "use strict";
  6684. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
  6685. var lowerFirst = function (value) {
  6686. var str = Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(value);
  6687. return str.charAt(0).toLowerCase() + str.substring(1);
  6688. };
  6689. /* harmony default export */ __webpack_exports__["a"] = (lowerFirst);
  6690. /***/ }),
  6691. /* 123 */
  6692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6693. "use strict";
  6694. function substitute(str, o) {
  6695. if (!str || !o) {
  6696. return str;
  6697. }
  6698. return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
  6699. if (match.charAt(0) === '\\') {
  6700. return match.slice(1);
  6701. }
  6702. return o[name] === undefined ? '' : o[name];
  6703. });
  6704. }
  6705. /* harmony default export */ __webpack_exports__["a"] = (substitute);
  6706. /***/ }),
  6707. /* 124 */
  6708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6709. "use strict";
  6710. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
  6711. var upperCase = function (str) {
  6712. return Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(str).toUpperCase();
  6713. };
  6714. /* harmony default export */ __webpack_exports__["a"] = (upperCase);
  6715. /***/ }),
  6716. /* 125 */
  6717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6718. "use strict";
  6719. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
  6720. var upperFirst = function (value) {
  6721. var str = Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(value);
  6722. return str.charAt(0).toUpperCase() + str.substring(1);
  6723. };
  6724. /* harmony default export */ __webpack_exports__["a"] = (upperFirst);
  6725. /***/ }),
  6726. /* 126 */
  6727. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6728. "use strict";
  6729. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  6730. /**
  6731. * 是否是参数类型
  6732. *
  6733. * @param {Object} value 测试的值
  6734. * @return {Boolean}
  6735. */
  6736. var isArguments = function (value) {
  6737. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Arguments');
  6738. };
  6739. /* harmony default export */ __webpack_exports__["a"] = (isArguments);
  6740. /***/ }),
  6741. /* 127 */
  6742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6743. "use strict";
  6744. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  6745. /**
  6746. * 是否是布尔类型
  6747. *
  6748. * @param {Object} value 测试的值
  6749. * @return {Boolean}
  6750. */
  6751. var isBoolean = function (value) {
  6752. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Boolean');
  6753. };
  6754. /* harmony default export */ __webpack_exports__["a"] = (isBoolean);
  6755. /***/ }),
  6756. /* 128 */
  6757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6758. "use strict";
  6759. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  6760. var isDate = function (value) {
  6761. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Date');
  6762. };
  6763. /* harmony default export */ __webpack_exports__["a"] = (isDate);
  6764. /***/ }),
  6765. /* 129 */
  6766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6767. "use strict";
  6768. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  6769. /**
  6770. * 是否是参数类型
  6771. *
  6772. * @param {Object} value 测试的值
  6773. * @return {Boolean}
  6774. */
  6775. var isError = function (value) {
  6776. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Error');
  6777. };
  6778. /* harmony default export */ __webpack_exports__["a"] = (isError);
  6779. /***/ }),
  6780. /* 130 */
  6781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6782. "use strict";
  6783. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
  6784. /**
  6785. * 判断是否为有限数
  6786. * @return {Boolean}
  6787. */
  6788. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  6789. return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(value) && isFinite(value);
  6790. });
  6791. /***/ }),
  6792. /* 131 */
  6793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6794. "use strict";
  6795. var isNull = function (value) {
  6796. return value === null;
  6797. };
  6798. /* harmony default export */ __webpack_exports__["a"] = (isNull);
  6799. /***/ }),
  6800. /* 132 */
  6801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6802. "use strict";
  6803. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
  6804. var isRegExp = function (str) {
  6805. return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(str, 'RegExp');
  6806. };
  6807. /* harmony default export */ __webpack_exports__["a"] = (isRegExp);
  6808. /***/ }),
  6809. /* 133 */
  6810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6811. "use strict";
  6812. var isUndefined = function (value) {
  6813. return value === undefined;
  6814. };
  6815. /* harmony default export */ __webpack_exports__["a"] = (isUndefined);
  6816. /***/ }),
  6817. /* 134 */
  6818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6819. "use strict";
  6820. /**
  6821. * 判断是否HTML元素
  6822. * @return {Boolean} 是否HTML元素
  6823. */
  6824. var isElement = function (o) {
  6825. return o instanceof Element || o instanceof HTMLDocument;
  6826. };
  6827. /* harmony default export */ __webpack_exports__["a"] = (isElement);
  6828. /***/ }),
  6829. /* 135 */
  6830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6831. "use strict";
  6832. /* harmony export (immutable) */ __webpack_exports__["a"] = requestAnimationFrame;
  6833. function requestAnimationFrame(fn) {
  6834. var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || // @ts-ignore
  6835. window.mozRequestAnimationFrame || // @ts-ignore
  6836. window.msRequestAnimationFrame || function (f) {
  6837. return setTimeout(f, 16);
  6838. };
  6839. return method(fn);
  6840. }
  6841. ;
  6842. /***/ }),
  6843. /* 136 */
  6844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6845. "use strict";
  6846. /* harmony export (immutable) */ __webpack_exports__["a"] = cancelAnimationFrame;
  6847. function cancelAnimationFrame(handler) {
  6848. var method = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || // @ts-ignore
  6849. window.mozCancelAnimationFrame || // @ts-ignore
  6850. window.msCancelAnimationFrame || clearTimeout;
  6851. method(handler);
  6852. }
  6853. ;
  6854. /***/ }),
  6855. /* 137 */
  6856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6857. "use strict";
  6858. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mix__ = __webpack_require__(41);
  6859. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
  6860. var augment = function () {
  6861. var args = [];
  6862. for (var _i = 0; _i < arguments.length; _i++) {
  6863. args[_i] = arguments[_i];
  6864. }
  6865. var c = args[0];
  6866. for (var i = 1; i < args.length; i++) {
  6867. var obj = args[i];
  6868. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj)) {
  6869. obj = obj.prototype;
  6870. }
  6871. Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(c.prototype, obj);
  6872. }
  6873. };
  6874. /* harmony default export */ __webpack_exports__["a"] = (augment);
  6875. /***/ }),
  6876. /* 138 */
  6877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6878. "use strict";
  6879. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6880. var clone = function (obj) {
  6881. if (typeof obj !== 'object' || obj === null) {
  6882. return obj;
  6883. }
  6884. var rst;
  6885. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(obj)) {
  6886. rst = [];
  6887. for (var i = 0, l = obj.length; i < l; i++) {
  6888. if (typeof obj[i] === 'object' && obj[i] != null) {
  6889. rst[i] = clone(obj[i]);
  6890. } else {
  6891. rst[i] = obj[i];
  6892. }
  6893. }
  6894. } else {
  6895. rst = {};
  6896. for (var k in obj) {
  6897. if (typeof obj[k] === 'object' && obj[k] != null) {
  6898. rst[k] = clone(obj[k]);
  6899. } else {
  6900. rst[k] = obj[k];
  6901. }
  6902. }
  6903. }
  6904. return rst;
  6905. };
  6906. /* harmony default export */ __webpack_exports__["a"] = (clone);
  6907. /***/ }),
  6908. /* 139 */
  6909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6910. "use strict";
  6911. function debounce(func, wait, immediate) {
  6912. var timeout;
  6913. return function () {
  6914. var context = this,
  6915. args = arguments;
  6916. var later = function () {
  6917. timeout = null;
  6918. if (!immediate) {
  6919. func.apply(context, args);
  6920. }
  6921. };
  6922. var callNow = immediate && !timeout;
  6923. clearTimeout(timeout);
  6924. timeout = setTimeout(later, wait);
  6925. if (callNow) {
  6926. func.apply(context, args);
  6927. }
  6928. };
  6929. }
  6930. /* harmony default export */ __webpack_exports__["a"] = (debounce);
  6931. /***/ }),
  6932. /* 140 */
  6933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6934. "use strict";
  6935. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
  6936. /**
  6937. * _.memoize(calColor);
  6938. * _.memoize(calColor, (...args) => args[0]);
  6939. * @param f
  6940. * @param resolver
  6941. */
  6942. /* harmony default export */ __webpack_exports__["a"] = (function (f, resolver) {
  6943. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(f)) {
  6944. throw new TypeError('Expected a function');
  6945. }
  6946. var memoized = function () {
  6947. var args = [];
  6948. for (var _i = 0; _i < arguments.length; _i++) {
  6949. args[_i] = arguments[_i];
  6950. } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
  6951. var key = resolver ? resolver.apply(this, args) : args[0];
  6952. var cache = memoized.cache;
  6953. if (cache.has(key)) {
  6954. return cache.get(key);
  6955. }
  6956. var result = f.apply(this, args); // 缓存起来
  6957. cache.set(key, result);
  6958. return result;
  6959. };
  6960. memoized.cache = new Map();
  6961. return memoized;
  6962. });
  6963. /***/ }),
  6964. /* 141 */
  6965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6966. "use strict";
  6967. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
  6968. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_plain_object__ = __webpack_require__(24);
  6969. var MAX_MIX_LEVEL = 5;
  6970. function _deepMix(dist, src, level, maxLevel) {
  6971. level = level || 0;
  6972. maxLevel = maxLevel || MAX_MIX_LEVEL;
  6973. for (var key in src) {
  6974. if (src.hasOwnProperty(key)) {
  6975. var value = src[key];
  6976. if (value !== null && Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(value)) {
  6977. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(dist[key])) {
  6978. dist[key] = {};
  6979. }
  6980. if (level < maxLevel) {
  6981. _deepMix(dist[key], value, level + 1, maxLevel);
  6982. } else {
  6983. dist[key] = src[key];
  6984. }
  6985. } else if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(value)) {
  6986. dist[key] = [];
  6987. dist[key] = dist[key].concat(value);
  6988. } else if (value !== undefined) {
  6989. dist[key] = value;
  6990. }
  6991. }
  6992. }
  6993. } // todo 重写
  6994. var deepMix = function (rst) {
  6995. var args = [];
  6996. for (var _i = 1; _i < arguments.length; _i++) {
  6997. args[_i - 1] = arguments[_i];
  6998. }
  6999. for (var i = 0; i < args.length; i += 1) {
  7000. _deepMix(rst, args[i]);
  7001. }
  7002. return rst;
  7003. };
  7004. /* harmony default export */ __webpack_exports__["a"] = (deepMix);
  7005. /***/ }),
  7006. /* 142 */
  7007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7008. "use strict";
  7009. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mix__ = __webpack_require__(41);
  7010. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
  7011. var extend = function (subclass, superclass, overrides, staticOverrides) {
  7012. // 如果只提供父类构造函数,则自动生成子类构造函数
  7013. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(superclass)) {
  7014. overrides = superclass;
  7015. superclass = subclass;
  7016. subclass = function () {};
  7017. }
  7018. var create = Object.create ? function (proto, c) {
  7019. return Object.create(proto, {
  7020. constructor: {
  7021. value: c
  7022. }
  7023. });
  7024. } : function (proto, c) {
  7025. function Tmp() {}
  7026. Tmp.prototype = proto;
  7027. var o = new Tmp();
  7028. o.constructor = c;
  7029. return o;
  7030. };
  7031. var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
  7032. subclass.prototype = Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(superObj, subclass.prototype); // 指定子类的prototype
  7033. subclass.superclass = create(superclass.prototype, superclass);
  7034. Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(superObj, overrides);
  7035. Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(subclass, staticOverrides);
  7036. return subclass;
  7037. };
  7038. /* harmony default export */ __webpack_exports__["a"] = (extend);
  7039. /***/ }),
  7040. /* 143 */
  7041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7042. "use strict";
  7043. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  7044. var indexOf = function (arr, obj) {
  7045. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
  7046. return -1;
  7047. }
  7048. var m = Array.prototype.indexOf;
  7049. if (m) {
  7050. return m.call(arr, obj);
  7051. }
  7052. var index = -1;
  7053. for (var i = 0; i < arr.length; i++) {
  7054. if (arr[i] === obj) {
  7055. index = i;
  7056. break;
  7057. }
  7058. }
  7059. return index;
  7060. };
  7061. /* harmony default export */ __webpack_exports__["a"] = (indexOf);
  7062. /***/ }),
  7063. /* 144 */
  7064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7065. "use strict";
  7066. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  7067. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
  7068. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__get_type__ = __webpack_require__(59);
  7069. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__is_prototype__ = __webpack_require__(60);
  7070. var hasOwnProperty = Object.prototype.hasOwnProperty;
  7071. function isEmpty(value) {
  7072. /**
  7073. * isEmpty(null) => true
  7074. * isEmpty() => true
  7075. * isEmpty(true) => true
  7076. * isEmpty(1) => true
  7077. * isEmpty([1, 2, 3]) => false
  7078. * isEmpty('abc') => false
  7079. * isEmpty({ a: 1 }) => false
  7080. */
  7081. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) {
  7082. return true;
  7083. }
  7084. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(value)) {
  7085. return !value.length;
  7086. }
  7087. var type = Object(__WEBPACK_IMPORTED_MODULE_2__get_type__["a" /* default */])(value);
  7088. if (type === 'Map' || type === 'Set') {
  7089. return !value.size;
  7090. }
  7091. if (Object(__WEBPACK_IMPORTED_MODULE_3__is_prototype__["a" /* default */])(value)) {
  7092. return !Object.keys(value).length;
  7093. }
  7094. for (var key in value) {
  7095. if (hasOwnProperty.call(value, key)) {
  7096. return false;
  7097. }
  7098. }
  7099. return true;
  7100. }
  7101. /* harmony default export */ __webpack_exports__["a"] = (isEmpty);
  7102. /***/ }),
  7103. /* 145 */
  7104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7105. "use strict";
  7106. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
  7107. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_equal__ = __webpack_require__(61);
  7108. /**
  7109. * @param {*} value The value to compare.
  7110. * @param {*} other The other value to compare.
  7111. * @param {Function} [fn] The function to customize comparisons.
  7112. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  7113. * @example
  7114. *
  7115. * function isGreeting(value) {
  7116. * return /^h(?:i|ello)$/.test(value);
  7117. * }
  7118. *
  7119. * function customizer(objValue, othValue) {
  7120. * if (isGreeting(objValue) && isGreeting(othValue)) {
  7121. * return true;
  7122. * }
  7123. * }
  7124. *
  7125. * var array = ['hello', 'goodbye'];
  7126. * var other = ['hi', 'goodbye'];
  7127. *
  7128. * isEqualWith(array, other, customizer); // => true
  7129. */
  7130. /* harmony default export */ __webpack_exports__["a"] = (function (value, other, fn) {
  7131. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(fn)) {
  7132. return Object(__WEBPACK_IMPORTED_MODULE_1__is_equal__["a" /* default */])(value, other);
  7133. }
  7134. return !!fn(value, other);
  7135. });
  7136. /***/ }),
  7137. /* 146 */
  7138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7139. "use strict";
  7140. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  7141. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
  7142. var map = function (arr, func) {
  7143. if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(arr)) {
  7144. // @ts-ignore
  7145. return arr;
  7146. }
  7147. var result = [];
  7148. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (value, index) {
  7149. result.push(func(value, index));
  7150. });
  7151. return result;
  7152. };
  7153. /* harmony default export */ __webpack_exports__["a"] = (map);
  7154. /***/ }),
  7155. /* 147 */
  7156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7157. "use strict";
  7158. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  7159. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_object__ = __webpack_require__(29);
  7160. var identity = function (v) {
  7161. return v;
  7162. };
  7163. /* harmony default export */ __webpack_exports__["a"] = (function (object, func) {
  7164. if (func === void 0) {
  7165. func = identity;
  7166. }
  7167. var r = {};
  7168. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_object__["a" /* default */])(object) && !Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(object)) {
  7169. Object.keys(object).forEach(function (key) {
  7170. // @ts-ignore
  7171. r[key] = func(object[key], key);
  7172. });
  7173. }
  7174. return r;
  7175. });
  7176. /***/ }),
  7177. /* 148 */
  7178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7179. "use strict";
  7180. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_string__ = __webpack_require__(18);
  7181. /**
  7182. * https://github.com/developit/dlv/blob/master/index.js
  7183. * @param obj
  7184. * @param key
  7185. * @param defaultValue
  7186. */
  7187. /* harmony default export */ __webpack_exports__["a"] = (function (obj, key, defaultValue) {
  7188. var p = 0;
  7189. var keyArr = Object(__WEBPACK_IMPORTED_MODULE_0__is_string__["a" /* default */])(key) ? key.split('.') : key;
  7190. while (obj && p < keyArr.length) {
  7191. obj = obj[keyArr[p++]];
  7192. }
  7193. return obj === undefined || p < keyArr.length ? defaultValue : obj;
  7194. });
  7195. /***/ }),
  7196. /* 149 */
  7197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7198. "use strict";
  7199. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object__ = __webpack_require__(29);
  7200. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
  7201. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_number__ = __webpack_require__(12);
  7202. /**
  7203. * https://github.com/developit/dlv/blob/master/index.js
  7204. * @param obj
  7205. * @param path
  7206. * @param value
  7207. */
  7208. /* harmony default export */ __webpack_exports__["a"] = (function (obj, path, value) {
  7209. var o = obj;
  7210. var keyArr = Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(path) ? path.split('.') : path;
  7211. keyArr.forEach(function (key, idx) {
  7212. // 不是最后一个
  7213. if (idx < keyArr.length - 1) {
  7214. if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_object__["a" /* default */])(o[key])) {
  7215. o[key] = Object(__WEBPACK_IMPORTED_MODULE_2__is_number__["a" /* default */])(keyArr[idx + 1]) ? [] : {};
  7216. }
  7217. o = o[key];
  7218. } else {
  7219. o[key] = value;
  7220. }
  7221. });
  7222. return obj;
  7223. });
  7224. /***/ }),
  7225. /* 150 */
  7226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7227. "use strict";
  7228. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
  7229. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_plain_object__ = __webpack_require__(24);
  7230. var hasOwnProperty = Object.prototype.hasOwnProperty;
  7231. /* harmony default export */ __webpack_exports__["a"] = (function (object, keys) {
  7232. if (object === null || !Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(object)) {
  7233. return {};
  7234. }
  7235. var result = {};
  7236. Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(keys, function (key) {
  7237. if (hasOwnProperty.call(object, key)) {
  7238. result[key] = object[key];
  7239. }
  7240. });
  7241. return result;
  7242. });
  7243. /***/ }),
  7244. /* 151 */
  7245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7246. "use strict";
  7247. /* harmony default export */ __webpack_exports__["a"] = (function (func, wait, options) {
  7248. var timeout, context, args, result;
  7249. var previous = 0;
  7250. if (!options) options = {};
  7251. var later = function () {
  7252. previous = options.leading === false ? 0 : Date.now();
  7253. timeout = null;
  7254. result = func.apply(context, args);
  7255. if (!timeout) context = args = null;
  7256. };
  7257. var throttled = function () {
  7258. var now = Date.now();
  7259. if (!previous && options.leading === false) previous = now;
  7260. var remaining = wait - (now - previous);
  7261. context = this;
  7262. args = arguments;
  7263. if (remaining <= 0 || remaining > wait) {
  7264. if (timeout) {
  7265. clearTimeout(timeout);
  7266. timeout = null;
  7267. }
  7268. previous = now;
  7269. result = func.apply(context, args);
  7270. if (!timeout) context = args = null;
  7271. } else if (!timeout && options.trailing !== false) {
  7272. timeout = setTimeout(later, remaining);
  7273. }
  7274. return result;
  7275. };
  7276. throttled.cancel = function () {
  7277. clearTimeout(timeout);
  7278. previous = 0;
  7279. timeout = context = args = null;
  7280. };
  7281. return throttled;
  7282. });
  7283. /***/ }),
  7284. /* 152 */
  7285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7286. "use strict";
  7287. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
  7288. /* harmony default export */ __webpack_exports__["a"] = (function (value) {
  7289. return Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(value) ? Array.prototype.slice.call(value) : [];
  7290. });
  7291. /***/ }),
  7292. /* 153 */
  7293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7294. "use strict";
  7295. var map = {};
  7296. /* harmony default export */ __webpack_exports__["a"] = (function (prefix) {
  7297. prefix = prefix || 'g';
  7298. if (!map[prefix]) {
  7299. map[prefix] = 1;
  7300. } else {
  7301. map[prefix] += 1;
  7302. }
  7303. return prefix + map[prefix];
  7304. });
  7305. /***/ }),
  7306. /* 154 */
  7307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7308. "use strict";
  7309. /* harmony default export */ __webpack_exports__["a"] = (function () {});
  7310. /***/ }),
  7311. /* 155 */
  7312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7313. "use strict";
  7314. /* harmony default export */ __webpack_exports__["a"] = (function (v) {
  7315. return v;
  7316. });
  7317. /***/ }),
  7318. /* 156 */
  7319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7320. "use strict";
  7321. /* harmony export (immutable) */ __webpack_exports__["a"] = size;
  7322. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
  7323. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
  7324. function size(o) {
  7325. if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(o)) {
  7326. return 0;
  7327. }
  7328. if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(o)) {
  7329. return o.length;
  7330. }
  7331. return Object.keys(o).length;
  7332. }
  7333. /***/ }),
  7334. /* 157 */
  7335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7336. "use strict";
  7337. /**
  7338. * k-v 存储
  7339. */
  7340. var default_1 =
  7341. /** @class */
  7342. function () {
  7343. function default_1() {
  7344. this.map = {};
  7345. }
  7346. default_1.prototype.has = function (key) {
  7347. return this.map[key] !== undefined;
  7348. };
  7349. default_1.prototype.get = function (key, def) {
  7350. var v = this.map[key];
  7351. return v === undefined ? def : v;
  7352. };
  7353. default_1.prototype.set = function (key, value) {
  7354. this.map[key] = value;
  7355. };
  7356. default_1.prototype.clear = function () {
  7357. this.map = {};
  7358. };
  7359. default_1.prototype.delete = function (key) {
  7360. delete this.map[key];
  7361. };
  7362. default_1.prototype.size = function () {
  7363. return Object.keys(this.map).length;
  7364. };
  7365. return default_1;
  7366. }();
  7367. /* harmony default export */ __webpack_exports__["a"] = (default_1);
  7368. /***/ }),
  7369. /* 158 */
  7370. /***/ (function(module, exports, __webpack_require__) {
  7371. "use strict";
  7372. var Util = __webpack_require__(0);
  7373. var Plot = /*#__PURE__*/function () {
  7374. function Plot(cfg) {
  7375. Util.mix(this, cfg);
  7376. this._init();
  7377. }
  7378. var _proto = Plot.prototype;
  7379. _proto._init = function _init() {
  7380. var self = this;
  7381. var start = self.start;
  7382. var end = self.end;
  7383. var xMin = Math.min(start.x, end.x);
  7384. var xMax = Math.max(start.x, end.x);
  7385. var yMin = Math.min(start.y, end.y);
  7386. var yMax = Math.max(start.y, end.y);
  7387. this.tl = {
  7388. x: xMin,
  7389. y: yMin
  7390. };
  7391. this.tr = {
  7392. x: xMax,
  7393. y: yMin
  7394. };
  7395. this.bl = {
  7396. x: xMin,
  7397. y: yMax
  7398. };
  7399. this.br = {
  7400. x: xMax,
  7401. y: yMax
  7402. };
  7403. this.width = xMax - xMin;
  7404. this.height = yMax - yMin;
  7405. }
  7406. /**
  7407. * reset
  7408. * @param {Object} start start point
  7409. * @param {Object} end end point
  7410. */
  7411. ;
  7412. _proto.reset = function reset(start, end) {
  7413. this.start = start;
  7414. this.end = end;
  7415. this._init();
  7416. }
  7417. /**
  7418. * check the point is in the range of plot
  7419. * @param {Nubmer} x x value
  7420. * @param {[type]} y y value
  7421. * @return {Boolean} return the result
  7422. */
  7423. ;
  7424. _proto.isInRange = function isInRange(x, y) {
  7425. if (Util.isObject(x)) {
  7426. y = x.y;
  7427. x = x.x;
  7428. }
  7429. var tl = this.tl;
  7430. var br = this.br;
  7431. return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
  7432. };
  7433. return Plot;
  7434. }();
  7435. module.exports = Plot;
  7436. /***/ }),
  7437. /* 159 */
  7438. /***/ (function(module, exports, __webpack_require__) {
  7439. "use strict";
  7440. var Coord = __webpack_require__(43);
  7441. __webpack_require__(160);
  7442. module.exports = Coord;
  7443. /***/ }),
  7444. /* 160 */
  7445. /***/ (function(module, exports, __webpack_require__) {
  7446. "use strict";
  7447. var _interopRequireDefault = __webpack_require__(1);
  7448. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  7449. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  7450. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  7451. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7452. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7453. var Base = __webpack_require__(43);
  7454. var Cartesian = /*#__PURE__*/function (_Base) {
  7455. (0, _inheritsLoose2["default"])(Cartesian, _Base);
  7456. var _super = _createSuper(Cartesian);
  7457. function Cartesian() {
  7458. return _Base.apply(this, arguments) || this;
  7459. }
  7460. var _proto = Cartesian.prototype;
  7461. _proto._initDefaultCfg = function _initDefaultCfg() {
  7462. this.type = 'cartesian';
  7463. this.transposed = false;
  7464. this.isRect = true;
  7465. };
  7466. _proto.init = function init(start, end) {
  7467. _Base.prototype.init.call(this, start, end);
  7468. this.x = {
  7469. start: start.x,
  7470. end: end.x
  7471. };
  7472. this.y = {
  7473. start: start.y,
  7474. end: end.y
  7475. };
  7476. };
  7477. _proto._convertPoint = function _convertPoint(point) {
  7478. var self = this;
  7479. var transposed = self.transposed;
  7480. var xDim = transposed ? 'y' : 'x';
  7481. var yDim = transposed ? 'x' : 'y';
  7482. var x = self.x;
  7483. var y = self.y;
  7484. return {
  7485. x: x.start + (x.end - x.start) * point[xDim],
  7486. y: y.start + (y.end - y.start) * point[yDim]
  7487. };
  7488. };
  7489. _proto._invertPoint = function _invertPoint(point) {
  7490. var self = this;
  7491. var transposed = self.transposed;
  7492. var xDim = transposed ? 'y' : 'x';
  7493. var yDim = transposed ? 'x' : 'y';
  7494. var x = self.x;
  7495. var y = self.y;
  7496. var rst = {};
  7497. rst[xDim] = (point.x - x.start) / (x.end - x.start);
  7498. rst[yDim] = (point.y - y.start) / (y.end - y.start);
  7499. return rst;
  7500. };
  7501. return Cartesian;
  7502. }(Base);
  7503. Base.Cartesian = Cartesian;
  7504. Base.Rect = Cartesian;
  7505. module.exports = Cartesian;
  7506. /***/ }),
  7507. /* 161 */
  7508. /***/ (function(module, exports, __webpack_require__) {
  7509. "use strict";
  7510. var _interopRequireDefault = __webpack_require__(1);
  7511. exports.__esModule = true;
  7512. exports.Color = exports.Size = exports.Shape = exports.Position = void 0;
  7513. var _position = _interopRequireDefault(__webpack_require__(162));
  7514. exports.Position = _position["default"];
  7515. var _shape = _interopRequireDefault(__webpack_require__(163));
  7516. exports.Shape = _shape["default"];
  7517. var _size = _interopRequireDefault(__webpack_require__(164));
  7518. exports.Size = _size["default"];
  7519. var _color = _interopRequireDefault(__webpack_require__(165));
  7520. exports.Color = _color["default"];
  7521. /***/ }),
  7522. /* 162 */
  7523. /***/ (function(module, exports, __webpack_require__) {
  7524. "use strict";
  7525. var _interopRequireDefault = __webpack_require__(1);
  7526. exports.__esModule = true;
  7527. exports["default"] = void 0;
  7528. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  7529. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  7530. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  7531. var _util = __webpack_require__(20);
  7532. var _base = _interopRequireDefault(__webpack_require__(32));
  7533. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7534. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7535. var Position = /*#__PURE__*/function (_Base) {
  7536. (0, _inheritsLoose2["default"])(Position, _Base);
  7537. var _super = _createSuper(Position);
  7538. function Position(cfg) {
  7539. var _this;
  7540. _this = _Base.call(this, cfg) || this;
  7541. _this.names = ['x', 'y'];
  7542. _this.type = 'position';
  7543. return _this;
  7544. }
  7545. var _proto = Position.prototype;
  7546. _proto.mapping = function mapping(x, y) {
  7547. var scales = this.scales;
  7548. var coord = this.coord;
  7549. var scaleX = scales[0];
  7550. var scaleY = scales[1];
  7551. var rstX;
  7552. var rstY;
  7553. var obj;
  7554. if ((0, _util.isNil)(x) || (0, _util.isNil)(y)) {
  7555. return [];
  7556. }
  7557. if ((0, _util.isArray)(y) && (0, _util.isArray)(x)) {
  7558. rstX = [];
  7559. rstY = [];
  7560. for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
  7561. obj = coord.convertPoint({
  7562. x: scaleX.scale(x[i]),
  7563. y: scaleY.scale(y[j])
  7564. });
  7565. rstX.push(obj.x);
  7566. rstY.push(obj.y);
  7567. }
  7568. } else if ((0, _util.isArray)(y)) {
  7569. x = scaleX.scale(x);
  7570. rstY = [];
  7571. (0, _util.each)(y, function (yVal) {
  7572. yVal = scaleY.scale(yVal);
  7573. obj = coord.convertPoint({
  7574. x: x,
  7575. y: yVal
  7576. });
  7577. if (rstX && rstX !== obj.x) {
  7578. if (!(0, _util.isArray)(rstX)) {
  7579. rstX = [rstX];
  7580. }
  7581. rstX.push(obj.x);
  7582. } else {
  7583. rstX = obj.x;
  7584. }
  7585. rstY.push(obj.y);
  7586. });
  7587. } else if ((0, _util.isArray)(x)) {
  7588. y = scaleY.scale(y);
  7589. rstX = [];
  7590. (0, _util.each)(x, function (xVal) {
  7591. xVal = scaleX.scale(xVal);
  7592. obj = coord.convertPoint({
  7593. x: xVal,
  7594. y: y
  7595. });
  7596. if (rstY && rstY !== obj.y) {
  7597. if (!(0, _util.isArray)(rstY)) {
  7598. rstY = [rstY];
  7599. }
  7600. rstY.push(obj.y);
  7601. } else {
  7602. rstY = obj.y;
  7603. }
  7604. rstX.push(obj.x);
  7605. });
  7606. } else {
  7607. x = scaleX.scale(x);
  7608. y = scaleY.scale(y);
  7609. var point = coord.convertPoint({
  7610. x: x,
  7611. y: y
  7612. });
  7613. rstX = point.x;
  7614. rstY = point.y;
  7615. }
  7616. return [rstX, rstY];
  7617. };
  7618. return Position;
  7619. }(_base["default"]);
  7620. var _default = Position;
  7621. exports["default"] = _default;
  7622. /***/ }),
  7623. /* 163 */
  7624. /***/ (function(module, exports, __webpack_require__) {
  7625. "use strict";
  7626. var _interopRequireDefault = __webpack_require__(1);
  7627. exports.__esModule = true;
  7628. exports["default"] = void 0;
  7629. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  7630. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  7631. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  7632. var _base = _interopRequireDefault(__webpack_require__(32));
  7633. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7634. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7635. var Shape = /*#__PURE__*/function (_Base) {
  7636. (0, _inheritsLoose2["default"])(Shape, _Base);
  7637. var _super = _createSuper(Shape);
  7638. function Shape(cfg) {
  7639. var _this;
  7640. _this = _Base.call(this, cfg) || this;
  7641. _this.names = ['shape'];
  7642. _this.type = 'shape';
  7643. _this.gradient = null;
  7644. return _this;
  7645. }
  7646. /**
  7647. * @override
  7648. */
  7649. var _proto = Shape.prototype;
  7650. _proto.getLinearValue = function getLinearValue(percent) {
  7651. var values = this.values;
  7652. var index = Math.round((values.length - 1) * percent);
  7653. return values[index];
  7654. };
  7655. return Shape;
  7656. }(_base["default"]);
  7657. var _default = Shape;
  7658. exports["default"] = _default;
  7659. /***/ }),
  7660. /* 164 */
  7661. /***/ (function(module, exports, __webpack_require__) {
  7662. "use strict";
  7663. var _interopRequireDefault = __webpack_require__(1);
  7664. exports.__esModule = true;
  7665. exports["default"] = void 0;
  7666. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  7667. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  7668. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  7669. var _base = _interopRequireDefault(__webpack_require__(32));
  7670. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7671. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7672. var Size = /*#__PURE__*/function (_Base) {
  7673. (0, _inheritsLoose2["default"])(Size, _Base);
  7674. var _super = _createSuper(Size);
  7675. function Size(cfg) {
  7676. var _this;
  7677. _this = _Base.call(this, cfg) || this;
  7678. _this.names = ['size'];
  7679. _this.type = 'size';
  7680. _this.gradient = null;
  7681. return _this;
  7682. }
  7683. return Size;
  7684. }(_base["default"]);
  7685. var _default = Size;
  7686. exports["default"] = _default;
  7687. /***/ }),
  7688. /* 165 */
  7689. /***/ (function(module, exports, __webpack_require__) {
  7690. "use strict";
  7691. var _interopRequireDefault = __webpack_require__(1);
  7692. exports.__esModule = true;
  7693. exports["default"] = void 0;
  7694. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  7695. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  7696. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  7697. var _util = __webpack_require__(20);
  7698. var _base = _interopRequireDefault(__webpack_require__(32));
  7699. var _colorUtil = _interopRequireDefault(__webpack_require__(166));
  7700. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7701. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7702. var Color = /*#__PURE__*/function (_Base) {
  7703. (0, _inheritsLoose2["default"])(Color, _Base);
  7704. var _super = _createSuper(Color);
  7705. function Color(cfg) {
  7706. var _this;
  7707. _this = _Base.call(this, cfg) || this;
  7708. _this.names = ['color'];
  7709. _this.type = 'color';
  7710. _this.gradient = null;
  7711. if ((0, _util.isString)(_this.values)) {
  7712. _this.linear = true;
  7713. }
  7714. return _this;
  7715. }
  7716. /**
  7717. * @override
  7718. */
  7719. var _proto = Color.prototype;
  7720. _proto.getLinearValue = function getLinearValue(percent) {
  7721. var gradient = this.gradient;
  7722. if (!gradient) {
  7723. var values = this.values;
  7724. gradient = _colorUtil["default"].gradient(values);
  7725. this.gradient = gradient;
  7726. }
  7727. return gradient(percent);
  7728. };
  7729. return Color;
  7730. }(_base["default"]);
  7731. var _default = Color;
  7732. exports["default"] = _default;
  7733. /***/ }),
  7734. /* 166 */
  7735. /***/ (function(module, exports, __webpack_require__) {
  7736. "use strict";
  7737. exports.__esModule = true;
  7738. exports["default"] = void 0;
  7739. var _util = __webpack_require__(20);
  7740. // Get the interpolation between colors
  7741. function getValue(start, end, percent, index) {
  7742. var value = start[index] + (end[index] - start[index]) * percent;
  7743. return value;
  7744. } // convert to hex
  7745. function arr2hex(arr) {
  7746. return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
  7747. }
  7748. function toRGBValue(value) {
  7749. value = Math.round(value);
  7750. value = value.toString(16);
  7751. if (value.length === 1) {
  7752. value = '0' + value;
  7753. }
  7754. return value;
  7755. }
  7756. function calColor(colors, percent) {
  7757. var steps = colors.length - 1;
  7758. var step = Math.floor(steps * percent);
  7759. var left = steps * percent - step;
  7760. var start = colors[step];
  7761. var end = step === steps ? start : colors[step + 1];
  7762. var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
  7763. return rgb;
  7764. }
  7765. function hex2arr(str) {
  7766. var arr = [];
  7767. arr.push(parseInt(str.substr(1, 2), 16));
  7768. arr.push(parseInt(str.substr(3, 2), 16));
  7769. arr.push(parseInt(str.substr(5, 2), 16));
  7770. return arr;
  7771. }
  7772. var colorCache = {
  7773. black: '#000000',
  7774. blue: '#0000ff',
  7775. grey: '#808080',
  7776. green: '#008000',
  7777. orange: '#ffa500',
  7778. pink: '#ffc0cb',
  7779. purple: '#800080',
  7780. red: '#ff0000',
  7781. white: '#ffffff',
  7782. yellow: '#ffff00'
  7783. };
  7784. var ColorUtil = {
  7785. /**
  7786. * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
  7787. * @param {String} color color value
  7788. * @return {String} Returns a hexadecimal string
  7789. */
  7790. toHex: function toHex(color) {
  7791. if (colorCache[color]) {
  7792. return colorCache[color];
  7793. }
  7794. if (color[0] === '#') {
  7795. if (color.length === 7) {
  7796. return color;
  7797. }
  7798. var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
  7799. return '#' + r + r + g + g + b + b;
  7800. }); // hex3 to hex6
  7801. colorCache[color] = hex;
  7802. return hex;
  7803. } // rgb/rgba to hex
  7804. var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  7805. rst.shift();
  7806. rst = arr2hex(rst);
  7807. colorCache[color] = rst;
  7808. return rst;
  7809. },
  7810. hex2arr: hex2arr,
  7811. /**
  7812. * handle the gradient color
  7813. * @param {Array} colors the colors
  7814. * @return {String} return the color value
  7815. */
  7816. gradient: function gradient(colors) {
  7817. var points = [];
  7818. if ((0, _util.isString)(colors)) {
  7819. colors = colors.split('-');
  7820. }
  7821. (0, _util.each)(colors, function (color) {
  7822. if (color.indexOf('#') === -1) {
  7823. color = ColorUtil.toHex(color);
  7824. }
  7825. points.push(hex2arr(color));
  7826. });
  7827. return function (percent) {
  7828. return calColor(points, percent);
  7829. };
  7830. }
  7831. };
  7832. var _default = ColorUtil;
  7833. exports["default"] = _default;
  7834. /***/ }),
  7835. /* 167 */
  7836. /***/ (function(module, exports, __webpack_require__) {
  7837. "use strict";
  7838. var Util = __webpack_require__(0);
  7839. var Global = __webpack_require__(6);
  7840. var Scale = __webpack_require__(168);
  7841. var SCALE_TYPES_MAP = {
  7842. linear: 'Linear',
  7843. cat: 'Cat',
  7844. timeCat: 'TimeCat',
  7845. identity: 'Identity'
  7846. };
  7847. function isFullCircle(coord) {
  7848. if (!coord.isPolar) {
  7849. return false;
  7850. }
  7851. var startAngle = coord.startAngle;
  7852. var endAngle = coord.endAngle;
  7853. if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
  7854. return false;
  7855. }
  7856. return true;
  7857. }
  7858. function clearObj(obj) {
  7859. Object.keys(obj).forEach(function (key) {
  7860. delete obj[key];
  7861. });
  7862. }
  7863. var ScaleController = /*#__PURE__*/function () {
  7864. function ScaleController(cfg) {
  7865. // defs 列定义
  7866. this.defs = {}; // 已经实例化的scale
  7867. this.scales = {};
  7868. Util.mix(this, cfg);
  7869. }
  7870. var _proto = ScaleController.prototype;
  7871. _proto.setFieldDef = function setFieldDef(field, cfg) {
  7872. var defs = this.defs;
  7873. if (Util.isObject(field)) {
  7874. Util.mix(defs, field);
  7875. } else {
  7876. defs[field] = cfg;
  7877. } // 因为可能同时变更多个scale,所以要把所有已实例化的scale都更新下
  7878. this.updateScales();
  7879. };
  7880. _proto._getDef = function _getDef(field) {
  7881. var defs = this.defs;
  7882. var def = null;
  7883. if (Global.scales[field] || defs[field]) {
  7884. def = Util.mix({}, Global.scales[field]);
  7885. Util.each(defs[field], function (v, k) {
  7886. if (Util.isNil(v)) {
  7887. delete def[k];
  7888. } else {
  7889. def[k] = v;
  7890. }
  7891. });
  7892. }
  7893. return def;
  7894. };
  7895. _proto._getDefaultType = function _getDefaultType(field, data, def) {
  7896. if (def && def.type) {
  7897. return def.type;
  7898. }
  7899. var type = 'linear';
  7900. var value = Util.Array.firstValue(data, field);
  7901. if (Util.isArray(value)) {
  7902. value = value[0];
  7903. }
  7904. if (Util.isString(value)) {
  7905. type = 'cat';
  7906. }
  7907. return type;
  7908. };
  7909. _proto._getScaleDef = function _getScaleDef(type, field, data, def) {
  7910. var values;
  7911. if (def && def.values) {
  7912. values = def.values;
  7913. } else {
  7914. values = Util.Array.values(data, field);
  7915. }
  7916. var cfg = {
  7917. field: field,
  7918. values: values
  7919. };
  7920. if (type !== 'cat' && type !== 'timeCat') {
  7921. if (!def || !(def.min && def.max)) {
  7922. var _Util$Array$getRange = Util.Array.getRange(values),
  7923. min = _Util$Array$getRange.min,
  7924. max = _Util$Array$getRange.max;
  7925. cfg.min = min;
  7926. cfg.max = max;
  7927. cfg.nice = true;
  7928. }
  7929. } else {
  7930. cfg.isRounding = false; // used for tickCount calculation
  7931. }
  7932. return cfg;
  7933. } // 调整range,为了让图形居中
  7934. ;
  7935. _proto._adjustRange = function _adjustRange(type, cfg) {
  7936. var range = cfg.range,
  7937. values = cfg.values; // 如果是线性, 或者有自定义range都不处理
  7938. if (type === 'linear' || range || !values) {
  7939. return cfg;
  7940. }
  7941. var count = values.length; // 单只有一条数据时,在中间显示
  7942. if (count === 1) {
  7943. cfg.range = [0.5, 1];
  7944. } else {
  7945. var chart = this.chart;
  7946. var coord = chart.get('coord');
  7947. var widthRatio = Global.widthRatio.multiplePie;
  7948. var offset = 0;
  7949. if (isFullCircle(coord)) {
  7950. if (!coord.transposed) {
  7951. cfg.range = [0, 1 - 1 / count];
  7952. } else {
  7953. offset = 1 / count * widthRatio;
  7954. cfg.range = [offset / 2, 1 - offset / 2];
  7955. }
  7956. } else {
  7957. // 为了让图形居中,所以才设置range
  7958. offset = 1 / count * 1 / 2;
  7959. cfg.range = [offset, 1 - offset];
  7960. }
  7961. }
  7962. return cfg;
  7963. };
  7964. _proto._getScaleCfg = function _getScaleCfg(field, data) {
  7965. var self = this;
  7966. var def = self._getDef(field);
  7967. if (!data || !data.length) {
  7968. if (def && def.type) {
  7969. def.field = field;
  7970. return {
  7971. type: SCALE_TYPES_MAP[def.type],
  7972. cfg: def
  7973. };
  7974. }
  7975. return {
  7976. type: 'Identity',
  7977. cfg: {
  7978. value: field,
  7979. field: field.toString(),
  7980. values: [field]
  7981. }
  7982. };
  7983. }
  7984. var firstObj = data[0];
  7985. var firstValue = firstObj[field];
  7986. if (firstValue === null) {
  7987. firstValue = Util.Array.firstValue(data, field);
  7988. }
  7989. if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
  7990. return {
  7991. type: 'Identity',
  7992. cfg: {
  7993. value: field,
  7994. field: field.toString(),
  7995. values: [field]
  7996. }
  7997. };
  7998. }
  7999. var type = self._getDefaultType(field, data, def);
  8000. var cfg = self._getScaleDef(type, field, data, def);
  8001. def && Util.mix(cfg, def);
  8002. cfg = this._adjustRange(type, cfg);
  8003. return {
  8004. type: SCALE_TYPES_MAP[type],
  8005. cfg: cfg
  8006. };
  8007. };
  8008. _proto.createScale = function createScale(field, data) {
  8009. var scales = this.scales;
  8010. var _this$_getScaleCfg = this._getScaleCfg(field, data),
  8011. type = _this$_getScaleCfg.type,
  8012. cfg = _this$_getScaleCfg.cfg;
  8013. var scale = scales[field]; // 如果已经存在,且类型相等时直接返回
  8014. if (scale && SCALE_TYPES_MAP[scale.type] === type) {
  8015. scale.change(cfg);
  8016. return scale;
  8017. }
  8018. var newScale = new Scale[type](cfg);
  8019. scales[field] = newScale;
  8020. return newScale;
  8021. };
  8022. _proto._updateScale = function _updateScale(scale) {
  8023. var field = scale.field; // 因为每个field的数据都会不同
  8024. var data = this.chart._getScaleData(field);
  8025. var _this$_getScaleCfg2 = this._getScaleCfg(field, data),
  8026. cfg = _this$_getScaleCfg2.cfg;
  8027. scale.change(cfg);
  8028. };
  8029. _proto.updateScales = function updateScales() {
  8030. var _this = this;
  8031. var scales = this.scales; // 修改完列定义后,需要更新已经实例化的scale
  8032. // 如果是还没有实例化的,在geom初始化的时候会被实例化,所以这里可以不用更新
  8033. Util.each(scales, function (scale) {
  8034. _this._updateScale(scale);
  8035. });
  8036. } // 调整scale从0开始
  8037. ;
  8038. _proto.adjustStartZero = function adjustStartZero(scale) {
  8039. var defs = this.defs;
  8040. var field = scale.field,
  8041. min = scale.min,
  8042. max = scale.max; // 如果有定义,则不处理
  8043. if (defs[field] && defs[field].min) {
  8044. return;
  8045. }
  8046. if (min > 0) {
  8047. scale.change({
  8048. min: 0
  8049. });
  8050. } else if (max < 0) {
  8051. scale.change({
  8052. max: 0
  8053. });
  8054. }
  8055. };
  8056. _proto.clear = function clear() {
  8057. // this.defs = {};
  8058. // this.scales = {};
  8059. clearObj(this.defs);
  8060. clearObj(this.scales);
  8061. this.data = null;
  8062. };
  8063. return ScaleController;
  8064. }();
  8065. module.exports = ScaleController;
  8066. /***/ }),
  8067. /* 168 */
  8068. /***/ (function(module, exports, __webpack_require__) {
  8069. "use strict";
  8070. var Scale = __webpack_require__(26);
  8071. __webpack_require__(169);
  8072. __webpack_require__(172);
  8073. __webpack_require__(69);
  8074. module.exports = Scale;
  8075. /***/ }),
  8076. /* 169 */
  8077. /***/ (function(module, exports, __webpack_require__) {
  8078. function _inheritsLoose(subClass, superClass) {
  8079. subClass.prototype = Object.create(superClass.prototype);
  8080. subClass.prototype.constructor = subClass;
  8081. subClass.__proto__ = superClass;
  8082. }
  8083. /**
  8084. * @fileOverview The measurement of linear data scale function
  8085. * @author dxq613@gmail.com
  8086. */
  8087. var isNil = __webpack_require__(35);
  8088. var each = __webpack_require__(15);
  8089. var Base = __webpack_require__(26);
  8090. var numberAuto = __webpack_require__(170);
  8091. /**
  8092. * 线性度量
  8093. * @class Scale.Linear
  8094. */
  8095. var Linear = /*#__PURE__*/function (_Base) {
  8096. _inheritsLoose(Linear, _Base);
  8097. function Linear() {
  8098. return _Base.apply(this, arguments) || this;
  8099. }
  8100. var _proto = Linear.prototype;
  8101. _proto._initDefaultCfg = function _initDefaultCfg() {
  8102. _Base.prototype._initDefaultCfg.call(this);
  8103. var self = this;
  8104. self.type = 'linear';
  8105. self.isLinear = true;
  8106. /**
  8107. * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
  8108. * @type {Boolean}
  8109. * @default false
  8110. */
  8111. self.nice = false;
  8112. /**
  8113. * min value of the scale
  8114. * @type {Number}
  8115. * @default null
  8116. */
  8117. self.min = null;
  8118. /**
  8119. * min value limitted of the scale
  8120. * @type {Number}
  8121. * @default null
  8122. */
  8123. self.minLimit = null;
  8124. /**
  8125. * max value of the scale
  8126. * @type {Number}
  8127. * @default null
  8128. */
  8129. self.max = null;
  8130. /**
  8131. * max value limitted of the scale
  8132. * @type {Number}
  8133. * @default null
  8134. */
  8135. self.maxLimit = null;
  8136. /**
  8137. * 自动生成标记时的个数
  8138. * @type {Number}
  8139. * @default null
  8140. */
  8141. self.tickCount = null;
  8142. /**
  8143. * 坐标轴点之间的间距,指的是真实数据的差值
  8144. * @type {Number}
  8145. * @default null
  8146. */
  8147. self.tickInterval = null;
  8148. /**
  8149. * 坐标轴点之间的最小间距,指的是真实数据的差值
  8150. * @type {Number}
  8151. * @default null
  8152. */
  8153. self.minTickInterval = null;
  8154. /**
  8155. * 用于计算坐标点时逼近的数组
  8156. * @type {Array}
  8157. */
  8158. self.snapArray = null;
  8159. }
  8160. /**
  8161. * @protected
  8162. * @override
  8163. */
  8164. ;
  8165. _proto.init = function init() {
  8166. var self = this;
  8167. if (!self.ticks) {
  8168. self.min = self.translate(self.min);
  8169. self.max = self.translate(self.max);
  8170. self.initTicks();
  8171. } else {
  8172. var ticks = self.ticks;
  8173. var firstValue = self.translate(ticks[0]);
  8174. var lastValue = self.translate(ticks[ticks.length - 1]);
  8175. if (isNil(self.min) || self.min > firstValue) {
  8176. self.min = firstValue;
  8177. }
  8178. if (isNil(self.max) || self.max < lastValue) {
  8179. self.max = lastValue;
  8180. }
  8181. }
  8182. }
  8183. /**
  8184. * 计算坐标点
  8185. * @protected
  8186. * @return {Array} 计算完成的坐标点
  8187. */
  8188. ;
  8189. _proto.calculateTicks = function calculateTicks() {
  8190. var min = this.min,
  8191. max = this.max,
  8192. minLimit = this.minLimit,
  8193. maxLimit = this.maxLimit,
  8194. tickCount = this.tickCount,
  8195. tickInterval = this.tickInterval,
  8196. minTickInterval = this.minTickInterval,
  8197. snapArray = this.snapArray;
  8198. if (tickCount === 1) {
  8199. throw new Error('linear scale\'tickCount should not be 1');
  8200. }
  8201. if (max < min) {
  8202. throw new Error("max: " + max + " should not be less than min: " + min);
  8203. }
  8204. var tmp = numberAuto({
  8205. min: min,
  8206. max: max,
  8207. minLimit: minLimit,
  8208. maxLimit: maxLimit,
  8209. minCount: tickCount,
  8210. maxCount: tickCount,
  8211. interval: tickInterval,
  8212. minTickInterval: minTickInterval,
  8213. snapArray: snapArray
  8214. });
  8215. return tmp.ticks;
  8216. } // 初始化ticks
  8217. ;
  8218. _proto.initTicks = function initTicks() {
  8219. var self = this;
  8220. var calTicks = self.calculateTicks();
  8221. if (self.nice) {
  8222. // 如果需要优化显示的tick
  8223. self.ticks = calTicks;
  8224. self.min = calTicks[0];
  8225. self.max = calTicks[calTicks.length - 1];
  8226. } else {
  8227. var ticks = [];
  8228. each(calTicks, function (tick) {
  8229. if (tick >= self.min && tick <= self.max) {
  8230. ticks.push(tick);
  8231. }
  8232. }); // 如果 ticks 为空,直接输入最小值、最大值
  8233. if (!ticks.length) {
  8234. ticks.push(self.min);
  8235. ticks.push(self.max);
  8236. }
  8237. self.ticks = ticks;
  8238. }
  8239. }
  8240. /**
  8241. * @override
  8242. */
  8243. ;
  8244. _proto.scale = function scale(value) {
  8245. if (isNil(value)) {
  8246. return NaN;
  8247. }
  8248. var max = this.max;
  8249. var min = this.min;
  8250. if (max === min) {
  8251. return 0;
  8252. }
  8253. var percent = (value - min) / (max - min);
  8254. var rangeMin = this.rangeMin();
  8255. var rangeMax = this.rangeMax();
  8256. return rangeMin + percent * (rangeMax - rangeMin);
  8257. }
  8258. /**
  8259. * @override
  8260. */
  8261. ;
  8262. _proto.invert = function invert(value) {
  8263. var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
  8264. return this.min + percent * (this.max - this.min);
  8265. };
  8266. return Linear;
  8267. }(Base);
  8268. Base.Linear = Linear;
  8269. module.exports = Linear;
  8270. /***/ }),
  8271. /* 170 */
  8272. /***/ (function(module, exports, __webpack_require__) {
  8273. /**
  8274. * @fileOverview 自动计算数字坐标轴
  8275. * @author dxq613@gmail.com
  8276. */
  8277. var isNil = __webpack_require__(35);
  8278. var isNumber = __webpack_require__(36);
  8279. var AutoUtil = __webpack_require__(171);
  8280. var MIN_COUNT = 5;
  8281. var MAX_COUNT = 7;
  8282. var SNAP_COUNT_ARRAY = [0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
  8283. var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
  8284. var EPS = 1e-12;
  8285. module.exports = function (info) {
  8286. var min = info.min;
  8287. var max = info.max;
  8288. var interval = info.interval;
  8289. var minTickInterval = info.minTickInterval;
  8290. var ticks = [];
  8291. var minCount = info.minCount || MIN_COUNT;
  8292. var maxCount = info.maxCount || MAX_COUNT;
  8293. var isFixedCount = minCount === maxCount; // 是否限定死了个数
  8294. var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
  8295. var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
  8296. var avgCount = (minCount + maxCount) / 2;
  8297. var count = avgCount; // 用户传入的逼近数组
  8298. var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
  8299. if (min === minLimit && max === maxLimit && isFixedCount) {
  8300. interval = (max - min) / (count - 1);
  8301. }
  8302. if (isNil(min)) {
  8303. min = 0;
  8304. }
  8305. if (isNil(max)) {
  8306. max = 0;
  8307. }
  8308. if (Math.abs(max - min) < EPS) {
  8309. if (min === 0) {
  8310. max = 1;
  8311. } else {
  8312. if (min > 0) {
  8313. min = 0;
  8314. } else {
  8315. max = 0;
  8316. }
  8317. }
  8318. if (max - min < 5 && !interval && max - min >= 1) {
  8319. interval = 1;
  8320. }
  8321. }
  8322. if (isNil(interval)) {
  8323. // 计算间距
  8324. var temp = (max - min) / (avgCount - 1);
  8325. interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
  8326. if (maxCount !== minCount) {
  8327. count = parseInt((max - min) / interval, 10);
  8328. if (count > maxCount) {
  8329. count = maxCount;
  8330. }
  8331. if (count < minCount) {
  8332. count = minCount;
  8333. } // 不确定tick的个数时,使得tick偏小
  8334. interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
  8335. }
  8336. } // interval should not be less than minTickInterval
  8337. if (isNumber(minTickInterval) && interval < minTickInterval) {
  8338. interval = minTickInterval;
  8339. }
  8340. if (info.interval || maxCount !== minCount) {
  8341. // 校正 max 和 min
  8342. max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
  8343. min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
  8344. count = Math.round((max - min) / interval);
  8345. min = AutoUtil.fixedBase(min, interval);
  8346. max = AutoUtil.fixedBase(max, interval);
  8347. } else {
  8348. avgCount = parseInt(avgCount, 10); // 取整
  8349. var avg = (max + min) / 2;
  8350. var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
  8351. var sideCount = Math.floor((avgCount - 2) / 2);
  8352. var maxTick = avgTick + sideCount * interval;
  8353. var minTick;
  8354. if (avgCount % 2 === 0) {
  8355. minTick = avgTick - sideCount * interval;
  8356. } else {
  8357. minTick = avgTick - (sideCount + 1) * interval;
  8358. }
  8359. var prevMaxTick = null; // 如果减去intervl, fixBase后,新的minTick没有大于之前的值,就退出,防止死循环
  8360. while (maxTick < max && (prevMaxTick === null || maxTick > prevMaxTick)) {
  8361. // 保证计算出来的刻度最大值 maxTick 不小于数据最大值 max
  8362. prevMaxTick = maxTick;
  8363. maxTick = AutoUtil.fixedBase(maxTick + interval, interval);
  8364. }
  8365. var prevMinTick = null; // 如果减去intervl, fixBase后,新的minTick没有小于之前的值,就退出,防止死循环
  8366. while (minTick > min && (prevMinTick === null || minTick < prevMinTick)) {
  8367. // 保证计算出来的刻度最小值 minTick 不小于数据最大值 min
  8368. prevMinTick = minTick;
  8369. minTick = AutoUtil.fixedBase(minTick - interval, interval); // 防止超常浮点数计算问题
  8370. }
  8371. max = maxTick;
  8372. min = minTick;
  8373. }
  8374. max = Math.min(max, maxLimit);
  8375. min = Math.max(min, minLimit);
  8376. ticks.push(min);
  8377. for (var i = 1; i < count; i++) {
  8378. var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
  8379. if (tickValue < max) {
  8380. ticks.push(tickValue);
  8381. }
  8382. }
  8383. if (ticks[ticks.length - 1] < max) {
  8384. ticks.push(max);
  8385. }
  8386. return {
  8387. min: min,
  8388. max: max,
  8389. interval: interval,
  8390. count: count,
  8391. ticks: ticks
  8392. };
  8393. };
  8394. /***/ }),
  8395. /* 171 */
  8396. /***/ (function(module, exports) {
  8397. /**
  8398. * @fileOverview 计算方法
  8399. * @author dxq613@gmail.com
  8400. */
  8401. // 如果小数点后面超过 10 位浮点数时进行一下处理
  8402. var DECIMAL_LENGTH = 12; // 获取系数
  8403. function getFactor(v) {
  8404. var factor = 1;
  8405. if (v === Infinity || v === -Infinity) {
  8406. throw new Error('Not support Infinity!');
  8407. }
  8408. if (v < 1) {
  8409. var count = 0;
  8410. while (v < 1) {
  8411. factor = factor / 10;
  8412. v = v * 10;
  8413. count++;
  8414. } // 浮点数计算出现问题
  8415. if (factor.toString().length > DECIMAL_LENGTH) {
  8416. factor = parseFloat(factor.toFixed(count));
  8417. }
  8418. } else {
  8419. while (v > 10) {
  8420. factor = factor * 10;
  8421. v = v / 10;
  8422. }
  8423. }
  8424. return factor;
  8425. } // 取小于当前值的
  8426. function arrayFloor(values, value) {
  8427. var length = values.length;
  8428. if (length === 0) {
  8429. return NaN;
  8430. }
  8431. var pre = values[0];
  8432. if (value < values[0]) {
  8433. return NaN;
  8434. }
  8435. if (value >= values[length - 1]) {
  8436. return values[length - 1];
  8437. }
  8438. for (var i = 1; i < values.length; i++) {
  8439. if (value < values[i]) {
  8440. break;
  8441. }
  8442. pre = values[i];
  8443. }
  8444. return pre;
  8445. } // 大于当前值的第一个
  8446. function arrayCeiling(values, value) {
  8447. var length = values.length;
  8448. if (length === 0) {
  8449. return NaN;
  8450. } // var pre = values[0];
  8451. var rst;
  8452. if (value > values[length - 1]) {
  8453. return NaN;
  8454. }
  8455. if (value < values[0]) {
  8456. return values[0];
  8457. }
  8458. for (var i = 1; i < values.length; i++) {
  8459. if (value <= values[i]) {
  8460. rst = values[i];
  8461. break;
  8462. }
  8463. }
  8464. return rst;
  8465. }
  8466. var Util = {
  8467. // 获取逼近的数值
  8468. snapFactorTo: function snapFactorTo(v, arr, snapType) {
  8469. // 假设 v = -512,isFloor = true
  8470. if (isNaN(v)) {
  8471. return NaN;
  8472. }
  8473. var factor = 1; // 计算系数
  8474. if (v !== 0) {
  8475. if (v < 0) {
  8476. factor = -1;
  8477. }
  8478. v = v * factor; // v = 512
  8479. var tmpFactor = getFactor(v);
  8480. factor = factor * tmpFactor; // factor = -100
  8481. v = v / tmpFactor; // v = 5.12
  8482. }
  8483. if (snapType === 'floor') {
  8484. v = Util.snapFloor(arr, v); // v = 5
  8485. } else if (snapType === 'ceil') {
  8486. v = Util.snapCeiling(arr, v); // v = 6
  8487. } else {
  8488. v = Util.snapTo(arr, v); // 四舍五入 5
  8489. }
  8490. var rst = parseFloat((v * factor).toPrecision(DECIMAL_LENGTH)); // 如果出现浮点数计算问题,需要处理一下
  8491. // 如果出现浮点数计算问题,需要处理一下
  8492. if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
  8493. var decimalVal = parseInt(1 / factor);
  8494. var symbol = factor > 0 ? 1 : -1;
  8495. rst = v / decimalVal * symbol;
  8496. }
  8497. return rst;
  8498. },
  8499. // 获取逼近的倍数
  8500. snapMultiple: function snapMultiple(v, base, snapType) {
  8501. var div;
  8502. if (snapType === 'ceil') {
  8503. div = Math.ceil(v / base);
  8504. } else if (snapType === 'floor') {
  8505. div = Math.floor(v / base);
  8506. } else {
  8507. div = Math.round(v / base);
  8508. }
  8509. return div * base;
  8510. },
  8511. /**
  8512. * 获取逼近的值,用于对齐数据
  8513. * @param {Array} values 数据集合
  8514. * @param {Number} value 数值
  8515. * @return {Number} 逼近的值
  8516. */
  8517. snapTo: function snapTo(values, value) {
  8518. // 这里假定values是升序排列
  8519. var floorVal = arrayFloor(values, value);
  8520. var ceilingVal = arrayCeiling(values, value);
  8521. if (isNaN(floorVal) || isNaN(ceilingVal)) {
  8522. if (values[0] >= value) {
  8523. return values[0];
  8524. }
  8525. var last = values[values.length - 1];
  8526. if (last <= value) {
  8527. return last;
  8528. }
  8529. }
  8530. if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
  8531. return floorVal;
  8532. }
  8533. return ceilingVal;
  8534. },
  8535. /**
  8536. * 获取逼近的最小值,用于对齐数据
  8537. * @param {Array} values 数据集合
  8538. * @param {Number} value 数值
  8539. * @return {Number} 逼近的最小值
  8540. */
  8541. snapFloor: function snapFloor(values, value) {
  8542. // 这里假定values是升序排列
  8543. return arrayFloor(values, value);
  8544. },
  8545. /**
  8546. * 获取逼近的最大值,用于对齐数据
  8547. * @param {Array} values 数据集合
  8548. * @param {Number} value 数值
  8549. * @return {Number} 逼近的最大值
  8550. */
  8551. snapCeiling: function snapCeiling(values, value) {
  8552. // 这里假定values是升序排列
  8553. return arrayCeiling(values, value);
  8554. },
  8555. fixedBase: function fixedBase(v, base) {
  8556. var str = base.toString();
  8557. var index = str.indexOf('.');
  8558. var indexOfExp = str.indexOf('e-'); // 判断是否带小数点,1.000001 1.23e-9
  8559. if (index < 0 && indexOfExp < 0) {
  8560. // base为整数
  8561. return Math.round(v);
  8562. }
  8563. var length = indexOfExp >= 0 ? parseInt(str.substr(indexOfExp + 2), 10) : str.substr(index + 1).length;
  8564. if (length > 20) {
  8565. length = 20;
  8566. }
  8567. return parseFloat(v.toFixed(length));
  8568. }
  8569. };
  8570. module.exports = Util;
  8571. /***/ }),
  8572. /* 172 */
  8573. /***/ (function(module, exports, __webpack_require__) {
  8574. function _inheritsLoose(subClass, superClass) {
  8575. subClass.prototype = Object.create(superClass.prototype);
  8576. subClass.prototype.constructor = subClass;
  8577. subClass.__proto__ = superClass;
  8578. }
  8579. var Base = __webpack_require__(26);
  8580. var isNumber = __webpack_require__(36);
  8581. var Identity = /*#__PURE__*/function (_Base) {
  8582. _inheritsLoose(Identity, _Base);
  8583. function Identity() {
  8584. return _Base.apply(this, arguments) || this;
  8585. }
  8586. var _proto = Identity.prototype;
  8587. _proto._initDefaultCfg = function _initDefaultCfg() {
  8588. _Base.prototype._initDefaultCfg.call(this);
  8589. this.isIdentity = true;
  8590. this.type = 'identity';
  8591. /**
  8592. * 常量值
  8593. * @type {*}
  8594. */
  8595. this.value = null;
  8596. }
  8597. /**
  8598. * @override
  8599. */
  8600. ;
  8601. _proto.getText = function getText() {
  8602. return this.value.toString();
  8603. }
  8604. /**
  8605. * @override
  8606. */
  8607. ;
  8608. _proto.scale = function scale(value) {
  8609. if (this.value !== value && isNumber(value)) {
  8610. return value;
  8611. }
  8612. return this.range[0];
  8613. }
  8614. /**
  8615. * @override
  8616. */
  8617. ;
  8618. _proto.invert = function invert() {
  8619. return this.value;
  8620. };
  8621. return Identity;
  8622. }(Base);
  8623. Base.Identity = Identity;
  8624. module.exports = Identity;
  8625. /***/ }),
  8626. /* 173 */
  8627. /***/ (function(module, exports, __webpack_require__) {
  8628. "use strict";
  8629. var Util = __webpack_require__(0);
  8630. var Axis = __webpack_require__(174);
  8631. var Global = __webpack_require__(6);
  8632. var _require = __webpack_require__(16),
  8633. Shape = _require.Shape;
  8634. function formatTicks(ticks) {
  8635. var tmp = ticks.slice(0);
  8636. if (tmp.length > 0) {
  8637. var first = tmp[0];
  8638. var last = tmp[tmp.length - 1];
  8639. if (first.value !== 0) {
  8640. tmp.unshift({
  8641. value: 0
  8642. });
  8643. }
  8644. if (last.value !== 1) {
  8645. tmp.push({
  8646. value: 1
  8647. });
  8648. }
  8649. }
  8650. return tmp;
  8651. }
  8652. var AxisController = /*#__PURE__*/function () {
  8653. function AxisController(cfg) {
  8654. this.axisCfg = {};
  8655. this.frontPlot = null;
  8656. this.backPlot = null;
  8657. this.axes = {}; // store the axes's options
  8658. Util.mix(this, cfg);
  8659. }
  8660. var _proto = AxisController.prototype;
  8661. _proto._isHide = function _isHide(field) {
  8662. var axisCfg = this.axisCfg;
  8663. return !axisCfg || axisCfg[field] === false;
  8664. };
  8665. _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
  8666. var position = '';
  8667. var field = scale.field;
  8668. var axisCfg = this.axisCfg;
  8669. if (axisCfg[field] && axisCfg[field].position) {
  8670. position = axisCfg[field].position;
  8671. } else if (dimType === 'x') {
  8672. position = transposed ? 'left' : 'bottom';
  8673. } else if (dimType === 'y') {
  8674. position = index ? 'right' : 'left';
  8675. if (transposed) {
  8676. position = 'bottom';
  8677. }
  8678. }
  8679. return position;
  8680. };
  8681. _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
  8682. var start;
  8683. var end;
  8684. var factor = 1; // Mark clockwise or counterclockwise
  8685. if (dimType === 'x') {
  8686. start = {
  8687. x: 0,
  8688. y: 0
  8689. };
  8690. end = {
  8691. x: 1,
  8692. y: 0
  8693. };
  8694. } else {
  8695. if (position === 'right') {
  8696. // there will be several y axes
  8697. start = {
  8698. x: 1,
  8699. y: 0
  8700. };
  8701. end = {
  8702. x: 1,
  8703. y: 1
  8704. };
  8705. } else {
  8706. start = {
  8707. x: 0,
  8708. y: 0
  8709. };
  8710. end = {
  8711. x: 0,
  8712. y: 1
  8713. };
  8714. factor = -1;
  8715. }
  8716. }
  8717. if (coord.transposed) {
  8718. factor *= -1;
  8719. }
  8720. return {
  8721. offsetFactor: factor,
  8722. start: coord.convertPoint(start),
  8723. end: coord.convertPoint(end)
  8724. };
  8725. };
  8726. _proto._getCircleCfg = function _getCircleCfg(coord) {
  8727. return {
  8728. startAngle: coord.startAngle,
  8729. endAngle: coord.endAngle,
  8730. center: coord.center,
  8731. radius: coord.circleRadius
  8732. };
  8733. };
  8734. _proto._getRadiusCfg = function _getRadiusCfg(coord) {
  8735. var transposed = coord.transposed;
  8736. var start;
  8737. var end;
  8738. if (transposed) {
  8739. start = {
  8740. x: 0,
  8741. y: 0
  8742. };
  8743. end = {
  8744. x: 1,
  8745. y: 0
  8746. };
  8747. } else {
  8748. start = {
  8749. x: 0,
  8750. y: 0
  8751. };
  8752. end = {
  8753. x: 0,
  8754. y: 1
  8755. };
  8756. }
  8757. return {
  8758. offsetFactor: -1,
  8759. start: coord.convertPoint(start),
  8760. end: coord.convertPoint(end)
  8761. };
  8762. };
  8763. _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
  8764. var self = this;
  8765. var axisCfg = this.axisCfg;
  8766. var ticks = scale.getTicks();
  8767. var cfg = Util.deepMix({
  8768. ticks: ticks,
  8769. frontContainer: this.frontPlot,
  8770. backContainer: this.backPlot
  8771. }, defaultCfg, axisCfg[scale.field]);
  8772. var labels = [];
  8773. var label = cfg.label;
  8774. var count = ticks.length;
  8775. var maxWidth = 0;
  8776. var maxHeight = 0;
  8777. var labelCfg = label;
  8778. Util.each(ticks, function (tick, index) {
  8779. if (Util.isFunction(label)) {
  8780. var executedLabel = label(tick.text, index, count);
  8781. labelCfg = executedLabel ? Util.mix({}, Global._defaultAxis.label, executedLabel) : null;
  8782. }
  8783. if (labelCfg) {
  8784. var textStyle = {};
  8785. if (labelCfg.textAlign) {
  8786. textStyle.textAlign = labelCfg.textAlign;
  8787. }
  8788. if (labelCfg.textBaseline) {
  8789. textStyle.textBaseline = labelCfg.textBaseline;
  8790. }
  8791. var axisLabel = new Shape.Text({
  8792. className: 'axis-label',
  8793. attrs: Util.mix({
  8794. x: 0,
  8795. y: 0,
  8796. text: tick.text,
  8797. fontFamily: self.chart.get('canvas').get('fontFamily')
  8798. }, labelCfg),
  8799. value: tick.value,
  8800. textStyle: textStyle,
  8801. top: labelCfg.top,
  8802. context: self.chart.get('canvas').get('context')
  8803. });
  8804. labels.push(axisLabel);
  8805. var _axisLabel$getBBox = axisLabel.getBBox(),
  8806. width = _axisLabel$getBBox.width,
  8807. height = _axisLabel$getBBox.height;
  8808. maxWidth = Math.max(maxWidth, width);
  8809. maxHeight = Math.max(maxHeight, height);
  8810. }
  8811. });
  8812. cfg.labels = labels;
  8813. cfg.maxWidth = maxWidth;
  8814. cfg.maxHeight = maxHeight;
  8815. return cfg;
  8816. };
  8817. _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
  8818. if (index === void 0) {
  8819. index = '';
  8820. }
  8821. var self = this;
  8822. var coordType = coord.type;
  8823. var transposed = coord.transposed;
  8824. var type;
  8825. var key;
  8826. var defaultCfg;
  8827. if (coordType === 'cartesian' || coordType === 'rect') {
  8828. var position = self._getLinePosition(scale, dimType, index, transposed);
  8829. defaultCfg = Global.axis[position];
  8830. defaultCfg.position = position;
  8831. type = 'Line';
  8832. key = position;
  8833. } else {
  8834. if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
  8835. defaultCfg = Global.axis.circle;
  8836. type = 'Circle';
  8837. key = 'circle';
  8838. } else {
  8839. defaultCfg = Global.axis.radius;
  8840. type = 'Line';
  8841. key = 'radius';
  8842. }
  8843. }
  8844. var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
  8845. cfg.type = type;
  8846. cfg.dimType = dimType;
  8847. cfg.verticalScale = verticalScale;
  8848. cfg.index = index;
  8849. this.axes[key] = cfg;
  8850. };
  8851. _proto.createAxis = function createAxis(coord, xScale, yScales) {
  8852. var self = this;
  8853. if (xScale && !self._isHide(xScale.field)) {
  8854. self._createAxis(coord, xScale, yScales[0], 'x');
  8855. }
  8856. Util.each(yScales, function (yScale, index) {
  8857. if (!self._isHide(yScale.field)) {
  8858. self._createAxis(coord, yScale, xScale, 'y', index);
  8859. }
  8860. });
  8861. var axes = this.axes;
  8862. var chart = self.chart;
  8863. if (chart._isAutoPadding()) {
  8864. var userPadding = Util.parsePadding(chart.get('padding'));
  8865. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  8866. var legendRange = chart.get('legendRange') || {
  8867. top: 0,
  8868. right: 0,
  8869. bottom: 0,
  8870. left: 0
  8871. };
  8872. var padding = [userPadding[0] === 'auto' ? legendRange.top + appendPadding[0] * 2 : userPadding[0], userPadding[1] === 'auto' ? legendRange.right + appendPadding[1] : userPadding[1], userPadding[2] === 'auto' ? legendRange.bottom + appendPadding[2] : userPadding[2], userPadding[3] === 'auto' ? legendRange.left + appendPadding[3] : userPadding[3]];
  8873. if (coord.isPolar) {
  8874. var circleAxis = axes.circle;
  8875. if (circleAxis) {
  8876. var maxHeight = circleAxis.maxHeight,
  8877. maxWidth = circleAxis.maxWidth,
  8878. labelOffset = circleAxis.labelOffset;
  8879. padding[0] += maxHeight + labelOffset;
  8880. padding[1] += maxWidth + labelOffset;
  8881. padding[2] += maxHeight + labelOffset;
  8882. padding[3] += maxWidth + labelOffset;
  8883. }
  8884. } else {
  8885. if (axes.right && userPadding[1] === 'auto') {
  8886. var _axes$right = axes.right,
  8887. _maxWidth = _axes$right.maxWidth,
  8888. _labelOffset = _axes$right.labelOffset;
  8889. padding[1] += _maxWidth + _labelOffset;
  8890. }
  8891. if (axes.left && userPadding[3] === 'auto') {
  8892. var _axes$left = axes.left,
  8893. _maxWidth2 = _axes$left.maxWidth,
  8894. _labelOffset2 = _axes$left.labelOffset;
  8895. padding[3] += _maxWidth2 + _labelOffset2;
  8896. }
  8897. if (axes.bottom && userPadding[2] === 'auto') {
  8898. var _axes$bottom = axes.bottom,
  8899. _maxHeight = _axes$bottom.maxHeight,
  8900. _labelOffset3 = _axes$bottom.labelOffset;
  8901. padding[2] += _maxHeight + _labelOffset3;
  8902. }
  8903. }
  8904. chart.set('_padding', padding);
  8905. chart._updateLayout(padding);
  8906. }
  8907. Util.each(axes, function (axis) {
  8908. var type = axis.type,
  8909. grid = axis.grid,
  8910. verticalScale = axis.verticalScale,
  8911. ticks = axis.ticks,
  8912. dimType = axis.dimType,
  8913. position = axis.position,
  8914. index = axis.index;
  8915. var appendCfg;
  8916. if (coord.isPolar) {
  8917. if (type === 'Line') {
  8918. appendCfg = self._getRadiusCfg(coord);
  8919. } else if (type === 'Circle') {
  8920. appendCfg = self._getCircleCfg(coord);
  8921. }
  8922. } else {
  8923. appendCfg = self._getLineCfg(coord, dimType, position);
  8924. }
  8925. if (grid && verticalScale) {
  8926. var gridPoints = [];
  8927. var verticalTicks = formatTicks(verticalScale.getTicks());
  8928. Util.each(ticks, function (tick) {
  8929. var subPoints = [];
  8930. Util.each(verticalTicks, function (verticalTick) {
  8931. var x = dimType === 'x' ? tick.value : verticalTick.value;
  8932. var y = dimType === 'x' ? verticalTick.value : tick.value;
  8933. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  8934. var point = coord.convertPoint({
  8935. x: x,
  8936. y: y
  8937. });
  8938. subPoints.push(point);
  8939. }
  8940. });
  8941. gridPoints.push({
  8942. points: subPoints,
  8943. _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
  8944. });
  8945. });
  8946. axis.gridPoints = gridPoints;
  8947. if (coord.isPolar) {
  8948. axis.center = coord.center;
  8949. axis.startAngle = coord.startAngle;
  8950. axis.endAngle = coord.endAngle;
  8951. }
  8952. }
  8953. appendCfg._id = 'axis-' + dimType;
  8954. if (!Util.isNil(index)) {
  8955. appendCfg._id = 'axis-' + dimType + index;
  8956. }
  8957. new Axis[type](Util.mix(axis, appendCfg));
  8958. });
  8959. };
  8960. _proto.clear = function clear() {
  8961. this.axes = {};
  8962. this.frontPlot.clear();
  8963. this.backPlot.clear();
  8964. };
  8965. return AxisController;
  8966. }();
  8967. module.exports = AxisController;
  8968. /***/ }),
  8969. /* 174 */
  8970. /***/ (function(module, exports, __webpack_require__) {
  8971. "use strict";
  8972. var Abstract = __webpack_require__(45);
  8973. __webpack_require__(175);
  8974. module.exports = Abstract;
  8975. /***/ }),
  8976. /* 175 */
  8977. /***/ (function(module, exports, __webpack_require__) {
  8978. "use strict";
  8979. var _interopRequireDefault = __webpack_require__(1);
  8980. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  8981. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  8982. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  8983. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  8984. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8985. var Util = __webpack_require__(0);
  8986. var Abstract = __webpack_require__(45);
  8987. var Line = /*#__PURE__*/function (_Abstract) {
  8988. (0, _inheritsLoose2["default"])(Line, _Abstract);
  8989. var _super = _createSuper(Line);
  8990. function Line() {
  8991. return _Abstract.apply(this, arguments) || this;
  8992. }
  8993. var _proto = Line.prototype;
  8994. _proto._initDefaultCfg = function _initDefaultCfg() {
  8995. _Abstract.prototype._initDefaultCfg.call(this);
  8996. this.start = null;
  8997. this.end = null;
  8998. };
  8999. _proto.getOffsetPoint = function getOffsetPoint(value) {
  9000. var start = this.start,
  9001. end = this.end;
  9002. return {
  9003. x: start.x + (end.x - start.x) * value,
  9004. y: start.y + (end.y - start.y) * value
  9005. };
  9006. };
  9007. _proto.getAxisVector = function getAxisVector() {
  9008. var start = this.start,
  9009. end = this.end;
  9010. return [end.x - start.x, end.y - start.y];
  9011. };
  9012. _proto.drawLine = function drawLine(lineCfg) {
  9013. var container = this.getContainer(lineCfg.top);
  9014. var start = this.start,
  9015. end = this.end;
  9016. container.addShape('line', {
  9017. className: 'axis-line',
  9018. attrs: Util.mix({
  9019. x1: start.x,
  9020. y1: start.y,
  9021. x2: end.x,
  9022. y2: end.y
  9023. }, lineCfg)
  9024. });
  9025. };
  9026. return Line;
  9027. }(Abstract);
  9028. Abstract.Line = Line;
  9029. module.exports = Line;
  9030. /***/ }),
  9031. /* 176 */
  9032. /***/ (function(module, exports, __webpack_require__) {
  9033. "use strict";
  9034. var _interopRequireDefault = __webpack_require__(1);
  9035. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9036. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9037. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9038. var _emit = _interopRequireDefault(__webpack_require__(42));
  9039. var _controller = _interopRequireDefault(__webpack_require__(177));
  9040. var _canvasElement = _interopRequireDefault(__webpack_require__(178));
  9041. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9042. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9043. var Util = __webpack_require__(0);
  9044. var Container = __webpack_require__(66);
  9045. var Group = __webpack_require__(67);
  9046. var _require = __webpack_require__(70),
  9047. requestAnimationFrame = _require.requestAnimationFrame;
  9048. var Canvas = /*#__PURE__*/function (_EventEmit) {
  9049. (0, _inheritsLoose2["default"])(Canvas, _EventEmit);
  9050. var _super = _createSuper(Canvas);
  9051. var _proto = Canvas.prototype;
  9052. _proto.get = function get(name) {
  9053. return this._attrs[name];
  9054. };
  9055. _proto.set = function set(name, value) {
  9056. this._attrs[name] = value;
  9057. };
  9058. function Canvas(cfg) {
  9059. var _this;
  9060. _this = _EventEmit.call(this) || this;
  9061. _this._attrs = Util.mix({
  9062. type: 'canvas',
  9063. children: []
  9064. }, cfg);
  9065. _this._initPixelRatio();
  9066. _this._initCanvas();
  9067. return _this;
  9068. }
  9069. _proto._initPixelRatio = function _initPixelRatio() {
  9070. var pixelRatio = this.get('pixelRatio');
  9071. if (!pixelRatio) {
  9072. this.set('pixelRatio', Util.getPixelRatio());
  9073. }
  9074. };
  9075. _proto.beforeDraw = function beforeDraw() {
  9076. var context = this._attrs.context;
  9077. var el = this._attrs.el;
  9078. context && context.clearRect && context.clearRect(0, 0, el.width, el.height);
  9079. };
  9080. _proto._initCanvas = function _initCanvas() {
  9081. var self = this;
  9082. var el = self.get('el');
  9083. var context = self.get('context');
  9084. if (!el && !context) {
  9085. throw new Error('Please specify the id, el or context of the chart!');
  9086. }
  9087. var canvas;
  9088. if (el) {
  9089. // DOMElement or String
  9090. canvas = Util.isString(el) ? Util.getDomById(el) : el;
  9091. } else {
  9092. // 说明没有指定el
  9093. canvas = _canvasElement["default"].create(context);
  9094. }
  9095. if (context && canvas && !canvas.getContext) {
  9096. canvas.getContext = function () {
  9097. return context;
  9098. };
  9099. }
  9100. var width = self.get('width');
  9101. if (!width) {
  9102. width = Util.getWidth(canvas);
  9103. }
  9104. var height = self.get('height');
  9105. if (!height) {
  9106. height = Util.getHeight(canvas);
  9107. }
  9108. self.set('canvas', this);
  9109. self.set('el', canvas);
  9110. self.set('context', context || canvas.getContext('2d'));
  9111. self.changeSize(width, height); // 初始化事件控制器
  9112. var eventController = new _controller["default"]({
  9113. canvas: this,
  9114. el: canvas
  9115. });
  9116. self.set('eventController', eventController);
  9117. };
  9118. _proto.changeSize = function changeSize(width, height) {
  9119. var pixelRatio = this.get('pixelRatio');
  9120. var canvasDOM = this.get('el'); // HTMLCanvasElement or canvasElement
  9121. // 浏览器环境设置style样式
  9122. if (canvasDOM.style) {
  9123. canvasDOM.style.width = width + 'px';
  9124. canvasDOM.style.height = height + 'px';
  9125. }
  9126. if (Util.isCanvasElement(canvasDOM)) {
  9127. canvasDOM.width = width * pixelRatio;
  9128. canvasDOM.height = height * pixelRatio;
  9129. if (pixelRatio !== 1) {
  9130. var ctx = this.get('context');
  9131. ctx.scale(pixelRatio, pixelRatio);
  9132. }
  9133. }
  9134. this.set('width', width);
  9135. this.set('height', height);
  9136. };
  9137. _proto.getWidth = function getWidth() {
  9138. var pixelRatio = this.get('pixelRatio');
  9139. var width = this.get('width');
  9140. return width * pixelRatio;
  9141. };
  9142. _proto.getHeight = function getHeight() {
  9143. var pixelRatio = this.get('pixelRatio');
  9144. var height = this.get('height');
  9145. return height * pixelRatio;
  9146. };
  9147. _proto.getPointByClient = function getPointByClient(clientX, clientY) {
  9148. var el = this.get('el');
  9149. var bbox = el.getBoundingClientRect();
  9150. var width = bbox.right - bbox.left;
  9151. var height = bbox.bottom - bbox.top;
  9152. return {
  9153. x: (clientX - bbox.left) * (el.width / width),
  9154. y: (clientY - bbox.top) * (el.height / height)
  9155. };
  9156. };
  9157. _proto._beginDraw = function _beginDraw() {
  9158. this._attrs.toDraw = true;
  9159. };
  9160. _proto._endDraw = function _endDraw() {
  9161. this._attrs.toDraw = false;
  9162. };
  9163. _proto.draw = function draw() {
  9164. var self = this;
  9165. function drawInner() {
  9166. self.set('animateHandler', requestAnimationFrame(function () {
  9167. self.set('animateHandler', undefined);
  9168. if (self.get('toDraw')) {
  9169. drawInner();
  9170. }
  9171. }));
  9172. self.beforeDraw();
  9173. try {
  9174. var context = self._attrs.context;
  9175. var children = self._attrs.children;
  9176. for (var i = 0, len = children.length; i < len; i++) {
  9177. var child = children[i];
  9178. child.draw(context);
  9179. } // 支付宝,微信小程序,需要调context.draw才能完成绘制, 所以这里直接判断是否有.draw方法
  9180. if (context.draw) {
  9181. context.draw();
  9182. }
  9183. } catch (ev) {
  9184. console.warn('error in draw canvas, detail as:');
  9185. console.warn(ev);
  9186. self._endDraw();
  9187. }
  9188. self._endDraw();
  9189. }
  9190. if (self.get('destroyed')) {
  9191. return;
  9192. }
  9193. if (self.get('animateHandler')) {
  9194. this._beginDraw();
  9195. } else {
  9196. drawInner();
  9197. }
  9198. };
  9199. _proto.destroy = function destroy() {
  9200. if (this.get('destroyed')) {
  9201. return;
  9202. } // 需要清理 canvas 画布内容,否则会导致 spa 应用 ios 下 canvas 白屏
  9203. // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12
  9204. // https://github.com/antvis/F2/issues/630
  9205. var el = this.get('el');
  9206. el.width = 0;
  9207. el.height = 0;
  9208. this.clear();
  9209. this._attrs = {};
  9210. this.set('destroyed', true);
  9211. };
  9212. _proto.isDestroyed = function isDestroyed() {
  9213. return this.get('destroyed');
  9214. };
  9215. return Canvas;
  9216. }(_emit["default"]);
  9217. Util.mix(Canvas.prototype, Container, {
  9218. getGroupClass: function getGroupClass() {
  9219. return Group;
  9220. }
  9221. });
  9222. module.exports = Canvas;
  9223. /***/ }),
  9224. /* 177 */
  9225. /***/ (function(module, exports, __webpack_require__) {
  9226. "use strict";
  9227. exports.__esModule = true;
  9228. exports["default"] = void 0;
  9229. var _dom = __webpack_require__(62);
  9230. var _common = __webpack_require__(0);
  9231. // 计算滑动的方向
  9232. var calcDirection = function calcDirection(start, end) {
  9233. var xDistance = end.x - start.x;
  9234. var yDistance = end.y - start.y; // x 的距离大于y 说明是横向,否则就是纵向
  9235. if (Math.abs(xDistance) > Math.abs(yDistance)) {
  9236. return xDistance > 0 ? 'right' : 'left';
  9237. }
  9238. return yDistance > 0 ? 'down' : 'up';
  9239. }; // 计算2点之间的距离
  9240. var calcDistance = function calcDistance(point1, point2) {
  9241. var xDistance = Math.abs(point2.x - point1.x);
  9242. var yDistance = Math.abs(point2.y - point1.y);
  9243. return Math.sqrt(xDistance * xDistance + yDistance * yDistance);
  9244. };
  9245. var getCenter = function getCenter(point1, point2) {
  9246. var x = point1.x + (point2.x - point1.x) / 2;
  9247. var y = point1.y + (point2.y - point1.y) / 2;
  9248. return {
  9249. x: x,
  9250. y: y
  9251. };
  9252. };
  9253. var convertPoints = function convertPoints(touches, canvas) {
  9254. if (!touches) return;
  9255. var points = [];
  9256. var len = touches.length;
  9257. for (var i = 0; i < len; i++) {
  9258. var touch = touches[i]; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
  9259. var x = touch.x,
  9260. y = touch.y,
  9261. clientX = touch.clientX,
  9262. clientY = touch.clientY;
  9263. var point = void 0; // 小程序环境会有x,y
  9264. if ((0, _common.isNumber)(x) || (0, _common.isNumber)(y)) {
  9265. point = {
  9266. x: x,
  9267. y: y
  9268. };
  9269. } else {
  9270. // 浏览器环境再计算下canvas的相对位置
  9271. point = (0, _dom.getRelativePosition)({
  9272. x: clientX,
  9273. y: clientY
  9274. }, canvas);
  9275. }
  9276. points.push(point);
  9277. }
  9278. return points;
  9279. };
  9280. var PRESS_DELAY = 250;
  9281. var EventController = /*#__PURE__*/function () {
  9282. function EventController(_ref) {
  9283. var _this = this;
  9284. var canvas = _ref.canvas,
  9285. el = _ref.el;
  9286. this._click = function (ev) {
  9287. _this.emitEvent('click', ev);
  9288. };
  9289. this._start = function (ev) {
  9290. var points = convertPoints(ev.touches, _this.canvas);
  9291. if (!points) {
  9292. return;
  9293. }
  9294. ev.points = points;
  9295. _this.emitEvent('touchstart', ev); // 防止上次的内容没有清理掉,重新reset下
  9296. _this.reset(); // 记录touch start 的时间
  9297. _this.startTime = Date.now(); // 记录touch start 的点
  9298. _this.startPoints = points;
  9299. if (points.length > 1) {
  9300. _this.startDistance = calcDistance(points[0], points[1]);
  9301. _this.center = getCenter(points[0], points[1]);
  9302. } else {
  9303. // 如果touchstart后停顿250ms, 则也触发press事件
  9304. _this.pressTimeout = setTimeout(function () {
  9305. // 这里固定触发press事件
  9306. var eventType = 'press';
  9307. ev.direction = 'none';
  9308. _this.emitStart(eventType, ev);
  9309. _this.emitEvent(eventType, ev);
  9310. _this.eventType = eventType;
  9311. }, PRESS_DELAY);
  9312. }
  9313. };
  9314. this._move = function (ev) {
  9315. var points = convertPoints(ev.touches, _this.canvas);
  9316. if (!points) return;
  9317. _this.clearPressTimeout();
  9318. ev.points = points;
  9319. _this.emitEvent('touchmove', ev);
  9320. var startPoints = _this.startPoints;
  9321. if (!startPoints) return; // 多指触控
  9322. if (points.length > 1) {
  9323. // touchstart的距离
  9324. var startDistance = _this.startDistance;
  9325. var currentDistance = calcDistance(points[0], points[1]);
  9326. ev.zoom = currentDistance / startDistance;
  9327. ev.center = _this.center; // 触发缩放事件
  9328. _this.emitStart('pinch', ev);
  9329. _this.emitEvent('pinch', ev);
  9330. } else {
  9331. var deltaX = points[0].x - startPoints[0].x;
  9332. var deltaY = points[0].y - startPoints[0].y;
  9333. var direction = _this.direction || calcDirection(startPoints[0], points[0]);
  9334. _this.direction = direction; // 获取press或者pan的事件类型
  9335. // press 按住滑动, pan表示平移
  9336. // 如果start后立刻move,则触发pan, 如果有停顿,则触发press
  9337. var eventType = _this.getEventType(points);
  9338. ev.direction = direction;
  9339. ev.deltaX = deltaX;
  9340. ev.deltaY = deltaY;
  9341. _this.emitStart(eventType, ev);
  9342. _this.emitEvent(eventType, ev); // 记录最后2次move的时间和坐标,为了给swipe事件用
  9343. var prevMoveTime = _this.lastMoveTime;
  9344. var now = Date.now(); // 最后2次的时间间隔一定要大于0,否则swipe没发计算
  9345. if (now - prevMoveTime > 0) {
  9346. _this.prevMoveTime = prevMoveTime;
  9347. _this.prevMovePoints = _this.lastMovePoints;
  9348. _this.lastMoveTime = now;
  9349. _this.lastMovePoints = points;
  9350. }
  9351. }
  9352. };
  9353. this._end = function (ev) {
  9354. _this.emitEnd(ev);
  9355. _this.emitEvent('touchend', ev); // swipe事件处理, 在touchend之后触发
  9356. var lastMoveTime = _this.lastMoveTime;
  9357. var now = Date.now(); // 做这个判断是为了最后一次touchmove后到end前,还有一个停顿的过程
  9358. // 100 是拍的一个值,理论这个值会很短,一般不卡顿的话在10ms以内
  9359. if (now - lastMoveTime < 100) {
  9360. var prevMoveTime = _this.prevMoveTime || _this.startTime;
  9361. var intervalTime = lastMoveTime - prevMoveTime; // 时间间隔一定要大于0, 否则计算没意义
  9362. if (intervalTime > 0) {
  9363. var prevMovePoints = _this.prevMovePoints || _this.startPoints;
  9364. var lastMovePoints = _this.lastMovePoints; // move速率
  9365. var velocity = calcDistance(prevMovePoints[0], lastMovePoints[0]) / intervalTime; // 0.3 是参考hammerjs的设置
  9366. if (velocity > 0.3) {
  9367. ev.velocity = velocity;
  9368. ev.direction = calcDirection(prevMovePoints[0], lastMovePoints[0]);
  9369. _this.emitEvent('swipe', ev);
  9370. }
  9371. }
  9372. }
  9373. _this.reset();
  9374. var touches = ev.touches; // 当多指只释放了1指时也会触发end, 这时重新触发一次start
  9375. if (touches && touches.length > 0) {
  9376. _this._start(ev);
  9377. }
  9378. };
  9379. this._cancel = function (ev) {
  9380. _this.emitEvent('touchcancel', ev);
  9381. _this.reset();
  9382. };
  9383. // canvasEl
  9384. this.canvas = canvas;
  9385. this.delegateEvent(el); // 用来记录当前触发的事件
  9386. this.processEvent = {};
  9387. }
  9388. var _proto = EventController.prototype;
  9389. _proto.delegateEvent = function delegateEvent(canvasEl) {
  9390. // 代理这几个事件
  9391. canvasEl.addEventListener('click', this._click);
  9392. canvasEl.addEventListener('touchstart', this._start);
  9393. canvasEl.addEventListener('touchmove', this._move);
  9394. canvasEl.addEventListener('touchend', this._end);
  9395. canvasEl.addEventListener('touchcancel', this._cancel);
  9396. };
  9397. _proto.emitEvent = function emitEvent(type, ev) {
  9398. var canvas = this.canvas;
  9399. canvas.emit(type, ev);
  9400. };
  9401. _proto.getEventType = function getEventType(points) {
  9402. var eventType = this.eventType,
  9403. canvas = this.canvas,
  9404. startTime = this.startTime,
  9405. startPoints = this.startPoints;
  9406. if (eventType) {
  9407. return eventType;
  9408. }
  9409. var type;
  9410. var panEventListeners = canvas.__events.pan; // 如果没有pan事件的监听,默认都是press
  9411. if (!panEventListeners || !panEventListeners.length) {
  9412. type = 'press';
  9413. } else {
  9414. // 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
  9415. var now = Date.now();
  9416. if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], points[0]) < 10) {
  9417. type = 'press';
  9418. } else {
  9419. type = 'pan';
  9420. }
  9421. }
  9422. this.eventType = type;
  9423. return type;
  9424. };
  9425. _proto.enable = function enable(eventType) {
  9426. this.processEvent[eventType] = true;
  9427. } // 是否进行中的事件
  9428. ;
  9429. _proto.isProcess = function isProcess(eventType) {
  9430. return this.processEvent[eventType];
  9431. } // 触发start事件
  9432. ;
  9433. _proto.emitStart = function emitStart(type, ev) {
  9434. if (this.isProcess(type)) {
  9435. return;
  9436. }
  9437. this.enable(type);
  9438. this.emitEvent(type + "start", ev);
  9439. } // 触发end事件
  9440. ;
  9441. _proto.emitEnd = function emitEnd(ev) {
  9442. var _this2 = this;
  9443. var processEvent = this.processEvent;
  9444. Object.keys(processEvent).forEach(function (type) {
  9445. _this2.emitEvent(type + "end", ev);
  9446. delete processEvent[type];
  9447. });
  9448. };
  9449. _proto.clearPressTimeout = function clearPressTimeout() {
  9450. if (this.pressTimeout) {
  9451. clearTimeout(this.pressTimeout);
  9452. this.pressTimeout = 0;
  9453. }
  9454. };
  9455. _proto.reset = function reset() {
  9456. this.clearPressTimeout();
  9457. this.startTime = 0;
  9458. this.startPoints = null;
  9459. this.startDistance = 0;
  9460. this.direction = null;
  9461. this.eventType = null;
  9462. this.pinch = false;
  9463. this.prevMoveTime = 0;
  9464. this.prevMovePoints = null;
  9465. this.lastMoveTime = 0;
  9466. this.lastMovePoints = null;
  9467. };
  9468. return EventController;
  9469. }();
  9470. var _default = EventController;
  9471. exports["default"] = _default;
  9472. /***/ }),
  9473. /* 178 */
  9474. /***/ (function(module, exports, __webpack_require__) {
  9475. "use strict";
  9476. var _interopRequireDefault = __webpack_require__(1);
  9477. exports.__esModule = true;
  9478. exports["default"] = void 0;
  9479. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9480. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9481. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9482. var _emit = _interopRequireDefault(__webpack_require__(42));
  9483. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9484. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9485. var CanvasElement = /*#__PURE__*/function (_EventEmit) {
  9486. (0, _inheritsLoose2["default"])(CanvasElement, _EventEmit);
  9487. var _super = _createSuper(CanvasElement);
  9488. function CanvasElement(ctx) {
  9489. var _this;
  9490. _this = _EventEmit.call(this) || this;
  9491. _this.context = ctx; // canvas实际的宽高 (width/height) * pixelRatio
  9492. _this.width = 0;
  9493. _this.height = 0;
  9494. _this.style = {};
  9495. _this.currentStyle = {}; // 用来标识是CanvasElement实例
  9496. _this.isCanvasElement = true;
  9497. return _this;
  9498. }
  9499. var _proto = CanvasElement.prototype;
  9500. _proto.getContext = function getContext()
  9501. /* type */
  9502. {
  9503. return this.context;
  9504. };
  9505. _proto.getBoundingClientRect = function getBoundingClientRect() {
  9506. var width = this.width;
  9507. var height = this.height; // 默认都处理成可视窗口的顶部位置
  9508. return {
  9509. top: 0,
  9510. right: width,
  9511. bottom: height,
  9512. left: 0
  9513. };
  9514. };
  9515. _proto.addEventListener = function addEventListener(type, listener) {
  9516. this.on(type, listener);
  9517. };
  9518. _proto.removeEventListener = function removeEventListener(type, listener) {
  9519. this.off(type, listener);
  9520. };
  9521. _proto.dispatchEvent = function dispatchEvent(type, e) {
  9522. this.emit(type, e);
  9523. };
  9524. return CanvasElement;
  9525. }(_emit["default"]);
  9526. function supportEventListener(canvas) {
  9527. if (!canvas) {
  9528. return false;
  9529. } // 非 HTMLCanvasElement
  9530. if (canvas.nodeType !== 1 || !canvas.nodeName || canvas.nodeName.toLowerCase() !== 'canvas') {
  9531. return false;
  9532. } // 微信小程序canvas.getContext('2d')时也是CanvasRenderingContext2D
  9533. // 也会有ctx.canvas, 而且nodeType也是1,所以还要在看下是否支持addEventListener
  9534. var support = false;
  9535. try {
  9536. canvas.addEventListener('eventTest', function () {
  9537. support = true;
  9538. });
  9539. canvas.dispatchEvent(new Event('eventTest'));
  9540. } catch (error) {
  9541. support = false;
  9542. }
  9543. return support;
  9544. }
  9545. var _default = {
  9546. create: function create(ctx) {
  9547. if (!ctx) {
  9548. return null;
  9549. }
  9550. if (supportEventListener(ctx.canvas)) {
  9551. return ctx.canvas;
  9552. }
  9553. return new CanvasElement(ctx);
  9554. }
  9555. };
  9556. exports["default"] = _default;
  9557. /***/ }),
  9558. /* 179 */
  9559. /***/ (function(module, exports, __webpack_require__) {
  9560. "use strict";
  9561. var Util = __webpack_require__(0);
  9562. function _mod(n, m) {
  9563. return (n % m + m) % m;
  9564. }
  9565. function _addStop(steps, gradient) {
  9566. Util.each(steps, function (item) {
  9567. item = item.split(':');
  9568. gradient.addColorStop(Number(item[0]), item[1]);
  9569. });
  9570. } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
  9571. function _parseLineGradient(color, shape, context) {
  9572. var arr = color.split(' ');
  9573. var angle = arr[0].slice(2, arr[0].length - 1);
  9574. angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
  9575. var steps = arr.slice(1);
  9576. var _shape$getBBox = shape.getBBox(),
  9577. minX = _shape$getBBox.minX,
  9578. minY = _shape$getBBox.minY,
  9579. maxX = _shape$getBBox.maxX,
  9580. maxY = _shape$getBBox.maxY;
  9581. var start;
  9582. var end;
  9583. if (angle >= 0 && angle < 0.5 * Math.PI) {
  9584. start = {
  9585. x: minX,
  9586. y: minY
  9587. };
  9588. end = {
  9589. x: maxX,
  9590. y: maxY
  9591. };
  9592. } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
  9593. start = {
  9594. x: maxX,
  9595. y: minY
  9596. };
  9597. end = {
  9598. x: minX,
  9599. y: maxY
  9600. };
  9601. } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
  9602. start = {
  9603. x: maxX,
  9604. y: maxY
  9605. };
  9606. end = {
  9607. x: minX,
  9608. y: minY
  9609. };
  9610. } else {
  9611. start = {
  9612. x: minX,
  9613. y: maxY
  9614. };
  9615. end = {
  9616. x: maxX,
  9617. y: minY
  9618. };
  9619. }
  9620. var tanTheta = Math.tan(angle);
  9621. var tanTheta2 = tanTheta * tanTheta;
  9622. var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
  9623. var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
  9624. var gradient = context.createLinearGradient(start.x, start.y, x, y);
  9625. _addStop(steps, gradient);
  9626. return gradient;
  9627. } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
  9628. function _parseRadialGradient(color, shape, context) {
  9629. var arr = color.split(' ');
  9630. var circleCfg = arr[0].slice(2, arr[0].length - 1);
  9631. circleCfg = circleCfg.split(',');
  9632. var fx = parseFloat(circleCfg[0]);
  9633. var fy = parseFloat(circleCfg[1]);
  9634. var fr = parseFloat(circleCfg[2]);
  9635. var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
  9636. if (fr === 0) {
  9637. var _color = steps[steps.length - 1];
  9638. return _color.split(':')[1];
  9639. }
  9640. var _shape$getBBox2 = shape.getBBox(),
  9641. width = _shape$getBBox2.width,
  9642. height = _shape$getBBox2.height,
  9643. minX = _shape$getBBox2.minX,
  9644. minY = _shape$getBBox2.minY;
  9645. var r = Math.sqrt(width * width + height * height) / 2;
  9646. var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
  9647. _addStop(steps, gradient);
  9648. return gradient;
  9649. }
  9650. module.exports = {
  9651. parseStyle: function parseStyle(color, shape, context) {
  9652. if (color[1] === '(') {
  9653. try {
  9654. var firstCode = color[0];
  9655. if (firstCode === 'l') {
  9656. return _parseLineGradient(color, shape, context);
  9657. } else if (firstCode === 'r') {
  9658. return _parseRadialGradient(color, shape, context);
  9659. }
  9660. } catch (ev) {
  9661. console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
  9662. console.error(ev);
  9663. }
  9664. }
  9665. return color;
  9666. }
  9667. };
  9668. /***/ }),
  9669. /* 180 */
  9670. /***/ (function(module, exports, __webpack_require__) {
  9671. "use strict";
  9672. var _interopRequireDefault = __webpack_require__(1);
  9673. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9674. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9675. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9676. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9677. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9678. var Util = __webpack_require__(0);
  9679. var Shape = __webpack_require__(10);
  9680. var Rect = /*#__PURE__*/function (_Shape) {
  9681. (0, _inheritsLoose2["default"])(Rect, _Shape);
  9682. var _super = _createSuper(Rect);
  9683. function Rect() {
  9684. return _Shape.apply(this, arguments) || this;
  9685. }
  9686. var _proto = Rect.prototype;
  9687. _proto._initProperties = function _initProperties() {
  9688. _Shape.prototype._initProperties.call(this);
  9689. this._attrs.canFill = true;
  9690. this._attrs.canStroke = true;
  9691. this._attrs.type = 'rect';
  9692. };
  9693. _proto.getDefaultAttrs = function getDefaultAttrs() {
  9694. return {
  9695. x: 0,
  9696. y: 0,
  9697. width: 0,
  9698. height: 0,
  9699. radius: 0,
  9700. lineWidth: 0
  9701. };
  9702. };
  9703. _proto.createPath = function createPath(context) {
  9704. var self = this;
  9705. var attrs = self.get('attrs');
  9706. var x = attrs.x,
  9707. y = attrs.y,
  9708. width = attrs.width,
  9709. height = attrs.height;
  9710. context.beginPath();
  9711. var radius = attrs.radius;
  9712. if (!radius || !(width * height)) {
  9713. context.rect(x, y, width, height);
  9714. } else {
  9715. radius = Util.parsePadding(radius);
  9716. context.moveTo(x + radius[0], y);
  9717. context.lineTo(x + width - radius[1], y);
  9718. context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
  9719. context.lineTo(x + width, y + height - radius[2]);
  9720. context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
  9721. context.lineTo(x + radius[3], y + height);
  9722. context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
  9723. context.lineTo(x, y + radius[0]);
  9724. context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
  9725. context.closePath();
  9726. }
  9727. };
  9728. _proto.calculateBox = function calculateBox() {
  9729. var attrs = this.get('attrs');
  9730. var x = attrs.x,
  9731. y = attrs.y,
  9732. width = attrs.width,
  9733. height = attrs.height;
  9734. return {
  9735. minX: x,
  9736. minY: y,
  9737. maxX: x + width,
  9738. maxY: y + height
  9739. };
  9740. };
  9741. return Rect;
  9742. }(Shape);
  9743. Shape.Rect = Rect;
  9744. module.exports = Rect;
  9745. /***/ }),
  9746. /* 181 */
  9747. /***/ (function(module, exports, __webpack_require__) {
  9748. "use strict";
  9749. var _interopRequireDefault = __webpack_require__(1);
  9750. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9751. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9752. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9753. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9754. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9755. var Shape = __webpack_require__(10);
  9756. var Circle = /*#__PURE__*/function (_Shape) {
  9757. (0, _inheritsLoose2["default"])(Circle, _Shape);
  9758. var _super = _createSuper(Circle);
  9759. function Circle() {
  9760. return _Shape.apply(this, arguments) || this;
  9761. }
  9762. var _proto = Circle.prototype;
  9763. _proto._initProperties = function _initProperties() {
  9764. _Shape.prototype._initProperties.call(this);
  9765. this._attrs.canFill = true;
  9766. this._attrs.canStroke = true;
  9767. this._attrs.type = 'circle';
  9768. };
  9769. _proto.getDefaultAttrs = function getDefaultAttrs() {
  9770. return {
  9771. x: 0,
  9772. y: 0,
  9773. r: 0,
  9774. lineWidth: 0
  9775. };
  9776. };
  9777. _proto.createPath = function createPath(context) {
  9778. var attrs = this.get('attrs');
  9779. var x = attrs.x,
  9780. y = attrs.y,
  9781. r = attrs.r;
  9782. context.beginPath();
  9783. context.arc(x, y, r, 0, Math.PI * 2, false);
  9784. context.closePath();
  9785. };
  9786. _proto.calculateBox = function calculateBox() {
  9787. var attrs = this.get('attrs');
  9788. var x = attrs.x,
  9789. y = attrs.y,
  9790. r = attrs.r;
  9791. return {
  9792. minX: x - r,
  9793. maxX: x + r,
  9794. minY: y - r,
  9795. maxY: y + r
  9796. };
  9797. };
  9798. return Circle;
  9799. }(Shape);
  9800. Shape.Circle = Circle;
  9801. module.exports = Circle;
  9802. /***/ }),
  9803. /* 182 */
  9804. /***/ (function(module, exports, __webpack_require__) {
  9805. "use strict";
  9806. var _interopRequireDefault = __webpack_require__(1);
  9807. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9808. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9809. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9810. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9811. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9812. var Shape = __webpack_require__(10);
  9813. var bbox = __webpack_require__(21);
  9814. var Line = /*#__PURE__*/function (_Shape) {
  9815. (0, _inheritsLoose2["default"])(Line, _Shape);
  9816. var _super = _createSuper(Line);
  9817. function Line() {
  9818. return _Shape.apply(this, arguments) || this;
  9819. }
  9820. var _proto = Line.prototype;
  9821. _proto._initProperties = function _initProperties() {
  9822. _Shape.prototype._initProperties.call(this);
  9823. this._attrs.canStroke = true;
  9824. this._attrs.type = 'line';
  9825. };
  9826. _proto.getDefaultAttrs = function getDefaultAttrs() {
  9827. return {
  9828. x1: 0,
  9829. y1: 0,
  9830. x2: 0,
  9831. y2: 0,
  9832. lineWidth: 1
  9833. };
  9834. };
  9835. _proto.createPath = function createPath(context) {
  9836. var attrs = this.get('attrs');
  9837. var x1 = attrs.x1,
  9838. y1 = attrs.y1,
  9839. x2 = attrs.x2,
  9840. y2 = attrs.y2;
  9841. context.beginPath();
  9842. context.moveTo(x1, y1);
  9843. context.lineTo(x2, y2);
  9844. };
  9845. _proto.calculateBox = function calculateBox() {
  9846. var attrs = this.get('attrs');
  9847. var x1 = attrs.x1,
  9848. y1 = attrs.y1,
  9849. x2 = attrs.x2,
  9850. y2 = attrs.y2,
  9851. lineWidth = attrs.lineWidth;
  9852. return bbox.getBBoxFromLine(x1, y1, x2, y2, lineWidth);
  9853. };
  9854. return Line;
  9855. }(Shape);
  9856. Shape.Line = Line;
  9857. module.exports = Line;
  9858. /***/ }),
  9859. /* 183 */
  9860. /***/ (function(module, exports, __webpack_require__) {
  9861. "use strict";
  9862. var _interopRequireDefault = __webpack_require__(1);
  9863. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9864. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9865. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9866. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9867. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9868. var Shape = __webpack_require__(10);
  9869. var bbox = __webpack_require__(21);
  9870. var Polygon = /*#__PURE__*/function (_Shape) {
  9871. (0, _inheritsLoose2["default"])(Polygon, _Shape);
  9872. var _super = _createSuper(Polygon);
  9873. function Polygon() {
  9874. return _Shape.apply(this, arguments) || this;
  9875. }
  9876. var _proto = Polygon.prototype;
  9877. _proto._initProperties = function _initProperties() {
  9878. _Shape.prototype._initProperties.call(this);
  9879. this._attrs.canFill = true;
  9880. this._attrs.canStroke = true;
  9881. this._attrs.type = 'polygon';
  9882. };
  9883. _proto.getDefaultAttrs = function getDefaultAttrs() {
  9884. return {
  9885. points: null,
  9886. lineWidth: 0
  9887. };
  9888. };
  9889. _proto.createPath = function createPath(context) {
  9890. var self = this;
  9891. var attrs = self.get('attrs');
  9892. var points = attrs.points;
  9893. context.beginPath();
  9894. for (var i = 0, len = points.length; i < len; i++) {
  9895. var point = points[i];
  9896. if (i === 0) {
  9897. context.moveTo(point.x, point.y);
  9898. } else {
  9899. context.lineTo(point.x, point.y);
  9900. }
  9901. }
  9902. context.closePath();
  9903. };
  9904. _proto.calculateBox = function calculateBox() {
  9905. var attrs = this.get('attrs');
  9906. var points = attrs.points;
  9907. return bbox.getBBoxFromPoints(points);
  9908. };
  9909. return Polygon;
  9910. }(Shape);
  9911. Shape.Polygon = Polygon;
  9912. module.exports = Polygon;
  9913. /***/ }),
  9914. /* 184 */
  9915. /***/ (function(module, exports, __webpack_require__) {
  9916. "use strict";
  9917. var _interopRequireDefault = __webpack_require__(1);
  9918. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  9919. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  9920. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  9921. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  9922. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9923. var Shape = __webpack_require__(10);
  9924. var Smooth = __webpack_require__(71);
  9925. var bbox = __webpack_require__(21); // filter the point which x or y is NaN
  9926. function _filterPoints(points) {
  9927. var filteredPoints = [];
  9928. for (var i = 0, len = points.length; i < len; i++) {
  9929. var point = points[i];
  9930. if (!isNaN(point.x) && !isNaN(point.y)) {
  9931. filteredPoints.push(point);
  9932. }
  9933. }
  9934. return filteredPoints;
  9935. }
  9936. var Polyline = /*#__PURE__*/function (_Shape) {
  9937. (0, _inheritsLoose2["default"])(Polyline, _Shape);
  9938. var _super = _createSuper(Polyline);
  9939. function Polyline() {
  9940. return _Shape.apply(this, arguments) || this;
  9941. }
  9942. var _proto = Polyline.prototype;
  9943. _proto._initProperties = function _initProperties() {
  9944. _Shape.prototype._initProperties.call(this);
  9945. this._attrs.canFill = true;
  9946. this._attrs.canStroke = true;
  9947. this._attrs.type = 'polyline';
  9948. };
  9949. _proto.getDefaultAttrs = function getDefaultAttrs() {
  9950. return {
  9951. points: null,
  9952. lineWidth: 1,
  9953. smooth: false
  9954. };
  9955. };
  9956. _proto.createPath = function createPath(context) {
  9957. var self = this;
  9958. var attrs = self.get('attrs');
  9959. var points = attrs.points,
  9960. smooth = attrs.smooth;
  9961. var filteredPoints = _filterPoints(points);
  9962. context.beginPath();
  9963. if (filteredPoints.length) {
  9964. context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
  9965. if (smooth) {
  9966. var constaint = [[0, 0], [1, 1]];
  9967. var sps = Smooth.smooth(filteredPoints, false, constaint);
  9968. for (var i = 0, n = sps.length; i < n; i++) {
  9969. var sp = sps[i];
  9970. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  9971. }
  9972. } else {
  9973. var _i;
  9974. var l;
  9975. for (_i = 1, l = filteredPoints.length - 1; _i < l; _i++) {
  9976. context.lineTo(filteredPoints[_i].x, filteredPoints[_i].y);
  9977. }
  9978. context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
  9979. }
  9980. }
  9981. };
  9982. _proto.calculateBox = function calculateBox() {
  9983. var attrs = this.get('attrs');
  9984. var points = attrs.points,
  9985. smooth = attrs.smooth,
  9986. lineWidth = attrs.lineWidth;
  9987. var filteredPoints = _filterPoints(points);
  9988. if (smooth) {
  9989. var newPoints = [];
  9990. var constaint = [[0, 0], [1, 1]];
  9991. var sps = Smooth.smooth(filteredPoints, false, constaint);
  9992. for (var i = 0, n = sps.length; i < n; i++) {
  9993. var sp = sps[i];
  9994. if (i === 0) {
  9995. newPoints.push([filteredPoints[0].x, filteredPoints[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  9996. } else {
  9997. var lastPoint = sps[i - 1];
  9998. newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  9999. }
  10000. }
  10001. return bbox.getBBoxFromBezierGroup(newPoints, lineWidth);
  10002. }
  10003. return bbox.getBBoxFromPoints(filteredPoints, lineWidth);
  10004. };
  10005. return Polyline;
  10006. }(Shape);
  10007. Shape.Polyline = Polyline;
  10008. module.exports = Polyline;
  10009. /***/ }),
  10010. /* 185 */
  10011. /***/ (function(module, exports, __webpack_require__) {
  10012. "use strict";
  10013. var _interopRequireDefault = __webpack_require__(1);
  10014. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10015. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10016. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10017. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10018. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10019. var Shape = __webpack_require__(10);
  10020. var bbox = __webpack_require__(21);
  10021. var Arc = /*#__PURE__*/function (_Shape) {
  10022. (0, _inheritsLoose2["default"])(Arc, _Shape);
  10023. var _super = _createSuper(Arc);
  10024. function Arc() {
  10025. return _Shape.apply(this, arguments) || this;
  10026. }
  10027. var _proto = Arc.prototype;
  10028. _proto._initProperties = function _initProperties() {
  10029. _Shape.prototype._initProperties.call(this);
  10030. this._attrs.canStroke = true;
  10031. this._attrs.canFill = true;
  10032. this._attrs.type = 'arc';
  10033. };
  10034. _proto.getDefaultAttrs = function getDefaultAttrs() {
  10035. return {
  10036. x: 0,
  10037. y: 0,
  10038. r: 0,
  10039. startAngle: 0,
  10040. endAngle: Math.PI * 2,
  10041. anticlockwise: false,
  10042. lineWidth: 1
  10043. };
  10044. };
  10045. _proto.createPath = function createPath(context) {
  10046. var attrs = this.get('attrs');
  10047. var x = attrs.x,
  10048. y = attrs.y,
  10049. r = attrs.r,
  10050. startAngle = attrs.startAngle,
  10051. endAngle = attrs.endAngle,
  10052. anticlockwise = attrs.anticlockwise;
  10053. context.beginPath();
  10054. if (startAngle !== endAngle) {
  10055. context.arc(x, y, r, startAngle, endAngle, anticlockwise);
  10056. }
  10057. };
  10058. _proto.calculateBox = function calculateBox() {
  10059. var attrs = this.get('attrs');
  10060. var x = attrs.x,
  10061. y = attrs.y,
  10062. r = attrs.r,
  10063. startAngle = attrs.startAngle,
  10064. endAngle = attrs.endAngle,
  10065. anticlockwise = attrs.anticlockwise;
  10066. return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
  10067. };
  10068. return Arc;
  10069. }(Shape);
  10070. Shape.Arc = Arc;
  10071. module.exports = Arc;
  10072. /***/ }),
  10073. /* 186 */
  10074. /***/ (function(module, exports, __webpack_require__) {
  10075. "use strict";
  10076. var _interopRequireDefault = __webpack_require__(1);
  10077. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10078. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10079. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10080. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10081. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10082. var Shape = __webpack_require__(10);
  10083. var bbox = __webpack_require__(21);
  10084. var Sector = /*#__PURE__*/function (_Shape) {
  10085. (0, _inheritsLoose2["default"])(Sector, _Shape);
  10086. var _super = _createSuper(Sector);
  10087. function Sector() {
  10088. return _Shape.apply(this, arguments) || this;
  10089. }
  10090. var _proto = Sector.prototype;
  10091. _proto._initProperties = function _initProperties() {
  10092. _Shape.prototype._initProperties.call(this);
  10093. this._attrs.canFill = true;
  10094. this._attrs.canStroke = true;
  10095. this._attrs.type = 'sector';
  10096. };
  10097. _proto.getDefaultAttrs = function getDefaultAttrs() {
  10098. return {
  10099. x: 0,
  10100. y: 0,
  10101. lineWidth: 0,
  10102. r: 0,
  10103. r0: 0,
  10104. startAngle: 0,
  10105. endAngle: Math.PI * 2,
  10106. anticlockwise: false
  10107. };
  10108. };
  10109. _proto.createPath = function createPath(context) {
  10110. var attrs = this.get('attrs');
  10111. var x = attrs.x,
  10112. y = attrs.y,
  10113. startAngle = attrs.startAngle,
  10114. endAngle = attrs.endAngle,
  10115. r = attrs.r,
  10116. r0 = attrs.r0,
  10117. anticlockwise = attrs.anticlockwise;
  10118. context.beginPath();
  10119. var unitX = Math.cos(startAngle);
  10120. var unitY = Math.sin(startAngle);
  10121. context.moveTo(unitX * r0 + x, unitY * r0 + y);
  10122. context.lineTo(unitX * r + x, unitY * r + y); // 当扇形的角度非常小的时候,就不进行弧线的绘制;或者整个只有1个扇形时,会出现end<0的情况不绘制
  10123. if (Math.abs(endAngle - startAngle) > 0.0001 || startAngle === 0 && endAngle < 0) {
  10124. context.arc(x, y, r, startAngle, endAngle, anticlockwise);
  10125. context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
  10126. if (r0 !== 0) {
  10127. context.arc(x, y, r0, endAngle, startAngle, !anticlockwise);
  10128. }
  10129. }
  10130. context.closePath();
  10131. };
  10132. _proto.calculateBox = function calculateBox() {
  10133. var attrs = this.get('attrs');
  10134. var x = attrs.x,
  10135. y = attrs.y,
  10136. r = attrs.r,
  10137. r0 = attrs.r0,
  10138. startAngle = attrs.startAngle,
  10139. endAngle = attrs.endAngle,
  10140. anticlockwise = attrs.anticlockwise;
  10141. var outerBBox = bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
  10142. var innerBBox = bbox.getBBoxFromArc(x, y, r0, startAngle, endAngle, anticlockwise);
  10143. return {
  10144. minX: Math.min(outerBBox.minX, innerBBox.minX),
  10145. minY: Math.min(outerBBox.minY, innerBBox.minY),
  10146. maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
  10147. maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
  10148. };
  10149. };
  10150. return Sector;
  10151. }(Shape);
  10152. Shape.Sector = Sector;
  10153. module.exports = Sector;
  10154. /***/ }),
  10155. /* 187 */
  10156. /***/ (function(module, exports, __webpack_require__) {
  10157. "use strict";
  10158. var _interopRequireDefault = __webpack_require__(1);
  10159. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10160. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10161. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10162. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10163. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10164. var Util = __webpack_require__(0);
  10165. var Shape = __webpack_require__(10);
  10166. var RectUtil = __webpack_require__(188);
  10167. var textWidthCacheCounter = 0;
  10168. var textWidthCache = {};
  10169. var TEXT_CACHE_MAX = 5000;
  10170. var Text = /*#__PURE__*/function (_Shape) {
  10171. (0, _inheritsLoose2["default"])(Text, _Shape);
  10172. var _super = _createSuper(Text);
  10173. function Text() {
  10174. return _Shape.apply(this, arguments) || this;
  10175. }
  10176. var _proto = Text.prototype;
  10177. _proto._initProperties = function _initProperties() {
  10178. _Shape.prototype._initProperties.call(this);
  10179. this._attrs.canFill = true;
  10180. this._attrs.canStroke = true;
  10181. this._attrs.type = 'text';
  10182. };
  10183. _proto.getDefaultAttrs = function getDefaultAttrs() {
  10184. return {
  10185. lineWidth: 0,
  10186. lineCount: 1,
  10187. fontSize: 12,
  10188. fontFamily: 'sans-serif',
  10189. fontStyle: 'normal',
  10190. fontWeight: 'normal',
  10191. fontVariant: 'normal',
  10192. textAlign: 'start',
  10193. textBaseline: 'bottom',
  10194. lineHeight: null,
  10195. textArr: null
  10196. };
  10197. };
  10198. _proto._getFontStyle = function _getFontStyle() {
  10199. var attrs = this._attrs.attrs;
  10200. var fontSize = attrs.fontSize,
  10201. fontFamily = attrs.fontFamily,
  10202. fontWeight = attrs.fontWeight,
  10203. fontStyle = attrs.fontStyle,
  10204. fontVariant = attrs.fontVariant;
  10205. return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
  10206. };
  10207. _proto._afterAttrsSet = function _afterAttrsSet() {
  10208. var attrs = this._attrs.attrs;
  10209. attrs.font = this._getFontStyle();
  10210. if (attrs.text) {
  10211. var text = attrs.text;
  10212. var textArr = null;
  10213. var lineCount = 1;
  10214. if (Util.isString(text) && text.indexOf('\n') !== -1) {
  10215. textArr = text.split('\n');
  10216. lineCount = textArr.length;
  10217. }
  10218. attrs.lineCount = lineCount;
  10219. attrs.textArr = textArr;
  10220. }
  10221. this.set('attrs', attrs);
  10222. };
  10223. _proto._getTextHeight = function _getTextHeight() {
  10224. var attrs = this._attrs.attrs;
  10225. if (attrs.height) {
  10226. return attrs.height;
  10227. }
  10228. var lineCount = attrs.lineCount;
  10229. var fontSize = attrs.fontSize * 1;
  10230. if (lineCount > 1) {
  10231. var spaceingY = this._getSpaceingY();
  10232. return fontSize * lineCount + spaceingY * (lineCount - 1);
  10233. }
  10234. return fontSize;
  10235. };
  10236. _proto._getSpaceingY = function _getSpaceingY() {
  10237. var attrs = this._attrs.attrs;
  10238. var lineHeight = attrs.lineHeight;
  10239. var fontSize = attrs.fontSize * 1;
  10240. return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
  10241. };
  10242. _proto.drawInner = function drawInner(context) {
  10243. var self = this;
  10244. var attrs = self._attrs.attrs;
  10245. var text = attrs.text;
  10246. var x = attrs.x;
  10247. var y = attrs.y;
  10248. if (Util.isNil(text) || isNaN(x) || isNaN(y)) {
  10249. // text will be 0
  10250. return;
  10251. }
  10252. var textArr = attrs.textArr;
  10253. var fontSize = attrs.fontSize * 1;
  10254. var spaceingY = self._getSpaceingY();
  10255. if (attrs.rotate) {
  10256. // do rotation
  10257. context.translate(x, y);
  10258. context.rotate(attrs.rotate);
  10259. x = 0;
  10260. y = 0;
  10261. }
  10262. var textBaseline = attrs.textBaseline;
  10263. var height;
  10264. if (textArr) {
  10265. height = self._getTextHeight();
  10266. }
  10267. var subY; // context.beginPath();
  10268. if (self.hasFill()) {
  10269. var fillOpacity = attrs.fillOpacity;
  10270. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  10271. context.globalAlpha = fillOpacity;
  10272. }
  10273. if (textArr) {
  10274. for (var i = 0, len = textArr.length; i < len; i++) {
  10275. var subText = textArr[i];
  10276. subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
  10277. if (textBaseline === 'middle') {
  10278. subY += height - fontSize - (height - fontSize) / 2;
  10279. }
  10280. if (textBaseline === 'top') {
  10281. subY += height - fontSize;
  10282. }
  10283. context.fillText(subText, x, subY);
  10284. }
  10285. } else {
  10286. context.fillText(text, x, y);
  10287. }
  10288. }
  10289. if (self.hasStroke()) {
  10290. if (textArr) {
  10291. for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
  10292. var _subText = textArr[_i];
  10293. subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
  10294. if (textBaseline === 'middle') {
  10295. subY += height - fontSize - (height - fontSize) / 2;
  10296. }
  10297. if (textBaseline === 'top') {
  10298. subY += height - fontSize;
  10299. }
  10300. context.strokeText(_subText, x, subY);
  10301. }
  10302. } else {
  10303. context.strokeText(text, x, y);
  10304. }
  10305. }
  10306. };
  10307. _proto.calculateBox = function calculateBox() {
  10308. var self = this;
  10309. var attrs = self._attrs.attrs;
  10310. var x = attrs.x,
  10311. y = attrs.y,
  10312. textAlign = attrs.textAlign,
  10313. textBaseline = attrs.textBaseline;
  10314. var width = self._getTextWidth(); // attrs.width
  10315. if (!width) {
  10316. return {
  10317. minX: x,
  10318. minY: y,
  10319. maxX: x,
  10320. maxY: y
  10321. };
  10322. }
  10323. var height = self._getTextHeight(); // attrs.height
  10324. if (attrs.rotate) {
  10325. var rotatedBox = RectUtil.calcRotatedBox({
  10326. width: width,
  10327. height: height,
  10328. rotate: attrs.rotate
  10329. });
  10330. width = rotatedBox.width;
  10331. height = rotatedBox.height;
  10332. }
  10333. var point = {
  10334. x: x,
  10335. y: y - height
  10336. }; // default textAlign: start, textBaseline: bottom
  10337. if (textAlign) {
  10338. if (textAlign === 'end' || textAlign === 'right') {
  10339. point.x -= width;
  10340. } else if (textAlign === 'center') {
  10341. point.x -= width / 2;
  10342. }
  10343. }
  10344. if (textBaseline) {
  10345. if (textBaseline === 'top') {
  10346. point.y += height;
  10347. } else if (textBaseline === 'middle') {
  10348. point.y += height / 2;
  10349. }
  10350. }
  10351. return {
  10352. minX: point.x,
  10353. minY: point.y,
  10354. maxX: point.x + width,
  10355. maxY: point.y + height
  10356. };
  10357. };
  10358. _proto._getTextWidth = function _getTextWidth() {
  10359. var attrs = this._attrs.attrs;
  10360. if (attrs.width) {
  10361. return attrs.width;
  10362. }
  10363. var text = attrs.text;
  10364. var context = this.get('context');
  10365. if (Util.isNil(text)) return undefined;
  10366. var font = attrs.font;
  10367. var textArr = attrs.textArr;
  10368. var key = text + '' + font;
  10369. if (textWidthCache[key]) {
  10370. return textWidthCache[key];
  10371. }
  10372. var width = 0;
  10373. if (textArr) {
  10374. for (var i = 0, length = textArr.length; i < length; i++) {
  10375. var subText = textArr[i];
  10376. width = Math.max(width, Util.measureText(subText, font, context).width);
  10377. }
  10378. } else {
  10379. width = Util.measureText(text, font, context).width;
  10380. }
  10381. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  10382. textWidthCacheCounter = 0;
  10383. textWidthCache = {};
  10384. }
  10385. textWidthCacheCounter++;
  10386. textWidthCache[key] = width;
  10387. return width;
  10388. };
  10389. return Text;
  10390. }(Shape);
  10391. Shape.Text = Text;
  10392. module.exports = Text;
  10393. /***/ }),
  10394. /* 188 */
  10395. /***/ (function(module, exports, __webpack_require__) {
  10396. "use strict";
  10397. var Rect = {
  10398. calcRotatedBox: function calcRotatedBox(_ref) {
  10399. var width = _ref.width,
  10400. height = _ref.height,
  10401. rotate = _ref.rotate;
  10402. var absRotate = Math.abs(rotate);
  10403. return {
  10404. width: Math.abs(width * Math.cos(absRotate) + height * Math.sin(absRotate)),
  10405. height: Math.abs(height * Math.cos(absRotate) + width * Math.sin(absRotate))
  10406. };
  10407. }
  10408. };
  10409. module.exports = Rect;
  10410. /***/ }),
  10411. /* 189 */
  10412. /***/ (function(module, exports, __webpack_require__) {
  10413. "use strict";
  10414. var _interopRequireDefault = __webpack_require__(1);
  10415. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10416. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10417. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10418. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10419. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10420. var Shape = __webpack_require__(10);
  10421. var Custom = /*#__PURE__*/function (_Shape) {
  10422. (0, _inheritsLoose2["default"])(Custom, _Shape);
  10423. var _super = _createSuper(Custom);
  10424. function Custom() {
  10425. return _Shape.apply(this, arguments) || this;
  10426. }
  10427. var _proto = Custom.prototype;
  10428. _proto._initProperties = function _initProperties() {
  10429. _Shape.prototype._initProperties.call(this);
  10430. this._attrs.canFill = true;
  10431. this._attrs.canStroke = true;
  10432. this._attrs.createPath = null;
  10433. this._attrs.type = 'custom';
  10434. };
  10435. _proto.createPath = function createPath(context) {
  10436. var createPath = this.get('createPath');
  10437. createPath && createPath.call(this, context);
  10438. };
  10439. _proto.calculateBox = function calculateBox() {
  10440. var calculateBox = this.get('calculateBox');
  10441. return calculateBox && calculateBox.call(this);
  10442. };
  10443. return Custom;
  10444. }(Shape);
  10445. Shape.Custom = Custom;
  10446. module.exports = Custom;
  10447. /***/ }),
  10448. /* 190 */
  10449. /***/ (function(module, exports, __webpack_require__) {
  10450. "use strict";
  10451. var _interopRequireDefault = __webpack_require__(1);
  10452. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10453. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10454. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10455. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10456. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10457. var Path = __webpack_require__(72);
  10458. var Geom = __webpack_require__(17);
  10459. __webpack_require__(68);
  10460. var Line = /*#__PURE__*/function (_Path) {
  10461. (0, _inheritsLoose2["default"])(Line, _Path);
  10462. var _super = _createSuper(Line);
  10463. function Line() {
  10464. return _Path.apply(this, arguments) || this;
  10465. }
  10466. var _proto = Line.prototype;
  10467. _proto.getDefaultCfg = function getDefaultCfg() {
  10468. var cfg = _Path.prototype.getDefaultCfg.call(this);
  10469. cfg.type = 'line';
  10470. cfg.sortable = true;
  10471. return cfg;
  10472. };
  10473. return Line;
  10474. }(Path);
  10475. Geom.Line = Line;
  10476. module.exports = Line;
  10477. /***/ }),
  10478. /* 191 */
  10479. /***/ (function(module, exports, __webpack_require__) {
  10480. "use strict";
  10481. var _interopRequireDefault = __webpack_require__(1);
  10482. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  10483. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  10484. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  10485. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  10486. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  10487. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10488. var Geom = __webpack_require__(17);
  10489. var Util = __webpack_require__(0);
  10490. var SizeMixin = __webpack_require__(73);
  10491. __webpack_require__(192);
  10492. var Interval = /*#__PURE__*/function (_Geom) {
  10493. (0, _inheritsLoose2["default"])(Interval, _Geom);
  10494. var _super = _createSuper(Interval);
  10495. var _proto = Interval.prototype;
  10496. _proto.getDefaultCfg = function getDefaultCfg() {
  10497. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  10498. cfg.type = 'interval';
  10499. cfg.shapeType = 'interval';
  10500. cfg.generatePoints = true;
  10501. return cfg;
  10502. };
  10503. function Interval(cfg) {
  10504. var _this;
  10505. _this = _Geom.call(this, cfg) || this;
  10506. Util.mix((0, _assertThisInitialized2["default"])(_this), SizeMixin);
  10507. return _this;
  10508. }
  10509. _proto.init = function init() {
  10510. _Geom.prototype.init.call(this); // 绑定事件
  10511. this.initEvent();
  10512. };
  10513. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  10514. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  10515. cfg.size = this.getNormalizedSize(obj);
  10516. return cfg;
  10517. };
  10518. _proto.clearInner = function clearInner() {
  10519. _Geom.prototype.clearInner.call(this);
  10520. this.set('defaultSize', null);
  10521. };
  10522. return Interval;
  10523. }(Geom);
  10524. Geom.Interval = Interval;
  10525. module.exports = Interval;
  10526. /***/ }),
  10527. /* 192 */
  10528. /***/ (function(module, exports, __webpack_require__) {
  10529. "use strict";
  10530. var Util = __webpack_require__(0);
  10531. var Shape = __webpack_require__(19);
  10532. var Vector2 = __webpack_require__(13);
  10533. var Global = __webpack_require__(6);
  10534. function getRectPoints(cfg) {
  10535. var x = cfg.x,
  10536. y = cfg.y,
  10537. y0 = cfg.y0,
  10538. size = cfg.size;
  10539. var ymin = y0;
  10540. var ymax = y;
  10541. if (Util.isArray(y)) {
  10542. ymax = y[1];
  10543. ymin = y[0];
  10544. }
  10545. var xmin;
  10546. var xmax;
  10547. if (Util.isArray(x)) {
  10548. xmin = x[0];
  10549. xmax = x[1];
  10550. } else {
  10551. xmin = x - size / 2;
  10552. xmax = x + size / 2;
  10553. }
  10554. return [{
  10555. x: xmin,
  10556. y: ymin
  10557. }, {
  10558. x: xmin,
  10559. y: ymax
  10560. }, {
  10561. x: xmax,
  10562. y: ymax
  10563. }, {
  10564. x: xmax,
  10565. y: ymin
  10566. }];
  10567. }
  10568. function getRectRange(points) {
  10569. var xValues = [];
  10570. var yValues = [];
  10571. for (var i = 0, len = points.length; i < len; i++) {
  10572. var point = points[i];
  10573. xValues.push(point.x);
  10574. yValues.push(point.y);
  10575. }
  10576. var xMin = Math.min.apply(null, xValues);
  10577. var yMin = Math.min.apply(null, yValues);
  10578. var xMax = Math.max.apply(null, xValues);
  10579. var yMax = Math.max.apply(null, yValues);
  10580. return {
  10581. x: xMin,
  10582. y: yMin,
  10583. width: xMax - xMin,
  10584. height: yMax - yMin
  10585. };
  10586. }
  10587. function getMiddlePoint(a, b) {
  10588. var x = (a.x - b.x) / 2 + b.x;
  10589. var y = (a.y - b.y) / 2 + b.y;
  10590. return {
  10591. x: x,
  10592. y: y
  10593. };
  10594. }
  10595. var Interval = Shape.registerFactory('interval', {
  10596. defaultShapeType: 'rect',
  10597. getDefaultPoints: function getDefaultPoints(cfg) {
  10598. return getRectPoints(cfg);
  10599. }
  10600. });
  10601. Shape.registerShape('interval', 'rect', {
  10602. draw: function draw(cfg, container) {
  10603. var points = this.parsePoints(cfg.points);
  10604. var style = Util.mix({
  10605. fill: cfg.color
  10606. }, Global.shape.interval, cfg.style);
  10607. if (cfg.isInCircle) {
  10608. var newPoints = points.slice(0);
  10609. if (this._coord.transposed) {
  10610. newPoints = [points[0], points[3], points[2], points[1]];
  10611. }
  10612. var _cfg$center = cfg.center,
  10613. x = _cfg$center.x,
  10614. y = _cfg$center.y;
  10615. var v = [1, 0];
  10616. var v0 = [newPoints[0].x - x, newPoints[0].y - y];
  10617. var v1 = [newPoints[1].x - x, newPoints[1].y - y];
  10618. var v2 = [newPoints[2].x - x, newPoints[2].y - y];
  10619. var startAngle = Vector2.angleTo(v, v1);
  10620. var endAngle = Vector2.angleTo(v, v2);
  10621. var r0 = Vector2.length(v0);
  10622. var r = Vector2.length(v1);
  10623. if (startAngle >= 1.5 * Math.PI) {
  10624. startAngle = startAngle - 2 * Math.PI;
  10625. }
  10626. if (endAngle >= 1.5 * Math.PI) {
  10627. endAngle = endAngle - 2 * Math.PI;
  10628. }
  10629. return container.addShape('Sector', {
  10630. className: 'interval',
  10631. attrs: Util.mix({
  10632. x: x,
  10633. y: y,
  10634. r: r,
  10635. r0: r0,
  10636. startAngle: startAngle,
  10637. endAngle: endAngle
  10638. }, style)
  10639. });
  10640. }
  10641. var rectCfg = getRectRange(points);
  10642. return container.addShape('rect', {
  10643. className: 'interval',
  10644. attrs: Util.mix(rectCfg, style)
  10645. });
  10646. }
  10647. }); // 金字塔 和 漏斗图
  10648. ['pyramid', 'funnel'].forEach(function (shapeType) {
  10649. Shape.registerShape('interval', shapeType, {
  10650. getPoints: function getPoints(cfg) {
  10651. cfg.size = cfg.size * 2; // 漏斗图的 size 是柱状图的两倍
  10652. return getRectPoints(cfg);
  10653. },
  10654. draw: function draw(cfg, container) {
  10655. var points = this.parsePoints(cfg.points);
  10656. var nextPoints = this.parsePoints(cfg.nextPoints);
  10657. var polygonPoints = null;
  10658. if (nextPoints) {
  10659. polygonPoints = [points[0], points[1], nextPoints[1], nextPoints[0]];
  10660. } else {
  10661. polygonPoints = [points[0], points[1]]; // pyramid 顶部是三角形,所以取中心点就好了,funnel顶部是长方形
  10662. if (shapeType === 'pyramid') {
  10663. polygonPoints.push(getMiddlePoint(points[2], points[3]));
  10664. } else {
  10665. polygonPoints.push(points[2], points[3]);
  10666. }
  10667. }
  10668. var attrs = Util.mix({
  10669. fill: cfg.color,
  10670. points: polygonPoints
  10671. }, Global.shape.interval, cfg.style);
  10672. return container.addShape('polygon', {
  10673. className: 'interval',
  10674. attrs: attrs
  10675. });
  10676. }
  10677. });
  10678. });
  10679. module.exports = Interval;
  10680. /***/ }),
  10681. /* 193 */
  10682. /***/ (function(module, exports, __webpack_require__) {
  10683. "use strict";
  10684. module.exports = {
  10685. Stack: __webpack_require__(194),
  10686. Dodge: __webpack_require__(196),
  10687. Symmetric: __webpack_require__(198)
  10688. };
  10689. /***/ }),
  10690. /* 194 */
  10691. /***/ (function(module, exports, __webpack_require__) {
  10692. "use strict";
  10693. var Stack = __webpack_require__(195);
  10694. module.exports = Stack;
  10695. /***/ }),
  10696. /* 195 */
  10697. /***/ (function(module, exports, __webpack_require__) {
  10698. function _inheritsLoose(subClass, superClass) {
  10699. subClass.prototype = Object.create(superClass.prototype);
  10700. subClass.prototype.constructor = subClass;
  10701. subClass.__proto__ = superClass;
  10702. }
  10703. var isArray = __webpack_require__(34);
  10704. var isNil = __webpack_require__(35);
  10705. var Adjust = __webpack_require__(33);
  10706. var Stack = /*#__PURE__*/function (_Adjust) {
  10707. _inheritsLoose(Stack, _Adjust);
  10708. function Stack() {
  10709. return _Adjust.apply(this, arguments) || this;
  10710. }
  10711. var _proto = Stack.prototype;
  10712. _proto._initDefaultCfg = function _initDefaultCfg() {
  10713. this.xField = null; // 调整对应的 x 方向对应的字段名称
  10714. this.yField = null; // 调整对应的 y 方向对应的字段名称
  10715. };
  10716. _proto.processAdjust = function processAdjust(dataArray) {
  10717. this.processStack(dataArray);
  10718. };
  10719. _proto.processStack = function processStack(dataArray) {
  10720. var self = this;
  10721. var xField = self.xField;
  10722. var yField = self.yField;
  10723. var count = dataArray.length;
  10724. var stackCache = {
  10725. positive: {},
  10726. negative: {}
  10727. }; // 层叠顺序翻转
  10728. if (self.reverseOrder) {
  10729. dataArray = dataArray.slice(0).reverse();
  10730. }
  10731. for (var i = 0; i < count; i++) {
  10732. var data = dataArray[i];
  10733. for (var j = 0, len = data.length; j < len; j++) {
  10734. var item = data[j];
  10735. var x = item[xField] || 0;
  10736. var y = item[yField];
  10737. var xkey = x.toString();
  10738. y = isArray(y) ? y[1] : y;
  10739. if (!isNil(y)) {
  10740. var direction = y >= 0 ? 'positive' : 'negative';
  10741. if (!stackCache[direction][xkey]) {
  10742. stackCache[direction][xkey] = 0;
  10743. }
  10744. item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
  10745. stackCache[direction][xkey] += y;
  10746. }
  10747. }
  10748. }
  10749. };
  10750. return Stack;
  10751. }(Adjust);
  10752. Adjust.Stack = Stack;
  10753. module.exports = Stack;
  10754. /***/ }),
  10755. /* 196 */
  10756. /***/ (function(module, exports, __webpack_require__) {
  10757. "use strict";
  10758. var Dodge = __webpack_require__(197);
  10759. module.exports = Dodge;
  10760. /***/ }),
  10761. /* 197 */
  10762. /***/ (function(module, exports, __webpack_require__) {
  10763. function _inheritsLoose(subClass, superClass) {
  10764. subClass.prototype = Object.create(superClass.prototype);
  10765. subClass.prototype.constructor = subClass;
  10766. subClass.__proto__ = superClass;
  10767. }
  10768. var Adjust = __webpack_require__(33);
  10769. var each = __webpack_require__(15);
  10770. var MARGIN_RATIO = 1 / 2;
  10771. var DODGE_RATIO = 1 / 2;
  10772. var Dodge = /*#__PURE__*/function (_Adjust) {
  10773. _inheritsLoose(Dodge, _Adjust);
  10774. function Dodge() {
  10775. return _Adjust.apply(this, arguments) || this;
  10776. }
  10777. var _proto = Dodge.prototype;
  10778. _proto._initDefaultCfg = function _initDefaultCfg() {
  10779. /**
  10780. * 调整过程中,2个数据的间距
  10781. * @type {Number}
  10782. */
  10783. this.marginRatio = MARGIN_RATIO;
  10784. /**
  10785. * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
  10786. * @type {Number}
  10787. */
  10788. this.dodgeRatio = DODGE_RATIO;
  10789. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  10790. };
  10791. _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
  10792. var self = this;
  10793. var pre = range.pre;
  10794. var next = range.next;
  10795. var tickLength = next - pre;
  10796. var width = tickLength * self.dodgeRatio / count;
  10797. var margin = self.marginRatio * width;
  10798. var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
  10799. return (pre + next) / 2 + offset;
  10800. };
  10801. _proto.processAdjust = function processAdjust(dataArray) {
  10802. var self = this;
  10803. var count = dataArray.length;
  10804. var xField = self.xField;
  10805. each(dataArray, function (data, index) {
  10806. for (var i = 0, len = data.length; i < len; i++) {
  10807. var obj = data[i];
  10808. var value = obj[xField];
  10809. var range = {
  10810. pre: len === 1 ? value - 1 : value - 0.5,
  10811. next: len === 1 ? value + 1 : value + 0.5
  10812. };
  10813. var dodgeValue = self.getDodgeOffset(range, index, count);
  10814. obj[xField] = dodgeValue;
  10815. }
  10816. });
  10817. };
  10818. return Dodge;
  10819. }(Adjust);
  10820. Adjust.Dodge = Dodge;
  10821. module.exports = Dodge;
  10822. /***/ }),
  10823. /* 198 */
  10824. /***/ (function(module, exports, __webpack_require__) {
  10825. "use strict";
  10826. var Symmetric = __webpack_require__(199);
  10827. module.exports = Symmetric;
  10828. /***/ }),
  10829. /* 199 */
  10830. /***/ (function(module, exports, __webpack_require__) {
  10831. function _inheritsLoose(subClass, superClass) {
  10832. subClass.prototype = Object.create(superClass.prototype);
  10833. subClass.prototype.constructor = subClass;
  10834. subClass.__proto__ = superClass;
  10835. }
  10836. var each = __webpack_require__(15);
  10837. var maxBy = __webpack_require__(200);
  10838. var isArray = __webpack_require__(34);
  10839. var ArrayUtil = {
  10840. merge: __webpack_require__(202)
  10841. };
  10842. var Adjust = __webpack_require__(33);
  10843. var Symmetric = /*#__PURE__*/function (_Adjust) {
  10844. _inheritsLoose(Symmetric, _Adjust);
  10845. function Symmetric() {
  10846. return _Adjust.apply(this, arguments) || this;
  10847. }
  10848. var _proto = Symmetric.prototype;
  10849. _proto._initDefaultCfg = function _initDefaultCfg() {
  10850. this.xField = null; // 调整对应的 x 方向对应的字段名称
  10851. this.yField = null; // 调整对应的 y 方向对应的字段名称
  10852. this.cacheMax = null; // 缓存的最大值
  10853. this.adjustNames = ['y']; // Only support stack y
  10854. this.groupFields = null; // 参与分组的数据维度
  10855. }; // 获取最大的y值
  10856. _proto._getMax = function _getMax(dim) {
  10857. var self = this;
  10858. var mergeData = self.mergeData;
  10859. var maxRecord = maxBy(mergeData, function (obj) {
  10860. var value = obj[dim];
  10861. if (isArray(value)) {
  10862. return Math.max.apply(null, value);
  10863. }
  10864. return value;
  10865. });
  10866. var maxValue = maxRecord[dim];
  10867. var max = isArray(maxValue) ? Math.max.apply(null, maxValue) : maxValue;
  10868. return max;
  10869. }; // 获取每个字段最大的值
  10870. _proto._getXValuesMax = function _getXValuesMax() {
  10871. var self = this;
  10872. var yField = self.yField;
  10873. var xField = self.xField;
  10874. var cache = {};
  10875. var mergeData = self.mergeData;
  10876. each(mergeData, function (obj) {
  10877. var xValue = obj[xField];
  10878. var yValue = obj[yField];
  10879. var max = isArray(yValue) ? Math.max.apply(null, yValue) : yValue;
  10880. cache[xValue] = cache[xValue] || 0;
  10881. if (cache[xValue] < max) {
  10882. cache[xValue] = max;
  10883. }
  10884. });
  10885. return cache;
  10886. }; // 入口函数
  10887. _proto.processAdjust = function processAdjust(dataArray) {
  10888. var self = this;
  10889. var mergeData = ArrayUtil.merge(dataArray);
  10890. self.mergeData = mergeData;
  10891. self._processSymmetric(dataArray);
  10892. self.mergeData = null;
  10893. }; // 处理对称
  10894. _proto._processSymmetric = function _processSymmetric(dataArray) {
  10895. var self = this;
  10896. var xField = self.xField;
  10897. var yField = self.yField;
  10898. var max = self._getMax(yField);
  10899. var first = dataArray[0][0];
  10900. var cache;
  10901. if (first && isArray(first[yField])) {
  10902. cache = self._getXValuesMax();
  10903. }
  10904. each(dataArray, function (data) {
  10905. each(data, function (obj) {
  10906. var value = obj[yField];
  10907. var offset;
  10908. if (isArray(value)) {
  10909. var xValue = obj[xField];
  10910. var valueMax = cache[xValue];
  10911. offset = (max - valueMax) / 2;
  10912. var tmp = [];
  10913. /* eslint-disable no-loop-func */
  10914. each(value, function (subVal) {
  10915. // 多个字段
  10916. tmp.push(offset + subVal);
  10917. });
  10918. /* eslint-enable no-loop-func */
  10919. obj[yField] = tmp;
  10920. } else {
  10921. offset = (max - value) / 2;
  10922. obj[yField] = [offset, value + offset];
  10923. }
  10924. });
  10925. });
  10926. };
  10927. return Symmetric;
  10928. }(Adjust);
  10929. Adjust.Symmetric = Symmetric;
  10930. module.exports = Symmetric;
  10931. /***/ }),
  10932. /* 200 */
  10933. /***/ (function(module, exports, __webpack_require__) {
  10934. var isArray = __webpack_require__(34);
  10935. var isFunction = __webpack_require__(201);
  10936. var each = __webpack_require__(15);
  10937. /**
  10938. * @param {Array} arr The array to iterate over.
  10939. * @param {Function} [fn] The iteratee invoked per element.
  10940. * @return {*} Returns the maximum value.
  10941. * @example
  10942. *
  10943. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  10944. *
  10945. * maxBy(objects, function(o) { return o.n; });
  10946. * // => { 'n': 2 }
  10947. *
  10948. * maxBy(objects, 'n');
  10949. * // => { 'n': 2 }
  10950. */
  10951. var maxBy = function maxBy(arr, fn) {
  10952. if (!isArray(arr)) {
  10953. return undefined;
  10954. }
  10955. var max = arr[0];
  10956. var maxData = void 0;
  10957. if (isFunction(fn)) {
  10958. maxData = fn(arr[0]);
  10959. } else {
  10960. maxData = arr[0][fn];
  10961. }
  10962. var data = void 0;
  10963. each(arr, function (val) {
  10964. if (isFunction(fn)) {
  10965. data = fn(val);
  10966. } else {
  10967. data = val[fn];
  10968. }
  10969. if (data > maxData) {
  10970. max = val;
  10971. maxData = data;
  10972. }
  10973. });
  10974. return max;
  10975. };
  10976. module.exports = maxBy;
  10977. /***/ }),
  10978. /* 201 */
  10979. /***/ (function(module, exports, __webpack_require__) {
  10980. /**
  10981. * 是否为函数
  10982. * @param {*} fn 对象
  10983. * @return {Boolean} 是否函数
  10984. */
  10985. var isType = __webpack_require__(27);
  10986. var isFunction = function isFunction(value) {
  10987. return isType(value, 'Function');
  10988. };
  10989. module.exports = isFunction;
  10990. /***/ }),
  10991. /* 202 */
  10992. /***/ (function(module, exports) {
  10993. var merge = function merge(dataArray) {
  10994. var rst = [];
  10995. for (var i = 0; i < dataArray.length; i++) {
  10996. rst = rst.concat(dataArray[i]);
  10997. }
  10998. return rst;
  10999. };
  11000. module.exports = merge;
  11001. /***/ }),
  11002. /* 203 */
  11003. /***/ (function(module, exports, __webpack_require__) {
  11004. "use strict";
  11005. var _interopRequireDefault = __webpack_require__(1);
  11006. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  11007. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  11008. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  11009. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  11010. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11011. var Base = __webpack_require__(43);
  11012. var Vector2 = __webpack_require__(13);
  11013. var Matrix = __webpack_require__(31);
  11014. var Polar = /*#__PURE__*/function (_Base) {
  11015. (0, _inheritsLoose2["default"])(Polar, _Base);
  11016. var _super = _createSuper(Polar);
  11017. function Polar() {
  11018. return _Base.apply(this, arguments) || this;
  11019. }
  11020. var _proto = Polar.prototype;
  11021. _proto._initDefaultCfg = function _initDefaultCfg() {
  11022. this.type = 'polar';
  11023. this.startAngle = -Math.PI / 2;
  11024. this.endAngle = Math.PI * 3 / 2;
  11025. this.inner = 0;
  11026. this.innerRadius = 0; // alias
  11027. this.isPolar = true;
  11028. this.transposed = false;
  11029. this.center = null;
  11030. this.radius = null; // relative, 0 ~ 1
  11031. };
  11032. _proto.init = function init(start, end) {
  11033. _Base.prototype.init.call(this, start, end);
  11034. var self = this;
  11035. var inner = self.inner || self.innerRadius;
  11036. var width = Math.abs(end.x - start.x);
  11037. var height = Math.abs(end.y - start.y);
  11038. var maxRadius;
  11039. var center;
  11040. if (self.startAngle === -Math.PI && self.endAngle === 0) {
  11041. maxRadius = Math.min(width / 2, height);
  11042. center = {
  11043. x: (start.x + end.x) / 2,
  11044. y: start.y
  11045. };
  11046. } else {
  11047. maxRadius = Math.min(width, height) / 2;
  11048. center = {
  11049. x: (start.x + end.x) / 2,
  11050. y: (start.y + end.y) / 2
  11051. };
  11052. }
  11053. var radius = self.radius;
  11054. if (radius > 0 && radius <= 1) {
  11055. maxRadius = maxRadius * radius;
  11056. }
  11057. this.x = {
  11058. start: self.startAngle,
  11059. end: self.endAngle
  11060. };
  11061. this.y = {
  11062. start: maxRadius * inner,
  11063. end: maxRadius
  11064. };
  11065. this.center = center;
  11066. this.circleRadius = maxRadius; // the radius value in px
  11067. };
  11068. _proto._convertPoint = function _convertPoint(point) {
  11069. var self = this;
  11070. var center = self.center;
  11071. var transposed = self.transposed;
  11072. var xDim = transposed ? 'y' : 'x';
  11073. var yDim = transposed ? 'x' : 'y';
  11074. var x = self.x;
  11075. var y = self.y;
  11076. var angle = x.start + (x.end - x.start) * point[xDim];
  11077. var radius = y.start + (y.end - y.start) * point[yDim];
  11078. return {
  11079. x: center.x + Math.cos(angle) * radius,
  11080. y: center.y + Math.sin(angle) * radius
  11081. };
  11082. };
  11083. _proto._invertPoint = function _invertPoint(point) {
  11084. var self = this;
  11085. var center = self.center,
  11086. transposed = self.transposed,
  11087. x = self.x,
  11088. y = self.y;
  11089. var xDim = transposed ? 'y' : 'x';
  11090. var yDim = transposed ? 'x' : 'y';
  11091. var m = [1, 0, 0, 1, 0, 0];
  11092. Matrix.rotate(m, m, x.start);
  11093. var startV = [1, 0];
  11094. Vector2.transformMat2d(startV, startV, m);
  11095. startV = [startV[0], startV[1]];
  11096. var pointV = [point.x - center.x, point.y - center.y];
  11097. if (Vector2.zero(pointV)) {
  11098. return {
  11099. x: 0,
  11100. y: 0
  11101. };
  11102. }
  11103. var theta = Vector2.angleTo(startV, pointV, x.end < x.start);
  11104. if (Math.abs(theta - Math.PI * 2) < 0.001) {
  11105. theta = 0;
  11106. }
  11107. var l = Vector2.length(pointV);
  11108. var percentX = theta / (x.end - x.start);
  11109. percentX = x.end - x.start > 0 ? percentX : -percentX;
  11110. var percentY = (l - y.start) / (y.end - y.start);
  11111. var rst = {};
  11112. rst[xDim] = percentX;
  11113. rst[yDim] = percentY;
  11114. return rst;
  11115. };
  11116. return Polar;
  11117. }(Base);
  11118. Base.Polar = Polar;
  11119. module.exports = Polar;
  11120. /***/ }),
  11121. /* 204 */
  11122. /***/ (function(module, exports, __webpack_require__) {
  11123. /**
  11124. * @fileOverview 提取公共代码到util方法
  11125. * @author dxq613@gmail.com
  11126. */
  11127. var isString = __webpack_require__(48);
  11128. var isDate = __webpack_require__(222);
  11129. module.exports = {
  11130. toTimeStamp: function toTimeStamp(value) {
  11131. if (isString(value)) {
  11132. if (value.indexOf('T') > 0) {
  11133. value = new Date(value).getTime();
  11134. } else {
  11135. value = new Date(value.replace(/-/ig, '/')).getTime();
  11136. }
  11137. }
  11138. if (isDate(value)) {
  11139. value = value.getTime();
  11140. }
  11141. return value;
  11142. }
  11143. };
  11144. /***/ }),
  11145. /* 205 */
  11146. /***/ (function(module, exports, __webpack_require__) {
  11147. "use strict";
  11148. var Util = __webpack_require__(0);
  11149. var _require = __webpack_require__(16),
  11150. Group = _require.Group;
  11151. var Marker = __webpack_require__(76);
  11152. var MARKER_RADIUS = 3;
  11153. var List = /*#__PURE__*/function () {
  11154. var _proto = List.prototype;
  11155. _proto.getDefaultCfg = function getDefaultCfg() {
  11156. return {
  11157. showTitle: false,
  11158. /**
  11159. * title string
  11160. * @type {?String}
  11161. */
  11162. title: null,
  11163. /**
  11164. * items array
  11165. * @type {?Array}
  11166. */
  11167. items: null,
  11168. /**
  11169. * offset between title and items
  11170. * @type {Number}
  11171. */
  11172. titleGap: 12,
  11173. /**
  11174. * offset between each item
  11175. * @type {Number}
  11176. */
  11177. itemGap: 10,
  11178. /**
  11179. * the offset between each item in vertical direaction
  11180. * @type {Number}
  11181. */
  11182. itemMarginBottom: 12,
  11183. /**
  11184. * the formatter for item text
  11185. * @type {[type]}
  11186. */
  11187. itemFormatter: null,
  11188. itemWidth: null,
  11189. /**
  11190. * offset between marker and text
  11191. * @type {Number}
  11192. */
  11193. wordSpace: 6,
  11194. x: 0,
  11195. y: 0,
  11196. layout: 'horizontal',
  11197. /**
  11198. * the join string of `name` and `value`
  11199. * @type {String}
  11200. */
  11201. joinString: ': '
  11202. };
  11203. };
  11204. function List(cfg) {
  11205. Util.deepMix(this, this.getDefaultCfg(), cfg);
  11206. this._init();
  11207. this._renderTitle();
  11208. this._renderItems();
  11209. }
  11210. _proto._init = function _init() {
  11211. var container = new Group({
  11212. zIndex: this.zIndex || 0
  11213. });
  11214. this.container = container;
  11215. var wrapper = container.addGroup();
  11216. this.wrapper = wrapper;
  11217. var itemsGroup = wrapper.addGroup({
  11218. className: 'itemsGroup'
  11219. });
  11220. this.itemsGroup = itemsGroup;
  11221. if (this.parent) {
  11222. this.parent.add(container);
  11223. }
  11224. };
  11225. _proto._renderTitle = function _renderTitle(title) {
  11226. title = title || this.title;
  11227. var titleShape = this.titleShape;
  11228. var titleHeight = 0;
  11229. if (this.showTitle && title) {
  11230. if (titleShape && !titleShape.get('destroyed')) {
  11231. titleShape.attr('text', title);
  11232. } else {
  11233. var wrapper = this.wrapper,
  11234. titleStyle = this.titleStyle;
  11235. titleShape = wrapper.addShape('text', {
  11236. className: 'title',
  11237. attrs: Util.mix({
  11238. x: 0,
  11239. y: 0,
  11240. text: title
  11241. }, titleStyle)
  11242. });
  11243. this.titleShape = titleShape;
  11244. }
  11245. titleHeight = titleShape.getBBox().height + this.titleGap;
  11246. }
  11247. this._titleHeight = titleHeight;
  11248. };
  11249. _proto._renderItems = function _renderItems(items) {
  11250. var self = this;
  11251. items = items || self.items;
  11252. if (!items) {
  11253. return;
  11254. }
  11255. if (self.reversed) {
  11256. items.reverse();
  11257. }
  11258. Util.each(items, function (item, index) {
  11259. self._addItem(item, index);
  11260. });
  11261. if (items.length > 1) {
  11262. this._adjustItems();
  11263. }
  11264. this._renderBackground();
  11265. };
  11266. _proto._renderBackground = function _renderBackground() {
  11267. var background = this.background;
  11268. if (background) {
  11269. var container = this.container;
  11270. var wrapper = this.wrapper;
  11271. var _wrapper$getBBox = wrapper.getBBox(),
  11272. minX = _wrapper$getBBox.minX,
  11273. minY = _wrapper$getBBox.minY,
  11274. width = _wrapper$getBBox.width,
  11275. height = _wrapper$getBBox.height;
  11276. var padding = background.padding || [0, 0, 0, 0];
  11277. padding = Util.parsePadding(padding);
  11278. var attrs = Util.mix({
  11279. x: minX - padding[3],
  11280. y: minY - padding[0],
  11281. width: width + padding[1] + padding[3],
  11282. height: height + padding[0] + padding[2]
  11283. }, background);
  11284. var backShape = this.backShape;
  11285. if (backShape) {
  11286. backShape.attr(attrs);
  11287. } else {
  11288. backShape = container.addShape('Rect', {
  11289. zIndex: -1,
  11290. attrs: attrs
  11291. });
  11292. }
  11293. this.backShape = backShape;
  11294. container.sort();
  11295. }
  11296. };
  11297. _proto._addItem = function _addItem(item) {
  11298. var itemsGroup = this.itemsGroup;
  11299. var itemGroup = itemsGroup.addGroup({
  11300. name: item.name,
  11301. value: item.value,
  11302. dataValue: item.dataValue,
  11303. checked: item.checked
  11304. });
  11305. var unCheckStyle = this.unCheckStyle,
  11306. unCheckColor = this.unCheckColor,
  11307. nameStyle = this.nameStyle,
  11308. valueStyle = this.valueStyle,
  11309. wordSpace = this.wordSpace;
  11310. var marker = item.marker,
  11311. value = item.value;
  11312. var startX = 0;
  11313. if (unCheckColor) {
  11314. unCheckStyle.fill = unCheckColor;
  11315. }
  11316. if (marker) {
  11317. var radius = marker.radius || MARKER_RADIUS;
  11318. var markerAttrs = Util.mix({
  11319. x: radius,
  11320. y: this._titleHeight
  11321. }, marker);
  11322. if (item.checked === false) {
  11323. Util.mix(markerAttrs, unCheckStyle);
  11324. }
  11325. var markerShape = new Marker({
  11326. className: 'item-marker',
  11327. attrs: markerAttrs
  11328. });
  11329. itemGroup.add(markerShape);
  11330. startX += markerShape.getBBox().width + wordSpace;
  11331. }
  11332. var nameText;
  11333. var name = item.name;
  11334. if (name) {
  11335. var joinString = this.joinString || '';
  11336. name = value ? name + joinString : name;
  11337. nameText = itemGroup.addShape('text', {
  11338. className: 'name',
  11339. attrs: Util.mix({
  11340. x: startX,
  11341. y: this._titleHeight,
  11342. text: this._formatItemValue(name)
  11343. }, nameStyle, item.checked === false ? unCheckStyle : null)
  11344. });
  11345. }
  11346. if (value) {
  11347. var valueX = startX;
  11348. if (nameText) {
  11349. valueX += nameText.getBBox().width;
  11350. }
  11351. itemGroup.addShape('text', {
  11352. className: 'value',
  11353. attrs: Util.mix({
  11354. x: valueX,
  11355. y: this._titleHeight,
  11356. text: value
  11357. }, valueStyle, item.checked === false ? unCheckStyle : null)
  11358. });
  11359. }
  11360. return itemGroup;
  11361. };
  11362. _proto._formatItemValue = function _formatItemValue(value) {
  11363. var formatter = this.itemFormatter;
  11364. if (formatter) {
  11365. value = formatter.call(this, value);
  11366. }
  11367. return value;
  11368. };
  11369. _proto._getMaxItemWidth = function _getMaxItemWidth() {
  11370. var width;
  11371. var itemWidth = this.itemWidth;
  11372. if (Util.isNumber(itemWidth) || Util.isNil(itemWidth)) {
  11373. return itemWidth;
  11374. }
  11375. if (itemWidth === 'auto') {
  11376. var itemsGroup = this.itemsGroup;
  11377. var children = itemsGroup.get('children');
  11378. var count = children.length;
  11379. var maxItemWidth = 0;
  11380. for (var i = 0; i < count; i++) {
  11381. var _children$i$getBBox = children[i].getBBox(),
  11382. _width = _children$i$getBBox.width;
  11383. maxItemWidth = Math.max(maxItemWidth, _width);
  11384. }
  11385. var maxLength = this.maxLength;
  11386. var itemGap = this.itemGap;
  11387. var twoAvgWidth = (maxLength - itemGap) / 2;
  11388. var threeAvgWidth = (maxLength - itemGap * 2) / 3;
  11389. if (count === 2) {
  11390. width = Math.max(maxItemWidth, twoAvgWidth);
  11391. } else {
  11392. // 1. max <= 3Avg, 3Avg
  11393. // 2. 3Avg < max && max < 2avg, 2avg
  11394. // 3. max > 2avg, max, one column
  11395. if (maxItemWidth <= threeAvgWidth) {
  11396. width = threeAvgWidth;
  11397. } else if (maxItemWidth <= twoAvgWidth) {
  11398. width = twoAvgWidth;
  11399. } else {
  11400. width = maxItemWidth;
  11401. }
  11402. }
  11403. return width;
  11404. }
  11405. };
  11406. _proto._adjustHorizontal = function _adjustHorizontal() {
  11407. var maxLength = this.maxLength,
  11408. itemsGroup = this.itemsGroup;
  11409. var children = itemsGroup.get('children');
  11410. var itemGap = this.itemGap,
  11411. itemMarginBottom = this.itemMarginBottom;
  11412. var titleHeight = this._titleHeight;
  11413. var row = 0;
  11414. var rowWidth = 0;
  11415. var width;
  11416. var height;
  11417. var itemWidth = this._getMaxItemWidth();
  11418. var legendHitBoxes = [];
  11419. for (var i = 0, len = children.length; i < len; i++) {
  11420. var child = children[i];
  11421. var box = child.getBBox();
  11422. var childHeight = box.height;
  11423. var childWidth = box.width;
  11424. width = itemWidth || childWidth;
  11425. height = childHeight + itemMarginBottom;
  11426. if (width - (maxLength - rowWidth) > 0.0001) {
  11427. row++;
  11428. rowWidth = 0;
  11429. }
  11430. child.moveTo(rowWidth, row * height);
  11431. legendHitBoxes.push({
  11432. x: rowWidth,
  11433. y: row * height + titleHeight - childHeight / 2,
  11434. width: childWidth * 1.375,
  11435. height: childHeight * 1.375
  11436. });
  11437. rowWidth += width + itemGap;
  11438. }
  11439. this.legendHitBoxes = legendHitBoxes;
  11440. return;
  11441. };
  11442. _proto._adjustVertical = function _adjustVertical() {
  11443. var maxLength = this.maxLength,
  11444. itemsGroup = this.itemsGroup;
  11445. var itemGap = this.itemGap,
  11446. itemMarginBottom = this.itemMarginBottom,
  11447. itemWidth = this.itemWidth;
  11448. var titleHeight = this._titleHeight;
  11449. var children = itemsGroup.get('children');
  11450. var colHeight = 0;
  11451. var width;
  11452. var height;
  11453. var maxItemWidth = 0;
  11454. var totalWidth = 0;
  11455. var legendHitBoxes = [];
  11456. for (var i = 0, length = children.length; i < length; i++) {
  11457. var child = children[i];
  11458. var bbox = child.getBBox();
  11459. width = bbox.width;
  11460. height = bbox.height;
  11461. if (Util.isNumber(itemWidth)) {
  11462. maxItemWidth = itemWidth + itemGap;
  11463. } else if (width > maxItemWidth) {
  11464. maxItemWidth = width + itemGap;
  11465. }
  11466. if (maxLength - colHeight < height) {
  11467. colHeight = 0;
  11468. totalWidth += maxItemWidth;
  11469. child.moveTo(totalWidth, 0);
  11470. legendHitBoxes.push({
  11471. x: totalWidth,
  11472. y: titleHeight - height / 2,
  11473. width: width * 1.375,
  11474. height: height * 1.375
  11475. });
  11476. } else {
  11477. child.moveTo(totalWidth, colHeight);
  11478. legendHitBoxes.push({
  11479. x: totalWidth,
  11480. y: colHeight - height / 2 + titleHeight,
  11481. width: width * 1.375,
  11482. height: height * 1.375
  11483. });
  11484. }
  11485. colHeight += height + itemMarginBottom;
  11486. }
  11487. this.legendHitBoxes = legendHitBoxes;
  11488. return;
  11489. };
  11490. _proto._adjustItems = function _adjustItems() {
  11491. var layout = this.layout;
  11492. if (layout === 'horizontal') {
  11493. this._adjustHorizontal();
  11494. } else {
  11495. this._adjustVertical();
  11496. }
  11497. };
  11498. _proto.moveTo = function moveTo(x, y) {
  11499. this.x = x;
  11500. this.y = y;
  11501. var container = this.container;
  11502. container && container.moveTo(x, y);
  11503. return this;
  11504. };
  11505. _proto.setItems = function setItems(items) {
  11506. this.clearItems();
  11507. this._renderItems(items);
  11508. };
  11509. _proto.setTitle = function setTitle(title) {
  11510. this._renderTitle(title);
  11511. };
  11512. _proto.clearItems = function clearItems() {
  11513. var itemsGroup = this.itemsGroup;
  11514. itemsGroup.clear();
  11515. };
  11516. _proto.getWidth = function getWidth() {
  11517. var container = this.container;
  11518. var bbox = container.getBBox();
  11519. return bbox.width;
  11520. };
  11521. _proto.getHeight = function getHeight() {
  11522. var container = this.container;
  11523. var bbox = container.getBBox();
  11524. return bbox.height;
  11525. };
  11526. _proto.show = function show() {
  11527. var container = this.container;
  11528. container.show();
  11529. };
  11530. _proto.hide = function hide() {
  11531. var container = this.container;
  11532. container.hide();
  11533. };
  11534. _proto.clear = function clear() {
  11535. var container = this.container;
  11536. container.clear();
  11537. container.remove(true);
  11538. };
  11539. return List;
  11540. }();
  11541. module.exports = List;
  11542. /***/ }),
  11543. /* 206 */
  11544. /***/ (function(module, exports, __webpack_require__) {
  11545. "use strict";
  11546. /**
  11547. * Animate configuration and register
  11548. * @author sima.zhang1990@gmail.com
  11549. */
  11550. var Util = __webpack_require__(0);
  11551. var defaultAnimationCfg = {
  11552. appear: {
  11553. duration: 450,
  11554. easing: 'quadraticOut'
  11555. },
  11556. // 'appear' animation options
  11557. update: {
  11558. duration: 300,
  11559. easing: 'quadraticOut'
  11560. },
  11561. // 'update' animation options
  11562. enter: {
  11563. duration: 300,
  11564. easing: 'quadraticOut'
  11565. },
  11566. // 'enter' animation options
  11567. leave: {
  11568. duration: 350,
  11569. easing: 'quadraticIn'
  11570. } // 'leave' animation options
  11571. };
  11572. var Animate = {
  11573. defaultCfg: {},
  11574. Action: {},
  11575. getAnimation: function getAnimation(geomType, coord, animationType) {
  11576. var geomAnimateCfg = this.defaultCfg[geomType];
  11577. if (geomAnimateCfg) {
  11578. var animation = geomAnimateCfg[animationType];
  11579. if (Util.isFunction(animation)) {
  11580. return animation(coord);
  11581. }
  11582. }
  11583. return false;
  11584. },
  11585. getAnimateCfg: function getAnimateCfg(geomType, animationType) {
  11586. var defaultCfg = defaultAnimationCfg[animationType];
  11587. var geomConfig = this.defaultCfg[geomType];
  11588. if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
  11589. return Util.deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
  11590. }
  11591. return defaultCfg;
  11592. },
  11593. registerAnimation: function registerAnimation(animationName, animationFun) {
  11594. if (!this.Action) {
  11595. this.Action = {};
  11596. }
  11597. this.Action[animationName] = animationFun;
  11598. }
  11599. };
  11600. module.exports = Animate;
  11601. /***/ }),
  11602. /* 207 */
  11603. /***/ (function(module, exports, __webpack_require__) {
  11604. "use strict";
  11605. /**
  11606. * Utility
  11607. * @author sima.zhang1990@gmail.com
  11608. */
  11609. var _require = __webpack_require__(16),
  11610. Matrix = _require.Matrix;
  11611. var Util = __webpack_require__(0);
  11612. var Helpers = {
  11613. getCoordInfo: function getCoordInfo(coord) {
  11614. var start = coord.start;
  11615. var end = coord.end;
  11616. return {
  11617. start: start,
  11618. end: end,
  11619. width: end.x - start.x,
  11620. height: Math.abs(end.y - start.y)
  11621. };
  11622. },
  11623. getScaledMatrix: function getScaledMatrix(shape, v, direct) {
  11624. var scaledMatrix;
  11625. shape.apply(v);
  11626. var x = v[0];
  11627. var y = v[1];
  11628. if (direct === 'x') {
  11629. shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
  11630. var matrix = shape.getMatrix();
  11631. scaledMatrix = Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
  11632. } else if (direct === 'y') {
  11633. shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);
  11634. var _matrix = shape.getMatrix();
  11635. scaledMatrix = Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
  11636. } else if (direct === 'xy') {
  11637. shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);
  11638. var _matrix2 = shape.getMatrix();
  11639. scaledMatrix = Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
  11640. }
  11641. return scaledMatrix;
  11642. },
  11643. getAnimateParam: function getAnimateParam(animateCfg, index, id) {
  11644. var result = {};
  11645. if (animateCfg.delay) {
  11646. result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
  11647. }
  11648. result.easing = animateCfg.easing;
  11649. result.duration = animateCfg.duration;
  11650. result.delay = animateCfg.delay;
  11651. return result;
  11652. },
  11653. doAnimation: function doAnimation(shape, endState, animateCfg, callback) {
  11654. var id = shape._id;
  11655. var index = shape.get('index');
  11656. var _Helpers$getAnimatePa = Helpers.getAnimateParam(animateCfg, index, id),
  11657. easing = _Helpers$getAnimatePa.easing,
  11658. delay = _Helpers$getAnimatePa.delay,
  11659. duration = _Helpers$getAnimatePa.duration;
  11660. var anim = shape.animate().to({
  11661. attrs: endState,
  11662. duration: duration,
  11663. delay: delay,
  11664. easing: easing
  11665. });
  11666. if (callback) {
  11667. anim.onEnd(function () {
  11668. callback();
  11669. });
  11670. }
  11671. }
  11672. };
  11673. module.exports = Helpers;
  11674. /***/ }),
  11675. /* 208 */
  11676. /***/ (function(module, exports, __webpack_require__) {
  11677. "use strict";
  11678. var TimeUtil = __webpack_require__(204);
  11679. var Util = __webpack_require__(0);
  11680. module.exports = {
  11681. getColDef: function getColDef(chart, field) {
  11682. var colDef;
  11683. if (chart.get('colDefs') && chart.get('colDefs')[field]) {
  11684. colDef = chart.get('colDefs')[field];
  11685. }
  11686. return colDef;
  11687. },
  11688. getScale: function getScale(chart, field) {
  11689. var scales = chart.get('scales');
  11690. return scales[field];
  11691. },
  11692. getFieldRange: function getFieldRange(scale, limitRange, type) {
  11693. if (!scale) return [0, 1];
  11694. var minRatio = 0;
  11695. var maxRatio = 0;
  11696. if (type === 'linear') {
  11697. var min = limitRange.min,
  11698. max = limitRange.max;
  11699. minRatio = (scale.min - min) / (max - min);
  11700. maxRatio = (scale.max - min) / (max - min);
  11701. } else {
  11702. var originValues = limitRange;
  11703. var values = scale.values || [];
  11704. var firstIndex = originValues.indexOf(values[0]);
  11705. var lastIndex = originValues.indexOf(values[values.length - 1]);
  11706. minRatio = firstIndex / (originValues.length - 1);
  11707. maxRatio = lastIndex / (originValues.length - 1);
  11708. }
  11709. return [minRatio, maxRatio];
  11710. },
  11711. getLimitRange: function getLimitRange(data, scale) {
  11712. var result;
  11713. var field = scale.field,
  11714. type = scale.type;
  11715. var values = Util.Array.values(data, field);
  11716. if (type === 'linear') {
  11717. result = Util.Array.getRange(values);
  11718. if (scale.min < result.min) {
  11719. result.min = scale.min;
  11720. }
  11721. if (scale.max > result.max) {
  11722. result.max = scale.max;
  11723. }
  11724. } else if (type === 'timeCat') {
  11725. Util.each(values, function (v, i) {
  11726. values[i] = TimeUtil.toTimeStamp(v);
  11727. });
  11728. values.sort(function (v1, v2) {
  11729. return v1 - v2;
  11730. });
  11731. result = values;
  11732. } else {
  11733. result = values;
  11734. }
  11735. return result;
  11736. }
  11737. };
  11738. /***/ }),
  11739. /* 209 */
  11740. /***/ (function(module, exports, __webpack_require__) {
  11741. "use strict";
  11742. var Geom = __webpack_require__(17);
  11743. __webpack_require__(210);
  11744. __webpack_require__(72);
  11745. __webpack_require__(190);
  11746. __webpack_require__(212);
  11747. __webpack_require__(191);
  11748. __webpack_require__(214);
  11749. __webpack_require__(216);
  11750. module.exports = Geom;
  11751. /***/ }),
  11752. /* 210 */
  11753. /***/ (function(module, exports, __webpack_require__) {
  11754. "use strict";
  11755. var _interopRequireDefault = __webpack_require__(1);
  11756. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  11757. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  11758. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  11759. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  11760. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11761. var Util = __webpack_require__(0);
  11762. var Geom = __webpack_require__(17);
  11763. __webpack_require__(211);
  11764. var Point = /*#__PURE__*/function (_Geom) {
  11765. (0, _inheritsLoose2["default"])(Point, _Geom);
  11766. var _super = _createSuper(Point);
  11767. function Point() {
  11768. return _Geom.apply(this, arguments) || this;
  11769. }
  11770. var _proto = Point.prototype;
  11771. _proto.getDefaultCfg = function getDefaultCfg() {
  11772. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  11773. cfg.type = 'point';
  11774. cfg.shapeType = 'point';
  11775. cfg.generatePoints = false;
  11776. return cfg;
  11777. };
  11778. _proto.draw = function draw(data, shapeFactory) {
  11779. var self = this;
  11780. var container = self.get('container');
  11781. Util.each(data, function (obj) {
  11782. var shape = obj.shape;
  11783. var cfg = self.getDrawCfg(obj);
  11784. if (Util.isArray(obj.y)) {
  11785. var hasStack = self.hasAdjust('stack');
  11786. Util.each(obj.y, function (y, idx) {
  11787. cfg.y = y;
  11788. if (!hasStack || idx !== 0) {
  11789. self.drawShape(shape, obj, cfg, container, shapeFactory);
  11790. }
  11791. });
  11792. } else if (!Util.isNil(obj.y)) {
  11793. self.drawShape(shape, obj, cfg, container, shapeFactory);
  11794. }
  11795. });
  11796. };
  11797. return Point;
  11798. }(Geom);
  11799. Geom.Point = Point;
  11800. module.exports = Point;
  11801. /***/ }),
  11802. /* 211 */
  11803. /***/ (function(module, exports, __webpack_require__) {
  11804. "use strict";
  11805. var Util = __webpack_require__(0);
  11806. var Global = __webpack_require__(6);
  11807. var ShapeUtil = __webpack_require__(38);
  11808. var Shape = __webpack_require__(19);
  11809. var SHAPES = ['circle', 'hollowCircle', 'rect'];
  11810. var Point = Shape.registerFactory('point', {
  11811. defaultShapeType: 'circle',
  11812. getDefaultPoints: function getDefaultPoints(pointInfo) {
  11813. return ShapeUtil.splitPoints(pointInfo);
  11814. }
  11815. });
  11816. function getPointsCfg(cfg) {
  11817. var style = {
  11818. lineWidth: 0,
  11819. stroke: cfg.color,
  11820. fill: cfg.color
  11821. };
  11822. if (cfg.size) {
  11823. style.size = cfg.size;
  11824. }
  11825. Util.mix(style, cfg.style);
  11826. return Util.mix({}, Global.shape.point, style);
  11827. }
  11828. function drawShape(cfg, container, shape) {
  11829. if (cfg.size === 0) return;
  11830. var pointCfg = getPointsCfg(cfg);
  11831. var size = pointCfg.r || pointCfg.size;
  11832. var x = cfg.x;
  11833. var y = !Util.isArray(cfg.y) ? [cfg.y] : cfg.y;
  11834. if (shape === 'hollowCircle') {
  11835. pointCfg.lineWidth = 1;
  11836. pointCfg.fill = null;
  11837. }
  11838. for (var i = 0, len = y.length; i < len; i++) {
  11839. if (shape === 'rect') {
  11840. return container.addShape('Rect', {
  11841. className: 'point',
  11842. attrs: Util.mix({
  11843. x: x - size,
  11844. y: y[i] - size,
  11845. width: size * 2,
  11846. height: size * 2
  11847. }, pointCfg)
  11848. });
  11849. }
  11850. return container.addShape('Circle', {
  11851. className: 'point',
  11852. attrs: Util.mix({
  11853. x: x,
  11854. y: y[i],
  11855. r: size
  11856. }, pointCfg)
  11857. });
  11858. }
  11859. }
  11860. Util.each(SHAPES, function (shapeType) {
  11861. Shape.registerShape('point', shapeType, {
  11862. draw: function draw(cfg, container) {
  11863. return drawShape(cfg, container, shapeType);
  11864. }
  11865. });
  11866. });
  11867. module.exports = Point;
  11868. /***/ }),
  11869. /* 212 */
  11870. /***/ (function(module, exports, __webpack_require__) {
  11871. "use strict";
  11872. var _interopRequireDefault = __webpack_require__(1);
  11873. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  11874. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  11875. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  11876. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  11877. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11878. /**
  11879. * @fileOverview area geometry
  11880. * @author dxq613 @gmail.com
  11881. * @author sima.zhang1990@gmail.com
  11882. */
  11883. var Geom = __webpack_require__(17);
  11884. var ShapeUtil = __webpack_require__(38);
  11885. var Util = __webpack_require__(0);
  11886. __webpack_require__(213);
  11887. var Area = /*#__PURE__*/function (_Geom) {
  11888. (0, _inheritsLoose2["default"])(Area, _Geom);
  11889. var _super = _createSuper(Area);
  11890. function Area() {
  11891. return _Geom.apply(this, arguments) || this;
  11892. }
  11893. var _proto = Area.prototype;
  11894. /**
  11895. * get the default configuration
  11896. * @protected
  11897. * @return {Object} return the result
  11898. */
  11899. _proto.getDefaultCfg = function getDefaultCfg() {
  11900. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  11901. cfg.type = 'area';
  11902. cfg.shapeType = 'area';
  11903. cfg.generatePoints = true;
  11904. cfg.sortable = true;
  11905. return cfg;
  11906. };
  11907. _proto.draw = function draw(data, shapeFactory) {
  11908. var self = this;
  11909. var container = self.get('container');
  11910. var cfg = this.getDrawCfg(data[0]);
  11911. var yScale = self.getYScale();
  11912. var connectNulls = self.get('connectNulls');
  11913. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  11914. cfg.origin = data;
  11915. Util.each(splitArray, function (subData, splitedIndex) {
  11916. cfg.splitedIndex = splitedIndex;
  11917. var points = subData.map(function (obj) {
  11918. return obj.points;
  11919. });
  11920. cfg.points = points;
  11921. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  11922. });
  11923. };
  11924. return Area;
  11925. }(Geom);
  11926. Geom.Area = Area;
  11927. module.exports = Area;
  11928. /***/ }),
  11929. /* 213 */
  11930. /***/ (function(module, exports, __webpack_require__) {
  11931. "use strict";
  11932. var Util = __webpack_require__(0);
  11933. var Shape = __webpack_require__(19);
  11934. var Smooth = __webpack_require__(71);
  11935. var bbox = __webpack_require__(21);
  11936. var Global = __webpack_require__(6);
  11937. function equals(v1, v2) {
  11938. return Math.abs(v1 - v2) < 0.00001;
  11939. }
  11940. function notEmpty(value) {
  11941. return !isNaN(value) && !Util.isNil(value);
  11942. }
  11943. function filterPoints(points) {
  11944. var filteredPoints = []; // filter the point which x or y is NaN
  11945. for (var i = 0, len = points.length; i < len; i++) {
  11946. var point = points[i];
  11947. if (notEmpty(point.x) && notEmpty(point.y)) {
  11948. filteredPoints.push(point);
  11949. }
  11950. }
  11951. return filteredPoints;
  11952. }
  11953. function equalsCenter(points, center) {
  11954. var eqls = true;
  11955. Util.each(points, function (point) {
  11956. if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
  11957. eqls = false;
  11958. return false;
  11959. }
  11960. });
  11961. return eqls;
  11962. }
  11963. function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
  11964. var shape;
  11965. var points = topPoints.concat(bottomPoints);
  11966. if (isSmooth) {
  11967. shape = container.addShape('Custom', {
  11968. className: 'area',
  11969. attrs: Util.mix({
  11970. points: points
  11971. }, style),
  11972. createPath: function createPath(context) {
  11973. var constaint = [[0, 0], [1, 1]];
  11974. var points = filterPoints(this._attrs.attrs.points);
  11975. var pointsLen = points.length;
  11976. var topPoints = points.slice(0, pointsLen / 2);
  11977. var bottomPoints = points.slice(pointsLen / 2, pointsLen);
  11978. var topSps = Smooth.smooth(topPoints, false, constaint);
  11979. context.beginPath();
  11980. context.moveTo(topPoints[0].x, topPoints[0].y);
  11981. for (var i = 0, n = topSps.length; i < n; i++) {
  11982. var sp = topSps[i];
  11983. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  11984. }
  11985. if (bottomPoints.length) {
  11986. var bottomSps = Smooth.smooth(bottomPoints, false, constaint);
  11987. context.lineTo(bottomPoints[0].x, bottomPoints[0].y);
  11988. for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
  11989. var _sp = bottomSps[_i];
  11990. context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
  11991. }
  11992. }
  11993. context.closePath();
  11994. },
  11995. calculateBox: function calculateBox() {
  11996. var points = filterPoints(this._attrs.attrs.points);
  11997. return bbox.getBBoxFromPoints(points);
  11998. }
  11999. });
  12000. } else {
  12001. shape = container.addShape('Polyline', {
  12002. className: 'area',
  12003. attrs: Util.mix({
  12004. points: points
  12005. }, style)
  12006. });
  12007. }
  12008. return shape;
  12009. }
  12010. function drawShape(cfg, container, isSmooth) {
  12011. var self = this;
  12012. var points = cfg.points;
  12013. var topPoints = [];
  12014. var bottomPoints = [];
  12015. Util.each(points, function (point) {
  12016. bottomPoints.push(point[0]);
  12017. topPoints.push(point[1]);
  12018. });
  12019. var style = Util.mix({
  12020. fillStyle: cfg.color
  12021. }, Global.shape.area, cfg.style);
  12022. bottomPoints.reverse();
  12023. topPoints = self.parsePoints(topPoints);
  12024. bottomPoints = self.parsePoints(bottomPoints);
  12025. if (cfg.isInCircle) {
  12026. topPoints.push(topPoints[0]);
  12027. bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);
  12028. if (equalsCenter(bottomPoints, cfg.center)) {
  12029. bottomPoints = [];
  12030. }
  12031. }
  12032. return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
  12033. }
  12034. var Area = Shape.registerFactory('area', {
  12035. defaultShapeType: 'area',
  12036. getDefaultPoints: function getDefaultPoints(obj) {
  12037. var x = obj.x;
  12038. var y = obj.y;
  12039. var y0 = obj.y0;
  12040. y = Util.isArray(y) ? y : [y0, y];
  12041. var points = [];
  12042. points.push({
  12043. x: x,
  12044. y: y[0]
  12045. }, {
  12046. x: x,
  12047. y: y[1]
  12048. });
  12049. return points;
  12050. }
  12051. });
  12052. var SHAPES = ['area', 'smooth'];
  12053. Util.each(SHAPES, function (shapeType) {
  12054. Shape.registerShape('area', shapeType, {
  12055. draw: function draw(cfg, container) {
  12056. var smooth = shapeType === 'smooth';
  12057. return drawShape.call(this, cfg, container, smooth);
  12058. }
  12059. });
  12060. });
  12061. module.exports = Area;
  12062. /***/ }),
  12063. /* 214 */
  12064. /***/ (function(module, exports, __webpack_require__) {
  12065. "use strict";
  12066. var _interopRequireDefault = __webpack_require__(1);
  12067. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  12068. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  12069. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  12070. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  12071. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12072. var Geom = __webpack_require__(17);
  12073. var Util = __webpack_require__(0);
  12074. __webpack_require__(215);
  12075. var Polygon = /*#__PURE__*/function (_Geom) {
  12076. (0, _inheritsLoose2["default"])(Polygon, _Geom);
  12077. var _super = _createSuper(Polygon);
  12078. function Polygon() {
  12079. return _Geom.apply(this, arguments) || this;
  12080. }
  12081. var _proto = Polygon.prototype;
  12082. _proto.getDefaultCfg = function getDefaultCfg() {
  12083. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  12084. cfg.type = 'polygon';
  12085. cfg.shapeType = 'polygon';
  12086. cfg.generatePoints = true;
  12087. return cfg;
  12088. };
  12089. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  12090. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  12091. var self = this;
  12092. var x = cfg.x;
  12093. var y = cfg.y;
  12094. var temp;
  12095. if (!(Util.isArray(x) && Util.isArray(y))) {
  12096. var xScale = self.getXScale();
  12097. var yScale = self.getYScale();
  12098. var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
  12099. var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
  12100. var xOffset = 0.5 * 1 / xCount;
  12101. var yOffset = 0.5 * 1 / yCount;
  12102. if (xScale.isCategory && yScale.isCategory) {
  12103. x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
  12104. y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
  12105. } else if (Util.isArray(x)) {
  12106. temp = x;
  12107. x = [temp[0], temp[0], temp[1], temp[1]];
  12108. y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
  12109. } else if (Util.isArray(y)) {
  12110. temp = y;
  12111. y = [temp[0], temp[1], temp[1], temp[0]];
  12112. x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
  12113. }
  12114. cfg.x = x;
  12115. cfg.y = y;
  12116. }
  12117. return cfg;
  12118. };
  12119. return Polygon;
  12120. }(Geom);
  12121. Geom.Polygon = Polygon;
  12122. module.exports = Polygon;
  12123. /***/ }),
  12124. /* 215 */
  12125. /***/ (function(module, exports, __webpack_require__) {
  12126. "use strict";
  12127. var Shape = __webpack_require__(19);
  12128. var Util = __webpack_require__(0);
  12129. var Polygon = Shape.registerFactory('polygon', {
  12130. defaultShapeType: 'polygon',
  12131. getDefaultPoints: function getDefaultPoints(pointInfo) {
  12132. var points = [];
  12133. var x = pointInfo.x,
  12134. y = pointInfo.y;
  12135. for (var i = 0, len = x.length; i < len; i++) {
  12136. points.push({
  12137. x: x[i],
  12138. y: y[i]
  12139. });
  12140. }
  12141. return points;
  12142. }
  12143. });
  12144. Shape.registerShape('polygon', 'polygon', {
  12145. draw: function draw(cfg, container) {
  12146. var points = this.parsePoints(cfg.points);
  12147. var style = Util.mix({
  12148. fill: cfg.color,
  12149. points: points
  12150. }, cfg.style);
  12151. return container.addShape('Polygon', {
  12152. className: 'polygon',
  12153. attrs: style
  12154. });
  12155. }
  12156. });
  12157. module.exports = Polygon;
  12158. /***/ }),
  12159. /* 216 */
  12160. /***/ (function(module, exports, __webpack_require__) {
  12161. "use strict";
  12162. var _interopRequireDefault = __webpack_require__(1);
  12163. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  12164. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  12165. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  12166. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  12167. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  12168. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12169. var Geom = __webpack_require__(17);
  12170. var Util = __webpack_require__(0);
  12171. var SizeMixin = __webpack_require__(73);
  12172. __webpack_require__(217);
  12173. var Schema = /*#__PURE__*/function (_Geom) {
  12174. (0, _inheritsLoose2["default"])(Schema, _Geom);
  12175. var _super = _createSuper(Schema);
  12176. var _proto = Schema.prototype;
  12177. _proto.getDefaultCfg = function getDefaultCfg() {
  12178. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  12179. cfg.type = 'schema';
  12180. cfg.shapeType = 'schema';
  12181. cfg.generatePoints = true;
  12182. return cfg;
  12183. };
  12184. function Schema(cfg) {
  12185. var _this;
  12186. _this = _Geom.call(this, cfg) || this;
  12187. Util.mix((0, _assertThisInitialized2["default"])(_this), SizeMixin);
  12188. return _this;
  12189. }
  12190. _proto.init = function init() {
  12191. _Geom.prototype.init.call(this); // 绑定事件
  12192. this.initEvent();
  12193. };
  12194. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  12195. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  12196. cfg.size = this.getNormalizedSize(obj);
  12197. return cfg;
  12198. };
  12199. _proto.clearInner = function clearInner() {
  12200. _Geom.prototype.clearInner.call(this);
  12201. this.set('defaultSize', null);
  12202. };
  12203. return Schema;
  12204. }(Geom);
  12205. Geom.Schema = Schema;
  12206. module.exports = Schema;
  12207. /***/ }),
  12208. /* 217 */
  12209. /***/ (function(module, exports, __webpack_require__) {
  12210. "use strict";
  12211. var Shape = __webpack_require__(19);
  12212. var Util = __webpack_require__(0);
  12213. function _sortValue(value) {
  12214. var sorted = value.sort(function (a, b) {
  12215. return a < b ? 1 : -1;
  12216. });
  12217. var length = sorted.length;
  12218. if (length < 4) {
  12219. var min = sorted[length - 1];
  12220. for (var i = 0; i < 4 - length; i++) {
  12221. sorted.push(min);
  12222. }
  12223. }
  12224. return sorted;
  12225. } // from left bottom corner, and clockwise
  12226. function getCandlePoints(x, y, width) {
  12227. var yValues = _sortValue(y);
  12228. var points = [{
  12229. x: x,
  12230. y: yValues[0]
  12231. }, {
  12232. x: x,
  12233. y: yValues[1]
  12234. }, {
  12235. x: x - width / 2,
  12236. y: yValues[2]
  12237. }, {
  12238. x: x - width / 2,
  12239. y: yValues[1]
  12240. }, {
  12241. x: x + width / 2,
  12242. y: yValues[1]
  12243. }, {
  12244. x: x + width / 2,
  12245. y: yValues[2]
  12246. }, {
  12247. x: x,
  12248. y: yValues[2]
  12249. }, {
  12250. x: x,
  12251. y: yValues[3]
  12252. }];
  12253. return points;
  12254. }
  12255. var Schema = Shape.registerFactory('schema', {});
  12256. Shape.registerShape('schema', 'candle', {
  12257. getPoints: function getPoints(cfg) {
  12258. return getCandlePoints(cfg.x, cfg.y, cfg.size);
  12259. },
  12260. draw: function draw(cfg, container) {
  12261. var points = this.parsePoints(cfg.points);
  12262. var style = Util.mix({
  12263. stroke: cfg.color,
  12264. fill: cfg.color,
  12265. lineWidth: 1
  12266. }, cfg.style);
  12267. return container.addShape('Custom', {
  12268. className: 'schema',
  12269. attrs: style,
  12270. createPath: function createPath(ctx) {
  12271. ctx.beginPath();
  12272. ctx.moveTo(points[0].x, points[0].y);
  12273. ctx.lineTo(points[1].x, points[1].y);
  12274. ctx.moveTo(points[2].x, points[2].y);
  12275. for (var i = 3; i < 6; i++) {
  12276. ctx.lineTo(points[i].x, points[i].y);
  12277. }
  12278. ctx.closePath();
  12279. ctx.moveTo(points[6].x, points[6].y);
  12280. ctx.lineTo(points[7].x, points[7].y);
  12281. }
  12282. });
  12283. }
  12284. });
  12285. module.exports = Schema;
  12286. /***/ }),
  12287. /* 218 */
  12288. /***/ (function(module, exports, __webpack_require__) {
  12289. "use strict";
  12290. var _interopRequireDefault = __webpack_require__(1);
  12291. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  12292. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  12293. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  12294. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  12295. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12296. var Util = __webpack_require__(0);
  12297. var Abstract = __webpack_require__(45);
  12298. var Circle = /*#__PURE__*/function (_Abstract) {
  12299. (0, _inheritsLoose2["default"])(Circle, _Abstract);
  12300. var _super = _createSuper(Circle);
  12301. function Circle() {
  12302. return _Abstract.apply(this, arguments) || this;
  12303. }
  12304. var _proto = Circle.prototype;
  12305. _proto._initDefaultCfg = function _initDefaultCfg() {
  12306. _Abstract.prototype._initDefaultCfg.call(this);
  12307. this.startAngle = -Math.PI / 2; // start angle,in radian
  12308. this.endAngle = Math.PI * 3 / 2; // end angle, in radian
  12309. this.radius = null; // radius
  12310. this.center = null; // center
  12311. };
  12312. _proto.getOffsetPoint = function getOffsetPoint(value) {
  12313. var startAngle = this.startAngle,
  12314. endAngle = this.endAngle;
  12315. var angle = startAngle + (endAngle - startAngle) * value;
  12316. return this._getCirclePoint(angle);
  12317. };
  12318. _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
  12319. var self = this;
  12320. var center = self.center;
  12321. radius = radius || self.radius;
  12322. return {
  12323. x: center.x + Math.cos(angle) * radius,
  12324. y: center.y + Math.sin(angle) * radius
  12325. };
  12326. };
  12327. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  12328. var self = this;
  12329. var offsetVector = self.getOffsetVector(point, offset);
  12330. var align;
  12331. var baseLine = 'middle';
  12332. if (offsetVector[0] > 0) {
  12333. align = 'left';
  12334. } else if (offsetVector[0] < 0) {
  12335. align = 'right';
  12336. } else {
  12337. align = 'center';
  12338. if (offsetVector[1] > 0) {
  12339. baseLine = 'top';
  12340. } else if (offsetVector[1] < 0) {
  12341. baseLine = 'bottom';
  12342. }
  12343. }
  12344. return {
  12345. textAlign: align,
  12346. textBaseline: baseLine
  12347. };
  12348. };
  12349. _proto.getAxisVector = function getAxisVector(point) {
  12350. var center = this.center;
  12351. var factor = this.offsetFactor;
  12352. return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
  12353. };
  12354. _proto.drawLine = function drawLine(lineCfg) {
  12355. var center = this.center,
  12356. radius = this.radius,
  12357. startAngle = this.startAngle,
  12358. endAngle = this.endAngle;
  12359. var container = this.getContainer(lineCfg.top);
  12360. container.addShape('arc', {
  12361. className: 'axis-line',
  12362. attrs: Util.mix({
  12363. x: center.x,
  12364. y: center.y,
  12365. r: radius,
  12366. startAngle: startAngle,
  12367. endAngle: endAngle
  12368. }, lineCfg)
  12369. });
  12370. };
  12371. return Circle;
  12372. }(Abstract);
  12373. Abstract.Circle = Circle;
  12374. module.exports = Circle;
  12375. /***/ }),
  12376. /* 219 */
  12377. /***/ (function(module, exports, __webpack_require__) {
  12378. "use strict";
  12379. var TimeCat = __webpack_require__(220);
  12380. module.exports = TimeCat;
  12381. /***/ }),
  12382. /* 220 */
  12383. /***/ (function(module, exports, __webpack_require__) {
  12384. function _inheritsLoose(subClass, superClass) {
  12385. subClass.prototype = Object.create(superClass.prototype);
  12386. subClass.prototype.constructor = subClass;
  12387. subClass.__proto__ = superClass;
  12388. }
  12389. /**
  12390. * @fileOverview 时间数据作为分类类型
  12391. * @author dxq613@gmail.com
  12392. */
  12393. var Base = __webpack_require__(26);
  12394. var Category = __webpack_require__(69);
  12395. var fecha = __webpack_require__(221);
  12396. var catAuto = __webpack_require__(65);
  12397. var TimeUtil = __webpack_require__(204);
  12398. var each = __webpack_require__(15);
  12399. var isNumber = __webpack_require__(36);
  12400. var isObject = __webpack_require__(44);
  12401. var isString = __webpack_require__(48);
  12402. /**
  12403. * 度量的构造函数
  12404. * @class Scale.TimeCategory
  12405. */
  12406. var TimeCategory = /*#__PURE__*/function (_Category) {
  12407. _inheritsLoose(TimeCategory, _Category);
  12408. function TimeCategory() {
  12409. return _Category.apply(this, arguments) || this;
  12410. }
  12411. var _proto = TimeCategory.prototype;
  12412. _proto._initDefaultCfg = function _initDefaultCfg() {
  12413. _Category.prototype._initDefaultCfg.call(this);
  12414. this.type = 'timeCat';
  12415. /**
  12416. * 是否需要排序,默认进行排序
  12417. * @type {Boolean}
  12418. */
  12419. this.sortable = true;
  12420. this.tickCount = 5;
  12421. /**
  12422. * 时间格式化
  12423. * @type {String}
  12424. */
  12425. this.mask = 'YYYY-MM-DD';
  12426. };
  12427. _proto.init = function init() {
  12428. var self = this;
  12429. var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳
  12430. each(values, function (v, i) {
  12431. values[i] = self._toTimeStamp(v);
  12432. });
  12433. if (this.sortable) {
  12434. // 允许排序
  12435. values.sort(function (v1, v2) {
  12436. return v1 - v2;
  12437. });
  12438. }
  12439. if (!self.ticks) {
  12440. self.ticks = this.calculateTicks();
  12441. }
  12442. }
  12443. /**
  12444. * 计算 ticks
  12445. * @return {array} 返回 ticks 数组
  12446. */
  12447. ;
  12448. _proto.calculateTicks = function calculateTicks() {
  12449. var self = this;
  12450. var count = self.tickCount;
  12451. var ticks;
  12452. if (count) {
  12453. var temp = catAuto({
  12454. maxCount: count,
  12455. data: self.values,
  12456. isRounding: self.isRounding
  12457. });
  12458. ticks = temp.ticks;
  12459. } else {
  12460. ticks = self.values;
  12461. }
  12462. return ticks;
  12463. }
  12464. /**
  12465. * @override
  12466. */
  12467. ;
  12468. _proto.translate = function translate(value) {
  12469. value = this._toTimeStamp(value);
  12470. var index = this.values.indexOf(value);
  12471. if (index === -1) {
  12472. if (isNumber(value) && value < this.values.length) {
  12473. index = value;
  12474. } else {
  12475. index = NaN;
  12476. }
  12477. }
  12478. return index;
  12479. }
  12480. /**
  12481. * @override
  12482. */
  12483. ;
  12484. _proto.scale = function scale(value) {
  12485. var rangeMin = this.rangeMin();
  12486. var rangeMax = this.rangeMax();
  12487. var index = this.translate(value);
  12488. var percent;
  12489. if (this.values.length === 1 || isNaN(index)) {
  12490. // is index is NAN should not be set as 0
  12491. percent = index;
  12492. } else if (index > -1) {
  12493. percent = index / (this.values.length - 1);
  12494. } else {
  12495. percent = 0;
  12496. }
  12497. return rangeMin + percent * (rangeMax - rangeMin);
  12498. }
  12499. /**
  12500. * @override
  12501. */
  12502. ;
  12503. _proto.getText = function getText(value) {
  12504. var result = '';
  12505. var index = this.translate(value);
  12506. if (index > -1) {
  12507. result = this.values[index];
  12508. } else {
  12509. result = value;
  12510. }
  12511. var formatter = this.formatter;
  12512. result = parseInt(result, 10);
  12513. result = formatter ? formatter(result) : fecha.format(result, this.mask);
  12514. return result;
  12515. }
  12516. /**
  12517. * @override
  12518. */
  12519. ;
  12520. _proto.getTicks = function getTicks() {
  12521. var self = this;
  12522. var ticks = this.ticks;
  12523. var rst = [];
  12524. each(ticks, function (tick) {
  12525. var obj;
  12526. if (isObject(tick)) {
  12527. obj = tick;
  12528. } else {
  12529. obj = {
  12530. text: isString(tick) ? tick : self.getText(tick),
  12531. value: self.scale(tick),
  12532. tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
  12533. };
  12534. }
  12535. rst.push(obj);
  12536. });
  12537. return rst;
  12538. } // 将时间转换为时间戳
  12539. ;
  12540. _proto._toTimeStamp = function _toTimeStamp(value) {
  12541. return TimeUtil.toTimeStamp(value);
  12542. };
  12543. return TimeCategory;
  12544. }(Category);
  12545. Base.TimeCat = TimeCategory;
  12546. module.exports = TimeCategory;
  12547. /***/ }),
  12548. /* 221 */
  12549. /***/ (function(module, exports, __webpack_require__) {
  12550. var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) {
  12551. 'use strict';
  12552. /**
  12553. * Parse or format dates
  12554. * @class fecha
  12555. */
  12556. var fecha = {};
  12557. var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
  12558. var twoDigits = /\d\d?/;
  12559. var threeDigits = /\d{3}/;
  12560. var fourDigits = /\d{4}/;
  12561. var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  12562. var literal = /\[([^]*?)\]/gm;
  12563. var noop = function () {};
  12564. function shorten(arr, sLen) {
  12565. var newArr = [];
  12566. for (var i = 0, len = arr.length; i < len; i++) {
  12567. newArr.push(arr[i].substr(0, sLen));
  12568. }
  12569. return newArr;
  12570. }
  12571. function monthUpdate(arrName) {
  12572. return function (d, v, i18n) {
  12573. var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
  12574. if (~index) {
  12575. d.month = index;
  12576. }
  12577. };
  12578. }
  12579. function pad(val, len) {
  12580. val = String(val);
  12581. len = len || 2;
  12582. while (val.length < len) {
  12583. val = '0' + val;
  12584. }
  12585. return val;
  12586. }
  12587. var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  12588. var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  12589. var monthNamesShort = shorten(monthNames, 3);
  12590. var dayNamesShort = shorten(dayNames, 3);
  12591. fecha.i18n = {
  12592. dayNamesShort: dayNamesShort,
  12593. dayNames: dayNames,
  12594. monthNamesShort: monthNamesShort,
  12595. monthNames: monthNames,
  12596. amPm: ['am', 'pm'],
  12597. DoFn: function DoFn(D) {
  12598. return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
  12599. }
  12600. };
  12601. var formatFlags = {
  12602. D: function (dateObj) {
  12603. return dateObj.getDate();
  12604. },
  12605. DD: function (dateObj) {
  12606. return pad(dateObj.getDate());
  12607. },
  12608. Do: function (dateObj, i18n) {
  12609. return i18n.DoFn(dateObj.getDate());
  12610. },
  12611. d: function (dateObj) {
  12612. return dateObj.getDay();
  12613. },
  12614. dd: function (dateObj) {
  12615. return pad(dateObj.getDay());
  12616. },
  12617. ddd: function (dateObj, i18n) {
  12618. return i18n.dayNamesShort[dateObj.getDay()];
  12619. },
  12620. dddd: function (dateObj, i18n) {
  12621. return i18n.dayNames[dateObj.getDay()];
  12622. },
  12623. M: function (dateObj) {
  12624. return dateObj.getMonth() + 1;
  12625. },
  12626. MM: function (dateObj) {
  12627. return pad(dateObj.getMonth() + 1);
  12628. },
  12629. MMM: function (dateObj, i18n) {
  12630. return i18n.monthNamesShort[dateObj.getMonth()];
  12631. },
  12632. MMMM: function (dateObj, i18n) {
  12633. return i18n.monthNames[dateObj.getMonth()];
  12634. },
  12635. YY: function (dateObj) {
  12636. return String(dateObj.getFullYear()).substr(2);
  12637. },
  12638. YYYY: function (dateObj) {
  12639. return pad(dateObj.getFullYear(), 4);
  12640. },
  12641. h: function (dateObj) {
  12642. return dateObj.getHours() % 12 || 12;
  12643. },
  12644. hh: function (dateObj) {
  12645. return pad(dateObj.getHours() % 12 || 12);
  12646. },
  12647. H: function (dateObj) {
  12648. return dateObj.getHours();
  12649. },
  12650. HH: function (dateObj) {
  12651. return pad(dateObj.getHours());
  12652. },
  12653. m: function (dateObj) {
  12654. return dateObj.getMinutes();
  12655. },
  12656. mm: function (dateObj) {
  12657. return pad(dateObj.getMinutes());
  12658. },
  12659. s: function (dateObj) {
  12660. return dateObj.getSeconds();
  12661. },
  12662. ss: function (dateObj) {
  12663. return pad(dateObj.getSeconds());
  12664. },
  12665. S: function (dateObj) {
  12666. return Math.round(dateObj.getMilliseconds() / 100);
  12667. },
  12668. SS: function (dateObj) {
  12669. return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
  12670. },
  12671. SSS: function (dateObj) {
  12672. return pad(dateObj.getMilliseconds(), 3);
  12673. },
  12674. a: function (dateObj, i18n) {
  12675. return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
  12676. },
  12677. A: function (dateObj, i18n) {
  12678. return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
  12679. },
  12680. ZZ: function (dateObj) {
  12681. var o = dateObj.getTimezoneOffset();
  12682. return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
  12683. }
  12684. };
  12685. var parseFlags = {
  12686. D: [twoDigits, function (d, v) {
  12687. d.day = v;
  12688. }],
  12689. Do: [new RegExp(twoDigits.source + word.source), function (d, v) {
  12690. d.day = parseInt(v, 10);
  12691. }],
  12692. M: [twoDigits, function (d, v) {
  12693. d.month = v - 1;
  12694. }],
  12695. YY: [twoDigits, function (d, v) {
  12696. var da = new Date(),
  12697. cent = +('' + da.getFullYear()).substr(0, 2);
  12698. d.year = '' + (v > 68 ? cent - 1 : cent) + v;
  12699. }],
  12700. h: [twoDigits, function (d, v) {
  12701. d.hour = v;
  12702. }],
  12703. m: [twoDigits, function (d, v) {
  12704. d.minute = v;
  12705. }],
  12706. s: [twoDigits, function (d, v) {
  12707. d.second = v;
  12708. }],
  12709. YYYY: [fourDigits, function (d, v) {
  12710. d.year = v;
  12711. }],
  12712. S: [/\d/, function (d, v) {
  12713. d.millisecond = v * 100;
  12714. }],
  12715. SS: [/\d{2}/, function (d, v) {
  12716. d.millisecond = v * 10;
  12717. }],
  12718. SSS: [threeDigits, function (d, v) {
  12719. d.millisecond = v;
  12720. }],
  12721. d: [twoDigits, noop],
  12722. ddd: [word, noop],
  12723. MMM: [word, monthUpdate('monthNamesShort')],
  12724. MMMM: [word, monthUpdate('monthNames')],
  12725. a: [word, function (d, v, i18n) {
  12726. var val = v.toLowerCase();
  12727. if (val === i18n.amPm[0]) {
  12728. d.isPm = false;
  12729. } else if (val === i18n.amPm[1]) {
  12730. d.isPm = true;
  12731. }
  12732. }],
  12733. ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
  12734. if (v === 'Z') v = '+00:00';
  12735. var parts = (v + '').match(/([\+\-]|\d\d)/gi),
  12736. minutes;
  12737. if (parts) {
  12738. minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
  12739. d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
  12740. }
  12741. }]
  12742. };
  12743. parseFlags.dd = parseFlags.d;
  12744. parseFlags.dddd = parseFlags.ddd;
  12745. parseFlags.DD = parseFlags.D;
  12746. parseFlags.mm = parseFlags.m;
  12747. parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
  12748. parseFlags.MM = parseFlags.M;
  12749. parseFlags.ss = parseFlags.s;
  12750. parseFlags.A = parseFlags.a; // Some common format strings
  12751. fecha.masks = {
  12752. default: 'ddd MMM DD YYYY HH:mm:ss',
  12753. shortDate: 'M/D/YY',
  12754. mediumDate: 'MMM D, YYYY',
  12755. longDate: 'MMMM D, YYYY',
  12756. fullDate: 'dddd, MMMM D, YYYY',
  12757. shortTime: 'HH:mm',
  12758. mediumTime: 'HH:mm:ss',
  12759. longTime: 'HH:mm:ss.SSS'
  12760. };
  12761. /***
  12762. * Format a date
  12763. * @method format
  12764. * @param {Date|number} dateObj
  12765. * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
  12766. */
  12767. fecha.format = function (dateObj, mask, i18nSettings) {
  12768. var i18n = i18nSettings || fecha.i18n;
  12769. if (typeof dateObj === 'number') {
  12770. dateObj = new Date(dateObj);
  12771. }
  12772. if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
  12773. throw new Error('Invalid Date in fecha.format');
  12774. }
  12775. mask = fecha.masks[mask] || mask || fecha.masks['default'];
  12776. var literals = []; // Make literals inactive by replacing them with ??
  12777. mask = mask.replace(literal, function ($0, $1) {
  12778. literals.push($1);
  12779. return '??';
  12780. }); // Apply formatting rules
  12781. mask = mask.replace(token, function ($0) {
  12782. return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
  12783. }); // Inline literal values back into the formatted value
  12784. return mask.replace(/\?\?/g, function () {
  12785. return literals.shift();
  12786. });
  12787. };
  12788. /**
  12789. * Parse a date string into an object, changes - into /
  12790. * @method parse
  12791. * @param {string} dateStr Date string
  12792. * @param {string} format Date parse format
  12793. * @returns {Date|boolean}
  12794. */
  12795. fecha.parse = function (dateStr, format, i18nSettings) {
  12796. var i18n = i18nSettings || fecha.i18n;
  12797. if (typeof format !== 'string') {
  12798. throw new Error('Invalid format in fecha.parse');
  12799. }
  12800. format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings
  12801. // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
  12802. if (dateStr.length > 1000) {
  12803. return false;
  12804. }
  12805. var isValid = true;
  12806. var dateInfo = {};
  12807. format.replace(token, function ($0) {
  12808. if (parseFlags[$0]) {
  12809. var info = parseFlags[$0];
  12810. var index = dateStr.search(info[0]);
  12811. if (!~index) {
  12812. isValid = false;
  12813. } else {
  12814. dateStr.replace(info[0], function (result) {
  12815. info[1](dateInfo, result, i18n);
  12816. dateStr = dateStr.substr(index + result.length);
  12817. return result;
  12818. });
  12819. }
  12820. }
  12821. return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
  12822. });
  12823. if (!isValid) {
  12824. return false;
  12825. }
  12826. var today = new Date();
  12827. if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
  12828. dateInfo.hour = +dateInfo.hour + 12;
  12829. } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
  12830. dateInfo.hour = 0;
  12831. }
  12832. var date;
  12833. if (dateInfo.timezoneOffset != null) {
  12834. dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
  12835. date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
  12836. } else {
  12837. date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
  12838. }
  12839. return date;
  12840. };
  12841. /* istanbul ignore next */
  12842. if (typeof module !== 'undefined' && module.exports) {
  12843. module.exports = fecha;
  12844. } else if (true) {
  12845. !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
  12846. return fecha;
  12847. }.call(exports, __webpack_require__, exports, module),
  12848. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  12849. } else {
  12850. main.fecha = fecha;
  12851. }
  12852. })(this);
  12853. /***/ }),
  12854. /* 222 */
  12855. /***/ (function(module, exports, __webpack_require__) {
  12856. var isType = __webpack_require__(27);
  12857. var isDate = function isDate(value) {
  12858. return isType(value, 'Date');
  12859. };
  12860. module.exports = isDate;
  12861. /***/ }),
  12862. /* 223 */
  12863. /***/ (function(module, exports, __webpack_require__) {
  12864. "use strict";
  12865. var _interopRequireDefault = __webpack_require__(1);
  12866. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  12867. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  12868. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  12869. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  12870. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12871. var Util = __webpack_require__(0);
  12872. var GuideBase = __webpack_require__(23);
  12873. var Arc = /*#__PURE__*/function (_GuideBase) {
  12874. (0, _inheritsLoose2["default"])(Arc, _GuideBase);
  12875. var _super = _createSuper(Arc);
  12876. function Arc() {
  12877. return _GuideBase.apply(this, arguments) || this;
  12878. }
  12879. var _proto = Arc.prototype;
  12880. _proto._initDefaultCfg = function _initDefaultCfg() {
  12881. this.type = 'arc';
  12882. /**
  12883. * start point
  12884. * @type {Array | Function}
  12885. */
  12886. this.start = [];
  12887. /**
  12888. * end point
  12889. * @type {Array | Function}
  12890. */
  12891. this.end = [];
  12892. /**
  12893. * style configuration
  12894. * @type {Object}
  12895. */
  12896. this.style = {
  12897. stroke: '#999',
  12898. lineWidth: 1
  12899. };
  12900. };
  12901. _proto.render = function render(coord, container) {
  12902. var self = this;
  12903. var start = self.parsePoint(coord, self.start);
  12904. var end = self.parsePoint(coord, self.end);
  12905. if (!start || !end) {
  12906. return;
  12907. }
  12908. var coordCenter = coord.center;
  12909. var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
  12910. var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
  12911. var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
  12912. var shape = container.addShape('arc', {
  12913. className: 'guide-arc',
  12914. attrs: Util.mix({
  12915. x: coordCenter.x,
  12916. y: coordCenter.y,
  12917. r: radius,
  12918. startAngle: startAngle,
  12919. endAngle: endAngle
  12920. }, self.style)
  12921. });
  12922. self.element = shape;
  12923. return shape;
  12924. };
  12925. return Arc;
  12926. }(GuideBase);
  12927. GuideBase.Arc = Arc;
  12928. module.exports = Arc;
  12929. /***/ }),
  12930. /* 224 */
  12931. /***/ (function(module, exports, __webpack_require__) {
  12932. "use strict";
  12933. var _interopRequireDefault = __webpack_require__(1);
  12934. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  12935. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  12936. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  12937. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  12938. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12939. var Util = __webpack_require__(0);
  12940. var GuideBase = __webpack_require__(23);
  12941. function getOffsetFromAlign(alignX, alignY, width, height) {
  12942. var result = [];
  12943. if (alignX === 'left' && alignY === 'top') {
  12944. result[0] = 0;
  12945. result[1] = 0;
  12946. } else if (alignX === 'right' && alignY === 'top') {
  12947. result[0] = -width;
  12948. result[1] = 0;
  12949. } else if (alignX === 'left' && alignY === 'bottom') {
  12950. result[0] = 0;
  12951. result[1] = Math.floor(-height);
  12952. } else if (alignX === 'right' && alignY === 'bottom') {
  12953. result[0] = Math.floor(-width);
  12954. result[1] = Math.floor(-height);
  12955. } else if (alignX === 'right' && alignY === 'middle') {
  12956. result[0] = Math.floor(-width);
  12957. result[1] = Math.floor(-height / 2);
  12958. } else if (alignX === 'left' && alignY === 'middle') {
  12959. result[0] = 0;
  12960. result[1] = Math.floor(-height / 2);
  12961. } else if (alignX === 'center' && alignY === 'bottom') {
  12962. result[0] = Math.floor(-width / 2);
  12963. result[1] = Math.floor(-height);
  12964. } else if (alignX === 'center' && alignY === 'top') {
  12965. result[0] = Math.floor(-width / 2);
  12966. result[1] = 0;
  12967. } else {
  12968. result[0] = Math.floor(-width / 2);
  12969. result[1] = Math.floor(-height / 2);
  12970. }
  12971. return result;
  12972. }
  12973. function modifyCSS(DOM, CSS) {
  12974. for (var key in CSS) {
  12975. if (CSS.hasOwnProperty(key)) {
  12976. DOM.style[key] = CSS[key];
  12977. }
  12978. }
  12979. return DOM;
  12980. }
  12981. function createDom(str) {
  12982. var container = document.createElement('div');
  12983. str = str.replace(/(^\s*)|(\s*$)/g, '');
  12984. container.innerHTML = '' + str;
  12985. return container.childNodes[0];
  12986. }
  12987. var Html = /*#__PURE__*/function (_GuideBase) {
  12988. (0, _inheritsLoose2["default"])(Html, _GuideBase);
  12989. var _super = _createSuper(Html);
  12990. function Html() {
  12991. return _GuideBase.apply(this, arguments) || this;
  12992. }
  12993. var _proto = Html.prototype;
  12994. _proto._initDefaultCfg = function _initDefaultCfg() {
  12995. this.type = 'html';
  12996. /**
  12997. * dom position
  12998. * @type {Object | Array}
  12999. */
  13000. this.position = null;
  13001. /**
  13002. * alignment for horizontal direction,can be 'left','center','right'
  13003. * @type {String}
  13004. */
  13005. this.alignX = 'center';
  13006. /**
  13007. * alignment for vertical direction,can be 'top', 'middle', 'bottom'
  13008. * @type {String}
  13009. */
  13010. this.alignY = 'middle';
  13011. /**
  13012. * offset for horizontal direction
  13013. * @type {Number}
  13014. */
  13015. this.offsetX = null;
  13016. /**
  13017. * offset for vertical direction
  13018. * @type {Number}
  13019. */
  13020. this.offsetY = null;
  13021. /**
  13022. * the html string
  13023. *@type {String | Function}
  13024. */
  13025. this.html = null;
  13026. } // override paint
  13027. ;
  13028. _proto.render = function render(coord, container) {
  13029. var self = this;
  13030. var position = self.parsePoint(coord, self.position);
  13031. if (!position) {
  13032. return;
  13033. }
  13034. var myNode = createDom(self.html);
  13035. myNode = modifyCSS(myNode, {
  13036. position: 'absolute',
  13037. top: Math.floor(position.y) + 'px',
  13038. left: Math.floor(position.x) + 'px',
  13039. visibility: 'hidden'
  13040. });
  13041. var canvasDom = container.get('canvas').get('el');
  13042. var parentNode = canvasDom.parentNode;
  13043. parentNode = modifyCSS(parentNode, {
  13044. position: 'relative'
  13045. });
  13046. var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
  13047. parentNode.appendChild(wrapperNode);
  13048. wrapperNode.appendChild(myNode);
  13049. var canvasOffsetTop = canvasDom.offsetTop;
  13050. var canvasOffsetLeft = canvasDom.offsetLeft;
  13051. var alignX = self.alignX,
  13052. alignY = self.alignY,
  13053. offsetX = self.offsetX,
  13054. offsetY = self.offsetY;
  13055. var width = Util.getWidth(myNode);
  13056. var height = Util.getHeight(myNode);
  13057. var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
  13058. position.x = position.x + newOffset[0] + canvasOffsetLeft;
  13059. position.y = position.y + newOffset[1] + canvasOffsetTop;
  13060. if (offsetX) {
  13061. position.x += offsetX;
  13062. }
  13063. if (offsetY) {
  13064. position.y += offsetY;
  13065. }
  13066. modifyCSS(myNode, {
  13067. top: Math.floor(position.y) + 'px',
  13068. left: Math.floor(position.x) + 'px',
  13069. visibility: 'visible'
  13070. });
  13071. self.element = wrapperNode;
  13072. };
  13073. _proto.remove = function remove() {
  13074. var element = this.element;
  13075. element && element.parentNode && element.parentNode.removeChild(element);
  13076. };
  13077. return Html;
  13078. }(GuideBase);
  13079. GuideBase.Html = Html;
  13080. module.exports = Html;
  13081. /***/ }),
  13082. /* 225 */
  13083. /***/ (function(module, exports, __webpack_require__) {
  13084. "use strict";
  13085. var _interopRequireDefault = __webpack_require__(1);
  13086. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  13087. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  13088. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  13089. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  13090. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13091. var Util = __webpack_require__(0);
  13092. var GuideBase = __webpack_require__(23);
  13093. var Line = /*#__PURE__*/function (_GuideBase) {
  13094. (0, _inheritsLoose2["default"])(Line, _GuideBase);
  13095. var _super = _createSuper(Line);
  13096. function Line() {
  13097. return _GuideBase.apply(this, arguments) || this;
  13098. }
  13099. var _proto = Line.prototype;
  13100. _proto._initDefaultCfg = function _initDefaultCfg() {
  13101. this.type = 'line';
  13102. this.start = [];
  13103. this.end = [];
  13104. this.style = {
  13105. stroke: '#000',
  13106. lineWidth: 1
  13107. };
  13108. };
  13109. _proto.render = function render(coord, container) {
  13110. var points = [];
  13111. points[0] = this.parsePoint(coord, this.start);
  13112. points[1] = this.parsePoint(coord, this.end);
  13113. if (!points[0] || !points[1]) {
  13114. return;
  13115. }
  13116. var shape = container.addShape('Line', {
  13117. className: 'guide-line',
  13118. attrs: Util.mix({
  13119. x1: points[0].x,
  13120. y1: points[0].y,
  13121. x2: points[1].x,
  13122. y2: points[1].y
  13123. }, this.style)
  13124. });
  13125. this.element = shape;
  13126. return shape;
  13127. };
  13128. return Line;
  13129. }(GuideBase);
  13130. GuideBase.Line = Line;
  13131. module.exports = Line;
  13132. /***/ }),
  13133. /* 226 */
  13134. /***/ (function(module, exports, __webpack_require__) {
  13135. "use strict";
  13136. var _interopRequireDefault = __webpack_require__(1);
  13137. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  13138. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  13139. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  13140. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  13141. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13142. var Util = __webpack_require__(0);
  13143. var GuideBase = __webpack_require__(23);
  13144. var Rect = /*#__PURE__*/function (_GuideBase) {
  13145. (0, _inheritsLoose2["default"])(Rect, _GuideBase);
  13146. var _super = _createSuper(Rect);
  13147. function Rect() {
  13148. return _GuideBase.apply(this, arguments) || this;
  13149. }
  13150. var _proto = Rect.prototype;
  13151. _proto._initDefaultCfg = function _initDefaultCfg() {
  13152. this.type = 'rect';
  13153. this.start = [];
  13154. this.end = [];
  13155. this.style = {
  13156. fill: '#CCD7EB',
  13157. opacity: 0.4
  13158. };
  13159. };
  13160. _proto.render = function render(coord, container) {
  13161. var start = this.parsePoint(coord, this.start);
  13162. var end = this.parsePoint(coord, this.end);
  13163. if (!start || !end) {
  13164. return;
  13165. }
  13166. var shape = container.addShape('rect', {
  13167. className: 'guide-rect',
  13168. attrs: Util.mix({
  13169. x: Math.min(start.x, end.x),
  13170. y: Math.min(start.y, end.y),
  13171. width: Math.abs(end.x - start.x),
  13172. height: Math.abs(start.y - end.y)
  13173. }, this.style)
  13174. });
  13175. this.element = shape;
  13176. return shape;
  13177. };
  13178. return Rect;
  13179. }(GuideBase);
  13180. GuideBase.Rect = Rect;
  13181. module.exports = Rect;
  13182. /***/ }),
  13183. /* 227 */
  13184. /***/ (function(module, exports, __webpack_require__) {
  13185. "use strict";
  13186. var _interopRequireDefault = __webpack_require__(1);
  13187. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  13188. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  13189. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  13190. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  13191. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13192. var Util = __webpack_require__(0);
  13193. var GuideBase = __webpack_require__(23);
  13194. var Text = /*#__PURE__*/function (_GuideBase) {
  13195. (0, _inheritsLoose2["default"])(Text, _GuideBase);
  13196. var _super = _createSuper(Text);
  13197. function Text() {
  13198. return _GuideBase.apply(this, arguments) || this;
  13199. }
  13200. var _proto = Text.prototype;
  13201. _proto._initDefaultCfg = function _initDefaultCfg() {
  13202. this.type = 'text';
  13203. /**
  13204. * the position of text
  13205. * @type {Function | Array}
  13206. */
  13207. this.position = null;
  13208. /**
  13209. * the display content
  13210. * @type {String}
  13211. */
  13212. this.content = null;
  13213. /**
  13214. * style configuration for text
  13215. * @type {Object}
  13216. */
  13217. this.style = {
  13218. fill: '#000'
  13219. };
  13220. /**
  13221. * offset of horizontal direction
  13222. * @type {Number}
  13223. */
  13224. this.offsetX = 0;
  13225. /**
  13226. * offset of vertical direction
  13227. * @type {Number}
  13228. */
  13229. this.offsetY = 0;
  13230. };
  13231. _proto.render = function render(coord, container) {
  13232. var position = this.position;
  13233. var point = this.parsePoint(coord, position);
  13234. if (!point) {
  13235. return;
  13236. }
  13237. var content = this.content,
  13238. style = this.style,
  13239. offsetX = this.offsetX,
  13240. offsetY = this.offsetY;
  13241. if (offsetX) {
  13242. point.x += offsetX;
  13243. }
  13244. if (offsetY) {
  13245. point.y += offsetY;
  13246. }
  13247. var shape = container.addShape('text', {
  13248. className: 'guide-text',
  13249. attrs: Util.mix({
  13250. x: point.x,
  13251. y: point.y,
  13252. text: content
  13253. }, style)
  13254. });
  13255. this.element = shape;
  13256. return shape;
  13257. };
  13258. return Text;
  13259. }(GuideBase);
  13260. GuideBase.Text = Text;
  13261. module.exports = Text;
  13262. /***/ }),
  13263. /* 228 */
  13264. /***/ (function(module, exports, __webpack_require__) {
  13265. "use strict";
  13266. var _interopRequireDefault = __webpack_require__(1);
  13267. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  13268. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  13269. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  13270. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  13271. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13272. var Util = __webpack_require__(0);
  13273. var GuideBase = __webpack_require__(23);
  13274. var Tag = /*#__PURE__*/function (_GuideBase) {
  13275. (0, _inheritsLoose2["default"])(Tag, _GuideBase);
  13276. var _super = _createSuper(Tag);
  13277. function Tag() {
  13278. return _GuideBase.apply(this, arguments) || this;
  13279. }
  13280. var _proto = Tag.prototype;
  13281. _proto._initDefaultCfg = function _initDefaultCfg() {
  13282. this.type = 'tag';
  13283. this.position = null;
  13284. this.content = null;
  13285. this.direct = 'tl';
  13286. this.autoAdjust = true;
  13287. this.offsetX = 0;
  13288. this.offsetY = 0;
  13289. this.side = 4;
  13290. this.background = {
  13291. padding: 5,
  13292. radius: 2,
  13293. fill: '#1890FF'
  13294. };
  13295. this.textStyle = {
  13296. fontSize: 12,
  13297. fill: '#fff',
  13298. textAlign: 'center',
  13299. textBaseline: 'middle'
  13300. };
  13301. this.withPoint = true;
  13302. this.pointStyle = {
  13303. fill: '#1890FF',
  13304. r: 3,
  13305. lineWidth: 1,
  13306. stroke: '#fff'
  13307. };
  13308. };
  13309. _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
  13310. var direct = this.direct;
  13311. var side = this.side;
  13312. var canvas = container.get('canvas');
  13313. var clientWidth = canvas.get('width');
  13314. var clientHeight = canvas.get('height');
  13315. var x = point.x,
  13316. y = point.y;
  13317. var vertical = direct[0];
  13318. var horizontal = direct[1]; // adjust for vertical direction
  13319. if (vertical === 't' && y - side - tagHeight < 0) {
  13320. vertical = 'b';
  13321. } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
  13322. vertical = 't';
  13323. } // adjust for horizontal direction
  13324. var diff = vertical === 'c' ? side : 0;
  13325. if (horizontal === 'l' && x - diff - tagWidth < 0) {
  13326. horizontal = 'r';
  13327. } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
  13328. horizontal = 'l';
  13329. } else if (horizontal === 'c') {
  13330. if (tagWidth / 2 + x + diff > clientWidth) {
  13331. horizontal = 'l';
  13332. } else if (x - tagWidth / 2 - diff < 0) {
  13333. horizontal = 'r';
  13334. }
  13335. }
  13336. direct = vertical + horizontal;
  13337. return direct;
  13338. };
  13339. _proto.render = function render(coord, container) {
  13340. var position = this.parsePoint(coord, this.position);
  13341. if (!position) {
  13342. return;
  13343. } // 数据不在显示范围内时,x/y 会为NaN
  13344. if (isNaN(position.x) || isNaN(position.y)) {
  13345. return;
  13346. }
  13347. var content = this.content,
  13348. background = this.background,
  13349. textStyle = this.textStyle;
  13350. var shapes = [];
  13351. var wrapperContainer = container.addGroup({
  13352. className: 'guide-tag'
  13353. });
  13354. if (this.withPoint) {
  13355. var pointShape = wrapperContainer.addShape('Circle', {
  13356. className: 'guide-tag-point',
  13357. attrs: Util.mix({
  13358. x: position.x,
  13359. y: position.y
  13360. }, this.pointStyle)
  13361. });
  13362. shapes.push(pointShape);
  13363. }
  13364. var tagContainer = wrapperContainer.addGroup(); // create a text shape
  13365. var tagText = tagContainer.addShape('text', {
  13366. className: 'guide-tag-text',
  13367. zIndex: 1,
  13368. attrs: Util.mix({
  13369. x: 0,
  13370. y: 0,
  13371. text: content
  13372. }, textStyle)
  13373. });
  13374. shapes.push(tagText); // create background box
  13375. var textBBox = tagText.getBBox();
  13376. var padding = Util.parsePadding(background.padding);
  13377. var tagWidth = textBBox.width + padding[1] + padding[3];
  13378. var tagHeight = textBBox.height + padding[0] + padding[2];
  13379. var yMin = textBBox.minY - padding[0];
  13380. var xMin = textBBox.minX - padding[3];
  13381. var tagBg = tagContainer.addShape('rect', {
  13382. className: 'guide-tag-bg',
  13383. zIndex: -1,
  13384. attrs: Util.mix({
  13385. x: xMin,
  13386. y: yMin,
  13387. width: tagWidth,
  13388. height: tagHeight
  13389. }, background)
  13390. });
  13391. shapes.push(tagBg);
  13392. var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
  13393. var side = this.side;
  13394. var x = position.x + this.offsetX;
  13395. var y = position.y + this.offsetY;
  13396. var arrowPoints;
  13397. var radius = Util.parsePadding(background.radius);
  13398. if (direct === 'tl') {
  13399. arrowPoints = [{
  13400. x: tagWidth + xMin - side - 1,
  13401. y: tagHeight + yMin - 1
  13402. }, // 这个 1 是为了防止出现白边
  13403. {
  13404. x: tagWidth + xMin,
  13405. y: tagHeight + yMin - 1
  13406. }, {
  13407. x: tagWidth + xMin,
  13408. y: tagHeight + side + yMin
  13409. }];
  13410. radius[2] = 0;
  13411. x = x - tagWidth;
  13412. y = y - side - tagHeight;
  13413. } else if (direct === 'cl') {
  13414. arrowPoints = [{
  13415. x: tagWidth + xMin - 1,
  13416. y: (tagHeight - side) / 2 + yMin - 1
  13417. }, {
  13418. x: tagWidth + xMin - 1,
  13419. y: (tagHeight + side) / 2 + yMin + 1
  13420. }, {
  13421. x: tagWidth + side + xMin,
  13422. y: tagHeight / 2 + yMin
  13423. }];
  13424. x = x - tagWidth - side;
  13425. y = y - tagHeight / 2;
  13426. } else if (direct === 'bl') {
  13427. arrowPoints = [{
  13428. x: tagWidth + xMin,
  13429. y: -side + yMin
  13430. }, {
  13431. x: tagWidth + xMin - side - 1,
  13432. y: yMin + 1
  13433. }, {
  13434. x: tagWidth + xMin,
  13435. y: yMin + 1
  13436. }];
  13437. radius[1] = 0;
  13438. x = x - tagWidth;
  13439. y = y + side;
  13440. } else if (direct === 'bc') {
  13441. arrowPoints = [{
  13442. x: tagWidth / 2 + xMin,
  13443. y: -side + yMin
  13444. }, {
  13445. x: (tagWidth - side) / 2 + xMin - 1,
  13446. y: yMin + 1
  13447. }, {
  13448. x: (tagWidth + side) / 2 + xMin + 1,
  13449. y: yMin + 1
  13450. }];
  13451. x = x - tagWidth / 2;
  13452. y = y + side;
  13453. } else if (direct === 'br') {
  13454. arrowPoints = [{
  13455. x: xMin,
  13456. y: yMin - side
  13457. }, {
  13458. x: xMin,
  13459. y: yMin + 1
  13460. }, {
  13461. x: xMin + side + 1,
  13462. y: yMin + 1
  13463. }];
  13464. radius[0] = 0;
  13465. y = y + side;
  13466. } else if (direct === 'cr') {
  13467. arrowPoints = [{
  13468. x: xMin - side,
  13469. y: tagHeight / 2 + yMin
  13470. }, {
  13471. x: xMin + 1,
  13472. y: (tagHeight - side) / 2 + yMin - 1
  13473. }, {
  13474. x: xMin + 1,
  13475. y: (tagHeight + side) / 2 + yMin + 1
  13476. }];
  13477. x = x + side;
  13478. y = y - tagHeight / 2;
  13479. } else if (direct === 'tr') {
  13480. arrowPoints = [{
  13481. x: xMin,
  13482. y: tagHeight + side + yMin
  13483. }, {
  13484. x: xMin,
  13485. y: tagHeight + yMin - 1
  13486. }, {
  13487. x: side + xMin + 1,
  13488. y: tagHeight + yMin - 1
  13489. }];
  13490. radius[3] = 0;
  13491. y = y - tagHeight - side;
  13492. } else if (direct === 'tc') {
  13493. arrowPoints = [{
  13494. x: (tagWidth - side) / 2 + xMin - 1,
  13495. y: tagHeight + yMin - 1
  13496. }, {
  13497. x: (tagWidth + side) / 2 + xMin + 1,
  13498. y: tagHeight + yMin - 1
  13499. }, {
  13500. x: tagWidth / 2 + xMin,
  13501. y: tagHeight + side + yMin
  13502. }];
  13503. x = x - tagWidth / 2;
  13504. y = y - tagHeight - side;
  13505. }
  13506. var sideShape = tagContainer.addShape('Polygon', {
  13507. className: 'guide-tag-side',
  13508. zIndex: 0,
  13509. attrs: {
  13510. points: arrowPoints,
  13511. fill: background.fill
  13512. }
  13513. });
  13514. shapes.push(sideShape);
  13515. tagBg.attr('radius', radius);
  13516. tagContainer.moveTo(x - xMin, y - yMin);
  13517. tagContainer.sort();
  13518. this.element = wrapperContainer;
  13519. return shapes;
  13520. };
  13521. return Tag;
  13522. }(GuideBase);
  13523. GuideBase.Tag = Tag;
  13524. module.exports = Tag;
  13525. /***/ }),
  13526. /* 229 */
  13527. /***/ (function(module, exports, __webpack_require__) {
  13528. "use strict";
  13529. var _interopRequireDefault = __webpack_require__(1);
  13530. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  13531. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  13532. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  13533. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  13534. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13535. var Util = __webpack_require__(0);
  13536. var GuideBase = __webpack_require__(23);
  13537. var Point = /*#__PURE__*/function (_GuideBase) {
  13538. (0, _inheritsLoose2["default"])(Point, _GuideBase);
  13539. var _super = _createSuper(Point);
  13540. function Point() {
  13541. return _GuideBase.apply(this, arguments) || this;
  13542. }
  13543. var _proto = Point.prototype;
  13544. _proto._initDefaultCfg = function _initDefaultCfg() {
  13545. this.type = 'point';
  13546. this.position = null;
  13547. this.offsetX = 0;
  13548. this.offsetY = 0;
  13549. this.style = {
  13550. fill: '#1890FF',
  13551. r: 3,
  13552. lineWidth: 1,
  13553. stroke: '#fff'
  13554. };
  13555. };
  13556. _proto.render = function render(coord, container) {
  13557. var position = this.parsePoint(coord, this.position);
  13558. if (!position) return null;
  13559. var shape = container.addShape('Circle', {
  13560. className: 'guide-point',
  13561. attrs: Util.mix({
  13562. x: position.x + this.offsetX,
  13563. y: position.y + this.offsetY
  13564. }, this.style)
  13565. });
  13566. this.element = shape;
  13567. return shape;
  13568. };
  13569. return Point;
  13570. }(GuideBase);
  13571. GuideBase.Point = Point;
  13572. module.exports = Point;
  13573. /***/ }),
  13574. /* 230 */
  13575. /***/ (function(module, exports, __webpack_require__) {
  13576. "use strict";
  13577. var Util = __webpack_require__(0);
  13578. var Global = __webpack_require__(6);
  13579. var Tooltip = __webpack_require__(231);
  13580. var Helper = __webpack_require__(37); // Register the default configuration for Tooltip
  13581. Global.tooltip = Util.deepMix({
  13582. triggerOn: 'press',
  13583. triggerOff: 'pressend',
  13584. alwaysShow: false,
  13585. showTitle: false,
  13586. showCrosshairs: false,
  13587. crosshairsStyle: {
  13588. stroke: 'rgba(0, 0, 0, 0.25)',
  13589. lineWidth: 1
  13590. },
  13591. showTooltipMarker: true,
  13592. background: {
  13593. radius: 1,
  13594. fill: 'rgba(0, 0, 0, 0.65)',
  13595. padding: [3, 5]
  13596. },
  13597. titleStyle: {
  13598. fontSize: 12,
  13599. fill: '#fff',
  13600. textAlign: 'start',
  13601. textBaseline: 'top'
  13602. },
  13603. nameStyle: {
  13604. fontSize: 12,
  13605. fill: 'rgba(255, 255, 255, 0.65)',
  13606. textAlign: 'start',
  13607. textBaseline: 'middle'
  13608. },
  13609. valueStyle: {
  13610. fontSize: 12,
  13611. fill: '#fff',
  13612. textAlign: 'start',
  13613. textBaseline: 'middle'
  13614. },
  13615. showItemMarker: true,
  13616. itemMarkerStyle: {
  13617. radius: 3,
  13618. symbol: 'circle',
  13619. lineWidth: 1,
  13620. stroke: '#fff'
  13621. },
  13622. layout: 'horizontal',
  13623. snap: false
  13624. }, Global.tooltip || {});
  13625. function _getTooltipValueScale(geom) {
  13626. var colorAttr = geom.getAttr('color');
  13627. if (colorAttr) {
  13628. var colorScale = colorAttr.getScale(colorAttr.type);
  13629. if (colorScale.isLinear) {
  13630. return colorScale;
  13631. }
  13632. }
  13633. var xScale = geom.getXScale();
  13634. var yScale = geom.getYScale();
  13635. if (yScale) {
  13636. return yScale;
  13637. }
  13638. return xScale;
  13639. }
  13640. function getTooltipName(geom, origin) {
  13641. var name;
  13642. var nameScale;
  13643. var groupScales = geom._getGroupScales();
  13644. if (groupScales.length) {
  13645. Util.each(groupScales, function (scale) {
  13646. nameScale = scale;
  13647. return false;
  13648. });
  13649. }
  13650. if (nameScale) {
  13651. var field = nameScale.field;
  13652. name = nameScale.getText(origin[field]);
  13653. } else {
  13654. var valueScale = _getTooltipValueScale(geom);
  13655. name = valueScale.alias || valueScale.field;
  13656. }
  13657. return name;
  13658. }
  13659. function getTooltipValue(geom, origin) {
  13660. var scale = _getTooltipValueScale(geom);
  13661. return scale.getText(origin[scale.field]);
  13662. }
  13663. function getTooltipTitle(geom, origin) {
  13664. var position = geom.getAttr('position');
  13665. var field = position.getFields()[0];
  13666. var scale = geom.get('scales')[field];
  13667. return scale.getText(origin[scale.field]);
  13668. }
  13669. function _indexOfArray(items, item) {
  13670. var rst = -1;
  13671. Util.each(items, function (sub, index) {
  13672. if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
  13673. rst = index;
  13674. return false;
  13675. }
  13676. });
  13677. return rst;
  13678. }
  13679. function _uniqItems(items) {
  13680. var tmp = [];
  13681. Util.each(items, function (item) {
  13682. var index = _indexOfArray(tmp, item);
  13683. if (index === -1) {
  13684. tmp.push(item);
  13685. } else {
  13686. tmp[index] = item;
  13687. }
  13688. });
  13689. return tmp;
  13690. }
  13691. function isEqual(arr1, arr2) {
  13692. return JSON.stringify(arr1) === JSON.stringify(arr2);
  13693. }
  13694. var TooltipController = /*#__PURE__*/function () {
  13695. function TooltipController(cfg) {
  13696. var _this = this;
  13697. this.handleShowEvent = function (ev) {
  13698. var chart = _this.chart;
  13699. if (!_this.enable) return;
  13700. var plot = chart.get('plotRange');
  13701. var point = Util.createEvent(ev, chart);
  13702. if (!Helper.isPointInPlot(point, plot) && !_this._tooltipCfg.alwaysShow) {
  13703. // not in chart plot
  13704. _this.hideTooltip();
  13705. return;
  13706. }
  13707. var lastTimeStamp = _this.timeStamp;
  13708. var timeStamp = +new Date();
  13709. if (timeStamp - lastTimeStamp > 16) {
  13710. _this.showTooltip(point);
  13711. _this.timeStamp = timeStamp;
  13712. }
  13713. };
  13714. this.handleHideEvent = function () {
  13715. if (!_this.enable) return;
  13716. _this.hideTooltip();
  13717. };
  13718. this.enable = true;
  13719. this.cfg = {};
  13720. this.tooltip = null;
  13721. this.chart = null;
  13722. this.timeStamp = 0;
  13723. Util.mix(this, cfg);
  13724. var _chart = this.chart;
  13725. var canvas = _chart.get('canvas');
  13726. this.canvas = canvas;
  13727. this.canvasDom = canvas.get('el');
  13728. }
  13729. var _proto = TooltipController.prototype;
  13730. _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
  13731. var self = this;
  13732. var chart = self.chart;
  13733. var defaultCfg = Util.mix({}, Global.tooltip);
  13734. var geoms = chart.get('geoms');
  13735. var shapes = [];
  13736. Util.each(geoms, function (geom) {
  13737. var type = geom.get('type');
  13738. if (shapes.indexOf(type) === -1) {
  13739. shapes.push(type);
  13740. }
  13741. });
  13742. var coordType = chart.get('coord').type;
  13743. if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
  13744. if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
  13745. Util.mix(defaultCfg, {
  13746. showCrosshairs: true
  13747. });
  13748. }
  13749. }
  13750. return defaultCfg;
  13751. };
  13752. _proto._getMaxLength = function _getMaxLength(cfg) {
  13753. if (cfg === void 0) {
  13754. cfg = {};
  13755. }
  13756. var _cfg = cfg,
  13757. layout = _cfg.layout,
  13758. plotRange = _cfg.plotRange;
  13759. return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
  13760. };
  13761. _proto.render = function render() {
  13762. var self = this;
  13763. if (self.tooltip) {
  13764. return;
  13765. }
  13766. var chart = self.chart;
  13767. var canvas = chart.get('canvas');
  13768. var frontPlot = chart.get('frontPlot').addGroup({
  13769. className: 'tooltipContainer',
  13770. zIndex: 10
  13771. });
  13772. var backPlot = chart.get('backPlot').addGroup({
  13773. className: 'tooltipContainer'
  13774. });
  13775. var plotRange = chart.get('plotRange');
  13776. var coord = chart.get('coord');
  13777. var defaultCfg = self._setCrosshairsCfg();
  13778. var cfg = self.cfg; // 通过 chart.tooltip() 接口传入的 tooltip 配置项
  13779. var tooltipCfg = Util.deepMix({
  13780. plotRange: plotRange,
  13781. frontPlot: frontPlot,
  13782. backPlot: backPlot,
  13783. canvas: canvas,
  13784. fixed: coord.transposed || coord.isPolar
  13785. }, defaultCfg, cfg); // 创建 tooltip 实例需要的配置,不应该修改 this.cfg,即用户传入的配置
  13786. tooltipCfg.maxLength = self._getMaxLength(tooltipCfg);
  13787. this._tooltipCfg = tooltipCfg;
  13788. var tooltip = new Tooltip(tooltipCfg);
  13789. self.tooltip = tooltip;
  13790. self.bindEvents();
  13791. };
  13792. _proto.clear = function clear() {
  13793. var tooltip = this.tooltip;
  13794. if (tooltip) {
  13795. tooltip.destroy();
  13796. this.unBindEvents();
  13797. }
  13798. this.tooltip = null;
  13799. this.prePoint = null;
  13800. this._lastActive = null;
  13801. };
  13802. _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
  13803. if (cfg === void 0) {
  13804. cfg = {};
  13805. }
  13806. var _cfg2 = cfg,
  13807. type = _cfg2.type,
  13808. items = _cfg2.items;
  13809. var tooltipCfg = this._tooltipCfg;
  13810. if (type === 'rect') {
  13811. var x;
  13812. var y;
  13813. var width;
  13814. var height;
  13815. var chart = this.chart;
  13816. var _chart$get = chart.get('plotRange'),
  13817. tl = _chart$get.tl,
  13818. br = _chart$get.br;
  13819. var coord = chart.get('coord');
  13820. var firstItem = items[0];
  13821. var lastItem = items[items.length - 1];
  13822. var intervalWidth = firstItem.width;
  13823. if (coord.transposed) {
  13824. x = tl.x;
  13825. y = lastItem.y - intervalWidth * 0.75;
  13826. width = br.x - tl.x;
  13827. height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
  13828. } else {
  13829. x = firstItem.x - intervalWidth * 0.75;
  13830. y = tl.y;
  13831. width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
  13832. height = br.y - tl.y;
  13833. }
  13834. cfg.style = Util.mix({
  13835. x: x,
  13836. y: y,
  13837. width: width,
  13838. height: height,
  13839. fill: '#CCD6EC',
  13840. opacity: 0.3
  13841. }, tooltipCfg.tooltipMarkerStyle);
  13842. } else {
  13843. cfg.style = Util.mix({
  13844. radius: 4,
  13845. fill: '#fff',
  13846. lineWidth: 2
  13847. }, tooltipCfg.tooltipMarkerStyle);
  13848. }
  13849. return cfg;
  13850. };
  13851. _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
  13852. if (tooltipMarkerCfg === void 0) {
  13853. tooltipMarkerCfg = {};
  13854. }
  13855. var lastActive = this._lastActive;
  13856. var tooltip = this.tooltip;
  13857. var cfg = this._tooltipCfg;
  13858. items = _uniqItems(items);
  13859. var chart = this.chart;
  13860. var coord = chart.get('coord');
  13861. var yScale = chart.getYScales()[0];
  13862. var snap = cfg.snap;
  13863. if (snap === false && yScale.isLinear) {
  13864. var invertPoint = coord.invertPoint(point);
  13865. var plot = chart.get('plotRange');
  13866. var tip;
  13867. var pos;
  13868. if (Helper.isPointInPlot(point, plot)) {
  13869. if (coord.transposed) {
  13870. tip = yScale.invert(invertPoint.x);
  13871. pos = point.x;
  13872. tooltip.setXTipContent(tip);
  13873. tooltip.setXTipPosition(pos);
  13874. tooltip.setYCrosshairPosition(pos);
  13875. } else {
  13876. tip = yScale.invert(invertPoint.y);
  13877. pos = point.y;
  13878. tooltip.setYTipContent(tip);
  13879. tooltip.setYTipPosition(pos);
  13880. tooltip.setXCrosshairPosition(pos);
  13881. }
  13882. }
  13883. }
  13884. if (cfg.onShow) {
  13885. cfg.onShow({
  13886. x: point.x,
  13887. y: point.y,
  13888. tooltip: tooltip,
  13889. items: items,
  13890. tooltipMarkerCfg: tooltipMarkerCfg
  13891. });
  13892. }
  13893. if (isEqual(lastActive, items)) {
  13894. if (snap === false && (Util.directionEnabled(cfg.crosshairsType, 'y') || cfg.showYTip)) {
  13895. var canvas = this.chart.get('canvas');
  13896. canvas.draw();
  13897. }
  13898. return;
  13899. }
  13900. this._lastActive = items;
  13901. var onChange = cfg.onChange;
  13902. if (onChange) {
  13903. onChange({
  13904. x: point.x,
  13905. y: point.y,
  13906. tooltip: tooltip,
  13907. items: items,
  13908. tooltipMarkerCfg: tooltipMarkerCfg
  13909. });
  13910. }
  13911. var first = items[0];
  13912. var title = first.title || first.name;
  13913. var xTipPosX = first.x;
  13914. if (items.length > 1) {
  13915. xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
  13916. }
  13917. tooltip.setContent(title, items, coord.transposed);
  13918. tooltip.setPosition(items, point);
  13919. if (coord.transposed) {
  13920. var yTipPosY = first.y;
  13921. if (items.length > 1) {
  13922. yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
  13923. }
  13924. tooltip.setYTipContent(title);
  13925. tooltip.setYTipPosition(yTipPosY);
  13926. tooltip.setXCrosshairPosition(yTipPosY);
  13927. if (snap) {
  13928. tooltip.setXTipContent(first.value);
  13929. tooltip.setXTipPosition(xTipPosX);
  13930. tooltip.setYCrosshairPosition(xTipPosX);
  13931. }
  13932. } else {
  13933. tooltip.setXTipContent(title);
  13934. tooltip.setXTipPosition(xTipPosX);
  13935. tooltip.setYCrosshairPosition(xTipPosX);
  13936. if (snap) {
  13937. tooltip.setYTipContent(first.value);
  13938. tooltip.setYTipPosition(first.y);
  13939. tooltip.setXCrosshairPosition(first.y);
  13940. }
  13941. }
  13942. var markerItems = tooltipMarkerCfg.items;
  13943. if (cfg.showTooltipMarker && markerItems.length) {
  13944. tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
  13945. tooltip.setMarkers(tooltipMarkerCfg);
  13946. } else {
  13947. tooltip.clearMarkers();
  13948. }
  13949. tooltip.show();
  13950. };
  13951. _proto.showTooltip = function showTooltip(point) {
  13952. var self = this;
  13953. var chart = self.chart;
  13954. var tooltipMarkerType;
  13955. var tooltipMarkerItems = [];
  13956. var items = [];
  13957. var cfg = self._tooltipCfg;
  13958. var marker;
  13959. if (cfg.showItemMarker) {
  13960. marker = cfg.itemMarkerStyle;
  13961. }
  13962. var geoms = chart.get('geoms');
  13963. var coord = chart.get('coord');
  13964. Util.each(geoms, function (geom) {
  13965. if (geom.get('visible')) {
  13966. var type = geom.get('type');
  13967. var records = geom.getSnapRecords(point);
  13968. var adjust = geom.get('adjust'); // 漏斗图和金子塔图tooltip位置有问题,暂时不开放显示
  13969. if (type === 'interval' && adjust && adjust.type === 'symmetric') {
  13970. return;
  13971. }
  13972. Util.each(records, function (record) {
  13973. if (record.x && record.y) {
  13974. var x = record.x,
  13975. y = record.y,
  13976. _origin = record._origin,
  13977. color = record.color;
  13978. var tooltipItem = {
  13979. x: x,
  13980. y: Util.isArray(y) ? y[1] : y,
  13981. color: color || Global.defaultColor,
  13982. origin: _origin,
  13983. name: getTooltipName(geom, _origin),
  13984. value: getTooltipValue(geom, _origin),
  13985. title: getTooltipTitle(geom, _origin)
  13986. };
  13987. if (marker) {
  13988. tooltipItem.marker = Util.mix({
  13989. fill: color || Global.defaultColor
  13990. }, marker);
  13991. }
  13992. items.push(tooltipItem);
  13993. if (['line', 'area', 'path'].indexOf(type) !== -1) {
  13994. tooltipMarkerType = 'circle';
  13995. tooltipMarkerItems.push(tooltipItem);
  13996. } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
  13997. tooltipMarkerType = 'rect';
  13998. tooltipItem.width = geom.getSize(record._origin);
  13999. tooltipMarkerItems.push(tooltipItem);
  14000. }
  14001. }
  14002. });
  14003. }
  14004. });
  14005. if (items.length) {
  14006. var tooltipMarkerCfg = {
  14007. items: tooltipMarkerItems,
  14008. type: tooltipMarkerType
  14009. };
  14010. self._setTooltip(point, items, tooltipMarkerCfg);
  14011. } else {
  14012. self.hideTooltip();
  14013. }
  14014. };
  14015. _proto.hideTooltip = function hideTooltip() {
  14016. var cfg = this._tooltipCfg;
  14017. this._lastActive = null;
  14018. var tooltip = this.tooltip;
  14019. if (tooltip) {
  14020. tooltip.hide();
  14021. if (cfg.onHide) {
  14022. cfg.onHide({
  14023. tooltip: tooltip
  14024. });
  14025. }
  14026. var canvas = this.chart.get('canvas');
  14027. canvas.draw();
  14028. }
  14029. };
  14030. _proto._handleEvent = function _handleEvent(methodName, method, action) {
  14031. var canvas = this.canvas;
  14032. Util.each([].concat(methodName), function (aMethod) {
  14033. if (action === 'bind') {
  14034. canvas.on(aMethod, method);
  14035. } else {
  14036. canvas.off(aMethod, method);
  14037. }
  14038. });
  14039. };
  14040. _proto.bindEvents = function bindEvents() {
  14041. var cfg = this._tooltipCfg;
  14042. var triggerOn = cfg.triggerOn,
  14043. triggerOff = cfg.triggerOff,
  14044. alwaysShow = cfg.alwaysShow;
  14045. triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'bind'); // 如果 !alwaysShow, 则在手势离开后就隐藏
  14046. if (!alwaysShow) {
  14047. this._handleEvent(triggerOff, this.handleHideEvent, 'bind');
  14048. }
  14049. };
  14050. _proto.unBindEvents = function unBindEvents() {
  14051. var cfg = this._tooltipCfg;
  14052. var triggerOn = cfg.triggerOn,
  14053. triggerOff = cfg.triggerOff,
  14054. alwaysShow = cfg.alwaysShow;
  14055. triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'unBind');
  14056. if (!alwaysShow) {
  14057. this._handleEvent(triggerOff, this.handleHideEvent, 'unBind');
  14058. }
  14059. };
  14060. return TooltipController;
  14061. }();
  14062. module.exports = {
  14063. init: function init(chart) {
  14064. var tooltipController = new TooltipController({
  14065. chart: chart
  14066. });
  14067. chart.set('tooltipController', tooltipController);
  14068. chart.tooltip = function (enable, cfg) {
  14069. if (Util.isObject(enable)) {
  14070. cfg = enable;
  14071. enable = true;
  14072. }
  14073. tooltipController.enable = enable;
  14074. if (cfg) {
  14075. tooltipController.cfg = cfg;
  14076. }
  14077. return this;
  14078. };
  14079. },
  14080. afterGeomDraw: function afterGeomDraw(chart) {
  14081. var tooltipController = chart.get('tooltipController');
  14082. tooltipController.render();
  14083. chart.showTooltip = function (point) {
  14084. tooltipController.showTooltip(point);
  14085. return this;
  14086. };
  14087. chart.hideTooltip = function () {
  14088. tooltipController.hideTooltip();
  14089. return this;
  14090. };
  14091. },
  14092. clearInner: function clearInner(chart) {
  14093. var tooltipController = chart.get('tooltipController');
  14094. tooltipController.clear();
  14095. }
  14096. };
  14097. /***/ }),
  14098. /* 231 */
  14099. /***/ (function(module, exports, __webpack_require__) {
  14100. "use strict";
  14101. var Util = __webpack_require__(0);
  14102. var Marker = __webpack_require__(76);
  14103. var Container = __webpack_require__(205);
  14104. var TextBox = __webpack_require__(232);
  14105. var GAP = 4;
  14106. /**
  14107. * TODOList:
  14108. * 1. 移除 fixed 参数
  14109. */
  14110. var Tooltip = /*#__PURE__*/function () {
  14111. var _proto = Tooltip.prototype;
  14112. _proto.getDefaultCfg = function getDefaultCfg() {
  14113. return {
  14114. /**
  14115. * wether show the crosshairs
  14116. * @type {Object}
  14117. */
  14118. showCrosshairs: false,
  14119. /**
  14120. * the style for crosshairs
  14121. * @type {Object}
  14122. */
  14123. crosshairsStyle: {
  14124. stroke: 'rgba(0, 0, 0, 0.25)',
  14125. lineWidth: 1
  14126. },
  14127. /**
  14128. * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
  14129. */
  14130. crosshairsType: 'y',
  14131. /**
  14132. * show or hide the x axis tip
  14133. */
  14134. showXTip: false,
  14135. /**
  14136. * show or hide the y axis tip
  14137. */
  14138. showYTip: false,
  14139. xTip: null,
  14140. xTipBackground: {
  14141. radius: 1,
  14142. fill: 'rgba(0, 0, 0, 0.65)',
  14143. padding: [3, 5]
  14144. },
  14145. yTip: null,
  14146. yTipBackground: {
  14147. radius: 1,
  14148. fill: 'rgba(0, 0, 0, 0.65)',
  14149. padding: [3, 5]
  14150. },
  14151. /**
  14152. * the style for tooltip container's background
  14153. * @type {Object}
  14154. */
  14155. background: null,
  14156. /**
  14157. * layout, can be horizontal or vertical
  14158. * @type {String}
  14159. */
  14160. layout: 'horizontal',
  14161. offsetX: 0,
  14162. offsetY: 0
  14163. };
  14164. };
  14165. function Tooltip(cfg) {
  14166. Util.deepMix(this, this.getDefaultCfg(), cfg);
  14167. var frontPlot = this.frontPlot,
  14168. custom = this.custom;
  14169. if (!custom) {
  14170. // custom means user do customize
  14171. var container = new Container(Util.mix({
  14172. parent: frontPlot,
  14173. zIndex: 3
  14174. }, cfg));
  14175. this.container = container;
  14176. var fixed = this.fixed,
  14177. background = this.background;
  14178. if (!fixed) {
  14179. this.tooltipArrow = frontPlot.addShape('Polygon', {
  14180. className: 'tooltip-arrow',
  14181. visible: false,
  14182. zIndex: 2,
  14183. attrs: Util.mix({
  14184. points: []
  14185. }, background)
  14186. });
  14187. }
  14188. }
  14189. if (this.showXTip) {
  14190. var xTipBackground = this.xTipBackground;
  14191. var xTipBox = new TextBox({
  14192. className: 'xTip',
  14193. background: xTipBackground,
  14194. visible: false
  14195. });
  14196. frontPlot.add(xTipBox.container);
  14197. this.xTipBox = xTipBox;
  14198. }
  14199. if (this.showYTip) {
  14200. var yTipBackground = this.yTipBackground;
  14201. var yTipBox = new TextBox({
  14202. className: 'yTip',
  14203. background: yTipBackground,
  14204. visible: false
  14205. });
  14206. frontPlot.add(yTipBox.container);
  14207. this.yTipBox = yTipBox;
  14208. }
  14209. if (this.showCrosshairs) {
  14210. this._renderCrosshairs();
  14211. }
  14212. frontPlot.sort();
  14213. }
  14214. _proto.setContent = function setContent(title, items) {
  14215. this.title = title;
  14216. this.items = items;
  14217. if (!this.custom) {
  14218. var container = this.container;
  14219. container.setTitle(title);
  14220. container.setItems(items);
  14221. }
  14222. };
  14223. _proto.setYTipContent = function setYTipContent(val) {
  14224. var yTip = this.yTip;
  14225. if (Util.isFunction(yTip)) {
  14226. val = yTip(val);
  14227. } else {
  14228. val = Util.mix({
  14229. text: val
  14230. }, yTip);
  14231. }
  14232. this.yTipBox && this.yTipBox.updateContent(val);
  14233. };
  14234. _proto.setYTipPosition = function setYTipPosition(pos) {
  14235. var plotRange = this.plotRange;
  14236. var crosshairsShapeX = this.crosshairsShapeX;
  14237. if (this.showYTip) {
  14238. var yTipBox = this.yTipBox;
  14239. var yTipHeight = yTipBox.getHeight();
  14240. var yTipWidth = yTipBox.getWidth();
  14241. var posX = plotRange.tl.x - yTipWidth;
  14242. var posY = pos - yTipHeight / 2;
  14243. if (posY <= plotRange.tl.y) {
  14244. posY = plotRange.tl.y;
  14245. }
  14246. if (posY + yTipHeight >= plotRange.br.y) {
  14247. posY = plotRange.br.y - yTipHeight;
  14248. }
  14249. if (posX < 0) {
  14250. posX = plotRange.tl.x;
  14251. crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
  14252. }
  14253. yTipBox.updatePosition(posX, posY);
  14254. }
  14255. };
  14256. _proto.setXTipContent = function setXTipContent(val) {
  14257. var xTip = this.xTip;
  14258. if (Util.isFunction(xTip)) {
  14259. val = xTip(val);
  14260. } else {
  14261. val = Util.mix({
  14262. text: val
  14263. }, xTip);
  14264. }
  14265. this.xTipBox && this.xTipBox.updateContent(val);
  14266. };
  14267. _proto.setXTipPosition = function setXTipPosition(pos) {
  14268. var showXTip = this.showXTip,
  14269. canvas = this.canvas,
  14270. plotRange = this.plotRange,
  14271. xTipBox = this.xTipBox,
  14272. crosshairsShapeY = this.crosshairsShapeY;
  14273. if (showXTip) {
  14274. // const el = canvas.get('el');
  14275. // const canvasHeight = Util.getHeight(el);
  14276. var canvasHeight = canvas.get('height');
  14277. var xTipWidth = xTipBox.getWidth();
  14278. var xTipHeight = xTipBox.getHeight();
  14279. var posX = pos - xTipWidth / 2;
  14280. var posY = plotRange.br.y;
  14281. if (posX <= plotRange.tl.x) {
  14282. posX = plotRange.tl.x;
  14283. }
  14284. if (posX + xTipWidth >= plotRange.tr.x) {
  14285. posX = plotRange.tr.x - xTipWidth;
  14286. }
  14287. if (canvasHeight - posY < xTipHeight) {
  14288. posY -= xTipHeight;
  14289. }
  14290. xTipBox.updatePosition(posX, posY);
  14291. crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
  14292. }
  14293. };
  14294. _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
  14295. this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
  14296. };
  14297. _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
  14298. this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
  14299. };
  14300. _proto.setPosition = function setPosition(items) {
  14301. var container = this.container,
  14302. plotRange = this.plotRange,
  14303. offsetX = this.offsetX,
  14304. offsetY = this.offsetY,
  14305. fixed = this.fixed,
  14306. tooltipArrow = this.tooltipArrow;
  14307. if (!container) {
  14308. return;
  14309. }
  14310. var containerBBox = container.container.getBBox();
  14311. var minX = containerBBox.minX,
  14312. minY = containerBBox.minY,
  14313. width = containerBBox.width,
  14314. height = containerBBox.height;
  14315. var tl = plotRange.tl,
  14316. tr = plotRange.tr;
  14317. var posX = 0;
  14318. var posY = tl.y - height - GAP + offsetY;
  14319. if (fixed) {
  14320. var x = (tl.x + tr.x) / 2;
  14321. posX = x - width / 2 + offsetX;
  14322. } else {
  14323. var _x;
  14324. if (items.length > 1) {
  14325. _x = (items[0].x + items[items.length - 1].x) / 2;
  14326. } else {
  14327. _x = items[0].x;
  14328. }
  14329. posX = _x - width / 2 + offsetX;
  14330. if (posX < tl.x) {
  14331. posX = tl.x;
  14332. }
  14333. if (posX + width > tr.x) {
  14334. posX = tr.x - width;
  14335. }
  14336. if (tooltipArrow) {
  14337. tooltipArrow.attr('points', [{
  14338. x: _x - 3,
  14339. y: tl.y - GAP + offsetY
  14340. }, {
  14341. x: _x + 3,
  14342. y: tl.y - GAP + offsetY
  14343. }, {
  14344. x: _x,
  14345. y: tl.y + offsetY
  14346. }]);
  14347. var backShape = container.backShape;
  14348. var radius = Util.parsePadding(backShape.attr('radius'));
  14349. if (_x === tl.x) {
  14350. radius[3] = 0;
  14351. tooltipArrow.attr('points', [{
  14352. x: tl.x,
  14353. y: tl.y + offsetY
  14354. }, {
  14355. x: tl.x,
  14356. y: tl.y - GAP + offsetY
  14357. }, {
  14358. x: tl.x + GAP,
  14359. y: tl.y - GAP + offsetY
  14360. }]);
  14361. } else if (_x === tr.x) {
  14362. radius[2] = 0;
  14363. tooltipArrow.attr('points', [{
  14364. x: tr.x,
  14365. y: tl.y + offsetY
  14366. }, {
  14367. x: tr.x - GAP,
  14368. y: tl.y - GAP + offsetY
  14369. }, {
  14370. x: tr.x,
  14371. y: tl.y - GAP + offsetY
  14372. }]);
  14373. }
  14374. backShape.attr('radius', radius);
  14375. }
  14376. }
  14377. container.moveTo(posX - minX, posY - minY);
  14378. };
  14379. _proto.setMarkers = function setMarkers(cfg) {
  14380. if (cfg === void 0) {
  14381. cfg = {};
  14382. }
  14383. var self = this;
  14384. var _cfg = cfg,
  14385. items = _cfg.items,
  14386. style = _cfg.style,
  14387. type = _cfg.type;
  14388. var markerGroup = self._getMarkerGroup(type);
  14389. if (type === 'circle') {
  14390. for (var i = 0, length = items.length; i < length; i++) {
  14391. var item = items[i];
  14392. var marker = new Marker({
  14393. className: 'tooltip-circle-marker',
  14394. attrs: Util.mix({
  14395. x: item.x,
  14396. y: item.y,
  14397. stroke: item.color
  14398. }, style)
  14399. });
  14400. markerGroup.add(marker);
  14401. }
  14402. } else {
  14403. markerGroup.addShape('rect', {
  14404. className: 'tooltip-rect-marker',
  14405. attrs: style
  14406. });
  14407. }
  14408. };
  14409. _proto.clearMarkers = function clearMarkers() {
  14410. var markerGroup = this.markerGroup;
  14411. markerGroup && markerGroup.clear();
  14412. };
  14413. _proto.show = function show() {
  14414. var crosshairsShapeX = this.crosshairsShapeX;
  14415. var crosshairsShapeY = this.crosshairsShapeY;
  14416. var markerGroup = this.markerGroup;
  14417. var container = this.container;
  14418. var tooltipArrow = this.tooltipArrow;
  14419. var xTipBox = this.xTipBox;
  14420. var yTipBox = this.yTipBox;
  14421. var canvas = this.canvas;
  14422. crosshairsShapeX && crosshairsShapeX.show();
  14423. crosshairsShapeY && crosshairsShapeY.show();
  14424. markerGroup && markerGroup.show();
  14425. container && container.show();
  14426. tooltipArrow && tooltipArrow.show();
  14427. xTipBox && xTipBox.show();
  14428. yTipBox && yTipBox.show();
  14429. canvas.draw();
  14430. };
  14431. _proto.hide = function hide() {
  14432. var crosshairsShapeX = this.crosshairsShapeX;
  14433. var crosshairsShapeY = this.crosshairsShapeY;
  14434. var markerGroup = this.markerGroup;
  14435. var container = this.container;
  14436. var tooltipArrow = this.tooltipArrow;
  14437. var xTipBox = this.xTipBox;
  14438. var yTipBox = this.yTipBox;
  14439. crosshairsShapeX && crosshairsShapeX.hide();
  14440. crosshairsShapeY && crosshairsShapeY.hide();
  14441. markerGroup && markerGroup.hide();
  14442. container && container.hide();
  14443. tooltipArrow && tooltipArrow.hide();
  14444. xTipBox && xTipBox.hide();
  14445. yTipBox && yTipBox.hide();
  14446. };
  14447. _proto.destroy = function destroy() {
  14448. var crosshairsShapeX = this.crosshairsShapeX;
  14449. var crosshairsShapeY = this.crosshairsShapeY;
  14450. var markerGroup = this.markerGroup;
  14451. var container = this.container;
  14452. var tooltipArrow = this.tooltipArrow;
  14453. var xTipBox = this.xTipBox;
  14454. var yTipBox = this.yTipBox;
  14455. crosshairsShapeX && crosshairsShapeX.remove(true);
  14456. crosshairsShapeY && crosshairsShapeY.remove(true);
  14457. markerGroup && markerGroup.remove(true);
  14458. tooltipArrow && tooltipArrow.remove(true);
  14459. container && container.clear();
  14460. xTipBox && xTipBox.clear();
  14461. yTipBox && yTipBox.clear();
  14462. this.destroyed = true;
  14463. };
  14464. _proto._getMarkerGroup = function _getMarkerGroup(type) {
  14465. var markerGroup = this.markerGroup;
  14466. if (!markerGroup) {
  14467. if (type === 'circle') {
  14468. markerGroup = this.frontPlot.addGroup({
  14469. zIndex: 1
  14470. });
  14471. this.frontPlot.sort();
  14472. } else {
  14473. markerGroup = this.backPlot.addGroup();
  14474. }
  14475. this.markerGroup = markerGroup;
  14476. } else {
  14477. markerGroup.clear();
  14478. }
  14479. return markerGroup;
  14480. };
  14481. _proto._renderCrosshairs = function _renderCrosshairs() {
  14482. var crosshairsType = this.crosshairsType,
  14483. crosshairsStyle = this.crosshairsStyle,
  14484. frontPlot = this.frontPlot,
  14485. plotRange = this.plotRange;
  14486. var tl = plotRange.tl,
  14487. br = plotRange.br;
  14488. if (Util.directionEnabled(crosshairsType, 'x')) {
  14489. this.crosshairsShapeX = frontPlot.addShape('Line', {
  14490. className: 'tooltip-crosshairs-x',
  14491. zIndex: 0,
  14492. visible: false,
  14493. attrs: Util.mix({
  14494. x1: tl.x,
  14495. y1: 0,
  14496. x2: br.x,
  14497. y2: 0
  14498. }, crosshairsStyle)
  14499. });
  14500. }
  14501. if (Util.directionEnabled(crosshairsType, 'y')) {
  14502. this.crosshairsShapeY = frontPlot.addShape('Line', {
  14503. className: 'tooltip-crosshairs-y',
  14504. zIndex: 0,
  14505. visible: false,
  14506. attrs: Util.mix({
  14507. x1: 0,
  14508. y1: br.y,
  14509. x2: 0,
  14510. y2: tl.y
  14511. }, crosshairsStyle)
  14512. });
  14513. }
  14514. };
  14515. return Tooltip;
  14516. }();
  14517. module.exports = Tooltip;
  14518. /***/ }),
  14519. /* 232 */
  14520. /***/ (function(module, exports, __webpack_require__) {
  14521. "use strict";
  14522. var Util = __webpack_require__(0);
  14523. var _require = __webpack_require__(16),
  14524. Group = _require.Group;
  14525. var TextBox = /*#__PURE__*/function () {
  14526. var _proto = TextBox.prototype;
  14527. _proto.getDefaultCfg = function getDefaultCfg() {
  14528. return {
  14529. x: 0,
  14530. y: 0,
  14531. content: '',
  14532. textStyle: {
  14533. fontSize: 12,
  14534. fill: '#fff',
  14535. textAlign: 'center',
  14536. textBaseline: 'middle'
  14537. },
  14538. background: {
  14539. radius: 1,
  14540. fill: 'rgba(0, 0, 0, 0.65)',
  14541. padding: [3, 5]
  14542. },
  14543. width: 0,
  14544. height: 0,
  14545. className: ''
  14546. };
  14547. };
  14548. function TextBox(cfg) {
  14549. Util.deepMix(this, this.getDefaultCfg(), cfg);
  14550. this._init();
  14551. var content = this.content,
  14552. x = this.x,
  14553. y = this.y;
  14554. if (!Util.isNil(content)) {
  14555. this.updateContent(content);
  14556. }
  14557. this.updatePosition(x, y);
  14558. }
  14559. _proto._init = function _init() {
  14560. var content = this.content,
  14561. textStyle = this.textStyle,
  14562. background = this.background,
  14563. className = this.className,
  14564. visible = this.visible;
  14565. var container = new Group({
  14566. className: className,
  14567. zIndex: 0,
  14568. visible: visible
  14569. });
  14570. var text = container.addShape('Text', {
  14571. className: className + '-text',
  14572. zIndex: 1,
  14573. attrs: Util.mix({
  14574. text: content,
  14575. x: 0,
  14576. y: 0
  14577. }, textStyle)
  14578. });
  14579. var backgroundShape = container.addShape('Rect', {
  14580. className: className + '-bg',
  14581. zIndex: -1,
  14582. attrs: Util.mix({
  14583. x: 0,
  14584. y: 0,
  14585. width: 0,
  14586. height: 0
  14587. }, background)
  14588. });
  14589. container.sort();
  14590. this.container = container;
  14591. this.textShape = text;
  14592. this.backgroundShape = backgroundShape;
  14593. };
  14594. _proto._getBBox = function _getBBox() {
  14595. var textShape = this.textShape;
  14596. var background = this.background;
  14597. var textBBox = textShape.getBBox();
  14598. var padding = Util.parsePadding(background.padding);
  14599. var width = textBBox.width + padding[1] + padding[3];
  14600. var height = textBBox.height + padding[0] + padding[2];
  14601. var x = textBBox.minX - padding[3];
  14602. var y = textBBox.minY - padding[0];
  14603. return {
  14604. x: x,
  14605. y: y,
  14606. width: width,
  14607. height: height
  14608. };
  14609. };
  14610. _proto.updateContent = function updateContent(text) {
  14611. var textShape = this.textShape,
  14612. backgroundShape = this.backgroundShape;
  14613. if (!Util.isNil(text)) {
  14614. if (!Util.isObject(text)) {
  14615. text = {
  14616. text: text
  14617. };
  14618. }
  14619. textShape.attr(text); // update box shape
  14620. var _this$_getBBox = this._getBBox(),
  14621. x = _this$_getBBox.x,
  14622. y = _this$_getBBox.y,
  14623. tipWidth = _this$_getBBox.width,
  14624. tipHeight = _this$_getBBox.height;
  14625. var width = this.width || tipWidth;
  14626. var height = this.height || tipHeight;
  14627. backgroundShape.attr({
  14628. x: x,
  14629. y: y,
  14630. width: width,
  14631. height: height
  14632. });
  14633. this._width = width;
  14634. this._height = height;
  14635. this.content = text.text;
  14636. }
  14637. };
  14638. _proto.updatePosition = function updatePosition(x, y) {
  14639. var container = this.container;
  14640. var _this$_getBBox2 = this._getBBox(),
  14641. xMin = _this$_getBBox2.x,
  14642. yMin = _this$_getBBox2.y;
  14643. container.moveTo(x - xMin, y - yMin);
  14644. this.x = x - xMin;
  14645. this.y = y - yMin;
  14646. };
  14647. _proto.getWidth = function getWidth() {
  14648. return this._width;
  14649. };
  14650. _proto.getHeight = function getHeight() {
  14651. return this._height;
  14652. };
  14653. _proto.show = function show() {
  14654. this.container.show();
  14655. };
  14656. _proto.hide = function hide() {
  14657. this.container.hide();
  14658. };
  14659. _proto.clear = function clear() {
  14660. var container = this.container;
  14661. container.clear();
  14662. container.remove(true);
  14663. this.container = null;
  14664. this.textShape = null;
  14665. this.backgroundShape = null;
  14666. };
  14667. return TextBox;
  14668. }();
  14669. module.exports = TextBox;
  14670. /***/ }),
  14671. /* 233 */
  14672. /***/ (function(module, exports, __webpack_require__) {
  14673. "use strict";
  14674. var Util = __webpack_require__(0);
  14675. var Guide = __webpack_require__(23);
  14676. var Global = __webpack_require__(6); // register the default configuration for Guide
  14677. Global.guide = Util.deepMix({
  14678. line: {
  14679. style: {
  14680. stroke: '#a3a3a3',
  14681. lineWidth: 1
  14682. },
  14683. top: true
  14684. },
  14685. text: {
  14686. style: {
  14687. fill: '#787878',
  14688. textAlign: 'center',
  14689. textBaseline: 'middle'
  14690. },
  14691. offsetX: 0,
  14692. offsetY: 0,
  14693. top: true
  14694. },
  14695. rect: {
  14696. style: {
  14697. fill: '#fafafa'
  14698. },
  14699. top: false
  14700. },
  14701. arc: {
  14702. style: {
  14703. stroke: '#a3a3a3'
  14704. },
  14705. top: true
  14706. },
  14707. html: {
  14708. offsetX: 0,
  14709. offsetY: 0,
  14710. alignX: 'center',
  14711. alignY: 'middle'
  14712. },
  14713. tag: {
  14714. top: true,
  14715. offsetX: 0,
  14716. offsetY: 0,
  14717. side: 4,
  14718. background: {
  14719. padding: 5,
  14720. radius: 2,
  14721. fill: '#1890FF'
  14722. },
  14723. textStyle: {
  14724. fontSize: 12,
  14725. fill: '#fff',
  14726. textAlign: 'center',
  14727. textBaseline: 'middle'
  14728. }
  14729. },
  14730. point: {
  14731. top: true,
  14732. offsetX: 0,
  14733. offsetY: 0,
  14734. style: {
  14735. fill: '#fff',
  14736. r: 3,
  14737. lineWidth: 2,
  14738. stroke: '#1890ff'
  14739. }
  14740. }
  14741. }, Global.guide || {});
  14742. var GuideController = /*#__PURE__*/function () {
  14743. function GuideController(cfg) {
  14744. this.guides = [];
  14745. this.xScale = null;
  14746. this.yScales = null;
  14747. this.guideShapes = [];
  14748. Util.mix(this, cfg);
  14749. }
  14750. var _proto = GuideController.prototype;
  14751. _proto._toString = function _toString(position) {
  14752. if (Util.isFunction(position)) {
  14753. position = position(this.xScale, this.yScales);
  14754. }
  14755. position = position.toString();
  14756. return position;
  14757. };
  14758. _proto._getId = function _getId(shape, guide) {
  14759. var id = guide.id;
  14760. if (!id) {
  14761. var type = guide.type;
  14762. if (type === 'arc' || type === 'line' || type === 'rect') {
  14763. id = this._toString(guide.start) + '-' + this._toString(guide.end);
  14764. } else {
  14765. id = this._toString(guide.position);
  14766. }
  14767. }
  14768. return id;
  14769. };
  14770. _proto.paint = function paint(coord) {
  14771. var self = this;
  14772. var chart = self.chart,
  14773. guides = self.guides,
  14774. xScale = self.xScale,
  14775. yScales = self.yScales;
  14776. var guideShapes = [];
  14777. Util.each(guides, function (guide, idx) {
  14778. guide.xScale = xScale;
  14779. guide.yScales = yScales;
  14780. var container;
  14781. if (guide.type === 'regionFilter') {
  14782. // TODO: RegionFilter support animation
  14783. guide.chart = chart;
  14784. } else {
  14785. container = guide.top ? self.frontPlot : self.backPlot;
  14786. }
  14787. guide.coord = coord;
  14788. guide.container = container;
  14789. guide.canvas = chart.get('canvas');
  14790. var shape = guide.render(coord, container);
  14791. if (shape) {
  14792. var id = self._getId(shape, guide);
  14793. [].concat(shape).forEach(function (s) {
  14794. s._id = s.get('className') + '-' + id;
  14795. s.set('index', idx);
  14796. guideShapes.push(s);
  14797. });
  14798. }
  14799. });
  14800. self.guideShapes = guideShapes;
  14801. };
  14802. _proto.clear = function clear() {
  14803. this.reset();
  14804. this.guides = [];
  14805. return this;
  14806. };
  14807. _proto.reset = function reset() {
  14808. var guides = this.guides;
  14809. Util.each(guides, function (guide) {
  14810. guide.remove();
  14811. });
  14812. };
  14813. _proto._createGuide = function _createGuide(type, cfg) {
  14814. var ClassName = Util.upperFirst(type);
  14815. var guide = new Guide[ClassName](Util.deepMix({}, Global.guide[type], cfg));
  14816. this.guides.push(guide);
  14817. return guide;
  14818. };
  14819. _proto.line = function line(cfg) {
  14820. if (cfg === void 0) {
  14821. cfg = {};
  14822. }
  14823. return this._createGuide('line', cfg);
  14824. };
  14825. _proto.text = function text(cfg) {
  14826. if (cfg === void 0) {
  14827. cfg = {};
  14828. }
  14829. return this._createGuide('text', cfg);
  14830. };
  14831. _proto.arc = function arc(cfg) {
  14832. if (cfg === void 0) {
  14833. cfg = {};
  14834. }
  14835. return this._createGuide('arc', cfg);
  14836. };
  14837. _proto.html = function html(cfg) {
  14838. if (cfg === void 0) {
  14839. cfg = {};
  14840. }
  14841. return this._createGuide('html', cfg);
  14842. };
  14843. _proto.rect = function rect(cfg) {
  14844. if (cfg === void 0) {
  14845. cfg = {};
  14846. }
  14847. return this._createGuide('rect', cfg);
  14848. };
  14849. _proto.tag = function tag(cfg) {
  14850. if (cfg === void 0) {
  14851. cfg = {};
  14852. }
  14853. return this._createGuide('tag', cfg);
  14854. };
  14855. _proto.point = function point(cfg) {
  14856. if (cfg === void 0) {
  14857. cfg = {};
  14858. }
  14859. return this._createGuide('point', cfg);
  14860. };
  14861. _proto.regionFilter = function regionFilter(cfg) {
  14862. if (cfg === void 0) {
  14863. cfg = {};
  14864. }
  14865. return this._createGuide('regionFilter', cfg);
  14866. };
  14867. return GuideController;
  14868. }();
  14869. module.exports = {
  14870. init: function init(chart) {
  14871. var guideController = new GuideController({
  14872. frontPlot: chart.get('frontPlot').addGroup({
  14873. zIndex: 20,
  14874. className: 'guideContainer'
  14875. }),
  14876. backPlot: chart.get('backPlot').addGroup({
  14877. className: 'guideContainer'
  14878. })
  14879. });
  14880. chart.set('guideController', guideController);
  14881. /**
  14882. * 为图表添加 guide
  14883. * @return {GuideController} 返回 guide 控制器
  14884. */
  14885. chart.guide = function () {
  14886. return guideController;
  14887. };
  14888. },
  14889. afterGeomDraw: function afterGeomDraw(chart) {
  14890. var guideController = chart.get('guideController');
  14891. if (!guideController.guides.length) {
  14892. return;
  14893. }
  14894. var xScale = chart.getXScale();
  14895. var yScales = chart.getYScales();
  14896. var coord = chart.get('coord');
  14897. guideController.xScale = xScale;
  14898. guideController.yScales = yScales;
  14899. guideController.chart = chart; // for regionFilter
  14900. guideController.paint(coord);
  14901. },
  14902. clear: function clear(chart) {
  14903. chart.get('guideController').clear();
  14904. },
  14905. repaint: function repaint(chart) {
  14906. chart.get('guideController').reset();
  14907. }
  14908. };
  14909. /***/ }),
  14910. /* 234 */
  14911. /***/ (function(module, exports, __webpack_require__) {
  14912. "use strict";
  14913. var Util = __webpack_require__(0);
  14914. var List = __webpack_require__(205);
  14915. var Global = __webpack_require__(6);
  14916. var LEGEND_GAP = 12;
  14917. var MARKER_SIZE = 3;
  14918. var DEFAULT_CFG = {
  14919. itemMarginBottom: 12,
  14920. itemGap: 10,
  14921. showTitle: false,
  14922. titleStyle: {
  14923. fontSize: 12,
  14924. fill: '#808080',
  14925. textAlign: 'start',
  14926. textBaseline: 'top'
  14927. },
  14928. nameStyle: {
  14929. fill: '#808080',
  14930. fontSize: 12,
  14931. textAlign: 'start',
  14932. textBaseline: 'middle'
  14933. },
  14934. valueStyle: {
  14935. fill: '#000000',
  14936. fontSize: 12,
  14937. textAlign: 'start',
  14938. textBaseline: 'middle'
  14939. },
  14940. unCheckStyle: {
  14941. fill: '#bfbfbf'
  14942. },
  14943. itemWidth: 'auto',
  14944. wordSpace: 6,
  14945. selectedMode: 'multiple' // 'multiple' or 'single'
  14946. }; // Register the default configuration for Legend
  14947. Global.legend = Util.deepMix({
  14948. common: DEFAULT_CFG,
  14949. // common legend configuration
  14950. right: Util.mix({
  14951. position: 'right',
  14952. layout: 'vertical'
  14953. }, DEFAULT_CFG),
  14954. left: Util.mix({
  14955. position: 'left',
  14956. layout: 'vertical'
  14957. }, DEFAULT_CFG),
  14958. top: Util.mix({
  14959. position: 'top',
  14960. layout: 'horizontal'
  14961. }, DEFAULT_CFG),
  14962. bottom: Util.mix({
  14963. position: 'bottom',
  14964. layout: 'horizontal'
  14965. }, DEFAULT_CFG)
  14966. }, Global.legend || {});
  14967. function getPaddingByPos(pos, appendPadding) {
  14968. var padding = 0;
  14969. appendPadding = Util.parsePadding(appendPadding);
  14970. switch (pos) {
  14971. case 'top':
  14972. padding = appendPadding[0];
  14973. break;
  14974. case 'right':
  14975. padding = appendPadding[1];
  14976. break;
  14977. case 'bottom':
  14978. padding = appendPadding[2];
  14979. break;
  14980. case 'left':
  14981. padding = appendPadding[3];
  14982. break;
  14983. default:
  14984. break;
  14985. }
  14986. return padding;
  14987. }
  14988. var LegendController = /*#__PURE__*/function () {
  14989. function LegendController(cfg) {
  14990. var _this = this;
  14991. this.handleEvent = function (ev) {
  14992. var self = _this;
  14993. function findItem(x, y) {
  14994. var result = null;
  14995. var legends = self.legends;
  14996. Util.each(legends, function (legendItems) {
  14997. Util.each(legendItems, function (legend) {
  14998. var itemsGroup = legend.itemsGroup,
  14999. legendHitBoxes = legend.legendHitBoxes;
  15000. var children = itemsGroup.get('children');
  15001. if (children.length) {
  15002. var legendPosX = legend.x;
  15003. var legendPosY = legend.y;
  15004. Util.each(legendHitBoxes, function (box, index) {
  15005. if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
  15006. // inbox
  15007. result = {
  15008. clickedItem: children[index],
  15009. clickedLegend: legend
  15010. };
  15011. return false;
  15012. }
  15013. });
  15014. }
  15015. });
  15016. });
  15017. return result;
  15018. }
  15019. var chart = self.chart;
  15020. var _Util$createEvent = Util.createEvent(ev, chart),
  15021. x = _Util$createEvent.x,
  15022. y = _Util$createEvent.y;
  15023. var clicked = findItem(x, y);
  15024. if (clicked && clicked.clickedLegend.clickable !== false) {
  15025. var clickedItem = clicked.clickedItem,
  15026. clickedLegend = clicked.clickedLegend;
  15027. if (clickedLegend.onClick) {
  15028. ev.clickedItem = clickedItem;
  15029. clickedLegend.onClick(ev);
  15030. } else if (!clickedLegend.custom) {
  15031. var checked = clickedItem.get('checked');
  15032. var value = clickedItem.get('dataValue');
  15033. var filteredVals = clickedLegend.filteredVals,
  15034. field = clickedLegend.field,
  15035. selectedMode = clickedLegend.selectedMode;
  15036. var isSingeSelected = selectedMode === 'single';
  15037. if (isSingeSelected) {
  15038. chart.filter(field, function (val) {
  15039. return val === value;
  15040. });
  15041. } else {
  15042. if (checked) {
  15043. filteredVals.push(value);
  15044. } else {
  15045. Util.Array.remove(filteredVals, value);
  15046. }
  15047. chart.filter(field, function (val) {
  15048. return filteredVals.indexOf(val) === -1;
  15049. });
  15050. }
  15051. chart.repaint();
  15052. }
  15053. }
  15054. };
  15055. this.legendCfg = {};
  15056. this.enable = true;
  15057. this.position = 'top';
  15058. Util.mix(this, cfg);
  15059. var _chart = this.chart;
  15060. this.canvasDom = _chart.get('canvas').get('el');
  15061. this.clear();
  15062. }
  15063. var _proto = LegendController.prototype;
  15064. _proto.addLegend = function addLegend(scale, items, filteredVals) {
  15065. var self = this;
  15066. var legendCfg = self.legendCfg;
  15067. var field = scale.field;
  15068. var fieldCfg = legendCfg[field];
  15069. if (fieldCfg === false) {
  15070. return null;
  15071. }
  15072. if (fieldCfg && fieldCfg.custom) {
  15073. self.addCustomLegend(field);
  15074. } else {
  15075. var position = legendCfg.position || self.position;
  15076. if (fieldCfg && fieldCfg.position) {
  15077. position = fieldCfg.position;
  15078. }
  15079. if (scale.isCategory) {
  15080. self._addCategoryLegend(scale, items, position, filteredVals);
  15081. }
  15082. }
  15083. };
  15084. _proto.addCustomLegend = function addCustomLegend(field) {
  15085. var self = this;
  15086. var legendCfg = self.legendCfg;
  15087. if (field && legendCfg[field]) {
  15088. legendCfg = legendCfg[field];
  15089. }
  15090. var position = legendCfg.position || self.position;
  15091. var legends = self.legends;
  15092. legends[position] = legends[position] || [];
  15093. var items = legendCfg.items;
  15094. if (!items) {
  15095. return null;
  15096. }
  15097. var container = self.container;
  15098. Util.each(items, function (item) {
  15099. if (!Util.isPlainObject(item.marker)) {
  15100. item.marker = {
  15101. symbol: item.marker || 'circle',
  15102. fill: item.fill,
  15103. radius: MARKER_SIZE
  15104. };
  15105. } else {
  15106. item.marker.radius = item.marker.radius || MARKER_SIZE;
  15107. }
  15108. item.checked = Util.isNil(item.checked) ? true : item.checked;
  15109. item.name = item.name || item.value;
  15110. });
  15111. var legend = new List(Util.deepMix({}, Global.legend[position], legendCfg, {
  15112. maxLength: self._getMaxLength(position),
  15113. items: items,
  15114. parent: container
  15115. }));
  15116. legends[position].push(legend);
  15117. };
  15118. _proto.clear = function clear() {
  15119. var legends = this.legends;
  15120. Util.each(legends, function (legendItems) {
  15121. Util.each(legendItems, function (legend) {
  15122. legend.clear();
  15123. });
  15124. });
  15125. this.legends = {};
  15126. this.unBindEvents();
  15127. };
  15128. _proto._isFiltered = function _isFiltered(scale, values, value) {
  15129. var rst = false;
  15130. Util.each(values, function (val) {
  15131. rst = rst || scale.getText(val) === scale.getText(value);
  15132. if (rst) {
  15133. return false;
  15134. }
  15135. });
  15136. return rst;
  15137. };
  15138. _proto._getMaxLength = function _getMaxLength(position) {
  15139. var chart = this.chart;
  15140. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  15141. return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
  15142. };
  15143. _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filteredVals) {
  15144. var self = this;
  15145. var legendCfg = self.legendCfg,
  15146. legends = self.legends,
  15147. container = self.container,
  15148. chart = self.chart;
  15149. var field = scale.field;
  15150. legends[position] = legends[position] || [];
  15151. var symbol = 'circle';
  15152. if (legendCfg[field] && legendCfg[field].marker) {
  15153. symbol = legendCfg[field].marker;
  15154. } else if (legendCfg.marker) {
  15155. symbol = legendCfg.marker;
  15156. }
  15157. Util.each(items, function (item) {
  15158. if (Util.isPlainObject(symbol)) {
  15159. Util.mix(item.marker, symbol);
  15160. } else {
  15161. item.marker.symbol = symbol;
  15162. }
  15163. if (filteredVals) {
  15164. item.checked = !self._isFiltered(scale, filteredVals, item.dataValue);
  15165. }
  15166. });
  15167. var legendItems = chart.get('legendItems');
  15168. legendItems[field] = items;
  15169. var lastCfg = Util.deepMix({}, Global.legend[position], legendCfg[field] || legendCfg, {
  15170. maxLength: self._getMaxLength(position),
  15171. items: items,
  15172. field: field,
  15173. filteredVals: filteredVals,
  15174. parent: container
  15175. });
  15176. if (lastCfg.showTitle) {
  15177. Util.deepMix(lastCfg, {
  15178. title: scale.alias || scale.field
  15179. });
  15180. }
  15181. var legend = new List(lastCfg);
  15182. legends[position].push(legend);
  15183. return legend;
  15184. };
  15185. _proto._alignLegend = function _alignLegend(legend, pre, position) {
  15186. var self = this;
  15187. var _self$plotRange = self.plotRange,
  15188. tl = _self$plotRange.tl,
  15189. bl = _self$plotRange.bl;
  15190. var chart = self.chart;
  15191. var offsetX = legend.offsetX || 0;
  15192. var offsetY = legend.offsetY || 0;
  15193. var chartWidth = chart.get('width');
  15194. var chartHeight = chart.get('height');
  15195. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  15196. var legendHeight = legend.getHeight();
  15197. var legendWidth = legend.getWidth();
  15198. var x = 0;
  15199. var y = 0;
  15200. if (position === 'left' || position === 'right') {
  15201. var verticalAlign = legend.verticalAlign || 'middle';
  15202. var height = Math.abs(tl.y - bl.y);
  15203. x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
  15204. y = (height - legendHeight) / 2 + tl.y;
  15205. if (verticalAlign === 'top') {
  15206. y = tl.y;
  15207. } else if (verticalAlign === 'bottom') {
  15208. y = bl.y - legendHeight;
  15209. }
  15210. if (pre) {
  15211. y = pre.get('y') - legendHeight - LEGEND_GAP;
  15212. }
  15213. } else {
  15214. var align = legend.align || 'left';
  15215. x = appendPadding[3];
  15216. if (align === 'center') {
  15217. x = chartWidth / 2 - legendWidth / 2;
  15218. } else if (align === 'right') {
  15219. x = chartWidth - (legendWidth + appendPadding[1]);
  15220. }
  15221. y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;
  15222. if (pre) {
  15223. var preWidth = pre.getWidth();
  15224. x = pre.x + preWidth + LEGEND_GAP;
  15225. }
  15226. }
  15227. if (position === 'bottom' && offsetY > 0) {
  15228. offsetY = 0;
  15229. }
  15230. if (position === 'right' && offsetX > 0) {
  15231. offsetX = 0;
  15232. }
  15233. legend.moveTo(x + offsetX, y + offsetY);
  15234. };
  15235. _proto.alignLegends = function alignLegends() {
  15236. var self = this;
  15237. var legends = self.legends;
  15238. Util.each(legends, function (legendItems, position) {
  15239. Util.each(legendItems, function (legend, index) {
  15240. var pre = legendItems[index - 1];
  15241. self._alignLegend(legend, pre, position);
  15242. });
  15243. });
  15244. return self;
  15245. };
  15246. _proto.bindEvents = function bindEvents() {
  15247. var legendCfg = this.legendCfg;
  15248. var triggerOn = legendCfg.triggerOn || 'touchstart';
  15249. Util.addEventListener(this.canvasDom, triggerOn, this.handleEvent);
  15250. };
  15251. _proto.unBindEvents = function unBindEvents() {
  15252. var legendCfg = this.legendCfg;
  15253. var triggerOn = legendCfg.triggerOn || 'touchstart';
  15254. Util.removeEventListener(this.canvasDom, triggerOn, this.handleEvent);
  15255. };
  15256. return LegendController;
  15257. }();
  15258. module.exports = {
  15259. init: function init(chart) {
  15260. var legendController = new LegendController({
  15261. container: chart.get('backPlot'),
  15262. plotRange: chart.get('plotRange'),
  15263. chart: chart
  15264. });
  15265. chart.set('legendController', legendController);
  15266. chart.legend = function (field, cfg) {
  15267. var legendCfg = legendController.legendCfg;
  15268. legendController.enable = true;
  15269. if (Util.isBoolean(field)) {
  15270. legendController.enable = field;
  15271. legendCfg = cfg || {};
  15272. } else if (Util.isObject(field)) {
  15273. legendCfg = field;
  15274. } else {
  15275. legendCfg[field] = cfg;
  15276. }
  15277. legendController.legendCfg = legendCfg;
  15278. return this;
  15279. };
  15280. },
  15281. beforeGeomDraw: function beforeGeomDraw(chart) {
  15282. var legendController = chart.get('legendController');
  15283. if (!legendController.enable) return null; // legend is not displayed
  15284. var legendCfg = legendController.legendCfg;
  15285. if (legendCfg && legendCfg.custom) {
  15286. legendController.addCustomLegend();
  15287. } else {
  15288. var legendItems = chart.getLegendItems();
  15289. var scales = chart.get('scales');
  15290. var filters = chart.get('filters');
  15291. Util.each(legendItems, function (items, field) {
  15292. var scale = scales[field];
  15293. var values = scale.values;
  15294. var filteredVals;
  15295. if (filters && filters[field]) {
  15296. filteredVals = values.filter(function (v) {
  15297. return !filters[field](v);
  15298. });
  15299. } else {
  15300. filteredVals = [];
  15301. }
  15302. legendController.addLegend(scale, items, filteredVals);
  15303. });
  15304. }
  15305. if (legendCfg && legendCfg.clickable !== false) {
  15306. legendController.bindEvents();
  15307. }
  15308. var legends = legendController.legends;
  15309. var legendRange = {
  15310. top: 0,
  15311. right: 0,
  15312. bottom: 0,
  15313. left: 0
  15314. };
  15315. Util.each(legends, function (legendItems, position) {
  15316. var padding = 0;
  15317. Util.each(legendItems, function (legend) {
  15318. var width = legend.getWidth();
  15319. var height = legend.getHeight();
  15320. if (position === 'top' || position === 'bottom') {
  15321. padding = Math.max(padding, height);
  15322. if (legend.offsetY > 0) {
  15323. padding += legend.offsetY;
  15324. }
  15325. } else {
  15326. padding = Math.max(padding, width);
  15327. if (legend.offsetX > 0) {
  15328. padding += legend.offsetX;
  15329. }
  15330. }
  15331. });
  15332. legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
  15333. });
  15334. chart.set('legendRange', legendRange);
  15335. },
  15336. afterGeomDraw: function afterGeomDraw(chart) {
  15337. var legendController = chart.get('legendController');
  15338. legendController.alignLegends();
  15339. },
  15340. clearInner: function clearInner(chart) {
  15341. var legendController = chart.get('legendController');
  15342. legendController.clear();
  15343. chart.set('legendRange', null);
  15344. }
  15345. };
  15346. /***/ }),
  15347. /* 235 */
  15348. /***/ (function(module, exports, __webpack_require__) {
  15349. "use strict";
  15350. /**
  15351. * Handle the detail animations
  15352. * @author sima.zhang1990@gmail.com
  15353. */
  15354. var Util = __webpack_require__(0);
  15355. var Element = __webpack_require__(46);
  15356. var Timeline = __webpack_require__(236);
  15357. var Animator = __webpack_require__(237);
  15358. var Animate = __webpack_require__(206);
  15359. var ShapeAction = __webpack_require__(239);
  15360. var GroupAction = __webpack_require__(240);
  15361. var Chart = __webpack_require__(30);
  15362. var timeline;
  15363. Element.prototype.animate = function () {
  15364. var attrs = Util.mix({}, this.get('attrs'));
  15365. return new Animator(this, attrs, timeline);
  15366. };
  15367. Chart.prototype.animate = function (cfg) {
  15368. this.set('animate', cfg);
  15369. return this;
  15370. };
  15371. Animate.Action = ShapeAction;
  15372. Animate.defaultCfg = {
  15373. interval: {
  15374. enter: function enter(coord) {
  15375. if (coord.isPolar && coord.transposed) {
  15376. // for pie chart
  15377. return function (shape) {
  15378. shape.set('zIndex', -1);
  15379. var container = shape.get('parent');
  15380. container.sort();
  15381. };
  15382. }
  15383. return ShapeAction.fadeIn;
  15384. }
  15385. },
  15386. area: {
  15387. enter: function enter(coord) {
  15388. if (coord.isPolar) return null;
  15389. return ShapeAction.fadeIn;
  15390. }
  15391. },
  15392. line: {
  15393. enter: function enter(coord) {
  15394. if (coord.isPolar) return null;
  15395. return ShapeAction.fadeIn;
  15396. }
  15397. },
  15398. path: {
  15399. enter: function enter(coord) {
  15400. if (coord.isPolar) return null;
  15401. return ShapeAction.fadeIn;
  15402. }
  15403. }
  15404. };
  15405. var GROUP_ANIMATION = {
  15406. line: function line(coord) {
  15407. if (coord.isPolar) {
  15408. return GroupAction.groupScaleInXY;
  15409. }
  15410. return GroupAction.groupWaveIn;
  15411. },
  15412. area: function area(coord) {
  15413. if (coord.isPolar) {
  15414. return GroupAction.groupScaleInXY;
  15415. }
  15416. return GroupAction.groupWaveIn;
  15417. },
  15418. path: function path(coord) {
  15419. if (coord.isPolar) {
  15420. return GroupAction.groupScaleInXY;
  15421. }
  15422. return GroupAction.groupWaveIn;
  15423. },
  15424. point: function point() {
  15425. return GroupAction.shapesScaleInXY;
  15426. },
  15427. interval: function interval(coord) {
  15428. var result;
  15429. if (coord.isPolar) {
  15430. // polar coodinate
  15431. result = GroupAction.groupScaleInXY;
  15432. if (coord.transposed) {
  15433. // pie chart
  15434. result = GroupAction.groupWaveIn;
  15435. }
  15436. } else {
  15437. result = coord.transposed ? GroupAction.groupScaleInX : GroupAction.groupScaleInY;
  15438. }
  15439. return result;
  15440. },
  15441. schema: function schema() {
  15442. return GroupAction.groupWaveIn;
  15443. }
  15444. };
  15445. function diff(fromAttrs, toAttrs) {
  15446. var endState = {};
  15447. for (var k in toAttrs) {
  15448. if (Util.isNumber(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
  15449. endState[k] = toAttrs[k];
  15450. } else if (Util.isArray(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
  15451. endState[k] = toAttrs[k];
  15452. }
  15453. }
  15454. return endState;
  15455. } // Add a unique id identifier to each shape
  15456. function _getShapeId(geom, dataObj, geomIdx) {
  15457. var type = geom.get('type');
  15458. var id = 'geom' + geomIdx + '-' + type;
  15459. var xScale = geom.getXScale();
  15460. var yScale = geom.getYScale();
  15461. var xField = xScale.field || 'x';
  15462. var yField = yScale.field || 'y';
  15463. var yVal = dataObj[yField];
  15464. var xVal;
  15465. if (xScale.isIdentity) {
  15466. xVal = xScale.value;
  15467. } else {
  15468. xVal = dataObj[xField];
  15469. }
  15470. if (type === 'interval' || type === 'schema') {
  15471. id += '-' + xVal;
  15472. } else if (type === 'line' || type === 'area' || type === 'path') {
  15473. id += '-' + type;
  15474. } else {
  15475. id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
  15476. }
  15477. var groupScales = geom._getGroupScales();
  15478. Util.each(groupScales, function (groupScale) {
  15479. var field = groupScale.field;
  15480. if (groupScale.type !== 'identity') {
  15481. id += '-' + dataObj[field];
  15482. }
  15483. });
  15484. return id;
  15485. } // get geometry's shapes
  15486. function getShapes(geoms, chart, coord) {
  15487. var shapes = [];
  15488. Util.each(geoms, function (geom, geomIdx) {
  15489. var geomContainer = geom.get('container');
  15490. var geomShapes = geomContainer.get('children');
  15491. var type = geom.get('type');
  15492. var animateCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  15493. if (animateCfg !== false) {
  15494. Util.each(geomShapes, function (shape, index) {
  15495. if (shape.get('className') === type) {
  15496. shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
  15497. shape.set('coord', coord);
  15498. shape.set('animateCfg', animateCfg);
  15499. shape.set('index', index);
  15500. shapes.push(shape);
  15501. }
  15502. });
  15503. }
  15504. geom.set('shapes', geomShapes);
  15505. });
  15506. return shapes;
  15507. }
  15508. function cache(shapes) {
  15509. var rst = {};
  15510. for (var i = 0, len = shapes.length; i < len; i++) {
  15511. var shape = shapes[i];
  15512. if (!shape._id || shape.isClip) continue;
  15513. var id = shape._id;
  15514. rst[id] = {
  15515. _id: id,
  15516. type: shape.get('type'),
  15517. // the type of shape
  15518. attrs: Util.mix({}, shape._attrs.attrs),
  15519. // the graphics attributes of shape
  15520. className: shape.get('className'),
  15521. geomType: shape.get('className'),
  15522. index: shape.get('index'),
  15523. coord: shape.get('coord'),
  15524. animateCfg: shape.get('animateCfg')
  15525. };
  15526. }
  15527. return rst;
  15528. }
  15529. function getAnimate(geomType, coord, animationType, animationName) {
  15530. var result;
  15531. if (Util.isFunction(animationName)) {
  15532. result = animationName;
  15533. } else if (Util.isString(animationName)) {
  15534. result = Animate.Action[animationName];
  15535. } else {
  15536. result = Animate.getAnimation(geomType, coord, animationType);
  15537. }
  15538. return result;
  15539. }
  15540. function getAnimateCfg(geomType, animationType, animateCfg) {
  15541. if (animateCfg === false || Util.isObject(animateCfg) && animateCfg[animationType] === false) {
  15542. return false;
  15543. }
  15544. var defaultCfg = Animate.getAnimateCfg(geomType, animationType);
  15545. if (animateCfg && animateCfg[animationType]) {
  15546. return Util.deepMix({}, defaultCfg, animateCfg[animationType]);
  15547. }
  15548. return defaultCfg;
  15549. }
  15550. function addAnimate(cache, shapes, canvas) {
  15551. var animate;
  15552. var animateCfg; // the order of animation: leave -> update -> enter
  15553. var updateShapes = [];
  15554. var newShapes = [];
  15555. Util.each(shapes, function (shape) {
  15556. var result = cache[shape._id];
  15557. if (!result) {
  15558. newShapes.push(shape);
  15559. } else {
  15560. shape.set('cacheShape', result);
  15561. updateShapes.push(shape);
  15562. delete cache[shape._id];
  15563. }
  15564. }); // first do the leave animation
  15565. Util.each(cache, function (deletedShape) {
  15566. var className = deletedShape.className,
  15567. coord = deletedShape.coord,
  15568. _id = deletedShape._id,
  15569. attrs = deletedShape.attrs,
  15570. index = deletedShape.index,
  15571. type = deletedShape.type;
  15572. animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
  15573. if (animateCfg === false) return true;
  15574. animate = getAnimate(className, coord, 'leave', animateCfg.animation);
  15575. if (Util.isFunction(animate)) {
  15576. var tempShape = canvas.addShape(type, {
  15577. attrs: attrs,
  15578. index: index,
  15579. canvas: canvas,
  15580. className: className
  15581. });
  15582. tempShape._id = _id;
  15583. animate(tempShape, animateCfg, coord);
  15584. }
  15585. }); // then do the update animation
  15586. Util.each(updateShapes, function (updateShape) {
  15587. var className = updateShape.get('className');
  15588. animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
  15589. if (animateCfg === false) return true;
  15590. var coord = updateShape.get('coord');
  15591. var cacheAttrs = updateShape.get('cacheShape').attrs;
  15592. var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换
  15593. if (Object.keys(endState).length) {
  15594. animate = getAnimate(className, coord, 'update', animateCfg.animation);
  15595. if (Util.isFunction(animate)) {
  15596. animate(updateShape, animateCfg, coord);
  15597. } else {
  15598. updateShape.attr(cacheAttrs);
  15599. updateShape.animate().to({
  15600. attrs: endState,
  15601. duration: animateCfg.duration,
  15602. easing: animateCfg.easing,
  15603. delay: animateCfg.delay
  15604. }).onEnd(function () {
  15605. updateShape.set('cacheShape', null);
  15606. });
  15607. }
  15608. }
  15609. }); // last, enter animation
  15610. Util.each(newShapes, function (newShape) {
  15611. // 新图形元素的进场元素
  15612. var className = newShape.get('className');
  15613. var coord = newShape.get('coord');
  15614. animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
  15615. if (animateCfg === false) return true;
  15616. animate = getAnimate(className, coord, 'enter', animateCfg.animation);
  15617. if (Util.isFunction(animate)) {
  15618. if (className === 'interval' && coord.isPolar && coord.transposed) {
  15619. var index = newShape.get('index');
  15620. var lastShape = updateShapes[index - 1];
  15621. animate(newShape, animateCfg, lastShape);
  15622. } else {
  15623. animate(newShape, animateCfg, coord);
  15624. }
  15625. }
  15626. });
  15627. }
  15628. function _getAnimateCfgByShapeType(type, chart) {
  15629. if (!type) {
  15630. return null;
  15631. }
  15632. var animateCfg = chart.get('animate');
  15633. if (type.indexOf('guide-tag') > -1) {
  15634. type = 'guide-tag';
  15635. }
  15636. if (Util.isObject(animateCfg)) {
  15637. return animateCfg[type];
  15638. }
  15639. if (animateCfg === false) {
  15640. return false;
  15641. }
  15642. return null;
  15643. }
  15644. module.exports = {
  15645. afterCanvasInit: function afterCanvasInit()
  15646. /* chart */
  15647. {
  15648. timeline = new Timeline();
  15649. timeline.play();
  15650. },
  15651. beforeCanvasDraw: function beforeCanvasDraw(chart) {
  15652. if (chart.get('animate') === false) {
  15653. return;
  15654. }
  15655. var isUpdate = chart.get('isUpdate');
  15656. var canvas = chart.get('canvas');
  15657. var coord = chart.get('coord');
  15658. var geoms = chart.get('geoms');
  15659. var caches = canvas.get('caches') || [];
  15660. if (caches.length === 0) {
  15661. isUpdate = false;
  15662. }
  15663. var cacheShapes = getShapes(geoms, chart, coord);
  15664. var _chart$get = chart.get('axisController'),
  15665. frontPlot = _chart$get.frontPlot,
  15666. backPlot = _chart$get.backPlot;
  15667. var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
  15668. var guideShapes = [];
  15669. if (chart.get('guideController')) {
  15670. guideShapes = chart.get('guideController').guideShapes;
  15671. }
  15672. var componentShapes = [];
  15673. axisShapes.concat(guideShapes).forEach(function (s) {
  15674. var className = s.get('className');
  15675. var animateCfg = _getAnimateCfgByShapeType(className, chart);
  15676. s.set('coord', coord);
  15677. s.set('animateCfg', animateCfg);
  15678. componentShapes.push(s);
  15679. cacheShapes.push(s);
  15680. });
  15681. canvas.set('caches', cache(cacheShapes));
  15682. if (isUpdate) {
  15683. addAnimate(caches, cacheShapes, canvas);
  15684. } else {
  15685. // do the appear animation
  15686. var animateCfg;
  15687. var animate;
  15688. Util.each(geoms, function (geom) {
  15689. var type = geom.get('type');
  15690. var geomCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  15691. if (geomCfg !== false) {
  15692. animateCfg = getAnimateCfg(type, 'appear', geomCfg);
  15693. animate = getAnimate(type, coord, 'appear', animateCfg.animation);
  15694. if (Util.isFunction(animate)) {
  15695. var shapes = geom.get('shapes');
  15696. Util.each(shapes, function (shape) {
  15697. animate(shape, animateCfg, coord);
  15698. });
  15699. } else if (GROUP_ANIMATION[type]) {
  15700. // do the default animation
  15701. animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
  15702. var yScale = geom.getYScale();
  15703. var zeroY = coord.convertPoint({
  15704. x: 0,
  15705. y: yScale.scale(geom.getYMinValue())
  15706. });
  15707. var container = geom.get('container');
  15708. animate && animate(container, animateCfg, coord, zeroY);
  15709. }
  15710. }
  15711. }); // do the animation of components
  15712. Util.each(componentShapes, function (shape) {
  15713. var animateCfg = shape.get('animateCfg');
  15714. var className = shape.get('className');
  15715. if (animateCfg && animateCfg.appear) {
  15716. // if user configure
  15717. var defaultCfg = Animate.getAnimateCfg(className, 'appear');
  15718. var appearCfg = Util.deepMix({}, defaultCfg, animateCfg.appear);
  15719. var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);
  15720. if (Util.isFunction(_animate)) {
  15721. _animate(shape, appearCfg, coord);
  15722. }
  15723. }
  15724. });
  15725. }
  15726. },
  15727. afterCanvasDestroyed: function afterCanvasDestroyed()
  15728. /* chart */
  15729. {
  15730. timeline.stop();
  15731. }
  15732. };
  15733. /***/ }),
  15734. /* 236 */
  15735. /***/ (function(module, exports, __webpack_require__) {
  15736. "use strict";
  15737. var _require = __webpack_require__(70),
  15738. requestAnimationFrame = _require.requestAnimationFrame;
  15739. var clock = typeof performance === 'object' && performance.now ? performance : Date;
  15740. var Timeline = /*#__PURE__*/function () {
  15741. function Timeline() {
  15742. this.anims = [];
  15743. this.time = null;
  15744. this.playing = false;
  15745. this.canvas = [];
  15746. }
  15747. var _proto = Timeline.prototype;
  15748. _proto.play = function play() {
  15749. var self = this;
  15750. self.time = clock.now();
  15751. self.playing = true;
  15752. function step() {
  15753. if (self.playing) {
  15754. requestAnimationFrame(step);
  15755. self.update();
  15756. }
  15757. }
  15758. requestAnimationFrame(step);
  15759. };
  15760. _proto.stop = function stop() {
  15761. this.playing = false;
  15762. this.time = null;
  15763. this.canvas = [];
  15764. };
  15765. _proto.update = function update() {
  15766. var currentTime = clock.now();
  15767. this.canvas = [];
  15768. for (var i = 0; i < this.anims.length; i++) {
  15769. var propertyAnim = this.anims[i];
  15770. if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
  15771. continue;
  15772. }
  15773. var shape = propertyAnim.shape; // shape
  15774. if (shape.get('destroyed')) {
  15775. this.anims.splice(i, 1);
  15776. i--;
  15777. continue;
  15778. }
  15779. var startState = propertyAnim.startState,
  15780. endState = propertyAnim.endState,
  15781. interpolate = propertyAnim.interpolate,
  15782. duration = propertyAnim.duration;
  15783. if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
  15784. propertyAnim.hasStarted = true;
  15785. if (propertyAnim.onStart) {
  15786. propertyAnim.onStart();
  15787. }
  15788. }
  15789. var t = (currentTime - propertyAnim.startTime) / duration;
  15790. t = Math.max(0, Math.min(t, 1));
  15791. t = propertyAnim.easing(t);
  15792. if (propertyAnim.onFrame) {
  15793. propertyAnim.onFrame(t);
  15794. } else {
  15795. for (var key in interpolate) {
  15796. var diff = interpolate[key];
  15797. var value = diff(t);
  15798. var newValue = void 0;
  15799. if (key === 'points') {
  15800. newValue = [];
  15801. var aLen = Math.max(startState.points.length, endState.points.length);
  15802. for (var j = 0; j < aLen; j += 2) {
  15803. newValue.push({
  15804. x: value[j],
  15805. y: value[j + 1]
  15806. });
  15807. }
  15808. } else {
  15809. newValue = value;
  15810. }
  15811. shape._attrs.attrs[key] = newValue;
  15812. shape._attrs.bbox = null; // should clear calculated bbox
  15813. }
  15814. }
  15815. var canvas = shape.get('canvas');
  15816. if (this.canvas.indexOf(canvas) === -1) {
  15817. this.canvas.push(canvas);
  15818. }
  15819. if (propertyAnim.onUpdate) {
  15820. propertyAnim.onUpdate(t);
  15821. }
  15822. if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
  15823. propertyAnim.hasEnded = true;
  15824. if (propertyAnim.onEnd) {
  15825. propertyAnim.onEnd();
  15826. }
  15827. }
  15828. if (t === 1) {
  15829. // end
  15830. this.anims.splice(i, 1);
  15831. i--;
  15832. }
  15833. }
  15834. this.canvas.map(function (c) {
  15835. c.draw();
  15836. return c;
  15837. });
  15838. this.time = clock.now();
  15839. };
  15840. return Timeline;
  15841. }();
  15842. module.exports = Timeline;
  15843. /***/ }),
  15844. /* 237 */
  15845. /***/ (function(module, exports, __webpack_require__) {
  15846. "use strict";
  15847. var Easing = __webpack_require__(238);
  15848. function plainArray(arr) {
  15849. var result = [];
  15850. for (var i = 0, len = arr.length; i < len; i++) {
  15851. if (arr[i]) {
  15852. result.push(arr[i].x);
  15853. result.push(arr[i].y);
  15854. }
  15855. }
  15856. return result;
  15857. }
  15858. function interpolateNumber(a, b) {
  15859. a = +a;
  15860. b -= a;
  15861. return function (t) {
  15862. return a + b * t;
  15863. };
  15864. }
  15865. function interpolateArray(a, b) {
  15866. var nb = b ? b.length : 0;
  15867. var na = a ? Math.min(nb, a.length) : 0;
  15868. var x = new Array(na);
  15869. var c = new Array(nb);
  15870. var i;
  15871. for (i = 0; i < na; ++i) {
  15872. x[i] = interpolateNumber(a[i], b[i]);
  15873. }
  15874. for (; i < nb; ++i) {
  15875. c[i] = b[i];
  15876. }
  15877. return function (t) {
  15878. for (i = 0; i < na; ++i) {
  15879. c[i] = x[i](t);
  15880. }
  15881. return c;
  15882. };
  15883. }
  15884. var Animator = /*#__PURE__*/function () {
  15885. function Animator(shape, source, timeline) {
  15886. this.hasStarted = false;
  15887. this.hasEnded = false;
  15888. this.shape = shape;
  15889. this.source = source;
  15890. this.timeline = timeline;
  15891. this.animate = null;
  15892. } // delay, attrs, duration, easing
  15893. var _proto = Animator.prototype;
  15894. _proto.to = function to(cfg) {
  15895. if (cfg === void 0) {
  15896. cfg = {};
  15897. }
  15898. var delay = cfg.delay || 0;
  15899. var attrs = cfg.attrs || {};
  15900. var duration = cfg.duration || 1000;
  15901. var easing; // 缓动函数
  15902. if (typeof cfg.easing === 'function') {
  15903. easing = cfg.easing;
  15904. } else {
  15905. easing = Easing[cfg.easing] || Easing.linear;
  15906. }
  15907. var animInfo = {
  15908. shape: this.shape,
  15909. startTime: this.timeline.time + delay,
  15910. duration: duration,
  15911. easing: easing
  15912. };
  15913. var interpolate = {}; // 差值函数
  15914. for (var attrName in attrs) {
  15915. var startValue = this.source[attrName];
  15916. var endValue = attrs[attrName];
  15917. if (attrName === 'points') {
  15918. startValue = plainArray(startValue);
  15919. endValue = plainArray(endValue);
  15920. interpolate.points = interpolateArray(startValue, endValue);
  15921. this.source.points = startValue;
  15922. attrs.points = endValue;
  15923. } else if (attrName === 'matrix') {
  15924. interpolate.matrix = interpolateArray(startValue, endValue);
  15925. } else {
  15926. interpolate[attrName] = interpolateNumber(startValue, endValue);
  15927. }
  15928. }
  15929. animInfo.interpolate = interpolate;
  15930. animInfo.startState = this.source;
  15931. animInfo.endState = attrs;
  15932. animInfo.endTime = animInfo.startTime + duration;
  15933. this.timeline.anims.push(animInfo);
  15934. this.animate = animInfo;
  15935. return this;
  15936. };
  15937. _proto.onFrame = function onFrame(callback) {
  15938. // 自定义每一帧动画的动作
  15939. if (this.animate) {
  15940. this.animate.onFrame = function (frame) {
  15941. callback(frame);
  15942. };
  15943. }
  15944. return this;
  15945. };
  15946. _proto.onStart = function onStart(callback) {
  15947. if (this.animate) {
  15948. this.animate.onStart = function () {
  15949. callback();
  15950. };
  15951. }
  15952. return this;
  15953. };
  15954. _proto.onUpdate = function onUpdate(callback) {
  15955. if (this.animate) {
  15956. this.animate.onUpdate = function (frame) {
  15957. callback(frame);
  15958. };
  15959. }
  15960. return this;
  15961. };
  15962. _proto.onEnd = function onEnd(callback) {
  15963. if (this.animate) {
  15964. this.animate.onEnd = function () {
  15965. callback();
  15966. };
  15967. }
  15968. return this;
  15969. };
  15970. return Animator;
  15971. }();
  15972. module.exports = Animator;
  15973. /***/ }),
  15974. /* 238 */
  15975. /***/ (function(module, exports, __webpack_require__) {
  15976. "use strict";
  15977. var Easing = {
  15978. linear: function linear(k) {
  15979. return k;
  15980. },
  15981. quadraticIn: function quadraticIn(k) {
  15982. return k * k;
  15983. },
  15984. quadraticOut: function quadraticOut(k) {
  15985. return k * (2 - k);
  15986. },
  15987. quadraticInOut: function quadraticInOut(k) {
  15988. if ((k *= 2) < 1) {
  15989. return 0.5 * k * k;
  15990. }
  15991. return -0.5 * (--k * (k - 2) - 1);
  15992. },
  15993. cubicIn: function cubicIn(k) {
  15994. return k * k * k;
  15995. },
  15996. cubicOut: function cubicOut(k) {
  15997. return --k * k * k + 1;
  15998. },
  15999. cubicInOut: function cubicInOut(k) {
  16000. if ((k *= 2) < 1) {
  16001. return 0.5 * k * k * k;
  16002. }
  16003. return 0.5 * ((k -= 2) * k * k + 2);
  16004. },
  16005. elasticIn: function elasticIn(k) {
  16006. var s;
  16007. var a = 0.1;
  16008. var p = 0.4;
  16009. if (k === 0) return 0;
  16010. if (k === 1) return 1;
  16011. if (!p) {
  16012. p = 0.3;
  16013. }
  16014. if (!a || a < 1) {
  16015. a = 1;
  16016. s = p / 4;
  16017. } else {
  16018. s = p / (2 * Math.PI) * Math.asin(1 / a);
  16019. }
  16020. return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  16021. },
  16022. elasticOut: function elasticOut(k) {
  16023. var s;
  16024. var a = 0.1;
  16025. var p = 0.4;
  16026. if (k === 0) return 0;
  16027. if (k === 1) return 1;
  16028. if (!p) {
  16029. p = 0.3;
  16030. }
  16031. if (!a || a < 1) {
  16032. a = 1;
  16033. s = p / 4;
  16034. } else {
  16035. s = p / (2 * Math.PI) * Math.asin(1 / a);
  16036. }
  16037. return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
  16038. },
  16039. elasticInOut: function elasticInOut(k) {
  16040. var s;
  16041. var a = 0.1;
  16042. var p = 0.4;
  16043. if (k === 0) return 0;
  16044. if (k === 1) return 1;
  16045. if (!p) {
  16046. p = 0.3;
  16047. }
  16048. if (!a || a < 1) {
  16049. a = 1;
  16050. s = p / 4;
  16051. } else {
  16052. s = p / (2 * Math.PI) * Math.asin(1 / a);
  16053. }
  16054. if ((k *= 2) < 1) {
  16055. return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  16056. }
  16057. return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  16058. },
  16059. backIn: function backIn(k) {
  16060. var s = 1.70158;
  16061. return k * k * ((s + 1) * k - s);
  16062. },
  16063. backOut: function backOut(k) {
  16064. var s = 1.70158;
  16065. return (k = k - 1) * k * ((s + 1) * k + s) + 1;
  16066. },
  16067. backInOut: function backInOut(k) {
  16068. var s = 1.70158 * 1.525;
  16069. if ((k *= 2) < 1) {
  16070. return 0.5 * (k * k * ((s + 1) * k - s));
  16071. }
  16072. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  16073. },
  16074. bounceIn: function bounceIn(k) {
  16075. return 1 - Easing.bounceOut(1 - k);
  16076. },
  16077. bounceOut: function bounceOut(k) {
  16078. if ((k /= 1) < 1 / 2.75) {
  16079. return 7.5625 * k * k;
  16080. } else if (k < 2 / 2.75) {
  16081. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
  16082. } else if (k < 2.5 / 2.75) {
  16083. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
  16084. }
  16085. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
  16086. },
  16087. bounceInOut: function bounceInOut(k) {
  16088. if (k < 0.5) {
  16089. return Easing.bounceIn(k * 2) * 0.5;
  16090. }
  16091. return Easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  16092. }
  16093. };
  16094. module.exports = Easing;
  16095. /***/ }),
  16096. /* 239 */
  16097. /***/ (function(module, exports, __webpack_require__) {
  16098. "use strict";
  16099. /**
  16100. * Animation functions for shape
  16101. * @author sima.zhang1990@gmail.com
  16102. */
  16103. var Util = __webpack_require__(0);
  16104. var Helpers = __webpack_require__(207);
  16105. /*
  16106. function waveIn(shape, animateCfg, coord) {
  16107. const clip = Helpers.getClip(coord);
  16108. clip.set('canvas', shape.get('canvas'));
  16109. shape.attr('clip', clip);
  16110. const onEnd = function() {
  16111. shape.attr('clip', null);
  16112. clip.remove(true);
  16113. };
  16114. Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
  16115. }
  16116. function scaleInX(shape, animateCfg) {
  16117. const box = shape.getBBox();
  16118. const points = shape.get('origin').points;
  16119. let x;
  16120. const y = (box.minY + box.maxY) / 2;
  16121. if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
  16122. x = box.maxX;
  16123. } else {
  16124. x = box.minX;
  16125. }
  16126. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  16127. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  16128. }
  16129. function scaleInY(shape, animateCfg) {
  16130. const box = shape.getBBox();
  16131. const points = shape.get('origin').points;
  16132. const x = (box.minX + box.maxX) / 2;
  16133. let y;
  16134. if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
  16135. y = box.maxY;
  16136. } else {
  16137. y = box.minY;
  16138. }
  16139. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  16140. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  16141. }
  16142. */
  16143. function fadeIn(shape, animateCfg) {
  16144. var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
  16145. var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
  16146. shape.attr('fillOpacity', 0);
  16147. shape.attr('strokeOpacity', 0);
  16148. var endState = {
  16149. fillOpacity: fillOpacity,
  16150. strokeOpacity: strokeOpacity
  16151. };
  16152. Helpers.doAnimation(shape, endState, animateCfg);
  16153. }
  16154. module.exports = {
  16155. // waveIn,
  16156. // scaleInX,
  16157. // scaleInY,
  16158. fadeIn: fadeIn
  16159. };
  16160. /***/ }),
  16161. /* 240 */
  16162. /***/ (function(module, exports, __webpack_require__) {
  16163. "use strict";
  16164. /**
  16165. * Group animate functions
  16166. * @author sima.zhang1990@gmail.com
  16167. */
  16168. var Util = __webpack_require__(207);
  16169. var Helper = __webpack_require__(37);
  16170. var _require = __webpack_require__(16),
  16171. Shape = _require.Shape;
  16172. function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
  16173. var _Util$getCoordInfo = Util.getCoordInfo(coord),
  16174. start = _Util$getCoordInfo.start,
  16175. end = _Util$getCoordInfo.end,
  16176. width = _Util$getCoordInfo.width,
  16177. height = _Util$getCoordInfo.height;
  16178. var x;
  16179. var y;
  16180. var clip = new Shape.Rect({
  16181. attrs: {
  16182. x: start.x,
  16183. y: end.y,
  16184. width: width,
  16185. height: height
  16186. }
  16187. });
  16188. if (type === 'y') {
  16189. x = start.x + width / 2;
  16190. y = zeroY.y < start.y ? zeroY.y : start.y;
  16191. } else if (type === 'x') {
  16192. x = zeroY.x > start.x ? zeroY.x : start.x;
  16193. y = start.y + height / 2;
  16194. } else if (type === 'xy') {
  16195. if (coord.isPolar) {
  16196. x = coord.center.x;
  16197. y = coord.center.y;
  16198. } else {
  16199. x = (start.x + end.x) / 2;
  16200. y = (start.y + end.y) / 2;
  16201. }
  16202. }
  16203. var endMatrix = Util.getScaledMatrix(clip, [x, y], type);
  16204. clip.isClip = true;
  16205. clip.endState = {
  16206. matrix: endMatrix
  16207. };
  16208. clip.set('canvas', container.get('canvas'));
  16209. container.attr('clip', clip);
  16210. var onEnd = function onEnd() {
  16211. container.attr('clip', null);
  16212. clip.remove(true);
  16213. };
  16214. Util.doAnimation(clip, clip.endState, animateCfg, onEnd);
  16215. }
  16216. function _shapeScale(container, animateCfg, type) {
  16217. var shapes = container.get('children');
  16218. var x;
  16219. var y;
  16220. var endMatrix;
  16221. for (var i = 0, len = shapes.length; i < len; i++) {
  16222. var shape = shapes[i];
  16223. var box = shape.getBBox();
  16224. x = (box.minX + box.maxX) / 2;
  16225. y = (box.minY + box.maxY) / 2;
  16226. endMatrix = Util.getScaledMatrix(shape, [x, y], type);
  16227. Util.doAnimation(shape, {
  16228. matrix: endMatrix
  16229. }, animateCfg);
  16230. }
  16231. }
  16232. function groupScaleInX(container, animateCfg, coord, zeroY) {
  16233. _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
  16234. }
  16235. function groupScaleInY(container, animateCfg, coord, zeroY) {
  16236. _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
  16237. }
  16238. function groupScaleInXY(container, animateCfg, coord, zeroY) {
  16239. _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
  16240. }
  16241. function shapesScaleInX(container, animateCfg) {
  16242. _shapeScale(container, animateCfg, 'x');
  16243. }
  16244. function shapesScaleInY(container, animateCfg) {
  16245. _shapeScale(container, animateCfg, 'y');
  16246. }
  16247. function shapesScaleInXY(container, animateCfg) {
  16248. _shapeScale(container, animateCfg, 'xy');
  16249. }
  16250. function groupWaveIn(container, animateCfg, coord) {
  16251. var clip = Helper.getClip(coord);
  16252. clip.set('canvas', container.get('canvas'));
  16253. container.attr('clip', clip);
  16254. var onEnd = function onEnd() {
  16255. container.attr('clip', null);
  16256. clip.remove(true);
  16257. };
  16258. var endState = {};
  16259. if (coord.isPolar) {
  16260. var startAngle = coord.startAngle,
  16261. endAngle = coord.endAngle;
  16262. endState.endAngle = endAngle;
  16263. clip.attr('endAngle', startAngle);
  16264. } else {
  16265. var start = coord.start,
  16266. end = coord.end;
  16267. var width = Math.abs(start.x - end.x);
  16268. var height = Math.abs(start.y - end.y);
  16269. if (coord.isTransposed) {
  16270. clip.attr('height', 0);
  16271. endState.height = height;
  16272. } else {
  16273. clip.attr('width', 0);
  16274. endState.width = width;
  16275. }
  16276. }
  16277. Util.doAnimation(clip, endState, animateCfg, onEnd);
  16278. }
  16279. module.exports = {
  16280. groupWaveIn: groupWaveIn,
  16281. groupScaleInX: groupScaleInX,
  16282. groupScaleInY: groupScaleInY,
  16283. groupScaleInXY: groupScaleInXY,
  16284. shapesScaleInX: shapesScaleInX,
  16285. shapesScaleInY: shapesScaleInY,
  16286. shapesScaleInXY: shapesScaleInXY
  16287. };
  16288. /***/ }),
  16289. /* 241 */
  16290. /***/ (function(module, exports, __webpack_require__) {
  16291. "use strict";
  16292. exports.__esModule = true;
  16293. exports["default"] = void 0;
  16294. var _common = __webpack_require__(0);
  16295. var Chart = __webpack_require__(30);
  16296. Chart._Interactions = {};
  16297. Chart.registerInteraction = function (type, constructor) {
  16298. Chart._Interactions[type] = constructor;
  16299. };
  16300. Chart.getInteraction = function (type) {
  16301. return Chart._Interactions[type];
  16302. };
  16303. Chart.prototype.interaction = function (type, cfg) {
  16304. var interactions = this._interactions || {};
  16305. if (interactions[type]) {
  16306. // if reprated, destroy last
  16307. interactions[type].destroy();
  16308. }
  16309. var Ctor = Chart.getInteraction(type);
  16310. var interact = new Ctor(cfg, this);
  16311. interactions[type] = interact;
  16312. this._interactions = interactions;
  16313. return this;
  16314. };
  16315. Chart.prototype.clearInteraction = function (type) {
  16316. var interactions = this._interactions;
  16317. if (!interactions) return;
  16318. if (type) {
  16319. interactions[type] && interactions[type].destroy();
  16320. delete interactions[type];
  16321. } else {
  16322. (0, _common.each)(interactions, function (interaction, key) {
  16323. interaction.destroy();
  16324. delete interactions[key];
  16325. });
  16326. }
  16327. return this;
  16328. };
  16329. var _default = Chart;
  16330. exports["default"] = _default;
  16331. /***/ }),
  16332. /* 242 */
  16333. /***/ (function(module, exports, __webpack_require__) {
  16334. "use strict";
  16335. /**
  16336. * filter the data out of scale' range
  16337. */
  16338. var Util = __webpack_require__(0);
  16339. var TimeUtil = __webpack_require__(204);
  16340. module.exports = {
  16341. beforeGeomInit: function beforeGeomInit(chart) {
  16342. chart.set('limitInPlot', true);
  16343. var data = chart.get('filteredData');
  16344. var colDefs = chart.get('colDefs');
  16345. if (!colDefs) return data;
  16346. var geoms = chart.get('geoms');
  16347. var isSpecialGeom = false; // TODO
  16348. Util.each(geoms, function (geom) {
  16349. if (['area', 'line', 'path'].indexOf(geom.get('type')) !== -1) {
  16350. isSpecialGeom = true;
  16351. return false;
  16352. }
  16353. });
  16354. var fields = [];
  16355. Util.each(colDefs, function (def, key) {
  16356. if (!isSpecialGeom && def && (def.values || def.min || def.max)) {
  16357. fields.push(key);
  16358. }
  16359. });
  16360. if (fields.length === 0) {
  16361. return data;
  16362. }
  16363. var geomData = [];
  16364. Util.each(data, function (obj) {
  16365. var flag = true;
  16366. Util.each(fields, function (field) {
  16367. var value = obj[field];
  16368. if (value) {
  16369. var colDef = colDefs[field];
  16370. if (colDef.type === 'timeCat') {
  16371. var values = colDef.values;
  16372. if (Util.isNumber(values[0])) {
  16373. value = TimeUtil.toTimeStamp(value);
  16374. }
  16375. }
  16376. if (colDef.values && colDef.values.indexOf(value) === -1 || colDef.min && value < colDef.min || colDef.max && value > colDef.max) {
  16377. flag = false;
  16378. }
  16379. }
  16380. });
  16381. if (flag) {
  16382. geomData.push(obj);
  16383. }
  16384. });
  16385. chart.set('filteredData', geomData);
  16386. }
  16387. };
  16388. /***/ }),
  16389. /* 243 */
  16390. /***/ (function(module, exports, __webpack_require__) {
  16391. "use strict";
  16392. var Helper = __webpack_require__(208);
  16393. var Util = __webpack_require__(0);
  16394. module.exports = {
  16395. updateLinearScale: function updateLinearScale(field, min, max) {
  16396. var chart = this.chart;
  16397. var scale = Helper.getScale(chart, field); // const colDef = Helper.getColDef(chart, field);
  16398. // chart.scale(field, Util.mix({}, colDef, {
  16399. // min,
  16400. // max,
  16401. // nice: false
  16402. // }));
  16403. scale.change({
  16404. min: min,
  16405. max: max,
  16406. nice: false
  16407. });
  16408. },
  16409. updateCatScale: function updateCatScale(field, newValues, ticks, values, minIndex, maxIndex) {
  16410. var chart = this.chart; // const colDef = Helper.getColDef(chart, field);
  16411. var scale = Helper.getScale(chart, field);
  16412. scale.change({
  16413. values: newValues,
  16414. ticks: ticks,
  16415. scale: function scale(value) {
  16416. if (this.type === 'timeCat') {
  16417. value = this._toTimeStamp(value);
  16418. }
  16419. var rangeMin = this.rangeMin();
  16420. var rangeMax = this.rangeMax();
  16421. var range = rangeMax - rangeMin;
  16422. var min;
  16423. var max;
  16424. var percent;
  16425. var currentIndex = values.indexOf(value); // 在完整数据集中的索引值
  16426. if (currentIndex >= 0 && currentIndex < minIndex) {
  16427. // 不在范围内,左侧数据
  16428. max = rangeMin > 0 ? -0.1 : rangeMin - 0.1;
  16429. min = max - range;
  16430. percent = currentIndex / minIndex;
  16431. } else if (currentIndex >= 0 && currentIndex > maxIndex) {
  16432. // 不在范围内,右侧数据
  16433. min = rangeMax < 1 ? 1.1 : rangeMax + 0.1;
  16434. max = min + range;
  16435. percent = (currentIndex - maxIndex - 1) / (values.length - 1 - maxIndex);
  16436. } else {
  16437. // 数值在当前 this.values 范围内
  16438. var index = this.translate(value);
  16439. if (this.values.length === 1) {
  16440. percent = index;
  16441. } else {
  16442. percent = index / (this.values.length - 1);
  16443. }
  16444. min = rangeMin;
  16445. max = rangeMax;
  16446. }
  16447. return min + percent * (max - min);
  16448. },
  16449. getTicks: function getTicks() {
  16450. var self = this;
  16451. var ticks = this.ticks;
  16452. var rst = [];
  16453. Util.each(ticks, function (tick) {
  16454. var obj;
  16455. if (Util.isObject(tick)) {
  16456. obj = tick;
  16457. } else {
  16458. var value = self.scale(tick);
  16459. value = value >= 0 && value <= 1 ? value : NaN;
  16460. obj = {
  16461. text: Util.isString(tick) ? tick : self.getText(tick),
  16462. value: value,
  16463. tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
  16464. };
  16465. }
  16466. rst.push(obj);
  16467. });
  16468. return rst;
  16469. }
  16470. });
  16471. }
  16472. };
  16473. /***/ }),
  16474. /* 244 */,
  16475. /* 245 */
  16476. /***/ (function(module, exports, __webpack_require__) {
  16477. "use strict";
  16478. var Util = __webpack_require__(0);
  16479. var Helper = __webpack_require__(208);
  16480. var TOUCH_EVENTS = ['touchstart', 'touchmove', 'touchend', 'touchStart', 'touchMove', 'touchEnd'];
  16481. var DAY_TIMESTAMPS = 86400000;
  16482. module.exports = {
  16483. _handleMove: function _handleMove(e) {
  16484. if (e.type === 'swipe' && e.deltaTime > 350) {
  16485. // 区分 pan 操作和 swipe 操作
  16486. return null;
  16487. }
  16488. var currentDeltaX = this.currentDeltaX,
  16489. currentDeltaY = this.currentDeltaY,
  16490. lastPoint = this.lastPoint;
  16491. var deltaX;
  16492. var deltaY;
  16493. if (TOUCH_EVENTS.indexOf(e.type) !== -1) {
  16494. // support touch and miniprogram
  16495. var currentPoint = e.touches[0];
  16496. deltaX = currentPoint.x - lastPoint.x;
  16497. deltaY = currentPoint.y - lastPoint.y;
  16498. this.lastPoint = currentPoint;
  16499. } else if (currentDeltaX !== null && currentDeltaY !== null) {
  16500. deltaX = e.deltaX - currentDeltaX;
  16501. deltaY = e.deltaY - currentDeltaY;
  16502. this.currentDeltaX = e.deltaX;
  16503. this.currentDeltaY = e.deltaY;
  16504. }
  16505. if (Math.abs(deltaX) > 0 || Math.abs(deltaY) > 0) {
  16506. var lastTimestamp = this._timestamp;
  16507. var now = +new Date();
  16508. if (now - lastTimestamp > 16) {
  16509. this._doMove(deltaX, deltaY);
  16510. this._timestamp = now;
  16511. }
  16512. }
  16513. },
  16514. _doMove: function _doMove(deltaX, deltaY) {
  16515. var self = this;
  16516. var mode = self.mode,
  16517. chart = self.chart,
  16518. limitRange = self.limitRange;
  16519. var coord = chart.get('coord');
  16520. var start = coord.start,
  16521. end = coord.end;
  16522. var data = chart.get('data');
  16523. if (Util.directionEnabled(mode, 'x') && deltaX !== 0) {
  16524. var xScale = chart.getXScale();
  16525. var xField = xScale.field;
  16526. if (!limitRange[xField]) {
  16527. limitRange[xField] = Helper.getLimitRange(data, xScale);
  16528. }
  16529. var coordWidth = end.x - start.x;
  16530. if (xScale.isCategory) {
  16531. self._handleCatScale(xScale, deltaX, coordWidth);
  16532. } else if (xScale.isLinear) {
  16533. self._handleLinearScale(xScale, deltaX, coordWidth, 'x');
  16534. }
  16535. self.xRange = Helper.getFieldRange(xScale, limitRange[xField], xScale.type);
  16536. }
  16537. if (Util.directionEnabled(mode, 'y') && deltaY !== 0) {
  16538. var coordHeight = start.y - end.y;
  16539. var yScales = chart.getYScales();
  16540. Util.each(yScales, function (yScale) {
  16541. var yField = yScale.field;
  16542. if (!limitRange[yField]) {
  16543. limitRange[yField] = Helper.getLimitRange(data, yScale);
  16544. }
  16545. yScale.isLinear && self._handleLinearScale(yScale, deltaY, coordHeight, 'y');
  16546. });
  16547. var scale = yScales[0];
  16548. self.yRange = Helper.getFieldRange(scale, limitRange[scale.field], scale.type);
  16549. }
  16550. chart.repaint();
  16551. },
  16552. _handleLinearScale: function _handleLinearScale(scale, delta, range, flag) {
  16553. var field = scale.field,
  16554. min = scale.min,
  16555. max = scale.max;
  16556. var limitRange = this.limitRange;
  16557. if (min === limitRange[field].min && max === limitRange[field].max) return;
  16558. var ratio = delta / range;
  16559. var panValue = ratio * (max - min);
  16560. var newMax = flag === 'x' ? max - panValue : max + panValue;
  16561. var newMin = flag === 'x' ? min - panValue : min + panValue;
  16562. if (limitRange[field] && !Util.isNil(limitRange[field].min) && newMin <= limitRange[field].min) {
  16563. newMin = limitRange[field].min;
  16564. newMax = max - min + newMin;
  16565. }
  16566. if (limitRange[field] && !Util.isNil(limitRange[field].max) && newMax >= limitRange[field].max) {
  16567. newMax = limitRange[field].max;
  16568. newMin = newMax - (max - min);
  16569. }
  16570. this.updateLinearScale(field, newMin, newMax);
  16571. },
  16572. _handleCatScale: function _handleCatScale(scale, delta, range) {
  16573. var type = scale.type,
  16574. field = scale.field,
  16575. values = scale.values,
  16576. ticks = scale.ticks;
  16577. var duplicateRemovalValues = Util.uniq(values);
  16578. var originValues = this.limitRange[field];
  16579. var lastValueIndex = originValues.length - 1;
  16580. var currentLength = duplicateRemovalValues.length;
  16581. var speed = this.speed || 1;
  16582. var step = range / (currentLength * speed);
  16583. var firstIndex = originValues.indexOf(duplicateRemovalValues[0]);
  16584. var lastIndex = originValues.indexOf(duplicateRemovalValues[currentLength - 1]);
  16585. var minIndex = firstIndex;
  16586. var maxIndex = lastIndex;
  16587. var ratio = Math.abs(delta / range);
  16588. var panStep = this.step || Math.max(1, parseInt(ratio * currentLength));
  16589. this._panCumulativeDelta += delta;
  16590. minIndex = this._panCumulativeDelta > step ? Math.max(0, minIndex - panStep) : this._panCumulativeDelta < -step ? Math.min(lastValueIndex - currentLength + 1, minIndex + panStep) : minIndex;
  16591. maxIndex = Math.min(lastValueIndex, minIndex + currentLength - 1);
  16592. if (minIndex === firstIndex && maxIndex === lastIndex) {
  16593. return null;
  16594. }
  16595. var newValues = originValues.slice(minIndex, maxIndex + 1);
  16596. var newTicks = null;
  16597. if (type === 'timeCat') {
  16598. var tickGap = ticks.length > 2 ? ticks[1] - ticks[0] : DAY_TIMESTAMPS;
  16599. if (this._panCumulativeDelta > step) {
  16600. for (var i = ticks[0] - tickGap; i >= newValues[0]; i -= tickGap) {
  16601. ticks.unshift(i);
  16602. }
  16603. } else if (this._panCumulativeDelta < -step) {
  16604. for (var _i = ticks[ticks.length - 1] + tickGap; _i <= newValues[newValues.length - 1]; _i += tickGap) {
  16605. ticks.push(_i);
  16606. }
  16607. }
  16608. newTicks = ticks;
  16609. } else {
  16610. // 保留之前的ticks
  16611. newTicks = ticks;
  16612. }
  16613. this.updateCatScale(field, newValues, newTicks, originValues, minIndex, maxIndex);
  16614. this._panCumulativeDelta = minIndex !== firstIndex ? 0 : this._panCumulativeDelta;
  16615. }
  16616. };
  16617. /***/ }),
  16618. /* 246 */,
  16619. /* 247 */,
  16620. /* 248 */,
  16621. /* 249 */,
  16622. /* 250 */,
  16623. /* 251 */,
  16624. /* 252 */
  16625. /***/ (function(module, exports, __webpack_require__) {
  16626. "use strict";
  16627. /**
  16628. * all
  16629. */
  16630. var F2 = __webpack_require__(77);
  16631. __webpack_require__(209);
  16632. __webpack_require__(193);
  16633. __webpack_require__(203); // polar coordinate
  16634. __webpack_require__(218); // the axis for polar coordinate
  16635. __webpack_require__(219); // timeCat scale
  16636. __webpack_require__(253); // guide components
  16637. var Tooltip = __webpack_require__(230);
  16638. var Guide = __webpack_require__(233);
  16639. var Legend = __webpack_require__(234);
  16640. var Animation = __webpack_require__(235);
  16641. var ScrollBar = __webpack_require__(255);
  16642. var PieLabel = __webpack_require__(256);
  16643. var intervalLabel = __webpack_require__(257);
  16644. F2.Animate = __webpack_require__(206); // register plugins
  16645. F2.Chart.plugins.register([Tooltip, Legend, Guide, Animation, ScrollBar, PieLabel, intervalLabel]); // add interaction
  16646. __webpack_require__(258);
  16647. F2.Interaction = __webpack_require__(74);
  16648. module.exports = F2;
  16649. /***/ }),
  16650. /* 253 */
  16651. /***/ (function(module, exports, __webpack_require__) {
  16652. "use strict";
  16653. module.exports = {
  16654. Text: __webpack_require__(227),
  16655. Line: __webpack_require__(225),
  16656. Arc: __webpack_require__(223),
  16657. Rect: __webpack_require__(226),
  16658. Html: __webpack_require__(224),
  16659. Tag: __webpack_require__(228),
  16660. Point: __webpack_require__(229),
  16661. RegionFilter: __webpack_require__(254)
  16662. };
  16663. /***/ }),
  16664. /* 254 */
  16665. /***/ (function(module, exports, __webpack_require__) {
  16666. "use strict";
  16667. var _interopRequireDefault = __webpack_require__(1);
  16668. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  16669. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  16670. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  16671. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  16672. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  16673. var Util = __webpack_require__(0);
  16674. var GuideBase = __webpack_require__(23);
  16675. var _require = __webpack_require__(10),
  16676. Rect = _require.Rect;
  16677. var RegionFilter = /*#__PURE__*/function (_GuideBase) {
  16678. (0, _inheritsLoose2["default"])(RegionFilter, _GuideBase);
  16679. var _super = _createSuper(RegionFilter);
  16680. function RegionFilter() {
  16681. return _GuideBase.apply(this, arguments) || this;
  16682. }
  16683. var _proto = RegionFilter.prototype;
  16684. _proto._initDefaultCfg = function _initDefaultCfg() {
  16685. this.type = 'regionFilter';
  16686. this.start = [];
  16687. this.end = [];
  16688. this.color = null;
  16689. this.style = null;
  16690. };
  16691. _proto.render = function render(coord) {
  16692. var start = this.parsePoint(coord, this.start);
  16693. var end = this.parsePoint(coord, this.end);
  16694. if (!start || !end) {
  16695. return;
  16696. }
  16697. var clip = new Rect({
  16698. attrs: {
  16699. x: Math.min(start.x, end.x),
  16700. y: Math.min(start.y, end.y),
  16701. width: Math.abs(end.x - start.x),
  16702. height: Math.abs(end.y - start.y)
  16703. }
  16704. }); // 新建剪切区域
  16705. this.clip = clip;
  16706. var chart = this.chart;
  16707. var color = this.color;
  16708. var style = this.style || {};
  16709. var regionElements = [];
  16710. var geoms = chart.get('geoms');
  16711. geoms.map(function (geom) {
  16712. var geomContainer = geom.get('container');
  16713. var children = geomContainer.get('children');
  16714. var group = geomContainer.addGroup({
  16715. zIndex: 10,
  16716. className: 'guide-region-filter'
  16717. });
  16718. children.map(function (c) {
  16719. if (c.get('isShape')) {
  16720. var type = c.get('type');
  16721. var attrs = Util.mix({}, c.get('attrs'), style);
  16722. if (color && (attrs.fill || attrs.fillStyle)) {
  16723. attrs.fill = attrs.fillStyle = color;
  16724. }
  16725. if (color && (attrs.stroke || attrs.strokeStyle)) {
  16726. attrs.stroke = attrs.strokeStyle = color;
  16727. }
  16728. var cfg = {
  16729. attrs: attrs
  16730. };
  16731. if (type === 'custom' || type === 'Custom') {
  16732. // custom 类型的 shape 会自定义绘制 path 的逻辑
  16733. cfg.createPath = c.get('createPath');
  16734. cfg.calculateBox = c.get('calculateBox');
  16735. }
  16736. group.addShape(type, cfg);
  16737. }
  16738. return c;
  16739. });
  16740. group.attr('clip', clip);
  16741. geomContainer.sort();
  16742. regionElements.push(group);
  16743. return geom;
  16744. });
  16745. this.element = regionElements;
  16746. };
  16747. _proto.remove = function remove() {
  16748. var element = this.element;
  16749. Util.each(element, function (group) {
  16750. group && group.remove(true);
  16751. });
  16752. this.clip && this.clip.remove(true);
  16753. };
  16754. return RegionFilter;
  16755. }(GuideBase);
  16756. GuideBase.RegionFilter = RegionFilter;
  16757. module.exports = RegionFilter;
  16758. /***/ }),
  16759. /* 255 */
  16760. /***/ (function(module, exports, __webpack_require__) {
  16761. "use strict";
  16762. var Helper = __webpack_require__(208);
  16763. var Util = __webpack_require__(0);
  16764. var DEFAULT_CFG = {
  16765. mode: 'x',
  16766. xStyle: {
  16767. backgroundColor: 'rgba(202, 215, 239, .2)',
  16768. fillerColor: 'rgba(202, 215, 239, .5)',
  16769. size: 4,
  16770. lineCap: 'round',
  16771. offsetX: 0,
  16772. offsetY: 8
  16773. },
  16774. yStyle: {
  16775. backgroundColor: 'rgba(202, 215, 239, .2)',
  16776. fillerColor: 'rgba(202, 215, 239, .5)',
  16777. size: 4,
  16778. lineCap: 'round',
  16779. offsetX: 8,
  16780. offsetY: 0
  16781. }
  16782. };
  16783. module.exports = {
  16784. init: function init(chart) {
  16785. chart.set('_limitRange', {});
  16786. chart.scrollBar = function (cfg) {
  16787. if (cfg === true) {
  16788. cfg = DEFAULT_CFG;
  16789. } else if (Util.isObject(cfg)) {
  16790. cfg = Util.deepMix({}, DEFAULT_CFG, cfg);
  16791. }
  16792. this.set('_scrollBarCfg', cfg);
  16793. };
  16794. },
  16795. clear: function clear(chart) {
  16796. chart.set('_limitRange', {});
  16797. },
  16798. changeData: function changeData(chart) {
  16799. chart.set('_limitRange', {});
  16800. },
  16801. clearInner: function clearInner(chart) {
  16802. var hBar = chart.get('_horizontalBar');
  16803. var vBar = chart.get('_verticalBar');
  16804. hBar && hBar.remove(true);
  16805. vBar && vBar.remove(true);
  16806. chart.set('_horizontalBar', null);
  16807. chart.set('_verticalBar', null);
  16808. },
  16809. afterGeomDraw: function afterGeomDraw(chart) {
  16810. var scrollBarCfg = chart.get('_scrollBarCfg');
  16811. if (!scrollBarCfg) return;
  16812. var data = chart.get('data');
  16813. var plotRange = chart.get('plotRange');
  16814. var backPlot = chart.get('backPlot');
  16815. var canvas = chart.get('canvas');
  16816. var canvasHeight = canvas.get('height');
  16817. var limitRange = chart.get('_limitRange');
  16818. var mode = scrollBarCfg.mode;
  16819. if (Util.directionEnabled(mode, 'x')) {
  16820. var _scrollBarCfg$xStyle = scrollBarCfg.xStyle,
  16821. offsetX = _scrollBarCfg$xStyle.offsetX,
  16822. offsetY = _scrollBarCfg$xStyle.offsetY,
  16823. lineCap = _scrollBarCfg$xStyle.lineCap,
  16824. backgroundColor = _scrollBarCfg$xStyle.backgroundColor,
  16825. fillerColor = _scrollBarCfg$xStyle.fillerColor,
  16826. size = _scrollBarCfg$xStyle.size;
  16827. var xScale = chart.getXScale();
  16828. var xLimitRange = limitRange[xScale.field];
  16829. if (!xLimitRange) {
  16830. xLimitRange = Helper.getLimitRange(data, xScale);
  16831. limitRange[xScale.field] = xLimitRange;
  16832. }
  16833. var currentRange = Helper.getFieldRange(xScale, xLimitRange, xScale.type);
  16834. var horizontalBar = chart.get('_horizontalBar');
  16835. var yPos = canvasHeight - size / 2 + offsetY;
  16836. if (horizontalBar) {
  16837. var progressLine = horizontalBar.get('children')[1];
  16838. progressLine.attr({
  16839. x1: Math.max(plotRange.bl.x + plotRange.width * currentRange[0] + offsetX, plotRange.bl.x),
  16840. x2: Math.min(plotRange.bl.x + plotRange.width * currentRange[1] + offsetX, plotRange.br.x)
  16841. });
  16842. } else {
  16843. horizontalBar = backPlot.addGroup({
  16844. className: 'horizontalBar'
  16845. });
  16846. horizontalBar.addShape('line', {
  16847. attrs: {
  16848. x1: plotRange.bl.x + offsetX,
  16849. y1: yPos,
  16850. x2: plotRange.br.x + offsetX,
  16851. y2: yPos,
  16852. lineWidth: size,
  16853. stroke: backgroundColor,
  16854. lineCap: lineCap
  16855. }
  16856. });
  16857. horizontalBar.addShape('line', {
  16858. attrs: {
  16859. x1: Math.max(plotRange.bl.x + plotRange.width * currentRange[0] + offsetX, plotRange.bl.x),
  16860. y1: yPos,
  16861. x2: Math.min(plotRange.bl.x + plotRange.width * currentRange[1] + offsetX, plotRange.br.x),
  16862. y2: yPos,
  16863. lineWidth: size,
  16864. stroke: fillerColor,
  16865. lineCap: lineCap
  16866. }
  16867. });
  16868. chart.set('_horizontalBar', horizontalBar);
  16869. }
  16870. }
  16871. if (Util.directionEnabled(mode, 'y')) {
  16872. var _scrollBarCfg$yStyle = scrollBarCfg.yStyle,
  16873. _offsetX = _scrollBarCfg$yStyle.offsetX,
  16874. _offsetY = _scrollBarCfg$yStyle.offsetY,
  16875. _lineCap = _scrollBarCfg$yStyle.lineCap,
  16876. _backgroundColor = _scrollBarCfg$yStyle.backgroundColor,
  16877. _fillerColor = _scrollBarCfg$yStyle.fillerColor,
  16878. _size = _scrollBarCfg$yStyle.size;
  16879. var yScale = chart.getYScales()[0];
  16880. var yLimitRange = limitRange[yScale.field];
  16881. if (!yLimitRange) {
  16882. yLimitRange = Helper.getLimitRange(data, yScale);
  16883. limitRange[yScale.field] = yLimitRange;
  16884. }
  16885. var _currentRange = Helper.getFieldRange(yScale, yLimitRange, yScale.type);
  16886. var verticalBar = chart.get('_verticalBar');
  16887. var xPos = _size / 2 + _offsetX;
  16888. if (verticalBar) {
  16889. var _progressLine = verticalBar.get('children')[1];
  16890. _progressLine.attr({
  16891. y1: Math.max(plotRange.tl.y + plotRange.height * _currentRange[0] + _offsetY, plotRange.tl.y),
  16892. y2: Math.min(plotRange.tl.y + plotRange.height * _currentRange[1] + _offsetY, plotRange.bl.y)
  16893. });
  16894. } else {
  16895. verticalBar = backPlot.addGroup({
  16896. className: 'verticalBar'
  16897. });
  16898. verticalBar.addShape('line', {
  16899. attrs: {
  16900. x1: xPos,
  16901. y1: plotRange.tl.y + _offsetY,
  16902. x2: xPos,
  16903. y2: plotRange.bl.y + _offsetY,
  16904. lineWidth: _size,
  16905. stroke: _backgroundColor,
  16906. lineCap: _lineCap
  16907. }
  16908. });
  16909. verticalBar.addShape('line', {
  16910. attrs: {
  16911. x1: xPos,
  16912. y1: Math.max(plotRange.tl.y + plotRange.height * _currentRange[0] + _offsetY, plotRange.tl.y),
  16913. x2: xPos,
  16914. y2: Math.min(plotRange.tl.y + plotRange.height * _currentRange[1] + _offsetY, plotRange.bl.y),
  16915. lineWidth: _size,
  16916. stroke: _fillerColor,
  16917. lineCap: _lineCap
  16918. }
  16919. });
  16920. chart.set('_verticalBar', verticalBar);
  16921. }
  16922. }
  16923. }
  16924. };
  16925. /***/ }),
  16926. /* 256 */
  16927. /***/ (function(module, exports, __webpack_require__) {
  16928. "use strict";
  16929. var Util = __webpack_require__(0);
  16930. var _require = __webpack_require__(16),
  16931. Group = _require.Group;
  16932. var DEFAULT_CFG = {
  16933. anchorOffset: 5,
  16934. // 锚点的偏移量
  16935. inflectionOffset: 15,
  16936. // 拐点的偏移量
  16937. sidePadding: 20,
  16938. // 文本距离画布四边的距离
  16939. lineHeight: 32,
  16940. // 文本的行高
  16941. adjustOffset: 15,
  16942. // 发生调整时的偏移量
  16943. skipOverlapLabels: false,
  16944. // 是否不展示重叠的文本
  16945. triggerOn: 'touchstart',
  16946. // 点击行为触发的时间类型
  16947. activeShape: false,
  16948. // 当有图形被选中的时候,是否激活图形
  16949. activeStyle: {
  16950. offset: 1,
  16951. appendRadius: 8,
  16952. fillOpacity: 0.5
  16953. },
  16954. label1OffsetY: -1,
  16955. label2OffsetY: 1
  16956. };
  16957. function getEndPoint(center, angle, r) {
  16958. return {
  16959. x: center.x + r * Math.cos(angle),
  16960. y: center.y + r * Math.sin(angle)
  16961. };
  16962. } // 计算中间角度
  16963. function getMiddleAngle(startAngle, endAngle) {
  16964. if (endAngle < startAngle) {
  16965. endAngle += Math.PI * 2;
  16966. }
  16967. return (endAngle + startAngle) / 2;
  16968. } // 判断两个矩形是否相交
  16969. function isOverlap(label1, label2) {
  16970. var label1BBox = label1.getBBox();
  16971. var label2BBox = label2.getBBox();
  16972. return Math.max(label1BBox.minX, label2BBox.minX) <= Math.min(label1BBox.maxX, label2BBox.minX) && Math.max(label1BBox.minY, label2BBox.minY) <= Math.min(label1BBox.maxY, label2BBox.maxY);
  16973. }
  16974. var controller = /*#__PURE__*/function () {
  16975. function controller(cfg) {
  16976. var _this = this;
  16977. this._handleEvent = function (ev) {
  16978. var self = _this;
  16979. var chart = self.chart,
  16980. drawnLabels = self.drawnLabels,
  16981. pieLabelCfg = self.pieLabelCfg;
  16982. var onClick = pieLabelCfg.onClick,
  16983. activeShape = pieLabelCfg.activeShape;
  16984. var canvasEvent = Util.createEvent(ev, chart);
  16985. var x = canvasEvent.x,
  16986. y = canvasEvent.y; // 查找被点击的 label
  16987. var clickedShape;
  16988. for (var i = 0, len = drawnLabels.length; i < len; i++) {
  16989. var shape = drawnLabels[i];
  16990. var bbox = shape.getBBox(); // 通过最小包围盒来判断击中情况
  16991. if (x >= bbox.minX && x <= bbox.maxX && y >= bbox.minY && y <= bbox.maxY) {
  16992. clickedShape = shape;
  16993. break;
  16994. }
  16995. }
  16996. var pieData = chart.getSnapRecords({
  16997. x: x,
  16998. y: y
  16999. });
  17000. if (clickedShape) {
  17001. canvasEvent.data = clickedShape.get('data');
  17002. } else if (pieData.length) {
  17003. // 击中饼图扇形区域
  17004. canvasEvent.data = pieData[0]._origin;
  17005. }
  17006. onClick && onClick(canvasEvent);
  17007. canvasEvent.data && activeShape && _this._activeShape(canvasEvent.data);
  17008. };
  17009. Util.mix(this, cfg);
  17010. var _chart = this.chart;
  17011. this.canvasDom = _chart.get('canvas').get('el');
  17012. }
  17013. var _proto = controller.prototype;
  17014. _proto.renderLabels = function renderLabels() {
  17015. var self = this;
  17016. var chart = self.chart,
  17017. pieLabelCfg = self.pieLabelCfg,
  17018. labelGroup = self.labelGroup;
  17019. var halves = [[], // left
  17020. [] // right
  17021. ]; // 存储左右 labels
  17022. var geom = chart.get('geoms')[0];
  17023. var shapes = geom.get('container').get('children');
  17024. var anchorOffset = pieLabelCfg.anchorOffset,
  17025. inflectionOffset = pieLabelCfg.inflectionOffset,
  17026. label1 = pieLabelCfg.label1,
  17027. label2 = pieLabelCfg.label2,
  17028. lineHeight = pieLabelCfg.lineHeight,
  17029. skipOverlapLabels = pieLabelCfg.skipOverlapLabels,
  17030. label1OffsetY = pieLabelCfg.label1OffsetY,
  17031. label2OffsetY = pieLabelCfg.label2OffsetY;
  17032. var coord = chart.get('coord');
  17033. var center = coord.center,
  17034. radius = coord.circleRadius;
  17035. shapes.forEach(function (shape) {
  17036. var _shape$_attrs$attrs = shape._attrs.attrs,
  17037. startAngle = _shape$_attrs$attrs.startAngle,
  17038. endAngle = _shape$_attrs$attrs.endAngle;
  17039. var middleAngle = getMiddleAngle(startAngle, endAngle);
  17040. var anchorPoint = getEndPoint(center, middleAngle, radius + anchorOffset);
  17041. var inflectionPoint = getEndPoint(center, middleAngle, radius + inflectionOffset);
  17042. var origin = shape.get('origin');
  17043. var _origin = origin._origin,
  17044. color = origin.color;
  17045. var label = {
  17046. _anchor: anchorPoint,
  17047. _inflection: inflectionPoint,
  17048. _data: _origin,
  17049. x: inflectionPoint.x,
  17050. y: inflectionPoint.y,
  17051. r: radius + inflectionOffset,
  17052. fill: color
  17053. };
  17054. var textGroup = new Group({
  17055. context: chart.get('canvas').get('context'),
  17056. // 兼容 node、小程序环境
  17057. data: _origin // 存储原始数据
  17058. });
  17059. var textAttrs = {
  17060. x: 0,
  17061. y: 0,
  17062. fontSize: 12,
  17063. lineHeight: 12,
  17064. fill: '#808080'
  17065. };
  17066. if (Util.isFunction(label1)) {
  17067. textGroup.addShape('Text', {
  17068. attrs: Util.mix({
  17069. textBaseline: 'bottom'
  17070. }, textAttrs, label1(_origin, color)),
  17071. data: _origin,
  17072. // 存储原始数据
  17073. offsetY: label1OffsetY
  17074. });
  17075. }
  17076. if (Util.isFunction(label2)) {
  17077. textGroup.addShape('Text', {
  17078. attrs: Util.mix({
  17079. textBaseline: 'top'
  17080. }, textAttrs, label2(_origin, color)),
  17081. data: _origin,
  17082. // 存储原始数据
  17083. offsetY: label2OffsetY
  17084. });
  17085. }
  17086. label.textGroup = textGroup; // 判断文本的方向
  17087. if (anchorPoint.x < center.x) {
  17088. label._side = 'left';
  17089. halves[0].push(label);
  17090. } else {
  17091. label._side = 'right';
  17092. halves[1].push(label);
  17093. }
  17094. });
  17095. var drawnLabels = [];
  17096. if (skipOverlapLabels) {
  17097. var lastLabel; // 存储上一个 label 对象,用于检测文本是否重叠
  17098. var labels = halves[1].concat(halves[0]); // 顺时针
  17099. for (var i = 0, len = labels.length; i < len; i++) {
  17100. var label = labels[i];
  17101. var textGroup = self._drawLabel(label);
  17102. if (lastLabel) {
  17103. if (isOverlap(textGroup, lastLabel)) {
  17104. // 重叠了就不绘制
  17105. continue;
  17106. }
  17107. }
  17108. labelGroup.add(textGroup);
  17109. self._drawLabelLine(label);
  17110. lastLabel = textGroup;
  17111. drawnLabels.push(textGroup);
  17112. }
  17113. } else {
  17114. var height = chart.get('height');
  17115. var maxCountForOneSide = parseInt(height / lineHeight, 10);
  17116. halves.forEach(function (half) {
  17117. if (half.length > maxCountForOneSide) {
  17118. half.splice(maxCountForOneSide, half.length - maxCountForOneSide);
  17119. }
  17120. half.sort(function (a, b) {
  17121. return a.y - b.y;
  17122. });
  17123. var labels = self._antiCollision(half);
  17124. drawnLabels = drawnLabels.concat(labels);
  17125. });
  17126. }
  17127. this.drawnLabels = drawnLabels;
  17128. };
  17129. _proto.bindEvents = function bindEvents() {
  17130. var pieLabelCfg = this.pieLabelCfg;
  17131. var triggerOn = pieLabelCfg.triggerOn || 'touchstart';
  17132. Util.addEventListener(this.canvasDom, triggerOn, this._handleEvent);
  17133. };
  17134. _proto.unBindEvents = function unBindEvents() {
  17135. var pieLabelCfg = this.pieLabelCfg;
  17136. var triggerOn = pieLabelCfg.triggerOn || 'touchstart';
  17137. Util.removeEventListener(this.canvasDom, triggerOn, this._handleEvent);
  17138. };
  17139. _proto.clear = function clear() {
  17140. this.labelGroup && this.labelGroup.clear();
  17141. this.halo && this.halo.remove(true);
  17142. this.lastSelectedData = null;
  17143. this.drawnLabels = [];
  17144. this.unBindEvents();
  17145. };
  17146. _proto._drawLabel = function _drawLabel(label) {
  17147. var pieLabelCfg = this.pieLabelCfg,
  17148. chart = this.chart;
  17149. var canvasWidth = chart.get('width');
  17150. var sidePadding = pieLabelCfg.sidePadding;
  17151. var y = label.y,
  17152. textGroup = label.textGroup;
  17153. var children = textGroup.get('children');
  17154. var textAttrs = {
  17155. textAlign: label._side === 'left' ? 'left' : 'right',
  17156. x: label._side === 'left' ? sidePadding : canvasWidth - sidePadding
  17157. };
  17158. children.forEach(function (child) {
  17159. child.attr(textAttrs);
  17160. child.attr('y', y + child.get('offsetY'));
  17161. });
  17162. return textGroup;
  17163. };
  17164. _proto._drawLabelLine = function _drawLabelLine(label, maxLabelWidth) {
  17165. var chart = this.chart,
  17166. pieLabelCfg = this.pieLabelCfg,
  17167. labelGroup = this.labelGroup;
  17168. var canvasWidth = chart.get('width');
  17169. var sidePadding = pieLabelCfg.sidePadding,
  17170. adjustOffset = pieLabelCfg.adjustOffset,
  17171. lineStyle = pieLabelCfg.lineStyle,
  17172. anchorStyle = pieLabelCfg.anchorStyle,
  17173. skipOverlapLabels = pieLabelCfg.skipOverlapLabels;
  17174. var _anchor = label._anchor,
  17175. _inflection = label._inflection,
  17176. fill = label.fill,
  17177. y = label.y;
  17178. var lastPoint = {
  17179. x: label._side === 'left' ? sidePadding : canvasWidth - sidePadding,
  17180. y: y
  17181. };
  17182. var points = [_anchor, _inflection, lastPoint];
  17183. if (!skipOverlapLabels && _inflection.y !== y) {
  17184. // 展示全部文本文本位置做过调整
  17185. if (_inflection.y < y) {
  17186. // 文本被调整下去了,则添加拐点连接线
  17187. var point1 = _inflection;
  17188. var point2 = {
  17189. x: label._side === 'left' ? lastPoint.x + maxLabelWidth + adjustOffset : lastPoint.x - maxLabelWidth - adjustOffset,
  17190. y: _inflection.y
  17191. };
  17192. var point3 = {
  17193. x: label._side === 'left' ? lastPoint.x + maxLabelWidth : lastPoint.x - maxLabelWidth,
  17194. y: lastPoint.y
  17195. };
  17196. points = [_anchor, point1, point2, point3, lastPoint];
  17197. if (label._side === 'right' && point2.x < point1.x || label._side === 'left' && point2.x > point1.x) {
  17198. points = [_anchor, point3, lastPoint];
  17199. }
  17200. } else {
  17201. points = [_anchor, {
  17202. x: _inflection.x,
  17203. y: y
  17204. }, lastPoint];
  17205. }
  17206. }
  17207. labelGroup.addShape('Polyline', {
  17208. attrs: Util.mix({
  17209. points: points,
  17210. lineWidth: 1,
  17211. stroke: fill
  17212. }, lineStyle)
  17213. }); // 绘制锚点
  17214. labelGroup.addShape('Circle', {
  17215. attrs: Util.mix({
  17216. x: _anchor.x,
  17217. y: _anchor.y,
  17218. r: 2,
  17219. fill: fill
  17220. }, anchorStyle)
  17221. });
  17222. };
  17223. _proto._antiCollision = function _antiCollision(half) {
  17224. var self = this;
  17225. var chart = self.chart,
  17226. pieLabelCfg = self.pieLabelCfg;
  17227. var coord = chart.get('coord');
  17228. var canvasHeight = chart.get('height');
  17229. var center = coord.center,
  17230. r = coord.circleRadius;
  17231. var inflectionOffset = pieLabelCfg.inflectionOffset,
  17232. lineHeight = pieLabelCfg.lineHeight;
  17233. var startY = center.y - r - inflectionOffset - lineHeight;
  17234. var overlapping = true;
  17235. var totalH = canvasHeight;
  17236. var i;
  17237. var maxY = 0;
  17238. var minY = Number.MIN_VALUE;
  17239. var maxLabelWidth = 0;
  17240. var boxes = half.map(function (label) {
  17241. var labelY = label.y;
  17242. if (labelY > maxY) {
  17243. maxY = labelY;
  17244. }
  17245. if (labelY < minY) {
  17246. minY = labelY;
  17247. }
  17248. var textGroup = label.textGroup;
  17249. var labelWidth = textGroup.getBBox().width;
  17250. if (labelWidth >= maxLabelWidth) {
  17251. maxLabelWidth = labelWidth;
  17252. }
  17253. return {
  17254. size: lineHeight,
  17255. targets: [labelY - startY]
  17256. };
  17257. });
  17258. if (maxY - startY > totalH) {
  17259. totalH = maxY - startY;
  17260. }
  17261. var iteratorBoxed = function iteratorBoxed(boxes) {
  17262. boxes.forEach(function (box) {
  17263. var target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2;
  17264. box.pos = Math.min(Math.max(minY, target - box.size / 2), totalH - box.size);
  17265. });
  17266. };
  17267. while (overlapping) {
  17268. iteratorBoxed(boxes); // detect overlapping and join boxes
  17269. overlapping = false;
  17270. i = boxes.length;
  17271. while (i--) {
  17272. if (i > 0) {
  17273. var previousBox = boxes[i - 1];
  17274. var box = boxes[i];
  17275. if (previousBox.pos + previousBox.size > box.pos) {
  17276. // overlapping
  17277. previousBox.size += box.size;
  17278. previousBox.targets = previousBox.targets.concat(box.targets); // overflow, shift up
  17279. if (previousBox.pos + previousBox.size > totalH) {
  17280. previousBox.pos = totalH - previousBox.size;
  17281. }
  17282. boxes.splice(i, 1); // removing box
  17283. overlapping = true;
  17284. }
  17285. }
  17286. }
  17287. }
  17288. i = 0;
  17289. boxes.forEach(function (b) {
  17290. var posInCompositeBox = startY; // middle of the label
  17291. b.targets.forEach(function () {
  17292. half[i].y = b.pos + posInCompositeBox + lineHeight / 2;
  17293. posInCompositeBox += lineHeight;
  17294. i++;
  17295. });
  17296. });
  17297. var drawnLabels = [];
  17298. half.forEach(function (label) {
  17299. var textGroup = self._drawLabel(label);
  17300. var labelGroup = self.labelGroup;
  17301. labelGroup.add(textGroup);
  17302. self._drawLabelLine(label, maxLabelWidth);
  17303. drawnLabels.push(textGroup);
  17304. });
  17305. return drawnLabels;
  17306. };
  17307. _proto._getSelectedShapeByData = function _getSelectedShapeByData(data) {
  17308. var selectedShape = null;
  17309. var chart = this.chart;
  17310. var geom = chart.get('geoms')[0];
  17311. var container = geom.get('container');
  17312. var children = container.get('children');
  17313. Util.each(children, function (child) {
  17314. if (child.get('isShape') && child.get('className') === geom.get('type')) {
  17315. // get geometry's shape
  17316. var shapeData = child.get('origin')._origin;
  17317. if (Util.isObjectValueEqual(shapeData, data)) {
  17318. selectedShape = child;
  17319. return false;
  17320. }
  17321. }
  17322. });
  17323. return selectedShape;
  17324. };
  17325. _proto._activeShape = function _activeShape(data) {
  17326. var chart = this.chart,
  17327. lastSelectedData = this.lastSelectedData,
  17328. pieLabelCfg = this.pieLabelCfg;
  17329. if (data === lastSelectedData) {
  17330. return;
  17331. }
  17332. this.lastSelectedData = data;
  17333. var activeStyle = pieLabelCfg.activeStyle;
  17334. var selectedShape = this._getSelectedShapeByData(data);
  17335. var _selectedShape$_attrs = selectedShape._attrs.attrs,
  17336. x = _selectedShape$_attrs.x,
  17337. y = _selectedShape$_attrs.y,
  17338. startAngle = _selectedShape$_attrs.startAngle,
  17339. endAngle = _selectedShape$_attrs.endAngle,
  17340. r = _selectedShape$_attrs.r,
  17341. fill = _selectedShape$_attrs.fill;
  17342. var frontPlot = chart.get('frontPlot');
  17343. this.halo && this.halo.remove(true);
  17344. var halo = frontPlot.addShape('sector', {
  17345. attrs: Util.mix({
  17346. x: x,
  17347. y: y,
  17348. r: r + activeStyle.offset + activeStyle.appendRadius,
  17349. r0: r + activeStyle.offset,
  17350. fill: fill,
  17351. startAngle: startAngle,
  17352. endAngle: endAngle
  17353. }, activeStyle)
  17354. });
  17355. this.halo = halo;
  17356. chart.get('canvas').draw();
  17357. };
  17358. return controller;
  17359. }();
  17360. module.exports = {
  17361. init: function init(chart) {
  17362. var frontPlot = chart.get('frontPlot');
  17363. var labelGroup = frontPlot.addGroup({
  17364. className: 'pie-label',
  17365. zIndex: 0
  17366. });
  17367. var pieLabelController = new controller({
  17368. chart: chart,
  17369. labelGroup: labelGroup
  17370. });
  17371. chart.set('pieLabelController', pieLabelController);
  17372. chart.pieLabel = function (cfg) {
  17373. cfg = Util.deepMix({}, DEFAULT_CFG, cfg);
  17374. pieLabelController.pieLabelCfg = cfg;
  17375. return this;
  17376. };
  17377. },
  17378. afterGeomDraw: function afterGeomDraw(chart) {
  17379. var controller = chart.get('pieLabelController');
  17380. if (controller.pieLabelCfg) {
  17381. // 用户配置了饼图文本
  17382. controller.renderLabels();
  17383. controller.bindEvents(); // 绑定事件
  17384. }
  17385. },
  17386. clearInner: function clearInner(chart) {
  17387. var controller = chart.get('pieLabelController');
  17388. if (controller.pieLabelCfg) {
  17389. // 用户配置了饼图文本
  17390. controller.clear();
  17391. }
  17392. }
  17393. };
  17394. /***/ }),
  17395. /* 257 */
  17396. /***/ (function(module, exports, __webpack_require__) {
  17397. "use strict";
  17398. var Util = __webpack_require__(0);
  17399. var DEFAULT_CFG = {
  17400. label: null,
  17401. offsetX: 0,
  17402. offsetY: 0
  17403. };
  17404. var DEFAULT_LABEL_CFG = {
  17405. textBaseline: 'middle',
  17406. fill: '#808080'
  17407. }; // 2个点的中心点
  17408. function getMiddlePoint(a, b) {
  17409. var x = (a.x - b.x) / 2 + b.x;
  17410. var y = (a.y - b.y) / 2 + b.y;
  17411. return {
  17412. x: x,
  17413. y: y
  17414. };
  17415. } // function getLabelPoint(points, nextPoints) {
  17416. // let start;
  17417. // if (nextPoints && nextPoints.length) {
  17418. // start = getMiddlePoint(points[1], nextPoints[1]);
  17419. // } else {
  17420. // const nextPoint = getMiddlePoint(points[2], points[3]);
  17421. // start = getMiddlePoint(points[1], nextPoint);
  17422. // }
  17423. // const end = getMiddlePoint(points[1], points[2]);
  17424. // return { start, end };
  17425. // }
  17426. var Controller = /*#__PURE__*/function () {
  17427. function Controller(_ref) {
  17428. var chart = _ref.chart,
  17429. container = _ref.container;
  17430. this.cfg = null;
  17431. this.chart = chart;
  17432. this.container = container;
  17433. }
  17434. var _proto = Controller.prototype;
  17435. _proto.draw = function draw() {
  17436. var chart = this.chart,
  17437. container = this.container,
  17438. cfg = this.cfg;
  17439. if (!cfg) return;
  17440. var labelCfg = Util.mix({}, DEFAULT_CFG, cfg);
  17441. var coord = chart.get('coord');
  17442. var geom = chart.get('geoms')[0];
  17443. var shapes = geom.get('container').get('children');
  17444. shapes.forEach(function (shape) {
  17445. var origin = shape.get('origin');
  17446. var _origin = origin._origin,
  17447. color = origin.color,
  17448. points = origin.points;
  17449. if (labelCfg.label) {
  17450. var labelAttrs = labelCfg.label(_origin, color);
  17451. var group = container.addGroup();
  17452. var point = coord.convertPoint(getMiddlePoint(points[1], points[2]));
  17453. group.addShape('Text', {
  17454. attrs: Util.mix({
  17455. x: point.x + labelCfg.offsetX,
  17456. y: point.y + labelCfg.offsetY
  17457. }, labelAttrs, DEFAULT_LABEL_CFG)
  17458. });
  17459. }
  17460. });
  17461. };
  17462. _proto.clear = function clear() {
  17463. var container = this.container;
  17464. container.clear();
  17465. };
  17466. return Controller;
  17467. }();
  17468. module.exports = {
  17469. init: function init(chart) {
  17470. var frontPlot = chart.get('frontPlot');
  17471. var labelGroup = frontPlot.addGroup({
  17472. className: 'label',
  17473. zIndex: 0
  17474. });
  17475. var labelController = new Controller({
  17476. chart: chart,
  17477. container: labelGroup
  17478. });
  17479. chart.set('intervalLabelController', labelController);
  17480. chart.intervalLabel = function (cfg) {
  17481. labelController.cfg = cfg;
  17482. };
  17483. },
  17484. afterGeomDraw: function afterGeomDraw(chart) {
  17485. var labelController = chart.get('intervalLabelController');
  17486. labelController.draw();
  17487. },
  17488. clearInner: function clearInner(chart) {
  17489. var labelController = chart.get('intervalLabelController');
  17490. labelController.clear();
  17491. }
  17492. };
  17493. /***/ }),
  17494. /* 258 */
  17495. /***/ (function(module, exports, __webpack_require__) {
  17496. "use strict";
  17497. module.exports = {
  17498. Interaction: __webpack_require__(74),
  17499. PieSelect: __webpack_require__(260),
  17500. IntervalSelect: __webpack_require__(261),
  17501. Swipe: __webpack_require__(262),
  17502. Pan: __webpack_require__(263),
  17503. Pinch: __webpack_require__(264)
  17504. };
  17505. /***/ }),
  17506. /* 259 */
  17507. /***/ (function(module, exports, __webpack_require__) {
  17508. var __WEBPACK_AMD_DEFINE_RESULT__;/*! Hammer.JS - v2.0.7 - 2016-04-22
  17509. * http://hammerjs.github.io/
  17510. *
  17511. * Copyright (c) 2016 Jorik Tangelder;
  17512. * Licensed under the MIT license */
  17513. (function (window, document, exportName, undefined) {
  17514. 'use strict';
  17515. var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
  17516. var TEST_ELEMENT = document.createElement('div');
  17517. var TYPE_FUNCTION = 'function';
  17518. var round = Math.round;
  17519. var abs = Math.abs;
  17520. var now = Date.now;
  17521. /**
  17522. * set a timeout with a given scope
  17523. * @param {Function} fn
  17524. * @param {Number} timeout
  17525. * @param {Object} context
  17526. * @returns {number}
  17527. */
  17528. function setTimeoutContext(fn, timeout, context) {
  17529. return setTimeout(bindFn(fn, context), timeout);
  17530. }
  17531. /**
  17532. * if the argument is an array, we want to execute the fn on each entry
  17533. * if it aint an array we don't want to do a thing.
  17534. * this is used by all the methods that accept a single and array argument.
  17535. * @param {*|Array} arg
  17536. * @param {String} fn
  17537. * @param {Object} [context]
  17538. * @returns {Boolean}
  17539. */
  17540. function invokeArrayArg(arg, fn, context) {
  17541. if (Array.isArray(arg)) {
  17542. each(arg, context[fn], context);
  17543. return true;
  17544. }
  17545. return false;
  17546. }
  17547. /**
  17548. * walk objects and arrays
  17549. * @param {Object} obj
  17550. * @param {Function} iterator
  17551. * @param {Object} context
  17552. */
  17553. function each(obj, iterator, context) {
  17554. var i;
  17555. if (!obj) {
  17556. return;
  17557. }
  17558. if (obj.forEach) {
  17559. obj.forEach(iterator, context);
  17560. } else if (obj.length !== undefined) {
  17561. i = 0;
  17562. while (i < obj.length) {
  17563. iterator.call(context, obj[i], i, obj);
  17564. i++;
  17565. }
  17566. } else {
  17567. for (i in obj) {
  17568. obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
  17569. }
  17570. }
  17571. }
  17572. /**
  17573. * wrap a method with a deprecation warning and stack trace
  17574. * @param {Function} method
  17575. * @param {String} name
  17576. * @param {String} message
  17577. * @returns {Function} A new function wrapping the supplied method.
  17578. */
  17579. function deprecate(method, name, message) {
  17580. var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
  17581. return function () {
  17582. var e = new Error('get-stack-trace');
  17583. var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
  17584. var log = window.console && (window.console.warn || window.console.log);
  17585. if (log) {
  17586. log.call(window.console, deprecationMessage, stack);
  17587. }
  17588. return method.apply(this, arguments);
  17589. };
  17590. }
  17591. /**
  17592. * extend object.
  17593. * means that properties in dest will be overwritten by the ones in src.
  17594. * @param {Object} target
  17595. * @param {...Object} objects_to_assign
  17596. * @returns {Object} target
  17597. */
  17598. var assign;
  17599. if (typeof Object.assign !== 'function') {
  17600. assign = function assign(target) {
  17601. if (target === undefined || target === null) {
  17602. throw new TypeError('Cannot convert undefined or null to object');
  17603. }
  17604. var output = Object(target);
  17605. for (var index = 1; index < arguments.length; index++) {
  17606. var source = arguments[index];
  17607. if (source !== undefined && source !== null) {
  17608. for (var nextKey in source) {
  17609. if (source.hasOwnProperty(nextKey)) {
  17610. output[nextKey] = source[nextKey];
  17611. }
  17612. }
  17613. }
  17614. }
  17615. return output;
  17616. };
  17617. } else {
  17618. assign = Object.assign;
  17619. }
  17620. /**
  17621. * extend object.
  17622. * means that properties in dest will be overwritten by the ones in src.
  17623. * @param {Object} dest
  17624. * @param {Object} src
  17625. * @param {Boolean} [merge=false]
  17626. * @returns {Object} dest
  17627. */
  17628. var extend = deprecate(function extend(dest, src, merge) {
  17629. var keys = Object.keys(src);
  17630. var i = 0;
  17631. while (i < keys.length) {
  17632. if (!merge || merge && dest[keys[i]] === undefined) {
  17633. dest[keys[i]] = src[keys[i]];
  17634. }
  17635. i++;
  17636. }
  17637. return dest;
  17638. }, 'extend', 'Use `assign`.');
  17639. /**
  17640. * merge the values from src in the dest.
  17641. * means that properties that exist in dest will not be overwritten by src
  17642. * @param {Object} dest
  17643. * @param {Object} src
  17644. * @returns {Object} dest
  17645. */
  17646. var merge = deprecate(function merge(dest, src) {
  17647. return extend(dest, src, true);
  17648. }, 'merge', 'Use `assign`.');
  17649. /**
  17650. * simple class inheritance
  17651. * @param {Function} child
  17652. * @param {Function} base
  17653. * @param {Object} [properties]
  17654. */
  17655. function inherit(child, base, properties) {
  17656. var baseP = base.prototype,
  17657. childP;
  17658. childP = child.prototype = Object.create(baseP);
  17659. childP.constructor = child;
  17660. childP._super = baseP;
  17661. if (properties) {
  17662. assign(childP, properties);
  17663. }
  17664. }
  17665. /**
  17666. * simple function bind
  17667. * @param {Function} fn
  17668. * @param {Object} context
  17669. * @returns {Function}
  17670. */
  17671. function bindFn(fn, context) {
  17672. return function boundFn() {
  17673. return fn.apply(context, arguments);
  17674. };
  17675. }
  17676. /**
  17677. * let a boolean value also be a function that must return a boolean
  17678. * this first item in args will be used as the context
  17679. * @param {Boolean|Function} val
  17680. * @param {Array} [args]
  17681. * @returns {Boolean}
  17682. */
  17683. function boolOrFn(val, args) {
  17684. if (typeof val == TYPE_FUNCTION) {
  17685. return val.apply(args ? args[0] || undefined : undefined, args);
  17686. }
  17687. return val;
  17688. }
  17689. /**
  17690. * use the val2 when val1 is undefined
  17691. * @param {*} val1
  17692. * @param {*} val2
  17693. * @returns {*}
  17694. */
  17695. function ifUndefined(val1, val2) {
  17696. return val1 === undefined ? val2 : val1;
  17697. }
  17698. /**
  17699. * addEventListener with multiple events at once
  17700. * @param {EventTarget} target
  17701. * @param {String} types
  17702. * @param {Function} handler
  17703. */
  17704. function addEventListeners(target, types, handler) {
  17705. each(splitStr(types), function (type) {
  17706. target.addEventListener(type, handler, false);
  17707. });
  17708. }
  17709. /**
  17710. * removeEventListener with multiple events at once
  17711. * @param {EventTarget} target
  17712. * @param {String} types
  17713. * @param {Function} handler
  17714. */
  17715. function removeEventListeners(target, types, handler) {
  17716. each(splitStr(types), function (type) {
  17717. target.removeEventListener(type, handler, false);
  17718. });
  17719. }
  17720. /**
  17721. * find if a node is in the given parent
  17722. * @method hasParent
  17723. * @param {HTMLElement} node
  17724. * @param {HTMLElement} parent
  17725. * @return {Boolean} found
  17726. */
  17727. function hasParent(node, parent) {
  17728. while (node) {
  17729. if (node == parent) {
  17730. return true;
  17731. }
  17732. node = node.parentNode;
  17733. }
  17734. return false;
  17735. }
  17736. /**
  17737. * small indexOf wrapper
  17738. * @param {String} str
  17739. * @param {String} find
  17740. * @returns {Boolean} found
  17741. */
  17742. function inStr(str, find) {
  17743. return str.indexOf(find) > -1;
  17744. }
  17745. /**
  17746. * split string on whitespace
  17747. * @param {String} str
  17748. * @returns {Array} words
  17749. */
  17750. function splitStr(str) {
  17751. return str.trim().split(/\s+/g);
  17752. }
  17753. /**
  17754. * find if a array contains the object using indexOf or a simple polyFill
  17755. * @param {Array} src
  17756. * @param {String} find
  17757. * @param {String} [findByKey]
  17758. * @return {Boolean|Number} false when not found, or the index
  17759. */
  17760. function inArray(src, find, findByKey) {
  17761. if (src.indexOf && !findByKey) {
  17762. return src.indexOf(find);
  17763. } else {
  17764. var i = 0;
  17765. while (i < src.length) {
  17766. if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
  17767. return i;
  17768. }
  17769. i++;
  17770. }
  17771. return -1;
  17772. }
  17773. }
  17774. /**
  17775. * convert array-like objects to real arrays
  17776. * @param {Object} obj
  17777. * @returns {Array}
  17778. */
  17779. function toArray(obj) {
  17780. return Array.prototype.slice.call(obj, 0);
  17781. }
  17782. /**
  17783. * unique array with objects based on a key (like 'id') or just by the array's value
  17784. * @param {Array} src [{id:1},{id:2},{id:1}]
  17785. * @param {String} [key]
  17786. * @param {Boolean} [sort=False]
  17787. * @returns {Array} [{id:1},{id:2}]
  17788. */
  17789. function uniqueArray(src, key, sort) {
  17790. var results = [];
  17791. var values = [];
  17792. var i = 0;
  17793. while (i < src.length) {
  17794. var val = key ? src[i][key] : src[i];
  17795. if (inArray(values, val) < 0) {
  17796. results.push(src[i]);
  17797. }
  17798. values[i] = val;
  17799. i++;
  17800. }
  17801. if (sort) {
  17802. if (!key) {
  17803. results = results.sort();
  17804. } else {
  17805. results = results.sort(function sortUniqueArray(a, b) {
  17806. return a[key] > b[key];
  17807. });
  17808. }
  17809. }
  17810. return results;
  17811. }
  17812. /**
  17813. * get the prefixed property
  17814. * @param {Object} obj
  17815. * @param {String} property
  17816. * @returns {String|Undefined} prefixed
  17817. */
  17818. function prefixed(obj, property) {
  17819. var prefix, prop;
  17820. var camelProp = property[0].toUpperCase() + property.slice(1);
  17821. var i = 0;
  17822. while (i < VENDOR_PREFIXES.length) {
  17823. prefix = VENDOR_PREFIXES[i];
  17824. prop = prefix ? prefix + camelProp : property;
  17825. if (prop in obj) {
  17826. return prop;
  17827. }
  17828. i++;
  17829. }
  17830. return undefined;
  17831. }
  17832. /**
  17833. * get a unique id
  17834. * @returns {number} uniqueId
  17835. */
  17836. var _uniqueId = 1;
  17837. function uniqueId() {
  17838. return _uniqueId++;
  17839. }
  17840. /**
  17841. * get the window object of an element
  17842. * @param {HTMLElement} element
  17843. * @returns {DocumentView|Window}
  17844. */
  17845. function getWindowForElement(element) {
  17846. var doc = element.ownerDocument || element;
  17847. return doc.defaultView || doc.parentWindow || window;
  17848. }
  17849. var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
  17850. var SUPPORT_TOUCH = ('ontouchstart' in window);
  17851. var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
  17852. var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
  17853. var INPUT_TYPE_TOUCH = 'touch';
  17854. var INPUT_TYPE_PEN = 'pen';
  17855. var INPUT_TYPE_MOUSE = 'mouse';
  17856. var INPUT_TYPE_KINECT = 'kinect';
  17857. var COMPUTE_INTERVAL = 25;
  17858. var INPUT_START = 1;
  17859. var INPUT_MOVE = 2;
  17860. var INPUT_END = 4;
  17861. var INPUT_CANCEL = 8;
  17862. var DIRECTION_NONE = 1;
  17863. var DIRECTION_LEFT = 2;
  17864. var DIRECTION_RIGHT = 4;
  17865. var DIRECTION_UP = 8;
  17866. var DIRECTION_DOWN = 16;
  17867. var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
  17868. var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
  17869. var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
  17870. var PROPS_XY = ['x', 'y'];
  17871. var PROPS_CLIENT_XY = ['clientX', 'clientY'];
  17872. /**
  17873. * create new input type manager
  17874. * @param {Manager} manager
  17875. * @param {Function} callback
  17876. * @returns {Input}
  17877. * @constructor
  17878. */
  17879. function Input(manager, callback) {
  17880. var self = this;
  17881. this.manager = manager;
  17882. this.callback = callback;
  17883. this.element = manager.element;
  17884. this.target = manager.options.inputTarget; // smaller wrapper around the handler, for the scope and the enabled state of the manager,
  17885. // so when disabled the input events are completely bypassed.
  17886. this.domHandler = function (ev) {
  17887. if (boolOrFn(manager.options.enable, [manager])) {
  17888. self.handler(ev);
  17889. }
  17890. };
  17891. this.init();
  17892. }
  17893. Input.prototype = {
  17894. /**
  17895. * should handle the inputEvent data and trigger the callback
  17896. * @virtual
  17897. */
  17898. handler: function () {},
  17899. /**
  17900. * bind the events
  17901. */
  17902. init: function () {
  17903. this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
  17904. this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
  17905. this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
  17906. },
  17907. /**
  17908. * unbind the events
  17909. */
  17910. destroy: function () {
  17911. this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
  17912. this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
  17913. this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
  17914. }
  17915. };
  17916. /**
  17917. * create new input type manager
  17918. * called by the Manager constructor
  17919. * @param {Hammer} manager
  17920. * @returns {Input}
  17921. */
  17922. function createInputInstance(manager) {
  17923. var Type;
  17924. var inputClass = manager.options.inputClass;
  17925. if (inputClass) {
  17926. Type = inputClass;
  17927. } else if (SUPPORT_POINTER_EVENTS) {
  17928. Type = PointerEventInput;
  17929. } else if (SUPPORT_ONLY_TOUCH) {
  17930. Type = TouchInput;
  17931. } else if (!SUPPORT_TOUCH) {
  17932. Type = MouseInput;
  17933. } else {
  17934. Type = TouchMouseInput;
  17935. }
  17936. return new Type(manager, inputHandler);
  17937. }
  17938. /**
  17939. * handle input events
  17940. * @param {Manager} manager
  17941. * @param {String} eventType
  17942. * @param {Object} input
  17943. */
  17944. function inputHandler(manager, eventType, input) {
  17945. var pointersLen = input.pointers.length;
  17946. var changedPointersLen = input.changedPointers.length;
  17947. var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
  17948. var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
  17949. input.isFirst = !!isFirst;
  17950. input.isFinal = !!isFinal;
  17951. if (isFirst) {
  17952. manager.session = {};
  17953. } // source event is the normalized value of the domEvents
  17954. // like 'touchstart, mouseup, pointerdown'
  17955. input.eventType = eventType; // compute scale, rotation etc
  17956. computeInputData(manager, input); // emit secret event
  17957. manager.emit('hammer.input', input);
  17958. manager.recognize(input);
  17959. manager.session.prevInput = input;
  17960. }
  17961. /**
  17962. * extend the data with some usable properties like scale, rotate, velocity etc
  17963. * @param {Object} manager
  17964. * @param {Object} input
  17965. */
  17966. function computeInputData(manager, input) {
  17967. var session = manager.session;
  17968. var pointers = input.pointers;
  17969. var pointersLength = pointers.length; // store the first input to calculate the distance and direction
  17970. if (!session.firstInput) {
  17971. session.firstInput = simpleCloneInputData(input);
  17972. } // to compute scale and rotation we need to store the multiple touches
  17973. if (pointersLength > 1 && !session.firstMultiple) {
  17974. session.firstMultiple = simpleCloneInputData(input);
  17975. } else if (pointersLength === 1) {
  17976. session.firstMultiple = false;
  17977. }
  17978. var firstInput = session.firstInput;
  17979. var firstMultiple = session.firstMultiple;
  17980. var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
  17981. var center = input.center = getCenter(pointers);
  17982. input.timeStamp = now();
  17983. input.deltaTime = input.timeStamp - firstInput.timeStamp;
  17984. input.angle = getAngle(offsetCenter, center);
  17985. input.distance = getDistance(offsetCenter, center);
  17986. computeDeltaXY(session, input);
  17987. input.offsetDirection = getDirection(input.deltaX, input.deltaY);
  17988. var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
  17989. input.overallVelocityX = overallVelocity.x;
  17990. input.overallVelocityY = overallVelocity.y;
  17991. input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
  17992. input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
  17993. input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
  17994. input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
  17995. computeIntervalInputData(session, input); // find the correct target
  17996. var target = manager.element;
  17997. if (hasParent(input.srcEvent.target, target)) {
  17998. target = input.srcEvent.target;
  17999. }
  18000. input.target = target;
  18001. }
  18002. function computeDeltaXY(session, input) {
  18003. var center = input.center;
  18004. var offset = session.offsetDelta || {};
  18005. var prevDelta = session.prevDelta || {};
  18006. var prevInput = session.prevInput || {};
  18007. if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
  18008. prevDelta = session.prevDelta = {
  18009. x: prevInput.deltaX || 0,
  18010. y: prevInput.deltaY || 0
  18011. };
  18012. offset = session.offsetDelta = {
  18013. x: center.x,
  18014. y: center.y
  18015. };
  18016. }
  18017. input.deltaX = prevDelta.x + (center.x - offset.x);
  18018. input.deltaY = prevDelta.y + (center.y - offset.y);
  18019. }
  18020. /**
  18021. * velocity is calculated every x ms
  18022. * @param {Object} session
  18023. * @param {Object} input
  18024. */
  18025. function computeIntervalInputData(session, input) {
  18026. var last = session.lastInterval || input,
  18027. deltaTime = input.timeStamp - last.timeStamp,
  18028. velocity,
  18029. velocityX,
  18030. velocityY,
  18031. direction;
  18032. if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
  18033. var deltaX = input.deltaX - last.deltaX;
  18034. var deltaY = input.deltaY - last.deltaY;
  18035. var v = getVelocity(deltaTime, deltaX, deltaY);
  18036. velocityX = v.x;
  18037. velocityY = v.y;
  18038. velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
  18039. direction = getDirection(deltaX, deltaY);
  18040. session.lastInterval = input;
  18041. } else {
  18042. // use latest velocity info if it doesn't overtake a minimum period
  18043. velocity = last.velocity;
  18044. velocityX = last.velocityX;
  18045. velocityY = last.velocityY;
  18046. direction = last.direction;
  18047. }
  18048. input.velocity = velocity;
  18049. input.velocityX = velocityX;
  18050. input.velocityY = velocityY;
  18051. input.direction = direction;
  18052. }
  18053. /**
  18054. * create a simple clone from the input used for storage of firstInput and firstMultiple
  18055. * @param {Object} input
  18056. * @returns {Object} clonedInputData
  18057. */
  18058. function simpleCloneInputData(input) {
  18059. // make a simple copy of the pointers because we will get a reference if we don't
  18060. // we only need clientXY for the calculations
  18061. var pointers = [];
  18062. var i = 0;
  18063. while (i < input.pointers.length) {
  18064. pointers[i] = {
  18065. clientX: round(input.pointers[i].clientX),
  18066. clientY: round(input.pointers[i].clientY)
  18067. };
  18068. i++;
  18069. }
  18070. return {
  18071. timeStamp: now(),
  18072. pointers: pointers,
  18073. center: getCenter(pointers),
  18074. deltaX: input.deltaX,
  18075. deltaY: input.deltaY
  18076. };
  18077. }
  18078. /**
  18079. * get the center of all the pointers
  18080. * @param {Array} pointers
  18081. * @return {Object} center contains `x` and `y` properties
  18082. */
  18083. function getCenter(pointers) {
  18084. var pointersLength = pointers.length; // no need to loop when only one touch
  18085. if (pointersLength === 1) {
  18086. return {
  18087. x: round(pointers[0].clientX),
  18088. y: round(pointers[0].clientY)
  18089. };
  18090. }
  18091. var x = 0,
  18092. y = 0,
  18093. i = 0;
  18094. while (i < pointersLength) {
  18095. x += pointers[i].clientX;
  18096. y += pointers[i].clientY;
  18097. i++;
  18098. }
  18099. return {
  18100. x: round(x / pointersLength),
  18101. y: round(y / pointersLength)
  18102. };
  18103. }
  18104. /**
  18105. * calculate the velocity between two points. unit is in px per ms.
  18106. * @param {Number} deltaTime
  18107. * @param {Number} x
  18108. * @param {Number} y
  18109. * @return {Object} velocity `x` and `y`
  18110. */
  18111. function getVelocity(deltaTime, x, y) {
  18112. return {
  18113. x: x / deltaTime || 0,
  18114. y: y / deltaTime || 0
  18115. };
  18116. }
  18117. /**
  18118. * get the direction between two points
  18119. * @param {Number} x
  18120. * @param {Number} y
  18121. * @return {Number} direction
  18122. */
  18123. function getDirection(x, y) {
  18124. if (x === y) {
  18125. return DIRECTION_NONE;
  18126. }
  18127. if (abs(x) >= abs(y)) {
  18128. return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
  18129. }
  18130. return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
  18131. }
  18132. /**
  18133. * calculate the absolute distance between two points
  18134. * @param {Object} p1 {x, y}
  18135. * @param {Object} p2 {x, y}
  18136. * @param {Array} [props] containing x and y keys
  18137. * @return {Number} distance
  18138. */
  18139. function getDistance(p1, p2, props) {
  18140. if (!props) {
  18141. props = PROPS_XY;
  18142. }
  18143. var x = p2[props[0]] - p1[props[0]],
  18144. y = p2[props[1]] - p1[props[1]];
  18145. return Math.sqrt(x * x + y * y);
  18146. }
  18147. /**
  18148. * calculate the angle between two coordinates
  18149. * @param {Object} p1
  18150. * @param {Object} p2
  18151. * @param {Array} [props] containing x and y keys
  18152. * @return {Number} angle
  18153. */
  18154. function getAngle(p1, p2, props) {
  18155. if (!props) {
  18156. props = PROPS_XY;
  18157. }
  18158. var x = p2[props[0]] - p1[props[0]],
  18159. y = p2[props[1]] - p1[props[1]];
  18160. return Math.atan2(y, x) * 180 / Math.PI;
  18161. }
  18162. /**
  18163. * calculate the rotation degrees between two pointersets
  18164. * @param {Array} start array of pointers
  18165. * @param {Array} end array of pointers
  18166. * @return {Number} rotation
  18167. */
  18168. function getRotation(start, end) {
  18169. return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
  18170. }
  18171. /**
  18172. * calculate the scale factor between two pointersets
  18173. * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
  18174. * @param {Array} start array of pointers
  18175. * @param {Array} end array of pointers
  18176. * @return {Number} scale
  18177. */
  18178. function getScale(start, end) {
  18179. return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
  18180. }
  18181. var MOUSE_INPUT_MAP = {
  18182. mousedown: INPUT_START,
  18183. mousemove: INPUT_MOVE,
  18184. mouseup: INPUT_END
  18185. };
  18186. var MOUSE_ELEMENT_EVENTS = 'mousedown';
  18187. var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
  18188. /**
  18189. * Mouse events input
  18190. * @constructor
  18191. * @extends Input
  18192. */
  18193. function MouseInput() {
  18194. this.evEl = MOUSE_ELEMENT_EVENTS;
  18195. this.evWin = MOUSE_WINDOW_EVENTS;
  18196. this.pressed = false; // mousedown state
  18197. Input.apply(this, arguments);
  18198. }
  18199. inherit(MouseInput, Input, {
  18200. /**
  18201. * handle mouse events
  18202. * @param {Object} ev
  18203. */
  18204. handler: function MEhandler(ev) {
  18205. var eventType = MOUSE_INPUT_MAP[ev.type]; // on start we want to have the left mouse button down
  18206. if (eventType & INPUT_START && ev.button === 0) {
  18207. this.pressed = true;
  18208. }
  18209. if (eventType & INPUT_MOVE && ev.which !== 1) {
  18210. eventType = INPUT_END;
  18211. } // mouse must be down
  18212. if (!this.pressed) {
  18213. return;
  18214. }
  18215. if (eventType & INPUT_END) {
  18216. this.pressed = false;
  18217. }
  18218. this.callback(this.manager, eventType, {
  18219. pointers: [ev],
  18220. changedPointers: [ev],
  18221. pointerType: INPUT_TYPE_MOUSE,
  18222. srcEvent: ev
  18223. });
  18224. }
  18225. });
  18226. var POINTER_INPUT_MAP = {
  18227. pointerdown: INPUT_START,
  18228. pointermove: INPUT_MOVE,
  18229. pointerup: INPUT_END,
  18230. pointercancel: INPUT_CANCEL,
  18231. pointerout: INPUT_CANCEL
  18232. }; // in IE10 the pointer types is defined as an enum
  18233. var IE10_POINTER_TYPE_ENUM = {
  18234. 2: INPUT_TYPE_TOUCH,
  18235. 3: INPUT_TYPE_PEN,
  18236. 4: INPUT_TYPE_MOUSE,
  18237. 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
  18238. };
  18239. var POINTER_ELEMENT_EVENTS = 'pointerdown';
  18240. var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel'; // IE10 has prefixed support, and case-sensitive
  18241. if (window.MSPointerEvent && !window.PointerEvent) {
  18242. POINTER_ELEMENT_EVENTS = 'MSPointerDown';
  18243. POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
  18244. }
  18245. /**
  18246. * Pointer events input
  18247. * @constructor
  18248. * @extends Input
  18249. */
  18250. function PointerEventInput() {
  18251. this.evEl = POINTER_ELEMENT_EVENTS;
  18252. this.evWin = POINTER_WINDOW_EVENTS;
  18253. Input.apply(this, arguments);
  18254. this.store = this.manager.session.pointerEvents = [];
  18255. }
  18256. inherit(PointerEventInput, Input, {
  18257. /**
  18258. * handle mouse events
  18259. * @param {Object} ev
  18260. */
  18261. handler: function PEhandler(ev) {
  18262. var store = this.store;
  18263. var removePointer = false;
  18264. var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
  18265. var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
  18266. var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
  18267. var isTouch = pointerType == INPUT_TYPE_TOUCH; // get index of the event in the store
  18268. var storeIndex = inArray(store, ev.pointerId, 'pointerId'); // start and mouse must be down
  18269. if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
  18270. if (storeIndex < 0) {
  18271. store.push(ev);
  18272. storeIndex = store.length - 1;
  18273. }
  18274. } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
  18275. removePointer = true;
  18276. } // it not found, so the pointer hasn't been down (so it's probably a hover)
  18277. if (storeIndex < 0) {
  18278. return;
  18279. } // update the event in the store
  18280. store[storeIndex] = ev;
  18281. this.callback(this.manager, eventType, {
  18282. pointers: store,
  18283. changedPointers: [ev],
  18284. pointerType: pointerType,
  18285. srcEvent: ev
  18286. });
  18287. if (removePointer) {
  18288. // remove from the store
  18289. store.splice(storeIndex, 1);
  18290. }
  18291. }
  18292. });
  18293. var SINGLE_TOUCH_INPUT_MAP = {
  18294. touchstart: INPUT_START,
  18295. touchmove: INPUT_MOVE,
  18296. touchend: INPUT_END,
  18297. touchcancel: INPUT_CANCEL
  18298. };
  18299. var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
  18300. var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
  18301. /**
  18302. * Touch events input
  18303. * @constructor
  18304. * @extends Input
  18305. */
  18306. function SingleTouchInput() {
  18307. this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
  18308. this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
  18309. this.started = false;
  18310. Input.apply(this, arguments);
  18311. }
  18312. inherit(SingleTouchInput, Input, {
  18313. handler: function TEhandler(ev) {
  18314. var type = SINGLE_TOUCH_INPUT_MAP[ev.type]; // should we handle the touch events?
  18315. if (type === INPUT_START) {
  18316. this.started = true;
  18317. }
  18318. if (!this.started) {
  18319. return;
  18320. }
  18321. var touches = normalizeSingleTouches.call(this, ev, type); // when done, reset the started state
  18322. if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
  18323. this.started = false;
  18324. }
  18325. this.callback(this.manager, type, {
  18326. pointers: touches[0],
  18327. changedPointers: touches[1],
  18328. pointerType: INPUT_TYPE_TOUCH,
  18329. srcEvent: ev
  18330. });
  18331. }
  18332. });
  18333. /**
  18334. * @this {TouchInput}
  18335. * @param {Object} ev
  18336. * @param {Number} type flag
  18337. * @returns {undefined|Array} [all, changed]
  18338. */
  18339. function normalizeSingleTouches(ev, type) {
  18340. var all = toArray(ev.touches);
  18341. var changed = toArray(ev.changedTouches);
  18342. if (type & (INPUT_END | INPUT_CANCEL)) {
  18343. all = uniqueArray(all.concat(changed), 'identifier', true);
  18344. }
  18345. return [all, changed];
  18346. }
  18347. var TOUCH_INPUT_MAP = {
  18348. touchstart: INPUT_START,
  18349. touchmove: INPUT_MOVE,
  18350. touchend: INPUT_END,
  18351. touchcancel: INPUT_CANCEL
  18352. };
  18353. var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
  18354. /**
  18355. * Multi-user touch events input
  18356. * @constructor
  18357. * @extends Input
  18358. */
  18359. function TouchInput() {
  18360. this.evTarget = TOUCH_TARGET_EVENTS;
  18361. this.targetIds = {};
  18362. Input.apply(this, arguments);
  18363. }
  18364. inherit(TouchInput, Input, {
  18365. handler: function MTEhandler(ev) {
  18366. var type = TOUCH_INPUT_MAP[ev.type];
  18367. var touches = getTouches.call(this, ev, type);
  18368. if (!touches) {
  18369. return;
  18370. }
  18371. this.callback(this.manager, type, {
  18372. pointers: touches[0],
  18373. changedPointers: touches[1],
  18374. pointerType: INPUT_TYPE_TOUCH,
  18375. srcEvent: ev
  18376. });
  18377. }
  18378. });
  18379. /**
  18380. * @this {TouchInput}
  18381. * @param {Object} ev
  18382. * @param {Number} type flag
  18383. * @returns {undefined|Array} [all, changed]
  18384. */
  18385. function getTouches(ev, type) {
  18386. var allTouches = toArray(ev.touches);
  18387. var targetIds = this.targetIds; // when there is only one touch, the process can be simplified
  18388. if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
  18389. targetIds[allTouches[0].identifier] = true;
  18390. return [allTouches, allTouches];
  18391. }
  18392. var i,
  18393. targetTouches,
  18394. changedTouches = toArray(ev.changedTouches),
  18395. changedTargetTouches = [],
  18396. target = this.target; // get target touches from touches
  18397. targetTouches = allTouches.filter(function (touch) {
  18398. return hasParent(touch.target, target);
  18399. }); // collect touches
  18400. if (type === INPUT_START) {
  18401. i = 0;
  18402. while (i < targetTouches.length) {
  18403. targetIds[targetTouches[i].identifier] = true;
  18404. i++;
  18405. }
  18406. } // filter changed touches to only contain touches that exist in the collected target ids
  18407. i = 0;
  18408. while (i < changedTouches.length) {
  18409. if (targetIds[changedTouches[i].identifier]) {
  18410. changedTargetTouches.push(changedTouches[i]);
  18411. } // cleanup removed touches
  18412. if (type & (INPUT_END | INPUT_CANCEL)) {
  18413. delete targetIds[changedTouches[i].identifier];
  18414. }
  18415. i++;
  18416. }
  18417. if (!changedTargetTouches.length) {
  18418. return;
  18419. }
  18420. return [// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
  18421. uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
  18422. }
  18423. /**
  18424. * Combined touch and mouse input
  18425. *
  18426. * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
  18427. * This because touch devices also emit mouse events while doing a touch.
  18428. *
  18429. * @constructor
  18430. * @extends Input
  18431. */
  18432. var DEDUP_TIMEOUT = 2500;
  18433. var DEDUP_DISTANCE = 25;
  18434. function TouchMouseInput() {
  18435. Input.apply(this, arguments);
  18436. var handler = bindFn(this.handler, this);
  18437. this.touch = new TouchInput(this.manager, handler);
  18438. this.mouse = new MouseInput(this.manager, handler);
  18439. this.primaryTouch = null;
  18440. this.lastTouches = [];
  18441. }
  18442. inherit(TouchMouseInput, Input, {
  18443. /**
  18444. * handle mouse and touch events
  18445. * @param {Hammer} manager
  18446. * @param {String} inputEvent
  18447. * @param {Object} inputData
  18448. */
  18449. handler: function TMEhandler(manager, inputEvent, inputData) {
  18450. var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
  18451. isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
  18452. if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
  18453. return;
  18454. } // when we're in a touch event, record touches to de-dupe synthetic mouse event
  18455. if (isTouch) {
  18456. recordTouches.call(this, inputEvent, inputData);
  18457. } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
  18458. return;
  18459. }
  18460. this.callback(manager, inputEvent, inputData);
  18461. },
  18462. /**
  18463. * remove the event listeners
  18464. */
  18465. destroy: function destroy() {
  18466. this.touch.destroy();
  18467. this.mouse.destroy();
  18468. }
  18469. });
  18470. function recordTouches(eventType, eventData) {
  18471. if (eventType & INPUT_START) {
  18472. this.primaryTouch = eventData.changedPointers[0].identifier;
  18473. setLastTouch.call(this, eventData);
  18474. } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
  18475. setLastTouch.call(this, eventData);
  18476. }
  18477. }
  18478. function setLastTouch(eventData) {
  18479. var touch = eventData.changedPointers[0];
  18480. if (touch.identifier === this.primaryTouch) {
  18481. var lastTouch = {
  18482. x: touch.clientX,
  18483. y: touch.clientY
  18484. };
  18485. this.lastTouches.push(lastTouch);
  18486. var lts = this.lastTouches;
  18487. var removeLastTouch = function () {
  18488. var i = lts.indexOf(lastTouch);
  18489. if (i > -1) {
  18490. lts.splice(i, 1);
  18491. }
  18492. };
  18493. setTimeout(removeLastTouch, DEDUP_TIMEOUT);
  18494. }
  18495. }
  18496. function isSyntheticEvent(eventData) {
  18497. var x = eventData.srcEvent.clientX,
  18498. y = eventData.srcEvent.clientY;
  18499. for (var i = 0; i < this.lastTouches.length; i++) {
  18500. var t = this.lastTouches[i];
  18501. var dx = Math.abs(x - t.x),
  18502. dy = Math.abs(y - t.y);
  18503. if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
  18504. return true;
  18505. }
  18506. }
  18507. return false;
  18508. }
  18509. var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
  18510. var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined; // magical touchAction value
  18511. var TOUCH_ACTION_COMPUTE = 'compute';
  18512. var TOUCH_ACTION_AUTO = 'auto';
  18513. var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
  18514. var TOUCH_ACTION_NONE = 'none';
  18515. var TOUCH_ACTION_PAN_X = 'pan-x';
  18516. var TOUCH_ACTION_PAN_Y = 'pan-y';
  18517. var TOUCH_ACTION_MAP = getTouchActionProps();
  18518. /**
  18519. * Touch Action
  18520. * sets the touchAction property or uses the js alternative
  18521. * @param {Manager} manager
  18522. * @param {String} value
  18523. * @constructor
  18524. */
  18525. function TouchAction(manager, value) {
  18526. this.manager = manager;
  18527. this.set(value);
  18528. }
  18529. TouchAction.prototype = {
  18530. /**
  18531. * set the touchAction value on the element or enable the polyfill
  18532. * @param {String} value
  18533. */
  18534. set: function (value) {
  18535. // find out the touch-action by the event handlers
  18536. if (value == TOUCH_ACTION_COMPUTE) {
  18537. value = this.compute();
  18538. }
  18539. if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
  18540. this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
  18541. }
  18542. this.actions = value.toLowerCase().trim();
  18543. },
  18544. /**
  18545. * just re-set the touchAction value
  18546. */
  18547. update: function () {
  18548. this.set(this.manager.options.touchAction);
  18549. },
  18550. /**
  18551. * compute the value for the touchAction property based on the recognizer's settings
  18552. * @returns {String} value
  18553. */
  18554. compute: function () {
  18555. var actions = [];
  18556. each(this.manager.recognizers, function (recognizer) {
  18557. if (boolOrFn(recognizer.options.enable, [recognizer])) {
  18558. actions = actions.concat(recognizer.getTouchAction());
  18559. }
  18560. });
  18561. return cleanTouchActions(actions.join(' '));
  18562. },
  18563. /**
  18564. * this method is called on each input cycle and provides the preventing of the browser behavior
  18565. * @param {Object} input
  18566. */
  18567. preventDefaults: function (input) {
  18568. var srcEvent = input.srcEvent;
  18569. var direction = input.offsetDirection; // if the touch action did prevented once this session
  18570. if (this.manager.session.prevented) {
  18571. srcEvent.preventDefault();
  18572. return;
  18573. }
  18574. var actions = this.actions;
  18575. var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
  18576. var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
  18577. var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
  18578. if (hasNone) {
  18579. //do not prevent defaults if this is a tap gesture
  18580. var isTapPointer = input.pointers.length === 1;
  18581. var isTapMovement = input.distance < 2;
  18582. var isTapTouchTime = input.deltaTime < 250;
  18583. if (isTapPointer && isTapMovement && isTapTouchTime) {
  18584. return;
  18585. }
  18586. }
  18587. if (hasPanX && hasPanY) {
  18588. // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
  18589. return;
  18590. }
  18591. if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
  18592. return this.preventSrc(srcEvent);
  18593. }
  18594. },
  18595. /**
  18596. * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
  18597. * @param {Object} srcEvent
  18598. */
  18599. preventSrc: function (srcEvent) {
  18600. this.manager.session.prevented = true;
  18601. srcEvent.preventDefault();
  18602. }
  18603. };
  18604. /**
  18605. * when the touchActions are collected they are not a valid value, so we need to clean things up. *
  18606. * @param {String} actions
  18607. * @returns {*}
  18608. */
  18609. function cleanTouchActions(actions) {
  18610. // none
  18611. if (inStr(actions, TOUCH_ACTION_NONE)) {
  18612. return TOUCH_ACTION_NONE;
  18613. }
  18614. var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
  18615. var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y); // if both pan-x and pan-y are set (different recognizers
  18616. // for different directions, e.g. horizontal pan but vertical swipe?)
  18617. // we need none (as otherwise with pan-x pan-y combined none of these
  18618. // recognizers will work, since the browser would handle all panning
  18619. if (hasPanX && hasPanY) {
  18620. return TOUCH_ACTION_NONE;
  18621. } // pan-x OR pan-y
  18622. if (hasPanX || hasPanY) {
  18623. return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
  18624. } // manipulation
  18625. if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
  18626. return TOUCH_ACTION_MANIPULATION;
  18627. }
  18628. return TOUCH_ACTION_AUTO;
  18629. }
  18630. function getTouchActionProps() {
  18631. if (!NATIVE_TOUCH_ACTION) {
  18632. return false;
  18633. }
  18634. var touchMap = {};
  18635. var cssSupports = window.CSS && window.CSS.supports;
  18636. ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
  18637. // If css.supports is not supported but there is native touch-action assume it supports
  18638. // all values. This is the case for IE 10 and 11.
  18639. touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
  18640. });
  18641. return touchMap;
  18642. }
  18643. /**
  18644. * Recognizer flow explained; *
  18645. * All recognizers have the initial state of POSSIBLE when a input session starts.
  18646. * The definition of a input session is from the first input until the last input, with all it's movement in it. *
  18647. * Example session for mouse-input: mousedown -> mousemove -> mouseup
  18648. *
  18649. * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
  18650. * which determines with state it should be.
  18651. *
  18652. * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
  18653. * POSSIBLE to give it another change on the next cycle.
  18654. *
  18655. * Possible
  18656. * |
  18657. * +-----+---------------+
  18658. * | |
  18659. * +-----+-----+ |
  18660. * | | |
  18661. * Failed Cancelled |
  18662. * +-------+------+
  18663. * | |
  18664. * Recognized Began
  18665. * |
  18666. * Changed
  18667. * |
  18668. * Ended/Recognized
  18669. */
  18670. var STATE_POSSIBLE = 1;
  18671. var STATE_BEGAN = 2;
  18672. var STATE_CHANGED = 4;
  18673. var STATE_ENDED = 8;
  18674. var STATE_RECOGNIZED = STATE_ENDED;
  18675. var STATE_CANCELLED = 16;
  18676. var STATE_FAILED = 32;
  18677. /**
  18678. * Recognizer
  18679. * Every recognizer needs to extend from this class.
  18680. * @constructor
  18681. * @param {Object} options
  18682. */
  18683. function Recognizer(options) {
  18684. this.options = assign({}, this.defaults, options || {});
  18685. this.id = uniqueId();
  18686. this.manager = null; // default is enable true
  18687. this.options.enable = ifUndefined(this.options.enable, true);
  18688. this.state = STATE_POSSIBLE;
  18689. this.simultaneous = {};
  18690. this.requireFail = [];
  18691. }
  18692. Recognizer.prototype = {
  18693. /**
  18694. * @virtual
  18695. * @type {Object}
  18696. */
  18697. defaults: {},
  18698. /**
  18699. * set options
  18700. * @param {Object} options
  18701. * @return {Recognizer}
  18702. */
  18703. set: function (options) {
  18704. assign(this.options, options); // also update the touchAction, in case something changed about the directions/enabled state
  18705. this.manager && this.manager.touchAction.update();
  18706. return this;
  18707. },
  18708. /**
  18709. * recognize simultaneous with an other recognizer.
  18710. * @param {Recognizer} otherRecognizer
  18711. * @returns {Recognizer} this
  18712. */
  18713. recognizeWith: function (otherRecognizer) {
  18714. if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
  18715. return this;
  18716. }
  18717. var simultaneous = this.simultaneous;
  18718. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  18719. if (!simultaneous[otherRecognizer.id]) {
  18720. simultaneous[otherRecognizer.id] = otherRecognizer;
  18721. otherRecognizer.recognizeWith(this);
  18722. }
  18723. return this;
  18724. },
  18725. /**
  18726. * drop the simultaneous link. it doesnt remove the link on the other recognizer.
  18727. * @param {Recognizer} otherRecognizer
  18728. * @returns {Recognizer} this
  18729. */
  18730. dropRecognizeWith: function (otherRecognizer) {
  18731. if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
  18732. return this;
  18733. }
  18734. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  18735. delete this.simultaneous[otherRecognizer.id];
  18736. return this;
  18737. },
  18738. /**
  18739. * recognizer can only run when an other is failing
  18740. * @param {Recognizer} otherRecognizer
  18741. * @returns {Recognizer} this
  18742. */
  18743. requireFailure: function (otherRecognizer) {
  18744. if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
  18745. return this;
  18746. }
  18747. var requireFail = this.requireFail;
  18748. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  18749. if (inArray(requireFail, otherRecognizer) === -1) {
  18750. requireFail.push(otherRecognizer);
  18751. otherRecognizer.requireFailure(this);
  18752. }
  18753. return this;
  18754. },
  18755. /**
  18756. * drop the requireFailure link. it does not remove the link on the other recognizer.
  18757. * @param {Recognizer} otherRecognizer
  18758. * @returns {Recognizer} this
  18759. */
  18760. dropRequireFailure: function (otherRecognizer) {
  18761. if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
  18762. return this;
  18763. }
  18764. otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
  18765. var index = inArray(this.requireFail, otherRecognizer);
  18766. if (index > -1) {
  18767. this.requireFail.splice(index, 1);
  18768. }
  18769. return this;
  18770. },
  18771. /**
  18772. * has require failures boolean
  18773. * @returns {boolean}
  18774. */
  18775. hasRequireFailures: function () {
  18776. return this.requireFail.length > 0;
  18777. },
  18778. /**
  18779. * if the recognizer can recognize simultaneous with an other recognizer
  18780. * @param {Recognizer} otherRecognizer
  18781. * @returns {Boolean}
  18782. */
  18783. canRecognizeWith: function (otherRecognizer) {
  18784. return !!this.simultaneous[otherRecognizer.id];
  18785. },
  18786. /**
  18787. * You should use `tryEmit` instead of `emit` directly to check
  18788. * that all the needed recognizers has failed before emitting.
  18789. * @param {Object} input
  18790. */
  18791. emit: function (input) {
  18792. var self = this;
  18793. var state = this.state;
  18794. function emit(event) {
  18795. self.manager.emit(event, input);
  18796. } // 'panstart' and 'panmove'
  18797. if (state < STATE_ENDED) {
  18798. emit(self.options.event + stateStr(state));
  18799. }
  18800. emit(self.options.event); // simple 'eventName' events
  18801. if (input.additionalEvent) {
  18802. // additional event(panleft, panright, pinchin, pinchout...)
  18803. emit(input.additionalEvent);
  18804. } // panend and pancancel
  18805. if (state >= STATE_ENDED) {
  18806. emit(self.options.event + stateStr(state));
  18807. }
  18808. },
  18809. /**
  18810. * Check that all the require failure recognizers has failed,
  18811. * if true, it emits a gesture event,
  18812. * otherwise, setup the state to FAILED.
  18813. * @param {Object} input
  18814. */
  18815. tryEmit: function (input) {
  18816. if (this.canEmit()) {
  18817. return this.emit(input);
  18818. } // it's failing anyway
  18819. this.state = STATE_FAILED;
  18820. },
  18821. /**
  18822. * can we emit?
  18823. * @returns {boolean}
  18824. */
  18825. canEmit: function () {
  18826. var i = 0;
  18827. while (i < this.requireFail.length) {
  18828. if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
  18829. return false;
  18830. }
  18831. i++;
  18832. }
  18833. return true;
  18834. },
  18835. /**
  18836. * update the recognizer
  18837. * @param {Object} inputData
  18838. */
  18839. recognize: function (inputData) {
  18840. // make a new copy of the inputData
  18841. // so we can change the inputData without messing up the other recognizers
  18842. var inputDataClone = assign({}, inputData); // is is enabled and allow recognizing?
  18843. if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
  18844. this.reset();
  18845. this.state = STATE_FAILED;
  18846. return;
  18847. } // reset when we've reached the end
  18848. if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
  18849. this.state = STATE_POSSIBLE;
  18850. }
  18851. this.state = this.process(inputDataClone); // the recognizer has recognized a gesture
  18852. // so trigger an event
  18853. if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
  18854. this.tryEmit(inputDataClone);
  18855. }
  18856. },
  18857. /**
  18858. * return the state of the recognizer
  18859. * the actual recognizing happens in this method
  18860. * @virtual
  18861. * @param {Object} inputData
  18862. * @returns {Const} STATE
  18863. */
  18864. process: function (inputData) {},
  18865. // jshint ignore:line
  18866. /**
  18867. * return the preferred touch-action
  18868. * @virtual
  18869. * @returns {Array}
  18870. */
  18871. getTouchAction: function () {},
  18872. /**
  18873. * called when the gesture isn't allowed to recognize
  18874. * like when another is being recognized or it is disabled
  18875. * @virtual
  18876. */
  18877. reset: function () {}
  18878. };
  18879. /**
  18880. * get a usable string, used as event postfix
  18881. * @param {Const} state
  18882. * @returns {String} state
  18883. */
  18884. function stateStr(state) {
  18885. if (state & STATE_CANCELLED) {
  18886. return 'cancel';
  18887. } else if (state & STATE_ENDED) {
  18888. return 'end';
  18889. } else if (state & STATE_CHANGED) {
  18890. return 'move';
  18891. } else if (state & STATE_BEGAN) {
  18892. return 'start';
  18893. }
  18894. return '';
  18895. }
  18896. /**
  18897. * direction cons to string
  18898. * @param {Const} direction
  18899. * @returns {String}
  18900. */
  18901. function directionStr(direction) {
  18902. if (direction == DIRECTION_DOWN) {
  18903. return 'down';
  18904. } else if (direction == DIRECTION_UP) {
  18905. return 'up';
  18906. } else if (direction == DIRECTION_LEFT) {
  18907. return 'left';
  18908. } else if (direction == DIRECTION_RIGHT) {
  18909. return 'right';
  18910. }
  18911. return '';
  18912. }
  18913. /**
  18914. * get a recognizer by name if it is bound to a manager
  18915. * @param {Recognizer|String} otherRecognizer
  18916. * @param {Recognizer} recognizer
  18917. * @returns {Recognizer}
  18918. */
  18919. function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
  18920. var manager = recognizer.manager;
  18921. if (manager) {
  18922. return manager.get(otherRecognizer);
  18923. }
  18924. return otherRecognizer;
  18925. }
  18926. /**
  18927. * This recognizer is just used as a base for the simple attribute recognizers.
  18928. * @constructor
  18929. * @extends Recognizer
  18930. */
  18931. function AttrRecognizer() {
  18932. Recognizer.apply(this, arguments);
  18933. }
  18934. inherit(AttrRecognizer, Recognizer, {
  18935. /**
  18936. * @namespace
  18937. * @memberof AttrRecognizer
  18938. */
  18939. defaults: {
  18940. /**
  18941. * @type {Number}
  18942. * @default 1
  18943. */
  18944. pointers: 1
  18945. },
  18946. /**
  18947. * Used to check if it the recognizer receives valid input, like input.distance > 10.
  18948. * @memberof AttrRecognizer
  18949. * @param {Object} input
  18950. * @returns {Boolean} recognized
  18951. */
  18952. attrTest: function (input) {
  18953. var optionPointers = this.options.pointers;
  18954. return optionPointers === 0 || input.pointers.length === optionPointers;
  18955. },
  18956. /**
  18957. * Process the input and return the state for the recognizer
  18958. * @memberof AttrRecognizer
  18959. * @param {Object} input
  18960. * @returns {*} State
  18961. */
  18962. process: function (input) {
  18963. var state = this.state;
  18964. var eventType = input.eventType;
  18965. var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
  18966. var isValid = this.attrTest(input); // on cancel input and we've recognized before, return STATE_CANCELLED
  18967. if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
  18968. return state | STATE_CANCELLED;
  18969. } else if (isRecognized || isValid) {
  18970. if (eventType & INPUT_END) {
  18971. return state | STATE_ENDED;
  18972. } else if (!(state & STATE_BEGAN)) {
  18973. return STATE_BEGAN;
  18974. }
  18975. return state | STATE_CHANGED;
  18976. }
  18977. return STATE_FAILED;
  18978. }
  18979. });
  18980. /**
  18981. * Pan
  18982. * Recognized when the pointer is down and moved in the allowed direction.
  18983. * @constructor
  18984. * @extends AttrRecognizer
  18985. */
  18986. function PanRecognizer() {
  18987. AttrRecognizer.apply(this, arguments);
  18988. this.pX = null;
  18989. this.pY = null;
  18990. }
  18991. inherit(PanRecognizer, AttrRecognizer, {
  18992. /**
  18993. * @namespace
  18994. * @memberof PanRecognizer
  18995. */
  18996. defaults: {
  18997. event: 'pan',
  18998. threshold: 10,
  18999. pointers: 1,
  19000. direction: DIRECTION_ALL
  19001. },
  19002. getTouchAction: function () {
  19003. var direction = this.options.direction;
  19004. var actions = [];
  19005. if (direction & DIRECTION_HORIZONTAL) {
  19006. actions.push(TOUCH_ACTION_PAN_Y);
  19007. }
  19008. if (direction & DIRECTION_VERTICAL) {
  19009. actions.push(TOUCH_ACTION_PAN_X);
  19010. }
  19011. return actions;
  19012. },
  19013. directionTest: function (input) {
  19014. var options = this.options;
  19015. var hasMoved = true;
  19016. var distance = input.distance;
  19017. var direction = input.direction;
  19018. var x = input.deltaX;
  19019. var y = input.deltaY; // lock to axis?
  19020. if (!(direction & options.direction)) {
  19021. if (options.direction & DIRECTION_HORIZONTAL) {
  19022. direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
  19023. hasMoved = x != this.pX;
  19024. distance = Math.abs(input.deltaX);
  19025. } else {
  19026. direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
  19027. hasMoved = y != this.pY;
  19028. distance = Math.abs(input.deltaY);
  19029. }
  19030. }
  19031. input.direction = direction;
  19032. return hasMoved && distance > options.threshold && direction & options.direction;
  19033. },
  19034. attrTest: function (input) {
  19035. return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
  19036. },
  19037. emit: function (input) {
  19038. this.pX = input.deltaX;
  19039. this.pY = input.deltaY;
  19040. var direction = directionStr(input.direction);
  19041. if (direction) {
  19042. input.additionalEvent = this.options.event + direction;
  19043. }
  19044. this._super.emit.call(this, input);
  19045. }
  19046. });
  19047. /**
  19048. * Pinch
  19049. * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
  19050. * @constructor
  19051. * @extends AttrRecognizer
  19052. */
  19053. function PinchRecognizer() {
  19054. AttrRecognizer.apply(this, arguments);
  19055. }
  19056. inherit(PinchRecognizer, AttrRecognizer, {
  19057. /**
  19058. * @namespace
  19059. * @memberof PinchRecognizer
  19060. */
  19061. defaults: {
  19062. event: 'pinch',
  19063. threshold: 0,
  19064. pointers: 2
  19065. },
  19066. getTouchAction: function () {
  19067. return [TOUCH_ACTION_NONE];
  19068. },
  19069. attrTest: function (input) {
  19070. return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
  19071. },
  19072. emit: function (input) {
  19073. if (input.scale !== 1) {
  19074. var inOut = input.scale < 1 ? 'in' : 'out';
  19075. input.additionalEvent = this.options.event + inOut;
  19076. }
  19077. this._super.emit.call(this, input);
  19078. }
  19079. });
  19080. /**
  19081. * Press
  19082. * Recognized when the pointer is down for x ms without any movement.
  19083. * @constructor
  19084. * @extends Recognizer
  19085. */
  19086. function PressRecognizer() {
  19087. Recognizer.apply(this, arguments);
  19088. this._timer = null;
  19089. this._input = null;
  19090. }
  19091. inherit(PressRecognizer, Recognizer, {
  19092. /**
  19093. * @namespace
  19094. * @memberof PressRecognizer
  19095. */
  19096. defaults: {
  19097. event: 'press',
  19098. pointers: 1,
  19099. time: 251,
  19100. // minimal time of the pointer to be pressed
  19101. threshold: 9 // a minimal movement is ok, but keep it low
  19102. },
  19103. getTouchAction: function () {
  19104. return [TOUCH_ACTION_AUTO];
  19105. },
  19106. process: function (input) {
  19107. var options = this.options;
  19108. var validPointers = input.pointers.length === options.pointers;
  19109. var validMovement = input.distance < options.threshold;
  19110. var validTime = input.deltaTime > options.time;
  19111. this._input = input; // we only allow little movement
  19112. // and we've reached an end event, so a tap is possible
  19113. if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
  19114. this.reset();
  19115. } else if (input.eventType & INPUT_START) {
  19116. this.reset();
  19117. this._timer = setTimeoutContext(function () {
  19118. this.state = STATE_RECOGNIZED;
  19119. this.tryEmit();
  19120. }, options.time, this);
  19121. } else if (input.eventType & INPUT_END) {
  19122. return STATE_RECOGNIZED;
  19123. }
  19124. return STATE_FAILED;
  19125. },
  19126. reset: function () {
  19127. clearTimeout(this._timer);
  19128. },
  19129. emit: function (input) {
  19130. if (this.state !== STATE_RECOGNIZED) {
  19131. return;
  19132. }
  19133. if (input && input.eventType & INPUT_END) {
  19134. this.manager.emit(this.options.event + 'up', input);
  19135. } else {
  19136. this._input.timeStamp = now();
  19137. this.manager.emit(this.options.event, this._input);
  19138. }
  19139. }
  19140. });
  19141. /**
  19142. * Rotate
  19143. * Recognized when two or more pointer are moving in a circular motion.
  19144. * @constructor
  19145. * @extends AttrRecognizer
  19146. */
  19147. function RotateRecognizer() {
  19148. AttrRecognizer.apply(this, arguments);
  19149. }
  19150. inherit(RotateRecognizer, AttrRecognizer, {
  19151. /**
  19152. * @namespace
  19153. * @memberof RotateRecognizer
  19154. */
  19155. defaults: {
  19156. event: 'rotate',
  19157. threshold: 0,
  19158. pointers: 2
  19159. },
  19160. getTouchAction: function () {
  19161. return [TOUCH_ACTION_NONE];
  19162. },
  19163. attrTest: function (input) {
  19164. return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
  19165. }
  19166. });
  19167. /**
  19168. * Swipe
  19169. * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
  19170. * @constructor
  19171. * @extends AttrRecognizer
  19172. */
  19173. function SwipeRecognizer() {
  19174. AttrRecognizer.apply(this, arguments);
  19175. }
  19176. inherit(SwipeRecognizer, AttrRecognizer, {
  19177. /**
  19178. * @namespace
  19179. * @memberof SwipeRecognizer
  19180. */
  19181. defaults: {
  19182. event: 'swipe',
  19183. threshold: 10,
  19184. velocity: 0.3,
  19185. direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
  19186. pointers: 1
  19187. },
  19188. getTouchAction: function () {
  19189. return PanRecognizer.prototype.getTouchAction.call(this);
  19190. },
  19191. attrTest: function (input) {
  19192. var direction = this.options.direction;
  19193. var velocity;
  19194. if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
  19195. velocity = input.overallVelocity;
  19196. } else if (direction & DIRECTION_HORIZONTAL) {
  19197. velocity = input.overallVelocityX;
  19198. } else if (direction & DIRECTION_VERTICAL) {
  19199. velocity = input.overallVelocityY;
  19200. }
  19201. return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
  19202. },
  19203. emit: function (input) {
  19204. var direction = directionStr(input.offsetDirection);
  19205. if (direction) {
  19206. this.manager.emit(this.options.event + direction, input);
  19207. }
  19208. this.manager.emit(this.options.event, input);
  19209. }
  19210. });
  19211. /**
  19212. * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
  19213. * between the given interval and position. The delay option can be used to recognize multi-taps without firing
  19214. * a single tap.
  19215. *
  19216. * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
  19217. * multi-taps being recognized.
  19218. * @constructor
  19219. * @extends Recognizer
  19220. */
  19221. function TapRecognizer() {
  19222. Recognizer.apply(this, arguments); // previous time and center,
  19223. // used for tap counting
  19224. this.pTime = false;
  19225. this.pCenter = false;
  19226. this._timer = null;
  19227. this._input = null;
  19228. this.count = 0;
  19229. }
  19230. inherit(TapRecognizer, Recognizer, {
  19231. /**
  19232. * @namespace
  19233. * @memberof PinchRecognizer
  19234. */
  19235. defaults: {
  19236. event: 'tap',
  19237. pointers: 1,
  19238. taps: 1,
  19239. interval: 300,
  19240. // max time between the multi-tap taps
  19241. time: 250,
  19242. // max time of the pointer to be down (like finger on the screen)
  19243. threshold: 9,
  19244. // a minimal movement is ok, but keep it low
  19245. posThreshold: 10 // a multi-tap can be a bit off the initial position
  19246. },
  19247. getTouchAction: function () {
  19248. return [TOUCH_ACTION_MANIPULATION];
  19249. },
  19250. process: function (input) {
  19251. var options = this.options;
  19252. var validPointers = input.pointers.length === options.pointers;
  19253. var validMovement = input.distance < options.threshold;
  19254. var validTouchTime = input.deltaTime < options.time;
  19255. this.reset();
  19256. if (input.eventType & INPUT_START && this.count === 0) {
  19257. return this.failTimeout();
  19258. } // we only allow little movement
  19259. // and we've reached an end event, so a tap is possible
  19260. if (validMovement && validTouchTime && validPointers) {
  19261. if (input.eventType != INPUT_END) {
  19262. return this.failTimeout();
  19263. }
  19264. var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
  19265. var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
  19266. this.pTime = input.timeStamp;
  19267. this.pCenter = input.center;
  19268. if (!validMultiTap || !validInterval) {
  19269. this.count = 1;
  19270. } else {
  19271. this.count += 1;
  19272. }
  19273. this._input = input; // if tap count matches we have recognized it,
  19274. // else it has began recognizing...
  19275. var tapCount = this.count % options.taps;
  19276. if (tapCount === 0) {
  19277. // no failing requirements, immediately trigger the tap event
  19278. // or wait as long as the multitap interval to trigger
  19279. if (!this.hasRequireFailures()) {
  19280. return STATE_RECOGNIZED;
  19281. } else {
  19282. this._timer = setTimeoutContext(function () {
  19283. this.state = STATE_RECOGNIZED;
  19284. this.tryEmit();
  19285. }, options.interval, this);
  19286. return STATE_BEGAN;
  19287. }
  19288. }
  19289. }
  19290. return STATE_FAILED;
  19291. },
  19292. failTimeout: function () {
  19293. this._timer = setTimeoutContext(function () {
  19294. this.state = STATE_FAILED;
  19295. }, this.options.interval, this);
  19296. return STATE_FAILED;
  19297. },
  19298. reset: function () {
  19299. clearTimeout(this._timer);
  19300. },
  19301. emit: function () {
  19302. if (this.state == STATE_RECOGNIZED) {
  19303. this._input.tapCount = this.count;
  19304. this.manager.emit(this.options.event, this._input);
  19305. }
  19306. }
  19307. });
  19308. /**
  19309. * Simple way to create a manager with a default set of recognizers.
  19310. * @param {HTMLElement} element
  19311. * @param {Object} [options]
  19312. * @constructor
  19313. */
  19314. function Hammer(element, options) {
  19315. options = options || {};
  19316. options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
  19317. return new Manager(element, options);
  19318. }
  19319. /**
  19320. * @const {string}
  19321. */
  19322. Hammer.VERSION = '2.0.7';
  19323. /**
  19324. * default settings
  19325. * @namespace
  19326. */
  19327. Hammer.defaults = {
  19328. /**
  19329. * set if DOM events are being triggered.
  19330. * But this is slower and unused by simple implementations, so disabled by default.
  19331. * @type {Boolean}
  19332. * @default false
  19333. */
  19334. domEvents: false,
  19335. /**
  19336. * The value for the touchAction property/fallback.
  19337. * When set to `compute` it will magically set the correct value based on the added recognizers.
  19338. * @type {String}
  19339. * @default compute
  19340. */
  19341. touchAction: TOUCH_ACTION_COMPUTE,
  19342. /**
  19343. * @type {Boolean}
  19344. * @default true
  19345. */
  19346. enable: true,
  19347. /**
  19348. * EXPERIMENTAL FEATURE -- can be removed/changed
  19349. * Change the parent input target element.
  19350. * If Null, then it is being set the to main element.
  19351. * @type {Null|EventTarget}
  19352. * @default null
  19353. */
  19354. inputTarget: null,
  19355. /**
  19356. * force an input class
  19357. * @type {Null|Function}
  19358. * @default null
  19359. */
  19360. inputClass: null,
  19361. /**
  19362. * Default recognizer setup when calling `Hammer()`
  19363. * When creating a new Manager these will be skipped.
  19364. * @type {Array}
  19365. */
  19366. preset: [// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
  19367. [RotateRecognizer, {
  19368. enable: false
  19369. }], [PinchRecognizer, {
  19370. enable: false
  19371. }, ['rotate']], [SwipeRecognizer, {
  19372. direction: DIRECTION_HORIZONTAL
  19373. }], [PanRecognizer, {
  19374. direction: DIRECTION_HORIZONTAL
  19375. }, ['swipe']], [TapRecognizer], [TapRecognizer, {
  19376. event: 'doubletap',
  19377. taps: 2
  19378. }, ['tap']], [PressRecognizer]],
  19379. /**
  19380. * Some CSS properties can be used to improve the working of Hammer.
  19381. * Add them to this method and they will be set when creating a new Manager.
  19382. * @namespace
  19383. */
  19384. cssProps: {
  19385. /**
  19386. * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
  19387. * @type {String}
  19388. * @default 'none'
  19389. */
  19390. userSelect: 'none',
  19391. /**
  19392. * Disable the Windows Phone grippers when pressing an element.
  19393. * @type {String}
  19394. * @default 'none'
  19395. */
  19396. touchSelect: 'none',
  19397. /**
  19398. * Disables the default callout shown when you touch and hold a touch target.
  19399. * On iOS, when you touch and hold a touch target such as a link, Safari displays
  19400. * a callout containing information about the link. This property allows you to disable that callout.
  19401. * @type {String}
  19402. * @default 'none'
  19403. */
  19404. touchCallout: 'none',
  19405. /**
  19406. * Specifies whether zooming is enabled. Used by IE10>
  19407. * @type {String}
  19408. * @default 'none'
  19409. */
  19410. contentZooming: 'none',
  19411. /**
  19412. * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
  19413. * @type {String}
  19414. * @default 'none'
  19415. */
  19416. userDrag: 'none',
  19417. /**
  19418. * Overrides the highlight color shown when the user taps a link or a JavaScript
  19419. * clickable element in iOS. This property obeys the alpha value, if specified.
  19420. * @type {String}
  19421. * @default 'rgba(0,0,0,0)'
  19422. */
  19423. tapHighlightColor: 'rgba(0,0,0,0)'
  19424. }
  19425. };
  19426. var STOP = 1;
  19427. var FORCED_STOP = 2;
  19428. /**
  19429. * Manager
  19430. * @param {HTMLElement} element
  19431. * @param {Object} [options]
  19432. * @constructor
  19433. */
  19434. function Manager(element, options) {
  19435. this.options = assign({}, Hammer.defaults, options || {});
  19436. this.options.inputTarget = this.options.inputTarget || element;
  19437. this.handlers = {};
  19438. this.session = {};
  19439. this.recognizers = [];
  19440. this.oldCssProps = {};
  19441. this.element = element;
  19442. this.input = createInputInstance(this);
  19443. this.touchAction = new TouchAction(this, this.options.touchAction);
  19444. toggleCssProps(this, true);
  19445. each(this.options.recognizers, function (item) {
  19446. var recognizer = this.add(new item[0](item[1]));
  19447. item[2] && recognizer.recognizeWith(item[2]);
  19448. item[3] && recognizer.requireFailure(item[3]);
  19449. }, this);
  19450. }
  19451. Manager.prototype = {
  19452. /**
  19453. * set options
  19454. * @param {Object} options
  19455. * @returns {Manager}
  19456. */
  19457. set: function (options) {
  19458. assign(this.options, options); // Options that need a little more setup
  19459. if (options.touchAction) {
  19460. this.touchAction.update();
  19461. }
  19462. if (options.inputTarget) {
  19463. // Clean up existing event listeners and reinitialize
  19464. this.input.destroy();
  19465. this.input.target = options.inputTarget;
  19466. this.input.init();
  19467. }
  19468. return this;
  19469. },
  19470. /**
  19471. * stop recognizing for this session.
  19472. * This session will be discarded, when a new [input]start event is fired.
  19473. * When forced, the recognizer cycle is stopped immediately.
  19474. * @param {Boolean} [force]
  19475. */
  19476. stop: function (force) {
  19477. this.session.stopped = force ? FORCED_STOP : STOP;
  19478. },
  19479. /**
  19480. * run the recognizers!
  19481. * called by the inputHandler function on every movement of the pointers (touches)
  19482. * it walks through all the recognizers and tries to detect the gesture that is being made
  19483. * @param {Object} inputData
  19484. */
  19485. recognize: function (inputData) {
  19486. var session = this.session;
  19487. if (session.stopped) {
  19488. return;
  19489. } // run the touch-action polyfill
  19490. this.touchAction.preventDefaults(inputData);
  19491. var recognizer;
  19492. var recognizers = this.recognizers; // this holds the recognizer that is being recognized.
  19493. // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
  19494. // if no recognizer is detecting a thing, it is set to `null`
  19495. var curRecognizer = session.curRecognizer; // reset when the last recognizer is recognized
  19496. // or when we're in a new session
  19497. if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
  19498. curRecognizer = session.curRecognizer = null;
  19499. }
  19500. var i = 0;
  19501. while (i < recognizers.length) {
  19502. recognizer = recognizers[i]; // find out if we are allowed try to recognize the input for this one.
  19503. // 1. allow if the session is NOT forced stopped (see the .stop() method)
  19504. // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
  19505. // that is being recognized.
  19506. // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
  19507. // this can be setup with the `recognizeWith()` method on the recognizer.
  19508. if (session.stopped !== FORCED_STOP && ( // 1
  19509. !curRecognizer || recognizer == curRecognizer || // 2
  19510. recognizer.canRecognizeWith(curRecognizer))) {
  19511. // 3
  19512. recognizer.recognize(inputData);
  19513. } else {
  19514. recognizer.reset();
  19515. } // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
  19516. // current active recognizer. but only if we don't already have an active recognizer
  19517. if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
  19518. curRecognizer = session.curRecognizer = recognizer;
  19519. }
  19520. i++;
  19521. }
  19522. },
  19523. /**
  19524. * get a recognizer by its event name.
  19525. * @param {Recognizer|String} recognizer
  19526. * @returns {Recognizer|Null}
  19527. */
  19528. get: function (recognizer) {
  19529. if (recognizer instanceof Recognizer) {
  19530. return recognizer;
  19531. }
  19532. var recognizers = this.recognizers;
  19533. for (var i = 0; i < recognizers.length; i++) {
  19534. if (recognizers[i].options.event == recognizer) {
  19535. return recognizers[i];
  19536. }
  19537. }
  19538. return null;
  19539. },
  19540. /**
  19541. * add a recognizer to the manager
  19542. * existing recognizers with the same event name will be removed
  19543. * @param {Recognizer} recognizer
  19544. * @returns {Recognizer|Manager}
  19545. */
  19546. add: function (recognizer) {
  19547. if (invokeArrayArg(recognizer, 'add', this)) {
  19548. return this;
  19549. } // remove existing
  19550. var existing = this.get(recognizer.options.event);
  19551. if (existing) {
  19552. this.remove(existing);
  19553. }
  19554. this.recognizers.push(recognizer);
  19555. recognizer.manager = this;
  19556. this.touchAction.update();
  19557. return recognizer;
  19558. },
  19559. /**
  19560. * remove a recognizer by name or instance
  19561. * @param {Recognizer|String} recognizer
  19562. * @returns {Manager}
  19563. */
  19564. remove: function (recognizer) {
  19565. if (invokeArrayArg(recognizer, 'remove', this)) {
  19566. return this;
  19567. }
  19568. recognizer = this.get(recognizer); // let's make sure this recognizer exists
  19569. if (recognizer) {
  19570. var recognizers = this.recognizers;
  19571. var index = inArray(recognizers, recognizer);
  19572. if (index !== -1) {
  19573. recognizers.splice(index, 1);
  19574. this.touchAction.update();
  19575. }
  19576. }
  19577. return this;
  19578. },
  19579. /**
  19580. * bind event
  19581. * @param {String} events
  19582. * @param {Function} handler
  19583. * @returns {EventEmitter} this
  19584. */
  19585. on: function (events, handler) {
  19586. if (events === undefined) {
  19587. return;
  19588. }
  19589. if (handler === undefined) {
  19590. return;
  19591. }
  19592. var handlers = this.handlers;
  19593. each(splitStr(events), function (event) {
  19594. handlers[event] = handlers[event] || [];
  19595. handlers[event].push(handler);
  19596. });
  19597. return this;
  19598. },
  19599. /**
  19600. * unbind event, leave emit blank to remove all handlers
  19601. * @param {String} events
  19602. * @param {Function} [handler]
  19603. * @returns {EventEmitter} this
  19604. */
  19605. off: function (events, handler) {
  19606. if (events === undefined) {
  19607. return;
  19608. }
  19609. var handlers = this.handlers;
  19610. each(splitStr(events), function (event) {
  19611. if (!handler) {
  19612. delete handlers[event];
  19613. } else {
  19614. handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
  19615. }
  19616. });
  19617. return this;
  19618. },
  19619. /**
  19620. * emit event to the listeners
  19621. * @param {String} event
  19622. * @param {Object} data
  19623. */
  19624. emit: function (event, data) {
  19625. // we also want to trigger dom events
  19626. if (this.options.domEvents) {
  19627. triggerDomEvent(event, data);
  19628. } // no handlers, so skip it all
  19629. var handlers = this.handlers[event] && this.handlers[event].slice();
  19630. if (!handlers || !handlers.length) {
  19631. return;
  19632. }
  19633. data.type = event;
  19634. data.preventDefault = function () {
  19635. data.srcEvent.preventDefault();
  19636. };
  19637. var i = 0;
  19638. while (i < handlers.length) {
  19639. handlers[i](data);
  19640. i++;
  19641. }
  19642. },
  19643. /**
  19644. * destroy the manager and unbinds all events
  19645. * it doesn't unbind dom events, that is the user own responsibility
  19646. */
  19647. destroy: function () {
  19648. this.element && toggleCssProps(this, false);
  19649. this.handlers = {};
  19650. this.session = {};
  19651. this.input.destroy();
  19652. this.element = null;
  19653. }
  19654. };
  19655. /**
  19656. * add/remove the css properties as defined in manager.options.cssProps
  19657. * @param {Manager} manager
  19658. * @param {Boolean} add
  19659. */
  19660. function toggleCssProps(manager, add) {
  19661. var element = manager.element;
  19662. if (!element.style) {
  19663. return;
  19664. }
  19665. var prop;
  19666. each(manager.options.cssProps, function (value, name) {
  19667. prop = prefixed(element.style, name);
  19668. if (add) {
  19669. manager.oldCssProps[prop] = element.style[prop];
  19670. element.style[prop] = value;
  19671. } else {
  19672. element.style[prop] = manager.oldCssProps[prop] || '';
  19673. }
  19674. });
  19675. if (!add) {
  19676. manager.oldCssProps = {};
  19677. }
  19678. }
  19679. /**
  19680. * trigger dom event
  19681. * @param {String} event
  19682. * @param {Object} data
  19683. */
  19684. function triggerDomEvent(event, data) {
  19685. var gestureEvent = document.createEvent('Event');
  19686. gestureEvent.initEvent(event, true, true);
  19687. gestureEvent.gesture = data;
  19688. data.target.dispatchEvent(gestureEvent);
  19689. }
  19690. assign(Hammer, {
  19691. INPUT_START: INPUT_START,
  19692. INPUT_MOVE: INPUT_MOVE,
  19693. INPUT_END: INPUT_END,
  19694. INPUT_CANCEL: INPUT_CANCEL,
  19695. STATE_POSSIBLE: STATE_POSSIBLE,
  19696. STATE_BEGAN: STATE_BEGAN,
  19697. STATE_CHANGED: STATE_CHANGED,
  19698. STATE_ENDED: STATE_ENDED,
  19699. STATE_RECOGNIZED: STATE_RECOGNIZED,
  19700. STATE_CANCELLED: STATE_CANCELLED,
  19701. STATE_FAILED: STATE_FAILED,
  19702. DIRECTION_NONE: DIRECTION_NONE,
  19703. DIRECTION_LEFT: DIRECTION_LEFT,
  19704. DIRECTION_RIGHT: DIRECTION_RIGHT,
  19705. DIRECTION_UP: DIRECTION_UP,
  19706. DIRECTION_DOWN: DIRECTION_DOWN,
  19707. DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
  19708. DIRECTION_VERTICAL: DIRECTION_VERTICAL,
  19709. DIRECTION_ALL: DIRECTION_ALL,
  19710. Manager: Manager,
  19711. Input: Input,
  19712. TouchAction: TouchAction,
  19713. TouchInput: TouchInput,
  19714. MouseInput: MouseInput,
  19715. PointerEventInput: PointerEventInput,
  19716. TouchMouseInput: TouchMouseInput,
  19717. SingleTouchInput: SingleTouchInput,
  19718. Recognizer: Recognizer,
  19719. AttrRecognizer: AttrRecognizer,
  19720. Tap: TapRecognizer,
  19721. Pan: PanRecognizer,
  19722. Swipe: SwipeRecognizer,
  19723. Pinch: PinchRecognizer,
  19724. Rotate: RotateRecognizer,
  19725. Press: PressRecognizer,
  19726. on: addEventListeners,
  19727. off: removeEventListeners,
  19728. each: each,
  19729. merge: merge,
  19730. extend: extend,
  19731. assign: assign,
  19732. inherit: inherit,
  19733. bindFn: bindFn,
  19734. prefixed: prefixed
  19735. }); // this prevents errors when Hammer is loaded in the presence of an AMD
  19736. // style loader but by script tag, not by the loader.
  19737. var freeGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}; // jshint ignore:line
  19738. freeGlobal.Hammer = Hammer;
  19739. if (true) {
  19740. !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
  19741. return Hammer;
  19742. }.call(exports, __webpack_require__, exports, module),
  19743. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  19744. } else if (typeof module != 'undefined' && module.exports) {
  19745. module.exports = Hammer;
  19746. } else {
  19747. window[exportName] = Hammer;
  19748. }
  19749. })(window, document, 'Hammer');
  19750. /***/ }),
  19751. /* 260 */
  19752. /***/ (function(module, exports, __webpack_require__) {
  19753. "use strict";
  19754. var _interopRequireDefault = __webpack_require__(1);
  19755. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  19756. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  19757. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  19758. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  19759. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  19760. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  19761. var Util = __webpack_require__(0);
  19762. var Interaction = __webpack_require__(74);
  19763. var Chart = __webpack_require__(30);
  19764. var PieSelect = /*#__PURE__*/function (_Interaction) {
  19765. (0, _inheritsLoose2["default"])(PieSelect, _Interaction);
  19766. var _super = _createSuper(PieSelect);
  19767. var _proto = PieSelect.prototype;
  19768. _proto.getDefaultCfg = function getDefaultCfg() {
  19769. var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
  19770. defaultCfg = Util.mix({}, defaultCfg, {
  19771. startEvent: 'tap',
  19772. processEvent: null,
  19773. animate: false,
  19774. offset: 1,
  19775. appendRadius: 8,
  19776. style: {
  19777. fillOpacity: 0.5
  19778. },
  19779. cancelable: true,
  19780. defaultSelected: null // set the default selected shape
  19781. });
  19782. if (Util.isWx || Util.isMy) {
  19783. // 小程序
  19784. defaultCfg.startEvent = 'touchstart';
  19785. defaultCfg.endEvent = 'touchend';
  19786. }
  19787. return defaultCfg;
  19788. };
  19789. function PieSelect(cfg, chart) {
  19790. var _this;
  19791. _this = _Interaction.call(this, cfg, chart) || this;
  19792. var self = (0, _assertThisInitialized2["default"])(_this);
  19793. chart.registerPlugins({
  19794. clearInner: function clearInner() {
  19795. self.halo && self.halo.remove(true);
  19796. self.selected = false;
  19797. self.selectedShape = null;
  19798. self.lastShape = null;
  19799. self.halo = null;
  19800. self.defaultSelected = null;
  19801. }
  19802. });
  19803. var defaultSelected = self.defaultSelected;
  19804. if (Util.isObject(defaultSelected)) {
  19805. var selectedShape = self._getSelectedShapeByData(defaultSelected);
  19806. selectedShape && self._selectedShape(selectedShape);
  19807. _this.canvas.draw();
  19808. }
  19809. return _this;
  19810. }
  19811. _proto._getSelectedShapeByData = function _getSelectedShapeByData(data) {
  19812. var selectedShape = null;
  19813. var chart = this.chart;
  19814. var geom = chart.get('geoms')[0];
  19815. var container = geom.get('container');
  19816. var children = container.get('children');
  19817. Util.each(children, function (child) {
  19818. if (child.get('isShape') && child.get('className') === geom.get('type')) {
  19819. // get geometry's shape
  19820. var shapeData = child.get('origin')._origin;
  19821. if (Util.isObjectValueEqual(shapeData, data)) {
  19822. selectedShape = child;
  19823. return false;
  19824. }
  19825. }
  19826. });
  19827. return selectedShape;
  19828. };
  19829. _proto._selectedShape = function _selectedShape(selectedShape) {
  19830. var offset = this.offset,
  19831. style = this.style,
  19832. appendRadius = this.appendRadius,
  19833. chart = this.chart;
  19834. this.lastShape = selectedShape;
  19835. var _selectedShape$_attrs = selectedShape._attrs.attrs,
  19836. x = _selectedShape$_attrs.x,
  19837. y = _selectedShape$_attrs.y,
  19838. startAngle = _selectedShape$_attrs.startAngle,
  19839. endAngle = _selectedShape$_attrs.endAngle,
  19840. r = _selectedShape$_attrs.r,
  19841. fill = _selectedShape$_attrs.fill;
  19842. var frontPlot = chart.get('frontPlot');
  19843. var halo = frontPlot.addShape('sector', {
  19844. attrs: Util.mix({
  19845. x: x,
  19846. y: y,
  19847. r: r + offset + appendRadius,
  19848. r0: r + offset,
  19849. fill: fill,
  19850. startAngle: startAngle,
  19851. endAngle: endAngle
  19852. }, style)
  19853. });
  19854. this.halo = halo;
  19855. var animate = this.animate;
  19856. if (animate) {
  19857. if (animate === true) {
  19858. animate = {
  19859. duration: 300
  19860. };
  19861. }
  19862. halo.attr('r', r + offset);
  19863. halo.animate().to(Util.mix({
  19864. attrs: {
  19865. r: r + offset + appendRadius
  19866. }
  19867. }, animate));
  19868. }
  19869. };
  19870. _proto.start = function start(ev) {
  19871. var chart = this.chart;
  19872. if (ev.type === 'tap') {
  19873. ev.clientX = ev.center.x;
  19874. ev.clientY = ev.center.y;
  19875. }
  19876. var _Util$createEvent = Util.createEvent(ev, chart),
  19877. x = _Util$createEvent.x,
  19878. y = _Util$createEvent.y;
  19879. var records = chart.getSnapRecords({
  19880. x: x,
  19881. y: y
  19882. });
  19883. if (!records.length) {
  19884. this.selected = false;
  19885. this.selectedShape = null;
  19886. return;
  19887. }
  19888. var data = records[0]._origin;
  19889. var selectedShape = this._getSelectedShapeByData(data);
  19890. var lastShape = this.lastShape;
  19891. this.selectedShape = selectedShape;
  19892. this.selected = true;
  19893. if (selectedShape === lastShape) {
  19894. if (!this.cancelable) {
  19895. return;
  19896. }
  19897. this.halo && this.halo.remove(true);
  19898. this.lastShape = null;
  19899. this.selected = false;
  19900. } else {
  19901. this.halo && this.halo.remove(true);
  19902. this._selectedShape(selectedShape);
  19903. }
  19904. this.canvas.draw();
  19905. };
  19906. _proto.end = function end(ev) {
  19907. var selectedShape = this.selectedShape;
  19908. if (selectedShape && !selectedShape.get('destroyed')) {
  19909. ev.data = selectedShape.get('origin')._origin;
  19910. ev.shapeInfo = selectedShape.get('origin');
  19911. ev.shape = selectedShape;
  19912. ev.selected = !!this.selected;
  19913. }
  19914. };
  19915. return PieSelect;
  19916. }(Interaction);
  19917. Chart.registerInteraction('pie-select', PieSelect);
  19918. module.exports = PieSelect;
  19919. /***/ }),
  19920. /* 261 */
  19921. /***/ (function(module, exports, __webpack_require__) {
  19922. "use strict";
  19923. var _interopRequireDefault = __webpack_require__(1);
  19924. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  19925. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  19926. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  19927. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  19928. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  19929. var Util = __webpack_require__(0);
  19930. var Helper = __webpack_require__(37);
  19931. var Interaction = __webpack_require__(74);
  19932. var Chart = __webpack_require__(30);
  19933. var IntervalSelect = /*#__PURE__*/function (_Interaction) {
  19934. (0, _inheritsLoose2["default"])(IntervalSelect, _Interaction);
  19935. var _super = _createSuper(IntervalSelect);
  19936. var _proto = IntervalSelect.prototype;
  19937. _proto.getDefaultCfg = function getDefaultCfg() {
  19938. var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
  19939. defaultCfg = Util.mix({}, defaultCfg, {
  19940. startEvent: 'tap',
  19941. processEvent: null,
  19942. selectAxis: true,
  19943. selectAxisStyle: {
  19944. fontWeight: 'bold'
  19945. },
  19946. mode: 'shape',
  19947. selectStyle: {
  19948. fillOpacity: 1
  19949. },
  19950. unSelectStyle: {
  19951. fillOpacity: 0.4
  19952. },
  19953. cancelable: true,
  19954. defaultSelected: null // set the default selected shape
  19955. });
  19956. if (Util.isWx || Util.isMy) {
  19957. // 小程序
  19958. defaultCfg.startEvent = 'touchstart';
  19959. defaultCfg.endEvent = 'touchend';
  19960. }
  19961. return defaultCfg;
  19962. };
  19963. function IntervalSelect(cfg, chart) {
  19964. var _this;
  19965. _this = _Interaction.call(this, cfg, chart) || this;
  19966. var defaultSelected = _this.defaultSelected;
  19967. if (Util.isObject(defaultSelected)) {
  19968. var _this$_selectShapesBy = _this._selectShapesByData(defaultSelected),
  19969. selectedShape = _this$_selectShapesBy.selectedShape,
  19970. unSelectedShapes = _this$_selectShapesBy.unSelectedShapes;
  19971. selectedShape && _this._selectShapes(selectedShape, unSelectedShapes);
  19972. _this.selectedShape = selectedShape;
  19973. }
  19974. return _this;
  19975. }
  19976. _proto._getIntervalShapes = function _getIntervalShapes() {
  19977. var children = [];
  19978. var chart = this.chart;
  19979. var geoms = chart.get('geoms');
  19980. geoms.forEach(function (geom) {
  19981. if (geom.get('type') === 'interval') {
  19982. // only works for Interval geometry type
  19983. var container = geom.get('container');
  19984. children = children.concat(container.get('children'));
  19985. }
  19986. });
  19987. return children;
  19988. };
  19989. _proto._resetShape = function _resetShape(shape) {
  19990. var originAttrs = shape.get('_originAttrs');
  19991. if (originAttrs) {
  19992. shape._attrs.attrs = originAttrs;
  19993. shape.set('_originAttrs', null);
  19994. }
  19995. };
  19996. _proto._setEventData = function _setEventData(ev) {
  19997. var selectedShape = this.selectedShape;
  19998. if (selectedShape && !selectedShape.get('destroyed')) {
  19999. ev.data = selectedShape.get('origin')._origin;
  20000. ev.shapeInfo = selectedShape.get('origin');
  20001. ev.shape = selectedShape;
  20002. ev.selected = !!selectedShape.get('_selected');
  20003. }
  20004. };
  20005. _proto._selectShapesByData = function _selectShapesByData(data) {
  20006. var children = this._getIntervalShapes();
  20007. var selectedShape = null;
  20008. var unSelectedShapes = [];
  20009. Util.each(children, function (child) {
  20010. if (child.get('isShape') && child.get('className') === 'interval') {
  20011. // get geometry's shape
  20012. var shapeData = child.get('origin')._origin;
  20013. if (Util.isObjectValueEqual(shapeData, data)) {
  20014. selectedShape = child;
  20015. } else {
  20016. unSelectedShapes.push(child);
  20017. }
  20018. }
  20019. });
  20020. return {
  20021. selectedShape: selectedShape,
  20022. unSelectedShapes: unSelectedShapes
  20023. };
  20024. };
  20025. _proto._selectShapes = function _selectShapes(selectedShape, unSelectedShapes) {
  20026. var selectStyle = this.selectStyle,
  20027. unSelectStyle = this.unSelectStyle,
  20028. selectAxisStyle = this.selectAxisStyle,
  20029. chart = this.chart;
  20030. if (!selectedShape.get('_originAttrs')) {
  20031. var originAttrs = Object.assign({}, selectedShape.attr());
  20032. selectedShape.set('_originAttrs', originAttrs);
  20033. }
  20034. selectedShape.attr(selectStyle);
  20035. Util.each(unSelectedShapes, function (child) {
  20036. if (!child.get('_originAttrs')) {
  20037. var _originAttrs = Object.assign({}, child.attr());
  20038. child.set('_originAttrs', _originAttrs);
  20039. } else {
  20040. child.attr(child.get('_originAttrs'));
  20041. }
  20042. child.set('_selected', false);
  20043. unSelectStyle && child.attr(unSelectStyle);
  20044. });
  20045. selectedShape.set('_selected', true);
  20046. if (this.selectAxis) {
  20047. if (this.selectedAxisShape) {
  20048. this._resetShape(this.selectedAxisShape);
  20049. }
  20050. var xScale = chart.getXScale();
  20051. var origin = selectedShape.get('origin')._origin;
  20052. var _chart$get = chart.get('axisController'),
  20053. frontPlot = _chart$get.frontPlot,
  20054. backPlot = _chart$get.backPlot;
  20055. var axisShape;
  20056. Util.each(frontPlot.get('children').concat(backPlot.get('children')), function (s) {
  20057. if (s.get('value') === xScale.scale(origin[xScale.field])) {
  20058. axisShape = s;
  20059. return false;
  20060. }
  20061. });
  20062. this.selectedAxisShape = axisShape;
  20063. axisShape.set('_originAttrs', Object.assign({}, axisShape.attr()));
  20064. axisShape.attr(selectAxisStyle);
  20065. }
  20066. this.canvas.draw();
  20067. };
  20068. _proto.reset = function reset() {
  20069. var self = this;
  20070. if (!self.selectedShape) {
  20071. return;
  20072. }
  20073. var children = self._getIntervalShapes();
  20074. Util.each(children, function (child) {
  20075. self._resetShape(child);
  20076. child.set('_selected', false);
  20077. });
  20078. if (self.selectedAxisShape) {
  20079. self._resetShape(self.selectedAxisShape);
  20080. }
  20081. self.canvas.draw();
  20082. self.selectedShape = null;
  20083. self.selectedAxisShape = null;
  20084. };
  20085. _proto.start = function start(ev) {
  20086. var chart = this.chart;
  20087. if (ev.type === 'tap') {
  20088. ev.clientX = ev.center.x;
  20089. ev.clientY = ev.center.y;
  20090. }
  20091. var _Util$createEvent = Util.createEvent(ev, chart),
  20092. x = _Util$createEvent.x,
  20093. y = _Util$createEvent.y;
  20094. var mode = this.mode;
  20095. var children = this._getIntervalShapes();
  20096. var selectedShape;
  20097. var unSelectedShapes = [];
  20098. if (mode === 'shape') {
  20099. var plot = chart.get('plotRange');
  20100. if (!Helper.isPointInPlot({
  20101. x: x,
  20102. y: y
  20103. }, plot)) {
  20104. this.reset();
  20105. return;
  20106. }
  20107. Util.each(children, function (child) {
  20108. var box = child.getBBox();
  20109. if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.height + box.y) {
  20110. // inbox
  20111. selectedShape = child;
  20112. } else {
  20113. unSelectedShapes.push(child);
  20114. }
  20115. });
  20116. } else if (mode === 'range') {
  20117. var records = chart.getSnapRecords({
  20118. x: x,
  20119. y: y
  20120. });
  20121. if (!records.length) {
  20122. this.reset();
  20123. return;
  20124. }
  20125. var data = records[0]._origin;
  20126. var result = this._selectShapesByData(data);
  20127. selectedShape = result.selectedShape;
  20128. unSelectedShapes = result.unSelectedShapes;
  20129. }
  20130. if (selectedShape) {
  20131. this.selectedShape = selectedShape;
  20132. if (selectedShape.get('_selected')) {
  20133. if (!this.cancelable) {
  20134. this._setEventData(ev);
  20135. return;
  20136. }
  20137. this.reset();
  20138. } else {
  20139. this._selectShapes(selectedShape, unSelectedShapes);
  20140. }
  20141. } else {
  20142. this.reset();
  20143. }
  20144. this._setEventData(ev);
  20145. };
  20146. _proto.end = function end(ev) {
  20147. this._setEventData(ev);
  20148. };
  20149. return IntervalSelect;
  20150. }(Interaction);
  20151. Chart.registerInteraction('interval-select', IntervalSelect);
  20152. module.exports = IntervalSelect;
  20153. /***/ }),
  20154. /* 262 */
  20155. /***/ (function(module, exports, __webpack_require__) {
  20156. "use strict";
  20157. var _interopRequireDefault = __webpack_require__(1);
  20158. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  20159. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  20160. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  20161. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  20162. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  20163. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  20164. var Util = __webpack_require__(0);
  20165. var Interaction = __webpack_require__(74);
  20166. var Chart = __webpack_require__(30);
  20167. var FilterPlugin = __webpack_require__(242);
  20168. var MoveMixin = __webpack_require__(245);
  20169. var UpdateScaleMixin = __webpack_require__(243);
  20170. var Swipe = /*#__PURE__*/function (_Interaction) {
  20171. (0, _inheritsLoose2["default"])(Swipe, _Interaction);
  20172. var _super = _createSuper(Swipe);
  20173. var _proto = Swipe.prototype;
  20174. _proto.getDefaultCfg = function getDefaultCfg() {
  20175. var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
  20176. defaultCfg = Util.mix({}, defaultCfg, {
  20177. startEvent: 'touchstart',
  20178. processEvent: 'swipe',
  20179. endEvent: 'touchend',
  20180. currentDeltaX: null,
  20181. threshold: 10,
  20182. // Minimal distance required before recognizing.
  20183. velocity: 0.3,
  20184. // Minimal velocity required before recognizing, unit is in px per ms.
  20185. limitRange: {},
  20186. _timestamp: 0,
  20187. _panCumulativeDelta: 0,
  20188. speed: 5
  20189. });
  20190. return defaultCfg;
  20191. };
  20192. function Swipe(cfg, chart) {
  20193. var _this;
  20194. _this = _Interaction.call(this, cfg, chart) || this;
  20195. var self = (0, _assertThisInitialized2["default"])(_this);
  20196. var hammer = self.hammer,
  20197. threshold = self.threshold,
  20198. velocity = self.velocity;
  20199. if (hammer) {
  20200. hammer.get('swipe').set({
  20201. direction: 6,
  20202. // only support horizontal
  20203. threshold: threshold,
  20204. velocity: velocity
  20205. });
  20206. }
  20207. chart.registerPlugins([FilterPlugin, {
  20208. changeData: function changeData() {
  20209. self.limitRange = {};
  20210. },
  20211. clear: function clear() {
  20212. self.limitRange = {};
  20213. }
  20214. }]);
  20215. self.mode = 'x';
  20216. Util.mix(self, UpdateScaleMixin, MoveMixin);
  20217. return _this;
  20218. }
  20219. _proto.process = function process(e) {
  20220. this.currentDeltaX = 0;
  20221. this._handleMove(e);
  20222. };
  20223. _proto.end = function end() {
  20224. this.currentDeltaX = null;
  20225. this._panCumulativeDelta = 0;
  20226. };
  20227. return Swipe;
  20228. }(Interaction);
  20229. Chart.registerInteraction('swipe', Swipe);
  20230. module.exports = Swipe;
  20231. /***/ }),
  20232. /* 263 */
  20233. /***/ (function(module, exports, __webpack_require__) {
  20234. "use strict";
  20235. var _interopRequireDefault = __webpack_require__(1);
  20236. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  20237. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  20238. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  20239. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  20240. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  20241. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  20242. var Util = __webpack_require__(0);
  20243. var Interaction = __webpack_require__(74);
  20244. var Chart = __webpack_require__(30);
  20245. var FilterPlugin = __webpack_require__(242);
  20246. var MoveMixin = __webpack_require__(245); // const PressTooltipMixin = require('./mixin/press-tooltip');
  20247. var UpdateScaleMixin = __webpack_require__(243);
  20248. var Pan = /*#__PURE__*/function (_Interaction) {
  20249. (0, _inheritsLoose2["default"])(Pan, _Interaction);
  20250. var _super = _createSuper(Pan);
  20251. var _proto = Pan.prototype;
  20252. _proto.getDefaultCfg = function getDefaultCfg() {
  20253. var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
  20254. defaultCfg = Util.mix({}, defaultCfg, {
  20255. startEvent: 'panstart',
  20256. processEvent: 'panmove',
  20257. endEvent: 'panend',
  20258. resetEvent: 'touchend',
  20259. mode: 'x',
  20260. panThreshold: 10,
  20261. // Minimal pan distance required before recognizing
  20262. pressThreshold: 9,
  20263. // Minimal movement that is allowed while pressing
  20264. pressTime: 251,
  20265. // Minimal press time in ms
  20266. currentDeltaX: null,
  20267. currentDeltaY: null,
  20268. limitRange: {},
  20269. _timestamp: 0,
  20270. lastPoint: null,
  20271. _panCumulativeDelta: 0,
  20272. speed: 5
  20273. });
  20274. if (Util.isWx || Util.isMy) {
  20275. // 小程序
  20276. defaultCfg.startEvent = 'touchstart';
  20277. defaultCfg.processEvent = 'touchmove';
  20278. defaultCfg.endEvent = 'touchend';
  20279. }
  20280. return defaultCfg;
  20281. };
  20282. function Pan(cfg, chart) {
  20283. var _this;
  20284. _this = _Interaction.call(this, cfg, chart) || this;
  20285. var self = (0, _assertThisInitialized2["default"])(_this);
  20286. var hammer = self.hammer,
  20287. panThreshold = self.panThreshold;
  20288. if (hammer) {
  20289. hammer.get('pan').set({
  20290. threshold: panThreshold
  20291. }); // 为了兼容hammer的pan 和 tooltips里的press, 后面去hammerjs的时候需要去掉
  20292. chart.get('canvas').on('pan', function () {});
  20293. }
  20294. chart.registerPlugins([FilterPlugin, {
  20295. changeData: function changeData() {
  20296. self.limitRange = {};
  20297. },
  20298. clear: function clear() {
  20299. self.limitRange = {};
  20300. }
  20301. }]);
  20302. Util.mix((0, _assertThisInitialized2["default"])(_this), UpdateScaleMixin, MoveMixin);
  20303. return _this;
  20304. }
  20305. _proto.start = function start(e) {
  20306. if (this.pressed) return;
  20307. this.currentDeltaX = 0;
  20308. this.currentDeltaY = 0;
  20309. if (e.type === 'touchstart' || e.type === 'touchStart') {
  20310. this.lastPoint = e.touches[0];
  20311. }
  20312. this._handleMove(e);
  20313. };
  20314. _proto.process = function process(e) {
  20315. if (this.pressed) return;
  20316. this._handleMove(e);
  20317. };
  20318. _proto.end = function end() {
  20319. if (this.pressed) return;
  20320. this.currentDeltaX = null;
  20321. this.currentDeltaY = null;
  20322. this.lastPoint = null;
  20323. this._panCumulativeDelta = 0;
  20324. };
  20325. return Pan;
  20326. }(Interaction);
  20327. Chart.registerInteraction('pan', Pan);
  20328. module.exports = Pan;
  20329. /***/ }),
  20330. /* 264 */
  20331. /***/ (function(module, exports, __webpack_require__) {
  20332. "use strict";
  20333. var _interopRequireDefault = __webpack_require__(1);
  20334. var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
  20335. var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
  20336. var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
  20337. var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
  20338. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  20339. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  20340. var Util = __webpack_require__(0);
  20341. var Helper = __webpack_require__(208);
  20342. var Interaction = __webpack_require__(74);
  20343. var Chart = __webpack_require__(30);
  20344. var FilterPlugin = __webpack_require__(242);
  20345. var updateScaleMixin = __webpack_require__(243);
  20346. var Pinch = /*#__PURE__*/function (_Interaction) {
  20347. (0, _inheritsLoose2["default"])(Pinch, _Interaction);
  20348. var _super = _createSuper(Pinch);
  20349. var _proto = Pinch.prototype;
  20350. _proto.getDefaultCfg = function getDefaultCfg() {
  20351. var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
  20352. return Util.mix({}, defaultCfg, {
  20353. startEvent: 'pinchstart',
  20354. processEvent: 'pinch',
  20355. endEvent: 'pinchend',
  20356. resetEvent: 'touchend',
  20357. pressThreshold: 9,
  20358. // Minimal movement that is allowed while pressing
  20359. pressTime: 251,
  20360. // Minimal press time in ms
  20361. mode: 'x',
  20362. currentPinchScaling: null,
  20363. originValues: null,
  20364. minScale: null,
  20365. maxScale: null,
  20366. limitRange: {},
  20367. sensitivity: 1,
  20368. _pinchCumulativeDelta: 0,
  20369. _timestamp: 0
  20370. });
  20371. };
  20372. function Pinch(cfg, chart) {
  20373. var _this;
  20374. _this = _Interaction.call(this, cfg, chart) || this;
  20375. var self = (0, _assertThisInitialized2["default"])(_this);
  20376. var hammer = self.hammer;
  20377. hammer.get('pinch').set({
  20378. // open pinch recognizer
  20379. enable: true
  20380. });
  20381. chart.registerPlugins([FilterPlugin, {
  20382. changeData: function changeData() {
  20383. self.limitRange = {};
  20384. self.originTicks = null;
  20385. },
  20386. clear: function clear() {
  20387. self.limitRange = {};
  20388. self.originTicks = null;
  20389. }
  20390. }]);
  20391. Util.mix(self, updateScaleMixin);
  20392. return _this;
  20393. }
  20394. _proto.start = function start() {
  20395. if (this.pressed) return;
  20396. this.currentPinchScaling = 1;
  20397. };
  20398. _proto.process = function process(e) {
  20399. if (this.pressed) return;
  20400. this._handlePinch(e);
  20401. };
  20402. _proto.end = function end(e) {
  20403. if (this.pressed) return;
  20404. this._handlePinch(e);
  20405. this.currentPinchScaling = null; // reset
  20406. this.pinchCumulativeDelta = 0;
  20407. };
  20408. _proto._handlePinch = function _handlePinch(e) {
  20409. var currentPinchScaling = this.currentPinchScaling;
  20410. var diff = 1 / currentPinchScaling * e.scale;
  20411. var rect = e.target.getBoundingClientRect();
  20412. var offsetX = e.center.x - rect.left;
  20413. var offsetY = e.center.y - rect.top;
  20414. var center = {
  20415. x: offsetX,
  20416. y: offsetY
  20417. }; // fingers position difference
  20418. var x = Math.abs(e.pointers[0].clientX - e.pointers[1].clientX);
  20419. var y = Math.abs(e.pointers[0].clientY - e.pointers[1].clientY); // diagonal fingers will change both (xy) axes
  20420. var p = x / y;
  20421. var xy;
  20422. if (p > 0.3 && p < 1.7) {
  20423. xy = 'xy';
  20424. } else if (x > y) {
  20425. xy = 'x';
  20426. } else {
  20427. xy = 'y';
  20428. }
  20429. var lastTimestamp = this._timestamp;
  20430. var now = +new Date();
  20431. if (now - lastTimestamp > 16) {
  20432. this._doZoom(diff, center, xy);
  20433. this._timestamp = now;
  20434. } // Keep track of overall scale
  20435. this.currentPinchScaling = e.scale;
  20436. };
  20437. _proto._doZoom = function _doZoom(diff, center, whichAxes) {
  20438. var self = this;
  20439. var mode = self.mode,
  20440. chart = self.chart,
  20441. limitRange = self.limitRange; // Which axe should be modified when figers were used.
  20442. var _whichAxes;
  20443. if (mode === 'xy' && whichAxes !== undefined) {
  20444. // based on fingers positions
  20445. _whichAxes = whichAxes;
  20446. } else {
  20447. _whichAxes = 'xy';
  20448. }
  20449. var data = chart.get('data');
  20450. if (Util.directionEnabled(mode, 'x') && Util.directionEnabled(_whichAxes, 'x')) {
  20451. // x
  20452. var xScale = chart.getXScale();
  20453. var xField = xScale.field;
  20454. if (!limitRange[xField]) {
  20455. limitRange[xField] = Helper.getLimitRange(data, xScale);
  20456. }
  20457. if (xScale.isCategory) {
  20458. // 横轴为分类类型
  20459. self._zoomCatScale(xScale, diff, center);
  20460. } else if (xScale.isLinear) {
  20461. self._zoomLinearScale(xScale, diff, center, 'x');
  20462. }
  20463. this.xRange = Helper.getFieldRange(xScale, limitRange[xField], xScale.type);
  20464. }
  20465. if (Util.directionEnabled(mode, 'y') && Util.directionEnabled(_whichAxes, 'y')) {
  20466. // y
  20467. var yScales = chart.getYScales();
  20468. Util.each(yScales, function (yScale) {
  20469. var yField = yScale.field;
  20470. if (!limitRange[yField]) {
  20471. limitRange[yField] = Helper.getLimitRange(data, yScale);
  20472. }
  20473. yScale.isLinear && self._zoomLinearScale(yScale, diff, center, 'y');
  20474. });
  20475. var scale = yScales[0];
  20476. this.yRange = Helper.getFieldRange(scale, limitRange[scale.field], scale.type);
  20477. }
  20478. chart.repaint();
  20479. };
  20480. _proto._zoomLinearScale = function _zoomLinearScale(scale, zoom, center, flag) {
  20481. var chart = this.chart;
  20482. var min = scale.min,
  20483. max = scale.max,
  20484. field = scale.field;
  20485. var valueRange = max - min;
  20486. var limitRange = this.limitRange;
  20487. var originRange = limitRange[field].max - limitRange[field].min;
  20488. var coord = chart.get('coord');
  20489. var newDiff = valueRange * (zoom - 1);
  20490. if (this.minScale && zoom < 1) {
  20491. // zoom in
  20492. var maxRange = originRange / this.minScale;
  20493. newDiff = Math.max(valueRange - maxRange, newDiff);
  20494. }
  20495. if (this.maxScale && zoom >= 1) {
  20496. // zoom out
  20497. var minRange = originRange / this.maxScale;
  20498. newDiff = Math.min(valueRange - minRange, newDiff);
  20499. }
  20500. var offsetPoint = coord.invertPoint(center);
  20501. var percent = flag === 'x' ? offsetPoint.x : offsetPoint.y;
  20502. var minDelta = newDiff * percent;
  20503. var maxDelta = newDiff * (1 - percent);
  20504. var newMax = max - maxDelta;
  20505. var newMin = min + minDelta;
  20506. this.updateLinearScale(field, newMin, newMax);
  20507. } // 针对分类类型
  20508. ;
  20509. _proto._zoomCatScale = function _zoomCatScale(scale, zoom, center) {
  20510. var pinchCumulativeDelta = this._pinchCumulativeDelta;
  20511. var sensitivity = this.sensitivity;
  20512. pinchCumulativeDelta = zoom > 1 ? pinchCumulativeDelta + 1 : pinchCumulativeDelta - 1;
  20513. this._pinchCumulativeDelta = pinchCumulativeDelta;
  20514. var field = scale.field,
  20515. values = scale.values;
  20516. var chart = this.chart;
  20517. var coord = chart.get('coord');
  20518. if (!this.originTicks) {
  20519. this.originTicks = scale.ticks;
  20520. }
  20521. var originValues = this.limitRange[field];
  20522. var originValuesLen = originValues.length;
  20523. var minScale = this.minScale || 1;
  20524. var maxScale = this.maxScale || 5;
  20525. var minCount = parseInt(originValuesLen / maxScale);
  20526. var maxCount = parseInt(originValuesLen / minScale);
  20527. var currentLen = values.length;
  20528. if (pinchCumulativeDelta > 0 && currentLen <= minCount) {
  20529. return null;
  20530. }
  20531. if (pinchCumulativeDelta < 0 && currentLen >= maxCount) {
  20532. return null;
  20533. }
  20534. var lastLabelIndex = originValuesLen - 1;
  20535. var firstValue = values[0];
  20536. var lastValue = values[currentLen - 1];
  20537. var minIndex = originValues.indexOf(firstValue);
  20538. var maxIndex = originValues.indexOf(lastValue);
  20539. var chartCenter = (coord.start.x + coord.end.x) / 2;
  20540. var centerPointer = center.x;
  20541. if (Math.abs(pinchCumulativeDelta) > sensitivity) {
  20542. var deltaCount = Math.max(1, parseInt(currentLen * Math.abs(zoom - 1)));
  20543. if (pinchCumulativeDelta < 0) {
  20544. if (centerPointer >= chartCenter) {
  20545. if (minIndex <= 0) {
  20546. maxIndex = Math.min(lastLabelIndex, maxIndex + deltaCount);
  20547. } else {
  20548. minIndex = Math.max(0, minIndex - deltaCount);
  20549. }
  20550. } else if (centerPointer < chartCenter) {
  20551. if (maxIndex >= lastLabelIndex) {
  20552. minIndex = Math.max(0, minIndex - deltaCount);
  20553. } else {
  20554. maxIndex = Math.min(lastLabelIndex, maxIndex + deltaCount);
  20555. }
  20556. }
  20557. this._pinchCumulativeDelta = 0;
  20558. } else if (pinchCumulativeDelta > 0) {
  20559. if (centerPointer >= chartCenter) {
  20560. minIndex = minIndex < maxIndex ? minIndex = Math.min(maxIndex, minIndex + deltaCount) : minIndex;
  20561. } else if (centerPointer < chartCenter) {
  20562. maxIndex = maxIndex > minIndex ? maxIndex = Math.max(minIndex, maxIndex - deltaCount) : maxIndex;
  20563. }
  20564. this._pinchCumulativeDelta = 0;
  20565. }
  20566. var newValues = originValues.slice(minIndex, maxIndex + 1);
  20567. this.updateCatScale(field, newValues, this.originTicks, originValues, minIndex, maxIndex);
  20568. }
  20569. };
  20570. return Pinch;
  20571. }(Interaction);
  20572. Chart.registerInteraction('pinch', Pinch);
  20573. module.exports = Pinch;
  20574. /***/ })
  20575. /******/ ]);
  20576. });