12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["F2"] = factory();
- else
- root["F2"] = factory();
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 252);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireWildcard = __webpack_require__(49);
- exports.__esModule = true;
- var _exportNames = {
- isObjectValueEqual: true,
- parsePadding: true,
- directionEnabled: true,
- upperFirst: true,
- lowerFirst: true,
- isString: true,
- isNumber: true,
- isBoolean: true,
- isFunction: true,
- isDate: true,
- isArray: true,
- isNil: true,
- isObject: true,
- isPlainObject: true,
- isEqual: true,
- deepMix: true,
- mix: true,
- each: true,
- uniq: true,
- find: true,
- Array: true
- };
- exports.isObjectValueEqual = isObjectValueEqual;
- exports.parsePadding = parsePadding;
- exports.directionEnabled = directionEnabled;
- exports.Array = void 0;
- var _util = __webpack_require__(20);
- exports.upperFirst = _util.upperFirst;
- exports.lowerFirst = _util.lowerFirst;
- exports.isString = _util.isString;
- exports.isNumber = _util.isNumber;
- exports.isBoolean = _util.isBoolean;
- exports.isFunction = _util.isFunction;
- exports.isDate = _util.isDate;
- exports.isArray = _util.isArray;
- exports.isNil = _util.isNil;
- exports.isObject = _util.isObject;
- exports.isPlainObject = _util.isPlainObject;
- exports.isEqual = _util.isEqual;
- exports.deepMix = _util.deepMix;
- exports.mix = _util.mix;
- exports.each = _util.each;
- exports.uniq = _util.uniq;
- exports.find = _util.find;
- var ArrayUtil = _interopRequireWildcard(__webpack_require__(75));
- exports.Array = ArrayUtil;
- var _dom = __webpack_require__(62);
- Object.keys(_dom).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
- exports[key] = _dom[key];
- });
- /**
- * @fileOverview Utility for F2
- * @author dxq613 @gmail.com
- * @author sima.zhang1990@gmail.com
- */
- function isObjectValueEqual(a, b) {
- // for vue.js
- a = Object.assign({}, a);
- b = Object.assign({}, b);
- var aProps = Object.getOwnPropertyNames(a);
- var bProps = Object.getOwnPropertyNames(b);
- if (aProps.length !== bProps.length) {
- return false;
- }
- for (var i = 0, len = aProps.length; i < len; i++) {
- var propName = aProps[i];
- if (a[propName] !== b[propName]) {
- return false;
- }
- }
- return true;
- }
- function parsePadding(padding) {
- var top;
- var right;
- var bottom;
- var left;
- if ((0, _util.isNumber)(padding) || (0, _util.isString)(padding)) {
- top = bottom = left = right = padding;
- } else if ((0, _util.isArray)(padding)) {
- top = padding[0];
- right = !(0, _util.isNil)(padding[1]) ? padding[1] : padding[0];
- bottom = !(0, _util.isNil)(padding[2]) ? padding[2] : padding[0];
- left = !(0, _util.isNil)(padding[3]) ? padding[3] : right;
- }
- return [top, right, bottom, left];
- }
- function directionEnabled(mode, dir) {
- if (mode === undefined) {
- return true;
- } else if (typeof mode === 'string') {
- return mode.indexOf(dir) !== -1;
- }
- return false;
- }
- /***/ }),
- /* 1 */
- /***/ (function(module, exports) {
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {
- "default": obj
- };
- }
- module.exports = _interopRequireDefault;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- var _typeof = __webpack_require__(50);
- var assertThisInitialized = __webpack_require__(22);
- function _possibleConstructorReturn(self, call) {
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
- return call;
- }
- return assertThisInitialized(self);
- }
- module.exports = _possibleConstructorReturn;
- /***/ }),
- /* 3 */
- /***/ (function(module, exports) {
- function _getPrototypeOf(o) {
- module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- return _getPrototypeOf(o);
- }
- module.exports = _getPrototypeOf;
- /***/ }),
- /* 4 */
- /***/ (function(module, exports) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- module.exports = _inheritsLoose;
- /***/ }),
- /* 5 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- return Array.isArray ? Array.isArray(value) : Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Array');
- });
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Theme = __webpack_require__(78);
- var Util = __webpack_require__(0);
- var Global = {
- version: '3.6.3',
- scales: {},
- widthRatio: {
- column: 1 / 2,
- rose: 0.999999,
- multiplePie: 3 / 4
- },
- lineDash: [4, 4]
- };
- Global.setTheme = function (theme) {
- Util.deepMix(this, theme);
- };
- Global.setTheme(Theme);
- module.exports = Global;
- /***/ }),
- /* 7 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var isArrayLike = function (value) {
- /**
- * isArrayLike([1, 2, 3]) => true
- * isArrayLike(document.body.children) => true
- * isArrayLike('abc') => true
- * isArrayLike(Function) => false
- */
- return value !== null && typeof value !== 'function' && isFinite(value.length);
- };
- /* harmony default export */ __webpack_exports__["a"] = (isArrayLike);
- /***/ }),
- /* 8 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_object__ = __webpack_require__(29);
- function each(elements, func) {
- if (!elements) {
- return;
- }
- var rst;
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(elements)) {
- for (var i = 0, len = elements.length; i < len; i++) {
- rst = func(elements[i], i);
- if (rst === false) {
- break;
- }
- }
- } else if (Object(__WEBPACK_IMPORTED_MODULE_1__is_object__["a" /* default */])(elements)) {
- for (var k in elements) {
- if (elements.hasOwnProperty(k)) {
- rst = func(elements[k], k);
- if (rst === false) {
- break;
- }
- }
- }
- }
- }
- /* harmony default export */ __webpack_exports__["a"] = (each);
- /***/ }),
- /* 9 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /**
- * 是否为函数
- * @param {*} fn 对象
- * @return {Boolean} 是否函数
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Function');
- });
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(46);
- var Shape = /*#__PURE__*/function (_Element) {
- (0, _inheritsLoose2["default"])(Shape, _Element);
- var _super = _createSuper(Shape);
- function Shape() {
- return _Element.apply(this, arguments) || this;
- }
- var _proto = Shape.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false,
- isShape: true,
- attrs: {}
- };
- };
- _proto.getType = function getType() {
- return this._attrs.type;
- };
- _proto.drawInner = function drawInner(context) {
- var self = this;
- var attrs = self.get('attrs');
- self.createPath(context);
- var originOpacity = context.globalAlpha;
- if (self.hasFill()) {
- var fillOpacity = attrs.fillOpacity;
- if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
- context.globalAlpha = fillOpacity;
- context.fill();
- context.globalAlpha = originOpacity;
- } else {
- context.fill();
- }
- }
- if (self.hasStroke()) {
- var lineWidth = attrs.lineWidth;
- if (lineWidth > 0) {
- var strokeOpacity = attrs.strokeOpacity;
- if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
- context.globalAlpha = strokeOpacity;
- }
- context.stroke();
- }
- }
- };
- _proto.getBBox = function getBBox() {
- var bbox = this._attrs.bbox;
- if (!bbox) {
- bbox = this.calculateBox();
- if (bbox) {
- bbox.x = bbox.minX;
- bbox.y = bbox.minY;
- bbox.width = bbox.maxX - bbox.minX;
- bbox.height = bbox.maxY - bbox.minY;
- }
- this._attrs.bbox = bbox;
- }
- return bbox;
- };
- _proto.calculateBox = function calculateBox() {
- return null;
- };
- _proto.createPath = function createPath() {};
- return Shape;
- }(Element);
- module.exports = Shape;
- /***/ }),
- /* 11 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var toString = {}.toString;
- var isType = function (value, type) {
- return toString.call(value) === '[object ' + type + ']';
- };
- /* harmony default export */ __webpack_exports__["a"] = (isType);
- /***/ }),
- /* 12 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /**
- * 判断是否数字
- * @return {Boolean} 是否数字
- */
- var isNumber = function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Number');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isNumber);
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * 2 Dimensional Vector
- * @module vector2
- */
- module.exports = {
- /**
- * Creates a new, empty vector2
- *
- * @return {vector2} a new 2D vector
- */
- create: function create() {
- return [0, 0];
- },
- /**
- * Calculates the length of a vector2
- *
- * @param {vector2} v vector to calculate length of
- * @return {Number} length of v
- */
- length: function length(v) {
- var x = v[0];
- var y = v[1];
- return Math.sqrt(x * x + y * y);
- },
- /**
- * Normalize a vector2
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v vector to normalize
- * @return {vector2} out
- */
- normalize: function normalize(out, v) {
- var len = this.length(v);
- if (len === 0) {
- out[0] = 0;
- out[1] = 0;
- } else {
- out[0] = v[0] / len;
- out[1] = v[1] / len;
- }
- return out;
- },
- /**
- * Adds two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- add: function add(out, v1, v2) {
- out[0] = v1[0] + v2[0];
- out[1] = v1[1] + v2[1];
- return out;
- },
- /**
- * Subtracts vector v2 from vector v1
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- sub: function sub(out, v1, v2) {
- out[0] = v1[0] - v2[0];
- out[1] = v1[1] - v2[1];
- return out;
- },
- /**
- * Scales a vector2 by a scalar number
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v the vector to scale
- * @param {Number} s amount to scale the vector by
- * @return {vector2} out
- */
- scale: function scale(out, v, s) {
- out[0] = v[0] * s;
- out[1] = v[1] * s;
- return out;
- },
- /**
- * Calculates the dot product of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} dot product of v1 and v2
- */
- dot: function dot(v1, v2) {
- return v1[0] * v2[0] + v1[1] * v2[1];
- },
- /**
- * Calculates the direction of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Boolean} the direction of v1 and v2
- */
- direction: function direction(v1, v2) {
- return v1[0] * v2[1] - v2[0] * v1[1];
- },
- /**
- * Calculates the angle of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} angle of v1 and v2
- */
- angle: function angle(v1, v2) {
- var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
- return Math.acos(theta);
- },
- /**
- * Calculates the angle of two vector2's with direction
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @param {Boolean} direction the direction of two vector2's
- * @return {Number} angle of v1 and v2
- */
- angleTo: function angleTo(v1, v2, direction) {
- var angle = this.angle(v1, v2);
- var angleLargeThanPI = this.direction(v1, v2) >= 0;
- if (direction) {
- if (angleLargeThanPI) {
- return Math.PI * 2 - angle;
- }
- return angle;
- }
- if (angleLargeThanPI) {
- return angle;
- }
- return Math.PI * 2 - angle;
- },
- /**
- * whether a vector2 is zero vector
- *
- * @param {vector2} v vector to calculate
- * @return {Boolean} is or not a zero vector
- */
- zero: function zero(v) {
- return v[0] === 0 && v[1] === 0;
- },
- /**
- * Calculates the euclidian distance between two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} distance between a and b
- */
- distance: function distance(v1, v2) {
- var x = v2[0] - v1[0];
- var y = v2[1] - v1[1];
- return Math.sqrt(x * x + y * y);
- },
- /**
- * Creates a new vector2 initialized with values from an existing vector
- *
- * @param {vector2} v vector to clone
- * @return {Array} a new 2D vector
- */
- clone: function clone(v) {
- return [v[0], v[1]];
- },
- /**
- * Return the minimum of two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- min: function min(out, v1, v2) {
- out[0] = Math.min(v1[0], v2[0]);
- out[1] = Math.min(v1[1], v2[1]);
- return out;
- },
- /**
- * Return the maximum of two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- max: function max(out, v1, v2) {
- out[0] = Math.max(v1[0], v2[0]);
- out[1] = Math.max(v1[1], v2[1]);
- return out;
- },
- /**
- * Transforms the vector2 with a mat2d
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v the vector to transform
- * @param {mat2d} m matrix to transform with
- * @return {vector2} out
- */
- transformMat2d: function transformMat2d(out, v, m) {
- var x = v[0];
- var y = v[1];
- out[0] = m[0] * x + m[2] * y + m[4];
- out[1] = m[1] * x + m[3] * y + m[5];
- return out;
- }
- };
- /***/ }),
- /* 14 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- // isFinite,
- var isNil = function (value) {
- /**
- * isNil(null) => true
- * isNil() => true
- */
- return value === null || value === undefined;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isNil);
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(44);
- var isArray = __webpack_require__(34);
- var each = function each(elements, func) {
- if (!elements) {
- return;
- }
- var rst = void 0;
- if (isArray(elements)) {
- for (var i = 0, len = elements.length; i < len; i++) {
- rst = func(elements[i], i);
- if (rst === false) {
- break;
- }
- }
- } else if (isObject(elements)) {
- for (var k in elements) {
- if (elements.hasOwnProperty(k)) {
- rst = func(elements[k], k);
- if (rst === false) {
- break;
- }
- }
- }
- }
- };
- module.exports = each;
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var G = {
- Canvas: __webpack_require__(176),
- Group: __webpack_require__(67),
- Shape: __webpack_require__(10),
- Matrix: __webpack_require__(31),
- Vector2: __webpack_require__(13)
- };
- __webpack_require__(180);
- __webpack_require__(181);
- __webpack_require__(182);
- __webpack_require__(183);
- __webpack_require__(184);
- __webpack_require__(185);
- __webpack_require__(186);
- __webpack_require__(187);
- __webpack_require__(189);
- module.exports = G;
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireWildcard = __webpack_require__(49);
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var Attr = _interopRequireWildcard(__webpack_require__(161));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Base = __webpack_require__(63);
- var GROUP_ATTRS = ['color', 'size', 'shape'];
- var FIELD_ORIGIN = '_origin';
- var FIELD_ORIGIN_Y = '_originY';
- var Global = __webpack_require__(6);
- var GeometryShape = __webpack_require__(19);
- var Adjust = __webpack_require__(33);
- function parseFields(field) {
- if (Util.isArray(field)) {
- return field;
- }
- if (Util.isString(field)) {
- return field.split('*');
- }
- return [field];
- }
- /**
- * The parent class for Geometry
- * @class Geom
- */
- var Geom = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Geom, _Base);
- var _super = _createSuper(Geom);
- function Geom() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Geom.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * geometry type
- * @type {String}
- */
- type: null,
- /**
- * the data of geometry
- * @type {Array}
- */
- data: null,
- /**
- * the attrs of geo,etry
- * @type {Object}
- */
- attrs: {},
- scales: {},
- /**
- * group for storing the shapes
- * @type {Canvas}
- */
- container: null,
- /**
- * style options
- * @type {Object}
- */
- styleOptions: null,
- chart: null,
- shapeType: '',
- /**
- * wether to generate key points for each shape
- * @protected
- * @type {Boolean}
- */
- generatePoints: false,
- attrOptions: {},
- sortable: false,
- startOnZero: true,
- visible: true,
- connectNulls: false,
- // 是否丢弃没有值的分组。
- ignoreEmptyGroup: false
- };
- };
- _proto.init = function init() {
- var self = this;
- self._initAttrs();
- self._processData();
- };
- _proto._getGroupScales = function _getGroupScales() {
- var self = this;
- var scales = [];
- Util.each(GROUP_ATTRS, function (attrName) {
- var attr = self.getAttr(attrName);
- if (attr) {
- var attrScales = attr.scales;
- Util.each(attrScales, function (scale) {
- if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
- scales.push(scale);
- }
- });
- }
- });
- return scales;
- };
- _proto._groupData = function _groupData(data) {
- var self = this;
- var colDefs = self.get('colDefs');
- var groupScales = self._getGroupScales();
- if (groupScales.length) {
- var appendConditions = {};
- var names = [];
- Util.each(groupScales, function (scale) {
- var field = scale.field;
- names.push(field);
- if (colDefs && colDefs[field] && colDefs[field].values) {
- // users have defined
- appendConditions[scale.field] = colDefs[field].values;
- }
- });
- return Util.Array.group(data, names, appendConditions);
- }
- return [data];
- };
- _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
- var options = this.get('attrOptions');
- options[attrName] = attrCfg;
- var attrs = this.get('attrs'); // 说明已经初始化过了
- if (Object.keys(attrs).length) {
- this._createAttr(attrName, attrCfg);
- }
- };
- _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
- var attrCfg = {};
- attrCfg.field = field;
- if (cfg) {
- if (Util.isFunction(cfg)) {
- attrCfg.callback = cfg;
- } else {
- attrCfg.values = cfg;
- }
- } else {
- attrCfg.values = defaultValues;
- }
- this._setAttrOptions(attrName, attrCfg);
- };
- _proto._createAttr = function _createAttr(type, option) {
- var self = this;
- var attrs = self.get('attrs');
- var coord = self.get('coord');
- var className = Util.upperFirst(type);
- var fields = parseFields(option.field);
- if (type === 'position') {
- option.coord = coord;
- }
- var scales = [];
- for (var i = 0, len = fields.length; i < len; i++) {
- var field = fields[i];
- var scale = self._createScale(field);
- scales.push(scale);
- }
- if (type === 'position') {
- var yScale = scales[1]; // 饼图的处理,但是还不知道为啥
- if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
- if (yScale.values.length) {
- yScale.change({
- nice: false,
- min: 0,
- max: Math.max.apply(null, yScale.values)
- });
- }
- }
- }
- option.scales = scales;
- var attr = new Attr[className](option);
- attrs[type] = attr;
- return attr;
- };
- _proto._initAttrs = function _initAttrs() {
- var self = this;
- var attrOptions = self.get('attrOptions');
- for (var type in attrOptions) {
- if (attrOptions.hasOwnProperty(type)) {
- this._createAttr(type, attrOptions[type]);
- }
- }
- };
- _proto._createScale = function _createScale(field) {
- var scales = this.get('scales');
- var scale = scales[field];
- if (!scale) {
- scale = this.get('chart').createScale(field);
- scales[field] = scale;
- }
- return scale;
- };
- _proto._processData = function _processData() {
- var self = this;
- var data = this.get('data');
- var dataArray = [];
- var groupedArray = this._groupData(data);
- if (this.get('ignoreEmptyGroup')) {
- var yScale = this.getYScale();
- groupedArray = groupedArray.filter(function (group) {
- return group.some(function (item) {
- return typeof item[yScale.field] !== 'undefined';
- });
- });
- }
- for (var i = 0, len = groupedArray.length; i < len; i++) {
- var subData = groupedArray[i];
- var tempData = self._saveOrigin(subData);
- if (this.hasAdjust('dodge')) {
- self._numberic(tempData);
- }
- dataArray.push(tempData);
- }
- if (self.get('adjust')) {
- self._adjustData(dataArray);
- }
- if (self.get('sortable')) {
- self._sort(dataArray);
- }
- self.set('dataArray', dataArray);
- return dataArray;
- };
- _proto._saveOrigin = function _saveOrigin(data) {
- var rst = [];
- for (var i = 0, len = data.length; i < len; i++) {
- var origin = data[i];
- var obj = {};
- for (var k in origin) {
- obj[k] = origin[k];
- }
- obj[FIELD_ORIGIN] = origin;
- rst.push(obj);
- }
- return rst;
- };
- _proto._numberic = function _numberic(data) {
- var positionAttr = this.getAttr('position');
- var scales = positionAttr.scales;
- for (var j = 0, len = data.length; j < len; j++) {
- var obj = data[j];
- var count = Math.min(2, scales.length);
- for (var i = 0; i < count; i++) {
- var scale = scales[i];
- if (scale.isCategory) {
- var field = scale.field;
- obj[field] = scale.translate(obj[field]);
- }
- }
- }
- };
- _proto._adjustData = function _adjustData(dataArray) {
- var self = this;
- var adjust = self.get('adjust');
- if (adjust) {
- var adjustType = Util.upperFirst(adjust.type);
- if (!Adjust[adjustType]) {
- throw new Error('not support such adjust : ' + adjust);
- }
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var cfg = Util.mix({
- xField: xScale.field,
- yField: yScale.field
- }, adjust);
- var adjustObject = new Adjust[adjustType](cfg);
- adjustObject.processAdjust(dataArray);
- if (adjustType === 'Stack') {
- self._updateStackRange(yScale.field, yScale, dataArray);
- }
- }
- };
- _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
- var mergeArray = Util.Array.merge(dataArray);
- var min = scale.min;
- var max = scale.max;
- for (var i = 0, len = mergeArray.length; i < len; i++) {
- var obj = mergeArray[i];
- var tmpMin = Math.min.apply(null, obj[field]);
- var tmpMax = Math.max.apply(null, obj[field]);
- if (tmpMin < min) {
- min = tmpMin;
- }
- if (tmpMax > max) {
- max = tmpMax;
- }
- }
- if (min < scale.min || max > scale.max) {
- scale.change({
- min: min,
- max: max
- });
- }
- };
- _proto._sort = function _sort(mappedArray) {
- var self = this;
- var xScale = self.getXScale();
- var field = xScale.field,
- type = xScale.type;
- if (type !== 'identity' && xScale.values.length > 1) {
- Util.each(mappedArray, function (itemArr) {
- itemArr.sort(function (obj1, obj2) {
- if (type === 'timeCat') {
- return xScale._toTimeStamp(obj1[FIELD_ORIGIN][field]) - xScale._toTimeStamp(obj2[FIELD_ORIGIN][field]);
- }
- return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
- });
- });
- }
- self.set('hasSorted', true);
- self.set('dataArray', mappedArray);
- };
- _proto.paint = function paint() {
- var self = this;
- var dataArray = self.get('dataArray');
- var mappedArray = [];
- var shapeFactory = self.getShapeFactory();
- shapeFactory.setCoord(self.get('coord'));
- self._beforeMapping(dataArray);
- for (var i = 0, len = dataArray.length; i < len; i++) {
- var data = dataArray[i];
- if (data.length) {
- data = self._mapping(data);
- mappedArray.push(data);
- self.draw(data, shapeFactory);
- }
- }
- self.set('dataArray', mappedArray);
- };
- _proto.getShapeFactory = function getShapeFactory() {
- var shapeFactory = this.get('shapeFactory');
- if (!shapeFactory) {
- var shapeType = this.get('shapeType');
- shapeFactory = GeometryShape.getShapeFactory(shapeType);
- this.set('shapeFactory', shapeFactory);
- }
- return shapeFactory;
- };
- _proto._mapping = function _mapping(data) {
- var self = this;
- var attrs = self.get('attrs');
- var yField = self.getYScale().field; // 用来缓存转换的值,减少mapping耗时
- var mappedCache = {};
- for (var k in attrs) {
- if (attrs.hasOwnProperty(k)) {
- var attr = attrs[k];
- var names = attr.names;
- var scales = attr.scales;
- for (var i = 0, len = data.length; i < len; i++) {
- var record = data[i];
- record[FIELD_ORIGIN_Y] = record[yField]; // 获取视觉属性对应的value值
- // 位置的缓存命中率低,还是每次单独计算
- if (attr.type === 'position') {
- var values = self._getAttrValues(attr, record);
- for (var j = 0, _len = values.length; j < _len; j++) {
- var val = values[j];
- var name = names[j];
- record[name] = Util.isArray(val) && val.length === 1 ? val[0] : val;
- }
- } else {
- // 除了position其他都只有一项
- var _name = names[0];
- var field = scales[0].field;
- var value = record[field];
- var key = "" + _name + value;
- var _values = mappedCache[key];
- if (!_values) {
- _values = self._getAttrValues(attr, record);
- mappedCache[key] = _values;
- }
- record[_name] = _values[0];
- }
- }
- }
- }
- return data;
- };
- _proto._getAttrValues = function _getAttrValues(attr, record) {
- var scales = attr.scales;
- var params = [];
- for (var i = 0, len = scales.length; i < len; i++) {
- var scale = scales[i];
- var field = scale.field;
- if (scale.type === 'identity') {
- params.push(scale.value);
- } else {
- params.push(record[field]);
- }
- }
- var values = attr.mapping.apply(attr, params);
- return values;
- };
- _proto.getAttrValue = function getAttrValue(attrName, record) {
- var attr = this.getAttr(attrName);
- var rst = null;
- if (attr) {
- var values = this._getAttrValues(attr, record);
- rst = values[0];
- }
- return rst;
- };
- _proto._beforeMapping = function _beforeMapping(dataArray) {
- var self = this;
- if (self.get('generatePoints')) {
- self._generatePoints(dataArray);
- }
- };
- _proto.isInCircle = function isInCircle() {
- var coord = this.get('coord');
- return coord && coord.isPolar;
- };
- _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
- if (!fields) {
- return cfg;
- }
- var tmpCfg = {};
- var params = fields.map(function (field) {
- return origin[field];
- });
- Util.each(cfg, function (v, k) {
- if (Util.isFunction(v)) {
- tmpCfg[k] = v.apply(null, params);
- } else {
- tmpCfg[k] = v;
- }
- });
- return tmpCfg;
- };
- _proto.getDrawCfg = function getDrawCfg(obj) {
- var self = this;
- var isInCircle = self.isInCircle();
- var cfg = {
- origin: obj,
- x: obj.x,
- y: obj.y,
- color: obj.color,
- size: obj.size,
- shape: obj.shape,
- isInCircle: isInCircle,
- opacity: obj.opacity
- };
- var styleOptions = self.get('styleOptions');
- if (styleOptions && styleOptions.style) {
- cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
- }
- if (self.get('generatePoints')) {
- cfg.points = obj.points;
- cfg.nextPoints = obj.nextPoints;
- }
- if (isInCircle) {
- cfg.center = self.get('coord').center;
- }
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var yScale = self.getYScale();
- Util.each(data, function (obj, index) {
- if (yScale && Util.isNil(obj._origin[yScale.field])) {
- return;
- }
- obj.index = index;
- var cfg = self.getDrawCfg(obj);
- var shape = obj.shape;
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- });
- };
- _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
- var gShape = shapeFactory.drawShape(shape, cfg, container);
- if (gShape) {
- Util.each([].concat(gShape), function (s) {
- s.set('origin', shapeData);
- });
- }
- };
- _proto._generatePoints = function _generatePoints(dataArray) {
- var self = this;
- var shapeFactory = self.getShapeFactory();
- var shapeAttr = self.getAttr('shape');
- Util.each(dataArray, function (data) {
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var cfg = self.createShapePointsCfg(obj);
- var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
- var points = shapeFactory.getShapePoints(shape, cfg);
- obj.points = points;
- }
- }); // 添加nextPoints
- Util.each(dataArray, function (data, index) {
- var nextData = dataArray[index + 1];
- if (nextData) {
- data[0].nextPoints = nextData[0].points;
- }
- });
- }
- /**
- * get the info of each shape
- * @protected
- * @param {Object} obj the data item
- * @return {Object} cfg return the result
- */
- ;
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var xScale = this.getXScale();
- var yScale = this.getYScale();
- var x = this._normalizeValues(obj[xScale.field], xScale);
- var y;
- if (yScale) {
- y = this._normalizeValues(obj[yScale.field], yScale);
- } else {
- y = obj.y ? obj.y : 0.1;
- }
- return {
- x: x,
- y: y,
- y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
- };
- };
- _proto.getYMinValue = function getYMinValue() {
- var yScale = this.getYScale();
- var min = yScale.min,
- max = yScale.max;
- var value;
- if (this.get('startOnZero')) {
- if (max <= 0 && min <= 0) {
- value = max;
- } else {
- value = min >= 0 ? min : 0;
- }
- } else {
- value = min;
- }
- return value;
- };
- _proto._normalizeValues = function _normalizeValues(values, scale) {
- var rst = [];
- if (Util.isArray(values)) {
- for (var i = 0, len = values.length; i < len; i++) {
- var v = values[i];
- rst.push(scale.scale(v));
- }
- } else {
- rst = scale.scale(values);
- }
- return rst;
- };
- _proto.getAttr = function getAttr(name) {
- return this.get('attrs')[name];
- };
- _proto.getXScale = function getXScale() {
- return this.getAttr('position').scales[0];
- };
- _proto.getYScale = function getYScale() {
- return this.getAttr('position').scales[1];
- };
- _proto.hasAdjust = function hasAdjust(adjust) {
- return this.get('adjust') && this.get('adjust').type === adjust;
- };
- _proto._getSnap = function _getSnap(scale, item, arr) {
- var i = 0;
- var values;
- var yField = this.getYScale().field; // 叠加的维度
- if (this.hasAdjust('stack') && scale.field === yField) {
- values = [];
- arr.forEach(function (obj) {
- values.push(obj[FIELD_ORIGIN_Y]);
- });
- for (var len = values.length; i < len; i++) {
- if (values[0][0] > item) {
- break;
- }
- if (values[values.length - 1][1] <= item) {
- i = values.length - 1;
- break;
- }
- if (values[i][0] <= item && values[i][1] > item) {
- break;
- }
- }
- } else {
- values = scale.values;
- values.sort(function (a, b) {
- return a - b;
- });
- for (var _len2 = values.length; i < _len2; i++) {
- // 如果只有1个点直接返回第1个点
- if (_len2 <= 1) {
- break;
- } // 第1个点和第2个点之间
- if ((values[0] + values[1]) / 2 > item) {
- break;
- } // 中间的点
- if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
- break;
- } // 最后2个点
- if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
- i = values.length - 1;
- break;
- }
- }
- }
- var result = values[i];
- return result;
- };
- _proto.getSnapRecords = function getSnapRecords(point) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var xfield = xScale.field;
- var dataArray = self.get('dataArray');
- if (!this.get('hasSorted')) {
- this._sort(dataArray);
- }
- var rst = [];
- var invertPoint = coord.invertPoint(point);
- var invertPointX = invertPoint.x;
- if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
- invertPointX = xScale.rangeMin();
- }
- var xValue = xScale.invert(invertPointX);
- if (!xScale.isCategory) {
- xValue = self._getSnap(xScale, xValue);
- }
- var tmp = [];
- dataArray.forEach(function (data) {
- data.forEach(function (obj) {
- var originValue = Util.isNil(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
- if (self._isEqual(originValue, xValue, xScale)) {
- tmp.push(obj);
- }
- });
- }); // special for pie chart
- if (this.hasAdjust('stack') && coord.isPolar && coord.transposed) {
- if (invertPointX >= 0 && invertPointX <= 1) {
- var yValue = yScale.invert(invertPoint.y);
- yValue = self._getSnap(yScale, yValue, tmp);
- tmp.forEach(function (obj) {
- if (Util.isArray(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
- rst.push(obj);
- }
- });
- }
- } else {
- rst = tmp;
- }
- return rst;
- };
- _proto._isEqual = function _isEqual(originValue, value, scale) {
- if (scale.type === 'timeCat') {
- return scale._toTimeStamp(originValue) === value;
- }
- return value === originValue;
- };
- _proto.position = function position(field) {
- this._setAttrOptions('position', {
- field: field
- });
- return this;
- };
- _proto.color = function color(field, values) {
- this._createAttrOption('color', field, values, Global.colors);
- return this;
- };
- _proto.size = function size(field, values) {
- this._createAttrOption('size', field, values, Global.sizes);
- return this;
- };
- _proto.shape = function shape(field, values) {
- var type = this.get('type');
- var shapes = Global.shapes[type] || [];
- this._createAttrOption('shape', field, values, shapes);
- return this;
- };
- _proto.style = function style(field, cfg) {
- var styleOptions = this.get('styleOptions');
- if (!styleOptions) {
- styleOptions = {};
- this.set('styleOptions', styleOptions);
- }
- if (Util.isObject(field)) {
- cfg = field;
- field = null;
- }
- var fields;
- if (field) {
- fields = parseFields(field);
- }
- styleOptions.fields = fields;
- styleOptions.style = cfg;
- return this;
- };
- _proto.adjust = function adjust(type) {
- if (Util.isString(type)) {
- type = {
- type: type
- };
- }
- this.set('adjust', type);
- return this;
- };
- _proto.animate = function animate(cfg) {
- this.set('animateCfg', cfg);
- return this;
- };
- _proto.changeData = function changeData(data) {
- this.set('data', data); // 改变数据后,情况度量,因为需要重新实例化
- this.set('scales', {});
- this.init();
- };
- _proto.clearInner = function clearInner() {
- var container = this.get('container');
- if (container) {
- container.clear(); // container.setMatrix([ 1, 0, 0, 1, 0, 0 ]);
- }
- };
- _proto.reset = function reset() {
- this.set('attrs', {});
- this.set('attrOptions', {});
- this.set('adjust', null);
- this.clearInner();
- };
- _proto.clear = function clear() {
- this.clearInner();
- };
- _proto.destroy = function destroy() {
- this.clear();
- _Base.prototype.destroy.call(this);
- };
- _proto._display = function _display(visible) {
- this.set('visible', visible);
- var container = this.get('container');
- var canvas = container.get('canvas');
- container.set('visible', visible);
- canvas.draw();
- };
- _proto.show = function show() {
- this._display(true);
- };
- _proto.hide = function hide() {
- this._display(false);
- };
- return Geom;
- }(Base);
- module.exports = Geom;
- /***/ }),
- /* 18 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /* harmony default export */ __webpack_exports__["a"] = (function (str) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(str, 'String');
- });
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(6);
- var Shape = {};
- var ShapeBase = {
- _coord: null,
- /**
- * draw the shape
- * @param {Object} cfg options
- * @param {Object} container container to store the shapes
- */
- draw: function draw(cfg, container) {
- if (this.drawShape) {
- this.drawShape(cfg, container);
- }
- },
- /**
- * set the coordinate instance
- * @param {Coord} coord coordinate instance
- */
- setCoord: function setCoord(coord) {
- this._coord = coord;
- },
- /**
- * convert the normalized value to the canvas position
- * @param {point} point the point to convert
- * @return {point} point return the result
- */
- parsePoint: function parsePoint(point) {
- var coord = this._coord;
- if (coord.isPolar) {
- if (point.x === 1) point.x = 0.9999999;
- if (point.y === 1) point.y = 0.9999999;
- }
- return coord.convertPoint(point);
- },
- /**
- * convert the normalized value to the canvas position
- * @param {points} points the array that store the points
- * @return {points} points return the result
- */
- parsePoints: function parsePoints(points) {
- if (!points) return false;
- var self = this;
- var rst = [];
- points.forEach(function (point) {
- rst.push(self.parsePoint(point));
- });
- return rst;
- }
- };
- var ShapeFactoryBase = {
- defaultShapeType: null,
- setCoord: function setCoord(coord) {
- this._coord = coord;
- },
- getShape: function getShape(type) {
- var self = this;
- if (Util.isArray(type)) {
- type = type[0];
- }
- var shape = self[type] || self[self.defaultShapeType];
- shape._coord = self._coord;
- return shape;
- },
- getShapePoints: function getShapePoints(type, cfg) {
- var shape = this.getShape(type);
- var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
- var points = fn(cfg);
- return points;
- },
- getDefaultPoints: function getDefaultPoints()
- /* cfg */
- {
- return [];
- },
- drawShape: function drawShape(type, cfg, container) {
- var shape = this.getShape(type);
- if (!cfg.color) {
- cfg.color = Global.colors[0];
- }
- return shape.draw(cfg, container);
- }
- };
- Shape.registerFactory = function (factoryName, cfg) {
- var className = Util.upperFirst(factoryName);
- var geomObj = Util.mix({}, ShapeFactoryBase, cfg);
- Shape[className] = geomObj;
- geomObj.name = factoryName;
- return geomObj;
- };
- Shape.registerShape = function (factoryName, shapeType, cfg) {
- var className = Util.upperFirst(factoryName);
- var factory = Shape[className];
- var shapeObj = Util.mix({}, ShapeBase, cfg);
- factory[shapeType] = shapeObj;
- return shapeObj;
- };
- Shape.registShape = Shape.registerShape;
- Shape.getShapeFactory = function (factoryName) {
- var self = this;
- factoryName = factoryName || 'point';
- var className = Util.upperFirst(factoryName);
- return self[className];
- };
- module.exports = Shape;
- /***/ }),
- /* 20 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return __WEBPACK_IMPORTED_MODULE_0__contains__["a"]; });
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "includes", function() { return __WEBPACK_IMPORTED_MODULE_0__contains__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__difference__ = __webpack_require__(79);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "difference", function() { return __WEBPACK_IMPORTED_MODULE_1__difference__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__find__ = __webpack_require__(80);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "find", function() { return __WEBPACK_IMPORTED_MODULE_2__find__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__find_index__ = __webpack_require__(81);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findIndex", function() { return __WEBPACK_IMPORTED_MODULE_3__find_index__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__first_value__ = __webpack_require__(82);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "firstValue", function() { return __WEBPACK_IMPORTED_MODULE_4__first_value__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__flatten__ = __webpack_require__(83);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return __WEBPACK_IMPORTED_MODULE_5__flatten__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__flatten_deep__ = __webpack_require__(84);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "flattenDeep", function() { return __WEBPACK_IMPORTED_MODULE_6__flatten_deep__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__get_range__ = __webpack_require__(85);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getRange", function() { return __WEBPACK_IMPORTED_MODULE_7__get_range__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__pull__ = __webpack_require__(86);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pull", function() { return __WEBPACK_IMPORTED_MODULE_8__pull__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__pull_at__ = __webpack_require__(53);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pullAt", function() { return __WEBPACK_IMPORTED_MODULE_9__pull_at__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__reduce__ = __webpack_require__(87);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "reduce", function() { return __WEBPACK_IMPORTED_MODULE_10__reduce__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__remove__ = __webpack_require__(88);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "remove", function() { return __WEBPACK_IMPORTED_MODULE_11__remove__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__sort_by__ = __webpack_require__(89);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sortBy", function() { return __WEBPACK_IMPORTED_MODULE_12__sort_by__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__union__ = __webpack_require__(90);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "union", function() { return __WEBPACK_IMPORTED_MODULE_13__union__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__uniq__ = __webpack_require__(54);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniq", function() { return __WEBPACK_IMPORTED_MODULE_14__uniq__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__values_of_key__ = __webpack_require__(91);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "valuesOfKey", function() { return __WEBPACK_IMPORTED_MODULE_15__values_of_key__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__head__ = __webpack_require__(92);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "head", function() { return __WEBPACK_IMPORTED_MODULE_16__head__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__last__ = __webpack_require__(93);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "last", function() { return __WEBPACK_IMPORTED_MODULE_17__last__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__starts_with__ = __webpack_require__(94);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "startsWith", function() { return __WEBPACK_IMPORTED_MODULE_18__starts_with__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__ends_with__ = __webpack_require__(95);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "endsWith", function() { return __WEBPACK_IMPORTED_MODULE_19__ends_with__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__filter__ = __webpack_require__(39);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "filter", function() { return __WEBPACK_IMPORTED_MODULE_20__filter__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__every__ = __webpack_require__(96);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "every", function() { return __WEBPACK_IMPORTED_MODULE_21__every__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__some__ = __webpack_require__(97);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "some", function() { return __WEBPACK_IMPORTED_MODULE_22__some__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__group__ = __webpack_require__(98);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "group", function() { return __WEBPACK_IMPORTED_MODULE_23__group__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__group_by__ = __webpack_require__(56);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "groupBy", function() { return __WEBPACK_IMPORTED_MODULE_24__group_by__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__group_to_map__ = __webpack_require__(55);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "groupToMap", function() { return __WEBPACK_IMPORTED_MODULE_25__group_to_map__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__get_wrap_behavior__ = __webpack_require__(99);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getWrapBehavior", function() { return __WEBPACK_IMPORTED_MODULE_26__get_wrap_behavior__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__wrap_behavior__ = __webpack_require__(100);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "wrapBehavior", function() { return __WEBPACK_IMPORTED_MODULE_27__wrap_behavior__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__number2color__ = __webpack_require__(101);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "number2color", function() { return __WEBPACK_IMPORTED_MODULE_28__number2color__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__parse_radius__ = __webpack_require__(102);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "parseRadius", function() { return __WEBPACK_IMPORTED_MODULE_29__parse_radius__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__clamp__ = __webpack_require__(103);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clamp", function() { return __WEBPACK_IMPORTED_MODULE_30__clamp__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__fixed_base__ = __webpack_require__(104);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "fixedBase", function() { return __WEBPACK_IMPORTED_MODULE_31__fixed_base__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__is_decimal__ = __webpack_require__(105);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDecimal", function() { return __WEBPACK_IMPORTED_MODULE_32__is_decimal__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__is_even__ = __webpack_require__(106);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEven", function() { return __WEBPACK_IMPORTED_MODULE_33__is_even__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__is_integer__ = __webpack_require__(107);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return __WEBPACK_IMPORTED_MODULE_34__is_integer__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_35__is_negative__ = __webpack_require__(108);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNegative", function() { return __WEBPACK_IMPORTED_MODULE_35__is_negative__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__is_number_equal__ = __webpack_require__(109);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNumberEqual", function() { return __WEBPACK_IMPORTED_MODULE_36__is_number_equal__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__is_odd__ = __webpack_require__(110);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isOdd", function() { return __WEBPACK_IMPORTED_MODULE_37__is_odd__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__is_positive__ = __webpack_require__(111);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPositive", function() { return __WEBPACK_IMPORTED_MODULE_38__is_positive__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__max_by__ = __webpack_require__(112);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "maxBy", function() { return __WEBPACK_IMPORTED_MODULE_39__max_by__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__min_by__ = __webpack_require__(113);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "minBy", function() { return __WEBPACK_IMPORTED_MODULE_40__min_by__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__mod__ = __webpack_require__(114);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mod", function() { return __WEBPACK_IMPORTED_MODULE_41__mod__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__to_degree__ = __webpack_require__(115);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toDegree", function() { return __WEBPACK_IMPORTED_MODULE_42__to_degree__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__to_integer__ = __webpack_require__(116);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toInteger", function() { return __WEBPACK_IMPORTED_MODULE_43__to_integer__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__to_radian__ = __webpack_require__(117);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toRadian", function() { return __WEBPACK_IMPORTED_MODULE_44__to_radian__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__for_in__ = __webpack_require__(118);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "forIn", function() { return __WEBPACK_IMPORTED_MODULE_45__for_in__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__has__ = __webpack_require__(57);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "has", function() { return __WEBPACK_IMPORTED_MODULE_46__has__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_47__has_key__ = __webpack_require__(119);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "hasKey", function() { return __WEBPACK_IMPORTED_MODULE_47__has_key__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__has_value__ = __webpack_require__(120);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "hasValue", function() { return __WEBPACK_IMPORTED_MODULE_48__has_value__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_49__keys__ = __webpack_require__(52);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "keys", function() { return __WEBPACK_IMPORTED_MODULE_49__keys__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__is_match__ = __webpack_require__(51);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isMatch", function() { return __WEBPACK_IMPORTED_MODULE_50__is_match__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__values__ = __webpack_require__(58);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "values", function() { return __WEBPACK_IMPORTED_MODULE_51__values__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_52__lower_case__ = __webpack_require__(121);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "lowerCase", function() { return __WEBPACK_IMPORTED_MODULE_52__lower_case__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__lower_first__ = __webpack_require__(122);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "lowerFirst", function() { return __WEBPACK_IMPORTED_MODULE_53__lower_first__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__substitute__ = __webpack_require__(123);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "substitute", function() { return __WEBPACK_IMPORTED_MODULE_54__substitute__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__upper_case__ = __webpack_require__(124);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperCase", function() { return __WEBPACK_IMPORTED_MODULE_55__upper_case__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__upper_first__ = __webpack_require__(125);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperFirst", function() { return __WEBPACK_IMPORTED_MODULE_56__upper_first__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__get_type__ = __webpack_require__(59);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "getType", function() { return __WEBPACK_IMPORTED_MODULE_57__get_type__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__is_arguments__ = __webpack_require__(126);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArguments", function() { return __WEBPACK_IMPORTED_MODULE_58__is_arguments__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__is_array__ = __webpack_require__(5);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArray", function() { return __WEBPACK_IMPORTED_MODULE_59__is_array__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__is_array_like__ = __webpack_require__(7);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArrayLike", function() { return __WEBPACK_IMPORTED_MODULE_60__is_array_like__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_61__is_boolean__ = __webpack_require__(127);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isBoolean", function() { return __WEBPACK_IMPORTED_MODULE_61__is_boolean__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_62__is_date__ = __webpack_require__(128);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDate", function() { return __WEBPACK_IMPORTED_MODULE_62__is_date__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_63__is_error__ = __webpack_require__(129);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isError", function() { return __WEBPACK_IMPORTED_MODULE_63__is_error__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_64__is_function__ = __webpack_require__(9);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return __WEBPACK_IMPORTED_MODULE_64__is_function__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_65__is_finite__ = __webpack_require__(130);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFinite", function() { return __WEBPACK_IMPORTED_MODULE_65__is_finite__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_66__is_nil__ = __webpack_require__(14);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNil", function() { return __WEBPACK_IMPORTED_MODULE_66__is_nil__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_67__is_null__ = __webpack_require__(131);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNull", function() { return __WEBPACK_IMPORTED_MODULE_67__is_null__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_68__is_number__ = __webpack_require__(12);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNumber", function() { return __WEBPACK_IMPORTED_MODULE_68__is_number__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_69__is_object__ = __webpack_require__(29);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return __WEBPACK_IMPORTED_MODULE_69__is_object__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_70__is_object_like__ = __webpack_require__(40);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isObjectLike", function() { return __WEBPACK_IMPORTED_MODULE_70__is_object_like__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_71__is_plain_object__ = __webpack_require__(24);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPlainObject", function() { return __WEBPACK_IMPORTED_MODULE_71__is_plain_object__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_72__is_prototype__ = __webpack_require__(60);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isPrototype", function() { return __WEBPACK_IMPORTED_MODULE_72__is_prototype__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__is_reg_exp__ = __webpack_require__(132);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isRegExp", function() { return __WEBPACK_IMPORTED_MODULE_73__is_reg_exp__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_74__is_string__ = __webpack_require__(18);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return __WEBPACK_IMPORTED_MODULE_74__is_string__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_75__is_type__ = __webpack_require__(11);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isType", function() { return __WEBPACK_IMPORTED_MODULE_75__is_type__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_76__is_undefined__ = __webpack_require__(133);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isUndefined", function() { return __WEBPACK_IMPORTED_MODULE_76__is_undefined__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_77__is_element__ = __webpack_require__(134);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isElement", function() { return __WEBPACK_IMPORTED_MODULE_77__is_element__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_78__request_animation_frame__ = __webpack_require__(135);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "requestAnimationFrame", function() { return __WEBPACK_IMPORTED_MODULE_78__request_animation_frame__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_79__clear_animation_frame__ = __webpack_require__(136);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clearAnimationFrame", function() { return __WEBPACK_IMPORTED_MODULE_79__clear_animation_frame__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_80__augment__ = __webpack_require__(137);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "augment", function() { return __WEBPACK_IMPORTED_MODULE_80__augment__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_81__clone__ = __webpack_require__(138);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return __WEBPACK_IMPORTED_MODULE_81__clone__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_82__debounce__ = __webpack_require__(139);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return __WEBPACK_IMPORTED_MODULE_82__debounce__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_83__memoize__ = __webpack_require__(140);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "memoize", function() { return __WEBPACK_IMPORTED_MODULE_83__memoize__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_84__deep_mix__ = __webpack_require__(141);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "deepMix", function() { return __WEBPACK_IMPORTED_MODULE_84__deep_mix__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_85__each__ = __webpack_require__(8);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "each", function() { return __WEBPACK_IMPORTED_MODULE_85__each__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_86__extend__ = __webpack_require__(142);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "extend", function() { return __WEBPACK_IMPORTED_MODULE_86__extend__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_87__index_of__ = __webpack_require__(143);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "indexOf", function() { return __WEBPACK_IMPORTED_MODULE_87__index_of__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_88__is_empty__ = __webpack_require__(144);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return __WEBPACK_IMPORTED_MODULE_88__is_empty__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_89__is_equal__ = __webpack_require__(61);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEqual", function() { return __WEBPACK_IMPORTED_MODULE_89__is_equal__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_90__is_equal_with__ = __webpack_require__(145);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEqualWith", function() { return __WEBPACK_IMPORTED_MODULE_90__is_equal_with__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_91__map__ = __webpack_require__(146);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "map", function() { return __WEBPACK_IMPORTED_MODULE_91__map__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_92__map_values__ = __webpack_require__(147);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mapValues", function() { return __WEBPACK_IMPORTED_MODULE_92__map_values__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_93__mix__ = __webpack_require__(41);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mix", function() { return __WEBPACK_IMPORTED_MODULE_93__mix__["a"]; });
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "assign", function() { return __WEBPACK_IMPORTED_MODULE_93__mix__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_94__get__ = __webpack_require__(148);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "get", function() { return __WEBPACK_IMPORTED_MODULE_94__get__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_95__set__ = __webpack_require__(149);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return __WEBPACK_IMPORTED_MODULE_95__set__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_96__pick__ = __webpack_require__(150);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pick", function() { return __WEBPACK_IMPORTED_MODULE_96__pick__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_97__throttle__ = __webpack_require__(151);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return __WEBPACK_IMPORTED_MODULE_97__throttle__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_98__to_array__ = __webpack_require__(152);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toArray", function() { return __WEBPACK_IMPORTED_MODULE_98__to_array__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_99__to_string__ = __webpack_require__(25);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toString", function() { return __WEBPACK_IMPORTED_MODULE_99__to_string__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_100__unique_id__ = __webpack_require__(153);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniqueId", function() { return __WEBPACK_IMPORTED_MODULE_100__unique_id__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_101__noop__ = __webpack_require__(154);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "noop", function() { return __WEBPACK_IMPORTED_MODULE_101__noop__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_102__identity__ = __webpack_require__(155);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return __WEBPACK_IMPORTED_MODULE_102__identity__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_103__size__ = __webpack_require__(156);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "size", function() { return __WEBPACK_IMPORTED_MODULE_103__size__["a"]; });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_104__cache__ = __webpack_require__(157);
- /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Cache", function() { return __WEBPACK_IMPORTED_MODULE_104__cache__["a"]; });
- // array
- // event
- // format
- // math
- // object
- // string
- // type
- // other
- // 不知道为什么,需要把这个 export,不然 ts 会报类型错误
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Vector2 = __webpack_require__(13);
- var start = Vector2.create();
- var end = Vector2.create();
- var extremity = Vector2.create();
- function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
- var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
- var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
- return {
- x: x,
- y: y
- };
- } // cubic helper formula at T distance
- function CubicN(T, a, b, c, d) {
- var t2 = T * T;
- var t3 = t2 * T;
- return a + (-a * 3 + T * (3 * a - a * T)) * T + (3 * b + T * (-6 * b + b * 3 * T)) * T + (c * 3 - c * 3 * T) * t2 + d * t3;
- }
- function cubicBezierBounds(c) {
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- var s = {
- x: c[0],
- y: c[1]
- };
- var c1 = {
- x: c[2],
- y: c[3]
- };
- var c2 = {
- x: c[4],
- y: c[5]
- };
- var e = {
- x: c[6],
- y: c[7]
- };
- for (var t = 0; t < 100; t++) {
- var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
- if (pt.x < minX) {
- minX = pt.x;
- }
- if (pt.x > maxX) {
- maxX = pt.x;
- }
- if (pt.y < minY) {
- minY = pt.y;
- }
- if (pt.y > maxY) {
- maxY = pt.y;
- }
- }
- return {
- minX: minX,
- minY: minY,
- maxX: maxX,
- maxY: maxY
- };
- }
- module.exports = {
- getBBoxFromPoints: function getBBoxFromPoints(points, lineWidth) {
- if (points.length === 0) {
- return;
- }
- var p = points[0];
- var left = p.x;
- var right = p.x;
- var top = p.y;
- var bottom = p.y;
- var len = points.length;
- for (var i = 1; i < len; i++) {
- p = points[i];
- left = Math.min(left, p.x);
- right = Math.max(right, p.x);
- top = Math.min(top, p.y);
- bottom = Math.max(bottom, p.y);
- }
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: left - lineWidth,
- minY: top - lineWidth,
- maxX: right + lineWidth,
- maxY: bottom + lineWidth
- };
- },
- getBBoxFromLine: function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: Math.min(x0, x1) - lineWidth,
- minY: Math.min(y0, y1) - lineWidth,
- maxX: Math.max(x0, x1) + lineWidth,
- maxY: Math.max(y0, y1) + lineWidth
- };
- },
- getBBoxFromArc: function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
- var diff = Math.abs(startAngle - endAngle);
- if (diff % (Math.PI * 2) < 1e-4 && diff > 1e-4) {
- // Is a circle
- return {
- minX: x - r,
- minY: y - r,
- maxX: x + r,
- maxY: y + r
- };
- }
- start[0] = Math.cos(startAngle) * r + x;
- start[1] = Math.sin(startAngle) * r + y;
- end[0] = Math.cos(endAngle) * r + x;
- end[1] = Math.sin(endAngle) * r + y;
- var min = [0, 0];
- var max = [0, 0];
- Vector2.min(min, start, end);
- Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]
- startAngle = startAngle % (Math.PI * 2);
- if (startAngle < 0) {
- startAngle = startAngle + Math.PI * 2;
- }
- endAngle = endAngle % (Math.PI * 2);
- if (endAngle < 0) {
- endAngle = endAngle + Math.PI * 2;
- }
- if (startAngle > endAngle && !anticlockwise) {
- endAngle += Math.PI * 2;
- } else if (startAngle < endAngle && anticlockwise) {
- startAngle += Math.PI * 2;
- }
- if (anticlockwise) {
- var tmp = endAngle;
- endAngle = startAngle;
- startAngle = tmp;
- }
- for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
- if (angle > startAngle) {
- extremity[0] = Math.cos(angle) * r + x;
- extremity[1] = Math.sin(angle) * r + y;
- Vector2.min(min, extremity, min);
- Vector2.max(max, extremity, max);
- }
- }
- return {
- minX: min[0],
- minY: min[1],
- maxX: max[0],
- maxY: max[1]
- };
- },
- getBBoxFromBezierGroup: function getBBoxFromBezierGroup(points, lineWidth) {
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- for (var i = 0, len = points.length; i < len; i++) {
- var bbox = cubicBezierBounds(points[i]);
- if (bbox.minX < minX) {
- minX = bbox.minX;
- }
- if (bbox.maxX > maxX) {
- maxX = bbox.maxX;
- }
- if (bbox.minY < minY) {
- minY = bbox.minY;
- }
- if (bbox.maxY > maxY) {
- maxY = bbox.maxY;
- }
- }
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: minX - lineWidth,
- minY: minY - lineWidth,
- maxX: maxX + lineWidth,
- maxY: maxY + lineWidth
- };
- }
- };
- /***/ }),
- /* 22 */
- /***/ (function(module, exports) {
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- module.exports = _assertThisInitialized;
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var KEYWORDS_PERCENT = {
- min: 0,
- median: 0.5,
- max: 1
- };
- var GuideBase = /*#__PURE__*/function () {
- var _proto = GuideBase.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {};
- function GuideBase(cfg) {
- this._initDefaultCfg();
- Util.deepMix(this, cfg);
- }
- _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
- var rst;
- if (Util.isNil(KEYWORDS_PERCENT[val])) {
- rst = scale.scale(val);
- } else {
- rst = KEYWORDS_PERCENT[val];
- }
- return rst;
- };
- _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
- var xPercent = parseFloat(position[0]) / 100;
- var yPercent = parseFloat(position[1]) / 100;
- var start = coord.start;
- var end = coord.end;
- var width = Math.abs(start.x - end.x);
- var height = Math.abs(start.y - end.y);
- var x = width * xPercent + Math.min(start.x, end.x);
- var y = height * yPercent + Math.min(start.y, end.y);
- return {
- x: x,
- y: y
- };
- };
- _proto.parsePoint = function parsePoint(coord, position) {
- var self = this;
- var xScale = self.xScale;
- var yScales = self.yScales;
- if (Util.isFunction(position)) {
- position = position(xScale, yScales); // position 必须是对象
- } // 如果数据格式是 ['50%', '50%'] 的格式
- // fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590
- if (Util.isString(position[0]) && position[0].indexOf('%') !== -1 && !isNaN(position[0].slice(0, -1))) {
- return this.parsePercentPoint(coord, position);
- }
- var x = self._getNormalizedValue(position[0], xScale);
- var y = self._getNormalizedValue(position[1], yScales[0]);
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- if (self.limitInPlot) {
- // limit in chart plotRange
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
- return point;
- }
- return null;
- }
- return point;
- }
- /**
- * render the guide component
- * @param {Coord} coord coordinate instance
- * @param {Canvas.Group} group the container
- */
- ;
- _proto.render = function render()
- /* coord,group */
- {};
- _proto.repaint = function repaint() {
- this.remove();
- var coord = this.coord,
- container = this.container,
- canvas = this.canvas;
- if (container && !container.isDestroyed()) {
- this.render(coord, container);
- canvas.draw();
- }
- };
- _proto.remove = function remove() {
- var element = this.element;
- element && element.remove(true);
- };
- _proto.changeVisible = function changeVisible(visible) {
- var self = this;
- self.visible = visible;
- var element = self.element;
- if (!element) return;
- if (element.set) {
- element.set('visible', visible);
- } else {
- element.style.display = visible ? '' : 'none';
- }
- };
- return GuideBase;
- }();
- module.exports = GuideBase;
- /***/ }),
- /* 24 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object_like__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_type__ = __webpack_require__(11);
- var isPlainObject = function (value) {
- /**
- * isObjectLike(new Foo) => false
- * isObjectLike([1, 2, 3]) => false
- * isObjectLike({ x: 0, y: 0 }) => true
- * isObjectLike(Object.create(null)) => true
- */
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(value) || !Object(__WEBPACK_IMPORTED_MODULE_1__is_type__["a" /* default */])(value, 'Object')) {
- return false;
- }
- if (Object.getPrototypeOf(value) === null) {
- return true;
- }
- var proto = value;
- while (Object.getPrototypeOf(proto) !== null) {
- proto = Object.getPrototypeOf(proto);
- }
- return Object.getPrototypeOf(value) === proto;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isPlainObject);
- /***/ }),
- /* 25 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) return '';
- return value.toString();
- });
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- var mix = __webpack_require__(64);
- var each = __webpack_require__(15);
- var isObject = __webpack_require__(44);
- var isNil = __webpack_require__(35);
- var Scale = /*#__PURE__*/function () {
- var _proto = Scale.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'base';
- /**
- * 格式化函数,输出文本或者tick时的格式化函数
- * @type {Function}
- */
- this.formatter = null;
- /**
- * 输出的值域
- * @type {Array}
- */
- this.range = [0, 1];
- /**
- * 度量的标记
- * @type {Array}
- */
- this.ticks = null;
- /**
- * 参与度量计算的值,可选项
- * @type {Array}
- */
- this.values = [];
- };
- function Scale(cfg) {
- this._initDefaultCfg();
- mix(this, cfg);
- this.init();
- }
- /**
- * 度量初始化
- * @protected
- */
- _proto.init = function init() {}
- /**
- * 获取该度量的ticks,返回的是多个对象,
- * - text: tick 的文本
- * - value: 对应的度量转换后的值
- * <code>
- * [
- * {text: 0,value:0}
- * {text: 1,value:0.2}
- * {text: 2,value:0.4}
- * {text: 3,value:0.6}
- * {text: 4,value:0.8}
- * {text: 5,value:1}
- * ]
- * </code>
- * @param {Number} count 输出tick的个数的近似值,默认是 10
- * @return {Array} 返回 ticks 数组
- */
- ;
- _proto.getTicks = function getTicks() {
- var self = this;
- var ticks = self.ticks;
- var rst = [];
- each(ticks, function (tick) {
- var obj;
- if (isObject(tick)) {
- obj = tick;
- } else {
- obj = {
- text: self.getText(tick),
- tickValue: tick,
- value: self.scale(tick)
- };
- }
- rst.push(obj);
- });
- return rst;
- }
- /**
- * 获取格式化后的文本
- * @param {*} value 输入的数据
- * @param {*} key 字段的 key
- * @return {String} 格式化的文本
- */
- ;
- _proto.getText = function getText(value, key) {
- var formatter = this.formatter;
- value = formatter ? formatter(value, key) : value;
- if (isNil(value) || !value.toString) {
- value = '';
- }
- return value.toString();
- }
- /**
- * 输出的值域最小值
- * @protected
- * @return {Number} 返回最小的值
- */
- ;
- _proto.rangeMin = function rangeMin() {
- return this.range[0];
- }
- /**
- * 输出的值域最大值
- * @protected
- * @return {Number} 返回最大的值
- */
- ;
- _proto.rangeMax = function rangeMax() {
- var range = this.range;
- return range[range.length - 1];
- }
- /**
- * 度量转换后的结果,翻转回输入域
- * @param {Number} value 需要翻转的数值
- * @return {*} 度量的输入值
- */
- ;
- _proto.invert = function invert(value) {
- return value;
- }
- /**
- * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
- * @param {*} value 传入的值
- * @return {Number} 转换的值
- */
- ;
- _proto.translate = function translate(value) {
- return value;
- }
- /**
- * 进行度量转换
- * @param {*} value 输入值
- * @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
- */
- ;
- _proto.scale = function scale(value) {
- return value;
- }
- /**
- * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
- * @return {Scale} 克隆的度量
- */
- ;
- _proto.clone = function clone() {
- var self = this;
- var constr = self.constructor;
- var cfg = {};
- each(self, function (v, k) {
- cfg[k] = self[k];
- });
- return new constr(cfg);
- }
- /**
- * 更改度量的属性信息
- * @param {Object} info 属性信息
- * @chainable
- * @return {Scale} 返回自身的引用
- */
- ;
- _proto.change = function change(info) {
- this.ticks = null;
- mix(this, info);
- this.init();
- return this;
- };
- return Scale;
- }();
- module.exports = Scale;
- /***/ }),
- /* 27 */
- /***/ (function(module, exports) {
- var toString = {}.toString;
- var isType = function isType(value, type) {
- return toString.call(value) === '[object ' + type + ']';
- };
- module.exports = isType;
- /***/ }),
- /* 28 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- var contains = function (arr, value) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
- return false;
- }
- return arr.indexOf(value) > -1;
- };
- /* harmony default export */ __webpack_exports__["a"] = (contains);
- /***/ }),
- /* 29 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- /**
- * isObject({}) => true
- * isObject([1, 2, 3]) => true
- * isObject(Function) => true
- * isObject(null) => false
- */
- var type = typeof value;
- return value !== null && type === 'object' || type === 'function';
- });
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _const = __webpack_require__(47);
- 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); }; }
- 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; } }
- var Base = __webpack_require__(63);
- var Plot = __webpack_require__(158);
- var Util = __webpack_require__(0);
- var Coord = __webpack_require__(159);
- var Geom = __webpack_require__(17);
- var ScaleController = __webpack_require__(167);
- var AxisController = __webpack_require__(173);
- var Global = __webpack_require__(6);
- var _require = __webpack_require__(16),
- Canvas = _require.Canvas;
- var Helper = __webpack_require__(37);
- function compare(a, b) {
- return a - b;
- }
- function _isScaleExist(scales, compareScale) {
- var flag = false;
- Util.each(scales, function (scale) {
- var scaleValues = [].concat(scale.values);
- var compareScaleValues = [].concat(compareScale.values);
- if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
- flag = true;
- return;
- }
- });
- return flag;
- }
- var Chart = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Chart, _Base);
- var _super = _createSuper(Chart);
- Chart.initPlugins = function initPlugins() {
- return {
- _plugins: [],
- _cacheId: 0,
- register: function register(plugins) {
- var p = this._plugins;
- [].concat(plugins).forEach(function (plugin) {
- if (p.indexOf(plugin) === -1) {
- p.push(plugin);
- }
- });
- this._cacheId++;
- },
- unregister: function unregister(plugins) {
- var p = this._plugins;
- [].concat(plugins).forEach(function (plugin) {
- var idx = p.indexOf(plugin);
- if (idx !== -1) {
- p.splice(idx, 1);
- }
- });
- this._cacheId++;
- },
- clear: function clear() {
- this._plugins = [];
- this._cacheId++;
- },
- count: function count() {
- return this._plugins.length;
- },
- getAll: function getAll() {
- return this._plugins;
- },
- notify: function notify(chart, hook, args) {
- var descriptors = this.descriptors(chart);
- var ilen = descriptors.length;
- var i;
- var descriptor;
- var plugin;
- var params;
- var method;
- for (i = 0; i < ilen; ++i) {
- descriptor = descriptors[i];
- plugin = descriptor.plugin;
- method = plugin[hook];
- if (typeof method === 'function') {
- params = [chart].concat(args || []);
- if (method.apply(plugin, params) === false) {
- return false;
- }
- }
- }
- return true;
- },
- descriptors: function descriptors(chart) {
- var cache = chart._plugins || (chart._plugins = {});
- if (cache.id === this._cacheId) {
- return cache.descriptors;
- }
- var plugins = [];
- var descriptors = [];
- this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
- var idx = plugins.indexOf(plugin);
- if (idx !== -1) {
- return;
- }
- plugins.push(plugin);
- descriptors.push({
- plugin: plugin
- });
- });
- cache.descriptors = descriptors;
- cache.id = this._cacheId;
- return descriptors;
- }
- };
- };
- var _proto = Chart.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * the id of canvas
- * @type {String}
- */
- id: null,
- rendered: false,
- /**
- * padding
- * @type {Array|Number}
- */
- padding: Global.padding,
- /**
- * data
- * @type {Array}
- */
- data: null,
- /**
- * scales of chart
- * @type {Object}
- */
- scales: {},
- /**
- * @private
- * geometry instances
- * @type {Array}
- */
- geoms: [],
- /**
- * scale configuration
- * @type {Object}
- */
- colDefs: null,
- pixelRatio: Global.pixelRatio,
- /**
- * filter options
- * @type {Object}
- */
- filters: null,
- appendPadding: Global.appendPadding
- };
- };
- _proto._syncYScales = function _syncYScales() {
- var syncY = this.get('syncY');
- if (!syncY) {
- return;
- }
- var geoms = this.get('geoms');
- var syncScales = [];
- var min = [];
- var max = [];
- Util.each(geoms, function (geom) {
- var yScale = geom.getYScale();
- if (yScale.isLinear) {
- syncScales.push(yScale);
- min.push(yScale.min);
- max.push(yScale.max);
- }
- });
- min = Math.min.apply(null, min);
- max = Math.max.apply(null, max);
- Util.each(syncScales, function (scale) {
- scale.change({
- min: min
- });
- scale.change({
- max: max
- });
- });
- };
- _proto._getFieldsForLegend = function _getFieldsForLegend() {
- var fields = [];
- var geoms = this.get('geoms');
- Util.each(geoms, function (geom) {
- var attrOptions = geom.get('attrOptions');
- var attrCfg = attrOptions.color;
- if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
- var arr = attrCfg.field.split('*');
- Util.each(arr, function (item) {
- if (fields.indexOf(item) === -1) {
- fields.push(item);
- }
- });
- }
- });
- return fields;
- };
- _proto._getScaleData = function _getScaleData(field) {
- var data = this.get('data');
- var filteredData = this.get('filteredData');
- if (filteredData.length) {
- var legendFields = this._getFieldsForLegend();
- if (legendFields.indexOf(field) === -1) {
- data = filteredData;
- }
- }
- return data;
- } // _updateScales() {
- // const scaleController = this.get('scaleController');
- // scaleController.updateScales();
- // this._adjustScale();
- // }
- ;
- _proto._adjustScale = function _adjustScale() {
- var self = this;
- var scaleController = self.get('scaleController'); // 看起来是为了让柱状图最小或最大都默认从0开始
- var geoms = this.get('geoms');
- for (var i = 0; i < geoms.length; i++) {
- var geom = geoms[i];
- if (geom.get('type') === 'interval') {
- var yScale = geom.getYScale();
- scaleController.adjustStartZero(yScale);
- }
- }
- };
- _proto._removeGeoms = function _removeGeoms() {
- var geoms = this.get('geoms');
- while (geoms.length > 0) {
- var geom = geoms.shift();
- geom.destroy();
- }
- };
- _proto._clearGeoms = function _clearGeoms() {
- var geoms = this.get('geoms');
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.clear();
- }
- };
- _proto._clearInner = function _clearInner() {
- this._clearGeoms();
- Chart.plugins.notify(this, 'clearInner');
- this.get('axisController') && this.get('axisController').clear();
- };
- _proto._initFilteredData = function _initFilteredData() {
- var filters = this.get('filters');
- var data = this.get('data') || [];
- if (filters) {
- data = data.filter(function (obj) {
- var rst = true;
- Util.each(filters, function (fn, k) {
- if (fn) {
- rst = fn(obj[k], obj);
- if (!rst) {
- return false;
- }
- }
- });
- return rst;
- });
- }
- this.set('filteredData', data);
- };
- _proto._changeGeomsData = function _changeGeomsData() {
- var geoms = this.get('geoms');
- var data = this.get('filteredData');
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.changeData(data);
- }
- };
- _proto._initGeom = function _initGeom(geom) {
- var coord = this.get('coord');
- var data = this.get('filteredData');
- var colDefs = this.get('colDefs');
- var middlePlot = this.get('middlePlot');
- geom.set('chart', this);
- geom.set('container', middlePlot.addGroup());
- geom.set('data', data);
- geom.set('coord', coord);
- geom.set('colDefs', colDefs);
- geom.init();
- this.emit(_const.EVENT_AFTER_GEOM_INIT, geom);
- };
- _proto._initGeoms = function _initGeoms() {
- var geoms = this.get('geoms');
- for (var i = 0, length = geoms.length; i < length; i++) {
- this._initGeom(geoms[i]);
- }
- };
- _proto._initCoord = function _initCoord() {
- var plot = this.get('plotRange');
- var coordCfg = Util.mix({
- type: 'cartesian'
- }, this.get('coordCfg'), {
- plot: plot
- });
- var type = coordCfg.type;
- var C = Coord[Util.upperFirst(type)];
- var coord = new C(coordCfg);
- this.set('coord', coord);
- };
- _proto._initLayout = function _initLayout() {
- var padding = this.get('_padding');
- if (!padding) {
- padding = this.get('margin') || this.get('padding');
- padding = Util.parsePadding(padding);
- }
- var top = padding[0] === 'auto' ? 0 : padding[0];
- var right = padding[1] === 'auto' ? 0 : padding[1];
- var bottom = padding[2] === 'auto' ? 0 : padding[2];
- var left = padding[3] === 'auto' ? 0 : padding[3];
- var width = this.get('width');
- var height = this.get('height');
- var start = {
- x: left,
- y: top
- };
- var end = {
- x: width - right,
- y: height - bottom
- };
- var plot = this.get('plot');
- if (plot) {
- plot.reset(start, end);
- return;
- }
- var newPlot = new Plot({
- start: start,
- end: end
- });
- this.set('plotRange', newPlot);
- this.set('plot', newPlot);
- };
- _proto._initCanvas = function _initCanvas() {
- var self = this;
- try {
- var canvas = new Canvas({
- el: self.get('el') || self.get('id'),
- context: self.get('context'),
- pixelRatio: self.get('pixelRatio'),
- width: self.get('width'),
- height: self.get('height'),
- fontFamily: Global.fontFamily
- });
- self.set('canvas', canvas);
- self.set('el', canvas.get('el'));
- self.set('width', canvas.get('width'));
- self.set('height', canvas.get('height'));
- } catch (error) {
- throw error;
- }
- Chart.plugins.notify(self, 'afterCanvasInit');
- };
- _proto._initLayers = function _initLayers() {
- var canvas = this.get('canvas');
- this.set('backPlot', canvas.addGroup());
- this.set('middlePlot', canvas.addGroup({
- zIndex: 10
- }));
- this.set('frontPlot', canvas.addGroup({
- zIndex: 20
- }));
- };
- _proto._initEvents = function _initEvents() {
- var _this2 = this;
- // 数据更新后的一些更新
- this.on(_const.EVENT_AFTER_DATA_CHANGE, function () {
- // 数据更新后,重新设置filterdata
- _this2._initFilteredData(); // 更新geoms里的数据
- _this2._changeGeomsData();
- _this2._adjustScale();
- }); // 大小变化后的一些更新
- this.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
- _this2._initLayout(); // layout变化后,坐标轴也需要做相应的变化
- var coord = _this2.get('coord');
- if (coord) {
- coord.reset(_this2.get('plot'));
- }
- });
- };
- _proto._initScaleController = function _initScaleController() {
- var scaleController = new ScaleController({
- chart: this
- }); // 让colDefs 和 scaleController.defs 用同一个对象,这样就不用考虑同步的问题
- this.set('colDefs', scaleController.defs); // 已经实例化的scales 也保持统一个对象
- this.set('scales', scaleController.scales);
- this.set('scaleController', scaleController);
- };
- _proto._clearScaleController = function _clearScaleController() {
- var scaleController = this.get('scaleController');
- scaleController.clear();
- };
- _proto._init = function _init() {
- var self = this;
- self._initCanvas();
- self._initLayout();
- self._initLayers();
- self._initEvents();
- self._initScaleController();
- self.set('axisController', new AxisController({
- frontPlot: self.get('frontPlot').addGroup({
- className: 'axisContainer'
- }),
- backPlot: self.get('backPlot').addGroup({
- className: 'axisContainer'
- }),
- chart: self
- }));
- Chart.plugins.notify(self, 'init');
- };
- function Chart(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- var self = (0, _assertThisInitialized2["default"])(_this);
- Util.each(Geom, function (geomConstructor, className) {
- var methodName = Util.lowerFirst(className);
- self[methodName] = function (cfg) {
- var geom = new geomConstructor(cfg);
- self.addGeom(geom);
- return geom;
- };
- });
- self._init();
- return _this;
- }
- _proto.init = function init() {
- // 初始filterData
- this._initFilteredData(); // initialization coordinate instance
- this._initCoord();
- Chart.plugins.notify(this, 'beforeGeomInit'); // init all geometry instances
- this._initGeoms(); // 多 Y 轴的情况时,统一 Y 轴的数值范围。
- this._syncYScales(); // do some adjust for data
- this._adjustScale();
- this.emit(_const.EVENT_AFTER_INIT);
- }
- /**
- * set data and some scale configuration
- * @chainable
- * @param {Array} data the dataset to visualize
- * @param {Object} colDefs the configuration for scales
- * @return {Chart} return the chart instance
- */
- ;
- _proto.source = function source(data, colDefs) {
- this.set('data', data);
- if (colDefs) {
- this.scale(colDefs);
- }
- return this;
- };
- _proto.scale = function scale(field, cfg) {
- var scaleController = this.get('scaleController');
- scaleController.setFieldDef(field, cfg);
- return this;
- }
- /**
- * configure the axis
- * @chainable
- * @param {String|Boolean} field the field name of data
- * @param {Object} cfg configuration for axis
- * @return {Chart} return the chart instance
- */
- ;
- _proto.axis = function axis(field, cfg) {
- var axisController = this.get('axisController');
- if (!field) {
- axisController.axisCfg = null;
- } else {
- axisController.axisCfg = axisController.axisCfg || {};
- axisController.axisCfg[field] = cfg;
- }
- return this;
- }
- /**
- * configure the coordinate
- * @chainable
- * @param {String} type set the type of coodinate
- * @param {Object} cfg configuration for coordinate
- * @return {Chart} return the chart instance
- */
- ;
- _proto.coord = function coord(type, cfg) {
- var coordCfg;
- if (Util.isObject(type)) {
- coordCfg = type;
- } else {
- coordCfg = cfg || {};
- coordCfg.type = type || 'cartesian';
- }
- this.set('coordCfg', coordCfg);
- return this;
- };
- _proto.filter = function filter(field, condition) {
- var filters = this.get('filters') || {};
- filters[field] = condition;
- this.set('filters', filters); // 如果已经render过,则再重新触发一次change
- if (this.get('rendered')) {
- this.emit(_const.EVENT_AFTER_DATA_CHANGE, this.get('data'));
- }
- }
- /**
- * render the chart
- * @chainable
- * @return {Chart} return the chart instance
- */
- ;
- _proto.render = function render() {
- var rendered = this.get('rendered');
- var canvas = this.get('canvas');
- var geoms = this.get('geoms');
- if (!rendered) {
- this.init();
- this.set('rendered', true);
- }
- this.emit(_const.EVENT_BEFORE_RENDER);
- Chart.plugins.notify(this, 'beforeGeomDraw');
- this._renderAxis();
- var middlePlot = this.get('middlePlot');
- if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
- var coord = this.get('coord');
- var clip = Helper.getClip(coord);
- clip.set('canvas', middlePlot.get('canvas'));
- middlePlot.attr('clip', clip);
- }
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.paint();
- }
- Chart.plugins.notify(this, 'afterGeomDraw');
- canvas.sort();
- this.get('frontPlot').sort();
- Chart.plugins.notify(this, 'beforeCanvasDraw');
- canvas.draw();
- this.emit(_const.EVENT_AFTER_RENDER);
- return this;
- }
- /**
- * clear the chart, include geometris and all the shapes
- * @chainable
- * @return {Chart} return the chart
- */
- ;
- _proto.clear = function clear() {
- Chart.plugins.notify(this, 'clear');
- this._clearInner();
- this._removeGeoms();
- this._clearScaleController();
- this.set('legendItems', null);
- this.set('filters', null);
- this.set('isUpdate', false);
- this.set('_padding', null);
- this.set('rendered', false);
- var canvas = this.get('canvas');
- canvas.draw();
- return this;
- };
- _proto.repaint = function repaint() {
- // 如果在没有render之前就repaint的,就直接return退出
- var rendered = this.get('rendered');
- if (!rendered) {
- return;
- }
- this.set('isUpdate', true);
- this.set('legendItems', null);
- Chart.plugins.notify(this, 'repaint');
- this._clearInner();
- this.render();
- };
- _proto.changeData = function changeData(data) {
- this.emit(_const.EVENT_BEFORE_DATA_CHANGE, data);
- this.set('data', data);
- Chart.plugins.notify(this, 'changeData');
- this.emit(_const.EVENT_AFTER_DATA_CHANGE, data);
- this.set('_padding', null);
- this.repaint();
- };
- _proto.changeSize = function changeSize(width, height) {
- if (width) {
- this.set('width', width);
- } else {
- width = this.get('width');
- }
- if (height) {
- this.set('height', height);
- } else {
- height = this.get('height');
- }
- var canvas = this.get('canvas');
- canvas.changeSize(width, height);
- this.emit(_const.EVENT_AFTER_SIZE_CHANGE, {
- width: width,
- height: height
- });
- this.repaint();
- return this;
- };
- _proto.destroy = function destroy() {
- this.clear();
- var canvas = this.get('canvas');
- canvas.destroy();
- Chart.plugins.notify(this, 'afterCanvasDestroyed');
- if (this._interactions) {
- Util.each(this._interactions, function (interaction) {
- interaction.destroy();
- });
- }
- _Base.prototype.destroy.call(this);
- }
- /**
- * calculate dataset's position on canvas
- * @param {Object} record the dataset
- * @return {Object} return the position
- */
- ;
- _proto.getPosition = function getPosition(record) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScales()[0];
- var xField = xScale.field;
- var x = xScale.scale(record[xField]);
- var yField = yScale.field;
- var y = yScale.scale(record[yField]);
- return coord.convertPoint({
- x: x,
- y: y
- });
- }
- /**
- * get the data item of the point
- * @param {Object} point canvas position
- * @return {Object} return the data item
- */
- ;
- _proto.getRecord = function getRecord(point) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScales()[0];
- var invertPoint = coord.invertPoint(point);
- var record = {};
- record[xScale.field] = xScale.invert(invertPoint.x);
- record[yScale.field] = yScale.invert(invertPoint.y);
- return record;
- }
- /**
- * get the dataset of the point
- * @param {Object} point canvas position
- * @return {Array} return the dataset
- **/
- ;
- _proto.getSnapRecords = function getSnapRecords(point) {
- var geom = this.get('geoms')[0];
- var data = [];
- if (geom) {
- // need to judge
- data = geom.getSnapRecords(point);
- }
- return data;
- }
- /**
- * creat scale instances
- * @param {String} field field name of data
- * @return {Scale} return the scale
- */
- ;
- _proto.createScale = function createScale(field) {
- var data = this._getScaleData(field);
- var scaleController = this.get('scaleController');
- return scaleController.createScale(field, data);
- }
- /**
- * @protected
- * add geometry instance to geoms
- * @param {Geom} geom geometry instance
- */
- ;
- _proto.addGeom = function addGeom(geom) {
- var rendered = this.get('rendered');
- var geoms = this.get('geoms');
- geoms.push(geom); // 如果图表已经渲染过了,则直接初始化geom
- if (rendered) {
- this._initGeom(geom);
- }
- }
- /**
- * get the scale of x axis
- * @return {Scale} return the scale
- */
- ;
- _proto.getXScale = function getXScale() {
- var self = this;
- var geoms = self.get('geoms');
- var xScale = geoms[0].getXScale();
- return xScale;
- }
- /**
- * get the scale of y axis
- * @return {Array} return the scale
- */
- ;
- _proto.getYScales = function getYScales() {
- var geoms = this.get('geoms');
- var rst = [];
- Util.each(geoms, function (geom) {
- var yScale = geom.getYScale();
- if (rst.indexOf(yScale) === -1) {
- rst.push(yScale);
- }
- });
- return rst;
- };
- _proto.getLegendItems = function getLegendItems() {
- if (this.get('legendItems')) {
- return this.get('legendItems');
- }
- var legendItems = {};
- var scales = [];
- var geoms = this.get('geoms');
- Util.each(geoms, function (geom) {
- var colorAttr = geom.getAttr('color');
- if (colorAttr) {
- var scale = colorAttr.getScale('color'); // 只支持分类图例
- if (scale.isCategory && !_isScaleExist(scales, scale)) {
- scales.push(scale);
- var field = scale.field;
- var ticks = scale.getTicks();
- var items = [];
- Util.each(ticks, function (tick) {
- var text = tick.text;
- var name = text;
- var scaleValue = tick.value;
- var value = scale.invert(scaleValue);
- var color = colorAttr.mapping(value).join('') || Global.defaultColor;
- var marker = {
- fill: color,
- radius: 3,
- symbol: 'circle',
- stroke: '#fff'
- };
- items.push({
- name: name,
- // for display
- dataValue: value,
- // the origin value
- checked: true,
- marker: marker
- });
- });
- legendItems[field] = items;
- }
- }
- });
- this.set('legendItems', legendItems);
- return legendItems;
- } // register the plugins
- ;
- _proto.registerPlugins = function registerPlugins(plugins) {
- var self = this;
- var chartPlugins = self.get('plugins') || [];
- if (!Util.isArray(chartPlugins)) {
- chartPlugins = [chartPlugins];
- }
- [].concat(plugins).forEach(function (plugin) {
- if (chartPlugins.indexOf(plugin) === -1) {
- plugin.init && plugin.init(self); // init
- chartPlugins.push(plugin);
- }
- });
- Chart.plugins._cacheId++;
- self.set('plugins', chartPlugins);
- };
- _proto._renderAxis = function _renderAxis() {
- var axisController = this.get('axisController');
- var xScale = this.getXScale();
- var yScales = this.getYScales();
- var coord = this.get('coord');
- Chart.plugins.notify(this, 'beforeRenderAxis');
- axisController.createAxis(coord, xScale, yScales);
- };
- _proto._isAutoPadding = function _isAutoPadding() {
- if (this.get('_padding')) {
- return false;
- }
- var padding = this.get('padding');
- if (Util.isArray(padding)) {
- return padding.indexOf('auto') !== -1;
- }
- return padding === 'auto';
- };
- _proto._updateLayout = function _updateLayout(padding) {
- var width = this.get('width');
- var height = this.get('height');
- var start = {
- x: padding[3],
- y: padding[0]
- };
- var end = {
- x: width - padding[1],
- y: height - padding[2]
- };
- var plot = this.get('plot');
- var coord = this.get('coord');
- plot.reset(start, end);
- coord.reset(plot);
- };
- return Chart;
- }(Base);
- Chart.plugins = Chart.initPlugins();
- module.exports = Chart;
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Matrix = {
- multiply: function multiply(m1, m2) {
- var m11 = m1[0] * m2[0] + m1[2] * m2[1];
- var m12 = m1[1] * m2[0] + m1[3] * m2[1];
- var m21 = m1[0] * m2[2] + m1[2] * m2[3];
- var m22 = m1[1] * m2[2] + m1[3] * m2[3];
- var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
- var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
- return [m11, m12, m21, m22, dx, dy];
- },
- scale: function scale(out, m, v) {
- out[0] = m[0] * v[0];
- out[1] = m[1] * v[0];
- out[2] = m[2] * v[1];
- out[3] = m[3] * v[1];
- out[4] = m[4];
- out[5] = m[5];
- return out;
- },
- rotate: function rotate(out, m, radian) {
- var c = Math.cos(radian);
- var s = Math.sin(radian);
- var m11 = m[0] * c + m[2] * s;
- var m12 = m[1] * c + m[3] * s;
- var m21 = m[0] * -s + m[2] * c;
- var m22 = m[1] * -s + m[3] * c;
- out[0] = m11;
- out[1] = m12;
- out[2] = m21;
- out[3] = m22;
- out[4] = m[4];
- out[5] = m[5];
- return out;
- },
- translate: function translate(out, m, v) {
- out[0] = m[0];
- out[1] = m[1];
- out[2] = m[2];
- out[3] = m[3];
- out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
- out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
- return out;
- },
- transform: function transform(m, actions) {
- var out = [].concat(m);
- for (var i = 0, len = actions.length; i < len; i++) {
- var action = actions[i];
- switch (action[0]) {
- case 't':
- Matrix.translate(out, out, [action[1], action[2]]);
- break;
- case 's':
- Matrix.scale(out, out, [action[1], action[2]]);
- break;
- case 'r':
- Matrix.rotate(out, out, action[1]);
- break;
- default:
- break;
- }
- }
- return out;
- }
- };
- module.exports = Matrix;
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports["default"] = void 0;
- var _util = __webpack_require__(20);
- /**
- * @fileOverview the Attribute base class
- */
- function toScaleString(scale, value) {
- if ((0, _util.isString)(value)) {
- return value;
- }
- return scale.invert(scale.scale(value));
- }
- /**
- * 所有视觉通道属性的基类
- * @class Attr
- */
- var AttributeBase = /*#__PURE__*/function () {
- function AttributeBase(cfg) {
- var _this = this;
- /**
- * 属性的类型
- * @type {String}
- */
- this.type = 'base';
- /**
- * 属性的名称
- * @type {String}
- */
- this.name = null;
- /**
- * 回调函数
- * @type {Function}
- */
- this.method = null;
- /**
- * 备选的值数组
- * @type {Array}
- */
- this.values = [];
- /**
- * 属性内部的度量
- * @type {Array}
- */
- this.scales = [];
- /**
- * 是否通过线性取值, 如果未指定,则根据数值的类型判定
- * @type {Boolean}
- */
- this.linear = null;
- /**
- * 当用户设置的 callback 返回 null 时, 应该返回默认 callback 中的值
- */
- var mixedCallback = null;
- var defaultCallback = this.callback;
- if (cfg.callback) {
- var userCallback = cfg.callback;
- mixedCallback = function mixedCallback() {
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
- params[_key] = arguments[_key];
- }
- var ret = userCallback.apply(void 0, params);
- if ((0, _util.isNil)(ret)) {
- ret = defaultCallback.apply(_this, params);
- }
- return ret;
- };
- }
- (0, _util.mix)(this, cfg);
- if (mixedCallback) {
- (0, _util.mix)(this, {
- callback: mixedCallback
- });
- }
- } // 获取属性值,将值映射到视觉通道
- var _proto = AttributeBase.prototype;
- _proto._getAttrValue = function _getAttrValue(scale, value) {
- var values = this.values;
- if (scale.isCategory && !this.linear) {
- var index = scale.translate(value);
- return values[index % values.length];
- }
- var percent = scale.scale(value);
- return this.getLinearValue(percent);
- }
- /**
- * 如果进行线性映射,返回对应的映射值
- * @protected
- * @param {Number} percent 百分比
- * @return {*} 颜色值、形状、大小等
- */
- ;
- _proto.getLinearValue = function getLinearValue(percent) {
- var values = this.values;
- var steps = values.length - 1;
- var step = Math.floor(steps * percent);
- var leftPercent = steps * percent - step;
- var start = values[step];
- var end = step === steps ? start : values[step + 1];
- var rstValue = start + (end - start) * leftPercent;
- return rstValue;
- }
- /**
- * 默认的回调函数
- * @param {*} value 回调函数的值
- * @type {Function}
- * @return {Array} 返回映射后的值
- */
- ;
- _proto.callback = function callback(value) {
- var self = this;
- var scale = self.scales[0];
- var rstValue = null;
- if (scale.type === 'identity') {
- rstValue = scale.value;
- } else {
- rstValue = self._getAttrValue(scale, value);
- }
- return rstValue;
- }
- /**
- * 根据度量获取属性名
- * @return {Array} dims of this Attribute
- */
- ;
- _proto.getNames = function getNames() {
- var scales = this.scales;
- var names = this.names;
- var length = Math.min(scales.length, names.length);
- var rst = [];
- for (var i = 0; i < length; i++) {
- rst.push(names[i]);
- }
- return rst;
- }
- /**
- * 根据度量获取维度名
- * @return {Array} dims of this Attribute
- */
- ;
- _proto.getFields = function getFields() {
- var scales = this.scales;
- var rst = [];
- (0, _util.each)(scales, function (scale) {
- rst.push(scale.field);
- });
- return rst;
- }
- /**
- * 根据名称获取度量
- * @param {String} name the name of scale
- * @return {Scale} scale
- */
- ;
- _proto.getScale = function getScale(name) {
- var scales = this.scales;
- var names = this.names;
- var index = names.indexOf(name);
- return scales[index];
- }
- /**
- * 映射数据
- * @param {*} param1...paramn 多个数值
- * @return {Array} 映射的值组成的数组
- */
- ;
- _proto.mapping = function mapping() {
- var scales = this.scales;
- var callback = this.callback;
- for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- params[_key2] = arguments[_key2];
- }
- var values = params;
- if (callback) {
- for (var i = 0, len = params.length; i < len; i++) {
- params[i] = this._toOriginParam(params[i], scales[i]);
- }
- values = callback.apply(this, params);
- }
- values = [].concat(values);
- return values;
- } // 原始的参数
- ;
- _proto._toOriginParam = function _toOriginParam(param, scale) {
- var rst = param;
- if (!scale.isLinear) {
- if ((0, _util.isArray)(param)) {
- rst = [];
- for (var i = 0, len = param.length; i < len; i++) {
- rst.push(toScaleString(scale, param[i]));
- }
- } else {
- rst = toScaleString(scale, param);
- }
- }
- return rst;
- };
- return AttributeBase;
- }();
- var _default = AttributeBase;
- exports["default"] = _default;
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- var mix = __webpack_require__(64);
- var Adjust = /*#__PURE__*/function () {
- var _proto = Adjust.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
- };
- function Adjust(cfg) {
- this._initDefaultCfg();
- mix(this, cfg);
- }
- /**
- * @override
- */
- _proto.processAdjust = function processAdjust()
- /* dataArray */
- {};
- return Adjust;
- }();
- module.exports = Adjust;
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(27);
- var isArray = Array.isArray ? Array.isArray : function (value) {
- return isType(value, 'Array');
- };
- module.exports = isArray;
- /***/ }),
- /* 35 */
- /***/ (function(module, exports) {
- // isFinite,
- var isNil = function isNil(value) {
- /**
- * isNil(null) => true
- * isNil() => true
- */
- return value === null || value === undefined;
- };
- module.exports = isNil;
- /***/ }),
- /* 36 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 判断是否数字
- * @return {Boolean} 是否数字
- */
- var isType = __webpack_require__(27);
- var isNumber = function isNumber(value) {
- return isType(value, 'Number');
- };
- module.exports = isNumber;
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports.getClip = getClip;
- exports.isPointInPlot = isPointInPlot;
- var _require = __webpack_require__(16),
- Shape = _require.Shape;
- function getClip(coord) {
- var start = coord.start;
- var end = coord.end;
- var width = end.x - start.x;
- var height = Math.abs(end.y - start.y);
- var margin = 10;
- var clip;
- if (coord.isPolar) {
- var circleRadius = coord.circleRadius,
- center = coord.center,
- startAngle = coord.startAngle,
- endAngle = coord.endAngle;
- clip = new Shape.Sector({
- attrs: {
- x: center.x,
- y: center.y,
- r: circleRadius,
- r0: 0,
- startAngle: startAngle,
- endAngle: endAngle
- }
- });
- } else {
- clip = new Shape.Rect({
- attrs: {
- x: start.x,
- y: end.y - margin,
- width: width,
- height: height + 2 * margin
- }
- });
- }
- clip.isClip = true;
- return clip;
- }
- function isPointInPlot(point, plot) {
- var x = point.x,
- y = point.y;
- var tl = plot.tl,
- tr = plot.tr,
- br = plot.br;
- return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
- }
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @fileOverview shape util
- * @author dxq613@gmail.com
- */
- var Util = __webpack_require__(0);
- var ShapeUtil = {
- splitPoints: function splitPoints(obj) {
- var points = [];
- var x = obj.x;
- var y = obj.y;
- y = Util.isArray(y) ? y : [y];
- y.forEach(function (yItem, index) {
- var point = {
- x: Util.isArray(x) ? x[index] : x,
- y: yItem
- };
- points.push(point);
- });
- return points;
- },
- splitArray: function splitArray(data, yField, connectNulls) {
- if (!data.length) return [];
- var arr = [];
- var tmp = [];
- var yValue;
- Util.each(data, function (obj) {
- yValue = obj._origin ? obj._origin[yField] : obj[yField];
- if (connectNulls) {
- if (!Util.isNil(yValue)) {
- tmp.push(obj);
- }
- } else {
- if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
- if (tmp.length) {
- arr.push(tmp);
- tmp = [];
- }
- } else {
- tmp.push(obj);
- }
- }
- });
- if (tmp.length) {
- arr.push(tmp);
- }
- return arr;
- }
- };
- module.exports = ShapeUtil;
- /***/ }),
- /* 39 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
- var filter = function (arr, func) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(arr)) {
- return arr;
- }
- var result = [];
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (value, index) {
- if (func(value, index)) {
- result.push(value);
- }
- });
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (filter);
- /***/ }),
- /* 40 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var isObjectLike = function (value) {
- /**
- * isObjectLike({}) => true
- * isObjectLike([1, 2, 3]) => true
- * isObjectLike(Function) => false
- * isObjectLike(null) => false
- */
- return typeof value === 'object' && value !== null;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isObjectLike);
- /***/ }),
- /* 41 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = mix;
- // FIXME: Mutable param should be forbidden in static lang.
- function _mix(dist, obj) {
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
- dist[key] = obj[key];
- }
- }
- }
- function mix(dist, src1, src2, src3) {
- if (src1) _mix(dist, src1);
- if (src2) _mix(dist, src2);
- if (src3) _mix(dist, src3);
- return dist;
- }
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports["default"] = void 0;
- var _common = __webpack_require__(0);
- // 实现简单的事件机制
- var EventEmit = /*#__PURE__*/function () {
- function EventEmit() {
- this.__events = {};
- }
- var _proto = EventEmit.prototype;
- _proto.on = function on(type, listener) {
- if (!type || !listener) {
- return;
- }
- var events = this.__events[type] || [];
- events.push(listener);
- this.__events[type] = events;
- };
- _proto.emit = function emit(type, e) {
- var _this = this;
- if ((0, _common.isObject)(type)) {
- e = type;
- type = e && e.type;
- }
- if (!type) {
- return;
- }
- var events = this.__events[type];
- if (!events || !events.length) {
- return;
- }
- events.forEach(function (listener) {
- listener.call(_this, e);
- });
- };
- _proto.off = function off(type, listener) {
- var __events = this.__events;
- var events = __events[type];
- if (!events || !events.length) {
- return;
- } // 如果没有指定方法,则删除所有项
- if (!listener) {
- delete __events[type];
- return;
- } // 删除指定的 listener
- for (var i = 0, len = events.length; i < len; i++) {
- if (events[i] === listener) {
- events.splice(i, 1);
- }
- }
- };
- return EventEmit;
- }();
- var _default = EventEmit;
- exports["default"] = _default;
- /***/ }),
- /* 43 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var MatrixUtil = __webpack_require__(31);
- var Vector2 = __webpack_require__(13);
- var defaultMatrix = [1, 0, 0, 1, 0, 0];
- var Base = /*#__PURE__*/function () {
- var _proto = Base.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {};
- function Base(cfg) {
- this._initDefaultCfg();
- Util.mix(this, cfg);
- var start;
- var end;
- if (this.plot) {
- start = this.plot.bl;
- end = this.plot.tr;
- this.start = start;
- this.end = end;
- } else {
- start = this.start;
- end = this.end;
- }
- this.init(start, end);
- }
- _proto._scale = function _scale(s1, s2) {
- var matrix = this.matrix;
- var center = this.center;
- MatrixUtil.translate(matrix, matrix, [center.x, center.y]);
- MatrixUtil.scale(matrix, matrix, [s1, s2]);
- MatrixUtil.translate(matrix, matrix, [-center.x, -center.y]);
- };
- _proto.init = function init(start, end) {
- this.matrix = [].concat(defaultMatrix); // 设置中心点
- this.center = {
- x: (end.x - start.x) / 2 + start.x,
- y: (end.y - start.y) / 2 + start.y
- };
- if (this.scale) {
- this._scale(this.scale[0], this.scale[1]);
- }
- };
- _proto.convertPoint = function convertPoint(point) {
- var _this$_convertPoint = this._convertPoint(point),
- x = _this$_convertPoint.x,
- y = _this$_convertPoint.y;
- var vector = [x, y];
- Vector2.transformMat2d(vector, vector, this.matrix);
- return {
- x: vector[0],
- y: vector[1]
- };
- };
- _proto.invertPoint = function invertPoint(point) {
- return this._invertPoint(point);
- };
- _proto._convertPoint = function _convertPoint(point) {
- return point;
- };
- _proto._invertPoint = function _invertPoint(point) {
- return point;
- };
- _proto.reset = function reset(plot) {
- this.plot = plot;
- var bl = plot.bl,
- tr = plot.tr;
- this.start = bl;
- this.end = tr;
- this.init(bl, tr);
- };
- return Base;
- }();
- module.exports = Base;
- /***/ }),
- /* 44 */
- /***/ (function(module, exports) {
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- var isObject = function isObject(value) {
- /**
- * isObject({}) => true
- * isObject([1, 2, 3]) => true
- * isObject(Function) => true
- * isObject(null) => false
- */
- var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
- return value !== null && type === 'object' || type === 'function';
- };
- module.exports = isObject;
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(6);
- var Vector2 = __webpack_require__(13);
- var Abastract = /*#__PURE__*/function () {
- var _proto = Abastract.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- /**
- * ticks
- * @type {Array}
- */
- this.ticks = [];
- /**
- * the configuration for tickLine
- * @type {Object}
- */
- this.tickLine = {};
- /**
- * the direction of ticks, 1 means clockwise
- * @type {Number}
- */
- this.offsetFactor = 1;
- /**
- * the top container
- * @type {container}
- */
- this.frontContainer = null;
- /**
- * the back container
- * @type {[type]}
- */
- this.backContainer = null;
- /**
- * points for draw grid line
- * @type {Array}
- */
- this.gridPoints = [];
- };
- function Abastract(cfg) {
- this._initDefaultCfg();
- Util.mix(this, cfg);
- this.draw();
- }
- _proto.draw = function draw() {
- var line = this.line,
- tickLine = this.tickLine,
- label = this.label,
- grid = this.grid;
- grid && this.drawGrid(grid); // draw the grid lines
- tickLine && this.drawTicks(tickLine); // draw the tickLine
- line && this.drawLine(line); // draw axis line
- label && this.drawLabels(); // draw ticks
- };
- _proto.drawTicks = function drawTicks(tickCfg) {
- var self = this;
- var ticks = self.ticks;
- var length = tickCfg.length;
- var container = self.getContainer(tickCfg.top);
- Util.each(ticks, function (tick) {
- var start = self.getOffsetPoint(tick.value);
- var end = self.getSidePoint(start, length);
- var shape = container.addShape('line', {
- className: 'axis-tick',
- attrs: Util.mix({
- x1: start.x,
- y1: start.y,
- x2: end.x,
- y2: end.y
- }, tickCfg)
- });
- shape._id = self._id + '-ticks';
- });
- };
- _proto.drawLabels = function drawLabels() {
- var self = this;
- var labelOffset = self.labelOffset;
- var labels = self.labels;
- Util.each(labels, function (labelShape) {
- var container = self.getContainer(labelShape.get('top'));
- var start = self.getOffsetPoint(labelShape.get('value'));
- var _self$getSidePoint = self.getSidePoint(start, labelOffset),
- x = _self$getSidePoint.x,
- y = _self$getSidePoint.y;
- labelShape.attr(Util.mix({
- x: x,
- y: y
- }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
- labelShape._id = self._id + '-' + labelShape.attr('text');
- container.add(labelShape);
- });
- };
- _proto.drawLine = function drawLine() {};
- _proto.drawGrid = function drawGrid(grid) {
- var self = this;
- var gridPoints = self.gridPoints,
- ticks = self.ticks;
- var gridCfg = grid;
- var count = gridPoints.length;
- Util.each(gridPoints, function (subPoints, index) {
- if (Util.isFunction(grid)) {
- var tick = ticks[index] || {};
- var executedGrid = grid(tick.text, index, count);
- gridCfg = executedGrid ? Util.mix({}, Global._defaultAxis.grid, executedGrid) : null;
- }
- if (gridCfg) {
- var type = gridCfg.type; // has two types: 'line' and 'arc'
- var points = subPoints.points;
- var container = self.getContainer(gridCfg.top);
- var shape;
- if (type === 'arc') {
- var center = self.center,
- startAngle = self.startAngle,
- endAngle = self.endAngle;
- var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
- shape = container.addShape('Arc', {
- className: 'axis-grid',
- attrs: Util.mix({
- x: center.x,
- y: center.y,
- startAngle: startAngle,
- endAngle: endAngle,
- r: radius
- }, gridCfg)
- });
- } else {
- shape = container.addShape('Polyline', {
- className: 'axis-grid',
- attrs: Util.mix({
- points: points
- }, gridCfg)
- });
- }
- shape._id = subPoints._id;
- }
- });
- };
- _proto.getOffsetPoint = function getOffsetPoint() {};
- _proto.getAxisVector = function getAxisVector() {};
- _proto.getOffsetVector = function getOffsetVector(point, offset) {
- var self = this;
- var axisVector = self.getAxisVector(point);
- var normal = Vector2.normalize([], axisVector);
- var factor = self.offsetFactor;
- var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
- return Vector2.scale([], verticalVector, offset);
- };
- _proto.getSidePoint = function getSidePoint(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- return {
- x: point.x + offsetVector[0],
- y: point.y + offsetVector[1]
- };
- };
- _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- var align;
- var baseLine;
- if (offsetVector[0] > 0) {
- align = 'left';
- } else if (offsetVector[0] < 0) {
- align = 'right';
- } else {
- align = 'center';
- }
- if (offsetVector[1] > 0) {
- baseLine = 'top';
- } else if (offsetVector[1] < 0) {
- baseLine = 'bottom';
- } else {
- baseLine = 'middle';
- }
- return {
- textAlign: align,
- textBaseline: baseLine
- };
- };
- _proto.getContainer = function getContainer(isTop) {
- var frontContainer = this.frontContainer,
- backContainer = this.backContainer;
- return isTop ? frontContainer : backContainer;
- };
- return Abastract;
- }();
- module.exports = Abastract;
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var MatrixUtil = __webpack_require__(31);
- var Vector2 = __webpack_require__(13);
- var StyleUtil = __webpack_require__(179);
- function isUnchanged(m) {
- return m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
- }
- var ALIAS_ATTRS_MAP = {
- stroke: 'strokeStyle',
- fill: 'fillStyle',
- opacity: 'globalAlpha'
- };
- var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'shadow' // 兼容支付宝小程序
- ];
- var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
- var Element = /*#__PURE__*/function () {
- var _proto = Element.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false
- };
- };
- function Element(cfg) {
- this._initProperties();
- Util.mix(this._attrs, cfg);
- var attrs = this._attrs.attrs;
- if (attrs) {
- this.initAttrs(attrs);
- }
- this.initTransform();
- }
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- _proto.isGroup = function isGroup() {
- return this.get('isGroup');
- };
- _proto.isShape = function isShape() {
- return this.get('isShape');
- };
- _proto.initAttrs = function initAttrs(attrs) {
- this.attr(Util.mix(this.getDefaultAttrs(), attrs));
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {};
- };
- _proto._setAttr = function _setAttr(name, value) {
- var attrs = this._attrs.attrs;
- if (name === 'clip') {
- value = this._setAttrClip(value);
- } else {
- var alias = ALIAS_ATTRS_MAP[name];
- if (alias) {
- attrs[alias] = value;
- }
- }
- attrs[name] = value;
- };
- _proto._getAttr = function _getAttr(name) {
- return this._attrs.attrs[name];
- } // _afterAttrsSet() {}
- ;
- _proto._setAttrClip = function _setAttrClip(clip) {
- if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
- if (clip.get('canvas') === null) {
- clip = Object.assign({}, clip);
- }
- clip.set('parent', this.get('parent'));
- clip.set('context', this.get('context'));
- return clip;
- }
- return null;
- };
- _proto.attr = function attr(name, value) {
- var self = this;
- if (self.get('destroyed')) return null;
- var argumentsLen = arguments.length;
- if (argumentsLen === 0) {
- return self._attrs.attrs;
- }
- if (Util.isObject(name)) {
- this._attrs.bbox = null;
- for (var k in name) {
- self._setAttr(k, name[k]);
- }
- if (self._afterAttrsSet) {
- self._afterAttrsSet();
- }
- return self;
- }
- if (argumentsLen === 2) {
- this._attrs.bbox = null;
- self._setAttr(name, value);
- if (self._afterAttrsSet) {
- self._afterAttrsSet();
- }
- return self;
- }
- return self._getAttr(name);
- };
- _proto.getParent = function getParent() {
- return this.get('parent');
- };
- _proto.draw = function draw(context) {
- if (this.get('destroyed')) {
- return;
- }
- if (this.get('visible')) {
- this.setContext(context);
- this.drawInner(context);
- this.restoreContext(context);
- }
- };
- _proto.setContext = function setContext(context) {
- var clip = this._attrs.attrs.clip;
- context.save();
- if (clip) {
- clip.resetTransform(context);
- clip.createPath(context);
- context.clip();
- }
- this.resetContext(context);
- this.resetTransform(context);
- };
- _proto.restoreContext = function restoreContext(context) {
- context.restore();
- };
- _proto.resetContext = function resetContext(context) {
- var elAttrs = this._attrs.attrs;
- if (!this._attrs.isGroup) {
- for (var k in elAttrs) {
- if (SHAPE_ATTRS.indexOf(k) > -1) {
- var v = elAttrs[k];
- if (k === 'fillStyle' || k === 'strokeStyle') {
- v = StyleUtil.parseStyle(v, this, context);
- }
- if (k === 'lineDash' && context.setLineDash && Util.isArray(v)) {
- context.setLineDash(v);
- } else {
- context[k] = v;
- }
- }
- }
- }
- };
- _proto.hasFill = function hasFill() {
- return this.get('canFill') && this._attrs.attrs.fillStyle;
- };
- _proto.hasStroke = function hasStroke() {
- return this.get('canStroke') && this._attrs.attrs.strokeStyle;
- };
- _proto.drawInner = function drawInner()
- /* context */
- {};
- _proto.show = function show() {
- this.set('visible', true);
- return this;
- };
- _proto.hide = function hide() {
- this.set('visible', false);
- return this;
- };
- _proto.isVisible = function isVisible() {
- return this.get('visible');
- };
- _proto._removeFromParent = function _removeFromParent() {
- var parent = this.get('parent');
- if (parent) {
- var children = parent.get('children');
- Util.Array.remove(children, this);
- }
- return this;
- };
- _proto.remove = function remove(destroy) {
- if (destroy) {
- this.destroy();
- } else {
- this._removeFromParent();
- }
- };
- _proto.destroy = function destroy() {
- var destroyed = this.get('destroyed');
- if (destroyed) {
- return null;
- }
- this._removeFromParent();
- this._attrs = {};
- this.set('destroyed', true);
- };
- _proto.getBBox = function getBBox() {
- return {
- minX: 0,
- maxX: 0,
- minY: 0,
- maxY: 0,
- width: 0,
- height: 0
- };
- };
- _proto.initTransform = function initTransform() {
- var attrs = this._attrs.attrs || {};
- if (!attrs.matrix) {
- attrs.matrix = [1, 0, 0, 1, 0, 0];
- }
- this._attrs.attrs = attrs;
- };
- _proto.getMatrix = function getMatrix() {
- return this._attrs.attrs.matrix;
- };
- _proto.setMatrix = function setMatrix(m) {
- this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
- };
- _proto.transform = function transform(actions) {
- var matrix = this._attrs.attrs.matrix;
- this._attrs.attrs.matrix = MatrixUtil.transform(matrix, actions);
- return this;
- };
- _proto.setTransform = function setTransform(actions) {
- this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
- return this.transform(actions);
- };
- _proto.translate = function translate(x, y) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.translate(matrix, matrix, [x, y]);
- };
- _proto.rotate = function rotate(rad) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.rotate(matrix, matrix, rad);
- };
- _proto.scale = function scale(sx, sy) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.scale(matrix, matrix, [sx, sy]);
- };
- _proto.moveTo = function moveTo(x, y) {
- var cx = this._attrs.x || 0;
- var cy = this._attrs.y || 0;
- this.translate(x - cx, y - cy);
- this.set('x', x);
- this.set('y', y);
- };
- _proto.apply = function apply(v) {
- var m = this._attrs.attrs.matrix;
- Vector2.transformMat2d(v, v, m);
- return this;
- };
- _proto.resetTransform = function resetTransform(context) {
- var mo = this._attrs.attrs.matrix;
- if (!isUnchanged(mo)) {
- context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
- }
- };
- _proto.isDestroyed = function isDestroyed() {
- return this.get('destroyed');
- };
- return Element;
- }();
- module.exports = Element;
- /***/ }),
- /* 47 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- 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;
- var EVENT_AFTER_INIT = 'afterinit';
- exports.EVENT_AFTER_INIT = EVENT_AFTER_INIT;
- var EVENT_BEFORE_RENDER = 'beforerender';
- exports.EVENT_BEFORE_RENDER = EVENT_BEFORE_RENDER;
- var EVENT_AFTER_RENDER = 'afterrender';
- exports.EVENT_AFTER_RENDER = EVENT_AFTER_RENDER;
- var EVENT_BEFORE_DATA_CHANGE = 'beforedatachange';
- exports.EVENT_BEFORE_DATA_CHANGE = EVENT_BEFORE_DATA_CHANGE;
- var EVENT_AFTER_DATA_CHANGE = 'afterdatachange';
- exports.EVENT_AFTER_DATA_CHANGE = EVENT_AFTER_DATA_CHANGE;
- var EVENT_AFTER_SIZE_CHANGE = '_aftersizechange';
- exports.EVENT_AFTER_SIZE_CHANGE = EVENT_AFTER_SIZE_CHANGE;
- var EVENT_AFTER_GEOM_INIT = '_aftergeominit';
- exports.EVENT_AFTER_GEOM_INIT = EVENT_AFTER_GEOM_INIT;
- /***/ }),
- /* 48 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(27);
- var isString = function isString(str) {
- return isType(str, 'String');
- };
- module.exports = isString;
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
- var _typeof = __webpack_require__(50);
- function _getRequireWildcardCache() {
- if (typeof WeakMap !== "function") return null;
- var cache = new WeakMap();
- _getRequireWildcardCache = function _getRequireWildcardCache() {
- return cache;
- };
- return cache;
- }
- function _interopRequireWildcard(obj) {
- if (obj && obj.__esModule) {
- return obj;
- }
- if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
- return {
- "default": obj
- };
- }
- var cache = _getRequireWildcardCache();
- if (cache && cache.has(obj)) {
- return cache.get(obj);
- }
- var newObj = {};
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
- if (desc && (desc.get || desc.set)) {
- Object.defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- newObj["default"] = obj;
- if (cache) {
- cache.set(obj, newObj);
- }
- return newObj;
- }
- module.exports = _interopRequireWildcard;
- /***/ }),
- /* 50 */
- /***/ (function(module, exports) {
- function _typeof(obj) {
- "@babel/helpers - typeof";
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- module.exports = _typeof = function _typeof(obj) {
- return typeof obj;
- };
- } else {
- module.exports = _typeof = function _typeof(obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
- return _typeof(obj);
- }
- module.exports = _typeof;
- /***/ }),
- /* 51 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__keys__ = __webpack_require__(52);
- function isMatch(obj, attrs) {
- var _keys = Object(__WEBPACK_IMPORTED_MODULE_1__keys__["a" /* default */])(attrs);
- var length = _keys.length;
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(obj)) return !length;
- for (var i = 0; i < length; i += 1) {
- var key = _keys[i];
- if (attrs[key] !== obj[key] || !(key in obj)) {
- return false;
- }
- }
- return true;
- }
- /* harmony default export */ __webpack_exports__["a"] = (isMatch);
- /***/ }),
- /* 52 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
- var keys = Object.keys ? function (obj) {
- return Object.keys(obj);
- } : function (obj) {
- var result = [];
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(obj, function (value, key) {
- if (!(Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj) && key === 'prototype')) {
- result.push(key);
- }
- });
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (keys);
- /***/ }),
- /* 53 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- var splice = Array.prototype.splice;
- var pullAt = function pullAt(arr, indexes) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
- return [];
- }
- var length = arr ? indexes.length : 0;
- var last = length - 1;
- while (length--) {
- var previous = void 0;
- var index = indexes[length];
- if (length === last || index !== previous) {
- previous = index;
- splice.call(arr, index, 1);
- }
- }
- return arr;
- };
- /* harmony default export */ __webpack_exports__["a"] = (pullAt);
- /***/ }),
- /* 54 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each__ = __webpack_require__(8);
- var uniq = function (arr) {
- var resultArr = [];
- Object(__WEBPACK_IMPORTED_MODULE_1__each__["a" /* default */])(arr, function (item) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__contains__["a" /* default */])(resultArr, item)) {
- resultArr.push(item);
- }
- });
- return resultArr;
- };
- /* harmony default export */ __webpack_exports__["a"] = (uniq);
- /***/ }),
- /* 55 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__group_by__ = __webpack_require__(56);
- var groupToMap = function (data, condition) {
- if (!condition) {
- return {
- 0: data
- };
- }
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(condition)) {
- var paramsCondition_1 = Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(condition) ? condition : condition.replace(/\s+/g, '').split('*');
- condition = function (row) {
- var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
- for (var i = 0, l = paramsCondition_1.length; i < l; i++) {
- unique += row[paramsCondition_1[i]] && row[paramsCondition_1[i]].toString();
- }
- return unique;
- };
- }
- var groups = Object(__WEBPACK_IMPORTED_MODULE_2__group_by__["a" /* default */])(data, condition);
- return groups;
- };
- /* harmony default export */ __webpack_exports__["a"] = (groupToMap);
- /***/ }),
- /* 56 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function groupBy(data, condition) {
- if (!condition || !Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(data)) {
- return {};
- }
- var result = {}; // 兼容方法和 字符串的写法
- var predicate = Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(condition) ? condition : function (item) {
- return item[condition];
- };
- var key;
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(data, function (item) {
- key = predicate(item);
- if (hasOwnProperty.call(result, key)) {
- result[key].push(item);
- } else {
- result[key] = [item];
- }
- });
- return result;
- }
- /* harmony default export */ __webpack_exports__["a"] = (groupBy);
- /***/ }),
- /* 57 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (obj, key) {
- return obj.hasOwnProperty(key);
- });
- /***/ }),
- /* 58 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
- // @ts-ignore
- var values = Object.values ? function (obj) {
- return Object.values(obj);
- } : function (obj) {
- var result = [];
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(obj, function (value, key) {
- if (!(Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj) && key === 'prototype')) {
- result.push(value);
- }
- });
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (values);
- /***/ }),
- /* 59 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var toString = {}.toString;
- var getType = function (value) {
- return toString.call(value).replace(/^\[object /, '').replace(/]$/, '');
- };
- /* harmony default export */ __webpack_exports__["a"] = (getType);
- /***/ }),
- /* 60 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var objectProto = Object.prototype;
- var isPrototype = function (value) {
- var Ctor = value && value.constructor;
- var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
- return value === proto;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isPrototype);
- /***/ }),
- /* 61 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object_like__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_string__ = __webpack_require__(18);
- var isEqual = function (value, other) {
- if (value === other) {
- return true;
- }
- if (!value || !other) {
- return false;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_string__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_2__is_string__["a" /* default */])(other)) {
- return false;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(other)) {
- if (value.length !== other.length) {
- return false;
- }
- var rst = true;
- for (var i = 0; i < value.length; i++) {
- rst = isEqual(value[i], other[i]);
- if (!rst) {
- break;
- }
- }
- return rst;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_0__is_object_like__["a" /* default */])(other)) {
- var valueKeys = Object.keys(value);
- var otherKeys = Object.keys(other);
- if (valueKeys.length !== otherKeys.length) {
- return false;
- }
- var rst = true;
- for (var i = 0; i < valueKeys.length; i++) {
- rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]);
- if (!rst) {
- break;
- }
- }
- return rst;
- }
- return false;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isEqual);
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports.isCanvasElement = isCanvasElement;
- exports.getPixelRatio = getPixelRatio;
- exports.getStyle = getStyle;
- exports.getWidth = getWidth;
- exports.getHeight = getHeight;
- exports.getDomById = getDomById;
- exports.getRelativePosition = getRelativePosition;
- exports.addEventListener = addEventListener;
- exports.removeEventListener = removeEventListener;
- exports.createEvent = createEvent;
- exports.measureText = measureText;
- exports.isBrowser = exports.isNode = exports.isMy = exports.isWx = void 0;
- /**
- * Detects support for options object argument in addEventListener.
- * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
- * @private
- */
- var supportsEventListenerOptions = function () {
- var supports = false;
- try {
- var options = Object.defineProperty({}, 'passive', {
- get: function get() {
- supports = true;
- }
- });
- window.addEventListener('e', null, options);
- } catch (e) {// continue regardless of error
- }
- return supports;
- }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
- // https://github.com/chartjs/Chart.js/issues/4287
- var eventListenerOptions = supportsEventListenerOptions ? {
- passive: true
- } : false;
- /* global wx, my */
- // weixin miniprogram
- var isWx = typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function'; // ant miniprogram
- exports.isWx = isWx;
- var isMy = typeof my === 'object' && typeof my.getSystemInfoSync === 'function'; // in node
- exports.isMy = isMy;
- var isNode = typeof module !== 'undefined' && typeof module.exports !== 'undefined'; // in browser
- exports.isNode = isNode;
- var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined';
- exports.isBrowser = isBrowser;
- function isCanvasElement(el) {
- if (!el || typeof el !== 'object') return false;
- if (el.nodeType === 1 && el.nodeName) {
- // HTMLCanvasElement
- return true;
- } // CanvasElement
- return !!el.isCanvasElement;
- }
- function getPixelRatio() {
- return window && window.devicePixelRatio || 1;
- }
- function getStyle(el, property) {
- return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
- }
- function getWidth(el) {
- var width = getStyle(el, 'width');
- if (width === 'auto') {
- width = el.offsetWidth;
- }
- return parseFloat(width);
- }
- function getHeight(el) {
- var height = getStyle(el, 'height');
- if (height === 'auto') {
- height = el.offsetHeight;
- }
- return parseFloat(height);
- }
- function getDomById(id) {
- if (!id) {
- return null;
- }
- return document.getElementById(id);
- }
- function getRelativePosition(point, canvas) {
- var canvasDom = canvas.get('el');
- if (!canvasDom) return point;
- var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
- top = _canvasDom$getBoundin.top,
- right = _canvasDom$getBoundin.right,
- bottom = _canvasDom$getBoundin.bottom,
- left = _canvasDom$getBoundin.left;
- var paddingLeft = parseFloat(getStyle(canvasDom, 'padding-left'));
- var paddingTop = parseFloat(getStyle(canvasDom, 'padding-top'));
- var paddingRight = parseFloat(getStyle(canvasDom, 'padding-right'));
- var paddingBottom = parseFloat(getStyle(canvasDom, 'padding-bottom'));
- var width = right - left - paddingLeft - paddingRight;
- var height = bottom - top - paddingTop - paddingBottom;
- var pixelRatio = canvas.get('pixelRatio');
- var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
- var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
- return {
- x: mouseX,
- y: mouseY
- };
- }
- function addEventListener(source, type, listener) {
- source.addEventListener(type, listener, eventListenerOptions);
- }
- function removeEventListener(source, type, listener) {
- source.removeEventListener(type, listener, eventListenerOptions);
- }
- function createEventObj(type, chart, x, y, nativeEvent) {
- return {
- type: type,
- chart: chart,
- "native": nativeEvent || null,
- x: x !== undefined ? x : null,
- y: y !== undefined ? y : null
- };
- }
- function createEvent(event, chart) {
- var type = event.type;
- var clientPoint; // 说明是touch相关事件
- if (event.touches) {
- // https://developer.mozilla.org/zh-CN/docs/Web/API/TouchEvent/changedTouches
- // 这里直接拿changedTouches就可以了,不管是touchstart, touchmove, touchend changedTouches 都是有的
- // 为了以防万一,做个空判断
- var touch = event.changedTouches[0] || {}; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
- var x = touch.x,
- y = touch.y,
- clientX = touch.clientX,
- clientY = touch.clientY; // 小程序环境会有x,y,这里就直接返回
- if (x && y) {
- return createEventObj(type, chart, x, y, event);
- }
- clientPoint = {
- x: clientX,
- y: clientY
- };
- } else {
- // mouse相关事件
- clientPoint = {
- x: event.clientX,
- y: event.clientY
- };
- } // 理论上应该是只有有在浏览器环境才会走到这里
- var canvas = chart.get('canvas'); // 通过clientX, clientY 计算x, y
- var point = getRelativePosition(clientPoint, canvas);
- return createEventObj(type, chart, point.x, point.y, event);
- }
- function measureText(text, font, ctx) {
- if (!ctx) {
- ctx = document.createElement('canvas').getContext('2d');
- }
- ctx.font = font || '12px sans-serif';
- return ctx.measureText(text);
- }
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _emit = _interopRequireDefault(__webpack_require__(42));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Base = /*#__PURE__*/function (_Emit) {
- (0, _inheritsLoose2["default"])(Base, _Emit);
- var _super = _createSuper(Base);
- var _proto = Base.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {};
- };
- function Base(cfg) {
- var _this;
- _this = _Emit.call(this) || this;
- var attrs = {};
- var defaultCfg = _this.getDefaultCfg();
- _this._attrs = attrs;
- Util.mix(attrs, defaultCfg, cfg);
- return _this;
- }
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- _proto.destroy = function destroy() {
- this._attrs = {};
- this.destroyed = true;
- };
- return Base;
- }(_emit["default"]);
- module.exports = Base;
- /***/ }),
- /* 64 */
- /***/ (function(module, exports) {
- function _mix(dist, obj) {
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
- dist[key] = obj[key];
- }
- }
- }
- var mix = function mix(dist, src1, src2, src3) {
- if (src1) _mix(dist, src1);
- if (src2) _mix(dist, src2);
- if (src3) _mix(dist, src3);
- return dist;
- };
- module.exports = mix;
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 计算分类的的坐标点
- * @author dxq613@gmail.com
- */
- var each = __webpack_require__(15);
- var MAX_COUNT = 8;
- var SUB_COUNT = 4; // 控制个数不能过小
- function getSimpleArray(data) {
- var arr = [];
- each(data, function (sub) {
- arr = arr.concat(sub);
- });
- return arr;
- }
- function getGreatestFactor(count, number) {
- var i;
- for (i = number; i > 0; i--) {
- if (count % i === 0) {
- break;
- }
- } // 如果是素数,没有可以整除的数字
- if (i === 1) {
- for (i = number; i > 0; i--) {
- if ((count - 1) % i === 0) {
- break;
- }
- }
- }
- return i;
- }
- module.exports = function (info) {
- var rst = {};
- var ticks = [];
- var isRounding = info.isRounding;
- var categories = getSimpleArray(info.data);
- var length = categories.length;
- var maxCount = info.maxCount || MAX_COUNT;
- var tickCount;
- if (isRounding) {
- // 取整操作
- tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
- if (tickCount === 2) {
- tickCount = maxCount;
- } else if (tickCount < maxCount - SUB_COUNT) {
- tickCount = maxCount - SUB_COUNT;
- }
- } else {
- tickCount = maxCount;
- }
- if (!isRounding && length <= tickCount + tickCount / 2) {
- ticks = [].concat(categories);
- } else {
- var step = parseInt(length / (tickCount - 1), 10);
- var groups = categories.map(function (e, i) {
- return i % step === 0 ? categories.slice(i, i + step) : null;
- }).filter(function (e) {
- return e;
- });
- for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
- ticks.push(groups[i][0]);
- }
- if (categories.length) {
- ticks.unshift(categories[0]);
- var last = categories[length - 1];
- if (ticks.indexOf(last) === -1) {
- ticks.push(last);
- }
- }
- }
- rst.categories = categories;
- rst.ticks = ticks;
- return rst;
- };
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(10);
- var SHAPE_MAP = {};
- var INDEX = '_INDEX';
- function getComparer(compare) {
- return function (left, right) {
- var result = compare(left, right);
- return result === 0 ? left[INDEX] - right[INDEX] : result;
- };
- }
- module.exports = {
- getGroupClass: function getGroupClass() {},
- getChildren: function getChildren() {
- return this.get('children');
- },
- addShape: function addShape(type, cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var canvas = this.get('canvas');
- var shapeType = SHAPE_MAP[type];
- if (!shapeType) {
- shapeType = Util.upperFirst(type);
- SHAPE_MAP[type] = shapeType;
- }
- cfg.canvas = canvas;
- if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
- cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
- }
- var shape = new Shape[shapeType](cfg);
- this.add(shape);
- return shape;
- },
- addGroup: function addGroup(cfg) {
- var canvas = this.get('canvas');
- var groupClass = this.getGroupClass();
- cfg = Util.mix({}, cfg);
- cfg.canvas = canvas;
- cfg.parent = this;
- var rst = new groupClass(cfg);
- this.add(rst);
- return rst;
- },
- contain: function contain(item) {
- var children = this.get('children');
- return children.indexOf(item) > -1;
- },
- sort: function sort() {
- var children = this.get('children');
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child[INDEX] = i;
- }
- children.sort(getComparer(function (obj1, obj2) {
- return obj1.get('zIndex') - obj2.get('zIndex');
- }));
- return this;
- },
- clear: function clear() {
- var children = this.get('children');
- while (children.length !== 0) {
- children[children.length - 1].remove(true);
- }
- return this;
- },
- add: function add(items) {
- var self = this;
- var children = self.get('children');
- if (!Util.isArray(items)) {
- items = [items];
- }
- for (var i = 0, len = items.length; i < len; i++) {
- var item = items[i];
- var parent = item.get('parent');
- if (parent) {
- var descendants = parent.get('children');
- Util.Array.remove(descendants, item);
- }
- self._setEvn(item);
- children.push(item);
- }
- return self;
- },
- _setEvn: function _setEvn(item) {
- var self = this;
- item._attrs.parent = self;
- item._attrs.context = self._attrs.context;
- item._attrs.canvas = self._attrs.canvas;
- var clip = item._attrs.attrs.clip;
- if (clip) {
- clip.set('parent', self);
- clip.set('context', self.get('context'));
- }
- if (item._attrs.isGroup) {
- var children = item._attrs.children;
- for (var i = 0, len = children.length; i < len; i++) {
- item._setEvn(children[i]);
- }
- }
- }
- };
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(46);
- var Container = __webpack_require__(66);
- var Vector2 = __webpack_require__(13);
- var Group = /*#__PURE__*/function (_Element) {
- (0, _inheritsLoose2["default"])(Group, _Element);
- var _super = _createSuper(Group);
- function Group() {
- return _Element.apply(this, arguments) || this;
- }
- var _proto = Group.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false,
- isGroup: true,
- children: []
- };
- };
- _proto.drawInner = function drawInner(context) {
- var children = this.get('children');
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child.draw(context);
- }
- return this;
- };
- _proto.getBBox = function getBBox() {
- var self = this;
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- var children = self.get('children');
- for (var i = 0, length = children.length; i < length; i++) {
- var child = children[i];
- if (child.get('visible')) {
- var box = child.getBBox();
- if (!box) {
- continue;
- }
- var leftTop = [box.minX, box.minY];
- var leftBottom = [box.minX, box.maxY];
- var rightTop = [box.maxX, box.minY];
- var rightBottom = [box.maxX, box.maxY];
- var matrix = child.attr('matrix');
- Vector2.transformMat2d(leftTop, leftTop, matrix);
- Vector2.transformMat2d(leftBottom, leftBottom, matrix);
- Vector2.transformMat2d(rightTop, rightTop, matrix);
- Vector2.transformMat2d(rightBottom, rightBottom, matrix);
- minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
- maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
- minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
- maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
- }
- }
- return {
- minX: minX,
- minY: minY,
- maxX: maxX,
- maxY: maxY,
- x: minX,
- y: minY,
- width: maxX - minX,
- height: maxY - minY
- };
- };
- _proto.destroy = function destroy() {
- if (this.get('destroyed')) {
- return;
- }
- this.clear();
- _Element.prototype.destroy.call(this);
- };
- return Group;
- }(Element);
- Util.mix(Group.prototype, Container, {
- getGroupClass: function getGroupClass() {
- return Group;
- }
- });
- module.exports = Group;
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(19);
- var ShapeUtil = __webpack_require__(38);
- var Global = __webpack_require__(6); // register line geom
- var Line = Shape.registerFactory('line', {
- defaultShapeType: 'line'
- });
- function getStyle(cfg) {
- var style = {
- strokeStyle: cfg.color
- };
- if (cfg.size >= 0) {
- style.lineWidth = cfg.size;
- }
- Util.mix(style, cfg.style);
- return Util.mix({}, Global.shape.line, style);
- }
- function drawLines(cfg, container, style, smooth) {
- var points = cfg.points;
- if (points.length && Util.isArray(points[0].y)) {
- var topPoints = [];
- var bottomPoints = [];
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- var tmp = ShapeUtil.splitPoints(point);
- bottomPoints.push(tmp[0]);
- topPoints.push(tmp[1]);
- }
- if (cfg.isInCircle) {
- topPoints.push(topPoints[0]);
- bottomPoints.push(bottomPoints[0]);
- }
- if (cfg.isStack) {
- return container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: topPoints,
- smooth: smooth
- }, style)
- });
- }
- var topShape = container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: topPoints,
- smooth: smooth
- }, style)
- });
- var bottomShape = container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: bottomPoints,
- smooth: smooth
- }, style)
- });
- return [topShape, bottomShape];
- }
- if (cfg.isInCircle) {
- points.push(points[0]);
- }
- return container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: points,
- smooth: smooth
- }, style)
- });
- }
- var SHAPES = ['line', 'smooth', 'dash'];
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('line', shapeType, {
- draw: function draw(cfg, container) {
- var smooth = shapeType === 'smooth';
- var style = getStyle(cfg);
- if (shapeType === 'dash') {
- style.lineDash = Global.lineDash;
- }
- return drawLines(cfg, container, style, smooth);
- }
- });
- });
- module.exports = Line;
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(26);
- var catAuto = __webpack_require__(65);
- var each = __webpack_require__(15);
- var isNumber = __webpack_require__(36);
- var isString = __webpack_require__(48);
- var Category = /*#__PURE__*/function (_Base) {
- _inheritsLoose(Category, _Base);
- function Category() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Category.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- this.type = 'cat';
- /**
- * 是否分类度量
- * @type {Boolean}
- */
- this.isCategory = true;
- this.isRounding = true; // 是否进行取整操作
- }
- /**
- * @override
- */
- ;
- _proto.init = function init() {
- var self = this;
- var values = self.values;
- var tickCount = self.tickCount;
- each(values, function (v, i) {
- values[i] = v.toString();
- });
- if (!self.ticks) {
- var ticks = values;
- if (tickCount) {
- var temp = catAuto({
- maxCount: tickCount,
- data: values,
- isRounding: self.isRounding
- });
- ticks = temp.ticks;
- }
- this.ticks = ticks;
- }
- }
- /**
- * @override
- */
- ;
- _proto.getText = function getText(value) {
- if (this.values.indexOf(value) === -1 && isNumber(value)) {
- value = this.values[Math.round(value)];
- }
- return _Base.prototype.getText.call(this, value);
- }
- /**
- * @override
- */
- ;
- _proto.translate = function translate(value) {
- var index = this.values.indexOf(value);
- if (index === -1 && isNumber(value)) {
- index = value;
- } else if (index === -1) {
- index = NaN;
- }
- return index;
- }
- /**
- * @override
- */
- ;
- _proto.scale = function scale(value) {
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- var percent;
- if (isString(value) || this.values.indexOf(value) !== -1) {
- value = this.translate(value);
- }
- if (this.values.length > 1) {
- percent = value / (this.values.length - 1);
- } else {
- percent = value;
- }
- return rangeMin + percent * (rangeMax - rangeMin);
- }
- /**
- * @override
- */
- ;
- _proto.invert = function invert(value) {
- if (isString(value)) {
- // 如果已经是字符串
- return value;
- }
- var min = this.rangeMin();
- var max = this.rangeMax(); // 归一到 范围内
- if (value < min) {
- value = min;
- }
- if (value > max) {
- value = max;
- }
- var percent = (value - min) / (max - min);
- var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
- index = index || 0;
- return this.values[index];
- };
- return Category;
- }(Base);
- Base.Cat = Category;
- module.exports = Category;
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = {
- requestAnimationFrame: typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
- return setTimeout(fn, 16);
- }
- };
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @fileOverview convert the line to curve
- * @author dxq613@gmail.com
- */
- var Vector2 = __webpack_require__(13);
- function getPoint(v) {
- return [v.x, v.y];
- }
- function smoothBezier(points, smooth, isLoop, constraint) {
- var cps = [];
- var prevPoint;
- var nextPoint;
- var hasConstraint = !!constraint;
- var min;
- var max;
- var point;
- var len;
- var l;
- var i;
- if (hasConstraint) {
- min = [Infinity, Infinity];
- max = [-Infinity, -Infinity];
- for (i = 0, l = points.length; i < l; i++) {
- point = getPoint(points[i]);
- Vector2.min(min, min, point);
- Vector2.max(max, max, point);
- }
- Vector2.min(min, min, constraint[0]);
- Vector2.max(max, max, constraint[1]);
- }
- for (i = 0, len = points.length; i < len; i++) {
- point = getPoint(points[i]);
- if (isLoop) {
- prevPoint = getPoint(points[i ? i - 1 : len - 1]);
- nextPoint = getPoint(points[(i + 1) % len]);
- } else {
- if (i === 0 || i === len - 1) {
- cps.push([point[0], point[1]]);
- continue;
- } else {
- prevPoint = getPoint(points[i - 1]);
- nextPoint = getPoint(points[i + 1]);
- }
- }
- var v = Vector2.sub([], nextPoint, prevPoint);
- Vector2.scale(v, v, smooth);
- var d0 = Vector2.distance(point, prevPoint);
- var d1 = Vector2.distance(point, nextPoint);
- var sum = d0 + d1;
- if (sum !== 0) {
- d0 /= sum;
- d1 /= sum;
- }
- var v1 = Vector2.scale([], v, -d0);
- var v2 = Vector2.scale([], v, d1);
- var cp0 = Vector2.add([], point, v1);
- var cp1 = Vector2.add([], point, v2);
- if (hasConstraint) {
- Vector2.max(cp0, cp0, min);
- Vector2.min(cp0, cp0, max);
- Vector2.max(cp1, cp1, min);
- Vector2.min(cp1, cp1, max);
- }
- cps.push([cp0[0], cp0[1]]);
- cps.push([cp1[0], cp1[1]]);
- }
- if (isLoop) {
- cps.push(cps.shift());
- }
- return cps;
- }
- function catmullRom2bezier(pointList, z, constraint) {
- var isLoop = !!z;
- var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
- var len = pointList.length;
- var d1 = [];
- var cp1;
- var cp2;
- var p;
- for (var i = 0; i < len - 1; i++) {
- cp1 = controlPointList[i * 2];
- cp2 = controlPointList[i * 2 + 1];
- p = pointList[i + 1];
- d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
- }
- if (isLoop) {
- cp1 = controlPointList[len];
- cp2 = controlPointList[len + 1];
- p = pointList[0];
- d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
- }
- return d1;
- }
- module.exports = {
- smooth: catmullRom2bezier
- };
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Geom = __webpack_require__(17);
- var ShapeUtil = __webpack_require__(38);
- var Util = __webpack_require__(0);
- __webpack_require__(68);
- var Path = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Path, _Geom);
- var _super = _createSuper(Path);
- function Path() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Path.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'path';
- cfg.shapeType = 'line';
- return cfg;
- };
- _proto.getDrawCfg = function getDrawCfg(obj) {
- var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
- cfg.isStack = this.hasAdjust('stack');
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var yScale = self.getYScale();
- var connectNulls = self.get('connectNulls');
- var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
- var cfg = this.getDrawCfg(data[0]);
- cfg.origin = data;
- Util.each(splitArray, function (subData, splitedIndex) {
- cfg.splitedIndex = splitedIndex;
- cfg.points = subData;
- self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
- });
- };
- return Path;
- }(Geom);
- Geom.Path = Path;
- module.exports = Path;
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _const = __webpack_require__(47);
- /**
- * @fileOverview Utility for calculate the with ratui in x axis
- * @author sima.zhang1990@gmail.com
- * @author dxq613@gmail.com
- */
- var Global = __webpack_require__(6);
- var Util = __webpack_require__(0);
- var SizeMixin = {
- initEvent: function initEvent() {
- var _this = this;
- var chart = this.get('chart');
- if (!chart) {
- return;
- }
- chart.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
- _this.set('_width', null);
- });
- },
- getDefalutSize: function getDefalutSize() {
- var defaultSize = this.get('defaultSize');
- if (!defaultSize) {
- var coord = this.get('coord');
- var xScale = this.getXScale();
- var dataArray = this.get('dataArray');
- var values = Util.uniq(xScale.values);
- var count = values.length;
- var range = xScale.range;
- var normalizeSize = 1 / count;
- var widthRatio = 1;
- if (coord && coord.isPolar) {
- if (coord.transposed && count > 1) {
- widthRatio = Global.widthRatio.multiplePie;
- } else {
- widthRatio = Global.widthRatio.rose;
- }
- } else {
- if (xScale.isLinear) {
- normalizeSize *= range[1] - range[0];
- }
- widthRatio = Global.widthRatio.column;
- }
- normalizeSize *= widthRatio;
- if (this.hasAdjust('dodge')) {
- normalizeSize = normalizeSize / dataArray.length;
- }
- defaultSize = normalizeSize;
- this.set('defaultSize', defaultSize);
- }
- return defaultSize;
- },
- getDimWidth: function getDimWidth(dimName) {
- var coord = this.get('coord');
- var start = coord.convertPoint({
- x: 0,
- y: 0
- });
- var end = coord.convertPoint({
- x: dimName === 'x' ? 1 : 0,
- y: dimName === 'x' ? 0 : 1
- });
- var width = 0;
- if (start && end) {
- width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
- }
- return width;
- },
- _getWidth: function _getWidth() {
- var width = this.get('_width');
- if (!width) {
- var coord = this.get('coord');
- if (coord && coord.isPolar && !coord.transposed) {
- width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
- } else {
- width = this.getDimWidth('x');
- }
- this.set('_width', width);
- }
- return width;
- },
- _toNormalizedSize: function _toNormalizedSize(size) {
- var width = this._getWidth();
- return size / width;
- },
- _toCoordSize: function _toCoordSize(normalizeSize) {
- var width = this._getWidth();
- return width * normalizeSize;
- },
- getNormalizedSize: function getNormalizedSize(obj) {
- var size = this.getAttrValue('size', obj);
- if (Util.isNil(size)) {
- size = this.getDefalutSize();
- } else {
- size = this._toNormalizedSize(size);
- }
- return size;
- },
- getSize: function getSize(obj) {
- var size = this.getAttrValue('size', obj);
- if (Util.isNil(size)) {
- var normalizeSize = this.getDefalutSize();
- size = this._toCoordSize(normalizeSize);
- }
- return size;
- }
- };
- module.exports = SizeMixin;
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- __webpack_require__(241);
- /**
- * The parent class of interaction
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var Hammer;
- if (!Util.isWx && !Util.isMy) {
- Hammer = __webpack_require__(259);
- }
- var TOUCH_EVENTS = ['touchstart', 'touchmove', 'touchend'];
- var Interaction = /*#__PURE__*/function () {
- var _proto = Interaction.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- startEvent: TOUCH_EVENTS[0],
- processEvent: TOUCH_EVENTS[1],
- endEvent: TOUCH_EVENTS[2],
- resetEvent: null
- };
- };
- // override
- _proto.start = function start() {} // override
- ;
- _proto.process = function process() {} // override
- ;
- _proto.end = function end() {} // override
- ;
- _proto.reset = function reset() {};
- function Interaction(cfg, chart) {
- var _this = this;
- this._start = function (ev) {
- _this.preStart && _this.preStart(ev);
- _this.start(ev);
- _this.onStart && _this.onStart(ev);
- };
- this._process = function (ev) {
- _this.preProcess && _this.preProcess(ev);
- _this.process(ev);
- _this.onProcess && _this.onProcess(ev);
- };
- this._end = function (ev) {
- _this.preEnd && _this.preEnd(ev);
- _this.end(ev);
- _this.onEnd && _this.onEnd(ev);
- };
- this._reset = function (ev) {
- _this.preReset && _this.preReset(ev);
- _this.reset(ev);
- _this.onReset && _this.onReset(ev);
- };
- var defaultCfg = this.getDefaultCfg();
- Util.deepMix(this, defaultCfg, cfg);
- this.chart = chart;
- this.canvas = chart.get('canvas');
- this.el = chart.get('canvas').get('el');
- this._bindEvents();
- }
- _proto._bindEvents = function _bindEvents() {
- this._clearEvents(); // clear events
- var startEvent = this.startEvent,
- processEvent = this.processEvent,
- endEvent = this.endEvent,
- resetEvent = this.resetEvent,
- el = this.el;
- if (Hammer) {
- this.hammer = new Hammer(el);
- }
- this._bindEvent(startEvent, this._start);
- this._bindEvent(processEvent, this._process);
- this._bindEvent(endEvent, this._end);
- this._bindEvent(resetEvent, this._reset);
- };
- _proto._clearEvents = function _clearEvents() {
- var startEvent = this.startEvent,
- processEvent = this.processEvent,
- endEvent = this.endEvent,
- resetEvent = this.resetEvent;
- if (this.hammer) {
- this.hammer.destroy();
- this.hammer = null;
- }
- this._clearTouchEvent(startEvent, this._start);
- this._clearTouchEvent(processEvent, this._process);
- this._clearTouchEvent(endEvent, this._end);
- this._clearTouchEvent(resetEvent, this._reset);
- };
- _proto._bindEvent = function _bindEvent(eventName, method) {
- var el = this.el;
- if (eventName) {
- if (TOUCH_EVENTS.indexOf(eventName) !== -1) {
- Util.addEventListener(el, eventName, method);
- } else if (this.hammer) {
- this.hammer.on(eventName, method);
- }
- }
- };
- _proto._clearTouchEvent = function _clearTouchEvent(eventName, method) {
- var el = this.el;
- if (eventName && TOUCH_EVENTS.indexOf(eventName) !== -1) {
- Util.removeEventListener(el, eventName, method);
- }
- };
- _proto.destroy = function destroy() {
- this._clearEvents();
- };
- return Interaction;
- }();
- module.exports = Interaction;
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports.merge = merge;
- exports.values = values;
- exports.firstValue = firstValue;
- exports.group = group;
- exports.groupToMap = groupToMap;
- exports.remove = remove;
- exports.getRange = getRange;
- var _util = __webpack_require__(20);
- function merge(dataArray) {
- var rst = [];
- for (var i = 0, len = dataArray.length; i < len; i++) {
- rst = rst.concat(dataArray[i]);
- }
- return rst;
- }
- function values(data, name) {
- var rst = [];
- var tmpMap = {};
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!(0, _util.isNil)(value)) {
- if (!(0, _util.isArray)(value)) {
- if (!tmpMap[value]) {
- rst.push(value);
- tmpMap[value] = true;
- }
- } else {
- (0, _util.each)(value, function (val) {
- if (!tmpMap[val]) {
- rst.push(val);
- tmpMap[val] = true;
- }
- });
- }
- }
- }
- return rst;
- }
- function firstValue(data, name) {
- var rst = null;
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!(0, _util.isNil)(value)) {
- if ((0, _util.isArray)(value)) {
- rst = value[0];
- } else {
- rst = value;
- }
- break;
- }
- }
- return rst;
- }
- function groupToMap(data, fields) {
- if (!fields) {
- return {
- 0: data
- };
- }
- var callback = function callback(row) {
- var unique = '_';
- for (var i = 0, l = fields.length; i < l; i++) {
- unique += row[fields[i]] && row[fields[i]].toString();
- }
- return unique;
- };
- var groups = {};
- for (var i = 0, len = data.length; i < len; i++) {
- var row = data[i];
- var key = callback(row);
- if (groups[key]) {
- groups[key].push(row);
- } else {
- groups[key] = [row];
- }
- }
- return groups;
- }
- function group(data, fields, appendConditions) {
- if (appendConditions === void 0) {
- appendConditions = {};
- }
- if (!fields) {
- return [data];
- }
- var groups = groupToMap(data, fields);
- var array = [];
- if (fields.length === 1 && appendConditions[fields[0]]) {
- var _values = appendConditions[fields[0]];
- (0, _util.each)(_values, function (value) {
- value = '_' + value;
- array.push(groups[value]);
- });
- } else {
- for (var i in groups) {
- array.push(groups[i]);
- }
- }
- return array;
- }
- function remove(arr, obj) {
- if (!arr) {
- return;
- }
- var index = arr.indexOf(obj);
- if (index !== -1) {
- arr.splice(index, 1);
- }
- }
- function getRange(values) {
- if (!values.length) {
- return {
- min: 0,
- max: 0
- };
- }
- var max = Math.max.apply(null, values);
- var min = Math.min.apply(null, values);
- return {
- min: min,
- max: max
- };
- }
- /***/ }),
- /* 76 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- /**
- * marker shapes,used for tooltip and legend
- */
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(16),
- Shape = _require.Shape;
- var SYMBOLS = {
- circle: function circle(x, y, r, ctx) {
- ctx.arc(x, y, r, 0, Math.PI * 2, false);
- },
- square: function square(x, y, r, ctx) {
- ctx.moveTo(x - r, y - r);
- ctx.lineTo(x + r, y - r);
- ctx.lineTo(x + r, y + r);
- ctx.lineTo(x - r, y + r);
- ctx.closePath();
- }
- };
- var Marker = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Marker, _Shape);
- var _super = _createSuper(Marker);
- function Marker() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Marker.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'marker';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- radius = attrs.radius;
- var symbol = attrs.symbol || 'circle';
- var method;
- if (Util.isFunction(symbol)) {
- method = symbol;
- } else {
- method = SYMBOLS[symbol];
- }
- context.beginPath();
- method(x, y, radius, context, this);
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- radius = attrs.radius;
- return {
- minX: x - radius,
- minY: y - radius,
- maxX: x + radius,
- maxY: y + radius
- };
- };
- return Marker;
- }(Shape);
- module.exports = Marker;
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Core = {};
- var Global = __webpack_require__(6);
- Core.Global = Global;
- Core.version = Global.version;
- Core.Chart = __webpack_require__(30);
- Core.Shape = __webpack_require__(19);
- Core.G = __webpack_require__(16);
- Core.Util = __webpack_require__(0);
- Core.Helper = __webpack_require__(37); // Core.track = function(enable) {
- // Global.trackable = enable;
- // };
- // require('./track');
- // 2018-12-27 关闭打点
- Core.track = function () {
- return null;
- };
- module.exports = Core;
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @fileOverview default theme
- * @author dxq613@gail.com
- */
- var Util = __webpack_require__(0);
- var color1 = '#E8E8E8'; // color of axis-line and axis-grid
- var color2 = '#808080'; // color of axis label
- var defaultAxis = {
- label: {
- fill: color2,
- fontSize: 10
- },
- line: {
- stroke: color1,
- lineWidth: 1
- },
- grid: {
- type: 'line',
- stroke: color1,
- lineWidth: 1,
- lineDash: [2]
- },
- tickLine: null,
- labelOffset: 7.5
- };
- var Theme = {
- fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
- defaultColor: '#1890FF',
- pixelRatio: 1,
- padding: 'auto',
- appendPadding: 15,
- colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
- shapes: {
- line: ['line', 'dash'],
- point: ['circle', 'hollowCircle']
- },
- sizes: [4, 10],
- axis: {
- common: defaultAxis,
- // common axis configuration
- bottom: Util.mix({}, defaultAxis, {
- grid: null
- }),
- left: Util.mix({}, defaultAxis, {
- line: null
- }),
- right: Util.mix({}, defaultAxis, {
- line: null
- }),
- circle: Util.mix({}, defaultAxis, {
- line: null
- }),
- radius: Util.mix({}, defaultAxis, {
- labelOffset: 4
- })
- },
- shape: {
- line: {
- lineWidth: 2,
- lineJoin: 'round',
- lineCap: 'round'
- },
- point: {
- lineWidth: 0,
- size: 3
- },
- area: {
- fillOpacity: 0.1
- }
- },
- _defaultAxis: defaultAxis
- };
- module.exports = Theme;
- /***/ }),
- /* 79 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__filter__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__contains__ = __webpack_require__(28);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to inspect.
- * @param {Array} values The values to exclude.
- * @return {Array} Returns the new array of filtered values.
- * @example
- * difference([2, 1], [2, 3]); // => [1]
- */
- var difference = function (arr, values) {
- if (values === void 0) {
- values = [];
- }
- return Object(__WEBPACK_IMPORTED_MODULE_0__filter__["a" /* default */])(arr, function (value) {
- return !Object(__WEBPACK_IMPORTED_MODULE_1__contains__["a" /* default */])(values, value);
- });
- };
- /* harmony default export */ __webpack_exports__["a"] = (difference);
- /***/ }),
- /* 80 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_match__ = __webpack_require__(51);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__is_plain_object__ = __webpack_require__(24);
- function find(arr, predicate) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_2__is_array__["a" /* default */])(arr)) return null;
- var _predicate;
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(predicate)) {
- _predicate = predicate;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_3__is_plain_object__["a" /* default */])(predicate)) {
- _predicate = function (a) {
- return Object(__WEBPACK_IMPORTED_MODULE_1__is_match__["a" /* default */])(a, predicate);
- };
- }
- if (_predicate) {
- for (var i = 0; i < arr.length; i += 1) {
- if (_predicate(arr[i])) {
- return arr[i];
- }
- }
- }
- return null;
- }
- /* harmony default export */ __webpack_exports__["a"] = (find);
- /***/ }),
- /* 81 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function findIndex(arr, predicate, fromIndex) {
- if (fromIndex === void 0) {
- fromIndex = 0;
- }
- for (var i = fromIndex; i < arr.length; i++) {
- if (predicate(arr[i], i)) {
- // 找到终止循环
- return i;
- }
- }
- return -1;
- }
- /* harmony default export */ __webpack_exports__["a"] = (findIndex);
- /***/ }),
- /* 82 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- var firstValue = function (data, name) {
- var rst = null;
- for (var i = 0; i < data.length; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) {
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(value)) {
- rst = value[0]; // todo 这里是否应该使用递归,调用 firstValue @绝云
- } else {
- rst = value;
- }
- break;
- }
- }
- return rst;
- };
- /* harmony default export */ __webpack_exports__["a"] = (firstValue);
- /***/ }),
- /* 83 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to flatten.
- * @return {Array} Returns the new flattened array.
- * @example
- *
- * flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
- */
- var flatten = function (arr) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr)) {
- return [];
- }
- var rst = [];
- for (var i = 0; i < arr.length; i++) {
- rst = rst.concat(arr[i]);
- }
- return rst;
- };
- /* harmony default export */ __webpack_exports__["a"] = (flatten);
- /***/ }),
- /* 84 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /**
- * Flattens `array` a single level deep.
- *
- * @param {Array} arr The array to flatten.
- * @param {Array} result The array to return.
- * @return {Array} Returns the new flattened array.
- * @example
- *
- * flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
- */
- var flattenDeep = function (arr, result) {
- if (result === void 0) {
- result = [];
- }
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(arr)) {
- result.push(arr);
- } else {
- for (var i = 0; i < arr.length; i += 1) {
- flattenDeep(arr[i], result);
- }
- }
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (flattenDeep);
- /***/ }),
- /* 85 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__filter__ = __webpack_require__(39);
- var getRange = function (values) {
- // 存在 NaN 时,min,max 判定会出问题
- values = Object(__WEBPACK_IMPORTED_MODULE_1__filter__["a" /* default */])(values, function (v) {
- return !isNaN(v);
- });
- if (!values.length) {
- // 如果没有数值则直接返回0
- return {
- min: 0,
- max: 0
- };
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(values[0])) {
- var tmp = [];
- for (var i = 0; i < values.length; i++) {
- tmp = tmp.concat(values[i]);
- }
- values = tmp;
- }
- var max = Math.max.apply(null, values);
- var min = Math.min.apply(null, values);
- return {
- min: min,
- max: max
- };
- };
- /* harmony default export */ __webpack_exports__["a"] = (getRange);
- /***/ }),
- /* 86 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var arrPrototype = Array.prototype;
- var splice = arrPrototype.splice;
- var indexOf = arrPrototype.indexOf;
- var pull = function (arr) {
- var values = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- values[_i - 1] = arguments[_i];
- }
- for (var i = 0; i < values.length; i++) {
- var value = values[i];
- var fromIndex = -1;
- while ((fromIndex = indexOf.call(arr, value)) > -1) {
- splice.call(arr, fromIndex, 1);
- }
- }
- return arr;
- };
- /* harmony default export */ __webpack_exports__["a"] = (pull);
- /***/ }),
- /* 87 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_plain_object__ = __webpack_require__(24);
- var reduce = function (arr, fn, init) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr) && !Object(__WEBPACK_IMPORTED_MODULE_2__is_plain_object__["a" /* default */])(arr)) {
- return arr;
- }
- var result = init;
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (data, i) {
- result = fn(result, data, i);
- });
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (reduce);
- /***/ }),
- /* 88 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__pull_at__ = __webpack_require__(53);
- var remove = function (arr, predicate) {
- /**
- * const arr = [1, 2, 3, 4]
- * const evens = remove(arr, n => n % 2 == 0)
- * console.log(arr) // => [1, 3]
- * console.log(evens) // => [2, 4]
- */
- var result = [];
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
- return result;
- }
- var i = -1;
- var indexes = [];
- var length = arr.length;
- while (++i < length) {
- var value = arr[i];
- if (predicate(value, i, arr)) {
- result.push(value);
- indexes.push(i);
- }
- }
- Object(__WEBPACK_IMPORTED_MODULE_1__pull_at__["a" /* default */])(arr, indexes);
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (remove);
- /***/ }),
- /* 89 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
- function sortBy(arr, key) {
- var comparer;
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(key)) {
- comparer = function (a, b) {
- return key(a) - key(b);
- };
- } else {
- var keys_1 = [];
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(key)) {
- keys_1.push(key);
- } else if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(key)) {
- keys_1 = key;
- }
- comparer = function (a, b) {
- for (var i = 0; i < keys_1.length; i += 1) {
- var prop = keys_1[i];
- if (a[prop] > b[prop]) {
- return 1;
- }
- if (a[prop] < b[prop]) {
- return -1;
- }
- }
- return 0;
- };
- }
- arr.sort(comparer);
- return arr;
- }
- /* harmony default export */ __webpack_exports__["a"] = (sortBy);
- /***/ }),
- /* 90 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__uniq__ = __webpack_require__(54);
- var union = function () {
- var sources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- sources[_i] = arguments[_i];
- }
- return Object(__WEBPACK_IMPORTED_MODULE_0__uniq__["a" /* default */])([].concat.apply([], sources));
- };
- /* harmony default export */ __webpack_exports__["a"] = (union);
- /***/ }),
- /* 91 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_nil__ = __webpack_require__(14);
- /* harmony default export */ __webpack_exports__["a"] = (function (data, name) {
- var rst = [];
- var tmpMap = {};
- data.forEach(function (obj) {
- var value = obj[name];
- if (!Object(__WEBPACK_IMPORTED_MODULE_2__is_nil__["a" /* default */])(value)) {
- // flatten
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(value)) {
- value = [value];
- }
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(value, function (val) {
- // unique
- if (!tmpMap[val]) {
- rst.push(val);
- tmpMap[val] = true;
- }
- });
- }
- });
- return rst;
- });
- /***/ }),
- /* 92 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = head;
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- function head(o) {
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(o)) {
- return o[0];
- }
- return undefined;
- }
- /***/ }),
- /* 93 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = last;
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- function last(o) {
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(o)) {
- var arr = o;
- return arr[arr.length - 1];
- }
- return undefined;
- }
- /***/ }),
- /* 94 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
- function startsWith(arr, e) {
- 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;
- }
- /* harmony default export */ __webpack_exports__["a"] = (startsWith);
- /***/ }),
- /* 95 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
- function endsWith(arr, e) {
- 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;
- }
- /* harmony default export */ __webpack_exports__["a"] = (endsWith);
- /***/ }),
- /* 96 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * 只要有一个不满足条件就返回 false
- * @param arr
- * @param func
- */
- var every = function (arr, func) {
- for (var i = 0; i < arr.length; i++) {
- if (!func(arr[i], i)) return false;
- }
- return true;
- };
- /* harmony default export */ __webpack_exports__["a"] = (every);
- /***/ }),
- /* 97 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * 只要有一个满足条件就返回 true
- * @param arr
- * @param func
- */
- var some = function (arr, func) {
- for (var i = 0; i < arr.length; i++) {
- if (func(arr[i], i)) return true;
- }
- return false;
- };
- /* harmony default export */ __webpack_exports__["a"] = (some);
- /***/ }),
- /* 98 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__group_to_map__ = __webpack_require__(55);
- /* harmony default export */ __webpack_exports__["a"] = (function (data, condition) {
- if (!condition) {
- // 没有条件,则自身改成数组
- return [data];
- }
- var groups = Object(__WEBPACK_IMPORTED_MODULE_0__group_to_map__["a" /* default */])(data, condition);
- var array = [];
- for (var i in groups) {
- array.push(groups[i]);
- }
- return array;
- });
- /***/ }),
- /* 99 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * 获取封装的事件
- * @protected
- * @param {Object} obj 对象
- * @param {String} action 事件名称
- * @return {Function} 返回事件处理函数
- */
- function getWrapBehavior(obj, action) {
- return obj['_wrap_' + action];
- }
- /* harmony default export */ __webpack_exports__["a"] = (getWrapBehavior);
- /***/ }),
- /* 100 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * 封装事件,便于使用上下文this,和便于解除事件时使用
- * @protected
- * @param {Object} obj 对象
- * @param {String} action 事件名称
- * @return {Function} 返回事件处理函数
- */
- function wrapBehavior(obj, action) {
- if (obj['_wrap_' + action]) {
- return obj['_wrap_' + action];
- }
- var method = function (e) {
- obj[action](e);
- };
- obj['_wrap_' + action] = method;
- return method;
- }
- /* harmony default export */ __webpack_exports__["a"] = (wrapBehavior);
- /***/ }),
- /* 101 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var numColorCache = {};
- function numberToColor(num) {
- // 增加缓存
- var color = numColorCache[num];
- if (!color) {
- var str = num.toString(16);
- for (var i = str.length; i < 6; i++) {
- str = '0' + str;
- }
- color = '#' + str;
- numColorCache[num] = color;
- }
- return color;
- }
- /* harmony default export */ __webpack_exports__["a"] = (numberToColor);
- /***/ }),
- /* 102 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- function parseRadius(radius) {
- var r1 = 0,
- r2 = 0,
- r3 = 0,
- r4 = 0;
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(radius)) {
- if (radius.length === 1) {
- r1 = r2 = r3 = r4 = radius[0];
- } else if (radius.length === 2) {
- r1 = r3 = radius[0];
- r2 = r4 = radius[1];
- } else if (radius.length === 3) {
- r1 = radius[0];
- r2 = r4 = radius[1];
- r3 = radius[2];
- } else {
- r1 = radius[0];
- r2 = radius[1];
- r3 = radius[2];
- r4 = radius[3];
- }
- } else {
- r1 = r2 = r3 = r4 = radius;
- }
- return {
- r1: r1,
- r2: r2,
- r3: r3,
- r4: r4
- };
- }
- /* harmony default export */ __webpack_exports__["a"] = (parseRadius);
- /***/ }),
- /* 103 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var clamp = function (a, min, max) {
- if (a < min) {
- return min;
- } else if (a > max) {
- return max;
- }
- return a;
- };
- /* harmony default export */ __webpack_exports__["a"] = (clamp);
- /***/ }),
- /* 104 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var fixedBase = function (v, base) {
- var str = base.toString();
- var index = str.indexOf('.');
- if (index === -1) {
- return Math.round(v);
- }
- var length = str.substr(index + 1).length;
- if (length > 20) {
- length = 20;
- }
- return parseFloat(v.toFixed(length));
- };
- /* harmony default export */ __webpack_exports__["a"] = (fixedBase);
- /***/ }),
- /* 105 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isDecimal = function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 1 !== 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isDecimal);
- /***/ }),
- /* 106 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isEven = function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 2 === 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isEven);
- /***/ }),
- /* 107 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isInteger = Number.isInteger ? Number.isInteger : function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 1 === 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isInteger);
- /***/ }),
- /* 108 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isNegative = function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num < 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isNegative);
- /***/ }),
- /* 109 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = isNumberEqual;
- var PRECISION = 0.00001; // numbers less than this is considered as 0
- function isNumberEqual(a, b, precision) {
- if (precision === void 0) {
- precision = PRECISION;
- }
- return Math.abs(a - b) < precision;
- }
- ;
- /***/ }),
- /* 110 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isOdd = function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num % 2 !== 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isOdd);
- /***/ }),
- /* 111 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- var isPositive = function (num) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(num) && num > 0;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isPositive);
- /***/ }),
- /* 112 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
- /**
- * @param {Array} arr The array to iterate over.
- * @param {Function} [fn] The iteratee invoked per element.
- * @return {*} Returns the maximum value.
- * @example
- *
- * var objects = [{ 'n': 1 }, { 'n': 2 }];
- *
- * maxBy(objects, function(o) { return o.n; });
- * // => { 'n': 2 }
- *
- * maxBy(objects, 'n');
- * // => { 'n': 2 }
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (arr, fn) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr)) {
- return undefined;
- }
- var max = arr[0];
- var maxData;
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
- maxData = fn(arr[0]);
- } else {
- maxData = arr[0][fn];
- }
- var data;
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (val) {
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
- data = fn(val);
- } else {
- data = val[fn];
- }
- if (data > maxData) {
- max = val;
- maxData = data;
- }
- });
- return max;
- });
- /***/ }),
- /* 113 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_function__ = __webpack_require__(9);
- /**
- * @param {Array} arr The array to iterate over.
- * @param {Function} [fn] The iteratee invoked per element.
- * @return {*} Returns the minimum value.
- * @example
- *
- * var objects = [{ 'n': 1 }, { 'n': 2 }];
- *
- * minBy(objects, function(o) { return o.n; });
- * // => { 'n': 1 }
- *
- * minBy(objects, 'n');
- * // => { 'n': 1 }
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (arr, fn) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array__["a" /* default */])(arr)) {
- return undefined;
- }
- var min = arr[0];
- var minData;
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
- minData = fn(arr[0]);
- } else {
- minData = arr[0][fn];
- }
- var data;
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (val) {
- if (Object(__WEBPACK_IMPORTED_MODULE_2__is_function__["a" /* default */])(fn)) {
- data = fn(val);
- } else {
- data = val[fn];
- }
- if (data < minData) {
- min = val;
- minData = data;
- }
- });
- return min;
- });
- /***/ }),
- /* 114 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var mod = function (n, m) {
- return (n % m + m) % m;
- };
- /* harmony default export */ __webpack_exports__["a"] = (mod);
- /***/ }),
- /* 115 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var DEGREE = 180 / Math.PI;
- var toDegree = function (radian) {
- return DEGREE * radian;
- };
- /* harmony default export */ __webpack_exports__["a"] = (toDegree);
- /***/ }),
- /* 116 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (parseInt);
- /***/ }),
- /* 117 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var RADIAN = Math.PI / 180;
- var toRadian = function (degree) {
- return RADIAN * degree;
- };
- /* harmony default export */ __webpack_exports__["a"] = (toRadian);
- /***/ }),
- /* 118 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */]);
- /***/ }),
- /* 119 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__has__ = __webpack_require__(57);
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__has__["a" /* default */]);
- /***/ }),
- /* 120 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__contains__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__values__ = __webpack_require__(58);
- /* harmony default export */ __webpack_exports__["a"] = (function (obj, value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__contains__["a" /* default */])(Object(__WEBPACK_IMPORTED_MODULE_1__values__["a" /* default */])(obj), value);
- });
- /***/ }),
- /* 121 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
- var lowerCase = function (str) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(str).toLowerCase();
- };
- /* harmony default export */ __webpack_exports__["a"] = (lowerCase);
- /***/ }),
- /* 122 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
- var lowerFirst = function (value) {
- var str = Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(value);
- return str.charAt(0).toLowerCase() + str.substring(1);
- };
- /* harmony default export */ __webpack_exports__["a"] = (lowerFirst);
- /***/ }),
- /* 123 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function substitute(str, o) {
- if (!str || !o) {
- return str;
- }
- return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
- if (match.charAt(0) === '\\') {
- return match.slice(1);
- }
- return o[name] === undefined ? '' : o[name];
- });
- }
- /* harmony default export */ __webpack_exports__["a"] = (substitute);
- /***/ }),
- /* 124 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
- var upperCase = function (str) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(str).toUpperCase();
- };
- /* harmony default export */ __webpack_exports__["a"] = (upperCase);
- /***/ }),
- /* 125 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__to_string__ = __webpack_require__(25);
- var upperFirst = function (value) {
- var str = Object(__WEBPACK_IMPORTED_MODULE_0__to_string__["a" /* default */])(value);
- return str.charAt(0).toUpperCase() + str.substring(1);
- };
- /* harmony default export */ __webpack_exports__["a"] = (upperFirst);
- /***/ }),
- /* 126 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /**
- * 是否是参数类型
- *
- * @param {Object} value 测试的值
- * @return {Boolean}
- */
- var isArguments = function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Arguments');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isArguments);
- /***/ }),
- /* 127 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /**
- * 是否是布尔类型
- *
- * @param {Object} value 测试的值
- * @return {Boolean}
- */
- var isBoolean = function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Boolean');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isBoolean);
- /***/ }),
- /* 128 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- var isDate = function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Date');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isDate);
- /***/ }),
- /* 129 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- /**
- * 是否是参数类型
- *
- * @param {Object} value 测试的值
- * @return {Boolean}
- */
- var isError = function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(value, 'Error');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isError);
- /***/ }),
- /* 130 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_number__ = __webpack_require__(12);
- /**
- * 判断是否为有限数
- * @return {Boolean}
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_number__["a" /* default */])(value) && isFinite(value);
- });
- /***/ }),
- /* 131 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var isNull = function (value) {
- return value === null;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isNull);
- /***/ }),
- /* 132 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_type__ = __webpack_require__(11);
- var isRegExp = function (str) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_type__["a" /* default */])(str, 'RegExp');
- };
- /* harmony default export */ __webpack_exports__["a"] = (isRegExp);
- /***/ }),
- /* 133 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var isUndefined = function (value) {
- return value === undefined;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isUndefined);
- /***/ }),
- /* 134 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * 判断是否HTML元素
- * @return {Boolean} 是否HTML元素
- */
- var isElement = function (o) {
- return o instanceof Element || o instanceof HTMLDocument;
- };
- /* harmony default export */ __webpack_exports__["a"] = (isElement);
- /***/ }),
- /* 135 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = requestAnimationFrame;
- function requestAnimationFrame(fn) {
- var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || // @ts-ignore
- window.mozRequestAnimationFrame || // @ts-ignore
- window.msRequestAnimationFrame || function (f) {
- return setTimeout(f, 16);
- };
- return method(fn);
- }
- ;
- /***/ }),
- /* 136 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = cancelAnimationFrame;
- function cancelAnimationFrame(handler) {
- var method = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || // @ts-ignore
- window.mozCancelAnimationFrame || // @ts-ignore
- window.msCancelAnimationFrame || clearTimeout;
- method(handler);
- }
- ;
- /***/ }),
- /* 137 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mix__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
- var augment = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var c = args[0];
- for (var i = 1; i < args.length; i++) {
- var obj = args[i];
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(obj)) {
- obj = obj.prototype;
- }
- Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(c.prototype, obj);
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (augment);
- /***/ }),
- /* 138 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- var clone = function (obj) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
- var rst;
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(obj)) {
- rst = [];
- for (var i = 0, l = obj.length; i < l; i++) {
- if (typeof obj[i] === 'object' && obj[i] != null) {
- rst[i] = clone(obj[i]);
- } else {
- rst[i] = obj[i];
- }
- }
- } else {
- rst = {};
- for (var k in obj) {
- if (typeof obj[k] === 'object' && obj[k] != null) {
- rst[k] = clone(obj[k]);
- } else {
- rst[k] = obj[k];
- }
- }
- }
- return rst;
- };
- /* harmony default export */ __webpack_exports__["a"] = (clone);
- /***/ }),
- /* 139 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function debounce(func, wait, immediate) {
- var timeout;
- return function () {
- var context = this,
- args = arguments;
- var later = function () {
- timeout = null;
- if (!immediate) {
- func.apply(context, args);
- }
- };
- var callNow = immediate && !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) {
- func.apply(context, args);
- }
- };
- }
- /* harmony default export */ __webpack_exports__["a"] = (debounce);
- /***/ }),
- /* 140 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
- /**
- * _.memoize(calColor);
- * _.memoize(calColor, (...args) => args[0]);
- * @param f
- * @param resolver
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (f, resolver) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(f)) {
- throw new TypeError('Expected a function');
- }
- var memoized = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
- var key = resolver ? resolver.apply(this, args) : args[0];
- var cache = memoized.cache;
- if (cache.has(key)) {
- return cache.get(key);
- }
- var result = f.apply(this, args); // 缓存起来
- cache.set(key, result);
- return result;
- };
- memoized.cache = new Map();
- return memoized;
- });
- /***/ }),
- /* 141 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_plain_object__ = __webpack_require__(24);
- var MAX_MIX_LEVEL = 5;
- function _deepMix(dist, src, level, maxLevel) {
- level = level || 0;
- maxLevel = maxLevel || MAX_MIX_LEVEL;
- for (var key in src) {
- if (src.hasOwnProperty(key)) {
- var value = src[key];
- if (value !== null && Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(value)) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(dist[key])) {
- dist[key] = {};
- }
- if (level < maxLevel) {
- _deepMix(dist[key], value, level + 1, maxLevel);
- } else {
- dist[key] = src[key];
- }
- } else if (Object(__WEBPACK_IMPORTED_MODULE_0__is_array__["a" /* default */])(value)) {
- dist[key] = [];
- dist[key] = dist[key].concat(value);
- } else if (value !== undefined) {
- dist[key] = value;
- }
- }
- }
- } // todo 重写
- var deepMix = function (rst) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- for (var i = 0; i < args.length; i += 1) {
- _deepMix(rst, args[i]);
- }
- return rst;
- };
- /* harmony default export */ __webpack_exports__["a"] = (deepMix);
- /***/ }),
- /* 142 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mix__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_function__ = __webpack_require__(9);
- var extend = function (subclass, superclass, overrides, staticOverrides) {
- // 如果只提供父类构造函数,则自动生成子类构造函数
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_function__["a" /* default */])(superclass)) {
- overrides = superclass;
- superclass = subclass;
- subclass = function () {};
- }
- var create = Object.create ? function (proto, c) {
- return Object.create(proto, {
- constructor: {
- value: c
- }
- });
- } : function (proto, c) {
- function Tmp() {}
- Tmp.prototype = proto;
- var o = new Tmp();
- o.constructor = c;
- return o;
- };
- var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
- subclass.prototype = Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(superObj, subclass.prototype); // 指定子类的prototype
- subclass.superclass = create(superclass.prototype, superclass);
- Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(superObj, overrides);
- Object(__WEBPACK_IMPORTED_MODULE_0__mix__["a" /* default */])(subclass, staticOverrides);
- return subclass;
- };
- /* harmony default export */ __webpack_exports__["a"] = (extend);
- /***/ }),
- /* 143 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- var indexOf = function (arr, obj) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(arr)) {
- return -1;
- }
- var m = Array.prototype.indexOf;
- if (m) {
- return m.call(arr, obj);
- }
- var index = -1;
- for (var i = 0; i < arr.length; i++) {
- if (arr[i] === obj) {
- index = i;
- break;
- }
- }
- return index;
- };
- /* harmony default export */ __webpack_exports__["a"] = (indexOf);
- /***/ }),
- /* 144 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__get_type__ = __webpack_require__(59);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__is_prototype__ = __webpack_require__(60);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function isEmpty(value) {
- /**
- * isEmpty(null) => true
- * isEmpty() => true
- * isEmpty(true) => true
- * isEmpty(1) => true
- * isEmpty([1, 2, 3]) => false
- * isEmpty('abc') => false
- * isEmpty({ a: 1 }) => false
- */
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(value)) {
- return true;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(value)) {
- return !value.length;
- }
- var type = Object(__WEBPACK_IMPORTED_MODULE_2__get_type__["a" /* default */])(value);
- if (type === 'Map' || type === 'Set') {
- return !value.size;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_3__is_prototype__["a" /* default */])(value)) {
- return !Object.keys(value).length;
- }
- for (var key in value) {
- if (hasOwnProperty.call(value, key)) {
- return false;
- }
- }
- return true;
- }
- /* harmony default export */ __webpack_exports__["a"] = (isEmpty);
- /***/ }),
- /* 145 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_function__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_equal__ = __webpack_require__(61);
- /**
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [fn] The function to customize comparisons.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * function isGreeting(value) {
- * return /^h(?:i|ello)$/.test(value);
- * }
- *
- * function customizer(objValue, othValue) {
- * if (isGreeting(objValue) && isGreeting(othValue)) {
- * return true;
- * }
- * }
- *
- * var array = ['hello', 'goodbye'];
- * var other = ['hi', 'goodbye'];
- *
- * isEqualWith(array, other, customizer); // => true
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (value, other, fn) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_function__["a" /* default */])(fn)) {
- return Object(__WEBPACK_IMPORTED_MODULE_1__is_equal__["a" /* default */])(value, other);
- }
- return !!fn(value, other);
- });
- /***/ }),
- /* 146 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
- var map = function (arr, func) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(arr)) {
- // @ts-ignore
- return arr;
- }
- var result = [];
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(arr, function (value, index) {
- result.push(func(value, index));
- });
- return result;
- };
- /* harmony default export */ __webpack_exports__["a"] = (map);
- /***/ }),
- /* 147 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_object__ = __webpack_require__(29);
- var identity = function (v) {
- return v;
- };
- /* harmony default export */ __webpack_exports__["a"] = (function (object, func) {
- if (func === void 0) {
- func = identity;
- }
- var r = {};
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_object__["a" /* default */])(object) && !Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(object)) {
- Object.keys(object).forEach(function (key) {
- // @ts-ignore
- r[key] = func(object[key], key);
- });
- }
- return r;
- });
- /***/ }),
- /* 148 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_string__ = __webpack_require__(18);
- /**
- * https://github.com/developit/dlv/blob/master/index.js
- * @param obj
- * @param key
- * @param defaultValue
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (obj, key, defaultValue) {
- var p = 0;
- var keyArr = Object(__WEBPACK_IMPORTED_MODULE_0__is_string__["a" /* default */])(key) ? key.split('.') : key;
- while (obj && p < keyArr.length) {
- obj = obj[keyArr[p++]];
- }
- return obj === undefined || p < keyArr.length ? defaultValue : obj;
- });
- /***/ }),
- /* 149 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_object__ = __webpack_require__(29);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_string__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__is_number__ = __webpack_require__(12);
- /**
- * https://github.com/developit/dlv/blob/master/index.js
- * @param obj
- * @param path
- * @param value
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (obj, path, value) {
- var o = obj;
- var keyArr = Object(__WEBPACK_IMPORTED_MODULE_1__is_string__["a" /* default */])(path) ? path.split('.') : path;
- keyArr.forEach(function (key, idx) {
- // 不是最后一个
- if (idx < keyArr.length - 1) {
- if (!Object(__WEBPACK_IMPORTED_MODULE_0__is_object__["a" /* default */])(o[key])) {
- o[key] = Object(__WEBPACK_IMPORTED_MODULE_2__is_number__["a" /* default */])(keyArr[idx + 1]) ? [] : {};
- }
- o = o[key];
- } else {
- o[key] = value;
- }
- });
- return obj;
- });
- /***/ }),
- /* 150 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__each__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_plain_object__ = __webpack_require__(24);
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- /* harmony default export */ __webpack_exports__["a"] = (function (object, keys) {
- if (object === null || !Object(__WEBPACK_IMPORTED_MODULE_1__is_plain_object__["a" /* default */])(object)) {
- return {};
- }
- var result = {};
- Object(__WEBPACK_IMPORTED_MODULE_0__each__["a" /* default */])(keys, function (key) {
- if (hasOwnProperty.call(object, key)) {
- result[key] = object[key];
- }
- });
- return result;
- });
- /***/ }),
- /* 151 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (func, wait, options) {
- var timeout, context, args, result;
- var previous = 0;
- if (!options) options = {};
- var later = function () {
- previous = options.leading === false ? 0 : Date.now();
- timeout = null;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- };
- var throttled = function () {
- var now = Date.now();
- if (!previous && options.leading === false) previous = now;
- var remaining = wait - (now - previous);
- context = this;
- args = arguments;
- if (remaining <= 0 || remaining > wait) {
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
- }
- previous = now;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- } else if (!timeout && options.trailing !== false) {
- timeout = setTimeout(later, remaining);
- }
- return result;
- };
- throttled.cancel = function () {
- clearTimeout(timeout);
- previous = 0;
- timeout = context = args = null;
- };
- return throttled;
- });
- /***/ }),
- /* 152 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_array_like__ = __webpack_require__(7);
- /* harmony default export */ __webpack_exports__["a"] = (function (value) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__is_array_like__["a" /* default */])(value) ? Array.prototype.slice.call(value) : [];
- });
- /***/ }),
- /* 153 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var map = {};
- /* harmony default export */ __webpack_exports__["a"] = (function (prefix) {
- prefix = prefix || 'g';
- if (!map[prefix]) {
- map[prefix] = 1;
- } else {
- map[prefix] += 1;
- }
- return prefix + map[prefix];
- });
- /***/ }),
- /* 154 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function () {});
- /***/ }),
- /* 155 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (v) {
- return v;
- });
- /***/ }),
- /* 156 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = size;
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__is_nil__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__is_array_like__ = __webpack_require__(7);
- function size(o) {
- if (Object(__WEBPACK_IMPORTED_MODULE_0__is_nil__["a" /* default */])(o)) {
- return 0;
- }
- if (Object(__WEBPACK_IMPORTED_MODULE_1__is_array_like__["a" /* default */])(o)) {
- return o.length;
- }
- return Object.keys(o).length;
- }
- /***/ }),
- /* 157 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * k-v 存储
- */
- var default_1 =
- /** @class */
- function () {
- function default_1() {
- this.map = {};
- }
- default_1.prototype.has = function (key) {
- return this.map[key] !== undefined;
- };
- default_1.prototype.get = function (key, def) {
- var v = this.map[key];
- return v === undefined ? def : v;
- };
- default_1.prototype.set = function (key, value) {
- this.map[key] = value;
- };
- default_1.prototype.clear = function () {
- this.map = {};
- };
- default_1.prototype.delete = function (key) {
- delete this.map[key];
- };
- default_1.prototype.size = function () {
- return Object.keys(this.map).length;
- };
- return default_1;
- }();
- /* harmony default export */ __webpack_exports__["a"] = (default_1);
- /***/ }),
- /* 158 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Plot = /*#__PURE__*/function () {
- function Plot(cfg) {
- Util.mix(this, cfg);
- this._init();
- }
- var _proto = Plot.prototype;
- _proto._init = function _init() {
- var self = this;
- var start = self.start;
- var end = self.end;
- var xMin = Math.min(start.x, end.x);
- var xMax = Math.max(start.x, end.x);
- var yMin = Math.min(start.y, end.y);
- var yMax = Math.max(start.y, end.y);
- this.tl = {
- x: xMin,
- y: yMin
- };
- this.tr = {
- x: xMax,
- y: yMin
- };
- this.bl = {
- x: xMin,
- y: yMax
- };
- this.br = {
- x: xMax,
- y: yMax
- };
- this.width = xMax - xMin;
- this.height = yMax - yMin;
- }
- /**
- * reset
- * @param {Object} start start point
- * @param {Object} end end point
- */
- ;
- _proto.reset = function reset(start, end) {
- this.start = start;
- this.end = end;
- this._init();
- }
- /**
- * check the point is in the range of plot
- * @param {Nubmer} x x value
- * @param {[type]} y y value
- * @return {Boolean} return the result
- */
- ;
- _proto.isInRange = function isInRange(x, y) {
- if (Util.isObject(x)) {
- y = x.y;
- x = x.x;
- }
- var tl = this.tl;
- var br = this.br;
- return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
- };
- return Plot;
- }();
- module.exports = Plot;
- /***/ }),
- /* 159 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Coord = __webpack_require__(43);
- __webpack_require__(160);
- module.exports = Coord;
- /***/ }),
- /* 160 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Base = __webpack_require__(43);
- var Cartesian = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Cartesian, _Base);
- var _super = _createSuper(Cartesian);
- function Cartesian() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Cartesian.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'cartesian';
- this.transposed = false;
- this.isRect = true;
- };
- _proto.init = function init(start, end) {
- _Base.prototype.init.call(this, start, end);
- this.x = {
- start: start.x,
- end: end.x
- };
- this.y = {
- start: start.y,
- end: end.y
- };
- };
- _proto._convertPoint = function _convertPoint(point) {
- var self = this;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- return {
- x: x.start + (x.end - x.start) * point[xDim],
- y: y.start + (y.end - y.start) * point[yDim]
- };
- };
- _proto._invertPoint = function _invertPoint(point) {
- var self = this;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- var rst = {};
- rst[xDim] = (point.x - x.start) / (x.end - x.start);
- rst[yDim] = (point.y - y.start) / (y.end - y.start);
- return rst;
- };
- return Cartesian;
- }(Base);
- Base.Cartesian = Cartesian;
- Base.Rect = Cartesian;
- module.exports = Cartesian;
- /***/ }),
- /* 161 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports.Color = exports.Size = exports.Shape = exports.Position = void 0;
- var _position = _interopRequireDefault(__webpack_require__(162));
- exports.Position = _position["default"];
- var _shape = _interopRequireDefault(__webpack_require__(163));
- exports.Shape = _shape["default"];
- var _size = _interopRequireDefault(__webpack_require__(164));
- exports.Size = _size["default"];
- var _color = _interopRequireDefault(__webpack_require__(165));
- exports.Color = _color["default"];
- /***/ }),
- /* 162 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports["default"] = void 0;
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _util = __webpack_require__(20);
- var _base = _interopRequireDefault(__webpack_require__(32));
- 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); }; }
- 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; } }
- var Position = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Position, _Base);
- var _super = _createSuper(Position);
- function Position(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['x', 'y'];
- _this.type = 'position';
- return _this;
- }
- var _proto = Position.prototype;
- _proto.mapping = function mapping(x, y) {
- var scales = this.scales;
- var coord = this.coord;
- var scaleX = scales[0];
- var scaleY = scales[1];
- var rstX;
- var rstY;
- var obj;
- if ((0, _util.isNil)(x) || (0, _util.isNil)(y)) {
- return [];
- }
- if ((0, _util.isArray)(y) && (0, _util.isArray)(x)) {
- rstX = [];
- rstY = [];
- for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
- obj = coord.convertPoint({
- x: scaleX.scale(x[i]),
- y: scaleY.scale(y[j])
- });
- rstX.push(obj.x);
- rstY.push(obj.y);
- }
- } else if ((0, _util.isArray)(y)) {
- x = scaleX.scale(x);
- rstY = [];
- (0, _util.each)(y, function (yVal) {
- yVal = scaleY.scale(yVal);
- obj = coord.convertPoint({
- x: x,
- y: yVal
- });
- if (rstX && rstX !== obj.x) {
- if (!(0, _util.isArray)(rstX)) {
- rstX = [rstX];
- }
- rstX.push(obj.x);
- } else {
- rstX = obj.x;
- }
- rstY.push(obj.y);
- });
- } else if ((0, _util.isArray)(x)) {
- y = scaleY.scale(y);
- rstX = [];
- (0, _util.each)(x, function (xVal) {
- xVal = scaleX.scale(xVal);
- obj = coord.convertPoint({
- x: xVal,
- y: y
- });
- if (rstY && rstY !== obj.y) {
- if (!(0, _util.isArray)(rstY)) {
- rstY = [rstY];
- }
- rstY.push(obj.y);
- } else {
- rstY = obj.y;
- }
- rstX.push(obj.x);
- });
- } else {
- x = scaleX.scale(x);
- y = scaleY.scale(y);
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- rstX = point.x;
- rstY = point.y;
- }
- return [rstX, rstY];
- };
- return Position;
- }(_base["default"]);
- var _default = Position;
- exports["default"] = _default;
- /***/ }),
- /* 163 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports["default"] = void 0;
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _base = _interopRequireDefault(__webpack_require__(32));
- 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); }; }
- 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; } }
- var Shape = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Shape, _Base);
- var _super = _createSuper(Shape);
- function Shape(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['shape'];
- _this.type = 'shape';
- _this.gradient = null;
- return _this;
- }
- /**
- * @override
- */
- var _proto = Shape.prototype;
- _proto.getLinearValue = function getLinearValue(percent) {
- var values = this.values;
- var index = Math.round((values.length - 1) * percent);
- return values[index];
- };
- return Shape;
- }(_base["default"]);
- var _default = Shape;
- exports["default"] = _default;
- /***/ }),
- /* 164 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports["default"] = void 0;
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _base = _interopRequireDefault(__webpack_require__(32));
- 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); }; }
- 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; } }
- var Size = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Size, _Base);
- var _super = _createSuper(Size);
- function Size(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['size'];
- _this.type = 'size';
- _this.gradient = null;
- return _this;
- }
- return Size;
- }(_base["default"]);
- var _default = Size;
- exports["default"] = _default;
- /***/ }),
- /* 165 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports["default"] = void 0;
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _util = __webpack_require__(20);
- var _base = _interopRequireDefault(__webpack_require__(32));
- var _colorUtil = _interopRequireDefault(__webpack_require__(166));
- 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); }; }
- 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; } }
- var Color = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Color, _Base);
- var _super = _createSuper(Color);
- function Color(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['color'];
- _this.type = 'color';
- _this.gradient = null;
- if ((0, _util.isString)(_this.values)) {
- _this.linear = true;
- }
- return _this;
- }
- /**
- * @override
- */
- var _proto = Color.prototype;
- _proto.getLinearValue = function getLinearValue(percent) {
- var gradient = this.gradient;
- if (!gradient) {
- var values = this.values;
- gradient = _colorUtil["default"].gradient(values);
- this.gradient = gradient;
- }
- return gradient(percent);
- };
- return Color;
- }(_base["default"]);
- var _default = Color;
- exports["default"] = _default;
- /***/ }),
- /* 166 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports["default"] = void 0;
- var _util = __webpack_require__(20);
- // Get the interpolation between colors
- function getValue(start, end, percent, index) {
- var value = start[index] + (end[index] - start[index]) * percent;
- return value;
- } // convert to hex
- function arr2hex(arr) {
- return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
- }
- function toRGBValue(value) {
- value = Math.round(value);
- value = value.toString(16);
- if (value.length === 1) {
- value = '0' + value;
- }
- return value;
- }
- function calColor(colors, percent) {
- var steps = colors.length - 1;
- var step = Math.floor(steps * percent);
- var left = steps * percent - step;
- var start = colors[step];
- var end = step === steps ? start : colors[step + 1];
- var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
- return rgb;
- }
- function hex2arr(str) {
- var arr = [];
- arr.push(parseInt(str.substr(1, 2), 16));
- arr.push(parseInt(str.substr(3, 2), 16));
- arr.push(parseInt(str.substr(5, 2), 16));
- return arr;
- }
- var colorCache = {
- black: '#000000',
- blue: '#0000ff',
- grey: '#808080',
- green: '#008000',
- orange: '#ffa500',
- pink: '#ffc0cb',
- purple: '#800080',
- red: '#ff0000',
- white: '#ffffff',
- yellow: '#ffff00'
- };
- var ColorUtil = {
- /**
- * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
- * @param {String} color color value
- * @return {String} Returns a hexadecimal string
- */
- toHex: function toHex(color) {
- if (colorCache[color]) {
- return colorCache[color];
- }
- if (color[0] === '#') {
- if (color.length === 7) {
- return color;
- }
- var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
- return '#' + r + r + g + g + b + b;
- }); // hex3 to hex6
- colorCache[color] = hex;
- return hex;
- } // rgb/rgba to hex
- var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
- rst.shift();
- rst = arr2hex(rst);
- colorCache[color] = rst;
- return rst;
- },
- hex2arr: hex2arr,
- /**
- * handle the gradient color
- * @param {Array} colors the colors
- * @return {String} return the color value
- */
- gradient: function gradient(colors) {
- var points = [];
- if ((0, _util.isString)(colors)) {
- colors = colors.split('-');
- }
- (0, _util.each)(colors, function (color) {
- if (color.indexOf('#') === -1) {
- color = ColorUtil.toHex(color);
- }
- points.push(hex2arr(color));
- });
- return function (percent) {
- return calColor(points, percent);
- };
- }
- };
- var _default = ColorUtil;
- exports["default"] = _default;
- /***/ }),
- /* 167 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(6);
- var Scale = __webpack_require__(168);
- var SCALE_TYPES_MAP = {
- linear: 'Linear',
- cat: 'Cat',
- timeCat: 'TimeCat',
- identity: 'Identity'
- };
- function isFullCircle(coord) {
- if (!coord.isPolar) {
- return false;
- }
- var startAngle = coord.startAngle;
- var endAngle = coord.endAngle;
- if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
- return false;
- }
- return true;
- }
- function clearObj(obj) {
- Object.keys(obj).forEach(function (key) {
- delete obj[key];
- });
- }
- var ScaleController = /*#__PURE__*/function () {
- function ScaleController(cfg) {
- // defs 列定义
- this.defs = {}; // 已经实例化的scale
- this.scales = {};
- Util.mix(this, cfg);
- }
- var _proto = ScaleController.prototype;
- _proto.setFieldDef = function setFieldDef(field, cfg) {
- var defs = this.defs;
- if (Util.isObject(field)) {
- Util.mix(defs, field);
- } else {
- defs[field] = cfg;
- } // 因为可能同时变更多个scale,所以要把所有已实例化的scale都更新下
- this.updateScales();
- };
- _proto._getDef = function _getDef(field) {
- var defs = this.defs;
- var def = null;
- if (Global.scales[field] || defs[field]) {
- def = Util.mix({}, Global.scales[field]);
- Util.each(defs[field], function (v, k) {
- if (Util.isNil(v)) {
- delete def[k];
- } else {
- def[k] = v;
- }
- });
- }
- return def;
- };
- _proto._getDefaultType = function _getDefaultType(field, data, def) {
- if (def && def.type) {
- return def.type;
- }
- var type = 'linear';
- var value = Util.Array.firstValue(data, field);
- if (Util.isArray(value)) {
- value = value[0];
- }
- if (Util.isString(value)) {
- type = 'cat';
- }
- return type;
- };
- _proto._getScaleDef = function _getScaleDef(type, field, data, def) {
- var values;
- if (def && def.values) {
- values = def.values;
- } else {
- values = Util.Array.values(data, field);
- }
- var cfg = {
- field: field,
- values: values
- };
- if (type !== 'cat' && type !== 'timeCat') {
- if (!def || !(def.min && def.max)) {
- var _Util$Array$getRange = Util.Array.getRange(values),
- min = _Util$Array$getRange.min,
- max = _Util$Array$getRange.max;
- cfg.min = min;
- cfg.max = max;
- cfg.nice = true;
- }
- } else {
- cfg.isRounding = false; // used for tickCount calculation
- }
- return cfg;
- } // 调整range,为了让图形居中
- ;
- _proto._adjustRange = function _adjustRange(type, cfg) {
- var range = cfg.range,
- values = cfg.values; // 如果是线性, 或者有自定义range都不处理
- if (type === 'linear' || range || !values) {
- return cfg;
- }
- var count = values.length; // 单只有一条数据时,在中间显示
- if (count === 1) {
- cfg.range = [0.5, 1];
- } else {
- var chart = this.chart;
- var coord = chart.get('coord');
- var widthRatio = Global.widthRatio.multiplePie;
- var offset = 0;
- if (isFullCircle(coord)) {
- if (!coord.transposed) {
- cfg.range = [0, 1 - 1 / count];
- } else {
- offset = 1 / count * widthRatio;
- cfg.range = [offset / 2, 1 - offset / 2];
- }
- } else {
- // 为了让图形居中,所以才设置range
- offset = 1 / count * 1 / 2;
- cfg.range = [offset, 1 - offset];
- }
- }
- return cfg;
- };
- _proto._getScaleCfg = function _getScaleCfg(field, data) {
- var self = this;
- var def = self._getDef(field);
- if (!data || !data.length) {
- if (def && def.type) {
- def.field = field;
- return {
- type: SCALE_TYPES_MAP[def.type],
- cfg: def
- };
- }
- return {
- type: 'Identity',
- cfg: {
- value: field,
- field: field.toString(),
- values: [field]
- }
- };
- }
- var firstObj = data[0];
- var firstValue = firstObj[field];
- if (firstValue === null) {
- firstValue = Util.Array.firstValue(data, field);
- }
- if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
- return {
- type: 'Identity',
- cfg: {
- value: field,
- field: field.toString(),
- values: [field]
- }
- };
- }
- var type = self._getDefaultType(field, data, def);
- var cfg = self._getScaleDef(type, field, data, def);
- def && Util.mix(cfg, def);
- cfg = this._adjustRange(type, cfg);
- return {
- type: SCALE_TYPES_MAP[type],
- cfg: cfg
- };
- };
- _proto.createScale = function createScale(field, data) {
- var scales = this.scales;
- var _this$_getScaleCfg = this._getScaleCfg(field, data),
- type = _this$_getScaleCfg.type,
- cfg = _this$_getScaleCfg.cfg;
- var scale = scales[field]; // 如果已经存在,且类型相等时直接返回
- if (scale && SCALE_TYPES_MAP[scale.type] === type) {
- scale.change(cfg);
- return scale;
- }
- var newScale = new Scale[type](cfg);
- scales[field] = newScale;
- return newScale;
- };
- _proto._updateScale = function _updateScale(scale) {
- var field = scale.field; // 因为每个field的数据都会不同
- var data = this.chart._getScaleData(field);
- var _this$_getScaleCfg2 = this._getScaleCfg(field, data),
- cfg = _this$_getScaleCfg2.cfg;
- scale.change(cfg);
- };
- _proto.updateScales = function updateScales() {
- var _this = this;
- var scales = this.scales; // 修改完列定义后,需要更新已经实例化的scale
- // 如果是还没有实例化的,在geom初始化的时候会被实例化,所以这里可以不用更新
- Util.each(scales, function (scale) {
- _this._updateScale(scale);
- });
- } // 调整scale从0开始
- ;
- _proto.adjustStartZero = function adjustStartZero(scale) {
- var defs = this.defs;
- var field = scale.field,
- min = scale.min,
- max = scale.max; // 如果有定义,则不处理
- if (defs[field] && defs[field].min) {
- return;
- }
- if (min > 0) {
- scale.change({
- min: 0
- });
- } else if (max < 0) {
- scale.change({
- max: 0
- });
- }
- };
- _proto.clear = function clear() {
- // this.defs = {};
- // this.scales = {};
- clearObj(this.defs);
- clearObj(this.scales);
- this.data = null;
- };
- return ScaleController;
- }();
- module.exports = ScaleController;
- /***/ }),
- /* 168 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Scale = __webpack_require__(26);
- __webpack_require__(169);
- __webpack_require__(172);
- __webpack_require__(69);
- module.exports = Scale;
- /***/ }),
- /* 169 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- /**
- * @fileOverview The measurement of linear data scale function
- * @author dxq613@gmail.com
- */
- var isNil = __webpack_require__(35);
- var each = __webpack_require__(15);
- var Base = __webpack_require__(26);
- var numberAuto = __webpack_require__(170);
- /**
- * 线性度量
- * @class Scale.Linear
- */
- var Linear = /*#__PURE__*/function (_Base) {
- _inheritsLoose(Linear, _Base);
- function Linear() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Linear.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- var self = this;
- self.type = 'linear';
- self.isLinear = true;
- /**
- * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
- * @type {Boolean}
- * @default false
- */
- self.nice = false;
- /**
- * min value of the scale
- * @type {Number}
- * @default null
- */
- self.min = null;
- /**
- * min value limitted of the scale
- * @type {Number}
- * @default null
- */
- self.minLimit = null;
- /**
- * max value of the scale
- * @type {Number}
- * @default null
- */
- self.max = null;
- /**
- * max value limitted of the scale
- * @type {Number}
- * @default null
- */
- self.maxLimit = null;
- /**
- * 自动生成标记时的个数
- * @type {Number}
- * @default null
- */
- self.tickCount = null;
- /**
- * 坐标轴点之间的间距,指的是真实数据的差值
- * @type {Number}
- * @default null
- */
- self.tickInterval = null;
- /**
- * 坐标轴点之间的最小间距,指的是真实数据的差值
- * @type {Number}
- * @default null
- */
- self.minTickInterval = null;
- /**
- * 用于计算坐标点时逼近的数组
- * @type {Array}
- */
- self.snapArray = null;
- }
- /**
- * @protected
- * @override
- */
- ;
- _proto.init = function init() {
- var self = this;
- if (!self.ticks) {
- self.min = self.translate(self.min);
- self.max = self.translate(self.max);
- self.initTicks();
- } else {
- var ticks = self.ticks;
- var firstValue = self.translate(ticks[0]);
- var lastValue = self.translate(ticks[ticks.length - 1]);
- if (isNil(self.min) || self.min > firstValue) {
- self.min = firstValue;
- }
- if (isNil(self.max) || self.max < lastValue) {
- self.max = lastValue;
- }
- }
- }
- /**
- * 计算坐标点
- * @protected
- * @return {Array} 计算完成的坐标点
- */
- ;
- _proto.calculateTicks = function calculateTicks() {
- var min = this.min,
- max = this.max,
- minLimit = this.minLimit,
- maxLimit = this.maxLimit,
- tickCount = this.tickCount,
- tickInterval = this.tickInterval,
- minTickInterval = this.minTickInterval,
- snapArray = this.snapArray;
- if (tickCount === 1) {
- throw new Error('linear scale\'tickCount should not be 1');
- }
- if (max < min) {
- throw new Error("max: " + max + " should not be less than min: " + min);
- }
- var tmp = numberAuto({
- min: min,
- max: max,
- minLimit: minLimit,
- maxLimit: maxLimit,
- minCount: tickCount,
- maxCount: tickCount,
- interval: tickInterval,
- minTickInterval: minTickInterval,
- snapArray: snapArray
- });
- return tmp.ticks;
- } // 初始化ticks
- ;
- _proto.initTicks = function initTicks() {
- var self = this;
- var calTicks = self.calculateTicks();
- if (self.nice) {
- // 如果需要优化显示的tick
- self.ticks = calTicks;
- self.min = calTicks[0];
- self.max = calTicks[calTicks.length - 1];
- } else {
- var ticks = [];
- each(calTicks, function (tick) {
- if (tick >= self.min && tick <= self.max) {
- ticks.push(tick);
- }
- }); // 如果 ticks 为空,直接输入最小值、最大值
- if (!ticks.length) {
- ticks.push(self.min);
- ticks.push(self.max);
- }
- self.ticks = ticks;
- }
- }
- /**
- * @override
- */
- ;
- _proto.scale = function scale(value) {
- if (isNil(value)) {
- return NaN;
- }
- var max = this.max;
- var min = this.min;
- if (max === min) {
- return 0;
- }
- var percent = (value - min) / (max - min);
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- return rangeMin + percent * (rangeMax - rangeMin);
- }
- /**
- * @override
- */
- ;
- _proto.invert = function invert(value) {
- var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
- return this.min + percent * (this.max - this.min);
- };
- return Linear;
- }(Base);
- Base.Linear = Linear;
- module.exports = Linear;
- /***/ }),
- /* 170 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 自动计算数字坐标轴
- * @author dxq613@gmail.com
- */
- var isNil = __webpack_require__(35);
- var isNumber = __webpack_require__(36);
- var AutoUtil = __webpack_require__(171);
- var MIN_COUNT = 5;
- var MAX_COUNT = 7;
- var SNAP_COUNT_ARRAY = [0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
- var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
- var EPS = 1e-12;
- module.exports = function (info) {
- var min = info.min;
- var max = info.max;
- var interval = info.interval;
- var minTickInterval = info.minTickInterval;
- var ticks = [];
- var minCount = info.minCount || MIN_COUNT;
- var maxCount = info.maxCount || MAX_COUNT;
- var isFixedCount = minCount === maxCount; // 是否限定死了个数
- var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
- var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
- var avgCount = (minCount + maxCount) / 2;
- var count = avgCount; // 用户传入的逼近数组
- var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
- if (min === minLimit && max === maxLimit && isFixedCount) {
- interval = (max - min) / (count - 1);
- }
- if (isNil(min)) {
- min = 0;
- }
- if (isNil(max)) {
- max = 0;
- }
- if (Math.abs(max - min) < EPS) {
- if (min === 0) {
- max = 1;
- } else {
- if (min > 0) {
- min = 0;
- } else {
- max = 0;
- }
- }
- if (max - min < 5 && !interval && max - min >= 1) {
- interval = 1;
- }
- }
- if (isNil(interval)) {
- // 计算间距
- var temp = (max - min) / (avgCount - 1);
- interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
- if (maxCount !== minCount) {
- count = parseInt((max - min) / interval, 10);
- if (count > maxCount) {
- count = maxCount;
- }
- if (count < minCount) {
- count = minCount;
- } // 不确定tick的个数时,使得tick偏小
- interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
- }
- } // interval should not be less than minTickInterval
- if (isNumber(minTickInterval) && interval < minTickInterval) {
- interval = minTickInterval;
- }
- if (info.interval || maxCount !== minCount) {
- // 校正 max 和 min
- max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
- min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
- count = Math.round((max - min) / interval);
- min = AutoUtil.fixedBase(min, interval);
- max = AutoUtil.fixedBase(max, interval);
- } else {
- avgCount = parseInt(avgCount, 10); // 取整
- var avg = (max + min) / 2;
- var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
- var sideCount = Math.floor((avgCount - 2) / 2);
- var maxTick = avgTick + sideCount * interval;
- var minTick;
- if (avgCount % 2 === 0) {
- minTick = avgTick - sideCount * interval;
- } else {
- minTick = avgTick - (sideCount + 1) * interval;
- }
- var prevMaxTick = null; // 如果减去intervl, fixBase后,新的minTick没有大于之前的值,就退出,防止死循环
- while (maxTick < max && (prevMaxTick === null || maxTick > prevMaxTick)) {
- // 保证计算出来的刻度最大值 maxTick 不小于数据最大值 max
- prevMaxTick = maxTick;
- maxTick = AutoUtil.fixedBase(maxTick + interval, interval);
- }
- var prevMinTick = null; // 如果减去intervl, fixBase后,新的minTick没有小于之前的值,就退出,防止死循环
- while (minTick > min && (prevMinTick === null || minTick < prevMinTick)) {
- // 保证计算出来的刻度最小值 minTick 不小于数据最大值 min
- prevMinTick = minTick;
- minTick = AutoUtil.fixedBase(minTick - interval, interval); // 防止超常浮点数计算问题
- }
- max = maxTick;
- min = minTick;
- }
- max = Math.min(max, maxLimit);
- min = Math.max(min, minLimit);
- ticks.push(min);
- for (var i = 1; i < count; i++) {
- var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
- if (tickValue < max) {
- ticks.push(tickValue);
- }
- }
- if (ticks[ticks.length - 1] < max) {
- ticks.push(max);
- }
- return {
- min: min,
- max: max,
- interval: interval,
- count: count,
- ticks: ticks
- };
- };
- /***/ }),
- /* 171 */
- /***/ (function(module, exports) {
- /**
- * @fileOverview 计算方法
- * @author dxq613@gmail.com
- */
- // 如果小数点后面超过 10 位浮点数时进行一下处理
- var DECIMAL_LENGTH = 12; // 获取系数
- function getFactor(v) {
- var factor = 1;
- if (v === Infinity || v === -Infinity) {
- throw new Error('Not support Infinity!');
- }
- if (v < 1) {
- var count = 0;
- while (v < 1) {
- factor = factor / 10;
- v = v * 10;
- count++;
- } // 浮点数计算出现问题
- if (factor.toString().length > DECIMAL_LENGTH) {
- factor = parseFloat(factor.toFixed(count));
- }
- } else {
- while (v > 10) {
- factor = factor * 10;
- v = v / 10;
- }
- }
- return factor;
- } // 取小于当前值的
- function arrayFloor(values, value) {
- var length = values.length;
- if (length === 0) {
- return NaN;
- }
- var pre = values[0];
- if (value < values[0]) {
- return NaN;
- }
- if (value >= values[length - 1]) {
- return values[length - 1];
- }
- for (var i = 1; i < values.length; i++) {
- if (value < values[i]) {
- break;
- }
- pre = values[i];
- }
- return pre;
- } // 大于当前值的第一个
- function arrayCeiling(values, value) {
- var length = values.length;
- if (length === 0) {
- return NaN;
- } // var pre = values[0];
- var rst;
- if (value > values[length - 1]) {
- return NaN;
- }
- if (value < values[0]) {
- return values[0];
- }
- for (var i = 1; i < values.length; i++) {
- if (value <= values[i]) {
- rst = values[i];
- break;
- }
- }
- return rst;
- }
- var Util = {
- // 获取逼近的数值
- snapFactorTo: function snapFactorTo(v, arr, snapType) {
- // 假设 v = -512,isFloor = true
- if (isNaN(v)) {
- return NaN;
- }
- var factor = 1; // 计算系数
- if (v !== 0) {
- if (v < 0) {
- factor = -1;
- }
- v = v * factor; // v = 512
- var tmpFactor = getFactor(v);
- factor = factor * tmpFactor; // factor = -100
- v = v / tmpFactor; // v = 5.12
- }
- if (snapType === 'floor') {
- v = Util.snapFloor(arr, v); // v = 5
- } else if (snapType === 'ceil') {
- v = Util.snapCeiling(arr, v); // v = 6
- } else {
- v = Util.snapTo(arr, v); // 四舍五入 5
- }
- var rst = parseFloat((v * factor).toPrecision(DECIMAL_LENGTH)); // 如果出现浮点数计算问题,需要处理一下
- // 如果出现浮点数计算问题,需要处理一下
- if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
- var decimalVal = parseInt(1 / factor);
- var symbol = factor > 0 ? 1 : -1;
- rst = v / decimalVal * symbol;
- }
- return rst;
- },
- // 获取逼近的倍数
- snapMultiple: function snapMultiple(v, base, snapType) {
- var div;
- if (snapType === 'ceil') {
- div = Math.ceil(v / base);
- } else if (snapType === 'floor') {
- div = Math.floor(v / base);
- } else {
- div = Math.round(v / base);
- }
- return div * base;
- },
- /**
- * 获取逼近的值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的值
- */
- snapTo: function snapTo(values, value) {
- // 这里假定values是升序排列
- var floorVal = arrayFloor(values, value);
- var ceilingVal = arrayCeiling(values, value);
- if (isNaN(floorVal) || isNaN(ceilingVal)) {
- if (values[0] >= value) {
- return values[0];
- }
- var last = values[values.length - 1];
- if (last <= value) {
- return last;
- }
- }
- if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
- return floorVal;
- }
- return ceilingVal;
- },
- /**
- * 获取逼近的最小值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的最小值
- */
- snapFloor: function snapFloor(values, value) {
- // 这里假定values是升序排列
- return arrayFloor(values, value);
- },
- /**
- * 获取逼近的最大值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的最大值
- */
- snapCeiling: function snapCeiling(values, value) {
- // 这里假定values是升序排列
- return arrayCeiling(values, value);
- },
- fixedBase: function fixedBase(v, base) {
- var str = base.toString();
- var index = str.indexOf('.');
- var indexOfExp = str.indexOf('e-'); // 判断是否带小数点,1.000001 1.23e-9
- if (index < 0 && indexOfExp < 0) {
- // base为整数
- return Math.round(v);
- }
- var length = indexOfExp >= 0 ? parseInt(str.substr(indexOfExp + 2), 10) : str.substr(index + 1).length;
- if (length > 20) {
- length = 20;
- }
- return parseFloat(v.toFixed(length));
- }
- };
- module.exports = Util;
- /***/ }),
- /* 172 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(26);
- var isNumber = __webpack_require__(36);
- var Identity = /*#__PURE__*/function (_Base) {
- _inheritsLoose(Identity, _Base);
- function Identity() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Identity.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- this.isIdentity = true;
- this.type = 'identity';
- /**
- * 常量值
- * @type {*}
- */
- this.value = null;
- }
- /**
- * @override
- */
- ;
- _proto.getText = function getText() {
- return this.value.toString();
- }
- /**
- * @override
- */
- ;
- _proto.scale = function scale(value) {
- if (this.value !== value && isNumber(value)) {
- return value;
- }
- return this.range[0];
- }
- /**
- * @override
- */
- ;
- _proto.invert = function invert() {
- return this.value;
- };
- return Identity;
- }(Base);
- Base.Identity = Identity;
- module.exports = Identity;
- /***/ }),
- /* 173 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Axis = __webpack_require__(174);
- var Global = __webpack_require__(6);
- var _require = __webpack_require__(16),
- Shape = _require.Shape;
- function formatTicks(ticks) {
- var tmp = ticks.slice(0);
- if (tmp.length > 0) {
- var first = tmp[0];
- var last = tmp[tmp.length - 1];
- if (first.value !== 0) {
- tmp.unshift({
- value: 0
- });
- }
- if (last.value !== 1) {
- tmp.push({
- value: 1
- });
- }
- }
- return tmp;
- }
- var AxisController = /*#__PURE__*/function () {
- function AxisController(cfg) {
- this.axisCfg = {};
- this.frontPlot = null;
- this.backPlot = null;
- this.axes = {}; // store the axes's options
- Util.mix(this, cfg);
- }
- var _proto = AxisController.prototype;
- _proto._isHide = function _isHide(field) {
- var axisCfg = this.axisCfg;
- return !axisCfg || axisCfg[field] === false;
- };
- _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
- var position = '';
- var field = scale.field;
- var axisCfg = this.axisCfg;
- if (axisCfg[field] && axisCfg[field].position) {
- position = axisCfg[field].position;
- } else if (dimType === 'x') {
- position = transposed ? 'left' : 'bottom';
- } else if (dimType === 'y') {
- position = index ? 'right' : 'left';
- if (transposed) {
- position = 'bottom';
- }
- }
- return position;
- };
- _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
- var start;
- var end;
- var factor = 1; // Mark clockwise or counterclockwise
- if (dimType === 'x') {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 1,
- y: 0
- };
- } else {
- if (position === 'right') {
- // there will be several y axes
- start = {
- x: 1,
- y: 0
- };
- end = {
- x: 1,
- y: 1
- };
- } else {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 0,
- y: 1
- };
- factor = -1;
- }
- }
- if (coord.transposed) {
- factor *= -1;
- }
- return {
- offsetFactor: factor,
- start: coord.convertPoint(start),
- end: coord.convertPoint(end)
- };
- };
- _proto._getCircleCfg = function _getCircleCfg(coord) {
- return {
- startAngle: coord.startAngle,
- endAngle: coord.endAngle,
- center: coord.center,
- radius: coord.circleRadius
- };
- };
- _proto._getRadiusCfg = function _getRadiusCfg(coord) {
- var transposed = coord.transposed;
- var start;
- var end;
- if (transposed) {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 1,
- y: 0
- };
- } else {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 0,
- y: 1
- };
- }
- return {
- offsetFactor: -1,
- start: coord.convertPoint(start),
- end: coord.convertPoint(end)
- };
- };
- _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
- var self = this;
- var axisCfg = this.axisCfg;
- var ticks = scale.getTicks();
- var cfg = Util.deepMix({
- ticks: ticks,
- frontContainer: this.frontPlot,
- backContainer: this.backPlot
- }, defaultCfg, axisCfg[scale.field]);
- var labels = [];
- var label = cfg.label;
- var count = ticks.length;
- var maxWidth = 0;
- var maxHeight = 0;
- var labelCfg = label;
- Util.each(ticks, function (tick, index) {
- if (Util.isFunction(label)) {
- var executedLabel = label(tick.text, index, count);
- labelCfg = executedLabel ? Util.mix({}, Global._defaultAxis.label, executedLabel) : null;
- }
- if (labelCfg) {
- var textStyle = {};
- if (labelCfg.textAlign) {
- textStyle.textAlign = labelCfg.textAlign;
- }
- if (labelCfg.textBaseline) {
- textStyle.textBaseline = labelCfg.textBaseline;
- }
- var axisLabel = new Shape.Text({
- className: 'axis-label',
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: tick.text,
- fontFamily: self.chart.get('canvas').get('fontFamily')
- }, labelCfg),
- value: tick.value,
- textStyle: textStyle,
- top: labelCfg.top,
- context: self.chart.get('canvas').get('context')
- });
- labels.push(axisLabel);
- var _axisLabel$getBBox = axisLabel.getBBox(),
- width = _axisLabel$getBBox.width,
- height = _axisLabel$getBBox.height;
- maxWidth = Math.max(maxWidth, width);
- maxHeight = Math.max(maxHeight, height);
- }
- });
- cfg.labels = labels;
- cfg.maxWidth = maxWidth;
- cfg.maxHeight = maxHeight;
- return cfg;
- };
- _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
- if (index === void 0) {
- index = '';
- }
- var self = this;
- var coordType = coord.type;
- var transposed = coord.transposed;
- var type;
- var key;
- var defaultCfg;
- if (coordType === 'cartesian' || coordType === 'rect') {
- var position = self._getLinePosition(scale, dimType, index, transposed);
- defaultCfg = Global.axis[position];
- defaultCfg.position = position;
- type = 'Line';
- key = position;
- } else {
- if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
- defaultCfg = Global.axis.circle;
- type = 'Circle';
- key = 'circle';
- } else {
- defaultCfg = Global.axis.radius;
- type = 'Line';
- key = 'radius';
- }
- }
- var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
- cfg.type = type;
- cfg.dimType = dimType;
- cfg.verticalScale = verticalScale;
- cfg.index = index;
- this.axes[key] = cfg;
- };
- _proto.createAxis = function createAxis(coord, xScale, yScales) {
- var self = this;
- if (xScale && !self._isHide(xScale.field)) {
- self._createAxis(coord, xScale, yScales[0], 'x');
- }
- Util.each(yScales, function (yScale, index) {
- if (!self._isHide(yScale.field)) {
- self._createAxis(coord, yScale, xScale, 'y', index);
- }
- });
- var axes = this.axes;
- var chart = self.chart;
- if (chart._isAutoPadding()) {
- var userPadding = Util.parsePadding(chart.get('padding'));
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- var legendRange = chart.get('legendRange') || {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- var padding = [userPadding[0] === 'auto' ? legendRange.top + appendPadding[0] * 2 : userPadding[0], userPadding[1] === 'auto' ? legendRange.right + appendPadding[1] : userPadding[1], userPadding[2] === 'auto' ? legendRange.bottom + appendPadding[2] : userPadding[2], userPadding[3] === 'auto' ? legendRange.left + appendPadding[3] : userPadding[3]];
- if (coord.isPolar) {
- var circleAxis = axes.circle;
- if (circleAxis) {
- var maxHeight = circleAxis.maxHeight,
- maxWidth = circleAxis.maxWidth,
- labelOffset = circleAxis.labelOffset;
- padding[0] += maxHeight + labelOffset;
- padding[1] += maxWidth + labelOffset;
- padding[2] += maxHeight + labelOffset;
- padding[3] += maxWidth + labelOffset;
- }
- } else {
- if (axes.right && userPadding[1] === 'auto') {
- var _axes$right = axes.right,
- _maxWidth = _axes$right.maxWidth,
- _labelOffset = _axes$right.labelOffset;
- padding[1] += _maxWidth + _labelOffset;
- }
- if (axes.left && userPadding[3] === 'auto') {
- var _axes$left = axes.left,
- _maxWidth2 = _axes$left.maxWidth,
- _labelOffset2 = _axes$left.labelOffset;
- padding[3] += _maxWidth2 + _labelOffset2;
- }
- if (axes.bottom && userPadding[2] === 'auto') {
- var _axes$bottom = axes.bottom,
- _maxHeight = _axes$bottom.maxHeight,
- _labelOffset3 = _axes$bottom.labelOffset;
- padding[2] += _maxHeight + _labelOffset3;
- }
- }
- chart.set('_padding', padding);
- chart._updateLayout(padding);
- }
- Util.each(axes, function (axis) {
- var type = axis.type,
- grid = axis.grid,
- verticalScale = axis.verticalScale,
- ticks = axis.ticks,
- dimType = axis.dimType,
- position = axis.position,
- index = axis.index;
- var appendCfg;
- if (coord.isPolar) {
- if (type === 'Line') {
- appendCfg = self._getRadiusCfg(coord);
- } else if (type === 'Circle') {
- appendCfg = self._getCircleCfg(coord);
- }
- } else {
- appendCfg = self._getLineCfg(coord, dimType, position);
- }
- if (grid && verticalScale) {
- var gridPoints = [];
- var verticalTicks = formatTicks(verticalScale.getTicks());
- Util.each(ticks, function (tick) {
- var subPoints = [];
- Util.each(verticalTicks, function (verticalTick) {
- var x = dimType === 'x' ? tick.value : verticalTick.value;
- var y = dimType === 'x' ? verticalTick.value : tick.value;
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- subPoints.push(point);
- }
- });
- gridPoints.push({
- points: subPoints,
- _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
- });
- });
- axis.gridPoints = gridPoints;
- if (coord.isPolar) {
- axis.center = coord.center;
- axis.startAngle = coord.startAngle;
- axis.endAngle = coord.endAngle;
- }
- }
- appendCfg._id = 'axis-' + dimType;
- if (!Util.isNil(index)) {
- appendCfg._id = 'axis-' + dimType + index;
- }
- new Axis[type](Util.mix(axis, appendCfg));
- });
- };
- _proto.clear = function clear() {
- this.axes = {};
- this.frontPlot.clear();
- this.backPlot.clear();
- };
- return AxisController;
- }();
- module.exports = AxisController;
- /***/ }),
- /* 174 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Abstract = __webpack_require__(45);
- __webpack_require__(175);
- module.exports = Abstract;
- /***/ }),
- /* 175 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Abstract = __webpack_require__(45);
- var Line = /*#__PURE__*/function (_Abstract) {
- (0, _inheritsLoose2["default"])(Line, _Abstract);
- var _super = _createSuper(Line);
- function Line() {
- return _Abstract.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Abstract.prototype._initDefaultCfg.call(this);
- this.start = null;
- this.end = null;
- };
- _proto.getOffsetPoint = function getOffsetPoint(value) {
- var start = this.start,
- end = this.end;
- return {
- x: start.x + (end.x - start.x) * value,
- y: start.y + (end.y - start.y) * value
- };
- };
- _proto.getAxisVector = function getAxisVector() {
- var start = this.start,
- end = this.end;
- return [end.x - start.x, end.y - start.y];
- };
- _proto.drawLine = function drawLine(lineCfg) {
- var container = this.getContainer(lineCfg.top);
- var start = this.start,
- end = this.end;
- container.addShape('line', {
- className: 'axis-line',
- attrs: Util.mix({
- x1: start.x,
- y1: start.y,
- x2: end.x,
- y2: end.y
- }, lineCfg)
- });
- };
- return Line;
- }(Abstract);
- Abstract.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 176 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _emit = _interopRequireDefault(__webpack_require__(42));
- var _controller = _interopRequireDefault(__webpack_require__(177));
- var _canvasElement = _interopRequireDefault(__webpack_require__(178));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Container = __webpack_require__(66);
- var Group = __webpack_require__(67);
- var _require = __webpack_require__(70),
- requestAnimationFrame = _require.requestAnimationFrame;
- var Canvas = /*#__PURE__*/function (_EventEmit) {
- (0, _inheritsLoose2["default"])(Canvas, _EventEmit);
- var _super = _createSuper(Canvas);
- var _proto = Canvas.prototype;
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- function Canvas(cfg) {
- var _this;
- _this = _EventEmit.call(this) || this;
- _this._attrs = Util.mix({
- type: 'canvas',
- children: []
- }, cfg);
- _this._initPixelRatio();
- _this._initCanvas();
- return _this;
- }
- _proto._initPixelRatio = function _initPixelRatio() {
- var pixelRatio = this.get('pixelRatio');
- if (!pixelRatio) {
- this.set('pixelRatio', Util.getPixelRatio());
- }
- };
- _proto.beforeDraw = function beforeDraw() {
- var context = this._attrs.context;
- var el = this._attrs.el;
- context && context.clearRect && context.clearRect(0, 0, el.width, el.height);
- };
- _proto._initCanvas = function _initCanvas() {
- var self = this;
- var el = self.get('el');
- var context = self.get('context');
- if (!el && !context) {
- throw new Error('Please specify the id, el or context of the chart!');
- }
- var canvas;
- if (el) {
- // DOMElement or String
- canvas = Util.isString(el) ? Util.getDomById(el) : el;
- } else {
- // 说明没有指定el
- canvas = _canvasElement["default"].create(context);
- }
- if (context && canvas && !canvas.getContext) {
- canvas.getContext = function () {
- return context;
- };
- }
- var width = self.get('width');
- if (!width) {
- width = Util.getWidth(canvas);
- }
- var height = self.get('height');
- if (!height) {
- height = Util.getHeight(canvas);
- }
- self.set('canvas', this);
- self.set('el', canvas);
- self.set('context', context || canvas.getContext('2d'));
- self.changeSize(width, height); // 初始化事件控制器
- var eventController = new _controller["default"]({
- canvas: this,
- el: canvas
- });
- self.set('eventController', eventController);
- };
- _proto.changeSize = function changeSize(width, height) {
- var pixelRatio = this.get('pixelRatio');
- var canvasDOM = this.get('el'); // HTMLCanvasElement or canvasElement
- // 浏览器环境设置style样式
- if (canvasDOM.style) {
- canvasDOM.style.width = width + 'px';
- canvasDOM.style.height = height + 'px';
- }
- if (Util.isCanvasElement(canvasDOM)) {
- canvasDOM.width = width * pixelRatio;
- canvasDOM.height = height * pixelRatio;
- if (pixelRatio !== 1) {
- var ctx = this.get('context');
- ctx.scale(pixelRatio, pixelRatio);
- }
- }
- this.set('width', width);
- this.set('height', height);
- };
- _proto.getWidth = function getWidth() {
- var pixelRatio = this.get('pixelRatio');
- var width = this.get('width');
- return width * pixelRatio;
- };
- _proto.getHeight = function getHeight() {
- var pixelRatio = this.get('pixelRatio');
- var height = this.get('height');
- return height * pixelRatio;
- };
- _proto.getPointByClient = function getPointByClient(clientX, clientY) {
- var el = this.get('el');
- var bbox = el.getBoundingClientRect();
- var width = bbox.right - bbox.left;
- var height = bbox.bottom - bbox.top;
- return {
- x: (clientX - bbox.left) * (el.width / width),
- y: (clientY - bbox.top) * (el.height / height)
- };
- };
- _proto._beginDraw = function _beginDraw() {
- this._attrs.toDraw = true;
- };
- _proto._endDraw = function _endDraw() {
- this._attrs.toDraw = false;
- };
- _proto.draw = function draw() {
- var self = this;
- function drawInner() {
- self.set('animateHandler', requestAnimationFrame(function () {
- self.set('animateHandler', undefined);
- if (self.get('toDraw')) {
- drawInner();
- }
- }));
- self.beforeDraw();
- try {
- var context = self._attrs.context;
- var children = self._attrs.children;
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child.draw(context);
- } // 支付宝,微信小程序,需要调context.draw才能完成绘制, 所以这里直接判断是否有.draw方法
- if (context.draw) {
- context.draw();
- }
- } catch (ev) {
- console.warn('error in draw canvas, detail as:');
- console.warn(ev);
- self._endDraw();
- }
- self._endDraw();
- }
- if (self.get('destroyed')) {
- return;
- }
- if (self.get('animateHandler')) {
- this._beginDraw();
- } else {
- drawInner();
- }
- };
- _proto.destroy = function destroy() {
- if (this.get('destroyed')) {
- return;
- } // 需要清理 canvas 画布内容,否则会导致 spa 应用 ios 下 canvas 白屏
- // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12
- // https://github.com/antvis/F2/issues/630
- var el = this.get('el');
- el.width = 0;
- el.height = 0;
- this.clear();
- this._attrs = {};
- this.set('destroyed', true);
- };
- _proto.isDestroyed = function isDestroyed() {
- return this.get('destroyed');
- };
- return Canvas;
- }(_emit["default"]);
- Util.mix(Canvas.prototype, Container, {
- getGroupClass: function getGroupClass() {
- return Group;
- }
- });
- module.exports = Canvas;
- /***/ }),
- /* 177 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports["default"] = void 0;
- var _dom = __webpack_require__(62);
- var _common = __webpack_require__(0);
- // 计算滑动的方向
- var calcDirection = function calcDirection(start, end) {
- var xDistance = end.x - start.x;
- var yDistance = end.y - start.y; // x 的距离大于y 说明是横向,否则就是纵向
- if (Math.abs(xDistance) > Math.abs(yDistance)) {
- return xDistance > 0 ? 'right' : 'left';
- }
- return yDistance > 0 ? 'down' : 'up';
- }; // 计算2点之间的距离
- var calcDistance = function calcDistance(point1, point2) {
- var xDistance = Math.abs(point2.x - point1.x);
- var yDistance = Math.abs(point2.y - point1.y);
- return Math.sqrt(xDistance * xDistance + yDistance * yDistance);
- };
- var getCenter = function getCenter(point1, point2) {
- var x = point1.x + (point2.x - point1.x) / 2;
- var y = point1.y + (point2.y - point1.y) / 2;
- return {
- x: x,
- y: y
- };
- };
- var convertPoints = function convertPoints(touches, canvas) {
- if (!touches) return;
- var points = [];
- var len = touches.length;
- for (var i = 0; i < len; i++) {
- var touch = touches[i]; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
- var x = touch.x,
- y = touch.y,
- clientX = touch.clientX,
- clientY = touch.clientY;
- var point = void 0; // 小程序环境会有x,y
- if ((0, _common.isNumber)(x) || (0, _common.isNumber)(y)) {
- point = {
- x: x,
- y: y
- };
- } else {
- // 浏览器环境再计算下canvas的相对位置
- point = (0, _dom.getRelativePosition)({
- x: clientX,
- y: clientY
- }, canvas);
- }
- points.push(point);
- }
- return points;
- };
- var PRESS_DELAY = 250;
- var EventController = /*#__PURE__*/function () {
- function EventController(_ref) {
- var _this = this;
- var canvas = _ref.canvas,
- el = _ref.el;
- this._click = function (ev) {
- _this.emitEvent('click', ev);
- };
- this._start = function (ev) {
- var points = convertPoints(ev.touches, _this.canvas);
- if (!points) {
- return;
- }
- ev.points = points;
- _this.emitEvent('touchstart', ev); // 防止上次的内容没有清理掉,重新reset下
- _this.reset(); // 记录touch start 的时间
- _this.startTime = Date.now(); // 记录touch start 的点
- _this.startPoints = points;
- if (points.length > 1) {
- _this.startDistance = calcDistance(points[0], points[1]);
- _this.center = getCenter(points[0], points[1]);
- } else {
- // 如果touchstart后停顿250ms, 则也触发press事件
- _this.pressTimeout = setTimeout(function () {
- // 这里固定触发press事件
- var eventType = 'press';
- ev.direction = 'none';
- _this.emitStart(eventType, ev);
- _this.emitEvent(eventType, ev);
- _this.eventType = eventType;
- }, PRESS_DELAY);
- }
- };
- this._move = function (ev) {
- var points = convertPoints(ev.touches, _this.canvas);
- if (!points) return;
- _this.clearPressTimeout();
- ev.points = points;
- _this.emitEvent('touchmove', ev);
- var startPoints = _this.startPoints;
- if (!startPoints) return; // 多指触控
- if (points.length > 1) {
- // touchstart的距离
- var startDistance = _this.startDistance;
- var currentDistance = calcDistance(points[0], points[1]);
- ev.zoom = currentDistance / startDistance;
- ev.center = _this.center; // 触发缩放事件
- _this.emitStart('pinch', ev);
- _this.emitEvent('pinch', ev);
- } else {
- var deltaX = points[0].x - startPoints[0].x;
- var deltaY = points[0].y - startPoints[0].y;
- var direction = _this.direction || calcDirection(startPoints[0], points[0]);
- _this.direction = direction; // 获取press或者pan的事件类型
- // press 按住滑动, pan表示平移
- // 如果start后立刻move,则触发pan, 如果有停顿,则触发press
- var eventType = _this.getEventType(points);
- ev.direction = direction;
- ev.deltaX = deltaX;
- ev.deltaY = deltaY;
- _this.emitStart(eventType, ev);
- _this.emitEvent(eventType, ev); // 记录最后2次move的时间和坐标,为了给swipe事件用
- var prevMoveTime = _this.lastMoveTime;
- var now = Date.now(); // 最后2次的时间间隔一定要大于0,否则swipe没发计算
- if (now - prevMoveTime > 0) {
- _this.prevMoveTime = prevMoveTime;
- _this.prevMovePoints = _this.lastMovePoints;
- _this.lastMoveTime = now;
- _this.lastMovePoints = points;
- }
- }
- };
- this._end = function (ev) {
- _this.emitEnd(ev);
- _this.emitEvent('touchend', ev); // swipe事件处理, 在touchend之后触发
- var lastMoveTime = _this.lastMoveTime;
- var now = Date.now(); // 做这个判断是为了最后一次touchmove后到end前,还有一个停顿的过程
- // 100 是拍的一个值,理论这个值会很短,一般不卡顿的话在10ms以内
- if (now - lastMoveTime < 100) {
- var prevMoveTime = _this.prevMoveTime || _this.startTime;
- var intervalTime = lastMoveTime - prevMoveTime; // 时间间隔一定要大于0, 否则计算没意义
- if (intervalTime > 0) {
- var prevMovePoints = _this.prevMovePoints || _this.startPoints;
- var lastMovePoints = _this.lastMovePoints; // move速率
- var velocity = calcDistance(prevMovePoints[0], lastMovePoints[0]) / intervalTime; // 0.3 是参考hammerjs的设置
- if (velocity > 0.3) {
- ev.velocity = velocity;
- ev.direction = calcDirection(prevMovePoints[0], lastMovePoints[0]);
- _this.emitEvent('swipe', ev);
- }
- }
- }
- _this.reset();
- var touches = ev.touches; // 当多指只释放了1指时也会触发end, 这时重新触发一次start
- if (touches && touches.length > 0) {
- _this._start(ev);
- }
- };
- this._cancel = function (ev) {
- _this.emitEvent('touchcancel', ev);
- _this.reset();
- };
- // canvasEl
- this.canvas = canvas;
- this.delegateEvent(el); // 用来记录当前触发的事件
- this.processEvent = {};
- }
- var _proto = EventController.prototype;
- _proto.delegateEvent = function delegateEvent(canvasEl) {
- // 代理这几个事件
- canvasEl.addEventListener('click', this._click);
- canvasEl.addEventListener('touchstart', this._start);
- canvasEl.addEventListener('touchmove', this._move);
- canvasEl.addEventListener('touchend', this._end);
- canvasEl.addEventListener('touchcancel', this._cancel);
- };
- _proto.emitEvent = function emitEvent(type, ev) {
- var canvas = this.canvas;
- canvas.emit(type, ev);
- };
- _proto.getEventType = function getEventType(points) {
- var eventType = this.eventType,
- canvas = this.canvas,
- startTime = this.startTime,
- startPoints = this.startPoints;
- if (eventType) {
- return eventType;
- }
- var type;
- var panEventListeners = canvas.__events.pan; // 如果没有pan事件的监听,默认都是press
- if (!panEventListeners || !panEventListeners.length) {
- type = 'press';
- } else {
- // 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
- var now = Date.now();
- if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], points[0]) < 10) {
- type = 'press';
- } else {
- type = 'pan';
- }
- }
- this.eventType = type;
- return type;
- };
- _proto.enable = function enable(eventType) {
- this.processEvent[eventType] = true;
- } // 是否进行中的事件
- ;
- _proto.isProcess = function isProcess(eventType) {
- return this.processEvent[eventType];
- } // 触发start事件
- ;
- _proto.emitStart = function emitStart(type, ev) {
- if (this.isProcess(type)) {
- return;
- }
- this.enable(type);
- this.emitEvent(type + "start", ev);
- } // 触发end事件
- ;
- _proto.emitEnd = function emitEnd(ev) {
- var _this2 = this;
- var processEvent = this.processEvent;
- Object.keys(processEvent).forEach(function (type) {
- _this2.emitEvent(type + "end", ev);
- delete processEvent[type];
- });
- };
- _proto.clearPressTimeout = function clearPressTimeout() {
- if (this.pressTimeout) {
- clearTimeout(this.pressTimeout);
- this.pressTimeout = 0;
- }
- };
- _proto.reset = function reset() {
- this.clearPressTimeout();
- this.startTime = 0;
- this.startPoints = null;
- this.startDistance = 0;
- this.direction = null;
- this.eventType = null;
- this.pinch = false;
- this.prevMoveTime = 0;
- this.prevMovePoints = null;
- this.lastMoveTime = 0;
- this.lastMovePoints = null;
- };
- return EventController;
- }();
- var _default = EventController;
- exports["default"] = _default;
- /***/ }),
- /* 178 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- exports.__esModule = true;
- exports["default"] = void 0;
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- var _emit = _interopRequireDefault(__webpack_require__(42));
- 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); }; }
- 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; } }
- var CanvasElement = /*#__PURE__*/function (_EventEmit) {
- (0, _inheritsLoose2["default"])(CanvasElement, _EventEmit);
- var _super = _createSuper(CanvasElement);
- function CanvasElement(ctx) {
- var _this;
- _this = _EventEmit.call(this) || this;
- _this.context = ctx; // canvas实际的宽高 (width/height) * pixelRatio
- _this.width = 0;
- _this.height = 0;
- _this.style = {};
- _this.currentStyle = {}; // 用来标识是CanvasElement实例
- _this.isCanvasElement = true;
- return _this;
- }
- var _proto = CanvasElement.prototype;
- _proto.getContext = function getContext()
- /* type */
- {
- return this.context;
- };
- _proto.getBoundingClientRect = function getBoundingClientRect() {
- var width = this.width;
- var height = this.height; // 默认都处理成可视窗口的顶部位置
- return {
- top: 0,
- right: width,
- bottom: height,
- left: 0
- };
- };
- _proto.addEventListener = function addEventListener(type, listener) {
- this.on(type, listener);
- };
- _proto.removeEventListener = function removeEventListener(type, listener) {
- this.off(type, listener);
- };
- _proto.dispatchEvent = function dispatchEvent(type, e) {
- this.emit(type, e);
- };
- return CanvasElement;
- }(_emit["default"]);
- function supportEventListener(canvas) {
- if (!canvas) {
- return false;
- } // 非 HTMLCanvasElement
- if (canvas.nodeType !== 1 || !canvas.nodeName || canvas.nodeName.toLowerCase() !== 'canvas') {
- return false;
- } // 微信小程序canvas.getContext('2d')时也是CanvasRenderingContext2D
- // 也会有ctx.canvas, 而且nodeType也是1,所以还要在看下是否支持addEventListener
- var support = false;
- try {
- canvas.addEventListener('eventTest', function () {
- support = true;
- });
- canvas.dispatchEvent(new Event('eventTest'));
- } catch (error) {
- support = false;
- }
- return support;
- }
- var _default = {
- create: function create(ctx) {
- if (!ctx) {
- return null;
- }
- if (supportEventListener(ctx.canvas)) {
- return ctx.canvas;
- }
- return new CanvasElement(ctx);
- }
- };
- exports["default"] = _default;
- /***/ }),
- /* 179 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- function _mod(n, m) {
- return (n % m + m) % m;
- }
- function _addStop(steps, gradient) {
- Util.each(steps, function (item) {
- item = item.split(':');
- gradient.addColorStop(Number(item[0]), item[1]);
- });
- } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
- function _parseLineGradient(color, shape, context) {
- var arr = color.split(' ');
- var angle = arr[0].slice(2, arr[0].length - 1);
- angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
- var steps = arr.slice(1);
- var _shape$getBBox = shape.getBBox(),
- minX = _shape$getBBox.minX,
- minY = _shape$getBBox.minY,
- maxX = _shape$getBBox.maxX,
- maxY = _shape$getBBox.maxY;
- var start;
- var end;
- if (angle >= 0 && angle < 0.5 * Math.PI) {
- start = {
- x: minX,
- y: minY
- };
- end = {
- x: maxX,
- y: maxY
- };
- } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
- start = {
- x: maxX,
- y: minY
- };
- end = {
- x: minX,
- y: maxY
- };
- } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
- start = {
- x: maxX,
- y: maxY
- };
- end = {
- x: minX,
- y: minY
- };
- } else {
- start = {
- x: minX,
- y: maxY
- };
- end = {
- x: maxX,
- y: minY
- };
- }
- var tanTheta = Math.tan(angle);
- var tanTheta2 = tanTheta * tanTheta;
- var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
- var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
- var gradient = context.createLinearGradient(start.x, start.y, x, y);
- _addStop(steps, gradient);
- return gradient;
- } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
- function _parseRadialGradient(color, shape, context) {
- var arr = color.split(' ');
- var circleCfg = arr[0].slice(2, arr[0].length - 1);
- circleCfg = circleCfg.split(',');
- var fx = parseFloat(circleCfg[0]);
- var fy = parseFloat(circleCfg[1]);
- var fr = parseFloat(circleCfg[2]);
- var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
- if (fr === 0) {
- var _color = steps[steps.length - 1];
- return _color.split(':')[1];
- }
- var _shape$getBBox2 = shape.getBBox(),
- width = _shape$getBBox2.width,
- height = _shape$getBBox2.height,
- minX = _shape$getBBox2.minX,
- minY = _shape$getBBox2.minY;
- var r = Math.sqrt(width * width + height * height) / 2;
- var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
- _addStop(steps, gradient);
- return gradient;
- }
- module.exports = {
- parseStyle: function parseStyle(color, shape, context) {
- if (color[1] === '(') {
- try {
- var firstCode = color[0];
- if (firstCode === 'l') {
- return _parseLineGradient(color, shape, context);
- } else if (firstCode === 'r') {
- return _parseRadialGradient(color, shape, context);
- }
- } catch (ev) {
- console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
- console.error(ev);
- }
- }
- return color;
- }
- };
- /***/ }),
- /* 180 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(10);
- var Rect = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Rect, _Shape);
- var _super = _createSuper(Rect);
- function Rect() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Rect.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'rect';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- radius: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- width = attrs.width,
- height = attrs.height;
- context.beginPath();
- var radius = attrs.radius;
- if (!radius || !(width * height)) {
- context.rect(x, y, width, height);
- } else {
- radius = Util.parsePadding(radius);
- context.moveTo(x + radius[0], y);
- context.lineTo(x + width - radius[1], y);
- context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
- context.lineTo(x + width, y + height - radius[2]);
- context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
- context.lineTo(x + radius[3], y + height);
- context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
- context.lineTo(x, y + radius[0]);
- context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
- context.closePath();
- }
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- width = attrs.width,
- height = attrs.height;
- return {
- minX: x,
- minY: y,
- maxX: x + width,
- maxY: y + height
- };
- };
- return Rect;
- }(Shape);
- Shape.Rect = Rect;
- module.exports = Rect;
- /***/ }),
- /* 181 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var Circle = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Circle, _Shape);
- var _super = _createSuper(Circle);
- function Circle() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Circle.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'circle';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- r: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r;
- context.beginPath();
- context.arc(x, y, r, 0, Math.PI * 2, false);
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r;
- return {
- minX: x - r,
- maxX: x + r,
- minY: y - r,
- maxY: y + r
- };
- };
- return Circle;
- }(Shape);
- Shape.Circle = Circle;
- module.exports = Circle;
- /***/ }),
- /* 182 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var bbox = __webpack_require__(21);
- var Line = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Line, _Shape);
- var _super = _createSuper(Line);
- function Line() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canStroke = true;
- this._attrs.type = 'line';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x1: 0,
- y1: 0,
- x2: 0,
- y2: 0,
- lineWidth: 1
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x1 = attrs.x1,
- y1 = attrs.y1,
- x2 = attrs.x2,
- y2 = attrs.y2;
- context.beginPath();
- context.moveTo(x1, y1);
- context.lineTo(x2, y2);
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x1 = attrs.x1,
- y1 = attrs.y1,
- x2 = attrs.x2,
- y2 = attrs.y2,
- lineWidth = attrs.lineWidth;
- return bbox.getBBoxFromLine(x1, y1, x2, y2, lineWidth);
- };
- return Line;
- }(Shape);
- Shape.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 183 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var bbox = __webpack_require__(21);
- var Polygon = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Polygon, _Shape);
- var _super = _createSuper(Polygon);
- function Polygon() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'polygon';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- points: null,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var points = attrs.points;
- context.beginPath();
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (i === 0) {
- context.moveTo(point.x, point.y);
- } else {
- context.lineTo(point.x, point.y);
- }
- }
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var points = attrs.points;
- return bbox.getBBoxFromPoints(points);
- };
- return Polygon;
- }(Shape);
- Shape.Polygon = Polygon;
- module.exports = Polygon;
- /***/ }),
- /* 184 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var Smooth = __webpack_require__(71);
- var bbox = __webpack_require__(21); // filter the point which x or y is NaN
- function _filterPoints(points) {
- var filteredPoints = [];
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (!isNaN(point.x) && !isNaN(point.y)) {
- filteredPoints.push(point);
- }
- }
- return filteredPoints;
- }
- var Polyline = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Polyline, _Shape);
- var _super = _createSuper(Polyline);
- function Polyline() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Polyline.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'polyline';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- points: null,
- lineWidth: 1,
- smooth: false
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var points = attrs.points,
- smooth = attrs.smooth;
- var filteredPoints = _filterPoints(points);
- context.beginPath();
- if (filteredPoints.length) {
- context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
- if (smooth) {
- var constaint = [[0, 0], [1, 1]];
- var sps = Smooth.smooth(filteredPoints, false, constaint);
- for (var i = 0, n = sps.length; i < n; i++) {
- var sp = sps[i];
- context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
- }
- } else {
- var _i;
- var l;
- for (_i = 1, l = filteredPoints.length - 1; _i < l; _i++) {
- context.lineTo(filteredPoints[_i].x, filteredPoints[_i].y);
- }
- context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
- }
- }
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var points = attrs.points,
- smooth = attrs.smooth,
- lineWidth = attrs.lineWidth;
- var filteredPoints = _filterPoints(points);
- if (smooth) {
- var newPoints = [];
- var constaint = [[0, 0], [1, 1]];
- var sps = Smooth.smooth(filteredPoints, false, constaint);
- for (var i = 0, n = sps.length; i < n; i++) {
- var sp = sps[i];
- if (i === 0) {
- newPoints.push([filteredPoints[0].x, filteredPoints[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
- } else {
- var lastPoint = sps[i - 1];
- newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
- }
- }
- return bbox.getBBoxFromBezierGroup(newPoints, lineWidth);
- }
- return bbox.getBBoxFromPoints(filteredPoints, lineWidth);
- };
- return Polyline;
- }(Shape);
- Shape.Polyline = Polyline;
- module.exports = Polyline;
- /***/ }),
- /* 185 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var bbox = __webpack_require__(21);
- var Arc = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Arc, _Shape);
- var _super = _createSuper(Arc);
- function Arc() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Arc.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canStroke = true;
- this._attrs.canFill = true;
- this._attrs.type = 'arc';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- r: 0,
- startAngle: 0,
- endAngle: Math.PI * 2,
- anticlockwise: false,
- lineWidth: 1
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- anticlockwise = attrs.anticlockwise;
- context.beginPath();
- if (startAngle !== endAngle) {
- context.arc(x, y, r, startAngle, endAngle, anticlockwise);
- }
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- anticlockwise = attrs.anticlockwise;
- return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
- };
- return Arc;
- }(Shape);
- Shape.Arc = Arc;
- module.exports = Arc;
- /***/ }),
- /* 186 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var bbox = __webpack_require__(21);
- var Sector = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Sector, _Shape);
- var _super = _createSuper(Sector);
- function Sector() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Sector.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'sector';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- lineWidth: 0,
- r: 0,
- r0: 0,
- startAngle: 0,
- endAngle: Math.PI * 2,
- anticlockwise: false
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- r = attrs.r,
- r0 = attrs.r0,
- anticlockwise = attrs.anticlockwise;
- context.beginPath();
- var unitX = Math.cos(startAngle);
- var unitY = Math.sin(startAngle);
- context.moveTo(unitX * r0 + x, unitY * r0 + y);
- context.lineTo(unitX * r + x, unitY * r + y); // 当扇形的角度非常小的时候,就不进行弧线的绘制;或者整个只有1个扇形时,会出现end<0的情况不绘制
- if (Math.abs(endAngle - startAngle) > 0.0001 || startAngle === 0 && endAngle < 0) {
- context.arc(x, y, r, startAngle, endAngle, anticlockwise);
- context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
- if (r0 !== 0) {
- context.arc(x, y, r0, endAngle, startAngle, !anticlockwise);
- }
- }
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- r0 = attrs.r0,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- anticlockwise = attrs.anticlockwise;
- var outerBBox = bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise);
- var innerBBox = bbox.getBBoxFromArc(x, y, r0, startAngle, endAngle, anticlockwise);
- return {
- minX: Math.min(outerBBox.minX, innerBBox.minX),
- minY: Math.min(outerBBox.minY, innerBBox.minY),
- maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
- maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
- };
- };
- return Sector;
- }(Shape);
- Shape.Sector = Sector;
- module.exports = Sector;
- /***/ }),
- /* 187 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(10);
- var RectUtil = __webpack_require__(188);
- var textWidthCacheCounter = 0;
- var textWidthCache = {};
- var TEXT_CACHE_MAX = 5000;
- var Text = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Text, _Shape);
- var _super = _createSuper(Text);
- function Text() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Text.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'text';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- lineWidth: 0,
- lineCount: 1,
- fontSize: 12,
- fontFamily: 'sans-serif',
- fontStyle: 'normal',
- fontWeight: 'normal',
- fontVariant: 'normal',
- textAlign: 'start',
- textBaseline: 'bottom',
- lineHeight: null,
- textArr: null
- };
- };
- _proto._getFontStyle = function _getFontStyle() {
- var attrs = this._attrs.attrs;
- var fontSize = attrs.fontSize,
- fontFamily = attrs.fontFamily,
- fontWeight = attrs.fontWeight,
- fontStyle = attrs.fontStyle,
- fontVariant = attrs.fontVariant;
- return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
- };
- _proto._afterAttrsSet = function _afterAttrsSet() {
- var attrs = this._attrs.attrs;
- attrs.font = this._getFontStyle();
- if (attrs.text) {
- var text = attrs.text;
- var textArr = null;
- var lineCount = 1;
- if (Util.isString(text) && text.indexOf('\n') !== -1) {
- textArr = text.split('\n');
- lineCount = textArr.length;
- }
- attrs.lineCount = lineCount;
- attrs.textArr = textArr;
- }
- this.set('attrs', attrs);
- };
- _proto._getTextHeight = function _getTextHeight() {
- var attrs = this._attrs.attrs;
- if (attrs.height) {
- return attrs.height;
- }
- var lineCount = attrs.lineCount;
- var fontSize = attrs.fontSize * 1;
- if (lineCount > 1) {
- var spaceingY = this._getSpaceingY();
- return fontSize * lineCount + spaceingY * (lineCount - 1);
- }
- return fontSize;
- };
- _proto._getSpaceingY = function _getSpaceingY() {
- var attrs = this._attrs.attrs;
- var lineHeight = attrs.lineHeight;
- var fontSize = attrs.fontSize * 1;
- return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
- };
- _proto.drawInner = function drawInner(context) {
- var self = this;
- var attrs = self._attrs.attrs;
- var text = attrs.text;
- var x = attrs.x;
- var y = attrs.y;
- if (Util.isNil(text) || isNaN(x) || isNaN(y)) {
- // text will be 0
- return;
- }
- var textArr = attrs.textArr;
- var fontSize = attrs.fontSize * 1;
- var spaceingY = self._getSpaceingY();
- if (attrs.rotate) {
- // do rotation
- context.translate(x, y);
- context.rotate(attrs.rotate);
- x = 0;
- y = 0;
- }
- var textBaseline = attrs.textBaseline;
- var height;
- if (textArr) {
- height = self._getTextHeight();
- }
- var subY; // context.beginPath();
- if (self.hasFill()) {
- var fillOpacity = attrs.fillOpacity;
- if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
- context.globalAlpha = fillOpacity;
- }
- if (textArr) {
- for (var i = 0, len = textArr.length; i < len; i++) {
- var subText = textArr[i];
- subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
- if (textBaseline === 'middle') {
- subY += height - fontSize - (height - fontSize) / 2;
- }
- if (textBaseline === 'top') {
- subY += height - fontSize;
- }
- context.fillText(subText, x, subY);
- }
- } else {
- context.fillText(text, x, y);
- }
- }
- if (self.hasStroke()) {
- if (textArr) {
- for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
- var _subText = textArr[_i];
- subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
- if (textBaseline === 'middle') {
- subY += height - fontSize - (height - fontSize) / 2;
- }
- if (textBaseline === 'top') {
- subY += height - fontSize;
- }
- context.strokeText(_subText, x, subY);
- }
- } else {
- context.strokeText(text, x, y);
- }
- }
- };
- _proto.calculateBox = function calculateBox() {
- var self = this;
- var attrs = self._attrs.attrs;
- var x = attrs.x,
- y = attrs.y,
- textAlign = attrs.textAlign,
- textBaseline = attrs.textBaseline;
- var width = self._getTextWidth(); // attrs.width
- if (!width) {
- return {
- minX: x,
- minY: y,
- maxX: x,
- maxY: y
- };
- }
- var height = self._getTextHeight(); // attrs.height
- if (attrs.rotate) {
- var rotatedBox = RectUtil.calcRotatedBox({
- width: width,
- height: height,
- rotate: attrs.rotate
- });
- width = rotatedBox.width;
- height = rotatedBox.height;
- }
- var point = {
- x: x,
- y: y - height
- }; // default textAlign: start, textBaseline: bottom
- if (textAlign) {
- if (textAlign === 'end' || textAlign === 'right') {
- point.x -= width;
- } else if (textAlign === 'center') {
- point.x -= width / 2;
- }
- }
- if (textBaseline) {
- if (textBaseline === 'top') {
- point.y += height;
- } else if (textBaseline === 'middle') {
- point.y += height / 2;
- }
- }
- return {
- minX: point.x,
- minY: point.y,
- maxX: point.x + width,
- maxY: point.y + height
- };
- };
- _proto._getTextWidth = function _getTextWidth() {
- var attrs = this._attrs.attrs;
- if (attrs.width) {
- return attrs.width;
- }
- var text = attrs.text;
- var context = this.get('context');
- if (Util.isNil(text)) return undefined;
- var font = attrs.font;
- var textArr = attrs.textArr;
- var key = text + '' + font;
- if (textWidthCache[key]) {
- return textWidthCache[key];
- }
- var width = 0;
- if (textArr) {
- for (var i = 0, length = textArr.length; i < length; i++) {
- var subText = textArr[i];
- width = Math.max(width, Util.measureText(subText, font, context).width);
- }
- } else {
- width = Util.measureText(text, font, context).width;
- }
- if (textWidthCacheCounter > TEXT_CACHE_MAX) {
- textWidthCacheCounter = 0;
- textWidthCache = {};
- }
- textWidthCacheCounter++;
- textWidthCache[key] = width;
- return width;
- };
- return Text;
- }(Shape);
- Shape.Text = Text;
- module.exports = Text;
- /***/ }),
- /* 188 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Rect = {
- calcRotatedBox: function calcRotatedBox(_ref) {
- var width = _ref.width,
- height = _ref.height,
- rotate = _ref.rotate;
- var absRotate = Math.abs(rotate);
- return {
- width: Math.abs(width * Math.cos(absRotate) + height * Math.sin(absRotate)),
- height: Math.abs(height * Math.cos(absRotate) + width * Math.sin(absRotate))
- };
- }
- };
- module.exports = Rect;
- /***/ }),
- /* 189 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Shape = __webpack_require__(10);
- var Custom = /*#__PURE__*/function (_Shape) {
- (0, _inheritsLoose2["default"])(Custom, _Shape);
- var _super = _createSuper(Custom);
- function Custom() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Custom.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.createPath = null;
- this._attrs.type = 'custom';
- };
- _proto.createPath = function createPath(context) {
- var createPath = this.get('createPath');
- createPath && createPath.call(this, context);
- };
- _proto.calculateBox = function calculateBox() {
- var calculateBox = this.get('calculateBox');
- return calculateBox && calculateBox.call(this);
- };
- return Custom;
- }(Shape);
- Shape.Custom = Custom;
- module.exports = Custom;
- /***/ }),
- /* 190 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Path = __webpack_require__(72);
- var Geom = __webpack_require__(17);
- __webpack_require__(68);
- var Line = /*#__PURE__*/function (_Path) {
- (0, _inheritsLoose2["default"])(Line, _Path);
- var _super = _createSuper(Line);
- function Line() {
- return _Path.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Path.prototype.getDefaultCfg.call(this);
- cfg.type = 'line';
- cfg.sortable = true;
- return cfg;
- };
- return Line;
- }(Path);
- Geom.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 191 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Geom = __webpack_require__(17);
- var Util = __webpack_require__(0);
- var SizeMixin = __webpack_require__(73);
- __webpack_require__(192);
- var Interval = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Interval, _Geom);
- var _super = _createSuper(Interval);
- var _proto = Interval.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'interval';
- cfg.shapeType = 'interval';
- cfg.generatePoints = true;
- return cfg;
- };
- function Interval(cfg) {
- var _this;
- _this = _Geom.call(this, cfg) || this;
- Util.mix((0, _assertThisInitialized2["default"])(_this), SizeMixin);
- return _this;
- }
- _proto.init = function init() {
- _Geom.prototype.init.call(this); // 绑定事件
- this.initEvent();
- };
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- cfg.size = this.getNormalizedSize(obj);
- return cfg;
- };
- _proto.clearInner = function clearInner() {
- _Geom.prototype.clearInner.call(this);
- this.set('defaultSize', null);
- };
- return Interval;
- }(Geom);
- Geom.Interval = Interval;
- module.exports = Interval;
- /***/ }),
- /* 192 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(19);
- var Vector2 = __webpack_require__(13);
- var Global = __webpack_require__(6);
- function getRectPoints(cfg) {
- var x = cfg.x,
- y = cfg.y,
- y0 = cfg.y0,
- size = cfg.size;
- var ymin = y0;
- var ymax = y;
- if (Util.isArray(y)) {
- ymax = y[1];
- ymin = y[0];
- }
- var xmin;
- var xmax;
- if (Util.isArray(x)) {
- xmin = x[0];
- xmax = x[1];
- } else {
- xmin = x - size / 2;
- xmax = x + size / 2;
- }
- return [{
- x: xmin,
- y: ymin
- }, {
- x: xmin,
- y: ymax
- }, {
- x: xmax,
- y: ymax
- }, {
- x: xmax,
- y: ymin
- }];
- }
- function getRectRange(points) {
- var xValues = [];
- var yValues = [];
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- xValues.push(point.x);
- yValues.push(point.y);
- }
- var xMin = Math.min.apply(null, xValues);
- var yMin = Math.min.apply(null, yValues);
- var xMax = Math.max.apply(null, xValues);
- var yMax = Math.max.apply(null, yValues);
- return {
- x: xMin,
- y: yMin,
- width: xMax - xMin,
- height: yMax - yMin
- };
- }
- function getMiddlePoint(a, b) {
- var x = (a.x - b.x) / 2 + b.x;
- var y = (a.y - b.y) / 2 + b.y;
- return {
- x: x,
- y: y
- };
- }
- var Interval = Shape.registerFactory('interval', {
- defaultShapeType: 'rect',
- getDefaultPoints: function getDefaultPoints(cfg) {
- return getRectPoints(cfg);
- }
- });
- Shape.registerShape('interval', 'rect', {
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- fill: cfg.color
- }, Global.shape.interval, cfg.style);
- if (cfg.isInCircle) {
- var newPoints = points.slice(0);
- if (this._coord.transposed) {
- newPoints = [points[0], points[3], points[2], points[1]];
- }
- var _cfg$center = cfg.center,
- x = _cfg$center.x,
- y = _cfg$center.y;
- var v = [1, 0];
- var v0 = [newPoints[0].x - x, newPoints[0].y - y];
- var v1 = [newPoints[1].x - x, newPoints[1].y - y];
- var v2 = [newPoints[2].x - x, newPoints[2].y - y];
- var startAngle = Vector2.angleTo(v, v1);
- var endAngle = Vector2.angleTo(v, v2);
- var r0 = Vector2.length(v0);
- var r = Vector2.length(v1);
- if (startAngle >= 1.5 * Math.PI) {
- startAngle = startAngle - 2 * Math.PI;
- }
- if (endAngle >= 1.5 * Math.PI) {
- endAngle = endAngle - 2 * Math.PI;
- }
- return container.addShape('Sector', {
- className: 'interval',
- attrs: Util.mix({
- x: x,
- y: y,
- r: r,
- r0: r0,
- startAngle: startAngle,
- endAngle: endAngle
- }, style)
- });
- }
- var rectCfg = getRectRange(points);
- return container.addShape('rect', {
- className: 'interval',
- attrs: Util.mix(rectCfg, style)
- });
- }
- }); // 金字塔 和 漏斗图
- ['pyramid', 'funnel'].forEach(function (shapeType) {
- Shape.registerShape('interval', shapeType, {
- getPoints: function getPoints(cfg) {
- cfg.size = cfg.size * 2; // 漏斗图的 size 是柱状图的两倍
- return getRectPoints(cfg);
- },
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var nextPoints = this.parsePoints(cfg.nextPoints);
- var polygonPoints = null;
- if (nextPoints) {
- polygonPoints = [points[0], points[1], nextPoints[1], nextPoints[0]];
- } else {
- polygonPoints = [points[0], points[1]]; // pyramid 顶部是三角形,所以取中心点就好了,funnel顶部是长方形
- if (shapeType === 'pyramid') {
- polygonPoints.push(getMiddlePoint(points[2], points[3]));
- } else {
- polygonPoints.push(points[2], points[3]);
- }
- }
- var attrs = Util.mix({
- fill: cfg.color,
- points: polygonPoints
- }, Global.shape.interval, cfg.style);
- return container.addShape('polygon', {
- className: 'interval',
- attrs: attrs
- });
- }
- });
- });
- module.exports = Interval;
- /***/ }),
- /* 193 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = {
- Stack: __webpack_require__(194),
- Dodge: __webpack_require__(196),
- Symmetric: __webpack_require__(198)
- };
- /***/ }),
- /* 194 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Stack = __webpack_require__(195);
- module.exports = Stack;
- /***/ }),
- /* 195 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var isArray = __webpack_require__(34);
- var isNil = __webpack_require__(35);
- var Adjust = __webpack_require__(33);
- var Stack = /*#__PURE__*/function (_Adjust) {
- _inheritsLoose(Stack, _Adjust);
- function Stack() {
- return _Adjust.apply(this, arguments) || this;
- }
- var _proto = Stack.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.xField = null; // 调整对应的 x 方向对应的字段名称
- this.yField = null; // 调整对应的 y 方向对应的字段名称
- };
- _proto.processAdjust = function processAdjust(dataArray) {
- this.processStack(dataArray);
- };
- _proto.processStack = function processStack(dataArray) {
- var self = this;
- var xField = self.xField;
- var yField = self.yField;
- var count = dataArray.length;
- var stackCache = {
- positive: {},
- negative: {}
- }; // 层叠顺序翻转
- if (self.reverseOrder) {
- dataArray = dataArray.slice(0).reverse();
- }
- for (var i = 0; i < count; i++) {
- var data = dataArray[i];
- for (var j = 0, len = data.length; j < len; j++) {
- var item = data[j];
- var x = item[xField] || 0;
- var y = item[yField];
- var xkey = x.toString();
- y = isArray(y) ? y[1] : y;
- if (!isNil(y)) {
- var direction = y >= 0 ? 'positive' : 'negative';
- if (!stackCache[direction][xkey]) {
- stackCache[direction][xkey] = 0;
- }
- item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
- stackCache[direction][xkey] += y;
- }
- }
- }
- };
- return Stack;
- }(Adjust);
- Adjust.Stack = Stack;
- module.exports = Stack;
- /***/ }),
- /* 196 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Dodge = __webpack_require__(197);
- module.exports = Dodge;
- /***/ }),
- /* 197 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Adjust = __webpack_require__(33);
- var each = __webpack_require__(15);
- var MARGIN_RATIO = 1 / 2;
- var DODGE_RATIO = 1 / 2;
- var Dodge = /*#__PURE__*/function (_Adjust) {
- _inheritsLoose(Dodge, _Adjust);
- function Dodge() {
- return _Adjust.apply(this, arguments) || this;
- }
- var _proto = Dodge.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- /**
- * 调整过程中,2个数据的间距
- * @type {Number}
- */
- this.marginRatio = MARGIN_RATIO;
- /**
- * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
- * @type {Number}
- */
- this.dodgeRatio = DODGE_RATIO;
- this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
- };
- _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
- var self = this;
- var pre = range.pre;
- var next = range.next;
- var tickLength = next - pre;
- var width = tickLength * self.dodgeRatio / count;
- var margin = self.marginRatio * width;
- var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
- return (pre + next) / 2 + offset;
- };
- _proto.processAdjust = function processAdjust(dataArray) {
- var self = this;
- var count = dataArray.length;
- var xField = self.xField;
- each(dataArray, function (data, index) {
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[xField];
- var range = {
- pre: len === 1 ? value - 1 : value - 0.5,
- next: len === 1 ? value + 1 : value + 0.5
- };
- var dodgeValue = self.getDodgeOffset(range, index, count);
- obj[xField] = dodgeValue;
- }
- });
- };
- return Dodge;
- }(Adjust);
- Adjust.Dodge = Dodge;
- module.exports = Dodge;
- /***/ }),
- /* 198 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Symmetric = __webpack_require__(199);
- module.exports = Symmetric;
- /***/ }),
- /* 199 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var each = __webpack_require__(15);
- var maxBy = __webpack_require__(200);
- var isArray = __webpack_require__(34);
- var ArrayUtil = {
- merge: __webpack_require__(202)
- };
- var Adjust = __webpack_require__(33);
- var Symmetric = /*#__PURE__*/function (_Adjust) {
- _inheritsLoose(Symmetric, _Adjust);
- function Symmetric() {
- return _Adjust.apply(this, arguments) || this;
- }
- var _proto = Symmetric.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.xField = null; // 调整对应的 x 方向对应的字段名称
- this.yField = null; // 调整对应的 y 方向对应的字段名称
- this.cacheMax = null; // 缓存的最大值
- this.adjustNames = ['y']; // Only support stack y
- this.groupFields = null; // 参与分组的数据维度
- }; // 获取最大的y值
- _proto._getMax = function _getMax(dim) {
- var self = this;
- var mergeData = self.mergeData;
- var maxRecord = maxBy(mergeData, function (obj) {
- var value = obj[dim];
- if (isArray(value)) {
- return Math.max.apply(null, value);
- }
- return value;
- });
- var maxValue = maxRecord[dim];
- var max = isArray(maxValue) ? Math.max.apply(null, maxValue) : maxValue;
- return max;
- }; // 获取每个字段最大的值
- _proto._getXValuesMax = function _getXValuesMax() {
- var self = this;
- var yField = self.yField;
- var xField = self.xField;
- var cache = {};
- var mergeData = self.mergeData;
- each(mergeData, function (obj) {
- var xValue = obj[xField];
- var yValue = obj[yField];
- var max = isArray(yValue) ? Math.max.apply(null, yValue) : yValue;
- cache[xValue] = cache[xValue] || 0;
- if (cache[xValue] < max) {
- cache[xValue] = max;
- }
- });
- return cache;
- }; // 入口函数
- _proto.processAdjust = function processAdjust(dataArray) {
- var self = this;
- var mergeData = ArrayUtil.merge(dataArray);
- self.mergeData = mergeData;
- self._processSymmetric(dataArray);
- self.mergeData = null;
- }; // 处理对称
- _proto._processSymmetric = function _processSymmetric(dataArray) {
- var self = this;
- var xField = self.xField;
- var yField = self.yField;
- var max = self._getMax(yField);
- var first = dataArray[0][0];
- var cache;
- if (first && isArray(first[yField])) {
- cache = self._getXValuesMax();
- }
- each(dataArray, function (data) {
- each(data, function (obj) {
- var value = obj[yField];
- var offset;
- if (isArray(value)) {
- var xValue = obj[xField];
- var valueMax = cache[xValue];
- offset = (max - valueMax) / 2;
- var tmp = [];
- /* eslint-disable no-loop-func */
- each(value, function (subVal) {
- // 多个字段
- tmp.push(offset + subVal);
- });
- /* eslint-enable no-loop-func */
- obj[yField] = tmp;
- } else {
- offset = (max - value) / 2;
- obj[yField] = [offset, value + offset];
- }
- });
- });
- };
- return Symmetric;
- }(Adjust);
- Adjust.Symmetric = Symmetric;
- module.exports = Symmetric;
- /***/ }),
- /* 200 */
- /***/ (function(module, exports, __webpack_require__) {
- var isArray = __webpack_require__(34);
- var isFunction = __webpack_require__(201);
- var each = __webpack_require__(15);
- /**
- * @param {Array} arr The array to iterate over.
- * @param {Function} [fn] The iteratee invoked per element.
- * @return {*} Returns the maximum value.
- * @example
- *
- * var objects = [{ 'n': 1 }, { 'n': 2 }];
- *
- * maxBy(objects, function(o) { return o.n; });
- * // => { 'n': 2 }
- *
- * maxBy(objects, 'n');
- * // => { 'n': 2 }
- */
- var maxBy = function maxBy(arr, fn) {
- if (!isArray(arr)) {
- return undefined;
- }
- var max = arr[0];
- var maxData = void 0;
- if (isFunction(fn)) {
- maxData = fn(arr[0]);
- } else {
- maxData = arr[0][fn];
- }
- var data = void 0;
- each(arr, function (val) {
- if (isFunction(fn)) {
- data = fn(val);
- } else {
- data = val[fn];
- }
- if (data > maxData) {
- max = val;
- maxData = data;
- }
- });
- return max;
- };
- module.exports = maxBy;
- /***/ }),
- /* 201 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 是否为函数
- * @param {*} fn 对象
- * @return {Boolean} 是否函数
- */
- var isType = __webpack_require__(27);
- var isFunction = function isFunction(value) {
- return isType(value, 'Function');
- };
- module.exports = isFunction;
- /***/ }),
- /* 202 */
- /***/ (function(module, exports) {
- var merge = function merge(dataArray) {
- var rst = [];
- for (var i = 0; i < dataArray.length; i++) {
- rst = rst.concat(dataArray[i]);
- }
- return rst;
- };
- module.exports = merge;
- /***/ }),
- /* 203 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Base = __webpack_require__(43);
- var Vector2 = __webpack_require__(13);
- var Matrix = __webpack_require__(31);
- var Polar = /*#__PURE__*/function (_Base) {
- (0, _inheritsLoose2["default"])(Polar, _Base);
- var _super = _createSuper(Polar);
- function Polar() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Polar.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'polar';
- this.startAngle = -Math.PI / 2;
- this.endAngle = Math.PI * 3 / 2;
- this.inner = 0;
- this.innerRadius = 0; // alias
- this.isPolar = true;
- this.transposed = false;
- this.center = null;
- this.radius = null; // relative, 0 ~ 1
- };
- _proto.init = function init(start, end) {
- _Base.prototype.init.call(this, start, end);
- var self = this;
- var inner = self.inner || self.innerRadius;
- var width = Math.abs(end.x - start.x);
- var height = Math.abs(end.y - start.y);
- var maxRadius;
- var center;
- if (self.startAngle === -Math.PI && self.endAngle === 0) {
- maxRadius = Math.min(width / 2, height);
- center = {
- x: (start.x + end.x) / 2,
- y: start.y
- };
- } else {
- maxRadius = Math.min(width, height) / 2;
- center = {
- x: (start.x + end.x) / 2,
- y: (start.y + end.y) / 2
- };
- }
- var radius = self.radius;
- if (radius > 0 && radius <= 1) {
- maxRadius = maxRadius * radius;
- }
- this.x = {
- start: self.startAngle,
- end: self.endAngle
- };
- this.y = {
- start: maxRadius * inner,
- end: maxRadius
- };
- this.center = center;
- this.circleRadius = maxRadius; // the radius value in px
- };
- _proto._convertPoint = function _convertPoint(point) {
- var self = this;
- var center = self.center;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- var angle = x.start + (x.end - x.start) * point[xDim];
- var radius = y.start + (y.end - y.start) * point[yDim];
- return {
- x: center.x + Math.cos(angle) * radius,
- y: center.y + Math.sin(angle) * radius
- };
- };
- _proto._invertPoint = function _invertPoint(point) {
- var self = this;
- var center = self.center,
- transposed = self.transposed,
- x = self.x,
- y = self.y;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var m = [1, 0, 0, 1, 0, 0];
- Matrix.rotate(m, m, x.start);
- var startV = [1, 0];
- Vector2.transformMat2d(startV, startV, m);
- startV = [startV[0], startV[1]];
- var pointV = [point.x - center.x, point.y - center.y];
- if (Vector2.zero(pointV)) {
- return {
- x: 0,
- y: 0
- };
- }
- var theta = Vector2.angleTo(startV, pointV, x.end < x.start);
- if (Math.abs(theta - Math.PI * 2) < 0.001) {
- theta = 0;
- }
- var l = Vector2.length(pointV);
- var percentX = theta / (x.end - x.start);
- percentX = x.end - x.start > 0 ? percentX : -percentX;
- var percentY = (l - y.start) / (y.end - y.start);
- var rst = {};
- rst[xDim] = percentX;
- rst[yDim] = percentY;
- return rst;
- };
- return Polar;
- }(Base);
- Base.Polar = Polar;
- module.exports = Polar;
- /***/ }),
- /* 204 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 提取公共代码到util方法
- * @author dxq613@gmail.com
- */
- var isString = __webpack_require__(48);
- var isDate = __webpack_require__(222);
- module.exports = {
- toTimeStamp: function toTimeStamp(value) {
- if (isString(value)) {
- if (value.indexOf('T') > 0) {
- value = new Date(value).getTime();
- } else {
- value = new Date(value.replace(/-/ig, '/')).getTime();
- }
- }
- if (isDate(value)) {
- value = value.getTime();
- }
- return value;
- }
- };
- /***/ }),
- /* 205 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(16),
- Group = _require.Group;
- var Marker = __webpack_require__(76);
- var MARKER_RADIUS = 3;
- var List = /*#__PURE__*/function () {
- var _proto = List.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- showTitle: false,
- /**
- * title string
- * @type {?String}
- */
- title: null,
- /**
- * items array
- * @type {?Array}
- */
- items: null,
- /**
- * offset between title and items
- * @type {Number}
- */
- titleGap: 12,
- /**
- * offset between each item
- * @type {Number}
- */
- itemGap: 10,
- /**
- * the offset between each item in vertical direaction
- * @type {Number}
- */
- itemMarginBottom: 12,
- /**
- * the formatter for item text
- * @type {[type]}
- */
- itemFormatter: null,
- itemWidth: null,
- /**
- * offset between marker and text
- * @type {Number}
- */
- wordSpace: 6,
- x: 0,
- y: 0,
- layout: 'horizontal',
- /**
- * the join string of `name` and `value`
- * @type {String}
- */
- joinString: ': '
- };
- };
- function List(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- this._init();
- this._renderTitle();
- this._renderItems();
- }
- _proto._init = function _init() {
- var container = new Group({
- zIndex: this.zIndex || 0
- });
- this.container = container;
- var wrapper = container.addGroup();
- this.wrapper = wrapper;
- var itemsGroup = wrapper.addGroup({
- className: 'itemsGroup'
- });
- this.itemsGroup = itemsGroup;
- if (this.parent) {
- this.parent.add(container);
- }
- };
- _proto._renderTitle = function _renderTitle(title) {
- title = title || this.title;
- var titleShape = this.titleShape;
- var titleHeight = 0;
- if (this.showTitle && title) {
- if (titleShape && !titleShape.get('destroyed')) {
- titleShape.attr('text', title);
- } else {
- var wrapper = this.wrapper,
- titleStyle = this.titleStyle;
- titleShape = wrapper.addShape('text', {
- className: 'title',
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: title
- }, titleStyle)
- });
- this.titleShape = titleShape;
- }
- titleHeight = titleShape.getBBox().height + this.titleGap;
- }
- this._titleHeight = titleHeight;
- };
- _proto._renderItems = function _renderItems(items) {
- var self = this;
- items = items || self.items;
- if (!items) {
- return;
- }
- if (self.reversed) {
- items.reverse();
- }
- Util.each(items, function (item, index) {
- self._addItem(item, index);
- });
- if (items.length > 1) {
- this._adjustItems();
- }
- this._renderBackground();
- };
- _proto._renderBackground = function _renderBackground() {
- var background = this.background;
- if (background) {
- var container = this.container;
- var wrapper = this.wrapper;
- var _wrapper$getBBox = wrapper.getBBox(),
- minX = _wrapper$getBBox.minX,
- minY = _wrapper$getBBox.minY,
- width = _wrapper$getBBox.width,
- height = _wrapper$getBBox.height;
- var padding = background.padding || [0, 0, 0, 0];
- padding = Util.parsePadding(padding);
- var attrs = Util.mix({
- x: minX - padding[3],
- y: minY - padding[0],
- width: width + padding[1] + padding[3],
- height: height + padding[0] + padding[2]
- }, background);
- var backShape = this.backShape;
- if (backShape) {
- backShape.attr(attrs);
- } else {
- backShape = container.addShape('Rect', {
- zIndex: -1,
- attrs: attrs
- });
- }
- this.backShape = backShape;
- container.sort();
- }
- };
- _proto._addItem = function _addItem(item) {
- var itemsGroup = this.itemsGroup;
- var itemGroup = itemsGroup.addGroup({
- name: item.name,
- value: item.value,
- dataValue: item.dataValue,
- checked: item.checked
- });
- var unCheckStyle = this.unCheckStyle,
- unCheckColor = this.unCheckColor,
- nameStyle = this.nameStyle,
- valueStyle = this.valueStyle,
- wordSpace = this.wordSpace;
- var marker = item.marker,
- value = item.value;
- var startX = 0;
- if (unCheckColor) {
- unCheckStyle.fill = unCheckColor;
- }
- if (marker) {
- var radius = marker.radius || MARKER_RADIUS;
- var markerAttrs = Util.mix({
- x: radius,
- y: this._titleHeight
- }, marker);
- if (item.checked === false) {
- Util.mix(markerAttrs, unCheckStyle);
- }
- var markerShape = new Marker({
- className: 'item-marker',
- attrs: markerAttrs
- });
- itemGroup.add(markerShape);
- startX += markerShape.getBBox().width + wordSpace;
- }
- var nameText;
- var name = item.name;
- if (name) {
- var joinString = this.joinString || '';
- name = value ? name + joinString : name;
- nameText = itemGroup.addShape('text', {
- className: 'name',
- attrs: Util.mix({
- x: startX,
- y: this._titleHeight,
- text: this._formatItemValue(name)
- }, nameStyle, item.checked === false ? unCheckStyle : null)
- });
- }
- if (value) {
- var valueX = startX;
- if (nameText) {
- valueX += nameText.getBBox().width;
- }
- itemGroup.addShape('text', {
- className: 'value',
- attrs: Util.mix({
- x: valueX,
- y: this._titleHeight,
- text: value
- }, valueStyle, item.checked === false ? unCheckStyle : null)
- });
- }
- return itemGroup;
- };
- _proto._formatItemValue = function _formatItemValue(value) {
- var formatter = this.itemFormatter;
- if (formatter) {
- value = formatter.call(this, value);
- }
- return value;
- };
- _proto._getMaxItemWidth = function _getMaxItemWidth() {
- var width;
- var itemWidth = this.itemWidth;
- if (Util.isNumber(itemWidth) || Util.isNil(itemWidth)) {
- return itemWidth;
- }
- if (itemWidth === 'auto') {
- var itemsGroup = this.itemsGroup;
- var children = itemsGroup.get('children');
- var count = children.length;
- var maxItemWidth = 0;
- for (var i = 0; i < count; i++) {
- var _children$i$getBBox = children[i].getBBox(),
- _width = _children$i$getBBox.width;
- maxItemWidth = Math.max(maxItemWidth, _width);
- }
- var maxLength = this.maxLength;
- var itemGap = this.itemGap;
- var twoAvgWidth = (maxLength - itemGap) / 2;
- var threeAvgWidth = (maxLength - itemGap * 2) / 3;
- if (count === 2) {
- width = Math.max(maxItemWidth, twoAvgWidth);
- } else {
- // 1. max <= 3Avg, 3Avg
- // 2. 3Avg < max && max < 2avg, 2avg
- // 3. max > 2avg, max, one column
- if (maxItemWidth <= threeAvgWidth) {
- width = threeAvgWidth;
- } else if (maxItemWidth <= twoAvgWidth) {
- width = twoAvgWidth;
- } else {
- width = maxItemWidth;
- }
- }
- return width;
- }
- };
- _proto._adjustHorizontal = function _adjustHorizontal() {
- var maxLength = this.maxLength,
- itemsGroup = this.itemsGroup;
- var children = itemsGroup.get('children');
- var itemGap = this.itemGap,
- itemMarginBottom = this.itemMarginBottom;
- var titleHeight = this._titleHeight;
- var row = 0;
- var rowWidth = 0;
- var width;
- var height;
- var itemWidth = this._getMaxItemWidth();
- var legendHitBoxes = [];
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- var box = child.getBBox();
- var childHeight = box.height;
- var childWidth = box.width;
- width = itemWidth || childWidth;
- height = childHeight + itemMarginBottom;
- if (width - (maxLength - rowWidth) > 0.0001) {
- row++;
- rowWidth = 0;
- }
- child.moveTo(rowWidth, row * height);
- legendHitBoxes.push({
- x: rowWidth,
- y: row * height + titleHeight - childHeight / 2,
- width: childWidth * 1.375,
- height: childHeight * 1.375
- });
- rowWidth += width + itemGap;
- }
- this.legendHitBoxes = legendHitBoxes;
- return;
- };
- _proto._adjustVertical = function _adjustVertical() {
- var maxLength = this.maxLength,
- itemsGroup = this.itemsGroup;
- var itemGap = this.itemGap,
- itemMarginBottom = this.itemMarginBottom,
- itemWidth = this.itemWidth;
- var titleHeight = this._titleHeight;
- var children = itemsGroup.get('children');
- var colHeight = 0;
- var width;
- var height;
- var maxItemWidth = 0;
- var totalWidth = 0;
- var legendHitBoxes = [];
- for (var i = 0, length = children.length; i < length; i++) {
- var child = children[i];
- var bbox = child.getBBox();
- width = bbox.width;
- height = bbox.height;
- if (Util.isNumber(itemWidth)) {
- maxItemWidth = itemWidth + itemGap;
- } else if (width > maxItemWidth) {
- maxItemWidth = width + itemGap;
- }
- if (maxLength - colHeight < height) {
- colHeight = 0;
- totalWidth += maxItemWidth;
- child.moveTo(totalWidth, 0);
- legendHitBoxes.push({
- x: totalWidth,
- y: titleHeight - height / 2,
- width: width * 1.375,
- height: height * 1.375
- });
- } else {
- child.moveTo(totalWidth, colHeight);
- legendHitBoxes.push({
- x: totalWidth,
- y: colHeight - height / 2 + titleHeight,
- width: width * 1.375,
- height: height * 1.375
- });
- }
- colHeight += height + itemMarginBottom;
- }
- this.legendHitBoxes = legendHitBoxes;
- return;
- };
- _proto._adjustItems = function _adjustItems() {
- var layout = this.layout;
- if (layout === 'horizontal') {
- this._adjustHorizontal();
- } else {
- this._adjustVertical();
- }
- };
- _proto.moveTo = function moveTo(x, y) {
- this.x = x;
- this.y = y;
- var container = this.container;
- container && container.moveTo(x, y);
- return this;
- };
- _proto.setItems = function setItems(items) {
- this.clearItems();
- this._renderItems(items);
- };
- _proto.setTitle = function setTitle(title) {
- this._renderTitle(title);
- };
- _proto.clearItems = function clearItems() {
- var itemsGroup = this.itemsGroup;
- itemsGroup.clear();
- };
- _proto.getWidth = function getWidth() {
- var container = this.container;
- var bbox = container.getBBox();
- return bbox.width;
- };
- _proto.getHeight = function getHeight() {
- var container = this.container;
- var bbox = container.getBBox();
- return bbox.height;
- };
- _proto.show = function show() {
- var container = this.container;
- container.show();
- };
- _proto.hide = function hide() {
- var container = this.container;
- container.hide();
- };
- _proto.clear = function clear() {
- var container = this.container;
- container.clear();
- container.remove(true);
- };
- return List;
- }();
- module.exports = List;
- /***/ }),
- /* 206 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * Animate configuration and register
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var defaultAnimationCfg = {
- appear: {
- duration: 450,
- easing: 'quadraticOut'
- },
- // 'appear' animation options
- update: {
- duration: 300,
- easing: 'quadraticOut'
- },
- // 'update' animation options
- enter: {
- duration: 300,
- easing: 'quadraticOut'
- },
- // 'enter' animation options
- leave: {
- duration: 350,
- easing: 'quadraticIn'
- } // 'leave' animation options
- };
- var Animate = {
- defaultCfg: {},
- Action: {},
- getAnimation: function getAnimation(geomType, coord, animationType) {
- var geomAnimateCfg = this.defaultCfg[geomType];
- if (geomAnimateCfg) {
- var animation = geomAnimateCfg[animationType];
- if (Util.isFunction(animation)) {
- return animation(coord);
- }
- }
- return false;
- },
- getAnimateCfg: function getAnimateCfg(geomType, animationType) {
- var defaultCfg = defaultAnimationCfg[animationType];
- var geomConfig = this.defaultCfg[geomType];
- if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
- return Util.deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
- }
- return defaultCfg;
- },
- registerAnimation: function registerAnimation(animationName, animationFun) {
- if (!this.Action) {
- this.Action = {};
- }
- this.Action[animationName] = animationFun;
- }
- };
- module.exports = Animate;
- /***/ }),
- /* 207 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * Utility
- * @author sima.zhang1990@gmail.com
- */
- var _require = __webpack_require__(16),
- Matrix = _require.Matrix;
- var Util = __webpack_require__(0);
- var Helpers = {
- getCoordInfo: function getCoordInfo(coord) {
- var start = coord.start;
- var end = coord.end;
- return {
- start: start,
- end: end,
- width: end.x - start.x,
- height: Math.abs(end.y - start.y)
- };
- },
- getScaledMatrix: function getScaledMatrix(shape, v, direct) {
- var scaledMatrix;
- shape.apply(v);
- var x = v[0];
- var y = v[1];
- if (direct === 'x') {
- shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
- var matrix = shape.getMatrix();
- scaledMatrix = Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
- } else if (direct === 'y') {
- shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);
- var _matrix = shape.getMatrix();
- scaledMatrix = Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
- } else if (direct === 'xy') {
- shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);
- var _matrix2 = shape.getMatrix();
- scaledMatrix = Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
- }
- return scaledMatrix;
- },
- getAnimateParam: function getAnimateParam(animateCfg, index, id) {
- var result = {};
- if (animateCfg.delay) {
- result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
- }
- result.easing = animateCfg.easing;
- result.duration = animateCfg.duration;
- result.delay = animateCfg.delay;
- return result;
- },
- doAnimation: function doAnimation(shape, endState, animateCfg, callback) {
- var id = shape._id;
- var index = shape.get('index');
- var _Helpers$getAnimatePa = Helpers.getAnimateParam(animateCfg, index, id),
- easing = _Helpers$getAnimatePa.easing,
- delay = _Helpers$getAnimatePa.delay,
- duration = _Helpers$getAnimatePa.duration;
- var anim = shape.animate().to({
- attrs: endState,
- duration: duration,
- delay: delay,
- easing: easing
- });
- if (callback) {
- anim.onEnd(function () {
- callback();
- });
- }
- }
- };
- module.exports = Helpers;
- /***/ }),
- /* 208 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var TimeUtil = __webpack_require__(204);
- var Util = __webpack_require__(0);
- module.exports = {
- getColDef: function getColDef(chart, field) {
- var colDef;
- if (chart.get('colDefs') && chart.get('colDefs')[field]) {
- colDef = chart.get('colDefs')[field];
- }
- return colDef;
- },
- getScale: function getScale(chart, field) {
- var scales = chart.get('scales');
- return scales[field];
- },
- getFieldRange: function getFieldRange(scale, limitRange, type) {
- if (!scale) return [0, 1];
- var minRatio = 0;
- var maxRatio = 0;
- if (type === 'linear') {
- var min = limitRange.min,
- max = limitRange.max;
- minRatio = (scale.min - min) / (max - min);
- maxRatio = (scale.max - min) / (max - min);
- } else {
- var originValues = limitRange;
- var values = scale.values || [];
- var firstIndex = originValues.indexOf(values[0]);
- var lastIndex = originValues.indexOf(values[values.length - 1]);
- minRatio = firstIndex / (originValues.length - 1);
- maxRatio = lastIndex / (originValues.length - 1);
- }
- return [minRatio, maxRatio];
- },
- getLimitRange: function getLimitRange(data, scale) {
- var result;
- var field = scale.field,
- type = scale.type;
- var values = Util.Array.values(data, field);
- if (type === 'linear') {
- result = Util.Array.getRange(values);
- if (scale.min < result.min) {
- result.min = scale.min;
- }
- if (scale.max > result.max) {
- result.max = scale.max;
- }
- } else if (type === 'timeCat') {
- Util.each(values, function (v, i) {
- values[i] = TimeUtil.toTimeStamp(v);
- });
- values.sort(function (v1, v2) {
- return v1 - v2;
- });
- result = values;
- } else {
- result = values;
- }
- return result;
- }
- };
- /***/ }),
- /* 209 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Geom = __webpack_require__(17);
- __webpack_require__(210);
- __webpack_require__(72);
- __webpack_require__(190);
- __webpack_require__(212);
- __webpack_require__(191);
- __webpack_require__(214);
- __webpack_require__(216);
- module.exports = Geom;
- /***/ }),
- /* 210 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Geom = __webpack_require__(17);
- __webpack_require__(211);
- var Point = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Point, _Geom);
- var _super = _createSuper(Point);
- function Point() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Point.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'point';
- cfg.shapeType = 'point';
- cfg.generatePoints = false;
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- Util.each(data, function (obj) {
- var shape = obj.shape;
- var cfg = self.getDrawCfg(obj);
- if (Util.isArray(obj.y)) {
- var hasStack = self.hasAdjust('stack');
- Util.each(obj.y, function (y, idx) {
- cfg.y = y;
- if (!hasStack || idx !== 0) {
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- }
- });
- } else if (!Util.isNil(obj.y)) {
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- }
- });
- };
- return Point;
- }(Geom);
- Geom.Point = Point;
- module.exports = Point;
- /***/ }),
- /* 211 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(6);
- var ShapeUtil = __webpack_require__(38);
- var Shape = __webpack_require__(19);
- var SHAPES = ['circle', 'hollowCircle', 'rect'];
- var Point = Shape.registerFactory('point', {
- defaultShapeType: 'circle',
- getDefaultPoints: function getDefaultPoints(pointInfo) {
- return ShapeUtil.splitPoints(pointInfo);
- }
- });
- function getPointsCfg(cfg) {
- var style = {
- lineWidth: 0,
- stroke: cfg.color,
- fill: cfg.color
- };
- if (cfg.size) {
- style.size = cfg.size;
- }
- Util.mix(style, cfg.style);
- return Util.mix({}, Global.shape.point, style);
- }
- function drawShape(cfg, container, shape) {
- if (cfg.size === 0) return;
- var pointCfg = getPointsCfg(cfg);
- var size = pointCfg.r || pointCfg.size;
- var x = cfg.x;
- var y = !Util.isArray(cfg.y) ? [cfg.y] : cfg.y;
- if (shape === 'hollowCircle') {
- pointCfg.lineWidth = 1;
- pointCfg.fill = null;
- }
- for (var i = 0, len = y.length; i < len; i++) {
- if (shape === 'rect') {
- return container.addShape('Rect', {
- className: 'point',
- attrs: Util.mix({
- x: x - size,
- y: y[i] - size,
- width: size * 2,
- height: size * 2
- }, pointCfg)
- });
- }
- return container.addShape('Circle', {
- className: 'point',
- attrs: Util.mix({
- x: x,
- y: y[i],
- r: size
- }, pointCfg)
- });
- }
- }
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('point', shapeType, {
- draw: function draw(cfg, container) {
- return drawShape(cfg, container, shapeType);
- }
- });
- });
- module.exports = Point;
- /***/ }),
- /* 212 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- /**
- * @fileOverview area geometry
- * @author dxq613 @gmail.com
- * @author sima.zhang1990@gmail.com
- */
- var Geom = __webpack_require__(17);
- var ShapeUtil = __webpack_require__(38);
- var Util = __webpack_require__(0);
- __webpack_require__(213);
- var Area = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Area, _Geom);
- var _super = _createSuper(Area);
- function Area() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Area.prototype;
- /**
- * get the default configuration
- * @protected
- * @return {Object} return the result
- */
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'area';
- cfg.shapeType = 'area';
- cfg.generatePoints = true;
- cfg.sortable = true;
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var cfg = this.getDrawCfg(data[0]);
- var yScale = self.getYScale();
- var connectNulls = self.get('connectNulls');
- var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
- cfg.origin = data;
- Util.each(splitArray, function (subData, splitedIndex) {
- cfg.splitedIndex = splitedIndex;
- var points = subData.map(function (obj) {
- return obj.points;
- });
- cfg.points = points;
- self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
- });
- };
- return Area;
- }(Geom);
- Geom.Area = Area;
- module.exports = Area;
- /***/ }),
- /* 213 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(19);
- var Smooth = __webpack_require__(71);
- var bbox = __webpack_require__(21);
- var Global = __webpack_require__(6);
- function equals(v1, v2) {
- return Math.abs(v1 - v2) < 0.00001;
- }
- function notEmpty(value) {
- return !isNaN(value) && !Util.isNil(value);
- }
- function filterPoints(points) {
- var filteredPoints = []; // filter the point which x or y is NaN
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (notEmpty(point.x) && notEmpty(point.y)) {
- filteredPoints.push(point);
- }
- }
- return filteredPoints;
- }
- function equalsCenter(points, center) {
- var eqls = true;
- Util.each(points, function (point) {
- if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
- eqls = false;
- return false;
- }
- });
- return eqls;
- }
- function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
- var shape;
- var points = topPoints.concat(bottomPoints);
- if (isSmooth) {
- shape = container.addShape('Custom', {
- className: 'area',
- attrs: Util.mix({
- points: points
- }, style),
- createPath: function createPath(context) {
- var constaint = [[0, 0], [1, 1]];
- var points = filterPoints(this._attrs.attrs.points);
- var pointsLen = points.length;
- var topPoints = points.slice(0, pointsLen / 2);
- var bottomPoints = points.slice(pointsLen / 2, pointsLen);
- var topSps = Smooth.smooth(topPoints, false, constaint);
- context.beginPath();
- context.moveTo(topPoints[0].x, topPoints[0].y);
- for (var i = 0, n = topSps.length; i < n; i++) {
- var sp = topSps[i];
- context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
- }
- if (bottomPoints.length) {
- var bottomSps = Smooth.smooth(bottomPoints, false, constaint);
- context.lineTo(bottomPoints[0].x, bottomPoints[0].y);
- for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
- var _sp = bottomSps[_i];
- context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
- }
- }
- context.closePath();
- },
- calculateBox: function calculateBox() {
- var points = filterPoints(this._attrs.attrs.points);
- return bbox.getBBoxFromPoints(points);
- }
- });
- } else {
- shape = container.addShape('Polyline', {
- className: 'area',
- attrs: Util.mix({
- points: points
- }, style)
- });
- }
- return shape;
- }
- function drawShape(cfg, container, isSmooth) {
- var self = this;
- var points = cfg.points;
- var topPoints = [];
- var bottomPoints = [];
- Util.each(points, function (point) {
- bottomPoints.push(point[0]);
- topPoints.push(point[1]);
- });
- var style = Util.mix({
- fillStyle: cfg.color
- }, Global.shape.area, cfg.style);
- bottomPoints.reverse();
- topPoints = self.parsePoints(topPoints);
- bottomPoints = self.parsePoints(bottomPoints);
- if (cfg.isInCircle) {
- topPoints.push(topPoints[0]);
- bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);
- if (equalsCenter(bottomPoints, cfg.center)) {
- bottomPoints = [];
- }
- }
- return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
- }
- var Area = Shape.registerFactory('area', {
- defaultShapeType: 'area',
- getDefaultPoints: function getDefaultPoints(obj) {
- var x = obj.x;
- var y = obj.y;
- var y0 = obj.y0;
- y = Util.isArray(y) ? y : [y0, y];
- var points = [];
- points.push({
- x: x,
- y: y[0]
- }, {
- x: x,
- y: y[1]
- });
- return points;
- }
- });
- var SHAPES = ['area', 'smooth'];
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('area', shapeType, {
- draw: function draw(cfg, container) {
- var smooth = shapeType === 'smooth';
- return drawShape.call(this, cfg, container, smooth);
- }
- });
- });
- module.exports = Area;
- /***/ }),
- /* 214 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Geom = __webpack_require__(17);
- var Util = __webpack_require__(0);
- __webpack_require__(215);
- var Polygon = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Polygon, _Geom);
- var _super = _createSuper(Polygon);
- function Polygon() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'polygon';
- cfg.shapeType = 'polygon';
- cfg.generatePoints = true;
- return cfg;
- };
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- var self = this;
- var x = cfg.x;
- var y = cfg.y;
- var temp;
- if (!(Util.isArray(x) && Util.isArray(y))) {
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
- var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
- var xOffset = 0.5 * 1 / xCount;
- var yOffset = 0.5 * 1 / yCount;
- if (xScale.isCategory && yScale.isCategory) {
- x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
- y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
- } else if (Util.isArray(x)) {
- temp = x;
- x = [temp[0], temp[0], temp[1], temp[1]];
- y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
- } else if (Util.isArray(y)) {
- temp = y;
- y = [temp[0], temp[1], temp[1], temp[0]];
- x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
- }
- cfg.x = x;
- cfg.y = y;
- }
- return cfg;
- };
- return Polygon;
- }(Geom);
- Geom.Polygon = Polygon;
- module.exports = Polygon;
- /***/ }),
- /* 215 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Shape = __webpack_require__(19);
- var Util = __webpack_require__(0);
- var Polygon = Shape.registerFactory('polygon', {
- defaultShapeType: 'polygon',
- getDefaultPoints: function getDefaultPoints(pointInfo) {
- var points = [];
- var x = pointInfo.x,
- y = pointInfo.y;
- for (var i = 0, len = x.length; i < len; i++) {
- points.push({
- x: x[i],
- y: y[i]
- });
- }
- return points;
- }
- });
- Shape.registerShape('polygon', 'polygon', {
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- fill: cfg.color,
- points: points
- }, cfg.style);
- return container.addShape('Polygon', {
- className: 'polygon',
- attrs: style
- });
- }
- });
- module.exports = Polygon;
- /***/ }),
- /* 216 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Geom = __webpack_require__(17);
- var Util = __webpack_require__(0);
- var SizeMixin = __webpack_require__(73);
- __webpack_require__(217);
- var Schema = /*#__PURE__*/function (_Geom) {
- (0, _inheritsLoose2["default"])(Schema, _Geom);
- var _super = _createSuper(Schema);
- var _proto = Schema.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'schema';
- cfg.shapeType = 'schema';
- cfg.generatePoints = true;
- return cfg;
- };
- function Schema(cfg) {
- var _this;
- _this = _Geom.call(this, cfg) || this;
- Util.mix((0, _assertThisInitialized2["default"])(_this), SizeMixin);
- return _this;
- }
- _proto.init = function init() {
- _Geom.prototype.init.call(this); // 绑定事件
- this.initEvent();
- };
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- cfg.size = this.getNormalizedSize(obj);
- return cfg;
- };
- _proto.clearInner = function clearInner() {
- _Geom.prototype.clearInner.call(this);
- this.set('defaultSize', null);
- };
- return Schema;
- }(Geom);
- Geom.Schema = Schema;
- module.exports = Schema;
- /***/ }),
- /* 217 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Shape = __webpack_require__(19);
- var Util = __webpack_require__(0);
- function _sortValue(value) {
- var sorted = value.sort(function (a, b) {
- return a < b ? 1 : -1;
- });
- var length = sorted.length;
- if (length < 4) {
- var min = sorted[length - 1];
- for (var i = 0; i < 4 - length; i++) {
- sorted.push(min);
- }
- }
- return sorted;
- } // from left bottom corner, and clockwise
- function getCandlePoints(x, y, width) {
- var yValues = _sortValue(y);
- var points = [{
- x: x,
- y: yValues[0]
- }, {
- x: x,
- y: yValues[1]
- }, {
- x: x - width / 2,
- y: yValues[2]
- }, {
- x: x - width / 2,
- y: yValues[1]
- }, {
- x: x + width / 2,
- y: yValues[1]
- }, {
- x: x + width / 2,
- y: yValues[2]
- }, {
- x: x,
- y: yValues[2]
- }, {
- x: x,
- y: yValues[3]
- }];
- return points;
- }
- var Schema = Shape.registerFactory('schema', {});
- Shape.registerShape('schema', 'candle', {
- getPoints: function getPoints(cfg) {
- return getCandlePoints(cfg.x, cfg.y, cfg.size);
- },
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- stroke: cfg.color,
- fill: cfg.color,
- lineWidth: 1
- }, cfg.style);
- return container.addShape('Custom', {
- className: 'schema',
- attrs: style,
- createPath: function createPath(ctx) {
- ctx.beginPath();
- ctx.moveTo(points[0].x, points[0].y);
- ctx.lineTo(points[1].x, points[1].y);
- ctx.moveTo(points[2].x, points[2].y);
- for (var i = 3; i < 6; i++) {
- ctx.lineTo(points[i].x, points[i].y);
- }
- ctx.closePath();
- ctx.moveTo(points[6].x, points[6].y);
- ctx.lineTo(points[7].x, points[7].y);
- }
- });
- }
- });
- module.exports = Schema;
- /***/ }),
- /* 218 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Abstract = __webpack_require__(45);
- var Circle = /*#__PURE__*/function (_Abstract) {
- (0, _inheritsLoose2["default"])(Circle, _Abstract);
- var _super = _createSuper(Circle);
- function Circle() {
- return _Abstract.apply(this, arguments) || this;
- }
- var _proto = Circle.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Abstract.prototype._initDefaultCfg.call(this);
- this.startAngle = -Math.PI / 2; // start angle,in radian
- this.endAngle = Math.PI * 3 / 2; // end angle, in radian
- this.radius = null; // radius
- this.center = null; // center
- };
- _proto.getOffsetPoint = function getOffsetPoint(value) {
- var startAngle = this.startAngle,
- endAngle = this.endAngle;
- var angle = startAngle + (endAngle - startAngle) * value;
- return this._getCirclePoint(angle);
- };
- _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
- var self = this;
- var center = self.center;
- radius = radius || self.radius;
- return {
- x: center.x + Math.cos(angle) * radius,
- y: center.y + Math.sin(angle) * radius
- };
- };
- _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- var align;
- var baseLine = 'middle';
- if (offsetVector[0] > 0) {
- align = 'left';
- } else if (offsetVector[0] < 0) {
- align = 'right';
- } else {
- align = 'center';
- if (offsetVector[1] > 0) {
- baseLine = 'top';
- } else if (offsetVector[1] < 0) {
- baseLine = 'bottom';
- }
- }
- return {
- textAlign: align,
- textBaseline: baseLine
- };
- };
- _proto.getAxisVector = function getAxisVector(point) {
- var center = this.center;
- var factor = this.offsetFactor;
- return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
- };
- _proto.drawLine = function drawLine(lineCfg) {
- var center = this.center,
- radius = this.radius,
- startAngle = this.startAngle,
- endAngle = this.endAngle;
- var container = this.getContainer(lineCfg.top);
- container.addShape('arc', {
- className: 'axis-line',
- attrs: Util.mix({
- x: center.x,
- y: center.y,
- r: radius,
- startAngle: startAngle,
- endAngle: endAngle
- }, lineCfg)
- });
- };
- return Circle;
- }(Abstract);
- Abstract.Circle = Circle;
- module.exports = Circle;
- /***/ }),
- /* 219 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var TimeCat = __webpack_require__(220);
- module.exports = TimeCat;
- /***/ }),
- /* 220 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- /**
- * @fileOverview 时间数据作为分类类型
- * @author dxq613@gmail.com
- */
- var Base = __webpack_require__(26);
- var Category = __webpack_require__(69);
- var fecha = __webpack_require__(221);
- var catAuto = __webpack_require__(65);
- var TimeUtil = __webpack_require__(204);
- var each = __webpack_require__(15);
- var isNumber = __webpack_require__(36);
- var isObject = __webpack_require__(44);
- var isString = __webpack_require__(48);
- /**
- * 度量的构造函数
- * @class Scale.TimeCategory
- */
- var TimeCategory = /*#__PURE__*/function (_Category) {
- _inheritsLoose(TimeCategory, _Category);
- function TimeCategory() {
- return _Category.apply(this, arguments) || this;
- }
- var _proto = TimeCategory.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Category.prototype._initDefaultCfg.call(this);
- this.type = 'timeCat';
- /**
- * 是否需要排序,默认进行排序
- * @type {Boolean}
- */
- this.sortable = true;
- this.tickCount = 5;
- /**
- * 时间格式化
- * @type {String}
- */
- this.mask = 'YYYY-MM-DD';
- };
- _proto.init = function init() {
- var self = this;
- var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳
- each(values, function (v, i) {
- values[i] = self._toTimeStamp(v);
- });
- if (this.sortable) {
- // 允许排序
- values.sort(function (v1, v2) {
- return v1 - v2;
- });
- }
- if (!self.ticks) {
- self.ticks = this.calculateTicks();
- }
- }
- /**
- * 计算 ticks
- * @return {array} 返回 ticks 数组
- */
- ;
- _proto.calculateTicks = function calculateTicks() {
- var self = this;
- var count = self.tickCount;
- var ticks;
- if (count) {
- var temp = catAuto({
- maxCount: count,
- data: self.values,
- isRounding: self.isRounding
- });
- ticks = temp.ticks;
- } else {
- ticks = self.values;
- }
- return ticks;
- }
- /**
- * @override
- */
- ;
- _proto.translate = function translate(value) {
- value = this._toTimeStamp(value);
- var index = this.values.indexOf(value);
- if (index === -1) {
- if (isNumber(value) && value < this.values.length) {
- index = value;
- } else {
- index = NaN;
- }
- }
- return index;
- }
- /**
- * @override
- */
- ;
- _proto.scale = function scale(value) {
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- var index = this.translate(value);
- var percent;
- if (this.values.length === 1 || isNaN(index)) {
- // is index is NAN should not be set as 0
- percent = index;
- } else if (index > -1) {
- percent = index / (this.values.length - 1);
- } else {
- percent = 0;
- }
- return rangeMin + percent * (rangeMax - rangeMin);
- }
- /**
- * @override
- */
- ;
- _proto.getText = function getText(value) {
- var result = '';
- var index = this.translate(value);
- if (index > -1) {
- result = this.values[index];
- } else {
- result = value;
- }
- var formatter = this.formatter;
- result = parseInt(result, 10);
- result = formatter ? formatter(result) : fecha.format(result, this.mask);
- return result;
- }
- /**
- * @override
- */
- ;
- _proto.getTicks = function getTicks() {
- var self = this;
- var ticks = this.ticks;
- var rst = [];
- each(ticks, function (tick) {
- var obj;
- if (isObject(tick)) {
- obj = tick;
- } else {
- obj = {
- text: isString(tick) ? tick : self.getText(tick),
- value: self.scale(tick),
- tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
- };
- }
- rst.push(obj);
- });
- return rst;
- } // 将时间转换为时间戳
- ;
- _proto._toTimeStamp = function _toTimeStamp(value) {
- return TimeUtil.toTimeStamp(value);
- };
- return TimeCategory;
- }(Category);
- Base.TimeCat = TimeCategory;
- module.exports = TimeCategory;
- /***/ }),
- /* 221 */
- /***/ (function(module, exports, __webpack_require__) {
- var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) {
- 'use strict';
- /**
- * Parse or format dates
- * @class fecha
- */
- var fecha = {};
- var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
- var twoDigits = /\d\d?/;
- var threeDigits = /\d{3}/;
- var fourDigits = /\d{4}/;
- var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
- var literal = /\[([^]*?)\]/gm;
- var noop = function () {};
- function shorten(arr, sLen) {
- var newArr = [];
- for (var i = 0, len = arr.length; i < len; i++) {
- newArr.push(arr[i].substr(0, sLen));
- }
- return newArr;
- }
- function monthUpdate(arrName) {
- return function (d, v, i18n) {
- var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
- if (~index) {
- d.month = index;
- }
- };
- }
- function pad(val, len) {
- val = String(val);
- len = len || 2;
- while (val.length < len) {
- val = '0' + val;
- }
- return val;
- }
- var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
- var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- var monthNamesShort = shorten(monthNames, 3);
- var dayNamesShort = shorten(dayNames, 3);
- fecha.i18n = {
- dayNamesShort: dayNamesShort,
- dayNames: dayNames,
- monthNamesShort: monthNamesShort,
- monthNames: monthNames,
- amPm: ['am', 'pm'],
- DoFn: function DoFn(D) {
- return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
- }
- };
- var formatFlags = {
- D: function (dateObj) {
- return dateObj.getDate();
- },
- DD: function (dateObj) {
- return pad(dateObj.getDate());
- },
- Do: function (dateObj, i18n) {
- return i18n.DoFn(dateObj.getDate());
- },
- d: function (dateObj) {
- return dateObj.getDay();
- },
- dd: function (dateObj) {
- return pad(dateObj.getDay());
- },
- ddd: function (dateObj, i18n) {
- return i18n.dayNamesShort[dateObj.getDay()];
- },
- dddd: function (dateObj, i18n) {
- return i18n.dayNames[dateObj.getDay()];
- },
- M: function (dateObj) {
- return dateObj.getMonth() + 1;
- },
- MM: function (dateObj) {
- return pad(dateObj.getMonth() + 1);
- },
- MMM: function (dateObj, i18n) {
- return i18n.monthNamesShort[dateObj.getMonth()];
- },
- MMMM: function (dateObj, i18n) {
- return i18n.monthNames[dateObj.getMonth()];
- },
- YY: function (dateObj) {
- return String(dateObj.getFullYear()).substr(2);
- },
- YYYY: function (dateObj) {
- return pad(dateObj.getFullYear(), 4);
- },
- h: function (dateObj) {
- return dateObj.getHours() % 12 || 12;
- },
- hh: function (dateObj) {
- return pad(dateObj.getHours() % 12 || 12);
- },
- H: function (dateObj) {
- return dateObj.getHours();
- },
- HH: function (dateObj) {
- return pad(dateObj.getHours());
- },
- m: function (dateObj) {
- return dateObj.getMinutes();
- },
- mm: function (dateObj) {
- return pad(dateObj.getMinutes());
- },
- s: function (dateObj) {
- return dateObj.getSeconds();
- },
- ss: function (dateObj) {
- return pad(dateObj.getSeconds());
- },
- S: function (dateObj) {
- return Math.round(dateObj.getMilliseconds() / 100);
- },
- SS: function (dateObj) {
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
- },
- SSS: function (dateObj) {
- return pad(dateObj.getMilliseconds(), 3);
- },
- a: function (dateObj, i18n) {
- return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
- },
- A: function (dateObj, i18n) {
- return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
- },
- ZZ: function (dateObj) {
- var o = dateObj.getTimezoneOffset();
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
- }
- };
- var parseFlags = {
- D: [twoDigits, function (d, v) {
- d.day = v;
- }],
- Do: [new RegExp(twoDigits.source + word.source), function (d, v) {
- d.day = parseInt(v, 10);
- }],
- M: [twoDigits, function (d, v) {
- d.month = v - 1;
- }],
- YY: [twoDigits, function (d, v) {
- var da = new Date(),
- cent = +('' + da.getFullYear()).substr(0, 2);
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
- }],
- h: [twoDigits, function (d, v) {
- d.hour = v;
- }],
- m: [twoDigits, function (d, v) {
- d.minute = v;
- }],
- s: [twoDigits, function (d, v) {
- d.second = v;
- }],
- YYYY: [fourDigits, function (d, v) {
- d.year = v;
- }],
- S: [/\d/, function (d, v) {
- d.millisecond = v * 100;
- }],
- SS: [/\d{2}/, function (d, v) {
- d.millisecond = v * 10;
- }],
- SSS: [threeDigits, function (d, v) {
- d.millisecond = v;
- }],
- d: [twoDigits, noop],
- ddd: [word, noop],
- MMM: [word, monthUpdate('monthNamesShort')],
- MMMM: [word, monthUpdate('monthNames')],
- a: [word, function (d, v, i18n) {
- var val = v.toLowerCase();
- if (val === i18n.amPm[0]) {
- d.isPm = false;
- } else if (val === i18n.amPm[1]) {
- d.isPm = true;
- }
- }],
- ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
- if (v === 'Z') v = '+00:00';
- var parts = (v + '').match(/([\+\-]|\d\d)/gi),
- minutes;
- if (parts) {
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
- }
- }]
- };
- parseFlags.dd = parseFlags.d;
- parseFlags.dddd = parseFlags.ddd;
- parseFlags.DD = parseFlags.D;
- parseFlags.mm = parseFlags.m;
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
- parseFlags.MM = parseFlags.M;
- parseFlags.ss = parseFlags.s;
- parseFlags.A = parseFlags.a; // Some common format strings
- fecha.masks = {
- default: 'ddd MMM DD YYYY HH:mm:ss',
- shortDate: 'M/D/YY',
- mediumDate: 'MMM D, YYYY',
- longDate: 'MMMM D, YYYY',
- fullDate: 'dddd, MMMM D, YYYY',
- shortTime: 'HH:mm',
- mediumTime: 'HH:mm:ss',
- longTime: 'HH:mm:ss.SSS'
- };
- /***
- * Format a date
- * @method format
- * @param {Date|number} dateObj
- * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
- */
- fecha.format = function (dateObj, mask, i18nSettings) {
- var i18n = i18nSettings || fecha.i18n;
- if (typeof dateObj === 'number') {
- dateObj = new Date(dateObj);
- }
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
- throw new Error('Invalid Date in fecha.format');
- }
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
- var literals = []; // Make literals inactive by replacing them with ??
- mask = mask.replace(literal, function ($0, $1) {
- literals.push($1);
- return '??';
- }); // Apply formatting rules
- mask = mask.replace(token, function ($0) {
- return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
- }); // Inline literal values back into the formatted value
- return mask.replace(/\?\?/g, function () {
- return literals.shift();
- });
- };
- /**
- * Parse a date string into an object, changes - into /
- * @method parse
- * @param {string} dateStr Date string
- * @param {string} format Date parse format
- * @returns {Date|boolean}
- */
- fecha.parse = function (dateStr, format, i18nSettings) {
- var i18n = i18nSettings || fecha.i18n;
- if (typeof format !== 'string') {
- throw new Error('Invalid format in fecha.parse');
- }
- format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
- if (dateStr.length > 1000) {
- return false;
- }
- var isValid = true;
- var dateInfo = {};
- format.replace(token, function ($0) {
- if (parseFlags[$0]) {
- var info = parseFlags[$0];
- var index = dateStr.search(info[0]);
- if (!~index) {
- isValid = false;
- } else {
- dateStr.replace(info[0], function (result) {
- info[1](dateInfo, result, i18n);
- dateStr = dateStr.substr(index + result.length);
- return result;
- });
- }
- }
- return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
- });
- if (!isValid) {
- return false;
- }
- var today = new Date();
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
- dateInfo.hour = +dateInfo.hour + 12;
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
- dateInfo.hour = 0;
- }
- var date;
- if (dateInfo.timezoneOffset != null) {
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
- } else {
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
- }
- return date;
- };
- /* istanbul ignore next */
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = fecha;
- } else if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
- return fecha;
- }.call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {
- main.fecha = fecha;
- }
- })(this);
- /***/ }),
- /* 222 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(27);
- var isDate = function isDate(value) {
- return isType(value, 'Date');
- };
- module.exports = isDate;
- /***/ }),
- /* 223 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Arc = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Arc, _GuideBase);
- var _super = _createSuper(Arc);
- function Arc() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Arc.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'arc';
- /**
- * start point
- * @type {Array | Function}
- */
- this.start = [];
- /**
- * end point
- * @type {Array | Function}
- */
- this.end = [];
- /**
- * style configuration
- * @type {Object}
- */
- this.style = {
- stroke: '#999',
- lineWidth: 1
- };
- };
- _proto.render = function render(coord, container) {
- var self = this;
- var start = self.parsePoint(coord, self.start);
- var end = self.parsePoint(coord, self.end);
- if (!start || !end) {
- return;
- }
- var coordCenter = coord.center;
- var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
- var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
- var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
- var shape = container.addShape('arc', {
- className: 'guide-arc',
- attrs: Util.mix({
- x: coordCenter.x,
- y: coordCenter.y,
- r: radius,
- startAngle: startAngle,
- endAngle: endAngle
- }, self.style)
- });
- self.element = shape;
- return shape;
- };
- return Arc;
- }(GuideBase);
- GuideBase.Arc = Arc;
- module.exports = Arc;
- /***/ }),
- /* 224 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- function getOffsetFromAlign(alignX, alignY, width, height) {
- var result = [];
- if (alignX === 'left' && alignY === 'top') {
- result[0] = 0;
- result[1] = 0;
- } else if (alignX === 'right' && alignY === 'top') {
- result[0] = -width;
- result[1] = 0;
- } else if (alignX === 'left' && alignY === 'bottom') {
- result[0] = 0;
- result[1] = Math.floor(-height);
- } else if (alignX === 'right' && alignY === 'bottom') {
- result[0] = Math.floor(-width);
- result[1] = Math.floor(-height);
- } else if (alignX === 'right' && alignY === 'middle') {
- result[0] = Math.floor(-width);
- result[1] = Math.floor(-height / 2);
- } else if (alignX === 'left' && alignY === 'middle') {
- result[0] = 0;
- result[1] = Math.floor(-height / 2);
- } else if (alignX === 'center' && alignY === 'bottom') {
- result[0] = Math.floor(-width / 2);
- result[1] = Math.floor(-height);
- } else if (alignX === 'center' && alignY === 'top') {
- result[0] = Math.floor(-width / 2);
- result[1] = 0;
- } else {
- result[0] = Math.floor(-width / 2);
- result[1] = Math.floor(-height / 2);
- }
- return result;
- }
- function modifyCSS(DOM, CSS) {
- for (var key in CSS) {
- if (CSS.hasOwnProperty(key)) {
- DOM.style[key] = CSS[key];
- }
- }
- return DOM;
- }
- function createDom(str) {
- var container = document.createElement('div');
- str = str.replace(/(^\s*)|(\s*$)/g, '');
- container.innerHTML = '' + str;
- return container.childNodes[0];
- }
- var Html = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Html, _GuideBase);
- var _super = _createSuper(Html);
- function Html() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Html.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'html';
- /**
- * dom position
- * @type {Object | Array}
- */
- this.position = null;
- /**
- * alignment for horizontal direction,can be 'left','center','right'
- * @type {String}
- */
- this.alignX = 'center';
- /**
- * alignment for vertical direction,can be 'top', 'middle', 'bottom'
- * @type {String}
- */
- this.alignY = 'middle';
- /**
- * offset for horizontal direction
- * @type {Number}
- */
- this.offsetX = null;
- /**
- * offset for vertical direction
- * @type {Number}
- */
- this.offsetY = null;
- /**
- * the html string
- *@type {String | Function}
- */
- this.html = null;
- } // override paint
- ;
- _proto.render = function render(coord, container) {
- var self = this;
- var position = self.parsePoint(coord, self.position);
- if (!position) {
- return;
- }
- var myNode = createDom(self.html);
- myNode = modifyCSS(myNode, {
- position: 'absolute',
- top: Math.floor(position.y) + 'px',
- left: Math.floor(position.x) + 'px',
- visibility: 'hidden'
- });
- var canvasDom = container.get('canvas').get('el');
- var parentNode = canvasDom.parentNode;
- parentNode = modifyCSS(parentNode, {
- position: 'relative'
- });
- var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
- parentNode.appendChild(wrapperNode);
- wrapperNode.appendChild(myNode);
- var canvasOffsetTop = canvasDom.offsetTop;
- var canvasOffsetLeft = canvasDom.offsetLeft;
- var alignX = self.alignX,
- alignY = self.alignY,
- offsetX = self.offsetX,
- offsetY = self.offsetY;
- var width = Util.getWidth(myNode);
- var height = Util.getHeight(myNode);
- var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
- position.x = position.x + newOffset[0] + canvasOffsetLeft;
- position.y = position.y + newOffset[1] + canvasOffsetTop;
- if (offsetX) {
- position.x += offsetX;
- }
- if (offsetY) {
- position.y += offsetY;
- }
- modifyCSS(myNode, {
- top: Math.floor(position.y) + 'px',
- left: Math.floor(position.x) + 'px',
- visibility: 'visible'
- });
- self.element = wrapperNode;
- };
- _proto.remove = function remove() {
- var element = this.element;
- element && element.parentNode && element.parentNode.removeChild(element);
- };
- return Html;
- }(GuideBase);
- GuideBase.Html = Html;
- module.exports = Html;
- /***/ }),
- /* 225 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Line = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Line, _GuideBase);
- var _super = _createSuper(Line);
- function Line() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'line';
- this.start = [];
- this.end = [];
- this.style = {
- stroke: '#000',
- lineWidth: 1
- };
- };
- _proto.render = function render(coord, container) {
- var points = [];
- points[0] = this.parsePoint(coord, this.start);
- points[1] = this.parsePoint(coord, this.end);
- if (!points[0] || !points[1]) {
- return;
- }
- var shape = container.addShape('Line', {
- className: 'guide-line',
- attrs: Util.mix({
- x1: points[0].x,
- y1: points[0].y,
- x2: points[1].x,
- y2: points[1].y
- }, this.style)
- });
- this.element = shape;
- return shape;
- };
- return Line;
- }(GuideBase);
- GuideBase.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 226 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Rect = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Rect, _GuideBase);
- var _super = _createSuper(Rect);
- function Rect() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Rect.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'rect';
- this.start = [];
- this.end = [];
- this.style = {
- fill: '#CCD7EB',
- opacity: 0.4
- };
- };
- _proto.render = function render(coord, container) {
- var start = this.parsePoint(coord, this.start);
- var end = this.parsePoint(coord, this.end);
- if (!start || !end) {
- return;
- }
- var shape = container.addShape('rect', {
- className: 'guide-rect',
- attrs: Util.mix({
- x: Math.min(start.x, end.x),
- y: Math.min(start.y, end.y),
- width: Math.abs(end.x - start.x),
- height: Math.abs(start.y - end.y)
- }, this.style)
- });
- this.element = shape;
- return shape;
- };
- return Rect;
- }(GuideBase);
- GuideBase.Rect = Rect;
- module.exports = Rect;
- /***/ }),
- /* 227 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Text = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Text, _GuideBase);
- var _super = _createSuper(Text);
- function Text() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Text.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'text';
- /**
- * the position of text
- * @type {Function | Array}
- */
- this.position = null;
- /**
- * the display content
- * @type {String}
- */
- this.content = null;
- /**
- * style configuration for text
- * @type {Object}
- */
- this.style = {
- fill: '#000'
- };
- /**
- * offset of horizontal direction
- * @type {Number}
- */
- this.offsetX = 0;
- /**
- * offset of vertical direction
- * @type {Number}
- */
- this.offsetY = 0;
- };
- _proto.render = function render(coord, container) {
- var position = this.position;
- var point = this.parsePoint(coord, position);
- if (!point) {
- return;
- }
- var content = this.content,
- style = this.style,
- offsetX = this.offsetX,
- offsetY = this.offsetY;
- if (offsetX) {
- point.x += offsetX;
- }
- if (offsetY) {
- point.y += offsetY;
- }
- var shape = container.addShape('text', {
- className: 'guide-text',
- attrs: Util.mix({
- x: point.x,
- y: point.y,
- text: content
- }, style)
- });
- this.element = shape;
- return shape;
- };
- return Text;
- }(GuideBase);
- GuideBase.Text = Text;
- module.exports = Text;
- /***/ }),
- /* 228 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Tag = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Tag, _GuideBase);
- var _super = _createSuper(Tag);
- function Tag() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Tag.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'tag';
- this.position = null;
- this.content = null;
- this.direct = 'tl';
- this.autoAdjust = true;
- this.offsetX = 0;
- this.offsetY = 0;
- this.side = 4;
- this.background = {
- padding: 5,
- radius: 2,
- fill: '#1890FF'
- };
- this.textStyle = {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- };
- this.withPoint = true;
- this.pointStyle = {
- fill: '#1890FF',
- r: 3,
- lineWidth: 1,
- stroke: '#fff'
- };
- };
- _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
- var direct = this.direct;
- var side = this.side;
- var canvas = container.get('canvas');
- var clientWidth = canvas.get('width');
- var clientHeight = canvas.get('height');
- var x = point.x,
- y = point.y;
- var vertical = direct[0];
- var horizontal = direct[1]; // adjust for vertical direction
- if (vertical === 't' && y - side - tagHeight < 0) {
- vertical = 'b';
- } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
- vertical = 't';
- } // adjust for horizontal direction
- var diff = vertical === 'c' ? side : 0;
- if (horizontal === 'l' && x - diff - tagWidth < 0) {
- horizontal = 'r';
- } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
- horizontal = 'l';
- } else if (horizontal === 'c') {
- if (tagWidth / 2 + x + diff > clientWidth) {
- horizontal = 'l';
- } else if (x - tagWidth / 2 - diff < 0) {
- horizontal = 'r';
- }
- }
- direct = vertical + horizontal;
- return direct;
- };
- _proto.render = function render(coord, container) {
- var position = this.parsePoint(coord, this.position);
- if (!position) {
- return;
- } // 数据不在显示范围内时,x/y 会为NaN
- if (isNaN(position.x) || isNaN(position.y)) {
- return;
- }
- var content = this.content,
- background = this.background,
- textStyle = this.textStyle;
- var shapes = [];
- var wrapperContainer = container.addGroup({
- className: 'guide-tag'
- });
- if (this.withPoint) {
- var pointShape = wrapperContainer.addShape('Circle', {
- className: 'guide-tag-point',
- attrs: Util.mix({
- x: position.x,
- y: position.y
- }, this.pointStyle)
- });
- shapes.push(pointShape);
- }
- var tagContainer = wrapperContainer.addGroup(); // create a text shape
- var tagText = tagContainer.addShape('text', {
- className: 'guide-tag-text',
- zIndex: 1,
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: content
- }, textStyle)
- });
- shapes.push(tagText); // create background box
- var textBBox = tagText.getBBox();
- var padding = Util.parsePadding(background.padding);
- var tagWidth = textBBox.width + padding[1] + padding[3];
- var tagHeight = textBBox.height + padding[0] + padding[2];
- var yMin = textBBox.minY - padding[0];
- var xMin = textBBox.minX - padding[3];
- var tagBg = tagContainer.addShape('rect', {
- className: 'guide-tag-bg',
- zIndex: -1,
- attrs: Util.mix({
- x: xMin,
- y: yMin,
- width: tagWidth,
- height: tagHeight
- }, background)
- });
- shapes.push(tagBg);
- var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
- var side = this.side;
- var x = position.x + this.offsetX;
- var y = position.y + this.offsetY;
- var arrowPoints;
- var radius = Util.parsePadding(background.radius);
- if (direct === 'tl') {
- arrowPoints = [{
- x: tagWidth + xMin - side - 1,
- y: tagHeight + yMin - 1
- }, // 这个 1 是为了防止出现白边
- {
- x: tagWidth + xMin,
- y: tagHeight + yMin - 1
- }, {
- x: tagWidth + xMin,
- y: tagHeight + side + yMin
- }];
- radius[2] = 0;
- x = x - tagWidth;
- y = y - side - tagHeight;
- } else if (direct === 'cl') {
- arrowPoints = [{
- x: tagWidth + xMin - 1,
- y: (tagHeight - side) / 2 + yMin - 1
- }, {
- x: tagWidth + xMin - 1,
- y: (tagHeight + side) / 2 + yMin + 1
- }, {
- x: tagWidth + side + xMin,
- y: tagHeight / 2 + yMin
- }];
- x = x - tagWidth - side;
- y = y - tagHeight / 2;
- } else if (direct === 'bl') {
- arrowPoints = [{
- x: tagWidth + xMin,
- y: -side + yMin
- }, {
- x: tagWidth + xMin - side - 1,
- y: yMin + 1
- }, {
- x: tagWidth + xMin,
- y: yMin + 1
- }];
- radius[1] = 0;
- x = x - tagWidth;
- y = y + side;
- } else if (direct === 'bc') {
- arrowPoints = [{
- x: tagWidth / 2 + xMin,
- y: -side + yMin
- }, {
- x: (tagWidth - side) / 2 + xMin - 1,
- y: yMin + 1
- }, {
- x: (tagWidth + side) / 2 + xMin + 1,
- y: yMin + 1
- }];
- x = x - tagWidth / 2;
- y = y + side;
- } else if (direct === 'br') {
- arrowPoints = [{
- x: xMin,
- y: yMin - side
- }, {
- x: xMin,
- y: yMin + 1
- }, {
- x: xMin + side + 1,
- y: yMin + 1
- }];
- radius[0] = 0;
- y = y + side;
- } else if (direct === 'cr') {
- arrowPoints = [{
- x: xMin - side,
- y: tagHeight / 2 + yMin
- }, {
- x: xMin + 1,
- y: (tagHeight - side) / 2 + yMin - 1
- }, {
- x: xMin + 1,
- y: (tagHeight + side) / 2 + yMin + 1
- }];
- x = x + side;
- y = y - tagHeight / 2;
- } else if (direct === 'tr') {
- arrowPoints = [{
- x: xMin,
- y: tagHeight + side + yMin
- }, {
- x: xMin,
- y: tagHeight + yMin - 1
- }, {
- x: side + xMin + 1,
- y: tagHeight + yMin - 1
- }];
- radius[3] = 0;
- y = y - tagHeight - side;
- } else if (direct === 'tc') {
- arrowPoints = [{
- x: (tagWidth - side) / 2 + xMin - 1,
- y: tagHeight + yMin - 1
- }, {
- x: (tagWidth + side) / 2 + xMin + 1,
- y: tagHeight + yMin - 1
- }, {
- x: tagWidth / 2 + xMin,
- y: tagHeight + side + yMin
- }];
- x = x - tagWidth / 2;
- y = y - tagHeight - side;
- }
- var sideShape = tagContainer.addShape('Polygon', {
- className: 'guide-tag-side',
- zIndex: 0,
- attrs: {
- points: arrowPoints,
- fill: background.fill
- }
- });
- shapes.push(sideShape);
- tagBg.attr('radius', radius);
- tagContainer.moveTo(x - xMin, y - yMin);
- tagContainer.sort();
- this.element = wrapperContainer;
- return shapes;
- };
- return Tag;
- }(GuideBase);
- GuideBase.Tag = Tag;
- module.exports = Tag;
- /***/ }),
- /* 229 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var Point = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(Point, _GuideBase);
- var _super = _createSuper(Point);
- function Point() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Point.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'point';
- this.position = null;
- this.offsetX = 0;
- this.offsetY = 0;
- this.style = {
- fill: '#1890FF',
- r: 3,
- lineWidth: 1,
- stroke: '#fff'
- };
- };
- _proto.render = function render(coord, container) {
- var position = this.parsePoint(coord, this.position);
- if (!position) return null;
- var shape = container.addShape('Circle', {
- className: 'guide-point',
- attrs: Util.mix({
- x: position.x + this.offsetX,
- y: position.y + this.offsetY
- }, this.style)
- });
- this.element = shape;
- return shape;
- };
- return Point;
- }(GuideBase);
- GuideBase.Point = Point;
- module.exports = Point;
- /***/ }),
- /* 230 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(6);
- var Tooltip = __webpack_require__(231);
- var Helper = __webpack_require__(37); // Register the default configuration for Tooltip
- Global.tooltip = Util.deepMix({
- triggerOn: 'press',
- triggerOff: 'pressend',
- alwaysShow: false,
- showTitle: false,
- showCrosshairs: false,
- crosshairsStyle: {
- stroke: 'rgba(0, 0, 0, 0.25)',
- lineWidth: 1
- },
- showTooltipMarker: true,
- background: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- titleStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'start',
- textBaseline: 'top'
- },
- nameStyle: {
- fontSize: 12,
- fill: 'rgba(255, 255, 255, 0.65)',
- textAlign: 'start',
- textBaseline: 'middle'
- },
- valueStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'start',
- textBaseline: 'middle'
- },
- showItemMarker: true,
- itemMarkerStyle: {
- radius: 3,
- symbol: 'circle',
- lineWidth: 1,
- stroke: '#fff'
- },
- layout: 'horizontal',
- snap: false
- }, Global.tooltip || {});
- function _getTooltipValueScale(geom) {
- var colorAttr = geom.getAttr('color');
- if (colorAttr) {
- var colorScale = colorAttr.getScale(colorAttr.type);
- if (colorScale.isLinear) {
- return colorScale;
- }
- }
- var xScale = geom.getXScale();
- var yScale = geom.getYScale();
- if (yScale) {
- return yScale;
- }
- return xScale;
- }
- function getTooltipName(geom, origin) {
- var name;
- var nameScale;
- var groupScales = geom._getGroupScales();
- if (groupScales.length) {
- Util.each(groupScales, function (scale) {
- nameScale = scale;
- return false;
- });
- }
- if (nameScale) {
- var field = nameScale.field;
- name = nameScale.getText(origin[field]);
- } else {
- var valueScale = _getTooltipValueScale(geom);
- name = valueScale.alias || valueScale.field;
- }
- return name;
- }
- function getTooltipValue(geom, origin) {
- var scale = _getTooltipValueScale(geom);
- return scale.getText(origin[scale.field]);
- }
- function getTooltipTitle(geom, origin) {
- var position = geom.getAttr('position');
- var field = position.getFields()[0];
- var scale = geom.get('scales')[field];
- return scale.getText(origin[scale.field]);
- }
- function _indexOfArray(items, item) {
- var rst = -1;
- Util.each(items, function (sub, index) {
- if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
- rst = index;
- return false;
- }
- });
- return rst;
- }
- function _uniqItems(items) {
- var tmp = [];
- Util.each(items, function (item) {
- var index = _indexOfArray(tmp, item);
- if (index === -1) {
- tmp.push(item);
- } else {
- tmp[index] = item;
- }
- });
- return tmp;
- }
- function isEqual(arr1, arr2) {
- return JSON.stringify(arr1) === JSON.stringify(arr2);
- }
- var TooltipController = /*#__PURE__*/function () {
- function TooltipController(cfg) {
- var _this = this;
- this.handleShowEvent = function (ev) {
- var chart = _this.chart;
- if (!_this.enable) return;
- var plot = chart.get('plotRange');
- var point = Util.createEvent(ev, chart);
- if (!Helper.isPointInPlot(point, plot) && !_this._tooltipCfg.alwaysShow) {
- // not in chart plot
- _this.hideTooltip();
- return;
- }
- var lastTimeStamp = _this.timeStamp;
- var timeStamp = +new Date();
- if (timeStamp - lastTimeStamp > 16) {
- _this.showTooltip(point);
- _this.timeStamp = timeStamp;
- }
- };
- this.handleHideEvent = function () {
- if (!_this.enable) return;
- _this.hideTooltip();
- };
- this.enable = true;
- this.cfg = {};
- this.tooltip = null;
- this.chart = null;
- this.timeStamp = 0;
- Util.mix(this, cfg);
- var _chart = this.chart;
- var canvas = _chart.get('canvas');
- this.canvas = canvas;
- this.canvasDom = canvas.get('el');
- }
- var _proto = TooltipController.prototype;
- _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
- var self = this;
- var chart = self.chart;
- var defaultCfg = Util.mix({}, Global.tooltip);
- var geoms = chart.get('geoms');
- var shapes = [];
- Util.each(geoms, function (geom) {
- var type = geom.get('type');
- if (shapes.indexOf(type) === -1) {
- shapes.push(type);
- }
- });
- var coordType = chart.get('coord').type;
- if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
- if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
- Util.mix(defaultCfg, {
- showCrosshairs: true
- });
- }
- }
- return defaultCfg;
- };
- _proto._getMaxLength = function _getMaxLength(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var _cfg = cfg,
- layout = _cfg.layout,
- plotRange = _cfg.plotRange;
- return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
- };
- _proto.render = function render() {
- var self = this;
- if (self.tooltip) {
- return;
- }
- var chart = self.chart;
- var canvas = chart.get('canvas');
- var frontPlot = chart.get('frontPlot').addGroup({
- className: 'tooltipContainer',
- zIndex: 10
- });
- var backPlot = chart.get('backPlot').addGroup({
- className: 'tooltipContainer'
- });
- var plotRange = chart.get('plotRange');
- var coord = chart.get('coord');
- var defaultCfg = self._setCrosshairsCfg();
- var cfg = self.cfg; // 通过 chart.tooltip() 接口传入的 tooltip 配置项
- var tooltipCfg = Util.deepMix({
- plotRange: plotRange,
- frontPlot: frontPlot,
- backPlot: backPlot,
- canvas: canvas,
- fixed: coord.transposed || coord.isPolar
- }, defaultCfg, cfg); // 创建 tooltip 实例需要的配置,不应该修改 this.cfg,即用户传入的配置
- tooltipCfg.maxLength = self._getMaxLength(tooltipCfg);
- this._tooltipCfg = tooltipCfg;
- var tooltip = new Tooltip(tooltipCfg);
- self.tooltip = tooltip;
- self.bindEvents();
- };
- _proto.clear = function clear() {
- var tooltip = this.tooltip;
- if (tooltip) {
- tooltip.destroy();
- this.unBindEvents();
- }
- this.tooltip = null;
- this.prePoint = null;
- this._lastActive = null;
- };
- _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var _cfg2 = cfg,
- type = _cfg2.type,
- items = _cfg2.items;
- var tooltipCfg = this._tooltipCfg;
- if (type === 'rect') {
- var x;
- var y;
- var width;
- var height;
- var chart = this.chart;
- var _chart$get = chart.get('plotRange'),
- tl = _chart$get.tl,
- br = _chart$get.br;
- var coord = chart.get('coord');
- var firstItem = items[0];
- var lastItem = items[items.length - 1];
- var intervalWidth = firstItem.width;
- if (coord.transposed) {
- x = tl.x;
- y = lastItem.y - intervalWidth * 0.75;
- width = br.x - tl.x;
- height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
- } else {
- x = firstItem.x - intervalWidth * 0.75;
- y = tl.y;
- width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
- height = br.y - tl.y;
- }
- cfg.style = Util.mix({
- x: x,
- y: y,
- width: width,
- height: height,
- fill: '#CCD6EC',
- opacity: 0.3
- }, tooltipCfg.tooltipMarkerStyle);
- } else {
- cfg.style = Util.mix({
- radius: 4,
- fill: '#fff',
- lineWidth: 2
- }, tooltipCfg.tooltipMarkerStyle);
- }
- return cfg;
- };
- _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
- if (tooltipMarkerCfg === void 0) {
- tooltipMarkerCfg = {};
- }
- var lastActive = this._lastActive;
- var tooltip = this.tooltip;
- var cfg = this._tooltipCfg;
- items = _uniqItems(items);
- var chart = this.chart;
- var coord = chart.get('coord');
- var yScale = chart.getYScales()[0];
- var snap = cfg.snap;
- if (snap === false && yScale.isLinear) {
- var invertPoint = coord.invertPoint(point);
- var plot = chart.get('plotRange');
- var tip;
- var pos;
- if (Helper.isPointInPlot(point, plot)) {
- if (coord.transposed) {
- tip = yScale.invert(invertPoint.x);
- pos = point.x;
- tooltip.setXTipContent(tip);
- tooltip.setXTipPosition(pos);
- tooltip.setYCrosshairPosition(pos);
- } else {
- tip = yScale.invert(invertPoint.y);
- pos = point.y;
- tooltip.setYTipContent(tip);
- tooltip.setYTipPosition(pos);
- tooltip.setXCrosshairPosition(pos);
- }
- }
- }
- if (cfg.onShow) {
- cfg.onShow({
- x: point.x,
- y: point.y,
- tooltip: tooltip,
- items: items,
- tooltipMarkerCfg: tooltipMarkerCfg
- });
- }
- if (isEqual(lastActive, items)) {
- if (snap === false && (Util.directionEnabled(cfg.crosshairsType, 'y') || cfg.showYTip)) {
- var canvas = this.chart.get('canvas');
- canvas.draw();
- }
- return;
- }
- this._lastActive = items;
- var onChange = cfg.onChange;
- if (onChange) {
- onChange({
- x: point.x,
- y: point.y,
- tooltip: tooltip,
- items: items,
- tooltipMarkerCfg: tooltipMarkerCfg
- });
- }
- var first = items[0];
- var title = first.title || first.name;
- var xTipPosX = first.x;
- if (items.length > 1) {
- xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
- }
- tooltip.setContent(title, items, coord.transposed);
- tooltip.setPosition(items, point);
- if (coord.transposed) {
- var yTipPosY = first.y;
- if (items.length > 1) {
- yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
- }
- tooltip.setYTipContent(title);
- tooltip.setYTipPosition(yTipPosY);
- tooltip.setXCrosshairPosition(yTipPosY);
- if (snap) {
- tooltip.setXTipContent(first.value);
- tooltip.setXTipPosition(xTipPosX);
- tooltip.setYCrosshairPosition(xTipPosX);
- }
- } else {
- tooltip.setXTipContent(title);
- tooltip.setXTipPosition(xTipPosX);
- tooltip.setYCrosshairPosition(xTipPosX);
- if (snap) {
- tooltip.setYTipContent(first.value);
- tooltip.setYTipPosition(first.y);
- tooltip.setXCrosshairPosition(first.y);
- }
- }
- var markerItems = tooltipMarkerCfg.items;
- if (cfg.showTooltipMarker && markerItems.length) {
- tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
- tooltip.setMarkers(tooltipMarkerCfg);
- } else {
- tooltip.clearMarkers();
- }
- tooltip.show();
- };
- _proto.showTooltip = function showTooltip(point) {
- var self = this;
- var chart = self.chart;
- var tooltipMarkerType;
- var tooltipMarkerItems = [];
- var items = [];
- var cfg = self._tooltipCfg;
- var marker;
- if (cfg.showItemMarker) {
- marker = cfg.itemMarkerStyle;
- }
- var geoms = chart.get('geoms');
- var coord = chart.get('coord');
- Util.each(geoms, function (geom) {
- if (geom.get('visible')) {
- var type = geom.get('type');
- var records = geom.getSnapRecords(point);
- var adjust = geom.get('adjust'); // 漏斗图和金子塔图tooltip位置有问题,暂时不开放显示
- if (type === 'interval' && adjust && adjust.type === 'symmetric') {
- return;
- }
- Util.each(records, function (record) {
- if (record.x && record.y) {
- var x = record.x,
- y = record.y,
- _origin = record._origin,
- color = record.color;
- var tooltipItem = {
- x: x,
- y: Util.isArray(y) ? y[1] : y,
- color: color || Global.defaultColor,
- origin: _origin,
- name: getTooltipName(geom, _origin),
- value: getTooltipValue(geom, _origin),
- title: getTooltipTitle(geom, _origin)
- };
- if (marker) {
- tooltipItem.marker = Util.mix({
- fill: color || Global.defaultColor
- }, marker);
- }
- items.push(tooltipItem);
- if (['line', 'area', 'path'].indexOf(type) !== -1) {
- tooltipMarkerType = 'circle';
- tooltipMarkerItems.push(tooltipItem);
- } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
- tooltipMarkerType = 'rect';
- tooltipItem.width = geom.getSize(record._origin);
- tooltipMarkerItems.push(tooltipItem);
- }
- }
- });
- }
- });
- if (items.length) {
- var tooltipMarkerCfg = {
- items: tooltipMarkerItems,
- type: tooltipMarkerType
- };
- self._setTooltip(point, items, tooltipMarkerCfg);
- } else {
- self.hideTooltip();
- }
- };
- _proto.hideTooltip = function hideTooltip() {
- var cfg = this._tooltipCfg;
- this._lastActive = null;
- var tooltip = this.tooltip;
- if (tooltip) {
- tooltip.hide();
- if (cfg.onHide) {
- cfg.onHide({
- tooltip: tooltip
- });
- }
- var canvas = this.chart.get('canvas');
- canvas.draw();
- }
- };
- _proto._handleEvent = function _handleEvent(methodName, method, action) {
- var canvas = this.canvas;
- Util.each([].concat(methodName), function (aMethod) {
- if (action === 'bind') {
- canvas.on(aMethod, method);
- } else {
- canvas.off(aMethod, method);
- }
- });
- };
- _proto.bindEvents = function bindEvents() {
- var cfg = this._tooltipCfg;
- var triggerOn = cfg.triggerOn,
- triggerOff = cfg.triggerOff,
- alwaysShow = cfg.alwaysShow;
- triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'bind'); // 如果 !alwaysShow, 则在手势离开后就隐藏
- if (!alwaysShow) {
- this._handleEvent(triggerOff, this.handleHideEvent, 'bind');
- }
- };
- _proto.unBindEvents = function unBindEvents() {
- var cfg = this._tooltipCfg;
- var triggerOn = cfg.triggerOn,
- triggerOff = cfg.triggerOff,
- alwaysShow = cfg.alwaysShow;
- triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'unBind');
- if (!alwaysShow) {
- this._handleEvent(triggerOff, this.handleHideEvent, 'unBind');
- }
- };
- return TooltipController;
- }();
- module.exports = {
- init: function init(chart) {
- var tooltipController = new TooltipController({
- chart: chart
- });
- chart.set('tooltipController', tooltipController);
- chart.tooltip = function (enable, cfg) {
- if (Util.isObject(enable)) {
- cfg = enable;
- enable = true;
- }
- tooltipController.enable = enable;
- if (cfg) {
- tooltipController.cfg = cfg;
- }
- return this;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var tooltipController = chart.get('tooltipController');
- tooltipController.render();
- chart.showTooltip = function (point) {
- tooltipController.showTooltip(point);
- return this;
- };
- chart.hideTooltip = function () {
- tooltipController.hideTooltip();
- return this;
- };
- },
- clearInner: function clearInner(chart) {
- var tooltipController = chart.get('tooltipController');
- tooltipController.clear();
- }
- };
- /***/ }),
- /* 231 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Marker = __webpack_require__(76);
- var Container = __webpack_require__(205);
- var TextBox = __webpack_require__(232);
- var GAP = 4;
- /**
- * TODOList:
- * 1. 移除 fixed 参数
- */
- var Tooltip = /*#__PURE__*/function () {
- var _proto = Tooltip.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * wether show the crosshairs
- * @type {Object}
- */
- showCrosshairs: false,
- /**
- * the style for crosshairs
- * @type {Object}
- */
- crosshairsStyle: {
- stroke: 'rgba(0, 0, 0, 0.25)',
- lineWidth: 1
- },
- /**
- * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
- */
- crosshairsType: 'y',
- /**
- * show or hide the x axis tip
- */
- showXTip: false,
- /**
- * show or hide the y axis tip
- */
- showYTip: false,
- xTip: null,
- xTipBackground: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- yTip: null,
- yTipBackground: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- /**
- * the style for tooltip container's background
- * @type {Object}
- */
- background: null,
- /**
- * layout, can be horizontal or vertical
- * @type {String}
- */
- layout: 'horizontal',
- offsetX: 0,
- offsetY: 0
- };
- };
- function Tooltip(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- var frontPlot = this.frontPlot,
- custom = this.custom;
- if (!custom) {
- // custom means user do customize
- var container = new Container(Util.mix({
- parent: frontPlot,
- zIndex: 3
- }, cfg));
- this.container = container;
- var fixed = this.fixed,
- background = this.background;
- if (!fixed) {
- this.tooltipArrow = frontPlot.addShape('Polygon', {
- className: 'tooltip-arrow',
- visible: false,
- zIndex: 2,
- attrs: Util.mix({
- points: []
- }, background)
- });
- }
- }
- if (this.showXTip) {
- var xTipBackground = this.xTipBackground;
- var xTipBox = new TextBox({
- className: 'xTip',
- background: xTipBackground,
- visible: false
- });
- frontPlot.add(xTipBox.container);
- this.xTipBox = xTipBox;
- }
- if (this.showYTip) {
- var yTipBackground = this.yTipBackground;
- var yTipBox = new TextBox({
- className: 'yTip',
- background: yTipBackground,
- visible: false
- });
- frontPlot.add(yTipBox.container);
- this.yTipBox = yTipBox;
- }
- if (this.showCrosshairs) {
- this._renderCrosshairs();
- }
- frontPlot.sort();
- }
- _proto.setContent = function setContent(title, items) {
- this.title = title;
- this.items = items;
- if (!this.custom) {
- var container = this.container;
- container.setTitle(title);
- container.setItems(items);
- }
- };
- _proto.setYTipContent = function setYTipContent(val) {
- var yTip = this.yTip;
- if (Util.isFunction(yTip)) {
- val = yTip(val);
- } else {
- val = Util.mix({
- text: val
- }, yTip);
- }
- this.yTipBox && this.yTipBox.updateContent(val);
- };
- _proto.setYTipPosition = function setYTipPosition(pos) {
- var plotRange = this.plotRange;
- var crosshairsShapeX = this.crosshairsShapeX;
- if (this.showYTip) {
- var yTipBox = this.yTipBox;
- var yTipHeight = yTipBox.getHeight();
- var yTipWidth = yTipBox.getWidth();
- var posX = plotRange.tl.x - yTipWidth;
- var posY = pos - yTipHeight / 2;
- if (posY <= plotRange.tl.y) {
- posY = plotRange.tl.y;
- }
- if (posY + yTipHeight >= plotRange.br.y) {
- posY = plotRange.br.y - yTipHeight;
- }
- if (posX < 0) {
- posX = plotRange.tl.x;
- crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
- }
- yTipBox.updatePosition(posX, posY);
- }
- };
- _proto.setXTipContent = function setXTipContent(val) {
- var xTip = this.xTip;
- if (Util.isFunction(xTip)) {
- val = xTip(val);
- } else {
- val = Util.mix({
- text: val
- }, xTip);
- }
- this.xTipBox && this.xTipBox.updateContent(val);
- };
- _proto.setXTipPosition = function setXTipPosition(pos) {
- var showXTip = this.showXTip,
- canvas = this.canvas,
- plotRange = this.plotRange,
- xTipBox = this.xTipBox,
- crosshairsShapeY = this.crosshairsShapeY;
- if (showXTip) {
- // const el = canvas.get('el');
- // const canvasHeight = Util.getHeight(el);
- var canvasHeight = canvas.get('height');
- var xTipWidth = xTipBox.getWidth();
- var xTipHeight = xTipBox.getHeight();
- var posX = pos - xTipWidth / 2;
- var posY = plotRange.br.y;
- if (posX <= plotRange.tl.x) {
- posX = plotRange.tl.x;
- }
- if (posX + xTipWidth >= plotRange.tr.x) {
- posX = plotRange.tr.x - xTipWidth;
- }
- if (canvasHeight - posY < xTipHeight) {
- posY -= xTipHeight;
- }
- xTipBox.updatePosition(posX, posY);
- crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
- }
- };
- _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
- this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
- };
- _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
- this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
- };
- _proto.setPosition = function setPosition(items) {
- var container = this.container,
- plotRange = this.plotRange,
- offsetX = this.offsetX,
- offsetY = this.offsetY,
- fixed = this.fixed,
- tooltipArrow = this.tooltipArrow;
- if (!container) {
- return;
- }
- var containerBBox = container.container.getBBox();
- var minX = containerBBox.minX,
- minY = containerBBox.minY,
- width = containerBBox.width,
- height = containerBBox.height;
- var tl = plotRange.tl,
- tr = plotRange.tr;
- var posX = 0;
- var posY = tl.y - height - GAP + offsetY;
- if (fixed) {
- var x = (tl.x + tr.x) / 2;
- posX = x - width / 2 + offsetX;
- } else {
- var _x;
- if (items.length > 1) {
- _x = (items[0].x + items[items.length - 1].x) / 2;
- } else {
- _x = items[0].x;
- }
- posX = _x - width / 2 + offsetX;
- if (posX < tl.x) {
- posX = tl.x;
- }
- if (posX + width > tr.x) {
- posX = tr.x - width;
- }
- if (tooltipArrow) {
- tooltipArrow.attr('points', [{
- x: _x - 3,
- y: tl.y - GAP + offsetY
- }, {
- x: _x + 3,
- y: tl.y - GAP + offsetY
- }, {
- x: _x,
- y: tl.y + offsetY
- }]);
- var backShape = container.backShape;
- var radius = Util.parsePadding(backShape.attr('radius'));
- if (_x === tl.x) {
- radius[3] = 0;
- tooltipArrow.attr('points', [{
- x: tl.x,
- y: tl.y + offsetY
- }, {
- x: tl.x,
- y: tl.y - GAP + offsetY
- }, {
- x: tl.x + GAP,
- y: tl.y - GAP + offsetY
- }]);
- } else if (_x === tr.x) {
- radius[2] = 0;
- tooltipArrow.attr('points', [{
- x: tr.x,
- y: tl.y + offsetY
- }, {
- x: tr.x - GAP,
- y: tl.y - GAP + offsetY
- }, {
- x: tr.x,
- y: tl.y - GAP + offsetY
- }]);
- }
- backShape.attr('radius', radius);
- }
- }
- container.moveTo(posX - minX, posY - minY);
- };
- _proto.setMarkers = function setMarkers(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var self = this;
- var _cfg = cfg,
- items = _cfg.items,
- style = _cfg.style,
- type = _cfg.type;
- var markerGroup = self._getMarkerGroup(type);
- if (type === 'circle') {
- for (var i = 0, length = items.length; i < length; i++) {
- var item = items[i];
- var marker = new Marker({
- className: 'tooltip-circle-marker',
- attrs: Util.mix({
- x: item.x,
- y: item.y,
- stroke: item.color
- }, style)
- });
- markerGroup.add(marker);
- }
- } else {
- markerGroup.addShape('rect', {
- className: 'tooltip-rect-marker',
- attrs: style
- });
- }
- };
- _proto.clearMarkers = function clearMarkers() {
- var markerGroup = this.markerGroup;
- markerGroup && markerGroup.clear();
- };
- _proto.show = function show() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- var canvas = this.canvas;
- crosshairsShapeX && crosshairsShapeX.show();
- crosshairsShapeY && crosshairsShapeY.show();
- markerGroup && markerGroup.show();
- container && container.show();
- tooltipArrow && tooltipArrow.show();
- xTipBox && xTipBox.show();
- yTipBox && yTipBox.show();
- canvas.draw();
- };
- _proto.hide = function hide() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- crosshairsShapeX && crosshairsShapeX.hide();
- crosshairsShapeY && crosshairsShapeY.hide();
- markerGroup && markerGroup.hide();
- container && container.hide();
- tooltipArrow && tooltipArrow.hide();
- xTipBox && xTipBox.hide();
- yTipBox && yTipBox.hide();
- };
- _proto.destroy = function destroy() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- crosshairsShapeX && crosshairsShapeX.remove(true);
- crosshairsShapeY && crosshairsShapeY.remove(true);
- markerGroup && markerGroup.remove(true);
- tooltipArrow && tooltipArrow.remove(true);
- container && container.clear();
- xTipBox && xTipBox.clear();
- yTipBox && yTipBox.clear();
- this.destroyed = true;
- };
- _proto._getMarkerGroup = function _getMarkerGroup(type) {
- var markerGroup = this.markerGroup;
- if (!markerGroup) {
- if (type === 'circle') {
- markerGroup = this.frontPlot.addGroup({
- zIndex: 1
- });
- this.frontPlot.sort();
- } else {
- markerGroup = this.backPlot.addGroup();
- }
- this.markerGroup = markerGroup;
- } else {
- markerGroup.clear();
- }
- return markerGroup;
- };
- _proto._renderCrosshairs = function _renderCrosshairs() {
- var crosshairsType = this.crosshairsType,
- crosshairsStyle = this.crosshairsStyle,
- frontPlot = this.frontPlot,
- plotRange = this.plotRange;
- var tl = plotRange.tl,
- br = plotRange.br;
- if (Util.directionEnabled(crosshairsType, 'x')) {
- this.crosshairsShapeX = frontPlot.addShape('Line', {
- className: 'tooltip-crosshairs-x',
- zIndex: 0,
- visible: false,
- attrs: Util.mix({
- x1: tl.x,
- y1: 0,
- x2: br.x,
- y2: 0
- }, crosshairsStyle)
- });
- }
- if (Util.directionEnabled(crosshairsType, 'y')) {
- this.crosshairsShapeY = frontPlot.addShape('Line', {
- className: 'tooltip-crosshairs-y',
- zIndex: 0,
- visible: false,
- attrs: Util.mix({
- x1: 0,
- y1: br.y,
- x2: 0,
- y2: tl.y
- }, crosshairsStyle)
- });
- }
- };
- return Tooltip;
- }();
- module.exports = Tooltip;
- /***/ }),
- /* 232 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(16),
- Group = _require.Group;
- var TextBox = /*#__PURE__*/function () {
- var _proto = TextBox.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- x: 0,
- y: 0,
- content: '',
- textStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- },
- background: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- width: 0,
- height: 0,
- className: ''
- };
- };
- function TextBox(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- this._init();
- var content = this.content,
- x = this.x,
- y = this.y;
- if (!Util.isNil(content)) {
- this.updateContent(content);
- }
- this.updatePosition(x, y);
- }
- _proto._init = function _init() {
- var content = this.content,
- textStyle = this.textStyle,
- background = this.background,
- className = this.className,
- visible = this.visible;
- var container = new Group({
- className: className,
- zIndex: 0,
- visible: visible
- });
- var text = container.addShape('Text', {
- className: className + '-text',
- zIndex: 1,
- attrs: Util.mix({
- text: content,
- x: 0,
- y: 0
- }, textStyle)
- });
- var backgroundShape = container.addShape('Rect', {
- className: className + '-bg',
- zIndex: -1,
- attrs: Util.mix({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }, background)
- });
- container.sort();
- this.container = container;
- this.textShape = text;
- this.backgroundShape = backgroundShape;
- };
- _proto._getBBox = function _getBBox() {
- var textShape = this.textShape;
- var background = this.background;
- var textBBox = textShape.getBBox();
- var padding = Util.parsePadding(background.padding);
- var width = textBBox.width + padding[1] + padding[3];
- var height = textBBox.height + padding[0] + padding[2];
- var x = textBBox.minX - padding[3];
- var y = textBBox.minY - padding[0];
- return {
- x: x,
- y: y,
- width: width,
- height: height
- };
- };
- _proto.updateContent = function updateContent(text) {
- var textShape = this.textShape,
- backgroundShape = this.backgroundShape;
- if (!Util.isNil(text)) {
- if (!Util.isObject(text)) {
- text = {
- text: text
- };
- }
- textShape.attr(text); // update box shape
- var _this$_getBBox = this._getBBox(),
- x = _this$_getBBox.x,
- y = _this$_getBBox.y,
- tipWidth = _this$_getBBox.width,
- tipHeight = _this$_getBBox.height;
- var width = this.width || tipWidth;
- var height = this.height || tipHeight;
- backgroundShape.attr({
- x: x,
- y: y,
- width: width,
- height: height
- });
- this._width = width;
- this._height = height;
- this.content = text.text;
- }
- };
- _proto.updatePosition = function updatePosition(x, y) {
- var container = this.container;
- var _this$_getBBox2 = this._getBBox(),
- xMin = _this$_getBBox2.x,
- yMin = _this$_getBBox2.y;
- container.moveTo(x - xMin, y - yMin);
- this.x = x - xMin;
- this.y = y - yMin;
- };
- _proto.getWidth = function getWidth() {
- return this._width;
- };
- _proto.getHeight = function getHeight() {
- return this._height;
- };
- _proto.show = function show() {
- this.container.show();
- };
- _proto.hide = function hide() {
- this.container.hide();
- };
- _proto.clear = function clear() {
- var container = this.container;
- container.clear();
- container.remove(true);
- this.container = null;
- this.textShape = null;
- this.backgroundShape = null;
- };
- return TextBox;
- }();
- module.exports = TextBox;
- /***/ }),
- /* 233 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Guide = __webpack_require__(23);
- var Global = __webpack_require__(6); // register the default configuration for Guide
- Global.guide = Util.deepMix({
- line: {
- style: {
- stroke: '#a3a3a3',
- lineWidth: 1
- },
- top: true
- },
- text: {
- style: {
- fill: '#787878',
- textAlign: 'center',
- textBaseline: 'middle'
- },
- offsetX: 0,
- offsetY: 0,
- top: true
- },
- rect: {
- style: {
- fill: '#fafafa'
- },
- top: false
- },
- arc: {
- style: {
- stroke: '#a3a3a3'
- },
- top: true
- },
- html: {
- offsetX: 0,
- offsetY: 0,
- alignX: 'center',
- alignY: 'middle'
- },
- tag: {
- top: true,
- offsetX: 0,
- offsetY: 0,
- side: 4,
- background: {
- padding: 5,
- radius: 2,
- fill: '#1890FF'
- },
- textStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- }
- },
- point: {
- top: true,
- offsetX: 0,
- offsetY: 0,
- style: {
- fill: '#fff',
- r: 3,
- lineWidth: 2,
- stroke: '#1890ff'
- }
- }
- }, Global.guide || {});
- var GuideController = /*#__PURE__*/function () {
- function GuideController(cfg) {
- this.guides = [];
- this.xScale = null;
- this.yScales = null;
- this.guideShapes = [];
- Util.mix(this, cfg);
- }
- var _proto = GuideController.prototype;
- _proto._toString = function _toString(position) {
- if (Util.isFunction(position)) {
- position = position(this.xScale, this.yScales);
- }
- position = position.toString();
- return position;
- };
- _proto._getId = function _getId(shape, guide) {
- var id = guide.id;
- if (!id) {
- var type = guide.type;
- if (type === 'arc' || type === 'line' || type === 'rect') {
- id = this._toString(guide.start) + '-' + this._toString(guide.end);
- } else {
- id = this._toString(guide.position);
- }
- }
- return id;
- };
- _proto.paint = function paint(coord) {
- var self = this;
- var chart = self.chart,
- guides = self.guides,
- xScale = self.xScale,
- yScales = self.yScales;
- var guideShapes = [];
- Util.each(guides, function (guide, idx) {
- guide.xScale = xScale;
- guide.yScales = yScales;
- var container;
- if (guide.type === 'regionFilter') {
- // TODO: RegionFilter support animation
- guide.chart = chart;
- } else {
- container = guide.top ? self.frontPlot : self.backPlot;
- }
- guide.coord = coord;
- guide.container = container;
- guide.canvas = chart.get('canvas');
- var shape = guide.render(coord, container);
- if (shape) {
- var id = self._getId(shape, guide);
- [].concat(shape).forEach(function (s) {
- s._id = s.get('className') + '-' + id;
- s.set('index', idx);
- guideShapes.push(s);
- });
- }
- });
- self.guideShapes = guideShapes;
- };
- _proto.clear = function clear() {
- this.reset();
- this.guides = [];
- return this;
- };
- _proto.reset = function reset() {
- var guides = this.guides;
- Util.each(guides, function (guide) {
- guide.remove();
- });
- };
- _proto._createGuide = function _createGuide(type, cfg) {
- var ClassName = Util.upperFirst(type);
- var guide = new Guide[ClassName](Util.deepMix({}, Global.guide[type], cfg));
- this.guides.push(guide);
- return guide;
- };
- _proto.line = function line(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('line', cfg);
- };
- _proto.text = function text(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('text', cfg);
- };
- _proto.arc = function arc(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('arc', cfg);
- };
- _proto.html = function html(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('html', cfg);
- };
- _proto.rect = function rect(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('rect', cfg);
- };
- _proto.tag = function tag(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('tag', cfg);
- };
- _proto.point = function point(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('point', cfg);
- };
- _proto.regionFilter = function regionFilter(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('regionFilter', cfg);
- };
- return GuideController;
- }();
- module.exports = {
- init: function init(chart) {
- var guideController = new GuideController({
- frontPlot: chart.get('frontPlot').addGroup({
- zIndex: 20,
- className: 'guideContainer'
- }),
- backPlot: chart.get('backPlot').addGroup({
- className: 'guideContainer'
- })
- });
- chart.set('guideController', guideController);
- /**
- * 为图表添加 guide
- * @return {GuideController} 返回 guide 控制器
- */
- chart.guide = function () {
- return guideController;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var guideController = chart.get('guideController');
- if (!guideController.guides.length) {
- return;
- }
- var xScale = chart.getXScale();
- var yScales = chart.getYScales();
- var coord = chart.get('coord');
- guideController.xScale = xScale;
- guideController.yScales = yScales;
- guideController.chart = chart; // for regionFilter
- guideController.paint(coord);
- },
- clear: function clear(chart) {
- chart.get('guideController').clear();
- },
- repaint: function repaint(chart) {
- chart.get('guideController').reset();
- }
- };
- /***/ }),
- /* 234 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var List = __webpack_require__(205);
- var Global = __webpack_require__(6);
- var LEGEND_GAP = 12;
- var MARKER_SIZE = 3;
- var DEFAULT_CFG = {
- itemMarginBottom: 12,
- itemGap: 10,
- showTitle: false,
- titleStyle: {
- fontSize: 12,
- fill: '#808080',
- textAlign: 'start',
- textBaseline: 'top'
- },
- nameStyle: {
- fill: '#808080',
- fontSize: 12,
- textAlign: 'start',
- textBaseline: 'middle'
- },
- valueStyle: {
- fill: '#000000',
- fontSize: 12,
- textAlign: 'start',
- textBaseline: 'middle'
- },
- unCheckStyle: {
- fill: '#bfbfbf'
- },
- itemWidth: 'auto',
- wordSpace: 6,
- selectedMode: 'multiple' // 'multiple' or 'single'
- }; // Register the default configuration for Legend
- Global.legend = Util.deepMix({
- common: DEFAULT_CFG,
- // common legend configuration
- right: Util.mix({
- position: 'right',
- layout: 'vertical'
- }, DEFAULT_CFG),
- left: Util.mix({
- position: 'left',
- layout: 'vertical'
- }, DEFAULT_CFG),
- top: Util.mix({
- position: 'top',
- layout: 'horizontal'
- }, DEFAULT_CFG),
- bottom: Util.mix({
- position: 'bottom',
- layout: 'horizontal'
- }, DEFAULT_CFG)
- }, Global.legend || {});
- function getPaddingByPos(pos, appendPadding) {
- var padding = 0;
- appendPadding = Util.parsePadding(appendPadding);
- switch (pos) {
- case 'top':
- padding = appendPadding[0];
- break;
- case 'right':
- padding = appendPadding[1];
- break;
- case 'bottom':
- padding = appendPadding[2];
- break;
- case 'left':
- padding = appendPadding[3];
- break;
- default:
- break;
- }
- return padding;
- }
- var LegendController = /*#__PURE__*/function () {
- function LegendController(cfg) {
- var _this = this;
- this.handleEvent = function (ev) {
- var self = _this;
- function findItem(x, y) {
- var result = null;
- var legends = self.legends;
- Util.each(legends, function (legendItems) {
- Util.each(legendItems, function (legend) {
- var itemsGroup = legend.itemsGroup,
- legendHitBoxes = legend.legendHitBoxes;
- var children = itemsGroup.get('children');
- if (children.length) {
- var legendPosX = legend.x;
- var legendPosY = legend.y;
- Util.each(legendHitBoxes, function (box, index) {
- if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
- // inbox
- result = {
- clickedItem: children[index],
- clickedLegend: legend
- };
- return false;
- }
- });
- }
- });
- });
- return result;
- }
- var chart = self.chart;
- var _Util$createEvent = Util.createEvent(ev, chart),
- x = _Util$createEvent.x,
- y = _Util$createEvent.y;
- var clicked = findItem(x, y);
- if (clicked && clicked.clickedLegend.clickable !== false) {
- var clickedItem = clicked.clickedItem,
- clickedLegend = clicked.clickedLegend;
- if (clickedLegend.onClick) {
- ev.clickedItem = clickedItem;
- clickedLegend.onClick(ev);
- } else if (!clickedLegend.custom) {
- var checked = clickedItem.get('checked');
- var value = clickedItem.get('dataValue');
- var filteredVals = clickedLegend.filteredVals,
- field = clickedLegend.field,
- selectedMode = clickedLegend.selectedMode;
- var isSingeSelected = selectedMode === 'single';
- if (isSingeSelected) {
- chart.filter(field, function (val) {
- return val === value;
- });
- } else {
- if (checked) {
- filteredVals.push(value);
- } else {
- Util.Array.remove(filteredVals, value);
- }
- chart.filter(field, function (val) {
- return filteredVals.indexOf(val) === -1;
- });
- }
- chart.repaint();
- }
- }
- };
- this.legendCfg = {};
- this.enable = true;
- this.position = 'top';
- Util.mix(this, cfg);
- var _chart = this.chart;
- this.canvasDom = _chart.get('canvas').get('el');
- this.clear();
- }
- var _proto = LegendController.prototype;
- _proto.addLegend = function addLegend(scale, items, filteredVals) {
- var self = this;
- var legendCfg = self.legendCfg;
- var field = scale.field;
- var fieldCfg = legendCfg[field];
- if (fieldCfg === false) {
- return null;
- }
- if (fieldCfg && fieldCfg.custom) {
- self.addCustomLegend(field);
- } else {
- var position = legendCfg.position || self.position;
- if (fieldCfg && fieldCfg.position) {
- position = fieldCfg.position;
- }
- if (scale.isCategory) {
- self._addCategoryLegend(scale, items, position, filteredVals);
- }
- }
- };
- _proto.addCustomLegend = function addCustomLegend(field) {
- var self = this;
- var legendCfg = self.legendCfg;
- if (field && legendCfg[field]) {
- legendCfg = legendCfg[field];
- }
- var position = legendCfg.position || self.position;
- var legends = self.legends;
- legends[position] = legends[position] || [];
- var items = legendCfg.items;
- if (!items) {
- return null;
- }
- var container = self.container;
- Util.each(items, function (item) {
- if (!Util.isPlainObject(item.marker)) {
- item.marker = {
- symbol: item.marker || 'circle',
- fill: item.fill,
- radius: MARKER_SIZE
- };
- } else {
- item.marker.radius = item.marker.radius || MARKER_SIZE;
- }
- item.checked = Util.isNil(item.checked) ? true : item.checked;
- item.name = item.name || item.value;
- });
- var legend = new List(Util.deepMix({}, Global.legend[position], legendCfg, {
- maxLength: self._getMaxLength(position),
- items: items,
- parent: container
- }));
- legends[position].push(legend);
- };
- _proto.clear = function clear() {
- var legends = this.legends;
- Util.each(legends, function (legendItems) {
- Util.each(legendItems, function (legend) {
- legend.clear();
- });
- });
- this.legends = {};
- this.unBindEvents();
- };
- _proto._isFiltered = function _isFiltered(scale, values, value) {
- var rst = false;
- Util.each(values, function (val) {
- rst = rst || scale.getText(val) === scale.getText(value);
- if (rst) {
- return false;
- }
- });
- return rst;
- };
- _proto._getMaxLength = function _getMaxLength(position) {
- var chart = this.chart;
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
- };
- _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filteredVals) {
- var self = this;
- var legendCfg = self.legendCfg,
- legends = self.legends,
- container = self.container,
- chart = self.chart;
- var field = scale.field;
- legends[position] = legends[position] || [];
- var symbol = 'circle';
- if (legendCfg[field] && legendCfg[field].marker) {
- symbol = legendCfg[field].marker;
- } else if (legendCfg.marker) {
- symbol = legendCfg.marker;
- }
- Util.each(items, function (item) {
- if (Util.isPlainObject(symbol)) {
- Util.mix(item.marker, symbol);
- } else {
- item.marker.symbol = symbol;
- }
- if (filteredVals) {
- item.checked = !self._isFiltered(scale, filteredVals, item.dataValue);
- }
- });
- var legendItems = chart.get('legendItems');
- legendItems[field] = items;
- var lastCfg = Util.deepMix({}, Global.legend[position], legendCfg[field] || legendCfg, {
- maxLength: self._getMaxLength(position),
- items: items,
- field: field,
- filteredVals: filteredVals,
- parent: container
- });
- if (lastCfg.showTitle) {
- Util.deepMix(lastCfg, {
- title: scale.alias || scale.field
- });
- }
- var legend = new List(lastCfg);
- legends[position].push(legend);
- return legend;
- };
- _proto._alignLegend = function _alignLegend(legend, pre, position) {
- var self = this;
- var _self$plotRange = self.plotRange,
- tl = _self$plotRange.tl,
- bl = _self$plotRange.bl;
- var chart = self.chart;
- var offsetX = legend.offsetX || 0;
- var offsetY = legend.offsetY || 0;
- var chartWidth = chart.get('width');
- var chartHeight = chart.get('height');
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- var legendHeight = legend.getHeight();
- var legendWidth = legend.getWidth();
- var x = 0;
- var y = 0;
- if (position === 'left' || position === 'right') {
- var verticalAlign = legend.verticalAlign || 'middle';
- var height = Math.abs(tl.y - bl.y);
- x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
- y = (height - legendHeight) / 2 + tl.y;
- if (verticalAlign === 'top') {
- y = tl.y;
- } else if (verticalAlign === 'bottom') {
- y = bl.y - legendHeight;
- }
- if (pre) {
- y = pre.get('y') - legendHeight - LEGEND_GAP;
- }
- } else {
- var align = legend.align || 'left';
- x = appendPadding[3];
- if (align === 'center') {
- x = chartWidth / 2 - legendWidth / 2;
- } else if (align === 'right') {
- x = chartWidth - (legendWidth + appendPadding[1]);
- }
- y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;
- if (pre) {
- var preWidth = pre.getWidth();
- x = pre.x + preWidth + LEGEND_GAP;
- }
- }
- if (position === 'bottom' && offsetY > 0) {
- offsetY = 0;
- }
- if (position === 'right' && offsetX > 0) {
- offsetX = 0;
- }
- legend.moveTo(x + offsetX, y + offsetY);
- };
- _proto.alignLegends = function alignLegends() {
- var self = this;
- var legends = self.legends;
- Util.each(legends, function (legendItems, position) {
- Util.each(legendItems, function (legend, index) {
- var pre = legendItems[index - 1];
- self._alignLegend(legend, pre, position);
- });
- });
- return self;
- };
- _proto.bindEvents = function bindEvents() {
- var legendCfg = this.legendCfg;
- var triggerOn = legendCfg.triggerOn || 'touchstart';
- Util.addEventListener(this.canvasDom, triggerOn, this.handleEvent);
- };
- _proto.unBindEvents = function unBindEvents() {
- var legendCfg = this.legendCfg;
- var triggerOn = legendCfg.triggerOn || 'touchstart';
- Util.removeEventListener(this.canvasDom, triggerOn, this.handleEvent);
- };
- return LegendController;
- }();
- module.exports = {
- init: function init(chart) {
- var legendController = new LegendController({
- container: chart.get('backPlot'),
- plotRange: chart.get('plotRange'),
- chart: chart
- });
- chart.set('legendController', legendController);
- chart.legend = function (field, cfg) {
- var legendCfg = legendController.legendCfg;
- legendController.enable = true;
- if (Util.isBoolean(field)) {
- legendController.enable = field;
- legendCfg = cfg || {};
- } else if (Util.isObject(field)) {
- legendCfg = field;
- } else {
- legendCfg[field] = cfg;
- }
- legendController.legendCfg = legendCfg;
- return this;
- };
- },
- beforeGeomDraw: function beforeGeomDraw(chart) {
- var legendController = chart.get('legendController');
- if (!legendController.enable) return null; // legend is not displayed
- var legendCfg = legendController.legendCfg;
- if (legendCfg && legendCfg.custom) {
- legendController.addCustomLegend();
- } else {
- var legendItems = chart.getLegendItems();
- var scales = chart.get('scales');
- var filters = chart.get('filters');
- Util.each(legendItems, function (items, field) {
- var scale = scales[field];
- var values = scale.values;
- var filteredVals;
- if (filters && filters[field]) {
- filteredVals = values.filter(function (v) {
- return !filters[field](v);
- });
- } else {
- filteredVals = [];
- }
- legendController.addLegend(scale, items, filteredVals);
- });
- }
- if (legendCfg && legendCfg.clickable !== false) {
- legendController.bindEvents();
- }
- var legends = legendController.legends;
- var legendRange = {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- Util.each(legends, function (legendItems, position) {
- var padding = 0;
- Util.each(legendItems, function (legend) {
- var width = legend.getWidth();
- var height = legend.getHeight();
- if (position === 'top' || position === 'bottom') {
- padding = Math.max(padding, height);
- if (legend.offsetY > 0) {
- padding += legend.offsetY;
- }
- } else {
- padding = Math.max(padding, width);
- if (legend.offsetX > 0) {
- padding += legend.offsetX;
- }
- }
- });
- legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
- });
- chart.set('legendRange', legendRange);
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var legendController = chart.get('legendController');
- legendController.alignLegends();
- },
- clearInner: function clearInner(chart) {
- var legendController = chart.get('legendController');
- legendController.clear();
- chart.set('legendRange', null);
- }
- };
- /***/ }),
- /* 235 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * Handle the detail animations
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(46);
- var Timeline = __webpack_require__(236);
- var Animator = __webpack_require__(237);
- var Animate = __webpack_require__(206);
- var ShapeAction = __webpack_require__(239);
- var GroupAction = __webpack_require__(240);
- var Chart = __webpack_require__(30);
- var timeline;
- Element.prototype.animate = function () {
- var attrs = Util.mix({}, this.get('attrs'));
- return new Animator(this, attrs, timeline);
- };
- Chart.prototype.animate = function (cfg) {
- this.set('animate', cfg);
- return this;
- };
- Animate.Action = ShapeAction;
- Animate.defaultCfg = {
- interval: {
- enter: function enter(coord) {
- if (coord.isPolar && coord.transposed) {
- // for pie chart
- return function (shape) {
- shape.set('zIndex', -1);
- var container = shape.get('parent');
- container.sort();
- };
- }
- return ShapeAction.fadeIn;
- }
- },
- area: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- },
- line: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- },
- path: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- }
- };
- var GROUP_ANIMATION = {
- line: function line(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- area: function area(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- path: function path(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- point: function point() {
- return GroupAction.shapesScaleInXY;
- },
- interval: function interval(coord) {
- var result;
- if (coord.isPolar) {
- // polar coodinate
- result = GroupAction.groupScaleInXY;
- if (coord.transposed) {
- // pie chart
- result = GroupAction.groupWaveIn;
- }
- } else {
- result = coord.transposed ? GroupAction.groupScaleInX : GroupAction.groupScaleInY;
- }
- return result;
- },
- schema: function schema() {
- return GroupAction.groupWaveIn;
- }
- };
- function diff(fromAttrs, toAttrs) {
- var endState = {};
- for (var k in toAttrs) {
- if (Util.isNumber(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
- endState[k] = toAttrs[k];
- } else if (Util.isArray(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
- endState[k] = toAttrs[k];
- }
- }
- return endState;
- } // Add a unique id identifier to each shape
- function _getShapeId(geom, dataObj, geomIdx) {
- var type = geom.get('type');
- var id = 'geom' + geomIdx + '-' + type;
- var xScale = geom.getXScale();
- var yScale = geom.getYScale();
- var xField = xScale.field || 'x';
- var yField = yScale.field || 'y';
- var yVal = dataObj[yField];
- var xVal;
- if (xScale.isIdentity) {
- xVal = xScale.value;
- } else {
- xVal = dataObj[xField];
- }
- if (type === 'interval' || type === 'schema') {
- id += '-' + xVal;
- } else if (type === 'line' || type === 'area' || type === 'path') {
- id += '-' + type;
- } else {
- id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
- }
- var groupScales = geom._getGroupScales();
- Util.each(groupScales, function (groupScale) {
- var field = groupScale.field;
- if (groupScale.type !== 'identity') {
- id += '-' + dataObj[field];
- }
- });
- return id;
- } // get geometry's shapes
- function getShapes(geoms, chart, coord) {
- var shapes = [];
- Util.each(geoms, function (geom, geomIdx) {
- var geomContainer = geom.get('container');
- var geomShapes = geomContainer.get('children');
- var type = geom.get('type');
- var animateCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
- if (animateCfg !== false) {
- Util.each(geomShapes, function (shape, index) {
- if (shape.get('className') === type) {
- shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
- shape.set('coord', coord);
- shape.set('animateCfg', animateCfg);
- shape.set('index', index);
- shapes.push(shape);
- }
- });
- }
- geom.set('shapes', geomShapes);
- });
- return shapes;
- }
- function cache(shapes) {
- var rst = {};
- for (var i = 0, len = shapes.length; i < len; i++) {
- var shape = shapes[i];
- if (!shape._id || shape.isClip) continue;
- var id = shape._id;
- rst[id] = {
- _id: id,
- type: shape.get('type'),
- // the type of shape
- attrs: Util.mix({}, shape._attrs.attrs),
- // the graphics attributes of shape
- className: shape.get('className'),
- geomType: shape.get('className'),
- index: shape.get('index'),
- coord: shape.get('coord'),
- animateCfg: shape.get('animateCfg')
- };
- }
- return rst;
- }
- function getAnimate(geomType, coord, animationType, animationName) {
- var result;
- if (Util.isFunction(animationName)) {
- result = animationName;
- } else if (Util.isString(animationName)) {
- result = Animate.Action[animationName];
- } else {
- result = Animate.getAnimation(geomType, coord, animationType);
- }
- return result;
- }
- function getAnimateCfg(geomType, animationType, animateCfg) {
- if (animateCfg === false || Util.isObject(animateCfg) && animateCfg[animationType] === false) {
- return false;
- }
- var defaultCfg = Animate.getAnimateCfg(geomType, animationType);
- if (animateCfg && animateCfg[animationType]) {
- return Util.deepMix({}, defaultCfg, animateCfg[animationType]);
- }
- return defaultCfg;
- }
- function addAnimate(cache, shapes, canvas) {
- var animate;
- var animateCfg; // the order of animation: leave -> update -> enter
- var updateShapes = [];
- var newShapes = [];
- Util.each(shapes, function (shape) {
- var result = cache[shape._id];
- if (!result) {
- newShapes.push(shape);
- } else {
- shape.set('cacheShape', result);
- updateShapes.push(shape);
- delete cache[shape._id];
- }
- }); // first do the leave animation
- Util.each(cache, function (deletedShape) {
- var className = deletedShape.className,
- coord = deletedShape.coord,
- _id = deletedShape._id,
- attrs = deletedShape.attrs,
- index = deletedShape.index,
- type = deletedShape.type;
- animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
- if (animateCfg === false) return true;
- animate = getAnimate(className, coord, 'leave', animateCfg.animation);
- if (Util.isFunction(animate)) {
- var tempShape = canvas.addShape(type, {
- attrs: attrs,
- index: index,
- canvas: canvas,
- className: className
- });
- tempShape._id = _id;
- animate(tempShape, animateCfg, coord);
- }
- }); // then do the update animation
- Util.each(updateShapes, function (updateShape) {
- var className = updateShape.get('className');
- animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
- if (animateCfg === false) return true;
- var coord = updateShape.get('coord');
- var cacheAttrs = updateShape.get('cacheShape').attrs;
- var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换
- if (Object.keys(endState).length) {
- animate = getAnimate(className, coord, 'update', animateCfg.animation);
- if (Util.isFunction(animate)) {
- animate(updateShape, animateCfg, coord);
- } else {
- updateShape.attr(cacheAttrs);
- updateShape.animate().to({
- attrs: endState,
- duration: animateCfg.duration,
- easing: animateCfg.easing,
- delay: animateCfg.delay
- }).onEnd(function () {
- updateShape.set('cacheShape', null);
- });
- }
- }
- }); // last, enter animation
- Util.each(newShapes, function (newShape) {
- // 新图形元素的进场元素
- var className = newShape.get('className');
- var coord = newShape.get('coord');
- animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
- if (animateCfg === false) return true;
- animate = getAnimate(className, coord, 'enter', animateCfg.animation);
- if (Util.isFunction(animate)) {
- if (className === 'interval' && coord.isPolar && coord.transposed) {
- var index = newShape.get('index');
- var lastShape = updateShapes[index - 1];
- animate(newShape, animateCfg, lastShape);
- } else {
- animate(newShape, animateCfg, coord);
- }
- }
- });
- }
- function _getAnimateCfgByShapeType(type, chart) {
- if (!type) {
- return null;
- }
- var animateCfg = chart.get('animate');
- if (type.indexOf('guide-tag') > -1) {
- type = 'guide-tag';
- }
- if (Util.isObject(animateCfg)) {
- return animateCfg[type];
- }
- if (animateCfg === false) {
- return false;
- }
- return null;
- }
- module.exports = {
- afterCanvasInit: function afterCanvasInit()
- /* chart */
- {
- timeline = new Timeline();
- timeline.play();
- },
- beforeCanvasDraw: function beforeCanvasDraw(chart) {
- if (chart.get('animate') === false) {
- return;
- }
- var isUpdate = chart.get('isUpdate');
- var canvas = chart.get('canvas');
- var coord = chart.get('coord');
- var geoms = chart.get('geoms');
- var caches = canvas.get('caches') || [];
- if (caches.length === 0) {
- isUpdate = false;
- }
- var cacheShapes = getShapes(geoms, chart, coord);
- var _chart$get = chart.get('axisController'),
- frontPlot = _chart$get.frontPlot,
- backPlot = _chart$get.backPlot;
- var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
- var guideShapes = [];
- if (chart.get('guideController')) {
- guideShapes = chart.get('guideController').guideShapes;
- }
- var componentShapes = [];
- axisShapes.concat(guideShapes).forEach(function (s) {
- var className = s.get('className');
- var animateCfg = _getAnimateCfgByShapeType(className, chart);
- s.set('coord', coord);
- s.set('animateCfg', animateCfg);
- componentShapes.push(s);
- cacheShapes.push(s);
- });
- canvas.set('caches', cache(cacheShapes));
- if (isUpdate) {
- addAnimate(caches, cacheShapes, canvas);
- } else {
- // do the appear animation
- var animateCfg;
- var animate;
- Util.each(geoms, function (geom) {
- var type = geom.get('type');
- var geomCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
- if (geomCfg !== false) {
- animateCfg = getAnimateCfg(type, 'appear', geomCfg);
- animate = getAnimate(type, coord, 'appear', animateCfg.animation);
- if (Util.isFunction(animate)) {
- var shapes = geom.get('shapes');
- Util.each(shapes, function (shape) {
- animate(shape, animateCfg, coord);
- });
- } else if (GROUP_ANIMATION[type]) {
- // do the default animation
- animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
- var yScale = geom.getYScale();
- var zeroY = coord.convertPoint({
- x: 0,
- y: yScale.scale(geom.getYMinValue())
- });
- var container = geom.get('container');
- animate && animate(container, animateCfg, coord, zeroY);
- }
- }
- }); // do the animation of components
- Util.each(componentShapes, function (shape) {
- var animateCfg = shape.get('animateCfg');
- var className = shape.get('className');
- if (animateCfg && animateCfg.appear) {
- // if user configure
- var defaultCfg = Animate.getAnimateCfg(className, 'appear');
- var appearCfg = Util.deepMix({}, defaultCfg, animateCfg.appear);
- var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);
- if (Util.isFunction(_animate)) {
- _animate(shape, appearCfg, coord);
- }
- }
- });
- }
- },
- afterCanvasDestroyed: function afterCanvasDestroyed()
- /* chart */
- {
- timeline.stop();
- }
- };
- /***/ }),
- /* 236 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _require = __webpack_require__(70),
- requestAnimationFrame = _require.requestAnimationFrame;
- var clock = typeof performance === 'object' && performance.now ? performance : Date;
- var Timeline = /*#__PURE__*/function () {
- function Timeline() {
- this.anims = [];
- this.time = null;
- this.playing = false;
- this.canvas = [];
- }
- var _proto = Timeline.prototype;
- _proto.play = function play() {
- var self = this;
- self.time = clock.now();
- self.playing = true;
- function step() {
- if (self.playing) {
- requestAnimationFrame(step);
- self.update();
- }
- }
- requestAnimationFrame(step);
- };
- _proto.stop = function stop() {
- this.playing = false;
- this.time = null;
- this.canvas = [];
- };
- _proto.update = function update() {
- var currentTime = clock.now();
- this.canvas = [];
- for (var i = 0; i < this.anims.length; i++) {
- var propertyAnim = this.anims[i];
- if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
- continue;
- }
- var shape = propertyAnim.shape; // shape
- if (shape.get('destroyed')) {
- this.anims.splice(i, 1);
- i--;
- continue;
- }
- var startState = propertyAnim.startState,
- endState = propertyAnim.endState,
- interpolate = propertyAnim.interpolate,
- duration = propertyAnim.duration;
- if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
- propertyAnim.hasStarted = true;
- if (propertyAnim.onStart) {
- propertyAnim.onStart();
- }
- }
- var t = (currentTime - propertyAnim.startTime) / duration;
- t = Math.max(0, Math.min(t, 1));
- t = propertyAnim.easing(t);
- if (propertyAnim.onFrame) {
- propertyAnim.onFrame(t);
- } else {
- for (var key in interpolate) {
- var diff = interpolate[key];
- var value = diff(t);
- var newValue = void 0;
- if (key === 'points') {
- newValue = [];
- var aLen = Math.max(startState.points.length, endState.points.length);
- for (var j = 0; j < aLen; j += 2) {
- newValue.push({
- x: value[j],
- y: value[j + 1]
- });
- }
- } else {
- newValue = value;
- }
- shape._attrs.attrs[key] = newValue;
- shape._attrs.bbox = null; // should clear calculated bbox
- }
- }
- var canvas = shape.get('canvas');
- if (this.canvas.indexOf(canvas) === -1) {
- this.canvas.push(canvas);
- }
- if (propertyAnim.onUpdate) {
- propertyAnim.onUpdate(t);
- }
- if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
- propertyAnim.hasEnded = true;
- if (propertyAnim.onEnd) {
- propertyAnim.onEnd();
- }
- }
- if (t === 1) {
- // end
- this.anims.splice(i, 1);
- i--;
- }
- }
- this.canvas.map(function (c) {
- c.draw();
- return c;
- });
- this.time = clock.now();
- };
- return Timeline;
- }();
- module.exports = Timeline;
- /***/ }),
- /* 237 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Easing = __webpack_require__(238);
- function plainArray(arr) {
- var result = [];
- for (var i = 0, len = arr.length; i < len; i++) {
- if (arr[i]) {
- result.push(arr[i].x);
- result.push(arr[i].y);
- }
- }
- return result;
- }
- function interpolateNumber(a, b) {
- a = +a;
- b -= a;
- return function (t) {
- return a + b * t;
- };
- }
- function interpolateArray(a, b) {
- var nb = b ? b.length : 0;
- var na = a ? Math.min(nb, a.length) : 0;
- var x = new Array(na);
- var c = new Array(nb);
- var i;
- for (i = 0; i < na; ++i) {
- x[i] = interpolateNumber(a[i], b[i]);
- }
- for (; i < nb; ++i) {
- c[i] = b[i];
- }
- return function (t) {
- for (i = 0; i < na; ++i) {
- c[i] = x[i](t);
- }
- return c;
- };
- }
- var Animator = /*#__PURE__*/function () {
- function Animator(shape, source, timeline) {
- this.hasStarted = false;
- this.hasEnded = false;
- this.shape = shape;
- this.source = source;
- this.timeline = timeline;
- this.animate = null;
- } // delay, attrs, duration, easing
- var _proto = Animator.prototype;
- _proto.to = function to(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var delay = cfg.delay || 0;
- var attrs = cfg.attrs || {};
- var duration = cfg.duration || 1000;
- var easing; // 缓动函数
- if (typeof cfg.easing === 'function') {
- easing = cfg.easing;
- } else {
- easing = Easing[cfg.easing] || Easing.linear;
- }
- var animInfo = {
- shape: this.shape,
- startTime: this.timeline.time + delay,
- duration: duration,
- easing: easing
- };
- var interpolate = {}; // 差值函数
- for (var attrName in attrs) {
- var startValue = this.source[attrName];
- var endValue = attrs[attrName];
- if (attrName === 'points') {
- startValue = plainArray(startValue);
- endValue = plainArray(endValue);
- interpolate.points = interpolateArray(startValue, endValue);
- this.source.points = startValue;
- attrs.points = endValue;
- } else if (attrName === 'matrix') {
- interpolate.matrix = interpolateArray(startValue, endValue);
- } else {
- interpolate[attrName] = interpolateNumber(startValue, endValue);
- }
- }
- animInfo.interpolate = interpolate;
- animInfo.startState = this.source;
- animInfo.endState = attrs;
- animInfo.endTime = animInfo.startTime + duration;
- this.timeline.anims.push(animInfo);
- this.animate = animInfo;
- return this;
- };
- _proto.onFrame = function onFrame(callback) {
- // 自定义每一帧动画的动作
- if (this.animate) {
- this.animate.onFrame = function (frame) {
- callback(frame);
- };
- }
- return this;
- };
- _proto.onStart = function onStart(callback) {
- if (this.animate) {
- this.animate.onStart = function () {
- callback();
- };
- }
- return this;
- };
- _proto.onUpdate = function onUpdate(callback) {
- if (this.animate) {
- this.animate.onUpdate = function (frame) {
- callback(frame);
- };
- }
- return this;
- };
- _proto.onEnd = function onEnd(callback) {
- if (this.animate) {
- this.animate.onEnd = function () {
- callback();
- };
- }
- return this;
- };
- return Animator;
- }();
- module.exports = Animator;
- /***/ }),
- /* 238 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Easing = {
- linear: function linear(k) {
- return k;
- },
- quadraticIn: function quadraticIn(k) {
- return k * k;
- },
- quadraticOut: function quadraticOut(k) {
- return k * (2 - k);
- },
- quadraticInOut: function quadraticInOut(k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k;
- }
- return -0.5 * (--k * (k - 2) - 1);
- },
- cubicIn: function cubicIn(k) {
- return k * k * k;
- },
- cubicOut: function cubicOut(k) {
- return --k * k * k + 1;
- },
- cubicInOut: function cubicInOut(k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k + 2);
- },
- elasticIn: function elasticIn(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- },
- elasticOut: function elasticOut(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
- },
- elasticInOut: function elasticInOut(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- if ((k *= 2) < 1) {
- return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- }
- return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
- },
- backIn: function backIn(k) {
- var s = 1.70158;
- return k * k * ((s + 1) * k - s);
- },
- backOut: function backOut(k) {
- var s = 1.70158;
- return (k = k - 1) * k * ((s + 1) * k + s) + 1;
- },
- backInOut: function backInOut(k) {
- var s = 1.70158 * 1.525;
- if ((k *= 2) < 1) {
- return 0.5 * (k * k * ((s + 1) * k - s));
- }
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
- },
- bounceIn: function bounceIn(k) {
- return 1 - Easing.bounceOut(1 - k);
- },
- bounceOut: function bounceOut(k) {
- if ((k /= 1) < 1 / 2.75) {
- return 7.5625 * k * k;
- } else if (k < 2 / 2.75) {
- return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
- } else if (k < 2.5 / 2.75) {
- return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
- }
- return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
- },
- bounceInOut: function bounceInOut(k) {
- if (k < 0.5) {
- return Easing.bounceIn(k * 2) * 0.5;
- }
- return Easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
- }
- };
- module.exports = Easing;
- /***/ }),
- /* 239 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * Animation functions for shape
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var Helpers = __webpack_require__(207);
- /*
- function waveIn(shape, animateCfg, coord) {
- const clip = Helpers.getClip(coord);
- clip.set('canvas', shape.get('canvas'));
- shape.attr('clip', clip);
- const onEnd = function() {
- shape.attr('clip', null);
- clip.remove(true);
- };
- Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
- }
- function scaleInX(shape, animateCfg) {
- const box = shape.getBBox();
- const points = shape.get('origin').points;
- let x;
- const y = (box.minY + box.maxY) / 2;
- if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
- x = box.maxX;
- } else {
- x = box.minX;
- }
- const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
- Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
- }
- function scaleInY(shape, animateCfg) {
- const box = shape.getBBox();
- const points = shape.get('origin').points;
- const x = (box.minX + box.maxX) / 2;
- let y;
- if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
- y = box.maxY;
- } else {
- y = box.minY;
- }
- const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
- Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
- }
- */
- function fadeIn(shape, animateCfg) {
- var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
- var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
- shape.attr('fillOpacity', 0);
- shape.attr('strokeOpacity', 0);
- var endState = {
- fillOpacity: fillOpacity,
- strokeOpacity: strokeOpacity
- };
- Helpers.doAnimation(shape, endState, animateCfg);
- }
- module.exports = {
- // waveIn,
- // scaleInX,
- // scaleInY,
- fadeIn: fadeIn
- };
- /***/ }),
- /* 240 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * Group animate functions
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(207);
- var Helper = __webpack_require__(37);
- var _require = __webpack_require__(16),
- Shape = _require.Shape;
- function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
- var _Util$getCoordInfo = Util.getCoordInfo(coord),
- start = _Util$getCoordInfo.start,
- end = _Util$getCoordInfo.end,
- width = _Util$getCoordInfo.width,
- height = _Util$getCoordInfo.height;
- var x;
- var y;
- var clip = new Shape.Rect({
- attrs: {
- x: start.x,
- y: end.y,
- width: width,
- height: height
- }
- });
- if (type === 'y') {
- x = start.x + width / 2;
- y = zeroY.y < start.y ? zeroY.y : start.y;
- } else if (type === 'x') {
- x = zeroY.x > start.x ? zeroY.x : start.x;
- y = start.y + height / 2;
- } else if (type === 'xy') {
- if (coord.isPolar) {
- x = coord.center.x;
- y = coord.center.y;
- } else {
- x = (start.x + end.x) / 2;
- y = (start.y + end.y) / 2;
- }
- }
- var endMatrix = Util.getScaledMatrix(clip, [x, y], type);
- clip.isClip = true;
- clip.endState = {
- matrix: endMatrix
- };
- clip.set('canvas', container.get('canvas'));
- container.attr('clip', clip);
- var onEnd = function onEnd() {
- container.attr('clip', null);
- clip.remove(true);
- };
- Util.doAnimation(clip, clip.endState, animateCfg, onEnd);
- }
- function _shapeScale(container, animateCfg, type) {
- var shapes = container.get('children');
- var x;
- var y;
- var endMatrix;
- for (var i = 0, len = shapes.length; i < len; i++) {
- var shape = shapes[i];
- var box = shape.getBBox();
- x = (box.minX + box.maxX) / 2;
- y = (box.minY + box.maxY) / 2;
- endMatrix = Util.getScaledMatrix(shape, [x, y], type);
- Util.doAnimation(shape, {
- matrix: endMatrix
- }, animateCfg);
- }
- }
- function groupScaleInX(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
- }
- function groupScaleInY(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
- }
- function groupScaleInXY(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
- }
- function shapesScaleInX(container, animateCfg) {
- _shapeScale(container, animateCfg, 'x');
- }
- function shapesScaleInY(container, animateCfg) {
- _shapeScale(container, animateCfg, 'y');
- }
- function shapesScaleInXY(container, animateCfg) {
- _shapeScale(container, animateCfg, 'xy');
- }
- function groupWaveIn(container, animateCfg, coord) {
- var clip = Helper.getClip(coord);
- clip.set('canvas', container.get('canvas'));
- container.attr('clip', clip);
- var onEnd = function onEnd() {
- container.attr('clip', null);
- clip.remove(true);
- };
- var endState = {};
- if (coord.isPolar) {
- var startAngle = coord.startAngle,
- endAngle = coord.endAngle;
- endState.endAngle = endAngle;
- clip.attr('endAngle', startAngle);
- } else {
- var start = coord.start,
- end = coord.end;
- var width = Math.abs(start.x - end.x);
- var height = Math.abs(start.y - end.y);
- if (coord.isTransposed) {
- clip.attr('height', 0);
- endState.height = height;
- } else {
- clip.attr('width', 0);
- endState.width = width;
- }
- }
- Util.doAnimation(clip, endState, animateCfg, onEnd);
- }
- module.exports = {
- groupWaveIn: groupWaveIn,
- groupScaleInX: groupScaleInX,
- groupScaleInY: groupScaleInY,
- groupScaleInXY: groupScaleInXY,
- shapesScaleInX: shapesScaleInX,
- shapesScaleInY: shapesScaleInY,
- shapesScaleInXY: shapesScaleInXY
- };
- /***/ }),
- /* 241 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- exports.__esModule = true;
- exports["default"] = void 0;
- var _common = __webpack_require__(0);
- var Chart = __webpack_require__(30);
- Chart._Interactions = {};
- Chart.registerInteraction = function (type, constructor) {
- Chart._Interactions[type] = constructor;
- };
- Chart.getInteraction = function (type) {
- return Chart._Interactions[type];
- };
- Chart.prototype.interaction = function (type, cfg) {
- var interactions = this._interactions || {};
- if (interactions[type]) {
- // if reprated, destroy last
- interactions[type].destroy();
- }
- var Ctor = Chart.getInteraction(type);
- var interact = new Ctor(cfg, this);
- interactions[type] = interact;
- this._interactions = interactions;
- return this;
- };
- Chart.prototype.clearInteraction = function (type) {
- var interactions = this._interactions;
- if (!interactions) return;
- if (type) {
- interactions[type] && interactions[type].destroy();
- delete interactions[type];
- } else {
- (0, _common.each)(interactions, function (interaction, key) {
- interaction.destroy();
- delete interactions[key];
- });
- }
- return this;
- };
- var _default = Chart;
- exports["default"] = _default;
- /***/ }),
- /* 242 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * filter the data out of scale' range
- */
- var Util = __webpack_require__(0);
- var TimeUtil = __webpack_require__(204);
- module.exports = {
- beforeGeomInit: function beforeGeomInit(chart) {
- chart.set('limitInPlot', true);
- var data = chart.get('filteredData');
- var colDefs = chart.get('colDefs');
- if (!colDefs) return data;
- var geoms = chart.get('geoms');
- var isSpecialGeom = false; // TODO
- Util.each(geoms, function (geom) {
- if (['area', 'line', 'path'].indexOf(geom.get('type')) !== -1) {
- isSpecialGeom = true;
- return false;
- }
- });
- var fields = [];
- Util.each(colDefs, function (def, key) {
- if (!isSpecialGeom && def && (def.values || def.min || def.max)) {
- fields.push(key);
- }
- });
- if (fields.length === 0) {
- return data;
- }
- var geomData = [];
- Util.each(data, function (obj) {
- var flag = true;
- Util.each(fields, function (field) {
- var value = obj[field];
- if (value) {
- var colDef = colDefs[field];
- if (colDef.type === 'timeCat') {
- var values = colDef.values;
- if (Util.isNumber(values[0])) {
- value = TimeUtil.toTimeStamp(value);
- }
- }
- if (colDef.values && colDef.values.indexOf(value) === -1 || colDef.min && value < colDef.min || colDef.max && value > colDef.max) {
- flag = false;
- }
- }
- });
- if (flag) {
- geomData.push(obj);
- }
- });
- chart.set('filteredData', geomData);
- }
- };
- /***/ }),
- /* 243 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Helper = __webpack_require__(208);
- var Util = __webpack_require__(0);
- module.exports = {
- updateLinearScale: function updateLinearScale(field, min, max) {
- var chart = this.chart;
- var scale = Helper.getScale(chart, field); // const colDef = Helper.getColDef(chart, field);
- // chart.scale(field, Util.mix({}, colDef, {
- // min,
- // max,
- // nice: false
- // }));
- scale.change({
- min: min,
- max: max,
- nice: false
- });
- },
- updateCatScale: function updateCatScale(field, newValues, ticks, values, minIndex, maxIndex) {
- var chart = this.chart; // const colDef = Helper.getColDef(chart, field);
- var scale = Helper.getScale(chart, field);
- scale.change({
- values: newValues,
- ticks: ticks,
- scale: function scale(value) {
- if (this.type === 'timeCat') {
- value = this._toTimeStamp(value);
- }
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- var range = rangeMax - rangeMin;
- var min;
- var max;
- var percent;
- var currentIndex = values.indexOf(value); // 在完整数据集中的索引值
- if (currentIndex >= 0 && currentIndex < minIndex) {
- // 不在范围内,左侧数据
- max = rangeMin > 0 ? -0.1 : rangeMin - 0.1;
- min = max - range;
- percent = currentIndex / minIndex;
- } else if (currentIndex >= 0 && currentIndex > maxIndex) {
- // 不在范围内,右侧数据
- min = rangeMax < 1 ? 1.1 : rangeMax + 0.1;
- max = min + range;
- percent = (currentIndex - maxIndex - 1) / (values.length - 1 - maxIndex);
- } else {
- // 数值在当前 this.values 范围内
- var index = this.translate(value);
- if (this.values.length === 1) {
- percent = index;
- } else {
- percent = index / (this.values.length - 1);
- }
- min = rangeMin;
- max = rangeMax;
- }
- return min + percent * (max - min);
- },
- getTicks: function getTicks() {
- var self = this;
- var ticks = this.ticks;
- var rst = [];
- Util.each(ticks, function (tick) {
- var obj;
- if (Util.isObject(tick)) {
- obj = tick;
- } else {
- var value = self.scale(tick);
- value = value >= 0 && value <= 1 ? value : NaN;
- obj = {
- text: Util.isString(tick) ? tick : self.getText(tick),
- value: value,
- tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
- };
- }
- rst.push(obj);
- });
- return rst;
- }
- });
- }
- };
- /***/ }),
- /* 244 */,
- /* 245 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var Helper = __webpack_require__(208);
- var TOUCH_EVENTS = ['touchstart', 'touchmove', 'touchend', 'touchStart', 'touchMove', 'touchEnd'];
- var DAY_TIMESTAMPS = 86400000;
- module.exports = {
- _handleMove: function _handleMove(e) {
- if (e.type === 'swipe' && e.deltaTime > 350) {
- // 区分 pan 操作和 swipe 操作
- return null;
- }
- var currentDeltaX = this.currentDeltaX,
- currentDeltaY = this.currentDeltaY,
- lastPoint = this.lastPoint;
- var deltaX;
- var deltaY;
- if (TOUCH_EVENTS.indexOf(e.type) !== -1) {
- // support touch and miniprogram
- var currentPoint = e.touches[0];
- deltaX = currentPoint.x - lastPoint.x;
- deltaY = currentPoint.y - lastPoint.y;
- this.lastPoint = currentPoint;
- } else if (currentDeltaX !== null && currentDeltaY !== null) {
- deltaX = e.deltaX - currentDeltaX;
- deltaY = e.deltaY - currentDeltaY;
- this.currentDeltaX = e.deltaX;
- this.currentDeltaY = e.deltaY;
- }
- if (Math.abs(deltaX) > 0 || Math.abs(deltaY) > 0) {
- var lastTimestamp = this._timestamp;
- var now = +new Date();
- if (now - lastTimestamp > 16) {
- this._doMove(deltaX, deltaY);
- this._timestamp = now;
- }
- }
- },
- _doMove: function _doMove(deltaX, deltaY) {
- var self = this;
- var mode = self.mode,
- chart = self.chart,
- limitRange = self.limitRange;
- var coord = chart.get('coord');
- var start = coord.start,
- end = coord.end;
- var data = chart.get('data');
- if (Util.directionEnabled(mode, 'x') && deltaX !== 0) {
- var xScale = chart.getXScale();
- var xField = xScale.field;
- if (!limitRange[xField]) {
- limitRange[xField] = Helper.getLimitRange(data, xScale);
- }
- var coordWidth = end.x - start.x;
- if (xScale.isCategory) {
- self._handleCatScale(xScale, deltaX, coordWidth);
- } else if (xScale.isLinear) {
- self._handleLinearScale(xScale, deltaX, coordWidth, 'x');
- }
- self.xRange = Helper.getFieldRange(xScale, limitRange[xField], xScale.type);
- }
- if (Util.directionEnabled(mode, 'y') && deltaY !== 0) {
- var coordHeight = start.y - end.y;
- var yScales = chart.getYScales();
- Util.each(yScales, function (yScale) {
- var yField = yScale.field;
- if (!limitRange[yField]) {
- limitRange[yField] = Helper.getLimitRange(data, yScale);
- }
- yScale.isLinear && self._handleLinearScale(yScale, deltaY, coordHeight, 'y');
- });
- var scale = yScales[0];
- self.yRange = Helper.getFieldRange(scale, limitRange[scale.field], scale.type);
- }
- chart.repaint();
- },
- _handleLinearScale: function _handleLinearScale(scale, delta, range, flag) {
- var field = scale.field,
- min = scale.min,
- max = scale.max;
- var limitRange = this.limitRange;
- if (min === limitRange[field].min && max === limitRange[field].max) return;
- var ratio = delta / range;
- var panValue = ratio * (max - min);
- var newMax = flag === 'x' ? max - panValue : max + panValue;
- var newMin = flag === 'x' ? min - panValue : min + panValue;
- if (limitRange[field] && !Util.isNil(limitRange[field].min) && newMin <= limitRange[field].min) {
- newMin = limitRange[field].min;
- newMax = max - min + newMin;
- }
- if (limitRange[field] && !Util.isNil(limitRange[field].max) && newMax >= limitRange[field].max) {
- newMax = limitRange[field].max;
- newMin = newMax - (max - min);
- }
- this.updateLinearScale(field, newMin, newMax);
- },
- _handleCatScale: function _handleCatScale(scale, delta, range) {
- var type = scale.type,
- field = scale.field,
- values = scale.values,
- ticks = scale.ticks;
- var duplicateRemovalValues = Util.uniq(values);
- var originValues = this.limitRange[field];
- var lastValueIndex = originValues.length - 1;
- var currentLength = duplicateRemovalValues.length;
- var speed = this.speed || 1;
- var step = range / (currentLength * speed);
- var firstIndex = originValues.indexOf(duplicateRemovalValues[0]);
- var lastIndex = originValues.indexOf(duplicateRemovalValues[currentLength - 1]);
- var minIndex = firstIndex;
- var maxIndex = lastIndex;
- var ratio = Math.abs(delta / range);
- var panStep = this.step || Math.max(1, parseInt(ratio * currentLength));
- this._panCumulativeDelta += delta;
- minIndex = this._panCumulativeDelta > step ? Math.max(0, minIndex - panStep) : this._panCumulativeDelta < -step ? Math.min(lastValueIndex - currentLength + 1, minIndex + panStep) : minIndex;
- maxIndex = Math.min(lastValueIndex, minIndex + currentLength - 1);
- if (minIndex === firstIndex && maxIndex === lastIndex) {
- return null;
- }
- var newValues = originValues.slice(minIndex, maxIndex + 1);
- var newTicks = null;
- if (type === 'timeCat') {
- var tickGap = ticks.length > 2 ? ticks[1] - ticks[0] : DAY_TIMESTAMPS;
- if (this._panCumulativeDelta > step) {
- for (var i = ticks[0] - tickGap; i >= newValues[0]; i -= tickGap) {
- ticks.unshift(i);
- }
- } else if (this._panCumulativeDelta < -step) {
- for (var _i = ticks[ticks.length - 1] + tickGap; _i <= newValues[newValues.length - 1]; _i += tickGap) {
- ticks.push(_i);
- }
- }
- newTicks = ticks;
- } else {
- // 保留之前的ticks
- newTicks = ticks;
- }
- this.updateCatScale(field, newValues, newTicks, originValues, minIndex, maxIndex);
- this._panCumulativeDelta = minIndex !== firstIndex ? 0 : this._panCumulativeDelta;
- }
- };
- /***/ }),
- /* 246 */,
- /* 247 */,
- /* 248 */,
- /* 249 */,
- /* 250 */,
- /* 251 */,
- /* 252 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * all
- */
- var F2 = __webpack_require__(77);
- __webpack_require__(209);
- __webpack_require__(193);
- __webpack_require__(203); // polar coordinate
- __webpack_require__(218); // the axis for polar coordinate
- __webpack_require__(219); // timeCat scale
- __webpack_require__(253); // guide components
- var Tooltip = __webpack_require__(230);
- var Guide = __webpack_require__(233);
- var Legend = __webpack_require__(234);
- var Animation = __webpack_require__(235);
- var ScrollBar = __webpack_require__(255);
- var PieLabel = __webpack_require__(256);
- var intervalLabel = __webpack_require__(257);
- F2.Animate = __webpack_require__(206); // register plugins
- F2.Chart.plugins.register([Tooltip, Legend, Guide, Animation, ScrollBar, PieLabel, intervalLabel]); // add interaction
- __webpack_require__(258);
- F2.Interaction = __webpack_require__(74);
- module.exports = F2;
- /***/ }),
- /* 253 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = {
- Text: __webpack_require__(227),
- Line: __webpack_require__(225),
- Arc: __webpack_require__(223),
- Rect: __webpack_require__(226),
- Html: __webpack_require__(224),
- Tag: __webpack_require__(228),
- Point: __webpack_require__(229),
- RegionFilter: __webpack_require__(254)
- };
- /***/ }),
- /* 254 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(23);
- var _require = __webpack_require__(10),
- Rect = _require.Rect;
- var RegionFilter = /*#__PURE__*/function (_GuideBase) {
- (0, _inheritsLoose2["default"])(RegionFilter, _GuideBase);
- var _super = _createSuper(RegionFilter);
- function RegionFilter() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = RegionFilter.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'regionFilter';
- this.start = [];
- this.end = [];
- this.color = null;
- this.style = null;
- };
- _proto.render = function render(coord) {
- var start = this.parsePoint(coord, this.start);
- var end = this.parsePoint(coord, this.end);
- if (!start || !end) {
- return;
- }
- var clip = new Rect({
- attrs: {
- x: Math.min(start.x, end.x),
- y: Math.min(start.y, end.y),
- width: Math.abs(end.x - start.x),
- height: Math.abs(end.y - start.y)
- }
- }); // 新建剪切区域
- this.clip = clip;
- var chart = this.chart;
- var color = this.color;
- var style = this.style || {};
- var regionElements = [];
- var geoms = chart.get('geoms');
- geoms.map(function (geom) {
- var geomContainer = geom.get('container');
- var children = geomContainer.get('children');
- var group = geomContainer.addGroup({
- zIndex: 10,
- className: 'guide-region-filter'
- });
- children.map(function (c) {
- if (c.get('isShape')) {
- var type = c.get('type');
- var attrs = Util.mix({}, c.get('attrs'), style);
- if (color && (attrs.fill || attrs.fillStyle)) {
- attrs.fill = attrs.fillStyle = color;
- }
- if (color && (attrs.stroke || attrs.strokeStyle)) {
- attrs.stroke = attrs.strokeStyle = color;
- }
- var cfg = {
- attrs: attrs
- };
- if (type === 'custom' || type === 'Custom') {
- // custom 类型的 shape 会自定义绘制 path 的逻辑
- cfg.createPath = c.get('createPath');
- cfg.calculateBox = c.get('calculateBox');
- }
- group.addShape(type, cfg);
- }
- return c;
- });
- group.attr('clip', clip);
- geomContainer.sort();
- regionElements.push(group);
- return geom;
- });
- this.element = regionElements;
- };
- _proto.remove = function remove() {
- var element = this.element;
- Util.each(element, function (group) {
- group && group.remove(true);
- });
- this.clip && this.clip.remove(true);
- };
- return RegionFilter;
- }(GuideBase);
- GuideBase.RegionFilter = RegionFilter;
- module.exports = RegionFilter;
- /***/ }),
- /* 255 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Helper = __webpack_require__(208);
- var Util = __webpack_require__(0);
- var DEFAULT_CFG = {
- mode: 'x',
- xStyle: {
- backgroundColor: 'rgba(202, 215, 239, .2)',
- fillerColor: 'rgba(202, 215, 239, .5)',
- size: 4,
- lineCap: 'round',
- offsetX: 0,
- offsetY: 8
- },
- yStyle: {
- backgroundColor: 'rgba(202, 215, 239, .2)',
- fillerColor: 'rgba(202, 215, 239, .5)',
- size: 4,
- lineCap: 'round',
- offsetX: 8,
- offsetY: 0
- }
- };
- module.exports = {
- init: function init(chart) {
- chart.set('_limitRange', {});
- chart.scrollBar = function (cfg) {
- if (cfg === true) {
- cfg = DEFAULT_CFG;
- } else if (Util.isObject(cfg)) {
- cfg = Util.deepMix({}, DEFAULT_CFG, cfg);
- }
- this.set('_scrollBarCfg', cfg);
- };
- },
- clear: function clear(chart) {
- chart.set('_limitRange', {});
- },
- changeData: function changeData(chart) {
- chart.set('_limitRange', {});
- },
- clearInner: function clearInner(chart) {
- var hBar = chart.get('_horizontalBar');
- var vBar = chart.get('_verticalBar');
- hBar && hBar.remove(true);
- vBar && vBar.remove(true);
- chart.set('_horizontalBar', null);
- chart.set('_verticalBar', null);
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var scrollBarCfg = chart.get('_scrollBarCfg');
- if (!scrollBarCfg) return;
- var data = chart.get('data');
- var plotRange = chart.get('plotRange');
- var backPlot = chart.get('backPlot');
- var canvas = chart.get('canvas');
- var canvasHeight = canvas.get('height');
- var limitRange = chart.get('_limitRange');
- var mode = scrollBarCfg.mode;
- if (Util.directionEnabled(mode, 'x')) {
- var _scrollBarCfg$xStyle = scrollBarCfg.xStyle,
- offsetX = _scrollBarCfg$xStyle.offsetX,
- offsetY = _scrollBarCfg$xStyle.offsetY,
- lineCap = _scrollBarCfg$xStyle.lineCap,
- backgroundColor = _scrollBarCfg$xStyle.backgroundColor,
- fillerColor = _scrollBarCfg$xStyle.fillerColor,
- size = _scrollBarCfg$xStyle.size;
- var xScale = chart.getXScale();
- var xLimitRange = limitRange[xScale.field];
- if (!xLimitRange) {
- xLimitRange = Helper.getLimitRange(data, xScale);
- limitRange[xScale.field] = xLimitRange;
- }
- var currentRange = Helper.getFieldRange(xScale, xLimitRange, xScale.type);
- var horizontalBar = chart.get('_horizontalBar');
- var yPos = canvasHeight - size / 2 + offsetY;
- if (horizontalBar) {
- var progressLine = horizontalBar.get('children')[1];
- progressLine.attr({
- x1: Math.max(plotRange.bl.x + plotRange.width * currentRange[0] + offsetX, plotRange.bl.x),
- x2: Math.min(plotRange.bl.x + plotRange.width * currentRange[1] + offsetX, plotRange.br.x)
- });
- } else {
- horizontalBar = backPlot.addGroup({
- className: 'horizontalBar'
- });
- horizontalBar.addShape('line', {
- attrs: {
- x1: plotRange.bl.x + offsetX,
- y1: yPos,
- x2: plotRange.br.x + offsetX,
- y2: yPos,
- lineWidth: size,
- stroke: backgroundColor,
- lineCap: lineCap
- }
- });
- horizontalBar.addShape('line', {
- attrs: {
- x1: Math.max(plotRange.bl.x + plotRange.width * currentRange[0] + offsetX, plotRange.bl.x),
- y1: yPos,
- x2: Math.min(plotRange.bl.x + plotRange.width * currentRange[1] + offsetX, plotRange.br.x),
- y2: yPos,
- lineWidth: size,
- stroke: fillerColor,
- lineCap: lineCap
- }
- });
- chart.set('_horizontalBar', horizontalBar);
- }
- }
- if (Util.directionEnabled(mode, 'y')) {
- var _scrollBarCfg$yStyle = scrollBarCfg.yStyle,
- _offsetX = _scrollBarCfg$yStyle.offsetX,
- _offsetY = _scrollBarCfg$yStyle.offsetY,
- _lineCap = _scrollBarCfg$yStyle.lineCap,
- _backgroundColor = _scrollBarCfg$yStyle.backgroundColor,
- _fillerColor = _scrollBarCfg$yStyle.fillerColor,
- _size = _scrollBarCfg$yStyle.size;
- var yScale = chart.getYScales()[0];
- var yLimitRange = limitRange[yScale.field];
- if (!yLimitRange) {
- yLimitRange = Helper.getLimitRange(data, yScale);
- limitRange[yScale.field] = yLimitRange;
- }
- var _currentRange = Helper.getFieldRange(yScale, yLimitRange, yScale.type);
- var verticalBar = chart.get('_verticalBar');
- var xPos = _size / 2 + _offsetX;
- if (verticalBar) {
- var _progressLine = verticalBar.get('children')[1];
- _progressLine.attr({
- y1: Math.max(plotRange.tl.y + plotRange.height * _currentRange[0] + _offsetY, plotRange.tl.y),
- y2: Math.min(plotRange.tl.y + plotRange.height * _currentRange[1] + _offsetY, plotRange.bl.y)
- });
- } else {
- verticalBar = backPlot.addGroup({
- className: 'verticalBar'
- });
- verticalBar.addShape('line', {
- attrs: {
- x1: xPos,
- y1: plotRange.tl.y + _offsetY,
- x2: xPos,
- y2: plotRange.bl.y + _offsetY,
- lineWidth: _size,
- stroke: _backgroundColor,
- lineCap: _lineCap
- }
- });
- verticalBar.addShape('line', {
- attrs: {
- x1: xPos,
- y1: Math.max(plotRange.tl.y + plotRange.height * _currentRange[0] + _offsetY, plotRange.tl.y),
- x2: xPos,
- y2: Math.min(plotRange.tl.y + plotRange.height * _currentRange[1] + _offsetY, plotRange.bl.y),
- lineWidth: _size,
- stroke: _fillerColor,
- lineCap: _lineCap
- }
- });
- chart.set('_verticalBar', verticalBar);
- }
- }
- }
- };
- /***/ }),
- /* 256 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(16),
- Group = _require.Group;
- var DEFAULT_CFG = {
- anchorOffset: 5,
- // 锚点的偏移量
- inflectionOffset: 15,
- // 拐点的偏移量
- sidePadding: 20,
- // 文本距离画布四边的距离
- lineHeight: 32,
- // 文本的行高
- adjustOffset: 15,
- // 发生调整时的偏移量
- skipOverlapLabels: false,
- // 是否不展示重叠的文本
- triggerOn: 'touchstart',
- // 点击行为触发的时间类型
- activeShape: false,
- // 当有图形被选中的时候,是否激活图形
- activeStyle: {
- offset: 1,
- appendRadius: 8,
- fillOpacity: 0.5
- },
- label1OffsetY: -1,
- label2OffsetY: 1
- };
- function getEndPoint(center, angle, r) {
- return {
- x: center.x + r * Math.cos(angle),
- y: center.y + r * Math.sin(angle)
- };
- } // 计算中间角度
- function getMiddleAngle(startAngle, endAngle) {
- if (endAngle < startAngle) {
- endAngle += Math.PI * 2;
- }
- return (endAngle + startAngle) / 2;
- } // 判断两个矩形是否相交
- function isOverlap(label1, label2) {
- var label1BBox = label1.getBBox();
- var label2BBox = label2.getBBox();
- 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);
- }
- var controller = /*#__PURE__*/function () {
- function controller(cfg) {
- var _this = this;
- this._handleEvent = function (ev) {
- var self = _this;
- var chart = self.chart,
- drawnLabels = self.drawnLabels,
- pieLabelCfg = self.pieLabelCfg;
- var onClick = pieLabelCfg.onClick,
- activeShape = pieLabelCfg.activeShape;
- var canvasEvent = Util.createEvent(ev, chart);
- var x = canvasEvent.x,
- y = canvasEvent.y; // 查找被点击的 label
- var clickedShape;
- for (var i = 0, len = drawnLabels.length; i < len; i++) {
- var shape = drawnLabels[i];
- var bbox = shape.getBBox(); // 通过最小包围盒来判断击中情况
- if (x >= bbox.minX && x <= bbox.maxX && y >= bbox.minY && y <= bbox.maxY) {
- clickedShape = shape;
- break;
- }
- }
- var pieData = chart.getSnapRecords({
- x: x,
- y: y
- });
- if (clickedShape) {
- canvasEvent.data = clickedShape.get('data');
- } else if (pieData.length) {
- // 击中饼图扇形区域
- canvasEvent.data = pieData[0]._origin;
- }
- onClick && onClick(canvasEvent);
- canvasEvent.data && activeShape && _this._activeShape(canvasEvent.data);
- };
- Util.mix(this, cfg);
- var _chart = this.chart;
- this.canvasDom = _chart.get('canvas').get('el');
- }
- var _proto = controller.prototype;
- _proto.renderLabels = function renderLabels() {
- var self = this;
- var chart = self.chart,
- pieLabelCfg = self.pieLabelCfg,
- labelGroup = self.labelGroup;
- var halves = [[], // left
- [] // right
- ]; // 存储左右 labels
- var geom = chart.get('geoms')[0];
- var shapes = geom.get('container').get('children');
- var anchorOffset = pieLabelCfg.anchorOffset,
- inflectionOffset = pieLabelCfg.inflectionOffset,
- label1 = pieLabelCfg.label1,
- label2 = pieLabelCfg.label2,
- lineHeight = pieLabelCfg.lineHeight,
- skipOverlapLabels = pieLabelCfg.skipOverlapLabels,
- label1OffsetY = pieLabelCfg.label1OffsetY,
- label2OffsetY = pieLabelCfg.label2OffsetY;
- var coord = chart.get('coord');
- var center = coord.center,
- radius = coord.circleRadius;
- shapes.forEach(function (shape) {
- var _shape$_attrs$attrs = shape._attrs.attrs,
- startAngle = _shape$_attrs$attrs.startAngle,
- endAngle = _shape$_attrs$attrs.endAngle;
- var middleAngle = getMiddleAngle(startAngle, endAngle);
- var anchorPoint = getEndPoint(center, middleAngle, radius + anchorOffset);
- var inflectionPoint = getEndPoint(center, middleAngle, radius + inflectionOffset);
- var origin = shape.get('origin');
- var _origin = origin._origin,
- color = origin.color;
- var label = {
- _anchor: anchorPoint,
- _inflection: inflectionPoint,
- _data: _origin,
- x: inflectionPoint.x,
- y: inflectionPoint.y,
- r: radius + inflectionOffset,
- fill: color
- };
- var textGroup = new Group({
- context: chart.get('canvas').get('context'),
- // 兼容 node、小程序环境
- data: _origin // 存储原始数据
- });
- var textAttrs = {
- x: 0,
- y: 0,
- fontSize: 12,
- lineHeight: 12,
- fill: '#808080'
- };
- if (Util.isFunction(label1)) {
- textGroup.addShape('Text', {
- attrs: Util.mix({
- textBaseline: 'bottom'
- }, textAttrs, label1(_origin, color)),
- data: _origin,
- // 存储原始数据
- offsetY: label1OffsetY
- });
- }
- if (Util.isFunction(label2)) {
- textGroup.addShape('Text', {
- attrs: Util.mix({
- textBaseline: 'top'
- }, textAttrs, label2(_origin, color)),
- data: _origin,
- // 存储原始数据
- offsetY: label2OffsetY
- });
- }
- label.textGroup = textGroup; // 判断文本的方向
- if (anchorPoint.x < center.x) {
- label._side = 'left';
- halves[0].push(label);
- } else {
- label._side = 'right';
- halves[1].push(label);
- }
- });
- var drawnLabels = [];
- if (skipOverlapLabels) {
- var lastLabel; // 存储上一个 label 对象,用于检测文本是否重叠
- var labels = halves[1].concat(halves[0]); // 顺时针
- for (var i = 0, len = labels.length; i < len; i++) {
- var label = labels[i];
- var textGroup = self._drawLabel(label);
- if (lastLabel) {
- if (isOverlap(textGroup, lastLabel)) {
- // 重叠了就不绘制
- continue;
- }
- }
- labelGroup.add(textGroup);
- self._drawLabelLine(label);
- lastLabel = textGroup;
- drawnLabels.push(textGroup);
- }
- } else {
- var height = chart.get('height');
- var maxCountForOneSide = parseInt(height / lineHeight, 10);
- halves.forEach(function (half) {
- if (half.length > maxCountForOneSide) {
- half.splice(maxCountForOneSide, half.length - maxCountForOneSide);
- }
- half.sort(function (a, b) {
- return a.y - b.y;
- });
- var labels = self._antiCollision(half);
- drawnLabels = drawnLabels.concat(labels);
- });
- }
- this.drawnLabels = drawnLabels;
- };
- _proto.bindEvents = function bindEvents() {
- var pieLabelCfg = this.pieLabelCfg;
- var triggerOn = pieLabelCfg.triggerOn || 'touchstart';
- Util.addEventListener(this.canvasDom, triggerOn, this._handleEvent);
- };
- _proto.unBindEvents = function unBindEvents() {
- var pieLabelCfg = this.pieLabelCfg;
- var triggerOn = pieLabelCfg.triggerOn || 'touchstart';
- Util.removeEventListener(this.canvasDom, triggerOn, this._handleEvent);
- };
- _proto.clear = function clear() {
- this.labelGroup && this.labelGroup.clear();
- this.halo && this.halo.remove(true);
- this.lastSelectedData = null;
- this.drawnLabels = [];
- this.unBindEvents();
- };
- _proto._drawLabel = function _drawLabel(label) {
- var pieLabelCfg = this.pieLabelCfg,
- chart = this.chart;
- var canvasWidth = chart.get('width');
- var sidePadding = pieLabelCfg.sidePadding;
- var y = label.y,
- textGroup = label.textGroup;
- var children = textGroup.get('children');
- var textAttrs = {
- textAlign: label._side === 'left' ? 'left' : 'right',
- x: label._side === 'left' ? sidePadding : canvasWidth - sidePadding
- };
- children.forEach(function (child) {
- child.attr(textAttrs);
- child.attr('y', y + child.get('offsetY'));
- });
- return textGroup;
- };
- _proto._drawLabelLine = function _drawLabelLine(label, maxLabelWidth) {
- var chart = this.chart,
- pieLabelCfg = this.pieLabelCfg,
- labelGroup = this.labelGroup;
- var canvasWidth = chart.get('width');
- var sidePadding = pieLabelCfg.sidePadding,
- adjustOffset = pieLabelCfg.adjustOffset,
- lineStyle = pieLabelCfg.lineStyle,
- anchorStyle = pieLabelCfg.anchorStyle,
- skipOverlapLabels = pieLabelCfg.skipOverlapLabels;
- var _anchor = label._anchor,
- _inflection = label._inflection,
- fill = label.fill,
- y = label.y;
- var lastPoint = {
- x: label._side === 'left' ? sidePadding : canvasWidth - sidePadding,
- y: y
- };
- var points = [_anchor, _inflection, lastPoint];
- if (!skipOverlapLabels && _inflection.y !== y) {
- // 展示全部文本文本位置做过调整
- if (_inflection.y < y) {
- // 文本被调整下去了,则添加拐点连接线
- var point1 = _inflection;
- var point2 = {
- x: label._side === 'left' ? lastPoint.x + maxLabelWidth + adjustOffset : lastPoint.x - maxLabelWidth - adjustOffset,
- y: _inflection.y
- };
- var point3 = {
- x: label._side === 'left' ? lastPoint.x + maxLabelWidth : lastPoint.x - maxLabelWidth,
- y: lastPoint.y
- };
- points = [_anchor, point1, point2, point3, lastPoint];
- if (label._side === 'right' && point2.x < point1.x || label._side === 'left' && point2.x > point1.x) {
- points = [_anchor, point3, lastPoint];
- }
- } else {
- points = [_anchor, {
- x: _inflection.x,
- y: y
- }, lastPoint];
- }
- }
- labelGroup.addShape('Polyline', {
- attrs: Util.mix({
- points: points,
- lineWidth: 1,
- stroke: fill
- }, lineStyle)
- }); // 绘制锚点
- labelGroup.addShape('Circle', {
- attrs: Util.mix({
- x: _anchor.x,
- y: _anchor.y,
- r: 2,
- fill: fill
- }, anchorStyle)
- });
- };
- _proto._antiCollision = function _antiCollision(half) {
- var self = this;
- var chart = self.chart,
- pieLabelCfg = self.pieLabelCfg;
- var coord = chart.get('coord');
- var canvasHeight = chart.get('height');
- var center = coord.center,
- r = coord.circleRadius;
- var inflectionOffset = pieLabelCfg.inflectionOffset,
- lineHeight = pieLabelCfg.lineHeight;
- var startY = center.y - r - inflectionOffset - lineHeight;
- var overlapping = true;
- var totalH = canvasHeight;
- var i;
- var maxY = 0;
- var minY = Number.MIN_VALUE;
- var maxLabelWidth = 0;
- var boxes = half.map(function (label) {
- var labelY = label.y;
- if (labelY > maxY) {
- maxY = labelY;
- }
- if (labelY < minY) {
- minY = labelY;
- }
- var textGroup = label.textGroup;
- var labelWidth = textGroup.getBBox().width;
- if (labelWidth >= maxLabelWidth) {
- maxLabelWidth = labelWidth;
- }
- return {
- size: lineHeight,
- targets: [labelY - startY]
- };
- });
- if (maxY - startY > totalH) {
- totalH = maxY - startY;
- }
- var iteratorBoxed = function iteratorBoxed(boxes) {
- boxes.forEach(function (box) {
- var target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2;
- box.pos = Math.min(Math.max(minY, target - box.size / 2), totalH - box.size);
- });
- };
- while (overlapping) {
- iteratorBoxed(boxes); // detect overlapping and join boxes
- overlapping = false;
- i = boxes.length;
- while (i--) {
- if (i > 0) {
- var previousBox = boxes[i - 1];
- var box = boxes[i];
- if (previousBox.pos + previousBox.size > box.pos) {
- // overlapping
- previousBox.size += box.size;
- previousBox.targets = previousBox.targets.concat(box.targets); // overflow, shift up
- if (previousBox.pos + previousBox.size > totalH) {
- previousBox.pos = totalH - previousBox.size;
- }
- boxes.splice(i, 1); // removing box
- overlapping = true;
- }
- }
- }
- }
- i = 0;
- boxes.forEach(function (b) {
- var posInCompositeBox = startY; // middle of the label
- b.targets.forEach(function () {
- half[i].y = b.pos + posInCompositeBox + lineHeight / 2;
- posInCompositeBox += lineHeight;
- i++;
- });
- });
- var drawnLabels = [];
- half.forEach(function (label) {
- var textGroup = self._drawLabel(label);
- var labelGroup = self.labelGroup;
- labelGroup.add(textGroup);
- self._drawLabelLine(label, maxLabelWidth);
- drawnLabels.push(textGroup);
- });
- return drawnLabels;
- };
- _proto._getSelectedShapeByData = function _getSelectedShapeByData(data) {
- var selectedShape = null;
- var chart = this.chart;
- var geom = chart.get('geoms')[0];
- var container = geom.get('container');
- var children = container.get('children');
- Util.each(children, function (child) {
- if (child.get('isShape') && child.get('className') === geom.get('type')) {
- // get geometry's shape
- var shapeData = child.get('origin')._origin;
- if (Util.isObjectValueEqual(shapeData, data)) {
- selectedShape = child;
- return false;
- }
- }
- });
- return selectedShape;
- };
- _proto._activeShape = function _activeShape(data) {
- var chart = this.chart,
- lastSelectedData = this.lastSelectedData,
- pieLabelCfg = this.pieLabelCfg;
- if (data === lastSelectedData) {
- return;
- }
- this.lastSelectedData = data;
- var activeStyle = pieLabelCfg.activeStyle;
- var selectedShape = this._getSelectedShapeByData(data);
- var _selectedShape$_attrs = selectedShape._attrs.attrs,
- x = _selectedShape$_attrs.x,
- y = _selectedShape$_attrs.y,
- startAngle = _selectedShape$_attrs.startAngle,
- endAngle = _selectedShape$_attrs.endAngle,
- r = _selectedShape$_attrs.r,
- fill = _selectedShape$_attrs.fill;
- var frontPlot = chart.get('frontPlot');
- this.halo && this.halo.remove(true);
- var halo = frontPlot.addShape('sector', {
- attrs: Util.mix({
- x: x,
- y: y,
- r: r + activeStyle.offset + activeStyle.appendRadius,
- r0: r + activeStyle.offset,
- fill: fill,
- startAngle: startAngle,
- endAngle: endAngle
- }, activeStyle)
- });
- this.halo = halo;
- chart.get('canvas').draw();
- };
- return controller;
- }();
- module.exports = {
- init: function init(chart) {
- var frontPlot = chart.get('frontPlot');
- var labelGroup = frontPlot.addGroup({
- className: 'pie-label',
- zIndex: 0
- });
- var pieLabelController = new controller({
- chart: chart,
- labelGroup: labelGroup
- });
- chart.set('pieLabelController', pieLabelController);
- chart.pieLabel = function (cfg) {
- cfg = Util.deepMix({}, DEFAULT_CFG, cfg);
- pieLabelController.pieLabelCfg = cfg;
- return this;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var controller = chart.get('pieLabelController');
- if (controller.pieLabelCfg) {
- // 用户配置了饼图文本
- controller.renderLabels();
- controller.bindEvents(); // 绑定事件
- }
- },
- clearInner: function clearInner(chart) {
- var controller = chart.get('pieLabelController');
- if (controller.pieLabelCfg) {
- // 用户配置了饼图文本
- controller.clear();
- }
- }
- };
- /***/ }),
- /* 257 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var Util = __webpack_require__(0);
- var DEFAULT_CFG = {
- label: null,
- offsetX: 0,
- offsetY: 0
- };
- var DEFAULT_LABEL_CFG = {
- textBaseline: 'middle',
- fill: '#808080'
- }; // 2个点的中心点
- function getMiddlePoint(a, b) {
- var x = (a.x - b.x) / 2 + b.x;
- var y = (a.y - b.y) / 2 + b.y;
- return {
- x: x,
- y: y
- };
- } // function getLabelPoint(points, nextPoints) {
- // let start;
- // if (nextPoints && nextPoints.length) {
- // start = getMiddlePoint(points[1], nextPoints[1]);
- // } else {
- // const nextPoint = getMiddlePoint(points[2], points[3]);
- // start = getMiddlePoint(points[1], nextPoint);
- // }
- // const end = getMiddlePoint(points[1], points[2]);
- // return { start, end };
- // }
- var Controller = /*#__PURE__*/function () {
- function Controller(_ref) {
- var chart = _ref.chart,
- container = _ref.container;
- this.cfg = null;
- this.chart = chart;
- this.container = container;
- }
- var _proto = Controller.prototype;
- _proto.draw = function draw() {
- var chart = this.chart,
- container = this.container,
- cfg = this.cfg;
- if (!cfg) return;
- var labelCfg = Util.mix({}, DEFAULT_CFG, cfg);
- var coord = chart.get('coord');
- var geom = chart.get('geoms')[0];
- var shapes = geom.get('container').get('children');
- shapes.forEach(function (shape) {
- var origin = shape.get('origin');
- var _origin = origin._origin,
- color = origin.color,
- points = origin.points;
- if (labelCfg.label) {
- var labelAttrs = labelCfg.label(_origin, color);
- var group = container.addGroup();
- var point = coord.convertPoint(getMiddlePoint(points[1], points[2]));
- group.addShape('Text', {
- attrs: Util.mix({
- x: point.x + labelCfg.offsetX,
- y: point.y + labelCfg.offsetY
- }, labelAttrs, DEFAULT_LABEL_CFG)
- });
- }
- });
- };
- _proto.clear = function clear() {
- var container = this.container;
- container.clear();
- };
- return Controller;
- }();
- module.exports = {
- init: function init(chart) {
- var frontPlot = chart.get('frontPlot');
- var labelGroup = frontPlot.addGroup({
- className: 'label',
- zIndex: 0
- });
- var labelController = new Controller({
- chart: chart,
- container: labelGroup
- });
- chart.set('intervalLabelController', labelController);
- chart.intervalLabel = function (cfg) {
- labelController.cfg = cfg;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var labelController = chart.get('intervalLabelController');
- labelController.draw();
- },
- clearInner: function clearInner(chart) {
- var labelController = chart.get('intervalLabelController');
- labelController.clear();
- }
- };
- /***/ }),
- /* 258 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- module.exports = {
- Interaction: __webpack_require__(74),
- PieSelect: __webpack_require__(260),
- IntervalSelect: __webpack_require__(261),
- Swipe: __webpack_require__(262),
- Pan: __webpack_require__(263),
- Pinch: __webpack_require__(264)
- };
- /***/ }),
- /* 259 */
- /***/ (function(module, exports, __webpack_require__) {
- var __WEBPACK_AMD_DEFINE_RESULT__;/*! Hammer.JS - v2.0.7 - 2016-04-22
- * http://hammerjs.github.io/
- *
- * Copyright (c) 2016 Jorik Tangelder;
- * Licensed under the MIT license */
- (function (window, document, exportName, undefined) {
- 'use strict';
- var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
- var TEST_ELEMENT = document.createElement('div');
- var TYPE_FUNCTION = 'function';
- var round = Math.round;
- var abs = Math.abs;
- var now = Date.now;
- /**
- * set a timeout with a given scope
- * @param {Function} fn
- * @param {Number} timeout
- * @param {Object} context
- * @returns {number}
- */
- function setTimeoutContext(fn, timeout, context) {
- return setTimeout(bindFn(fn, context), timeout);
- }
- /**
- * if the argument is an array, we want to execute the fn on each entry
- * if it aint an array we don't want to do a thing.
- * this is used by all the methods that accept a single and array argument.
- * @param {*|Array} arg
- * @param {String} fn
- * @param {Object} [context]
- * @returns {Boolean}
- */
- function invokeArrayArg(arg, fn, context) {
- if (Array.isArray(arg)) {
- each(arg, context[fn], context);
- return true;
- }
- return false;
- }
- /**
- * walk objects and arrays
- * @param {Object} obj
- * @param {Function} iterator
- * @param {Object} context
- */
- function each(obj, iterator, context) {
- var i;
- if (!obj) {
- return;
- }
- if (obj.forEach) {
- obj.forEach(iterator, context);
- } else if (obj.length !== undefined) {
- i = 0;
- while (i < obj.length) {
- iterator.call(context, obj[i], i, obj);
- i++;
- }
- } else {
- for (i in obj) {
- obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
- }
- }
- }
- /**
- * wrap a method with a deprecation warning and stack trace
- * @param {Function} method
- * @param {String} name
- * @param {String} message
- * @returns {Function} A new function wrapping the supplied method.
- */
- function deprecate(method, name, message) {
- var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
- return function () {
- var e = new Error('get-stack-trace');
- var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
- var log = window.console && (window.console.warn || window.console.log);
- if (log) {
- log.call(window.console, deprecationMessage, stack);
- }
- return method.apply(this, arguments);
- };
- }
- /**
- * extend object.
- * means that properties in dest will be overwritten by the ones in src.
- * @param {Object} target
- * @param {...Object} objects_to_assign
- * @returns {Object} target
- */
- var assign;
- if (typeof Object.assign !== 'function') {
- assign = function assign(target) {
- if (target === undefined || target === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
- var output = Object(target);
- for (var index = 1; index < arguments.length; index++) {
- var source = arguments[index];
- if (source !== undefined && source !== null) {
- for (var nextKey in source) {
- if (source.hasOwnProperty(nextKey)) {
- output[nextKey] = source[nextKey];
- }
- }
- }
- }
- return output;
- };
- } else {
- assign = Object.assign;
- }
- /**
- * extend object.
- * means that properties in dest will be overwritten by the ones in src.
- * @param {Object} dest
- * @param {Object} src
- * @param {Boolean} [merge=false]
- * @returns {Object} dest
- */
- var extend = deprecate(function extend(dest, src, merge) {
- var keys = Object.keys(src);
- var i = 0;
- while (i < keys.length) {
- if (!merge || merge && dest[keys[i]] === undefined) {
- dest[keys[i]] = src[keys[i]];
- }
- i++;
- }
- return dest;
- }, 'extend', 'Use `assign`.');
- /**
- * merge the values from src in the dest.
- * means that properties that exist in dest will not be overwritten by src
- * @param {Object} dest
- * @param {Object} src
- * @returns {Object} dest
- */
- var merge = deprecate(function merge(dest, src) {
- return extend(dest, src, true);
- }, 'merge', 'Use `assign`.');
- /**
- * simple class inheritance
- * @param {Function} child
- * @param {Function} base
- * @param {Object} [properties]
- */
- function inherit(child, base, properties) {
- var baseP = base.prototype,
- childP;
- childP = child.prototype = Object.create(baseP);
- childP.constructor = child;
- childP._super = baseP;
- if (properties) {
- assign(childP, properties);
- }
- }
- /**
- * simple function bind
- * @param {Function} fn
- * @param {Object} context
- * @returns {Function}
- */
- function bindFn(fn, context) {
- return function boundFn() {
- return fn.apply(context, arguments);
- };
- }
- /**
- * let a boolean value also be a function that must return a boolean
- * this first item in args will be used as the context
- * @param {Boolean|Function} val
- * @param {Array} [args]
- * @returns {Boolean}
- */
- function boolOrFn(val, args) {
- if (typeof val == TYPE_FUNCTION) {
- return val.apply(args ? args[0] || undefined : undefined, args);
- }
- return val;
- }
- /**
- * use the val2 when val1 is undefined
- * @param {*} val1
- * @param {*} val2
- * @returns {*}
- */
- function ifUndefined(val1, val2) {
- return val1 === undefined ? val2 : val1;
- }
- /**
- * addEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function addEventListeners(target, types, handler) {
- each(splitStr(types), function (type) {
- target.addEventListener(type, handler, false);
- });
- }
- /**
- * removeEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function removeEventListeners(target, types, handler) {
- each(splitStr(types), function (type) {
- target.removeEventListener(type, handler, false);
- });
- }
- /**
- * find if a node is in the given parent
- * @method hasParent
- * @param {HTMLElement} node
- * @param {HTMLElement} parent
- * @return {Boolean} found
- */
- function hasParent(node, parent) {
- while (node) {
- if (node == parent) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
- }
- /**
- * small indexOf wrapper
- * @param {String} str
- * @param {String} find
- * @returns {Boolean} found
- */
- function inStr(str, find) {
- return str.indexOf(find) > -1;
- }
- /**
- * split string on whitespace
- * @param {String} str
- * @returns {Array} words
- */
- function splitStr(str) {
- return str.trim().split(/\s+/g);
- }
- /**
- * find if a array contains the object using indexOf or a simple polyFill
- * @param {Array} src
- * @param {String} find
- * @param {String} [findByKey]
- * @return {Boolean|Number} false when not found, or the index
- */
- function inArray(src, find, findByKey) {
- if (src.indexOf && !findByKey) {
- return src.indexOf(find);
- } else {
- var i = 0;
- while (i < src.length) {
- if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
- return i;
- }
- i++;
- }
- return -1;
- }
- }
- /**
- * convert array-like objects to real arrays
- * @param {Object} obj
- * @returns {Array}
- */
- function toArray(obj) {
- return Array.prototype.slice.call(obj, 0);
- }
- /**
- * unique array with objects based on a key (like 'id') or just by the array's value
- * @param {Array} src [{id:1},{id:2},{id:1}]
- * @param {String} [key]
- * @param {Boolean} [sort=False]
- * @returns {Array} [{id:1},{id:2}]
- */
- function uniqueArray(src, key, sort) {
- var results = [];
- var values = [];
- var i = 0;
- while (i < src.length) {
- var val = key ? src[i][key] : src[i];
- if (inArray(values, val) < 0) {
- results.push(src[i]);
- }
- values[i] = val;
- i++;
- }
- if (sort) {
- if (!key) {
- results = results.sort();
- } else {
- results = results.sort(function sortUniqueArray(a, b) {
- return a[key] > b[key];
- });
- }
- }
- return results;
- }
- /**
- * get the prefixed property
- * @param {Object} obj
- * @param {String} property
- * @returns {String|Undefined} prefixed
- */
- function prefixed(obj, property) {
- var prefix, prop;
- var camelProp = property[0].toUpperCase() + property.slice(1);
- var i = 0;
- while (i < VENDOR_PREFIXES.length) {
- prefix = VENDOR_PREFIXES[i];
- prop = prefix ? prefix + camelProp : property;
- if (prop in obj) {
- return prop;
- }
- i++;
- }
- return undefined;
- }
- /**
- * get a unique id
- * @returns {number} uniqueId
- */
- var _uniqueId = 1;
- function uniqueId() {
- return _uniqueId++;
- }
- /**
- * get the window object of an element
- * @param {HTMLElement} element
- * @returns {DocumentView|Window}
- */
- function getWindowForElement(element) {
- var doc = element.ownerDocument || element;
- return doc.defaultView || doc.parentWindow || window;
- }
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
- var SUPPORT_TOUCH = ('ontouchstart' in window);
- var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
- var INPUT_TYPE_TOUCH = 'touch';
- var INPUT_TYPE_PEN = 'pen';
- var INPUT_TYPE_MOUSE = 'mouse';
- var INPUT_TYPE_KINECT = 'kinect';
- var COMPUTE_INTERVAL = 25;
- var INPUT_START = 1;
- var INPUT_MOVE = 2;
- var INPUT_END = 4;
- var INPUT_CANCEL = 8;
- var DIRECTION_NONE = 1;
- var DIRECTION_LEFT = 2;
- var DIRECTION_RIGHT = 4;
- var DIRECTION_UP = 8;
- var DIRECTION_DOWN = 16;
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
- var PROPS_XY = ['x', 'y'];
- var PROPS_CLIENT_XY = ['clientX', 'clientY'];
- /**
- * create new input type manager
- * @param {Manager} manager
- * @param {Function} callback
- * @returns {Input}
- * @constructor
- */
- function Input(manager, callback) {
- var self = this;
- this.manager = manager;
- this.callback = callback;
- this.element = manager.element;
- this.target = manager.options.inputTarget; // smaller wrapper around the handler, for the scope and the enabled state of the manager,
- // so when disabled the input events are completely bypassed.
- this.domHandler = function (ev) {
- if (boolOrFn(manager.options.enable, [manager])) {
- self.handler(ev);
- }
- };
- this.init();
- }
- Input.prototype = {
- /**
- * should handle the inputEvent data and trigger the callback
- * @virtual
- */
- handler: function () {},
- /**
- * bind the events
- */
- init: function () {
- this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- },
- /**
- * unbind the events
- */
- destroy: function () {
- this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- }
- };
- /**
- * create new input type manager
- * called by the Manager constructor
- * @param {Hammer} manager
- * @returns {Input}
- */
- function createInputInstance(manager) {
- var Type;
- var inputClass = manager.options.inputClass;
- if (inputClass) {
- Type = inputClass;
- } else if (SUPPORT_POINTER_EVENTS) {
- Type = PointerEventInput;
- } else if (SUPPORT_ONLY_TOUCH) {
- Type = TouchInput;
- } else if (!SUPPORT_TOUCH) {
- Type = MouseInput;
- } else {
- Type = TouchMouseInput;
- }
- return new Type(manager, inputHandler);
- }
- /**
- * handle input events
- * @param {Manager} manager
- * @param {String} eventType
- * @param {Object} input
- */
- function inputHandler(manager, eventType, input) {
- var pointersLen = input.pointers.length;
- var changedPointersLen = input.changedPointers.length;
- var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
- var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
- input.isFirst = !!isFirst;
- input.isFinal = !!isFinal;
- if (isFirst) {
- manager.session = {};
- } // source event is the normalized value of the domEvents
- // like 'touchstart, mouseup, pointerdown'
- input.eventType = eventType; // compute scale, rotation etc
- computeInputData(manager, input); // emit secret event
- manager.emit('hammer.input', input);
- manager.recognize(input);
- manager.session.prevInput = input;
- }
- /**
- * extend the data with some usable properties like scale, rotate, velocity etc
- * @param {Object} manager
- * @param {Object} input
- */
- function computeInputData(manager, input) {
- var session = manager.session;
- var pointers = input.pointers;
- var pointersLength = pointers.length; // store the first input to calculate the distance and direction
- if (!session.firstInput) {
- session.firstInput = simpleCloneInputData(input);
- } // to compute scale and rotation we need to store the multiple touches
- if (pointersLength > 1 && !session.firstMultiple) {
- session.firstMultiple = simpleCloneInputData(input);
- } else if (pointersLength === 1) {
- session.firstMultiple = false;
- }
- var firstInput = session.firstInput;
- var firstMultiple = session.firstMultiple;
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
- var center = input.center = getCenter(pointers);
- input.timeStamp = now();
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
- input.angle = getAngle(offsetCenter, center);
- input.distance = getDistance(offsetCenter, center);
- computeDeltaXY(session, input);
- input.offsetDirection = getDirection(input.deltaX, input.deltaY);
- var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
- input.overallVelocityX = overallVelocity.x;
- input.overallVelocityY = overallVelocity.y;
- input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
- input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
- input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
- input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
- computeIntervalInputData(session, input); // find the correct target
- var target = manager.element;
- if (hasParent(input.srcEvent.target, target)) {
- target = input.srcEvent.target;
- }
- input.target = target;
- }
- function computeDeltaXY(session, input) {
- var center = input.center;
- var offset = session.offsetDelta || {};
- var prevDelta = session.prevDelta || {};
- var prevInput = session.prevInput || {};
- if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
- prevDelta = session.prevDelta = {
- x: prevInput.deltaX || 0,
- y: prevInput.deltaY || 0
- };
- offset = session.offsetDelta = {
- x: center.x,
- y: center.y
- };
- }
- input.deltaX = prevDelta.x + (center.x - offset.x);
- input.deltaY = prevDelta.y + (center.y - offset.y);
- }
- /**
- * velocity is calculated every x ms
- * @param {Object} session
- * @param {Object} input
- */
- function computeIntervalInputData(session, input) {
- var last = session.lastInterval || input,
- deltaTime = input.timeStamp - last.timeStamp,
- velocity,
- velocityX,
- velocityY,
- direction;
- if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
- var deltaX = input.deltaX - last.deltaX;
- var deltaY = input.deltaY - last.deltaY;
- var v = getVelocity(deltaTime, deltaX, deltaY);
- velocityX = v.x;
- velocityY = v.y;
- velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
- direction = getDirection(deltaX, deltaY);
- session.lastInterval = input;
- } else {
- // use latest velocity info if it doesn't overtake a minimum period
- velocity = last.velocity;
- velocityX = last.velocityX;
- velocityY = last.velocityY;
- direction = last.direction;
- }
- input.velocity = velocity;
- input.velocityX = velocityX;
- input.velocityY = velocityY;
- input.direction = direction;
- }
- /**
- * create a simple clone from the input used for storage of firstInput and firstMultiple
- * @param {Object} input
- * @returns {Object} clonedInputData
- */
- function simpleCloneInputData(input) {
- // make a simple copy of the pointers because we will get a reference if we don't
- // we only need clientXY for the calculations
- var pointers = [];
- var i = 0;
- while (i < input.pointers.length) {
- pointers[i] = {
- clientX: round(input.pointers[i].clientX),
- clientY: round(input.pointers[i].clientY)
- };
- i++;
- }
- return {
- timeStamp: now(),
- pointers: pointers,
- center: getCenter(pointers),
- deltaX: input.deltaX,
- deltaY: input.deltaY
- };
- }
- /**
- * get the center of all the pointers
- * @param {Array} pointers
- * @return {Object} center contains `x` and `y` properties
- */
- function getCenter(pointers) {
- var pointersLength = pointers.length; // no need to loop when only one touch
- if (pointersLength === 1) {
- return {
- x: round(pointers[0].clientX),
- y: round(pointers[0].clientY)
- };
- }
- var x = 0,
- y = 0,
- i = 0;
- while (i < pointersLength) {
- x += pointers[i].clientX;
- y += pointers[i].clientY;
- i++;
- }
- return {
- x: round(x / pointersLength),
- y: round(y / pointersLength)
- };
- }
- /**
- * calculate the velocity between two points. unit is in px per ms.
- * @param {Number} deltaTime
- * @param {Number} x
- * @param {Number} y
- * @return {Object} velocity `x` and `y`
- */
- function getVelocity(deltaTime, x, y) {
- return {
- x: x / deltaTime || 0,
- y: y / deltaTime || 0
- };
- }
- /**
- * get the direction between two points
- * @param {Number} x
- * @param {Number} y
- * @return {Number} direction
- */
- function getDirection(x, y) {
- if (x === y) {
- return DIRECTION_NONE;
- }
- if (abs(x) >= abs(y)) {
- return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
- }
- return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
- }
- /**
- * calculate the absolute distance between two points
- * @param {Object} p1 {x, y}
- * @param {Object} p2 {x, y}
- * @param {Array} [props] containing x and y keys
- * @return {Number} distance
- */
- function getDistance(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]],
- y = p2[props[1]] - p1[props[1]];
- return Math.sqrt(x * x + y * y);
- }
- /**
- * calculate the angle between two coordinates
- * @param {Object} p1
- * @param {Object} p2
- * @param {Array} [props] containing x and y keys
- * @return {Number} angle
- */
- function getAngle(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]],
- y = p2[props[1]] - p1[props[1]];
- return Math.atan2(y, x) * 180 / Math.PI;
- }
- /**
- * calculate the rotation degrees between two pointersets
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} rotation
- */
- function getRotation(start, end) {
- return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
- }
- /**
- * calculate the scale factor between two pointersets
- * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} scale
- */
- function getScale(start, end) {
- return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
- }
- var MOUSE_INPUT_MAP = {
- mousedown: INPUT_START,
- mousemove: INPUT_MOVE,
- mouseup: INPUT_END
- };
- var MOUSE_ELEMENT_EVENTS = 'mousedown';
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
- /**
- * Mouse events input
- * @constructor
- * @extends Input
- */
- function MouseInput() {
- this.evEl = MOUSE_ELEMENT_EVENTS;
- this.evWin = MOUSE_WINDOW_EVENTS;
- this.pressed = false; // mousedown state
- Input.apply(this, arguments);
- }
- inherit(MouseInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function MEhandler(ev) {
- var eventType = MOUSE_INPUT_MAP[ev.type]; // on start we want to have the left mouse button down
- if (eventType & INPUT_START && ev.button === 0) {
- this.pressed = true;
- }
- if (eventType & INPUT_MOVE && ev.which !== 1) {
- eventType = INPUT_END;
- } // mouse must be down
- if (!this.pressed) {
- return;
- }
- if (eventType & INPUT_END) {
- this.pressed = false;
- }
- this.callback(this.manager, eventType, {
- pointers: [ev],
- changedPointers: [ev],
- pointerType: INPUT_TYPE_MOUSE,
- srcEvent: ev
- });
- }
- });
- var POINTER_INPUT_MAP = {
- pointerdown: INPUT_START,
- pointermove: INPUT_MOVE,
- pointerup: INPUT_END,
- pointercancel: INPUT_CANCEL,
- pointerout: INPUT_CANCEL
- }; // in IE10 the pointer types is defined as an enum
- var IE10_POINTER_TYPE_ENUM = {
- 2: INPUT_TYPE_TOUCH,
- 3: INPUT_TYPE_PEN,
- 4: INPUT_TYPE_MOUSE,
- 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
- };
- var POINTER_ELEMENT_EVENTS = 'pointerdown';
- var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel'; // IE10 has prefixed support, and case-sensitive
- if (window.MSPointerEvent && !window.PointerEvent) {
- POINTER_ELEMENT_EVENTS = 'MSPointerDown';
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
- }
- /**
- * Pointer events input
- * @constructor
- * @extends Input
- */
- function PointerEventInput() {
- this.evEl = POINTER_ELEMENT_EVENTS;
- this.evWin = POINTER_WINDOW_EVENTS;
- Input.apply(this, arguments);
- this.store = this.manager.session.pointerEvents = [];
- }
- inherit(PointerEventInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function PEhandler(ev) {
- var store = this.store;
- var removePointer = false;
- var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
- var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
- var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
- var isTouch = pointerType == INPUT_TYPE_TOUCH; // get index of the event in the store
- var storeIndex = inArray(store, ev.pointerId, 'pointerId'); // start and mouse must be down
- if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
- if (storeIndex < 0) {
- store.push(ev);
- storeIndex = store.length - 1;
- }
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
- removePointer = true;
- } // it not found, so the pointer hasn't been down (so it's probably a hover)
- if (storeIndex < 0) {
- return;
- } // update the event in the store
- store[storeIndex] = ev;
- this.callback(this.manager, eventType, {
- pointers: store,
- changedPointers: [ev],
- pointerType: pointerType,
- srcEvent: ev
- });
- if (removePointer) {
- // remove from the store
- store.splice(storeIndex, 1);
- }
- }
- });
- var SINGLE_TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
- var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Touch events input
- * @constructor
- * @extends Input
- */
- function SingleTouchInput() {
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
- this.started = false;
- Input.apply(this, arguments);
- }
- inherit(SingleTouchInput, Input, {
- handler: function TEhandler(ev) {
- var type = SINGLE_TOUCH_INPUT_MAP[ev.type]; // should we handle the touch events?
- if (type === INPUT_START) {
- this.started = true;
- }
- if (!this.started) {
- return;
- }
- var touches = normalizeSingleTouches.call(this, ev, type); // when done, reset the started state
- if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
- this.started = false;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function normalizeSingleTouches(ev, type) {
- var all = toArray(ev.touches);
- var changed = toArray(ev.changedTouches);
- if (type & (INPUT_END | INPUT_CANCEL)) {
- all = uniqueArray(all.concat(changed), 'identifier', true);
- }
- return [all, changed];
- }
- var TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Multi-user touch events input
- * @constructor
- * @extends Input
- */
- function TouchInput() {
- this.evTarget = TOUCH_TARGET_EVENTS;
- this.targetIds = {};
- Input.apply(this, arguments);
- }
- inherit(TouchInput, Input, {
- handler: function MTEhandler(ev) {
- var type = TOUCH_INPUT_MAP[ev.type];
- var touches = getTouches.call(this, ev, type);
- if (!touches) {
- return;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function getTouches(ev, type) {
- var allTouches = toArray(ev.touches);
- var targetIds = this.targetIds; // when there is only one touch, the process can be simplified
- if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
- targetIds[allTouches[0].identifier] = true;
- return [allTouches, allTouches];
- }
- var i,
- targetTouches,
- changedTouches = toArray(ev.changedTouches),
- changedTargetTouches = [],
- target = this.target; // get target touches from touches
- targetTouches = allTouches.filter(function (touch) {
- return hasParent(touch.target, target);
- }); // collect touches
- if (type === INPUT_START) {
- i = 0;
- while (i < targetTouches.length) {
- targetIds[targetTouches[i].identifier] = true;
- i++;
- }
- } // filter changed touches to only contain touches that exist in the collected target ids
- i = 0;
- while (i < changedTouches.length) {
- if (targetIds[changedTouches[i].identifier]) {
- changedTargetTouches.push(changedTouches[i]);
- } // cleanup removed touches
- if (type & (INPUT_END | INPUT_CANCEL)) {
- delete targetIds[changedTouches[i].identifier];
- }
- i++;
- }
- if (!changedTargetTouches.length) {
- return;
- }
- return [// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
- uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
- }
- /**
- * Combined touch and mouse input
- *
- * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
- * This because touch devices also emit mouse events while doing a touch.
- *
- * @constructor
- * @extends Input
- */
- var DEDUP_TIMEOUT = 2500;
- var DEDUP_DISTANCE = 25;
- function TouchMouseInput() {
- Input.apply(this, arguments);
- var handler = bindFn(this.handler, this);
- this.touch = new TouchInput(this.manager, handler);
- this.mouse = new MouseInput(this.manager, handler);
- this.primaryTouch = null;
- this.lastTouches = [];
- }
- inherit(TouchMouseInput, Input, {
- /**
- * handle mouse and touch events
- * @param {Hammer} manager
- * @param {String} inputEvent
- * @param {Object} inputData
- */
- handler: function TMEhandler(manager, inputEvent, inputData) {
- var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
- isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
- if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
- return;
- } // when we're in a touch event, record touches to de-dupe synthetic mouse event
- if (isTouch) {
- recordTouches.call(this, inputEvent, inputData);
- } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
- return;
- }
- this.callback(manager, inputEvent, inputData);
- },
- /**
- * remove the event listeners
- */
- destroy: function destroy() {
- this.touch.destroy();
- this.mouse.destroy();
- }
- });
- function recordTouches(eventType, eventData) {
- if (eventType & INPUT_START) {
- this.primaryTouch = eventData.changedPointers[0].identifier;
- setLastTouch.call(this, eventData);
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
- setLastTouch.call(this, eventData);
- }
- }
- function setLastTouch(eventData) {
- var touch = eventData.changedPointers[0];
- if (touch.identifier === this.primaryTouch) {
- var lastTouch = {
- x: touch.clientX,
- y: touch.clientY
- };
- this.lastTouches.push(lastTouch);
- var lts = this.lastTouches;
- var removeLastTouch = function () {
- var i = lts.indexOf(lastTouch);
- if (i > -1) {
- lts.splice(i, 1);
- }
- };
- setTimeout(removeLastTouch, DEDUP_TIMEOUT);
- }
- }
- function isSyntheticEvent(eventData) {
- var x = eventData.srcEvent.clientX,
- y = eventData.srcEvent.clientY;
- for (var i = 0; i < this.lastTouches.length; i++) {
- var t = this.lastTouches[i];
- var dx = Math.abs(x - t.x),
- dy = Math.abs(y - t.y);
- if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
- return true;
- }
- }
- return false;
- }
- var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined; // magical touchAction value
- var TOUCH_ACTION_COMPUTE = 'compute';
- var TOUCH_ACTION_AUTO = 'auto';
- var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
- var TOUCH_ACTION_NONE = 'none';
- var TOUCH_ACTION_PAN_X = 'pan-x';
- var TOUCH_ACTION_PAN_Y = 'pan-y';
- var TOUCH_ACTION_MAP = getTouchActionProps();
- /**
- * Touch Action
- * sets the touchAction property or uses the js alternative
- * @param {Manager} manager
- * @param {String} value
- * @constructor
- */
- function TouchAction(manager, value) {
- this.manager = manager;
- this.set(value);
- }
- TouchAction.prototype = {
- /**
- * set the touchAction value on the element or enable the polyfill
- * @param {String} value
- */
- set: function (value) {
- // find out the touch-action by the event handlers
- if (value == TOUCH_ACTION_COMPUTE) {
- value = this.compute();
- }
- if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
- this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
- }
- this.actions = value.toLowerCase().trim();
- },
- /**
- * just re-set the touchAction value
- */
- update: function () {
- this.set(this.manager.options.touchAction);
- },
- /**
- * compute the value for the touchAction property based on the recognizer's settings
- * @returns {String} value
- */
- compute: function () {
- var actions = [];
- each(this.manager.recognizers, function (recognizer) {
- if (boolOrFn(recognizer.options.enable, [recognizer])) {
- actions = actions.concat(recognizer.getTouchAction());
- }
- });
- return cleanTouchActions(actions.join(' '));
- },
- /**
- * this method is called on each input cycle and provides the preventing of the browser behavior
- * @param {Object} input
- */
- preventDefaults: function (input) {
- var srcEvent = input.srcEvent;
- var direction = input.offsetDirection; // if the touch action did prevented once this session
- if (this.manager.session.prevented) {
- srcEvent.preventDefault();
- return;
- }
- var actions = this.actions;
- var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
- if (hasNone) {
- //do not prevent defaults if this is a tap gesture
- var isTapPointer = input.pointers.length === 1;
- var isTapMovement = input.distance < 2;
- var isTapTouchTime = input.deltaTime < 250;
- if (isTapPointer && isTapMovement && isTapTouchTime) {
- return;
- }
- }
- if (hasPanX && hasPanY) {
- // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
- return;
- }
- if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
- return this.preventSrc(srcEvent);
- }
- },
- /**
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
- * @param {Object} srcEvent
- */
- preventSrc: function (srcEvent) {
- this.manager.session.prevented = true;
- srcEvent.preventDefault();
- }
- };
- /**
- * when the touchActions are collected they are not a valid value, so we need to clean things up. *
- * @param {String} actions
- * @returns {*}
- */
- function cleanTouchActions(actions) {
- // none
- if (inStr(actions, TOUCH_ACTION_NONE)) {
- return TOUCH_ACTION_NONE;
- }
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y); // if both pan-x and pan-y are set (different recognizers
- // for different directions, e.g. horizontal pan but vertical swipe?)
- // we need none (as otherwise with pan-x pan-y combined none of these
- // recognizers will work, since the browser would handle all panning
- if (hasPanX && hasPanY) {
- return TOUCH_ACTION_NONE;
- } // pan-x OR pan-y
- if (hasPanX || hasPanY) {
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
- } // manipulation
- if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
- return TOUCH_ACTION_MANIPULATION;
- }
- return TOUCH_ACTION_AUTO;
- }
- function getTouchActionProps() {
- if (!NATIVE_TOUCH_ACTION) {
- return false;
- }
- var touchMap = {};
- var cssSupports = window.CSS && window.CSS.supports;
- ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
- // If css.supports is not supported but there is native touch-action assume it supports
- // all values. This is the case for IE 10 and 11.
- touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
- });
- return touchMap;
- }
- /**
- * Recognizer flow explained; *
- * All recognizers have the initial state of POSSIBLE when a input session starts.
- * The definition of a input session is from the first input until the last input, with all it's movement in it. *
- * Example session for mouse-input: mousedown -> mousemove -> mouseup
- *
- * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
- * which determines with state it should be.
- *
- * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
- * POSSIBLE to give it another change on the next cycle.
- *
- * Possible
- * |
- * +-----+---------------+
- * | |
- * +-----+-----+ |
- * | | |
- * Failed Cancelled |
- * +-------+------+
- * | |
- * Recognized Began
- * |
- * Changed
- * |
- * Ended/Recognized
- */
- var STATE_POSSIBLE = 1;
- var STATE_BEGAN = 2;
- var STATE_CHANGED = 4;
- var STATE_ENDED = 8;
- var STATE_RECOGNIZED = STATE_ENDED;
- var STATE_CANCELLED = 16;
- var STATE_FAILED = 32;
- /**
- * Recognizer
- * Every recognizer needs to extend from this class.
- * @constructor
- * @param {Object} options
- */
- function Recognizer(options) {
- this.options = assign({}, this.defaults, options || {});
- this.id = uniqueId();
- this.manager = null; // default is enable true
- this.options.enable = ifUndefined(this.options.enable, true);
- this.state = STATE_POSSIBLE;
- this.simultaneous = {};
- this.requireFail = [];
- }
- Recognizer.prototype = {
- /**
- * @virtual
- * @type {Object}
- */
- defaults: {},
- /**
- * set options
- * @param {Object} options
- * @return {Recognizer}
- */
- set: function (options) {
- assign(this.options, options); // also update the touchAction, in case something changed about the directions/enabled state
- this.manager && this.manager.touchAction.update();
- return this;
- },
- /**
- * recognize simultaneous with an other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- recognizeWith: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
- return this;
- }
- var simultaneous = this.simultaneous;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (!simultaneous[otherRecognizer.id]) {
- simultaneous[otherRecognizer.id] = otherRecognizer;
- otherRecognizer.recognizeWith(this);
- }
- return this;
- },
- /**
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRecognizeWith: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- delete this.simultaneous[otherRecognizer.id];
- return this;
- },
- /**
- * recognizer can only run when an other is failing
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- requireFailure: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
- return this;
- }
- var requireFail = this.requireFail;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (inArray(requireFail, otherRecognizer) === -1) {
- requireFail.push(otherRecognizer);
- otherRecognizer.requireFailure(this);
- }
- return this;
- },
- /**
- * drop the requireFailure link. it does not remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRequireFailure: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- var index = inArray(this.requireFail, otherRecognizer);
- if (index > -1) {
- this.requireFail.splice(index, 1);
- }
- return this;
- },
- /**
- * has require failures boolean
- * @returns {boolean}
- */
- hasRequireFailures: function () {
- return this.requireFail.length > 0;
- },
- /**
- * if the recognizer can recognize simultaneous with an other recognizer
- * @param {Recognizer} otherRecognizer
- * @returns {Boolean}
- */
- canRecognizeWith: function (otherRecognizer) {
- return !!this.simultaneous[otherRecognizer.id];
- },
- /**
- * You should use `tryEmit` instead of `emit` directly to check
- * that all the needed recognizers has failed before emitting.
- * @param {Object} input
- */
- emit: function (input) {
- var self = this;
- var state = this.state;
- function emit(event) {
- self.manager.emit(event, input);
- } // 'panstart' and 'panmove'
- if (state < STATE_ENDED) {
- emit(self.options.event + stateStr(state));
- }
- emit(self.options.event); // simple 'eventName' events
- if (input.additionalEvent) {
- // additional event(panleft, panright, pinchin, pinchout...)
- emit(input.additionalEvent);
- } // panend and pancancel
- if (state >= STATE_ENDED) {
- emit(self.options.event + stateStr(state));
- }
- },
- /**
- * Check that all the require failure recognizers has failed,
- * if true, it emits a gesture event,
- * otherwise, setup the state to FAILED.
- * @param {Object} input
- */
- tryEmit: function (input) {
- if (this.canEmit()) {
- return this.emit(input);
- } // it's failing anyway
- this.state = STATE_FAILED;
- },
- /**
- * can we emit?
- * @returns {boolean}
- */
- canEmit: function () {
- var i = 0;
- while (i < this.requireFail.length) {
- if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
- return false;
- }
- i++;
- }
- return true;
- },
- /**
- * update the recognizer
- * @param {Object} inputData
- */
- recognize: function (inputData) {
- // make a new copy of the inputData
- // so we can change the inputData without messing up the other recognizers
- var inputDataClone = assign({}, inputData); // is is enabled and allow recognizing?
- if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
- this.reset();
- this.state = STATE_FAILED;
- return;
- } // reset when we've reached the end
- if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
- this.state = STATE_POSSIBLE;
- }
- this.state = this.process(inputDataClone); // the recognizer has recognized a gesture
- // so trigger an event
- if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
- this.tryEmit(inputDataClone);
- }
- },
- /**
- * return the state of the recognizer
- * the actual recognizing happens in this method
- * @virtual
- * @param {Object} inputData
- * @returns {Const} STATE
- */
- process: function (inputData) {},
- // jshint ignore:line
- /**
- * return the preferred touch-action
- * @virtual
- * @returns {Array}
- */
- getTouchAction: function () {},
- /**
- * called when the gesture isn't allowed to recognize
- * like when another is being recognized or it is disabled
- * @virtual
- */
- reset: function () {}
- };
- /**
- * get a usable string, used as event postfix
- * @param {Const} state
- * @returns {String} state
- */
- function stateStr(state) {
- if (state & STATE_CANCELLED) {
- return 'cancel';
- } else if (state & STATE_ENDED) {
- return 'end';
- } else if (state & STATE_CHANGED) {
- return 'move';
- } else if (state & STATE_BEGAN) {
- return 'start';
- }
- return '';
- }
- /**
- * direction cons to string
- * @param {Const} direction
- * @returns {String}
- */
- function directionStr(direction) {
- if (direction == DIRECTION_DOWN) {
- return 'down';
- } else if (direction == DIRECTION_UP) {
- return 'up';
- } else if (direction == DIRECTION_LEFT) {
- return 'left';
- } else if (direction == DIRECTION_RIGHT) {
- return 'right';
- }
- return '';
- }
- /**
- * get a recognizer by name if it is bound to a manager
- * @param {Recognizer|String} otherRecognizer
- * @param {Recognizer} recognizer
- * @returns {Recognizer}
- */
- function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
- var manager = recognizer.manager;
- if (manager) {
- return manager.get(otherRecognizer);
- }
- return otherRecognizer;
- }
- /**
- * This recognizer is just used as a base for the simple attribute recognizers.
- * @constructor
- * @extends Recognizer
- */
- function AttrRecognizer() {
- Recognizer.apply(this, arguments);
- }
- inherit(AttrRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof AttrRecognizer
- */
- defaults: {
- /**
- * @type {Number}
- * @default 1
- */
- pointers: 1
- },
- /**
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {Boolean} recognized
- */
- attrTest: function (input) {
- var optionPointers = this.options.pointers;
- return optionPointers === 0 || input.pointers.length === optionPointers;
- },
- /**
- * Process the input and return the state for the recognizer
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {*} State
- */
- process: function (input) {
- var state = this.state;
- var eventType = input.eventType;
- var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
- var isValid = this.attrTest(input); // on cancel input and we've recognized before, return STATE_CANCELLED
- if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
- return state | STATE_CANCELLED;
- } else if (isRecognized || isValid) {
- if (eventType & INPUT_END) {
- return state | STATE_ENDED;
- } else if (!(state & STATE_BEGAN)) {
- return STATE_BEGAN;
- }
- return state | STATE_CHANGED;
- }
- return STATE_FAILED;
- }
- });
- /**
- * Pan
- * Recognized when the pointer is down and moved in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function PanRecognizer() {
- AttrRecognizer.apply(this, arguments);
- this.pX = null;
- this.pY = null;
- }
- inherit(PanRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PanRecognizer
- */
- defaults: {
- event: 'pan',
- threshold: 10,
- pointers: 1,
- direction: DIRECTION_ALL
- },
- getTouchAction: function () {
- var direction = this.options.direction;
- var actions = [];
- if (direction & DIRECTION_HORIZONTAL) {
- actions.push(TOUCH_ACTION_PAN_Y);
- }
- if (direction & DIRECTION_VERTICAL) {
- actions.push(TOUCH_ACTION_PAN_X);
- }
- return actions;
- },
- directionTest: function (input) {
- var options = this.options;
- var hasMoved = true;
- var distance = input.distance;
- var direction = input.direction;
- var x = input.deltaX;
- var y = input.deltaY; // lock to axis?
- if (!(direction & options.direction)) {
- if (options.direction & DIRECTION_HORIZONTAL) {
- direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
- hasMoved = x != this.pX;
- distance = Math.abs(input.deltaX);
- } else {
- direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
- hasMoved = y != this.pY;
- distance = Math.abs(input.deltaY);
- }
- }
- input.direction = direction;
- return hasMoved && distance > options.threshold && direction & options.direction;
- },
- attrTest: function (input) {
- return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
- },
- emit: function (input) {
- this.pX = input.deltaX;
- this.pY = input.deltaY;
- var direction = directionStr(input.direction);
- if (direction) {
- input.additionalEvent = this.options.event + direction;
- }
- this._super.emit.call(this, input);
- }
- });
- /**
- * Pinch
- * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
- * @constructor
- * @extends AttrRecognizer
- */
- function PinchRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(PinchRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'pinch',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function (input) {
- return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
- },
- emit: function (input) {
- if (input.scale !== 1) {
- var inOut = input.scale < 1 ? 'in' : 'out';
- input.additionalEvent = this.options.event + inOut;
- }
- this._super.emit.call(this, input);
- }
- });
- /**
- * Press
- * Recognized when the pointer is down for x ms without any movement.
- * @constructor
- * @extends Recognizer
- */
- function PressRecognizer() {
- Recognizer.apply(this, arguments);
- this._timer = null;
- this._input = null;
- }
- inherit(PressRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PressRecognizer
- */
- defaults: {
- event: 'press',
- pointers: 1,
- time: 251,
- // minimal time of the pointer to be pressed
- threshold: 9 // a minimal movement is ok, but keep it low
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_AUTO];
- },
- process: function (input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTime = input.deltaTime > options.time;
- this._input = input; // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
- this.reset();
- } else if (input.eventType & INPUT_START) {
- this.reset();
- this._timer = setTimeoutContext(function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.time, this);
- } else if (input.eventType & INPUT_END) {
- return STATE_RECOGNIZED;
- }
- return STATE_FAILED;
- },
- reset: function () {
- clearTimeout(this._timer);
- },
- emit: function (input) {
- if (this.state !== STATE_RECOGNIZED) {
- return;
- }
- if (input && input.eventType & INPUT_END) {
- this.manager.emit(this.options.event + 'up', input);
- } else {
- this._input.timeStamp = now();
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Rotate
- * Recognized when two or more pointer are moving in a circular motion.
- * @constructor
- * @extends AttrRecognizer
- */
- function RotateRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(RotateRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof RotateRecognizer
- */
- defaults: {
- event: 'rotate',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function (input) {
- return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
- }
- });
- /**
- * Swipe
- * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function SwipeRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(SwipeRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof SwipeRecognizer
- */
- defaults: {
- event: 'swipe',
- threshold: 10,
- velocity: 0.3,
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
- pointers: 1
- },
- getTouchAction: function () {
- return PanRecognizer.prototype.getTouchAction.call(this);
- },
- attrTest: function (input) {
- var direction = this.options.direction;
- var velocity;
- if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
- velocity = input.overallVelocity;
- } else if (direction & DIRECTION_HORIZONTAL) {
- velocity = input.overallVelocityX;
- } else if (direction & DIRECTION_VERTICAL) {
- velocity = input.overallVelocityY;
- }
- 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;
- },
- emit: function (input) {
- var direction = directionStr(input.offsetDirection);
- if (direction) {
- this.manager.emit(this.options.event + direction, input);
- }
- this.manager.emit(this.options.event, input);
- }
- });
- /**
- * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
- * between the given interval and position. The delay option can be used to recognize multi-taps without firing
- * a single tap.
- *
- * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
- * multi-taps being recognized.
- * @constructor
- * @extends Recognizer
- */
- function TapRecognizer() {
- Recognizer.apply(this, arguments); // previous time and center,
- // used for tap counting
- this.pTime = false;
- this.pCenter = false;
- this._timer = null;
- this._input = null;
- this.count = 0;
- }
- inherit(TapRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'tap',
- pointers: 1,
- taps: 1,
- interval: 300,
- // max time between the multi-tap taps
- time: 250,
- // max time of the pointer to be down (like finger on the screen)
- threshold: 9,
- // a minimal movement is ok, but keep it low
- posThreshold: 10 // a multi-tap can be a bit off the initial position
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_MANIPULATION];
- },
- process: function (input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTouchTime = input.deltaTime < options.time;
- this.reset();
- if (input.eventType & INPUT_START && this.count === 0) {
- return this.failTimeout();
- } // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (validMovement && validTouchTime && validPointers) {
- if (input.eventType != INPUT_END) {
- return this.failTimeout();
- }
- var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
- var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
- this.pTime = input.timeStamp;
- this.pCenter = input.center;
- if (!validMultiTap || !validInterval) {
- this.count = 1;
- } else {
- this.count += 1;
- }
- this._input = input; // if tap count matches we have recognized it,
- // else it has began recognizing...
- var tapCount = this.count % options.taps;
- if (tapCount === 0) {
- // no failing requirements, immediately trigger the tap event
- // or wait as long as the multitap interval to trigger
- if (!this.hasRequireFailures()) {
- return STATE_RECOGNIZED;
- } else {
- this._timer = setTimeoutContext(function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.interval, this);
- return STATE_BEGAN;
- }
- }
- }
- return STATE_FAILED;
- },
- failTimeout: function () {
- this._timer = setTimeoutContext(function () {
- this.state = STATE_FAILED;
- }, this.options.interval, this);
- return STATE_FAILED;
- },
- reset: function () {
- clearTimeout(this._timer);
- },
- emit: function () {
- if (this.state == STATE_RECOGNIZED) {
- this._input.tapCount = this.count;
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Simple way to create a manager with a default set of recognizers.
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Hammer(element, options) {
- options = options || {};
- options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
- return new Manager(element, options);
- }
- /**
- * @const {string}
- */
- Hammer.VERSION = '2.0.7';
- /**
- * default settings
- * @namespace
- */
- Hammer.defaults = {
- /**
- * set if DOM events are being triggered.
- * But this is slower and unused by simple implementations, so disabled by default.
- * @type {Boolean}
- * @default false
- */
- domEvents: false,
- /**
- * The value for the touchAction property/fallback.
- * When set to `compute` it will magically set the correct value based on the added recognizers.
- * @type {String}
- * @default compute
- */
- touchAction: TOUCH_ACTION_COMPUTE,
- /**
- * @type {Boolean}
- * @default true
- */
- enable: true,
- /**
- * EXPERIMENTAL FEATURE -- can be removed/changed
- * Change the parent input target element.
- * If Null, then it is being set the to main element.
- * @type {Null|EventTarget}
- * @default null
- */
- inputTarget: null,
- /**
- * force an input class
- * @type {Null|Function}
- * @default null
- */
- inputClass: null,
- /**
- * Default recognizer setup when calling `Hammer()`
- * When creating a new Manager these will be skipped.
- * @type {Array}
- */
- preset: [// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
- [RotateRecognizer, {
- enable: false
- }], [PinchRecognizer, {
- enable: false
- }, ['rotate']], [SwipeRecognizer, {
- direction: DIRECTION_HORIZONTAL
- }], [PanRecognizer, {
- direction: DIRECTION_HORIZONTAL
- }, ['swipe']], [TapRecognizer], [TapRecognizer, {
- event: 'doubletap',
- taps: 2
- }, ['tap']], [PressRecognizer]],
- /**
- * Some CSS properties can be used to improve the working of Hammer.
- * Add them to this method and they will be set when creating a new Manager.
- * @namespace
- */
- cssProps: {
- /**
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userSelect: 'none',
- /**
- * Disable the Windows Phone grippers when pressing an element.
- * @type {String}
- * @default 'none'
- */
- touchSelect: 'none',
- /**
- * Disables the default callout shown when you touch and hold a touch target.
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
- * a callout containing information about the link. This property allows you to disable that callout.
- * @type {String}
- * @default 'none'
- */
- touchCallout: 'none',
- /**
- * Specifies whether zooming is enabled. Used by IE10>
- * @type {String}
- * @default 'none'
- */
- contentZooming: 'none',
- /**
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userDrag: 'none',
- /**
- * Overrides the highlight color shown when the user taps a link or a JavaScript
- * clickable element in iOS. This property obeys the alpha value, if specified.
- * @type {String}
- * @default 'rgba(0,0,0,0)'
- */
- tapHighlightColor: 'rgba(0,0,0,0)'
- }
- };
- var STOP = 1;
- var FORCED_STOP = 2;
- /**
- * Manager
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Manager(element, options) {
- this.options = assign({}, Hammer.defaults, options || {});
- this.options.inputTarget = this.options.inputTarget || element;
- this.handlers = {};
- this.session = {};
- this.recognizers = [];
- this.oldCssProps = {};
- this.element = element;
- this.input = createInputInstance(this);
- this.touchAction = new TouchAction(this, this.options.touchAction);
- toggleCssProps(this, true);
- each(this.options.recognizers, function (item) {
- var recognizer = this.add(new item[0](item[1]));
- item[2] && recognizer.recognizeWith(item[2]);
- item[3] && recognizer.requireFailure(item[3]);
- }, this);
- }
- Manager.prototype = {
- /**
- * set options
- * @param {Object} options
- * @returns {Manager}
- */
- set: function (options) {
- assign(this.options, options); // Options that need a little more setup
- if (options.touchAction) {
- this.touchAction.update();
- }
- if (options.inputTarget) {
- // Clean up existing event listeners and reinitialize
- this.input.destroy();
- this.input.target = options.inputTarget;
- this.input.init();
- }
- return this;
- },
- /**
- * stop recognizing for this session.
- * This session will be discarded, when a new [input]start event is fired.
- * When forced, the recognizer cycle is stopped immediately.
- * @param {Boolean} [force]
- */
- stop: function (force) {
- this.session.stopped = force ? FORCED_STOP : STOP;
- },
- /**
- * run the recognizers!
- * called by the inputHandler function on every movement of the pointers (touches)
- * it walks through all the recognizers and tries to detect the gesture that is being made
- * @param {Object} inputData
- */
- recognize: function (inputData) {
- var session = this.session;
- if (session.stopped) {
- return;
- } // run the touch-action polyfill
- this.touchAction.preventDefaults(inputData);
- var recognizer;
- var recognizers = this.recognizers; // this holds the recognizer that is being recognized.
- // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
- // if no recognizer is detecting a thing, it is set to `null`
- var curRecognizer = session.curRecognizer; // reset when the last recognizer is recognized
- // or when we're in a new session
- if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
- curRecognizer = session.curRecognizer = null;
- }
- var i = 0;
- while (i < recognizers.length) {
- recognizer = recognizers[i]; // find out if we are allowed try to recognize the input for this one.
- // 1. allow if the session is NOT forced stopped (see the .stop() method)
- // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
- // that is being recognized.
- // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
- // this can be setup with the `recognizeWith()` method on the recognizer.
- if (session.stopped !== FORCED_STOP && ( // 1
- !curRecognizer || recognizer == curRecognizer || // 2
- recognizer.canRecognizeWith(curRecognizer))) {
- // 3
- recognizer.recognize(inputData);
- } else {
- recognizer.reset();
- } // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
- // current active recognizer. but only if we don't already have an active recognizer
- if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
- curRecognizer = session.curRecognizer = recognizer;
- }
- i++;
- }
- },
- /**
- * get a recognizer by its event name.
- * @param {Recognizer|String} recognizer
- * @returns {Recognizer|Null}
- */
- get: function (recognizer) {
- if (recognizer instanceof Recognizer) {
- return recognizer;
- }
- var recognizers = this.recognizers;
- for (var i = 0; i < recognizers.length; i++) {
- if (recognizers[i].options.event == recognizer) {
- return recognizers[i];
- }
- }
- return null;
- },
- /**
- * add a recognizer to the manager
- * existing recognizers with the same event name will be removed
- * @param {Recognizer} recognizer
- * @returns {Recognizer|Manager}
- */
- add: function (recognizer) {
- if (invokeArrayArg(recognizer, 'add', this)) {
- return this;
- } // remove existing
- var existing = this.get(recognizer.options.event);
- if (existing) {
- this.remove(existing);
- }
- this.recognizers.push(recognizer);
- recognizer.manager = this;
- this.touchAction.update();
- return recognizer;
- },
- /**
- * remove a recognizer by name or instance
- * @param {Recognizer|String} recognizer
- * @returns {Manager}
- */
- remove: function (recognizer) {
- if (invokeArrayArg(recognizer, 'remove', this)) {
- return this;
- }
- recognizer = this.get(recognizer); // let's make sure this recognizer exists
- if (recognizer) {
- var recognizers = this.recognizers;
- var index = inArray(recognizers, recognizer);
- if (index !== -1) {
- recognizers.splice(index, 1);
- this.touchAction.update();
- }
- }
- return this;
- },
- /**
- * bind event
- * @param {String} events
- * @param {Function} handler
- * @returns {EventEmitter} this
- */
- on: function (events, handler) {
- if (events === undefined) {
- return;
- }
- if (handler === undefined) {
- return;
- }
- var handlers = this.handlers;
- each(splitStr(events), function (event) {
- handlers[event] = handlers[event] || [];
- handlers[event].push(handler);
- });
- return this;
- },
- /**
- * unbind event, leave emit blank to remove all handlers
- * @param {String} events
- * @param {Function} [handler]
- * @returns {EventEmitter} this
- */
- off: function (events, handler) {
- if (events === undefined) {
- return;
- }
- var handlers = this.handlers;
- each(splitStr(events), function (event) {
- if (!handler) {
- delete handlers[event];
- } else {
- handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
- }
- });
- return this;
- },
- /**
- * emit event to the listeners
- * @param {String} event
- * @param {Object} data
- */
- emit: function (event, data) {
- // we also want to trigger dom events
- if (this.options.domEvents) {
- triggerDomEvent(event, data);
- } // no handlers, so skip it all
- var handlers = this.handlers[event] && this.handlers[event].slice();
- if (!handlers || !handlers.length) {
- return;
- }
- data.type = event;
- data.preventDefault = function () {
- data.srcEvent.preventDefault();
- };
- var i = 0;
- while (i < handlers.length) {
- handlers[i](data);
- i++;
- }
- },
- /**
- * destroy the manager and unbinds all events
- * it doesn't unbind dom events, that is the user own responsibility
- */
- destroy: function () {
- this.element && toggleCssProps(this, false);
- this.handlers = {};
- this.session = {};
- this.input.destroy();
- this.element = null;
- }
- };
- /**
- * add/remove the css properties as defined in manager.options.cssProps
- * @param {Manager} manager
- * @param {Boolean} add
- */
- function toggleCssProps(manager, add) {
- var element = manager.element;
- if (!element.style) {
- return;
- }
- var prop;
- each(manager.options.cssProps, function (value, name) {
- prop = prefixed(element.style, name);
- if (add) {
- manager.oldCssProps[prop] = element.style[prop];
- element.style[prop] = value;
- } else {
- element.style[prop] = manager.oldCssProps[prop] || '';
- }
- });
- if (!add) {
- manager.oldCssProps = {};
- }
- }
- /**
- * trigger dom event
- * @param {String} event
- * @param {Object} data
- */
- function triggerDomEvent(event, data) {
- var gestureEvent = document.createEvent('Event');
- gestureEvent.initEvent(event, true, true);
- gestureEvent.gesture = data;
- data.target.dispatchEvent(gestureEvent);
- }
- assign(Hammer, {
- INPUT_START: INPUT_START,
- INPUT_MOVE: INPUT_MOVE,
- INPUT_END: INPUT_END,
- INPUT_CANCEL: INPUT_CANCEL,
- STATE_POSSIBLE: STATE_POSSIBLE,
- STATE_BEGAN: STATE_BEGAN,
- STATE_CHANGED: STATE_CHANGED,
- STATE_ENDED: STATE_ENDED,
- STATE_RECOGNIZED: STATE_RECOGNIZED,
- STATE_CANCELLED: STATE_CANCELLED,
- STATE_FAILED: STATE_FAILED,
- DIRECTION_NONE: DIRECTION_NONE,
- DIRECTION_LEFT: DIRECTION_LEFT,
- DIRECTION_RIGHT: DIRECTION_RIGHT,
- DIRECTION_UP: DIRECTION_UP,
- DIRECTION_DOWN: DIRECTION_DOWN,
- DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
- DIRECTION_VERTICAL: DIRECTION_VERTICAL,
- DIRECTION_ALL: DIRECTION_ALL,
- Manager: Manager,
- Input: Input,
- TouchAction: TouchAction,
- TouchInput: TouchInput,
- MouseInput: MouseInput,
- PointerEventInput: PointerEventInput,
- TouchMouseInput: TouchMouseInput,
- SingleTouchInput: SingleTouchInput,
- Recognizer: Recognizer,
- AttrRecognizer: AttrRecognizer,
- Tap: TapRecognizer,
- Pan: PanRecognizer,
- Swipe: SwipeRecognizer,
- Pinch: PinchRecognizer,
- Rotate: RotateRecognizer,
- Press: PressRecognizer,
- on: addEventListeners,
- off: removeEventListeners,
- each: each,
- merge: merge,
- extend: extend,
- assign: assign,
- inherit: inherit,
- bindFn: bindFn,
- prefixed: prefixed
- }); // this prevents errors when Hammer is loaded in the presence of an AMD
- // style loader but by script tag, not by the loader.
- var freeGlobal = typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}; // jshint ignore:line
- freeGlobal.Hammer = Hammer;
- if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
- return Hammer;
- }.call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else if (typeof module != 'undefined' && module.exports) {
- module.exports = Hammer;
- } else {
- window[exportName] = Hammer;
- }
- })(window, document, 'Hammer');
- /***/ }),
- /* 260 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Interaction = __webpack_require__(74);
- var Chart = __webpack_require__(30);
- var PieSelect = /*#__PURE__*/function (_Interaction) {
- (0, _inheritsLoose2["default"])(PieSelect, _Interaction);
- var _super = _createSuper(PieSelect);
- var _proto = PieSelect.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
- defaultCfg = Util.mix({}, defaultCfg, {
- startEvent: 'tap',
- processEvent: null,
- animate: false,
- offset: 1,
- appendRadius: 8,
- style: {
- fillOpacity: 0.5
- },
- cancelable: true,
- defaultSelected: null // set the default selected shape
- });
- if (Util.isWx || Util.isMy) {
- // 小程序
- defaultCfg.startEvent = 'touchstart';
- defaultCfg.endEvent = 'touchend';
- }
- return defaultCfg;
- };
- function PieSelect(cfg, chart) {
- var _this;
- _this = _Interaction.call(this, cfg, chart) || this;
- var self = (0, _assertThisInitialized2["default"])(_this);
- chart.registerPlugins({
- clearInner: function clearInner() {
- self.halo && self.halo.remove(true);
- self.selected = false;
- self.selectedShape = null;
- self.lastShape = null;
- self.halo = null;
- self.defaultSelected = null;
- }
- });
- var defaultSelected = self.defaultSelected;
- if (Util.isObject(defaultSelected)) {
- var selectedShape = self._getSelectedShapeByData(defaultSelected);
- selectedShape && self._selectedShape(selectedShape);
- _this.canvas.draw();
- }
- return _this;
- }
- _proto._getSelectedShapeByData = function _getSelectedShapeByData(data) {
- var selectedShape = null;
- var chart = this.chart;
- var geom = chart.get('geoms')[0];
- var container = geom.get('container');
- var children = container.get('children');
- Util.each(children, function (child) {
- if (child.get('isShape') && child.get('className') === geom.get('type')) {
- // get geometry's shape
- var shapeData = child.get('origin')._origin;
- if (Util.isObjectValueEqual(shapeData, data)) {
- selectedShape = child;
- return false;
- }
- }
- });
- return selectedShape;
- };
- _proto._selectedShape = function _selectedShape(selectedShape) {
- var offset = this.offset,
- style = this.style,
- appendRadius = this.appendRadius,
- chart = this.chart;
- this.lastShape = selectedShape;
- var _selectedShape$_attrs = selectedShape._attrs.attrs,
- x = _selectedShape$_attrs.x,
- y = _selectedShape$_attrs.y,
- startAngle = _selectedShape$_attrs.startAngle,
- endAngle = _selectedShape$_attrs.endAngle,
- r = _selectedShape$_attrs.r,
- fill = _selectedShape$_attrs.fill;
- var frontPlot = chart.get('frontPlot');
- var halo = frontPlot.addShape('sector', {
- attrs: Util.mix({
- x: x,
- y: y,
- r: r + offset + appendRadius,
- r0: r + offset,
- fill: fill,
- startAngle: startAngle,
- endAngle: endAngle
- }, style)
- });
- this.halo = halo;
- var animate = this.animate;
- if (animate) {
- if (animate === true) {
- animate = {
- duration: 300
- };
- }
- halo.attr('r', r + offset);
- halo.animate().to(Util.mix({
- attrs: {
- r: r + offset + appendRadius
- }
- }, animate));
- }
- };
- _proto.start = function start(ev) {
- var chart = this.chart;
- if (ev.type === 'tap') {
- ev.clientX = ev.center.x;
- ev.clientY = ev.center.y;
- }
- var _Util$createEvent = Util.createEvent(ev, chart),
- x = _Util$createEvent.x,
- y = _Util$createEvent.y;
- var records = chart.getSnapRecords({
- x: x,
- y: y
- });
- if (!records.length) {
- this.selected = false;
- this.selectedShape = null;
- return;
- }
- var data = records[0]._origin;
- var selectedShape = this._getSelectedShapeByData(data);
- var lastShape = this.lastShape;
- this.selectedShape = selectedShape;
- this.selected = true;
- if (selectedShape === lastShape) {
- if (!this.cancelable) {
- return;
- }
- this.halo && this.halo.remove(true);
- this.lastShape = null;
- this.selected = false;
- } else {
- this.halo && this.halo.remove(true);
- this._selectedShape(selectedShape);
- }
- this.canvas.draw();
- };
- _proto.end = function end(ev) {
- var selectedShape = this.selectedShape;
- if (selectedShape && !selectedShape.get('destroyed')) {
- ev.data = selectedShape.get('origin')._origin;
- ev.shapeInfo = selectedShape.get('origin');
- ev.shape = selectedShape;
- ev.selected = !!this.selected;
- }
- };
- return PieSelect;
- }(Interaction);
- Chart.registerInteraction('pie-select', PieSelect);
- module.exports = PieSelect;
- /***/ }),
- /* 261 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Helper = __webpack_require__(37);
- var Interaction = __webpack_require__(74);
- var Chart = __webpack_require__(30);
- var IntervalSelect = /*#__PURE__*/function (_Interaction) {
- (0, _inheritsLoose2["default"])(IntervalSelect, _Interaction);
- var _super = _createSuper(IntervalSelect);
- var _proto = IntervalSelect.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
- defaultCfg = Util.mix({}, defaultCfg, {
- startEvent: 'tap',
- processEvent: null,
- selectAxis: true,
- selectAxisStyle: {
- fontWeight: 'bold'
- },
- mode: 'shape',
- selectStyle: {
- fillOpacity: 1
- },
- unSelectStyle: {
- fillOpacity: 0.4
- },
- cancelable: true,
- defaultSelected: null // set the default selected shape
- });
- if (Util.isWx || Util.isMy) {
- // 小程序
- defaultCfg.startEvent = 'touchstart';
- defaultCfg.endEvent = 'touchend';
- }
- return defaultCfg;
- };
- function IntervalSelect(cfg, chart) {
- var _this;
- _this = _Interaction.call(this, cfg, chart) || this;
- var defaultSelected = _this.defaultSelected;
- if (Util.isObject(defaultSelected)) {
- var _this$_selectShapesBy = _this._selectShapesByData(defaultSelected),
- selectedShape = _this$_selectShapesBy.selectedShape,
- unSelectedShapes = _this$_selectShapesBy.unSelectedShapes;
- selectedShape && _this._selectShapes(selectedShape, unSelectedShapes);
- _this.selectedShape = selectedShape;
- }
- return _this;
- }
- _proto._getIntervalShapes = function _getIntervalShapes() {
- var children = [];
- var chart = this.chart;
- var geoms = chart.get('geoms');
- geoms.forEach(function (geom) {
- if (geom.get('type') === 'interval') {
- // only works for Interval geometry type
- var container = geom.get('container');
- children = children.concat(container.get('children'));
- }
- });
- return children;
- };
- _proto._resetShape = function _resetShape(shape) {
- var originAttrs = shape.get('_originAttrs');
- if (originAttrs) {
- shape._attrs.attrs = originAttrs;
- shape.set('_originAttrs', null);
- }
- };
- _proto._setEventData = function _setEventData(ev) {
- var selectedShape = this.selectedShape;
- if (selectedShape && !selectedShape.get('destroyed')) {
- ev.data = selectedShape.get('origin')._origin;
- ev.shapeInfo = selectedShape.get('origin');
- ev.shape = selectedShape;
- ev.selected = !!selectedShape.get('_selected');
- }
- };
- _proto._selectShapesByData = function _selectShapesByData(data) {
- var children = this._getIntervalShapes();
- var selectedShape = null;
- var unSelectedShapes = [];
- Util.each(children, function (child) {
- if (child.get('isShape') && child.get('className') === 'interval') {
- // get geometry's shape
- var shapeData = child.get('origin')._origin;
- if (Util.isObjectValueEqual(shapeData, data)) {
- selectedShape = child;
- } else {
- unSelectedShapes.push(child);
- }
- }
- });
- return {
- selectedShape: selectedShape,
- unSelectedShapes: unSelectedShapes
- };
- };
- _proto._selectShapes = function _selectShapes(selectedShape, unSelectedShapes) {
- var selectStyle = this.selectStyle,
- unSelectStyle = this.unSelectStyle,
- selectAxisStyle = this.selectAxisStyle,
- chart = this.chart;
- if (!selectedShape.get('_originAttrs')) {
- var originAttrs = Object.assign({}, selectedShape.attr());
- selectedShape.set('_originAttrs', originAttrs);
- }
- selectedShape.attr(selectStyle);
- Util.each(unSelectedShapes, function (child) {
- if (!child.get('_originAttrs')) {
- var _originAttrs = Object.assign({}, child.attr());
- child.set('_originAttrs', _originAttrs);
- } else {
- child.attr(child.get('_originAttrs'));
- }
- child.set('_selected', false);
- unSelectStyle && child.attr(unSelectStyle);
- });
- selectedShape.set('_selected', true);
- if (this.selectAxis) {
- if (this.selectedAxisShape) {
- this._resetShape(this.selectedAxisShape);
- }
- var xScale = chart.getXScale();
- var origin = selectedShape.get('origin')._origin;
- var _chart$get = chart.get('axisController'),
- frontPlot = _chart$get.frontPlot,
- backPlot = _chart$get.backPlot;
- var axisShape;
- Util.each(frontPlot.get('children').concat(backPlot.get('children')), function (s) {
- if (s.get('value') === xScale.scale(origin[xScale.field])) {
- axisShape = s;
- return false;
- }
- });
- this.selectedAxisShape = axisShape;
- axisShape.set('_originAttrs', Object.assign({}, axisShape.attr()));
- axisShape.attr(selectAxisStyle);
- }
- this.canvas.draw();
- };
- _proto.reset = function reset() {
- var self = this;
- if (!self.selectedShape) {
- return;
- }
- var children = self._getIntervalShapes();
- Util.each(children, function (child) {
- self._resetShape(child);
- child.set('_selected', false);
- });
- if (self.selectedAxisShape) {
- self._resetShape(self.selectedAxisShape);
- }
- self.canvas.draw();
- self.selectedShape = null;
- self.selectedAxisShape = null;
- };
- _proto.start = function start(ev) {
- var chart = this.chart;
- if (ev.type === 'tap') {
- ev.clientX = ev.center.x;
- ev.clientY = ev.center.y;
- }
- var _Util$createEvent = Util.createEvent(ev, chart),
- x = _Util$createEvent.x,
- y = _Util$createEvent.y;
- var mode = this.mode;
- var children = this._getIntervalShapes();
- var selectedShape;
- var unSelectedShapes = [];
- if (mode === 'shape') {
- var plot = chart.get('plotRange');
- if (!Helper.isPointInPlot({
- x: x,
- y: y
- }, plot)) {
- this.reset();
- return;
- }
- Util.each(children, function (child) {
- var box = child.getBBox();
- if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.height + box.y) {
- // inbox
- selectedShape = child;
- } else {
- unSelectedShapes.push(child);
- }
- });
- } else if (mode === 'range') {
- var records = chart.getSnapRecords({
- x: x,
- y: y
- });
- if (!records.length) {
- this.reset();
- return;
- }
- var data = records[0]._origin;
- var result = this._selectShapesByData(data);
- selectedShape = result.selectedShape;
- unSelectedShapes = result.unSelectedShapes;
- }
- if (selectedShape) {
- this.selectedShape = selectedShape;
- if (selectedShape.get('_selected')) {
- if (!this.cancelable) {
- this._setEventData(ev);
- return;
- }
- this.reset();
- } else {
- this._selectShapes(selectedShape, unSelectedShapes);
- }
- } else {
- this.reset();
- }
- this._setEventData(ev);
- };
- _proto.end = function end(ev) {
- this._setEventData(ev);
- };
- return IntervalSelect;
- }(Interaction);
- Chart.registerInteraction('interval-select', IntervalSelect);
- module.exports = IntervalSelect;
- /***/ }),
- /* 262 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Interaction = __webpack_require__(74);
- var Chart = __webpack_require__(30);
- var FilterPlugin = __webpack_require__(242);
- var MoveMixin = __webpack_require__(245);
- var UpdateScaleMixin = __webpack_require__(243);
- var Swipe = /*#__PURE__*/function (_Interaction) {
- (0, _inheritsLoose2["default"])(Swipe, _Interaction);
- var _super = _createSuper(Swipe);
- var _proto = Swipe.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
- defaultCfg = Util.mix({}, defaultCfg, {
- startEvent: 'touchstart',
- processEvent: 'swipe',
- endEvent: 'touchend',
- currentDeltaX: null,
- threshold: 10,
- // Minimal distance required before recognizing.
- velocity: 0.3,
- // Minimal velocity required before recognizing, unit is in px per ms.
- limitRange: {},
- _timestamp: 0,
- _panCumulativeDelta: 0,
- speed: 5
- });
- return defaultCfg;
- };
- function Swipe(cfg, chart) {
- var _this;
- _this = _Interaction.call(this, cfg, chart) || this;
- var self = (0, _assertThisInitialized2["default"])(_this);
- var hammer = self.hammer,
- threshold = self.threshold,
- velocity = self.velocity;
- if (hammer) {
- hammer.get('swipe').set({
- direction: 6,
- // only support horizontal
- threshold: threshold,
- velocity: velocity
- });
- }
- chart.registerPlugins([FilterPlugin, {
- changeData: function changeData() {
- self.limitRange = {};
- },
- clear: function clear() {
- self.limitRange = {};
- }
- }]);
- self.mode = 'x';
- Util.mix(self, UpdateScaleMixin, MoveMixin);
- return _this;
- }
- _proto.process = function process(e) {
- this.currentDeltaX = 0;
- this._handleMove(e);
- };
- _proto.end = function end() {
- this.currentDeltaX = null;
- this._panCumulativeDelta = 0;
- };
- return Swipe;
- }(Interaction);
- Chart.registerInteraction('swipe', Swipe);
- module.exports = Swipe;
- /***/ }),
- /* 263 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Interaction = __webpack_require__(74);
- var Chart = __webpack_require__(30);
- var FilterPlugin = __webpack_require__(242);
- var MoveMixin = __webpack_require__(245); // const PressTooltipMixin = require('./mixin/press-tooltip');
- var UpdateScaleMixin = __webpack_require__(243);
- var Pan = /*#__PURE__*/function (_Interaction) {
- (0, _inheritsLoose2["default"])(Pan, _Interaction);
- var _super = _createSuper(Pan);
- var _proto = Pan.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
- defaultCfg = Util.mix({}, defaultCfg, {
- startEvent: 'panstart',
- processEvent: 'panmove',
- endEvent: 'panend',
- resetEvent: 'touchend',
- mode: 'x',
- panThreshold: 10,
- // Minimal pan distance required before recognizing
- pressThreshold: 9,
- // Minimal movement that is allowed while pressing
- pressTime: 251,
- // Minimal press time in ms
- currentDeltaX: null,
- currentDeltaY: null,
- limitRange: {},
- _timestamp: 0,
- lastPoint: null,
- _panCumulativeDelta: 0,
- speed: 5
- });
- if (Util.isWx || Util.isMy) {
- // 小程序
- defaultCfg.startEvent = 'touchstart';
- defaultCfg.processEvent = 'touchmove';
- defaultCfg.endEvent = 'touchend';
- }
- return defaultCfg;
- };
- function Pan(cfg, chart) {
- var _this;
- _this = _Interaction.call(this, cfg, chart) || this;
- var self = (0, _assertThisInitialized2["default"])(_this);
- var hammer = self.hammer,
- panThreshold = self.panThreshold;
- if (hammer) {
- hammer.get('pan').set({
- threshold: panThreshold
- }); // 为了兼容hammer的pan 和 tooltips里的press, 后面去hammerjs的时候需要去掉
- chart.get('canvas').on('pan', function () {});
- }
- chart.registerPlugins([FilterPlugin, {
- changeData: function changeData() {
- self.limitRange = {};
- },
- clear: function clear() {
- self.limitRange = {};
- }
- }]);
- Util.mix((0, _assertThisInitialized2["default"])(_this), UpdateScaleMixin, MoveMixin);
- return _this;
- }
- _proto.start = function start(e) {
- if (this.pressed) return;
- this.currentDeltaX = 0;
- this.currentDeltaY = 0;
- if (e.type === 'touchstart' || e.type === 'touchStart') {
- this.lastPoint = e.touches[0];
- }
- this._handleMove(e);
- };
- _proto.process = function process(e) {
- if (this.pressed) return;
- this._handleMove(e);
- };
- _proto.end = function end() {
- if (this.pressed) return;
- this.currentDeltaX = null;
- this.currentDeltaY = null;
- this.lastPoint = null;
- this._panCumulativeDelta = 0;
- };
- return Pan;
- }(Interaction);
- Chart.registerInteraction('pan', Pan);
- module.exports = Pan;
- /***/ }),
- /* 264 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _interopRequireDefault = __webpack_require__(1);
- var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(22));
- var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(2));
- var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(3));
- var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(4));
- 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); }; }
- 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; } }
- var Util = __webpack_require__(0);
- var Helper = __webpack_require__(208);
- var Interaction = __webpack_require__(74);
- var Chart = __webpack_require__(30);
- var FilterPlugin = __webpack_require__(242);
- var updateScaleMixin = __webpack_require__(243);
- var Pinch = /*#__PURE__*/function (_Interaction) {
- (0, _inheritsLoose2["default"])(Pinch, _Interaction);
- var _super = _createSuper(Pinch);
- var _proto = Pinch.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
- return Util.mix({}, defaultCfg, {
- startEvent: 'pinchstart',
- processEvent: 'pinch',
- endEvent: 'pinchend',
- resetEvent: 'touchend',
- pressThreshold: 9,
- // Minimal movement that is allowed while pressing
- pressTime: 251,
- // Minimal press time in ms
- mode: 'x',
- currentPinchScaling: null,
- originValues: null,
- minScale: null,
- maxScale: null,
- limitRange: {},
- sensitivity: 1,
- _pinchCumulativeDelta: 0,
- _timestamp: 0
- });
- };
- function Pinch(cfg, chart) {
- var _this;
- _this = _Interaction.call(this, cfg, chart) || this;
- var self = (0, _assertThisInitialized2["default"])(_this);
- var hammer = self.hammer;
- hammer.get('pinch').set({
- // open pinch recognizer
- enable: true
- });
- chart.registerPlugins([FilterPlugin, {
- changeData: function changeData() {
- self.limitRange = {};
- self.originTicks = null;
- },
- clear: function clear() {
- self.limitRange = {};
- self.originTicks = null;
- }
- }]);
- Util.mix(self, updateScaleMixin);
- return _this;
- }
- _proto.start = function start() {
- if (this.pressed) return;
- this.currentPinchScaling = 1;
- };
- _proto.process = function process(e) {
- if (this.pressed) return;
- this._handlePinch(e);
- };
- _proto.end = function end(e) {
- if (this.pressed) return;
- this._handlePinch(e);
- this.currentPinchScaling = null; // reset
- this.pinchCumulativeDelta = 0;
- };
- _proto._handlePinch = function _handlePinch(e) {
- var currentPinchScaling = this.currentPinchScaling;
- var diff = 1 / currentPinchScaling * e.scale;
- var rect = e.target.getBoundingClientRect();
- var offsetX = e.center.x - rect.left;
- var offsetY = e.center.y - rect.top;
- var center = {
- x: offsetX,
- y: offsetY
- }; // fingers position difference
- var x = Math.abs(e.pointers[0].clientX - e.pointers[1].clientX);
- var y = Math.abs(e.pointers[0].clientY - e.pointers[1].clientY); // diagonal fingers will change both (xy) axes
- var p = x / y;
- var xy;
- if (p > 0.3 && p < 1.7) {
- xy = 'xy';
- } else if (x > y) {
- xy = 'x';
- } else {
- xy = 'y';
- }
- var lastTimestamp = this._timestamp;
- var now = +new Date();
- if (now - lastTimestamp > 16) {
- this._doZoom(diff, center, xy);
- this._timestamp = now;
- } // Keep track of overall scale
- this.currentPinchScaling = e.scale;
- };
- _proto._doZoom = function _doZoom(diff, center, whichAxes) {
- var self = this;
- var mode = self.mode,
- chart = self.chart,
- limitRange = self.limitRange; // Which axe should be modified when figers were used.
- var _whichAxes;
- if (mode === 'xy' && whichAxes !== undefined) {
- // based on fingers positions
- _whichAxes = whichAxes;
- } else {
- _whichAxes = 'xy';
- }
- var data = chart.get('data');
- if (Util.directionEnabled(mode, 'x') && Util.directionEnabled(_whichAxes, 'x')) {
- // x
- var xScale = chart.getXScale();
- var xField = xScale.field;
- if (!limitRange[xField]) {
- limitRange[xField] = Helper.getLimitRange(data, xScale);
- }
- if (xScale.isCategory) {
- // 横轴为分类类型
- self._zoomCatScale(xScale, diff, center);
- } else if (xScale.isLinear) {
- self._zoomLinearScale(xScale, diff, center, 'x');
- }
- this.xRange = Helper.getFieldRange(xScale, limitRange[xField], xScale.type);
- }
- if (Util.directionEnabled(mode, 'y') && Util.directionEnabled(_whichAxes, 'y')) {
- // y
- var yScales = chart.getYScales();
- Util.each(yScales, function (yScale) {
- var yField = yScale.field;
- if (!limitRange[yField]) {
- limitRange[yField] = Helper.getLimitRange(data, yScale);
- }
- yScale.isLinear && self._zoomLinearScale(yScale, diff, center, 'y');
- });
- var scale = yScales[0];
- this.yRange = Helper.getFieldRange(scale, limitRange[scale.field], scale.type);
- }
- chart.repaint();
- };
- _proto._zoomLinearScale = function _zoomLinearScale(scale, zoom, center, flag) {
- var chart = this.chart;
- var min = scale.min,
- max = scale.max,
- field = scale.field;
- var valueRange = max - min;
- var limitRange = this.limitRange;
- var originRange = limitRange[field].max - limitRange[field].min;
- var coord = chart.get('coord');
- var newDiff = valueRange * (zoom - 1);
- if (this.minScale && zoom < 1) {
- // zoom in
- var maxRange = originRange / this.minScale;
- newDiff = Math.max(valueRange - maxRange, newDiff);
- }
- if (this.maxScale && zoom >= 1) {
- // zoom out
- var minRange = originRange / this.maxScale;
- newDiff = Math.min(valueRange - minRange, newDiff);
- }
- var offsetPoint = coord.invertPoint(center);
- var percent = flag === 'x' ? offsetPoint.x : offsetPoint.y;
- var minDelta = newDiff * percent;
- var maxDelta = newDiff * (1 - percent);
- var newMax = max - maxDelta;
- var newMin = min + minDelta;
- this.updateLinearScale(field, newMin, newMax);
- } // 针对分类类型
- ;
- _proto._zoomCatScale = function _zoomCatScale(scale, zoom, center) {
- var pinchCumulativeDelta = this._pinchCumulativeDelta;
- var sensitivity = this.sensitivity;
- pinchCumulativeDelta = zoom > 1 ? pinchCumulativeDelta + 1 : pinchCumulativeDelta - 1;
- this._pinchCumulativeDelta = pinchCumulativeDelta;
- var field = scale.field,
- values = scale.values;
- var chart = this.chart;
- var coord = chart.get('coord');
- if (!this.originTicks) {
- this.originTicks = scale.ticks;
- }
- var originValues = this.limitRange[field];
- var originValuesLen = originValues.length;
- var minScale = this.minScale || 1;
- var maxScale = this.maxScale || 5;
- var minCount = parseInt(originValuesLen / maxScale);
- var maxCount = parseInt(originValuesLen / minScale);
- var currentLen = values.length;
- if (pinchCumulativeDelta > 0 && currentLen <= minCount) {
- return null;
- }
- if (pinchCumulativeDelta < 0 && currentLen >= maxCount) {
- return null;
- }
- var lastLabelIndex = originValuesLen - 1;
- var firstValue = values[0];
- var lastValue = values[currentLen - 1];
- var minIndex = originValues.indexOf(firstValue);
- var maxIndex = originValues.indexOf(lastValue);
- var chartCenter = (coord.start.x + coord.end.x) / 2;
- var centerPointer = center.x;
- if (Math.abs(pinchCumulativeDelta) > sensitivity) {
- var deltaCount = Math.max(1, parseInt(currentLen * Math.abs(zoom - 1)));
- if (pinchCumulativeDelta < 0) {
- if (centerPointer >= chartCenter) {
- if (minIndex <= 0) {
- maxIndex = Math.min(lastLabelIndex, maxIndex + deltaCount);
- } else {
- minIndex = Math.max(0, minIndex - deltaCount);
- }
- } else if (centerPointer < chartCenter) {
- if (maxIndex >= lastLabelIndex) {
- minIndex = Math.max(0, minIndex - deltaCount);
- } else {
- maxIndex = Math.min(lastLabelIndex, maxIndex + deltaCount);
- }
- }
- this._pinchCumulativeDelta = 0;
- } else if (pinchCumulativeDelta > 0) {
- if (centerPointer >= chartCenter) {
- minIndex = minIndex < maxIndex ? minIndex = Math.min(maxIndex, minIndex + deltaCount) : minIndex;
- } else if (centerPointer < chartCenter) {
- maxIndex = maxIndex > minIndex ? maxIndex = Math.max(minIndex, maxIndex - deltaCount) : maxIndex;
- }
- this._pinchCumulativeDelta = 0;
- }
- var newValues = originValues.slice(minIndex, maxIndex + 1);
- this.updateCatScale(field, newValues, this.originTicks, originValues, minIndex, maxIndex);
- }
- };
- return Pinch;
- }(Interaction);
- Chart.registerInteraction('pinch', Pinch);
- module.exports = Pinch;
- /***/ })
- /******/ ]);
- });
|