f2-simple.js 212 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["F2"] = factory();
  8. else
  9. root["F2"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 130);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. /**
  80. * @fileOverview Utility for F2
  81. * @author dxq613@gmail.com
  82. */
  83. var DomUtil = __webpack_require__(43);
  84. var Util = {
  85. upperFirst: __webpack_require__(44),
  86. lowerFirst: __webpack_require__(45),
  87. isString: __webpack_require__(15),
  88. isNumber: __webpack_require__(13),
  89. isBoolean: __webpack_require__(46),
  90. isFunction: __webpack_require__(47),
  91. isDate: __webpack_require__(33),
  92. isArray: __webpack_require__(10),
  93. isNil: __webpack_require__(7),
  94. isObject: __webpack_require__(18),
  95. isPlainObject: __webpack_require__(28),
  96. deepMix: __webpack_require__(49),
  97. mix: __webpack_require__(16),
  98. each: __webpack_require__(3),
  99. isObjectValueEqual: function isObjectValueEqual(a, b) {
  100. // for vue.js
  101. a = Object.assign({}, a);
  102. b = Object.assign({}, b);
  103. var aProps = Object.getOwnPropertyNames(a);
  104. var bProps = Object.getOwnPropertyNames(b);
  105. if (aProps.length !== bProps.length) {
  106. return false;
  107. }
  108. for (var i = 0, len = aProps.length; i < len; i++) {
  109. var propName = aProps[i];
  110. if (a[propName] !== b[propName]) {
  111. return false;
  112. }
  113. }
  114. return true;
  115. },
  116. wrapBehavior: function wrapBehavior(obj, action) {
  117. if (obj['_wrap_' + action]) {
  118. return obj['_wrap_' + action];
  119. }
  120. var method = function method(e) {
  121. obj[action](e);
  122. };
  123. obj['_wrap_' + action] = method;
  124. return method;
  125. },
  126. getWrapBehavior: function getWrapBehavior(obj, action) {
  127. return obj['_wrap_' + action];
  128. },
  129. parsePadding: function parsePadding(padding) {
  130. var top;
  131. var right;
  132. var bottom;
  133. var left;
  134. if (Util.isNumber(padding) || Util.isString(padding)) {
  135. top = bottom = left = right = padding;
  136. } else if (Util.isArray(padding)) {
  137. top = padding[0];
  138. right = !Util.isNil(padding[1]) ? padding[1] : padding[0];
  139. bottom = !Util.isNil(padding[2]) ? padding[2] : padding[0];
  140. left = !Util.isNil(padding[3]) ? padding[3] : right;
  141. }
  142. return [top, right, bottom, left];
  143. },
  144. directionEnabled: function directionEnabled(mode, dir) {
  145. if (mode === undefined) {
  146. return true;
  147. } else if (typeof mode === 'string') {
  148. return mode.indexOf(dir) !== -1;
  149. }
  150. return false;
  151. }
  152. };
  153. Util.Array = {
  154. merge: function merge(dataArray) {
  155. var rst = [];
  156. for (var i = 0, len = dataArray.length; i < len; i++) {
  157. rst = rst.concat(dataArray[i]);
  158. }
  159. return rst;
  160. },
  161. values: function values(data, name) {
  162. var rst = [];
  163. var tmpMap = {};
  164. for (var i = 0, len = data.length; i < len; i++) {
  165. var obj = data[i];
  166. var value = obj[name];
  167. if (!Util.isNil(value)) {
  168. if (!Util.isArray(value)) {
  169. if (!tmpMap[value]) {
  170. rst.push(value);
  171. tmpMap[value] = true;
  172. }
  173. } else {
  174. Util.each(value, function (val) {
  175. if (!tmpMap[val]) {
  176. rst.push(val);
  177. tmpMap[val] = true;
  178. }
  179. });
  180. }
  181. }
  182. }
  183. return rst;
  184. },
  185. firstValue: function firstValue(data, name) {
  186. var rst = null;
  187. for (var i = 0, len = data.length; i < len; i++) {
  188. var obj = data[i];
  189. var value = obj[name];
  190. if (!Util.isNil(value)) {
  191. if (Util.isArray(value)) {
  192. rst = value[0];
  193. } else {
  194. rst = value;
  195. }
  196. break;
  197. }
  198. }
  199. return rst;
  200. },
  201. group: function group(data, fields, appendConditions) {
  202. if (appendConditions === void 0) {
  203. appendConditions = {};
  204. }
  205. if (!fields) {
  206. return [data];
  207. }
  208. var groups = Util.Array.groupToMap(data, fields);
  209. var array = [];
  210. if (fields.length === 1 && appendConditions[fields[0]]) {
  211. var values = appendConditions[fields[0]];
  212. Util.each(values, function (value) {
  213. value = '_' + value;
  214. array.push(groups[value]);
  215. });
  216. } else {
  217. for (var i in groups) {
  218. array.push(groups[i]);
  219. }
  220. }
  221. return array;
  222. },
  223. groupToMap: function groupToMap(data, fields) {
  224. if (!fields) {
  225. return {
  226. 0: data
  227. };
  228. }
  229. var callback = function callback(row) {
  230. var unique = '_';
  231. for (var i = 0, l = fields.length; i < l; i++) {
  232. unique += row[fields[i]] && row[fields[i]].toString();
  233. }
  234. return unique;
  235. };
  236. var groups = {};
  237. for (var i = 0, len = data.length; i < len; i++) {
  238. var row = data[i];
  239. var key = callback(row);
  240. if (groups[key]) {
  241. groups[key].push(row);
  242. } else {
  243. groups[key] = [row];
  244. }
  245. }
  246. return groups;
  247. },
  248. remove: function remove(arr, obj) {
  249. if (!arr) {
  250. return;
  251. }
  252. var index = arr.indexOf(obj);
  253. if (index !== -1) {
  254. arr.splice(index, 1);
  255. }
  256. },
  257. getRange: function getRange(values) {
  258. if (!values.length) {
  259. return {
  260. min: 0,
  261. max: 0
  262. };
  263. }
  264. var max = Math.max.apply(null, values);
  265. var min = Math.min.apply(null, values);
  266. return {
  267. min: min,
  268. max: max
  269. };
  270. }
  271. };
  272. Util.mix(Util, DomUtil);
  273. module.exports = Util;
  274. /***/ }),
  275. /* 1 */
  276. /***/ (function(module, exports, __webpack_require__) {
  277. var Theme = __webpack_require__(42);
  278. var Util = __webpack_require__(0);
  279. var Global = {
  280. version: '3.3.3',
  281. trackable: true,
  282. scales: {},
  283. widthRatio: {
  284. column: 1 / 2,
  285. rose: 0.999999,
  286. multiplePie: 3 / 4
  287. },
  288. lineDash: [4, 4]
  289. };
  290. Global.setTheme = function (theme) {
  291. Util.deepMix(this, theme);
  292. };
  293. Global.setTheme(Theme);
  294. module.exports = Global;
  295. /***/ }),
  296. /* 2 */
  297. /***/ (function(module, exports, __webpack_require__) {
  298. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  299. var Util = __webpack_require__(0);
  300. var Element = __webpack_require__(25);
  301. var Shape =
  302. /*#__PURE__*/
  303. function (_Element) {
  304. _inheritsLoose(Shape, _Element);
  305. function Shape() {
  306. return _Element.apply(this, arguments) || this;
  307. }
  308. var _proto = Shape.prototype;
  309. _proto._initProperties = function _initProperties() {
  310. this._attrs = {
  311. zIndex: 0,
  312. visible: true,
  313. destroyed: false,
  314. isShape: true,
  315. attrs: {}
  316. };
  317. };
  318. _proto.getType = function getType() {
  319. return this._attrs.type;
  320. };
  321. _proto.drawInner = function drawInner(context) {
  322. var self = this;
  323. var attrs = self.get('attrs');
  324. self.createPath(context);
  325. var originOpacity = context.globalAlpha;
  326. if (self.hasFill()) {
  327. var fillOpacity = attrs.fillOpacity;
  328. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  329. context.globalAlpha = fillOpacity;
  330. context.fill();
  331. context.globalAlpha = originOpacity;
  332. } else {
  333. context.fill();
  334. }
  335. }
  336. if (self.hasStroke()) {
  337. var lineWidth = attrs.lineWidth;
  338. if (lineWidth > 0) {
  339. var strokeOpacity = attrs.strokeOpacity;
  340. if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
  341. context.globalAlpha = strokeOpacity;
  342. }
  343. context.stroke();
  344. }
  345. }
  346. };
  347. _proto.getBBox = function getBBox() {
  348. var bbox = this._attrs.bbox;
  349. if (!bbox) {
  350. bbox = this.calculateBox();
  351. if (bbox) {
  352. bbox.x = bbox.minX;
  353. bbox.y = bbox.minY;
  354. bbox.width = bbox.maxX - bbox.minX;
  355. bbox.height = bbox.maxY - bbox.minY;
  356. }
  357. this._attrs.bbox = bbox;
  358. }
  359. return bbox;
  360. };
  361. _proto.calculateBox = function calculateBox() {
  362. return null;
  363. };
  364. _proto.createPath = function createPath() {};
  365. return Shape;
  366. }(Element);
  367. module.exports = Shape;
  368. /***/ }),
  369. /* 3 */
  370. /***/ (function(module, exports, __webpack_require__) {
  371. var isObject = __webpack_require__(18);
  372. var isArray = __webpack_require__(10);
  373. var each = function each(elements, func) {
  374. if (!elements) {
  375. return;
  376. }
  377. var rst = void 0;
  378. if (isArray(elements)) {
  379. for (var i = 0, len = elements.length; i < len; i++) {
  380. rst = func(elements[i], i);
  381. if (rst === false) {
  382. break;
  383. }
  384. }
  385. } else if (isObject(elements)) {
  386. for (var k in elements) {
  387. if (elements.hasOwnProperty(k)) {
  388. rst = func(elements[k], k);
  389. if (rst === false) {
  390. break;
  391. }
  392. }
  393. }
  394. }
  395. };
  396. module.exports = each;
  397. /***/ }),
  398. /* 4 */
  399. /***/ (function(module, exports) {
  400. /**
  401. * 2 Dimensional Vector
  402. * @module vector2
  403. */
  404. module.exports = {
  405. /**
  406. * Creates a new, empty vector2
  407. *
  408. * @return {vector2} a new 2D vector
  409. */
  410. create: function create() {
  411. return [0, 0];
  412. },
  413. /**
  414. * Calculates the length of a vector2
  415. *
  416. * @param {vector2} v vector to calculate length of
  417. * @return {Number} length of v
  418. */
  419. length: function length(v) {
  420. var x = v[0];
  421. var y = v[1];
  422. return Math.sqrt(x * x + y * y);
  423. },
  424. /**
  425. * Normalize a vector2
  426. *
  427. * @param {vector2} out the receiving vector
  428. * @param {vector2} v vector to normalize
  429. * @return {vector2} out
  430. */
  431. normalize: function normalize(out, v) {
  432. var len = this.length(v);
  433. if (len === 0) {
  434. out[0] = 0;
  435. out[1] = 0;
  436. } else {
  437. out[0] = v[0] / len;
  438. out[1] = v[1] / len;
  439. }
  440. return out;
  441. },
  442. /**
  443. * Adds two vector2's
  444. *
  445. * @param {vector2} out the receiving vector
  446. * @param {vector2} v1 the first operand
  447. * @param {vector2} v2 the second operand
  448. * @return {vector2} out
  449. */
  450. add: function add(out, v1, v2) {
  451. out[0] = v1[0] + v2[0];
  452. out[1] = v1[1] + v2[1];
  453. return out;
  454. },
  455. /**
  456. * Subtracts vector v2 from vector v1
  457. *
  458. * @param {vector2} out the receiving vector
  459. * @param {vector2} v1 the first operand
  460. * @param {vector2} v2 the second operand
  461. * @return {vector2} out
  462. */
  463. sub: function sub(out, v1, v2) {
  464. out[0] = v1[0] - v2[0];
  465. out[1] = v1[1] - v2[1];
  466. return out;
  467. },
  468. /**
  469. * Scales a vector2 by a scalar number
  470. *
  471. * @param {vector2} out the receiving vector
  472. * @param {vector2} v the vector to scale
  473. * @param {Number} s amount to scale the vector by
  474. * @return {vector2} out
  475. */
  476. scale: function scale(out, v, s) {
  477. out[0] = v[0] * s;
  478. out[1] = v[1] * s;
  479. return out;
  480. },
  481. /**
  482. * Calculates the dot product of two vector2's
  483. *
  484. * @param {vector2} v1 the first operand
  485. * @param {vector2} v2 the second operand
  486. * @return {Number} dot product of v1 and v2
  487. */
  488. dot: function dot(v1, v2) {
  489. return v1[0] * v2[0] + v1[1] * v2[1];
  490. },
  491. /**
  492. * Calculates the direction of two vector2's
  493. *
  494. * @param {vector2} v1 the first operand
  495. * @param {vector2} v2 the second operand
  496. * @return {Boolean} the direction of v1 and v2
  497. */
  498. direction: function direction(v1, v2) {
  499. return v1[0] * v2[1] - v2[0] * v1[1];
  500. },
  501. /**
  502. * Calculates the angle of two vector2's
  503. *
  504. * @param {vector2} v1 the first operand
  505. * @param {vector2} v2 the second operand
  506. * @return {Number} angle of v1 and v2
  507. */
  508. angle: function angle(v1, v2) {
  509. var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
  510. return Math.acos(theta);
  511. },
  512. /**
  513. * Calculates the angle of two vector2's with direction
  514. *
  515. * @param {vector2} v1 the first operand
  516. * @param {vector2} v2 the second operand
  517. * @param {Boolean} direction the direction of two vector2's
  518. * @return {Number} angle of v1 and v2
  519. */
  520. angleTo: function angleTo(v1, v2, direction) {
  521. var angle = this.angle(v1, v2);
  522. var angleLargeThanPI = this.direction(v1, v2) >= 0;
  523. if (direction) {
  524. if (angleLargeThanPI) {
  525. return Math.PI * 2 - angle;
  526. }
  527. return angle;
  528. }
  529. if (angleLargeThanPI) {
  530. return angle;
  531. }
  532. return Math.PI * 2 - angle;
  533. },
  534. /**
  535. * whether a vector2 is zero vector
  536. *
  537. * @param {vector2} v vector to calculate
  538. * @return {Boolean} is or not a zero vector
  539. */
  540. zero: function zero(v) {
  541. return v[0] === 0 && v[1] === 0;
  542. },
  543. /**
  544. * Calculates the euclidian distance between two vector2's
  545. *
  546. * @param {vector2} v1 the first operand
  547. * @param {vector2} v2 the second operand
  548. * @return {Number} distance between a and b
  549. */
  550. distance: function distance(v1, v2) {
  551. var x = v2[0] - v1[0];
  552. var y = v2[1] - v1[1];
  553. return Math.sqrt(x * x + y * y);
  554. },
  555. /**
  556. * Creates a new vector2 initialized with values from an existing vector
  557. *
  558. * @param {vector2} v vector to clone
  559. * @return {Array} a new 2D vector
  560. */
  561. clone: function clone(v) {
  562. return [v[0], v[1]];
  563. },
  564. /**
  565. * Return the minimum of two vector2's
  566. *
  567. * @param {vector2} out the receiving vector
  568. * @param {vector2} v1 the first operand
  569. * @param {vector2} v2 the second operand
  570. * @return {vector2} out
  571. */
  572. min: function min(out, v1, v2) {
  573. out[0] = Math.min(v1[0], v2[0]);
  574. out[1] = Math.min(v1[1], v2[1]);
  575. return out;
  576. },
  577. /**
  578. * Return the maximum of two vector2's
  579. *
  580. * @param {vector2} out the receiving vector
  581. * @param {vector2} v1 the first operand
  582. * @param {vector2} v2 the second operand
  583. * @return {vector2} out
  584. */
  585. max: function max(out, v1, v2) {
  586. out[0] = Math.max(v1[0], v2[0]);
  587. out[1] = Math.max(v1[1], v2[1]);
  588. return out;
  589. },
  590. /**
  591. * Transforms the vector2 with a mat2d
  592. *
  593. * @param {vector2} out the receiving vector
  594. * @param {vector2} v the vector to transform
  595. * @param {mat2d} m matrix to transform with
  596. * @return {vector2} out
  597. */
  598. transformMat2d: function transformMat2d(out, v, m) {
  599. var x = v[0];
  600. var y = v[1];
  601. out[0] = m[0] * x + m[2] * y + m[4];
  602. out[1] = m[1] * x + m[3] * y + m[5];
  603. return out;
  604. }
  605. };
  606. /***/ }),
  607. /* 5 */
  608. /***/ (function(module, exports, __webpack_require__) {
  609. var G = {
  610. Canvas: __webpack_require__(68),
  611. Group: __webpack_require__(31),
  612. Shape: __webpack_require__(2),
  613. Matrix: __webpack_require__(23),
  614. Vector2: __webpack_require__(4)
  615. };
  616. __webpack_require__(70);
  617. __webpack_require__(71);
  618. __webpack_require__(72);
  619. __webpack_require__(73);
  620. __webpack_require__(74);
  621. __webpack_require__(75);
  622. __webpack_require__(76);
  623. __webpack_require__(77);
  624. __webpack_require__(78);
  625. module.exports = G;
  626. /***/ }),
  627. /* 6 */
  628. /***/ (function(module, exports, __webpack_require__) {
  629. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  630. var Util = __webpack_require__(0);
  631. var Base = __webpack_require__(29);
  632. var GROUP_ATTRS = ['color', 'size', 'shape'];
  633. var FIELD_ORIGIN = '_origin';
  634. var FIELD_ORIGIN_Y = '_originY';
  635. var Global = __webpack_require__(1);
  636. var Attr = __webpack_require__(53);
  637. var GeometryShape = __webpack_require__(9);
  638. var Adjust = __webpack_require__(22);
  639. function parseFields(field) {
  640. if (Util.isArray(field)) {
  641. return field;
  642. }
  643. if (Util.isString(field)) {
  644. return field.split('*');
  645. }
  646. return [field];
  647. }
  648. /**
  649. * The parent class for Geometry
  650. * @class Geom
  651. */
  652. var Geom =
  653. /*#__PURE__*/
  654. function (_Base) {
  655. _inheritsLoose(Geom, _Base);
  656. function Geom() {
  657. return _Base.apply(this, arguments) || this;
  658. }
  659. var _proto = Geom.prototype;
  660. _proto.getDefaultCfg = function getDefaultCfg() {
  661. return {
  662. /**
  663. * geometry type
  664. * @type {String}
  665. */
  666. type: null,
  667. /**
  668. * the data of geometry
  669. * @type {Array}
  670. */
  671. data: null,
  672. /**
  673. * the attrs of geo,etry
  674. * @type {Object}
  675. */
  676. attrs: {},
  677. scales: {},
  678. /**
  679. * group for storing the shapes
  680. * @type {Canvas}
  681. */
  682. container: null,
  683. /**
  684. * style options
  685. * @type {Object}
  686. */
  687. styleOptions: null,
  688. chart: null,
  689. shapeType: '',
  690. /**
  691. * wether to generate key points for each shape
  692. * @protected
  693. * @type {Boolean}
  694. */
  695. generatePoints: false,
  696. attrOptions: {},
  697. sortable: false,
  698. startOnZero: true,
  699. visible: true,
  700. connectNulls: false
  701. };
  702. };
  703. _proto.init = function init() {
  704. var self = this;
  705. self._initAttrs();
  706. var dataArray = self._processData();
  707. if (self.get('adjust')) {
  708. self._adjustData(dataArray);
  709. }
  710. self.set('dataArray', dataArray);
  711. };
  712. _proto._getGroupScales = function _getGroupScales() {
  713. var self = this;
  714. var scales = [];
  715. Util.each(GROUP_ATTRS, function (attrName) {
  716. var attr = self.getAttr(attrName);
  717. if (attr) {
  718. var attrScales = attr.scales;
  719. Util.each(attrScales, function (scale) {
  720. if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
  721. scales.push(scale);
  722. }
  723. });
  724. }
  725. });
  726. return scales;
  727. };
  728. _proto._groupData = function _groupData(data) {
  729. var self = this;
  730. var colDefs = self.get('colDefs');
  731. var groupScales = self._getGroupScales();
  732. if (groupScales.length) {
  733. var appendConditions = {};
  734. var names = [];
  735. Util.each(groupScales, function (scale) {
  736. var field = scale.field;
  737. names.push(field);
  738. if (colDefs && colDefs[field] && colDefs[field].values) {
  739. // users have defined
  740. appendConditions[scale.field] = colDefs[field].values;
  741. }
  742. });
  743. return Util.Array.group(data, names, appendConditions);
  744. }
  745. return [data];
  746. };
  747. _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
  748. var options = this.get('attrOptions');
  749. options[attrName] = attrCfg;
  750. };
  751. _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
  752. var attrCfg = {};
  753. attrCfg.field = field;
  754. if (cfg) {
  755. if (Util.isFunction(cfg)) {
  756. attrCfg.callback = cfg;
  757. } else {
  758. attrCfg.values = cfg;
  759. }
  760. } else {
  761. attrCfg.values = defaultValues;
  762. }
  763. this._setAttrOptions(attrName, attrCfg);
  764. };
  765. _proto._initAttrs = function _initAttrs() {
  766. var self = this;
  767. var attrs = self.get('attrs');
  768. var attrOptions = self.get('attrOptions');
  769. var coord = self.get('coord');
  770. for (var type in attrOptions) {
  771. if (attrOptions.hasOwnProperty(type)) {
  772. var option = attrOptions[type];
  773. var className = Util.upperFirst(type);
  774. var fields = parseFields(option.field);
  775. if (type === 'position') {
  776. option.coord = coord;
  777. }
  778. var scales = [];
  779. for (var i = 0, len = fields.length; i < len; i++) {
  780. var field = fields[i];
  781. var scale = self._createScale(field);
  782. scales.push(scale);
  783. }
  784. if (type === 'position') {
  785. var yScale = scales[1];
  786. if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
  787. if (yScale.values.length) {
  788. yScale.change({
  789. nice: false,
  790. min: 0,
  791. max: Math.max.apply(null, yScale.values)
  792. });
  793. }
  794. }
  795. }
  796. option.scales = scales;
  797. var attr = new Attr[className](option);
  798. attrs[type] = attr;
  799. }
  800. }
  801. };
  802. _proto._createScale = function _createScale(field) {
  803. var scales = this.get('scales');
  804. var scale = scales[field];
  805. if (!scale) {
  806. scale = this.get('chart').createScale(field);
  807. scales[field] = scale;
  808. }
  809. return scale;
  810. };
  811. _proto._processData = function _processData() {
  812. var self = this;
  813. var data = this.get('data');
  814. var dataArray = [];
  815. var groupedArray = this._groupData(data);
  816. for (var i = 0, len = groupedArray.length; i < len; i++) {
  817. var subData = groupedArray[i];
  818. var tempData = self._saveOrigin(subData);
  819. if (this.hasAdjust('dodge')) {
  820. self._numberic(tempData);
  821. }
  822. dataArray.push(tempData);
  823. }
  824. return dataArray;
  825. };
  826. _proto._saveOrigin = function _saveOrigin(data) {
  827. var rst = [];
  828. for (var i = 0, len = data.length; i < len; i++) {
  829. var origin = data[i];
  830. var obj = {};
  831. for (var k in origin) {
  832. obj[k] = origin[k];
  833. }
  834. obj[FIELD_ORIGIN] = origin;
  835. rst.push(obj);
  836. }
  837. return rst;
  838. };
  839. _proto._numberic = function _numberic(data) {
  840. var positionAttr = this.getAttr('position');
  841. var scales = positionAttr.scales;
  842. for (var j = 0, len = data.length; j < len; j++) {
  843. var obj = data[j];
  844. var count = Math.min(2, scales.length);
  845. for (var i = 0; i < count; i++) {
  846. var scale = scales[i];
  847. if (scale.isCategory) {
  848. var field = scale.field;
  849. obj[field] = scale.translate(obj[field]);
  850. }
  851. }
  852. }
  853. };
  854. _proto._adjustData = function _adjustData(dataArray) {
  855. var self = this;
  856. var adjust = self.get('adjust');
  857. if (adjust) {
  858. var adjustType = Util.upperFirst(adjust.type);
  859. if (!Adjust[adjustType]) {
  860. throw new Error('not support such adjust : ' + adjust);
  861. }
  862. var xScale = self.getXScale();
  863. var yScale = self.getYScale();
  864. var cfg = Util.mix({
  865. xField: xScale.field,
  866. yField: yScale.field
  867. }, adjust);
  868. var adjustObject = new Adjust[adjustType](cfg);
  869. adjustObject.processAdjust(dataArray);
  870. if (adjustType === 'Stack') {
  871. self._updateStackRange(yScale.field, yScale, dataArray);
  872. }
  873. }
  874. };
  875. _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
  876. var mergeArray = Util.Array.merge(dataArray);
  877. var min = scale.min;
  878. var max = scale.max;
  879. for (var i = 0, len = mergeArray.length; i < len; i++) {
  880. var obj = mergeArray[i];
  881. var tmpMin = Math.min.apply(null, obj[field]);
  882. var tmpMax = Math.max.apply(null, obj[field]);
  883. if (tmpMin < min) {
  884. min = tmpMin;
  885. }
  886. if (tmpMax > max) {
  887. max = tmpMax;
  888. }
  889. }
  890. if (min < scale.min || max > scale.max) {
  891. scale.change({
  892. min: min,
  893. max: max
  894. });
  895. }
  896. };
  897. _proto._sort = function _sort(mappedArray) {
  898. var self = this;
  899. var xScale = self.getXScale();
  900. var field = xScale.field,
  901. type = xScale.type;
  902. if (type !== 'identity' && xScale.values.length > 1) {
  903. Util.each(mappedArray, function (itemArr) {
  904. itemArr.sort(function (obj1, obj2) {
  905. if (type === 'timeCat') {
  906. return xScale._toTimeStamp(obj1[FIELD_ORIGIN][field]) - xScale._toTimeStamp(obj2[FIELD_ORIGIN][field]);
  907. }
  908. return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
  909. });
  910. });
  911. }
  912. self.set('hasSorted', true);
  913. self.set('dataArray', mappedArray);
  914. };
  915. _proto.paint = function paint() {
  916. var self = this;
  917. var dataArray = self.get('dataArray');
  918. var mappedArray = [];
  919. var shapeFactory = self.getShapeFactory();
  920. shapeFactory.setCoord(self.get('coord'));
  921. self._beforeMapping(dataArray);
  922. for (var i = 0, len = dataArray.length; i < len; i++) {
  923. var data = dataArray[i];
  924. if (data.length) {
  925. data = self._mapping(data);
  926. mappedArray.push(data);
  927. self.draw(data, shapeFactory);
  928. }
  929. }
  930. self.set('dataArray', mappedArray);
  931. };
  932. _proto.getShapeFactory = function getShapeFactory() {
  933. var shapeFactory = this.get('shapeFactory');
  934. if (!shapeFactory) {
  935. var shapeType = this.get('shapeType');
  936. shapeFactory = GeometryShape.getShapeFactory(shapeType);
  937. this.set('shapeFactory', shapeFactory);
  938. }
  939. return shapeFactory;
  940. };
  941. _proto._mapping = function _mapping(data) {
  942. var self = this;
  943. var attrs = self.get('attrs');
  944. var yField = self.getYScale().field;
  945. var mappedData = [];
  946. for (var i = 0, len = data.length; i < len; i++) {
  947. var record = data[i];
  948. var newRecord = {};
  949. newRecord[FIELD_ORIGIN] = record[FIELD_ORIGIN];
  950. newRecord.points = record.points; // 避免
  951. newRecord[FIELD_ORIGIN_Y] = record[yField];
  952. for (var k in attrs) {
  953. if (attrs.hasOwnProperty(k)) {
  954. var attr = attrs[k];
  955. var names = attr.names;
  956. var values = self._getAttrValues(attr, record);
  957. if (names.length > 1) {
  958. for (var j = 0, _len = values.length; j < _len; j++) {
  959. var val = values[j];
  960. var name = names[j];
  961. newRecord[name] = Util.isArray(val) && val.length === 1 ? val[0] : val;
  962. }
  963. } else {
  964. newRecord[names[0]] = values.length === 1 ? values[0] : values;
  965. }
  966. }
  967. }
  968. mappedData.push(newRecord);
  969. }
  970. return mappedData;
  971. };
  972. _proto._getAttrValues = function _getAttrValues(attr, record) {
  973. var scales = attr.scales;
  974. var params = [];
  975. for (var i = 0, len = scales.length; i < len; i++) {
  976. var scale = scales[i];
  977. var field = scale.field;
  978. if (scale.type === 'identity') {
  979. params.push(scale.value);
  980. } else {
  981. params.push(record[field]);
  982. }
  983. }
  984. var values = attr.mapping.apply(attr, params);
  985. return values;
  986. };
  987. _proto.getAttrValue = function getAttrValue(attrName, record) {
  988. var attr = this.getAttr(attrName);
  989. var rst = null;
  990. if (attr) {
  991. var values = this._getAttrValues(attr, record);
  992. rst = values[0];
  993. }
  994. return rst;
  995. };
  996. _proto._beforeMapping = function _beforeMapping(dataArray) {
  997. var self = this;
  998. if (self.get('sortable')) {
  999. self._sort(dataArray);
  1000. }
  1001. if (self.get('generatePoints')) {
  1002. Util.each(dataArray, function (data) {
  1003. self._generatePoints(data);
  1004. });
  1005. }
  1006. };
  1007. _proto.isInCircle = function isInCircle() {
  1008. var coord = this.get('coord');
  1009. return coord && coord.isPolar;
  1010. };
  1011. _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
  1012. if (!fields) {
  1013. return cfg;
  1014. }
  1015. var tmpCfg = {};
  1016. var params = fields.map(function (field) {
  1017. return origin[field];
  1018. });
  1019. Util.each(cfg, function (v, k) {
  1020. if (Util.isFunction(v)) {
  1021. tmpCfg[k] = v.apply(null, params);
  1022. } else {
  1023. tmpCfg[k] = v;
  1024. }
  1025. });
  1026. return tmpCfg;
  1027. };
  1028. _proto.getDrawCfg = function getDrawCfg(obj) {
  1029. var self = this;
  1030. var isInCircle = self.isInCircle();
  1031. var cfg = {
  1032. origin: obj,
  1033. x: obj.x,
  1034. y: obj.y,
  1035. color: obj.color,
  1036. size: obj.size,
  1037. shape: obj.shape,
  1038. isInCircle: isInCircle,
  1039. opacity: obj.opacity
  1040. };
  1041. var styleOptions = self.get('styleOptions');
  1042. if (styleOptions && styleOptions.style) {
  1043. cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
  1044. }
  1045. if (self.get('generatePoints')) {
  1046. cfg.points = obj.points;
  1047. }
  1048. if (isInCircle) {
  1049. cfg.center = self.get('coord').center;
  1050. }
  1051. return cfg;
  1052. };
  1053. _proto.draw = function draw(data, shapeFactory) {
  1054. var self = this;
  1055. var container = self.get('container');
  1056. var yScale = self.getYScale();
  1057. Util.each(data, function (obj, index) {
  1058. if (yScale && Util.isNil(obj._origin[yScale.field])) {
  1059. return;
  1060. }
  1061. obj.index = index;
  1062. var cfg = self.getDrawCfg(obj);
  1063. var shape = obj.shape;
  1064. self.drawShape(shape, obj, cfg, container, shapeFactory);
  1065. });
  1066. };
  1067. _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
  1068. var gShape = shapeFactory.drawShape(shape, cfg, container);
  1069. if (gShape) {
  1070. Util.each([].concat(gShape), function (s) {
  1071. s.set('origin', shapeData);
  1072. });
  1073. }
  1074. };
  1075. _proto._generatePoints = function _generatePoints(data) {
  1076. var self = this;
  1077. var shapeFactory = self.getShapeFactory();
  1078. var shapeAttr = self.getAttr('shape');
  1079. for (var i = 0, len = data.length; i < len; i++) {
  1080. var obj = data[i];
  1081. var cfg = self.createShapePointsCfg(obj);
  1082. var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
  1083. var points = shapeFactory.getShapePoints(shape, cfg);
  1084. obj.points = points;
  1085. }
  1086. };
  1087. /**
  1088. * get the info of each shape
  1089. * @protected
  1090. * @param {Object} obj the data item
  1091. * @return {Object} cfg return the result
  1092. */
  1093. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  1094. var xScale = this.getXScale();
  1095. var yScale = this.getYScale();
  1096. var x = this._normalizeValues(obj[xScale.field], xScale);
  1097. var y;
  1098. if (yScale) {
  1099. y = this._normalizeValues(obj[yScale.field], yScale);
  1100. } else {
  1101. y = obj.y ? obj.y : 0.1;
  1102. }
  1103. return {
  1104. x: x,
  1105. y: y,
  1106. y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
  1107. };
  1108. };
  1109. _proto.getYMinValue = function getYMinValue() {
  1110. var yScale = this.getYScale();
  1111. var min = yScale.min,
  1112. max = yScale.max;
  1113. var value;
  1114. if (this.get('startOnZero')) {
  1115. if (max <= 0 && min <= 0) {
  1116. value = max;
  1117. } else {
  1118. value = min >= 0 ? min : 0;
  1119. }
  1120. } else {
  1121. value = min;
  1122. }
  1123. return value;
  1124. };
  1125. _proto._normalizeValues = function _normalizeValues(values, scale) {
  1126. var rst = [];
  1127. if (Util.isArray(values)) {
  1128. for (var i = 0, len = values.length; i < len; i++) {
  1129. var v = values[i];
  1130. rst.push(scale.scale(v));
  1131. }
  1132. } else {
  1133. rst = scale.scale(values);
  1134. }
  1135. return rst;
  1136. };
  1137. _proto.getAttr = function getAttr(name) {
  1138. return this.get('attrs')[name];
  1139. };
  1140. _proto.getXScale = function getXScale() {
  1141. return this.getAttr('position').scales[0];
  1142. };
  1143. _proto.getYScale = function getYScale() {
  1144. return this.getAttr('position').scales[1];
  1145. };
  1146. _proto.hasAdjust = function hasAdjust(adjust) {
  1147. return this.get('adjust') && this.get('adjust').type === adjust;
  1148. };
  1149. _proto._getSnap = function _getSnap(scale, item, arr) {
  1150. var i = 0;
  1151. var values;
  1152. var yField = this.getYScale().field; // 叠加的维度
  1153. if (this.hasAdjust('stack') && scale.field === yField) {
  1154. values = [];
  1155. arr.forEach(function (obj) {
  1156. values.push(obj[FIELD_ORIGIN_Y]);
  1157. });
  1158. for (var len = values.length; i < len; i++) {
  1159. if (values[0][0] > item) {
  1160. break;
  1161. }
  1162. if (values[values.length - 1][1] <= item) {
  1163. i = values.length - 1;
  1164. break;
  1165. }
  1166. if (values[i][0] <= item && values[i][1] > item) {
  1167. break;
  1168. }
  1169. }
  1170. } else {
  1171. values = scale.values;
  1172. values.sort(function (a, b) {
  1173. return a - b;
  1174. });
  1175. for (var _len2 = values.length; i < _len2; i++) {
  1176. if ((values[0] + values[1]) / 2 > item) {
  1177. break;
  1178. }
  1179. if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
  1180. break;
  1181. }
  1182. if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
  1183. i = values.length - 1;
  1184. break;
  1185. }
  1186. }
  1187. }
  1188. var result = values[i];
  1189. return result;
  1190. };
  1191. _proto.getSnapRecords = function getSnapRecords(point) {
  1192. var self = this;
  1193. var coord = self.get('coord');
  1194. var xScale = self.getXScale();
  1195. var yScale = self.getYScale();
  1196. var xfield = xScale.field;
  1197. var dataArray = self.get('dataArray');
  1198. if (!this.get('hasSorted')) {
  1199. this._sort(dataArray);
  1200. }
  1201. var rst = [];
  1202. var invertPoint = coord.invertPoint(point);
  1203. var invertPointX = invertPoint.x;
  1204. if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
  1205. invertPointX = xScale.rangeMin();
  1206. }
  1207. var xValue = xScale.invert(invertPointX);
  1208. if (!xScale.isCategory) {
  1209. xValue = self._getSnap(xScale, xValue);
  1210. }
  1211. var tmp = [];
  1212. dataArray.forEach(function (data) {
  1213. data.forEach(function (obj) {
  1214. var originValue = Util.isNil(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
  1215. if (self._isEqual(originValue, xValue, xScale)) {
  1216. tmp.push(obj);
  1217. }
  1218. });
  1219. }); // special for pie chart
  1220. if (this.hasAdjust('stack') && coord.isPolar && coord.transposed && xScale.values.length === 1) {
  1221. if (invertPointX >= 0 && invertPointX <= 1) {
  1222. var yValue = yScale.invert(invertPoint.y);
  1223. yValue = self._getSnap(yScale, yValue, tmp);
  1224. tmp.forEach(function (obj) {
  1225. if (Util.isArray(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
  1226. rst.push(obj);
  1227. }
  1228. });
  1229. }
  1230. } else {
  1231. rst = tmp;
  1232. }
  1233. return rst;
  1234. };
  1235. _proto._isEqual = function _isEqual(originValue, value, scale) {
  1236. if (scale.type === 'timeCat') {
  1237. return scale._toTimeStamp(originValue) === value;
  1238. }
  1239. return value === originValue;
  1240. };
  1241. _proto.position = function position(field) {
  1242. this._setAttrOptions('position', {
  1243. field: field
  1244. });
  1245. return this;
  1246. };
  1247. _proto.color = function color(field, values) {
  1248. this._createAttrOption('color', field, values, Global.colors);
  1249. return this;
  1250. };
  1251. _proto.size = function size(field, values) {
  1252. this._createAttrOption('size', field, values, Global.sizes);
  1253. return this;
  1254. };
  1255. _proto.shape = function shape(field, values) {
  1256. var type = this.get('type');
  1257. var shapes = Global.shapes[type] || [];
  1258. this._createAttrOption('shape', field, values, shapes);
  1259. return this;
  1260. };
  1261. _proto.style = function style(field, cfg) {
  1262. var styleOptions = this.get('styleOptions');
  1263. if (!styleOptions) {
  1264. styleOptions = {};
  1265. this.set('styleOptions', styleOptions);
  1266. }
  1267. if (Util.isObject(field)) {
  1268. cfg = field;
  1269. field = null;
  1270. }
  1271. var fields;
  1272. if (field) {
  1273. fields = parseFields(field);
  1274. }
  1275. styleOptions.fields = fields;
  1276. styleOptions.style = cfg;
  1277. return this;
  1278. };
  1279. _proto.adjust = function adjust(type) {
  1280. if (Util.isString(type)) {
  1281. type = {
  1282. type: type
  1283. };
  1284. }
  1285. this.set('adjust', type);
  1286. return this;
  1287. };
  1288. _proto.animate = function animate(cfg) {
  1289. this.set('animateCfg', cfg);
  1290. return this;
  1291. };
  1292. _proto.reset = function reset() {
  1293. this.set('attrOptions', {});
  1294. this.set('adjust', null);
  1295. this.clearInner();
  1296. };
  1297. _proto.clearInner = function clearInner() {
  1298. var container = this.get('container');
  1299. if (container) {
  1300. container.clear();
  1301. container.setMatrix([1, 0, 0, 1, 0, 0]);
  1302. }
  1303. container && container.clear();
  1304. this.set('attrs', {});
  1305. this.set('groupScales', null);
  1306. this.set('xDistance', null);
  1307. this.set('_width', null);
  1308. };
  1309. _proto.clear = function clear() {
  1310. this.clearInner();
  1311. this.set('scales', {});
  1312. };
  1313. _proto.destroy = function destroy() {
  1314. this.clear();
  1315. _Base.prototype.destroy.call(this);
  1316. };
  1317. _proto._display = function _display(visible) {
  1318. this.set('visible', visible);
  1319. var container = this.get('container');
  1320. var canvas = container.get('canvas');
  1321. container.set('visible', visible);
  1322. canvas.draw();
  1323. };
  1324. _proto.show = function show() {
  1325. this._display(true);
  1326. };
  1327. _proto.hide = function hide() {
  1328. this._display(false);
  1329. };
  1330. return Geom;
  1331. }(Base);
  1332. module.exports = Geom;
  1333. /***/ }),
  1334. /* 7 */
  1335. /***/ (function(module, exports) {
  1336. // isFinite,
  1337. var isNil = function isNil(value) {
  1338. /**
  1339. * isNil(null) => true
  1340. * isNil() => true
  1341. */
  1342. return value === null || value === undefined;
  1343. };
  1344. module.exports = isNil;
  1345. /***/ }),
  1346. /* 8 */
  1347. /***/ (function(module, exports) {
  1348. var toString = {}.toString;
  1349. var isType = function isType(value, type) {
  1350. return toString.call(value) === '[object ' + type + ']';
  1351. };
  1352. module.exports = isType;
  1353. /***/ }),
  1354. /* 9 */
  1355. /***/ (function(module, exports, __webpack_require__) {
  1356. var Util = __webpack_require__(0);
  1357. var Global = __webpack_require__(1);
  1358. var Shape = {};
  1359. var ShapeBase = {
  1360. _coord: null,
  1361. /**
  1362. * draw the shape
  1363. * @param {Object} cfg options
  1364. * @param {Object} container container to store the shapes
  1365. */
  1366. draw: function draw(cfg, container) {
  1367. if (this.drawShape) {
  1368. this.drawShape(cfg, container);
  1369. }
  1370. },
  1371. /**
  1372. * set the coordinate instance
  1373. * @param {Coord} coord coordinate instance
  1374. */
  1375. setCoord: function setCoord(coord) {
  1376. this._coord = coord;
  1377. },
  1378. /**
  1379. * convert the normalized value to the canvas position
  1380. * @param {point} point the point to convert
  1381. * @return {point} point return the result
  1382. */
  1383. parsePoint: function parsePoint(point) {
  1384. var coord = this._coord;
  1385. if (coord.isPolar) {
  1386. if (point.x === 1) point.x = 0.9999999;
  1387. if (point.y === 1) point.y = 0.9999999;
  1388. }
  1389. return coord.convertPoint(point);
  1390. },
  1391. /**
  1392. * convert the normalized value to the canvas position
  1393. * @param {points} points the array that store the points
  1394. * @return {points} points return the result
  1395. */
  1396. parsePoints: function parsePoints(points) {
  1397. if (!points) return false;
  1398. var self = this;
  1399. var rst = [];
  1400. points.forEach(function (point) {
  1401. rst.push(self.parsePoint(point));
  1402. });
  1403. return rst;
  1404. }
  1405. };
  1406. var ShapeFactoryBase = {
  1407. defaultShapeType: null,
  1408. setCoord: function setCoord(coord) {
  1409. this._coord = coord;
  1410. },
  1411. getShape: function getShape(type) {
  1412. var self = this;
  1413. if (Util.isArray(type)) {
  1414. type = type[0];
  1415. }
  1416. var shape = self[type] || self[self.defaultShapeType];
  1417. shape._coord = self._coord;
  1418. return shape;
  1419. },
  1420. getShapePoints: function getShapePoints(type, cfg) {
  1421. var shape = this.getShape(type);
  1422. var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
  1423. var points = fn(cfg);
  1424. return points;
  1425. },
  1426. getDefaultPoints: function getDefaultPoints()
  1427. /* cfg */
  1428. {
  1429. return [];
  1430. },
  1431. drawShape: function drawShape(type, cfg, container) {
  1432. var shape = this.getShape(type);
  1433. if (!cfg.color) {
  1434. cfg.color = Global.colors[0];
  1435. }
  1436. return shape.draw(cfg, container);
  1437. }
  1438. };
  1439. Shape.registerFactory = function (factoryName, cfg) {
  1440. var className = Util.upperFirst(factoryName);
  1441. var geomObj = Util.mix({}, ShapeFactoryBase, cfg);
  1442. Shape[className] = geomObj;
  1443. geomObj.name = factoryName;
  1444. return geomObj;
  1445. };
  1446. Shape.registerShape = function (factoryName, shapeType, cfg) {
  1447. var className = Util.upperFirst(factoryName);
  1448. var factory = Shape[className];
  1449. var shapeObj = Util.mix({}, ShapeBase, cfg);
  1450. factory[shapeType] = shapeObj;
  1451. return shapeObj;
  1452. };
  1453. Shape.registShape = Shape.registerShape;
  1454. Shape.getShapeFactory = function (factoryName) {
  1455. var self = this;
  1456. factoryName = factoryName || 'point';
  1457. var className = Util.upperFirst(factoryName);
  1458. return self[className];
  1459. };
  1460. module.exports = Shape;
  1461. /***/ }),
  1462. /* 10 */
  1463. /***/ (function(module, exports, __webpack_require__) {
  1464. var isType = __webpack_require__(8);
  1465. var isArray = Array.isArray ? Array.isArray : function (value) {
  1466. return isType(value, 'Array');
  1467. };
  1468. module.exports = isArray;
  1469. /***/ }),
  1470. /* 11 */
  1471. /***/ (function(module, exports, __webpack_require__) {
  1472. var Vector2 = __webpack_require__(4);
  1473. var start = Vector2.create();
  1474. var end = Vector2.create();
  1475. var extremity = Vector2.create();
  1476. function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
  1477. var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
  1478. var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
  1479. return {
  1480. x: x,
  1481. y: y
  1482. };
  1483. } // cubic helper formula at T distance
  1484. function CubicN(T, a, b, c, d) {
  1485. var t2 = T * T;
  1486. var t3 = t2 * T;
  1487. 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;
  1488. }
  1489. function cubicBezierBounds(c) {
  1490. var minX = Infinity;
  1491. var maxX = -Infinity;
  1492. var minY = Infinity;
  1493. var maxY = -Infinity;
  1494. var s = {
  1495. x: c[0],
  1496. y: c[1]
  1497. };
  1498. var c1 = {
  1499. x: c[2],
  1500. y: c[3]
  1501. };
  1502. var c2 = {
  1503. x: c[4],
  1504. y: c[5]
  1505. };
  1506. var e = {
  1507. x: c[6],
  1508. y: c[7]
  1509. };
  1510. for (var t = 0; t < 100; t++) {
  1511. var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
  1512. if (pt.x < minX) {
  1513. minX = pt.x;
  1514. }
  1515. if (pt.x > maxX) {
  1516. maxX = pt.x;
  1517. }
  1518. if (pt.y < minY) {
  1519. minY = pt.y;
  1520. }
  1521. if (pt.y > maxY) {
  1522. maxY = pt.y;
  1523. }
  1524. }
  1525. return {
  1526. minX: minX,
  1527. minY: minY,
  1528. maxX: maxX,
  1529. maxY: maxY
  1530. };
  1531. }
  1532. module.exports = {
  1533. getBBoxFromPoints: function getBBoxFromPoints(points, lineWidth) {
  1534. if (points.length === 0) {
  1535. return;
  1536. }
  1537. var p = points[0];
  1538. var left = p.x;
  1539. var right = p.x;
  1540. var top = p.y;
  1541. var bottom = p.y;
  1542. var len = points.length;
  1543. for (var i = 1; i < len; i++) {
  1544. p = points[i];
  1545. left = Math.min(left, p.x);
  1546. right = Math.max(right, p.x);
  1547. top = Math.min(top, p.y);
  1548. bottom = Math.max(bottom, p.y);
  1549. }
  1550. lineWidth = lineWidth / 2 || 0;
  1551. return {
  1552. minX: left - lineWidth,
  1553. minY: top - lineWidth,
  1554. maxX: right + lineWidth,
  1555. maxY: bottom + lineWidth
  1556. };
  1557. },
  1558. getBBoxFromLine: function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
  1559. lineWidth = lineWidth / 2 || 0;
  1560. return {
  1561. minX: Math.min(x0, x1) - lineWidth,
  1562. minY: Math.min(y0, y1) - lineWidth,
  1563. maxX: Math.max(x0, x1) + lineWidth,
  1564. maxY: Math.max(y0, y1) + lineWidth
  1565. };
  1566. },
  1567. getBBoxFromArc: function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
  1568. var diff = Math.abs(startAngle - endAngle);
  1569. if (diff % Math.PI * 2 < 1e-4 && diff > 1e-4) {
  1570. // Is a circle
  1571. return {
  1572. minX: x - r,
  1573. minY: y - r,
  1574. maxX: x + r,
  1575. maxY: y + r
  1576. };
  1577. }
  1578. start[0] = Math.cos(startAngle) * r + x;
  1579. start[1] = Math.sin(startAngle) * r + y;
  1580. end[0] = Math.cos(endAngle) * r + x;
  1581. end[1] = Math.sin(endAngle) * r + y;
  1582. var min = [0, 0];
  1583. var max = [0, 0];
  1584. Vector2.min(min, start, end);
  1585. Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]
  1586. startAngle = startAngle % (Math.PI * 2);
  1587. if (startAngle < 0) {
  1588. startAngle = startAngle + Math.PI * 2;
  1589. }
  1590. endAngle = endAngle % (Math.PI * 2);
  1591. if (endAngle < 0) {
  1592. endAngle = endAngle + Math.PI * 2;
  1593. }
  1594. if (startAngle > endAngle && !anticlockwise) {
  1595. endAngle += Math.PI * 2;
  1596. } else if (startAngle < endAngle && anticlockwise) {
  1597. startAngle += Math.PI * 2;
  1598. }
  1599. if (anticlockwise) {
  1600. var tmp = endAngle;
  1601. endAngle = startAngle;
  1602. startAngle = tmp;
  1603. }
  1604. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  1605. if (angle > startAngle) {
  1606. extremity[0] = Math.cos(angle) * r + x;
  1607. extremity[1] = Math.sin(angle) * r + y;
  1608. Vector2.min(min, extremity, min);
  1609. Vector2.max(max, extremity, max);
  1610. }
  1611. }
  1612. return {
  1613. minX: min[0],
  1614. minY: min[1],
  1615. maxX: max[0],
  1616. maxY: max[1]
  1617. };
  1618. },
  1619. getBBoxFromBezierGroup: function getBBoxFromBezierGroup(points, lineWidth) {
  1620. var minX = Infinity;
  1621. var maxX = -Infinity;
  1622. var minY = Infinity;
  1623. var maxY = -Infinity;
  1624. for (var i = 0, len = points.length; i < len; i++) {
  1625. var bbox = cubicBezierBounds(points[i]);
  1626. if (bbox.minX < minX) {
  1627. minX = bbox.minX;
  1628. }
  1629. if (bbox.maxX > maxX) {
  1630. maxX = bbox.maxX;
  1631. }
  1632. if (bbox.minY < minY) {
  1633. minY = bbox.minY;
  1634. }
  1635. if (bbox.maxY > maxY) {
  1636. maxY = bbox.maxY;
  1637. }
  1638. }
  1639. lineWidth = lineWidth / 2 || 0;
  1640. return {
  1641. minX: minX - lineWidth,
  1642. minY: minY - lineWidth,
  1643. maxX: maxX + lineWidth,
  1644. maxY: maxY + lineWidth
  1645. };
  1646. }
  1647. };
  1648. /***/ }),
  1649. /* 12 */,
  1650. /* 13 */
  1651. /***/ (function(module, exports, __webpack_require__) {
  1652. /**
  1653. * 判断是否数字
  1654. * @return {Boolean} 是否数字
  1655. */
  1656. var isType = __webpack_require__(8);
  1657. var isNumber = function isNumber(value) {
  1658. return isType(value, 'Number');
  1659. };
  1660. module.exports = isNumber;
  1661. /***/ }),
  1662. /* 14 */
  1663. /***/ (function(module, exports, __webpack_require__) {
  1664. var mix = __webpack_require__(16);
  1665. var each = __webpack_require__(3);
  1666. var isObject = __webpack_require__(18);
  1667. var isNil = __webpack_require__(7);
  1668. var Scale =
  1669. /*#__PURE__*/
  1670. function () {
  1671. var _proto = Scale.prototype;
  1672. _proto._initDefaultCfg = function _initDefaultCfg() {
  1673. this.type = 'base';
  1674. /**
  1675. * 格式化函数,输出文本或者tick时的格式化函数
  1676. * @type {Function}
  1677. */
  1678. this.formatter = null;
  1679. /**
  1680. * 输出的值域
  1681. * @type {Array}
  1682. */
  1683. this.range = [0, 1];
  1684. /**
  1685. * 度量的标记
  1686. * @type {Array}
  1687. */
  1688. this.ticks = null;
  1689. /**
  1690. * 参与度量计算的值,可选项
  1691. * @type {Array}
  1692. */
  1693. this.values = [];
  1694. };
  1695. function Scale(cfg) {
  1696. this._initDefaultCfg();
  1697. mix(this, cfg);
  1698. this.init();
  1699. }
  1700. /**
  1701. * 度量初始化
  1702. * @protected
  1703. */
  1704. _proto.init = function init() {};
  1705. /**
  1706. * 获取该度量的ticks,返回的是多个对象,
  1707. * - text: tick 的文本
  1708. * - value: 对应的度量转换后的值
  1709. * <code>
  1710. * [
  1711. * {text: 0,value:0}
  1712. * {text: 1,value:0.2}
  1713. * {text: 2,value:0.4}
  1714. * {text: 3,value:0.6}
  1715. * {text: 4,value:0.8}
  1716. * {text: 5,value:1}
  1717. * ]
  1718. * </code>
  1719. * @param {Number} count 输出tick的个数的近似值,默认是 10
  1720. * @return {Array} 返回 ticks 数组
  1721. */
  1722. _proto.getTicks = function getTicks() {
  1723. var self = this;
  1724. var ticks = self.ticks;
  1725. var rst = [];
  1726. each(ticks, function (tick) {
  1727. var obj;
  1728. if (isObject(tick)) {
  1729. obj = tick;
  1730. } else {
  1731. obj = {
  1732. text: self.getText(tick),
  1733. tickValue: tick,
  1734. value: self.scale(tick)
  1735. };
  1736. }
  1737. rst.push(obj);
  1738. });
  1739. return rst;
  1740. };
  1741. /**
  1742. * 获取格式化后的文本
  1743. * @param {*} value 输入的数据
  1744. * @param {*} key 字段的 key
  1745. * @return {String} 格式化的文本
  1746. */
  1747. _proto.getText = function getText(value, key) {
  1748. var formatter = this.formatter;
  1749. value = formatter ? formatter(value, key) : value;
  1750. if (isNil(value) || !value.toString) {
  1751. value = '';
  1752. }
  1753. return value.toString();
  1754. };
  1755. /**
  1756. * 输出的值域最小值
  1757. * @protected
  1758. * @return {Number} 返回最小的值
  1759. */
  1760. _proto.rangeMin = function rangeMin() {
  1761. return this.range[0];
  1762. };
  1763. /**
  1764. * 输出的值域最大值
  1765. * @protected
  1766. * @return {Number} 返回最大的值
  1767. */
  1768. _proto.rangeMax = function rangeMax() {
  1769. var range = this.range;
  1770. return range[range.length - 1];
  1771. };
  1772. /**
  1773. * 度量转换后的结果,翻转回输入域
  1774. * @param {Number} value 需要翻转的数值
  1775. * @return {*} 度量的输入值
  1776. */
  1777. _proto.invert = function invert(value) {
  1778. return value;
  1779. };
  1780. /**
  1781. * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
  1782. * @param {*} value 传入的值
  1783. * @return {Number} 转换的值
  1784. */
  1785. _proto.translate = function translate(value) {
  1786. return value;
  1787. };
  1788. /**
  1789. * 进行度量转换
  1790. * @param {*} value 输入值
  1791. * @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
  1792. */
  1793. _proto.scale = function scale(value) {
  1794. return value;
  1795. };
  1796. /**
  1797. * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
  1798. * @return {Scale} 克隆的度量
  1799. */
  1800. _proto.clone = function clone() {
  1801. var self = this;
  1802. var constr = self.constructor;
  1803. var cfg = {};
  1804. each(self, function (v, k) {
  1805. cfg[k] = self[k];
  1806. });
  1807. return new constr(cfg);
  1808. };
  1809. /**
  1810. * 更改度量的属性信息
  1811. * @param {Object} info 属性信息
  1812. * @chainable
  1813. * @return {Scale} 返回自身的引用
  1814. */
  1815. _proto.change = function change(info) {
  1816. this.ticks = null;
  1817. mix(this, info);
  1818. this.init();
  1819. return this;
  1820. };
  1821. return Scale;
  1822. }();
  1823. module.exports = Scale;
  1824. /***/ }),
  1825. /* 15 */
  1826. /***/ (function(module, exports, __webpack_require__) {
  1827. var isType = __webpack_require__(8);
  1828. var isString = function isString(str) {
  1829. return isType(str, 'String');
  1830. };
  1831. module.exports = isString;
  1832. /***/ }),
  1833. /* 16 */
  1834. /***/ (function(module, exports) {
  1835. function _mix(dist, obj) {
  1836. for (var key in obj) {
  1837. if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
  1838. dist[key] = obj[key];
  1839. }
  1840. }
  1841. }
  1842. var mix = function mix(dist, src1, src2, src3) {
  1843. if (src1) _mix(dist, src1);
  1844. if (src2) _mix(dist, src2);
  1845. if (src3) _mix(dist, src3);
  1846. return dist;
  1847. };
  1848. module.exports = mix;
  1849. /***/ }),
  1850. /* 17 */
  1851. /***/ (function(module, exports, __webpack_require__) {
  1852. /**
  1853. * @fileOverview the Attribute base class
  1854. */
  1855. var isString = __webpack_require__(15);
  1856. var isArray = __webpack_require__(10);
  1857. var mix = __webpack_require__(16);
  1858. var each = __webpack_require__(3);
  1859. function toScaleString(scale, value) {
  1860. if (isString(value)) {
  1861. return value;
  1862. }
  1863. return scale.invert(scale.scale(value));
  1864. }
  1865. /**
  1866. * 所有视觉通道属性的基类
  1867. * @class Attr
  1868. */
  1869. var AttributeBase =
  1870. /*#__PURE__*/
  1871. function () {
  1872. function AttributeBase(cfg) {
  1873. /**
  1874. * 属性的类型
  1875. * @type {String}
  1876. */
  1877. this.type = 'base';
  1878. /**
  1879. * 属性的名称
  1880. * @type {String}
  1881. */
  1882. this.name = null;
  1883. /**
  1884. * 回调函数
  1885. * @type {Function}
  1886. */
  1887. this.method = null;
  1888. /**
  1889. * 备选的值数组
  1890. * @type {Array}
  1891. */
  1892. this.values = [];
  1893. /**
  1894. * 属性内部的度量
  1895. * @type {Array}
  1896. */
  1897. this.scales = [];
  1898. /**
  1899. * 是否通过线性取值, 如果未指定,则根据数值的类型判定
  1900. * @type {Boolean}
  1901. */
  1902. this.linear = null;
  1903. mix(this, cfg);
  1904. } // 获取属性值,将值映射到视觉通道
  1905. var _proto = AttributeBase.prototype;
  1906. _proto._getAttrValue = function _getAttrValue(scale, value) {
  1907. var values = this.values;
  1908. if (scale.isCategory && !this.linear) {
  1909. var index = scale.translate(value);
  1910. return values[index % values.length];
  1911. }
  1912. var percent = scale.scale(value);
  1913. return this.getLinearValue(percent);
  1914. };
  1915. /**
  1916. * 如果进行线性映射,返回对应的映射值
  1917. * @protected
  1918. * @param {Number} percent 百分比
  1919. * @return {*} 颜色值、形状、大小等
  1920. */
  1921. _proto.getLinearValue = function getLinearValue(percent) {
  1922. var values = this.values;
  1923. var steps = values.length - 1;
  1924. var step = Math.floor(steps * percent);
  1925. var leftPercent = steps * percent - step;
  1926. var start = values[step];
  1927. var end = step === steps ? start : values[step + 1];
  1928. var rstValue = start + (end - start) * leftPercent;
  1929. return rstValue;
  1930. };
  1931. /**
  1932. * 默认的回调函数
  1933. * @param {*} value 回调函数的值
  1934. * @type {Function}
  1935. * @return {Array} 返回映射后的值
  1936. */
  1937. _proto.callback = function callback(value) {
  1938. var self = this;
  1939. var scale = self.scales[0];
  1940. var rstValue = null;
  1941. if (scale.type === 'identity') {
  1942. rstValue = scale.value;
  1943. } else {
  1944. rstValue = self._getAttrValue(scale, value);
  1945. }
  1946. return rstValue;
  1947. };
  1948. /**
  1949. * 根据度量获取属性名
  1950. * @return {Array} dims of this Attribute
  1951. */
  1952. _proto.getNames = function getNames() {
  1953. var scales = this.scales;
  1954. var names = this.names;
  1955. var length = Math.min(scales.length, names.length);
  1956. var rst = [];
  1957. for (var i = 0; i < length; i++) {
  1958. rst.push(names[i]);
  1959. }
  1960. return rst;
  1961. };
  1962. /**
  1963. * 根据度量获取维度名
  1964. * @return {Array} dims of this Attribute
  1965. */
  1966. _proto.getFields = function getFields() {
  1967. var scales = this.scales;
  1968. var rst = [];
  1969. each(scales, function (scale) {
  1970. rst.push(scale.field);
  1971. });
  1972. return rst;
  1973. };
  1974. /**
  1975. * 根据名称获取度量
  1976. * @param {String} name the name of scale
  1977. * @return {Scale} scale
  1978. */
  1979. _proto.getScale = function getScale(name) {
  1980. var scales = this.scales;
  1981. var names = this.names;
  1982. var index = names.indexOf(name);
  1983. return scales[index];
  1984. };
  1985. /**
  1986. * 映射数据
  1987. * @param {*} param1...paramn 多个数值
  1988. * @return {Array} 映射的值组成的数组
  1989. */
  1990. _proto.mapping = function mapping() {
  1991. var scales = this.scales;
  1992. var callback = this.callback;
  1993. for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
  1994. params[_key] = arguments[_key];
  1995. }
  1996. var values = params;
  1997. if (callback) {
  1998. for (var i = 0, len = params.length; i < len; i++) {
  1999. params[i] = this._toOriginParam(params[i], scales[i]);
  2000. }
  2001. values = callback.apply(this, params);
  2002. }
  2003. values = [].concat(values);
  2004. return values;
  2005. }; // 原始的参数
  2006. _proto._toOriginParam = function _toOriginParam(param, scale) {
  2007. var rst = param;
  2008. if (!scale.isLinear) {
  2009. if (isArray(param)) {
  2010. rst = [];
  2011. for (var i = 0, len = param.length; i < len; i++) {
  2012. rst.push(toScaleString(scale, param[i]));
  2013. }
  2014. } else {
  2015. rst = toScaleString(scale, param);
  2016. }
  2017. }
  2018. return rst;
  2019. };
  2020. return AttributeBase;
  2021. }();
  2022. module.exports = AttributeBase;
  2023. /***/ }),
  2024. /* 18 */
  2025. /***/ (function(module, exports) {
  2026. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  2027. return typeof obj;
  2028. } : function (obj) {
  2029. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2030. };
  2031. var isObject = function isObject(value) {
  2032. /**
  2033. * isObject({}) => true
  2034. * isObject([1, 2, 3]) => true
  2035. * isObject(Function) => true
  2036. * isObject(null) => false
  2037. */
  2038. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  2039. return value !== null && type === 'object' || type === 'function';
  2040. };
  2041. module.exports = isObject;
  2042. /***/ }),
  2043. /* 19 */
  2044. /***/ (function(module, exports, __webpack_require__) {
  2045. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2046. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2047. var Base = __webpack_require__(29);
  2048. var Plot = __webpack_require__(50);
  2049. var Util = __webpack_require__(0);
  2050. var Coord = __webpack_require__(51);
  2051. var Geom = __webpack_require__(6);
  2052. var ScaleController = __webpack_require__(59);
  2053. var AxisController = __webpack_require__(65);
  2054. var Global = __webpack_require__(1);
  2055. var _require = __webpack_require__(5),
  2056. Canvas = _require.Canvas;
  2057. var Helper = __webpack_require__(26);
  2058. function isFullCircle(coord) {
  2059. var startAngle = coord.startAngle;
  2060. var endAngle = coord.endAngle;
  2061. if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
  2062. return false;
  2063. }
  2064. return true;
  2065. }
  2066. function compare(a, b) {
  2067. return a - b;
  2068. }
  2069. function _isScaleExist(scales, compareScale) {
  2070. var flag = false;
  2071. Util.each(scales, function (scale) {
  2072. var scaleValues = [].concat(scale.values);
  2073. var compareScaleValues = [].concat(compareScale.values);
  2074. if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
  2075. flag = true;
  2076. return;
  2077. }
  2078. });
  2079. return flag;
  2080. }
  2081. var Chart =
  2082. /*#__PURE__*/
  2083. function (_Base) {
  2084. _inheritsLoose(Chart, _Base);
  2085. Chart.initPlugins = function initPlugins() {
  2086. return {
  2087. _plugins: [],
  2088. _cacheId: 0,
  2089. register: function register(plugins) {
  2090. var p = this._plugins;
  2091. [].concat(plugins).forEach(function (plugin) {
  2092. if (p.indexOf(plugin) === -1) {
  2093. p.push(plugin);
  2094. }
  2095. });
  2096. this._cacheId++;
  2097. },
  2098. unregister: function unregister(plugins) {
  2099. var p = this._plugins;
  2100. [].concat(plugins).forEach(function (plugin) {
  2101. var idx = p.indexOf(plugin);
  2102. if (idx !== -1) {
  2103. p.splice(idx, 1);
  2104. }
  2105. });
  2106. this._cacheId++;
  2107. },
  2108. clear: function clear() {
  2109. this._plugins = [];
  2110. this._cacheId++;
  2111. },
  2112. count: function count() {
  2113. return this._plugins.length;
  2114. },
  2115. getAll: function getAll() {
  2116. return this._plugins;
  2117. },
  2118. notify: function notify(chart, hook, args) {
  2119. var descriptors = this.descriptors(chart);
  2120. var ilen = descriptors.length;
  2121. var i;
  2122. var descriptor;
  2123. var plugin;
  2124. var params;
  2125. var method;
  2126. for (i = 0; i < ilen; ++i) {
  2127. descriptor = descriptors[i];
  2128. plugin = descriptor.plugin;
  2129. method = plugin[hook];
  2130. if (typeof method === 'function') {
  2131. params = [chart].concat(args || []);
  2132. if (method.apply(plugin, params) === false) {
  2133. return false;
  2134. }
  2135. }
  2136. }
  2137. return true;
  2138. },
  2139. descriptors: function descriptors(chart) {
  2140. var cache = chart._plugins || (chart._plugins = {});
  2141. if (cache.id === this._cacheId) {
  2142. return cache.descriptors;
  2143. }
  2144. var plugins = [];
  2145. var descriptors = [];
  2146. this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
  2147. var idx = plugins.indexOf(plugin);
  2148. if (idx !== -1) {
  2149. return;
  2150. }
  2151. plugins.push(plugin);
  2152. descriptors.push({
  2153. plugin: plugin
  2154. });
  2155. });
  2156. cache.descriptors = descriptors;
  2157. cache.id = this._cacheId;
  2158. return descriptors;
  2159. }
  2160. };
  2161. };
  2162. var _proto = Chart.prototype;
  2163. _proto.getDefaultCfg = function getDefaultCfg() {
  2164. return {
  2165. /**
  2166. * the id of canvas
  2167. * @type {String}
  2168. */
  2169. id: null,
  2170. /**
  2171. * padding
  2172. * @type {Array|Number}
  2173. */
  2174. padding: Global.padding,
  2175. /**
  2176. * data
  2177. * @type {Array}
  2178. */
  2179. data: null,
  2180. /**
  2181. * scales of chart
  2182. * @type {Object}
  2183. */
  2184. scales: {},
  2185. /**
  2186. * @private
  2187. * geometry instances
  2188. * @type {Array}
  2189. */
  2190. geoms: null,
  2191. /**
  2192. * scale configuration
  2193. * @type {Object}
  2194. */
  2195. colDefs: null,
  2196. pixelRatio: Global.pixelRatio,
  2197. /**
  2198. * filter options
  2199. * @type {Object}
  2200. */
  2201. filters: null,
  2202. appendPadding: Global.appendPadding
  2203. };
  2204. };
  2205. _proto._syncYScales = function _syncYScales() {
  2206. var geoms = this.get('geoms');
  2207. var syncScales = [];
  2208. var min = [];
  2209. var max = [];
  2210. Util.each(geoms, function (geom) {
  2211. var yScale = geom.getYScale();
  2212. if (yScale.isLinear) {
  2213. syncScales.push(yScale);
  2214. min.push(yScale.min);
  2215. max.push(yScale.max);
  2216. }
  2217. });
  2218. min = Math.min.apply(null, min);
  2219. max = Math.max.apply(null, max);
  2220. Util.each(syncScales, function (scale) {
  2221. scale.change({
  2222. min: min
  2223. });
  2224. scale.change({
  2225. max: max
  2226. });
  2227. });
  2228. };
  2229. _proto._getFieldsForLegend = function _getFieldsForLegend() {
  2230. var fields = [];
  2231. var geoms = this.get('geoms');
  2232. Util.each(geoms, function (geom) {
  2233. var attrOptions = geom.get('attrOptions');
  2234. var attrCfg = attrOptions.color;
  2235. if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
  2236. var arr = attrCfg.field.split('*');
  2237. Util.each(arr, function (item) {
  2238. if (fields.indexOf(item) === -1) {
  2239. fields.push(item);
  2240. }
  2241. });
  2242. }
  2243. });
  2244. return fields;
  2245. };
  2246. _proto._createScale = function _createScale(field, data) {
  2247. var scaleController = this.get('scaleController');
  2248. return scaleController.createScale(field, data);
  2249. };
  2250. _proto._adjustScale = function _adjustScale() {
  2251. var self = this;
  2252. var coord = self.get('coord');
  2253. var xScale = self.getXScale();
  2254. var yScales = self.getYScales();
  2255. var scales = [];
  2256. xScale && scales.push(xScale);
  2257. scales = scales.concat(yScales);
  2258. var inFullCircle = coord.isPolar && isFullCircle(coord);
  2259. var scaleController = self.get('scaleController');
  2260. var colDefs = scaleController.defs;
  2261. Util.each(scales, function (scale) {
  2262. if ((scale.isCategory || scale.isIdentity) && scale.values && !(colDefs[scale.field] && colDefs[scale.field].range)) {
  2263. var count = scale.values.length;
  2264. var range;
  2265. if (count === 1) {
  2266. range = [0.5, 1];
  2267. } else {
  2268. var widthRatio = 1;
  2269. var offset = 0;
  2270. if (inFullCircle) {
  2271. if (!coord.transposed) {
  2272. range = [0, 1 - 1 / count];
  2273. } else {
  2274. widthRatio = Global.widthRatio.multiplePie;
  2275. offset = 1 / count * widthRatio;
  2276. range = [offset / 2, 1 - offset / 2];
  2277. }
  2278. } else {
  2279. offset = 1 / count * 1 / 2;
  2280. range = [offset, 1 - offset];
  2281. }
  2282. }
  2283. scale.range = range;
  2284. }
  2285. });
  2286. var geoms = this.get('geoms');
  2287. for (var i = 0; i < geoms.length; i++) {
  2288. var geom = geoms[i];
  2289. if (geom.get('type') === 'interval') {
  2290. var yScale = geom.getYScale();
  2291. var field = yScale.field,
  2292. min = yScale.min,
  2293. max = yScale.max,
  2294. type = yScale.type;
  2295. if (!(colDefs[field] && colDefs[field].min) && type !== 'time') {
  2296. if (min > 0) {
  2297. yScale.change({
  2298. min: 0
  2299. });
  2300. } else if (max <= 0) {
  2301. yScale.change({
  2302. max: 0
  2303. });
  2304. }
  2305. }
  2306. }
  2307. }
  2308. };
  2309. _proto._removeGeoms = function _removeGeoms() {
  2310. var geoms = this.get('geoms');
  2311. while (geoms.length > 0) {
  2312. var geom = geoms.shift();
  2313. geom.destroy();
  2314. }
  2315. };
  2316. _proto._clearGeoms = function _clearGeoms() {
  2317. var geoms = this.get('geoms');
  2318. for (var i = 0, length = geoms.length; i < length; i++) {
  2319. var geom = geoms[i];
  2320. geom.clear();
  2321. }
  2322. };
  2323. _proto._clearInner = function _clearInner() {
  2324. this.set('scales', {});
  2325. this.set('legendItems', null);
  2326. this._clearGeoms();
  2327. Chart.plugins.notify(this, 'clearInner');
  2328. this.get('axisController') && this.get('axisController').clear();
  2329. };
  2330. _proto._execFilter = function _execFilter(data) {
  2331. var filters = this.get('filters');
  2332. if (filters) {
  2333. data = data.filter(function (obj) {
  2334. var rst = true;
  2335. Util.each(filters, function (fn, k) {
  2336. if (fn) {
  2337. rst = fn(obj[k], obj);
  2338. if (!rst) {
  2339. return false;
  2340. }
  2341. }
  2342. });
  2343. return rst;
  2344. });
  2345. }
  2346. return data;
  2347. };
  2348. _proto._initGeoms = function _initGeoms(geoms) {
  2349. var coord = this.get('coord');
  2350. var data = this.get('filteredData');
  2351. var colDefs = this.get('colDefs');
  2352. for (var i = 0, length = geoms.length; i < length; i++) {
  2353. var geom = geoms[i];
  2354. geom.set('data', data);
  2355. geom.set('coord', coord);
  2356. geom.set('colDefs', colDefs);
  2357. geom.init();
  2358. }
  2359. };
  2360. _proto._initCoord = function _initCoord() {
  2361. var plot = this.get('plotRange');
  2362. var coordCfg = Util.mix({
  2363. type: 'cartesian'
  2364. }, this.get('coordCfg'), {
  2365. plot: plot
  2366. });
  2367. var type = coordCfg.type;
  2368. var C = Coord[Util.upperFirst(type)];
  2369. var coord = new C(coordCfg);
  2370. this.set('coord', coord);
  2371. };
  2372. _proto._initLayout = function _initLayout() {
  2373. var padding = this.get('_padding');
  2374. if (!padding) {
  2375. padding = this.get('margin') || this.get('padding');
  2376. padding = Util.parsePadding(padding);
  2377. }
  2378. var top = padding[0] === 'auto' ? 0 : padding[0];
  2379. var right = padding[1] === 'auto' ? 0 : padding[1];
  2380. var bottom = padding[2] === 'auto' ? 0 : padding[2];
  2381. var left = padding[3] === 'auto' ? 0 : padding[3];
  2382. var width = this.get('width');
  2383. var height = this.get('height');
  2384. var plot = new Plot({
  2385. start: {
  2386. x: left,
  2387. y: top
  2388. },
  2389. end: {
  2390. x: width - right,
  2391. y: height - bottom
  2392. }
  2393. });
  2394. this.set('plotRange', plot);
  2395. this.set('plot', plot);
  2396. };
  2397. _proto._initCanvas = function _initCanvas() {
  2398. var self = this;
  2399. try {
  2400. var canvas = new Canvas({
  2401. el: self.get('el') || self.get('id'),
  2402. context: self.get('context'),
  2403. pixelRatio: self.get('pixelRatio'),
  2404. width: self.get('width'),
  2405. height: self.get('height'),
  2406. fontFamily: Global.fontFamily
  2407. });
  2408. self.set('canvas', canvas);
  2409. self.set('width', canvas.get('width'));
  2410. self.set('height', canvas.get('height'));
  2411. } catch (error) {
  2412. throw error;
  2413. }
  2414. Chart.plugins.notify(self, 'afterCanvasInit');
  2415. self._initLayout();
  2416. };
  2417. _proto._initLayers = function _initLayers() {
  2418. var canvas = this.get('canvas');
  2419. this.set('backPlot', canvas.addGroup());
  2420. this.set('middlePlot', canvas.addGroup({
  2421. zIndex: 10
  2422. }));
  2423. this.set('frontPlot', canvas.addGroup({
  2424. zIndex: 20
  2425. }));
  2426. };
  2427. _proto._init = function _init() {
  2428. var self = this;
  2429. self._initCanvas();
  2430. self._initLayers();
  2431. self.set('geoms', []);
  2432. self.set('scaleController', new ScaleController());
  2433. self.set('axisController', new AxisController({
  2434. frontPlot: self.get('frontPlot').addGroup({
  2435. className: 'axisContainer'
  2436. }),
  2437. backPlot: self.get('backPlot').addGroup({
  2438. className: 'axisContainer'
  2439. }),
  2440. chart: self
  2441. }));
  2442. Chart.plugins.notify(self, 'init');
  2443. };
  2444. function Chart(cfg) {
  2445. var _this;
  2446. _this = _Base.call(this, cfg) || this;
  2447. var self = _assertThisInitialized(_assertThisInitialized(_this));
  2448. Util.each(Geom, function (geomConstructor, className) {
  2449. var methodName = Util.lowerFirst(className);
  2450. self[methodName] = function (cfg) {
  2451. var geom = new geomConstructor(cfg);
  2452. self.addGeom(geom);
  2453. return geom;
  2454. };
  2455. });
  2456. self._init();
  2457. return _this;
  2458. }
  2459. /**
  2460. * set data and some scale configuration
  2461. * @chainable
  2462. * @param {Array} data the dataset to visualize
  2463. * @param {Object} colDefs the configuration for scales
  2464. * @return {Chart} return the chart instance
  2465. */
  2466. _proto.source = function source(data, colDefs) {
  2467. this.set('data', data);
  2468. if (colDefs) {
  2469. this.scale(colDefs);
  2470. }
  2471. return this;
  2472. };
  2473. _proto.scale = function scale(field, cfg) {
  2474. var colDefs = this.get('colDefs') || {};
  2475. if (Util.isObject(field)) {
  2476. Util.mix(colDefs, field);
  2477. } else {
  2478. colDefs[field] = cfg;
  2479. }
  2480. this.set('colDefs', colDefs);
  2481. var scaleController = this.get('scaleController');
  2482. scaleController.defs = colDefs;
  2483. return this;
  2484. };
  2485. /**
  2486. * configure the axis
  2487. * @chainable
  2488. * @param {String|Boolean} field the field name of data
  2489. * @param {Object} cfg configuration for axis
  2490. * @return {Chart} return the chart instance
  2491. */
  2492. _proto.axis = function axis(field, cfg) {
  2493. var axisController = this.get('axisController');
  2494. if (!field) {
  2495. axisController.axisCfg = null;
  2496. } else {
  2497. axisController.axisCfg = axisController.axisCfg || {};
  2498. axisController.axisCfg[field] = cfg;
  2499. }
  2500. return this;
  2501. };
  2502. /**
  2503. * configure the coordinate
  2504. * @chainable
  2505. * @param {String} type set the type of coodinate
  2506. * @param {Object} cfg configuration for coordinate
  2507. * @return {Chart} return the chart instance
  2508. */
  2509. _proto.coord = function coord(type, cfg) {
  2510. var coordCfg;
  2511. if (Util.isObject(type)) {
  2512. coordCfg = type;
  2513. } else {
  2514. coordCfg = cfg || {};
  2515. coordCfg.type = type || 'cartesian';
  2516. }
  2517. this.set('coordCfg', coordCfg);
  2518. return this;
  2519. };
  2520. _proto.filter = function filter(field, condition) {
  2521. var filters = this.get('filters') || {};
  2522. filters[field] = condition;
  2523. this.set('filters', filters);
  2524. };
  2525. /**
  2526. * render the chart
  2527. * @chainable
  2528. * @return {Chart} return the chart instance
  2529. */
  2530. _proto.render = function render() {
  2531. var canvas = this.get('canvas');
  2532. var geoms = this.get('geoms');
  2533. var data = this.get('data') || [];
  2534. var filteredData = this._execFilter(data); // filter data
  2535. this.set('filteredData', filteredData);
  2536. this._initCoord(); // initialization coordinate instance
  2537. Chart.plugins.notify(this, 'beforeGeomInit');
  2538. this._initGeoms(geoms); // init all geometry instances
  2539. this.get('syncY') && this._syncYScales();
  2540. this._adjustScale(); // do some adjust for data
  2541. Chart.plugins.notify(this, 'beforeGeomDraw');
  2542. this._renderAxis();
  2543. var middlePlot = this.get('middlePlot');
  2544. if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
  2545. var coord = this.get('coord');
  2546. var clip = Helper.getClip(coord);
  2547. clip.set('canvas', middlePlot.get('canvas'));
  2548. middlePlot.attr('clip', clip);
  2549. }
  2550. for (var i = 0, length = geoms.length; i < length; i++) {
  2551. var geom = geoms[i];
  2552. geom.paint();
  2553. }
  2554. Chart.plugins.notify(this, 'afterGeomDraw');
  2555. canvas.sort();
  2556. this.get('frontPlot').sort();
  2557. Chart.plugins.notify(this, 'beforeCanvasDraw');
  2558. canvas.draw();
  2559. return this;
  2560. };
  2561. /**
  2562. * clear the chart, include geometris and all the shapes
  2563. * @chainable
  2564. * @return {Chart} return the chart
  2565. */
  2566. _proto.clear = function clear() {
  2567. Chart.plugins.notify(this, 'clear');
  2568. this._removeGeoms();
  2569. this._clearInner();
  2570. this.set('filters', null);
  2571. this.set('isUpdate', false);
  2572. this.set('_padding', null);
  2573. var canvas = this.get('canvas');
  2574. canvas.draw();
  2575. return this;
  2576. };
  2577. _proto.repaint = function repaint() {
  2578. this.set('isUpdate', true);
  2579. Chart.plugins.notify(this, 'repaint');
  2580. this._clearInner();
  2581. this.render();
  2582. };
  2583. _proto.changeData = function changeData(data) {
  2584. this.set('data', data);
  2585. Chart.plugins.notify(this, 'changeData');
  2586. this.set('_padding', null);
  2587. this.repaint();
  2588. };
  2589. _proto.changeSize = function changeSize(width, height) {
  2590. if (width) {
  2591. this.set('width', width);
  2592. } else {
  2593. width = this.get('width');
  2594. }
  2595. if (height) {
  2596. this.set('height', height);
  2597. } else {
  2598. height = this.get('height');
  2599. }
  2600. var canvas = this.get('canvas');
  2601. canvas.changeSize(width, height);
  2602. this._initLayout();
  2603. this.repaint();
  2604. return this;
  2605. };
  2606. _proto.destroy = function destroy() {
  2607. this.clear();
  2608. var canvas = this.get('canvas');
  2609. canvas.destroy();
  2610. Chart.plugins.notify(this, 'afterCanvasDestroyed');
  2611. if (this._interactions) {
  2612. Util.each(this._interactions, function (interaction) {
  2613. interaction.destroy();
  2614. });
  2615. }
  2616. _Base.prototype.destroy.call(this);
  2617. };
  2618. /**
  2619. * calculate dataset's position on canvas
  2620. * @param {Object} record the dataset
  2621. * @return {Object} return the position
  2622. */
  2623. _proto.getPosition = function getPosition(record) {
  2624. var self = this;
  2625. var coord = self.get('coord');
  2626. var xScale = self.getXScale();
  2627. var yScale = self.getYScales()[0];
  2628. var xField = xScale.field;
  2629. var x = xScale.scale(record[xField]);
  2630. var yField = yScale.field;
  2631. var y = yScale.scale(record[yField]);
  2632. return coord.convertPoint({
  2633. x: x,
  2634. y: y
  2635. });
  2636. };
  2637. /**
  2638. * get the data item of the point
  2639. * @param {Object} point canvas position
  2640. * @return {Object} return the data item
  2641. */
  2642. _proto.getRecord = function getRecord(point) {
  2643. var self = this;
  2644. var coord = self.get('coord');
  2645. var xScale = self.getXScale();
  2646. var yScale = self.getYScales()[0];
  2647. var invertPoint = coord.invertPoint(point);
  2648. var record = {};
  2649. record[xScale.field] = xScale.invert(invertPoint.x);
  2650. record[yScale.field] = yScale.invert(invertPoint.y);
  2651. return record;
  2652. };
  2653. /**
  2654. * get the dataset of the point
  2655. * @param {Object} point canvas position
  2656. * @return {Array} return the dataset
  2657. **/
  2658. _proto.getSnapRecords = function getSnapRecords(point) {
  2659. var geom = this.get('geoms')[0];
  2660. var data = [];
  2661. if (geom) {
  2662. // need to judge
  2663. data = geom.getSnapRecords(point);
  2664. }
  2665. return data;
  2666. };
  2667. /**
  2668. * creat scale instances
  2669. * @param {String} field field name of data
  2670. * @return {Scale} return the scale
  2671. */
  2672. _proto.createScale = function createScale(field) {
  2673. var data = this.get('data');
  2674. var filteredData = this.get('filteredData');
  2675. if (filteredData.length) {
  2676. var legendFields = this._getFieldsForLegend();
  2677. if (legendFields.indexOf(field) === -1) {
  2678. data = filteredData;
  2679. }
  2680. }
  2681. var scales = this.get('scales');
  2682. if (!scales[field]) {
  2683. scales[field] = this._createScale(field, data);
  2684. }
  2685. return scales[field];
  2686. };
  2687. /**
  2688. * @protected
  2689. * add geometry instance to geoms
  2690. * @param {Geom} geom geometry instance
  2691. */
  2692. _proto.addGeom = function addGeom(geom) {
  2693. var geoms = this.get('geoms');
  2694. var middlePlot = this.get('middlePlot');
  2695. geoms.push(geom);
  2696. geom.set('chart', this);
  2697. geom.set('container', middlePlot.addGroup());
  2698. };
  2699. /**
  2700. * get the scale of x axis
  2701. * @return {Scale} return the scale
  2702. */
  2703. _proto.getXScale = function getXScale() {
  2704. var self = this;
  2705. var geoms = self.get('geoms');
  2706. var xScale = geoms[0].getXScale();
  2707. return xScale;
  2708. };
  2709. /**
  2710. * get the scale of y axis
  2711. * @return {Array} return the scale
  2712. */
  2713. _proto.getYScales = function getYScales() {
  2714. var geoms = this.get('geoms');
  2715. var rst = [];
  2716. Util.each(geoms, function (geom) {
  2717. var yScale = geom.getYScale();
  2718. if (rst.indexOf(yScale) === -1) {
  2719. rst.push(yScale);
  2720. }
  2721. });
  2722. return rst;
  2723. };
  2724. _proto.getLegendItems = function getLegendItems() {
  2725. if (this.get('legendItems')) {
  2726. return this.get('legendItems');
  2727. }
  2728. var legendItems = {};
  2729. var scales = [];
  2730. var geoms = this.get('geoms');
  2731. Util.each(geoms, function (geom) {
  2732. var colorAttr = geom.getAttr('color');
  2733. if (colorAttr) {
  2734. var scale = colorAttr.getScale('color');
  2735. if (scale.type !== 'identity' && !_isScaleExist(scales, scale)) {
  2736. scales.push(scale);
  2737. var field = scale.field;
  2738. var ticks = scale.getTicks();
  2739. var items = [];
  2740. Util.each(ticks, function (tick) {
  2741. var text = tick.text;
  2742. var name = text;
  2743. var scaleValue = tick.value;
  2744. var value = scale.invert(scaleValue);
  2745. var color = colorAttr.mapping(value).join('') || Global.defaultColor;
  2746. var marker = {
  2747. fill: color,
  2748. radius: 3,
  2749. symbol: 'circle',
  2750. stroke: '#fff'
  2751. };
  2752. items.push({
  2753. name: name,
  2754. // for display
  2755. dataValue: value,
  2756. // the origin value
  2757. checked: true,
  2758. marker: marker
  2759. });
  2760. });
  2761. legendItems[field] = items;
  2762. }
  2763. }
  2764. });
  2765. this.set('legendItems', legendItems);
  2766. return legendItems;
  2767. }; // register the plugins
  2768. _proto.registerPlugins = function registerPlugins(plugins) {
  2769. var self = this;
  2770. var chartPlugins = self.get('plugins') || [];
  2771. if (!Util.isArray(chartPlugins)) {
  2772. chartPlugins = [chartPlugins];
  2773. }
  2774. [].concat(plugins).forEach(function (plugin) {
  2775. if (chartPlugins.indexOf(plugin) === -1) {
  2776. plugin.init && plugin.init(self); // init
  2777. chartPlugins.push(plugin);
  2778. }
  2779. });
  2780. Chart.plugins._cacheId++;
  2781. self.set('plugins', chartPlugins);
  2782. };
  2783. _proto._renderAxis = function _renderAxis() {
  2784. var axisController = this.get('axisController');
  2785. var xScale = this.getXScale();
  2786. var yScales = this.getYScales();
  2787. var coord = this.get('coord');
  2788. Chart.plugins.notify(this, 'beforeRenderAxis');
  2789. axisController.createAxis(coord, xScale, yScales);
  2790. };
  2791. _proto._isAutoPadding = function _isAutoPadding() {
  2792. if (this.get('_padding')) {
  2793. return false;
  2794. }
  2795. var padding = this.get('padding');
  2796. if (Util.isArray(padding)) {
  2797. return padding.indexOf('auto') !== -1;
  2798. }
  2799. return padding === 'auto';
  2800. };
  2801. _proto._updateLayout = function _updateLayout(padding) {
  2802. var width = this.get('width');
  2803. var height = this.get('height');
  2804. var start = {
  2805. x: padding[3],
  2806. y: padding[0]
  2807. };
  2808. var end = {
  2809. x: width - padding[1],
  2810. y: height - padding[2]
  2811. };
  2812. var plot = this.get('plot');
  2813. var coord = this.get('coord');
  2814. plot.reset(start, end);
  2815. coord.reset(plot);
  2816. };
  2817. return Chart;
  2818. }(Base);
  2819. Chart.plugins = Chart.initPlugins();
  2820. module.exports = Chart;
  2821. /***/ }),
  2822. /* 20 */
  2823. /***/ (function(module, exports, __webpack_require__) {
  2824. /**
  2825. * @fileOverview shape util
  2826. * @author dxq613@gmail.com
  2827. */
  2828. var Util = __webpack_require__(0);
  2829. var ShapeUtil = {
  2830. splitPoints: function splitPoints(obj) {
  2831. var points = [];
  2832. var x = obj.x;
  2833. var y = obj.y;
  2834. y = Util.isArray(y) ? y : [y];
  2835. y.forEach(function (yItem, index) {
  2836. var point = {
  2837. x: Util.isArray(x) ? x[index] : x,
  2838. y: yItem
  2839. };
  2840. points.push(point);
  2841. });
  2842. return points;
  2843. },
  2844. splitArray: function splitArray(data, yField, connectNulls) {
  2845. if (!data.length) return [];
  2846. var arr = [];
  2847. var tmp = [];
  2848. var yValue;
  2849. Util.each(data, function (obj) {
  2850. yValue = obj._origin ? obj._origin[yField] : obj[yField];
  2851. if (connectNulls) {
  2852. if (!Util.isNil(yValue)) {
  2853. tmp.push(obj);
  2854. }
  2855. } else {
  2856. if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
  2857. if (tmp.length) {
  2858. arr.push(tmp);
  2859. tmp = [];
  2860. }
  2861. } else {
  2862. tmp.push(obj);
  2863. }
  2864. }
  2865. });
  2866. if (tmp.length) {
  2867. arr.push(tmp);
  2868. }
  2869. return arr;
  2870. }
  2871. };
  2872. module.exports = ShapeUtil;
  2873. /***/ }),
  2874. /* 21 */
  2875. /***/ (function(module, exports, __webpack_require__) {
  2876. var Util = __webpack_require__(0);
  2877. var Base =
  2878. /*#__PURE__*/
  2879. function () {
  2880. var _proto = Base.prototype;
  2881. _proto._initDefaultCfg = function _initDefaultCfg() {};
  2882. function Base(cfg) {
  2883. this._initDefaultCfg();
  2884. Util.mix(this, cfg);
  2885. var start;
  2886. var end;
  2887. if (this.plot) {
  2888. start = this.plot.bl;
  2889. end = this.plot.tr;
  2890. this.start = start;
  2891. this.end = end;
  2892. } else {
  2893. start = this.start;
  2894. end = this.end;
  2895. }
  2896. this.init(start, end);
  2897. }
  2898. _proto.init = function init() {};
  2899. _proto.convertPoint = function convertPoint(point) {
  2900. return point;
  2901. };
  2902. _proto.invertPoint = function invertPoint(point) {
  2903. return point;
  2904. };
  2905. _proto.reset = function reset(plot) {
  2906. this.plot = plot;
  2907. var bl = plot.bl,
  2908. tr = plot.tr;
  2909. this.start = bl;
  2910. this.end = tr;
  2911. this.init(bl, tr);
  2912. };
  2913. return Base;
  2914. }();
  2915. module.exports = Base;
  2916. /***/ }),
  2917. /* 22 */
  2918. /***/ (function(module, exports, __webpack_require__) {
  2919. var mix = __webpack_require__(16);
  2920. var Adjust =
  2921. /*#__PURE__*/
  2922. function () {
  2923. var _proto = Adjust.prototype;
  2924. _proto._initDefaultCfg = function _initDefaultCfg() {
  2925. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  2926. };
  2927. function Adjust(cfg) {
  2928. this._initDefaultCfg();
  2929. mix(this, cfg);
  2930. }
  2931. /**
  2932. * @override
  2933. */
  2934. _proto.processAdjust = function processAdjust()
  2935. /* dataArray */
  2936. {};
  2937. return Adjust;
  2938. }();
  2939. module.exports = Adjust;
  2940. /***/ }),
  2941. /* 23 */
  2942. /***/ (function(module, exports) {
  2943. var Matrix = {
  2944. multiply: function multiply(m1, m2) {
  2945. var m11 = m1[0] * m2[0] + m1[2] * m2[1];
  2946. var m12 = m1[1] * m2[0] + m1[3] * m2[1];
  2947. var m21 = m1[0] * m2[2] + m1[2] * m2[3];
  2948. var m22 = m1[1] * m2[2] + m1[3] * m2[3];
  2949. var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  2950. var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  2951. return [m11, m12, m21, m22, dx, dy];
  2952. },
  2953. scale: function scale(out, m, v) {
  2954. out[0] = m[0] * v[0];
  2955. out[1] = m[1] * v[0];
  2956. out[2] = m[2] * v[1];
  2957. out[3] = m[3] * v[1];
  2958. out[4] = m[4];
  2959. out[5] = m[5];
  2960. return out;
  2961. },
  2962. rotate: function rotate(out, m, radian) {
  2963. var c = Math.cos(radian);
  2964. var s = Math.sin(radian);
  2965. var m11 = m[0] * c + m[2] * s;
  2966. var m12 = m[1] * c + m[3] * s;
  2967. var m21 = m[0] * -s + m[2] * c;
  2968. var m22 = m[1] * -s + m[3] * c;
  2969. out[0] = m11;
  2970. out[1] = m12;
  2971. out[2] = m21;
  2972. out[3] = m22;
  2973. out[4] = m[4];
  2974. out[5] = m[5];
  2975. return out;
  2976. },
  2977. translate: function translate(out, m, v) {
  2978. out[0] = m[0];
  2979. out[1] = m[1];
  2980. out[2] = m[2];
  2981. out[3] = m[3];
  2982. out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
  2983. out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
  2984. return out;
  2985. },
  2986. transform: function transform(m, actions) {
  2987. var out = [].concat(m);
  2988. for (var i = 0, len = actions.length; i < len; i++) {
  2989. var action = actions[i];
  2990. switch (action[0]) {
  2991. case 't':
  2992. Matrix.translate(out, out, [action[1], action[2]]);
  2993. break;
  2994. case 's':
  2995. Matrix.scale(out, out, [action[1], action[2]]);
  2996. break;
  2997. case 'r':
  2998. Matrix.rotate(out, out, action[1]);
  2999. break;
  3000. default:
  3001. break;
  3002. }
  3003. }
  3004. return out;
  3005. }
  3006. };
  3007. module.exports = Matrix;
  3008. /***/ }),
  3009. /* 24 */
  3010. /***/ (function(module, exports, __webpack_require__) {
  3011. var Util = __webpack_require__(0);
  3012. var Global = __webpack_require__(1);
  3013. var Vector2 = __webpack_require__(4);
  3014. var Abastract =
  3015. /*#__PURE__*/
  3016. function () {
  3017. var _proto = Abastract.prototype;
  3018. _proto._initDefaultCfg = function _initDefaultCfg() {
  3019. /**
  3020. * ticks
  3021. * @type {Array}
  3022. */
  3023. this.ticks = [];
  3024. /**
  3025. * the configuration for tickLine
  3026. * @type {Object}
  3027. */
  3028. this.tickLine = {};
  3029. /**
  3030. * the direction of ticks, 1 means clockwise
  3031. * @type {Number}
  3032. */
  3033. this.offsetFactor = 1;
  3034. /**
  3035. * the top container
  3036. * @type {container}
  3037. */
  3038. this.frontContainer = null;
  3039. /**
  3040. * the back container
  3041. * @type {[type]}
  3042. */
  3043. this.backContainer = null;
  3044. /**
  3045. * points for draw grid line
  3046. * @type {Array}
  3047. */
  3048. this.gridPoints = [];
  3049. };
  3050. function Abastract(cfg) {
  3051. this._initDefaultCfg();
  3052. Util.mix(this, cfg);
  3053. this.draw();
  3054. }
  3055. _proto.draw = function draw() {
  3056. var line = this.line,
  3057. tickLine = this.tickLine,
  3058. label = this.label,
  3059. grid = this.grid;
  3060. grid && this.drawGrid(grid); // draw the grid lines
  3061. tickLine && this.drawTicks(tickLine); // draw the tickLine
  3062. line && this.drawLine(line); // draw axis line
  3063. label && this.drawLabels(); // draw ticks
  3064. };
  3065. _proto.drawTicks = function drawTicks(tickCfg) {
  3066. var self = this;
  3067. var ticks = self.ticks;
  3068. var length = tickCfg.length;
  3069. var container = self.getContainer(tickCfg.top);
  3070. Util.each(ticks, function (tick) {
  3071. var start = self.getOffsetPoint(tick.value);
  3072. var end = self.getSidePoint(start, length);
  3073. var shape = container.addShape('line', {
  3074. className: 'axis-tick',
  3075. attrs: Util.mix({
  3076. x1: start.x,
  3077. y1: start.y,
  3078. x2: end.x,
  3079. y2: end.y
  3080. }, tickCfg)
  3081. });
  3082. shape._id = self._id + '-ticks';
  3083. });
  3084. };
  3085. _proto.drawLabels = function drawLabels() {
  3086. var self = this;
  3087. var labelOffset = self.labelOffset;
  3088. var labels = self.labels;
  3089. Util.each(labels, function (labelShape) {
  3090. var container = self.getContainer(labelShape.get('top'));
  3091. var start = self.getOffsetPoint(labelShape.get('value'));
  3092. var _self$getSidePoint = self.getSidePoint(start, labelOffset),
  3093. x = _self$getSidePoint.x,
  3094. y = _self$getSidePoint.y;
  3095. labelShape.attr(Util.mix({
  3096. x: x,
  3097. y: y
  3098. }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
  3099. labelShape._id = self._id + '-' + labelShape.attr('text');
  3100. container.add(labelShape);
  3101. });
  3102. };
  3103. _proto.drawLine = function drawLine() {};
  3104. _proto.drawGrid = function drawGrid(grid) {
  3105. var self = this;
  3106. var gridPoints = self.gridPoints,
  3107. ticks = self.ticks;
  3108. var gridCfg = grid;
  3109. var count = gridPoints.length;
  3110. Util.each(gridPoints, function (subPoints, index) {
  3111. if (Util.isFunction(grid)) {
  3112. var tick = ticks[index] || {};
  3113. var executedGrid = grid(tick.text, index, count);
  3114. gridCfg = executedGrid ? Util.mix({}, Global._defaultAxis.grid, executedGrid) : null;
  3115. }
  3116. if (gridCfg) {
  3117. var type = gridCfg.type; // has two types: 'line' and 'arc'
  3118. var points = subPoints.points;
  3119. var container = self.getContainer(gridCfg.top);
  3120. var shape;
  3121. if (type === 'arc') {
  3122. var center = self.center,
  3123. startAngle = self.startAngle,
  3124. endAngle = self.endAngle;
  3125. var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
  3126. shape = container.addShape('Arc', {
  3127. className: 'axis-grid',
  3128. attrs: Util.mix({
  3129. x: center.x,
  3130. y: center.y,
  3131. startAngle: startAngle,
  3132. endAngle: endAngle,
  3133. r: radius
  3134. }, gridCfg)
  3135. });
  3136. } else {
  3137. shape = container.addShape('Polyline', {
  3138. className: 'axis-grid',
  3139. attrs: Util.mix({
  3140. points: points
  3141. }, gridCfg)
  3142. });
  3143. }
  3144. shape._id = subPoints._id;
  3145. }
  3146. });
  3147. };
  3148. _proto.getOffsetPoint = function getOffsetPoint() {};
  3149. _proto.getAxisVector = function getAxisVector() {};
  3150. _proto.getOffsetVector = function getOffsetVector(point, offset) {
  3151. var self = this;
  3152. var axisVector = self.getAxisVector(point);
  3153. var normal = Vector2.normalize([], axisVector);
  3154. var factor = self.offsetFactor;
  3155. var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
  3156. return Vector2.scale([], verticalVector, offset);
  3157. };
  3158. _proto.getSidePoint = function getSidePoint(point, offset) {
  3159. var self = this;
  3160. var offsetVector = self.getOffsetVector(point, offset);
  3161. return {
  3162. x: point.x + offsetVector[0],
  3163. y: point.y + offsetVector[1]
  3164. };
  3165. };
  3166. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  3167. var self = this;
  3168. var offsetVector = self.getOffsetVector(point, offset);
  3169. var align;
  3170. var baseLine;
  3171. if (offsetVector[0] > 0) {
  3172. align = 'left';
  3173. } else if (offsetVector[0] < 0) {
  3174. align = 'right';
  3175. } else {
  3176. align = 'center';
  3177. }
  3178. if (offsetVector[1] > 0) {
  3179. baseLine = 'top';
  3180. } else if (offsetVector[1] < 0) {
  3181. baseLine = 'bottom';
  3182. } else {
  3183. baseLine = 'middle';
  3184. }
  3185. return {
  3186. textAlign: align,
  3187. textBaseline: baseLine
  3188. };
  3189. };
  3190. _proto.getContainer = function getContainer(isTop) {
  3191. var frontContainer = this.frontContainer,
  3192. backContainer = this.backContainer;
  3193. return isTop ? frontContainer : backContainer;
  3194. };
  3195. return Abastract;
  3196. }();
  3197. module.exports = Abastract;
  3198. /***/ }),
  3199. /* 25 */
  3200. /***/ (function(module, exports, __webpack_require__) {
  3201. var Util = __webpack_require__(0);
  3202. var MatrixUtil = __webpack_require__(23);
  3203. var Vector2 = __webpack_require__(4);
  3204. var StyleUtil = __webpack_require__(69);
  3205. function isUnchanged(m) {
  3206. return m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
  3207. }
  3208. var ALIAS_ATTRS_MAP = {
  3209. stroke: 'strokeStyle',
  3210. fill: 'fillStyle',
  3211. opacity: 'globalAlpha'
  3212. };
  3213. var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash'];
  3214. var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
  3215. var Element =
  3216. /*#__PURE__*/
  3217. function () {
  3218. var _proto = Element.prototype;
  3219. _proto._initProperties = function _initProperties() {
  3220. this._attrs = {
  3221. zIndex: 0,
  3222. visible: true,
  3223. destroyed: false
  3224. };
  3225. };
  3226. function Element(cfg) {
  3227. this._initProperties();
  3228. Util.mix(this._attrs, cfg);
  3229. var attrs = this._attrs.attrs;
  3230. if (attrs) {
  3231. this.initAttrs(attrs);
  3232. }
  3233. this.initTransform();
  3234. }
  3235. _proto.get = function get(name) {
  3236. return this._attrs[name];
  3237. };
  3238. _proto.set = function set(name, value) {
  3239. this._attrs[name] = value;
  3240. };
  3241. _proto.isGroup = function isGroup() {
  3242. return this.get('isGroup');
  3243. };
  3244. _proto.isShape = function isShape() {
  3245. return this.get('isShape');
  3246. };
  3247. _proto.initAttrs = function initAttrs(attrs) {
  3248. this.attr(Util.mix(this.getDefaultAttrs(), attrs));
  3249. };
  3250. _proto.getDefaultAttrs = function getDefaultAttrs() {
  3251. return {};
  3252. };
  3253. _proto._setAttr = function _setAttr(name, value) {
  3254. var attrs = this._attrs.attrs;
  3255. if (name === 'clip') {
  3256. value = this._setAttrClip(value);
  3257. } else {
  3258. var alias = ALIAS_ATTRS_MAP[name];
  3259. if (alias) {
  3260. attrs[alias] = value;
  3261. }
  3262. }
  3263. attrs[name] = value;
  3264. };
  3265. _proto._getAttr = function _getAttr(name) {
  3266. return this._attrs.attrs[name];
  3267. }; // _afterAttrsSet() {}
  3268. _proto._setAttrClip = function _setAttrClip(clip) {
  3269. if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
  3270. if (clip.get('canvas') === null) {
  3271. clip = Object.assign({}, clip);
  3272. }
  3273. clip.set('parent', this.get('parent'));
  3274. clip.set('context', this.get('context'));
  3275. return clip;
  3276. }
  3277. return null;
  3278. };
  3279. _proto.attr = function attr(name, value) {
  3280. var self = this;
  3281. if (self.get('destroyed')) return null;
  3282. var argumentsLen = arguments.length;
  3283. if (argumentsLen === 0) {
  3284. return self._attrs.attrs;
  3285. }
  3286. if (Util.isObject(name)) {
  3287. this._attrs.bbox = null;
  3288. for (var k in name) {
  3289. self._setAttr(k, name[k]);
  3290. }
  3291. if (self._afterAttrsSet) {
  3292. self._afterAttrsSet();
  3293. }
  3294. return self;
  3295. }
  3296. if (argumentsLen === 2) {
  3297. this._attrs.bbox = null;
  3298. self._setAttr(name, value);
  3299. if (self._afterAttrsSet) {
  3300. self._afterAttrsSet();
  3301. }
  3302. return self;
  3303. }
  3304. return self._getAttr(name);
  3305. };
  3306. _proto.getParent = function getParent() {
  3307. return this.get('parent');
  3308. };
  3309. _proto.draw = function draw(context) {
  3310. if (this.get('destroyed')) {
  3311. return;
  3312. }
  3313. if (this.get('visible')) {
  3314. this.setContext(context);
  3315. this.drawInner(context);
  3316. this.restoreContext(context);
  3317. }
  3318. };
  3319. _proto.setContext = function setContext(context) {
  3320. var clip = this._attrs.attrs.clip;
  3321. context.save();
  3322. if (clip) {
  3323. clip.resetTransform(context);
  3324. clip.createPath(context);
  3325. context.clip();
  3326. }
  3327. this.resetContext(context);
  3328. this.resetTransform(context);
  3329. };
  3330. _proto.restoreContext = function restoreContext(context) {
  3331. context.restore();
  3332. };
  3333. _proto.resetContext = function resetContext(context) {
  3334. var elAttrs = this._attrs.attrs;
  3335. if (!this._attrs.isGroup) {
  3336. for (var k in elAttrs) {
  3337. if (SHAPE_ATTRS.indexOf(k) > -1) {
  3338. var v = elAttrs[k];
  3339. if (k === 'fillStyle' || k === 'strokeStyle') {
  3340. v = StyleUtil.parseStyle(v, this, context);
  3341. }
  3342. if (k === 'lineDash' && context.setLineDash && Util.isArray(v)) {
  3343. context.setLineDash(v);
  3344. } else {
  3345. context[k] = v;
  3346. }
  3347. }
  3348. }
  3349. }
  3350. };
  3351. _proto.hasFill = function hasFill() {
  3352. return this.get('canFill') && this._attrs.attrs.fillStyle;
  3353. };
  3354. _proto.hasStroke = function hasStroke() {
  3355. return this.get('canStroke') && this._attrs.attrs.strokeStyle;
  3356. };
  3357. _proto.drawInner = function drawInner()
  3358. /* context */
  3359. {};
  3360. _proto.show = function show() {
  3361. this.set('visible', true);
  3362. return this;
  3363. };
  3364. _proto.hide = function hide() {
  3365. this.set('visible', false);
  3366. return this;
  3367. };
  3368. _proto.isVisible = function isVisible() {
  3369. return this.get('visible');
  3370. };
  3371. _proto._removeFromParent = function _removeFromParent() {
  3372. var parent = this.get('parent');
  3373. if (parent) {
  3374. var children = parent.get('children');
  3375. Util.Array.remove(children, this);
  3376. }
  3377. return this;
  3378. };
  3379. _proto.remove = function remove(destroy) {
  3380. if (destroy) {
  3381. this.destroy();
  3382. } else {
  3383. this._removeFromParent();
  3384. }
  3385. };
  3386. _proto.destroy = function destroy() {
  3387. var destroyed = this.get('destroyed');
  3388. if (destroyed) {
  3389. return null;
  3390. }
  3391. this._removeFromParent();
  3392. this._attrs = {};
  3393. this.set('destroyed', true);
  3394. };
  3395. _proto.getBBox = function getBBox() {
  3396. return {
  3397. minX: 0,
  3398. maxX: 0,
  3399. minY: 0,
  3400. maxY: 0,
  3401. width: 0,
  3402. height: 0
  3403. };
  3404. };
  3405. _proto.initTransform = function initTransform() {
  3406. var attrs = this._attrs.attrs || {};
  3407. if (!attrs.matrix) {
  3408. attrs.matrix = [1, 0, 0, 1, 0, 0];
  3409. }
  3410. this._attrs.attrs = attrs;
  3411. };
  3412. _proto.getMatrix = function getMatrix() {
  3413. return this._attrs.attrs.matrix;
  3414. };
  3415. _proto.setMatrix = function setMatrix(m) {
  3416. this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
  3417. };
  3418. _proto.transform = function transform(actions) {
  3419. var matrix = this._attrs.attrs.matrix;
  3420. this._attrs.attrs.matrix = MatrixUtil.transform(matrix, actions);
  3421. return this;
  3422. };
  3423. _proto.setTransform = function setTransform(actions) {
  3424. this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
  3425. return this.transform(actions);
  3426. };
  3427. _proto.translate = function translate(x, y) {
  3428. var matrix = this._attrs.attrs.matrix;
  3429. MatrixUtil.translate(matrix, matrix, [x, y]);
  3430. };
  3431. _proto.rotate = function rotate(rad) {
  3432. var matrix = this._attrs.attrs.matrix;
  3433. MatrixUtil.rotate(matrix, matrix, rad);
  3434. };
  3435. _proto.scale = function scale(sx, sy) {
  3436. var matrix = this._attrs.attrs.matrix;
  3437. MatrixUtil.scale(matrix, matrix, [sx, sy]);
  3438. };
  3439. _proto.moveTo = function moveTo(x, y) {
  3440. var cx = this._attrs.x || 0;
  3441. var cy = this._attrs.y || 0;
  3442. this.translate(x - cx, y - cy);
  3443. this.set('x', x);
  3444. this.set('y', y);
  3445. };
  3446. _proto.apply = function apply(v) {
  3447. var m = this._attrs.attrs.matrix;
  3448. Vector2.transformMat2d(v, v, m);
  3449. return this;
  3450. };
  3451. _proto.resetTransform = function resetTransform(context) {
  3452. var mo = this._attrs.attrs.matrix;
  3453. if (!isUnchanged(mo)) {
  3454. context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
  3455. }
  3456. };
  3457. _proto.isDestroyed = function isDestroyed() {
  3458. return this.get('destroyed');
  3459. };
  3460. return Element;
  3461. }();
  3462. module.exports = Element;
  3463. /***/ }),
  3464. /* 26 */
  3465. /***/ (function(module, exports, __webpack_require__) {
  3466. var _require = __webpack_require__(5),
  3467. Shape = _require.Shape;
  3468. module.exports = {
  3469. getClip: function getClip(coord) {
  3470. var start = coord.start;
  3471. var end = coord.end;
  3472. var width = end.x - start.x;
  3473. var height = Math.abs(end.y - start.y);
  3474. var margin = 10;
  3475. var clip;
  3476. if (coord.isPolar) {
  3477. var circleRadius = coord.circleRadius,
  3478. center = coord.center,
  3479. startAngle = coord.startAngle,
  3480. endAngle = coord.endAngle;
  3481. clip = new Shape.Sector({
  3482. attrs: {
  3483. x: center.x,
  3484. y: center.y,
  3485. r: circleRadius,
  3486. r0: 0,
  3487. startAngle: startAngle,
  3488. endAngle: endAngle
  3489. }
  3490. });
  3491. } else {
  3492. clip = new Shape.Rect({
  3493. attrs: {
  3494. x: start.x,
  3495. y: end.y - margin,
  3496. width: width,
  3497. height: height + 2 * margin
  3498. }
  3499. });
  3500. }
  3501. clip.isClip = true;
  3502. return clip;
  3503. },
  3504. isPointInPlot: function isPointInPlot(point, plot) {
  3505. var x = point.x,
  3506. y = point.y;
  3507. var tl = plot.tl,
  3508. tr = plot.tr,
  3509. br = plot.br;
  3510. return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
  3511. }
  3512. };
  3513. /***/ }),
  3514. /* 27 */
  3515. /***/ (function(module, exports, __webpack_require__) {
  3516. var isNil = __webpack_require__(7);
  3517. function toString(value) {
  3518. if (isNil(value)) return '';
  3519. return value.toString();
  3520. }
  3521. module.exports = toString;
  3522. /***/ }),
  3523. /* 28 */
  3524. /***/ (function(module, exports, __webpack_require__) {
  3525. var isObjectLike = __webpack_require__(48);
  3526. var isType = __webpack_require__(8);
  3527. var isPlainObject = function isPlainObject(value) {
  3528. /**
  3529. * isObjectLike(new Foo) => false
  3530. * isObjectLike([1, 2, 3]) => false
  3531. * isObjectLike({ x: 0, y: 0 }) => true
  3532. * isObjectLike(Object.create(null)) => true
  3533. */
  3534. if (!isObjectLike(value) || !isType(value, 'Object')) {
  3535. return false;
  3536. }
  3537. if (Object.getPrototypeOf(value) === null) {
  3538. return true;
  3539. }
  3540. var proto = value;
  3541. while (Object.getPrototypeOf(proto) !== null) {
  3542. proto = Object.getPrototypeOf(proto);
  3543. }
  3544. return Object.getPrototypeOf(value) === proto;
  3545. };
  3546. module.exports = isPlainObject;
  3547. /***/ }),
  3548. /* 29 */
  3549. /***/ (function(module, exports, __webpack_require__) {
  3550. /**
  3551. * @fileOverview Base class of chart and geometry
  3552. * @author dxq613@gmail.com
  3553. */
  3554. var Util = __webpack_require__(0);
  3555. var Base =
  3556. /*#__PURE__*/
  3557. function () {
  3558. var _proto = Base.prototype;
  3559. _proto.getDefaultCfg = function getDefaultCfg() {
  3560. return {};
  3561. };
  3562. function Base(cfg) {
  3563. var attrs = {};
  3564. var defaultCfg = this.getDefaultCfg();
  3565. this._attrs = attrs;
  3566. Util.mix(attrs, defaultCfg, cfg);
  3567. }
  3568. _proto.get = function get(name) {
  3569. return this._attrs[name];
  3570. };
  3571. _proto.set = function set(name, value) {
  3572. this._attrs[name] = value;
  3573. };
  3574. _proto.destroy = function destroy() {
  3575. this._attrs = {};
  3576. this.destroyed = true;
  3577. };
  3578. return Base;
  3579. }();
  3580. module.exports = Base;
  3581. /***/ }),
  3582. /* 30 */
  3583. /***/ (function(module, exports, __webpack_require__) {
  3584. var Util = __webpack_require__(0);
  3585. var Shape = __webpack_require__(2);
  3586. var SHAPE_MAP = {};
  3587. var INDEX = '_INDEX';
  3588. function getComparer(compare) {
  3589. return function (left, right) {
  3590. var result = compare(left, right);
  3591. return result === 0 ? left[INDEX] - right[INDEX] : result;
  3592. };
  3593. }
  3594. module.exports = {
  3595. getGroupClass: function getGroupClass() {},
  3596. getChildren: function getChildren() {
  3597. return this.get('children');
  3598. },
  3599. addShape: function addShape(type, cfg) {
  3600. if (cfg === void 0) {
  3601. cfg = {};
  3602. }
  3603. var canvas = this.get('canvas');
  3604. var shapeType = SHAPE_MAP[type];
  3605. if (!shapeType) {
  3606. shapeType = Util.upperFirst(type);
  3607. SHAPE_MAP[type] = shapeType;
  3608. }
  3609. cfg.canvas = canvas;
  3610. if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
  3611. cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
  3612. }
  3613. var shape = new Shape[shapeType](cfg);
  3614. this.add(shape);
  3615. return shape;
  3616. },
  3617. addGroup: function addGroup(cfg) {
  3618. var canvas = this.get('canvas');
  3619. var groupClass = this.getGroupClass();
  3620. cfg = Util.mix({}, cfg);
  3621. cfg.canvas = canvas;
  3622. cfg.parent = this;
  3623. var rst = new groupClass(cfg);
  3624. this.add(rst);
  3625. return rst;
  3626. },
  3627. contain: function contain(item) {
  3628. var children = this.get('children');
  3629. return children.indexOf(item) > -1;
  3630. },
  3631. sort: function sort() {
  3632. var children = this.get('children');
  3633. for (var i = 0, len = children.length; i < len; i++) {
  3634. var child = children[i];
  3635. child[INDEX] = i;
  3636. }
  3637. children.sort(getComparer(function (obj1, obj2) {
  3638. return obj1.get('zIndex') - obj2.get('zIndex');
  3639. }));
  3640. return this;
  3641. },
  3642. clear: function clear() {
  3643. var children = this.get('children');
  3644. while (children.length !== 0) {
  3645. children[children.length - 1].remove(true);
  3646. }
  3647. return this;
  3648. },
  3649. add: function add(items) {
  3650. var self = this;
  3651. var children = self.get('children');
  3652. if (!Util.isArray(items)) {
  3653. items = [items];
  3654. }
  3655. for (var i = 0, len = items.length; i < len; i++) {
  3656. var item = items[i];
  3657. var parent = item.get('parent');
  3658. if (parent) {
  3659. var descendants = parent.get('children');
  3660. Util.Array.remove(descendants, item);
  3661. }
  3662. self._setEvn(item);
  3663. children.push(item);
  3664. }
  3665. return self;
  3666. },
  3667. _setEvn: function _setEvn(item) {
  3668. var self = this;
  3669. item._attrs.parent = self;
  3670. item._attrs.context = self._attrs.context;
  3671. item._attrs.canvas = self._attrs.canvas;
  3672. var clip = item._attrs.attrs.clip;
  3673. if (clip) {
  3674. clip.set('parent', self);
  3675. clip.set('context', self.get('context'));
  3676. }
  3677. if (item._attrs.isGroup) {
  3678. var children = item._attrs.children;
  3679. for (var i = 0, len = children.length; i < len; i++) {
  3680. item._setEvn(children[i]);
  3681. }
  3682. }
  3683. }
  3684. };
  3685. /***/ }),
  3686. /* 31 */
  3687. /***/ (function(module, exports, __webpack_require__) {
  3688. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  3689. var Util = __webpack_require__(0);
  3690. var Element = __webpack_require__(25);
  3691. var Container = __webpack_require__(30);
  3692. var Vector2 = __webpack_require__(4);
  3693. var Group =
  3694. /*#__PURE__*/
  3695. function (_Element) {
  3696. _inheritsLoose(Group, _Element);
  3697. function Group() {
  3698. return _Element.apply(this, arguments) || this;
  3699. }
  3700. var _proto = Group.prototype;
  3701. _proto._initProperties = function _initProperties() {
  3702. this._attrs = {
  3703. zIndex: 0,
  3704. visible: true,
  3705. destroyed: false,
  3706. isGroup: true,
  3707. children: []
  3708. };
  3709. };
  3710. _proto.drawInner = function drawInner(context) {
  3711. var children = this.get('children');
  3712. for (var i = 0, len = children.length; i < len; i++) {
  3713. var child = children[i];
  3714. child.draw(context);
  3715. }
  3716. return this;
  3717. };
  3718. _proto.getBBox = function getBBox() {
  3719. var self = this;
  3720. var minX = Infinity;
  3721. var maxX = -Infinity;
  3722. var minY = Infinity;
  3723. var maxY = -Infinity;
  3724. var children = self.get('children');
  3725. for (var i = 0, length = children.length; i < length; i++) {
  3726. var child = children[i];
  3727. if (child.get('visible')) {
  3728. var box = child.getBBox();
  3729. if (!box) {
  3730. continue;
  3731. }
  3732. var leftTop = [box.minX, box.minY];
  3733. var leftBottom = [box.minX, box.maxY];
  3734. var rightTop = [box.maxX, box.minY];
  3735. var rightBottom = [box.maxX, box.maxY];
  3736. var matrix = child.attr('matrix');
  3737. Vector2.transformMat2d(leftTop, leftTop, matrix);
  3738. Vector2.transformMat2d(leftBottom, leftBottom, matrix);
  3739. Vector2.transformMat2d(rightTop, rightTop, matrix);
  3740. Vector2.transformMat2d(rightBottom, rightBottom, matrix);
  3741. minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
  3742. maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
  3743. minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
  3744. maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
  3745. }
  3746. }
  3747. return {
  3748. minX: minX,
  3749. minY: minY,
  3750. maxX: maxX,
  3751. maxY: maxY,
  3752. x: minX,
  3753. y: minY,
  3754. width: maxX - minX,
  3755. height: maxY - minY
  3756. };
  3757. };
  3758. _proto.destroy = function destroy() {
  3759. if (this.get('destroyed')) {
  3760. return;
  3761. }
  3762. this.clear();
  3763. _Element.prototype.destroy.call(this);
  3764. };
  3765. return Group;
  3766. }(Element);
  3767. Util.mix(Group.prototype, Container, {
  3768. getGroupClass: function getGroupClass() {
  3769. return Group;
  3770. }
  3771. });
  3772. module.exports = Group;
  3773. /***/ }),
  3774. /* 32 */
  3775. /***/ (function(module, exports, __webpack_require__) {
  3776. var Util = __webpack_require__(0);
  3777. var Shape = __webpack_require__(9);
  3778. var ShapeUtil = __webpack_require__(20);
  3779. var Global = __webpack_require__(1); // register line geom
  3780. var Line = Shape.registerFactory('line', {
  3781. defaultShapeType: 'line'
  3782. });
  3783. function getStyle(cfg) {
  3784. var style = {
  3785. strokeStyle: cfg.color
  3786. };
  3787. if (cfg.size >= 0) {
  3788. style.lineWidth = cfg.size;
  3789. }
  3790. Util.mix(style, cfg.style);
  3791. return Util.mix({}, Global.shape.line, style);
  3792. }
  3793. function drawLines(cfg, container, style, smooth) {
  3794. var points = cfg.points;
  3795. if (points.length && Util.isArray(points[0].y)) {
  3796. var topPoints = [];
  3797. var bottomPoints = [];
  3798. for (var i = 0, len = points.length; i < len; i++) {
  3799. var point = points[i];
  3800. var tmp = ShapeUtil.splitPoints(point);
  3801. bottomPoints.push(tmp[0]);
  3802. topPoints.push(tmp[1]);
  3803. }
  3804. if (cfg.isInCircle) {
  3805. topPoints.push(topPoints[0]);
  3806. bottomPoints.push(bottomPoints[0]);
  3807. }
  3808. if (cfg.isStack) {
  3809. return container.addShape('Polyline', {
  3810. className: 'line',
  3811. attrs: Util.mix({
  3812. points: topPoints,
  3813. smooth: smooth
  3814. }, style)
  3815. });
  3816. }
  3817. var topShape = container.addShape('Polyline', {
  3818. className: 'line',
  3819. attrs: Util.mix({
  3820. points: topPoints,
  3821. smooth: smooth
  3822. }, style)
  3823. });
  3824. var bottomShape = container.addShape('Polyline', {
  3825. className: 'line',
  3826. attrs: Util.mix({
  3827. points: bottomPoints,
  3828. smooth: smooth
  3829. }, style)
  3830. });
  3831. return [topShape, bottomShape];
  3832. }
  3833. if (cfg.isInCircle) {
  3834. points.push(points[0]);
  3835. }
  3836. return container.addShape('Polyline', {
  3837. className: 'line',
  3838. attrs: Util.mix({
  3839. points: points,
  3840. smooth: smooth
  3841. }, style)
  3842. });
  3843. }
  3844. var SHAPES = ['line', 'smooth', 'dash'];
  3845. Util.each(SHAPES, function (shapeType) {
  3846. Shape.registerShape('line', shapeType, {
  3847. draw: function draw(cfg, container) {
  3848. var smooth = shapeType === 'smooth';
  3849. var style = getStyle(cfg);
  3850. if (shapeType === 'dash') {
  3851. style.lineDash = Global.lineDash;
  3852. }
  3853. return drawLines(cfg, container, style, smooth);
  3854. }
  3855. });
  3856. });
  3857. module.exports = Line;
  3858. /***/ }),
  3859. /* 33 */
  3860. /***/ (function(module, exports, __webpack_require__) {
  3861. var isType = __webpack_require__(8);
  3862. var isDate = function isDate(value) {
  3863. return isType(value, 'Date');
  3864. };
  3865. module.exports = isDate;
  3866. /***/ }),
  3867. /* 34 */
  3868. /***/ (function(module, exports, __webpack_require__) {
  3869. function _inheritsLoose(subClass, superClass) {
  3870. subClass.prototype = Object.create(superClass.prototype);
  3871. subClass.prototype.constructor = subClass;
  3872. subClass.__proto__ = superClass;
  3873. }
  3874. var Base = __webpack_require__(14);
  3875. var catAuto = __webpack_require__(35);
  3876. var each = __webpack_require__(3);
  3877. var isNumber = __webpack_require__(13);
  3878. var isString = __webpack_require__(15);
  3879. var Category =
  3880. /*#__PURE__*/
  3881. function (_Base) {
  3882. _inheritsLoose(Category, _Base);
  3883. function Category() {
  3884. return _Base.apply(this, arguments) || this;
  3885. }
  3886. var _proto = Category.prototype;
  3887. _proto._initDefaultCfg = function _initDefaultCfg() {
  3888. _Base.prototype._initDefaultCfg.call(this);
  3889. this.type = 'cat';
  3890. /**
  3891. * 是否分类度量
  3892. * @type {Boolean}
  3893. */
  3894. this.isCategory = true;
  3895. this.isRounding = true; // 是否进行取整操作
  3896. };
  3897. /**
  3898. * @override
  3899. */
  3900. _proto.init = function init() {
  3901. var self = this;
  3902. var values = self.values;
  3903. var tickCount = self.tickCount;
  3904. each(values, function (v, i) {
  3905. values[i] = v.toString();
  3906. });
  3907. if (!self.ticks) {
  3908. var ticks = values;
  3909. if (tickCount) {
  3910. var temp = catAuto({
  3911. maxCount: tickCount,
  3912. data: values,
  3913. isRounding: self.isRounding
  3914. });
  3915. ticks = temp.ticks;
  3916. }
  3917. this.ticks = ticks;
  3918. }
  3919. };
  3920. /**
  3921. * @override
  3922. */
  3923. _proto.getText = function getText(value) {
  3924. if (this.values.indexOf(value) === -1 && isNumber(value)) {
  3925. value = this.values[Math.round(value)];
  3926. }
  3927. return _Base.prototype.getText.call(this, value);
  3928. };
  3929. /**
  3930. * @override
  3931. */
  3932. _proto.translate = function translate(value) {
  3933. var index = this.values.indexOf(value);
  3934. if (index === -1 && isNumber(value)) {
  3935. index = value;
  3936. } else if (index === -1) {
  3937. index = NaN;
  3938. }
  3939. return index;
  3940. };
  3941. /**
  3942. * @override
  3943. */
  3944. _proto.scale = function scale(value) {
  3945. var rangeMin = this.rangeMin();
  3946. var rangeMax = this.rangeMax();
  3947. var percent;
  3948. if (isString(value) || this.values.indexOf(value) !== -1) {
  3949. value = this.translate(value);
  3950. }
  3951. if (this.values.length > 1) {
  3952. percent = value / (this.values.length - 1);
  3953. } else {
  3954. percent = value;
  3955. }
  3956. return rangeMin + percent * (rangeMax - rangeMin);
  3957. };
  3958. /**
  3959. * @override
  3960. */
  3961. _proto.invert = function invert(value) {
  3962. if (isString(value)) {
  3963. // 如果已经是字符串
  3964. return value;
  3965. }
  3966. var min = this.rangeMin();
  3967. var max = this.rangeMax(); // 归一到 范围内
  3968. if (value < min) {
  3969. value = min;
  3970. }
  3971. if (value > max) {
  3972. value = max;
  3973. }
  3974. var percent = (value - min) / (max - min);
  3975. var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
  3976. index = index || 0;
  3977. return this.values[index];
  3978. };
  3979. return Category;
  3980. }(Base);
  3981. Base.Cat = Category;
  3982. module.exports = Category;
  3983. /***/ }),
  3984. /* 35 */
  3985. /***/ (function(module, exports, __webpack_require__) {
  3986. /**
  3987. * @fileOverview 计算分类的的坐标点
  3988. * @author dxq613@gmail.com
  3989. */
  3990. var each = __webpack_require__(3);
  3991. var MAX_COUNT = 8;
  3992. var SUB_COUNT = 4; // 控制个数不能过小
  3993. function getSimpleArray(data) {
  3994. var arr = [];
  3995. each(data, function (sub) {
  3996. arr = arr.concat(sub);
  3997. });
  3998. return arr;
  3999. }
  4000. function getGreatestFactor(count, number) {
  4001. var i;
  4002. for (i = number; i > 0; i--) {
  4003. if (count % i === 0) {
  4004. break;
  4005. }
  4006. } // 如果是素数,没有可以整除的数字
  4007. if (i === 1) {
  4008. for (i = number; i > 0; i--) {
  4009. if ((count - 1) % i === 0) {
  4010. break;
  4011. }
  4012. }
  4013. }
  4014. return i;
  4015. }
  4016. module.exports = function (info) {
  4017. var rst = {};
  4018. var ticks = [];
  4019. var isRounding = info.isRounding;
  4020. var categories = getSimpleArray(info.data);
  4021. var length = categories.length;
  4022. var maxCount = info.maxCount || MAX_COUNT;
  4023. var tickCount;
  4024. if (isRounding) {
  4025. // 取整操作
  4026. tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
  4027. if (tickCount === 2) {
  4028. tickCount = maxCount;
  4029. } else if (tickCount < maxCount - SUB_COUNT) {
  4030. tickCount = maxCount - SUB_COUNT;
  4031. }
  4032. } else {
  4033. tickCount = maxCount;
  4034. }
  4035. if (!isRounding && length <= tickCount + tickCount / 2) {
  4036. ticks = [].concat(categories);
  4037. } else {
  4038. var step = parseInt(length / (tickCount - 1), 10);
  4039. var groups = categories.map(function (e, i) {
  4040. return i % step === 0 ? categories.slice(i, i + step) : null;
  4041. }).filter(function (e) {
  4042. return e;
  4043. });
  4044. for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
  4045. ticks.push(groups[i][0]);
  4046. }
  4047. if (categories.length) {
  4048. ticks.unshift(categories[0]);
  4049. var last = categories[length - 1];
  4050. if (ticks.indexOf(last) === -1) {
  4051. ticks.push(last);
  4052. }
  4053. }
  4054. }
  4055. rst.categories = categories;
  4056. rst.ticks = ticks;
  4057. return rst;
  4058. };
  4059. /***/ }),
  4060. /* 36 */
  4061. /***/ (function(module, exports) {
  4062. module.exports = {
  4063. requestAnimationFrame: typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
  4064. return setTimeout(fn, 16);
  4065. }
  4066. };
  4067. /***/ }),
  4068. /* 37 */
  4069. /***/ (function(module, exports, __webpack_require__) {
  4070. /**
  4071. * @fileOverview convert the line to curve
  4072. * @author dxq613@gmail.com
  4073. */
  4074. var Vector2 = __webpack_require__(4);
  4075. function getPoint(v) {
  4076. return [v.x, v.y];
  4077. }
  4078. function smoothBezier(points, smooth, isLoop, constraint) {
  4079. var cps = [];
  4080. var prevPoint;
  4081. var nextPoint;
  4082. var hasConstraint = !!constraint;
  4083. var min;
  4084. var max;
  4085. var point;
  4086. var len;
  4087. var l;
  4088. var i;
  4089. if (hasConstraint) {
  4090. min = [Infinity, Infinity];
  4091. max = [-Infinity, -Infinity];
  4092. for (i = 0, l = points.length; i < l; i++) {
  4093. point = getPoint(points[i]);
  4094. Vector2.min(min, min, point);
  4095. Vector2.max(max, max, point);
  4096. }
  4097. Vector2.min(min, min, constraint[0]);
  4098. Vector2.max(max, max, constraint[1]);
  4099. }
  4100. for (i = 0, len = points.length; i < len; i++) {
  4101. point = getPoint(points[i]);
  4102. if (isLoop) {
  4103. prevPoint = getPoint(points[i ? i - 1 : len - 1]);
  4104. nextPoint = getPoint(points[(i + 1) % len]);
  4105. } else {
  4106. if (i === 0 || i === len - 1) {
  4107. cps.push([point[0], point[1]]);
  4108. continue;
  4109. } else {
  4110. prevPoint = getPoint(points[i - 1]);
  4111. nextPoint = getPoint(points[i + 1]);
  4112. }
  4113. }
  4114. var v = Vector2.sub([], nextPoint, prevPoint);
  4115. Vector2.scale(v, v, smooth);
  4116. var d0 = Vector2.distance(point, prevPoint);
  4117. var d1 = Vector2.distance(point, nextPoint);
  4118. var sum = d0 + d1;
  4119. if (sum !== 0) {
  4120. d0 /= sum;
  4121. d1 /= sum;
  4122. }
  4123. var v1 = Vector2.scale([], v, -d0);
  4124. var v2 = Vector2.scale([], v, d1);
  4125. var cp0 = Vector2.add([], point, v1);
  4126. var cp1 = Vector2.add([], point, v2);
  4127. if (hasConstraint) {
  4128. Vector2.max(cp0, cp0, min);
  4129. Vector2.min(cp0, cp0, max);
  4130. Vector2.max(cp1, cp1, min);
  4131. Vector2.min(cp1, cp1, max);
  4132. }
  4133. cps.push([cp0[0], cp0[1]]);
  4134. cps.push([cp1[0], cp1[1]]);
  4135. }
  4136. if (isLoop) {
  4137. cps.push(cps.shift());
  4138. }
  4139. return cps;
  4140. }
  4141. function catmullRom2bezier(pointList, z, constraint) {
  4142. var isLoop = !!z;
  4143. var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
  4144. var len = pointList.length;
  4145. var d1 = [];
  4146. var cp1;
  4147. var cp2;
  4148. var p;
  4149. for (var i = 0; i < len - 1; i++) {
  4150. cp1 = controlPointList[i * 2];
  4151. cp2 = controlPointList[i * 2 + 1];
  4152. p = pointList[i + 1];
  4153. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  4154. }
  4155. if (isLoop) {
  4156. cp1 = controlPointList[len];
  4157. cp2 = controlPointList[len + 1];
  4158. p = pointList[0];
  4159. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  4160. }
  4161. return d1;
  4162. }
  4163. module.exports = {
  4164. smooth: catmullRom2bezier
  4165. };
  4166. /***/ }),
  4167. /* 38 */
  4168. /***/ (function(module, exports, __webpack_require__) {
  4169. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4170. var Geom = __webpack_require__(6);
  4171. var ShapeUtil = __webpack_require__(20);
  4172. var Util = __webpack_require__(0);
  4173. __webpack_require__(32);
  4174. var Path =
  4175. /*#__PURE__*/
  4176. function (_Geom) {
  4177. _inheritsLoose(Path, _Geom);
  4178. function Path() {
  4179. return _Geom.apply(this, arguments) || this;
  4180. }
  4181. var _proto = Path.prototype;
  4182. _proto.getDefaultCfg = function getDefaultCfg() {
  4183. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  4184. cfg.type = 'path';
  4185. cfg.shapeType = 'line';
  4186. return cfg;
  4187. };
  4188. _proto.getDrawCfg = function getDrawCfg(obj) {
  4189. var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
  4190. cfg.isStack = this.hasAdjust('stack');
  4191. return cfg;
  4192. };
  4193. _proto.draw = function draw(data, shapeFactory) {
  4194. var self = this;
  4195. var container = self.get('container');
  4196. var yScale = self.getYScale();
  4197. var connectNulls = self.get('connectNulls');
  4198. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  4199. var cfg = this.getDrawCfg(data[0]);
  4200. cfg.origin = data;
  4201. Util.each(splitArray, function (subData, splitedIndex) {
  4202. cfg.splitedIndex = splitedIndex;
  4203. cfg.points = subData;
  4204. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  4205. });
  4206. };
  4207. return Path;
  4208. }(Geom);
  4209. Geom.Path = Path;
  4210. module.exports = Path;
  4211. /***/ }),
  4212. /* 39 */
  4213. /***/ (function(module, exports, __webpack_require__) {
  4214. /**
  4215. * @fileOverview Utility for calculate the with ratui in x axis
  4216. * @author sima.zhang1990@gmail.com
  4217. * @author dxq613@gmail.com
  4218. */
  4219. var Global = __webpack_require__(1);
  4220. var Util = __webpack_require__(0);
  4221. var SizeMixin = {
  4222. getDefalutSize: function getDefalutSize() {
  4223. var defaultSize = this.get('defaultSize');
  4224. if (!defaultSize) {
  4225. var coord = this.get('coord');
  4226. var xScale = this.getXScale();
  4227. var dataArray = this.get('dataArray');
  4228. var count = xScale.values.length;
  4229. var range = xScale.range;
  4230. var normalizeSize = 1 / count;
  4231. var widthRatio = 1;
  4232. if (coord && coord.isPolar) {
  4233. if (coord.transposed && count > 1) {
  4234. widthRatio = Global.widthRatio.multiplePie;
  4235. } else {
  4236. widthRatio = Global.widthRatio.rose;
  4237. }
  4238. } else {
  4239. if (xScale.isLinear) {
  4240. normalizeSize *= range[1] - range[0];
  4241. }
  4242. widthRatio = Global.widthRatio.column;
  4243. }
  4244. normalizeSize *= widthRatio;
  4245. if (this.hasAdjust('dodge')) {
  4246. normalizeSize = normalizeSize / dataArray.length;
  4247. }
  4248. defaultSize = normalizeSize;
  4249. this.set('defaultSize', defaultSize);
  4250. }
  4251. return defaultSize;
  4252. },
  4253. getDimWidth: function getDimWidth(dimName) {
  4254. var coord = this.get('coord');
  4255. var start = coord.convertPoint({
  4256. x: 0,
  4257. y: 0
  4258. });
  4259. var end = coord.convertPoint({
  4260. x: dimName === 'x' ? 1 : 0,
  4261. y: dimName === 'x' ? 0 : 1
  4262. });
  4263. var width = 0;
  4264. if (start && end) {
  4265. width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
  4266. }
  4267. return width;
  4268. },
  4269. _getWidth: function _getWidth() {
  4270. var width = this.get('_width');
  4271. if (!width) {
  4272. var coord = this.get('coord');
  4273. if (coord && coord.isPolar && !coord.transposed) {
  4274. width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
  4275. } else {
  4276. width = this.getDimWidth('x');
  4277. }
  4278. this.set('_width', width);
  4279. }
  4280. return width;
  4281. },
  4282. _toNormalizedSize: function _toNormalizedSize(size) {
  4283. var width = this._getWidth();
  4284. return size / width;
  4285. },
  4286. _toCoordSize: function _toCoordSize(normalizeSize) {
  4287. var width = this._getWidth();
  4288. return width * normalizeSize;
  4289. },
  4290. getNormalizedSize: function getNormalizedSize(obj) {
  4291. var size = this.getAttrValue('size', obj);
  4292. if (Util.isNil(size)) {
  4293. size = this.getDefalutSize();
  4294. } else {
  4295. size = this._toNormalizedSize(size);
  4296. }
  4297. return size;
  4298. },
  4299. getSize: function getSize(obj) {
  4300. var size = this.getAttrValue('size', obj);
  4301. if (Util.isNil(size)) {
  4302. var normalizeSize = this.getDefalutSize();
  4303. size = this._toCoordSize(normalizeSize);
  4304. }
  4305. return size;
  4306. }
  4307. };
  4308. module.exports = SizeMixin;
  4309. /***/ }),
  4310. /* 40 */,
  4311. /* 41 */
  4312. /***/ (function(module, exports, __webpack_require__) {
  4313. var Core = {};
  4314. var Global = __webpack_require__(1);
  4315. Core.Global = Global;
  4316. Core.version = Global.version;
  4317. Core.Chart = __webpack_require__(19);
  4318. Core.Shape = __webpack_require__(9);
  4319. Core.G = __webpack_require__(5);
  4320. Core.Util = __webpack_require__(0);
  4321. Core.track = function (enable) {
  4322. Global.trackable = enable;
  4323. };
  4324. __webpack_require__(79);
  4325. module.exports = Core;
  4326. /***/ }),
  4327. /* 42 */
  4328. /***/ (function(module, exports, __webpack_require__) {
  4329. /**
  4330. * @fileOverview default theme
  4331. * @author dxq613@gail.com
  4332. */
  4333. var Util = __webpack_require__(0);
  4334. var color1 = '#E8E8E8'; // color of axis-line and axis-grid
  4335. var color2 = '#808080'; // color of axis label
  4336. var defaultAxis = {
  4337. label: {
  4338. fill: color2,
  4339. fontSize: 10
  4340. },
  4341. line: {
  4342. stroke: color1,
  4343. lineWidth: 1
  4344. },
  4345. grid: {
  4346. type: 'line',
  4347. stroke: color1,
  4348. lineWidth: 1,
  4349. lineDash: [2]
  4350. },
  4351. tickLine: null,
  4352. labelOffset: 7.5
  4353. };
  4354. var Theme = {
  4355. fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
  4356. defaultColor: '#1890FF',
  4357. pixelRatio: 1,
  4358. padding: 'auto',
  4359. appendPadding: 15,
  4360. colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
  4361. shapes: {
  4362. line: ['line', 'dash'],
  4363. point: ['circle', 'hollowCircle']
  4364. },
  4365. sizes: [4, 10],
  4366. axis: {
  4367. common: defaultAxis,
  4368. // common axis configuration
  4369. bottom: Util.mix({}, defaultAxis, {
  4370. grid: null
  4371. }),
  4372. left: Util.mix({}, defaultAxis, {
  4373. line: null
  4374. }),
  4375. right: Util.mix({}, defaultAxis, {
  4376. line: null
  4377. }),
  4378. circle: Util.mix({}, defaultAxis, {
  4379. line: null
  4380. }),
  4381. radius: Util.mix({}, defaultAxis, {
  4382. labelOffset: 4
  4383. })
  4384. },
  4385. shape: {
  4386. line: {
  4387. lineWidth: 2,
  4388. lineJoin: 'round',
  4389. lineCap: 'round'
  4390. },
  4391. point: {
  4392. lineWidth: 0,
  4393. size: 3
  4394. },
  4395. area: {
  4396. fillOpacity: 0.1
  4397. }
  4398. },
  4399. _defaultAxis: defaultAxis
  4400. };
  4401. module.exports = Theme;
  4402. /***/ }),
  4403. /* 43 */
  4404. /***/ (function(module, exports) {
  4405. var DomUtil;
  4406. /**
  4407. * Detects support for options object argument in addEventListener.
  4408. * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  4409. * @private
  4410. */
  4411. var supportsEventListenerOptions = function () {
  4412. var supports = false;
  4413. try {
  4414. var options = Object.defineProperty({}, 'passive', {
  4415. get: function get() {
  4416. supports = true;
  4417. }
  4418. });
  4419. window.addEventListener('e', null, options);
  4420. } catch (e) {// continue regardless of error
  4421. }
  4422. return supports;
  4423. }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
  4424. // https://github.com/chartjs/Chart.js/issues/4287
  4425. var eventListenerOptions = supportsEventListenerOptions ? {
  4426. passive: true
  4427. } : false;
  4428. function createEvent(type, chart, x, y, nativeEvent) {
  4429. return {
  4430. type: type,
  4431. chart: chart,
  4432. native: nativeEvent || null,
  4433. x: x !== undefined ? x : null,
  4434. y: y !== undefined ? y : null
  4435. };
  4436. }
  4437. function fromNativeEvent(event, chart) {
  4438. var type = event.type;
  4439. var point = {};
  4440. var touches = event.targetTouches;
  4441. if (touches && touches.length > 0) {
  4442. point.x = touches[0].clientX;
  4443. point.y = touches[0].clientY;
  4444. } else {
  4445. point.x = event.clientX;
  4446. point.y = event.clientY;
  4447. }
  4448. var canvas = chart.get('canvas');
  4449. var pos = DomUtil.getRelativePosition(point, canvas);
  4450. return createEvent(type, chart, pos.x, pos.y, event);
  4451. }
  4452. DomUtil = {
  4453. /* global wx, my, module */
  4454. isWx: typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function',
  4455. // weixin miniprogram
  4456. isMy: typeof my === 'object' && typeof my.getSystemInfoSync === 'function',
  4457. // ant miniprogram
  4458. isNode: typeof module !== 'undefined' && typeof module.exports !== 'undefined',
  4459. // in node
  4460. isBrowser: typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined',
  4461. // in browser
  4462. getPixelRatio: function getPixelRatio() {
  4463. return window && window.devicePixelRatio || 1;
  4464. },
  4465. getStyle: function getStyle(el, property) {
  4466. return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
  4467. },
  4468. getWidth: function getWidth(el) {
  4469. var width = this.getStyle(el, 'width');
  4470. if (width === 'auto') {
  4471. width = el.offsetWidth;
  4472. }
  4473. return parseFloat(width);
  4474. },
  4475. getHeight: function getHeight(el) {
  4476. var height = this.getStyle(el, 'height');
  4477. if (height === 'auto') {
  4478. height = el.offsetHeight;
  4479. }
  4480. return parseFloat(height);
  4481. },
  4482. getDomById: function getDomById(id) {
  4483. if (!id) {
  4484. return null;
  4485. }
  4486. return document.getElementById(id);
  4487. },
  4488. getRelativePosition: function getRelativePosition(point, canvas) {
  4489. var canvasDom = canvas.get('el');
  4490. var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
  4491. top = _canvasDom$getBoundin.top,
  4492. right = _canvasDom$getBoundin.right,
  4493. bottom = _canvasDom$getBoundin.bottom,
  4494. left = _canvasDom$getBoundin.left;
  4495. var paddingLeft = parseFloat(this.getStyle(canvasDom, 'padding-left'));
  4496. var paddingTop = parseFloat(this.getStyle(canvasDom, 'padding-top'));
  4497. var paddingRight = parseFloat(this.getStyle(canvasDom, 'padding-right'));
  4498. var paddingBottom = parseFloat(this.getStyle(canvasDom, 'padding-bottom'));
  4499. var width = right - left - paddingLeft - paddingRight;
  4500. var height = bottom - top - paddingTop - paddingBottom;
  4501. var pixelRatio = canvas.get('pixelRatio');
  4502. var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
  4503. var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
  4504. return {
  4505. x: mouseX,
  4506. y: mouseY
  4507. };
  4508. },
  4509. addEventListener: function addEventListener(source, type, listener) {
  4510. DomUtil.isBrowser && source.addEventListener(type, listener, eventListenerOptions);
  4511. },
  4512. removeEventListener: function removeEventListener(source, type, listener) {
  4513. DomUtil.isBrowser && source.removeEventListener(type, listener, eventListenerOptions);
  4514. },
  4515. createEvent: function createEvent(event, chart) {
  4516. return fromNativeEvent(event, chart);
  4517. },
  4518. measureText: function measureText(text, font, ctx) {
  4519. if (!ctx) {
  4520. ctx = document.createElement('canvas').getContext('2d');
  4521. }
  4522. ctx.font = font || '12px sans-serif';
  4523. return ctx.measureText(text);
  4524. }
  4525. };
  4526. module.exports = DomUtil;
  4527. /***/ }),
  4528. /* 44 */
  4529. /***/ (function(module, exports, __webpack_require__) {
  4530. var toString = __webpack_require__(27);
  4531. var upperFirst = function upperFirst(value) {
  4532. var str = toString(value);
  4533. return str.charAt(0).toUpperCase() + str.substring(1);
  4534. };
  4535. module.exports = upperFirst;
  4536. /***/ }),
  4537. /* 45 */
  4538. /***/ (function(module, exports, __webpack_require__) {
  4539. var toString = __webpack_require__(27);
  4540. var lowerFirst = function lowerFirst(value) {
  4541. var str = toString(value);
  4542. return str.charAt(0).toLowerCase() + str.substring(1);
  4543. };
  4544. module.exports = lowerFirst;
  4545. /***/ }),
  4546. /* 46 */
  4547. /***/ (function(module, exports, __webpack_require__) {
  4548. /**
  4549. * 是否是布尔类型
  4550. *
  4551. * @param {Object} value 测试的值
  4552. * @return {Boolean}
  4553. */
  4554. var isType = __webpack_require__(8);
  4555. var isBoolean = function isBoolean(value) {
  4556. return isType(value, 'Boolean');
  4557. };
  4558. module.exports = isBoolean;
  4559. /***/ }),
  4560. /* 47 */
  4561. /***/ (function(module, exports, __webpack_require__) {
  4562. /**
  4563. * 是否为函数
  4564. * @param {*} fn 对象
  4565. * @return {Boolean} 是否函数
  4566. */
  4567. var isType = __webpack_require__(8);
  4568. var isFunction = function isFunction(value) {
  4569. return isType(value, 'Function');
  4570. };
  4571. module.exports = isFunction;
  4572. /***/ }),
  4573. /* 48 */
  4574. /***/ (function(module, exports) {
  4575. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  4576. return typeof obj;
  4577. } : function (obj) {
  4578. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  4579. };
  4580. var isObjectLike = function isObjectLike(value) {
  4581. /**
  4582. * isObjectLike({}) => true
  4583. * isObjectLike([1, 2, 3]) => true
  4584. * isObjectLike(Function) => false
  4585. * isObjectLike(null) => false
  4586. */
  4587. return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
  4588. };
  4589. module.exports = isObjectLike;
  4590. /***/ }),
  4591. /* 49 */
  4592. /***/ (function(module, exports, __webpack_require__) {
  4593. var isPlainObject = __webpack_require__(28);
  4594. var isArray = __webpack_require__(10);
  4595. var MAX_MIX_LEVEL = 5;
  4596. function _deepMix(dist, src, level, maxLevel) {
  4597. level = level || 0;
  4598. maxLevel = maxLevel || MAX_MIX_LEVEL;
  4599. for (var key in src) {
  4600. if (src.hasOwnProperty(key)) {
  4601. var value = src[key];
  4602. if (value !== null && isPlainObject(value)) {
  4603. if (!isPlainObject(dist[key])) {
  4604. dist[key] = {};
  4605. }
  4606. if (level < maxLevel) {
  4607. _deepMix(dist[key], value, level + 1, maxLevel);
  4608. } else {
  4609. dist[key] = src[key];
  4610. }
  4611. } else if (isArray(value)) {
  4612. dist[key] = [];
  4613. dist[key] = dist[key].concat(value);
  4614. } else if (value !== undefined) {
  4615. dist[key] = value;
  4616. }
  4617. }
  4618. }
  4619. }
  4620. var deepMix = function deepMix() {
  4621. var args = new Array(arguments.length);
  4622. var length = args.length;
  4623. for (var i = 0; i < length; i++) {
  4624. args[i] = arguments[i];
  4625. }
  4626. var rst = args[0];
  4627. for (var _i = 1; _i < length; _i++) {
  4628. _deepMix(rst, args[_i]);
  4629. }
  4630. return rst;
  4631. };
  4632. module.exports = deepMix;
  4633. /***/ }),
  4634. /* 50 */
  4635. /***/ (function(module, exports, __webpack_require__) {
  4636. var Util = __webpack_require__(0);
  4637. var Plot =
  4638. /*#__PURE__*/
  4639. function () {
  4640. function Plot(cfg) {
  4641. Util.mix(this, cfg);
  4642. this._init();
  4643. }
  4644. var _proto = Plot.prototype;
  4645. _proto._init = function _init() {
  4646. var self = this;
  4647. var start = self.start;
  4648. var end = self.end;
  4649. var xMin = Math.min(start.x, end.x);
  4650. var xMax = Math.max(start.x, end.x);
  4651. var yMin = Math.min(start.y, end.y);
  4652. var yMax = Math.max(start.y, end.y);
  4653. this.tl = {
  4654. x: xMin,
  4655. y: yMin
  4656. };
  4657. this.tr = {
  4658. x: xMax,
  4659. y: yMin
  4660. };
  4661. this.bl = {
  4662. x: xMin,
  4663. y: yMax
  4664. };
  4665. this.br = {
  4666. x: xMax,
  4667. y: yMax
  4668. };
  4669. this.width = xMax - xMin;
  4670. this.height = yMax - yMin;
  4671. };
  4672. /**
  4673. * reset
  4674. * @param {Object} start start point
  4675. * @param {Object} end end point
  4676. */
  4677. _proto.reset = function reset(start, end) {
  4678. this.start = start;
  4679. this.end = end;
  4680. this._init();
  4681. };
  4682. /**
  4683. * check the point is in the range of plot
  4684. * @param {Nubmer} x x value
  4685. * @param {[type]} y y value
  4686. * @return {Boolean} return the result
  4687. */
  4688. _proto.isInRange = function isInRange(x, y) {
  4689. if (Util.isObject(x)) {
  4690. y = x.y;
  4691. x = x.x;
  4692. }
  4693. var tl = this.tl;
  4694. var br = this.br;
  4695. return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
  4696. };
  4697. return Plot;
  4698. }();
  4699. module.exports = Plot;
  4700. /***/ }),
  4701. /* 51 */
  4702. /***/ (function(module, exports, __webpack_require__) {
  4703. var Coord = __webpack_require__(21);
  4704. __webpack_require__(52);
  4705. module.exports = Coord;
  4706. /***/ }),
  4707. /* 52 */
  4708. /***/ (function(module, exports, __webpack_require__) {
  4709. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4710. var Base = __webpack_require__(21);
  4711. var Cartesian =
  4712. /*#__PURE__*/
  4713. function (_Base) {
  4714. _inheritsLoose(Cartesian, _Base);
  4715. function Cartesian() {
  4716. return _Base.apply(this, arguments) || this;
  4717. }
  4718. var _proto = Cartesian.prototype;
  4719. _proto._initDefaultCfg = function _initDefaultCfg() {
  4720. this.type = 'cartesian';
  4721. this.transposed = false;
  4722. this.isRect = true;
  4723. };
  4724. _proto.init = function init(start, end) {
  4725. this.x = {
  4726. start: start.x,
  4727. end: end.x
  4728. };
  4729. this.y = {
  4730. start: start.y,
  4731. end: end.y
  4732. };
  4733. };
  4734. _proto.convertPoint = function convertPoint(point) {
  4735. var self = this;
  4736. var transposed = self.transposed;
  4737. var xDim = transposed ? 'y' : 'x';
  4738. var yDim = transposed ? 'x' : 'y';
  4739. var x = self.x;
  4740. var y = self.y;
  4741. return {
  4742. x: x.start + (x.end - x.start) * point[xDim],
  4743. y: y.start + (y.end - y.start) * point[yDim]
  4744. };
  4745. };
  4746. _proto.invertPoint = function invertPoint(point) {
  4747. var self = this;
  4748. var transposed = self.transposed;
  4749. var xDim = transposed ? 'y' : 'x';
  4750. var yDim = transposed ? 'x' : 'y';
  4751. var x = self.x;
  4752. var y = self.y;
  4753. var rst = {};
  4754. rst[xDim] = (point.x - x.start) / (x.end - x.start);
  4755. rst[yDim] = (point.y - y.start) / (y.end - y.start);
  4756. return rst;
  4757. };
  4758. return Cartesian;
  4759. }(Base);
  4760. Base.Cartesian = Cartesian;
  4761. Base.Rect = Cartesian;
  4762. module.exports = Cartesian;
  4763. /***/ }),
  4764. /* 53 */
  4765. /***/ (function(module, exports, __webpack_require__) {
  4766. module.exports = {
  4767. Position: __webpack_require__(54),
  4768. Shape: __webpack_require__(55),
  4769. Size: __webpack_require__(56),
  4770. Color: __webpack_require__(57)
  4771. };
  4772. /***/ }),
  4773. /* 54 */
  4774. /***/ (function(module, exports, __webpack_require__) {
  4775. function _inheritsLoose(subClass, superClass) {
  4776. subClass.prototype = Object.create(superClass.prototype);
  4777. subClass.prototype.constructor = subClass;
  4778. subClass.__proto__ = superClass;
  4779. }
  4780. var isNil = __webpack_require__(7);
  4781. var isArray = __webpack_require__(10);
  4782. var each = __webpack_require__(3);
  4783. var Base = __webpack_require__(17);
  4784. var Position =
  4785. /*#__PURE__*/
  4786. function (_Base) {
  4787. _inheritsLoose(Position, _Base);
  4788. function Position(cfg) {
  4789. var _this;
  4790. _this = _Base.call(this, cfg) || this;
  4791. _this.names = ['x', 'y'];
  4792. _this.type = 'position';
  4793. return _this;
  4794. }
  4795. var _proto = Position.prototype;
  4796. _proto.mapping = function mapping(x, y) {
  4797. var scales = this.scales;
  4798. var coord = this.coord;
  4799. var scaleX = scales[0];
  4800. var scaleY = scales[1];
  4801. var rstX;
  4802. var rstY;
  4803. var obj;
  4804. if (isNil(x) || isNil(y)) {
  4805. return [];
  4806. }
  4807. if (isArray(y) && isArray(x)) {
  4808. rstX = [];
  4809. rstY = [];
  4810. for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
  4811. obj = coord.convertPoint({
  4812. x: scaleX.scale(x[i]),
  4813. y: scaleY.scale(y[j])
  4814. });
  4815. rstX.push(obj.x);
  4816. rstY.push(obj.y);
  4817. }
  4818. } else if (isArray(y)) {
  4819. x = scaleX.scale(x);
  4820. rstY = [];
  4821. each(y, function (yVal) {
  4822. yVal = scaleY.scale(yVal);
  4823. obj = coord.convertPoint({
  4824. x: x,
  4825. y: yVal
  4826. });
  4827. if (rstX && rstX !== obj.x) {
  4828. if (!isArray(rstX)) {
  4829. rstX = [rstX];
  4830. }
  4831. rstX.push(obj.x);
  4832. } else {
  4833. rstX = obj.x;
  4834. }
  4835. rstY.push(obj.y);
  4836. });
  4837. } else if (isArray(x)) {
  4838. y = scaleY.scale(y);
  4839. rstX = [];
  4840. each(x, function (xVal) {
  4841. xVal = scaleX.scale(xVal);
  4842. obj = coord.convertPoint({
  4843. x: xVal,
  4844. y: y
  4845. });
  4846. if (rstY && rstY !== obj.y) {
  4847. if (!isArray(rstY)) {
  4848. rstY = [rstY];
  4849. }
  4850. rstY.push(obj.y);
  4851. } else {
  4852. rstY = obj.y;
  4853. }
  4854. rstX.push(obj.x);
  4855. });
  4856. } else {
  4857. x = scaleX.scale(x);
  4858. y = scaleY.scale(y);
  4859. var point = coord.convertPoint({
  4860. x: x,
  4861. y: y
  4862. });
  4863. rstX = point.x;
  4864. rstY = point.y;
  4865. }
  4866. return [rstX, rstY];
  4867. };
  4868. return Position;
  4869. }(Base);
  4870. module.exports = Position;
  4871. /***/ }),
  4872. /* 55 */
  4873. /***/ (function(module, exports, __webpack_require__) {
  4874. function _inheritsLoose(subClass, superClass) {
  4875. subClass.prototype = Object.create(superClass.prototype);
  4876. subClass.prototype.constructor = subClass;
  4877. subClass.__proto__ = superClass;
  4878. }
  4879. var Base = __webpack_require__(17);
  4880. var Shape =
  4881. /*#__PURE__*/
  4882. function (_Base) {
  4883. _inheritsLoose(Shape, _Base);
  4884. function Shape(cfg) {
  4885. var _this;
  4886. _this = _Base.call(this, cfg) || this;
  4887. _this.names = ['shape'];
  4888. _this.type = 'shape';
  4889. _this.gradient = null;
  4890. return _this;
  4891. }
  4892. /**
  4893. * @override
  4894. */
  4895. var _proto = Shape.prototype;
  4896. _proto.getLinearValue = function getLinearValue(percent) {
  4897. var values = this.values;
  4898. var index = Math.round((values.length - 1) * percent);
  4899. return values[index];
  4900. };
  4901. return Shape;
  4902. }(Base);
  4903. module.exports = Shape;
  4904. /***/ }),
  4905. /* 56 */
  4906. /***/ (function(module, exports, __webpack_require__) {
  4907. function _inheritsLoose(subClass, superClass) {
  4908. subClass.prototype = Object.create(superClass.prototype);
  4909. subClass.prototype.constructor = subClass;
  4910. subClass.__proto__ = superClass;
  4911. }
  4912. var Base = __webpack_require__(17);
  4913. var Size =
  4914. /*#__PURE__*/
  4915. function (_Base) {
  4916. _inheritsLoose(Size, _Base);
  4917. function Size(cfg) {
  4918. var _this;
  4919. _this = _Base.call(this, cfg) || this;
  4920. _this.names = ['size'];
  4921. _this.type = 'size';
  4922. _this.gradient = null;
  4923. return _this;
  4924. }
  4925. return Size;
  4926. }(Base);
  4927. module.exports = Size;
  4928. /***/ }),
  4929. /* 57 */
  4930. /***/ (function(module, exports, __webpack_require__) {
  4931. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4932. var Util = __webpack_require__(0);
  4933. var ColorUtil = __webpack_require__(58);
  4934. var Base = __webpack_require__(17);
  4935. var Color =
  4936. /*#__PURE__*/
  4937. function (_Base) {
  4938. _inheritsLoose(Color, _Base);
  4939. function Color(cfg) {
  4940. var _this;
  4941. _this = _Base.call(this, cfg) || this;
  4942. _this.names = ['color'];
  4943. _this.type = 'color';
  4944. _this.gradient = null;
  4945. if (Util.isString(_this.values)) {
  4946. _this.linear = true;
  4947. }
  4948. return _this;
  4949. }
  4950. /**
  4951. * @override
  4952. */
  4953. var _proto = Color.prototype;
  4954. _proto.getLinearValue = function getLinearValue(percent) {
  4955. var gradient = this.gradient;
  4956. if (!gradient) {
  4957. var values = this.values;
  4958. gradient = ColorUtil.gradient(values);
  4959. this.gradient = gradient;
  4960. }
  4961. return gradient(percent);
  4962. };
  4963. return Color;
  4964. }(Base);
  4965. module.exports = Color;
  4966. /***/ }),
  4967. /* 58 */
  4968. /***/ (function(module, exports, __webpack_require__) {
  4969. var Util = __webpack_require__(0); // Get the interpolation between colors
  4970. function getValue(start, end, percent, index) {
  4971. var value = start[index] + (end[index] - start[index]) * percent;
  4972. return value;
  4973. } // convert to hex
  4974. function arr2hex(arr) {
  4975. return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
  4976. }
  4977. function toRGBValue(value) {
  4978. value = Math.round(value);
  4979. value = value.toString(16);
  4980. if (value.length === 1) {
  4981. value = '0' + value;
  4982. }
  4983. return value;
  4984. }
  4985. function calColor(colors, percent) {
  4986. var steps = colors.length - 1;
  4987. var step = Math.floor(steps * percent);
  4988. var left = steps * percent - step;
  4989. var start = colors[step];
  4990. var end = step === steps ? start : colors[step + 1];
  4991. var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
  4992. return rgb;
  4993. }
  4994. function hex2arr(str) {
  4995. var arr = [];
  4996. arr.push(parseInt(str.substr(1, 2), 16));
  4997. arr.push(parseInt(str.substr(3, 2), 16));
  4998. arr.push(parseInt(str.substr(5, 2), 16));
  4999. return arr;
  5000. }
  5001. var colorCache = {
  5002. black: '#000000',
  5003. blue: '#0000ff',
  5004. grey: '#808080',
  5005. green: '#008000',
  5006. orange: '#ffa500',
  5007. pink: '#ffc0cb',
  5008. purple: '#800080',
  5009. red: '#ff0000',
  5010. white: '#ffffff',
  5011. yellow: '#ffff00'
  5012. };
  5013. var ColorUtil = {
  5014. /**
  5015. * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
  5016. * @param {String} color color value
  5017. * @return {String} Returns a hexadecimal string
  5018. */
  5019. toHex: function toHex(color) {
  5020. if (colorCache[color]) {
  5021. return colorCache[color];
  5022. }
  5023. if (color[0] === '#') {
  5024. if (color.length === 7) {
  5025. return color;
  5026. }
  5027. var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
  5028. return '#' + r + r + g + g + b + b;
  5029. }); // hex3 to hex6
  5030. colorCache[color] = hex;
  5031. return hex;
  5032. } // rgb/rgba to hex
  5033. var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  5034. rst.shift();
  5035. rst = arr2hex(rst);
  5036. colorCache[color] = rst;
  5037. return rst;
  5038. },
  5039. hex2arr: hex2arr,
  5040. /**
  5041. * handle the gradient color
  5042. * @param {Array} colors the colors
  5043. * @return {String} return the color value
  5044. */
  5045. gradient: function gradient(colors) {
  5046. var points = [];
  5047. if (Util.isString(colors)) {
  5048. colors = colors.split('-');
  5049. }
  5050. Util.each(colors, function (color) {
  5051. if (color.indexOf('#') === -1) {
  5052. color = ColorUtil.toHex(color);
  5053. }
  5054. points.push(hex2arr(color));
  5055. });
  5056. return function (percent) {
  5057. return calColor(points, percent);
  5058. };
  5059. }
  5060. };
  5061. module.exports = ColorUtil;
  5062. /***/ }),
  5063. /* 59 */
  5064. /***/ (function(module, exports, __webpack_require__) {
  5065. var Util = __webpack_require__(0);
  5066. var Global = __webpack_require__(1);
  5067. var Scale = __webpack_require__(60);
  5068. var SCALE_TYPES_MAP = {
  5069. linear: 'Linear',
  5070. cat: 'Cat',
  5071. timeCat: 'TimeCat',
  5072. identity: 'Identity'
  5073. };
  5074. var ScaleController =
  5075. /*#__PURE__*/
  5076. function () {
  5077. function ScaleController(cfg) {
  5078. // defs 列定义
  5079. this.defs = {};
  5080. Util.mix(this, cfg);
  5081. }
  5082. var _proto = ScaleController.prototype;
  5083. _proto._getDef = function _getDef(field) {
  5084. var defs = this.defs;
  5085. var def = null;
  5086. if (Global.scales[field] || defs[field]) {
  5087. def = Util.mix({}, Global.scales[field]);
  5088. Util.each(defs[field], function (v, k) {
  5089. if (Util.isNil(v)) {
  5090. delete def[k];
  5091. } else {
  5092. def[k] = v;
  5093. }
  5094. });
  5095. }
  5096. return def;
  5097. };
  5098. _proto._getDefaultType = function _getDefaultType(field, data, def) {
  5099. if (def && def.type) {
  5100. return def.type;
  5101. }
  5102. var type = 'linear';
  5103. var value = Util.Array.firstValue(data, field);
  5104. if (Util.isArray(value)) {
  5105. value = value[0];
  5106. }
  5107. if (Util.isString(value)) {
  5108. type = 'cat';
  5109. }
  5110. return type;
  5111. };
  5112. _proto._getScaleCfg = function _getScaleCfg(type, field, data, def) {
  5113. var values;
  5114. if (def && def.values) {
  5115. values = def.values;
  5116. } else {
  5117. values = Util.Array.values(data, field);
  5118. }
  5119. var cfg = {
  5120. field: field,
  5121. values: values
  5122. };
  5123. if (type !== 'cat' && type !== 'timeCat') {
  5124. if (!def || !(def.min && def.max)) {
  5125. var _Util$Array$getRange = Util.Array.getRange(values),
  5126. min = _Util$Array$getRange.min,
  5127. max = _Util$Array$getRange.max;
  5128. cfg.min = min;
  5129. cfg.max = max;
  5130. cfg.nice = true;
  5131. }
  5132. }
  5133. if (type === 'cat' || type === 'timeCat') {
  5134. cfg.isRounding = false; // used for tickCount calculation
  5135. }
  5136. return cfg;
  5137. };
  5138. _proto.createScale = function createScale(field, data) {
  5139. var self = this;
  5140. var def = self._getDef(field);
  5141. var scale;
  5142. if (!data || !data.length) {
  5143. if (def && def.type) {
  5144. def.field = field;
  5145. scale = new Scale[SCALE_TYPES_MAP[def.type]](def);
  5146. } else {
  5147. scale = new Scale.Identity({
  5148. value: field,
  5149. field: field.toString(),
  5150. values: [field]
  5151. });
  5152. }
  5153. return scale;
  5154. }
  5155. var firstObj = data[0];
  5156. var firstValue = firstObj[field];
  5157. if (firstValue === null) {
  5158. firstValue = Util.Array.firstValue(data, field);
  5159. }
  5160. if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
  5161. scale = new Scale.Identity({
  5162. value: field,
  5163. field: field.toString(),
  5164. values: [field]
  5165. });
  5166. } else {
  5167. var type = self._getDefaultType(field, data, def);
  5168. var cfg = self._getScaleCfg(type, field, data, def);
  5169. def && Util.mix(cfg, def);
  5170. scale = new Scale[SCALE_TYPES_MAP[type]](cfg);
  5171. }
  5172. return scale;
  5173. };
  5174. return ScaleController;
  5175. }();
  5176. module.exports = ScaleController;
  5177. /***/ }),
  5178. /* 60 */
  5179. /***/ (function(module, exports, __webpack_require__) {
  5180. var Scale = __webpack_require__(14);
  5181. __webpack_require__(61);
  5182. __webpack_require__(64);
  5183. __webpack_require__(34);
  5184. module.exports = Scale;
  5185. /***/ }),
  5186. /* 61 */
  5187. /***/ (function(module, exports, __webpack_require__) {
  5188. function _inheritsLoose(subClass, superClass) {
  5189. subClass.prototype = Object.create(superClass.prototype);
  5190. subClass.prototype.constructor = subClass;
  5191. subClass.__proto__ = superClass;
  5192. }
  5193. /**
  5194. * @fileOverview The measurement of linear data scale function
  5195. * @author dxq613@gmail.com
  5196. */
  5197. var isNil = __webpack_require__(7);
  5198. var each = __webpack_require__(3);
  5199. var Base = __webpack_require__(14);
  5200. var numberAuto = __webpack_require__(62);
  5201. /**
  5202. * 线性度量
  5203. * @class Scale.Linear
  5204. */
  5205. var Linear =
  5206. /*#__PURE__*/
  5207. function (_Base) {
  5208. _inheritsLoose(Linear, _Base);
  5209. function Linear() {
  5210. return _Base.apply(this, arguments) || this;
  5211. }
  5212. var _proto = Linear.prototype;
  5213. _proto._initDefaultCfg = function _initDefaultCfg() {
  5214. _Base.prototype._initDefaultCfg.call(this);
  5215. var self = this;
  5216. self.type = 'linear';
  5217. self.isLinear = true;
  5218. /**
  5219. * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
  5220. * @type {Boolean}
  5221. * @default false
  5222. */
  5223. self.nice = false;
  5224. /**
  5225. * min value of the scale
  5226. * @type {Number}
  5227. * @default null
  5228. */
  5229. self.min = null;
  5230. /**
  5231. * min value limitted of the scale
  5232. * @type {Number}
  5233. * @default null
  5234. */
  5235. self.minLimit = null;
  5236. /**
  5237. * max value of the scale
  5238. * @type {Number}
  5239. * @default null
  5240. */
  5241. self.max = null;
  5242. /**
  5243. * max value limitted of the scale
  5244. * @type {Number}
  5245. * @default null
  5246. */
  5247. self.maxLimit = null;
  5248. /**
  5249. * 自动生成标记时的个数
  5250. * @type {Number}
  5251. * @default null
  5252. */
  5253. self.tickCount = null;
  5254. /**
  5255. * 坐标轴点之间的间距,指的是真实数据的差值
  5256. * @type {Number}
  5257. * @default null
  5258. */
  5259. self.tickInterval = null;
  5260. /**
  5261. * 坐标轴点之间的最小间距,指的是真实数据的差值
  5262. * @type {Number}
  5263. * @default null
  5264. */
  5265. self.minTickInterval = null;
  5266. /**
  5267. * 用于计算坐标点时逼近的数组
  5268. * @type {Array}
  5269. */
  5270. self.snapArray = null;
  5271. };
  5272. /**
  5273. * @protected
  5274. * @override
  5275. */
  5276. _proto.init = function init() {
  5277. var self = this;
  5278. if (!self.ticks) {
  5279. self.min = self.translate(self.min);
  5280. self.max = self.translate(self.max);
  5281. self.initTicks();
  5282. } else {
  5283. var ticks = self.ticks;
  5284. var firstValue = self.translate(ticks[0]);
  5285. var lastValue = self.translate(ticks[ticks.length - 1]);
  5286. if (isNil(self.min) || self.min > firstValue) {
  5287. self.min = firstValue;
  5288. }
  5289. if (isNil(self.max) || self.max < lastValue) {
  5290. self.max = lastValue;
  5291. }
  5292. }
  5293. };
  5294. /**
  5295. * 计算坐标点
  5296. * @protected
  5297. * @return {Array} 计算完成的坐标点
  5298. */
  5299. _proto.calculateTicks = function calculateTicks() {
  5300. var min = this.min,
  5301. max = this.max,
  5302. minLimit = this.minLimit,
  5303. maxLimit = this.maxLimit,
  5304. tickCount = this.tickCount,
  5305. tickInterval = this.tickInterval,
  5306. minTickInterval = this.minTickInterval,
  5307. snapArray = this.snapArray;
  5308. if (tickCount === 1) {
  5309. throw new Error('linear scale\'tickCount should not be 1');
  5310. }
  5311. if (max < min) {
  5312. throw new Error("max: " + max + " should not be less than min: " + min);
  5313. }
  5314. var tmp = numberAuto({
  5315. min: min,
  5316. max: max,
  5317. minLimit: minLimit,
  5318. maxLimit: maxLimit,
  5319. minCount: tickCount,
  5320. maxCount: tickCount,
  5321. interval: tickInterval,
  5322. minTickInterval: minTickInterval,
  5323. snapArray: snapArray
  5324. });
  5325. return tmp.ticks;
  5326. }; // 初始化ticks
  5327. _proto.initTicks = function initTicks() {
  5328. var self = this;
  5329. var calTicks = self.calculateTicks();
  5330. if (self.nice) {
  5331. // 如果需要优化显示的tick
  5332. self.ticks = calTicks;
  5333. self.min = calTicks[0];
  5334. self.max = calTicks[calTicks.length - 1];
  5335. } else {
  5336. var ticks = [];
  5337. each(calTicks, function (tick) {
  5338. if (tick >= self.min && tick <= self.max) {
  5339. ticks.push(tick);
  5340. }
  5341. }); // 如果 ticks 为空,直接输入最小值、最大值
  5342. if (!ticks.length) {
  5343. ticks.push(self.min);
  5344. ticks.push(self.max);
  5345. }
  5346. self.ticks = ticks;
  5347. }
  5348. };
  5349. /**
  5350. * @override
  5351. */
  5352. _proto.scale = function scale(value) {
  5353. if (isNil(value)) {
  5354. return NaN;
  5355. }
  5356. var max = this.max;
  5357. var min = this.min;
  5358. if (max === min) {
  5359. return 0;
  5360. }
  5361. var percent = (value - min) / (max - min);
  5362. var rangeMin = this.rangeMin();
  5363. var rangeMax = this.rangeMax();
  5364. return rangeMin + percent * (rangeMax - rangeMin);
  5365. };
  5366. /**
  5367. * @override
  5368. */
  5369. _proto.invert = function invert(value) {
  5370. var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
  5371. return this.min + percent * (this.max - this.min);
  5372. };
  5373. return Linear;
  5374. }(Base);
  5375. Base.Linear = Linear;
  5376. module.exports = Linear;
  5377. /***/ }),
  5378. /* 62 */
  5379. /***/ (function(module, exports, __webpack_require__) {
  5380. /**
  5381. * @fileOverview 自动计算数字坐标轴
  5382. * @author dxq613@gmail.com
  5383. */
  5384. var isNil = __webpack_require__(7);
  5385. var isNumber = __webpack_require__(13);
  5386. var AutoUtil = __webpack_require__(63);
  5387. var MIN_COUNT = 5;
  5388. var MAX_COUNT = 7;
  5389. 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];
  5390. var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
  5391. module.exports = function (info) {
  5392. var min = info.min;
  5393. var max = info.max;
  5394. var interval = info.interval;
  5395. var minTickInterval = info.minTickInterval;
  5396. var ticks = [];
  5397. var minCount = info.minCount || MIN_COUNT;
  5398. var maxCount = info.maxCount || MAX_COUNT;
  5399. var isFixedCount = minCount === maxCount; // 是否限定死了个数
  5400. var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
  5401. var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
  5402. var avgCount = (minCount + maxCount) / 2;
  5403. var count = avgCount; // 用户传入的逼近数组
  5404. var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
  5405. if (min === minLimit && max === maxLimit && isFixedCount) {
  5406. interval = (max - min) / (count - 1);
  5407. }
  5408. if (isNil(min)) {
  5409. min = 0;
  5410. }
  5411. if (isNil(max)) {
  5412. max = 0;
  5413. }
  5414. if (max === min) {
  5415. if (min === 0) {
  5416. max = 1;
  5417. } else {
  5418. if (min > 0) {
  5419. min = 0;
  5420. } else {
  5421. max = 0;
  5422. }
  5423. }
  5424. if (max - min < 5 && !interval && max - min >= 1) {
  5425. interval = 1;
  5426. }
  5427. }
  5428. if (isNil(interval)) {
  5429. // 计算间距
  5430. var temp = (max - min) / (avgCount - 1);
  5431. interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
  5432. if (maxCount !== minCount) {
  5433. count = parseInt((max - min) / interval, 10);
  5434. if (count > maxCount) {
  5435. count = maxCount;
  5436. }
  5437. if (count < minCount) {
  5438. count = minCount;
  5439. } // 不确定tick的个数时,使得tick偏小
  5440. interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
  5441. }
  5442. } // interval should not be less than minTickInterval
  5443. if (isNumber(minTickInterval) && interval < minTickInterval) {
  5444. interval = minTickInterval;
  5445. }
  5446. if (info.interval || maxCount !== minCount) {
  5447. // 校正 max 和 min
  5448. max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
  5449. min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
  5450. count = Math.round((max - min) / interval);
  5451. min = AutoUtil.fixedBase(min, interval);
  5452. max = AutoUtil.fixedBase(max, interval);
  5453. } else {
  5454. avgCount = parseInt(avgCount, 10); // 取整
  5455. var avg = (max + min) / 2;
  5456. var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
  5457. var sideCount = Math.floor((avgCount - 2) / 2);
  5458. var maxTick = avgTick + sideCount * interval;
  5459. var minTick;
  5460. if (avgCount % 2 === 0) {
  5461. minTick = avgTick - sideCount * interval;
  5462. } else {
  5463. minTick = avgTick - (sideCount + 1) * interval;
  5464. }
  5465. if (maxTick < max) {
  5466. maxTick = maxTick + interval;
  5467. }
  5468. if (minTick > min) {
  5469. minTick = minTick - interval;
  5470. }
  5471. max = AutoUtil.fixedBase(maxTick, interval);
  5472. min = AutoUtil.fixedBase(minTick, interval);
  5473. }
  5474. max = Math.min(max, maxLimit);
  5475. min = Math.max(min, minLimit);
  5476. ticks.push(min);
  5477. for (var i = 1; i < count; i++) {
  5478. var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
  5479. if (tickValue < max) {
  5480. ticks.push(tickValue);
  5481. }
  5482. }
  5483. if (ticks[ticks.length - 1] < max) {
  5484. ticks.push(max);
  5485. }
  5486. return {
  5487. min: min,
  5488. max: max,
  5489. interval: interval,
  5490. count: count,
  5491. ticks: ticks
  5492. };
  5493. };
  5494. /***/ }),
  5495. /* 63 */
  5496. /***/ (function(module, exports) {
  5497. /**
  5498. * @fileOverview 计算方法
  5499. * @author dxq613@gmail.com
  5500. */
  5501. // 如果小数点后面超过 10 位浮点数时进行一下处理
  5502. var DECIMAL_LENGTH = 12; // 获取系数
  5503. function getFactor(v) {
  5504. var factor = 1;
  5505. if (v === Infinity || v === -Infinity) {
  5506. throw new Error('Not support Infinity!');
  5507. }
  5508. if (v < 1) {
  5509. var count = 0;
  5510. while (v < 1) {
  5511. factor = factor / 10;
  5512. v = v * 10;
  5513. count++;
  5514. } // 浮点数计算出现问题
  5515. if (factor.toString().length > DECIMAL_LENGTH) {
  5516. factor = parseFloat(factor.toFixed(count));
  5517. }
  5518. } else {
  5519. while (v > 10) {
  5520. factor = factor * 10;
  5521. v = v / 10;
  5522. }
  5523. }
  5524. return factor;
  5525. } // 取小于当前值的
  5526. function arrayFloor(values, value) {
  5527. var length = values.length;
  5528. if (length === 0) {
  5529. return NaN;
  5530. }
  5531. var pre = values[0];
  5532. if (value < values[0]) {
  5533. return NaN;
  5534. }
  5535. if (value >= values[length - 1]) {
  5536. return values[length - 1];
  5537. }
  5538. for (var i = 1; i < values.length; i++) {
  5539. if (value < values[i]) {
  5540. break;
  5541. }
  5542. pre = values[i];
  5543. }
  5544. return pre;
  5545. } // 大于当前值的第一个
  5546. function arrayCeiling(values, value) {
  5547. var length = values.length;
  5548. if (length === 0) {
  5549. return NaN;
  5550. } // var pre = values[0];
  5551. var rst;
  5552. if (value > values[length - 1]) {
  5553. return NaN;
  5554. }
  5555. if (value < values[0]) {
  5556. return values[0];
  5557. }
  5558. for (var i = 1; i < values.length; i++) {
  5559. if (value <= values[i]) {
  5560. rst = values[i];
  5561. break;
  5562. }
  5563. }
  5564. return rst;
  5565. }
  5566. var Util = {
  5567. // 获取逼近的数值
  5568. snapFactorTo: function snapFactorTo(v, arr, snapType) {
  5569. // 假设 v = -512,isFloor = true
  5570. if (isNaN(v)) {
  5571. return NaN;
  5572. }
  5573. var factor = 1; // 计算系数
  5574. if (v !== 0) {
  5575. if (v < 0) {
  5576. factor = -1;
  5577. }
  5578. v = v * factor; // v = 512
  5579. var tmpFactor = getFactor(v);
  5580. factor = factor * tmpFactor; // factor = -100
  5581. v = v / tmpFactor; // v = 5.12
  5582. }
  5583. if (snapType === 'floor') {
  5584. v = Util.snapFloor(arr, v); // v = 5
  5585. } else if (snapType === 'ceil') {
  5586. v = Util.snapCeiling(arr, v); // v = 6
  5587. } else {
  5588. v = Util.snapTo(arr, v); // 四舍五入 5
  5589. }
  5590. var rst = v * factor; // 如果出现浮点数计算问题,需要处理一下
  5591. if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
  5592. var decimalVal = parseInt(1 / factor);
  5593. var symbol = factor > 0 ? 1 : -1;
  5594. rst = v / decimalVal * symbol;
  5595. }
  5596. return rst;
  5597. },
  5598. // 获取逼近的倍数
  5599. snapMultiple: function snapMultiple(v, base, snapType) {
  5600. var div;
  5601. if (snapType === 'ceil') {
  5602. div = Math.ceil(v / base);
  5603. } else if (snapType === 'floor') {
  5604. div = Math.floor(v / base);
  5605. } else {
  5606. div = Math.round(v / base);
  5607. }
  5608. return div * base;
  5609. },
  5610. /**
  5611. * 获取逼近的值,用于对齐数据
  5612. * @param {Array} values 数据集合
  5613. * @param {Number} value 数值
  5614. * @return {Number} 逼近的值
  5615. */
  5616. snapTo: function snapTo(values, value) {
  5617. // 这里假定values是升序排列
  5618. var floorVal = arrayFloor(values, value);
  5619. var ceilingVal = arrayCeiling(values, value);
  5620. if (isNaN(floorVal) || isNaN(ceilingVal)) {
  5621. if (values[0] >= value) {
  5622. return values[0];
  5623. }
  5624. var last = values[values.length - 1];
  5625. if (last <= value) {
  5626. return last;
  5627. }
  5628. }
  5629. if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
  5630. return floorVal;
  5631. }
  5632. return ceilingVal;
  5633. },
  5634. /**
  5635. * 获取逼近的最小值,用于对齐数据
  5636. * @param {Array} values 数据集合
  5637. * @param {Number} value 数值
  5638. * @return {Number} 逼近的最小值
  5639. */
  5640. snapFloor: function snapFloor(values, value) {
  5641. // 这里假定values是升序排列
  5642. return arrayFloor(values, value);
  5643. },
  5644. /**
  5645. * 获取逼近的最大值,用于对齐数据
  5646. * @param {Array} values 数据集合
  5647. * @param {Number} value 数值
  5648. * @return {Number} 逼近的最大值
  5649. */
  5650. snapCeiling: function snapCeiling(values, value) {
  5651. // 这里假定values是升序排列
  5652. return arrayCeiling(values, value);
  5653. },
  5654. fixedBase: function fixedBase(v, base) {
  5655. var str = base.toString();
  5656. var index = str.indexOf('.');
  5657. if (index === -1) {
  5658. return Math.round(v);
  5659. }
  5660. var length = str.substr(index + 1).length;
  5661. if (length > 20) {
  5662. length = 20;
  5663. }
  5664. return parseFloat(v.toFixed(length));
  5665. }
  5666. };
  5667. module.exports = Util;
  5668. /***/ }),
  5669. /* 64 */
  5670. /***/ (function(module, exports, __webpack_require__) {
  5671. function _inheritsLoose(subClass, superClass) {
  5672. subClass.prototype = Object.create(superClass.prototype);
  5673. subClass.prototype.constructor = subClass;
  5674. subClass.__proto__ = superClass;
  5675. }
  5676. var Base = __webpack_require__(14);
  5677. var isNumber = __webpack_require__(13);
  5678. var Identity =
  5679. /*#__PURE__*/
  5680. function (_Base) {
  5681. _inheritsLoose(Identity, _Base);
  5682. function Identity() {
  5683. return _Base.apply(this, arguments) || this;
  5684. }
  5685. var _proto = Identity.prototype;
  5686. _proto._initDefaultCfg = function _initDefaultCfg() {
  5687. _Base.prototype._initDefaultCfg.call(this);
  5688. this.isIdentity = true;
  5689. this.type = 'identity';
  5690. /**
  5691. * 常量值
  5692. * @type {*}
  5693. */
  5694. this.value = null;
  5695. };
  5696. /**
  5697. * @override
  5698. */
  5699. _proto.getText = function getText() {
  5700. return this.value.toString();
  5701. };
  5702. /**
  5703. * @override
  5704. */
  5705. _proto.scale = function scale(value) {
  5706. if (this.value !== value && isNumber(value)) {
  5707. return value;
  5708. }
  5709. return this.range[0];
  5710. };
  5711. /**
  5712. * @override
  5713. */
  5714. _proto.invert = function invert() {
  5715. return this.value;
  5716. };
  5717. return Identity;
  5718. }(Base);
  5719. Base.Identity = Identity;
  5720. module.exports = Identity;
  5721. /***/ }),
  5722. /* 65 */
  5723. /***/ (function(module, exports, __webpack_require__) {
  5724. var Util = __webpack_require__(0);
  5725. var Axis = __webpack_require__(66);
  5726. var Global = __webpack_require__(1);
  5727. var _require = __webpack_require__(5),
  5728. Shape = _require.Shape;
  5729. function formatTicks(ticks) {
  5730. var tmp = ticks.slice(0);
  5731. if (tmp.length > 0) {
  5732. var first = tmp[0];
  5733. var last = tmp[tmp.length - 1];
  5734. if (first.value !== 0) {
  5735. tmp.unshift({
  5736. value: 0
  5737. });
  5738. }
  5739. if (last.value !== 1) {
  5740. tmp.push({
  5741. value: 1
  5742. });
  5743. }
  5744. }
  5745. return tmp;
  5746. }
  5747. var AxisController =
  5748. /*#__PURE__*/
  5749. function () {
  5750. function AxisController(cfg) {
  5751. this.axisCfg = {};
  5752. this.frontPlot = null;
  5753. this.backPlot = null;
  5754. this.axes = {}; // store the axes's options
  5755. Util.mix(this, cfg);
  5756. }
  5757. var _proto = AxisController.prototype;
  5758. _proto._isHide = function _isHide(field) {
  5759. var axisCfg = this.axisCfg;
  5760. return !axisCfg || axisCfg[field] === false;
  5761. };
  5762. _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
  5763. var position = '';
  5764. var field = scale.field;
  5765. var axisCfg = this.axisCfg;
  5766. if (axisCfg[field] && axisCfg[field].position) {
  5767. position = axisCfg[field].position;
  5768. } else if (dimType === 'x') {
  5769. position = transposed ? 'left' : 'bottom';
  5770. } else if (dimType === 'y') {
  5771. position = index ? 'right' : 'left';
  5772. if (transposed) {
  5773. position = 'bottom';
  5774. }
  5775. }
  5776. return position;
  5777. };
  5778. _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
  5779. var start;
  5780. var end;
  5781. var factor = 1; // Mark clockwise or counterclockwise
  5782. if (dimType === 'x') {
  5783. start = {
  5784. x: 0,
  5785. y: 0
  5786. };
  5787. end = {
  5788. x: 1,
  5789. y: 0
  5790. };
  5791. } else {
  5792. if (position === 'right') {
  5793. // there will be several y axes
  5794. start = {
  5795. x: 1,
  5796. y: 0
  5797. };
  5798. end = {
  5799. x: 1,
  5800. y: 1
  5801. };
  5802. } else {
  5803. start = {
  5804. x: 0,
  5805. y: 0
  5806. };
  5807. end = {
  5808. x: 0,
  5809. y: 1
  5810. };
  5811. factor = -1;
  5812. }
  5813. }
  5814. if (coord.transposed) {
  5815. factor *= -1;
  5816. }
  5817. return {
  5818. offsetFactor: factor,
  5819. start: coord.convertPoint(start),
  5820. end: coord.convertPoint(end)
  5821. };
  5822. };
  5823. _proto._getCircleCfg = function _getCircleCfg(coord) {
  5824. return {
  5825. startAngle: coord.startAngle,
  5826. endAngle: coord.endAngle,
  5827. center: coord.center,
  5828. radius: coord.circleRadius
  5829. };
  5830. };
  5831. _proto._getRadiusCfg = function _getRadiusCfg(coord) {
  5832. var transposed = coord.transposed;
  5833. var start;
  5834. var end;
  5835. if (transposed) {
  5836. start = {
  5837. x: 0,
  5838. y: 0
  5839. };
  5840. end = {
  5841. x: 1,
  5842. y: 0
  5843. };
  5844. } else {
  5845. start = {
  5846. x: 0,
  5847. y: 0
  5848. };
  5849. end = {
  5850. x: 0,
  5851. y: 1
  5852. };
  5853. }
  5854. return {
  5855. offsetFactor: -1,
  5856. start: coord.convertPoint(start),
  5857. end: coord.convertPoint(end)
  5858. };
  5859. };
  5860. _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
  5861. var self = this;
  5862. var axisCfg = this.axisCfg;
  5863. var ticks = scale.getTicks();
  5864. var cfg = Util.deepMix({
  5865. ticks: ticks,
  5866. frontContainer: this.frontPlot,
  5867. backContainer: this.backPlot
  5868. }, defaultCfg, axisCfg[scale.field]);
  5869. var labels = [];
  5870. var label = cfg.label;
  5871. var count = ticks.length;
  5872. var maxWidth = 0;
  5873. var maxHeight = 0;
  5874. var labelCfg = label;
  5875. Util.each(ticks, function (tick, index) {
  5876. if (Util.isFunction(label)) {
  5877. var executedLabel = label(tick.text, index, count);
  5878. labelCfg = executedLabel ? Util.mix({}, Global._defaultAxis.label, executedLabel) : null;
  5879. }
  5880. if (labelCfg) {
  5881. var textStyle = {};
  5882. if (labelCfg.textAlign) {
  5883. textStyle.textAlign = labelCfg.textAlign;
  5884. }
  5885. if (labelCfg.textBaseline) {
  5886. textStyle.textBaseline = labelCfg.textBaseline;
  5887. }
  5888. var axisLabel = new Shape.Text({
  5889. className: 'axis-label',
  5890. attrs: Util.mix({
  5891. x: 0,
  5892. y: 0,
  5893. text: tick.text,
  5894. fontFamily: self.chart.get('canvas').get('fontFamily')
  5895. }, labelCfg),
  5896. value: tick.value,
  5897. textStyle: textStyle,
  5898. top: labelCfg.top,
  5899. context: self.chart.get('canvas').get('context')
  5900. });
  5901. labels.push(axisLabel);
  5902. var _axisLabel$getBBox = axisLabel.getBBox(),
  5903. width = _axisLabel$getBBox.width,
  5904. height = _axisLabel$getBBox.height;
  5905. maxWidth = Math.max(maxWidth, width);
  5906. maxHeight = Math.max(maxHeight, height);
  5907. }
  5908. });
  5909. cfg.labels = labels;
  5910. cfg.maxWidth = maxWidth;
  5911. cfg.maxHeight = maxHeight;
  5912. return cfg;
  5913. };
  5914. _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
  5915. if (index === void 0) {
  5916. index = '';
  5917. }
  5918. var self = this;
  5919. var coordType = coord.type;
  5920. var transposed = coord.transposed;
  5921. var type;
  5922. var key;
  5923. var defaultCfg;
  5924. if (coordType === 'cartesian' || coordType === 'rect') {
  5925. var position = self._getLinePosition(scale, dimType, index, transposed);
  5926. defaultCfg = Global.axis[position];
  5927. defaultCfg.position = position;
  5928. type = 'Line';
  5929. key = position;
  5930. } else {
  5931. if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
  5932. defaultCfg = Global.axis.circle;
  5933. type = 'Circle';
  5934. key = 'circle';
  5935. } else {
  5936. defaultCfg = Global.axis.radius;
  5937. type = 'Line';
  5938. key = 'radius';
  5939. }
  5940. }
  5941. var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
  5942. cfg.type = type;
  5943. cfg.dimType = dimType;
  5944. cfg.verticalScale = verticalScale;
  5945. cfg.index = index;
  5946. this.axes[key] = cfg;
  5947. };
  5948. _proto.createAxis = function createAxis(coord, xScale, yScales) {
  5949. var self = this;
  5950. if (xScale && !self._isHide(xScale.field)) {
  5951. self._createAxis(coord, xScale, yScales[0], 'x');
  5952. }
  5953. Util.each(yScales, function (yScale, index) {
  5954. if (!self._isHide(yScale.field)) {
  5955. self._createAxis(coord, yScale, xScale, 'y', index);
  5956. }
  5957. });
  5958. var axes = this.axes;
  5959. var chart = self.chart;
  5960. if (chart._isAutoPadding()) {
  5961. var userPadding = Util.parsePadding(chart.get('padding'));
  5962. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  5963. var legendRange = chart.get('legendRange') || {
  5964. top: 0,
  5965. right: 0,
  5966. bottom: 0,
  5967. left: 0
  5968. };
  5969. 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]];
  5970. if (coord.isPolar) {
  5971. var circleAxis = axes.circle;
  5972. if (circleAxis) {
  5973. var maxHeight = circleAxis.maxHeight,
  5974. maxWidth = circleAxis.maxWidth,
  5975. labelOffset = circleAxis.labelOffset;
  5976. padding[0] += maxHeight + labelOffset;
  5977. padding[1] += maxWidth + labelOffset;
  5978. padding[2] += maxHeight + labelOffset;
  5979. padding[3] += maxWidth + labelOffset;
  5980. }
  5981. } else {
  5982. if (axes.right && userPadding[1] === 'auto') {
  5983. var _axes$right = axes.right,
  5984. _maxWidth = _axes$right.maxWidth,
  5985. _labelOffset = _axes$right.labelOffset;
  5986. padding[1] += _maxWidth + _labelOffset;
  5987. }
  5988. if (axes.left && userPadding[3] === 'auto') {
  5989. var _axes$left = axes.left,
  5990. _maxWidth2 = _axes$left.maxWidth,
  5991. _labelOffset2 = _axes$left.labelOffset;
  5992. padding[3] += _maxWidth2 + _labelOffset2;
  5993. }
  5994. if (axes.bottom && userPadding[2] === 'auto') {
  5995. var _axes$bottom = axes.bottom,
  5996. _maxHeight = _axes$bottom.maxHeight,
  5997. _labelOffset3 = _axes$bottom.labelOffset;
  5998. padding[2] += _maxHeight + _labelOffset3;
  5999. }
  6000. }
  6001. chart.set('_padding', padding);
  6002. chart._updateLayout(padding);
  6003. }
  6004. Util.each(axes, function (axis) {
  6005. var type = axis.type,
  6006. grid = axis.grid,
  6007. verticalScale = axis.verticalScale,
  6008. ticks = axis.ticks,
  6009. dimType = axis.dimType,
  6010. position = axis.position,
  6011. index = axis.index;
  6012. var appendCfg;
  6013. if (coord.isPolar) {
  6014. if (type === 'Line') {
  6015. appendCfg = self._getRadiusCfg(coord);
  6016. } else if (type === 'Circle') {
  6017. appendCfg = self._getCircleCfg(coord);
  6018. }
  6019. } else {
  6020. appendCfg = self._getLineCfg(coord, dimType, position);
  6021. }
  6022. if (grid && verticalScale) {
  6023. var gridPoints = [];
  6024. var verticalTicks = formatTicks(verticalScale.getTicks());
  6025. Util.each(ticks, function (tick) {
  6026. var subPoints = [];
  6027. Util.each(verticalTicks, function (verticalTick) {
  6028. var x = dimType === 'x' ? tick.value : verticalTick.value;
  6029. var y = dimType === 'x' ? verticalTick.value : tick.value;
  6030. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  6031. var point = coord.convertPoint({
  6032. x: x,
  6033. y: y
  6034. });
  6035. subPoints.push(point);
  6036. }
  6037. });
  6038. gridPoints.push({
  6039. points: subPoints,
  6040. _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
  6041. });
  6042. });
  6043. axis.gridPoints = gridPoints;
  6044. if (coord.isPolar) {
  6045. axis.center = coord.center;
  6046. axis.startAngle = coord.startAngle;
  6047. axis.endAngle = coord.endAngle;
  6048. }
  6049. }
  6050. appendCfg._id = 'axis-' + dimType;
  6051. if (!Util.isNil(index)) {
  6052. appendCfg._id = 'axis-' + dimType + index;
  6053. }
  6054. new Axis[type](Util.mix(axis, appendCfg));
  6055. });
  6056. };
  6057. _proto.clear = function clear() {
  6058. this.axes = {};
  6059. this.frontPlot.clear();
  6060. this.backPlot.clear();
  6061. };
  6062. return AxisController;
  6063. }();
  6064. module.exports = AxisController;
  6065. /***/ }),
  6066. /* 66 */
  6067. /***/ (function(module, exports, __webpack_require__) {
  6068. var Abstract = __webpack_require__(24);
  6069. __webpack_require__(67);
  6070. module.exports = Abstract;
  6071. /***/ }),
  6072. /* 67 */
  6073. /***/ (function(module, exports, __webpack_require__) {
  6074. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6075. var Util = __webpack_require__(0);
  6076. var Abstract = __webpack_require__(24);
  6077. var Line =
  6078. /*#__PURE__*/
  6079. function (_Abstract) {
  6080. _inheritsLoose(Line, _Abstract);
  6081. function Line() {
  6082. return _Abstract.apply(this, arguments) || this;
  6083. }
  6084. var _proto = Line.prototype;
  6085. _proto._initDefaultCfg = function _initDefaultCfg() {
  6086. _Abstract.prototype._initDefaultCfg.call(this);
  6087. this.start = null;
  6088. this.end = null;
  6089. };
  6090. _proto.getOffsetPoint = function getOffsetPoint(value) {
  6091. var start = this.start,
  6092. end = this.end;
  6093. return {
  6094. x: start.x + (end.x - start.x) * value,
  6095. y: start.y + (end.y - start.y) * value
  6096. };
  6097. };
  6098. _proto.getAxisVector = function getAxisVector() {
  6099. var start = this.start,
  6100. end = this.end;
  6101. return [end.x - start.x, end.y - start.y];
  6102. };
  6103. _proto.drawLine = function drawLine(lineCfg) {
  6104. var container = this.getContainer(lineCfg.top);
  6105. var start = this.start,
  6106. end = this.end;
  6107. container.addShape('line', {
  6108. className: 'axis-line',
  6109. attrs: Util.mix({
  6110. x1: start.x,
  6111. y1: start.y,
  6112. x2: end.x,
  6113. y2: end.y
  6114. }, lineCfg)
  6115. });
  6116. };
  6117. return Line;
  6118. }(Abstract);
  6119. Abstract.Line = Line;
  6120. module.exports = Line;
  6121. /***/ }),
  6122. /* 68 */
  6123. /***/ (function(module, exports, __webpack_require__) {
  6124. var Util = __webpack_require__(0);
  6125. var Container = __webpack_require__(30);
  6126. var Group = __webpack_require__(31);
  6127. var _require = __webpack_require__(36),
  6128. requestAnimationFrame = _require.requestAnimationFrame;
  6129. var Canvas =
  6130. /*#__PURE__*/
  6131. function () {
  6132. var _proto = Canvas.prototype;
  6133. _proto.get = function get(name) {
  6134. return this._attrs[name];
  6135. };
  6136. _proto.set = function set(name, value) {
  6137. this._attrs[name] = value;
  6138. };
  6139. function Canvas(cfg) {
  6140. this._attrs = Util.mix({
  6141. type: 'canvas',
  6142. children: []
  6143. }, cfg);
  6144. this._initPixelRatio();
  6145. this._initCanvas();
  6146. }
  6147. _proto._initPixelRatio = function _initPixelRatio() {
  6148. var pixelRatio = this.get('pixelRatio');
  6149. if (!pixelRatio) {
  6150. this.set('pixelRatio', Util.getPixelRatio());
  6151. }
  6152. };
  6153. _proto.beforeDraw = function beforeDraw() {
  6154. var context = this._attrs.context;
  6155. var el = this._attrs.el;
  6156. !Util.isWx && !Util.isMy && context && context.clearRect(0, 0, el.width, el.height);
  6157. };
  6158. _proto._initCanvas = function _initCanvas() {
  6159. var self = this;
  6160. var el = self.get('el');
  6161. var context = self.get('context');
  6162. var canvas;
  6163. if (context) {
  6164. // CanvasRenderingContext2D
  6165. canvas = context.canvas;
  6166. } else if (Util.isString(el)) {
  6167. // HTMLElement's id
  6168. canvas = Util.getDomById(el);
  6169. } else {
  6170. // HTMLElement
  6171. canvas = el;
  6172. }
  6173. if (!canvas) {
  6174. throw new Error('Please specify the id or el of the chart!');
  6175. }
  6176. if (context && canvas && !canvas.getContext) {
  6177. canvas.getContext = function () {
  6178. return context;
  6179. };
  6180. }
  6181. var width = self.get('width');
  6182. if (!width) {
  6183. width = Util.getWidth(canvas);
  6184. }
  6185. var height = self.get('height');
  6186. if (!height) {
  6187. height = Util.getHeight(canvas);
  6188. }
  6189. self.set('canvas', this);
  6190. self.set('el', canvas);
  6191. self.set('context', context || canvas.getContext('2d'));
  6192. self.changeSize(width, height);
  6193. };
  6194. _proto.changeSize = function changeSize(width, height) {
  6195. var pixelRatio = this.get('pixelRatio');
  6196. var canvasDOM = this.get('el');
  6197. if (Util.isBrowser) {
  6198. canvasDOM.style.width = width + 'px';
  6199. canvasDOM.style.height = height + 'px';
  6200. }
  6201. if (!Util.isWx && !Util.isMy) {
  6202. canvasDOM.width = width * pixelRatio;
  6203. canvasDOM.height = height * pixelRatio;
  6204. if (pixelRatio !== 1) {
  6205. var ctx = this.get('context');
  6206. ctx.scale(pixelRatio, pixelRatio);
  6207. }
  6208. }
  6209. this.set('width', width);
  6210. this.set('height', height);
  6211. };
  6212. _proto.getWidth = function getWidth() {
  6213. var pixelRatio = this.get('pixelRatio');
  6214. var width = this.get('width');
  6215. return width * pixelRatio;
  6216. };
  6217. _proto.getHeight = function getHeight() {
  6218. var pixelRatio = this.get('pixelRatio');
  6219. var height = this.get('height');
  6220. return height * pixelRatio;
  6221. };
  6222. _proto.getPointByClient = function getPointByClient(clientX, clientY) {
  6223. var el = this.get('el');
  6224. var bbox = el.getBoundingClientRect();
  6225. var width = bbox.right - bbox.left;
  6226. var height = bbox.bottom - bbox.top;
  6227. return {
  6228. x: (clientX - bbox.left) * (el.width / width),
  6229. y: (clientY - bbox.top) * (el.height / height)
  6230. };
  6231. };
  6232. _proto._beginDraw = function _beginDraw() {
  6233. this._attrs.toDraw = true;
  6234. };
  6235. _proto._endDraw = function _endDraw() {
  6236. this._attrs.toDraw = false;
  6237. };
  6238. _proto.draw = function draw() {
  6239. var self = this;
  6240. function drawInner() {
  6241. self.set('animateHandler', requestAnimationFrame(function () {
  6242. self.set('animateHandler', undefined);
  6243. if (self.get('toDraw')) {
  6244. drawInner();
  6245. }
  6246. }));
  6247. self.beforeDraw();
  6248. try {
  6249. var context = self._attrs.context;
  6250. var children = self._attrs.children;
  6251. for (var i = 0, len = children.length; i < len; i++) {
  6252. var child = children[i];
  6253. child.draw(context);
  6254. }
  6255. if (Util.isWx || Util.isMy) {
  6256. context.draw();
  6257. }
  6258. } catch (ev) {
  6259. console.warn('error in draw canvas, detail as:');
  6260. console.warn(ev);
  6261. self._endDraw();
  6262. }
  6263. self._endDraw();
  6264. }
  6265. if (self.get('destroyed')) {
  6266. return;
  6267. }
  6268. if (self.get('animateHandler')) {
  6269. this._beginDraw();
  6270. } else {
  6271. drawInner();
  6272. }
  6273. };
  6274. _proto.destroy = function destroy() {
  6275. if (this.get('destroyed')) {
  6276. return;
  6277. }
  6278. this.clear();
  6279. this._attrs = {};
  6280. this.set('destroyed', true);
  6281. };
  6282. _proto.isDestroyed = function isDestroyed() {
  6283. return this.get('destroyed');
  6284. };
  6285. return Canvas;
  6286. }();
  6287. Util.mix(Canvas.prototype, Container, {
  6288. getGroupClass: function getGroupClass() {
  6289. return Group;
  6290. }
  6291. });
  6292. module.exports = Canvas;
  6293. /***/ }),
  6294. /* 69 */
  6295. /***/ (function(module, exports, __webpack_require__) {
  6296. var Util = __webpack_require__(0);
  6297. function _mod(n, m) {
  6298. return (n % m + m) % m;
  6299. }
  6300. function _addStop(steps, gradient) {
  6301. Util.each(steps, function (item) {
  6302. item = item.split(':');
  6303. gradient.addColorStop(Number(item[0]), item[1]);
  6304. });
  6305. } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
  6306. function _parseLineGradient(color, shape, context) {
  6307. var arr = color.split(' ');
  6308. var angle = arr[0].slice(2, arr[0].length - 1);
  6309. angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
  6310. var steps = arr.slice(1);
  6311. var _shape$getBBox = shape.getBBox(),
  6312. minX = _shape$getBBox.minX,
  6313. minY = _shape$getBBox.minY,
  6314. maxX = _shape$getBBox.maxX,
  6315. maxY = _shape$getBBox.maxY;
  6316. var start;
  6317. var end;
  6318. if (angle >= 0 && angle < 0.5 * Math.PI) {
  6319. start = {
  6320. x: minX,
  6321. y: minY
  6322. };
  6323. end = {
  6324. x: maxX,
  6325. y: maxY
  6326. };
  6327. } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
  6328. start = {
  6329. x: maxX,
  6330. y: minY
  6331. };
  6332. end = {
  6333. x: minX,
  6334. y: maxY
  6335. };
  6336. } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
  6337. start = {
  6338. x: maxX,
  6339. y: maxY
  6340. };
  6341. end = {
  6342. x: minX,
  6343. y: minY
  6344. };
  6345. } else {
  6346. start = {
  6347. x: minX,
  6348. y: maxY
  6349. };
  6350. end = {
  6351. x: maxX,
  6352. y: minY
  6353. };
  6354. }
  6355. var tanTheta = Math.tan(angle);
  6356. var tanTheta2 = tanTheta * tanTheta;
  6357. var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
  6358. var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
  6359. var gradient = context.createLinearGradient(start.x, start.y, x, y);
  6360. _addStop(steps, gradient);
  6361. return gradient;
  6362. } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
  6363. function _parseRadialGradient(color, shape, context) {
  6364. var arr = color.split(' ');
  6365. var circleCfg = arr[0].slice(2, arr[0].length - 1);
  6366. circleCfg = circleCfg.split(',');
  6367. var fx = parseFloat(circleCfg[0]);
  6368. var fy = parseFloat(circleCfg[1]);
  6369. var fr = parseFloat(circleCfg[2]);
  6370. var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
  6371. if (fr === 0) {
  6372. var _color = steps[steps.length - 1];
  6373. return _color.split(':')[1];
  6374. }
  6375. var _shape$getBBox2 = shape.getBBox(),
  6376. width = _shape$getBBox2.width,
  6377. height = _shape$getBBox2.height,
  6378. minX = _shape$getBBox2.minX,
  6379. minY = _shape$getBBox2.minY;
  6380. var r = Math.sqrt(width * width + height * height) / 2;
  6381. var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
  6382. _addStop(steps, gradient);
  6383. return gradient;
  6384. }
  6385. module.exports = {
  6386. parseStyle: function parseStyle(color, shape, context) {
  6387. if (color[1] === '(') {
  6388. try {
  6389. var firstCode = color[0];
  6390. if (firstCode === 'l') {
  6391. return _parseLineGradient(color, shape, context);
  6392. } else if (firstCode === 'r') {
  6393. return _parseRadialGradient(color, shape, context);
  6394. }
  6395. } catch (ev) {
  6396. console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
  6397. console.error(ev);
  6398. }
  6399. }
  6400. return color;
  6401. }
  6402. };
  6403. /***/ }),
  6404. /* 70 */
  6405. /***/ (function(module, exports, __webpack_require__) {
  6406. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6407. var Util = __webpack_require__(0);
  6408. var Shape = __webpack_require__(2);
  6409. var Rect =
  6410. /*#__PURE__*/
  6411. function (_Shape) {
  6412. _inheritsLoose(Rect, _Shape);
  6413. function Rect() {
  6414. return _Shape.apply(this, arguments) || this;
  6415. }
  6416. var _proto = Rect.prototype;
  6417. _proto._initProperties = function _initProperties() {
  6418. _Shape.prototype._initProperties.call(this);
  6419. this._attrs.canFill = true;
  6420. this._attrs.canStroke = true;
  6421. this._attrs.type = 'rect';
  6422. };
  6423. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6424. return {
  6425. x: 0,
  6426. y: 0,
  6427. width: 0,
  6428. height: 0,
  6429. radius: 0,
  6430. lineWidth: 0
  6431. };
  6432. };
  6433. _proto.createPath = function createPath(context) {
  6434. var self = this;
  6435. var attrs = self.get('attrs');
  6436. var x = attrs.x,
  6437. y = attrs.y,
  6438. width = attrs.width,
  6439. height = attrs.height;
  6440. context.beginPath();
  6441. var radius = attrs.radius;
  6442. if (!radius || !(width * height)) {
  6443. context.rect(x, y, width, height);
  6444. } else {
  6445. radius = Util.parsePadding(radius);
  6446. context.moveTo(x + radius[0], y);
  6447. context.lineTo(x + width - radius[1], y);
  6448. context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
  6449. context.lineTo(x + width, y + height - radius[2]);
  6450. context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
  6451. context.lineTo(x + radius[3], y + height);
  6452. context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
  6453. context.lineTo(x, y + radius[0]);
  6454. context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
  6455. context.closePath();
  6456. }
  6457. };
  6458. _proto.calculateBox = function calculateBox() {
  6459. var attrs = this.get('attrs');
  6460. var x = attrs.x,
  6461. y = attrs.y,
  6462. width = attrs.width,
  6463. height = attrs.height;
  6464. return {
  6465. minX: x,
  6466. minY: y,
  6467. maxX: x + width,
  6468. maxY: y + height
  6469. };
  6470. };
  6471. return Rect;
  6472. }(Shape);
  6473. Shape.Rect = Rect;
  6474. module.exports = Rect;
  6475. /***/ }),
  6476. /* 71 */
  6477. /***/ (function(module, exports, __webpack_require__) {
  6478. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6479. var Shape = __webpack_require__(2);
  6480. var Circle =
  6481. /*#__PURE__*/
  6482. function (_Shape) {
  6483. _inheritsLoose(Circle, _Shape);
  6484. function Circle() {
  6485. return _Shape.apply(this, arguments) || this;
  6486. }
  6487. var _proto = Circle.prototype;
  6488. _proto._initProperties = function _initProperties() {
  6489. _Shape.prototype._initProperties.call(this);
  6490. this._attrs.canFill = true;
  6491. this._attrs.canStroke = true;
  6492. this._attrs.type = 'circle';
  6493. };
  6494. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6495. return {
  6496. x: 0,
  6497. y: 0,
  6498. r: 0,
  6499. lineWidth: 0
  6500. };
  6501. };
  6502. _proto.createPath = function createPath(context) {
  6503. var attrs = this.get('attrs');
  6504. var x = attrs.x,
  6505. y = attrs.y,
  6506. r = attrs.r;
  6507. context.beginPath();
  6508. context.arc(x, y, r, 0, Math.PI * 2, false);
  6509. context.closePath();
  6510. };
  6511. _proto.calculateBox = function calculateBox() {
  6512. var attrs = this.get('attrs');
  6513. var x = attrs.x,
  6514. y = attrs.y,
  6515. r = attrs.r;
  6516. return {
  6517. minX: x - r,
  6518. maxX: x + r,
  6519. minY: y - r,
  6520. maxY: y + r
  6521. };
  6522. };
  6523. return Circle;
  6524. }(Shape);
  6525. Shape.Circle = Circle;
  6526. module.exports = Circle;
  6527. /***/ }),
  6528. /* 72 */
  6529. /***/ (function(module, exports, __webpack_require__) {
  6530. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6531. var Shape = __webpack_require__(2);
  6532. var bbox = __webpack_require__(11);
  6533. var Line =
  6534. /*#__PURE__*/
  6535. function (_Shape) {
  6536. _inheritsLoose(Line, _Shape);
  6537. function Line() {
  6538. return _Shape.apply(this, arguments) || this;
  6539. }
  6540. var _proto = Line.prototype;
  6541. _proto._initProperties = function _initProperties() {
  6542. _Shape.prototype._initProperties.call(this);
  6543. this._attrs.canStroke = true;
  6544. this._attrs.type = 'line';
  6545. };
  6546. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6547. return {
  6548. x1: 0,
  6549. y1: 0,
  6550. x2: 0,
  6551. y2: 0,
  6552. lineWidth: 1
  6553. };
  6554. };
  6555. _proto.createPath = function createPath(context) {
  6556. var attrs = this.get('attrs');
  6557. var x1 = attrs.x1,
  6558. y1 = attrs.y1,
  6559. x2 = attrs.x2,
  6560. y2 = attrs.y2;
  6561. context.beginPath();
  6562. context.moveTo(x1, y1);
  6563. context.lineTo(x2, y2);
  6564. };
  6565. _proto.calculateBox = function calculateBox() {
  6566. var attrs = this.get('attrs');
  6567. var x1 = attrs.x1,
  6568. y1 = attrs.y1,
  6569. x2 = attrs.x2,
  6570. y2 = attrs.y2,
  6571. lineWidth = attrs.lineWidth;
  6572. return bbox.getBBoxFromLine(x1, y1, x2, y2, lineWidth);
  6573. };
  6574. return Line;
  6575. }(Shape);
  6576. Shape.Line = Line;
  6577. module.exports = Line;
  6578. /***/ }),
  6579. /* 73 */
  6580. /***/ (function(module, exports, __webpack_require__) {
  6581. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6582. var Shape = __webpack_require__(2);
  6583. var bbox = __webpack_require__(11);
  6584. var Polygon =
  6585. /*#__PURE__*/
  6586. function (_Shape) {
  6587. _inheritsLoose(Polygon, _Shape);
  6588. function Polygon() {
  6589. return _Shape.apply(this, arguments) || this;
  6590. }
  6591. var _proto = Polygon.prototype;
  6592. _proto._initProperties = function _initProperties() {
  6593. _Shape.prototype._initProperties.call(this);
  6594. this._attrs.canFill = true;
  6595. this._attrs.canStroke = true;
  6596. this._attrs.type = 'polygon';
  6597. };
  6598. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6599. return {
  6600. points: null,
  6601. lineWidth: 0
  6602. };
  6603. };
  6604. _proto.createPath = function createPath(context) {
  6605. var self = this;
  6606. var attrs = self.get('attrs');
  6607. var points = attrs.points;
  6608. context.beginPath();
  6609. for (var i = 0, len = points.length; i < len; i++) {
  6610. var point = points[i];
  6611. if (i === 0) {
  6612. context.moveTo(point.x, point.y);
  6613. } else {
  6614. context.lineTo(point.x, point.y);
  6615. }
  6616. }
  6617. context.closePath();
  6618. };
  6619. _proto.calculateBox = function calculateBox() {
  6620. var attrs = this.get('attrs');
  6621. var points = attrs.points;
  6622. return bbox.getBBoxFromPoints(points);
  6623. };
  6624. return Polygon;
  6625. }(Shape);
  6626. Shape.Polygon = Polygon;
  6627. module.exports = Polygon;
  6628. /***/ }),
  6629. /* 74 */
  6630. /***/ (function(module, exports, __webpack_require__) {
  6631. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6632. var Shape = __webpack_require__(2);
  6633. var Smooth = __webpack_require__(37);
  6634. var bbox = __webpack_require__(11);
  6635. var Polyline =
  6636. /*#__PURE__*/
  6637. function (_Shape) {
  6638. _inheritsLoose(Polyline, _Shape);
  6639. function Polyline() {
  6640. return _Shape.apply(this, arguments) || this;
  6641. }
  6642. var _proto = Polyline.prototype;
  6643. _proto._initProperties = function _initProperties() {
  6644. _Shape.prototype._initProperties.call(this);
  6645. this._attrs.canFill = true;
  6646. this._attrs.canStroke = true;
  6647. this._attrs.type = 'polyline';
  6648. };
  6649. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6650. return {
  6651. points: null,
  6652. lineWidth: 1,
  6653. smooth: false
  6654. };
  6655. };
  6656. _proto.createPath = function createPath(context) {
  6657. var self = this;
  6658. var attrs = self.get('attrs');
  6659. var points = attrs.points,
  6660. smooth = attrs.smooth;
  6661. var filteredPoints = []; // filter the point which x or y is NaN
  6662. for (var i = 0, len = points.length; i < len; i++) {
  6663. var point = points[i];
  6664. if (!isNaN(point.x) && !isNaN(point.y)) {
  6665. filteredPoints.push(point);
  6666. }
  6667. }
  6668. context.beginPath();
  6669. if (filteredPoints.length) {
  6670. context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
  6671. if (smooth) {
  6672. var constaint = [[0, 0], [1, 1]];
  6673. var sps = Smooth.smooth(filteredPoints, false, constaint);
  6674. for (var _i = 0, n = sps.length; _i < n; _i++) {
  6675. var sp = sps[_i];
  6676. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  6677. }
  6678. } else {
  6679. var _i2;
  6680. var l;
  6681. for (_i2 = 1, l = filteredPoints.length - 1; _i2 < l; _i2++) {
  6682. context.lineTo(filteredPoints[_i2].x, filteredPoints[_i2].y);
  6683. }
  6684. context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
  6685. }
  6686. }
  6687. };
  6688. _proto.calculateBox = function calculateBox() {
  6689. var attrs = this.get('attrs');
  6690. var points = attrs.points,
  6691. smooth = attrs.smooth,
  6692. lineWidth = attrs.lineWidth;
  6693. if (smooth) {
  6694. var newPoints = [];
  6695. var constaint = [[0, 0], [1, 1]];
  6696. var sps = Smooth.smooth(points, false, constaint);
  6697. for (var i = 0, n = sps.length; i < n; i++) {
  6698. var sp = sps[i];
  6699. if (i === 0) {
  6700. newPoints.push([points[0].x, points[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6701. } else {
  6702. var lastPoint = sps[i - 1];
  6703. newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6704. }
  6705. }
  6706. return bbox.getBBoxFromBezierGroup(newPoints, lineWidth);
  6707. }
  6708. return bbox.getBBoxFromPoints(points, lineWidth);
  6709. };
  6710. return Polyline;
  6711. }(Shape);
  6712. Shape.Polyline = Polyline;
  6713. module.exports = Polyline;
  6714. /***/ }),
  6715. /* 75 */
  6716. /***/ (function(module, exports, __webpack_require__) {
  6717. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6718. var Shape = __webpack_require__(2);
  6719. var bbox = __webpack_require__(11);
  6720. var Arc =
  6721. /*#__PURE__*/
  6722. function (_Shape) {
  6723. _inheritsLoose(Arc, _Shape);
  6724. function Arc() {
  6725. return _Shape.apply(this, arguments) || this;
  6726. }
  6727. var _proto = Arc.prototype;
  6728. _proto._initProperties = function _initProperties() {
  6729. _Shape.prototype._initProperties.call(this);
  6730. this._attrs.canStroke = true;
  6731. this._attrs.canFill = true;
  6732. this._attrs.type = 'arc';
  6733. };
  6734. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6735. return {
  6736. x: 0,
  6737. y: 0,
  6738. r: 0,
  6739. startAngle: 0,
  6740. endAngle: Math.PI * 2,
  6741. clockwise: false,
  6742. lineWidth: 1
  6743. };
  6744. };
  6745. _proto.createPath = function createPath(context) {
  6746. var attrs = this.get('attrs');
  6747. var x = attrs.x,
  6748. y = attrs.y,
  6749. r = attrs.r,
  6750. startAngle = attrs.startAngle,
  6751. endAngle = attrs.endAngle,
  6752. clockwise = attrs.clockwise;
  6753. context.beginPath();
  6754. context.arc(x, y, r, startAngle, endAngle, clockwise);
  6755. };
  6756. _proto.calculateBox = function calculateBox() {
  6757. var attrs = this.get('attrs');
  6758. var x = attrs.x,
  6759. y = attrs.y,
  6760. r = attrs.r,
  6761. startAngle = attrs.startAngle,
  6762. endAngle = attrs.endAngle,
  6763. clockwise = attrs.clockwise;
  6764. return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
  6765. };
  6766. return Arc;
  6767. }(Shape);
  6768. Shape.Arc = Arc;
  6769. module.exports = Arc;
  6770. /***/ }),
  6771. /* 76 */
  6772. /***/ (function(module, exports, __webpack_require__) {
  6773. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6774. var Shape = __webpack_require__(2);
  6775. var bbox = __webpack_require__(11);
  6776. var Sector =
  6777. /*#__PURE__*/
  6778. function (_Shape) {
  6779. _inheritsLoose(Sector, _Shape);
  6780. function Sector() {
  6781. return _Shape.apply(this, arguments) || this;
  6782. }
  6783. var _proto = Sector.prototype;
  6784. _proto._initProperties = function _initProperties() {
  6785. _Shape.prototype._initProperties.call(this);
  6786. this._attrs.canFill = true;
  6787. this._attrs.canStroke = true;
  6788. this._attrs.type = 'sector';
  6789. };
  6790. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6791. return {
  6792. x: 0,
  6793. y: 0,
  6794. lineWidth: 0,
  6795. r: 0,
  6796. r0: 0,
  6797. startAngle: 0,
  6798. endAngle: Math.PI * 2,
  6799. clockwise: false
  6800. };
  6801. };
  6802. _proto.createPath = function createPath(context) {
  6803. var attrs = this.get('attrs');
  6804. var x = attrs.x,
  6805. y = attrs.y,
  6806. startAngle = attrs.startAngle,
  6807. endAngle = attrs.endAngle,
  6808. r = attrs.r,
  6809. r0 = attrs.r0,
  6810. clockwise = attrs.clockwise;
  6811. context.beginPath();
  6812. var unitX = Math.cos(startAngle);
  6813. var unitY = Math.sin(startAngle);
  6814. context.moveTo(unitX * r0 + x, unitY * r0 + y);
  6815. context.lineTo(unitX * r + x, unitY * r + y);
  6816. context.arc(x, y, r, startAngle, endAngle, clockwise);
  6817. context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
  6818. if (r0 !== 0) {
  6819. context.arc(x, y, r0, endAngle, startAngle, !clockwise);
  6820. }
  6821. context.closePath();
  6822. };
  6823. _proto.calculateBox = function calculateBox() {
  6824. var attrs = this.get('attrs');
  6825. var x = attrs.x,
  6826. y = attrs.y,
  6827. r = attrs.r,
  6828. r0 = attrs.r0,
  6829. startAngle = attrs.startAngle,
  6830. endAngle = attrs.endAngle,
  6831. clockwise = attrs.clockwise;
  6832. var outerBBox = bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
  6833. var innerBBox = bbox.getBBoxFromArc(x, y, r0, startAngle, endAngle, clockwise);
  6834. return {
  6835. minX: Math.min(outerBBox.minX, innerBBox.minX),
  6836. minY: Math.min(outerBBox.minY, innerBBox.minY),
  6837. maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
  6838. maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
  6839. };
  6840. };
  6841. return Sector;
  6842. }(Shape);
  6843. Shape.Sector = Sector;
  6844. module.exports = Sector;
  6845. /***/ }),
  6846. /* 77 */
  6847. /***/ (function(module, exports, __webpack_require__) {
  6848. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6849. var Util = __webpack_require__(0);
  6850. var Shape = __webpack_require__(2);
  6851. var textWidthCacheCounter = 0;
  6852. var textWidthCache = {};
  6853. var TEXT_CACHE_MAX = 5000;
  6854. var Text =
  6855. /*#__PURE__*/
  6856. function (_Shape) {
  6857. _inheritsLoose(Text, _Shape);
  6858. function Text() {
  6859. return _Shape.apply(this, arguments) || this;
  6860. }
  6861. var _proto = Text.prototype;
  6862. _proto._initProperties = function _initProperties() {
  6863. _Shape.prototype._initProperties.call(this);
  6864. this._attrs.canFill = true;
  6865. this._attrs.canStroke = true;
  6866. this._attrs.type = 'text';
  6867. };
  6868. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6869. return {
  6870. lineWidth: 0,
  6871. lineCount: 1,
  6872. fontSize: 12,
  6873. fontFamily: 'sans-serif',
  6874. fontStyle: 'normal',
  6875. fontWeight: 'normal',
  6876. fontVariant: 'normal',
  6877. textAlign: 'start',
  6878. textBaseline: 'bottom',
  6879. lineHeight: null,
  6880. textArr: null
  6881. };
  6882. };
  6883. _proto._getFontStyle = function _getFontStyle() {
  6884. var attrs = this._attrs.attrs;
  6885. var fontSize = attrs.fontSize,
  6886. fontFamily = attrs.fontFamily,
  6887. fontWeight = attrs.fontWeight,
  6888. fontStyle = attrs.fontStyle,
  6889. fontVariant = attrs.fontVariant;
  6890. return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
  6891. };
  6892. _proto._afterAttrsSet = function _afterAttrsSet() {
  6893. var attrs = this._attrs.attrs;
  6894. attrs.font = this._getFontStyle();
  6895. if (attrs.text) {
  6896. var text = attrs.text;
  6897. var textArr = null;
  6898. var lineCount = 1;
  6899. if (Util.isString(text) && text.indexOf('\n') !== -1) {
  6900. textArr = text.split('\n');
  6901. lineCount = textArr.length;
  6902. }
  6903. attrs.lineCount = lineCount;
  6904. attrs.textArr = textArr;
  6905. }
  6906. this.set('attrs', attrs);
  6907. };
  6908. _proto._getTextHeight = function _getTextHeight() {
  6909. var attrs = this._attrs.attrs;
  6910. if (attrs.height) {
  6911. return attrs.height;
  6912. }
  6913. var lineCount = attrs.lineCount;
  6914. var fontSize = attrs.fontSize * 1;
  6915. if (lineCount > 1) {
  6916. var spaceingY = this._getSpaceingY();
  6917. return fontSize * lineCount + spaceingY * (lineCount - 1);
  6918. }
  6919. return fontSize;
  6920. };
  6921. _proto._getSpaceingY = function _getSpaceingY() {
  6922. var attrs = this._attrs.attrs;
  6923. var lineHeight = attrs.lineHeight;
  6924. var fontSize = attrs.fontSize * 1;
  6925. return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
  6926. };
  6927. _proto.drawInner = function drawInner(context) {
  6928. var self = this;
  6929. var attrs = self._attrs.attrs;
  6930. var text = attrs.text;
  6931. var x = attrs.x;
  6932. var y = attrs.y;
  6933. if (Util.isNil(text) || isNaN(x) || isNaN(y)) {
  6934. // text will be 0
  6935. return;
  6936. }
  6937. var textArr = attrs.textArr;
  6938. var fontSize = attrs.fontSize * 1;
  6939. var spaceingY = self._getSpaceingY();
  6940. if (attrs.rotate) {
  6941. // do rotation
  6942. context.translate(x, y);
  6943. context.rotate(attrs.rotate);
  6944. x = 0;
  6945. y = 0;
  6946. }
  6947. var textBaseline = attrs.textBaseline;
  6948. var height;
  6949. if (textArr) {
  6950. height = self._getTextHeight();
  6951. }
  6952. var subY; // context.beginPath();
  6953. if (self.hasFill()) {
  6954. var fillOpacity = attrs.fillOpacity;
  6955. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  6956. context.globalAlpha = fillOpacity;
  6957. }
  6958. if (textArr) {
  6959. for (var i = 0, len = textArr.length; i < len; i++) {
  6960. var subText = textArr[i];
  6961. subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
  6962. if (textBaseline === 'middle') {
  6963. subY += height - fontSize - (height - fontSize) / 2;
  6964. }
  6965. if (textBaseline === 'top') {
  6966. subY += height - fontSize;
  6967. }
  6968. context.fillText(subText, x, subY);
  6969. }
  6970. } else {
  6971. context.fillText(text, x, y);
  6972. }
  6973. }
  6974. if (self.hasStroke()) {
  6975. if (textArr) {
  6976. for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
  6977. var _subText = textArr[_i];
  6978. subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
  6979. if (textBaseline === 'middle') {
  6980. subY += height - fontSize - (height - fontSize) / 2;
  6981. }
  6982. if (textBaseline === 'top') {
  6983. subY += height - fontSize;
  6984. }
  6985. context.strokeText(_subText, x, subY);
  6986. }
  6987. } else {
  6988. context.strokeText(text, x, y);
  6989. }
  6990. }
  6991. };
  6992. _proto.calculateBox = function calculateBox() {
  6993. var self = this;
  6994. var attrs = self._attrs.attrs;
  6995. var x = attrs.x,
  6996. y = attrs.y,
  6997. textAlign = attrs.textAlign,
  6998. textBaseline = attrs.textBaseline;
  6999. var width = self._getTextWidth(); // attrs.width
  7000. if (!width) {
  7001. return {
  7002. minX: x,
  7003. minY: y,
  7004. maxX: x,
  7005. maxY: y
  7006. };
  7007. }
  7008. var height = self._getTextHeight(); // attrs.height
  7009. var point = {
  7010. x: x,
  7011. y: y - height
  7012. }; // default textAlign: start, textBaseline: bottom
  7013. if (textAlign) {
  7014. if (textAlign === 'end' || textAlign === 'right') {
  7015. point.x -= width;
  7016. } else if (textAlign === 'center') {
  7017. point.x -= width / 2;
  7018. }
  7019. }
  7020. if (textBaseline) {
  7021. if (textBaseline === 'top') {
  7022. point.y += height;
  7023. } else if (textBaseline === 'middle') {
  7024. point.y += height / 2;
  7025. }
  7026. }
  7027. return {
  7028. minX: point.x,
  7029. minY: point.y,
  7030. maxX: point.x + width,
  7031. maxY: point.y + height
  7032. };
  7033. };
  7034. _proto._getTextWidth = function _getTextWidth() {
  7035. var attrs = this._attrs.attrs;
  7036. if (attrs.width) {
  7037. return attrs.width;
  7038. }
  7039. var text = attrs.text;
  7040. var context = this.get('context');
  7041. if (Util.isNil(text)) return undefined;
  7042. var font = attrs.font;
  7043. var textArr = attrs.textArr;
  7044. var key = text + '' + font;
  7045. if (textWidthCache[key]) {
  7046. return textWidthCache[key];
  7047. }
  7048. var width = 0;
  7049. if (textArr) {
  7050. for (var i = 0, length = textArr.length; i < length; i++) {
  7051. var subText = textArr[i];
  7052. width = Math.max(width, Util.measureText(subText, font, context).width);
  7053. }
  7054. } else {
  7055. width = Util.measureText(text, font, context).width;
  7056. }
  7057. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  7058. textWidthCacheCounter = 0;
  7059. textWidthCache = {};
  7060. }
  7061. textWidthCacheCounter++;
  7062. textWidthCache[key] = width;
  7063. return width;
  7064. };
  7065. return Text;
  7066. }(Shape);
  7067. Shape.Text = Text;
  7068. module.exports = Text;
  7069. /***/ }),
  7070. /* 78 */
  7071. /***/ (function(module, exports, __webpack_require__) {
  7072. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7073. var Shape = __webpack_require__(2);
  7074. var Custom =
  7075. /*#__PURE__*/
  7076. function (_Shape) {
  7077. _inheritsLoose(Custom, _Shape);
  7078. function Custom() {
  7079. return _Shape.apply(this, arguments) || this;
  7080. }
  7081. var _proto = Custom.prototype;
  7082. _proto._initProperties = function _initProperties() {
  7083. _Shape.prototype._initProperties.call(this);
  7084. this._attrs.canFill = true;
  7085. this._attrs.canStroke = true;
  7086. this._attrs.createPath = null;
  7087. this._attrs.type = 'custom';
  7088. };
  7089. _proto.createPath = function createPath(context) {
  7090. var createPath = this.get('createPath');
  7091. createPath && createPath.call(this, context);
  7092. };
  7093. _proto.calculateBox = function calculateBox() {
  7094. var calculateBox = this.get('calculateBox');
  7095. return calculateBox && calculateBox.call(this);
  7096. };
  7097. return Custom;
  7098. }(Shape);
  7099. Shape.Custom = Custom;
  7100. module.exports = Custom;
  7101. /***/ }),
  7102. /* 79 */
  7103. /***/ (function(module, exports, __webpack_require__) {
  7104. /**
  7105. * @fileOverview track f2
  7106. * @author sima.zhang1990@gmail.com
  7107. */
  7108. var Global = __webpack_require__(1);
  7109. var Util = __webpack_require__(0);
  7110. var SERVER_URL = 'https://kcart.alipay.com/web/bi.do';
  7111. setTimeout(function () {
  7112. if (Global.trackable && Util.isBrowser) {
  7113. // Only works for H5 env
  7114. var image = new Image();
  7115. var newObj = {
  7116. pg: document.URL,
  7117. r: new Date().getTime(),
  7118. f2: true,
  7119. version: Global.version,
  7120. page_type: 'syslog'
  7121. };
  7122. var d = encodeURIComponent(JSON.stringify([newObj]));
  7123. image.src = SERVER_URL + "?BIProfile=merge&d=" + d;
  7124. }
  7125. }, 3000);
  7126. /***/ }),
  7127. /* 80 */
  7128. /***/ (function(module, exports, __webpack_require__) {
  7129. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7130. var Path = __webpack_require__(38);
  7131. var Geom = __webpack_require__(6);
  7132. __webpack_require__(32);
  7133. var Line =
  7134. /*#__PURE__*/
  7135. function (_Path) {
  7136. _inheritsLoose(Line, _Path);
  7137. function Line() {
  7138. return _Path.apply(this, arguments) || this;
  7139. }
  7140. var _proto = Line.prototype;
  7141. _proto.getDefaultCfg = function getDefaultCfg() {
  7142. var cfg = _Path.prototype.getDefaultCfg.call(this);
  7143. cfg.type = 'line';
  7144. cfg.sortable = true;
  7145. return cfg;
  7146. };
  7147. return Line;
  7148. }(Path);
  7149. Geom.Line = Line;
  7150. module.exports = Line;
  7151. /***/ }),
  7152. /* 81 */
  7153. /***/ (function(module, exports, __webpack_require__) {
  7154. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7155. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7156. var Geom = __webpack_require__(6);
  7157. var Util = __webpack_require__(0);
  7158. var SizeMixin = __webpack_require__(39);
  7159. __webpack_require__(82);
  7160. var Interval =
  7161. /*#__PURE__*/
  7162. function (_Geom) {
  7163. _inheritsLoose(Interval, _Geom);
  7164. var _proto = Interval.prototype;
  7165. _proto.getDefaultCfg = function getDefaultCfg() {
  7166. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7167. cfg.type = 'interval';
  7168. cfg.shapeType = 'interval';
  7169. cfg.generatePoints = true;
  7170. return cfg;
  7171. };
  7172. function Interval(cfg) {
  7173. var _this;
  7174. _this = _Geom.call(this, cfg) || this;
  7175. Util.mix(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
  7176. return _this;
  7177. }
  7178. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  7179. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  7180. cfg.size = this.getNormalizedSize(obj);
  7181. return cfg;
  7182. };
  7183. _proto.clearInner = function clearInner() {
  7184. _Geom.prototype.clearInner.call(this);
  7185. this.set('defaultSize', null);
  7186. };
  7187. return Interval;
  7188. }(Geom);
  7189. Geom.Interval = Interval;
  7190. module.exports = Interval;
  7191. /***/ }),
  7192. /* 82 */
  7193. /***/ (function(module, exports, __webpack_require__) {
  7194. var Util = __webpack_require__(0);
  7195. var Shape = __webpack_require__(9);
  7196. var Vector2 = __webpack_require__(4);
  7197. var Global = __webpack_require__(1);
  7198. function getRectPoints(cfg) {
  7199. var x = cfg.x,
  7200. y = cfg.y,
  7201. y0 = cfg.y0,
  7202. size = cfg.size;
  7203. var ymin = y0;
  7204. var ymax = y;
  7205. if (Util.isArray(y)) {
  7206. ymax = y[1];
  7207. ymin = y[0];
  7208. }
  7209. var xmin;
  7210. var xmax;
  7211. if (Util.isArray(x)) {
  7212. xmin = x[0];
  7213. xmax = x[1];
  7214. } else {
  7215. xmin = x - size / 2;
  7216. xmax = x + size / 2;
  7217. }
  7218. return [{
  7219. x: xmin,
  7220. y: ymin
  7221. }, {
  7222. x: xmin,
  7223. y: ymax
  7224. }, {
  7225. x: xmax,
  7226. y: ymax
  7227. }, {
  7228. x: xmax,
  7229. y: ymin
  7230. }];
  7231. }
  7232. function getRectRange(points) {
  7233. var xValues = [];
  7234. var yValues = [];
  7235. for (var i = 0, len = points.length; i < len; i++) {
  7236. var point = points[i];
  7237. xValues.push(point.x);
  7238. yValues.push(point.y);
  7239. }
  7240. var xMin = Math.min.apply(null, xValues);
  7241. var yMin = Math.min.apply(null, yValues);
  7242. var xMax = Math.max.apply(null, xValues);
  7243. var yMax = Math.max.apply(null, yValues);
  7244. return {
  7245. x: xMin,
  7246. y: yMin,
  7247. width: xMax - xMin,
  7248. height: yMax - yMin
  7249. };
  7250. }
  7251. var Interval = Shape.registerFactory('interval', {
  7252. defaultShapeType: 'rect',
  7253. getDefaultPoints: function getDefaultPoints(cfg) {
  7254. return getRectPoints(cfg);
  7255. }
  7256. });
  7257. Shape.registerShape('interval', 'rect', {
  7258. draw: function draw(cfg, container) {
  7259. var points = this.parsePoints(cfg.points);
  7260. var style = Util.mix({
  7261. fill: cfg.color
  7262. }, Global.shape.interval, cfg.style);
  7263. if (cfg.isInCircle) {
  7264. var newPoints = points.slice(0);
  7265. if (this._coord.transposed) {
  7266. newPoints = [points[0], points[3], points[2], points[1]];
  7267. }
  7268. var _cfg$center = cfg.center,
  7269. x = _cfg$center.x,
  7270. y = _cfg$center.y;
  7271. var v = [1, 0];
  7272. var v0 = [newPoints[0].x - x, newPoints[0].y - y];
  7273. var v1 = [newPoints[1].x - x, newPoints[1].y - y];
  7274. var v2 = [newPoints[2].x - x, newPoints[2].y - y];
  7275. var startAngle = Vector2.angleTo(v, v1);
  7276. var endAngle = Vector2.angleTo(v, v2);
  7277. var r0 = Vector2.length(v0);
  7278. var r = Vector2.length(v1);
  7279. if (startAngle >= 1.5 * Math.PI) {
  7280. startAngle = startAngle - 2 * Math.PI;
  7281. }
  7282. if (endAngle >= 1.5 * Math.PI) {
  7283. endAngle = endAngle - 2 * Math.PI;
  7284. }
  7285. return container.addShape('Sector', {
  7286. className: 'interval',
  7287. attrs: Util.mix({
  7288. x: x,
  7289. y: y,
  7290. r: r,
  7291. r0: r0,
  7292. startAngle: startAngle,
  7293. endAngle: endAngle
  7294. }, style)
  7295. });
  7296. }
  7297. var rectCfg = getRectRange(points);
  7298. return container.addShape('rect', {
  7299. className: 'interval',
  7300. attrs: Util.mix(rectCfg, style)
  7301. });
  7302. }
  7303. });
  7304. module.exports = Interval;
  7305. /***/ }),
  7306. /* 83 */
  7307. /***/ (function(module, exports, __webpack_require__) {
  7308. module.exports = {
  7309. Stack: __webpack_require__(84),
  7310. Dodge: __webpack_require__(86)
  7311. };
  7312. /***/ }),
  7313. /* 84 */
  7314. /***/ (function(module, exports, __webpack_require__) {
  7315. var Stack = __webpack_require__(85);
  7316. module.exports = Stack;
  7317. /***/ }),
  7318. /* 85 */
  7319. /***/ (function(module, exports, __webpack_require__) {
  7320. function _inheritsLoose(subClass, superClass) {
  7321. subClass.prototype = Object.create(superClass.prototype);
  7322. subClass.prototype.constructor = subClass;
  7323. subClass.__proto__ = superClass;
  7324. }
  7325. var isArray = __webpack_require__(10);
  7326. var isNil = __webpack_require__(7);
  7327. var Adjust = __webpack_require__(22);
  7328. var Stack =
  7329. /*#__PURE__*/
  7330. function (_Adjust) {
  7331. _inheritsLoose(Stack, _Adjust);
  7332. function Stack() {
  7333. return _Adjust.apply(this, arguments) || this;
  7334. }
  7335. var _proto = Stack.prototype;
  7336. _proto._initDefaultCfg = function _initDefaultCfg() {
  7337. this.xField = null; // 调整对应的 x 方向对应的字段名称
  7338. this.yField = null; // 调整对应的 y 方向对应的字段名称
  7339. };
  7340. _proto.processAdjust = function processAdjust(dataArray) {
  7341. this.processStack(dataArray);
  7342. };
  7343. _proto.processStack = function processStack(dataArray) {
  7344. var self = this;
  7345. var xField = self.xField;
  7346. var yField = self.yField;
  7347. var count = dataArray.length;
  7348. var stackCache = {
  7349. positive: {},
  7350. negative: {}
  7351. }; // 层叠顺序翻转
  7352. if (self.reverseOrder) {
  7353. dataArray = dataArray.slice(0).reverse();
  7354. }
  7355. for (var i = 0; i < count; i++) {
  7356. var data = dataArray[i];
  7357. for (var j = 0, len = data.length; j < len; j++) {
  7358. var item = data[j];
  7359. var x = item[xField] || 0;
  7360. var y = item[yField];
  7361. var xkey = x.toString();
  7362. y = isArray(y) ? y[1] : y;
  7363. if (!isNil(y)) {
  7364. var direction = y >= 0 ? 'positive' : 'negative';
  7365. if (!stackCache[direction][xkey]) {
  7366. stackCache[direction][xkey] = 0;
  7367. }
  7368. item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
  7369. stackCache[direction][xkey] += y;
  7370. }
  7371. }
  7372. }
  7373. };
  7374. return Stack;
  7375. }(Adjust);
  7376. Adjust.Stack = Stack;
  7377. module.exports = Stack;
  7378. /***/ }),
  7379. /* 86 */
  7380. /***/ (function(module, exports, __webpack_require__) {
  7381. var Dodge = __webpack_require__(87);
  7382. module.exports = Dodge;
  7383. /***/ }),
  7384. /* 87 */
  7385. /***/ (function(module, exports, __webpack_require__) {
  7386. function _inheritsLoose(subClass, superClass) {
  7387. subClass.prototype = Object.create(superClass.prototype);
  7388. subClass.prototype.constructor = subClass;
  7389. subClass.__proto__ = superClass;
  7390. }
  7391. var Adjust = __webpack_require__(22);
  7392. var each = __webpack_require__(3);
  7393. var MARGIN_RATIO = 1 / 2;
  7394. var DODGE_RATIO = 1 / 2;
  7395. var Dodge =
  7396. /*#__PURE__*/
  7397. function (_Adjust) {
  7398. _inheritsLoose(Dodge, _Adjust);
  7399. function Dodge() {
  7400. return _Adjust.apply(this, arguments) || this;
  7401. }
  7402. var _proto = Dodge.prototype;
  7403. _proto._initDefaultCfg = function _initDefaultCfg() {
  7404. /**
  7405. * 调整过程中,2个数据的间距
  7406. * @type {Number}
  7407. */
  7408. this.marginRatio = MARGIN_RATIO;
  7409. /**
  7410. * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
  7411. * @type {Number}
  7412. */
  7413. this.dodgeRatio = DODGE_RATIO;
  7414. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  7415. };
  7416. _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
  7417. var self = this;
  7418. var pre = range.pre;
  7419. var next = range.next;
  7420. var tickLength = next - pre;
  7421. var width = tickLength * self.dodgeRatio / count;
  7422. var margin = self.marginRatio * width;
  7423. var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
  7424. return (pre + next) / 2 + offset;
  7425. };
  7426. _proto.processAdjust = function processAdjust(dataArray) {
  7427. var self = this;
  7428. var count = dataArray.length;
  7429. var xField = self.xField;
  7430. each(dataArray, function (data, index) {
  7431. for (var i = 0, len = data.length; i < len; i++) {
  7432. var obj = data[i];
  7433. var value = obj[xField];
  7434. var range = {
  7435. pre: value - 0.5,
  7436. next: value + 0.5
  7437. };
  7438. var dodgeValue = self.getDodgeOffset(range, index, count);
  7439. obj[xField] = dodgeValue;
  7440. }
  7441. });
  7442. };
  7443. return Dodge;
  7444. }(Adjust);
  7445. Adjust.Dodge = Dodge;
  7446. module.exports = Dodge;
  7447. /***/ }),
  7448. /* 88 */
  7449. /***/ (function(module, exports, __webpack_require__) {
  7450. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7451. var Base = __webpack_require__(21);
  7452. var Vector2 = __webpack_require__(4);
  7453. var Matrix = __webpack_require__(23);
  7454. var Polar =
  7455. /*#__PURE__*/
  7456. function (_Base) {
  7457. _inheritsLoose(Polar, _Base);
  7458. function Polar() {
  7459. return _Base.apply(this, arguments) || this;
  7460. }
  7461. var _proto = Polar.prototype;
  7462. _proto._initDefaultCfg = function _initDefaultCfg() {
  7463. this.type = 'polar';
  7464. this.startAngle = -Math.PI / 2;
  7465. this.endAngle = Math.PI * 3 / 2;
  7466. this.inner = 0;
  7467. this.innerRadius = 0; // alias
  7468. this.isPolar = true;
  7469. this.transposed = false;
  7470. this.center = null;
  7471. this.radius = null; // relative, 0 ~ 1
  7472. };
  7473. _proto.init = function init(start, end) {
  7474. var self = this;
  7475. var inner = self.inner || self.innerRadius;
  7476. var width = Math.abs(end.x - start.x);
  7477. var height = Math.abs(end.y - start.y);
  7478. var maxRadius;
  7479. var center;
  7480. if (self.startAngle === -Math.PI && self.endAngle === 0) {
  7481. maxRadius = Math.min(width / 2, height);
  7482. center = {
  7483. x: (start.x + end.x) / 2,
  7484. y: start.y
  7485. };
  7486. } else {
  7487. maxRadius = Math.min(width, height) / 2;
  7488. center = {
  7489. x: (start.x + end.x) / 2,
  7490. y: (start.y + end.y) / 2
  7491. };
  7492. }
  7493. var radius = self.radius;
  7494. if (radius > 0 && radius <= 1) {
  7495. maxRadius = maxRadius * radius;
  7496. }
  7497. this.x = {
  7498. start: self.startAngle,
  7499. end: self.endAngle
  7500. };
  7501. this.y = {
  7502. start: maxRadius * inner,
  7503. end: maxRadius
  7504. };
  7505. this.center = center;
  7506. this.circleRadius = maxRadius; // the radius value in px
  7507. };
  7508. _proto.convertPoint = function convertPoint(point) {
  7509. var self = this;
  7510. var center = self.center;
  7511. var transposed = self.transposed;
  7512. var xDim = transposed ? 'y' : 'x';
  7513. var yDim = transposed ? 'x' : 'y';
  7514. var x = self.x;
  7515. var y = self.y;
  7516. var angle = x.start + (x.end - x.start) * point[xDim];
  7517. var radius = y.start + (y.end - y.start) * point[yDim];
  7518. return {
  7519. x: center.x + Math.cos(angle) * radius,
  7520. y: center.y + Math.sin(angle) * radius
  7521. };
  7522. };
  7523. _proto.invertPoint = function invertPoint(point) {
  7524. var self = this;
  7525. var center = self.center,
  7526. transposed = self.transposed,
  7527. x = self.x,
  7528. y = self.y;
  7529. var xDim = transposed ? 'y' : 'x';
  7530. var yDim = transposed ? 'x' : 'y';
  7531. var m = [1, 0, 0, 1, 0, 0];
  7532. Matrix.rotate(m, m, x.start);
  7533. var startV = [1, 0];
  7534. Vector2.transformMat2d(startV, startV, m);
  7535. startV = [startV[0], startV[1]];
  7536. var pointV = [point.x - center.x, point.y - center.y];
  7537. if (Vector2.zero(pointV)) {
  7538. return {
  7539. x: 0,
  7540. y: 0
  7541. };
  7542. }
  7543. var theta = Vector2.angleTo(startV, pointV, x.end < x.start);
  7544. if (Math.abs(theta - Math.PI * 2) < 0.001) {
  7545. theta = 0;
  7546. }
  7547. var l = Vector2.length(pointV);
  7548. var percentX = theta / (x.end - x.start);
  7549. percentX = x.end - x.start > 0 ? percentX : -percentX;
  7550. var percentY = (l - y.start) / (y.end - y.start);
  7551. var rst = {};
  7552. rst[xDim] = percentX;
  7553. rst[yDim] = percentY;
  7554. return rst;
  7555. };
  7556. return Polar;
  7557. }(Base);
  7558. Base.Polar = Polar;
  7559. module.exports = Polar;
  7560. /***/ }),
  7561. /* 89 */,
  7562. /* 90 */,
  7563. /* 91 */,
  7564. /* 92 */,
  7565. /* 93 */,
  7566. /* 94 */,
  7567. /* 95 */,
  7568. /* 96 */,
  7569. /* 97 */,
  7570. /* 98 */,
  7571. /* 99 */,
  7572. /* 100 */,
  7573. /* 101 */,
  7574. /* 102 */,
  7575. /* 103 */,
  7576. /* 104 */,
  7577. /* 105 */,
  7578. /* 106 */,
  7579. /* 107 */,
  7580. /* 108 */,
  7581. /* 109 */,
  7582. /* 110 */,
  7583. /* 111 */,
  7584. /* 112 */,
  7585. /* 113 */,
  7586. /* 114 */,
  7587. /* 115 */,
  7588. /* 116 */,
  7589. /* 117 */,
  7590. /* 118 */,
  7591. /* 119 */,
  7592. /* 120 */,
  7593. /* 121 */,
  7594. /* 122 */,
  7595. /* 123 */,
  7596. /* 124 */,
  7597. /* 125 */,
  7598. /* 126 */,
  7599. /* 127 */,
  7600. /* 128 */,
  7601. /* 129 */,
  7602. /* 130 */
  7603. /***/ (function(module, exports, __webpack_require__) {
  7604. /**
  7605. * Only support simple bar chart, line chart and pie chart
  7606. */
  7607. var F2 = __webpack_require__(41);
  7608. __webpack_require__(80);
  7609. __webpack_require__(81);
  7610. __webpack_require__(83);
  7611. __webpack_require__(88);
  7612. module.exports = F2;
  7613. /***/ })
  7614. /******/ ]);
  7615. });