123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global = global || self, global.ApexCharts = factory());
- }(this, (function () { 'use strict';
- function _typeof(obj) {
- "@babel/helpers - typeof";
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
- return _typeof(obj);
- }
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
- }
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
- }
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- }
- function ownKeys(object, enumerableOnly) {
- var keys = Object.keys(object);
- if (Object.getOwnPropertySymbols) {
- var symbols = Object.getOwnPropertySymbols(object);
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
- });
- keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread2(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- if (i % 2) {
- ownKeys(Object(source), true).forEach(function (key) {
- _defineProperty(target, key, source[key]);
- });
- } else if (Object.getOwnPropertyDescriptors) {
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
- } else {
- ownKeys(Object(source)).forEach(function (key) {
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
- });
- }
- }
- return target;
- }
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- if (superClass) _setPrototypeOf(subClass, superClass);
- }
- function _getPrototypeOf(o) {
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- return _getPrototypeOf(o);
- }
- function _setPrototypeOf(o, p) {
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- };
- return _setPrototypeOf(o, p);
- }
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- function _possibleConstructorReturn(self, call) {
- if (call && (typeof call === "object" || typeof call === "function")) {
- return call;
- }
- return _assertThisInitialized(self);
- }
- function _toConsumableArray(arr) {
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
- }
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
- return arr2;
- }
- }
- function _iterableToArray(iter) {
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
- }
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance");
- }
-
- var Utils = function () {
- function Utils() {
- _classCallCheck(this, Utils);
- }
- _createClass(Utils, [{
- key: "shadeRGBColor",
- value: function shadeRGBColor(percent, color) {
- var f = color.split(','),
- t = percent < 0 ? 0 : 255,
- p = percent < 0 ? percent * -1 : percent,
- R = parseInt(f[0].slice(4), 10),
- G = parseInt(f[1], 10),
- B = parseInt(f[2], 10);
- return 'rgb(' + (Math.round((t - R) * p) + R) + ',' + (Math.round((t - G) * p) + G) + ',' + (Math.round((t - B) * p) + B) + ')';
- }
- }, {
- key: "shadeHexColor",
- value: function shadeHexColor(percent, color) {
- var f = parseInt(color.slice(1), 16),
- t = percent < 0 ? 0 : 255,
- p = percent < 0 ? percent * -1 : percent,
- R = f >> 16,
- G = f >> 8 & 0x00ff,
- B = f & 0x0000ff;
- return '#' + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
- }
-
- }, {
- key: "shadeColor",
- value: function shadeColor(p, color) {
- if (Utils.isColorHex(color)) {
- return this.shadeHexColor(p, color);
- } else {
- return this.shadeRGBColor(p, color);
- }
- }
- }], [{
- key: "bind",
- value: function bind(fn, me) {
- return function () {
- return fn.apply(me, arguments);
- };
- }
- }, {
- key: "isObject",
- value: function isObject(item) {
- return item && _typeof(item) === 'object' && !Array.isArray(item) && item != null;
- }
- }, {
- key: "listToArray",
- value: function listToArray(list) {
- var i,
- array = [];
- for (i = 0; i < list.length; i++) {
- array[i] = list[i];
- }
- return array;
- }
-
- }, {
- key: "extend",
- value: function extend(target, source) {
- var _this = this;
- if (typeof Object.assign !== 'function') {
- (function () {
- Object.assign = function (target) {
- if (target === undefined || target === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
- var output = Object(target);
- for (var index = 1; index < arguments.length; index++) {
- var _source = arguments[index];
- if (_source !== undefined && _source !== null) {
- for (var nextKey in _source) {
- if (_source.hasOwnProperty(nextKey)) {
- output[nextKey] = _source[nextKey];
- }
- }
- }
- }
- return output;
- };
- })();
- }
- var output = Object.assign({}, target);
- if (this.isObject(target) && this.isObject(source)) {
- Object.keys(source).forEach(function (key) {
- if (_this.isObject(source[key])) {
- if (!(key in target)) {
- Object.assign(output, _defineProperty({}, key, source[key]));
- } else {
- output[key] = _this.extend(target[key], source[key]);
- }
- } else {
- Object.assign(output, _defineProperty({}, key, source[key]));
- }
- });
- }
- return output;
- }
- }, {
- key: "extendArray",
- value: function extendArray(arrToExtend, resultArr) {
- var extendedArr = [];
- arrToExtend.map(function (item) {
- extendedArr.push(Utils.extend(resultArr, item));
- });
- arrToExtend = extendedArr;
- return arrToExtend;
- }
- }, {
- key: "monthMod",
- value: function monthMod(month) {
- return month % 12;
- }
- }, {
- key: "clone",
- value: function clone(source) {
- if (Object.prototype.toString.call(source) === '[object Array]') {
- var cloneResult = [];
- for (var i = 0; i < source.length; i++) {
- cloneResult[i] = this.clone(source[i]);
- }
- return cloneResult;
- } else if (_typeof(source) === 'object') {
- var _cloneResult = {};
- for (var prop in source) {
- if (source.hasOwnProperty(prop)) {
- _cloneResult[prop] = this.clone(source[prop]);
- }
- }
- return _cloneResult;
- } else {
- return source;
- }
- }
- }, {
- key: "log10",
- value: function log10(x) {
- return Math.log(x) / Math.LN10;
- }
- }, {
- key: "roundToBase10",
- value: function roundToBase10(x) {
- return Math.pow(10, Math.floor(Math.log10(x)));
- }
- }, {
- key: "roundToBase",
- value: function roundToBase(x, base) {
- return Math.pow(base, Math.floor(Math.log(x) / Math.log(base)));
- }
- }, {
- key: "parseNumber",
- value: function parseNumber(val) {
- if (val === null) return val;
- return parseFloat(val);
- }
- }, {
- key: "randomId",
- value: function randomId() {
- return (new Date() % 9e6).toString(16);
- }
- }, {
- key: "noExponents",
- value: function noExponents(val) {
- var data = String(val).split(/[eE]/);
- if (data.length === 1) return data[0];
- var z = '',
- sign = val < 0 ? '-' : '',
- str = data[0].replace('.', ''),
- mag = Number(data[1]) + 1;
- if (mag < 0) {
- z = sign + '0.';
- while (mag++) {
- z += '0';
- }
- return z + str.replace(/^-/, '');
- }
- mag -= str.length;
- while (mag--) {
- z += '0';
- }
- return str + z;
- }
- }, {
- key: "getDimensions",
- value: function getDimensions(el) {
- var computedStyle = getComputedStyle(el);
- var ret = [];
- var elementHeight = el.clientHeight;
- var elementWidth = el.clientWidth;
- elementHeight -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
- elementWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
- ret.push(elementWidth);
- ret.push(elementHeight);
- return ret;
- }
- }, {
- key: "getBoundingClientRect",
- value: function getBoundingClientRect(element) {
- var rect = element.getBoundingClientRect();
- return {
- top: rect.top,
- right: rect.right,
- bottom: rect.bottom,
- left: rect.left,
- width: element.clientWidth,
- height: element.clientHeight,
- x: rect.left,
- y: rect.top
- };
- }
- }, {
- key: "getLargestStringFromArr",
- value: function getLargestStringFromArr(arr) {
- return arr.reduce(function (a, b) {
- if (Array.isArray(b)) {
- b = b.reduce(function (aa, bb) {
- return aa.length > bb.length ? aa : bb;
- });
- }
- return a.length > b.length ? a : b;
- }, 0);
- }
- }, {
- key: "hexToRgba",
- value: function hexToRgba() {
- var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#999999';
- var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
- if (hex.substring(0, 1) !== '#') {
- hex = '#999999';
- }
- var h = hex.replace('#', '');
- h = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g'));
- for (var i = 0; i < h.length; i++) {
- h[i] = parseInt(h[i].length === 1 ? h[i] + h[i] : h[i], 16);
- }
- if (typeof opacity !== 'undefined') h.push(opacity);
- return 'rgba(' + h.join(',') + ')';
- }
- }, {
- key: "getOpacityFromRGBA",
- value: function getOpacityFromRGBA(rgba) {
- return parseFloat(rgba.replace(/^.*,(.+)\)/, '$1'));
- }
- }, {
- key: "rgb2hex",
- value: function rgb2hex(rgb) {
- rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
- return rgb && rgb.length === 4 ? '#' + ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
- }
- }, {
- key: "isColorHex",
- value: function isColorHex(color) {
- return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)|(^#[0-9A-F]{8}$)/i.test(color);
- }
- }, {
- key: "polarToCartesian",
- value: function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
- var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
- return {
- x: centerX + radius * Math.cos(angleInRadians),
- y: centerY + radius * Math.sin(angleInRadians)
- };
- }
- }, {
- key: "escapeString",
- value: function escapeString(str) {
- var escapeWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';
- var newStr = str.toString().slice();
- newStr = newStr.replace(/[` ~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, escapeWith);
- return newStr;
- }
- }, {
- key: "negToZero",
- value: function negToZero(val) {
- return val < 0 ? 0 : val;
- }
- }, {
- key: "moveIndexInArray",
- value: function moveIndexInArray(arr, old_index, new_index) {
- if (new_index >= arr.length) {
- var k = new_index - arr.length + 1;
- while (k--) {
- arr.push(undefined);
- }
- }
- arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
- return arr;
- }
- }, {
- key: "extractNumber",
- value: function extractNumber(s) {
- return parseFloat(s.replace(/[^\d.]*/g, ''));
- }
- }, {
- key: "findAncestor",
- value: function findAncestor(el, cls) {
- while ((el = el.parentElement) && !el.classList.contains(cls)) {
- }
- return el;
- }
- }, {
- key: "setELstyles",
- value: function setELstyles(el, styles) {
- for (var key in styles) {
- if (styles.hasOwnProperty(key)) {
- el.style.key = styles[key];
- }
- }
- }
- }, {
- key: "isNumber",
- value: function isNumber(value) {
- return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
- }
- }, {
- key: "isFloat",
- value: function isFloat(n) {
- return Number(n) === n && n % 1 !== 0;
- }
- }, {
- key: "isSafari",
- value: function isSafari() {
- return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
- }
- }, {
- key: "isFirefox",
- value: function isFirefox() {
- return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- }
- }, {
- key: "isIE11",
- value: function isIE11() {
- if (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.appVersion.indexOf('Trident/') > -1) {
- return true;
- }
- }
- }, {
- key: "isIE",
- value: function isIE() {
- var ua = window.navigator.userAgent;
- var msie = ua.indexOf('MSIE ');
- if (msie > 0) {
-
- return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
- }
- var trident = ua.indexOf('Trident/');
- if (trident > 0) {
-
- var rv = ua.indexOf('rv:');
- return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
- }
- var edge = ua.indexOf('Edge/');
- if (edge > 0) {
-
- return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
- }
- return false;
- }
- }]);
- return Utils;
- }();
-
- var Filters = function () {
- function Filters(ctx) {
- _classCallCheck(this, Filters);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Filters, [{
- key: "getDefaultFilter",
- value: function getDefaultFilter(el, i) {
- var w = this.w;
- el.unfilter(true);
- var filter = new window.SVG.Filter();
- filter.size('120%', '180%', '-5%', '-40%');
- if (w.config.states.normal.filter !== 'none') {
- this.applyFilter(el, i, w.config.states.normal.filter.type, w.config.states.normal.filter.value);
- } else {
- if (w.config.chart.dropShadow.enabled) {
- this.dropShadow(el, w.config.chart.dropShadow, i);
- }
- }
- }
- }, {
- key: "addNormalFilter",
- value: function addNormalFilter(el, i) {
- var w = this.w;
-
- if (w.config.chart.dropShadow.enabled && !el.node.classList.contains('apexcharts-marker')) {
- this.dropShadow(el, w.config.chart.dropShadow, i);
- }
- }
- }, {
- key: "addLightenFilter",
- value: function addLightenFilter(el, i, attrs) {
- var _this = this;
- var w = this.w;
- var intensity = attrs.intensity;
- if (Utils.isFirefox()) {
- return;
- }
- el.unfilter(true);
- var filter = new window.SVG.Filter();
- el.filter(function (add) {
- var shadowAttr = w.config.chart.dropShadow;
- if (shadowAttr.enabled) {
- filter = _this.addShadow(add, i, shadowAttr);
- } else {
- filter = add;
- }
- filter.componentTransfer({
- rgb: {
- type: 'linear',
- slope: 1.5,
- intercept: intensity
- }
- });
- });
- el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
- this._scaleFilterSize(el.filterer.node);
- }
- }, {
- key: "addDarkenFilter",
- value: function addDarkenFilter(el, i, attrs) {
- var _this2 = this;
- var w = this.w;
- var intensity = attrs.intensity;
- if (Utils.isFirefox()) {
- return;
- }
- el.unfilter(true);
- var filter = new window.SVG.Filter();
- el.filter(function (add) {
- var shadowAttr = w.config.chart.dropShadow;
- if (shadowAttr.enabled) {
- filter = _this2.addShadow(add, i, shadowAttr);
- } else {
- filter = add;
- }
- filter.componentTransfer({
- rgb: {
- type: 'linear',
- slope: intensity
- }
- });
- });
- el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
- this._scaleFilterSize(el.filterer.node);
- }
- }, {
- key: "applyFilter",
- value: function applyFilter(el, i, filter) {
- var intensity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
- switch (filter) {
- case 'none':
- {
- this.addNormalFilter(el, i);
- break;
- }
- case 'lighten':
- {
- this.addLightenFilter(el, i, {
- intensity: intensity
- });
- break;
- }
- case 'darken':
- {
- this.addDarkenFilter(el, i, {
- intensity: intensity
- });
- break;
- }
- }
- }
- }, {
- key: "addShadow",
- value: function addShadow(add, i, attrs) {
- var blur = attrs.blur,
- top = attrs.top,
- left = attrs.left,
- color = attrs.color,
- opacity = attrs.opacity;
- var shadowBlur = add.flood(Array.isArray(color) ? color[i] : color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
- return add.blend(add.source, shadowBlur);
- }
-
- }, {
- key: "dropShadow",
- value: function dropShadow(el, attrs) {
- var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
- var top = attrs.top,
- left = attrs.left,
- blur = attrs.blur,
- color = attrs.color,
- opacity = attrs.opacity,
- noUserSpaceOnUse = attrs.noUserSpaceOnUse;
- var w = this.w;
- el.unfilter(true);
- if (Utils.isIE() && w.config.chart.type === 'radialBar') {
-
- return el;
- }
- color = Array.isArray(color) ? color[i] : color;
- el.filter(function (add) {
- var shadowBlur = null;
- if (Utils.isSafari() || Utils.isFirefox() || Utils.isIE()) {
-
- shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur);
- } else {
- shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
- }
- add.blend(add.source, shadowBlur);
- });
- if (!noUserSpaceOnUse) {
- el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
- }
- this._scaleFilterSize(el.filterer.node);
- return el;
- }
- }, {
- key: "setSelectionFilter",
- value: function setSelectionFilter(el, realIndex, dataPointIndex) {
- var w = this.w;
- if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') {
- if (w.globals.selectedDataPoints[realIndex].indexOf(dataPointIndex) > -1) {
- el.node.setAttribute('selected', true);
- var activeFilter = w.config.states.active.filter;
- if (activeFilter !== 'none') {
- this.applyFilter(el, realIndex, activeFilter.type, activeFilter.value);
- }
- }
- }
- }
- }, {
- key: "_scaleFilterSize",
- value: function _scaleFilterSize(el) {
- var setAttributes = function setAttributes(attrs) {
- for (var key in attrs) {
- if (attrs.hasOwnProperty(key)) {
- el.setAttribute(key, attrs[key]);
- }
- }
- };
- setAttributes({
- width: '200%',
- height: '200%',
- x: '-50%',
- y: '-50%'
- });
- }
- }]);
- return Filters;
- }();
-
- var Animations = function () {
- function Animations(ctx) {
- _classCallCheck(this, Animations);
- this.ctx = ctx;
- this.w = ctx.w;
- this.setEasingFunctions();
- }
- _createClass(Animations, [{
- key: "setEasingFunctions",
- value: function setEasingFunctions() {
- var easing;
- if (this.w.globals.easing) return;
- var userDefinedEasing = this.w.config.chart.animations.easing;
- switch (userDefinedEasing) {
- case 'linear':
- {
- easing = '-';
- break;
- }
- case 'easein':
- {
- easing = '<';
- break;
- }
- case 'easeout':
- {
- easing = '>';
- break;
- }
- case 'easeinout':
- {
- easing = '<>';
- break;
- }
- case 'swing':
- {
- easing = function easing(pos) {
- var s = 1.70158;
- var ret = (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
- return ret;
- };
- break;
- }
- case 'bounce':
- {
- easing = function easing(pos) {
- var ret = '';
- if (pos < 1 / 2.75) {
- ret = 7.5625 * pos * pos;
- } else if (pos < 2 / 2.75) {
- ret = 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75;
- } else if (pos < 2.5 / 2.75) {
- ret = 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375;
- } else {
- ret = 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375;
- }
- return ret;
- };
- break;
- }
- case 'elastic':
- {
- easing = function easing(pos) {
- if (pos === !!pos) return pos;
- return Math.pow(2, -10 * pos) * Math.sin((pos - 0.075) * (2 * Math.PI) / 0.3) + 1;
- };
- break;
- }
- default:
- {
- easing = '<>';
- }
- }
- this.w.globals.easing = easing;
- }
- }, {
- key: "animateLine",
- value: function animateLine(el, from, to, speed) {
- el.attr(from).animate(speed).attr(to);
- }
-
- }, {
- key: "animateCircleRadius",
- value: function animateCircleRadius(el, from, to, speed, easing, cb) {
- if (!from) from = 0;
- el.attr({
- r: from
- }).animate(speed, easing).attr({
- r: to
- }).afterAll(function () {
- cb();
- });
- }
-
- }, {
- key: "animateCircle",
- value: function animateCircle(el, from, to, speed, easing) {
- el.attr({
- r: from.r,
- cx: from.cx,
- cy: from.cy
- }).animate(speed, easing).attr({
- r: to.r,
- cx: to.cx,
- cy: to.cy
- });
- }
-
- }, {
- key: "animateRect",
- value: function animateRect(el, from, to, speed, fn) {
- el.attr(from).animate(speed).attr(to).afterAll(function () {
- return fn();
- });
- }
- }, {
- key: "animatePathsGradually",
- value: function animatePathsGradually(params) {
- var el = params.el,
- realIndex = params.realIndex,
- j = params.j,
- fill = params.fill,
- pathFrom = params.pathFrom,
- pathTo = params.pathTo,
- speed = params.speed,
- delay = params.delay;
- var me = this;
- var w = this.w;
- var delayFactor = 0;
- if (w.config.chart.animations.animateGradually.enabled) {
- delayFactor = w.config.chart.animations.animateGradually.delay;
- }
- if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged && w.config.chart.type !== 'bar') {
-
- delayFactor = 0;
- }
- me.morphSVG(el, realIndex, j, w.config.chart.type === 'line' && !w.globals.comboCharts ? 'stroke' : fill, pathFrom, pathTo, speed, delay * delayFactor);
- }
- }, {
- key: "showDelayedElements",
- value: function showDelayedElements() {
- this.w.globals.delayedElements.forEach(function (d) {
- var ele = d.el;
- ele.classList.remove('apexcharts-element-hidden');
- });
- }
- }, {
- key: "animationCompleted",
- value: function animationCompleted(el) {
- var w = this.w;
- if (w.globals.animationEnded) return;
- w.globals.animationEnded = true;
- this.showDelayedElements();
- if (typeof w.config.chart.events.animationEnd === 'function') {
- w.config.chart.events.animationEnd(this.ctx, {
- el: el,
- w: w
- });
- }
- }
- }, {
- key: "morphSVG",
- value: function morphSVG(el, realIndex, j, fill, pathFrom, pathTo, speed, delay) {
- var _this = this;
- var w = this.w;
- if (!pathFrom) {
- pathFrom = el.attr('pathFrom');
- }
- if (!pathTo) {
- pathTo = el.attr('pathTo');
- }
- var disableAnimationForCorrupPath = function disableAnimationForCorrupPath(path) {
- if (w.config.chart.type === 'radar') {
-
-
- speed = 1;
- }
- return "M 0 ".concat(w.globals.gridHeight);
- };
- if (!pathFrom || pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) {
- pathFrom = disableAnimationForCorrupPath();
- }
- if (pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) {
- pathTo = disableAnimationForCorrupPath();
- }
- if (!w.globals.shouldAnimate) {
- speed = 1;
- }
- el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo).afterAll(function () {
-
- if (Utils.isNumber(j)) {
- if (j === w.globals.series[w.globals.maxValsInArrayIndex].length - 2 && w.globals.shouldAnimate) {
- _this.animationCompleted(el);
- }
- } else if (fill !== 'none' && w.globals.shouldAnimate) {
- if (!w.globals.comboCharts && realIndex === w.globals.series.length - 1 || w.globals.comboCharts) {
- _this.animationCompleted(el);
- }
- }
- _this.showDelayedElements();
- });
- }
- }]);
- return Animations;
- }();
-
- var Graphics = function () {
- function Graphics(ctx) {
- _classCallCheck(this, Graphics);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Graphics, [{
- key: "drawLine",
- value: function drawLine(x1, y1, x2, y2) {
- var lineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#a8a8a8';
- var dashArray = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
- var strokeWidth = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
- var w = this.w;
- var line = w.globals.dom.Paper.line().attr({
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- stroke: lineColor,
- 'stroke-dasharray': dashArray,
- 'stroke-width': strokeWidth
- });
- return line;
- }
- }, {
- key: "drawRect",
- value: function drawRect() {
- var x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
- var y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- var x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
- var y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
- var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
- var color = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '#fefefe';
- var opacity = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1;
- var strokeWidth = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
- var strokeColor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
- var strokeDashArray = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 0;
- var w = this.w;
- var rect = w.globals.dom.Paper.rect();
- rect.attr({
- x: x1,
- y: y1,
- width: x2 > 0 ? x2 : 0,
- height: y2 > 0 ? y2 : 0,
- rx: radius,
- ry: radius,
- opacity: opacity,
- 'stroke-width': strokeWidth !== null ? strokeWidth : 0,
- stroke: strokeColor !== null ? strokeColor : 'none',
- 'stroke-dasharray': strokeDashArray
- });
- rect.node.setAttribute('fill', color);
- return rect;
- }
- }, {
- key: "drawPolygon",
- value: function drawPolygon(polygonString) {
- var stroke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#e1e1e1';
- var fill = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'none';
- var w = this.w;
- var polygon = w.globals.dom.Paper.polygon(polygonString).attr({
- fill: fill,
- stroke: stroke
- });
- return polygon;
- }
- }, {
- key: "drawCircle",
- value: function drawCircle(radius) {
- var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var w = this.w;
- var c = w.globals.dom.Paper.circle(radius * 2);
- if (attrs !== null) {
- c.attr(attrs);
- }
- return c;
- }
- }, {
- key: "drawPath",
- value: function drawPath(_ref) {
- var _ref$d = _ref.d,
- d = _ref$d === void 0 ? '' : _ref$d,
- _ref$stroke = _ref.stroke,
- stroke = _ref$stroke === void 0 ? '#a8a8a8' : _ref$stroke,
- _ref$strokeWidth = _ref.strokeWidth,
- strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
- fill = _ref.fill,
- _ref$fillOpacity = _ref.fillOpacity,
- fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
- _ref$strokeOpacity = _ref.strokeOpacity,
- strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
- classes = _ref.classes,
- _ref$strokeLinecap = _ref.strokeLinecap,
- strokeLinecap = _ref$strokeLinecap === void 0 ? null : _ref$strokeLinecap,
- _ref$strokeDashArray = _ref.strokeDashArray,
- strokeDashArray = _ref$strokeDashArray === void 0 ? 0 : _ref$strokeDashArray;
- var w = this.w;
- if (strokeLinecap === null) {
- strokeLinecap = w.config.stroke.lineCap;
- }
- if (d.indexOf('undefined') > -1 || d.indexOf('NaN') > -1) {
- d = "M 0 ".concat(w.globals.gridHeight);
- }
- var p = w.globals.dom.Paper.path(d).attr({
- fill: fill,
- 'fill-opacity': fillOpacity,
- stroke: stroke,
- 'stroke-opacity': strokeOpacity,
- 'stroke-linecap': strokeLinecap,
- 'stroke-width': strokeWidth,
- 'stroke-dasharray': strokeDashArray,
- class: classes
- });
- return p;
- }
- }, {
- key: "group",
- value: function group() {
- var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var w = this.w;
- var g = w.globals.dom.Paper.group();
- if (attrs !== null) {
- g.attr(attrs);
- }
- return g;
- }
- }, {
- key: "move",
- value: function move(x, y) {
- var move = ['M', x, y].join(' ');
- return move;
- }
- }, {
- key: "line",
- value: function line(x, y) {
- var hORv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var line = null;
- if (hORv === null) {
- line = ['L', x, y].join(' ');
- } else if (hORv === 'H') {
- line = ['H', x].join(' ');
- } else if (hORv === 'V') {
- line = ['V', y].join(' ');
- }
- return line;
- }
- }, {
- key: "curve",
- value: function curve(x1, y1, x2, y2, x, y) {
- var curve = ['C', x1, y1, x2, y2, x, y].join(' ');
- return curve;
- }
- }, {
- key: "quadraticCurve",
- value: function quadraticCurve(x1, y1, x, y) {
- var curve = ['Q', x1, y1, x, y].join(' ');
- return curve;
- }
- }, {
- key: "arc",
- value: function arc(rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y) {
- var relative = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
- var coord = 'A';
- if (relative) coord = 'a';
- var arc = [coord, rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y].join(' ');
- return arc;
- }
-
- }, {
- key: "renderPaths",
- value: function renderPaths(_ref2) {
- var j = _ref2.j,
- realIndex = _ref2.realIndex,
- pathFrom = _ref2.pathFrom,
- pathTo = _ref2.pathTo,
- stroke = _ref2.stroke,
- strokeWidth = _ref2.strokeWidth,
- strokeLinecap = _ref2.strokeLinecap,
- fill = _ref2.fill,
- animationDelay = _ref2.animationDelay,
- initialSpeed = _ref2.initialSpeed,
- dataChangeSpeed = _ref2.dataChangeSpeed,
- className = _ref2.className,
- _ref2$shouldClipToGri = _ref2.shouldClipToGrid,
- shouldClipToGrid = _ref2$shouldClipToGri === void 0 ? true : _ref2$shouldClipToGri,
- _ref2$bindEventsOnPat = _ref2.bindEventsOnPaths,
- bindEventsOnPaths = _ref2$bindEventsOnPat === void 0 ? true : _ref2$bindEventsOnPat,
- _ref2$drawShadow = _ref2.drawShadow,
- drawShadow = _ref2$drawShadow === void 0 ? true : _ref2$drawShadow;
- var w = this.w;
- var filters = new Filters(this.ctx);
- var anim = new Animations(this.ctx);
- var initialAnim = this.w.config.chart.animations.enabled;
- var dynamicAnim = initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
- var d;
- var shouldAnimate = !!(initialAnim && !w.globals.resized || dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate);
- if (shouldAnimate) {
- d = pathFrom;
- } else {
- d = pathTo;
- w.globals.animationEnded = true;
- }
- var strokeDashArrayOpt = w.config.stroke.dashArray;
- var strokeDashArray = 0;
- if (Array.isArray(strokeDashArrayOpt)) {
- strokeDashArray = strokeDashArrayOpt[realIndex];
- } else {
- strokeDashArray = w.config.stroke.dashArray;
- }
- var el = this.drawPath({
- d: d,
- stroke: stroke,
- strokeWidth: strokeWidth,
- fill: fill,
- fillOpacity: 1,
- classes: className,
- strokeLinecap: strokeLinecap,
- strokeDashArray: strokeDashArray
- });
- el.attr('index', realIndex);
- if (shouldClipToGrid) {
- el.attr({
- 'clip-path': "url(#gridRectMask".concat(w.globals.cuid, ")")
- });
- }
- if (w.config.states.normal.filter.type !== 'none') {
- filters.getDefaultFilter(el, realIndex);
- } else {
- if (w.config.chart.dropShadow.enabled && drawShadow) {
- if (!w.config.chart.dropShadow.enabledOnSeries || w.config.chart.dropShadow.enabledOnSeries && w.config.chart.dropShadow.enabledOnSeries.indexOf(realIndex) !== -1) {
- var shadow = w.config.chart.dropShadow;
- filters.dropShadow(el, shadow, realIndex);
- }
- }
- }
- if (bindEventsOnPaths) {
- el.node.addEventListener('mouseenter', this.pathMouseEnter.bind(this, el));
- el.node.addEventListener('mouseleave', this.pathMouseLeave.bind(this, el));
- el.node.addEventListener('mousedown', this.pathMouseDown.bind(this, el));
- }
- el.attr({
- pathTo: pathTo,
- pathFrom: pathFrom
- });
- var defaultAnimateOpts = {
- el: el,
- j: j,
- realIndex: realIndex,
- pathFrom: pathFrom,
- pathTo: pathTo,
- fill: fill,
- strokeWidth: strokeWidth,
- delay: animationDelay
- };
- if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
- anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
- speed: initialSpeed
- }));
- } else {
- if (w.globals.resized || !w.globals.dataChanged) {
- anim.showDelayedElements();
- }
- }
- if (w.globals.dataChanged && dynamicAnim && shouldAnimate) {
- anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
- speed: dataChangeSpeed
- }));
- }
- return el;
- }
- }, {
- key: "drawPattern",
- value: function drawPattern(style, width, height) {
- var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8';
- var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
- var w = this.w;
- var p = w.globals.dom.Paper.pattern(width, height, function (add) {
- if (style === 'horizontalLines') {
- add.line(0, 0, height, 0).stroke({
- color: stroke,
- width: strokeWidth + 1
- });
- } else if (style === 'verticalLines') {
- add.line(0, 0, 0, width).stroke({
- color: stroke,
- width: strokeWidth + 1
- });
- } else if (style === 'slantedLines') {
- add.line(0, 0, width, height).stroke({
- color: stroke,
- width: strokeWidth
- });
- } else if (style === 'squares') {
- add.rect(width, height).fill('none').stroke({
- color: stroke,
- width: strokeWidth
- });
- } else if (style === 'circles') {
- add.circle(width).fill('none').stroke({
- color: stroke,
- width: strokeWidth
- });
- }
- });
- return p;
- }
- }, {
- key: "drawGradient",
- value: function drawGradient(style, gfrom, gto, opacityFrom, opacityTo) {
- var size = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
- var stops = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
- var colorStops = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
- var i = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
- var w = this.w;
- var g;
- if (gfrom.length < 9 && gfrom.indexOf('#') === 0) {
-
- gfrom = Utils.hexToRgba(gfrom, opacityFrom);
- }
- if (gto.length < 9 && gto.indexOf('#') === 0) {
- gto = Utils.hexToRgba(gto, opacityTo);
- }
- var stop1 = 0;
- var stop2 = 1;
- var stop3 = 1;
- var stop4 = null;
- if (stops !== null) {
- stop1 = typeof stops[0] !== 'undefined' ? stops[0] / 100 : 0;
- stop2 = typeof stops[1] !== 'undefined' ? stops[1] / 100 : 1;
- stop3 = typeof stops[2] !== 'undefined' ? stops[2] / 100 : 1;
- stop4 = typeof stops[3] !== 'undefined' ? stops[3] / 100 : null;
- }
- var radial = !!(w.config.chart.type === 'donut' || w.config.chart.type === 'pie' || w.config.chart.type === 'bubble');
- if (colorStops === null || colorStops.length === 0) {
- g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
- stop.at(stop1, gfrom, opacityFrom);
- stop.at(stop2, gto, opacityTo);
- stop.at(stop3, gto, opacityTo);
- if (stop4 !== null) {
- stop.at(stop4, gfrom, opacityFrom);
- }
- });
- } else {
- g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
- var gradientStops = Array.isArray(colorStops[i]) ? colorStops[i] : colorStops;
- gradientStops.forEach(function (s) {
- stop.at(s.offset / 100, s.color, s.opacity);
- });
- });
- }
- if (!radial) {
- if (style === 'vertical') {
- g.from(0, 0).to(0, 1);
- } else if (style === 'diagonal') {
- g.from(0, 0).to(1, 1);
- } else if (style === 'horizontal') {
- g.from(0, 1).to(1, 1);
- } else if (style === 'diagonal2') {
- g.from(1, 0).to(0, 1);
- }
- } else {
- var offx = w.globals.gridWidth / 2;
- var offy = w.globals.gridHeight / 2;
- if (w.config.chart.type !== 'bubble') {
- g.attr({
- gradientUnits: 'userSpaceOnUse',
- cx: offx,
- cy: offy,
- r: size
- });
- } else {
- g.attr({
- cx: 0.5,
- cy: 0.5,
- r: 0.8,
- fx: 0.2,
- fy: 0.2
- });
- }
- }
- return g;
- }
- }, {
- key: "drawText",
- value: function drawText(_ref3) {
- var x = _ref3.x,
- y = _ref3.y,
- text = _ref3.text,
- textAnchor = _ref3.textAnchor,
- fontSize = _ref3.fontSize,
- fontFamily = _ref3.fontFamily,
- fontWeight = _ref3.fontWeight,
- foreColor = _ref3.foreColor,
- opacity = _ref3.opacity,
- _ref3$cssClass = _ref3.cssClass,
- cssClass = _ref3$cssClass === void 0 ? '' : _ref3$cssClass,
- _ref3$isPlainText = _ref3.isPlainText,
- isPlainText = _ref3$isPlainText === void 0 ? true : _ref3$isPlainText;
- var w = this.w;
- if (typeof text === 'undefined') text = '';
- if (!textAnchor) {
- textAnchor = 'start';
- }
- if (!foreColor || !foreColor.length) {
- foreColor = w.config.chart.foreColor;
- }
- fontFamily = fontFamily || w.config.chart.fontFamily;
- fontWeight = fontWeight || 'regular';
- var elText;
- if (Array.isArray(text)) {
- elText = w.globals.dom.Paper.text(function (add) {
- for (var i = 0; i < text.length; i++) {
- i === 0 ? add.tspan(text[i]) : add.tspan(text[i]).newLine();
- }
- });
- } else {
- elText = isPlainText ? w.globals.dom.Paper.plain(text) : w.globals.dom.Paper.text(function (add) {
- return add.tspan(text);
- });
- }
- elText.attr({
- x: x,
- y: y,
- 'text-anchor': textAnchor,
- 'dominant-baseline': 'auto',
- 'font-size': fontSize,
- 'font-family': fontFamily,
- 'font-weight': fontWeight,
- fill: foreColor,
- class: 'apexcharts-text ' + cssClass
- });
- elText.node.style.fontFamily = fontFamily;
- elText.node.style.opacity = opacity;
- return elText;
- }
- }, {
- key: "drawMarker",
- value: function drawMarker(x, y, opts) {
- x = x || 0;
- var size = opts.pSize || 0;
- var elPoint = null;
- if (opts.shape === 'square') {
- var radius = opts.pRadius === undefined ? size / 2 : opts.pRadius;
- if (y === null || !size) {
- size = 0;
- radius = 0;
- }
- var nSize = size * 1.2 + radius;
- var p = this.drawRect(nSize, nSize, nSize, nSize, radius);
- p.attr({
- x: x - nSize / 2,
- y: y - nSize / 2,
- cx: x,
- cy: y,
- class: opts.class ? opts.class : '',
- fill: opts.pointFillColor,
- 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
- stroke: opts.pointStrokeColor,
- 'stroke-width': opts.pWidth ? opts.pWidth : 0,
- 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
- });
- elPoint = p;
- } else if (opts.shape === 'circle' || !opts.shape) {
- if (!Utils.isNumber(y)) {
- size = 0;
- y = 0;
- }
- elPoint = this.drawCircle(size, {
- cx: x,
- cy: y,
- class: opts.class ? opts.class : '',
- stroke: opts.pointStrokeColor,
- fill: opts.pointFillColor,
- 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
- 'stroke-width': opts.pWidth ? opts.pWidth : 0,
- 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
- });
- }
- return elPoint;
- }
- }, {
- key: "pathMouseEnter",
- value: function pathMouseEnter(path, e) {
- var w = this.w;
- var filters = new Filters(this.ctx);
- var i = parseInt(path.node.getAttribute('index'), 10);
- var j = parseInt(path.node.getAttribute('j'), 10);
- if (typeof w.config.chart.events.dataPointMouseEnter === 'function') {
- w.config.chart.events.dataPointMouseEnter(e, this.ctx, {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- }
- this.ctx.events.fireEvent('dataPointMouseEnter', [e, this.ctx, {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- }]);
- if (w.config.states.active.filter.type !== 'none') {
- if (path.node.getAttribute('selected') === 'true') {
- return;
- }
- }
- if (w.config.states.hover.filter.type !== 'none') {
- if (w.config.states.active.filter.type !== 'none' && !w.globals.isTouchDevice) {
- var hoverFilter = w.config.states.hover.filter;
- filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value);
- }
- }
- }
- }, {
- key: "pathMouseLeave",
- value: function pathMouseLeave(path, e) {
- var w = this.w;
- var filters = new Filters(this.ctx);
- var i = parseInt(path.node.getAttribute('index'), 10);
- var j = parseInt(path.node.getAttribute('j'), 10);
- if (typeof w.config.chart.events.dataPointMouseLeave === 'function') {
- w.config.chart.events.dataPointMouseLeave(e, this.ctx, {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- }
- this.ctx.events.fireEvent('dataPointMouseLeave', [e, this.ctx, {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- }]);
- if (w.config.states.active.filter.type !== 'none') {
- if (path.node.getAttribute('selected') === 'true') {
- return;
- }
- }
- if (w.config.states.hover.filter.type !== 'none') {
- filters.getDefaultFilter(path, i);
- }
- }
- }, {
- key: "pathMouseDown",
- value: function pathMouseDown(path, e) {
- var w = this.w;
- var filters = new Filters(this.ctx);
- var i = parseInt(path.node.getAttribute('index'), 10);
- var j = parseInt(path.node.getAttribute('j'), 10);
- var selected = 'false';
- if (path.node.getAttribute('selected') === 'true') {
- path.node.setAttribute('selected', 'false');
- if (w.globals.selectedDataPoints[i].indexOf(j) > -1) {
- var index = w.globals.selectedDataPoints[i].indexOf(j);
- w.globals.selectedDataPoints[i].splice(index, 1);
- }
- } else {
- if (!w.config.states.active.allowMultipleDataPointsSelection && w.globals.selectedDataPoints.length > 0) {
- w.globals.selectedDataPoints = [];
- var elPaths = w.globals.dom.Paper.select('.apexcharts-series path').members;
- var elCircles = w.globals.dom.Paper.select('.apexcharts-series circle, .apexcharts-series rect').members;
- var deSelect = function deSelect(els) {
- Array.prototype.forEach.call(els, function (el) {
- el.node.setAttribute('selected', 'false');
- filters.getDefaultFilter(el, i);
- });
- };
- deSelect(elPaths);
- deSelect(elCircles);
- }
- path.node.setAttribute('selected', 'true');
- selected = 'true';
- if (typeof w.globals.selectedDataPoints[i] === 'undefined') {
- w.globals.selectedDataPoints[i] = [];
- }
- w.globals.selectedDataPoints[i].push(j);
- }
- if (selected === 'true') {
- var activeFilter = w.config.states.active.filter;
- if (activeFilter !== 'none') {
- filters.applyFilter(path, i, activeFilter.type, activeFilter.value);
- }
- } else {
- if (w.config.states.active.filter.type !== 'none') {
- filters.getDefaultFilter(path, i);
- }
- }
- if (typeof w.config.chart.events.dataPointSelection === 'function') {
- w.config.chart.events.dataPointSelection(e, this.ctx, {
- selectedDataPoints: w.globals.selectedDataPoints,
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- }
- if (e) {
- this.ctx.events.fireEvent('dataPointSelection', [e, this.ctx, {
- selectedDataPoints: w.globals.selectedDataPoints,
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- }]);
- }
- }
- }, {
- key: "rotateAroundCenter",
- value: function rotateAroundCenter(el) {
- var coord = el.getBBox();
- var x = coord.x + coord.width / 2;
- var y = coord.y + coord.height / 2;
- return {
- x: x,
- y: y
- };
- }
- }, {
- key: "getTextRects",
- value: function getTextRects(text, fontSize, fontFamily, transform) {
- var useBBox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
- var w = this.w;
- var virtualText = this.drawText({
- x: -200,
- y: -200,
- text: text,
- textAnchor: 'start',
- fontSize: fontSize,
- fontFamily: fontFamily,
- foreColor: '#fff',
- opacity: 0
- });
- if (transform) {
- virtualText.attr('transform', transform);
- }
- w.globals.dom.Paper.add(virtualText);
- var rect = virtualText.bbox();
- if (!useBBox) {
- rect = virtualText.node.getBoundingClientRect();
- }
- virtualText.remove();
- return {
- width: rect.width,
- height: rect.height
- };
- }
-
- }, {
- key: "placeTextWithEllipsis",
- value: function placeTextWithEllipsis(textObj, textString, width) {
- if (typeof textObj.getComputedTextLength !== 'function') return;
- textObj.textContent = textString;
- if (textString.length > 0) {
-
- if (textObj.getComputedTextLength() >= width / 0.8) {
- for (var x = textString.length - 3; x > 0; x -= 3) {
- if (textObj.getSubStringLength(0, x) <= width / 0.8) {
- textObj.textContent = textString.substring(0, x) + '...';
- return;
- }
- }
- textObj.textContent = '.';
- }
- }
- }
- }], [{
- key: "setAttrs",
- value: function setAttrs(el, attrs) {
- for (var key in attrs) {
- if (attrs.hasOwnProperty(key)) {
- el.setAttribute(key, attrs[key]);
- }
- }
- }
- }]);
- return Graphics;
- }();
- var Helpers = function () {
- function Helpers(annoCtx) {
- _classCallCheck(this, Helpers);
- this.w = annoCtx.w;
- this.annoCtx = annoCtx;
- }
- _createClass(Helpers, [{
- key: "setOrientations",
- value: function setOrientations(anno) {
- var annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var w = this.w;
- if (anno.label.orientation === 'vertical') {
- var i = annoIndex !== null ? annoIndex : 0;
- var xAnno = w.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(i, "']"));
- if (xAnno !== null) {
- var xAnnoCoord = xAnno.getBoundingClientRect();
- xAnno.setAttribute('x', parseFloat(xAnno.getAttribute('x')) - xAnnoCoord.height + 4);
- if (anno.label.position === 'top') {
- xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) + xAnnoCoord.width);
- } else {
- xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) - xAnnoCoord.width);
- }
- var annoRotatingCenter = this.annoCtx.graphics.rotateAroundCenter(xAnno);
- var x = annoRotatingCenter.x;
- var y = annoRotatingCenter.y;
- xAnno.setAttribute('transform', "rotate(-90 ".concat(x, " ").concat(y, ")"));
- }
- }
- }
- }, {
- key: "addBackgroundToAnno",
- value: function addBackgroundToAnno(annoEl, anno) {
- var w = this.w;
- if (!anno.label.text || anno.label.text && !anno.label.text.trim()) return null;
- var elGridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid').getBoundingClientRect();
- var coords = annoEl.getBoundingClientRect();
- var pleft = anno.label.style.padding.left;
- var pright = anno.label.style.padding.right;
- var ptop = anno.label.style.padding.top;
- var pbottom = anno.label.style.padding.bottom;
- if (anno.label.orientation === 'vertical') {
- ptop = anno.label.style.padding.left;
- pbottom = anno.label.style.padding.right;
- pleft = anno.label.style.padding.top;
- pright = anno.label.style.padding.bottom;
- }
- var x1 = coords.left - elGridRect.left - pleft;
- var y1 = coords.top - elGridRect.top - ptop;
- var elRect = this.annoCtx.graphics.drawRect(x1, y1, coords.width + pleft + pright, coords.height + ptop + pbottom, 0, anno.label.style.background, 1, anno.label.borderWidth, anno.label.borderColor, 0);
- if (anno.id) {
- elRect.node.classList.add(anno.id);
- }
- return elRect;
- }
- }, {
- key: "annotationsBackground",
- value: function annotationsBackground() {
- var _this = this;
- var w = this.w;
- var add = function add(anno, i, type) {
- var annoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(i, "']"));
- if (annoLabel) {
- var parent = annoLabel.parentNode;
- var elRect = _this.addBackgroundToAnno(annoLabel, anno);
- if (elRect) {
- parent.insertBefore(elRect.node, annoLabel);
- }
- }
- };
- w.config.annotations.xaxis.map(function (anno, i) {
- add(anno, i, 'xaxis');
- });
- w.config.annotations.yaxis.map(function (anno, i) {
- add(anno, i, 'yaxis');
- });
- w.config.annotations.points.map(function (anno, i) {
- add(anno, i, 'point');
- });
- }
- }, {
- key: "makeAnnotationDraggable",
- value: function makeAnnotationDraggable(el, annoType, index) {
- var w = this.w;
- var anno = w.config.annotations[annoType][index];
-
- el.draggable().on('dragend', function (de) {
- var x = de.target.getAttribute('x');
- var y = de.target.getAttribute('y');
- var cx = de.target.getAttribute('cx');
- var cy = de.target.getAttribute('cy');
- anno.x = x;
- anno.y = y;
- if (cx && cy) {
- anno.x = cx;
- anno.y = cy;
- }
- });
- el.node.addEventListener('mousedown', function (e) {
- e.stopPropagation();
- el.selectize({
- pointSize: 8,
- rotationPoint: false,
- pointType: 'rect'
- });
- el.resize().on('resizedone', function (re) {
- var width = re.target.getAttribute('width');
- var height = re.target.getAttribute('height');
- var r = re.target.getAttribute('r');
- anno.width = width;
- anno.height = height;
- if (r) {
- anno.radius = r;
- }
- });
- });
- }
- }, {
- key: "getStringX",
- value: function getStringX(x) {
- var w = this.w;
- var rX = x;
- if (w.config.xaxis.convertedCatToNumeric && w.globals.categoryLabels.length) {
- x = w.globals.categoryLabels.indexOf(x) + 1;
- }
- var catIndex = w.globals.labels.indexOf(x);
- var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
- if (xLabel) {
- rX = parseFloat(xLabel.getAttribute('x'));
- }
- return rX;
- }
- }]);
- return Helpers;
- }();
- var XAnnotations = function () {
- function XAnnotations(annoCtx) {
- _classCallCheck(this, XAnnotations);
- this.w = annoCtx.w;
- this.annoCtx = annoCtx;
- this.invertAxis = this.annoCtx.invertAxis;
- }
- _createClass(XAnnotations, [{
- key: "addXaxisAnnotation",
- value: function addXaxisAnnotation(anno, parent, index) {
- var w = this.w;
- var min = this.invertAxis ? w.globals.minY : w.globals.minX;
- var max = this.invertAxis ? w.globals.maxY : w.globals.maxX;
- var range = this.invertAxis ? w.globals.yRange[0] : w.globals.xRange;
- var x1 = (anno.x - min) / (range / w.globals.gridWidth);
- if (this.annoCtx.inversedReversedAxis) {
- x1 = (max - anno.x) / (range / w.globals.gridWidth);
- }
- var text = anno.label.text;
- if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
- x1 = this.annoCtx.helpers.getStringX(anno.x);
- }
- var strokeDashArray = anno.strokeDashArray;
- if (!Utils.isNumber(x1)) return;
- if (anno.x2 === null || typeof anno.x2 === 'undefined') {
- var line = this.annoCtx.graphics.drawLine(x1 + anno.offsetX,
- 0 + anno.offsetY,
- x1 + anno.offsetX,
- w.globals.gridHeight + anno.offsetY,
- anno.borderColor,
- strokeDashArray,
- anno.borderWidth);
- parent.appendChild(line.node);
- if (anno.id) {
- line.node.classList.add(anno.id);
- }
- } else {
- var x2 = (anno.x2 - min) / (range / w.globals.gridWidth);
- if (this.annoCtx.inversedReversedAxis) {
- x2 = (max - anno.x2) / (range / w.globals.gridWidth);
- }
- if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
- x2 = this.annoCtx.helpers.getStringX(anno.x2);
- }
- if (x2 < x1) {
- var temp = x1;
- x1 = x2;
- x2 = temp;
- }
- var rect = this.annoCtx.graphics.drawRect(x1 + anno.offsetX,
- 0 + anno.offsetY,
- x2 - x1,
- w.globals.gridHeight + anno.offsetY,
- 0,
- anno.fillColor,
- anno.opacity,
- 1,
- anno.borderColor,
- strokeDashArray
- );
- rect.node.classList.add('apexcharts-annotation-rect');
- rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
- parent.appendChild(rect.node);
- if (anno.id) {
- rect.node.classList.add(anno.id);
- }
- }
- var textY = anno.label.position === 'top' ? 4 : w.globals.gridHeight;
- var textRects = this.annoCtx.graphics.getTextRects(text, parseFloat(anno.label.style.fontSize));
- var elText = this.annoCtx.graphics.drawText({
- x: x1 + anno.label.offsetX,
- y: textY + anno.label.offsetY - (anno.label.orientation === 'vertical' ? anno.label.position === 'top' ? textRects.width / 2 - 12 : -textRects.width / 2 : 0),
- text: text,
- textAnchor: anno.label.textAnchor,
- fontSize: anno.label.style.fontSize,
- fontFamily: anno.label.style.fontFamily,
- fontWeight: anno.label.style.fontWeight,
- foreColor: anno.label.style.color,
- cssClass: "apexcharts-xaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
- });
- elText.attr({
- rel: index
- });
- parent.appendChild(elText.node);
- this.annoCtx.helpers.setOrientations(anno, index);
- }
- }, {
- key: "drawXAxisAnnotations",
- value: function drawXAxisAnnotations() {
- var _this = this;
- var w = this.w;
- var elg = this.annoCtx.graphics.group({
- class: 'apexcharts-xaxis-annotations'
- });
- w.config.annotations.xaxis.map(function (anno, index) {
- _this.addXaxisAnnotation(anno, elg.node, index);
- });
- return elg;
- }
- }]);
- return XAnnotations;
- }();
- var YAnnotations = function () {
- function YAnnotations(annoCtx) {
- _classCallCheck(this, YAnnotations);
- this.w = annoCtx.w;
- this.annoCtx = annoCtx;
- }
- _createClass(YAnnotations, [{
- key: "addYaxisAnnotation",
- value: function addYaxisAnnotation(anno, parent, index) {
- var w = this.w;
- var strokeDashArray = anno.strokeDashArray;
- var y1 = this._getY1Y2('y1', anno);
- var y2;
- var text = anno.label.text;
- if (anno.y2 === null || typeof anno.y2 === 'undefined') {
- var line = this.annoCtx.graphics.drawLine(0 + anno.offsetX,
- y1 + anno.offsetY,
- w.globals.gridWidth + anno.offsetX,
- y1 + anno.offsetY,
- anno.borderColor,
- strokeDashArray,
- anno.borderWidth);
- parent.appendChild(line.node);
- if (anno.id) {
- line.node.classList.add(anno.id);
- }
- } else {
- y2 = this._getY1Y2('y2', anno);
- if (y2 > y1) {
- var temp = y1;
- y1 = y2;
- y2 = temp;
- }
- var rect = this.annoCtx.graphics.drawRect(0 + anno.offsetX,
- y2 + anno.offsetY,
- w.globals.gridWidth + anno.offsetX,
- y1 - y2,
- 0,
- anno.fillColor,
- anno.opacity,
- 1,
- anno.borderColor,
- strokeDashArray
- );
- rect.node.classList.add('apexcharts-annotation-rect');
- rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
- parent.appendChild(rect.node);
- if (anno.id) {
- rect.node.classList.add(anno.id);
- }
- }
- var textX = anno.label.position === 'right' ? w.globals.gridWidth : 0;
- var elText = this.annoCtx.graphics.drawText({
- x: textX + anno.label.offsetX,
- y: (y2 || y1) + anno.label.offsetY - 3,
- text: text,
- textAnchor: anno.label.textAnchor,
- fontSize: anno.label.style.fontSize,
- fontFamily: anno.label.style.fontFamily,
- fontWeight: anno.label.style.fontWeight,
- foreColor: anno.label.style.color,
- cssClass: "apexcharts-yaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
- });
- elText.attr({
- rel: index
- });
- parent.appendChild(elText.node);
- }
- }, {
- key: "_getY1Y2",
- value: function _getY1Y2(type, anno) {
- var y = type === 'y1' ? anno.y : anno.y2;
- var yP;
- var w = this.w;
- if (this.annoCtx.invertAxis) {
- var catIndex = w.globals.labels.indexOf(y);
- if (w.config.xaxis.convertedCatToNumeric) {
- catIndex = w.globals.categoryLabels.indexOf(y);
- }
- var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
- if (xLabel) {
- yP = parseFloat(xLabel.getAttribute('y'));
- }
- } else {
- yP = w.globals.gridHeight - (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
- yP = (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- }
- }
- return yP;
- }
- }, {
- key: "drawYAxisAnnotations",
- value: function drawYAxisAnnotations() {
- var _this = this;
- var w = this.w;
- var elg = this.annoCtx.graphics.group({
- class: 'apexcharts-yaxis-annotations'
- });
- w.config.annotations.yaxis.map(function (anno, index) {
- _this.addYaxisAnnotation(anno, elg.node, index);
- });
- return elg;
- }
- }]);
- return YAnnotations;
- }();
- var PointAnnotations = function () {
- function PointAnnotations(annoCtx) {
- _classCallCheck(this, PointAnnotations);
- this.w = annoCtx.w;
- this.annoCtx = annoCtx;
- }
- _createClass(PointAnnotations, [{
- key: "addPointAnnotation",
- value: function addPointAnnotation(anno, parent, index) {
- var w = this.w;
- var x = 0;
- var y = 0;
- var pointY = 0;
- if (this.annoCtx.invertAxis) {
- console.warn('Point annotation is not supported in horizontal bar charts.');
- }
- if (typeof anno.x === 'string') {
- var catIndex = w.globals.labels.indexOf(anno.x);
- if (w.config.xaxis.convertedCatToNumeric) {
- catIndex = w.globals.categoryLabels.indexOf(anno.x);
- }
- x = this.annoCtx.helpers.getStringX(anno.x);
- var annoY = anno.y;
- if (anno.y === null) {
- annoY = w.globals.series[anno.seriesIndex][catIndex];
- }
- y = w.globals.gridHeight - (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) - parseFloat(anno.label.style.fontSize) - anno.marker.size;
- pointY = w.globals.gridHeight - (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
- y = (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) + parseFloat(anno.label.style.fontSize) + anno.marker.size;
- pointY = (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- }
- } else {
- x = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth);
- y = w.globals.gridHeight - (parseFloat(anno.y) - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) - parseFloat(anno.label.style.fontSize) - anno.marker.size;
- pointY = w.globals.gridHeight - (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
- y = (parseFloat(anno.y) - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) - parseFloat(anno.label.style.fontSize) - anno.marker.size;
- pointY = (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
- }
- }
- if (!Utils.isNumber(x)) return;
- var optsPoints = {
- pSize: anno.marker.size,
- pWidth: anno.marker.strokeWidth,
- pointFillColor: anno.marker.fillColor,
- pointStrokeColor: anno.marker.strokeColor,
- shape: anno.marker.shape,
- pRadius: anno.marker.radius,
- class: "apexcharts-point-annotation-marker ".concat(anno.marker.cssClass, " ").concat(anno.id ? anno.id : '')
- };
- var point = this.annoCtx.graphics.drawMarker(x + anno.marker.offsetX, pointY + anno.marker.offsetY, optsPoints);
- parent.appendChild(point.node);
- var text = anno.label.text ? anno.label.text : '';
- var elText = this.annoCtx.graphics.drawText({
- x: x + anno.label.offsetX,
- y: y + anno.label.offsetY,
- text: text,
- textAnchor: anno.label.textAnchor,
- fontSize: anno.label.style.fontSize,
- fontFamily: anno.label.style.fontFamily,
- fontWeight: anno.label.style.fontWeight,
- foreColor: anno.label.style.color,
- cssClass: "apexcharts-point-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
- });
- elText.attr({
- rel: index
- });
- parent.appendChild(elText.node);
- if (anno.customSVG.SVG) {
- var g = this.annoCtx.graphics.group({
- class: 'apexcharts-point-annotations-custom-svg ' + anno.customSVG.cssClass
- });
- g.attr({
- transform: "translate(".concat(x + anno.customSVG.offsetX, ", ").concat(y + anno.customSVG.offsetY, ")")
- });
- g.node.innerHTML = anno.customSVG.SVG;
- parent.appendChild(g.node);
- }
- if (anno.image.path) {
- var imgWidth = anno.image.width ? anno.image.width : 20;
- var imgHeight = anno.image.height ? anno.image.height : 20;
- this.annoCtx.addImage({
- x: x + anno.image.offsetX - imgWidth / 2,
- y: y + anno.image.offsetY - imgHeight / 2,
- width: imgWidth,
- height: imgHeight,
- path: anno.image.path,
- appendTo: '.apexcharts-point-annotations'
- });
- }
- }
- }, {
- key: "drawPointAnnotations",
- value: function drawPointAnnotations() {
- var _this = this;
- var w = this.w;
- var elg = this.annoCtx.graphics.group({
- class: 'apexcharts-point-annotations'
- });
- w.config.annotations.points.map(function (anno, index) {
- _this.addPointAnnotation(anno, elg.node, index);
- });
- return elg;
- }
- }]);
- return PointAnnotations;
- }();
- const name = "en";
- const options = {
- months: [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
- ],
- shortMonths: [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- ],
- days: [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
- ],
- shortDays: [
- "Sun",
- "Mon",
- "Tue",
- "Wed",
- "Thu",
- "Fri",
- "Sat"
- ],
- toolbar: {
- exportToSVG: "Download SVG",
- exportToPNG: "Download PNG",
- exportToCSV: "Download CSV",
- menu: "Menu",
- selection: "Selection",
- selectionZoom: "Selection Zoom",
- zoomIn: "Zoom In",
- zoomOut: "Zoom Out",
- pan: "Panning",
- reset: "Reset Zoom"
- }
- };
- var en = {
- name: name,
- options: options
- };
- var Options = function () {
- function Options() {
- _classCallCheck(this, Options);
- this.yAxis = {
- show: true,
- showAlways: false,
- showForNullSeries: true,
- seriesName: undefined,
- opposite: false,
- reversed: false,
- logarithmic: false,
- tickAmount: undefined,
- forceNiceScale: false,
- max: undefined,
- min: undefined,
- floating: false,
- decimalsInFloat: undefined,
- labels: {
- show: true,
- minWidth: 0,
- maxWidth: 160,
- offsetX: 0,
- offsetY: 0,
- align: undefined,
- rotate: 0,
- padding: 20,
- style: {
- colors: [],
- fontSize: '11px',
- fontWeight: 400,
- fontFamily: undefined,
- cssClass: ''
- },
- formatter: undefined
- },
- axisBorder: {
- show: false,
- color: '#e0e0e0',
- width: 1,
- offsetX: 0,
- offsetY: 0
- },
- axisTicks: {
- show: false,
- color: '#e0e0e0',
- width: 6,
- offsetX: 0,
- offsetY: 0
- },
- title: {
- text: undefined,
- rotate: 90,
- offsetY: 0,
- offsetX: 0,
- style: {
- color: undefined,
- fontSize: '11px',
- fontWeight: 900,
- fontFamily: undefined,
- cssClass: ''
- }
- },
- tooltip: {
- enabled: false,
- offsetX: 0
- },
- crosshairs: {
- show: true,
- position: 'front',
- stroke: {
- color: '#b6b6b6',
- width: 1,
- dashArray: 0
- }
- }
- };
- this.pointAnnotation = {
- x: 0,
- y: null,
- yAxisIndex: 0,
- seriesIndex: 0,
- marker: {
- size: 4,
- fillColor: '#fff',
- strokeWidth: 2,
- strokeColor: '#333',
- shape: 'circle',
- offsetX: 0,
- offsetY: 0,
- radius: 2,
- cssClass: ''
- },
- label: {
- borderColor: '#c2c2c2',
- borderWidth: 1,
- text: undefined,
- textAnchor: 'middle',
- offsetX: 0,
- offsetY: -15,
- style: {
- background: '#fff',
- color: undefined,
- fontSize: '11px',
- fontFamily: undefined,
- fontWeight: 400,
- cssClass: '',
- padding: {
- left: 5,
- right: 5,
- top: 2,
- bottom: 2
- }
- }
- },
- customSVG: {
-
- SVG: undefined,
- cssClass: undefined,
- offsetX: 0,
- offsetY: 0
- },
- image: {
- path: undefined,
- width: 20,
- height: 20,
- offsetX: 0,
- offsetY: 0
- }
- };
- this.yAxisAnnotation = {
- y: 0,
- y2: null,
- strokeDashArray: 1,
- fillColor: '#c2c2c2',
- borderColor: '#c2c2c2',
- borderWidth: 1,
- opacity: 0.3,
- offsetX: 0,
- offsetY: 0,
- yAxisIndex: 0,
- label: {
- borderColor: '#c2c2c2',
- borderWidth: 1,
- text: undefined,
- textAnchor: 'end',
- position: 'right',
- offsetX: 0,
- offsetY: -3,
- style: {
- background: '#fff',
- color: undefined,
- fontSize: '11px',
- fontFamily: undefined,
- fontWeight: 400,
- cssClass: '',
- padding: {
- left: 5,
- right: 5,
- top: 2,
- bottom: 2
- }
- }
- }
- };
- this.xAxisAnnotation = {
- x: 0,
- x2: null,
- strokeDashArray: 1,
- fillColor: '#c2c2c2',
- borderColor: '#c2c2c2',
- borderWidth: 1,
- opacity: 0.3,
- offsetX: 0,
- offsetY: 0,
- label: {
- borderColor: '#c2c2c2',
- borderWidth: 1,
- text: undefined,
- textAnchor: 'middle',
- orientation: 'vertical',
- position: 'top',
- offsetX: 0,
- offsetY: 0,
- style: {
- background: '#fff',
- color: undefined,
- fontSize: '11px',
- fontFamily: undefined,
- fontWeight: 400,
- cssClass: '',
- padding: {
- left: 5,
- right: 5,
- top: 2,
- bottom: 2
- }
- }
- }
- };
- this.text = {
- x: 0,
- y: 0,
- text: '',
- textAnchor: 'start',
- foreColor: undefined,
- fontSize: '13px',
- fontFamily: undefined,
- fontWeight: 400,
- appendTo: '.apexcharts-annotations',
- backgroundColor: 'transparent',
- borderColor: '#c2c2c2',
- borderRadius: 0,
- borderWidth: 0,
- paddingLeft: 4,
- paddingRight: 4,
- paddingTop: 2,
- paddingBottom: 2
- };
- this.shape = {
- x: 0,
- y: 0,
- type: 'rect',
- width: '100%',
-
- height: 50,
- appendTo: '.apexcharts-annotations',
- backgroundColor: '#fff',
- opacity: 1,
- borderWidth: 0,
- borderRadius: 4,
- borderColor: '#c2c2c2'
- };
- }
- _createClass(Options, [{
- key: "init",
- value: function init() {
- return {
- annotations: {
- position: 'front',
- yaxis: [this.yAxisAnnotation],
- xaxis: [this.xAxisAnnotation],
- points: [this.pointAnnotation],
- texts: [],
- images: [],
- shapes: []
- },
- chart: {
- animations: {
- enabled: true,
- easing: 'easeinout',
-
- speed: 800,
- animateGradually: {
- delay: 150,
- enabled: true
- },
- dynamicAnimation: {
- enabled: true,
- speed: 350
- }
- },
- background: 'transparent',
- locales: [en],
- defaultLocale: 'en',
- dropShadow: {
- enabled: false,
- enabledOnSeries: undefined,
- top: 2,
- left: 2,
- blur: 4,
- color: '#000',
- opacity: 0.35
- },
- events: {
- animationEnd: undefined,
- beforeMount: undefined,
- mounted: undefined,
- updated: undefined,
- click: undefined,
- mouseMove: undefined,
- legendClick: undefined,
- markerClick: undefined,
- selection: undefined,
- dataPointSelection: undefined,
- dataPointMouseEnter: undefined,
- dataPointMouseLeave: undefined,
- beforeZoom: undefined,
- zoomed: undefined,
- scrolled: undefined
- },
- foreColor: '#373d3f',
- fontFamily: 'Helvetica, Arial, sans-serif',
- height: 'auto',
- parentHeightOffset: 15,
- redrawOnParentResize: true,
- id: undefined,
- group: undefined,
- offsetX: 0,
- offsetY: 0,
- selection: {
- enabled: false,
- type: 'x',
-
- fill: {
- color: '#24292e',
- opacity: 0.1
- },
- stroke: {
- width: 1,
- color: '#24292e',
- opacity: 0.4,
- dashArray: 3
- },
- xaxis: {
- min: undefined,
- max: undefined
- },
- yaxis: {
- min: undefined,
- max: undefined
- }
- },
- sparkline: {
- enabled: false
- },
- brush: {
- enabled: false,
- autoScaleYaxis: true,
- target: undefined
- },
- stacked: false,
- stackType: 'normal',
- toolbar: {
- show: true,
- offsetX: 0,
- offsetY: 0,
- tools: {
- download: true,
- selection: true,
- zoom: true,
- zoomin: true,
- zoomout: true,
- pan: true,
- reset: true,
- customIcons: []
- },
- autoSelected: 'zoom'
- },
- type: 'line',
- width: '100%',
- zoom: {
- enabled: true,
- type: 'x',
- autoScaleYaxis: false,
- zoomedArea: {
- fill: {
- color: '#90CAF9',
- opacity: 0.4
- },
- stroke: {
- color: '#0D47A1',
- opacity: 0.4,
- width: 1
- }
- }
- }
- },
- plotOptions: {
- bar: {
- horizontal: false,
- columnWidth: '70%',
-
- barHeight: '70%',
-
- distributed: false,
- startingShape: 'flat',
- endingShape: 'flat',
- colors: {
- ranges: [],
- backgroundBarColors: [],
- backgroundBarOpacity: 1,
- backgroundBarRadius: 0
- },
- dataLabels: {
- position: 'top',
-
- maxItems: 100,
- hideOverflowingLabels: true,
- orientation: 'horizontal'
- }
- },
- bubble: {
- minBubbleRadius: undefined,
- maxBubbleRadius: undefined
- },
- candlestick: {
- colors: {
- upward: '#00B746',
- downward: '#EF403C'
- },
- wick: {
- useFillColor: true
- }
- },
- heatmap: {
- radius: 2,
- enableShades: true,
- shadeIntensity: 0.5,
- reverseNegativeShade: false,
- distributed: false,
- useFillColorAsStroke: false,
- colorScale: {
- inverse: false,
- ranges: [],
- min: undefined,
- max: undefined
- }
- },
- radialBar: {
- inverseOrder: false,
- startAngle: 0,
- endAngle: 360,
- offsetX: 0,
- offsetY: 0,
- hollow: {
- margin: 5,
- size: '50%',
- background: 'transparent',
- image: undefined,
- imageWidth: 150,
- imageHeight: 150,
- imageOffsetX: 0,
- imageOffsetY: 0,
- imageClipped: true,
- position: 'front',
- dropShadow: {
- enabled: false,
- top: 0,
- left: 0,
- blur: 3,
- color: '#000',
- opacity: 0.5
- }
- },
- track: {
- show: true,
- startAngle: undefined,
- endAngle: undefined,
- background: '#f2f2f2',
- strokeWidth: '97%',
- opacity: 1,
- margin: 5,
-
- dropShadow: {
- enabled: false,
- top: 0,
- left: 0,
- blur: 3,
- color: '#000',
- opacity: 0.5
- }
- },
- dataLabels: {
- show: true,
- name: {
- show: true,
- fontSize: '16px',
- fontFamily: undefined,
- fontWeight: 600,
- color: undefined,
- offsetY: 0,
- formatter: function formatter(val) {
- return val;
- }
- },
- value: {
- show: true,
- fontSize: '14px',
- fontFamily: undefined,
- fontWeight: 400,
- color: undefined,
- offsetY: 16,
- formatter: function formatter(val) {
- return val + '%';
- }
- },
- total: {
- show: false,
- label: 'Total',
- fontSize: '16px',
- fontWeight: 600,
- fontFamily: undefined,
- color: undefined,
- formatter: function formatter(w) {
- return w.globals.seriesTotals.reduce(function (a, b) {
- return a + b;
- }, 0) / w.globals.series.length + '%';
- }
- }
- }
- },
- pie: {
- customScale: 1,
- offsetX: 0,
- offsetY: 0,
- expandOnClick: true,
- dataLabels: {
-
- offset: 0,
-
- minAngleToShowLabel: 10
- },
- donut: {
- size: '65%',
- background: 'transparent',
- labels: {
-
- show: false,
- name: {
- show: true,
- fontSize: '16px',
- fontFamily: undefined,
- fontWeight: 600,
- color: undefined,
- offsetY: -10,
- formatter: function formatter(val) {
- return val;
- }
- },
- value: {
- show: true,
- fontSize: '20px',
- fontFamily: undefined,
- fontWeight: 400,
- color: undefined,
- offsetY: 10,
- formatter: function formatter(val) {
- return val;
- }
- },
- total: {
- show: false,
- showAlways: false,
- label: 'Total',
- fontSize: '16px',
- fontWeight: 400,
- fontFamily: undefined,
- color: undefined,
- formatter: function formatter(w) {
- return w.globals.seriesTotals.reduce(function (a, b) {
- return a + b;
- }, 0);
- }
- }
- }
- }
- },
- radar: {
- size: undefined,
- offsetX: 0,
- offsetY: 0,
- polygons: {
-
- strokeColors: '#e8e8e8',
- connectorColors: '#e8e8e8',
- fill: {
- colors: undefined
- }
- }
- }
- },
- colors: undefined,
- dataLabels: {
- enabled: true,
- enabledOnSeries: undefined,
- formatter: function formatter(val) {
- return val !== null ? val : '';
- },
- textAnchor: 'middle',
- distributed: false,
- offsetX: 0,
- offsetY: 0,
- style: {
- fontSize: '12px',
- fontFamily: undefined,
- fontWeight: 600,
- colors: undefined
- },
- background: {
- enabled: true,
- foreColor: '#fff',
- borderRadius: 2,
- padding: 4,
- opacity: 0.9,
- borderWidth: 1,
- borderColor: '#fff',
- dropShadow: {
- enabled: false,
- top: 1,
- left: 1,
- blur: 1,
- color: '#000',
- opacity: 0.45
- }
- },
- dropShadow: {
- enabled: false,
- top: 1,
- left: 1,
- blur: 1,
- color: '#000',
- opacity: 0.45
- }
- },
- fill: {
- type: 'solid',
- colors: undefined,
-
- opacity: 0.85,
- gradient: {
- shade: 'dark',
- type: 'horizontal',
- shadeIntensity: 0.5,
- gradientToColors: undefined,
- inverseColors: true,
- opacityFrom: 1,
- opacityTo: 1,
- stops: [0, 50, 100],
- colorStops: []
- },
- image: {
- src: [],
- width: undefined,
-
- height: undefined
- },
- pattern: {
- style: 'squares',
-
- width: 6,
- height: 6,
- strokeWidth: 2
- }
- },
- grid: {
- show: true,
- borderColor: '#e0e0e0',
- strokeDashArray: 0,
- position: 'back',
- xaxis: {
- lines: {
- show: false
- }
- },
- yaxis: {
- lines: {
- show: true
- }
- },
- row: {
- colors: undefined,
-
- opacity: 0.5
- },
- column: {
- colors: undefined,
-
- opacity: 0.5
- },
- padding: {
- top: 0,
- right: 10,
- bottom: 0,
- left: 12
- }
- },
- labels: [],
- legend: {
- show: true,
- showForSingleSeries: false,
- showForNullSeries: true,
- showForZeroSeries: true,
- floating: false,
- position: 'bottom',
-
-
- horizontalAlign: 'center',
-
- inverseOrder: false,
- fontSize: '12px',
- fontFamily: undefined,
- fontWeight: 400,
- width: undefined,
- height: undefined,
- formatter: undefined,
- tooltipHoverFormatter: undefined,
- offsetX: -20,
- offsetY: 0,
- labels: {
- colors: undefined,
- useSeriesColors: false
- },
- markers: {
- width: 12,
- height: 12,
- strokeWidth: 0,
- fillColors: undefined,
- strokeColor: '#fff',
- radius: 12,
- customHTML: undefined,
- offsetX: 0,
- offsetY: 0,
- onClick: undefined
- },
- itemMargin: {
- horizontal: 5,
- vertical: 0
- },
- onItemClick: {
- toggleDataSeries: true
- },
- onItemHover: {
- highlightDataSeries: true
- }
- },
- markers: {
- discrete: [],
- size: 0,
- colors: undefined,
-
- strokeColors: '#fff',
- strokeWidth: 2,
- strokeOpacity: 0.9,
- strokeDashArray: 0,
- fillOpacity: 1,
- shape: 'circle',
- radius: 2,
- offsetX: 0,
- offsetY: 0,
- onClick: undefined,
- onDblClick: undefined,
- showNullDataPoints: true,
- hover: {
- size: undefined,
- sizeOffset: 3
- }
- },
- noData: {
- text: undefined,
- align: 'center',
- verticalAlign: 'middle',
- offsetX: 0,
- offsetY: 0,
- style: {
- color: undefined,
- fontSize: '14px',
- fontFamily: undefined
- }
- },
- responsive: [],
-
- series: undefined,
- states: {
- normal: {
- filter: {
- type: 'none',
- value: 0
- }
- },
- hover: {
- filter: {
- type: 'lighten',
- value: 0.15
- }
- },
- active: {
- allowMultipleDataPointsSelection: false,
- filter: {
- type: 'darken',
- value: 0.65
- }
- }
- },
- title: {
- text: undefined,
- align: 'left',
- margin: 5,
- offsetX: 0,
- offsetY: 0,
- floating: false,
- style: {
- fontSize: '14px',
- fontWeight: 900,
- fontFamily: undefined,
- color: undefined
- }
- },
- subtitle: {
- text: undefined,
- align: 'left',
- margin: 5,
- offsetX: 0,
- offsetY: 30,
- floating: false,
- style: {
- fontSize: '12px',
- fontWeight: 400,
- fontFamily: undefined,
- color: undefined
- }
- },
- stroke: {
- show: true,
- curve: 'smooth',
-
- lineCap: 'butt',
-
- width: 2,
- colors: undefined,
-
- dashArray: 0
- },
- tooltip: {
- enabled: true,
- enabledOnSeries: undefined,
- shared: true,
- followCursor: false,
-
- intersect: false,
-
- inverseOrder: false,
- custom: undefined,
- fillSeriesColor: false,
- theme: 'light',
- style: {
- fontSize: '12px',
- fontFamily: undefined
- },
- onDatasetHover: {
- highlightDataSeries: false
- },
- x: {
-
- show: true,
- format: 'dd MMM',
-
- formatter: undefined
- },
- y: {
- formatter: undefined,
- title: {
- formatter: function formatter(seriesName) {
- return seriesName;
- }
- }
- },
- z: {
- formatter: undefined,
- title: 'Size: '
- },
- marker: {
- show: true,
- fillColors: undefined
- },
- items: {
- display: 'flex'
- },
- fixed: {
- enabled: false,
- position: 'topRight',
-
- offsetX: 0,
- offsetY: 0
- }
- },
- xaxis: {
- type: 'category',
- categories: [],
- convertedCatToNumeric: false,
-
- sorted: true,
- offsetX: 0,
- offsetY: 0,
- labels: {
- show: true,
- rotate: -45,
- rotateAlways: false,
- hideOverlappingLabels: true,
- trim: false,
- minHeight: undefined,
- maxHeight: 120,
- showDuplicates: true,
- style: {
- colors: [],
- fontSize: '12px',
- fontWeight: 400,
- fontFamily: undefined,
- cssClass: ''
- },
- offsetX: 0,
- offsetY: 0,
- format: undefined,
- formatter: undefined,
-
- datetimeUTC: true,
- datetimeFormatter: {
- year: 'yyyy',
- month: "MMM 'yy",
- day: 'dd MMM',
- hour: 'HH:mm',
- minute: 'HH:mm:ss'
- }
- },
- axisBorder: {
- show: true,
- color: '#e0e0e0',
- width: '100%',
- height: 1,
- offsetX: 0,
- offsetY: 0
- },
- axisTicks: {
- show: true,
- color: '#e0e0e0',
- height: 6,
- offsetX: 0,
- offsetY: 0
- },
- tickAmount: undefined,
- tickPlacement: 'on',
- min: undefined,
- max: undefined,
- range: undefined,
- floating: false,
- position: 'bottom',
- title: {
- text: undefined,
- offsetX: 0,
- offsetY: 0,
- style: {
- color: undefined,
- fontSize: '12px',
- fontWeight: 900,
- fontFamily: undefined,
- cssClass: ''
- }
- },
- crosshairs: {
- show: true,
- width: 1,
-
- position: 'back',
- opacity: 0.9,
- stroke: {
- color: '#b6b6b6',
- width: 1,
- dashArray: 3
- },
- fill: {
- type: 'solid',
-
- color: '#B1B9C4',
- gradient: {
- colorFrom: '#D8E3F0',
- colorTo: '#BED1E6',
- stops: [0, 100],
- opacityFrom: 0.4,
- opacityTo: 0.5
- }
- },
- dropShadow: {
- enabled: false,
- left: 0,
- top: 0,
- blur: 1,
- opacity: 0.4
- }
- },
- tooltip: {
- enabled: true,
- offsetY: 0,
- formatter: undefined,
- style: {
- fontSize: '12px',
- fontFamily: undefined
- }
- }
- },
- yaxis: this.yAxis,
- theme: {
- mode: 'light',
- palette: 'palette1',
-
- monochrome: {
-
- enabled: false,
- color: '#008FFB',
- shadeTo: 'light',
- shadeIntensity: 0.65
- }
- }
- };
- }
- }]);
- return Options;
- }();
-
- var Annotations = function () {
- function Annotations(ctx) {
- _classCallCheck(this, Annotations);
- this.ctx = ctx;
- this.w = ctx.w;
- this.graphics = new Graphics(this.ctx);
- if (this.w.globals.isBarHorizontal) {
- this.invertAxis = true;
- }
- this.helpers = new Helpers(this);
- this.xAxisAnnotations = new XAnnotations(this);
- this.yAxisAnnotations = new YAnnotations(this);
- this.pointsAnnotations = new PointAnnotations(this);
- if (this.w.globals.isBarHorizontal && this.w.config.yaxis[0].reversed) {
- this.inversedReversedAxis = true;
- }
- this.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints;
- }
- _createClass(Annotations, [{
- key: "drawAxesAnnotations",
- value: function drawAxesAnnotations() {
- var w = this.w;
- if (w.globals.axisCharts) {
- var yAnnotations = this.yAxisAnnotations.drawYAxisAnnotations();
- var xAnnotations = this.xAxisAnnotations.drawXAxisAnnotations();
- var pointAnnotations = this.pointsAnnotations.drawPointAnnotations();
- var initialAnim = w.config.chart.animations.enabled;
- var annoArray = [yAnnotations, xAnnotations, pointAnnotations];
- var annoElArray = [xAnnotations.node, yAnnotations.node, pointAnnotations.node];
- for (var i = 0; i < 3; i++) {
- w.globals.dom.elGraphical.add(annoArray[i]);
- if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
-
- if (w.config.chart.type !== 'scatter' && w.config.chart.type !== 'bubble' && w.globals.dataPoints > 1) {
- annoElArray[i].classList.add('apexcharts-element-hidden');
- }
- }
- w.globals.delayedElements.push({
- el: annoElArray[i],
- index: 0
- });
- }
- this.helpers.annotationsBackground();
- }
- }
- }, {
- key: "drawShapeAnnos",
- value: function drawShapeAnnos() {
- var _this = this;
- var w = this.w;
- w.config.annotations.shapes.map(function (s, index) {
- _this.addShape(s, index);
- });
- }
- }, {
- key: "drawImageAnnos",
- value: function drawImageAnnos() {
- var _this2 = this;
- var w = this.w;
- w.config.annotations.images.map(function (s, index) {
- _this2.addImage(s, index);
- });
- }
- }, {
- key: "drawTextAnnos",
- value: function drawTextAnnos() {
- var _this3 = this;
- var w = this.w;
- w.config.annotations.texts.map(function (t, index) {
- _this3.addText(t, index);
- });
- }
- }, {
- key: "addXaxisAnnotation",
- value: function addXaxisAnnotation(anno, parent, index) {
- this.xAxisAnnotations.addXaxisAnnotation(anno, parent, index);
- }
- }, {
- key: "addYaxisAnnotation",
- value: function addYaxisAnnotation(anno, parent, index) {
- this.yAxisAnnotations.addYaxisAnnotation(anno, parent, index);
- }
- }, {
- key: "addPointAnnotation",
- value: function addPointAnnotation(anno, parent, index) {
- this.pointsAnnotations.addPointAnnotation(anno, parent, index);
- }
- }, {
- key: "addText",
- value: function addText(params, index) {
- var x = params.x,
- y = params.y,
- text = params.text,
- textAnchor = params.textAnchor,
- foreColor = params.foreColor,
- fontSize = params.fontSize,
- fontFamily = params.fontFamily,
- fontWeight = params.fontWeight,
- cssClass = params.cssClass,
- backgroundColor = params.backgroundColor,
- borderWidth = params.borderWidth,
- strokeDashArray = params.strokeDashArray,
- borderRadius = params.borderRadius,
- borderColor = params.borderColor,
- _params$appendTo = params.appendTo,
- appendTo = _params$appendTo === void 0 ? '.apexcharts-annotations' : _params$appendTo,
- _params$paddingLeft = params.paddingLeft,
- paddingLeft = _params$paddingLeft === void 0 ? 4 : _params$paddingLeft,
- _params$paddingRight = params.paddingRight,
- paddingRight = _params$paddingRight === void 0 ? 4 : _params$paddingRight,
- _params$paddingBottom = params.paddingBottom,
- paddingBottom = _params$paddingBottom === void 0 ? 2 : _params$paddingBottom,
- _params$paddingTop = params.paddingTop,
- paddingTop = _params$paddingTop === void 0 ? 2 : _params$paddingTop;
- var w = this.w;
- var elText = this.graphics.drawText({
- x: x,
- y: y,
- text: text,
- textAnchor: textAnchor || 'start',
- fontSize: fontSize || '12px',
- fontWeight: fontWeight || 'regular',
- fontFamily: fontFamily || w.config.chart.fontFamily,
- foreColor: foreColor || w.config.chart.foreColor,
- cssClass: 'apexcharts-text ' + cssClass ? cssClass : ''
- });
- var parent = w.globals.dom.baseEl.querySelector(appendTo);
- if (parent) {
- parent.appendChild(elText.node);
- }
- var textRect = elText.bbox();
- if (params.draggable) {
- this.helpers.makeAnnotationDraggable(elText, 'texts', index);
- }
- if (text) {
- var elRect = this.graphics.drawRect(textRect.x - paddingLeft, textRect.y - paddingTop, textRect.width + paddingLeft + paddingRight, textRect.height + paddingBottom + paddingTop, borderRadius, backgroundColor ? backgroundColor : 'transparent', 1, borderWidth, borderColor, strokeDashArray);
- parent.insertBefore(elRect.node, elText.node);
- }
- }
- }, {
- key: "addShape",
- value: function addShape(params, index) {
- var opts = {
- type: params.type,
- x: params.x || 0,
- y: params.y || 0,
- width: params.width || '100%',
- height: params.height || 50,
- circleRadius: params.radius || 25,
- backgroundColor: params.backgroundColor || '#fff',
- opacity: params.opacity || 1,
- borderWidth: params.borderWidth || 0,
- borderRadius: params.borderRadius || 4,
- borderColor: params.borderColor || '#c2c2c2',
- appendTo: params.appendTo || '.apexcharts-annotations'
- };
- var w = this.w;
- if (String(opts.width).indexOf('%') > -1) {
- opts.width = parseInt(opts.width, 10) * parseInt(w.globals.svgWidth, 10) / 100;
- }
- var elShape = null;
- if (opts.type === 'circle') {
- elShape = this.graphics.drawCircle(opts.circleRadius, {
- fill: opts.backgroundColor,
- stroke: opts.borderColor,
- 'stroke-width': opts.borderWidth,
- opacity: opts.opacity,
- cx: opts.x,
- cy: opts.y
- });
- } else {
- elShape = this.graphics.drawRect(opts.x, opts.y, opts.width, opts.height, opts.borderRadius, opts.backgroundColor, opts.opacity, opts.borderWidth, opts.borderColor);
- }
- var parent = w.globals.dom.baseEl.querySelector(opts.appendTo);
- if (parent) {
- parent.appendChild(elShape.node);
- }
- if (params.draggable) {
- this.helpers.makeAnnotationDraggable(elShape, 'shapes', index);
- elShape.node.classList.add('apexcharts-resizable-element');
- }
- }
- }, {
- key: "addImage",
- value: function addImage(params, index) {
- var w = this.w;
- var path = params.path,
- _params$x = params.x,
- x = _params$x === void 0 ? 0 : _params$x,
- _params$y = params.y,
- y = _params$y === void 0 ? 0 : _params$y,
- _params$width = params.width,
- width = _params$width === void 0 ? 20 : _params$width,
- _params$height = params.height,
- height = _params$height === void 0 ? 20 : _params$height,
- _params$appendTo2 = params.appendTo,
- appendTo = _params$appendTo2 === void 0 ? '.apexcharts-annotations' : _params$appendTo2;
- var img = w.globals.dom.Paper.image(path);
- img.size(width, height).move(x, y);
- var parent = w.globals.dom.baseEl.querySelector(appendTo);
- if (parent) {
- parent.appendChild(img.node);
- }
- if (params.draggable) {
- this.helpers.makeAnnotationDraggable(img, 'images', index);
- img.node.classList.add('apexcharts-resizable-element');
- }
- }
- }, {
- key: "addXaxisAnnotationExternal",
- value: function addXaxisAnnotationExternal(params, pushToMemory, context) {
- this.addAnnotationExternal({
- params: params,
- pushToMemory: pushToMemory,
- context: context,
- type: 'xaxis',
- contextMethod: context.addXaxisAnnotation
- });
- return context;
- }
- }, {
- key: "addYaxisAnnotationExternal",
- value: function addYaxisAnnotationExternal(params, pushToMemory, context) {
- this.addAnnotationExternal({
- params: params,
- pushToMemory: pushToMemory,
- context: context,
- type: 'yaxis',
- contextMethod: context.addYaxisAnnotation
- });
- return context;
- }
- }, {
- key: "addPointAnnotationExternal",
- value: function addPointAnnotationExternal(params, pushToMemory, context) {
- if (typeof this.invertAxis === 'undefined') {
- this.invertAxis = context.w.globals.isBarHorizontal;
- }
- this.addAnnotationExternal({
- params: params,
- pushToMemory: pushToMemory,
- context: context,
- type: 'point',
- contextMethod: context.addPointAnnotation
- });
- return context;
- }
- }, {
- key: "addAnnotationExternal",
- value: function addAnnotationExternal(_ref) {
- var params = _ref.params,
- pushToMemory = _ref.pushToMemory,
- context = _ref.context,
- type = _ref.type,
- contextMethod = _ref.contextMethod;
- var me = context;
- var w = me.w;
- var parent = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations"));
- var index = parent.childNodes.length + 1;
- var options = new Options();
- var axesAnno = Object.assign({}, type === 'xaxis' ? options.xAxisAnnotation : type === 'yaxis' ? options.yAxisAnnotation : options.pointAnnotation);
- var anno = Utils.extend(axesAnno, params);
- switch (type) {
- case 'xaxis':
- this.addXaxisAnnotation(anno, parent, index);
- break;
- case 'yaxis':
- this.addYaxisAnnotation(anno, parent, index);
- break;
- case 'point':
- this.addPointAnnotation(anno, parent, index);
- break;
- }
- var axesAnnoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(index, "']"));
- var elRect = this.helpers.addBackgroundToAnno(axesAnnoLabel, anno);
- if (elRect) {
- parent.insertBefore(elRect.node, axesAnnoLabel);
- }
- if (pushToMemory) {
- w.globals.memory.methodsToExec.push({
- context: me,
- id: anno.id ? anno.id : Utils.randomId(),
- method: contextMethod,
- label: 'addAnnotation',
- params: params
- });
- }
- return context;
- }
- }, {
- key: "clearAnnotations",
- value: function clearAnnotations(ctx) {
- var w = ctx.w;
- var annos = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations');
- w.globals.memory.methodsToExec.map(function (m, i) {
- if (m.label === 'addText' || m.label === 'addAnnotation') {
- w.globals.memory.methodsToExec.splice(i, 1);
- }
- });
- annos = Utils.listToArray(annos);
- Array.prototype.forEach.call(annos, function (a) {
- while (a.firstChild) {
- a.removeChild(a.firstChild);
- }
- });
- }
- }, {
- key: "removeAnnotation",
- value: function removeAnnotation(ctx, id) {
- var w = ctx.w;
- var annos = w.globals.dom.baseEl.querySelectorAll(".".concat(id));
- if (annos) {
- w.globals.memory.methodsToExec.map(function (m, i) {
- if (m.id === id) {
- w.globals.memory.methodsToExec.splice(i, 1);
- }
- });
- Array.prototype.forEach.call(annos, function (a) {
- a.parentElement.removeChild(a);
- });
- }
- }
- }]);
- return Annotations;
- }();
-
- var DateTime = function () {
- function DateTime(ctx) {
- _classCallCheck(this, DateTime);
- this.ctx = ctx;
- this.w = ctx.w;
- this.months31 = [1, 3, 5, 7, 8, 10, 12];
- this.months30 = [2, 4, 6, 9, 11];
- this.daysCntOfYear = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
- }
- _createClass(DateTime, [{
- key: "isValidDate",
- value: function isValidDate(date) {
- return !isNaN(this.parseDate(date));
- }
- }, {
- key: "getTimeStamp",
- value: function getTimeStamp(dateStr) {
- if (!Date.parse(dateStr)) {
- return dateStr;
- }
- var utc = this.w.config.xaxis.labels.datetimeUTC;
- return !utc ? new Date(dateStr).getTime() : new Date(new Date(dateStr).toISOString().substr(0, 25)).getTime();
- }
- }, {
- key: "getDate",
- value: function getDate(timestamp) {
- var utc = this.w.config.xaxis.labels.datetimeUTC;
- return utc ? new Date(new Date(timestamp).toUTCString()) : new Date(timestamp);
- }
- }, {
- key: "parseDate",
- value: function parseDate(dateStr) {
- var parsed = Date.parse(dateStr);
- if (!isNaN(parsed)) {
- return this.getTimeStamp(dateStr);
- }
- var output = Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' '));
- output = this.getTimeStamp(output);
- return output;
- }
- }, {
- key: "formatDate",
- value: function formatDate(date, format) {
- var locale = this.w.globals.locale;
- var utc = this.w.config.xaxis.labels.datetimeUTC;
- var MMMM = ['\x00'].concat(_toConsumableArray(locale.months));
- var MMM = ['\x01'].concat(_toConsumableArray(locale.shortMonths));
- var dddd = ['\x02'].concat(_toConsumableArray(locale.days));
- var ddd = ['\x03'].concat(_toConsumableArray(locale.shortDays));
- function ii(i, len) {
- var s = i + '';
- len = len || 2;
- while (s.length < len) {
- s = '0' + s;
- }
- return s;
- }
- var y = utc ? date.getUTCFullYear() : date.getFullYear();
- format = format.replace(/(^|[^\\])yyyy+/g, '$1' + y);
- format = format.replace(/(^|[^\\])yy/g, '$1' + y.toString().substr(2, 2));
- format = format.replace(/(^|[^\\])y/g, '$1' + y);
- var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
- format = format.replace(/(^|[^\\])MMMM+/g, '$1' + MMMM[0]);
- format = format.replace(/(^|[^\\])MMM/g, '$1' + MMM[0]);
- format = format.replace(/(^|[^\\])MM/g, '$1' + ii(M));
- format = format.replace(/(^|[^\\])M/g, '$1' + M);
- var d = utc ? date.getUTCDate() : date.getDate();
- format = format.replace(/(^|[^\\])dddd+/g, '$1' + dddd[0]);
- format = format.replace(/(^|[^\\])ddd/g, '$1' + ddd[0]);
- format = format.replace(/(^|[^\\])dd/g, '$1' + ii(d));
- format = format.replace(/(^|[^\\])d/g, '$1' + d);
- var H = utc ? date.getUTCHours() : date.getHours();
- format = format.replace(/(^|[^\\])HH+/g, '$1' + ii(H));
- format = format.replace(/(^|[^\\])H/g, '$1' + H);
- var h = H > 12 ? H - 12 : H === 0 ? 12 : H;
- format = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h));
- format = format.replace(/(^|[^\\])h/g, '$1' + h);
- var m = utc ? date.getUTCMinutes() : date.getMinutes();
- format = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m));
- format = format.replace(/(^|[^\\])m/g, '$1' + m);
- var s = utc ? date.getUTCSeconds() : date.getSeconds();
- format = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s));
- format = format.replace(/(^|[^\\])s/g, '$1' + s);
- var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
- format = format.replace(/(^|[^\\])fff+/g, '$1' + ii(f, 3));
- f = Math.round(f / 10);
- format = format.replace(/(^|[^\\])ff/g, '$1' + ii(f));
- f = Math.round(f / 10);
- format = format.replace(/(^|[^\\])f/g, '$1' + f);
- var T = H < 12 ? 'AM' : 'PM';
- format = format.replace(/(^|[^\\])TT+/g, '$1' + T);
- format = format.replace(/(^|[^\\])T/g, '$1' + T.charAt(0));
- var t = T.toLowerCase();
- format = format.replace(/(^|[^\\])tt+/g, '$1' + t);
- format = format.replace(/(^|[^\\])t/g, '$1' + t.charAt(0));
- var tz = -date.getTimezoneOffset();
- var K = utc || !tz ? 'Z' : tz > 0 ? '+' : '-';
- if (!utc) {
- tz = Math.abs(tz);
- var tzHrs = Math.floor(tz / 60);
- var tzMin = tz % 60;
- K += ii(tzHrs) + ':' + ii(tzMin);
- }
- format = format.replace(/(^|[^\\])K/g, '$1' + K);
- var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
- format = format.replace(new RegExp(dddd[0], 'g'), dddd[day]);
- format = format.replace(new RegExp(ddd[0], 'g'), ddd[day]);
- format = format.replace(new RegExp(MMMM[0], 'g'), MMMM[M]);
- format = format.replace(new RegExp(MMM[0], 'g'), MMM[M]);
- format = format.replace(/\\(.)/g, '$1');
- return format;
- }
- }, {
- key: "getTimeUnitsfromTimestamp",
- value: function getTimeUnitsfromTimestamp(minX, maxX, utc) {
- var w = this.w;
- if (w.config.xaxis.min !== undefined) {
- minX = w.config.xaxis.min;
- }
- if (w.config.xaxis.max !== undefined) {
- maxX = w.config.xaxis.max;
- }
- var tsMin = this.getDate(minX);
- var tsMax = this.getDate(maxX);
- var minD = this.formatDate(tsMin, 'yyyy MM dd HH mm').split(' ');
- var maxD = this.formatDate(tsMax, 'yyyy MM dd HH mm').split(' ');
- return {
- minMinute: parseInt(minD[4], 10),
- maxMinute: parseInt(maxD[4], 10),
- minHour: parseInt(minD[3], 10),
- maxHour: parseInt(maxD[3], 10),
- minDate: parseInt(minD[2], 10),
- maxDate: parseInt(maxD[2], 10),
- minMonth: parseInt(minD[1], 10) - 1,
- maxMonth: parseInt(maxD[1], 10) - 1,
- minYear: parseInt(minD[0], 10),
- maxYear: parseInt(maxD[0], 10)
- };
- }
- }, {
- key: "isLeapYear",
- value: function isLeapYear(year) {
- return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
- }
- }, {
- key: "calculcateLastDaysOfMonth",
- value: function calculcateLastDaysOfMonth(month, year, subtract) {
- var days = this.determineDaysOfMonths(month, year);
- return days - subtract;
- }
- }, {
- key: "determineDaysOfYear",
- value: function determineDaysOfYear(year) {
- var days = 365;
- if (this.isLeapYear(year)) {
- days = 366;
- }
- return days;
- }
- }, {
- key: "determineRemainingDaysOfYear",
- value: function determineRemainingDaysOfYear(year, month, date) {
- var dayOfYear = this.daysCntOfYear[month] + date;
- if (month > 1 && this.isLeapYear()) dayOfYear++;
- return dayOfYear;
- }
- }, {
- key: "determineDaysOfMonths",
- value: function determineDaysOfMonths(month, year) {
- var days = 30;
- month = Utils.monthMod(month);
- switch (true) {
- case this.months30.indexOf(month) > -1:
- if (month === 2) {
- if (this.isLeapYear(year)) {
- days = 29;
- } else {
- days = 28;
- }
- }
- break;
- case this.months31.indexOf(month) > -1:
- days = 31;
- break;
- default:
- days = 31;
- break;
- }
- return days;
- }
- }]);
- return DateTime;
- }();
-
- var Defaults = function () {
- function Defaults(opts) {
- _classCallCheck(this, Defaults);
- this.opts = opts;
- }
- _createClass(Defaults, [{
- key: "line",
- value: function line() {
- return {
- chart: {
- animations: {
- easing: 'swing'
- }
- },
- dataLabels: {
- enabled: false
- },
- stroke: {
- width: 5,
- curve: 'straight'
- },
- markers: {
- size: 0,
- hover: {
- sizeOffset: 6
- }
- },
- xaxis: {
- crosshairs: {
- width: 1
- }
- }
- };
- }
- }, {
- key: "sparkline",
- value: function sparkline(defaults) {
- this.opts.yaxis[0].show = false;
- this.opts.yaxis[0].title.text = '';
- this.opts.yaxis[0].axisBorder.show = false;
- this.opts.yaxis[0].axisTicks.show = false;
- this.opts.yaxis[0].floating = true;
- var ret = {
- grid: {
- show: false,
- padding: {
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- }
- },
- legend: {
- show: false
- },
- xaxis: {
- labels: {
- show: false
- },
- tooltip: {
- enabled: false
- },
- axisBorder: {
- show: false
- },
- axisTicks: {
- show: false
- }
- },
- chart: {
- toolbar: {
- show: false
- },
- zoom: {
- enabled: false
- }
- },
- dataLabels: {
- enabled: false
- }
- };
- return Utils.extend(defaults, ret);
- }
- }, {
- key: "bar",
- value: function bar() {
- return {
- chart: {
- stacked: false,
- animations: {
- easing: 'swing'
- }
- },
- plotOptions: {
- bar: {
- dataLabels: {
- position: 'center'
- }
- }
- },
- dataLabels: {
- style: {
- colors: ['#fff']
- },
- background: {
- enabled: false
- }
- },
- stroke: {
- width: 0,
- lineCap: 'square'
- },
- fill: {
- opacity: 0.85
- },
- legend: {
- markers: {
- shape: 'square',
- radius: 2,
- size: 8
- }
- },
- tooltip: {
- shared: false
- },
- xaxis: {
- tooltip: {
- enabled: false
- },
- tickPlacement: 'between',
- crosshairs: {
- width: 'barWidth',
- position: 'back',
- fill: {
- type: 'gradient'
- },
- dropShadow: {
- enabled: false
- },
- stroke: {
- width: 0
- }
- }
- }
- };
- }
- }, {
- key: "candlestick",
- value: function candlestick() {
- return {
- stroke: {
- width: 1,
- colors: ['#333']
- },
- fill: {
- opacity: 1
- },
- dataLabels: {
- enabled: false
- },
- tooltip: {
- shared: true,
- custom: function custom(_ref) {
- var seriesIndex = _ref.seriesIndex,
- dataPointIndex = _ref.dataPointIndex,
- w = _ref.w;
- var o = w.globals.seriesCandleO[seriesIndex][dataPointIndex];
- var h = w.globals.seriesCandleH[seriesIndex][dataPointIndex];
- var l = w.globals.seriesCandleL[seriesIndex][dataPointIndex];
- var c = w.globals.seriesCandleC[seriesIndex][dataPointIndex];
- return '<div class="apexcharts-tooltip-candlestick">' + '<div>Open: <span class="value">' + o + '</span></div>' + '<div>High: <span class="value">' + h + '</span></div>' + '<div>Low: <span class="value">' + l + '</span></div>' + '<div>Close: <span class="value">' + c + '</span></div>' + '</div>';
- }
- },
- states: {
- active: {
- filter: {
- type: 'none'
- }
- }
- },
- xaxis: {
- crosshairs: {
- width: 1
- }
- }
- };
- }
- }, {
- key: "rangeBar",
- value: function rangeBar() {
- return {
- stroke: {
- width: 0,
- lineCap: 'square'
- },
- plotOptions: {
- bar: {
- dataLabels: {
- position: 'center'
- }
- }
- },
- dataLabels: {
- enabled: false,
- formatter: function formatter(val, _ref2) {
- var ctx = _ref2.ctx,
- seriesIndex = _ref2.seriesIndex,
- dataPointIndex = _ref2.dataPointIndex,
- w = _ref2.w;
- var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
- var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
- return end - start;
- },
- background: {
- enabled: false
- },
- style: {
- colors: ['#fff']
- }
- },
- tooltip: {
- shared: false,
- followCursor: true,
- custom: function custom(_ref3) {
- var ctx = _ref3.ctx,
- seriesIndex = _ref3.seriesIndex,
- dataPointIndex = _ref3.dataPointIndex,
- y1 = _ref3.y1,
- y2 = _ref3.y2,
- w = _ref3.w;
- var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
- var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
- var ylabel = w.globals.labels[dataPointIndex];
- var seriesName = w.config.series[seriesIndex].name;
- var yLbFormatter = w.config.tooltip.y.formatter;
- var yLbTitleFormatter = w.config.tooltip.y.title.formatter;
- var opts = {
- w: w,
- seriesIndex: seriesIndex,
- dataPointIndex: dataPointIndex
- };
- if (typeof yLbTitleFormatter === 'function') {
- seriesName = yLbTitleFormatter(seriesName, opts);
- }
- if (y1 && y2) {
- start = y1;
- end = y2;
- if (w.config.series[seriesIndex].data[dataPointIndex].x) {
- ylabel = w.config.series[seriesIndex].data[dataPointIndex].x + ':';
- }
- if (typeof yLbFormatter === 'function') {
- ylabel = yLbFormatter(ylabel, opts);
- }
- }
- var startVal = '';
- var endVal = '';
- var color = w.globals.colors[seriesIndex];
- if (w.config.tooltip.x.formatter === undefined) {
- if (w.config.xaxis.type === 'datetime') {
- var datetimeObj = new DateTime(ctx);
- startVal = datetimeObj.formatDate(datetimeObj.getDate(start), w.config.tooltip.x.format);
- endVal = datetimeObj.formatDate(datetimeObj.getDate(end), w.config.tooltip.x.format);
- } else {
- startVal = start;
- endVal = end;
- }
- } else {
- startVal = w.config.tooltip.x.formatter(start);
- endVal = w.config.tooltip.x.formatter(end);
- }
- return '<div class="apexcharts-tooltip-rangebar">' + '<div> <span class="series-name" style="color: ' + color + '">' + (seriesName ? seriesName : '') + '</span></div>' + '<div> <span class="category">' + ylabel + ' </span> <span class="value start-value">' + startVal + '</span> <span class="separator">-</span> <span class="value end-value">' + endVal + '</span></div>' + '</div>';
- }
- },
- xaxis: {
- tickPlacement: 'between',
- tooltip: {
- enabled: false
- },
- crosshairs: {
- stroke: {
- width: 0
- }
- }
- }
- };
- }
- }, {
- key: "area",
- value: function area() {
- return {
- stroke: {
- width: 4
- },
- fill: {
- type: 'gradient',
- gradient: {
- inverseColors: false,
- shade: 'light',
- type: 'vertical',
- opacityFrom: 0.65,
- opacityTo: 0.5,
- stops: [0, 100, 100]
- }
- },
- markers: {
- size: 0,
- hover: {
- sizeOffset: 6
- }
- },
- tooltip: {
- followCursor: false
- }
- };
- }
- }, {
- key: "brush",
- value: function brush(defaults) {
- var ret = {
- chart: {
- toolbar: {
- autoSelected: 'selection',
- show: false
- },
- zoom: {
- enabled: false
- }
- },
- dataLabels: {
- enabled: false
- },
- stroke: {
- width: 1
- },
- tooltip: {
- enabled: false
- },
- xaxis: {
- tooltip: {
- enabled: false
- }
- }
- };
- return Utils.extend(defaults, ret);
- }
- }, {
- key: "stacked100",
- value: function stacked100(opts) {
- opts.dataLabels = opts.dataLabels || {};
- opts.dataLabels.formatter = opts.dataLabels.formatter || undefined;
- var existingDataLabelFormatter = opts.dataLabels.formatter;
- opts.yaxis.forEach(function (yaxe, index) {
- opts.yaxis[index].min = 0;
- opts.yaxis[index].max = 100;
- });
- var isBar = opts.chart.type === 'bar';
- if (isBar) {
- opts.dataLabels.formatter = existingDataLabelFormatter || function (val) {
- if (typeof val === 'number') {
- return val ? val.toFixed(0) + '%' : val;
- }
- return val;
- };
- }
- return opts;
- }
- }, {
- key: "convertCatToNumeric",
- value: function convertCatToNumeric(opts) {
- opts.xaxis.convertedCatToNumeric = true;
- return opts;
- }
- }, {
- key: "convertCatToNumericXaxis",
- value: function convertCatToNumericXaxis(opts, ctx, cats) {
- opts.xaxis.type = 'numeric';
- opts.xaxis.labels = opts.xaxis.labels || {};
- opts.xaxis.labels.formatter = opts.xaxis.labels.formatter || function (val) {
- return Utils.isNumber(val) ? Math.floor(val) : val;
- };
- var defaultFormatter = opts.xaxis.labels.formatter;
- var labels = opts.xaxis.categories && opts.xaxis.categories.length ? opts.xaxis.categories : opts.labels;
- if (cats && cats.length) {
- labels = cats.map(function (c) {
- return c.toString();
- });
- }
- if (labels && labels.length) {
- opts.xaxis.labels.formatter = function (val) {
- return Utils.isNumber(val) ? defaultFormatter(labels[Math.floor(val) - 1]) : defaultFormatter(val);
- };
- }
- opts.xaxis.categories = [];
- opts.labels = [];
- opts.xaxis.tickAmount = opts.xaxis.tickAmount || 'dataPoints';
- return opts;
- }
- }, {
- key: "bubble",
- value: function bubble() {
- return {
- dataLabels: {
- style: {
- colors: ['#fff']
- }
- },
- tooltip: {
- shared: false,
- intersect: true
- },
- xaxis: {
- crosshairs: {
- width: 0
- }
- },
- fill: {
- type: 'solid',
- gradient: {
- shade: 'light',
- inverse: true,
- shadeIntensity: 0.55,
- opacityFrom: 0.4,
- opacityTo: 0.8
- }
- }
- };
- }
- }, {
- key: "scatter",
- value: function scatter() {
- return {
- dataLabels: {
- enabled: false
- },
- tooltip: {
- shared: false,
- intersect: true
- },
- markers: {
- size: 6,
- strokeWidth: 1,
- hover: {
- sizeOffset: 2
- }
- }
- };
- }
- }, {
- key: "heatmap",
- value: function heatmap() {
- return {
- chart: {
- stacked: false
- },
- fill: {
- opacity: 1
- },
- dataLabels: {
- style: {
- colors: ['#fff']
- }
- },
- stroke: {
- colors: ['#fff']
- },
- tooltip: {
- followCursor: true,
- marker: {
- show: false
- },
- x: {
- show: false
- }
- },
- legend: {
- position: 'top',
- markers: {
- shape: 'square',
- size: 10,
- offsetY: 2
- }
- },
- grid: {
- padding: {
- right: 20
- }
- }
- };
- }
- }, {
- key: "pie",
- value: function pie() {
- return {
- chart: {
- toolbar: {
- show: false
- }
- },
- plotOptions: {
- pie: {
- donut: {
- labels: {
- show: false
- }
- }
- }
- },
- dataLabels: {
- formatter: function formatter(val) {
- return val.toFixed(1) + '%';
- },
- style: {
- colors: ['#fff']
- },
- dropShadow: {
- enabled: true
- }
- },
- stroke: {
- colors: ['#fff']
- },
- fill: {
- opacity: 1,
- gradient: {
- shade: 'light',
- stops: [0, 100]
- }
- },
- tooltip: {
- theme: 'dark',
- fillSeriesColor: true
- },
- legend: {
- position: 'right'
- }
- };
- }
- }, {
- key: "donut",
- value: function donut() {
- return {
- chart: {
- toolbar: {
- show: false
- }
- },
- dataLabels: {
- formatter: function formatter(val) {
- return val.toFixed(1) + '%';
- },
- style: {
- colors: ['#fff']
- },
- dropShadow: {
- enabled: true
- }
- },
- stroke: {
- colors: ['#fff']
- },
- fill: {
- opacity: 1,
- gradient: {
- shade: 'light',
- shadeIntensity: 0.35,
- stops: [80, 100],
- opacityFrom: 1,
- opacityTo: 1
- }
- },
- tooltip: {
- theme: 'dark',
- fillSeriesColor: true
- },
- legend: {
- position: 'right'
- }
- };
- }
- }, {
- key: "radar",
- value: function radar() {
- this.opts.yaxis[0].labels.offsetY = this.opts.yaxis[0].labels.offsetY ? this.opts.yaxis[0].labels.offsetY : 6;
- return {
- dataLabels: {
- enabled: false,
- style: {
- fontSize: '11px'
- }
- },
- stroke: {
- width: 2
- },
- markers: {
- size: 3,
- strokeWidth: 1,
- strokeOpacity: 1
- },
- fill: {
- opacity: 0.2
- },
- tooltip: {
- shared: false,
- intersect: true,
- followCursor: true
- },
- grid: {
- show: false
- },
- xaxis: {
- labels: {
- formatter: function formatter(val) {
- return val;
- },
- style: {
- colors: ['#a8a8a8'],
- fontSize: '11px'
- }
- },
- tooltip: {
- enabled: false
- },
- crosshairs: {
- show: false
- }
- }
- };
- }
- }, {
- key: "radialBar",
- value: function radialBar() {
- return {
- chart: {
- animations: {
- dynamicAnimation: {
- enabled: true,
- speed: 800
- }
- },
- toolbar: {
- show: false
- }
- },
- fill: {
- gradient: {
- shade: 'dark',
- shadeIntensity: 0.4,
- inverseColors: false,
- type: 'diagonal2',
- opacityFrom: 1,
- opacityTo: 1,
- stops: [70, 98, 100]
- }
- },
- legend: {
- show: false,
- position: 'right'
- },
- tooltip: {
- enabled: false,
- fillSeriesColor: true
- }
- };
- }
- }]);
- return Defaults;
- }();
-
- var Config = function () {
- function Config(opts) {
- _classCallCheck(this, Config);
- this.opts = opts;
- }
- _createClass(Config, [{
- key: "init",
- value: function init(_ref) {
- var responsiveOverride = _ref.responsiveOverride;
- var opts = this.opts;
- var options = new Options();
- var defaults = new Defaults(opts);
- this.chartType = opts.chart.type;
- if (this.chartType === 'histogram') {
-
- opts.chart.type = 'bar';
- opts = Utils.extend({
- plotOptions: {
- bar: {
- columnWidth: '99.99%'
- }
- }
- }, opts);
- }
- opts = this.extendYAxis(opts);
- opts = this.extendAnnotations(opts);
- var config = options.init();
- var newDefaults = {};
- if (opts && _typeof(opts) === 'object') {
- var chartDefaults = {};
- var chartTypes = ['line', 'area', 'bar', 'candlestick', 'rangeBar', 'histogram', 'bubble', 'scatter', 'heatmap', 'pie', 'donut', 'radar', 'radialBar'];
- if (chartTypes.indexOf(opts.chart.type) !== -1) {
- chartDefaults = defaults[opts.chart.type]();
- } else {
- chartDefaults = defaults.line();
- }
- if (opts.chart.brush && opts.chart.brush.enabled) {
- chartDefaults = defaults.brush(chartDefaults);
- }
- if (opts.chart.stacked && opts.chart.stackType === '100%') {
- opts = defaults.stacked100(opts);
- }
- this.checkForDarkTheme(window.Apex);
- this.checkForDarkTheme(opts);
- opts.xaxis = opts.xaxis || window.Apex.xaxis || {};
-
- if (!responsiveOverride) {
- opts.xaxis.convertedCatToNumeric = false;
- }
- opts = this.checkForCatToNumericXAxis(this.chartType, chartDefaults, opts);
- if (opts.chart.sparkline && opts.chart.sparkline.enabled || window.Apex.chart && window.Apex.chart.sparkline && window.Apex.chart.sparkline.enabled) {
- chartDefaults = defaults.sparkline(chartDefaults);
- }
- newDefaults = Utils.extend(config, chartDefaults);
- }
-
-
- var mergedWithDefaultConfig = Utils.extend(newDefaults, window.Apex);
- config = Utils.extend(mergedWithDefaultConfig, opts);
- config = this.handleUserInputErrors(config);
- return config;
- }
- }, {
- key: "checkForCatToNumericXAxis",
- value: function checkForCatToNumericXAxis(chartType, chartDefaults, opts) {
- var defaults = new Defaults(opts);
- var isBarHorizontal = chartType === 'bar' && opts.plotOptions && opts.plotOptions.bar && opts.plotOptions.bar.horizontal;
- var unsupportedZoom = chartType === 'pie' || chartType === 'donut' || chartType === 'radar' || chartType === 'radialBar' || chartType === 'heatmap';
- var notNumericXAxis = opts.xaxis.type !== 'datetime' && opts.xaxis.type !== 'numeric';
- var tickPlacement = opts.xaxis.tickPlacement ? opts.xaxis.tickPlacement : chartDefaults.xaxis && chartDefaults.xaxis.tickPlacement;
- if (!isBarHorizontal && !unsupportedZoom && notNumericXAxis && tickPlacement !== 'between') {
- opts = defaults.convertCatToNumeric(opts);
- }
- return opts;
- }
- }, {
- key: "extendYAxis",
- value: function extendYAxis(opts) {
- var options = new Options();
- if (typeof opts.yaxis === 'undefined' || !opts.yaxis || Array.isArray(opts.yaxis) && opts.yaxis.length === 0) {
- opts.yaxis = {};
- }
- if (opts.yaxis.constructor !== Array && window.Apex.yaxis && window.Apex.yaxis.constructor !== Array) {
- opts.yaxis = Utils.extend(opts.yaxis, window.Apex.yaxis);
- }
-
- if (opts.yaxis.constructor !== Array) {
-
- opts.yaxis = [Utils.extend(options.yAxis, opts.yaxis)];
- } else {
- opts.yaxis = Utils.extendArray(opts.yaxis, options.yAxis);
- }
- var isLogY = false;
- opts.yaxis.forEach(function (y) {
- if (y.logarithmic) {
- isLogY = true;
- }
- });
-
- if (isLogY && opts.series.length !== opts.yaxis.length && opts.series.length) {
- opts.yaxis = opts.series.map(function (s, i) {
- if (!s.name) {
- opts.series[i].name = "series-".concat(i + 1);
- }
- if (opts.yaxis[i]) {
- opts.yaxis[i].seriesName = opts.series[i].name;
- return opts.yaxis[i];
- } else {
- var newYaxis = Utils.extend(options.yAxis, opts.yaxis[0]);
- newYaxis.show = false;
- return newYaxis;
- }
- });
- }
- if (isLogY && opts.series.length > 1 && opts.series.length !== opts.yaxis.length) {
- console.warn('A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both.');
- }
- return opts;
- }
- }, {
- key: "extendAnnotations",
- value: function extendAnnotations(opts) {
- if (typeof opts.annotations === 'undefined') {
- opts.annotations = {};
- opts.annotations.yaxis = [];
- opts.annotations.xaxis = [];
- opts.annotations.points = [];
- }
- opts = this.extendYAxisAnnotations(opts);
- opts = this.extendXAxisAnnotations(opts);
- opts = this.extendPointAnnotations(opts);
- return opts;
- }
- }, {
- key: "extendYAxisAnnotations",
- value: function extendYAxisAnnotations(opts) {
- var options = new Options();
- opts.annotations.yaxis = Utils.extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], options.yAxisAnnotation);
- return opts;
- }
- }, {
- key: "extendXAxisAnnotations",
- value: function extendXAxisAnnotations(opts) {
- var options = new Options();
- opts.annotations.xaxis = Utils.extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], options.xAxisAnnotation);
- return opts;
- }
- }, {
- key: "extendPointAnnotations",
- value: function extendPointAnnotations(opts) {
- var options = new Options();
- opts.annotations.points = Utils.extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], options.pointAnnotation);
- return opts;
- }
- }, {
- key: "checkForDarkTheme",
- value: function checkForDarkTheme(opts) {
- if (opts.theme && opts.theme.mode === 'dark') {
- if (!opts.tooltip) {
- opts.tooltip = {};
- }
- if (opts.tooltip.theme !== 'light') {
- opts.tooltip.theme = 'dark';
- }
- if (!opts.chart.foreColor) {
- opts.chart.foreColor = '#f6f7f8';
- }
- if (!opts.theme.palette) {
- opts.theme.palette = 'palette4';
- }
- }
- }
- }, {
- key: "handleUserInputErrors",
- value: function handleUserInputErrors(opts) {
- var config = opts;
- if (config.tooltip.shared && config.tooltip.intersect) {
- throw new Error('tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.');
- }
- if ((config.chart.type === 'bar' || config.chart.type === 'rangeBar') && config.plotOptions.bar.horizontal) {
-
- if (config.yaxis.length > 1) {
- throw new Error('Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false');
- }
- if (config.yaxis[0].reversed) {
- config.yaxis[0].opposite = true;
- }
- config.xaxis.tooltip.enabled = false;
- config.yaxis[0].tooltip.enabled = false;
- config.chart.zoom.enabled = false;
- }
- if (config.chart.type === 'bar' || config.chart.type === 'rangeBar') {
- if (config.tooltip.shared) {
- if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) {
- console.warn('crosshairs.width = "barWidth" is only supported in single series, not in a multi-series barChart.');
- config.xaxis.crosshairs.width = 'tickWidth';
- }
- if (config.plotOptions.bar.horizontal) {
- config.states.hover.type = 'none';
- config.tooltip.shared = false;
- }
- if (!config.tooltip.followCursor) {
- console.warn('followCursor option in shared columns cannot be turned off. Please set %ctooltip.followCursor: true', 'color: blue;');
- config.tooltip.followCursor = true;
- }
- }
- }
- if (config.chart.type === 'candlestick') {
- if (config.yaxis[0].reversed) {
- console.warn('Reversed y-axis in candlestick chart is not supported.');
- config.yaxis[0].reversed = false;
- }
- }
- if (config.chart.group && config.yaxis[0].labels.minWidth === 0) {
- console.warn('It looks like you have multiple charts in synchronization. You must provide yaxis.labels.minWidth which must be EQUAL for all grouped charts to prevent incorrect behaviour.');
- }
- if (Array.isArray(config.stroke.width)) {
- if (config.chart.type !== 'line' && config.chart.type !== 'area') {
- console.warn('stroke.width option accepts array only for line and area charts. Reverted back to Number');
- config.stroke.width = config.stroke.width[0];
- }
- }
- return config;
- }
- }]);
- return Config;
- }();
- var Globals = function () {
- function Globals() {
- _classCallCheck(this, Globals);
- }
- _createClass(Globals, [{
- key: "initGlobalVars",
- value: function initGlobalVars(gl) {
- gl.series = [];
- gl.seriesCandleO = [];
- gl.seriesCandleH = [];
- gl.seriesCandleL = [];
- gl.seriesCandleC = [];
- gl.seriesRangeStart = [];
- gl.seriesRangeEnd = [];
- gl.seriesRangeBarTimeline = [];
- gl.seriesPercent = [];
- gl.seriesX = [];
- gl.seriesZ = [];
- gl.seriesNames = [];
- gl.seriesTotals = [];
- gl.seriesLog = [];
- gl.stackedSeriesTotals = [];
- gl.seriesXvalues = [];
-
-
- gl.seriesYvalues = [];
-
- gl.labels = [];
- gl.categoryLabels = [];
- gl.timescaleLabels = [];
- gl.noLabelsProvided = false;
- gl.resizeTimer = null;
- gl.selectionResizeTimer = null;
- gl.delayedElements = [];
- gl.pointsArray = [];
- gl.dataLabelsRects = [];
- gl.isXNumeric = false;
- gl.xaxisLabelsCount = 0;
- gl.skipLastTimelinelabel = false;
- gl.skipFirstTimelinelabel = false;
- gl.x2SpaceAvailable = 0;
- gl.isDataXYZ = false;
- gl.isMultiLineX = false;
- gl.isMultipleYAxis = false;
- gl.maxY = -Number.MAX_VALUE;
- gl.minY = Number.MIN_VALUE;
- gl.minYArr = [];
- gl.maxYArr = [];
- gl.maxX = -Number.MAX_VALUE;
- gl.minX = Number.MAX_VALUE;
- gl.initialMaxX = -Number.MAX_VALUE;
- gl.initialMinX = Number.MAX_VALUE;
- gl.maxDate = 0;
- gl.minDate = Number.MAX_VALUE;
- gl.minZ = Number.MAX_VALUE;
- gl.maxZ = -Number.MAX_VALUE;
- gl.minXDiff = Number.MAX_VALUE;
- gl.yAxisScale = [];
- gl.xAxisScale = null;
- gl.xAxisTicksPositions = [];
- gl.yLabelsCoords = [];
- gl.yTitleCoords = [];
- gl.barPadForNumericAxis = 0;
- gl.padHorizontal = 0;
- gl.xRange = 0;
- gl.yRange = [];
- gl.zRange = 0;
- gl.dataPoints = 0;
- gl.xTickAmount = 0;
- }
- }, {
- key: "globalVars",
- value: function globalVars(config) {
- return {
- chartID: null,
-
- cuid: null,
-
- events: {
- beforeMount: [],
- mounted: [],
- updated: [],
- clicked: [],
- selection: [],
- dataPointSelection: [],
- zoomed: [],
- scrolled: []
- },
- colors: [],
- clientX: null,
- clientY: null,
- fill: {
- colors: []
- },
- stroke: {
- colors: []
- },
- dataLabels: {
- style: {
- colors: []
- }
- },
- radarPolygons: {
- fill: {
- colors: []
- }
- },
- markers: {
- colors: [],
- size: config.markers.size,
- largestSize: 0
- },
- animationEnded: false,
- isTouchDevice: 'ontouchstart' in window || navigator.msMaxTouchPoints,
- isDirty: false,
-
- isExecCalled: false,
-
- initialConfig: null,
-
- lastXAxis: [],
- lastYAxis: [],
- columnSeries: null,
- labels: [],
-
-
- timescaleLabels: [],
-
- noLabelsProvided: false,
-
- allSeriesCollapsed: false,
- collapsedSeries: [],
-
- collapsedSeriesIndices: [],
-
- ancillaryCollapsedSeries: [],
-
- ancillaryCollapsedSeriesIndices: [],
-
- risingSeries: [],
-
- dataFormatXNumeric: false,
-
- capturedSeriesIndex: -1,
- capturedDataPointIndex: -1,
- selectedDataPoints: [],
- goldenPadding: 35,
-
- invalidLogScale: false,
-
- ignoreYAxisIndexes: [],
-
- yAxisSameScaleIndices: [],
- maxValsInArrayIndex: 0,
- radialSize: 0,
- zoomEnabled: config.chart.toolbar.autoSelected === 'zoom' && config.chart.toolbar.tools.zoom && config.chart.zoom.enabled,
- panEnabled: config.chart.toolbar.autoSelected === 'pan' && config.chart.toolbar.tools.pan,
- selectionEnabled: config.chart.toolbar.autoSelected === 'selection' && config.chart.toolbar.tools.selection,
- yaxis: null,
- mousedown: false,
- lastClientPosition: {},
-
- visibleXRange: undefined,
- yValueDecimal: 0,
-
- total: 0,
- SVGNS: 'http://www.w3.org/2000/svg',
-
- svgWidth: 0,
-
- svgHeight: 0,
-
- noData: false,
-
- locale: {},
-
- dom: {},
-
- memory: {
- methodsToExec: []
- },
- shouldAnimate: true,
- skipLastTimelinelabel: false,
-
- skipFirstTimelinelabel: false,
-
- delayedElements: [],
-
- axisCharts: true,
-
-
- isDataXYZ: false,
-
- resized: false,
-
- resizeTimer: null,
-
-
- comboCharts: false,
-
- dataChanged: false,
-
- previousPaths: [],
-
-
- allSeriesHasEqualX: true,
- pointsArray: [],
-
-
- dataLabelsRects: [],
-
- lastDrawnDataLabelsIndexes: [],
- x2SpaceAvailable: 0,
-
- hasNullValues: false,
-
- easing: null,
-
- zoomed: false,
-
- gridWidth: 0,
-
- gridHeight: 0,
-
- rotateXLabels: false,
- defaultLabels: false,
- xLabelFormatter: undefined,
-
- yLabelFormatters: [],
- xaxisTooltipFormatter: undefined,
-
- ttKeyFormatter: undefined,
- ttVal: undefined,
- ttZFormatter: undefined,
- LINE_HEIGHT_RATIO: 1.618,
- xAxisLabelsHeight: 0,
- yAxisLabelsWidth: 0,
- scaleX: 1,
- scaleY: 1,
- translateX: 0,
- translateY: 0,
- translateYAxisX: [],
- yAxisWidths: [],
- translateXAxisY: 0,
- translateXAxisX: 0,
- tooltip: null
- };
- }
- }, {
- key: "init",
- value: function init(config) {
- var globals = this.globalVars(config);
- this.initGlobalVars(globals);
- globals.initialConfig = Utils.extend({}, config);
- globals.initialSeries = JSON.parse(JSON.stringify(globals.initialConfig.series));
- globals.lastXAxis = JSON.parse(JSON.stringify(globals.initialConfig.xaxis));
- globals.lastYAxis = JSON.parse(JSON.stringify(globals.initialConfig.yaxis));
- return globals;
- }
- }]);
- return Globals;
- }();
-
- var Base = function () {
- function Base(opts) {
- _classCallCheck(this, Base);
- this.opts = opts;
- }
- _createClass(Base, [{
- key: "init",
- value: function init() {
- var config = new Config(this.opts).init({
- responsiveOverride: false
- });
- var globals = new Globals().init(config);
- var w = {
- config: config,
- globals: globals
- };
- return w;
- }
- }]);
- return Base;
- }();
-
- var CoreUtils = function () {
- function CoreUtils(ctx) {
- _classCallCheck(this, CoreUtils);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(CoreUtils, [{
- key: "getStackedSeriesTotals",
-
- value: function getStackedSeriesTotals() {
- var w = this.w;
- var total = [];
- if (w.globals.series.length === 0) return total;
- for (var i = 0; i < w.globals.series[w.globals.maxValsInArrayIndex].length; i++) {
- var t = 0;
- for (var j = 0; j < w.globals.series.length; j++) {
- if (typeof w.globals.series[j][i] !== 'undefined') {
- t += w.globals.series[j][i];
- }
- }
- total.push(t);
- }
- w.globals.stackedSeriesTotals = total;
- return total;
- }
- }, {
- key: "getSeriesTotalByIndex",
- value: function getSeriesTotalByIndex() {
- var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- if (index === null) {
-
- return this.w.config.series.reduce(function (acc, cur) {
- return acc + cur;
- }, 0);
- } else {
-
- return this.w.globals.series[index].reduce(function (acc, cur) {
- return acc + cur;
- }, 0);
- }
- }
- }, {
- key: "isSeriesNull",
- value: function isSeriesNull() {
- var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var r = [];
- if (index === null) {
-
- r = this.w.config.series.filter(function (d) {
- return d !== null;
- });
- } else {
-
- r = this.w.config.series[index].data.filter(function (d) {
- return d !== null;
- });
- }
- return r.length === 0;
- }
- }, {
- key: "seriesHaveSameValues",
- value: function seriesHaveSameValues(index) {
- return this.w.globals.series[index].every(function (val, i, arr) {
- return val === arr[0];
- });
- }
- }, {
- key: "getCategoryLabels",
- value: function getCategoryLabels(labels) {
- var w = this.w;
- var catLabels = labels.slice();
- if (w.config.xaxis.convertedCatToNumeric) {
- catLabels = labels.map(function (i) {
- return w.config.xaxis.labels.formatter(i - w.globals.minX + 1);
- });
- }
- return catLabels;
- }
- }, {
- key: "getLargestSeries",
- value: function getLargestSeries() {
- var w = this.w;
- w.globals.maxValsInArrayIndex = w.globals.series.map(function (a) {
- return a.length;
- }).indexOf(Math.max.apply(Math, w.globals.series.map(function (a) {
- return a.length;
- })));
- }
- }, {
- key: "getLargestMarkerSize",
- value: function getLargestMarkerSize() {
- var w = this.w;
- var size = 0;
- w.globals.markers.size.forEach(function (m) {
- size = Math.max(size, m);
- });
- w.globals.markers.largestSize = size;
- return size;
- }
-
- }, {
- key: "getSeriesTotals",
- value: function getSeriesTotals() {
- var w = this.w;
- w.globals.seriesTotals = w.globals.series.map(function (ser, index) {
- var total = 0;
- if (Array.isArray(ser)) {
- for (var j = 0; j < ser.length; j++) {
- total += ser[j];
- }
- } else {
-
- total += ser;
- }
- return total;
- });
- }
- }, {
- key: "getSeriesTotalsXRange",
- value: function getSeriesTotalsXRange(minX, maxX) {
- var w = this.w;
- var seriesTotalsXRange = w.globals.series.map(function (ser, index) {
- var total = 0;
- for (var j = 0; j < ser.length; j++) {
- if (w.globals.seriesX[index][j] > minX && w.globals.seriesX[index][j] < maxX) {
- total += ser[j];
- }
- }
- return total;
- });
- return seriesTotalsXRange;
- }
-
- }, {
- key: "getPercentSeries",
- value: function getPercentSeries() {
- var w = this.w;
- w.globals.seriesPercent = w.globals.series.map(function (ser, index) {
- var seriesPercent = [];
- if (Array.isArray(ser)) {
- for (var j = 0; j < ser.length; j++) {
- var total = w.globals.stackedSeriesTotals[j];
- var percent = 0;
- if (total) {
- percent = 100 * ser[j] / total;
- }
- seriesPercent.push(percent);
- }
- } else {
- var _total = w.globals.seriesTotals.reduce(function (acc, val) {
- return acc + val;
- }, 0);
- var _percent = 100 * ser / _total;
- seriesPercent.push(_percent);
- }
- return seriesPercent;
- });
- }
- }, {
- key: "getCalculatedRatios",
- value: function getCalculatedRatios() {
- var gl = this.w.globals;
- var yRatio = [];
- var invertedYRatio = 0;
- var xRatio = 0;
- var initialXRatio = 0;
- var invertedXRatio = 0;
- var zRatio = 0;
- var baseLineY = [];
- var baseLineInvertedY = 0.1;
- var baseLineX = 0;
- gl.yRange = [];
- if (gl.isMultipleYAxis) {
- for (var i = 0; i < gl.minYArr.length; i++) {
- gl.yRange.push(Math.abs(gl.minYArr[i] - gl.maxYArr[i]));
- baseLineY.push(0);
- }
- } else {
- gl.yRange.push(Math.abs(gl.minY - gl.maxY));
- }
- gl.xRange = Math.abs(gl.maxX - gl.minX);
- gl.zRange = Math.abs(gl.maxZ - gl.minZ);
- for (var _i = 0; _i < gl.yRange.length; _i++) {
- yRatio.push(gl.yRange[_i] / gl.gridHeight);
- }
- xRatio = gl.xRange / gl.gridWidth;
- initialXRatio = Math.abs(gl.initialMaxX - gl.initialMinX) / gl.gridWidth;
- invertedYRatio = gl.yRange / gl.gridWidth;
- invertedXRatio = gl.xRange / gl.gridHeight;
- zRatio = gl.zRange / gl.gridHeight * 16;
- if (!zRatio) {
- zRatio = 1;
- }
- if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
-
- gl.hasNegs = true;
- }
- if (gl.isMultipleYAxis) {
- baseLineY = [];
- for (var _i2 = 0; _i2 < yRatio.length; _i2++) {
- baseLineY.push(-gl.minYArr[_i2] / yRatio[_i2]);
- }
- } else {
- baseLineY.push(-gl.minY / yRatio[0]);
- if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
- baseLineInvertedY = -gl.minY / invertedYRatio;
- baseLineX = gl.minX / xRatio;
- }
- }
- return {
- yRatio: yRatio,
- invertedYRatio: invertedYRatio,
- zRatio: zRatio,
- xRatio: xRatio,
- initialXRatio: initialXRatio,
- invertedXRatio: invertedXRatio,
- baseLineInvertedY: baseLineInvertedY,
- baseLineY: baseLineY,
- baseLineX: baseLineX
- };
- }
- }, {
- key: "getLogSeries",
- value: function getLogSeries(series) {
- var w = this.w;
- w.globals.seriesLog = series.map(function (s, i) {
- if (w.config.yaxis[i] && w.config.yaxis[i].logarithmic) {
- return s.map(function (d) {
- if (d === null) return null;
- var logVal = (Math.log(d) - Math.log(w.globals.minYArr[i])) / (Math.log(w.globals.maxYArr[i]) - Math.log(w.globals.minYArr[i]));
- return logVal;
- });
- } else {
- return s;
- }
- });
- return w.globals.invalidLogScale ? series : w.globals.seriesLog;
- }
- }, {
- key: "getLogYRatios",
- value: function getLogYRatios(yRatio) {
- var _this = this;
- var w = this.w;
- var gl = this.w.globals;
- gl.yLogRatio = yRatio.slice();
- gl.logYRange = gl.yRange.map(function (yRange, i) {
- if (w.config.yaxis[i] && _this.w.config.yaxis[i].logarithmic) {
- var maxY = -Number.MAX_VALUE;
- var minY = Number.MIN_VALUE;
- var range = 1;
- gl.seriesLog.forEach(function (s, si) {
- s.forEach(function (v) {
- if (w.config.yaxis[si] && w.config.yaxis[si].logarithmic) {
- maxY = Math.max(v, maxY);
- minY = Math.min(v, minY);
- }
- });
- });
- range = Math.pow(gl.yRange[i], Math.abs(minY - maxY) / gl.yRange[i]);
- gl.yLogRatio[i] = range / gl.gridHeight;
- return range;
- }
- });
- return gl.invalidLogScale ? yRatio.slice() : gl.yLogRatio;
- }
- }], [{
- key: "checkComboSeries",
- value: function checkComboSeries(series) {
- var comboCharts = false;
- var comboBarCount = 0;
- if (series.length && typeof series[0].type !== 'undefined') {
- comboCharts = true;
- series.forEach(function (s) {
- if (s.type === 'bar' || s.type === 'column' || s.type === 'candlestick') {
- comboBarCount++;
- }
- });
- }
- return {
- comboBarCount: comboBarCount,
- comboCharts: comboCharts
- };
- }
- }, {
- key: "extendArrayProps",
- value: function extendArrayProps(configInstance, options) {
- if (options.yaxis) {
- options = configInstance.extendYAxis(options);
- }
- if (options.annotations) {
- if (options.annotations.yaxis) {
- options = configInstance.extendYAxisAnnotations(options);
- }
- if (options.annotations.xaxis) {
- options = configInstance.extendXAxisAnnotations(options);
- }
- if (options.annotations.points) {
- options = configInstance.extendPointAnnotations(options);
- }
- }
- return options;
- }
- }]);
- return CoreUtils;
- }();
-
- var Fill = function () {
- function Fill(ctx) {
- _classCallCheck(this, Fill);
- this.ctx = ctx;
- this.w = ctx.w;
- this.opts = null;
- this.seriesIndex = 0;
- }
- _createClass(Fill, [{
- key: "clippedImgArea",
- value: function clippedImgArea(params) {
- var w = this.w;
- var cnf = w.config;
- var svgW = parseInt(w.globals.gridWidth, 10);
- var svgH = parseInt(w.globals.gridHeight, 10);
- var size = svgW > svgH ? svgW : svgH;
- var fillImg = params.image;
- var imgWidth = 0;
- var imgHeight = 0;
- if (typeof params.width === 'undefined' && typeof params.height === 'undefined') {
- if (cnf.fill.image.width !== undefined && cnf.fill.image.height !== undefined) {
- imgWidth = cnf.fill.image.width + 1;
- imgHeight = cnf.fill.image.height;
- } else {
- imgWidth = size + 1;
- imgHeight = size;
- }
- } else {
- imgWidth = params.width;
- imgHeight = params.height;
- }
- var elPattern = document.createElementNS(w.globals.SVGNS, 'pattern');
- Graphics.setAttrs(elPattern, {
- id: params.patternID,
- patternUnits: params.patternUnits ? params.patternUnits : 'userSpaceOnUse',
- width: imgWidth + 'px',
- height: imgHeight + 'px'
- });
- var elImage = document.createElementNS(w.globals.SVGNS, 'image');
- elPattern.appendChild(elImage);
- elImage.setAttributeNS(window.SVG.xlink, 'href', fillImg);
- Graphics.setAttrs(elImage, {
- x: 0,
- y: 0,
- preserveAspectRatio: 'none',
- width: imgWidth + 'px',
- height: imgHeight + 'px'
- });
- elImage.style.opacity = params.opacity;
- w.globals.dom.elDefs.node.appendChild(elPattern);
- }
- }, {
- key: "getSeriesIndex",
- value: function getSeriesIndex(opts) {
- var w = this.w;
- if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap') {
- this.seriesIndex = opts.seriesNumber;
- } else {
- this.seriesIndex = opts.seriesNumber % w.globals.series.length;
- }
- return this.seriesIndex;
- }
- }, {
- key: "fillPath",
- value: function fillPath(opts) {
- var w = this.w;
- this.opts = opts;
- var cnf = this.w.config;
- var pathFill;
- var patternFill, gradientFill;
- this.seriesIndex = this.getSeriesIndex(opts);
- var fillColors = this.getFillColors();
- var fillColor = fillColors[this.seriesIndex];
- if (typeof fillColor === 'function') {
- fillColor = fillColor({
- seriesIndex: this.seriesIndex,
- dataPointIndex: opts.dataPointIndex,
- value: opts.value,
- w: w
- });
- }
- var fillType = this.getFillType(this.seriesIndex);
- var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[this.seriesIndex] : cnf.fill.opacity;
- var defaultColor = fillColor;
- if (opts.color) {
- fillColor = opts.color;
- }
- if (fillColor.indexOf('rgb') === -1) {
- if (fillColor.length < 9) {
-
- defaultColor = Utils.hexToRgba(fillColor, fillOpacity);
- }
- } else {
- if (fillColor.indexOf('rgba') > -1) {
- fillOpacity = Utils.getOpacityFromRGBA(fillColor);
- }
- }
- if (opts.opacity) fillOpacity = opts.opacity;
- if (fillType === 'pattern') {
- patternFill = this.handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor);
- }
- if (fillType === 'gradient') {
- gradientFill = this.handleGradientFill(fillColor, fillOpacity, this.seriesIndex);
- }
- if (fillType === 'image') {
- var imgSrc = cnf.fill.image.src;
- var patternID = opts.patternID ? opts.patternID : '';
- this.clippedImgArea({
- opacity: fillOpacity,
- image: Array.isArray(imgSrc) ? opts.seriesNumber < imgSrc.length ? imgSrc[opts.seriesNumber] : imgSrc[0] : imgSrc,
- width: opts.width ? opts.width : undefined,
- height: opts.height ? opts.height : undefined,
- patternUnits: opts.patternUnits,
- patternID: "pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID)
- });
- pathFill = "url(#pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID, ")");
- } else if (fillType === 'gradient') {
- pathFill = gradientFill;
- } else if (fillType === 'pattern') {
- pathFill = patternFill;
- } else {
- pathFill = defaultColor;
- }
- if (opts.solid) {
- pathFill = defaultColor;
- }
- return pathFill;
- }
- }, {
- key: "getFillType",
- value: function getFillType(seriesIndex) {
- var w = this.w;
- if (Array.isArray(w.config.fill.type)) {
- return w.config.fill.type[seriesIndex];
- } else {
- return w.config.fill.type;
- }
- }
- }, {
- key: "getFillColors",
- value: function getFillColors() {
- var w = this.w;
- var cnf = w.config;
- var opts = this.opts;
- var fillColors = [];
- if (w.globals.comboCharts) {
- if (w.config.series[this.seriesIndex].type === 'line') {
- if (w.globals.stroke.colors instanceof Array) {
- fillColors = w.globals.stroke.colors;
- } else {
- fillColors.push(w.globals.stroke.colors);
- }
- } else {
- if (w.globals.fill.colors instanceof Array) {
- fillColors = w.globals.fill.colors;
- } else {
- fillColors.push(w.globals.fill.colors);
- }
- }
- } else {
- if (cnf.chart.type === 'line') {
- if (w.globals.stroke.colors instanceof Array) {
- fillColors = w.globals.stroke.colors;
- } else {
- fillColors.push(w.globals.stroke.colors);
- }
- } else {
- if (w.globals.fill.colors instanceof Array) {
- fillColors = w.globals.fill.colors;
- } else {
- fillColors.push(w.globals.fill.colors);
- }
- }
- }
- if (typeof opts.fillColors !== 'undefined') {
- fillColors = [];
- if (opts.fillColors instanceof Array) {
- fillColors = opts.fillColors.slice();
- } else {
- fillColors.push(opts.fillColors);
- }
- }
- return fillColors;
- }
- }, {
- key: "handlePatternFill",
- value: function handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor) {
- var cnf = this.w.config;
- var opts = this.opts;
- var graphics = new Graphics(this.ctx);
- var patternStrokeWidth = cnf.fill.pattern.strokeWidth === undefined ? Array.isArray(cnf.stroke.width) ? cnf.stroke.width[this.seriesIndex] : cnf.stroke.width : Array.isArray(cnf.fill.pattern.strokeWidth) ? cnf.fill.pattern.strokeWidth[this.seriesIndex] : cnf.fill.pattern.strokeWidth;
- var patternLineColor = fillColor;
- if (cnf.fill.pattern.style instanceof Array) {
- if (typeof cnf.fill.pattern.style[opts.seriesNumber] !== 'undefined') {
- var pf = graphics.drawPattern(cnf.fill.pattern.style[opts.seriesNumber], cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
- patternFill = pf;
- } else {
- patternFill = defaultColor;
- }
- } else {
- patternFill = graphics.drawPattern(cnf.fill.pattern.style, cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
- }
- return patternFill;
- }
- }, {
- key: "handleGradientFill",
- value: function handleGradientFill(fillColor, fillOpacity, i) {
- var cnf = this.w.config;
- var opts = this.opts;
- var graphics = new Graphics(this.ctx);
- var utils = new Utils();
- var type = cnf.fill.gradient.type;
- var gradientFrom = fillColor;
- var gradientTo;
- var opacityFrom = cnf.fill.gradient.opacityFrom === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityFrom) ? cnf.fill.gradient.opacityFrom[i] : cnf.fill.gradient.opacityFrom;
- if (gradientFrom.indexOf('rgba') > -1) {
- opacityFrom = Utils.getOpacityFromRGBA(gradientFrom);
- }
- var opacityTo = cnf.fill.gradient.opacityTo === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityTo) ? cnf.fill.gradient.opacityTo[i] : cnf.fill.gradient.opacityTo;
- if (cnf.fill.gradient.gradientToColors === undefined || cnf.fill.gradient.gradientToColors.length === 0) {
- if (cnf.fill.gradient.shade === 'dark') {
- gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity) * -1, fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
- } else {
- gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity), fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
- }
- } else {
- var gToColor = cnf.fill.gradient.gradientToColors[opts.seriesNumber];
- gradientTo = gToColor;
- if (gToColor.indexOf('rgba') > -1) {
- opacityTo = Utils.getOpacityFromRGBA(gToColor);
- }
- }
- if (cnf.fill.gradient.inverseColors) {
- var t = gradientFrom;
- gradientFrom = gradientTo;
- gradientTo = t;
- }
- if (gradientFrom.indexOf('rgb') > -1) {
- gradientFrom = Utils.rgb2hex(gradientFrom);
- }
- if (gradientTo.indexOf('rgb') > -1) {
- gradientTo = Utils.rgb2hex(gradientTo);
- }
- return graphics.drawGradient(type, gradientFrom, gradientTo, opacityFrom, opacityTo, opts.size, cnf.fill.gradient.stops, cnf.fill.gradient.colorStops, i);
- }
- }]);
- return Fill;
- }();
-
- var Markers = function () {
- function Markers(ctx, opts) {
- _classCallCheck(this, Markers);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Markers, [{
- key: "setGlobalMarkerSize",
- value: function setGlobalMarkerSize() {
- var w = this.w;
- w.globals.markers.size = Array.isArray(w.config.markers.size) ? w.config.markers.size : [w.config.markers.size];
- if (w.globals.markers.size.length > 0) {
- if (w.globals.markers.size.length < w.globals.series.length + 1) {
- for (var i = 0; i <= w.globals.series.length; i++) {
- if (typeof w.globals.markers.size[i] === 'undefined') {
- w.globals.markers.size.push(w.globals.markers.size[0]);
- }
- }
- }
- } else {
- w.globals.markers.size = w.config.series.map(function (s) {
- return w.config.markers.size;
- });
- }
- }
- }, {
- key: "plotChartMarkers",
- value: function plotChartMarkers(pointsPos, seriesIndex, j, pSize) {
- var alwaysDrawMarker = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
- var w = this.w;
- var i = seriesIndex;
- var p = pointsPos;
- var elPointsWrap = null;
- var graphics = new Graphics(this.ctx);
- var point;
- if (w.globals.markers.size[seriesIndex] > 0 || alwaysDrawMarker) {
- elPointsWrap = graphics.group({
- class: alwaysDrawMarker ? '' : 'apexcharts-series-markers'
- });
- elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
- }
- if (p.x instanceof Array) {
- for (var q = 0; q < p.x.length; q++) {
- var dataPointIndex = j;
- if (j === 1 && q === 0) dataPointIndex = 0;
- if (j === 1 && q === 1) dataPointIndex = 1;
- var PointClasses = 'apexcharts-marker';
- if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
- PointClasses += ' no-pointer-events';
- }
- var shouldMarkerDraw = Array.isArray(w.config.markers.size) ? w.globals.markers.size[seriesIndex] > 0 : w.config.markers.size > 0;
- if (shouldMarkerDraw || alwaysDrawMarker) {
- if (Utils.isNumber(p.y[q])) {
- PointClasses += " w".concat(Utils.randomId());
- } else {
- PointClasses = 'apexcharts-nullpoint';
- }
- var opts = this.getMarkerConfig(PointClasses, seriesIndex, dataPointIndex);
- if (w.config.series[i].data[j]) {
- if (w.config.series[i].data[j].fillColor) {
- opts.pointFillColor = w.config.series[i].data[j].fillColor;
- }
- if (w.config.series[i].data[j].strokeColor) {
- opts.pointStrokeColor = w.config.series[i].data[j].strokeColor;
- }
- }
- if (pSize) {
- opts.pSize = pSize;
- }
- point = graphics.drawMarker(p.x[q], p.y[q], opts);
- point.attr('rel', dataPointIndex);
- point.attr('j', dataPointIndex);
- point.attr('index', seriesIndex);
- point.node.setAttribute('default-marker-size', opts.pSize);
- var filters = new Filters(this.ctx);
- filters.setSelectionFilter(point, seriesIndex, dataPointIndex);
- this.addEvents(point);
- if (elPointsWrap) {
- elPointsWrap.add(point);
- }
- } else {
-
- if (typeof w.globals.pointsArray[seriesIndex] === 'undefined') w.globals.pointsArray[seriesIndex] = [];
- w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]);
- }
- }
- }
- return elPointsWrap;
- }
- }, {
- key: "getMarkerConfig",
- value: function getMarkerConfig(cssClass, seriesIndex) {
- var dataPointIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var w = this.w;
- var pStyle = this.getMarkerStyle(seriesIndex);
- var pSize = w.globals.markers.size[seriesIndex];
- var m = w.config.markers;
- if (dataPointIndex !== null && m.discrete.length) {
- m.discrete.map(function (marker) {
- if (marker.seriesIndex === seriesIndex && marker.dataPointIndex === dataPointIndex) {
- pStyle.pointStrokeColor = marker.strokeColor;
- pStyle.pointFillColor = marker.fillColor;
- pSize = marker.size;
- }
- });
- }
- return {
- pSize: pSize,
- pRadius: m.radius,
- pWidth: m.strokeWidth instanceof Array ? m.strokeWidth[seriesIndex] : m.strokeWidth,
- pointStrokeColor: pStyle.pointStrokeColor,
- pointFillColor: pStyle.pointFillColor,
- shape: m.shape instanceof Array ? m.shape[seriesIndex] : m.shape,
- class: cssClass,
- pointStrokeOpacity: m.strokeOpacity instanceof Array ? m.strokeOpacity[seriesIndex] : m.strokeOpacity,
- pointStrokeDashArray: m.strokeDashArray instanceof Array ? m.strokeDashArray[seriesIndex] : m.strokeDashArray,
- pointFillOpacity: m.fillOpacity instanceof Array ? m.fillOpacity[seriesIndex] : m.fillOpacity,
- seriesIndex: seriesIndex
- };
- }
- }, {
- key: "addEvents",
- value: function addEvents(circle) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- circle.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this.ctx, circle));
- circle.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this.ctx, circle));
- circle.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this.ctx, circle));
- circle.node.addEventListener('click', w.config.markers.onClick);
- circle.node.addEventListener('dblclick', w.config.markers.onDblClick);
- circle.node.addEventListener('touchstart', graphics.pathMouseDown.bind(this.ctx, circle), {
- passive: true
- });
- }
- }, {
- key: "getMarkerStyle",
- value: function getMarkerStyle(seriesIndex) {
- var w = this.w;
- var colors = w.globals.markers.colors;
- var strokeColors = w.config.markers.strokeColor || w.config.markers.strokeColors;
- var pointStrokeColor = strokeColors instanceof Array ? strokeColors[seriesIndex] : strokeColors;
- var pointFillColor = colors instanceof Array ? colors[seriesIndex] : colors;
- return {
- pointStrokeColor: pointStrokeColor,
- pointFillColor: pointFillColor
- };
- }
- }]);
- return Markers;
- }();
-
- var Scatter = function () {
- function Scatter(ctx) {
- _classCallCheck(this, Scatter);
- this.ctx = ctx;
- this.w = ctx.w;
- this.initialAnim = this.w.config.chart.animations.enabled;
- this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
- }
- _createClass(Scatter, [{
- key: "draw",
- value: function draw(elSeries, j, opts) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var realIndex = opts.realIndex;
- var pointsPos = opts.pointsPos;
- var zRatio = opts.zRatio;
- var elPointsMain = opts.elParent;
- var elPointsWrap = graphics.group({
- class: "apexcharts-series-markers apexcharts-series-".concat(w.config.chart.type)
- });
- elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
- if (pointsPos.x instanceof Array) {
- for (var q = 0; q < pointsPos.x.length; q++) {
- var dataPointIndex = j + 1;
- var shouldDraw = true;
- if (j === 0 && q === 0) dataPointIndex = 0;
- if (j === 0 && q === 1) dataPointIndex = 1;
- var radius = 0;
- var finishRadius = w.globals.markers.size[realIndex];
- if (zRatio !== Infinity) {
-
- finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] / zRatio;
- var bubble = w.config.plotOptions.bubble;
- if (bubble.minBubbleRadius && finishRadius < bubble.minBubbleRadius) {
- finishRadius = bubble.minBubbleRadius;
- }
- if (bubble.maxBubbleRadius && finishRadius > bubble.maxBubbleRadius) {
- finishRadius = bubble.maxBubbleRadius;
- }
- }
- if (!w.config.chart.animations.enabled) {
- radius = finishRadius;
- }
- var x = pointsPos.x[q];
- var y = pointsPos.y[q];
- radius = radius || 0;
- if (y === null || typeof w.globals.series[realIndex][dataPointIndex] === 'undefined') {
- shouldDraw = false;
- }
- if (shouldDraw) {
- var circle = this.drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j);
- elPointsWrap.add(circle);
- }
- elPointsMain.add(elPointsWrap);
- }
- }
- }
- }, {
- key: "drawPoint",
- value: function drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j) {
- var w = this.w;
- var i = realIndex;
- var anim = new Animations(this.ctx);
- var filters = new Filters(this.ctx);
- var fill = new Fill(this.ctx);
- var markers = new Markers(this.ctx);
- var graphics = new Graphics(this.ctx);
- var markerConfig = markers.getMarkerConfig('apexcharts-marker', i);
- var pathFillCircle = fill.fillPath({
- seriesNumber: realIndex,
- dataPointIndex: dataPointIndex,
- patternUnits: 'objectBoundingBox',
- value: w.globals.series[realIndex][j]
- });
- var circle = graphics.drawCircle(radius);
- if (w.config.series[i].data[dataPointIndex]) {
- if (w.config.series[i].data[dataPointIndex].fillColor) {
- pathFillCircle = w.config.series[i].data[dataPointIndex].fillColor;
- }
- }
- circle.attr({
- cx: x,
- cy: y,
- fill: pathFillCircle,
- stroke: markerConfig.pointStrokeColor,
- 'stroke-width': markerConfig.pWidth,
- 'stroke-dasharray': markerConfig.pointStrokeDashArray,
- 'stroke-opacity': markerConfig.pointStrokeOpacity
- });
- if (w.config.chart.dropShadow.enabled) {
- var dropShadow = w.config.chart.dropShadow;
- filters.dropShadow(circle, dropShadow, realIndex);
- }
- if (this.initialAnim && !w.globals.dataChanged) {
- var speed = 1;
- if (!w.globals.resized) {
- speed = w.config.chart.animations.speed;
- }
- anim.animateCircleRadius(circle, 0, finishRadius, speed, w.globals.easing, function () {
- window.setTimeout(function () {
- anim.animationCompleted(circle);
- }, 100);
- });
- }
- if (w.globals.dataChanged) {
- if (this.dynamicAnim) {
- var _speed = w.config.chart.animations.dynamicAnimation.speed;
- var prevX, prevY, prevR;
- var prevPathJ = null;
- prevPathJ = w.globals.previousPaths[realIndex] && w.globals.previousPaths[realIndex][j];
- if (typeof prevPathJ !== 'undefined' && prevPathJ !== null) {
-
- prevX = prevPathJ.x;
- prevY = prevPathJ.y;
- prevR = typeof prevPathJ.r !== 'undefined' ? prevPathJ.r : finishRadius;
- }
- for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) {
- if (w.globals.collapsedSeries[cs].index === realIndex) {
- _speed = 1;
- finishRadius = 0;
- }
- }
- if (x === 0 && y === 0) finishRadius = 0;
- anim.animateCircle(circle, {
- cx: prevX,
- cy: prevY,
- r: prevR
- }, {
- cx: x,
- cy: y,
- r: finishRadius
- }, _speed, w.globals.easing);
- } else {
- circle.attr({
- r: finishRadius
- });
- }
- }
- circle.attr({
- rel: dataPointIndex,
- j: dataPointIndex,
- index: realIndex,
- 'default-marker-size': finishRadius
- });
- filters.setSelectionFilter(circle, realIndex, dataPointIndex);
- markers.addEvents(circle);
- circle.node.classList.add('apexcharts-marker');
- return circle;
- }
- }, {
- key: "centerTextInBubble",
- value: function centerTextInBubble(y) {
- var w = this.w;
- y = y + parseInt(w.config.dataLabels.style.fontSize, 10) / 4;
- return {
- y: y
- };
- }
- }]);
- return Scatter;
- }();
-
- var DataLabels = function () {
- function DataLabels(ctx) {
- _classCallCheck(this, DataLabels);
- this.ctx = ctx;
- this.w = ctx.w;
- }
-
- _createClass(DataLabels, [{
- key: "dataLabelsCorrection",
- value: function dataLabelsCorrection(x, y, val, i, dataPointIndex, alwaysDrawDataLabel, fontSize) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var drawnextLabel = false;
- var textRects = graphics.getTextRects(val, fontSize);
- var width = textRects.width;
- var height = textRects.height;
- if (typeof w.globals.dataLabelsRects[i] === 'undefined') w.globals.dataLabelsRects[i] = [];
- w.globals.dataLabelsRects[i].push({
- x: x,
- y: y,
- width: width,
- height: height
- });
- var len = w.globals.dataLabelsRects[i].length - 2;
- var lastDrawnIndex = typeof w.globals.lastDrawnDataLabelsIndexes[i] !== 'undefined' ? w.globals.lastDrawnDataLabelsIndexes[i][w.globals.lastDrawnDataLabelsIndexes[i].length - 1] : 0;
- if (typeof w.globals.dataLabelsRects[i][len] !== 'undefined') {
- var lastDataLabelRect = w.globals.dataLabelsRects[i][lastDrawnIndex];
- if (
- x > lastDataLabelRect.x + lastDataLabelRect.width + 2 || y > lastDataLabelRect.y + lastDataLabelRect.height + 2 || x + width < lastDataLabelRect.x
- ) {
-
- drawnextLabel = true;
- }
- }
- if (dataPointIndex === 0 || alwaysDrawDataLabel) {
- drawnextLabel = true;
- }
- return {
- x: x,
- y: y,
- textRects: textRects,
- drawnextLabel: drawnextLabel
- };
- }
- }, {
- key: "drawDataLabel",
- value: function drawDataLabel(pos, i, j) {
- var _this = this;
- var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
-
-
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var dataLabelsConfig = w.config.dataLabels;
- var x = 0;
- var y = 0;
- var dataPointIndex = j;
- var elDataLabelsWrap = null;
- if (!dataLabelsConfig.enabled || pos.x instanceof Array !== true) {
- return elDataLabelsWrap;
- }
- elDataLabelsWrap = graphics.group({
- class: 'apexcharts-data-labels'
- });
- for (var q = 0; q < pos.x.length; q++) {
- x = pos.x[q] + dataLabelsConfig.offsetX;
- y = pos.y[q] + dataLabelsConfig.offsetY + strokeWidth;
- if (!isNaN(x)) {
-
- if (j === 1 && q === 0) dataPointIndex = 0;
- if (j === 1 && q === 1) dataPointIndex = 1;
- var val = w.globals.series[i][dataPointIndex];
- var text = '';
- var getText = function getText(v) {
- return w.config.dataLabels.formatter(v, {
- ctx: _this.ctx,
- seriesIndex: i,
- dataPointIndex: dataPointIndex,
- w: w
- });
- };
- if (w.config.chart.type === 'bubble') {
- val = w.globals.seriesZ[i][dataPointIndex];
- text = getText(val);
- y = pos.y[q];
- var scatter = new Scatter(this.ctx);
- var centerTextInBubbleCoords = scatter.centerTextInBubble(y, i, dataPointIndex);
- y = centerTextInBubbleCoords.y;
- } else {
- if (typeof val !== 'undefined') {
- text = getText(val);
- }
- }
- this.plotDataLabelsText({
- x: x,
- y: y,
- text: text,
- i: i,
- j: dataPointIndex,
- parent: elDataLabelsWrap,
- offsetCorrection: true,
- dataLabelsConfig: w.config.dataLabels
- });
- }
- }
- return elDataLabelsWrap;
- }
- }, {
- key: "plotDataLabelsText",
- value: function plotDataLabelsText(opts) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var x = opts.x,
- y = opts.y,
- i = opts.i,
- j = opts.j,
- text = opts.text,
- textAnchor = opts.textAnchor,
- parent = opts.parent,
- dataLabelsConfig = opts.dataLabelsConfig,
- color = opts.color,
- alwaysDrawDataLabel = opts.alwaysDrawDataLabel,
- offsetCorrection = opts.offsetCorrection;
- if (Array.isArray(w.config.dataLabels.enabledOnSeries)) {
- if (w.config.dataLabels.enabledOnSeries.indexOf(i) < 0) {
- return;
- }
- }
- var correctedLabels = {
- x: x,
- y: y,
- drawnextLabel: true
- };
- if (offsetCorrection) {
- correctedLabels = this.dataLabelsCorrection(x, y, text, i, j, alwaysDrawDataLabel, parseInt(dataLabelsConfig.style.fontSize, 10));
- }
-
- if (!w.globals.zoomed) {
- x = correctedLabels.x;
- y = correctedLabels.y;
- }
- if (correctedLabels.textRects) {
- if (x + correctedLabels.textRects.width < -20 || x > w.globals.gridWidth + 20) {
-
- text = '';
- }
- }
- var dataLabelColor = w.globals.dataLabels.style.colors[i];
- if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.dataLabels.distributed) {
- dataLabelColor = w.globals.dataLabels.style.colors[j];
- }
- if (color) {
- dataLabelColor = color;
- }
- var offX = dataLabelsConfig.offsetX;
- var offY = dataLabelsConfig.offsetY;
- if (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') {
-
-
-
- offX = 0;
- offY = 0;
- }
- if (correctedLabels.drawnextLabel) {
- var dataLabelText = graphics.drawText({
- width: 100,
- height: parseInt(dataLabelsConfig.style.fontSize, 10),
- x: x + offX,
- y: y + offY,
- foreColor: dataLabelColor,
- textAnchor: textAnchor || dataLabelsConfig.textAnchor,
- text: text,
- fontSize: dataLabelsConfig.style.fontSize,
- fontFamily: dataLabelsConfig.style.fontFamily,
- fontWeight: dataLabelsConfig.style.fontWeight || 'normal'
- });
- dataLabelText.attr({
- class: 'apexcharts-datalabel',
- cx: x,
- cy: y
- });
- if (dataLabelsConfig.dropShadow.enabled) {
- var textShadow = dataLabelsConfig.dropShadow;
- var filters = new Filters(this.ctx);
- filters.dropShadow(dataLabelText, textShadow);
- }
- parent.add(dataLabelText);
- if (typeof w.globals.lastDrawnDataLabelsIndexes[i] === 'undefined') {
- w.globals.lastDrawnDataLabelsIndexes[i] = [];
- }
- w.globals.lastDrawnDataLabelsIndexes[i].push(j);
- }
- }
- }, {
- key: "addBackgroundToDataLabel",
- value: function addBackgroundToDataLabel(el, coords) {
- var w = this.w;
- var bCnf = w.config.dataLabels.background;
- var paddingH = bCnf.padding;
- var paddingV = bCnf.padding / 2;
- var width = coords.width;
- var height = coords.height;
- var graphics = new Graphics(this.ctx);
- var elRect = graphics.drawRect(coords.x - paddingH, coords.y - paddingV / 2, width + paddingH * 2, height + paddingV, bCnf.borderRadius, w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background, bCnf.opacity, bCnf.borderWidth, bCnf.borderColor);
- if (bCnf.dropShadow.enabled) {
- var filters = new Filters(this.ctx);
- filters.dropShadow(elRect, bCnf.dropShadow);
- }
- return elRect;
- }
- }, {
- key: "dataLabelsBackground",
- value: function dataLabelsBackground() {
- var w = this.w;
- if (w.config.chart.type === 'bubble') return;
- var elDataLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-datalabels text');
- for (var i = 0; i < elDataLabels.length; i++) {
- var el = elDataLabels[i];
- var coords = el.getBBox();
- var elRect = null;
- if (coords.width && coords.height) {
- elRect = this.addBackgroundToDataLabel(el, coords);
- }
- if (elRect) {
- el.parentNode.insertBefore(elRect.node, el);
- var background = el.getAttribute('fill');
- var shouldAnim = w.config.chart.animations.enabled && !w.globals.resized && !w.globals.dataChanged;
- if (shouldAnim) {
- elRect.animate().attr({
- fill: background
- });
- } else {
- elRect.attr({
- fill: background
- });
- }
- el.setAttribute('fill', w.config.dataLabels.background.foreColor);
- }
- }
- }
- }, {
- key: "bringForward",
- value: function bringForward() {
- var w = this.w;
- var elDataLabelsNodes = w.globals.dom.baseEl.getElementsByClassName('apexcharts-datalabels');
- var elSeries = w.globals.dom.baseEl.querySelector('.apexcharts-plot-series:last-child');
- for (var i = 0; i < elDataLabelsNodes.length; i++) {
- if (elSeries) {
- elSeries.insertBefore(elDataLabelsNodes[i], elSeries.nextSibling);
- }
- }
- }
- }]);
- return DataLabels;
- }();
-
- var Series = function () {
- function Series(ctx) {
- _classCallCheck(this, Series);
- this.ctx = ctx;
- this.w = ctx.w;
- this.legendInactiveClass = 'legend-mouseover-inactive';
- }
- _createClass(Series, [{
- key: "getAllSeriesEls",
- value: function getAllSeriesEls() {
- return this.w.globals.dom.baseEl.getElementsByClassName("apexcharts-series");
- }
- }, {
- key: "getSeriesByName",
- value: function getSeriesByName(seriesName) {
- return this.w.globals.dom.baseEl.querySelector("[seriesName='".concat(Utils.escapeString(seriesName), "']"));
- }
- }, {
- key: "isSeriesHidden",
- value: function isSeriesHidden(seriesName) {
- var targetElement = this.getSeriesByName(seriesName);
- var realIndex = parseInt(targetElement.getAttribute('data:realIndex'), 10);
- var isHidden = targetElement.classList.contains('apexcharts-series-collapsed');
- return {
- isHidden: isHidden,
- realIndex: realIndex
- };
- }
- }, {
- key: "addCollapsedClassToSeries",
- value: function addCollapsedClassToSeries(elSeries, index) {
- var w = this.w;
- function iterateOnAllCollapsedSeries(series) {
- for (var cs = 0; cs < series.length; cs++) {
- if (series[cs].index === index) {
- elSeries.node.classList.add('apexcharts-series-collapsed');
- }
- }
- }
- iterateOnAllCollapsedSeries(w.globals.collapsedSeries);
- iterateOnAllCollapsedSeries(w.globals.ancillaryCollapsedSeries);
- }
- }, {
- key: "toggleSeries",
- value: function toggleSeries(seriesName) {
- var isSeriesHidden = this.isSeriesHidden(seriesName);
- this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, isSeriesHidden.isHidden);
- return isSeriesHidden.isHidden;
- }
- }, {
- key: "showSeries",
- value: function showSeries(seriesName) {
- var isSeriesHidden = this.isSeriesHidden(seriesName);
- if (isSeriesHidden.isHidden) {
- this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, true);
- }
- }
- }, {
- key: "hideSeries",
- value: function hideSeries(seriesName) {
- var isSeriesHidden = this.isSeriesHidden(seriesName);
- if (!isSeriesHidden.isHidden) {
- this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, false);
- }
- }
- }, {
- key: "resetSeries",
- value: function resetSeries() {
- var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var shouldResetCollapsed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var w = this.w;
- var series = w.globals.initialSeries.slice();
- w.config.series = series;
- w.globals.previousPaths = [];
- if (shouldResetCollapsed) {
- w.globals.collapsedSeries = [];
- w.globals.ancillaryCollapsedSeries = [];
- w.globals.collapsedSeriesIndices = [];
- w.globals.ancillaryCollapsedSeriesIndices = [];
- }
- if (shouldUpdateChart) {
- if (shouldResetZoom) {
- w.globals.zoomed = false;
- this.ctx.updateHelpers.revertDefaultAxisMinMax();
- }
- this.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
- }
- }
- }, {
- key: "toggleSeriesOnHover",
- value: function toggleSeriesOnHover(e, targetElement) {
- var w = this.w;
- var allSeriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");
- if (e.type === 'mousemove') {
- var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
- var seriesEl = null;
- var dataLabelEl = null;
- if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
- if (w.globals.axisCharts) {
- seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
- dataLabelEl = w.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(seriesCnt, "']"));
- } else {
- seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
- }
- } else {
- seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
- }
- for (var se = 0; se < allSeriesEls.length; se++) {
- allSeriesEls[se].classList.add(this.legendInactiveClass);
- }
- if (seriesEl !== null) {
- if (!w.globals.axisCharts) {
- seriesEl.parentNode.classList.remove(this.legendInactiveClass);
- }
- seriesEl.classList.remove(this.legendInactiveClass);
- if (dataLabelEl !== null) {
- dataLabelEl.classList.remove(this.legendInactiveClass);
- }
- }
- } else if (e.type === 'mouseout') {
- for (var _se = 0; _se < allSeriesEls.length; _se++) {
- allSeriesEls[_se].classList.remove(this.legendInactiveClass);
- }
- }
- }
- }, {
- key: "highlightRangeInSeries",
- value: function highlightRangeInSeries(e, targetElement) {
- var _this = this;
- var w = this.w;
- var allHeatMapElements = w.globals.dom.baseEl.getElementsByClassName('apexcharts-heatmap-rect');
- var activeInactive = function activeInactive(action) {
- for (var i = 0; i < allHeatMapElements.length; i++) {
- allHeatMapElements[i].classList[action](_this.legendInactiveClass);
- }
- };
- var removeInactiveClassFromHoveredRange = function removeInactiveClassFromHoveredRange(range) {
- for (var i = 0; i < allHeatMapElements.length; i++) {
- var val = parseInt(allHeatMapElements[i].getAttribute('val'), 10);
- if (val >= range.from && val <= range.to) {
- allHeatMapElements[i].classList.remove(_this.legendInactiveClass);
- }
- }
- };
- if (e.type === 'mousemove') {
- var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
- activeInactive('add');
- var range = w.config.plotOptions.heatmap.colorScale.ranges[seriesCnt];
- removeInactiveClassFromHoveredRange(range);
- } else if (e.type === 'mouseout') {
- activeInactive('remove');
- }
- }
- }, {
- key: "getActiveConfigSeriesIndex",
- value: function getActiveConfigSeriesIndex() {
- var ignoreBars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- var w = this.w;
- var activeIndex = 0;
- if (w.config.series.length > 1) {
-
- var firstActiveSeriesIndex = w.config.series.map(function (series, index) {
- var hasBars = false;
- if (ignoreBars) {
- hasBars = w.config.series[index].type === 'bar' || w.config.series[index].type === 'column';
- }
- return series.data && series.data.length > 0 && !hasBars ? index : -1;
- });
- for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
- if (firstActiveSeriesIndex[a] !== -1) {
- activeIndex = firstActiveSeriesIndex[a];
- break;
- }
- }
- }
- return activeIndex;
- }
- }, {
- key: "getPreviousPaths",
- value: function getPreviousPaths() {
- var w = this.w;
- w.globals.previousPaths = [];
- function pushPaths(seriesEls, i, type) {
- var paths = seriesEls[i].childNodes;
- var dArr = {
- type: type,
- paths: [],
- realIndex: seriesEls[i].getAttribute('data:realIndex')
- };
- for (var j = 0; j < paths.length; j++) {
- if (paths[j].hasAttribute('pathTo')) {
- var d = paths[j].getAttribute('pathTo');
- dArr.paths.push({
- d: d
- });
- }
- }
- w.globals.previousPaths.push(dArr);
- }
- var getPaths = function getPaths(chartType) {
- return w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(chartType, "-series .apexcharts-series"));
- };
- var chartTypes = ['line', 'area', 'bar', 'candlestick', 'radar'];
- chartTypes.forEach(function (type) {
- var paths = getPaths(type);
- for (var p = 0; p < paths.length; p++) {
- pushPaths(paths, p, type);
- }
- });
- this.handlePrevBubbleScatterPaths('bubble');
- this.handlePrevBubbleScatterPaths('scatter');
- var heatmapColors = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap .apexcharts-series');
- if (heatmapColors.length > 0) {
- for (var h = 0; h < heatmapColors.length; h++) {
- var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-heatmap .apexcharts-series[data\\:realIndex='".concat(h, "'] rect"));
- var dArr = [];
- for (var i = 0; i < seriesEls.length; i++) {
- dArr.push({
- color: seriesEls[i].getAttribute('color')
- });
- }
- w.globals.previousPaths.push(dArr);
- }
- }
- if (!w.globals.axisCharts) {
-
- w.globals.previousPaths = w.globals.series;
- }
- }
- }, {
- key: "handlePrevBubbleScatterPaths",
- value: function handlePrevBubbleScatterPaths(type) {
- var w = this.w;
- var paths = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series"));
- if (paths.length > 0) {
- for (var s = 0; s < paths.length; s++) {
- var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series[data\\:realIndex='").concat(s, "'] circle"));
- var dArr = [];
- for (var i = 0; i < seriesEls.length; i++) {
- dArr.push({
- x: seriesEls[i].getAttribute('cx'),
- y: seriesEls[i].getAttribute('cy'),
- r: seriesEls[i].getAttribute('r')
- });
- }
- w.globals.previousPaths.push(dArr);
- }
- }
- }
- }, {
- key: "clearPreviousPaths",
- value: function clearPreviousPaths() {
- var w = this.w;
- w.globals.previousPaths = [];
- w.globals.allSeriesCollapsed = false;
- }
- }, {
- key: "handleNoData",
- value: function handleNoData() {
- var w = this.w;
- var me = this;
- var noDataOpts = w.config.noData;
- var graphics = new Graphics(me.ctx);
- var x = w.globals.svgWidth / 2;
- var y = w.globals.svgHeight / 2;
- var textAnchor = 'middle';
- w.globals.noData = true;
- w.globals.animationEnded = true;
- if (noDataOpts.align === 'left') {
- x = 10;
- textAnchor = 'start';
- } else if (noDataOpts.align === 'right') {
- x = w.globals.svgWidth - 10;
- textAnchor = 'end';
- }
- if (noDataOpts.verticalAlign === 'top') {
- y = 50;
- } else if (noDataOpts.verticalAlign === 'bottom') {
- y = w.globals.svgHeight - 50;
- }
- x = x + noDataOpts.offsetX;
- y = y + parseInt(noDataOpts.style.fontSize, 10) + 2 + noDataOpts.offsetY;
- if (noDataOpts.text !== undefined && noDataOpts.text !== '') {
- var titleText = graphics.drawText({
- x: x,
- y: y,
- text: noDataOpts.text,
- textAnchor: textAnchor,
- fontSize: noDataOpts.style.fontSize,
- fontFamily: noDataOpts.style.fontFamily,
- foreColor: noDataOpts.style.color,
- opacity: 1,
- class: 'apexcharts-text-nodata'
- });
- w.globals.dom.Paper.add(titleText);
- }
- }
-
- }, {
- key: "setNullSeriesToZeroValues",
- value: function setNullSeriesToZeroValues(series) {
- var w = this.w;
- for (var sl = 0; sl < series.length; sl++) {
- if (series[sl].length === 0) {
- for (var j = 0; j < series[w.globals.maxValsInArrayIndex].length; j++) {
- series[sl].push(0);
- }
- }
- }
- return series;
- }
- }, {
- key: "hasAllSeriesEqualX",
- value: function hasAllSeriesEqualX() {
- var equalLen = true;
- var w = this.w;
- var filteredSerX = this.filteredSeriesX();
- for (var i = 0; i < filteredSerX.length - 1; i++) {
- if (filteredSerX[i][0] !== filteredSerX[i + 1][0]) {
- equalLen = false;
- break;
- }
- }
- w.globals.allSeriesHasEqualX = equalLen;
- return equalLen;
- }
- }, {
- key: "filteredSeriesX",
- value: function filteredSeriesX() {
- var w = this.w;
- var filteredSeriesX = w.globals.seriesX.map(function (ser) {
- return ser.length > 0 ? ser : [];
- });
- return filteredSeriesX;
- }
- }]);
- return Series;
- }();
- var Data = function () {
- function Data(ctx) {
- _classCallCheck(this, Data);
- this.ctx = ctx;
- this.w = ctx.w;
- this.twoDSeries = [];
- this.threeDSeries = [];
- this.twoDSeriesX = [];
- this.coreUtils = new CoreUtils(this.ctx);
- }
- _createClass(Data, [{
- key: "isMultiFormat",
- value: function isMultiFormat() {
- return this.isFormatXY() || this.isFormat2DArray();
- }
- }, {
- key: "isFormatXY",
- value: function isFormatXY() {
- var series = this.w.config.series.slice();
- var sr = new Series(this.ctx);
- this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
- if (typeof series[this.activeSeriesIndex].data !== 'undefined' && series[this.activeSeriesIndex].data.length > 0 && series[this.activeSeriesIndex].data[0] !== null && typeof series[this.activeSeriesIndex].data[0].x !== 'undefined' && series[this.activeSeriesIndex].data[0] !== null) {
- return true;
- }
- }
- }, {
- key: "isFormat2DArray",
- value: function isFormat2DArray() {
- var series = this.w.config.series.slice();
- var sr = new Series(this.ctx);
- this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
- if (typeof series[this.activeSeriesIndex].data !== 'undefined' && series[this.activeSeriesIndex].data.length > 0 && typeof series[this.activeSeriesIndex].data[0] !== 'undefined' && series[this.activeSeriesIndex].data[0] !== null && series[this.activeSeriesIndex].data[0].constructor === Array) {
- return true;
- }
- }
- }, {
- key: "handleFormat2DArray",
- value: function handleFormat2DArray(ser, i) {
- var cnf = this.w.config;
- var gl = this.w.globals;
- if (cnf.xaxis.sorted) {
- if (cnf.xaxis.type === 'datetime') {
- ser[i].data.sort(function (a, b) {
- return new Date(a[0]).getTime() - new Date(b[0]).getTime();
- });
- } else if (cnf.xaxis.type === 'numeric') {
- ser[i].data.sort(function (a, b) {
- return a[0] - b[0];
- });
- }
- }
- for (var j = 0; j < ser[i].data.length; j++) {
- if (typeof ser[i].data[j][1] !== 'undefined') {
- if (Array.isArray(ser[i].data[j][1]) && ser[i].data[j][1].length === 4) {
-
- this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1][3]));
- } else if (ser[i].data[j].length === 5) {
-
- this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][4]));
- } else {
- this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1]));
- }
- gl.dataFormatXNumeric = true;
- }
- if (cnf.xaxis.type === 'datetime') {
-
- var ts = new Date(ser[i].data[j][0]);
- ts = new Date(ts).getTime();
- this.twoDSeriesX.push(ts);
- } else {
- this.twoDSeriesX.push(ser[i].data[j][0]);
- }
- }
- for (var _j = 0; _j < ser[i].data.length; _j++) {
- if (typeof ser[i].data[_j][2] !== 'undefined') {
- this.threeDSeries.push(ser[i].data[_j][2]);
- gl.isDataXYZ = true;
- }
- }
- }
- }, {
- key: "handleFormatXY",
- value: function handleFormatXY(ser, i) {
- var cnf = this.w.config;
- var gl = this.w.globals;
- var dt = new DateTime(this.ctx);
- var activeI = i;
- if (gl.collapsedSeriesIndices.indexOf(i) > -1) {
-
- activeI = this.activeSeriesIndex;
- }
- if (cnf.xaxis.sorted) {
- if (cnf.xaxis.type === 'datetime') {
- ser[i].data.sort(function (a, b) {
- return new Date(a.x).getTime() - new Date(b.x).getTime();
- });
- } else if (cnf.xaxis.type === 'numeric') {
- ser[i].data.sort(function (a, b) {
- return a.x - b.x;
- });
- }
- }
- for (var j = 0; j < ser[i].data.length; j++) {
- if (typeof ser[i].data[j].y !== 'undefined') {
- if (Array.isArray(ser[i].data[j].y)) {
- this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y[ser[i].data[j].y.length - 1]));
- } else {
- this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y));
- }
- }
- }
- for (var _j2 = 0; _j2 < ser[activeI].data.length; _j2++) {
- var isXString = typeof ser[activeI].data[_j2].x === 'string';
- var isXArr = Array.isArray(ser[activeI].data[_j2].x);
- var isXDate = !isXArr && !!dt.isValidDate(ser[activeI].data[_j2].x.toString());
- if (isXString || isXDate) {
-
- if (isXString || cnf.xaxis.convertedCatToNumeric) {
- if (cnf.xaxis.type === 'datetime' && !gl.isRangeData) {
- this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x));
- } else {
-
- this.fallbackToCategory = true;
- this.twoDSeriesX.push(ser[activeI].data[_j2].x);
- }
- } else {
- if (cnf.xaxis.type === 'datetime') {
- this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x.toString()));
- } else {
- gl.dataFormatXNumeric = true;
- gl.isXNumeric = true;
- this.twoDSeriesX.push(parseFloat(ser[activeI].data[_j2].x));
- }
- }
- } else if (isXArr) {
-
- this.fallbackToCategory = true;
- this.twoDSeriesX.push(ser[activeI].data[_j2].x);
- } else {
-
- gl.isXNumeric = true;
- gl.dataFormatXNumeric = true;
- this.twoDSeriesX.push(ser[activeI].data[_j2].x);
- }
- }
- if (ser[i].data[0] && typeof ser[i].data[0].z !== 'undefined') {
- for (var t = 0; t < ser[i].data.length; t++) {
- this.threeDSeries.push(ser[i].data[t].z);
- }
- gl.isDataXYZ = true;
- }
- }
- }, {
- key: "handleRangeData",
- value: function handleRangeData(ser, i) {
- var cnf = this.w.config;
- var gl = this.w.globals;
- var range = {};
- if (this.isFormat2DArray()) {
- range = this.handleRangeDataFormat('array', ser, i);
- } else if (this.isFormatXY()) {
- range = this.handleRangeDataFormat('xy', ser, i);
- }
- gl.seriesRangeStart.push(range.start);
- gl.seriesRangeEnd.push(range.end);
- if (cnf.xaxis.type === 'datetime') {
- gl.seriesRangeBarTimeline.push(range.rangeUniques);
- }
- gl.seriesRangeBarTimeline.forEach(function (sr, si) {
- if (sr) {
- sr.forEach(function (sarr, sarri) {
- sarr.y.forEach(function (arr, arri) {
- for (var sri = 0; sri < sarr.y.length; sri++) {
- if (arri !== sri) {
- var range1y1 = arr.y1;
- var range1y2 = arr.y2;
- var range2y1 = sarr.y[sri].y1;
- var range2y2 = sarr.y[sri].y2;
- if (range1y1 <= range2y2 && range2y1 <= range1y2) {
- if (sarr.overlaps.indexOf(arr.rangeName) < 0) {
- sarr.overlaps.push(arr.rangeName);
- }
- if (sarr.overlaps.indexOf(sarr.y[sri].rangeName) < 0) {
- sarr.overlaps.push(sarr.y[sri].rangeName);
- }
- }
- }
- }
- });
- });
- }
- });
- return range;
- }
- }, {
- key: "handleCandleStickData",
- value: function handleCandleStickData(ser, i) {
- var gl = this.w.globals;
- var ohlc = {};
- if (this.isFormat2DArray()) {
- ohlc = this.handleCandleStickDataFormat('array', ser, i);
- } else if (this.isFormatXY()) {
- ohlc = this.handleCandleStickDataFormat('xy', ser, i);
- }
- gl.seriesCandleO[i] = ohlc.o;
- gl.seriesCandleH[i] = ohlc.h;
- gl.seriesCandleL[i] = ohlc.l;
- gl.seriesCandleC[i] = ohlc.c;
- return ohlc;
- }
- }, {
- key: "handleRangeDataFormat",
- value: function handleRangeDataFormat(format, ser, i) {
- var rangeStart = [];
- var rangeEnd = [];
- var uniqueKeys = ser[i].data.filter(function (thing, index, self) {
- return index === self.findIndex(function (t) {
- return t.x === thing.x;
- });
- }).map(function (r, index) {
- return {
- x: r.x,
- overlaps: [],
- y: []
- };
- });
- var err = 'Please provide [Start, End] values in valid format. Read more https://apexcharts.com/docs/series/#rangecharts';
- var serObj = new Series(this.ctx);
- var activeIndex = serObj.getActiveConfigSeriesIndex();
- if (format === 'array') {
- if (ser[activeIndex].data[0][1].length !== 2) {
- throw new Error(err);
- }
- for (var j = 0; j < ser[i].data.length; j++) {
- rangeStart.push(ser[i].data[j][1][0]);
- rangeEnd.push(ser[i].data[j][1][1]);
- }
- } else if (format === 'xy') {
- if (ser[activeIndex].data[0].y.length !== 2) {
- throw new Error(err);
- }
- var _loop = function _loop(_j3) {
- var id = Utils.randomId();
- var x = ser[i].data[_j3].x;
- var y = {
- y1: ser[i].data[_j3].y[0],
- y2: ser[i].data[_j3].y[1],
- rangeName: id
- };
-
- ser[i].data[_j3].rangeName = id;
- var uI = uniqueKeys.findIndex(function (t) {
- return t.x === x;
- });
- uniqueKeys[uI].y.push(y);
- rangeStart.push(y.y1);
- rangeEnd.push(y.y2);
- };
- for (var _j3 = 0; _j3 < ser[i].data.length; _j3++) {
- _loop(_j3);
- }
- }
- return {
- start: rangeStart,
- end: rangeEnd,
- rangeUniques: uniqueKeys
- };
- }
- }, {
- key: "handleCandleStickDataFormat",
- value: function handleCandleStickDataFormat(format, ser, i) {
- var serO = [];
- var serH = [];
- var serL = [];
- var serC = [];
- var err = 'Please provide [Open, High, Low and Close] values in valid format. Read more https://apexcharts.com/docs/series/#candlestick';
- if (format === 'array') {
- if (!Array.isArray(ser[i].data[0][1]) && ser[i].data[0].length !== 5 || Array.isArray(ser[i].data[0][1]) && ser[i].data[0][1].length !== 4) {
- throw new Error(err);
- }
- if (ser[i].data[0].length === 5) {
- for (var j = 0; j < ser[i].data.length; j++) {
- serO.push(ser[i].data[j][1]);
- serH.push(ser[i].data[j][2]);
- serL.push(ser[i].data[j][3]);
- serC.push(ser[i].data[j][4]);
- }
- } else {
- for (var _j4 = 0; _j4 < ser[i].data.length; _j4++) {
- serO.push(ser[i].data[_j4][1][0]);
- serH.push(ser[i].data[_j4][1][1]);
- serL.push(ser[i].data[_j4][1][2]);
- serC.push(ser[i].data[_j4][1][3]);
- }
- }
- } else if (format === 'xy') {
- if (ser[i].data[0].y.length !== 4) {
- throw new Error(err);
- }
- for (var _j5 = 0; _j5 < ser[i].data.length; _j5++) {
- serO.push(ser[i].data[_j5].y[0]);
- serH.push(ser[i].data[_j5].y[1]);
- serL.push(ser[i].data[_j5].y[2]);
- serC.push(ser[i].data[_j5].y[3]);
- }
- }
- return {
- o: serO,
- h: serH,
- l: serL,
- c: serC
- };
- }
- }, {
- key: "parseDataAxisCharts",
- value: function parseDataAxisCharts(ser) {
- var _this = this;
- var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.ctx;
- var cnf = this.w.config;
- var gl = this.w.globals;
- var dt = new DateTime(ctx);
- var xlabels = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice();
- var handleDates = function handleDates() {
- for (var j = 0; j < xlabels.length; j++) {
- if (typeof xlabels[j] === 'string') {
-
- var isDate = dt.isValidDate(xlabels[j]);
- if (isDate) {
- _this.twoDSeriesX.push(dt.parseDate(xlabels[j]));
- } else {
- throw new Error('You have provided invalid Date format. Please provide a valid JavaScript Date');
- }
- } else {
-
- if (String(xlabels[j]).length !== 13) {
- throw new Error('Please provide a valid JavaScript timestamp');
- } else {
- _this.twoDSeriesX.push(xlabels[j]);
- }
- }
- }
- };
- for (var i = 0; i < ser.length; i++) {
- this.twoDSeries = [];
- this.twoDSeriesX = [];
- this.threeDSeries = [];
- if (typeof ser[i].data === 'undefined') {
- console.error("It is a possibility that you may have not included 'data' property in series.");
- return;
- }
- if (cnf.chart.type === 'rangeBar' || cnf.chart.type === 'rangeArea' || ser[i].type === 'rangeBar' || ser[i].type === 'rangeArea') {
- gl.isRangeData = true;
- this.handleRangeData(ser, i);
- }
- if (this.isMultiFormat()) {
- if (this.isFormat2DArray()) {
- this.handleFormat2DArray(ser, i);
- } else if (this.isFormatXY()) {
- this.handleFormatXY(ser, i);
- }
- if (cnf.chart.type === 'candlestick' || ser[i].type === 'candlestick') {
- this.handleCandleStickData(ser, i);
- }
- gl.series.push(this.twoDSeries);
- gl.labels.push(this.twoDSeriesX);
- gl.seriesX.push(this.twoDSeriesX);
- if (i === this.activeSeriesIndex && !this.fallbackToCategory) {
- gl.isXNumeric = true;
- }
- } else {
- if (cnf.xaxis.type === 'datetime') {
-
-
- gl.isXNumeric = true;
- handleDates();
- gl.seriesX.push(this.twoDSeriesX);
- } else if (cnf.xaxis.type === 'numeric') {
- gl.isXNumeric = true;
- if (xlabels.length > 0) {
- this.twoDSeriesX = xlabels;
- gl.seriesX.push(this.twoDSeriesX);
- }
- }
- gl.labels.push(this.twoDSeriesX);
- var singleArray = ser[i].data.map(function (d) {
- return Utils.parseNumber(d);
- });
- gl.series.push(singleArray);
- }
- gl.seriesZ.push(this.threeDSeries);
- if (ser[i].name !== undefined) {
- gl.seriesNames.push(ser[i].name);
- } else {
- gl.seriesNames.push('series-' + parseInt(i + 1, 10));
- }
- }
- return this.w;
- }
- }, {
- key: "parseDataNonAxisCharts",
- value: function parseDataNonAxisCharts(ser) {
- var gl = this.w.globals;
- var cnf = this.w.config;
- gl.series = ser.slice();
- gl.seriesNames = cnf.labels.slice();
- for (var i = 0; i < gl.series.length; i++) {
- if (gl.seriesNames[i] === undefined) {
- gl.seriesNames.push('series-' + (i + 1));
- }
- }
- return this.w;
- }
-
- }, {
- key: "handleExternalLabelsData",
- value: function handleExternalLabelsData(ser) {
- var cnf = this.w.config;
- var gl = this.w.globals;
- if (cnf.xaxis.categories.length > 0) {
-
- gl.labels = cnf.xaxis.categories;
- } else if (cnf.labels.length > 0) {
-
- gl.labels = cnf.labels.slice();
- } else if (this.fallbackToCategory) {
-
- gl.labels = gl.labels[0];
- if (gl.seriesRangeBarTimeline.length) {
- gl.seriesRangeBarTimeline.map(function (srt) {
- srt.forEach(function (sr) {
- if (gl.labels.indexOf(sr.x) < 0 && sr.x) {
- gl.labels.push(sr.x);
- }
- });
- });
- gl.labels = gl.labels.filter(function (elem, pos, arr) {
- return arr.indexOf(elem) === pos;
- });
- }
- if (cnf.xaxis.convertedCatToNumeric) {
- var defaults = new Defaults(cnf);
- defaults.convertCatToNumericXaxis(cnf, this.ctx, gl.seriesX[0]);
- this._generateExternalLabels(ser);
- }
- } else {
- this._generateExternalLabels(ser);
- }
- }
- }, {
- key: "_generateExternalLabels",
- value: function _generateExternalLabels(ser) {
- var gl = this.w.globals;
- var cnf = this.w.config;
- var labelArr = [];
- if (gl.axisCharts) {
- if (gl.series.length > 0) {
- for (var i = 0; i < gl.series[gl.maxValsInArrayIndex].length; i++) {
- labelArr.push(i + 1);
- }
- }
- gl.seriesX = [];
- for (var _i = 0; _i < ser.length; _i++) {
- gl.seriesX.push(labelArr);
- }
- gl.isXNumeric = true;
- }
-
- if (labelArr.length === 0) {
- labelArr = gl.axisCharts ? [] : gl.series.map(function (gls, glsi) {
- return glsi + 1;
- });
- for (var _i2 = 0; _i2 < ser.length; _i2++) {
- gl.seriesX.push(labelArr);
- }
- }
- gl.labels = labelArr;
- if (cnf.xaxis.convertedCatToNumeric) {
- gl.categoryLabels = labelArr.map(function (l) {
- return cnf.xaxis.labels.formatter(l);
- });
- }
- gl.noLabelsProvided = true;
- }
- }, {
- key: "parseData",
- value: function parseData(ser) {
- var w = this.w;
- var cnf = w.config;
- var gl = w.globals;
- this.excludeCollapsedSeriesInYAxis();
- this.fallbackToCategory = false;
- this.ctx.core.resetGlobals();
- this.ctx.core.isMultipleY();
- if (gl.axisCharts) {
-
- this.parseDataAxisCharts(ser);
- } else {
-
- this.parseDataNonAxisCharts(ser);
- }
- this.coreUtils.getLargestSeries();
- if (cnf.chart.type === 'bar' && cnf.chart.stacked) {
- var series = new Series(this.ctx);
- gl.series = series.setNullSeriesToZeroValues(gl.series);
- }
- this.coreUtils.getSeriesTotals();
- if (gl.axisCharts) {
- this.coreUtils.getStackedSeriesTotals();
- }
- this.coreUtils.getPercentSeries();
- if (!gl.dataFormatXNumeric && (!gl.isXNumeric || cnf.xaxis.type === 'numeric' && cnf.labels.length === 0 && cnf.xaxis.categories.length === 0)) {
-
- this.handleExternalLabelsData(ser);
- }
- var catLabels = this.coreUtils.getCategoryLabels(gl.labels);
- for (var l = 0; l < catLabels.length; l++) {
- if (Array.isArray(catLabels[l])) {
- gl.isMultiLineX = true;
- break;
- }
- }
- }
- }, {
- key: "excludeCollapsedSeriesInYAxis",
- value: function excludeCollapsedSeriesInYAxis() {
- var _this2 = this;
- var w = this.w;
- w.globals.ignoreYAxisIndexes = w.globals.collapsedSeries.map(function (collapsed, i) {
-
-
- if (_this2.w.globals.isMultipleYAxis && !w.config.chart.stacked) {
- return collapsed.index;
- }
- });
- }
- }]);
- return Data;
- }();
-
- var Formatters = function () {
- function Formatters(ctx) {
- _classCallCheck(this, Formatters);
- this.ctx = ctx;
- this.w = ctx.w;
- this.tooltipKeyFormat = 'dd MMM';
- }
- _createClass(Formatters, [{
- key: "xLabelFormat",
- value: function xLabelFormat(fn, val, timestamp) {
- var w = this.w;
- if (w.config.xaxis.type === 'datetime') {
- if (w.config.xaxis.labels.formatter === undefined) {
-
- if (w.config.tooltip.x.formatter === undefined) {
- var datetimeObj = new DateTime(this.ctx);
- return datetimeObj.formatDate(datetimeObj.getDate(val), w.config.tooltip.x.format);
- }
- }
- }
- return fn(val, timestamp);
- }
- }, {
- key: "defaultGeneralFormatter",
- value: function defaultGeneralFormatter(val) {
- if (Array.isArray(val)) {
- return val.map(function (v) {
- return v;
- });
- } else {
- return val;
- }
- }
- }, {
- key: "defaultYFormatter",
- value: function defaultYFormatter(v, yaxe, i) {
- var w = this.w;
- if (Utils.isNumber(v)) {
- if (w.globals.yValueDecimal !== 0) {
- v = v.toFixed(yaxe.decimalsInFloat !== undefined ? yaxe.decimalsInFloat : w.globals.yValueDecimal);
- } else if (w.globals.maxYArr[i] - w.globals.minYArr[i] < 10) {
- v = v.toFixed(1);
- } else {
- v = v.toFixed(0);
- }
- }
- return v;
- }
- }, {
- key: "setLabelFormatters",
- value: function setLabelFormatters() {
- var _this = this;
- var w = this.w;
- w.globals.xLabelFormatter = function (val) {
- return _this.defaultGeneralFormatter(val);
- };
- w.globals.xaxisTooltipFormatter = function (val) {
- return _this.defaultGeneralFormatter(val);
- };
- w.globals.ttKeyFormatter = function (val) {
- return _this.defaultGeneralFormatter(val);
- };
- w.globals.ttZFormatter = function (val) {
- return val;
- };
- w.globals.legendFormatter = function (val) {
- return _this.defaultGeneralFormatter(val);
- };
- if (w.config.xaxis.labels.formatter !== undefined) {
- w.globals.xLabelFormatter = w.config.xaxis.labels.formatter;
- } else {
- w.globals.xLabelFormatter = function (val) {
- if (Utils.isNumber(val)) {
-
- if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric' && w.globals.dataPoints < 50) {
- return val.toFixed(1);
- }
- if (w.globals.isBarHorizontal) {
- var range = w.globals.maxY - w.globals.minYArr;
- if (range < 4) {
- return val.toFixed(1);
- }
- }
- return val.toFixed(0);
- }
- return val;
- };
- }
- if (typeof w.config.tooltip.x.formatter === 'function') {
- w.globals.ttKeyFormatter = w.config.tooltip.x.formatter;
- } else {
- w.globals.ttKeyFormatter = w.globals.xLabelFormatter;
- }
- if (typeof w.config.xaxis.tooltip.formatter === 'function') {
- w.globals.xaxisTooltipFormatter = w.config.xaxis.tooltip.formatter;
- }
- if (Array.isArray(w.config.tooltip.y)) {
- w.globals.ttVal = w.config.tooltip.y;
- } else {
- if (w.config.tooltip.y.formatter !== undefined) {
- w.globals.ttVal = w.config.tooltip.y;
- }
- }
- if (w.config.tooltip.z.formatter !== undefined) {
- w.globals.ttZFormatter = w.config.tooltip.z.formatter;
- }
- if (w.config.legend.formatter !== undefined) {
- w.globals.legendFormatter = w.config.legend.formatter;
- }
- w.config.yaxis.forEach(function (yaxe, i) {
- if (yaxe.labels.formatter !== undefined) {
- w.globals.yLabelFormatters[i] = yaxe.labels.formatter;
- } else {
- w.globals.yLabelFormatters[i] = function (val) {
- if (!w.globals.xyCharts) return val;
- if (Array.isArray(val)) {
- return val.map(function (v) {
- return _this.defaultYFormatter(v, yaxe, i);
- });
- } else {
- return _this.defaultYFormatter(val, yaxe, i);
- }
- };
- }
- });
- return w.globals;
- }
- }, {
- key: "heatmapLabelFormatters",
- value: function heatmapLabelFormatters() {
- var w = this.w;
- if (w.config.chart.type === 'heatmap') {
- w.globals.yAxisScale[0].result = w.globals.seriesNames.slice();
- var longest = w.globals.seriesNames.reduce(function (a, b) {
- return a.length > b.length ? a : b;
- }, 0);
- w.globals.yAxisScale[0].niceMax = longest;
- w.globals.yAxisScale[0].niceMin = longest;
- }
- }
- }]);
- return Formatters;
- }();
- var AxesUtils = function () {
- function AxesUtils(ctx) {
- _classCallCheck(this, AxesUtils);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(AxesUtils, [{
- key: "getLabel",
- value: function getLabel(labels, timescaleLabels, x, i) {
- var drawnLabels = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
- var fontSize = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '12px';
- var w = this.w;
- var rawLabel = typeof labels[i] === 'undefined' ? '' : labels[i];
- var label = rawLabel;
- var xlbFormatter = w.globals.xLabelFormatter;
- var customFormatter = w.config.xaxis.labels.formatter;
- var isBold = false;
- var xFormat = new Formatters(this.ctx);
- var timestamp = rawLabel;
- label = xFormat.xLabelFormat(xlbFormatter, rawLabel, timestamp);
- if (customFormatter !== undefined) {
- label = customFormatter(rawLabel, labels[i], i);
- }
- var determineHighestUnit = function determineHighestUnit(unit) {
- var highestUnit = null;
- timescaleLabels.forEach(function (t) {
- if (t.unit === 'month') {
- highestUnit = 'year';
- } else if (t.unit === 'day') {
- highestUnit = 'month';
- } else if (t.unit === 'hour') {
- highestUnit = 'day';
- } else if (t.unit === 'minute') {
- highestUnit = 'hour';
- }
- });
- return highestUnit === unit;
- };
- if (timescaleLabels.length > 0) {
- isBold = determineHighestUnit(timescaleLabels[i].unit);
- x = timescaleLabels[i].position;
- label = timescaleLabels[i].value;
- } else {
- if (w.config.xaxis.type === 'datetime' && customFormatter === undefined) {
- label = '';
- }
- }
- if (typeof label === 'undefined') label = '';
- label = Array.isArray(label) ? label : label.toString();
- var graphics = new Graphics(this.ctx);
- var textRect = {};
- if (w.globals.rotateXLabels) {
- textRect = graphics.getTextRects(label, parseInt(fontSize, 10), null, "rotate(".concat(w.config.xaxis.labels.rotate, " 0 0)"), false);
- } else {
- textRect = graphics.getTextRects(label, parseInt(fontSize, 10));
- }
- if (!Array.isArray(label) && (label.indexOf('NaN') === 0 || label.toLowerCase().indexOf('invalid') === 0 || label.toLowerCase().indexOf('infinity') >= 0 || drawnLabels.indexOf(label) >= 0 && !w.config.xaxis.labels.showDuplicates)) {
- label = '';
- }
- return {
- x: x,
- text: label,
- textRect: textRect,
- isBold: isBold
- };
- }
- }, {
- key: "checkForOverflowingLabels",
- value: function checkForOverflowingLabels(i, label, labelsLen, drawnLabels, drawnLabelsRects) {
- var w = this.w;
- if (i === 0) {
-
- if (w.globals.skipFirstTimelinelabel) {
- label.text = '';
- }
- }
- if (i === labelsLen - 1) {
-
- if (w.globals.skipLastTimelinelabel) {
- label.text = '';
- }
- }
- if (w.config.xaxis.labels.hideOverlappingLabels && drawnLabels.length > 0) {
- var prev = drawnLabelsRects[drawnLabelsRects.length - 1];
- if (label.x < prev.textRect.width / (w.globals.rotateXLabels ? Math.abs(w.config.xaxis.labels.rotate) / 12 : 1.01) + prev.x) {
- label.text = '';
- }
- }
- return label;
- }
- }, {
- key: "checkForReversedLabels",
- value: function checkForReversedLabels(i, labels) {
- var w = this.w;
- if (w.config.yaxis[i] && w.config.yaxis[i].reversed) {
- labels.reverse();
- }
- return labels;
- }
- }, {
- key: "isYAxisHidden",
- value: function isYAxisHidden(index) {
- var w = this.w;
- var coreUtils = new CoreUtils(this.ctx);
- return !w.config.yaxis[index].show || !w.config.yaxis[index].showForNullSeries && coreUtils.isSeriesNull(index) && w.globals.collapsedSeriesIndices.indexOf(index) === -1;
- }
- }, {
- key: "drawYAxisTicks",
- value: function drawYAxisTicks(x, tickAmount, axisBorder, axisTicks, realIndex, labelsDivider, elYaxis) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var t = w.globals.translateY;
- if (axisTicks.show && tickAmount > 0) {
- if (w.config.yaxis[realIndex].opposite === true) x = x + axisTicks.width;
- for (var i = tickAmount; i >= 0; i--) {
- var tY = t + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY - 1;
- if (w.globals.isBarHorizontal) {
- tY = labelsDivider * i;
- }
- if (w.config.chart.type === 'heatmap') {
- tY = tY + labelsDivider / 2;
- }
- var elTick = graphics.drawLine(x + axisBorder.offsetX - axisTicks.width + axisTicks.offsetX, tY + axisTicks.offsetY, x + axisBorder.offsetX + axisTicks.offsetX, tY + axisTicks.offsetY, axisTicks.color);
- elYaxis.add(elTick);
- t = t + labelsDivider;
- }
- }
- }
- }]);
- return AxesUtils;
- }();
- var Exports = function () {
- function Exports(ctx) {
- _classCallCheck(this, Exports);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Exports, [{
- key: "fixSvgStringForIe11",
- value: function fixSvgStringForIe11(svgData) {
-
- if (!Utils.isIE11()) {
-
- return svgData;
- }
- var nXmlnsSeen = 0;
- var result = svgData.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g, function (match) {
- nXmlnsSeen++;
- return nXmlnsSeen === 2 ? 'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs"' : match;
- });
- result = result.replace(/xmlns:NS\d+=""/g, '');
- result = result.replace(/NS\d+:(\w+:\w+=")/g, '$1');
- return result;
- }
- }, {
- key: "getSvgString",
- value: function getSvgString() {
- var svgString = this.w.globals.dom.Paper.svg();
- return this.fixSvgStringForIe11(svgString);
- }
- }, {
- key: "cleanup",
- value: function cleanup() {
- var w = this.w;
- var xcrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-xcrosshairs');
- var ycrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-ycrosshairs');
- var zoomSelectionRects = w.globals.dom.baseEl.querySelectorAll('.apexcharts-zoom-rect, .apexcharts-selection-rect');
- Array.prototype.forEach.call(zoomSelectionRects, function (z) {
- z.setAttribute('width', 0);
- });
- if (xcrosshairs) {
- xcrosshairs[0].setAttribute('x', -500);
- xcrosshairs[0].setAttribute('x1', -500);
- xcrosshairs[0].setAttribute('x2', -500);
- }
- if (ycrosshairs) {
- ycrosshairs[0].setAttribute('y', -100);
- ycrosshairs[0].setAttribute('y1', -100);
- ycrosshairs[0].setAttribute('y2', -100);
- }
- }
- }, {
- key: "svgUrl",
- value: function svgUrl() {
- this.cleanup();
- var svgData = this.getSvgString();
- var svgBlob = new Blob([svgData], {
- type: 'image/svg+xml;charset=utf-8'
- });
- return URL.createObjectURL(svgBlob);
- }
- }, {
- key: "dataURI",
- value: function dataURI() {
- var _this = this;
- return new Promise(function (resolve) {
- var w = _this.w;
- _this.cleanup();
- var canvas = document.createElement('canvas');
- canvas.width = w.globals.svgWidth;
- canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10);
- var canvasBg = w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background;
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = canvasBg;
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- var svgData = _this.getSvgString();
- if (window.canvg && Utils.isIE11()) {
-
-
- var v = window.canvg.Canvg.fromString(ctx, svgData, {
- ignoreClear: true,
- ignoreDimensions: true
- });
- v.start();
- var blob = canvas.msToBlob();
- v.stop();
- resolve({
- blob: blob
- });
- } else {
- var svgUrl = 'data:image/svg+xml,' + encodeURIComponent(svgData);
- var img = new Image();
- img.crossOrigin = 'anonymous';
- img.onload = function () {
- ctx.drawImage(img, 0, 0);
- if (canvas.msToBlob) {
-
- var _blob = canvas.msToBlob();
- resolve({
- blob: _blob
- });
- } else {
- var imgURI = canvas.toDataURL('image/png');
- resolve({
- imgURI: imgURI
- });
- }
- };
- img.src = svgUrl;
- }
- });
- }
- }, {
- key: "exportToSVG",
- value: function exportToSVG() {
- this.triggerDownload(this.svgUrl(), '.svg');
- }
- }, {
- key: "exportToPng",
- value: function exportToPng() {
- var _this2 = this;
- this.dataURI().then(function (_ref) {
- var imgURI = _ref.imgURI,
- blob = _ref.blob;
- if (blob) {
- navigator.msSaveOrOpenBlob(blob, _this2.w.globals.chartID + '.png');
- } else {
- _this2.triggerDownload(imgURI, '.png');
- }
- });
- }
- }, {
- key: "exportToCSV",
- value: function exportToCSV(_ref2) {
- var _this3 = this;
- var series = _ref2.series,
- _ref2$columnDelimiter = _ref2.columnDelimiter,
- columnDelimiter = _ref2$columnDelimiter === void 0 ? ',' : _ref2$columnDelimiter,
- _ref2$lineDelimiter = _ref2.lineDelimiter,
- lineDelimiter = _ref2$lineDelimiter === void 0 ? '\n' : _ref2$lineDelimiter;
- var w = this.w;
- var columns = [];
- var rows = [];
- var result = 'data:text/csv;charset=utf-8,';
- var dataFormat = new Data(this.ctx);
- var axesUtils = new AxesUtils(this.ctx);
- var getCat = function getCat(i) {
- var cat = '';
- if (!w.globals.axisCharts) {
- cat = w.config.labels[i];
- } else {
-
-
- if (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) {
- if (w.globals.isBarHorizontal) {
- var lbFormatter = w.globals.yLabelFormatters[0];
- var sr = new Series(_this3.ctx);
- var activeSeries = sr.getActiveConfigSeriesIndex();
- cat = lbFormatter(w.globals.labels[i], {
- seriesIndex: activeSeries,
- dataPointIndex: i,
- w: w
- });
- } else {
- cat = axesUtils.getLabel(w.globals.labels, w.globals.timescaleLabels, 0, i).text;
- }
- }
- if (w.config.xaxis.type === 'datetime') {
- if (w.config.xaxis.categories.length) {
- cat = w.config.xaxis.categories[i];
- } else if (w.config.labels.length) {
- cat = w.config.labels[i];
- }
- }
- }
- return cat;
- };
- var handleAxisRowsColumns = function handleAxisRowsColumns(s, sI) {
- if (columns.length) {
- rows.push(columns.join(columnDelimiter));
- }
- if (s.data && s.data.length) {
- for (var i = 0; i < s.data.length; i++) {
- columns = [];
- var cat = getCat(i);
- if (!cat) {
- if (dataFormat.isFormatXY()) {
- cat = series[sI].data[i].x;
- } else if (dataFormat.isFormat2DArray()) {
- cat = series[sI].data[i] ? series[sI].data[i][0] : '';
- }
- }
- if (sI === 0) {
- columns.push(cat);
- for (var ci = 0; ci < w.globals.series.length; ci++) {
- columns.push(w.globals.series[ci][i]);
- }
- }
- if (w.config.chart.type === 'candlestick' || s.type && s.type === 'candlestick') {
- columns.pop();
- columns.push(w.globals.seriesCandleO[sI][i]);
- columns.push(w.globals.seriesCandleH[sI][i]);
- columns.push(w.globals.seriesCandleL[sI][i]);
- columns.push(w.globals.seriesCandleC[sI][i]);
- }
- if (w.config.chart.type === 'rangeBar') {
- columns.pop();
- columns.push(w.globals.seriesRangeStart[sI][i]);
- columns.push(w.globals.seriesRangeEnd[sI][i]);
- }
- if (columns.length) {
- rows.push(columns.join(columnDelimiter));
- }
- }
- }
- };
- columns.push('category');
- series.map(function (s, sI) {
- if (w.globals.axisCharts) {
- columns.push(s.name ? s.name : "series-".concat(sI));
- }
- });
- if (!w.globals.axisCharts) {
- columns.push('value');
- rows.push(columns.join(columnDelimiter));
- }
- series.map(function (s, sI) {
- if (w.globals.axisCharts) {
- handleAxisRowsColumns(s, sI);
- } else {
- columns = [];
- columns.push(w.globals.labels[sI]);
- columns.push(w.globals.series[sI]);
- rows.push(columns.join(columnDelimiter));
- }
- });
- result += rows.join(lineDelimiter);
- this.triggerDownload(encodeURI(result), '.csv');
- }
- }, {
- key: "triggerDownload",
- value: function triggerDownload(href, ext) {
- var downloadLink = document.createElement('a');
- downloadLink.href = href;
- downloadLink.download = this.w.globals.chartID + ext;
- document.body.appendChild(downloadLink);
- downloadLink.click();
- document.body.removeChild(downloadLink);
- }
- }]);
- return Exports;
- }();
-
- var XAxis = function () {
- function XAxis(ctx) {
- _classCallCheck(this, XAxis);
- this.ctx = ctx;
- this.w = ctx.w;
- var w = this.w;
- this.axesUtils = new AxesUtils(ctx);
- this.xaxisLabels = w.globals.labels.slice();
- if (w.globals.timescaleLabels.length > 0 && !w.globals.isBarHorizontal) {
-
- this.xaxisLabels = w.globals.timescaleLabels.slice();
- }
- this.drawnLabels = [];
- this.drawnLabelsRects = [];
- if (w.config.xaxis.position === 'top') {
- this.offY = 0;
- } else {
- this.offY = w.globals.gridHeight + 1;
- }
- this.offY = this.offY + w.config.xaxis.axisBorder.offsetY;
- this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
- this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
- this.xaxisFontFamily = w.config.xaxis.labels.style.fontFamily;
- this.xaxisForeColors = w.config.xaxis.labels.style.colors;
- this.xaxisBorderWidth = w.config.xaxis.axisBorder.width;
- if (this.isCategoryBarHorizontal) {
- this.xaxisBorderWidth = w.config.yaxis[0].axisBorder.width.toString();
- }
- if (this.xaxisBorderWidth.indexOf('%') > -1) {
- this.xaxisBorderWidth = w.globals.gridWidth * parseInt(this.xaxisBorderWidth, 10) / 100;
- } else {
- this.xaxisBorderWidth = parseInt(this.xaxisBorderWidth, 10);
- }
- this.xaxisBorderHeight = w.config.xaxis.axisBorder.height;
-
- this.yaxis = w.config.yaxis[0];
- }
- _createClass(XAxis, [{
- key: "drawXaxis",
- value: function drawXaxis() {
- var _this = this;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var elXaxis = graphics.group({
- class: 'apexcharts-xaxis',
- transform: "translate(".concat(w.config.xaxis.offsetX, ", ").concat(w.config.xaxis.offsetY, ")")
- });
- var elXaxisTexts = graphics.group({
- class: 'apexcharts-xaxis-texts-g',
- transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
- });
- elXaxis.add(elXaxisTexts);
- var colWidth;
- var xPos = w.globals.padHorizontal;
- var labels = [];
- for (var i = 0; i < this.xaxisLabels.length; i++) {
- labels.push(this.xaxisLabels[i]);
- }
- var labelsLen = labels.length;
- if (w.globals.isXNumeric) {
- var len = labelsLen > 1 ? labelsLen - 1 : labelsLen;
- colWidth = w.globals.gridWidth / len;
- xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX;
- } else {
- colWidth = w.globals.gridWidth / labels.length;
- xPos = xPos + colWidth + w.config.xaxis.labels.offsetX;
- }
- if (w.config.xaxis.labels.show) {
- var _loop = function _loop(_i) {
- var x = xPos - colWidth / 2 + w.config.xaxis.labels.offsetX;
- if (_i === 0 && labelsLen === 1 && colWidth / 2 === xPos && w.globals.dataPoints === 1) {
-
- x = w.globals.gridWidth / 2;
- }
- var label = _this.axesUtils.getLabel(labels, w.globals.timescaleLabels, x, _i, _this.drawnLabels, _this.xaxisFontSize);
- var offsetYCorrection = 28;
- if (w.globals.rotateXLabels) {
- offsetYCorrection = 22;
- }
- label = _this.axesUtils.checkForOverflowingLabels(_i, label, labelsLen, _this.drawnLabels, _this.drawnLabelsRects);
- var getCatForeColor = function getCatForeColor() {
- return w.config.xaxis.convertedCatToNumeric ? _this.xaxisForeColors[w.globals.minX + _i - 1] : _this.xaxisForeColors[_i];
- };
- if (label.text) {
- w.globals.xaxisLabelsCount++;
- }
- var elText = graphics.drawText({
- x: label.x,
- y: _this.offY + w.config.xaxis.labels.offsetY + offsetYCorrection - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
- text: label.text,
- textAnchor: 'middle',
- fontWeight: label.isBold ? 600 : w.config.xaxis.labels.style.fontWeight,
- fontSize: _this.xaxisFontSize,
- fontFamily: _this.xaxisFontFamily,
- foreColor: Array.isArray(_this.xaxisForeColors) ? getCatForeColor() : _this.xaxisForeColors,
- isPlainText: false,
- cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
- });
- elXaxisTexts.add(elText);
- var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
- elTooltipTitle.textContent = label.text;
- elText.node.appendChild(elTooltipTitle);
- if (label.text !== '') {
- _this.drawnLabels.push(label.text);
- _this.drawnLabelsRects.push(label);
- }
- xPos = xPos + colWidth;
- };
- for (var _i = 0; _i <= labelsLen - 1; _i++) {
- _loop(_i);
- }
- }
- if (w.config.xaxis.title.text !== undefined) {
- var elXaxisTitle = graphics.group({
- class: 'apexcharts-xaxis-title'
- });
- var elXAxisTitleText = graphics.drawText({
- x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
- y: this.offY - parseFloat(this.xaxisFontSize) + w.globals.xAxisLabelsHeight + w.config.xaxis.title.offsetY,
- text: w.config.xaxis.title.text,
- textAnchor: 'middle',
- fontSize: w.config.xaxis.title.style.fontSize,
- fontFamily: w.config.xaxis.title.style.fontFamily,
- fontWeight: w.config.xaxis.title.style.fontWeight,
- foreColor: w.config.xaxis.title.style.color,
- cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
- });
- elXaxisTitle.add(elXAxisTitleText);
- elXaxis.add(elXaxisTitle);
- }
- if (w.config.xaxis.axisBorder.show) {
- var lineCorrection = 0;
- if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
- lineCorrection = lineCorrection - 15;
- }
- var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + w.config.xaxis.axisBorder.offsetX, this.offY, this.xaxisBorderWidth, this.offY, w.config.xaxis.axisBorder.color, 0, this.xaxisBorderHeight);
- elXaxis.add(elHorzLine);
- }
- return elXaxis;
- }
- }, {
- key: "drawXaxisInversed",
- value: function drawXaxisInversed(realIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var translateYAxisX = w.config.yaxis[0].opposite ? w.globals.translateYAxisX[realIndex] : 0;
- var elYaxis = graphics.group({
- class: 'apexcharts-yaxis apexcharts-xaxis-inversed',
- rel: realIndex
- });
- var elYaxisTexts = graphics.group({
- class: 'apexcharts-yaxis-texts-g apexcharts-xaxis-inversed-texts-g',
- transform: 'translate(' + translateYAxisX + ', 0)'
- });
- elYaxis.add(elYaxisTexts);
- var colHeight;
- var yPos;
- var labels = [];
- if (w.config.yaxis[realIndex].show) {
- for (var i = 0; i < this.xaxisLabels.length; i++) {
- labels.push(this.xaxisLabels[i]);
- }
- }
- colHeight = w.globals.gridHeight / labels.length;
- yPos = -(colHeight / 2.2);
- var lbFormatter = w.globals.yLabelFormatters[0];
- var ylabels = w.config.yaxis[0].labels;
- if (ylabels.show) {
- for (var _i2 = 0; _i2 <= labels.length - 1; _i2++) {
- var label = typeof labels[_i2] === 'undefined' ? '' : labels[_i2];
- label = lbFormatter(label, {
- seriesIndex: realIndex,
- dataPointIndex: _i2,
- w: w
- });
- var multiY = 0;
- if (Array.isArray(label)) {
- multiY = label.length / 2 * parseInt(ylabels.style.fontSize, 10);
- }
- var elLabel = graphics.drawText({
- x: ylabels.offsetX - 15,
- y: yPos + colHeight + ylabels.offsetY - multiY,
- text: label,
- textAnchor: this.yaxis.opposite ? 'start' : 'end',
- foreColor: Array.isArray(ylabels.style.colors) ? ylabels.style.colors[_i2] : ylabels.style.colors,
- fontSize: ylabels.style.fontSize,
- fontFamily: ylabels.style.fontFamily,
- fontWeight: ylabels.style.fontWeight,
- isPlainText: false,
- cssClass: 'apexcharts-yaxis-label ' + ylabels.style.cssClass
- });
- elYaxisTexts.add(elLabel);
- var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
- elTooltipTitle.textContent = label.text;
- elLabel.node.appendChild(elTooltipTitle);
- if (w.config.yaxis[realIndex].labels.rotate !== 0) {
- var labelRotatingCenter = graphics.rotateAroundCenter(elLabel.node);
- elLabel.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " 0 ").concat(labelRotatingCenter.y, ")"));
- }
- yPos = yPos + colHeight;
- }
- }
- if (w.config.yaxis[0].title.text !== undefined) {
- var elXaxisTitle = graphics.group({
- class: 'apexcharts-yaxis-title apexcharts-xaxis-title-inversed',
- transform: 'translate(' + translateYAxisX + ', 0)'
- });
- var elXAxisTitleText = graphics.drawText({
- x: 0,
- y: w.globals.gridHeight / 2,
- text: w.config.yaxis[0].title.text,
- textAnchor: 'middle',
- foreColor: w.config.yaxis[0].title.style.color,
- fontSize: w.config.yaxis[0].title.style.fontSize,
- fontWeight: w.config.yaxis[0].title.style.fontWeight,
- fontFamily: w.config.yaxis[0].title.style.fontFamily,
- cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[0].title.style.cssClass
- });
- elXaxisTitle.add(elXAxisTitleText);
- elYaxis.add(elXaxisTitle);
- }
- var offX = 0;
- if (this.isCategoryBarHorizontal && w.config.yaxis[0].opposite) {
- offX = w.globals.gridWidth;
- }
- var axisBorder = w.config.xaxis.axisBorder;
- if (axisBorder.show) {
- var elVerticalLine = graphics.drawLine(w.globals.padHorizontal + axisBorder.offsetX + offX, 1 + axisBorder.offsetY, w.globals.padHorizontal + axisBorder.offsetX + offX, w.globals.gridHeight + axisBorder.offsetY, axisBorder.color, 0);
- elYaxis.add(elVerticalLine);
- }
- if (w.config.yaxis[0].axisTicks.show) {
- this.axesUtils.drawYAxisTicks(offX, labels.length, w.config.yaxis[0].axisBorder, w.config.yaxis[0].axisTicks, 0, colHeight, elYaxis);
- }
- return elYaxis;
- }
- }, {
- key: "drawXaxisTicks",
- value: function drawXaxisTicks(x1, appendToElement) {
- var w = this.w;
- var x2 = x1;
- if (x1 < 0 || x1 - 2 > w.globals.gridWidth) return;
- var y1 = this.offY + w.config.xaxis.axisTicks.offsetY;
- var y2 = y1 + w.config.xaxis.axisTicks.height;
- if (w.config.xaxis.position === 'top') {
- y2 = y1 - w.config.xaxis.axisTicks.height;
- }
- if (w.config.xaxis.axisTicks.show) {
- var graphics = new Graphics(this.ctx);
- var line = graphics.drawLine(x1 + w.config.xaxis.axisTicks.offsetX, y1 + w.config.xaxis.offsetY, x2 + w.config.xaxis.axisTicks.offsetX, y2 + w.config.xaxis.offsetY, w.config.xaxis.axisTicks.color);
- appendToElement.add(line);
- line.node.classList.add('apexcharts-xaxis-tick');
- }
- }
- }, {
- key: "getXAxisTicksPositions",
- value: function getXAxisTicksPositions() {
- var w = this.w;
- var xAxisTicksPositions = [];
- var xCount = this.xaxisLabels.length;
- var x1 = w.globals.padHorizontal;
- if (w.globals.timescaleLabels.length > 0) {
- for (var i = 0; i < xCount; i++) {
- x1 = this.xaxisLabels[i].position;
- xAxisTicksPositions.push(x1);
- }
- } else {
- var xCountForCategoryCharts = xCount;
- for (var _i3 = 0; _i3 < xCountForCategoryCharts; _i3++) {
- var x1Count = xCountForCategoryCharts;
- if (w.globals.isXNumeric && w.config.chart.type !== 'bar') {
- x1Count -= 1;
- }
- x1 = x1 + w.globals.gridWidth / x1Count;
- xAxisTicksPositions.push(x1);
- }
- }
- return xAxisTicksPositions;
- }
- }, {
- key: "xAxisLabelCorrections",
- value: function xAxisLabelCorrections() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var xAxis = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g');
- var xAxisTexts = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-texts-g text');
- var yAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-inversed text');
- var xAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-inversed-texts-g text tspan');
- if (w.globals.rotateXLabels || w.config.xaxis.labels.rotateAlways) {
- for (var xat = 0; xat < xAxisTexts.length; xat++) {
- var textRotatingCenter = graphics.rotateAroundCenter(xAxisTexts[xat]);
- textRotatingCenter.y = textRotatingCenter.y - 1;
- textRotatingCenter.x = textRotatingCenter.x + 1;
- xAxisTexts[xat].setAttribute('transform', "rotate(".concat(w.config.xaxis.labels.rotate, " ").concat(textRotatingCenter.x, " ").concat(textRotatingCenter.y, ")"));
- xAxisTexts[xat].setAttribute('text-anchor', "end");
- var offsetHeight = 10;
- xAxis.setAttribute('transform', "translate(0, ".concat(-offsetHeight, ")"));
- var tSpan = xAxisTexts[xat].childNodes;
- if (w.config.xaxis.labels.trim) {
- Array.prototype.forEach.call(tSpan, function (ts) {
- graphics.placeTextWithEllipsis(ts, ts.textContent, w.config.xaxis.labels.maxHeight - (w.config.legend.position === 'bottom' ? 20 : 10));
- });
- }
- }
- } else {
- (function () {
- var width = w.globals.gridWidth / (w.globals.labels.length + 1);
- for (var _xat = 0; _xat < xAxisTexts.length; _xat++) {
- var _tSpan = xAxisTexts[_xat].childNodes;
- if (w.config.xaxis.labels.trim && w.config.xaxis.type !== 'datetime') {
- Array.prototype.forEach.call(_tSpan, function (ts) {
- graphics.placeTextWithEllipsis(ts, ts.textContent, width);
- });
- }
- }
- })();
- }
- if (yAxisTextsInversed.length > 0) {
-
- var firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox();
- var lastLabelPosX = yAxisTextsInversed[0].getBBox();
- if (firstLabelPosX.x < -20) {
- yAxisTextsInversed[yAxisTextsInversed.length - 1].parentNode.removeChild(yAxisTextsInversed[yAxisTextsInversed.length - 1]);
- }
- if (lastLabelPosX.x + lastLabelPosX.width > w.globals.gridWidth && !w.globals.isBarHorizontal) {
- yAxisTextsInversed[0].parentNode.removeChild(yAxisTextsInversed[0]);
- }
- for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) {
- graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 - 20);
- }
- }
- }
-
-
-
-
- }]);
- return XAxis;
- }();
-
- var Grid = function () {
- function Grid(ctx) {
- _classCallCheck(this, Grid);
- this.ctx = ctx;
- this.w = ctx.w;
- var w = this.w;
- this.xaxisLabels = w.globals.labels.slice();
- this.axesUtils = new AxesUtils(ctx);
- this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
- if (w.globals.timescaleLabels.length > 0) {
-
- this.xaxisLabels = w.globals.timescaleLabels.slice();
- }
- }
- _createClass(Grid, [{
- key: "drawGridArea",
- value: function drawGridArea() {
- var elGrid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- if (elGrid === null) {
- elGrid = graphics.group({
- class: 'apexcharts-grid'
- });
- }
- var elVerticalLine = graphics.drawLine(w.globals.padHorizontal, 1, w.globals.padHorizontal, w.globals.gridHeight, 'transparent');
- var elHorzLine = graphics.drawLine(w.globals.padHorizontal, w.globals.gridHeight, w.globals.gridWidth, w.globals.gridHeight, 'transparent');
- elGrid.add(elHorzLine);
- elGrid.add(elVerticalLine);
- return elGrid;
- }
- }, {
- key: "drawGrid",
- value: function drawGrid() {
- var gl = this.w.globals;
- var elgrid = null;
- if (gl.axisCharts) {
-
- elgrid = this.renderGrid();
- this.drawGridArea(elgrid.el);
- }
- return elgrid;
- }
- }, {
- key: "createGridMask",
- value: function createGridMask() {
- var w = this.w;
- var gl = w.globals;
- var graphics = new Graphics(this.ctx);
- var strokeSize = Array.isArray(w.config.stroke.width) ? 0 : w.config.stroke.width;
- if (Array.isArray(w.config.stroke.width)) {
- var strokeMaxSize = 0;
- w.config.stroke.width.forEach(function (m) {
- strokeMaxSize = Math.max(strokeMaxSize, m);
- });
- strokeSize = strokeMaxSize;
- }
- gl.dom.elGridRectMask = document.createElementNS(gl.SVGNS, 'clipPath');
- gl.dom.elGridRectMask.setAttribute('id', "gridRectMask".concat(gl.cuid));
- gl.dom.elGridRectMarkerMask = document.createElementNS(gl.SVGNS, 'clipPath');
- gl.dom.elGridRectMarkerMask.setAttribute('id', "gridRectMarkerMask".concat(gl.cuid));
- var type = w.config.chart.type;
- var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
- var barWidthLeft = 0;
- var barWidthRight = 0;
- if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal) {
- barWidthLeft = w.config.grid.padding.left;
- barWidthRight = w.config.grid.padding.right;
- if (gl.barPadForNumericAxis > barWidthLeft) {
- barWidthLeft = gl.barPadForNumericAxis;
- barWidthRight = gl.barPadForNumericAxis;
- }
- }
- gl.dom.elGridRect = graphics.drawRect(-strokeSize / 2 - barWidthLeft - 2, -strokeSize / 2, gl.gridWidth + strokeSize + barWidthRight + barWidthLeft + 4, gl.gridHeight + strokeSize, 0, '#fff');
- var coreUtils = new CoreUtils(this);
- coreUtils.getLargestMarkerSize();
- var markerSize = w.globals.markers.largestSize + 1;
- gl.dom.elGridRectMarker = graphics.drawRect(-markerSize * 2, -markerSize * 2, gl.gridWidth + markerSize * 4, gl.gridHeight + markerSize * 4, 0, '#fff');
- gl.dom.elGridRectMask.appendChild(gl.dom.elGridRect.node);
- gl.dom.elGridRectMarkerMask.appendChild(gl.dom.elGridRectMarker.node);
- var defs = gl.dom.baseEl.querySelector('defs');
- defs.appendChild(gl.dom.elGridRectMask);
- defs.appendChild(gl.dom.elGridRectMarkerMask);
- }
- }, {
- key: "_drawGridLines",
- value: function _drawGridLines(_ref) {
- var i = _ref.i,
- x1 = _ref.x1,
- y1 = _ref.y1,
- x2 = _ref.x2,
- y2 = _ref.y2,
- xCount = _ref.xCount,
- parent = _ref.parent;
- var w = this.w;
- var shouldDraw = function shouldDraw() {
- if (i === 0 && w.globals.skipFirstTimelinelabel) {
- return false;
- }
- if (i === xCount - 1 && w.globals.skipLastTimelinelabel) {
- return false;
- }
- if (w.config.chart.type === 'radar') {
- return false;
- }
- return true;
- };
- if (shouldDraw()) {
- if (w.config.grid.xaxis.lines.show) {
- this._drawGridLine({
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- parent: parent
- });
- }
- var xAxis = new XAxis(this.ctx);
- xAxis.drawXaxisTicks(x1, this.elg);
- }
- }
- }, {
- key: "_drawGridLine",
- value: function _drawGridLine(_ref2) {
- var x1 = _ref2.x1,
- y1 = _ref2.y1,
- x2 = _ref2.x2,
- y2 = _ref2.y2,
- parent = _ref2.parent;
- var w = this.w;
- var strokeDashArray = w.config.grid.strokeDashArray;
- var graphics = new Graphics(this);
- var line = graphics.drawLine(x1, y1, x2, y2, w.config.grid.borderColor, strokeDashArray);
- line.node.classList.add('apexcharts-gridline');
- parent.add(line);
- }
- }, {
- key: "_drawGridBandRect",
- value: function _drawGridBandRect(_ref3) {
- var c = _ref3.c,
- x1 = _ref3.x1,
- y1 = _ref3.y1,
- x2 = _ref3.x2,
- y2 = _ref3.y2,
- type = _ref3.type;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- if (type === 'column' && w.config.xaxis.type === 'datetime') return;
- var color = w.config.grid[type].colors[c];
- var rect = graphics.drawRect(x1, y1, x2, y2, 0, color, w.config.grid[type].opacity);
- this.elg.add(rect);
- rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
- rect.node.classList.add("apexcharts-grid-".concat(type));
- }
- }, {
- key: "_drawXYLines",
- value: function _drawXYLines(_ref4) {
- var _this = this;
- var xCount = _ref4.xCount,
- tickAmount = _ref4.tickAmount;
- var w = this.w;
- var datetimeLines = function datetimeLines(_ref5) {
- var xC = _ref5.xC,
- x1 = _ref5.x1,
- y1 = _ref5.y1,
- x2 = _ref5.x2,
- y2 = _ref5.y2;
- for (var i = 0; i < xC; i++) {
- x1 = _this.xaxisLabels[i].position;
- x2 = _this.xaxisLabels[i].position;
- _this._drawGridLines({
- i: i,
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- xCount: xCount,
- parent: _this.elgridLinesV
- });
- }
- };
- var categoryLines = function categoryLines(_ref6) {
- var xC = _ref6.xC,
- x1 = _ref6.x1,
- y1 = _ref6.y1,
- x2 = _ref6.x2,
- y2 = _ref6.y2;
- for (var i = 0; i < xC + (w.globals.isXNumeric ? 0 : 1); i++) {
- if (i === 0 && xC === 1 && w.globals.dataPoints === 1) {
-
- x1 = w.globals.gridWidth / 2;
- x2 = x1;
- }
- _this._drawGridLines({
- i: i,
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- xCount: xCount,
- parent: _this.elgridLinesV
- });
- x1 = x1 + w.globals.gridWidth / (w.globals.isXNumeric ? xC - 1 : xC);
- x2 = x1;
- }
- };
- if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
- var x1 = w.globals.padHorizontal;
- var y1 = 0;
- var x2;
- var y2 = w.globals.gridHeight;
- if (w.globals.timescaleLabels.length) {
- datetimeLines({
- xC: xCount,
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2
- });
- } else {
- if (w.globals.isXNumeric) {
- xCount = w.globals.xAxisScale.result.length;
- }
- if (w.config.xaxis.convertedCatToNumeric) {
-
- xCount = w.globals.xaxisLabelsCount;
- }
- categoryLines({
- xC: xCount,
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2
- });
- }
- }
- if (w.config.grid.yaxis.lines.show) {
- var _x = 0;
- var _y = 0;
- var _y2 = 0;
- var _x2 = w.globals.gridWidth;
- var tA = tickAmount + 1;
- if (this.isTimelineBar) {
- tA = w.globals.labels.length;
- }
- for (var i = 0; i < tA + (this.isTimelineBar ? 1 : 0); i++) {
- this._drawGridLine({
- x1: _x,
- y1: _y,
- x2: _x2,
- y2: _y2,
- parent: this.elgridLinesH
- });
- _y = _y + w.globals.gridHeight / (this.isTimelineBar ? tA : tickAmount);
- _y2 = _y;
- }
- }
- }
- }, {
- key: "_drawInvertedXYLines",
- value: function _drawInvertedXYLines(_ref7) {
- var xCount = _ref7.xCount;
- var w = this.w;
- if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
- var x1 = w.globals.padHorizontal;
- var y1 = 0;
- var x2;
- var y2 = w.globals.gridHeight;
- for (var i = 0; i < xCount + 1; i++) {
- if (w.config.grid.xaxis.lines.show) {
- this._drawGridLine({
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- parent: this.elgridLinesV
- });
- }
- var xAxis = new XAxis(this.ctx);
- xAxis.drawXaxisTicks(x1, this.elg);
- x1 = x1 + w.globals.gridWidth / xCount + 0.3;
- x2 = x1;
- }
- }
- if (w.config.grid.yaxis.lines.show) {
- var _x3 = 0;
- var _y3 = 0;
- var _y4 = 0;
- var _x4 = w.globals.gridWidth;
- for (var _i = 0; _i < w.globals.dataPoints + 1; _i++) {
- this._drawGridLine({
- x1: _x3,
- y1: _y3,
- x2: _x4,
- y2: _y4,
- parent: this.elgridLinesH
- });
- _y3 = _y3 + w.globals.gridHeight / w.globals.dataPoints;
- _y4 = _y3;
- }
- }
- }
- }, {
- key: "renderGrid",
- value: function renderGrid() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- this.elg = graphics.group({
- class: 'apexcharts-grid'
- });
- this.elgridLinesH = graphics.group({
- class: 'apexcharts-gridlines-horizontal'
- });
- this.elgridLinesV = graphics.group({
- class: 'apexcharts-gridlines-vertical'
- });
- this.elg.add(this.elgridLinesH);
- this.elg.add(this.elgridLinesV);
- if (!w.config.grid.show) {
- this.elgridLinesV.hide();
- this.elgridLinesH.hide();
- }
- var yTickAmount = w.globals.yAxisScale.length ? w.globals.yAxisScale[0].result.length - 1 : 5;
- for (var i = 0; i < w.globals.series.length; i++) {
- if (typeof w.globals.yAxisScale[i] !== 'undefined') {
- yTickAmount = w.globals.yAxisScale[i].result.length - 1;
- }
- if (yTickAmount > 2) break;
- }
- var xCount;
- if (!w.globals.isBarHorizontal || this.isTimelineBar) {
- xCount = this.xaxisLabels.length;
- if (this.isTimelineBar) {
- yTickAmount = w.globals.labels.length;
- }
- this._drawXYLines({
- xCount: xCount,
- tickAmount: yTickAmount
- });
- } else {
- xCount = yTickAmount;
- yTickAmount = w.globals.xTickAmount;
- this._drawInvertedXYLines({
- xCount: xCount,
- tickAmount: yTickAmount
- });
- }
- this.drawGridBands(xCount, yTickAmount);
- return {
- el: this.elg,
- xAxisTickWidth: w.globals.gridWidth / xCount
- };
- }
- }, {
- key: "drawGridBands",
- value: function drawGridBands(xCount, tickAmount) {
- var w = this.w;
- if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) {
- var x1 = 0;
- var y1 = 0;
- var y2 = w.globals.gridHeight / tickAmount;
- var x2 = w.globals.gridWidth;
- for (var i = 0, c = 0; i < tickAmount; i++, c++) {
- if (c >= w.config.grid.row.colors.length) {
- c = 0;
- }
- this._drawGridBandRect({
- c: c,
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2,
- type: 'row'
- });
- y1 = y1 + w.globals.gridHeight / tickAmount;
- }
- }
- if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) {
- var xc = !w.globals.isBarHorizontal && (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) ? xCount - 1 : xCount;
- var _x5 = w.globals.padHorizontal;
- var _y5 = 0;
- var _x6 = w.globals.padHorizontal + w.globals.gridWidth / xc;
- var _y6 = w.globals.gridHeight;
- for (var _i2 = 0, _c = 0; _i2 < xCount; _i2++, _c++) {
- if (_c >= w.config.grid.column.colors.length) {
- _c = 0;
- }
- this._drawGridBandRect({
- c: _c,
- x1: _x5,
- y1: _y5,
- x2: _x6,
- y2: _y6,
- type: 'column'
- });
- _x5 = _x5 + w.globals.gridWidth / xc;
- }
- }
- }
- }]);
- return Grid;
- }();
- var Range = function () {
- function Range(ctx) {
- _classCallCheck(this, Range);
- this.ctx = ctx;
- this.w = ctx.w;
- }
-
- _createClass(Range, [{
- key: "niceScale",
- value: function niceScale(yMin, yMax, diff) {
- var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
- var ticks = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
- var NO_MIN_MAX_PROVIDED = arguments.length > 5 ? arguments[5] : undefined;
- var w = this.w;
- if (ticks === 'dataPoints') {
- ticks = w.globals.dataPoints - 1;
- }
- if (yMin === Number.MIN_VALUE && yMax === 0 || !Utils.isNumber(yMin) && !Utils.isNumber(yMax) || yMin === Number.MIN_VALUE && yMax === -Number.MAX_VALUE) {
-
- yMin = 0;
- yMax = ticks;
- var linearScale = this.linearScale(yMin, yMax, ticks);
- return linearScale;
- }
- if (yMin > yMax) {
-
-
- console.warn('axis.min cannot be greater than axis.max');
- yMax = yMin + 0.1;
- } else if (yMin === yMax) {
-
-
-
- yMin = yMin === 0 ? 0 : yMin - 0.5;
- yMax = yMax === 0 ? 2 : yMax + 0.5;
- }
-
-
-
-
-
-
-
- var result = [];
- var range = Math.abs(yMax - yMin);
- if (range < 1 && NO_MIN_MAX_PROVIDED && (w.config.chart.type === 'candlestick' || w.config.series[index].type === 'candlestick' || w.globals.isRangeData)) {
-
- yMax = yMax * 1.01;
- }
- var tiks = ticks + 1;
- if (tiks < 2) {
- tiks = 2;
- } else if (tiks > 2) {
- tiks -= 2;
- }
- var tempStep = range / tiks;
- var mag = Math.floor(Utils.log10(tempStep));
- var magPow = Math.pow(10, mag);
- var magMsd = Math.round(tempStep / magPow);
- if (magMsd < 1) {
- magMsd = 1;
- }
- var stepSize = magMsd * magPow;
-
- var lb = stepSize * Math.floor(yMin / stepSize);
- var ub = stepSize * Math.ceil(yMax / stepSize);
- var val = lb;
- if (NO_MIN_MAX_PROVIDED && range > 2) {
- while (1) {
- result.push(val);
- val += stepSize;
- if (val > ub) {
- break;
- }
- }
- return {
- result: result,
- niceMin: result[0],
- niceMax: result[result.length - 1]
- };
- } else {
- result = [];
- var v = yMin;
- result.push(v);
- var valuesDivider = Math.abs(yMax - yMin) / ticks;
- for (var i = 0; i <= ticks; i++) {
- v = v + valuesDivider;
- result.push(v);
- }
- if (result[result.length - 2] >= yMax) {
- result.pop();
- }
- return {
- result: result,
- niceMin: result[0],
- niceMax: result[result.length - 1]
- };
- }
- }
- }, {
- key: "linearScale",
- value: function linearScale(yMin, yMax) {
- var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
- var range = Math.abs(yMax - yMin);
- var step = range / ticks;
- if (ticks === Number.MAX_VALUE) {
- ticks = 10;
- step = 1;
- }
- var result = [];
- var v = yMin;
- while (ticks >= 0) {
- result.push(v);
- v = v + step;
- ticks -= 1;
- }
- return {
- result: result,
- niceMin: result[0],
- niceMax: result[result.length - 1]
- };
- }
- }, {
- key: "logarithmicScale",
- value: function logarithmicScale(index, yMin, yMax, ticks) {
- if (yMin < 0 || yMin === Number.MIN_VALUE) yMin = 0.01;
- var base = 10;
- var min = Math.log(yMin) / Math.log(base);
- var max = Math.log(yMax) / Math.log(base);
- var range = Math.abs(yMax - yMin);
- var step = range / ticks;
- var result = [];
- var v = yMin;
- while (ticks >= 0) {
- result.push(v);
- v = v + step;
- ticks -= 1;
- }
- var logs = result.map(function (niceNumber, i) {
- if (niceNumber <= 0) {
- niceNumber = 0.01;
- }
- var scale = (max - min) / (yMax - yMin);
- var logVal = Math.pow(base, min + scale * (niceNumber - min));
- return Math.round(logVal / Utils.roundToBase(logVal, base)) * Utils.roundToBase(logVal, base);
- });
- if (logs[0] === 0) logs[0] = 1;
- return {
- result: logs,
- niceMin: logs[0],
- niceMax: logs[logs.length - 1]
- };
- }
- }, {
- key: "setYScaleForIndex",
- value: function setYScaleForIndex(index, minY, maxY) {
- var gl = this.w.globals;
- var cnf = this.w.config;
- var y = gl.isBarHorizontal ? cnf.xaxis : cnf.yaxis[index];
- if (typeof gl.yAxisScale[index] === 'undefined') {
- gl.yAxisScale[index] = [];
- }
- var diff = Math.abs(maxY - minY);
- if (y.logarithmic && diff <= 5) {
- gl.invalidLogScale = true;
- }
- if (y.logarithmic && diff > 5) {
- gl.allSeriesCollapsed = false;
- gl.yAxisScale[index] = this.logarithmicScale(index, minY, maxY, y.tickAmount ? y.tickAmount : Math.floor(Math.log10(maxY)));
- } else {
- if (maxY === -Number.MAX_VALUE || !Utils.isNumber(maxY)) {
-
- gl.yAxisScale[index] = this.linearScale(0, 5, 5);
- } else {
-
- gl.allSeriesCollapsed = false;
- if ((y.min !== undefined || y.max !== undefined) && !y.forceNiceScale) {
-
- gl.yAxisScale[index] = this.linearScale(minY, maxY, y.tickAmount);
- } else {
- var noMinMaxProvided = cnf.yaxis[index].max === undefined && cnf.yaxis[index].min === undefined || cnf.yaxis[index].forceNiceScale;
- gl.yAxisScale[index] = this.niceScale(minY, maxY, diff, index,
- y.tickAmount ? y.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5, noMinMaxProvided);
- }
- }
- }
- }
- }, {
- key: "setXScale",
- value: function setXScale(minX, maxX) {
- var w = this.w;
- var gl = w.globals;
- var x = w.config.xaxis;
- var diff = Math.abs(maxX - minX);
- if (maxX === -Number.MAX_VALUE || !Utils.isNumber(maxX)) {
-
- gl.xAxisScale = this.linearScale(0, 5, 5);
- } else {
- gl.xAxisScale = this.niceScale(minX, maxX, diff, 0, x.tickAmount ? x.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5);
- }
- return gl.xAxisScale;
- }
- }, {
- key: "setMultipleYScales",
- value: function setMultipleYScales() {
- var _this = this;
- var gl = this.w.globals;
- var cnf = this.w.config;
- var minYArr = gl.minYArr.concat([]);
- var maxYArr = gl.maxYArr.concat([]);
- var scalesIndices = [];
- cnf.yaxis.forEach(function (yaxe, i) {
- var index = i;
- cnf.series.forEach(function (s, si) {
-
-
-
- if (s.name === yaxe.seriesName) {
- index = si;
- if (i !== si) {
- scalesIndices.push({
- index: si,
- similarIndex: i,
- alreadyExists: true
- });
- } else {
- scalesIndices.push({
- index: si
- });
- }
- }
- });
- var minY = minYArr[index];
- var maxY = maxYArr[index];
- _this.setYScaleForIndex(i, minY, maxY);
- });
- this.sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices);
- }
- }, {
- key: "sameScaleInMultipleAxes",
- value: function sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) {
- var _this2 = this;
- var cnf = this.w.config;
- var gl = this.w.globals;
- var similarIndices = [];
- scalesIndices.forEach(function (scale) {
- if (scale.alreadyExists) {
- if (typeof similarIndices[scale.index] === 'undefined') {
- similarIndices[scale.index] = [];
- }
- similarIndices[scale.index].push(scale.index);
- similarIndices[scale.index].push(scale.similarIndex);
- }
- });
- function intersect(a, b) {
- return a.filter(function (value) {
- return b.indexOf(value) !== -1;
- });
- }
- gl.yAxisSameScaleIndices = similarIndices;
- similarIndices.forEach(function (si, i) {
- similarIndices.forEach(function (sj, j) {
- if (i !== j) {
- if (intersect(si, sj).length > 0) {
- similarIndices[i] = similarIndices[i].concat(similarIndices[j]);
- }
- }
- });
- });
- var uniqueSimilarIndices = similarIndices.map(function (item) {
- return item.filter(function (i, pos) {
- return item.indexOf(i) === pos;
- });
- });
- var sortedIndices = uniqueSimilarIndices.map(function (s) {
- return s.sort();
- });
- similarIndices = similarIndices.filter(function (s) {
- return !!s;
- });
- var indices = sortedIndices.slice();
- var stringIndices = indices.map(function (ind) {
- return JSON.stringify(ind);
- });
- indices = indices.filter(function (ind, p) {
- return stringIndices.indexOf(JSON.stringify(ind)) === p;
- });
- var sameScaleMinYArr = [];
- var sameScaleMaxYArr = [];
- minYArr.forEach(function (minYValue, yi) {
- indices.forEach(function (scale, i) {
-
- if (scale.indexOf(yi) > -1) {
- if (typeof sameScaleMinYArr[i] === 'undefined') {
- sameScaleMinYArr[i] = [];
- sameScaleMaxYArr[i] = [];
- }
- sameScaleMinYArr[i].push({
- key: yi,
- value: minYValue
- });
- sameScaleMaxYArr[i].push({
- key: yi,
- value: maxYArr[yi]
- });
- }
- });
- });
- var sameScaleMin = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, Number.MIN_VALUE);
- var sameScaleMax = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, -Number.MAX_VALUE);
- sameScaleMinYArr.forEach(function (s, i) {
- s.forEach(function (sc, j) {
- sameScaleMin[i] = Math.min(sc.value, sameScaleMin[i]);
- });
- });
- sameScaleMaxYArr.forEach(function (s, i) {
- s.forEach(function (sc, j) {
- sameScaleMax[i] = Math.max(sc.value, sameScaleMax[i]);
- });
- });
- minYArr.forEach(function (min, i) {
- sameScaleMaxYArr.forEach(function (s, si) {
- var minY = sameScaleMin[si];
- var maxY = sameScaleMax[si];
- if (cnf.chart.stacked) {
-
- maxY = 0;
- s.forEach(function (ind, k) {
-
- if (ind.value !== -Number.MAX_VALUE) {
- maxY += ind.value;
- }
- if (minY !== Number.MIN_VALUE) {
- minY += sameScaleMinYArr[si][k].value;
- }
- });
- }
- s.forEach(function (ind, k) {
- if (s[k].key === i) {
- if (cnf.yaxis[i].min !== undefined) {
- if (typeof cnf.yaxis[i].min === 'function') {
- minY = cnf.yaxis[i].min(gl.minY);
- } else {
- minY = cnf.yaxis[i].min;
- }
- }
- if (cnf.yaxis[i].max !== undefined) {
- if (typeof cnf.yaxis[i].max === 'function') {
- maxY = cnf.yaxis[i].max(gl.maxY);
- } else {
- maxY = cnf.yaxis[i].max;
- }
- }
- _this2.setYScaleForIndex(i, minY, maxY);
- }
- });
- });
- });
- }
- }, {
- key: "autoScaleY",
- value: function autoScaleY(ctx, yaxis, e) {
- if (!ctx) {
- ctx = this;
- }
- var w = ctx.w;
- if (w.globals.isMultipleYAxis || w.globals.collapsedSeries.length) {
-
-
- console.warn('autoScaleYaxis is not supported in a multi-yaxis chart.');
- return yaxis;
- }
- var seriesX = w.globals.seriesX[0];
- var isStacked = w.config.chart.stacked;
- yaxis.forEach(function (yaxe, yi) {
- var firstXIndex = 0;
- for (var xi = 0; xi < seriesX.length; xi++) {
- if (seriesX[xi] >= e.xaxis.min) {
- firstXIndex = xi;
- break;
- }
- }
- var initialMin = w.globals.minYArr[yi];
- var initialMax = w.globals.maxYArr[yi];
- var min, max;
- var stackedSer = w.globals.stackedSeriesTotals;
- w.globals.series.forEach(function (serie, sI) {
- var firstValue = serie[firstXIndex];
- if (isStacked) {
- firstValue = stackedSer[firstXIndex];
- min = max = firstValue;
- stackedSer.forEach(function (y, yI) {
- if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
- if (y > max && y !== null) max = y;
- if (serie[yI] < min && serie[yI] !== null) min = serie[yI];
- }
- });
- } else {
- min = max = firstValue;
- serie.forEach(function (y, yI) {
- if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
- var valMin = y;
- var valMax = y;
- w.globals.series.forEach(function (wS, wSI) {
- if (y !== null) {
- valMin = Math.min(wS[yI], valMin);
- valMax = Math.max(wS[yI], valMax);
- }
- });
- if (valMax > max && valMax !== null) max = valMax;
- if (valMin < min && valMin !== null) min = valMin;
- }
- });
- }
- if (min === undefined && max === undefined) {
- min = initialMin;
- max = initialMax;
- }
- min *= min < 0 ? 1.1 : 0.9;
- max *= max < 0 ? 0.9 : 1.1;
- if (max < 0 && max < initialMax) {
- max = initialMax;
- }
- if (min < 0 && min > initialMin) {
- min = initialMin;
- }
- if (yaxis.length > 1) {
- yaxis[sI].min = yaxe.min === undefined ? min : yaxe.min;
- yaxis[sI].max = yaxe.max === undefined ? max : yaxe.max;
- } else {
- yaxis[0].min = yaxe.min === undefined ? min : yaxe.min;
- yaxis[0].max = yaxe.max === undefined ? max : yaxe.max;
- }
- });
- });
- return yaxis;
- }
- }]);
- return Range;
- }();
-
- var Range$1 = function () {
- function Range$1(ctx) {
- _classCallCheck(this, Range$1);
- this.ctx = ctx;
- this.w = ctx.w;
- this.scales = new Range(ctx);
- }
- _createClass(Range$1, [{
- key: "init",
- value: function init() {
- this.setYRange();
- this.setXRange();
- this.setZRange();
- }
- }, {
- key: "getMinYMaxY",
- value: function getMinYMaxY(startingIndex) {
- var lowestY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
- var highestY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -Number.MAX_VALUE;
- var len = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- var cnf = this.w.config;
- var gl = this.w.globals;
- var maxY = -Number.MAX_VALUE;
- var minY = Number.MIN_VALUE;
- if (len === null) {
- len = startingIndex + 1;
- }
- var series = gl.series;
- var seriesMin = series;
- var seriesMax = series;
- if (cnf.chart.type === 'candlestick') {
- seriesMin = gl.seriesCandleL;
- seriesMax = gl.seriesCandleH;
- } else if (gl.isRangeData) {
- seriesMin = gl.seriesRangeStart;
- seriesMax = gl.seriesRangeEnd;
- }
- for (var i = startingIndex; i < len; i++) {
- gl.dataPoints = Math.max(gl.dataPoints, series[i].length);
- for (var j = 0; j < gl.series[i].length; j++) {
- var val = series[i][j];
- if (val !== null && Utils.isNumber(val)) {
- maxY = Math.max(maxY, seriesMax[i][j]);
- lowestY = Math.min(lowestY, seriesMin[i][j]);
- highestY = Math.max(highestY, seriesMin[i][j]);
- if (this.w.config.chart.type === 'candlestick') {
- maxY = Math.max(maxY, gl.seriesCandleO[i][j]);
- maxY = Math.max(maxY, gl.seriesCandleH[i][j]);
- maxY = Math.max(maxY, gl.seriesCandleL[i][j]);
- maxY = Math.max(maxY, gl.seriesCandleC[i][j]);
- highestY = maxY;
- }
- if (Utils.isFloat(val)) {
- val = Utils.noExponents(val);
- gl.yValueDecimal = Math.max(gl.yValueDecimal, val.toString().split('.')[1].length);
- }
- if (minY > seriesMin[i][j] && seriesMin[i][j] < 0) {
- minY = seriesMin[i][j];
- }
- } else {
- gl.hasNullValues = true;
- }
- }
- }
- if (cnf.chart.type === 'rangeBar' && gl.seriesRangeStart.length && cnf.xaxis.type === 'datetime') {
- minY = lowestY;
- }
- if (cnf.chart.type === 'bar') {
- if (minY < 0 && maxY < 0) {
-
- maxY = 0;
- }
- if (minY === Number.MIN_VALUE) {
- minY = 0;
- }
- }
- return {
- minY: minY,
- maxY: maxY,
- lowestY: lowestY,
- highestY: highestY
- };
- }
- }, {
- key: "setYRange",
- value: function setYRange() {
- var gl = this.w.globals;
- var cnf = this.w.config;
- gl.maxY = -Number.MAX_VALUE;
- gl.minY = Number.MIN_VALUE;
- var lowestYInAllSeries = Number.MAX_VALUE;
- if (gl.isMultipleYAxis) {
-
- for (var i = 0; i < gl.series.length; i++) {
- var minYMaxYArr = this.getMinYMaxY(i, lowestYInAllSeries, null, i + 1);
- gl.minYArr.push(minYMaxYArr.minY);
- gl.maxYArr.push(minYMaxYArr.maxY);
- lowestYInAllSeries = minYMaxYArr.lowestY;
- }
- }
- var minYMaxY = this.getMinYMaxY(0, lowestYInAllSeries, null, gl.series.length);
- gl.minY = minYMaxY.minY;
- gl.maxY = minYMaxY.maxY;
- lowestYInAllSeries = minYMaxY.lowestY;
- if (cnf.chart.stacked) {
- this._setStackedMinMax();
- }
-
- if (cnf.chart.type === 'line' || cnf.chart.type === 'area' || cnf.chart.type === 'candlestick') {
- if (gl.minY === Number.MIN_VALUE && lowestYInAllSeries !== -Number.MAX_VALUE && lowestYInAllSeries !== gl.maxY
- ) {
- var diff = gl.maxY - lowestYInAllSeries;
- if (lowestYInAllSeries >= 0 && lowestYInAllSeries <= 10) {
-
- diff = 0;
- }
- gl.minY = lowestYInAllSeries - diff * 5 / 100;
-
-
- if (lowestYInAllSeries > 0 && gl.minY < 0) {
- gl.minY = 0;
- }
-
- gl.maxY = gl.maxY + diff * 5 / 100;
- }
- }
- cnf.yaxis.forEach(function (yaxe, index) {
-
- if (yaxe.max !== undefined) {
- if (typeof yaxe.max === 'number') {
- gl.maxYArr[index] = yaxe.max;
- } else if (typeof yaxe.max === 'function') {
- gl.maxYArr[index] = yaxe.max(gl.maxY);
- }
- gl.maxY = gl.maxYArr[index];
- }
- if (yaxe.min !== undefined) {
- if (typeof yaxe.min === 'number') {
- gl.minYArr[index] = yaxe.min;
- } else if (typeof yaxe.min === 'function') {
- gl.minYArr[index] = yaxe.min(gl.minY);
- }
- gl.minY = gl.minYArr[index];
- }
- });
- if (gl.isBarHorizontal) {
- var minmax = ['min', 'max'];
- minmax.forEach(function (m) {
- if (cnf.xaxis[m] !== undefined && typeof cnf.xaxis[m] === 'number') {
- m === 'min' ? gl.minY = cnf.xaxis[m] : gl.maxY = cnf.xaxis[m];
- }
- });
- }
- if (gl.isMultipleYAxis) {
- this.scales.setMultipleYScales();
- gl.minY = lowestYInAllSeries;
- gl.yAxisScale.forEach(function (scale, i) {
- gl.minYArr[i] = scale.niceMin;
- gl.maxYArr[i] = scale.niceMax;
- });
- } else {
- this.scales.setYScaleForIndex(0, gl.minY, gl.maxY);
- gl.minY = gl.yAxisScale[0].niceMin;
- gl.maxY = gl.yAxisScale[0].niceMax;
- gl.minYArr[0] = gl.yAxisScale[0].niceMin;
- gl.maxYArr[0] = gl.yAxisScale[0].niceMax;
- }
- return {
- minY: gl.minY,
- maxY: gl.maxY,
- minYArr: gl.minYArr,
- maxYArr: gl.maxYArr
- };
- }
- }, {
- key: "setXRange",
- value: function setXRange() {
- var gl = this.w.globals;
- var cnf = this.w.config;
- var isXNumeric = cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'datetime' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided || gl.noLabelsProvided || gl.isXNumeric;
- var getInitialMinXMaxX = function getInitialMinXMaxX() {
- for (var i = 0; i < gl.series.length; i++) {
- if (gl.labels[i]) {
- for (var j = 0; j < gl.labels[i].length; j++) {
- if (gl.labels[i][j] !== null && Utils.isNumber(gl.labels[i][j])) {
- gl.maxX = Math.max(gl.maxX, gl.labels[i][j]);
- gl.initialMaxX = Math.max(gl.maxX, gl.labels[i][j]);
- gl.minX = Math.min(gl.minX, gl.labels[i][j]);
- gl.initialMinX = Math.min(gl.minX, gl.labels[i][j]);
- }
- }
- }
- }
- };
- if (gl.isXNumeric) {
- getInitialMinXMaxX();
- }
- if (gl.noLabelsProvided) {
- if (cnf.xaxis.categories.length === 0) {
- gl.maxX = gl.labels[gl.labels.length - 1];
- gl.initialMaxX = gl.labels[gl.labels.length - 1];
- gl.minX = 1;
- gl.initialMinX = 1;
- }
- }
- if (gl.isXNumeric || gl.noLabelsProvided || gl.dataFormatXNumeric) {
- var ticks;
- if (cnf.xaxis.tickAmount === undefined) {
- ticks = Math.round(gl.svgWidth / 150);
- if (cnf.xaxis.type === 'numeric' && gl.dataPoints < 30) {
- ticks = gl.dataPoints - 1;
- }
- if (ticks > gl.dataPoints && gl.dataPoints !== 0) {
- ticks = gl.dataPoints - 1;
- }
- } else if (cnf.xaxis.tickAmount === 'dataPoints') {
- if (gl.series.length > 1) {
- ticks = gl.series[gl.maxValsInArrayIndex].length - 1;
- }
- if (gl.isXNumeric) {
- ticks = gl.maxX - gl.minX - 1;
- }
- } else {
- ticks = cnf.xaxis.tickAmount;
- }
- gl.xTickAmount = ticks;
- if (cnf.xaxis.max !== undefined && typeof cnf.xaxis.max === 'number') {
- gl.maxX = cnf.xaxis.max;
- }
- if (cnf.xaxis.min !== undefined && typeof cnf.xaxis.min === 'number') {
- gl.minX = cnf.xaxis.min;
- }
- if (cnf.xaxis.range !== undefined) {
- gl.minX = gl.maxX - cnf.xaxis.range;
- }
- if (gl.minX !== Number.MAX_VALUE && gl.maxX !== -Number.MAX_VALUE) {
- if (cnf.xaxis.convertedCatToNumeric && !gl.dataFormatXNumeric) {
- var catScale = [];
- for (var i = gl.minX - 1; i < gl.maxX; i++) {
- catScale.push(i + 1);
- }
- gl.xAxisScale = {
- result: catScale,
- niceMin: catScale[0],
- niceMax: catScale[catScale.length - 1]
- };
- } else {
- gl.xAxisScale = this.scales.setXScale(gl.minX, gl.maxX);
- }
- } else {
- gl.xAxisScale = this.scales.linearScale(1, ticks, ticks);
- if (gl.noLabelsProvided && gl.labels.length > 0) {
- gl.xAxisScale = this.scales.linearScale(1, gl.labels.length, ticks - 1);
- gl.seriesX = gl.labels.slice();
- }
- }
- if (isXNumeric) {
- gl.labels = gl.xAxisScale.result.slice();
- }
- }
- if (gl.isBarHorizontal && gl.labels.length) {
- gl.xTickAmount = gl.labels.length;
- }
- this._handleSingleDataPoint();
- this._getMinXDiff();
- return {
- minX: gl.minX,
- maxX: gl.maxX
- };
- }
- }, {
- key: "setZRange",
- value: function setZRange() {
-
- var gl = this.w.globals;
- if (!gl.isDataXYZ) return;
- for (var i = 0; i < gl.series.length; i++) {
- if (typeof gl.seriesZ[i] !== 'undefined') {
- for (var j = 0; j < gl.seriesZ[i].length; j++) {
- if (gl.seriesZ[i][j] !== null && Utils.isNumber(gl.seriesZ[i][j])) {
- gl.maxZ = Math.max(gl.maxZ, gl.seriesZ[i][j]);
- gl.minZ = Math.min(gl.minZ, gl.seriesZ[i][j]);
- }
- }
- }
- }
- }
- }, {
- key: "_handleSingleDataPoint",
- value: function _handleSingleDataPoint() {
- var gl = this.w.globals;
- var cnf = this.w.config;
- if (gl.minX === gl.maxX) {
- var datetimeObj = new DateTime(this.ctx);
- if (cnf.xaxis.type === 'datetime') {
- var newMinX = datetimeObj.getDate(gl.minX);
- newMinX.setUTCDate(newMinX.getDate() - 2);
- gl.minX = new Date(newMinX).getTime();
- var newMaxX = datetimeObj.getDate(gl.maxX);
- newMaxX.setUTCDate(newMaxX.getDate() + 2);
- gl.maxX = new Date(newMaxX).getTime();
- } else if (cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided) {
- gl.minX = gl.minX - 2;
- gl.initialMinX = gl.minX;
- gl.maxX = gl.maxX + 2;
- gl.initialMaxX = gl.maxX;
- }
- }
- }
- }, {
- key: "_getMinXDiff",
- value: function _getMinXDiff() {
- var gl = this.w.globals;
- if (gl.isXNumeric) {
-
- gl.seriesX.forEach(function (sX, i) {
- if (sX.length === 1) {
-
-
- sX.push(gl.seriesX[gl.maxValsInArrayIndex][gl.seriesX[gl.maxValsInArrayIndex].length - 1]);
- }
- var seriesX = sX.slice();
- seriesX.sort(function (a, b) {
- return a - b;
- });
- seriesX.forEach(function (s, j) {
- if (j > 0) {
- var xDiff = s - gl.seriesX[i][j - 1];
- if (xDiff > 0) {
- gl.minXDiff = Math.min(xDiff, gl.minXDiff);
- }
- }
- });
- if (gl.dataPoints === 1 && gl.minXDiff === Number.MAX_VALUE) {
- gl.minXDiff = 0.5;
- }
- });
- }
- }
- }, {
- key: "_setStackedMinMax",
- value: function _setStackedMinMax() {
- var gl = this.w.globals;
- var stackedPoss = [];
- var stackedNegs = [];
- if (gl.series.length) {
- for (var j = 0; j < gl.series[gl.maxValsInArrayIndex].length; j++) {
- var poss = 0;
- var negs = 0;
- for (var i = 0; i < gl.series.length; i++) {
- if (gl.series[i][j] !== null && Utils.isNumber(gl.series[i][j])) {
-
- gl.series[i][j] > 0 ? poss = poss + parseFloat(gl.series[i][j]) + 0.0001 : negs = negs + parseFloat(gl.series[i][j]);
- }
- if (i === gl.series.length - 1) {
-
- stackedPoss.push(poss);
- stackedNegs.push(negs);
- }
- }
- }
- }
- for (var z = 0; z < stackedPoss.length; z++) {
- gl.maxY = Math.max(gl.maxY, stackedPoss[z]);
- gl.minY = Math.min(gl.minY, stackedNegs[z]);
- }
- }
- }]);
- return Range$1;
- }();
-
- var YAxis = function () {
- function YAxis(ctx) {
- _classCallCheck(this, YAxis);
- this.ctx = ctx;
- this.w = ctx.w;
- var w = this.w;
- this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
- this.axisFontFamily = w.config.xaxis.labels.style.fontFamily;
- this.xaxisForeColors = w.config.xaxis.labels.style.colors;
- this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
- this.xAxisoffX = 0;
- if (w.config.xaxis.position === 'bottom') {
- this.xAxisoffX = w.globals.gridHeight;
- }
- this.drawnLabels = [];
- this.axesUtils = new AxesUtils(ctx);
- }
- _createClass(YAxis, [{
- key: "drawYaxis",
- value: function drawYaxis(realIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var yaxisStyle = w.config.yaxis[realIndex].labels.style;
- var yaxisFontSize = yaxisStyle.fontSize;
- var yaxisFontFamily = yaxisStyle.fontFamily;
- var yaxisFontWeight = yaxisStyle.fontWeight;
- var elYaxis = graphics.group({
- class: 'apexcharts-yaxis',
- rel: realIndex,
- transform: 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)'
- });
- if (this.axesUtils.isYAxisHidden(realIndex)) {
- return elYaxis;
- }
- var elYaxisTexts = graphics.group({
- class: 'apexcharts-yaxis-texts-g'
- });
- elYaxis.add(elYaxisTexts);
- var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1;
- var labelsDivider = w.globals.gridHeight / tickAmount;
- var l = w.globals.translateY;
- var lbFormatter = w.globals.yLabelFormatters[realIndex];
- var labels = w.globals.yAxisScale[realIndex].result.slice();
- labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
- var firstLabel = '';
- if (w.config.yaxis[realIndex].labels.show) {
- var _loop = function _loop(i) {
- var val = labels[i];
- val = lbFormatter(val, i);
- var xPad = w.config.yaxis[realIndex].labels.padding;
- if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
- xPad = xPad * -1;
- }
- var getForeColor = function getForeColor() {
- return Array.isArray(yaxisStyle.colors) ? yaxisStyle.colors[i] : yaxisStyle.colors;
- };
- var label = graphics.drawText({
- x: xPad,
- y: l + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY + 1,
- text: val,
- textAnchor: w.config.yaxis[realIndex].opposite ? 'start' : 'end',
- fontSize: yaxisFontSize,
- fontFamily: yaxisFontFamily,
- fontWeight: yaxisFontWeight,
- foreColor: getForeColor(),
- isPlainText: false,
- cssClass: 'apexcharts-yaxis-label ' + yaxisStyle.cssClass
- });
- if (i === tickAmount) {
- firstLabel = label;
- }
- elYaxisTexts.add(label);
- if (w.config.yaxis[realIndex].labels.rotate !== 0) {
- var firstabelRotatingCenter = graphics.rotateAroundCenter(firstLabel.node);
- var labelRotatingCenter = graphics.rotateAroundCenter(label.node);
- label.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " ").concat(firstabelRotatingCenter.x, " ").concat(labelRotatingCenter.y, ")"));
- }
- l = l + labelsDivider;
- };
- for (var i = tickAmount; i >= 0; i--) {
- _loop(i);
- }
- }
- if (w.config.yaxis[realIndex].title.text !== undefined) {
- var elYaxisTitle = graphics.group({
- class: 'apexcharts-yaxis-title'
- });
- var _x = 0;
- if (w.config.yaxis[realIndex].opposite) {
- _x = w.globals.translateYAxisX[realIndex];
- }
- var elYAxisTitleText = graphics.drawText({
- x: _x,
- y: w.globals.gridHeight / 2 + w.globals.translateY + w.config.yaxis[realIndex].title.offsetY,
- text: w.config.yaxis[realIndex].title.text,
- textAnchor: 'end',
- foreColor: w.config.yaxis[realIndex].title.style.color,
- fontSize: w.config.yaxis[realIndex].title.style.fontSize,
- fontWeight: w.config.yaxis[realIndex].title.style.fontWeight,
- fontFamily: w.config.yaxis[realIndex].title.style.fontFamily,
- cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[realIndex].title.style.cssClass
- });
- elYaxisTitle.add(elYAxisTitleText);
- elYaxis.add(elYaxisTitle);
- }
- var axisBorder = w.config.yaxis[realIndex].axisBorder;
- var x = 31 + axisBorder.offsetX;
- if (w.config.yaxis[realIndex].opposite) {
- x = -31 - axisBorder.offsetX;
- }
- if (axisBorder.show) {
- var elVerticalLine = graphics.drawLine(x, w.globals.translateY + axisBorder.offsetY - 2, x, w.globals.gridHeight + w.globals.translateY + axisBorder.offsetY + 2, axisBorder.color, 0, axisBorder.width);
- elYaxis.add(elVerticalLine);
- }
- if (w.config.yaxis[realIndex].axisTicks.show) {
- this.axesUtils.drawYAxisTicks(x, tickAmount, axisBorder, w.config.yaxis[realIndex].axisTicks, realIndex, labelsDivider, elYaxis);
- }
- return elYaxis;
- }
- }, {
- key: "drawYaxisInversed",
- value: function drawYaxisInversed(realIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var elXaxis = graphics.group({
- class: 'apexcharts-xaxis apexcharts-yaxis-inversed'
- });
- var elXaxisTexts = graphics.group({
- class: 'apexcharts-xaxis-texts-g',
- transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
- });
- elXaxis.add(elXaxisTexts);
- var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1;
- var labelsDivider = w.globals.gridWidth / tickAmount + 0.1;
- var l = labelsDivider + w.config.xaxis.labels.offsetX;
- var lbFormatter = w.globals.xLabelFormatter;
- var labels = w.globals.yAxisScale[realIndex].result.slice();
- var timescaleLabels = w.globals.timescaleLabels;
- if (timescaleLabels.length > 0) {
- this.xaxisLabels = timescaleLabels.slice();
- labels = timescaleLabels.slice();
- tickAmount = labels.length;
- }
- labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
- var tl = timescaleLabels.length;
- if (w.config.xaxis.labels.show) {
- for (var i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
- var val = labels[i];
- val = lbFormatter(val, i);
- var x = w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX);
- if (timescaleLabels.length) {
- var label = this.axesUtils.getLabel(labels, timescaleLabels, x, i, this.drawnLabels, this.xaxisFontSize);
- x = label.x;
- val = label.text;
- this.drawnLabels.push(label.text);
- if (i === 0 && w.globals.skipFirstTimelinelabel) {
- val = '';
- }
- if (i === labels.length - 1 && w.globals.skipLastTimelinelabel) {
- val = '';
- }
- }
- var elTick = graphics.drawText({
- x: x,
- y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30 - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
- text: val,
- textAnchor: 'middle',
- foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors,
- fontSize: this.xaxisFontSize,
- fontFamily: this.xaxisFontFamily,
- fontWeight: w.config.xaxis.labels.style.fontWeight,
- isPlainText: false,
- cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
- });
- elXaxisTexts.add(elTick);
- elTick.tspan(val);
- var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
- elTooltipTitle.textContent = val;
- elTick.node.appendChild(elTooltipTitle);
- l = l + labelsDivider;
- }
- }
- this.inversedYAxisTitleText(elXaxis);
- this.inversedYAxisBorder(elXaxis);
- return elXaxis;
- }
- }, {
- key: "inversedYAxisBorder",
- value: function inversedYAxisBorder(parent) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var axisBorder = w.config.xaxis.axisBorder;
- if (axisBorder.show) {
- var lineCorrection = 0;
- if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
- lineCorrection = lineCorrection - 15;
- }
- var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + axisBorder.offsetX, this.xAxisoffX, w.globals.gridWidth, this.xAxisoffX, axisBorder.color, 0, axisBorder.height);
- parent.add(elHorzLine);
- }
- }
- }, {
- key: "inversedYAxisTitleText",
- value: function inversedYAxisTitleText(parent) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- if (w.config.xaxis.title.text !== undefined) {
- var elYaxisTitle = graphics.group({
- class: 'apexcharts-xaxis-title apexcharts-yaxis-title-inversed'
- });
- var elYAxisTitleText = graphics.drawText({
- x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
- y: this.xAxisoffX + parseFloat(this.xaxisFontSize) + parseFloat(w.config.xaxis.title.style.fontSize) + w.config.xaxis.title.offsetY + 20,
- text: w.config.xaxis.title.text,
- textAnchor: 'middle',
- fontSize: w.config.xaxis.title.style.fontSize,
- fontFamily: w.config.xaxis.title.style.fontFamily,
- fontWeight: w.config.xaxis.title.style.fontWeight,
- cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
- });
- elYaxisTitle.add(elYAxisTitleText);
- parent.add(elYaxisTitle);
- }
- }
- }, {
- key: "yAxisTitleRotate",
- value: function yAxisTitleRotate(realIndex, yAxisOpposite) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var yAxisLabelsCoord = {
- width: 0,
- height: 0
- };
- var yAxisTitleCoord = {
- width: 0,
- height: 0
- };
- var elYAxisLabelsWrap = w.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-texts-g"));
- if (elYAxisLabelsWrap !== null) {
- yAxisLabelsCoord = elYAxisLabelsWrap.getBoundingClientRect();
- }
- var yAxisTitle = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-title text"));
- if (yAxisTitle !== null) {
- yAxisTitleCoord = yAxisTitle.getBoundingClientRect();
- }
- if (yAxisTitle !== null) {
- var x = this.xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite);
- yAxisTitle.setAttribute('x', x.xPos - (yAxisOpposite ? 10 : 0));
- }
- if (yAxisTitle !== null) {
- var titleRotatingCenter = graphics.rotateAroundCenter(yAxisTitle);
- yAxisTitle.setAttribute('transform', "rotate(".concat(yAxisOpposite ? '' : '-').concat(w.config.yaxis[realIndex].title.rotate, " ").concat(titleRotatingCenter.x, " ").concat(titleRotatingCenter.y, ")"));
- }
- }
- }, {
- key: "xPaddingForYAxisTitle",
- value: function xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite) {
- var w = this.w;
- var oppositeAxisCount = 0;
- var x = 0;
- var padd = 10;
- if (w.config.yaxis[realIndex].title.text === undefined || realIndex < 0) {
- return {
- xPos: x,
- padd: 0
- };
- }
- if (yAxisOpposite) {
- x = yAxisLabelsCoord.width + w.config.yaxis[realIndex].title.offsetX + yAxisTitleCoord.width / 2 + padd / 2;
- oppositeAxisCount += 1;
- if (oppositeAxisCount === 0) {
- x = x - padd / 2;
- }
- } else {
- x = yAxisLabelsCoord.width * -1 + w.config.yaxis[realIndex].title.offsetX + padd / 2 + yAxisTitleCoord.width / 2;
- if (w.globals.isBarHorizontal) {
- padd = 25;
- x = yAxisLabelsCoord.width * -1 - w.config.yaxis[realIndex].title.offsetX - padd;
- }
- }
- return {
- xPos: x,
- padd: padd
- };
- }
- }, {
- key: "setYAxisXPosition",
- value: function setYAxisXPosition(yaxisLabelCoords, yTitleCoords) {
- var w = this.w;
- var xLeft = 0;
- var xRight = 0;
- var leftOffsetX = 18;
- var rightOffsetX = 1;
- if (w.config.yaxis.length > 1) {
- this.multipleYs = true;
- }
- w.config.yaxis.map(function (yaxe, index) {
- var shouldNotDrawAxis = w.globals.ignoreYAxisIndexes.indexOf(index) > -1 || !yaxe.show || yaxe.floating || yaxisLabelCoords[index].width === 0;
- var axisWidth = yaxisLabelCoords[index].width + yTitleCoords[index].width;
- if (!yaxe.opposite) {
- xLeft = w.globals.translateX - leftOffsetX;
- if (!shouldNotDrawAxis) {
- leftOffsetX = leftOffsetX + axisWidth + 20;
- }
- w.globals.translateYAxisX[index] = xLeft + yaxe.labels.offsetX;
- } else {
- if (w.globals.isBarHorizontal) {
- xRight = w.globals.gridWidth + w.globals.translateX - 1;
- w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX;
- } else {
- xRight = w.globals.gridWidth + w.globals.translateX + rightOffsetX;
- if (!shouldNotDrawAxis) {
- rightOffsetX = rightOffsetX + axisWidth + 20;
- }
- w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX + 20;
- }
- }
- });
- }
- }, {
- key: "setYAxisTextAlignments",
- value: function setYAxisTextAlignments() {
- var w = this.w;
- var yaxis = w.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");
- yaxis = Utils.listToArray(yaxis);
- yaxis.forEach(function (y, index) {
- var yaxe = w.config.yaxis[index];
- if (yaxe.labels.align !== undefined) {
- var yAxisInner = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-texts-g"));
- var yAxisTexts = w.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-label"));
- yAxisTexts = Utils.listToArray(yAxisTexts);
- var rect = yAxisInner.getBoundingClientRect();
- if (yaxe.labels.align === 'left') {
- yAxisTexts.forEach(function (label, lI) {
- label.setAttribute('text-anchor', 'start');
- });
- if (!yaxe.opposite) {
- yAxisInner.setAttribute('transform', "translate(-".concat(rect.width, ", 0)"));
- }
- } else if (yaxe.labels.align === 'center') {
- yAxisTexts.forEach(function (label, lI) {
- label.setAttribute('text-anchor', 'middle');
- });
- yAxisInner.setAttribute('transform', "translate(".concat(rect.width / 2 * (!yaxe.opposite ? -1 : 1), ", 0)"));
- } else if (yaxe.labels.align === 'right') {
- yAxisTexts.forEach(function (label, lI) {
- label.setAttribute('text-anchor', 'end');
- });
- if (yaxe.opposite) {
- yAxisInner.setAttribute('transform', "translate(".concat(rect.width, ", 0)"));
- }
- }
- }
- });
- }
- }]);
- return YAxis;
- }();
- var Events = function () {
- function Events(ctx) {
- _classCallCheck(this, Events);
- this.ctx = ctx;
- this.w = ctx.w;
- this.documentEvent = Utils.bind(this.documentEvent, this);
- }
- _createClass(Events, [{
- key: "addEventListener",
- value: function addEventListener(name, handler) {
- var w = this.w;
- if (w.globals.events.hasOwnProperty(name)) {
- w.globals.events[name].push(handler);
- } else {
- w.globals.events[name] = [handler];
- }
- }
- }, {
- key: "removeEventListener",
- value: function removeEventListener(name, handler) {
- var w = this.w;
- if (!w.globals.events.hasOwnProperty(name)) {
- return;
- }
- var index = w.globals.events[name].indexOf(handler);
- if (index !== -1) {
- w.globals.events[name].splice(index, 1);
- }
- }
- }, {
- key: "fireEvent",
- value: function fireEvent(name, args) {
- var w = this.w;
- if (!w.globals.events.hasOwnProperty(name)) {
- return;
- }
- if (!args || !args.length) {
- args = [];
- }
- var evs = w.globals.events[name];
- var l = evs.length;
- for (var i = 0; i < l; i++) {
- evs[i].apply(null, args);
- }
- }
- }, {
- key: "setupEventHandlers",
- value: function setupEventHandlers() {
- var _this = this;
- var w = this.w;
- var me = this.ctx;
- var clickableArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
- this.ctx.eventList.forEach(function (event) {
- clickableArea.addEventListener(event, function (e) {
- var opts = Object.assign({}, w, {
- seriesIndex: w.globals.capturedSeriesIndex,
- dataPointIndex: w.globals.capturedDataPointIndex
- });
- if (e.type === 'mousemove' || e.type === 'touchmove') {
- if (typeof w.config.chart.events.mouseMove === 'function') {
- w.config.chart.events.mouseMove(e, me, opts);
- }
- } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') {
- if (typeof w.config.chart.events.click === 'function') {
- w.config.chart.events.click(e, me, opts);
- }
- me.ctx.events.fireEvent('click', [e, me, opts]);
- }
- }, {
- capture: false,
- passive: true
- });
- });
- this.ctx.eventList.forEach(function (event) {
- document.addEventListener(event, _this.documentEvent);
- });
- this.ctx.core.setupBrushHandler();
- }
- }, {
- key: "documentEvent",
- value: function documentEvent(e) {
- var w = this.w;
- var target = e.target.className;
- if (e.type === 'click') {
- var elMenu = w.globals.dom.baseEl.querySelector('.apexcharts-menu');
- if (elMenu && elMenu.classList.contains('apexcharts-menu-open') && target !== 'apexcharts-menu-icon') {
- elMenu.classList.remove('apexcharts-menu-open');
- }
- }
- if (e.type === 'mousedown') {
- var elAnnos = w.globals.dom.Paper.select('.apexcharts-resizable-element').members;
- Array.prototype.forEach.call(elAnnos, function (el) {
-
- if (!e.target.classList.contains('apexcharts-resizable-element') && !e.target.classList.contains('svg_select_points')) {
- el.selectize(false);
- }
- });
- }
- w.globals.clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
- w.globals.clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
- }
- }]);
- return Events;
- }();
- var Localization = function () {
- function Localization(ctx) {
- _classCallCheck(this, Localization);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Localization, [{
- key: "setCurrentLocaleValues",
- value: function setCurrentLocaleValues(localeName) {
- var locales = this.w.config.chart.locales;
-
- if (window.Apex.chart && window.Apex.chart.locales && window.Apex.chart.locales.length > 0) {
- locales = this.w.config.chart.locales.concat(window.Apex.chart.locales);
- }
- var selectedLocale = locales.filter(function (c) {
- return c.name === localeName;
- })[0];
- if (selectedLocale) {
-
- var ret = Utils.extend(en, selectedLocale);
- this.w.globals.locale = ret.options;
- } else {
- throw new Error('Wrong locale name provided. Please make sure you set the correct locale name in options');
- }
- }
- }]);
- return Localization;
- }();
- var Axes = function () {
- function Axes(ctx) {
- _classCallCheck(this, Axes);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Axes, [{
- key: "drawAxis",
- value: function drawAxis(type, xyRatios) {
- var gl = this.w.globals;
- var cnf = this.w.config;
- var xAxis = new XAxis(this.ctx);
- var yAxis = new YAxis(this.ctx);
- if (gl.axisCharts && type !== 'radar') {
- var elXaxis, elYaxis;
- if (gl.isBarHorizontal) {
- elYaxis = yAxis.drawYaxisInversed(0);
- elXaxis = xAxis.drawXaxisInversed(0);
- gl.dom.elGraphical.add(elXaxis);
- gl.dom.elGraphical.add(elYaxis);
- } else {
- elXaxis = xAxis.drawXaxis();
- gl.dom.elGraphical.add(elXaxis);
- cnf.yaxis.map(function (yaxe, index) {
- if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
- elYaxis = yAxis.drawYaxis(index);
- gl.dom.Paper.add(elYaxis);
- }
- });
- }
- }
- cnf.yaxis.map(function (yaxe, index) {
- if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
- yAxis.yAxisTitleRotate(index, yaxe.opposite);
- }
- });
- }
- }]);
- return Axes;
- }();
- var Crosshairs = function () {
- function Crosshairs(ctx) {
- _classCallCheck(this, Crosshairs);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Crosshairs, [{
- key: "drawXCrosshairs",
- value: function drawXCrosshairs() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var filters = new Filters(this.ctx);
- var crosshairGradient = w.config.xaxis.crosshairs.fill.gradient;
- var crosshairShadow = w.config.xaxis.crosshairs.dropShadow;
- var fillType = w.config.xaxis.crosshairs.fill.type;
- var gradientFrom = crosshairGradient.colorFrom;
- var gradientTo = crosshairGradient.colorTo;
- var opacityFrom = crosshairGradient.opacityFrom;
- var opacityTo = crosshairGradient.opacityTo;
- var stops = crosshairGradient.stops;
- var shadow = 'none';
- var dropShadow = crosshairShadow.enabled;
- var shadowLeft = crosshairShadow.left;
- var shadowTop = crosshairShadow.top;
- var shadowBlur = crosshairShadow.blur;
- var shadowColor = crosshairShadow.color;
- var shadowOpacity = crosshairShadow.opacity;
- var xcrosshairsFill = w.config.xaxis.crosshairs.fill.color;
- if (w.config.xaxis.crosshairs.show) {
- if (fillType === 'gradient') {
- xcrosshairsFill = graphics.drawGradient('vertical', gradientFrom, gradientTo, opacityFrom, opacityTo, null, stops, null);
- }
- var xcrosshairs = graphics.drawRect();
- if (w.config.xaxis.crosshairs.width === 1) {
-
- xcrosshairs = graphics.drawLine();
- }
- xcrosshairs.attr({
- class: 'apexcharts-xcrosshairs',
- x: 0,
- y: 0,
- y2: w.globals.gridHeight,
- width: Utils.isNumber(w.config.xaxis.crosshairs.width) ? w.config.xaxis.crosshairs.width : 0,
- height: w.globals.gridHeight,
- fill: xcrosshairsFill,
- filter: shadow,
- 'fill-opacity': w.config.xaxis.crosshairs.opacity,
- stroke: w.config.xaxis.crosshairs.stroke.color,
- 'stroke-width': w.config.xaxis.crosshairs.stroke.width,
- 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray
- });
- if (dropShadow) {
- xcrosshairs = filters.dropShadow(xcrosshairs, {
- left: shadowLeft,
- top: shadowTop,
- blur: shadowBlur,
- color: shadowColor,
- opacity: shadowOpacity
- });
- }
- w.globals.dom.elGraphical.add(xcrosshairs);
- }
- }
- }, {
- key: "drawYCrosshairs",
- value: function drawYCrosshairs() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var crosshair = w.config.yaxis[0].crosshairs;
- if (w.config.yaxis[0].crosshairs.show) {
- var ycrosshairs = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width);
- ycrosshairs.attr({
- class: 'apexcharts-ycrosshairs'
- });
- w.globals.dom.elGraphical.add(ycrosshairs);
- }
- var ycrosshairsHidden = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, 0, 0);
- ycrosshairsHidden.attr({
- class: 'apexcharts-ycrosshairs-hidden'
- });
- w.globals.dom.elGraphical.add(ycrosshairsHidden);
- }
- }]);
- return Crosshairs;
- }();
-
- var Responsive = function () {
- function Responsive(ctx) {
- _classCallCheck(this, Responsive);
- this.ctx = ctx;
- this.w = ctx.w;
- }
-
- _createClass(Responsive, [{
- key: "checkResponsiveConfig",
- value: function checkResponsiveConfig(opts) {
- var _this = this;
- var w = this.w;
- var cnf = w.config;
- if (cnf.responsive.length === 0) return;
- var res = cnf.responsive.slice();
- res.sort(function (a, b) {
- return a.breakpoint > b.breakpoint ? 1 : b.breakpoint > a.breakpoint ? -1 : 0;
- }).reverse();
- var config = new Config({});
- var iterateResponsiveOptions = function iterateResponsiveOptions() {
- var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var largestBreakpoint = res[0].breakpoint;
- var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
- if (width > largestBreakpoint) {
- var options = CoreUtils.extendArrayProps(config, w.globals.initialConfig);
- newOptions = Utils.extend(options, newOptions);
- newOptions = Utils.extend(w.config, newOptions);
- _this.overrideResponsiveOptions(newOptions);
- } else {
- for (var i = 0; i < res.length; i++) {
- if (width < res[i].breakpoint) {
- newOptions = CoreUtils.extendArrayProps(config, res[i].options);
- newOptions = Utils.extend(w.config, newOptions);
- _this.overrideResponsiveOptions(newOptions);
- }
- }
- }
- };
- if (opts) {
- var options = CoreUtils.extendArrayProps(config, opts);
- options = Utils.extend(w.config, options);
- options = Utils.extend(options, opts);
- iterateResponsiveOptions(options);
- } else {
- iterateResponsiveOptions({});
- }
- }
- }, {
- key: "overrideResponsiveOptions",
- value: function overrideResponsiveOptions(newOptions) {
- var newConfig = new Config(newOptions).init({
- responsiveOverride: true
- });
- this.w.config = newConfig;
- }
- }]);
- return Responsive;
- }();
-
- var Theme = function () {
- function Theme(ctx) {
- _classCallCheck(this, Theme);
- this.ctx = ctx;
- this.colors = [];
- this.w = ctx.w;
- var w = this.w;
- this.isColorFn = false;
- this.isBarDistributed = w.config.plotOptions.bar.distributed && (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar');
- }
- _createClass(Theme, [{
- key: "init",
- value: function init() {
- this.setDefaultColors();
- }
- }, {
- key: "setDefaultColors",
- value: function setDefaultColors() {
- var _this = this;
- var w = this.w;
- var utils = new Utils();
- w.globals.dom.elWrap.classList.add("apexcharts-theme-".concat(w.config.theme.mode));
- if (w.config.colors === undefined) {
- w.globals.colors = this.predefined();
- } else {
- w.globals.colors = w.config.colors;
- if (w.globals.axisCharts && w.config.chart.type !== 'bar' && Array.isArray(w.config.colors) && w.config.colors.length > 0 && w.config.colors.length === w.config.series.length
- ) {
- w.globals.colors = w.config.colors.map(function (c, i) {
- if (typeof c === 'function') {
- _this.isColorFn = true;
- return c({
- value: w.globals.axisCharts ? w.globals.series[i][0] ? w.globals.series[i][0] : 0 : w.globals.series[i],
- seriesIndex: i,
- dataPointIndex: i,
- w: w
- });
- }
- return c;
- });
- }
- }
- if (w.config.theme.monochrome.enabled) {
- var monoArr = [];
- var glsCnt = w.globals.series.length;
- if (this.isBarDistributed) {
- glsCnt = w.globals.series[0].length * w.globals.series.length;
- }
- var mainColor = w.config.theme.monochrome.color;
- var part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity);
- var shade = w.config.theme.monochrome.shadeTo;
- var percent = 0;
- for (var gsl = 0; gsl < glsCnt; gsl++) {
- var newColor = void 0;
- if (shade === 'dark') {
- newColor = utils.shadeColor(percent * -1, mainColor);
- percent = percent + part;
- } else {
- newColor = utils.shadeColor(percent, mainColor);
- percent = percent + part;
- }
- monoArr.push(newColor);
- }
- w.globals.colors = monoArr.slice();
- }
- var defaultColors = w.globals.colors.slice();
- this.pushExtraColors(w.globals.colors);
- var colorTypes = ['fill', 'stroke'];
- colorTypes.forEach(function (c) {
- if (w.config[c].colors === undefined) {
- w.globals[c].colors = _this.isColorFn ? w.config.colors : defaultColors;
- } else {
- w.globals[c].colors = w.config[c].colors.slice();
- }
- _this.pushExtraColors(w.globals[c].colors);
- });
- if (w.config.dataLabels.style.colors === undefined) {
- w.globals.dataLabels.style.colors = defaultColors;
- } else {
- w.globals.dataLabels.style.colors = w.config.dataLabels.style.colors.slice();
- }
- this.pushExtraColors(w.globals.dataLabels.style.colors, 50);
- if (w.config.plotOptions.radar.polygons.fill.colors === undefined) {
- w.globals.radarPolygons.fill.colors = [w.config.theme.mode === 'dark' ? '#202D48' : '#fff'];
- } else {
- w.globals.radarPolygons.fill.colors = w.config.plotOptions.radar.polygons.fill.colors.slice();
- }
- this.pushExtraColors(w.globals.radarPolygons.fill.colors, 20);
- if (w.config.markers.colors === undefined) {
- w.globals.markers.colors = defaultColors;
- } else {
- w.globals.markers.colors = w.config.markers.colors.slice();
- }
- this.pushExtraColors(w.globals.markers.colors);
- }
-
-
-
- }, {
- key: "pushExtraColors",
- value: function pushExtraColors(colorSeries, length) {
- var distributed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var w = this.w;
- var len = length || w.globals.series.length;
- if (distributed === null) {
- distributed = this.isBarDistributed || w.config.chart.type === 'heatmap' && w.config.plotOptions.heatmap.colorScale.inverse;
- }
- if (distributed) {
- len = w.globals.series[0].length * w.globals.series.length;
- }
- if (colorSeries.length < len) {
- var diff = len - colorSeries.length;
- for (var i = 0; i < diff; i++) {
- colorSeries.push(colorSeries[i]);
- }
- }
- }
- }, {
- key: "updateThemeOptions",
- value: function updateThemeOptions(options) {
- options.chart = options.chart || {};
- options.tooltip = options.tooltip || {};
- var mode = options.theme.mode || 'light';
- var palette = options.theme.palette ? options.theme.palette : mode === 'dark' ? 'palette4' : 'palette1';
- var foreColor = options.chart.foreColor ? options.chart.foreColor : mode === 'dark' ? '#f6f7f8' : '#373d3f';
- options.tooltip.theme = mode;
- options.chart.foreColor = foreColor;
- options.theme.palette = palette;
- return options;
- }
- }, {
- key: "predefined",
- value: function predefined() {
- var palette = this.w.config.theme.palette;
- switch (palette) {
- case 'palette1':
- this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
- break;
- case 'palette2':
- this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800'];
- break;
- case 'palette3':
- this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B'];
- break;
- case 'palette4':
- this.colors = ['#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a', '#546E7A'];
- break;
- case 'palette5':
- this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7'];
- break;
- case 'palette6':
- this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D'];
- break;
- case 'palette7':
- this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#E2C044'];
- break;
- case 'palette8':
- this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD'];
- break;
- case 'palette9':
- this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF'];
- break;
- case 'palette10':
- this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2'];
- break;
- default:
- this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
- break;
- }
- return this.colors;
- }
- }]);
- return Theme;
- }();
- var TitleSubtitle = function () {
- function TitleSubtitle(ctx) {
- _classCallCheck(this, TitleSubtitle);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(TitleSubtitle, [{
- key: "draw",
- value: function draw() {
- this.drawTitleSubtitle('title');
- this.drawTitleSubtitle('subtitle');
- }
- }, {
- key: "drawTitleSubtitle",
- value: function drawTitleSubtitle(type) {
- var w = this.w;
- var tsConfig = type === 'title' ? w.config.title : w.config.subtitle;
- var x = w.globals.svgWidth / 2;
- var y = tsConfig.offsetY;
- var textAnchor = 'middle';
- if (tsConfig.align === 'left') {
- x = 10;
- textAnchor = 'start';
- } else if (tsConfig.align === 'right') {
- x = w.globals.svgWidth - 10;
- textAnchor = 'end';
- }
- x = x + tsConfig.offsetX;
- y = y + parseInt(tsConfig.style.fontSize, 10) + tsConfig.margin / 2;
- if (tsConfig.text !== undefined) {
- var graphics = new Graphics(this.ctx);
- var titleText = graphics.drawText({
- x: x,
- y: y,
- text: tsConfig.text,
- textAnchor: textAnchor,
- fontSize: tsConfig.style.fontSize,
- fontFamily: tsConfig.style.fontFamily,
- fontWeight: tsConfig.style.fontWeight,
- foreColor: tsConfig.style.color,
- opacity: 1
- });
- titleText.node.setAttribute('class', "apexcharts-".concat(type, "-text"));
- w.globals.dom.Paper.add(titleText);
- }
- }
- }]);
- return TitleSubtitle;
- }();
- var Helpers$1 = function () {
- function Helpers(dCtx) {
- _classCallCheck(this, Helpers);
- this.w = dCtx.w;
- this.dCtx = dCtx;
- }
-
- _createClass(Helpers, [{
- key: "getTitleSubtitleCoords",
- value: function getTitleSubtitleCoords(type) {
- var w = this.w;
- var width = 0;
- var height = 0;
- var floating = type === 'title' ? w.config.title.floating : w.config.subtitle.floating;
- var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-text"));
- if (el !== null && !floating) {
- var coord = el.getBoundingClientRect();
- width = coord.width;
- height = w.globals.axisCharts ? coord.height + 5 : coord.height;
- }
- return {
- width: width,
- height: height
- };
- }
- }, {
- key: "getLegendsRect",
- value: function getLegendsRect() {
- var w = this.w;
- var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
- var lgRect = Object.assign({}, Utils.getBoundingClientRect(elLegendWrap));
- if (elLegendWrap !== null && !w.config.legend.floating && w.config.legend.show) {
- this.dCtx.lgRect = {
- x: lgRect.x,
- y: lgRect.y,
- height: lgRect.height,
- width: lgRect.height === 0 ? 0 : lgRect.width
- };
- } else {
- this.dCtx.lgRect = {
- x: 0,
- y: 0,
- height: 0,
- width: 0
- };
- }
- if (w.config.legend.position === 'left' || w.config.legend.position === 'right') {
- if (this.dCtx.lgRect.width * 1.5 > w.globals.svgWidth) {
- this.dCtx.lgRect.width = w.globals.svgWidth / 1.5;
- }
- }
- return this.dCtx.lgRect;
- }
- }, {
- key: "getLargestStringFromMultiArr",
- value: function getLargestStringFromMultiArr(val, arr) {
- var w = this.w;
- var valArr = val;
- if (w.globals.isMultiLineX) {
-
- var maxArrs = arr.map(function (xl, idx) {
- return Array.isArray(xl) ? xl.length : 1;
- });
- var maxArrLen = Math.max.apply(Math, _toConsumableArray(maxArrs));
- var maxArrIndex = maxArrs.indexOf(maxArrLen);
- valArr = arr[maxArrIndex];
- }
- return valArr;
- }
- }]);
- return Helpers;
- }();
- var DimXAxis = function () {
- function DimXAxis(dCtx) {
- _classCallCheck(this, DimXAxis);
- this.w = dCtx.w;
- this.dCtx = dCtx;
- }
-
- _createClass(DimXAxis, [{
- key: "getxAxisLabelsCoords",
- value: function getxAxisLabelsCoords() {
- var w = this.w;
- var xaxisLabels = w.globals.labels.slice();
- if (w.config.xaxis.convertedCatToNumeric && xaxisLabels.length === 0) {
- xaxisLabels = w.globals.categoryLabels;
- }
- var rect;
- if (w.globals.timescaleLabels.length > 0) {
- var coords = this.getxAxisTimeScaleLabelsCoords();
- rect = {
- width: coords.width,
- height: coords.height
- };
- w.globals.rotateXLabels = false;
- } else {
- this.dCtx.lgWidthForSideLegends = (w.config.legend.position === 'left' || w.config.legend.position === 'right') && !w.config.legend.floating ? this.dCtx.lgRect.width : 0;
- var xlbFormatter = w.globals.xLabelFormatter;
- var val = Utils.getLargestStringFromArr(xaxisLabels);
- var valArr = this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, xaxisLabels);
- if (w.globals.isBarHorizontal) {
- val = w.globals.yAxisScale[0].result.reduce(function (a, b) {
- return a.length > b.length ? a : b;
- }, 0);
- valArr = val;
- }
- var xFormat = new Formatters(this.dCtx.ctx);
- var timestamp = val;
- val = xFormat.xLabelFormat(xlbFormatter, val, timestamp);
- valArr = xFormat.xLabelFormat(xlbFormatter, valArr, timestamp);
- if (w.config.xaxis.convertedCatToNumeric && typeof val === 'undefined' || String(val).trim() === '') {
- val = '1';
- valArr = val;
- }
- var graphics = new Graphics(this.dCtx.ctx);
- var xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
- var xArrLabelrect = xLabelrect;
- if (val !== valArr) {
- xArrLabelrect = graphics.getTextRects(valArr, w.config.xaxis.labels.style.fontSize);
- }
- rect = {
- width: xLabelrect.width >= xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width,
- height: xLabelrect.height >= xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height
- };
- if (rect.width * xaxisLabels.length > w.globals.svgWidth - this.dCtx.lgWidthForSideLegends - this.dCtx.yAxisWidth - this.dCtx.gridPad.left - this.dCtx.gridPad.right && w.config.xaxis.labels.rotate !== 0 || w.config.xaxis.labels.rotateAlways) {
- if (!w.globals.isBarHorizontal) {
- w.globals.rotateXLabels = true;
- var getRotatedTextRects = function getRotatedTextRects(text) {
- return graphics.getTextRects(text, w.config.xaxis.labels.style.fontSize, w.config.xaxis.labels.style.fontFamily, "rotate(".concat(w.config.xaxis.labels.rotate, " 0 0)"), false);
- };
- xLabelrect = getRotatedTextRects(val);
- if (val !== valArr) {
- xArrLabelrect = getRotatedTextRects(valArr);
- }
- rect.height = (xLabelrect.height > xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height) / 1.5;
- rect.width = xLabelrect.width > xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width;
- }
- } else {
- w.globals.rotateXLabels = false;
- }
- }
- if (!w.config.xaxis.labels.show) {
- rect = {
- width: 0,
- height: 0
- };
- }
- return {
- width: rect.width,
- height: rect.height
- };
- }
-
- }, {
- key: "getxAxisTitleCoords",
- value: function getxAxisTitleCoords() {
- var w = this.w;
- var width = 0;
- var height = 0;
- if (w.config.xaxis.title.text !== undefined) {
- var graphics = new Graphics(this.dCtx.ctx);
- var rect = graphics.getTextRects(w.config.xaxis.title.text, w.config.xaxis.title.style.fontSize);
- width = rect.width;
- height = rect.height;
- }
- return {
- width: width,
- height: height
- };
- }
- }, {
- key: "getxAxisTimeScaleLabelsCoords",
- value: function getxAxisTimeScaleLabelsCoords() {
- var w = this.w;
- var rect;
- this.dCtx.timescaleLabels = w.globals.timescaleLabels.slice();
- var labels = this.dCtx.timescaleLabels.map(function (label) {
- return label.value;
- });
- var val = labels.reduce(function (a, b) {
-
- if (typeof a === 'undefined') {
- console.error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date');
- return 0;
- } else {
- return a.length > b.length ? a : b;
- }
- }, 0);
- var graphics = new Graphics(this.dCtx.ctx);
- rect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
- var totalWidthRotated = rect.width * 1.05 * labels.length;
- if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) {
- w.globals.overlappingXLabels = true;
- }
- return rect;
- }
-
- }, {
- key: "additionalPaddingXLabels",
- value: function additionalPaddingXLabels(xaxisLabelCoords) {
- var _this = this;
- var w = this.w;
- var gl = w.globals;
- var cnf = w.config;
- var xtype = cnf.xaxis.type;
-
-
-
-
-
- var lbWidth = xaxisLabelCoords.width;
- gl.skipLastTimelinelabel = false;
- gl.skipFirstTimelinelabel = false;
- var isBarOpposite = w.config.yaxis[0].opposite && w.globals.isBarHorizontal;
- var isCollapsed = function isCollapsed(i) {
- return gl.collapsedSeriesIndices.indexOf(i) !== -1;
- };
- var rightPad = function rightPad(yaxe) {
- if (_this.dCtx.timescaleLabels && _this.dCtx.timescaleLabels.length) {
-
- var firstimescaleLabel = _this.dCtx.timescaleLabels[0];
- var lastTimescaleLabel = _this.dCtx.timescaleLabels[_this.dCtx.timescaleLabels.length - 1];
- var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 -
-
- _this.dCtx.yAxisWidthRight;
- var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 +
-
- _this.dCtx.yAxisWidthLeft;
- if (lastLabelPosition > gl.gridWidth) {
- gl.skipLastTimelinelabel = true;
- }
- if (firstLabelPosition < 0) {
- gl.skipFirstTimelinelabel = true;
- }
- } else if (xtype === 'datetime') {
-
- if (_this.dCtx.gridPad.right < lbWidth && !gl.rotateXLabels) {
- gl.skipLastTimelinelabel = true;
- }
- } else if (xtype !== 'datetime') {
- if (_this.dCtx.gridPad.right < lbWidth / 2 - _this.dCtx.yAxisWidthRight && !gl.rotateXLabels && (w.config.xaxis.tickPlacement !== 'between' || w.globals.isBarHorizontal)) {
- _this.dCtx.xPadRight = lbWidth / 2 + 1;
- }
- }
- };
- var padYAxe = function padYAxe(yaxe, i) {
- if (isCollapsed(i)) return;
- if (xtype !== 'datetime') {
- if (_this.dCtx.gridPad.left < lbWidth / 2 - _this.dCtx.yAxisWidthLeft && !gl.rotateXLabels && !cnf.xaxis.labels.trim) {
- _this.dCtx.xPadLeft = lbWidth / 2 + 1;
- }
- }
- rightPad();
- };
- cnf.yaxis.forEach(function (yaxe, i) {
- if (isBarOpposite) {
- if (_this.dCtx.gridPad.left < lbWidth) {
- _this.dCtx.xPadLeft = lbWidth / 2 + 1;
- }
- _this.dCtx.xPadRight = lbWidth / 2 + 1;
- } else {
- padYAxe(yaxe, i);
- }
- });
- }
- }]);
- return DimXAxis;
- }();
- var DimYAxis = function () {
- function DimYAxis(dCtx) {
- _classCallCheck(this, DimYAxis);
- this.w = dCtx.w;
- this.dCtx = dCtx;
- }
-
- _createClass(DimYAxis, [{
- key: "getyAxisLabelsCoords",
- value: function getyAxisLabelsCoords() {
- var _this = this;
- var w = this.w;
- var width = 0;
- var height = 0;
- var ret = [];
- var labelPad = 10;
- var axesUtils = new AxesUtils(this.dCtx.ctx);
- w.config.yaxis.map(function (yaxe, index) {
- if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && w.globals.yAxisScale[index].result.length) {
- var lbFormatter = w.globals.yLabelFormatters[index];
- var val = lbFormatter(w.globals.yAxisScale[index].niceMax, {
- seriesIndex: index,
- dataPointIndex: -1,
- w: w
- });
- var valArr = val;
- if (typeof val === 'undefined' || val.length === 0) {
- val = w.globals.yAxisScale[index].niceMax;
- }
- if (w.globals.isBarHorizontal) {
- labelPad = 0;
- var barYaxisLabels = w.globals.labels.slice();
- val = Utils.getLargestStringFromArr(barYaxisLabels);
- val = lbFormatter(val, {
- seriesIndex: index,
- dataPointIndex: -1,
- w: w
- });
- valArr = _this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, barYaxisLabels);
- }
- var graphics = new Graphics(_this.dCtx.ctx);
- var rect = graphics.getTextRects(val, yaxe.labels.style.fontSize);
- var arrLabelrect = rect;
- if (val !== valArr) {
- arrLabelrect = graphics.getTextRects(valArr, yaxe.labels.style.fontSize);
- }
- ret.push({
- width: (arrLabelrect.width > rect.width ? arrLabelrect.width : rect.width) + labelPad,
- height: arrLabelrect.height > rect.height ? arrLabelrect.height : rect.height
- });
- } else {
- ret.push({
- width: width,
- height: height
- });
- }
- });
- return ret;
- }
-
- }, {
- key: "getyAxisTitleCoords",
- value: function getyAxisTitleCoords() {
- var _this2 = this;
- var w = this.w;
- var ret = [];
- w.config.yaxis.map(function (yaxe, index) {
- if (yaxe.show && yaxe.title.text !== undefined) {
- var graphics = new Graphics(_this2.dCtx.ctx);
- var rect = graphics.getTextRects(yaxe.title.text, yaxe.title.style.fontSize, yaxe.title.style.fontFamily, 'rotate(-90 0 0)', false);
- ret.push({
- width: rect.width,
- height: rect.height
- });
- } else {
- ret.push({
- width: 0,
- height: 0
- });
- }
- });
- return ret;
- }
- }, {
- key: "getTotalYAxisWidth",
- value: function getTotalYAxisWidth() {
- var w = this.w;
- var yAxisWidth = 0;
- var yAxisWidthLeft = 0;
- var yAxisWidthRight = 0;
- var padding = w.globals.yAxisScale.length > 1 ? 10 : 0;
- var axesUtils = new AxesUtils(this.dCtx.ctx);
- var isHiddenYAxis = function isHiddenYAxis(index) {
- return w.globals.ignoreYAxisIndexes.indexOf(index) > -1;
- };
- var padForLabelTitle = function padForLabelTitle(coord, index) {
- var floating = w.config.yaxis[index].floating;
- var width = 0;
- if (coord.width > 0 && !floating) {
- width = coord.width + padding;
- if (isHiddenYAxis(index)) {
- width = width - coord.width - padding;
- }
- } else {
- width = floating || axesUtils.isYAxisHidden(index) ? 0 : 5;
- }
- w.config.yaxis[index].opposite ? yAxisWidthRight = yAxisWidthRight + width : yAxisWidthLeft = yAxisWidthLeft + width;
- yAxisWidth = yAxisWidth + width;
- };
- w.globals.yLabelsCoords.map(function (yLabelCoord, index) {
- padForLabelTitle(yLabelCoord, index);
- });
- w.globals.yTitleCoords.map(function (yTitleCoord, index) {
- padForLabelTitle(yTitleCoord, index);
- });
- if (w.globals.isBarHorizontal) {
- yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15;
- }
- this.dCtx.yAxisWidthLeft = yAxisWidthLeft;
- this.dCtx.yAxisWidthRight = yAxisWidthRight;
- return yAxisWidth;
- }
- }]);
- return DimYAxis;
- }();
- var DimGrid = function () {
- function DimGrid(dCtx) {
- _classCallCheck(this, DimGrid);
- this.w = dCtx.w;
- this.dCtx = dCtx;
- }
- _createClass(DimGrid, [{
- key: "gridPadForColumnsInNumericAxis",
- value: function gridPadForColumnsInNumericAxis(gridWidth) {
- var w = this.w;
- if (w.globals.noData || w.globals.allSeriesCollapsed) {
- return 0;
- }
- var type = w.config.chart.type;
- var barWidth = 0;
- var seriesLen = type === 'bar' || type === 'rangeBar' ? w.config.series.length : 1;
- if (w.globals.comboBarCount > 0) {
- seriesLen = w.globals.comboBarCount;
- }
- w.globals.collapsedSeries.forEach(function (c) {
- if (c.type === 'bar' || c.type === 'rangeBar') {
- seriesLen = seriesLen - 1;
- }
- });
- if (w.config.chart.stacked) {
- seriesLen = 1;
- }
- var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
- if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal && seriesLen > 0) {
- var xRatio = 0;
- var xRange = Math.abs(w.globals.initialMaxX - w.globals.initialMinX);
- if (xRange <= 3) {
- xRange = w.globals.dataPoints;
- }
- xRatio = xRange / gridWidth;
- var xDivision;
- if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
- xDivision = w.globals.minXDiff / xRatio;
- }
- barWidth = xDivision / seriesLen * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
- if (barWidth < 1) {
- barWidth = 1;
- }
- barWidth = barWidth / (seriesLen > 1 ? 1 : 1.5) + 5;
- w.globals.barPadForNumericAxis = barWidth;
- }
- return barWidth;
- }
- }, {
- key: "gridPadFortitleSubtitle",
- value: function gridPadFortitleSubtitle() {
- var _this = this;
- var w = this.w;
- var gl = w.globals;
- var gridShrinkOffset = this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 10;
- var titleSubtitle = ['title', 'subtitle'];
- titleSubtitle.forEach(function (t) {
- if (w.config[t].text !== undefined) {
- gridShrinkOffset += w.config[t].margin;
- } else {
- gridShrinkOffset += _this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 5;
- }
- });
- var nonAxisOrMultiSeriesCharts = w.config.series.length > 1 || !w.globals.axisCharts || w.config.legend.showForSingleSeries;
- if (w.config.legend.show && w.config.legend.position === 'bottom' && !w.config.legend.floating && nonAxisOrMultiSeriesCharts) {
- gridShrinkOffset += 10;
- }
- var titleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('title');
- var subtitleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('subtitle');
- gl.gridHeight = gl.gridHeight - titleCoords.height - subtitleCoords.height - gridShrinkOffset;
- gl.translateY = gl.translateY + titleCoords.height + subtitleCoords.height + gridShrinkOffset;
- }
- }, {
- key: "setGridXPosForDualYAxis",
- value: function setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords) {
- var w = this.w;
- var axesUtils = new AxesUtils(this.dCtx.ctx);
- w.config.yaxis.map(function (yaxe, index) {
- if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1 && !yaxe.floating && !axesUtils.isYAxisHidden(index)) {
- if (yaxe.opposite) {
- w.globals.translateX = w.globals.translateX - (yaxisLabelCoords[index].width + yTitleCoords[index].width) - parseInt(w.config.yaxis[index].labels.style.fontSize, 10) / 1.2 - 12;
- }
- }
- });
- }
- }]);
- return DimGrid;
- }();
-
- var Dimensions = function () {
- function Dimensions(ctx) {
- _classCallCheck(this, Dimensions);
- this.ctx = ctx;
- this.w = ctx.w;
- this.lgRect = {};
- this.yAxisWidth = 0;
- this.yAxisWidthLeft = 0;
- this.yAxisWidthRight = 0;
- this.xAxisHeight = 0;
- this.isSparkline = this.w.config.chart.sparkline.enabled;
- this.dimHelpers = new Helpers$1(this);
- this.dimYAxis = new DimYAxis(this);
- this.dimXAxis = new DimXAxis(this);
- this.dimGrid = new DimGrid(this);
- this.lgWidthForSideLegends = 0;
- this.gridPad = this.w.config.grid.padding;
- this.xPadRight = 0;
- this.xPadLeft = 0;
- }
-
- _createClass(Dimensions, [{
- key: "plotCoords",
- value: function plotCoords() {
- var w = this.w;
- var gl = w.globals;
- this.lgRect = this.dimHelpers.getLegendsRect();
- if (gl.axisCharts) {
-
- this.setDimensionsForAxisCharts();
- } else {
-
- this.setDimensionsForNonAxisCharts();
- }
- this.dimGrid.gridPadFortitleSubtitle();
- gl.gridHeight = gl.gridHeight - this.gridPad.top - this.gridPad.bottom;
- gl.gridWidth = gl.gridWidth - this.gridPad.left - this.gridPad.right - this.xPadRight - this.xPadLeft;
- var barWidth = this.dimGrid.gridPadForColumnsInNumericAxis(gl.gridWidth);
- gl.gridWidth = gl.gridWidth - barWidth * 2;
- gl.translateX = gl.translateX + this.gridPad.left + this.xPadLeft + (barWidth > 0 ? barWidth + 4 : 0);
- gl.translateY = gl.translateY + this.gridPad.top;
- }
- }, {
- key: "setDimensionsForAxisCharts",
- value: function setDimensionsForAxisCharts() {
- var _this = this;
- var w = this.w;
- var gl = w.globals;
- var yaxisLabelCoords = this.dimYAxis.getyAxisLabelsCoords();
- var yTitleCoords = this.dimYAxis.getyAxisTitleCoords();
- w.globals.yLabelsCoords = [];
- w.globals.yTitleCoords = [];
- w.config.yaxis.map(function (yaxe, index) {
-
- w.globals.yLabelsCoords.push({
- width: yaxisLabelCoords[index].width,
- index: index
- });
- w.globals.yTitleCoords.push({
- width: yTitleCoords[index].width,
- index: index
- });
- });
- this.yAxisWidth = this.dimYAxis.getTotalYAxisWidth();
- var xaxisLabelCoords = this.dimXAxis.getxAxisLabelsCoords();
- var xtitleCoords = this.dimXAxis.getxAxisTitleCoords();
- this.conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords);
- gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4;
- gl.translateXAxisX = w.globals.rotateXLabels && w.globals.isXNumeric && w.config.xaxis.labels.rotate <= -45 ? -this.xAxisWidth / 4 : 0;
- if (w.globals.isBarHorizontal) {
- gl.rotateXLabels = false;
- gl.translateXAxisY = -1 * (parseInt(w.config.xaxis.labels.style.fontSize, 10) / 1.5);
- }
- gl.translateXAxisY = gl.translateXAxisY + w.config.xaxis.labels.offsetY;
- gl.translateXAxisX = gl.translateXAxisX + w.config.xaxis.labels.offsetX;
- var yAxisWidth = this.yAxisWidth;
- var xAxisHeight = this.xAxisHeight;
- gl.xAxisLabelsHeight = this.xAxisHeight;
- gl.xAxisHeight = this.xAxisHeight;
- var translateY = 10;
- if (w.config.chart.type === 'radar' || this.isSparkline) {
- yAxisWidth = 0;
- xAxisHeight = gl.goldenPadding;
- }
- if (this.isSparkline) {
- this.lgRect = {
- height: 0,
- width: 0
- };
- xAxisHeight = 0;
- yAxisWidth = 0;
- translateY = 0;
- }
- this.dimXAxis.additionalPaddingXLabels(xaxisLabelCoords);
- var legendTopBottom = function legendTopBottom() {
- gl.translateX = yAxisWidth;
- gl.gridHeight = gl.svgHeight - _this.lgRect.height - xAxisHeight - (!_this.isSparkline ? w.globals.rotateXLabels ? 10 : 15 : 0);
- gl.gridWidth = gl.svgWidth - yAxisWidth;
- };
- if (w.config.xaxis.position === 'top') translateY = gl.xAxisHeight - w.config.xaxis.axisTicks.height - 5;
- switch (w.config.legend.position) {
- case 'bottom':
- gl.translateY = translateY;
- legendTopBottom();
- break;
- case 'top':
- gl.translateY = this.lgRect.height + translateY;
- legendTopBottom();
- break;
- case 'left':
- gl.translateY = translateY;
- gl.translateX = this.lgRect.width + yAxisWidth;
- gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
- gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth;
- break;
- case 'right':
- gl.translateY = translateY;
- gl.translateX = yAxisWidth;
- gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
- gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth - 5;
- break;
- default:
- throw new Error('Legend position not supported');
- }
- this.dimGrid.setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords);
- var objyAxis = new YAxis(this.ctx);
- objyAxis.setYAxisXPosition(yaxisLabelCoords, yTitleCoords);
- }
- }, {
- key: "setDimensionsForNonAxisCharts",
- value: function setDimensionsForNonAxisCharts() {
- var w = this.w;
- var gl = w.globals;
- var cnf = w.config;
- var xPad = 0;
- if (w.config.legend.show && !w.config.legend.floating) {
- xPad = 20;
- }
- var type = cnf.chart.type === 'pie' || cnf.chart.type === 'donut' ? 'pie' : 'radialBar';
- var offY = cnf.plotOptions[type].offsetY;
- var offX = cnf.plotOptions[type].offsetX;
- if (!cnf.legend.show || cnf.legend.floating) {
- gl.gridHeight = gl.svgHeight - cnf.grid.padding.left + cnf.grid.padding.right;
- gl.gridWidth = gl.gridHeight;
- gl.translateY = offY;
- gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
- return;
- }
- switch (cnf.legend.position) {
- case 'bottom':
- gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
- gl.gridWidth = gl.gridHeight;
- gl.translateY = offY - 10;
- gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
- break;
- case 'top':
- gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
- gl.gridWidth = gl.gridHeight;
- gl.translateY = this.lgRect.height + offY + 10;
- gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
- break;
- case 'left':
- gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad;
- gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
- gl.translateY = offY;
- gl.translateX = offX + this.lgRect.width + xPad;
- break;
- case 'right':
- gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad - 5;
- gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
- gl.translateY = offY;
- gl.translateX = offX + 10;
- break;
- default:
- throw new Error('Legend position not supported');
- }
- }
- }, {
- key: "conditionalChecksForAxisCoords",
- value: function conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords) {
- var w = this.w;
- this.xAxisHeight = (xaxisLabelCoords.height + xtitleCoords.height) * (w.globals.isMultiLineX ? 1.2 : w.globals.LINE_HEIGHT_RATIO) + (w.globals.rotateXLabels ? 22 : 10);
- this.xAxisWidth = xaxisLabelCoords.width;
- if (this.xAxisHeight - xtitleCoords.height > w.config.xaxis.labels.maxHeight) {
- this.xAxisHeight = w.config.xaxis.labels.maxHeight;
- }
- if (w.config.xaxis.labels.minHeight && this.xAxisHeight < w.config.xaxis.labels.minHeight) {
- this.xAxisHeight = w.config.xaxis.labels.minHeight;
- }
- if (w.config.xaxis.floating) {
- this.xAxisHeight = 0;
- }
- var minYAxisWidth = 0;
- var maxYAxisWidth = 0;
- w.config.yaxis.forEach(function (y) {
- minYAxisWidth += y.labels.minWidth;
- maxYAxisWidth += y.labels.maxWidth;
- });
- if (this.yAxisWidth < minYAxisWidth) {
- this.yAxisWidth = minYAxisWidth;
- }
- if (this.yAxisWidth > maxYAxisWidth) {
- this.yAxisWidth = maxYAxisWidth;
- }
- }
- }]);
- return Dimensions;
- }();
-
- var Pie = function () {
- function Pie(ctx) {
- _classCallCheck(this, Pie);
- this.ctx = ctx;
- this.w = ctx.w;
- this.chartType = this.w.config.chart.type;
- this.initialAnim = this.w.config.chart.animations.enabled;
- this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
- this.animBeginArr = [0];
- this.animDur = 0;
- this.donutDataLabels = this.w.config.plotOptions.pie.donut.labels;
- var w = this.w;
- this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
- this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight : w.globals.gridWidth;
- this.centerY = this.defaultSize / 2;
- this.centerX = w.globals.gridWidth / 2;
- this.fullAngle = 360;
- w.globals.radialSize = this.defaultSize / 2.05 - w.config.stroke.width - (!w.config.chart.sparkline.enabled ? w.config.chart.dropShadow.blur : 0);
- this.donutSize = w.globals.radialSize * parseInt(w.config.plotOptions.pie.donut.size, 10) / 100;
- this.sliceLabels = [];
- this.prevSectorAngleArr = [];
- }
- _createClass(Pie, [{
- key: "draw",
- value: function draw(series) {
- var self = this;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var ret = graphics.group({
- class: 'apexcharts-pie'
- });
- if (w.globals.noData) return ret;
- var total = 0;
- for (var k = 0; k < series.length; k++) {
-
- total += Utils.negToZero(series[k]);
- }
- var sectorAngleArr = [];
- var elSeries = graphics.group();
- if (total === 0) {
- total = 0.00001;
- }
- for (var i = 0; i < series.length; i++) {
-
- var angle = this.fullAngle * Utils.negToZero(series[i]) / total;
- sectorAngleArr.push(angle);
- }
- if (w.globals.dataChanged) {
- var prevTotal = 0;
- for (var _k = 0; _k < w.globals.previousPaths.length; _k++) {
-
- prevTotal += Utils.negToZero(w.globals.previousPaths[_k]);
- }
- var previousAngle;
- for (var _i = 0; _i < w.globals.previousPaths.length; _i++) {
-
- previousAngle = this.fullAngle * Utils.negToZero(w.globals.previousPaths[_i]) / prevTotal;
- this.prevSectorAngleArr.push(previousAngle);
- }
- }
- if (this.donutSize < 0) {
- this.donutSize = 0;
- }
- var scaleSize = w.config.plotOptions.pie.customScale;
- var halfW = w.globals.gridWidth / 2;
- var halfH = w.globals.gridHeight / 2;
- var translateX = halfW - w.globals.gridWidth / 2 * scaleSize;
- var translateY = halfH - w.globals.gridHeight / 2 * scaleSize;
- if (w.config.chart.type === 'donut') {
-
- var circle = graphics.drawCircle(this.donutSize);
- circle.attr({
- cx: this.centerX,
- cy: this.centerY,
- fill: w.config.plotOptions.pie.donut.background ? w.config.plotOptions.pie.donut.background : 'transparent'
- });
- elSeries.add(circle);
- }
- var elG = self.drawArcs(sectorAngleArr, series);
- this.sliceLabels.forEach(function (s) {
- elG.add(s);
- });
- elSeries.attr({
- transform: "translate(".concat(translateX, ", ").concat(translateY, ") scale(").concat(scaleSize, ")")
- });
- elSeries.add(elG);
- ret.add(elSeries);
- if (this.donutDataLabels.show) {
- var dataLabels = this.renderInnerDataLabels(this.donutDataLabels, {
- hollowSize: this.donutSize,
- centerX: this.centerX,
- centerY: this.centerY,
- opacity: this.donutDataLabels.show,
- translateX: translateX,
- translateY: translateY
- });
- ret.add(dataLabels);
- }
- return ret;
- }
- }, {
- key: "drawArcs",
- value: function drawArcs(sectorAngleArr, series) {
- var w = this.w;
- var filters = new Filters(this.ctx);
- var graphics = new Graphics(this.ctx);
- var fill = new Fill(this.ctx);
- var g = graphics.group({
- class: 'apexcharts-slices'
- });
- var startAngle = 0;
- var prevStartAngle = 0;
- var endAngle = 0;
- var prevEndAngle = 0;
- this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
- for (var i = 0; i < sectorAngleArr.length; i++) {
- var elPieArc = graphics.group({
- class: "apexcharts-series apexcharts-pie-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[i]),
- rel: i + 1,
- 'data:realIndex': i
- });
- g.add(elPieArc);
- startAngle = endAngle;
- prevStartAngle = prevEndAngle;
- endAngle = startAngle + sectorAngleArr[i];
- prevEndAngle = prevStartAngle + this.prevSectorAngleArr[i];
- var angle = endAngle - startAngle;
- var pathFill = fill.fillPath({
- seriesNumber: i,
- size: w.globals.radialSize,
- value: series[i]
- });
- var path = this.getChangedPath(prevStartAngle, prevEndAngle);
- var elPath = graphics.drawPath({
- d: path,
- stroke: this.lineColorArr instanceof Array ? this.lineColorArr[i] : this.lineColorArr,
- strokeWidth: 0,
- fill: pathFill,
- fillOpacity: w.config.fill.opacity,
- classes: "apexcharts-pie-area apexcharts-".concat(w.config.chart.type, "-slice-").concat(i)
- });
- elPath.attr({
- index: 0,
- j: i
- });
- if (w.config.chart.dropShadow.enabled) {
- var shadow = w.config.chart.dropShadow;
- filters.dropShadow(elPath, shadow, i);
- }
- this.addListeners(elPath, this.donutDataLabels);
- Graphics.setAttrs(elPath.node, {
- 'data:angle': angle,
- 'data:startAngle': startAngle,
- 'data:strokeWidth': this.strokeWidth,
- 'data:value': series[i]
- });
- var labelPosition = {
- x: 0,
- y: 0
- };
- if (w.config.chart.type === 'pie') {
- labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, w.globals.radialSize / 1.25 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
- } else if (w.config.chart.type === 'donut') {
- labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, (w.globals.radialSize + this.donutSize) / 2 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
- }
- elPieArc.add(elPath);
- var dur = 0;
- if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
- dur = (endAngle - startAngle) / this.fullAngle * w.config.chart.animations.speed;
- if (dur === 0) dur = 1;
- this.animDur = dur + this.animDur;
- this.animBeginArr.push(this.animDur);
- } else {
- this.animBeginArr.push(0);
- }
- if (this.dynamicAnim && w.globals.dataChanged) {
- this.animatePaths(elPath, {
- size: w.globals.radialSize,
- endAngle: endAngle,
- startAngle: startAngle,
- prevStartAngle: prevStartAngle,
- prevEndAngle: prevEndAngle,
- animateStartingPos: true,
- i: i,
- animBeginArr: this.animBeginArr,
- shouldSetPrevPaths: true,
- dur: w.config.chart.animations.dynamicAnimation.speed
- });
- } else {
- this.animatePaths(elPath, {
- size: w.globals.radialSize,
- endAngle: endAngle,
- startAngle: startAngle,
- i: i,
- totalItems: sectorAngleArr.length - 1,
- animBeginArr: this.animBeginArr,
- dur: dur
- });
- }
- if (w.config.plotOptions.pie.expandOnClick) {
- elPath.click(this.pieClicked.bind(this, i));
- }
- if (w.config.dataLabels.enabled) {
- var xPos = labelPosition.x;
- var yPos = labelPosition.y;
- var text = 100 * (endAngle - startAngle) / 360 + '%';
- if (angle !== 0 && w.config.plotOptions.pie.dataLabels.minAngleToShowLabel < sectorAngleArr[i]) {
- var formatter = w.config.dataLabels.formatter;
- if (formatter !== undefined) {
- text = formatter(w.globals.seriesPercent[i][0], {
- seriesIndex: i,
- w: w
- });
- }
- var foreColor = w.globals.dataLabels.style.colors[i];
- var elPieLabel = graphics.drawText({
- x: xPos,
- y: yPos,
- text: text,
- textAnchor: 'middle',
- fontSize: w.config.dataLabels.style.fontSize,
- fontFamily: w.config.dataLabels.style.fontFamily,
- fontWeight: w.config.dataLabels.style.fontWeight,
- foreColor: foreColor
- });
- if (w.config.dataLabels.dropShadow.enabled) {
- var textShadow = w.config.dataLabels.dropShadow;
- filters.dropShadow(elPieLabel, textShadow);
- }
- elPieLabel.node.classList.add('apexcharts-pie-label');
- if (w.config.chart.animations.animate && w.globals.resized === false) {
- elPieLabel.node.classList.add('apexcharts-pie-label-delay');
- elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + 's';
- }
- this.sliceLabels.push(elPieLabel);
- }
- }
- }
- return g;
- }
- }, {
- key: "addListeners",
- value: function addListeners(elPath, dataLabels) {
- var graphics = new Graphics(this.ctx);
- elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath));
- elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elPath));
- elPath.node.addEventListener('mouseleave', this.revertDataLabelsInner.bind(this, elPath.node, dataLabels));
- elPath.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elPath));
- if (!this.donutDataLabels.total.showAlways) {
- elPath.node.addEventListener('mouseenter', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
- elPath.node.addEventListener('mousedown', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
- }
- }
- }, {
- key: "animatePaths",
- value: function animatePaths(el, opts) {
- var w = this.w;
- var me = this;
- var angle = opts.endAngle - opts.startAngle;
- var prevAngle = angle;
- var fromStartAngle = opts.startAngle;
- var toStartAngle = opts.startAngle;
- if (opts.prevStartAngle !== undefined && opts.prevEndAngle !== undefined) {
- fromStartAngle = opts.prevEndAngle;
- prevAngle = opts.prevEndAngle - opts.prevStartAngle;
- }
- if (opts.i === w.config.series.length - 1) {
-
- if (angle + toStartAngle > this.fullAngle) {
- opts.endAngle = opts.endAngle - (angle + toStartAngle);
- } else if (angle + toStartAngle < this.fullAngle) {
- opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle));
- }
- }
- if (angle === this.fullAngle) angle = this.fullAngle - 0.01;
- me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts);
- }
- }, {
- key: "animateArc",
- value: function animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts) {
- var me = this;
- var w = this.w;
- var animations = new Animations(this.ctx);
- var size = opts.size;
- var path;
- if (isNaN(fromStartAngle) || isNaN(prevAngle)) {
- fromStartAngle = toStartAngle;
- prevAngle = angle;
- opts.dur = 0;
- }
- var currAngle = angle;
- var startAngle = toStartAngle;
- var fromAngle = fromStartAngle - toStartAngle;
- if (w.globals.dataChanged && opts.shouldSetPrevPaths) {
-
- if (opts.prevEndAngle) {
- path = me.getPiePath({
- me: me,
- startAngle: opts.prevStartAngle,
- angle: opts.prevEndAngle - opts.prevStartAngle,
- size: size
- });
- el.attr({
- d: path
- });
- }
- }
- if (opts.dur !== 0) {
- el.animate(opts.dur, w.globals.easing, opts.animBeginArr[opts.i]).afterAll(function () {
- if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') {
- this.animate(w.config.chart.animations.dynamicAnimation.speed).attr({
- 'stroke-width': me.strokeWidth
- });
- }
- if (opts.i === w.config.series.length - 1) {
- animations.animationCompleted(el);
- }
- }).during(function (pos) {
- currAngle = fromAngle + (angle - fromAngle) * pos;
- if (opts.animateStartingPos) {
- currAngle = prevAngle + (angle - prevAngle) * pos;
- startAngle = fromStartAngle - prevAngle + (toStartAngle - (fromStartAngle - prevAngle)) * pos;
- }
- path = me.getPiePath({
- me: me,
- startAngle: startAngle,
- angle: currAngle,
- size: size
- });
- el.node.setAttribute('data:pathOrig', path);
- el.attr({
- d: path
- });
- });
- } else {
- path = me.getPiePath({
- me: me,
- startAngle: startAngle,
- angle: angle,
- size: size
- });
- if (!opts.isTrack) {
- w.globals.animationEnded = true;
- }
- el.node.setAttribute('data:pathOrig', path);
- el.attr({
- d: path,
- 'stroke-width': me.strokeWidth
- });
- }
- }
- }, {
- key: "pieClicked",
- value: function pieClicked(i) {
- var w = this.w;
- var me = this;
- var path;
- var size = me.w.globals.radialSize + (w.config.plotOptions.pie.expandOnClick ? 4 : 0);
- var elPath = w.globals.dom.Paper.select(".apexcharts-".concat(w.config.chart.type.toLowerCase(), "-slice-").concat(i)).members[0];
- if (elPath.attr('data:pieClicked') === 'true') {
- elPath.attr({
- 'data:pieClicked': 'false'
- });
- this.revertDataLabelsInner(elPath.node, this.donutDataLabels);
- var origPath = elPath.attr('data:pathOrig');
- elPath.attr({
- d: origPath
- });
- return;
- } else {
-
- var allEls = w.globals.dom.baseEl.getElementsByClassName('apexcharts-pie-area');
- Array.prototype.forEach.call(allEls, function (pieSlice) {
- pieSlice.setAttribute('data:pieClicked', 'false');
- var origPath = pieSlice.getAttribute('data:pathOrig');
- pieSlice.setAttribute('d', origPath);
- });
- elPath.attr('data:pieClicked', 'true');
- }
- var startAngle = parseInt(elPath.attr('data:startAngle'), 10);
- var angle = parseInt(elPath.attr('data:angle'), 10);
- path = me.getPiePath({
- me: me,
- startAngle: startAngle,
- angle: angle,
- size: size
- });
- if (angle === 360) return;
- elPath.plot(path);
- }
- }, {
- key: "getChangedPath",
- value: function getChangedPath(prevStartAngle, prevEndAngle) {
- var path = '';
- if (this.dynamicAnim && this.w.globals.dataChanged) {
- path = this.getPiePath({
- me: this,
- startAngle: prevStartAngle,
- angle: prevEndAngle - prevStartAngle,
- size: this.size
- });
- }
- return path;
- }
- }, {
- key: "getPiePath",
- value: function getPiePath(_ref) {
- var me = _ref.me,
- startAngle = _ref.startAngle,
- angle = _ref.angle,
- size = _ref.size;
- var w = this.w;
- var path;
- var startDeg = startAngle;
- var startRadians = Math.PI * (startDeg - 90) / 180;
- var endDeg = angle + startAngle;
- if (Math.ceil(endDeg) >= 360) endDeg = 359.99;
- var endRadians = Math.PI * (endDeg - 90) / 180;
- var x1 = me.centerX + size * Math.cos(startRadians);
- var y1 = me.centerY + size * Math.sin(startRadians);
- var x2 = me.centerX + size * Math.cos(endRadians);
- var y2 = me.centerY + size * Math.sin(endRadians);
- var startInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, endDeg);
- var endInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, startDeg);
- var largeArc = angle > 180 ? 1 : 0;
- var pathBeginning = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2];
- if (w.config.chart.type === 'donut') {
- path = [].concat(pathBeginning, ['L', startInner.x, startInner.y, 'A', me.donutSize, me.donutSize, 0, largeArc, 0, endInner.x, endInner.y, 'L', x1, y1, 'z']).join(' ');
- } else if (w.config.chart.type === 'pie') {
- path = [].concat(pathBeginning, ['L', me.centerX, me.centerY, 'L', x1, y1]).join(' ');
- } else {
- path = [].concat(pathBeginning).join(' ');
- }
- return path;
- }
- }, {
- key: "renderInnerDataLabels",
- value: function renderInnerDataLabels(dataLabelsConfig, opts) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var g = graphics.group({
- class: 'apexcharts-datalabels-group',
- transform: "translate(".concat(opts.translateX ? opts.translateX : 0, ", ").concat(opts.translateY ? opts.translateY : 0, ") scale(").concat(w.config.plotOptions.pie.customScale, ")")
- });
- var showTotal = dataLabelsConfig.total.show;
- g.node.style.opacity = opts.opacity;
- var x = opts.centerX;
- var y = opts.centerY;
- var labelColor, valueColor;
- if (dataLabelsConfig.name.color === undefined) {
- labelColor = w.globals.colors[0];
- } else {
- labelColor = dataLabelsConfig.name.color;
- }
- var labelFontSize = dataLabelsConfig.name.fontSize;
- var labelFontFamily = dataLabelsConfig.name.fontFamily;
- var labelFontWeight = dataLabelsConfig.value.fontWeight;
- if (dataLabelsConfig.value.color === undefined) {
- valueColor = w.config.chart.foreColor;
- } else {
- valueColor = dataLabelsConfig.value.color;
- }
- var lbFormatter = dataLabelsConfig.value.formatter;
- var val = '';
- var name = '';
- if (showTotal) {
- labelColor = dataLabelsConfig.total.color;
- labelFontSize = dataLabelsConfig.total.fontSize;
- labelFontFamily = dataLabelsConfig.total.fontFamily;
- labelFontWeight = dataLabelsConfig.total.fontWeight;
- name = dataLabelsConfig.total.label;
- val = dataLabelsConfig.total.formatter(w);
- } else {
- if (w.globals.series.length === 1) {
- val = lbFormatter(w.globals.series[0], w);
- name = w.globals.seriesNames[0];
- }
- }
- if (name) {
- name = dataLabelsConfig.name.formatter(name, dataLabelsConfig.total.show, w);
- }
- if (dataLabelsConfig.name.show) {
- var elLabel = graphics.drawText({
- x: x,
- y: y + parseFloat(dataLabelsConfig.name.offsetY),
- text: name,
- textAnchor: 'middle',
- foreColor: labelColor,
- fontSize: labelFontSize,
- fontWeight: labelFontWeight,
- fontFamily: labelFontFamily
- });
- elLabel.node.classList.add('apexcharts-datalabel-label');
- g.add(elLabel);
- }
- if (dataLabelsConfig.value.show) {
- var valOffset = dataLabelsConfig.name.show ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
- var elValue = graphics.drawText({
- x: x,
- y: y + valOffset,
- text: val,
- textAnchor: 'middle',
- foreColor: valueColor,
- fontWeight: dataLabelsConfig.value.fontWeight,
- fontSize: dataLabelsConfig.value.fontSize,
- fontFamily: dataLabelsConfig.value.fontFamily
- });
- elValue.node.classList.add('apexcharts-datalabel-value');
- g.add(elValue);
- }
- return g;
- }
-
- }, {
- key: "printInnerLabels",
- value: function printInnerLabels(labelsConfig, name, val, el) {
- var w = this.w;
- var labelColor;
- if (el) {
- if (labelsConfig.name.color === undefined) {
- labelColor = w.globals.colors[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
- } else {
- labelColor = labelsConfig.name.color;
- }
- } else {
- if (w.globals.series.length > 1 && labelsConfig.total.show) {
- labelColor = labelsConfig.total.color;
- }
- }
- var elLabel = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-label');
- var elValue = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-value');
- var lbFormatter = labelsConfig.value.formatter;
- val = lbFormatter(val, w);
- if (!el && typeof labelsConfig.total.formatter === 'function') {
- val = labelsConfig.total.formatter(w);
- }
- var isTotal = name === labelsConfig.total.label;
- name = labelsConfig.name.formatter(name, isTotal, w);
- if (elLabel !== null) {
- elLabel.textContent = name;
- }
- if (elValue !== null) {
- elValue.textContent = val;
- }
- if (elLabel !== null) {
- elLabel.style.fill = labelColor;
- }
- }
- }, {
- key: "printDataLabelsInner",
- value: function printDataLabelsInner(el, dataLabelsConfig) {
- var w = this.w;
- var val = el.getAttribute('data:value');
- var name = w.globals.seriesNames[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
- if (w.globals.series.length > 1) {
- this.printInnerLabels(dataLabelsConfig, name, val, el);
- }
- var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
- if (dataLabelsGroup !== null) {
- dataLabelsGroup.style.opacity = 1;
- }
- }
- }, {
- key: "revertDataLabelsInner",
- value: function revertDataLabelsInner(elem, dataLabelsConfig, event) {
- var _this = this;
- var w = this.w;
- var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
- var sliceOut = false;
- var slices = w.globals.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
- var selectSlice = function selectSlice(_ref2) {
- var makeSliceOut = _ref2.makeSliceOut,
- printLabel = _ref2.printLabel;
- Array.prototype.forEach.call(slices, function (s) {
- if (s.getAttribute('data:pieClicked') === 'true') {
- if (makeSliceOut) {
- sliceOut = true;
- }
- if (printLabel) {
- _this.printDataLabelsInner(s, dataLabelsConfig);
- }
- }
- });
- };
- selectSlice({
- makeSliceOut: true,
- printLabel: false
- });
- if (dataLabelsConfig.total.show && w.globals.series.length > 1) {
- if (sliceOut && !dataLabelsConfig.total.showAlways) {
- selectSlice({
- makeSliceOut: false,
- printLabel: true
- });
- } else {
- this.printInnerLabels(dataLabelsConfig, dataLabelsConfig.total.label, dataLabelsConfig.total.formatter(w));
- }
- } else {
- selectSlice({
- makeSliceOut: false,
- printLabel: true
- });
- if (!sliceOut) {
- if (w.globals.selectedDataPoints.length && w.globals.series.length > 1) {
- if (w.globals.selectedDataPoints[0].length > 0) {
- var index = w.globals.selectedDataPoints[0];
- var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(w.config.chart.type.toLowerCase(), "-slice-").concat(index));
- this.printDataLabelsInner(el, dataLabelsConfig);
- } else if (dataLabelsGroup && w.globals.selectedDataPoints.length && w.globals.selectedDataPoints[0].length === 0) {
- dataLabelsGroup.style.opacity = 0;
- }
- } else {
- if (dataLabelsGroup && w.globals.series.length > 1) {
- dataLabelsGroup.style.opacity = 0;
- }
- }
- }
- }
- }
- }]);
- return Pie;
- }();
- var Helpers$2 = function () {
- function Helpers(lgCtx) {
- _classCallCheck(this, Helpers);
- this.w = lgCtx.w;
- this.lgCtx = lgCtx;
- }
- _createClass(Helpers, [{
- key: "getLegendStyles",
- value: function getLegendStyles() {
- var stylesheet = document.createElement('style');
- stylesheet.setAttribute('type', 'text/css');
- var text = "\t\n \t\n .apexcharts-legend {\t\n display: flex;\t\n overflow: auto;\t\n padding: 0 10px;\t\n }\t\n .apexcharts-legend.position-bottom, .apexcharts-legend.position-top {\t\n flex-wrap: wrap\t\n }\t\n .apexcharts-legend.position-right, .apexcharts-legend.position-left {\t\n flex-direction: column;\t\n bottom: 0;\t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-left, .apexcharts-legend.position-top.apexcharts-align-left, .apexcharts-legend.position-right, .apexcharts-legend.position-left {\t\n justify-content: flex-start;\t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-center, .apexcharts-legend.position-top.apexcharts-align-center {\t\n justify-content: center; \t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-right, .apexcharts-legend.position-top.apexcharts-align-right {\t\n justify-content: flex-end;\t\n }\t\n .apexcharts-legend-series {\t\n cursor: pointer;\t\n line-height: normal;\t\n }\t\n .apexcharts-legend.position-bottom .apexcharts-legend-series, .apexcharts-legend.position-top .apexcharts-legend-series{\t\n display: flex;\t\n align-items: center;\t\n }\t\n .apexcharts-legend-text {\t\n position: relative;\t\n font-size: 14px;\t\n }\t\n .apexcharts-legend-text *, .apexcharts-legend-marker * {\t\n pointer-events: none;\t\n }\t\n .apexcharts-legend-marker {\t\n position: relative;\t\n display: inline-block;\t\n cursor: pointer;\t\n margin-right: 3px;\t\n border-style: solid;\n }\t\n \t\n .apexcharts-legend.apexcharts-align-right .apexcharts-legend-series, .apexcharts-legend.apexcharts-align-left .apexcharts-legend-series{\t\n display: inline-block;\t\n }\t\n .apexcharts-legend-series.apexcharts-no-click {\t\n cursor: auto;\t\n }\t\n .apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\t\n display: none !important;\t\n }\t\n .apexcharts-inactive-legend {\t\n opacity: 0.45;\t\n }";
- var rules = document.createTextNode(text);
- stylesheet.appendChild(rules);
- return stylesheet;
- }
- }, {
- key: "getLegendBBox",
- value: function getLegendBBox() {
- var w = this.w;
- var currLegendsWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
- var currLegendsWrapRect = currLegendsWrap.getBoundingClientRect();
- var currLegendsWrapWidth = currLegendsWrapRect.width;
- var currLegendsWrapHeight = currLegendsWrapRect.height;
- return {
- clwh: currLegendsWrapHeight,
- clww: currLegendsWrapWidth
- };
- }
- }, {
- key: "appendToForeignObject",
- value: function appendToForeignObject() {
- var gl = this.w.globals;
- gl.dom.elLegendForeign = document.createElementNS(gl.SVGNS, 'foreignObject');
- var elForeign = gl.dom.elLegendForeign;
- elForeign.setAttribute('x', 0);
- elForeign.setAttribute('y', 0);
- elForeign.setAttribute('width', gl.svgWidth);
- elForeign.setAttribute('height', gl.svgHeight);
- gl.dom.elLegendWrap.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
- elForeign.appendChild(gl.dom.elLegendWrap);
- elForeign.appendChild(this.getLegendStyles());
- gl.dom.Paper.node.insertBefore(elForeign, gl.dom.elGraphical.node);
- }
- }, {
- key: "toggleDataSeries",
- value: function toggleDataSeries(seriesCnt, isHidden) {
- var _this = this;
- var w = this.w;
- if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
- w.globals.resized = true;
- var seriesEl = null;
- var realIndex = null;
- w.globals.risingSeries = [];
- if (w.globals.axisCharts) {
- seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
- realIndex = parseInt(seriesEl.getAttribute('data:realIndex'), 10);
- } else {
- seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
- realIndex = parseInt(seriesEl.getAttribute('rel'), 10) - 1;
- }
- if (isHidden) {
- var seriesToMakeVisible = [{
- cs: w.globals.collapsedSeries,
- csi: w.globals.collapsedSeriesIndices
- }, {
- cs: w.globals.ancillaryCollapsedSeries,
- csi: w.globals.ancillaryCollapsedSeriesIndices
- }];
- seriesToMakeVisible.forEach(function (r) {
- _this.riseCollapsedSeries(r.cs, r.csi, realIndex);
- });
- } else {
- this.hideSeries({
- seriesEl: seriesEl,
- realIndex: realIndex
- });
- }
- } else {
-
- var _seriesEl = w.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
- var type = w.config.chart.type;
- if (type === 'pie' || type === 'donut') {
- var dataLabels = w.config.plotOptions.pie.donut.labels;
- var graphics = new Graphics(this.lgCtx.ctx);
- var pie = new Pie(this.lgCtx.ctx);
- graphics.pathMouseDown(_seriesEl.members[0], null);
- pie.printDataLabelsInner(_seriesEl.members[0].node, dataLabels);
- }
- _seriesEl.fire('click');
- }
- }
- }, {
- key: "hideSeries",
- value: function hideSeries(_ref) {
- var seriesEl = _ref.seriesEl,
- realIndex = _ref.realIndex;
- var w = this.w;
- if (w.globals.axisCharts) {
- var shouldNotHideYAxis = false;
- if (w.config.yaxis[realIndex] && w.config.yaxis[realIndex].show && w.config.yaxis[realIndex].showAlways) {
- shouldNotHideYAxis = true;
- if (w.globals.ancillaryCollapsedSeriesIndices.indexOf(realIndex) < 0) {
- w.globals.ancillaryCollapsedSeries.push({
- index: realIndex,
- data: w.config.series[realIndex].data.slice(),
- type: seriesEl.parentNode.className.baseVal.split('-')[1]
- });
- w.globals.ancillaryCollapsedSeriesIndices.push(realIndex);
- }
- }
- if (!shouldNotHideYAxis) {
- w.globals.collapsedSeries.push({
- index: realIndex,
- data: w.config.series[realIndex].data.slice(),
- type: seriesEl.parentNode.className.baseVal.split('-')[1]
- });
- w.globals.collapsedSeriesIndices.push(realIndex);
- var removeIndexOfRising = w.globals.risingSeries.indexOf(realIndex);
- w.globals.risingSeries.splice(removeIndexOfRising, 1);
- }
- w.config.series[realIndex].data = [];
- } else {
- w.globals.collapsedSeries.push({
- index: realIndex,
- data: w.config.series[realIndex]
- });
- w.globals.collapsedSeriesIndices.push(realIndex);
- w.config.series[realIndex] = 0;
- }
- var seriesChildren = seriesEl.childNodes;
- for (var sc = 0; sc < seriesChildren.length; sc++) {
- if (seriesChildren[sc].classList.contains('apexcharts-series-markers-wrap')) {
- if (seriesChildren[sc].classList.contains('apexcharts-hide')) {
- seriesChildren[sc].classList.remove('apexcharts-hide');
- } else {
- seriesChildren[sc].classList.add('apexcharts-hide');
- }
- }
- }
- w.globals.allSeriesCollapsed = w.globals.collapsedSeries.length === w.config.series.length;
- this.lgCtx.ctx.updateHelpers._updateSeries(w.config.series, w.config.chart.animations.dynamicAnimation.enabled);
- }
- }, {
- key: "riseCollapsedSeries",
- value: function riseCollapsedSeries(series, seriesIndices, realIndex) {
- var w = this.w;
- if (series.length > 0) {
- for (var c = 0; c < series.length; c++) {
- if (series[c].index === realIndex) {
- if (w.globals.axisCharts) {
- w.config.series[realIndex].data = series[c].data.slice();
- series.splice(c, 1);
- seriesIndices.splice(c, 1);
- w.globals.risingSeries.push(realIndex);
- } else {
- w.config.series[realIndex] = series[c].data;
- series.splice(c, 1);
- seriesIndices.splice(c, 1);
- w.globals.risingSeries.push(realIndex);
- }
- this.lgCtx.ctx.updateHelpers._updateSeries(w.config.series, w.config.chart.animations.dynamicAnimation.enabled);
- }
- }
- }
- }
- }]);
- return Helpers;
- }();
-
- var Legend = function () {
- function Legend(ctx, opts) {
- _classCallCheck(this, Legend);
- this.ctx = ctx;
- this.w = ctx.w;
- this.onLegendClick = this.onLegendClick.bind(this);
- this.onLegendHovered = this.onLegendHovered.bind(this);
- this.isBarsDistributed = this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.distributed && this.w.config.series.length === 1;
- this.legendHelpers = new Helpers$2(this);
- }
- _createClass(Legend, [{
- key: "init",
- value: function init() {
- var w = this.w;
- var gl = w.globals;
- var cnf = w.config;
- var showLegendAlways = cnf.legend.showForSingleSeries && gl.series.length === 1 || this.isBarsDistributed || gl.series.length > 1;
- if ((showLegendAlways || !gl.axisCharts) && cnf.legend.show) {
- while (gl.dom.elLegendWrap.firstChild) {
- gl.dom.elLegendWrap.removeChild(gl.dom.elLegendWrap.firstChild);
- }
- this.drawLegends();
- if (!Utils.isIE11()) {
- this.legendHelpers.appendToForeignObject();
- } else {
-
- document.getElementsByTagName('head')[0].appendChild(this.legendHelpers.getLegendStyles());
- }
- if (cnf.legend.position === 'bottom' || cnf.legend.position === 'top') {
- this.legendAlignHorizontal();
- } else if (cnf.legend.position === 'right' || cnf.legend.position === 'left') {
- this.legendAlignVertical();
- }
- }
- }
- }, {
- key: "drawLegends",
- value: function drawLegends() {
- var self = this;
- var w = this.w;
- var fontFamily = w.config.legend.fontFamily;
- var legendNames = w.globals.seriesNames;
- var fillcolor = w.globals.colors.slice();
- if (w.config.chart.type === 'heatmap') {
- var ranges = w.config.plotOptions.heatmap.colorScale.ranges;
- legendNames = ranges.map(function (colorScale) {
- return colorScale.name ? colorScale.name : colorScale.from + ' - ' + colorScale.to;
- });
- fillcolor = ranges.map(function (color) {
- return color.color;
- });
- } else if (this.isBarsDistributed) {
- legendNames = w.globals.labels.slice();
- }
- var legendFormatter = w.globals.legendFormatter;
- var isLegendInversed = w.config.legend.inverseOrder;
- for (var i = isLegendInversed ? legendNames.length - 1 : 0; isLegendInversed ? i >= 0 : i <= legendNames.length - 1; isLegendInversed ? i-- : i++) {
- var text = legendFormatter(legendNames[i], {
- seriesIndex: i,
- w: w
- });
- var collapsedSeries = false;
- var ancillaryCollapsedSeries = false;
- if (w.globals.collapsedSeries.length > 0) {
- for (var c = 0; c < w.globals.collapsedSeries.length; c++) {
- if (w.globals.collapsedSeries[c].index === i) {
- collapsedSeries = true;
- }
- }
- }
- if (w.globals.ancillaryCollapsedSeriesIndices.length > 0) {
- for (var _c = 0; _c < w.globals.ancillaryCollapsedSeriesIndices.length; _c++) {
- if (w.globals.ancillaryCollapsedSeriesIndices[_c] === i) {
- ancillaryCollapsedSeries = true;
- }
- }
- }
- var elMarker = document.createElement('span');
- elMarker.classList.add('apexcharts-legend-marker');
- var mOffsetX = w.config.legend.markers.offsetX;
- var mOffsetY = w.config.legend.markers.offsetY;
- var mHeight = w.config.legend.markers.height;
- var mWidth = w.config.legend.markers.width;
- var mBorderWidth = w.config.legend.markers.strokeWidth;
- var mBorderColor = w.config.legend.markers.strokeColor;
- var mBorderRadius = w.config.legend.markers.radius;
- var mStyle = elMarker.style;
- mStyle.background = fillcolor[i];
- mStyle.color = fillcolor[i];
- if (w.config.legend.markers.fillColors && w.config.legend.markers.fillColors[i]) {
- mStyle.background = w.config.legend.markers.fillColors[i];
- }
- mStyle.height = Array.isArray(mHeight) ? parseFloat(mHeight[i]) + 'px' : parseFloat(mHeight) + 'px';
- mStyle.width = Array.isArray(mWidth) ? parseFloat(mWidth[i]) + 'px' : parseFloat(mWidth) + 'px';
- mStyle.left = Array.isArray(mOffsetX) ? mOffsetX[i] : mOffsetX;
- mStyle.top = Array.isArray(mOffsetY) ? mOffsetY[i] : mOffsetY;
- mStyle.borderWidth = Array.isArray(mBorderWidth) ? mBorderWidth[i] : mBorderWidth;
- mStyle.borderColor = Array.isArray(mBorderColor) ? mBorderColor[i] : mBorderColor;
- mStyle.borderRadius = Array.isArray(mBorderRadius) ? parseFloat(mBorderRadius[i]) + 'px' : parseFloat(mBorderRadius) + 'px';
- if (w.config.legend.markers.customHTML) {
- if (Array.isArray(w.config.legend.markers.customHTML)) {
- elMarker.innerHTML = w.config.legend.markers.customHTML[i]();
- } else {
- elMarker.innerHTML = w.config.legend.markers.customHTML();
- }
- }
- Graphics.setAttrs(elMarker, {
- rel: i + 1,
- 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
- });
- if (collapsedSeries || ancillaryCollapsedSeries) {
- elMarker.classList.add('apexcharts-inactive-legend');
- }
- var elLegend = document.createElement('div');
- var elLegendText = document.createElement('span');
- elLegendText.classList.add('apexcharts-legend-text');
- elLegendText.innerHTML = Array.isArray(text) ? text.join(' ') : text;
- var textColor = w.config.legend.labels.useSeriesColors ? w.globals.colors[i] : w.config.legend.labels.colors;
- if (!textColor) {
- textColor = w.config.chart.foreColor;
- }
- elLegendText.style.color = textColor;
- elLegendText.style.fontSize = parseFloat(w.config.legend.fontSize) + 'px';
- elLegendText.style.fontWeight = w.config.legend.fontWeight;
- elLegendText.style.fontFamily = fontFamily || w.config.chart.fontFamily;
- Graphics.setAttrs(elLegendText, {
- rel: i + 1,
- i: i,
- 'data:default-text': encodeURIComponent(text),
- 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
- });
- elLegend.appendChild(elMarker);
- elLegend.appendChild(elLegendText);
- var coreUtils = new CoreUtils(this.ctx);
- if (!w.config.legend.showForZeroSeries) {
- var total = coreUtils.getSeriesTotalByIndex(i);
- if (total === 0 && coreUtils.seriesHaveSameValues(i) && !coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
- elLegend.classList.add('apexcharts-hidden-zero-series');
- }
- }
- if (!w.config.legend.showForNullSeries) {
- if (coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
- elLegend.classList.add('apexcharts-hidden-null-series');
- }
- }
- w.globals.dom.elLegendWrap.appendChild(elLegend);
- w.globals.dom.elLegendWrap.classList.add("apexcharts-align-".concat(w.config.legend.horizontalAlign));
- w.globals.dom.elLegendWrap.classList.add('position-' + w.config.legend.position);
- elLegend.classList.add('apexcharts-legend-series');
- elLegend.style.margin = "".concat(w.config.legend.itemMargin.vertical, "px ").concat(w.config.legend.itemMargin.horizontal, "px");
- w.globals.dom.elLegendWrap.style.width = w.config.legend.width ? w.config.legend.width + 'px' : '';
- w.globals.dom.elLegendWrap.style.height = w.config.legend.height ? w.config.legend.height + 'px' : '';
- Graphics.setAttrs(elLegend, {
- rel: i + 1,
- 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
- });
- if (collapsedSeries || ancillaryCollapsedSeries) {
- elLegend.classList.add('apexcharts-inactive-legend');
- }
- if (!w.config.legend.onItemClick.toggleDataSeries) {
- elLegend.classList.add('apexcharts-no-click');
- }
- }
- var clickAllowed = w.config.chart.type !== 'heatmap' && !this.isBarsDistributed;
- if (clickAllowed && w.config.legend.onItemClick.toggleDataSeries) {
- w.globals.dom.elWrap.addEventListener('click', self.onLegendClick, true);
- }
- if (w.config.legend.onItemHover.highlightDataSeries) {
- w.globals.dom.elWrap.addEventListener('mousemove', self.onLegendHovered, true);
- w.globals.dom.elWrap.addEventListener('mouseout', self.onLegendHovered, true);
- }
- }
- }, {
- key: "setLegendWrapXY",
- value: function setLegendWrapXY(offsetX, offsetY) {
- var w = this.w;
- var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
- var legendRect = elLegendWrap.getBoundingClientRect();
- var x = 0;
- var y = 0;
- if (w.config.legend.position === 'bottom') {
- y = y + (w.globals.svgHeight - legendRect.height / 2);
- } else if (w.config.legend.position === 'top') {
- var dim = new Dimensions(this.ctx);
- var titleH = dim.dimHelpers.getTitleSubtitleCoords('title').height;
- var subtitleH = dim.dimHelpers.getTitleSubtitleCoords('subtitle').height;
- y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0);
- }
- elLegendWrap.style.position = 'absolute';
- x = x + offsetX + w.config.legend.offsetX;
- y = y + offsetY + w.config.legend.offsetY;
- elLegendWrap.style.left = x + 'px';
- elLegendWrap.style.top = y + 'px';
- if (w.config.legend.position === 'bottom') {
- elLegendWrap.style.top = 'auto';
- elLegendWrap.style.bottom = 5 - w.config.legend.offsetY + 'px';
- } else if (w.config.legend.position === 'right') {
- elLegendWrap.style.left = 'auto';
- elLegendWrap.style.right = 25 + w.config.legend.offsetX + 'px';
- }
- var fixedHeigthWidth = ['width', 'height'];
- fixedHeigthWidth.forEach(function (hw) {
- if (elLegendWrap.style[hw]) {
- elLegendWrap.style[hw] = parseInt(w.config.legend[hw], 10) + 'px';
- }
- });
- }
- }, {
- key: "legendAlignHorizontal",
- value: function legendAlignHorizontal() {
- var w = this.w;
- var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
- elLegendWrap.style.right = 0;
- var lRect = this.legendHelpers.getLegendBBox();
- var dimensions = new Dimensions(this.ctx);
- var titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title');
- var subtitleRect = dimensions.dimHelpers.getTitleSubtitleCoords('subtitle');
- var offsetX = 20;
- var offsetY = 0;
- if (w.config.legend.position === 'bottom') {
- offsetY = -lRect.clwh / 1.8;
- } else if (w.config.legend.position === 'top') {
- offsetY = titleRect.height + subtitleRect.height + w.config.title.margin + w.config.subtitle.margin - 10;
- }
- this.setLegendWrapXY(offsetX, offsetY);
- }
- }, {
- key: "legendAlignVertical",
- value: function legendAlignVertical() {
- var w = this.w;
- var lRect = this.legendHelpers.getLegendBBox();
- var offsetY = 20;
- var offsetX = 0;
- if (w.config.legend.position === 'left') {
- offsetX = 20;
- }
- if (w.config.legend.position === 'right') {
- offsetX = w.globals.svgWidth - lRect.clww - 10;
- }
- this.setLegendWrapXY(offsetX, offsetY);
- }
- }, {
- key: "onLegendHovered",
- value: function onLegendHovered(e) {
- var w = this.w;
- var hoverOverLegend = e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker');
- if (w.config.chart.type !== 'heatmap' && !this.isBarsDistributed) {
- if (!e.target.classList.contains('apexcharts-inactive-legend') && hoverOverLegend) {
- var series = new Series(this.ctx);
- series.toggleSeriesOnHover(e, e.target);
- }
- } else {
-
- if (hoverOverLegend) {
- var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
- this.ctx.events.fireEvent('legendHover', [this.ctx, seriesCnt, this.w]);
- var _series = new Series(this.ctx);
- _series.highlightRangeInSeries(e, e.target);
- }
- }
- }
- }, {
- key: "onLegendClick",
- value: function onLegendClick(e) {
- if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker')) {
- var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
- var isHidden = e.target.getAttribute('data:collapsed') === 'true';
- var legendClick = this.w.config.chart.events.legendClick;
- if (typeof legendClick === 'function') {
- legendClick(this.ctx, seriesCnt, this.w);
- }
- this.ctx.events.fireEvent('legendClick', [this.ctx, seriesCnt, this.w]);
- var markerClick = this.w.config.legend.markers.onClick;
- if (typeof markerClick === 'function' && e.target.classList.contains('apexcharts-legend-marker')) {
- markerClick(this.ctx, seriesCnt, this.w);
- this.ctx.events.fireEvent('legendMarkerClick', [this.ctx, seriesCnt, this.w]);
- }
- this.legendHelpers.toggleDataSeries(seriesCnt, isHidden);
- }
- }
- }]);
- return Legend;
- }();
- var icoPan = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"#000000\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <defs>\n <path d=\"M0 0h24v24H0z\" id=\"a\"/>\n </defs>\n <clipPath id=\"b\">\n <use overflow=\"visible\" xlink:href=\"#a\"/>\n </clipPath>\n <path clip-path=\"url(#b)\" d=\"M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z\"/>\n</svg>";
- var icoZoom = "<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"#000000\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\">\n <path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\"/>\n <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n <path d=\"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z\"/>\n</svg>";
- var icoReset = "<svg fill=\"#000000\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\"/>\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n</svg>";
- var icoZoomIn = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\"/>\n</svg>\n";
- var icoZoomOut = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\"/>\n</svg>\n";
- var icoSelect = "<svg fill=\"#6E8192\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2z\"/>\n</svg>";
- var icoMenu = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z\"/></svg>";
-
- var Toolbar = function () {
- function Toolbar(ctx) {
- _classCallCheck(this, Toolbar);
- this.ctx = ctx;
- this.w = ctx.w;
- this.ev = this.w.config.chart.events;
- this.selectedClass = 'apexcharts-selected';
- this.localeValues = this.w.globals.locale.toolbar;
- }
- _createClass(Toolbar, [{
- key: "createToolbar",
- value: function createToolbar() {
- var _this = this;
- var w = this.w;
- var createDiv = function createDiv() {
- return document.createElement('div');
- };
- var elToolbarWrap = createDiv();
- elToolbarWrap.setAttribute('class', 'apexcharts-toolbar');
- elToolbarWrap.style.top = w.config.chart.toolbar.offsetY + 'px';
- elToolbarWrap.style.right = -w.config.chart.toolbar.offsetX + 3 + 'px';
- w.globals.dom.elWrap.appendChild(elToolbarWrap);
- this.elZoom = createDiv();
- this.elZoomIn = createDiv();
- this.elZoomOut = createDiv();
- this.elPan = createDiv();
- this.elSelection = createDiv();
- this.elZoomReset = createDiv();
- this.elMenuIcon = createDiv();
- this.elMenu = createDiv();
- this.elCustomIcons = [];
- this.t = w.config.chart.toolbar.tools;
- if (Array.isArray(this.t.customIcons)) {
- for (var i = 0; i < this.t.customIcons.length; i++) {
- this.elCustomIcons.push(createDiv());
- }
- }
- var toolbarControls = [];
- var appendZoomControl = function appendZoomControl(type, el, ico) {
- var tool = type.toLowerCase();
- if (_this.t[tool] && w.config.chart.zoom.enabled) {
- toolbarControls.push({
- el: el,
- icon: typeof _this.t[tool] === 'string' ? _this.t[tool] : ico,
- title: _this.localeValues[type],
- class: "apexcharts-".concat(tool, "-icon")
- });
- }
- };
- appendZoomControl('zoomIn', this.elZoomIn, icoZoomIn);
- appendZoomControl('zoomOut', this.elZoomOut, icoZoomOut);
- var zoomSelectionCtrls = function zoomSelectionCtrls(z) {
- if (_this.t[z] && w.config.chart[z].enabled) {
- toolbarControls.push({
- el: z === 'zoom' ? _this.elZoom : _this.elSelection,
- icon: typeof _this.t[z] === 'string' ? _this.t[z] : z === 'zoom' ? icoZoom : icoSelect,
- title: _this.localeValues[z === 'zoom' ? 'selectionZoom' : 'selection'],
- class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : "apexcharts-".concat(z, "-icon")
- });
- }
- };
- zoomSelectionCtrls('zoom');
- zoomSelectionCtrls('selection');
- if (this.t.pan && w.config.chart.zoom.enabled) {
- toolbarControls.push({
- el: this.elPan,
- icon: typeof this.t.pan === 'string' ? this.t.pan : icoPan,
- title: this.localeValues.pan,
- class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : 'apexcharts-pan-icon'
- });
- }
- appendZoomControl('reset', this.elZoomReset, icoReset);
- if (this.t.download) {
- toolbarControls.push({
- el: this.elMenuIcon,
- icon: typeof this.t.download === 'string' ? this.t.download : icoMenu,
- title: this.localeValues.menu,
- class: 'apexcharts-menu-icon'
- });
- }
- for (var _i = 0; _i < this.elCustomIcons.length; _i++) {
- toolbarControls.push({
- el: this.elCustomIcons[_i],
- icon: this.t.customIcons[_i].icon,
- title: this.t.customIcons[_i].title,
- index: this.t.customIcons[_i].index,
- class: 'apexcharts-toolbar-custom-icon ' + this.t.customIcons[_i].class
- });
- }
- toolbarControls.forEach(function (t, index) {
- if (t.index) {
- Utils.moveIndexInArray(toolbarControls, index, t.index);
- }
- });
- for (var _i2 = 0; _i2 < toolbarControls.length; _i2++) {
- Graphics.setAttrs(toolbarControls[_i2].el, {
- class: toolbarControls[_i2].class,
- title: toolbarControls[_i2].title
- });
- toolbarControls[_i2].el.innerHTML = toolbarControls[_i2].icon;
- elToolbarWrap.appendChild(toolbarControls[_i2].el);
- }
- this._createHamburgerMenu(elToolbarWrap);
- if (w.globals.zoomEnabled) {
- this.elZoom.classList.add(this.selectedClass);
- } else if (w.globals.panEnabled) {
- this.elPan.classList.add(this.selectedClass);
- } else if (w.globals.selectionEnabled) {
- this.elSelection.classList.add(this.selectedClass);
- }
- this.addToolbarEventListeners();
- }
- }, {
- key: "_createHamburgerMenu",
- value: function _createHamburgerMenu(parent) {
- this.elMenuItems = [];
- parent.appendChild(this.elMenu);
- Graphics.setAttrs(this.elMenu, {
- class: 'apexcharts-menu'
- });
- var menuItems = [{
- name: 'exportSVG',
- title: this.localeValues.exportToSVG
- }, {
- name: 'exportPNG',
- title: this.localeValues.exportToPNG
- }, {
- name: 'exportCSV',
- title: this.localeValues.exportToCSV
- }];
- if (!this.w.globals.allSeriesHasEqualX) {
-
- menuItems.splice(2, 1);
- }
- for (var i = 0; i < menuItems.length; i++) {
- this.elMenuItems.push(document.createElement('div'));
- this.elMenuItems[i].innerHTML = menuItems[i].title;
- Graphics.setAttrs(this.elMenuItems[i], {
- class: "apexcharts-menu-item ".concat(menuItems[i].name),
- title: menuItems[i].title
- });
- this.elMenu.appendChild(this.elMenuItems[i]);
- }
- }
- }, {
- key: "addToolbarEventListeners",
- value: function addToolbarEventListeners() {
- var _this2 = this;
- this.elZoomReset.addEventListener('click', this.handleZoomReset.bind(this));
- this.elSelection.addEventListener('click', this.toggleZoomSelection.bind(this, 'selection'));
- this.elZoom.addEventListener('click', this.toggleZoomSelection.bind(this, 'zoom'));
- this.elZoomIn.addEventListener('click', this.handleZoomIn.bind(this));
- this.elZoomOut.addEventListener('click', this.handleZoomOut.bind(this));
- this.elPan.addEventListener('click', this.togglePanning.bind(this));
- this.elMenuIcon.addEventListener('click', this.toggleMenu.bind(this));
- this.elMenuItems.forEach(function (m) {
- if (m.classList.contains('exportSVG')) {
- m.addEventListener('click', _this2.handleDownload.bind(_this2, 'svg'));
- } else if (m.classList.contains('exportPNG')) {
- m.addEventListener('click', _this2.handleDownload.bind(_this2, 'png'));
- } else if (m.classList.contains('exportCSV')) {
- m.addEventListener('click', _this2.handleDownload.bind(_this2, 'csv'));
- }
- });
- for (var i = 0; i < this.t.customIcons.length; i++) {
- this.elCustomIcons[i].addEventListener('click', this.t.customIcons[i].click.bind(this, this.ctx, this.ctx.w));
- }
- }
- }, {
- key: "toggleZoomSelection",
- value: function toggleZoomSelection(type) {
- this.toggleOtherControls();
- var el = type === 'selection' ? this.elSelection : this.elZoom;
- var enabledType = type === 'selection' ? 'selectionEnabled' : 'zoomEnabled';
- this.w.globals[enabledType] = !this.w.globals[enabledType];
- if (!el.classList.contains(this.selectedClass)) {
- el.classList.add(this.selectedClass);
- } else {
- el.classList.remove(this.selectedClass);
- }
- }
- }, {
- key: "getToolbarIconsReference",
- value: function getToolbarIconsReference() {
- var w = this.w;
- if (!this.elZoom) {
- this.elZoom = w.globals.dom.baseEl.querySelector('.apexcharts-zoom-icon');
- }
- if (!this.elPan) {
- this.elPan = w.globals.dom.baseEl.querySelector('.apexcharts-pan-icon');
- }
- if (!this.elSelection) {
- this.elSelection = w.globals.dom.baseEl.querySelector('.apexcharts-selection-icon');
- }
- }
- }, {
- key: "enableZoomPanFromToolbar",
- value: function enableZoomPanFromToolbar(type) {
- this.toggleOtherControls();
- type === 'pan' ? this.w.globals.panEnabled = true : this.w.globals.zoomEnabled = true;
- var el = type === 'pan' ? this.elPan : this.elZoom;
- var el2 = type === 'pan' ? this.elZoom : this.elPan;
- if (el) {
- el.classList.add(this.selectedClass);
- }
- if (el2) {
- el2.classList.remove(this.selectedClass);
- }
- }
- }, {
- key: "togglePanning",
- value: function togglePanning() {
- this.toggleOtherControls();
- this.w.globals.panEnabled = !this.w.globals.panEnabled;
- if (!this.elPan.classList.contains(this.selectedClass)) {
- this.elPan.classList.add(this.selectedClass);
- } else {
- this.elPan.classList.remove(this.selectedClass);
- }
- }
- }, {
- key: "toggleOtherControls",
- value: function toggleOtherControls() {
- var _this3 = this;
- var w = this.w;
- w.globals.panEnabled = false;
- w.globals.zoomEnabled = false;
- w.globals.selectionEnabled = false;
- this.getToolbarIconsReference();
- var toggleEls = [this.elPan, this.elSelection, this.elZoom];
- toggleEls.forEach(function (el) {
- if (el) {
- el.classList.remove(_this3.selectedClass);
- }
- });
- }
- }, {
- key: "handleZoomIn",
- value: function handleZoomIn() {
- var w = this.w;
- var centerX = (w.globals.minX + w.globals.maxX) / 2;
- var newMinX = (w.globals.minX + centerX) / 2;
- var newMaxX = (w.globals.maxX + centerX) / 2;
- var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
- if (!w.globals.disableZoomIn) {
- this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
- }
- }
- }, {
- key: "handleZoomOut",
- value: function handleZoomOut() {
- var w = this.w;
- if (w.config.xaxis.type === 'datetime' && new Date(w.globals.minX).getUTCFullYear() < 1000) {
- return;
- }
- var centerX = (w.globals.minX + w.globals.maxX) / 2;
- var newMinX = w.globals.minX - (centerX - w.globals.minX);
- var newMaxX = w.globals.maxX - (centerX - w.globals.maxX);
- var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
- if (!w.globals.disableZoomOut) {
- this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
- }
- }
- }, {
- key: "_getNewMinXMaxX",
- value: function _getNewMinXMaxX(newMinX, newMaxX) {
- var shouldFloor = this.w.config.xaxis.convertedCatToNumeric;
- return {
- minX: shouldFloor ? Math.floor(newMinX) : newMinX,
- maxX: shouldFloor ? Math.floor(newMaxX) : newMaxX
- };
- }
- }, {
- key: "zoomUpdateOptions",
- value: function zoomUpdateOptions(newMinX, newMaxX) {
- var w = this.w;
- if (w.config.xaxis.convertedCatToNumeric) {
-
- if (newMinX < 1) {
- newMinX = 1;
- newMaxX = w.globals.dataPoints;
- }
- if (newMaxX - newMinX < 2) {
- return;
- }
- }
- var xaxis = {
- min: newMinX,
- max: newMaxX
- };
- var beforeZoomRange = this.getBeforeZoomRange(xaxis);
- if (beforeZoomRange) {
- xaxis = beforeZoomRange.xaxis;
- }
- var options = {
- xaxis: xaxis
- };
- var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
- if (w.config.chart.zoom.autoScaleYaxis) {
- var scale = new Range(this.ctx);
- yaxis = scale.autoScaleY(this.ctx, yaxis, {
- xaxis: xaxis
- });
- }
- if (!w.config.chart.group) {
-
-
- options.yaxis = yaxis;
- }
- this.w.globals.zoomed = true;
- this.ctx.updateHelpers._updateOptions(options, false, this.w.config.chart.animations.dynamicAnimation.enabled);
- this.zoomCallback(xaxis, yaxis);
- }
- }, {
- key: "zoomCallback",
- value: function zoomCallback(xaxis, yaxis) {
- if (typeof this.ev.zoomed === 'function') {
- this.ev.zoomed(this.ctx, {
- xaxis: xaxis,
- yaxis: yaxis
- });
- }
- }
- }, {
- key: "getBeforeZoomRange",
- value: function getBeforeZoomRange(xaxis, yaxis) {
- var newRange = null;
- if (typeof this.ev.beforeZoom === 'function') {
- newRange = this.ev.beforeZoom(this, {
- xaxis: xaxis,
- yaxis: yaxis
- });
- }
- return newRange;
- }
- }, {
- key: "toggleMenu",
- value: function toggleMenu() {
- var _this4 = this;
- window.setTimeout(function () {
- if (_this4.elMenu.classList.contains('apexcharts-menu-open')) {
- _this4.elMenu.classList.remove('apexcharts-menu-open');
- } else {
- _this4.elMenu.classList.add('apexcharts-menu-open');
- }
- }, 0);
- }
- }, {
- key: "handleDownload",
- value: function handleDownload(type) {
- var w = this.w;
- var exprt = new Exports(this.ctx);
- switch (type) {
- case 'svg':
- exprt.exportToSVG(this.ctx);
- break;
- case 'png':
- exprt.exportToPng(this.ctx);
- break;
- case 'csv':
- exprt.exportToCSV({
- series: w.config.series
- });
- break;
- }
- }
- }, {
- key: "handleZoomReset",
- value: function handleZoomReset(e) {
- var _this5 = this;
- var charts = this.ctx.getSyncedCharts();
- charts.forEach(function (ch) {
- var w = ch.w;
- ch.updateHelpers.revertDefaultAxisMinMax();
- if (typeof w.config.chart.events.zoomed === 'function') {
- _this5.zoomCallback({
- min: w.config.xaxis.min,
- max: w.config.xaxis.max
- });
- }
- w.globals.zoomed = false;
- ch.updateHelpers._updateSeries(w.globals.initialSeries, w.config.chart.animations.dynamicAnimation.enabled);
- });
- }
- }, {
- key: "destroy",
- value: function destroy() {
- this.elZoom = null;
- this.elZoomIn = null;
- this.elZoomOut = null;
- this.elPan = null;
- this.elSelection = null;
- this.elZoomReset = null;
- this.elMenuIcon = null;
- }
- }]);
- return Toolbar;
- }();
-
- var ZoomPanSelection = function (_Toolbar) {
- _inherits(ZoomPanSelection, _Toolbar);
- function ZoomPanSelection(ctx) {
- var _this;
- _classCallCheck(this, ZoomPanSelection);
- _this = _possibleConstructorReturn(this, _getPrototypeOf(ZoomPanSelection).call(this, ctx));
- _this.ctx = ctx;
- _this.w = ctx.w;
- _this.dragged = false;
- _this.graphics = new Graphics(_this.ctx);
- _this.eventList = ['mousedown', 'mouseleave', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
- _this.clientX = 0;
- _this.clientY = 0;
- _this.startX = 0;
- _this.endX = 0;
- _this.dragX = 0;
- _this.startY = 0;
- _this.endY = 0;
- _this.dragY = 0;
- _this.moveDirection = 'none';
- return _this;
- }
- _createClass(ZoomPanSelection, [{
- key: "init",
- value: function init(_ref) {
- var _this2 = this;
- var xyRatios = _ref.xyRatios;
- var w = this.w;
- var me = this;
- this.xyRatios = xyRatios;
- this.zoomRect = this.graphics.drawRect(0, 0, 0, 0);
- this.selectionRect = this.graphics.drawRect(0, 0, 0, 0);
- this.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid');
- this.zoomRect.node.classList.add('apexcharts-zoom-rect');
- this.selectionRect.node.classList.add('apexcharts-selection-rect');
- w.globals.dom.elGraphical.add(this.zoomRect);
- w.globals.dom.elGraphical.add(this.selectionRect);
- if (w.config.chart.selection.type === 'x') {
- this.slDraggableRect = this.selectionRect.draggable({
- minX: 0,
- minY: 0,
- maxX: w.globals.gridWidth,
- maxY: w.globals.gridHeight
- }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
- } else if (w.config.chart.selection.type === 'y') {
- this.slDraggableRect = this.selectionRect.draggable({
- minX: 0,
- maxX: w.globals.gridWidth
- }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
- } else {
- this.slDraggableRect = this.selectionRect.draggable().on('dragmove', this.selectionDragging.bind(this, 'dragging'));
- }
- this.preselectedSelection();
- this.hoverArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
- this.hoverArea.classList.add('apexcharts-zoomable');
- this.eventList.forEach(function (event) {
- _this2.hoverArea.addEventListener(event, me.svgMouseEvents.bind(me, xyRatios), {
- capture: false,
- passive: true
- });
- });
- }
- }, {
- key: "destroy",
- value: function destroy() {
- if (this.slDraggableRect) {
- this.slDraggableRect.draggable(false);
- this.slDraggableRect.off();
- this.selectionRect.off();
- }
- this.selectionRect = null;
- this.zoomRect = null;
- this.gridRect = null;
- }
- }, {
- key: "svgMouseEvents",
- value: function svgMouseEvents(xyRatios, e) {
- var w = this.w;
- var me = this;
- var toolbar = this.ctx.toolbar;
- var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type;
- if (e.shiftKey) {
- this.shiftWasPressed = true;
- toolbar.enableZoomPanFromToolbar('pan');
- } else {
- if (this.shiftWasPressed) {
- toolbar.enableZoomPanFromToolbar('zoom');
- this.shiftWasPressed = false;
- }
- }
- var falsePositives = e.target.classList.contains('apexcharts-selection-rect') || e.target.parentNode.classList.contains('apexcharts-toolbar');
- if (falsePositives) return;
- me.clientX = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientX : e.type === 'touchend' ? e.changedTouches[0].clientX : e.clientX;
- me.clientY = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientY : e.type === 'touchend' ? e.changedTouches[0].clientY : e.clientY;
- if (e.type === 'mousedown' && e.which === 1) {
- var gridRectDim = me.gridRect.getBoundingClientRect();
- me.startX = me.clientX - gridRectDim.left;
- me.startY = me.clientY - gridRectDim.top;
- me.dragged = false;
- me.w.globals.mousedown = true;
- }
- if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') {
- me.dragged = true;
- if (w.globals.panEnabled) {
- w.globals.selection = null;
- if (me.w.globals.mousedown) {
- me.panDragging({
- context: me,
- zoomtype: zoomtype,
- xyRatios: xyRatios
- });
- }
- } else {
- if (me.w.globals.mousedown && w.globals.zoomEnabled || me.w.globals.mousedown && w.globals.selectionEnabled) {
- me.selection = me.selectionDrawing({
- context: me,
- zoomtype: zoomtype
- });
- }
- }
- }
- if (e.type === 'mouseup' || e.type === 'touchend' || e.type === 'mouseleave') {
-
- var _gridRectDim = me.gridRect.getBoundingClientRect();
- if (me.w.globals.mousedown) {
-
- me.endX = me.clientX - _gridRectDim.left;
- me.endY = me.clientY - _gridRectDim.top;
- me.dragX = Math.abs(me.endX - me.startX);
- me.dragY = Math.abs(me.endY - me.startY);
- if (w.globals.zoomEnabled || w.globals.selectionEnabled) {
- me.selectionDrawn({
- context: me,
- zoomtype: zoomtype
- });
- }
- if (w.globals.panEnabled && w.config.xaxis.convertedCatToNumeric) {
- me.delayedPanScrolled();
- }
- }
- if (w.globals.zoomEnabled) {
- me.hideSelectionRect(this.selectionRect);
- }
- me.dragged = false;
- me.w.globals.mousedown = false;
- }
- this.makeSelectionRectDraggable();
- }
- }, {
- key: "makeSelectionRectDraggable",
- value: function makeSelectionRectDraggable() {
- var w = this.w;
- if (!this.selectionRect) return;
- var rectDim = this.selectionRect.node.getBoundingClientRect();
- if (rectDim.width > 0 && rectDim.height > 0) {
- this.slDraggableRect.selectize({
- points: 'l, r',
- pointSize: 8,
- pointType: 'rect'
- }).resize({
- constraint: {
- minX: 0,
- minY: 0,
- maxX: w.globals.gridWidth,
- maxY: w.globals.gridHeight
- }
- }).on('resizing', this.selectionDragging.bind(this, 'resizing'));
- }
- }
- }, {
- key: "preselectedSelection",
- value: function preselectedSelection() {
- var w = this.w;
- var xyRatios = this.xyRatios;
- if (!w.globals.zoomEnabled) {
- if (typeof w.globals.selection !== 'undefined' && w.globals.selection !== null) {
- this.drawSelectionRect(w.globals.selection);
- } else {
- if (w.config.chart.selection.xaxis.min !== undefined && w.config.chart.selection.xaxis.max !== undefined) {
- var x = (w.config.chart.selection.xaxis.min - w.globals.minX) / xyRatios.xRatio;
- var width = w.globals.gridWidth - (w.globals.maxX - w.config.chart.selection.xaxis.max) / xyRatios.xRatio - x;
- var selectionRect = {
- x: x,
- y: 0,
- width: width,
- height: w.globals.gridHeight,
- translateX: 0,
- translateY: 0,
- selectionEnabled: true
- };
- this.drawSelectionRect(selectionRect);
- this.makeSelectionRectDraggable();
- if (typeof w.config.chart.events.selection === 'function') {
- w.config.chart.events.selection(this.ctx, {
- xaxis: {
- min: w.config.chart.selection.xaxis.min,
- max: w.config.chart.selection.xaxis.max
- },
- yaxis: {}
- });
- }
- }
- }
- }
- }
- }, {
- key: "drawSelectionRect",
- value: function drawSelectionRect(_ref2) {
- var x = _ref2.x,
- y = _ref2.y,
- width = _ref2.width,
- height = _ref2.height,
- translateX = _ref2.translateX,
- translateY = _ref2.translateY;
- var w = this.w;
- var zoomRect = this.zoomRect;
- var selectionRect = this.selectionRect;
- if (this.dragged || w.globals.selection !== null) {
- var scalingAttrs = {
- transform: 'translate(' + translateX + ', ' + translateY + ')'
- };
-
- if (w.globals.zoomEnabled && this.dragged) {
- if (width < 0) width = 1;
- zoomRect.attr({
- x: x,
- y: y,
- width: width,
- height: height,
- fill: w.config.chart.zoom.zoomedArea.fill.color,
- 'fill-opacity': w.config.chart.zoom.zoomedArea.fill.opacity,
- stroke: w.config.chart.zoom.zoomedArea.stroke.color,
- 'stroke-width': w.config.chart.zoom.zoomedArea.stroke.width,
- 'stroke-opacity': w.config.chart.zoom.zoomedArea.stroke.opacity
- });
- Graphics.setAttrs(zoomRect.node, scalingAttrs);
- }
- if (w.globals.selectionEnabled) {
- selectionRect.attr({
- x: x,
- y: y,
- width: width > 0 ? width : 0,
- height: height > 0 ? height : 0,
- fill: w.config.chart.selection.fill.color,
- 'fill-opacity': w.config.chart.selection.fill.opacity,
- stroke: w.config.chart.selection.stroke.color,
- 'stroke-width': w.config.chart.selection.stroke.width,
- 'stroke-dasharray': w.config.chart.selection.stroke.dashArray,
- 'stroke-opacity': w.config.chart.selection.stroke.opacity
- });
- Graphics.setAttrs(selectionRect.node, scalingAttrs);
- }
- }
- }
- }, {
- key: "hideSelectionRect",
- value: function hideSelectionRect(rect) {
- if (rect) {
- rect.attr({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- });
- }
- }
- }, {
- key: "selectionDrawing",
- value: function selectionDrawing(_ref3) {
- var context = _ref3.context,
- zoomtype = _ref3.zoomtype;
- var w = this.w;
- var me = context;
- var gridRectDim = this.gridRect.getBoundingClientRect();
- var startX = me.startX - 1;
- var startY = me.startY;
- var selectionWidth = me.clientX - gridRectDim.left - startX;
- var selectionHeight = me.clientY - gridRectDim.top - startY;
- var translateX = 0;
- var translateY = 0;
- var selectionRect = {};
- if (Math.abs(selectionWidth + startX) > w.globals.gridWidth) {
-
- selectionWidth = w.globals.gridWidth - startX;
- } else if (me.clientX - gridRectDim.left < 0) {
-
- selectionWidth = startX;
- }
- if (startX > me.clientX - gridRectDim.left) {
- selectionWidth = Math.abs(selectionWidth);
- translateX = -selectionWidth;
- }
- if (startY > me.clientY - gridRectDim.top) {
- selectionHeight = Math.abs(selectionHeight);
- translateY = -selectionHeight;
- }
- if (zoomtype === 'x') {
- selectionRect = {
- x: startX,
- y: 0,
- width: selectionWidth,
- height: w.globals.gridHeight,
- translateX: translateX,
- translateY: 0
- };
- } else if (zoomtype === 'y') {
- selectionRect = {
- x: 0,
- y: startY,
- width: w.globals.gridWidth,
- height: selectionHeight,
- translateX: 0,
- translateY: translateY
- };
- } else {
- selectionRect = {
- x: startX,
- y: startY,
- width: selectionWidth,
- height: selectionHeight,
- translateX: translateX,
- translateY: translateY
- };
- }
- me.drawSelectionRect(selectionRect);
- me.selectionDragging('resizing');
- return selectionRect;
- }
- }, {
- key: "selectionDragging",
- value: function selectionDragging(type, e) {
- var _this3 = this;
- var w = this.w;
- var xyRatios = this.xyRatios;
- var selRect = this.selectionRect;
- var timerInterval = 0;
- if (type === 'resizing') {
- timerInterval = 30;
- }
- if (typeof w.config.chart.events.selection === 'function' && w.globals.selectionEnabled) {
-
- clearTimeout(this.w.globals.selectionResizeTimer);
- this.w.globals.selectionResizeTimer = window.setTimeout(function () {
- var gridRectDim = _this3.gridRect.getBoundingClientRect();
- var selectionRect = selRect.node.getBoundingClientRect();
- var minX = w.globals.xAxisScale.niceMin + (selectionRect.left - gridRectDim.left) * xyRatios.xRatio;
- var maxX = w.globals.xAxisScale.niceMin + (selectionRect.right - gridRectDim.left) * xyRatios.xRatio;
- var minY = w.globals.yAxisScale[0].niceMin + (gridRectDim.bottom - selectionRect.bottom) * xyRatios.yRatio[0];
- var maxY = w.globals.yAxisScale[0].niceMax - (selectionRect.top - gridRectDim.top) * xyRatios.yRatio[0];
- w.config.chart.events.selection(_this3.ctx, {
- xaxis: {
- min: minX,
- max: maxX
- },
- yaxis: {
- min: minY,
- max: maxY
- }
- });
- }, timerInterval);
- }
- }
- }, {
- key: "selectionDrawn",
- value: function selectionDrawn(_ref4) {
- var context = _ref4.context,
- zoomtype = _ref4.zoomtype;
- var w = this.w;
- var me = context;
- var xyRatios = this.xyRatios;
- var toolbar = this.ctx.toolbar;
- if (me.startX > me.endX) {
- var tempX = me.startX;
- me.startX = me.endX;
- me.endX = tempX;
- }
- if (me.startY > me.endY) {
- var tempY = me.startY;
- me.startY = me.endY;
- me.endY = tempY;
- }
- var xLowestValue = w.globals.xAxisScale.niceMin + me.startX * xyRatios.xRatio;
- var xHighestValue = w.globals.xAxisScale.niceMin + me.endX * xyRatios.xRatio;
- var yHighestValue = [];
- var yLowestValue = [];
- w.config.yaxis.forEach(function (yaxe, index) {
- yHighestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.startY);
- yLowestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.endY);
- });
- if (me.dragged && (me.dragX > 10 || me.dragY > 10) && xLowestValue !== xHighestValue) {
- if (w.globals.zoomEnabled) {
- var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
- var xaxis = Utils.clone(w.globals.initialConfig.xaxis);
- w.globals.zoomed = true;
-
-
- if (!w.globals.zoomed) {
- w.globals.lastXAxis = Utils.clone(w.config.xaxis);
- w.globals.lastYAxis = Utils.clone(w.config.yaxis);
- }
- if (w.config.xaxis.convertedCatToNumeric) {
- xLowestValue = Math.floor(xLowestValue);
- xHighestValue = Math.floor(xHighestValue);
- if (xLowestValue < 1) {
- xLowestValue = 1;
- xHighestValue = w.globals.dataPoints;
- }
- if (xHighestValue - xLowestValue < 2) {
- xHighestValue = xLowestValue + 1;
- }
- }
- if (zoomtype === 'xy' || zoomtype === 'x') {
- xaxis = {
- min: xLowestValue,
- max: xHighestValue
- };
- }
- if (zoomtype === 'xy' || zoomtype === 'y') {
- yaxis.forEach(function (yaxe, index) {
- yaxis[index].min = yLowestValue[index];
- yaxis[index].max = yHighestValue[index];
- });
- }
- if (w.config.chart.zoom.autoScaleYaxis) {
- var scale = new Range(me.ctx);
- yaxis = scale.autoScaleY(me.ctx, yaxis, {
- xaxis: xaxis
- });
- }
- if (toolbar) {
- var beforeZoomRange = toolbar.getBeforeZoomRange(xaxis, yaxis);
- if (beforeZoomRange) {
- xaxis = beforeZoomRange.xaxis ? beforeZoomRange.xaxis : xaxis;
- yaxis = beforeZoomRange.yaxis ? beforeZoomRange.yaxe : yaxis;
- }
- }
- var options = {
- xaxis: xaxis
- };
- if (!w.config.chart.group) {
-
-
- options.yaxis = yaxis;
- }
- me.ctx.updateHelpers._updateOptions(options, false, me.w.config.chart.animations.dynamicAnimation.enabled);
- if (typeof w.config.chart.events.zoomed === 'function') {
- toolbar.zoomCallback(xaxis, yaxis);
- }
- } else if (w.globals.selectionEnabled) {
- var _yaxis = null;
- var _xaxis = null;
- _xaxis = {
- min: xLowestValue,
- max: xHighestValue
- };
- if (zoomtype === 'xy' || zoomtype === 'y') {
- _yaxis = Utils.clone(w.config.yaxis);
- _yaxis.forEach(function (yaxe, index) {
- _yaxis[index].min = yLowestValue[index];
- _yaxis[index].max = yHighestValue[index];
- });
- }
- w.globals.selection = me.selection;
- if (typeof w.config.chart.events.selection === 'function') {
- w.config.chart.events.selection(me.ctx, {
- xaxis: _xaxis,
- yaxis: _yaxis
- });
- }
- }
- }
- }
- }, {
- key: "panDragging",
- value: function panDragging(_ref5) {
- var context = _ref5.context;
- var w = this.w;
- var me = context;
- if (typeof w.globals.lastClientPosition.x !== 'undefined') {
-
- var deltaX = w.globals.lastClientPosition.x - me.clientX;
- var deltaY = w.globals.lastClientPosition.y - me.clientY;
- if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) {
- this.moveDirection = 'left';
- } else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) {
- this.moveDirection = 'right';
- } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
- this.moveDirection = 'up';
- } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) {
- this.moveDirection = 'down';
- }
- }
- w.globals.lastClientPosition = {
- x: me.clientX,
- y: me.clientY
- };
- var xLowestValue = w.globals.minX;
- var xHighestValue = w.globals.maxX;
- if (!w.config.xaxis.convertedCatToNumeric) {
- me.panScrolled(xLowestValue, xHighestValue);
- }
- }
- }, {
- key: "delayedPanScrolled",
- value: function delayedPanScrolled() {
- var w = this.w;
- var newMinX = w.globals.minX;
- var newMaxX = w.globals.maxX;
- var centerX = (w.globals.maxX - w.globals.minX) / 2;
- if (this.moveDirection === 'left') {
- newMinX = w.globals.minX + centerX;
- newMaxX = w.globals.maxX + centerX;
- } else if (this.moveDirection === 'right') {
- newMinX = w.globals.minX - centerX;
- newMaxX = w.globals.maxX - centerX;
- }
- newMinX = Math.floor(newMinX);
- newMaxX = Math.floor(newMaxX);
- this.updateScrolledChart({
- xaxis: {
- min: newMinX,
- max: newMaxX
- }
- }, newMinX, newMaxX);
- }
- }, {
- key: "panScrolled",
- value: function panScrolled(xLowestValue, xHighestValue) {
- var w = this.w;
- var xyRatios = this.xyRatios;
- var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
- if (this.moveDirection === 'left') {
- xLowestValue = w.globals.minX + w.globals.gridWidth / 15 * xyRatios.xRatio;
- xHighestValue = w.globals.maxX + w.globals.gridWidth / 15 * xyRatios.xRatio;
- } else if (this.moveDirection === 'right') {
- xLowestValue = w.globals.minX - w.globals.gridWidth / 15 * xyRatios.xRatio;
- xHighestValue = w.globals.maxX - w.globals.gridWidth / 15 * xyRatios.xRatio;
- }
- if (xLowestValue < w.globals.initialMinX || xHighestValue > w.globals.initialMaxX) {
- xLowestValue = w.globals.minX;
- xHighestValue = w.globals.maxX;
- }
- var xaxis = {
- min: xLowestValue,
- max: xHighestValue
- };
- if (w.config.chart.zoom.autoScaleYaxis) {
- var scale = new Range(this.ctx);
- yaxis = scale.autoScaleY(this.ctx, yaxis, {
- xaxis: xaxis
- });
- }
- var options = {
- xaxis: {
- min: xLowestValue,
- max: xHighestValue
- }
- };
- if (!w.config.chart.group) {
-
-
- options.yaxis = yaxis;
- }
- this.updateScrolledChart(options, xLowestValue, xHighestValue);
- }
- }, {
- key: "updateScrolledChart",
- value: function updateScrolledChart(options, xLowestValue, xHighestValue) {
- var w = this.w;
- this.ctx.updateHelpers._updateOptions(options, false, false);
- if (typeof w.config.chart.events.scrolled === 'function') {
- w.config.chart.events.scrolled(this.ctx, {
- xaxis: {
- min: xLowestValue,
- max: xHighestValue
- }
- });
- }
- }
- }]);
- return ZoomPanSelection;
- }(Toolbar);
- var Utils$1 = function () {
- function Utils$1(tooltipContext) {
- _classCallCheck(this, Utils$1);
- this.w = tooltipContext.w;
- this.ttCtx = tooltipContext;
- this.ctx = tooltipContext.ctx;
- }
-
- _createClass(Utils$1, [{
- key: "getNearestValues",
- value: function getNearestValues(_ref) {
- var hoverArea = _ref.hoverArea,
- elGrid = _ref.elGrid,
- clientX = _ref.clientX,
- clientY = _ref.clientY;
- var w = this.w;
- var hoverWidth = w.globals.gridWidth;
- var xDivisor = hoverWidth / (w.globals.dataPoints - 1);
- var seriesBound = elGrid.getBoundingClientRect();
- var hasBars = this.hasBars();
- if (w.globals.comboCharts || hasBars) {
- xDivisor = hoverWidth / w.globals.dataPoints;
- }
- var hoverX = clientX - seriesBound.left;
- var hoverY = clientY - seriesBound.top;
- var notInRect = hoverX < 0 || hoverY < 0 || hoverX > w.globals.gridWidth || hoverY > w.globals.gridHeight;
- if (notInRect) {
- hoverArea.classList.remove('hovering-zoom');
- hoverArea.classList.remove('hovering-pan');
- } else {
- if (w.globals.zoomEnabled) {
- hoverArea.classList.remove('hovering-pan');
- hoverArea.classList.add('hovering-zoom');
- } else if (w.globals.panEnabled) {
- hoverArea.classList.remove('hovering-zoom');
- hoverArea.classList.add('hovering-pan');
- }
- }
- var j = Math.round(hoverX / xDivisor);
- if (hasBars) {
- j = Math.ceil(hoverX / xDivisor);
- j = j - 1;
- }
- var capturedSeries = null;
- var closest = null;
- var seriesXValArr = [];
- var seriesYValArr = [];
- for (var s = 0; s < w.globals.seriesXvalues.length; s++) {
- seriesXValArr.push([w.globals.seriesXvalues[s][0] - 0.000001].concat(w.globals.seriesXvalues[s]));
- }
- seriesXValArr = seriesXValArr.map(function (seriesXVal) {
- return seriesXVal.filter(function (s) {
- return s;
- });
- });
- seriesYValArr = w.globals.seriesYvalues.map(function (seriesYVal) {
- return seriesYVal.filter(function (s) {
- return Utils.isNumber(s);
- });
- });
- if (w.globals.isXNumeric) {
- closest = this.closestInMultiArray(hoverX, hoverY, seriesXValArr, seriesYValArr);
- capturedSeries = closest.index;
- j = closest.j;
- if (capturedSeries !== null) {
-
- seriesXValArr = w.globals.seriesXvalues[capturedSeries];
- closest = this.closestInArray(hoverX, seriesXValArr);
- j = closest.index;
- }
- }
- w.globals.capturedSeriesIndex = capturedSeries === null ? -1 : capturedSeries;
- if (!j || j < 1) j = 0;
- w.globals.capturedDataPointIndex = j;
- return {
- capturedSeries: capturedSeries,
- j: j,
- hoverX: hoverX,
- hoverY: hoverY
- };
- }
- }, {
- key: "closestInMultiArray",
- value: function closestInMultiArray(hoverX, hoverY, Xarrays, Yarrays) {
- var w = this.w;
- var activeIndex = 0;
- var currIndex = null;
- var j = -1;
- if (w.globals.series.length > 1) {
- activeIndex = this.getFirstActiveXArray(Xarrays);
- } else {
- currIndex = 0;
- }
- var currY = Yarrays[activeIndex][0];
- var currX = Xarrays[activeIndex][0];
- var diffX = Math.abs(hoverX - currX);
- var diffY = Math.abs(hoverY - currY);
- var diff = diffY + diffX;
- Yarrays.map(function (arrY, arrIndex) {
- arrY.map(function (y, innerKey) {
- var newdiffY = Math.abs(hoverY - Yarrays[arrIndex][innerKey]);
- var newdiffX = Math.abs(hoverX - Xarrays[arrIndex][innerKey]);
- var newdiff = newdiffX + newdiffY;
- if (newdiff < diff) {
- diff = newdiff;
- diffX = newdiffX;
- diffY = newdiffY;
- currIndex = arrIndex;
- j = innerKey;
- }
- });
- });
- return {
- index: currIndex,
- j: j
- };
- }
- }, {
- key: "getFirstActiveXArray",
- value: function getFirstActiveXArray(Xarrays) {
- var activeIndex = 0;
- var coreUtils = new CoreUtils(this.ctx);
- var firstActiveSeriesIndex = Xarrays.map(function (xarr, index) {
- return xarr.length > 0 ? index : -1;
- });
- for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
- var total = coreUtils.getSeriesTotalByIndex(a);
- if (firstActiveSeriesIndex[a] !== -1 && total !== 0 && !coreUtils.seriesHaveSameValues(a)) {
- activeIndex = firstActiveSeriesIndex[a];
- break;
- }
- }
- return activeIndex;
- }
- }, {
- key: "closestInArray",
- value: function closestInArray(val, arr) {
- var curr = arr[0];
- var currIndex = null;
- var diff = Math.abs(val - curr);
- for (var i = 0; i < arr.length; i++) {
- var newdiff = Math.abs(val - arr[i]);
- if (newdiff < diff) {
- diff = newdiff;
- currIndex = i;
- }
- }
- return {
- index: currIndex
- };
- }
-
- }, {
- key: "isXoverlap",
- value: function isXoverlap(j) {
- var w = this.w;
- var xSameForAllSeriesJArr = [];
- var seriesX = w.globals.seriesX.filter(function (s) {
- return typeof s[0] !== 'undefined';
- });
- if (seriesX.length > 0) {
- for (var i = 0; i < seriesX.length - 1; i++) {
- if (typeof seriesX[i][j] !== 'undefined' && typeof seriesX[i + 1][j] !== 'undefined') {
- if (seriesX[i][j] !== seriesX[i + 1][j]) {
- xSameForAllSeriesJArr.push('unEqual');
- }
- }
- }
- }
- if (xSameForAllSeriesJArr.length === 0) {
- return true;
- }
- return false;
- }
- }, {
- key: "isInitialSeriesSameLen",
- value: function isInitialSeriesSameLen() {
- var sameLen = true;
- var initialSeries = this.w.globals.initialSeries;
- for (var i = 0; i < initialSeries.length - 1; i++) {
- if (initialSeries[i].data.length !== initialSeries[i + 1].data.length) {
- sameLen = false;
- break;
- }
- }
- return sameLen;
- }
- }, {
- key: "getBarsHeight",
- value: function getBarsHeight(allbars) {
- var bars = _toConsumableArray(allbars);
- var totalHeight = bars.reduce(function (acc, bar) {
- return acc + bar.getBBox().height;
- }, 0);
- return totalHeight;
- }
- }, {
- key: "getElMarkers",
- value: function getElMarkers() {
- return this.w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers');
- }
- }, {
- key: "getAllMarkers",
- value: function getAllMarkers() {
-
-
- var markersWraps = this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers-wrap');
- markersWraps = _toConsumableArray(markersWraps);
- markersWraps.sort(function (a, b) {
- return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
- });
- var markers = [];
- markersWraps.forEach(function (m) {
- markers.push(m.querySelector('.apexcharts-marker'));
- });
- return markers;
- }
- }, {
- key: "hasMarkers",
- value: function hasMarkers() {
- var markers = this.getElMarkers();
- return markers.length > 0;
- }
- }, {
- key: "getElBars",
- value: function getElBars() {
- return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-rangebar-series');
- }
- }, {
- key: "hasBars",
- value: function hasBars() {
- var bars = this.getElBars();
- return bars.length > 0;
- }
- }, {
- key: "getHoverMarkerSize",
- value: function getHoverMarkerSize(index) {
- var w = this.w;
- var hoverSize = w.config.markers.hover.size;
- if (hoverSize === undefined) {
- hoverSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
- }
- return hoverSize;
- }
- }, {
- key: "toggleAllTooltipSeriesGroups",
- value: function toggleAllTooltipSeriesGroups(state) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- if (ttCtx.allTooltipSeriesGroups.length === 0) {
- ttCtx.allTooltipSeriesGroups = w.globals.dom.baseEl.querySelectorAll('.apexcharts-tooltip-series-group');
- }
- var allTooltipSeriesGroups = ttCtx.allTooltipSeriesGroups;
- for (var i = 0; i < allTooltipSeriesGroups.length; i++) {
- if (state === 'enable') {
- allTooltipSeriesGroups[i].classList.add('apexcharts-active');
- allTooltipSeriesGroups[i].style.display = w.config.tooltip.items.display;
- } else {
- allTooltipSeriesGroups[i].classList.remove('apexcharts-active');
- allTooltipSeriesGroups[i].style.display = 'none';
- }
- }
- }
- }]);
- return Utils$1;
- }();
-
- var Labels = function () {
- function Labels(tooltipContext) {
- _classCallCheck(this, Labels);
- this.w = tooltipContext.w;
- this.ctx = tooltipContext.ctx;
- this.ttCtx = tooltipContext;
- this.tooltipUtil = new Utils$1(tooltipContext);
- }
- _createClass(Labels, [{
- key: "drawSeriesTexts",
- value: function drawSeriesTexts(_ref) {
- var _ref$shared = _ref.shared,
- shared = _ref$shared === void 0 ? true : _ref$shared,
- ttItems = _ref.ttItems,
- _ref$i = _ref.i,
- i = _ref$i === void 0 ? 0 : _ref$i,
- _ref$j = _ref.j,
- j = _ref$j === void 0 ? null : _ref$j,
- y1 = _ref.y1,
- y2 = _ref.y2;
- var w = this.w;
- if (w.config.tooltip.custom !== undefined) {
- this.handleCustomTooltip({
- i: i,
- j: j,
- y1: y1,
- y2: y2,
- w: w
- });
- } else {
- this.toggleActiveInactiveSeries(shared);
- }
- var values = this.getValuesToPrint({
- i: i,
- j: j
- });
- this.printLabels({
- i: i,
- j: j,
- values: values,
- ttItems: ttItems,
- shared: shared
- });
- var tooltipEl = this.ttCtx.getElTooltip();
- this.ttCtx.tooltipRect.ttWidth = tooltipEl.getBoundingClientRect().width;
- this.ttCtx.tooltipRect.ttHeight = tooltipEl.getBoundingClientRect().height;
- }
- }, {
- key: "printLabels",
- value: function printLabels(_ref2) {
- var _this = this;
- var i = _ref2.i,
- j = _ref2.j,
- values = _ref2.values,
- ttItems = _ref2.ttItems,
- shared = _ref2.shared;
- var w = this.w;
- var val;
- var xVal = values.xVal,
- zVal = values.zVal,
- xAxisTTVal = values.xAxisTTVal;
- var seriesName = '';
- var pColor = w.globals.colors[i];
- if (j !== null && w.config.plotOptions.bar.distributed) {
- pColor = w.globals.colors[j];
- }
- var _loop = function _loop(t, inverset) {
- var f = _this.getFormatters(i);
- seriesName = _this.getSeriesName({
- fn: f.yLbTitleFormatter,
- index: i,
- seriesIndex: i,
- j: j
- });
- var tIndex = w.config.tooltip.inverseOrder ? inverset : t;
- if (w.globals.axisCharts) {
- var generalFormatter = function generalFormatter(index) {
- return f.yLbFormatter(w.globals.series[index][j], {
- series: w.globals.series,
- seriesIndex: index,
- dataPointIndex: j,
- w: w
- });
- };
- if (shared) {
- f = _this.getFormatters(tIndex);
- seriesName = _this.getSeriesName({
- fn: f.yLbTitleFormatter,
- index: tIndex,
- seriesIndex: i,
- j: j
- });
- pColor = w.globals.colors[tIndex];
- val = generalFormatter(tIndex);
- } else {
- val = generalFormatter(i);
- }
- }
- if (j === null) {
- val = f.yLbFormatter(w.globals.series[i], w);
- }
- _this.DOMHandling({
- i: i,
- t: tIndex,
- j: j,
- ttItems: ttItems,
- values: {
- val: val,
- xVal: xVal,
- xAxisTTVal: xAxisTTVal,
- zVal: zVal
- },
- seriesName: seriesName,
- shared: shared,
- pColor: pColor
- });
- };
- for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) {
- _loop(t, inverset);
- }
- }
- }, {
- key: "getFormatters",
- value: function getFormatters(i) {
- var w = this.w;
- var yLbFormatter = w.globals.yLabelFormatters[i];
- var yLbTitleFormatter;
- if (w.globals.ttVal !== undefined) {
- if (Array.isArray(w.globals.ttVal)) {
- yLbFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].formatter;
- yLbTitleFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].title && w.globals.ttVal[i].title.formatter;
- } else {
- yLbFormatter = w.globals.ttVal.formatter;
- if (typeof w.globals.ttVal.title.formatter === 'function') {
- yLbTitleFormatter = w.globals.ttVal.title.formatter;
- }
- }
- } else {
- yLbTitleFormatter = w.config.tooltip.y.title.formatter;
- }
- if (typeof yLbFormatter !== 'function') {
- if (w.globals.yLabelFormatters[0]) {
- yLbFormatter = w.globals.yLabelFormatters[0];
- } else {
- yLbFormatter = function yLbFormatter(label) {
- return label;
- };
- }
- }
- if (typeof yLbTitleFormatter !== 'function') {
- yLbTitleFormatter = function yLbTitleFormatter(label) {
- return label;
- };
- }
- return {
- yLbFormatter: yLbFormatter,
- yLbTitleFormatter: yLbTitleFormatter
- };
- }
- }, {
- key: "getSeriesName",
- value: function getSeriesName(_ref3) {
- var fn = _ref3.fn,
- index = _ref3.index,
- seriesIndex = _ref3.seriesIndex,
- j = _ref3.j;
- var w = this.w;
- return fn(String(w.globals.seriesNames[index]), {
- series: w.globals.series,
- seriesIndex: seriesIndex,
- dataPointIndex: j,
- w: w
- });
- }
- }, {
- key: "DOMHandling",
- value: function DOMHandling(_ref4) {
- var i = _ref4.i,
- t = _ref4.t,
- j = _ref4.j,
- ttItems = _ref4.ttItems,
- values = _ref4.values,
- seriesName = _ref4.seriesName,
- shared = _ref4.shared,
- pColor = _ref4.pColor;
- var w = this.w;
- var ttCtx = this.ttCtx;
- var val = values.val,
- xVal = values.xVal,
- xAxisTTVal = values.xAxisTTVal,
- zVal = values.zVal;
- var ttItemsChildren = null;
- ttItemsChildren = ttItems[t].children;
- if (w.config.tooltip.fillSeriesColor) {
-
- ttItems[t].style.backgroundColor = pColor;
- ttItemsChildren[0].style.display = 'none';
- }
- if (ttCtx.showTooltipTitle) {
- if (ttCtx.tooltipTitle === null) {
-
- ttCtx.tooltipTitle = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-title');
- }
- ttCtx.tooltipTitle.innerHTML = xVal;
- }
- if (ttCtx.blxaxisTooltip) {
- ttCtx.xaxisTooltipText.innerHTML = xAxisTTVal !== '' ? xAxisTTVal : xVal;
- }
- var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-label');
- if (ttYLabel) {
- ttYLabel.innerHTML = seriesName ? seriesName + ': ' : '';
- }
- var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-value');
- if (ttYVal) {
- ttYVal.innerHTML = typeof val !== 'undefined' ? val : '';
- }
- if (ttItemsChildren[0] && ttItemsChildren[0].classList.contains('apexcharts-tooltip-marker')) {
- if (w.config.tooltip.marker.fillColors && Array.isArray(w.config.tooltip.marker.fillColors)) {
- pColor = w.config.tooltip.marker.fillColors[i];
- }
- ttItemsChildren[0].style.backgroundColor = pColor;
- }
- if (!w.config.tooltip.marker.show) {
- ttItemsChildren[0].style.display = 'none';
- }
- if (zVal !== null) {
- var ttZLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-z-label');
- ttZLabel.innerHTML = w.config.tooltip.z.title;
- var ttZVal = ttItems[t].querySelector('.apexcharts-tooltip-text-z-value');
- ttZVal.innerHTML = typeof zVal !== 'undefined' ? zVal : '';
- }
- if (shared && ttItemsChildren[0]) {
-
- if (typeof val === 'undefined' || val === null || w.globals.collapsedSeriesIndices.indexOf(t) > -1) {
- ttItemsChildren[0].parentNode.style.display = 'none';
- } else {
- ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- }, {
- key: "toggleActiveInactiveSeries",
- value: function toggleActiveInactiveSeries(shared) {
- var w = this.w;
- if (shared) {
-
- this.tooltipUtil.toggleAllTooltipSeriesGroups('enable');
- } else {
-
- this.tooltipUtil.toggleAllTooltipSeriesGroups('disable');
- var firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-series-group');
- if (firstTooltipSeriesGroup) {
- firstTooltipSeriesGroup.classList.add('apexcharts-active');
- firstTooltipSeriesGroup.style.display = w.config.tooltip.items.display;
- }
- }
- }
- }, {
- key: "getValuesToPrint",
- value: function getValuesToPrint(_ref5) {
- var i = _ref5.i,
- j = _ref5.j;
- var w = this.w;
- var filteredSeriesX = this.ctx.series.filteredSeriesX();
- var xVal = '';
- var xAxisTTVal = '';
- var zVal = null;
- var val = null;
- var customFormatterOpts = {
- series: w.globals.series,
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- };
- var zFormatter = w.globals.ttZFormatter;
- if (j === null) {
- val = w.globals.series[i];
- } else {
- if (w.globals.isXNumeric) {
- xVal = filteredSeriesX[i][j];
- if (filteredSeriesX[i].length === 0) {
-
- var firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(filteredSeriesX);
- xVal = filteredSeriesX[firstActiveSeriesIndex][j];
- }
- } else {
- xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : '';
- }
- }
- var bufferXVal = xVal;
- if (w.globals.isXNumeric && w.config.xaxis.type === 'datetime') {
- var xFormat = new Formatters(this.ctx);
- xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal, bufferXVal);
- } else {
- if (!w.globals.isBarHorizontal) {
- xVal = w.globals.xLabelFormatter(bufferXVal, customFormatterOpts);
- }
- }
- if (w.config.tooltip.x.formatter !== undefined) {
- xVal = w.globals.ttKeyFormatter(bufferXVal, customFormatterOpts);
- }
- if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[0].length > 0) {
- zVal = zFormatter(w.globals.seriesZ[i][j], w);
- }
- if (typeof w.config.xaxis.tooltip.formatter === 'function') {
- xAxisTTVal = w.globals.xaxisTooltipFormatter(bufferXVal, customFormatterOpts);
- } else {
- xAxisTTVal = xVal;
- }
- return {
- val: Array.isArray(val) ? val.join(' ') : val,
- xVal: Array.isArray(xVal) ? xVal.join(' ') : xVal,
- xAxisTTVal: Array.isArray(xAxisTTVal) ? xAxisTTVal.join(' ') : xAxisTTVal,
- zVal: zVal
- };
- }
- }, {
- key: "handleCustomTooltip",
- value: function handleCustomTooltip(_ref6) {
- var i = _ref6.i,
- j = _ref6.j,
- y1 = _ref6.y1,
- y2 = _ref6.y2,
- w = _ref6.w;
- var tooltipEl = this.ttCtx.getElTooltip();
- var fn = w.config.tooltip.custom;
- if (Array.isArray(fn) && fn[i]) {
- fn = fn[i];
- }
- tooltipEl.innerHTML = fn({
- ctx: this.ctx,
- series: w.globals.series,
- seriesIndex: i,
- dataPointIndex: j,
- y1: y1,
- y2: y2,
- w: w
- });
- }
- }]);
- return Labels;
- }();
-
- var Position = function () {
- function Position(tooltipContext) {
- _classCallCheck(this, Position);
- this.ttCtx = tooltipContext;
- this.ctx = tooltipContext.ctx;
- this.w = tooltipContext.w;
- }
-
- _createClass(Position, [{
- key: "moveXCrosshairs",
- value: function moveXCrosshairs(cx) {
- var j = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var ttCtx = this.ttCtx;
- var w = this.w;
- var xcrosshairs = ttCtx.getElXCrosshairs();
- var x = cx - ttCtx.xcrosshairsWidth / 2;
- var tickAmount = w.globals.labels.slice().length;
- if (j !== null) {
- x = w.globals.gridWidth / tickAmount * j;
- }
- if (xcrosshairs !== null) {
- xcrosshairs.setAttribute('x', x);
- xcrosshairs.setAttribute('x1', x);
- xcrosshairs.setAttribute('x2', x);
- xcrosshairs.setAttribute('y2', w.globals.gridHeight);
- xcrosshairs.classList.add('apexcharts-active');
- }
- if (x < 0) {
- x = 0;
- }
- if (x > w.globals.gridWidth) {
- x = w.globals.gridWidth;
- }
- if (ttCtx.blxaxisTooltip) {
- var tx = x;
- if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') {
- tx = x + ttCtx.xcrosshairsWidth / 2;
- }
- this.moveXAxisTooltip(tx);
- }
- }
-
- }, {
- key: "moveYCrosshairs",
- value: function moveYCrosshairs(cy) {
- var ttCtx = this.ttCtx;
- if (ttCtx.ycrosshairs !== null) {
- Graphics.setAttrs(ttCtx.ycrosshairs, {
- y1: cy,
- y2: cy
- });
- Graphics.setAttrs(ttCtx.ycrosshairsHidden, {
- y1: cy,
- y2: cy
- });
- }
- }
-
- }, {
- key: "moveXAxisTooltip",
- value: function moveXAxisTooltip(cx) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- if (ttCtx.xaxisTooltip !== null) {
- ttCtx.xaxisTooltip.classList.add('apexcharts-active');
- var cy = ttCtx.xaxisOffY + w.config.xaxis.tooltip.offsetY + w.globals.translateY + 1 + w.config.xaxis.offsetY;
- var xaxisTTText = ttCtx.xaxisTooltip.getBoundingClientRect();
- var xaxisTTTextWidth = xaxisTTText.width;
- cx = cx - xaxisTTTextWidth / 2;
- if (!isNaN(cx)) {
- cx = cx + w.globals.translateX;
- var textRect = 0;
- var graphics = new Graphics(this.ctx);
- textRect = graphics.getTextRects(ttCtx.xaxisTooltipText.innerHTML);
- ttCtx.xaxisTooltipText.style.minWidth = textRect.width + 'px';
- ttCtx.xaxisTooltip.style.left = cx + 'px';
- ttCtx.xaxisTooltip.style.top = cy + 'px';
- }
- }
- }
- }, {
- key: "moveYAxisTooltip",
- value: function moveYAxisTooltip(index) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- if (ttCtx.yaxisTTEls === null) {
- ttCtx.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
- }
- var ycrosshairsHiddenRectY1 = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1'), 10);
- var cy = w.globals.translateY + ycrosshairsHiddenRectY1;
- var yAxisTTRect = ttCtx.yaxisTTEls[index].getBoundingClientRect();
- var yAxisTTHeight = yAxisTTRect.height;
- var cx = w.globals.translateYAxisX[index] - 2;
- if (w.config.yaxis[index].opposite) {
- cx = cx - 26;
- }
- cy = cy - yAxisTTHeight / 2;
- if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1) {
- ttCtx.yaxisTTEls[index].classList.add('apexcharts-active');
- ttCtx.yaxisTTEls[index].style.top = cy + 'px';
- ttCtx.yaxisTTEls[index].style.left = cx + w.config.yaxis[index].tooltip.offsetX + 'px';
- } else {
- ttCtx.yaxisTTEls[index].classList.remove('apexcharts-active');
- }
- }
-
- }, {
- key: "moveTooltip",
- value: function moveTooltip(cx, cy) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var w = this.w;
- var ttCtx = this.ttCtx;
- var tooltipEl = ttCtx.getElTooltip();
- var tooltipRect = ttCtx.tooltipRect;
- var pointR = r !== null ? parseFloat(r) : 1;
- var x = parseFloat(cx) + pointR + 5;
- var y = parseFloat(cy) + pointR / 2;
- if (x > w.globals.gridWidth / 2) {
- x = x - tooltipRect.ttWidth - pointR - 15;
- }
- if (x > w.globals.gridWidth - tooltipRect.ttWidth - 10) {
- x = w.globals.gridWidth - tooltipRect.ttWidth;
- }
- if (x < -20) {
- x = -20;
- }
- if (w.config.tooltip.followCursor) {
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top - tooltipRect.ttHeight / 2;
- }
- if (!w.config.tooltip.followCursor) {
- var newPositions = this.positionChecks(tooltipRect, x, y);
- x = newPositions.x;
- y = newPositions.y;
- }
- if (!isNaN(x)) {
- x = x + w.globals.translateX;
- tooltipEl.style.left = x + 'px';
- tooltipEl.style.top = y + 'px';
- }
- }
- }, {
- key: "positionChecks",
- value: function positionChecks(tooltipRect, x, y) {
- var w = this.w;
- if (tooltipRect.ttHeight / 2 + y > w.globals.gridHeight) {
- y = w.globals.gridHeight - tooltipRect.ttHeight + w.globals.translateY;
- }
- if (y < 0) {
- y = 0;
- }
- return {
- x: x,
- y: y
- };
- }
- }, {
- key: "moveMarkers",
- value: function moveMarkers(i, j) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- if (w.globals.markers.size[i] > 0) {
- var allPoints = w.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(i, "'] .apexcharts-marker"));
- for (var p = 0; p < allPoints.length; p++) {
- if (parseInt(allPoints[p].getAttribute('rel'), 10) === j) {
- ttCtx.marker.resetPointsSize();
- ttCtx.marker.enlargeCurrentPoint(j, allPoints[p]);
- }
- }
- } else {
- ttCtx.marker.resetPointsSize();
- this.moveDynamicPointOnHover(j, i);
- }
- }
-
- }, {
- key: "moveDynamicPointOnHover",
- value: function moveDynamicPointOnHover(j, capturedSeries) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- var cx = 0;
- var cy = 0;
- var pointsArr = w.globals.pointsArray;
- var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(capturedSeries);
- var serType = w.config.series[capturedSeries].type;
- if (serType && (serType === 'column' || serType === 'candlestick')) {
-
- return;
- }
- cx = pointsArr[capturedSeries][j][0];
- cy = pointsArr[capturedSeries][j][1] ? pointsArr[capturedSeries][j][1] : 0;
- var point = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(capturedSeries, "'] .apexcharts-series-markers circle"));
- if (point) {
- point.setAttribute('r', hoverSize);
- point.setAttribute('cx', cx);
- point.setAttribute('cy', cy);
- }
- this.moveXCrosshairs(cx);
- if (!ttCtx.fixedTooltip) {
- this.moveTooltip(cx, cy, hoverSize);
- }
- }
-
- }, {
- key: "moveDynamicPointsOnHover",
- value: function moveDynamicPointsOnHover(j) {
- var ttCtx = this.ttCtx;
- var w = ttCtx.w;
- var cx = 0;
- var cy = 0;
- var activeSeries = 0;
- var pointsArr = w.globals.pointsArray;
- var series = new Series(this.ctx);
- activeSeries = series.getActiveConfigSeriesIndex(true);
- var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(activeSeries);
- if (pointsArr[activeSeries]) {
- cx = pointsArr[activeSeries][j][0];
- cy = pointsArr[activeSeries][j][1];
- }
- var points = ttCtx.tooltipUtil.getAllMarkers();
- if (points !== null) {
- for (var p = 0; p < w.globals.series.length; p++) {
- var pointArr = pointsArr[p];
- if (w.globals.comboCharts) {
-
- if (typeof pointArr === 'undefined') {
-
- points.splice(p, 0, null);
- }
- }
- if (pointArr && pointArr.length) {
- var pcy = pointsArr[p][j][1];
- points[p].setAttribute('cx', cx);
- if (pcy !== null && !isNaN(pcy)) {
- points[p] && points[p].setAttribute('r', hoverSize);
- points[p] && points[p].setAttribute('cy', pcy);
- } else {
- points[p] && points[p].setAttribute('r', 0);
- }
- }
- }
- }
- this.moveXCrosshairs(cx);
- if (!ttCtx.fixedTooltip) {
- var tcy = cy || w.globals.gridHeight;
- this.moveTooltip(cx, tcy, hoverSize);
- }
- }
- }, {
- key: "moveStickyTooltipOverBars",
- value: function moveStickyTooltipOverBars(j) {
- var w = this.w;
- var ttCtx = this.ttCtx;
- var barLen = w.globals.columnSeries ? w.globals.columnSeries.length : w.globals.series.length;
- var i = barLen >= 2 && barLen % 2 === 0 ? Math.floor(barLen / 2) : Math.floor(barLen / 2) + 1;
- var jBar = w.globals.dom.baseEl.querySelector(".apexcharts-bar-series .apexcharts-series[rel='".concat(i, "'] path[j='").concat(j, "'], .apexcharts-candlestick-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "'], .apexcharts-rangebar-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "']"));
- var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0;
- var bcy = 0;
- var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0;
- if (w.globals.isXNumeric) {
- bcx = bcx - (barLen % 2 !== 0 ? bw / 2 : 0);
- } else {
- bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2;
- if (isNaN(bcx)) {
- bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2;
- }
- }
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- bcy = ttCtx.e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2;
- this.moveXCrosshairs(bcx);
- if (!ttCtx.fixedTooltip) {
- var tcy = bcy || w.globals.gridHeight;
- this.moveTooltip(bcx, tcy);
- }
- }
- }]);
- return Position;
- }();
-
- var Marker = function () {
- function Marker(tooltipContext) {
- _classCallCheck(this, Marker);
- this.w = tooltipContext.w;
- this.ttCtx = tooltipContext;
- this.ctx = tooltipContext.ctx;
- this.tooltipPosition = new Position(tooltipContext);
- }
- _createClass(Marker, [{
- key: "drawDynamicPoints",
- value: function drawDynamicPoints() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var marker = new Markers(this.ctx);
- var elsSeries = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
- elsSeries = _toConsumableArray(elsSeries);
- elsSeries.sort(function (a, b) {
- return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
- });
- for (var i = 0; i < elsSeries.length; i++) {
- var pointsMain = elsSeries[i].querySelector(".apexcharts-series-markers-wrap");
- if (pointsMain !== null) {
-
- var point = void 0;
- var PointClasses = "apexcharts-marker w".concat((Math.random() + 1).toString(36).substring(4));
- if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
- PointClasses += ' no-pointer-events';
- }
- var elPointOptions = marker.getMarkerConfig(PointClasses, i);
- point = graphics.drawMarker(0, 0, elPointOptions);
- point.node.setAttribute('default-marker-size', 0);
- var elPointsG = document.createElementNS(w.globals.SVGNS, 'g');
- elPointsG.classList.add('apexcharts-series-markers');
- elPointsG.appendChild(point.node);
- pointsMain.appendChild(elPointsG);
- }
- }
- }
- }, {
- key: "enlargeCurrentPoint",
- value: function enlargeCurrentPoint(rel, point) {
- var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
- var w = this.w;
- if (w.config.chart.type !== 'bubble') {
- this.newPointSize(rel, point);
- }
- var cx = point.getAttribute('cx');
- var cy = point.getAttribute('cy');
- if (x !== null && y !== null) {
- cx = x;
- cy = y;
- }
- this.tooltipPosition.moveXCrosshairs(cx);
- if (!this.fixedTooltip) {
- if (w.config.chart.type === 'radar') {
- var elGrid = this.ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- cx = this.ttCtx.e.clientX - seriesBound.left;
- }
- this.tooltipPosition.moveTooltip(cx, cy, w.config.markers.hover.size);
- }
- }
- }, {
- key: "enlargePoints",
- value: function enlargePoints(j) {
- var w = this.w;
- var me = this;
- var ttCtx = this.ttCtx;
- var col = j;
- var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
- var newSize = w.config.markers.hover.size;
- for (var p = 0; p < points.length; p++) {
- var rel = points[p].getAttribute('rel');
- var index = points[p].getAttribute('index');
- if (newSize === undefined) {
- newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
- }
- if (col === parseInt(rel, 10)) {
- me.newPointSize(col, points[p]);
- var cx = points[p].getAttribute('cx');
- var cy = points[p].getAttribute('cy');
- me.tooltipPosition.moveXCrosshairs(cx);
- if (!ttCtx.fixedTooltip) {
- me.tooltipPosition.moveTooltip(cx, cy, newSize);
- }
- } else {
- me.oldPointSize(points[p]);
- }
- }
- }
- }, {
- key: "newPointSize",
- value: function newPointSize(rel, point) {
- var w = this.w;
- var newSize = w.config.markers.hover.size;
- var elPoint = rel === 0 ? point.parentNode.firstChild : point.parentNode.lastChild;
- if (elPoint.getAttribute('default-marker-size') !== '0') {
- var index = parseInt(elPoint.getAttribute('index'), 10);
- if (newSize === undefined) {
- newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
- }
- elPoint.setAttribute('r', newSize);
- }
- }
- }, {
- key: "oldPointSize",
- value: function oldPointSize(point) {
- var size = parseFloat(point.getAttribute('default-marker-size'));
- point.setAttribute('r', size);
- }
- }, {
- key: "resetPointsSize",
- value: function resetPointsSize() {
- var w = this.w;
- var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
- for (var p = 0; p < points.length; p++) {
- var size = parseFloat(points[p].getAttribute('default-marker-size'));
- if (Utils.isNumber(size)) {
- points[p].setAttribute('r', size);
- } else {
- points[p].setAttribute('r', 0);
- }
- }
- }
- }]);
- return Marker;
- }();
-
- var Intersect = function () {
- function Intersect(tooltipContext) {
- _classCallCheck(this, Intersect);
- this.w = tooltipContext.w;
- this.ttCtx = tooltipContext;
- }
- _createClass(Intersect, [{
- key: "getAttr",
- value: function getAttr(e, attr) {
- return parseFloat(e.target.getAttribute(attr));
- }
- }, {
- key: "handleHeatTooltip",
- value: function handleHeatTooltip(_ref) {
- var e = _ref.e,
- opt = _ref.opt,
- x = _ref.x,
- y = _ref.y;
- var ttCtx = this.ttCtx;
- var w = this.w;
- if (e.target.classList.contains('apexcharts-heatmap-rect')) {
- var i = this.getAttr(e, 'i');
- var j = this.getAttr(e, 'j');
- var cx = this.getAttr(e, 'cx');
- var cy = this.getAttr(e, 'cy');
- var width = this.getAttr(e, 'width');
- var height = this.getAttr(e, 'height');
- ttCtx.tooltipLabels.drawSeriesTexts({
- ttItems: opt.ttItems,
- i: i,
- j: j,
- shared: false
- });
- w.globals.capturedSeriesIndex = i;
- w.globals.capturedDataPointIndex = j;
- x = cx + ttCtx.tooltipRect.ttWidth / 2 + width;
- y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2;
- ttCtx.tooltipPosition.moveXCrosshairs(cx + width / 2);
- if (x > w.globals.gridWidth / 2) {
- x = cx - ttCtx.tooltipRect.ttWidth / 2 + width;
- }
- if (ttCtx.w.config.tooltip.followCursor) {
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- y = ttCtx.e.clientY - seriesBound.top + w.globals.translateY / 2 - 10;
- }
- }
- return {
- x: x,
- y: y
- };
- }
- }, {
- key: "handleMarkerTooltip",
- value: function handleMarkerTooltip(_ref2) {
- var e = _ref2.e,
- opt = _ref2.opt,
- x = _ref2.x,
- y = _ref2.y;
- var w = this.w;
- var ttCtx = this.ttCtx;
- var i;
- var j;
- if (e.target.classList.contains('apexcharts-marker')) {
- var cx = parseInt(opt.paths.getAttribute('cx'), 10);
- var cy = parseInt(opt.paths.getAttribute('cy'), 10);
- var val = parseFloat(opt.paths.getAttribute('val'));
- j = parseInt(opt.paths.getAttribute('rel'), 10);
- i = parseInt(opt.paths.parentNode.parentNode.parentNode.getAttribute('rel'), 10) - 1;
- if (ttCtx.intersect) {
- var el = Utils.findAncestor(opt.paths, 'apexcharts-series');
- if (el) {
- i = parseInt(el.getAttribute('data:realIndex'), 10);
- }
- }
- ttCtx.tooltipLabels.drawSeriesTexts({
- ttItems: opt.ttItems,
- i: i,
- j: j,
- shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
- });
- if (e.type === 'mouseup') {
- ttCtx.markerClick(e, i, j);
- }
- w.globals.capturedSeriesIndex = i;
- w.globals.capturedDataPointIndex = j;
- x = cx;
- y = cy + w.globals.translateY - ttCtx.tooltipRect.ttHeight * 1.4;
- if (ttCtx.w.config.tooltip.followCursor) {
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top;
- }
- if (val < 0) {
- y = cy;
- }
- ttCtx.marker.enlargeCurrentPoint(j, opt.paths, x, y);
- }
- return {
- x: x,
- y: y
- };
- }
- }, {
- key: "handleBarTooltip",
- value: function handleBarTooltip(_ref3) {
- var e = _ref3.e,
- opt = _ref3.opt;
- var w = this.w;
- var ttCtx = this.ttCtx;
- var tooltipEl = ttCtx.getElTooltip();
- var bx = 0;
- var x = 0;
- var y = 0;
- var i = 0;
- var strokeWidth;
- var barXY = this.getBarTooltipXY({
- e: e,
- opt: opt
- });
- i = barXY.i;
- var barHeight = barXY.barHeight;
- var j = barXY.j;
- w.globals.capturedSeriesIndex = i;
- w.globals.capturedDataPointIndex = j;
- if (w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars() || !w.config.tooltip.shared) {
- x = barXY.x;
- y = barXY.y;
- strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[i] : w.config.stroke.width;
- bx = x;
- } else {
- if (!w.globals.comboCharts && !w.config.tooltip.shared) {
- bx = bx / 2;
- }
- }
- if (isNaN(y)) {
- y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight;
- } else if (y < 0) {
- y = 0;
- }
- if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth) {
- x = x - ttCtx.tooltipRect.ttWidth;
- } else if (x < 0) {
- x = 0;
- }
- if (ttCtx.w.config.tooltip.followCursor) {
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- y = ttCtx.e.clientY - seriesBound.top;
- }
- if (ttCtx.tooltip === null) {
- ttCtx.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
- }
- if (!w.config.tooltip.shared) {
- if (w.globals.comboBarCount > 0) {
- ttCtx.tooltipPosition.moveXCrosshairs(bx + strokeWidth / 2);
- } else {
- ttCtx.tooltipPosition.moveXCrosshairs(bx);
- }
- }
- if (!ttCtx.fixedTooltip && (!w.config.tooltip.shared || w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
- var isReversed = w.globals.isMultipleYAxis ? w.config.yaxis[seriesIndex] && w.config.yaxis[seriesIndex].reversed : w.config.yaxis[0].reversed;
- if (isReversed) {
- x = x - ttCtx.tooltipRect.ttWidth;
- if (x < 0) {
- x = 0;
- }
- }
- tooltipEl.style.left = x + w.globals.translateX + 'px';
- var seriesIndex = parseInt(opt.paths.parentNode.getAttribute('data:realIndex'), 10);
- if (isReversed && !(w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
- y = y + barHeight - (w.globals.series[i][j] < 0 ? barHeight : 0) * 2;
- }
- if (ttCtx.tooltipRect.ttHeight + y > w.globals.gridHeight) {
- y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight + w.globals.translateY;
- tooltipEl.style.top = y + 'px';
- } else {
- tooltipEl.style.top = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2 + 'px';
- }
- }
- }
- }, {
- key: "getBarTooltipXY",
- value: function getBarTooltipXY(_ref4) {
- var e = _ref4.e,
- opt = _ref4.opt;
- var w = this.w;
- var j = null;
- var ttCtx = this.ttCtx;
- var i = 0;
- var x = 0;
- var y = 0;
- var barWidth = 0;
- var barHeight = 0;
- var cl = e.target.classList;
- if (cl.contains('apexcharts-bar-area') || cl.contains('apexcharts-candlestick-area') || cl.contains('apexcharts-rangebar-area')) {
- var bar = e.target;
- var barRect = bar.getBoundingClientRect();
- var seriesBound = opt.elGrid.getBoundingClientRect();
- var bh = barRect.height;
- barHeight = barRect.height;
- var bw = barRect.width;
- var cx = parseInt(bar.getAttribute('cx'), 10);
- var cy = parseInt(bar.getAttribute('cy'), 10);
- barWidth = parseFloat(bar.getAttribute('barWidth'));
- var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
- j = parseInt(bar.getAttribute('j'), 10);
- i = parseInt(bar.parentNode.getAttribute('rel'), 10) - 1;
- var y1 = bar.getAttribute('data-range-y1');
- var y2 = bar.getAttribute('data-range-y2');
- if (w.globals.comboCharts) {
- i = parseInt(bar.parentNode.getAttribute('data:realIndex'), 10);
- }
-
-
-
-
-
- ttCtx.tooltipLabels.drawSeriesTexts({
- ttItems: opt.ttItems,
- i: i,
- j: j,
- y1: y1 ? parseInt(y1, 10) : null,
- y2: y2 ? parseInt(y2, 10) : null,
- shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
- });
- if (w.config.tooltip.followCursor) {
- if (w.globals.isBarHorizontal) {
- x = clientX - seriesBound.left + 15;
- y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
- } else {
- if (w.globals.isXNumeric) {
- x = cx - bw / 2;
- } else {
- x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
- }
- y = e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2 - 15;
- }
- } else {
- if (w.globals.isBarHorizontal) {
- x = cx;
- if (x < ttCtx.xyRatios.baseLineInvertedY) {
- x = cx - ttCtx.tooltipRect.ttWidth;
- }
- y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
- } else {
-
- if (w.globals.isXNumeric) {
- x = cx - bw / 2;
- } else {
- x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
- }
- y = cy;
- }
- }
- }
- return {
- x: x,
- y: y,
- barHeight: barHeight,
- barWidth: barWidth,
- i: i,
- j: j
- };
- }
- }]);
- return Intersect;
- }();
-
- var AxesTooltip = function () {
- function AxesTooltip(tooltipContext) {
- _classCallCheck(this, AxesTooltip);
- this.w = tooltipContext.w;
- this.ttCtx = tooltipContext;
- }
-
- _createClass(AxesTooltip, [{
- key: "drawXaxisTooltip",
- value: function drawXaxisTooltip() {
- var w = this.w;
- var ttCtx = this.ttCtx;
- var isBottom = w.config.xaxis.position === 'bottom';
- ttCtx.xaxisOffY = isBottom ? w.globals.gridHeight + 1 : -w.globals.xAxisHeight - w.config.xaxis.axisTicks.height + 3;
- var tooltipCssClass = isBottom ? 'apexcharts-xaxistooltip apexcharts-xaxistooltip-bottom' : 'apexcharts-xaxistooltip apexcharts-xaxistooltip-top';
- var renderTo = w.globals.dom.elWrap;
- if (ttCtx.blxaxisTooltip) {
- var xaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-xaxistooltip');
- if (xaxisTooltip === null) {
- ttCtx.xaxisTooltip = document.createElement('div');
- ttCtx.xaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
- renderTo.appendChild(ttCtx.xaxisTooltip);
- ttCtx.xaxisTooltipText = document.createElement('div');
- ttCtx.xaxisTooltipText.classList.add('apexcharts-xaxistooltip-text');
- ttCtx.xaxisTooltipText.style.fontFamily = w.config.xaxis.tooltip.style.fontFamily || w.config.chart.fontFamily;
- ttCtx.xaxisTooltipText.style.fontSize = w.config.xaxis.tooltip.style.fontSize;
- ttCtx.xaxisTooltip.appendChild(ttCtx.xaxisTooltipText);
- }
- }
- }
-
- }, {
- key: "drawYaxisTooltip",
- value: function drawYaxisTooltip() {
- var w = this.w;
- var ttCtx = this.ttCtx;
- var _loop = function _loop(i) {
- var isRight = w.config.yaxis[i].opposite || w.config.yaxis[i].crosshairs.opposite;
- ttCtx.yaxisOffX = isRight ? w.globals.gridWidth + 1 : 1;
- var tooltipCssClass = isRight ? "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-right") : "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-left");
- w.globals.yAxisSameScaleIndices.map(function (samescales, ssi) {
- samescales.map(function (s, si) {
- if (si === i) {
- tooltipCssClass += w.config.yaxis[si].show ? " " : " apexcharts-yaxistooltip-hidden";
- }
- });
- });
- var renderTo = w.globals.dom.elWrap;
- if (ttCtx.blyaxisTooltip) {
- var yaxisTooltip = w.globals.dom.baseEl.querySelector(".apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i));
- if (yaxisTooltip === null) {
- ttCtx.yaxisTooltip = document.createElement('div');
- ttCtx.yaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
- renderTo.appendChild(ttCtx.yaxisTooltip);
- if (i === 0) ttCtx.yaxisTooltipText = [];
- ttCtx.yaxisTooltipText.push(document.createElement('div'));
- ttCtx.yaxisTooltipText[i].classList.add('apexcharts-yaxistooltip-text');
- ttCtx.yaxisTooltip.appendChild(ttCtx.yaxisTooltipText[i]);
- }
- }
- };
- for (var i = 0; i < w.config.yaxis.length; i++) {
- _loop(i);
- }
- }
-
- }, {
- key: "setXCrosshairWidth",
- value: function setXCrosshairWidth() {
- var w = this.w;
- var ttCtx = this.ttCtx;
- var xcrosshairs = ttCtx.getElXCrosshairs();
- ttCtx.xcrosshairsWidth = parseInt(w.config.xaxis.crosshairs.width, 10);
- if (!w.globals.comboCharts) {
- if (w.config.xaxis.crosshairs.width === 'tickWidth') {
- var count = w.globals.labels.length;
- ttCtx.xcrosshairsWidth = w.globals.gridWidth / count;
- } else if (w.config.xaxis.crosshairs.width === 'barWidth') {
- var bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
- if (bar !== null) {
- var barWidth = parseFloat(bar.getAttribute('barWidth'));
- ttCtx.xcrosshairsWidth = barWidth;
- } else {
- ttCtx.xcrosshairsWidth = 1;
- }
- }
- } else {
- var _bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
- if (_bar !== null && w.config.xaxis.crosshairs.width === 'barWidth') {
- var _barWidth = parseFloat(_bar.getAttribute('barWidth'));
- ttCtx.xcrosshairsWidth = _barWidth;
- } else {
- if (w.config.xaxis.crosshairs.width === 'tickWidth') {
- var _count = w.globals.labels.length;
- ttCtx.xcrosshairsWidth = w.globals.gridWidth / _count;
- }
- }
- }
- if (w.globals.isBarHorizontal) {
- ttCtx.xcrosshairsWidth = 0;
- }
- if (xcrosshairs !== null && ttCtx.xcrosshairsWidth > 0) {
- xcrosshairs.setAttribute('width', ttCtx.xcrosshairsWidth);
- }
- }
- }, {
- key: "handleYCrosshair",
- value: function handleYCrosshair() {
- var w = this.w;
- var ttCtx = this.ttCtx;
- ttCtx.ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs');
- ttCtx.ycrosshairsHidden = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs-hidden');
- }
- }, {
- key: "drawYaxisTooltipText",
- value: function drawYaxisTooltipText(index, clientY, xyRatios) {
- var ttCtx = this.ttCtx;
- var w = this.w;
- var lbFormatter = w.globals.yLabelFormatters[index];
- if (ttCtx.blyaxisTooltip) {
- var elGrid = ttCtx.getElGrid();
- var seriesBound = elGrid.getBoundingClientRect();
- var hoverY = (clientY - seriesBound.top) * xyRatios.yRatio[index];
- var height = w.globals.maxYArr[index] - w.globals.minYArr[index];
- var val = w.globals.minYArr[index] + (height - hoverY);
- ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top);
- ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val);
- ttCtx.tooltipPosition.moveYAxisTooltip(index);
- }
- }
- }]);
- return AxesTooltip;
- }();
-
- var Tooltip = function () {
- function Tooltip(ctx) {
- _classCallCheck(this, Tooltip);
- this.ctx = ctx;
- this.w = ctx.w;
- var w = this.w;
- this.tConfig = w.config.tooltip;
- this.tooltipUtil = new Utils$1(this);
- this.tooltipLabels = new Labels(this);
- this.tooltipPosition = new Position(this);
- this.marker = new Marker(this);
- this.intersect = new Intersect(this);
- this.axesTooltip = new AxesTooltip(this);
- this.showOnIntersect = this.tConfig.intersect;
- this.showTooltipTitle = this.tConfig.x.show;
- this.fixedTooltip = this.tConfig.fixed.enabled;
- this.xaxisTooltip = null;
- this.yaxisTTEls = null;
- this.isBarShared = !w.globals.isBarHorizontal && this.tConfig.shared;
- }
- _createClass(Tooltip, [{
- key: "getElTooltip",
- value: function getElTooltip(ctx) {
- if (!ctx) ctx = this;
- return ctx.w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
- }
- }, {
- key: "getElXCrosshairs",
- value: function getElXCrosshairs() {
- return this.w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs');
- }
- }, {
- key: "getElGrid",
- value: function getElGrid() {
- return this.w.globals.dom.baseEl.querySelector('.apexcharts-grid');
- }
- }, {
- key: "drawTooltip",
- value: function drawTooltip(xyRatios) {
- var w = this.w;
- this.xyRatios = xyRatios;
- this.blxaxisTooltip = w.config.xaxis.tooltip.enabled && w.globals.axisCharts;
- this.blyaxisTooltip = w.config.yaxis[0].tooltip.enabled && w.globals.axisCharts;
- this.allTooltipSeriesGroups = [];
- if (!w.globals.axisCharts) {
- this.showTooltipTitle = false;
- }
- var tooltipEl = document.createElement('div');
- tooltipEl.classList.add('apexcharts-tooltip');
- tooltipEl.classList.add("apexcharts-theme-".concat(this.tConfig.theme));
- w.globals.dom.elWrap.appendChild(tooltipEl);
- if (w.globals.axisCharts) {
- this.axesTooltip.drawXaxisTooltip();
- this.axesTooltip.drawYaxisTooltip();
- this.axesTooltip.setXCrosshairWidth();
- this.axesTooltip.handleYCrosshair();
- var xAxis = new XAxis(this.ctx);
- this.xAxisTicksPositions = xAxis.getXAxisTicksPositions();
- }
- if ((w.globals.comboCharts || this.tConfig.intersect || w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && !this.tConfig.shared) {
- this.showOnIntersect = true;
- }
- if (w.config.markers.size === 0 || w.globals.markers.largestSize === 0) {
-
- this.marker.drawDynamicPoints(this);
- }
- if (w.globals.collapsedSeries.length === w.globals.series.length) return;
- this.dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
- this.dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
- if (this.showTooltipTitle) {
- this.tooltipTitle = document.createElement('div');
- this.tooltipTitle.classList.add('apexcharts-tooltip-title');
- this.tooltipTitle.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
- this.tooltipTitle.style.fontSize = this.tConfig.style.fontSize;
- tooltipEl.appendChild(this.tooltipTitle);
- }
- var ttItemsCnt = w.globals.series.length;
- if ((w.globals.xyCharts || w.globals.comboCharts) && this.tConfig.shared) {
- if (!this.showOnIntersect) {
- ttItemsCnt = w.globals.series.length;
- } else {
- ttItemsCnt = 1;
- }
- }
- this.legendLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-text');
- this.ttItems = this.createTTElements(ttItemsCnt);
- this.addSVGEvents();
- }
- }, {
- key: "createTTElements",
- value: function createTTElements(ttItemsCnt) {
- var w = this.w;
- var ttItems = [];
- var tooltipEl = this.getElTooltip();
- for (var i = 0; i < ttItemsCnt; i++) {
- var gTxt = document.createElement('div');
- gTxt.classList.add('apexcharts-tooltip-series-group');
- if (this.tConfig.shared && this.tConfig.enabledOnSeries && Array.isArray(this.tConfig.enabledOnSeries)) {
- if (this.tConfig.enabledOnSeries.indexOf(i) < 0) {
- gTxt.classList.add('apexcharts-tooltip-series-group-hidden');
- }
- }
- var point = document.createElement('span');
- point.classList.add('apexcharts-tooltip-marker');
- point.style.backgroundColor = w.globals.colors[i];
- gTxt.appendChild(point);
- var gYZ = document.createElement('div');
- gYZ.classList.add('apexcharts-tooltip-text');
- gYZ.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
- gYZ.style.fontSize = this.tConfig.style.fontSize;
- var gYValText = document.createElement('div');
- gYValText.classList.add('apexcharts-tooltip-y-group');
- var txtLabel = document.createElement('span');
- txtLabel.classList.add('apexcharts-tooltip-text-label');
- gYValText.appendChild(txtLabel);
- var txtValue = document.createElement('span');
- txtValue.classList.add('apexcharts-tooltip-text-value');
- gYValText.appendChild(txtValue);
- var gZValText = document.createElement('div');
- gZValText.classList.add('apexcharts-tooltip-z-group');
- var txtZLabel = document.createElement('span');
- txtZLabel.classList.add('apexcharts-tooltip-text-z-label');
- gZValText.appendChild(txtZLabel);
- var txtZValue = document.createElement('span');
- txtZValue.classList.add('apexcharts-tooltip-text-z-value');
- gZValText.appendChild(txtZValue);
- gYZ.appendChild(gYValText);
- gYZ.appendChild(gZValText);
- gTxt.appendChild(gYZ);
- tooltipEl.appendChild(gTxt);
- ttItems.push(gTxt);
- }
- return ttItems;
- }
- }, {
- key: "addSVGEvents",
- value: function addSVGEvents() {
- var w = this.w;
- var type = w.config.chart.type;
- var tooltipEl = this.getElTooltip();
- var commonBar = !!(type === 'bar' || type === 'candlestick' || type === 'rangeBar');
- var chartWithmarkers = type === 'area' || type === 'line' || type === 'scatter' || type === 'bubble' || type === 'radar';
- var hoverArea = w.globals.dom.Paper.node;
- var elGrid = this.getElGrid();
- if (elGrid) {
- this.seriesBound = elGrid.getBoundingClientRect();
- }
- var tooltipY = [];
- var tooltipX = [];
- var seriesHoverParams = {
- hoverArea: hoverArea,
- elGrid: elGrid,
- tooltipEl: tooltipEl,
- tooltipY: tooltipY,
- tooltipX: tooltipX,
- ttItems: this.ttItems
- };
- var points;
- if (w.globals.axisCharts) {
- if (chartWithmarkers) {
- points = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series[data\\:longestSeries='true'] .apexcharts-marker");
- } else if (commonBar) {
- points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area, .apexcharts-series .apexcharts-candlestick-area, .apexcharts-series .apexcharts-rangebar-area');
- } else if (type === 'heatmap') {
- points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap');
- }
- if (points && points.length) {
- for (var p = 0; p < points.length; p++) {
- tooltipY.push(points[p].getAttribute('cy'));
- tooltipX.push(points[p].getAttribute('cx'));
- }
- }
- }
- var validSharedChartTypes = w.globals.xyCharts && !this.showOnIntersect || w.globals.comboCharts && !this.showOnIntersect || commonBar && this.tooltipUtil.hasBars() && this.tConfig.shared;
- if (validSharedChartTypes) {
- this.addPathsEventListeners([hoverArea], seriesHoverParams);
- } else if (commonBar && !w.globals.comboCharts || chartWithmarkers && this.showOnIntersect) {
- this.addDatapointEventsListeners(seriesHoverParams);
- } else if (!w.globals.axisCharts || type === 'heatmap') {
- var seriesAll = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
- this.addPathsEventListeners(seriesAll, seriesHoverParams);
- }
- if (this.showOnIntersect) {
- var lineAreaPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-marker, .apexcharts-area-series .apexcharts-marker');
- if (lineAreaPoints.length > 0) {
-
- this.addPathsEventListeners(lineAreaPoints, seriesHoverParams);
- }
- if (this.tooltipUtil.hasBars() && !this.tConfig.shared) {
- this.addDatapointEventsListeners(seriesHoverParams);
- }
- }
- }
- }, {
- key: "drawFixedTooltipRect",
- value: function drawFixedTooltipRect() {
- var w = this.w;
- var tooltipEl = this.getElTooltip();
- var tooltipRect = tooltipEl.getBoundingClientRect();
- var ttWidth = tooltipRect.width + 10;
- var ttHeight = tooltipRect.height + 10;
- var x = this.tConfig.fixed.offsetX;
- var y = this.tConfig.fixed.offsetY;
- var fixed = this.tConfig.fixed.position.toLowerCase();
- if (fixed.indexOf('right') > -1) {
- x = x + w.globals.svgWidth - ttWidth + 10;
- }
- if (fixed.indexOf('bottom') > -1) {
- y = y + w.globals.svgHeight - ttHeight - 10;
- }
- tooltipEl.style.left = x + 'px';
- tooltipEl.style.top = y + 'px';
- return {
- x: x,
- y: y,
- ttWidth: ttWidth,
- ttHeight: ttHeight
- };
- }
- }, {
- key: "addDatapointEventsListeners",
- value: function addDatapointEventsListeners(seriesHoverParams) {
- var w = this.w;
- var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-rangebar-area');
- this.addPathsEventListeners(points, seriesHoverParams);
- }
- }, {
- key: "addPathsEventListeners",
- value: function addPathsEventListeners(paths, opts) {
- var self = this;
- var _loop = function _loop(p) {
- var extendedOpts = {
- paths: paths[p],
- tooltipEl: opts.tooltipEl,
- tooltipY: opts.tooltipY,
- tooltipX: opts.tooltipX,
- elGrid: opts.elGrid,
- hoverArea: opts.hoverArea,
- ttItems: opts.ttItems
- };
- var events = ['mousemove', 'mouseup', 'touchmove', 'mouseout', 'touchend'];
- events.map(function (ev) {
- return paths[p].addEventListener(ev, self.seriesHover.bind(self, extendedOpts), {
- capture: false,
- passive: true
- });
- });
- };
- for (var p = 0; p < paths.length; p++) {
- _loop(p);
- }
- }
-
- }, {
- key: "seriesHover",
- value: function seriesHover(opt, e) {
- var _this = this;
- var chartGroups = [];
- var w = this.w;
- if (w.config.chart.group) {
- chartGroups = this.ctx.getGroupedCharts();
- }
- if (w.globals.axisCharts && (w.globals.minX === -Infinity && w.globals.maxX === Infinity || w.globals.dataPoints === 0)) {
- return;
- }
- if (chartGroups.length) {
- chartGroups.forEach(function (ch) {
- var tooltipEl = _this.getElTooltip(ch);
- var newOpts = {
- paths: opt.paths,
- tooltipEl: tooltipEl,
- tooltipY: opt.tooltipY,
- tooltipX: opt.tooltipX,
- elGrid: opt.elGrid,
- hoverArea: opt.hoverArea,
- ttItems: ch.w.globals.tooltip.ttItems
- };
- if (ch.w.globals.minX === _this.w.globals.minX && ch.w.globals.maxX === _this.w.globals.maxX) {
- ch.w.globals.tooltip.seriesHoverByContext({
- chartCtx: ch,
- ttCtx: ch.w.globals.tooltip,
- opt: newOpts,
- e: e
- });
- }
- });
- } else {
- this.seriesHoverByContext({
- chartCtx: this.ctx,
- ttCtx: this.w.globals.tooltip,
- opt: opt,
- e: e
- });
- }
- }
- }, {
- key: "seriesHoverByContext",
- value: function seriesHoverByContext(_ref) {
- var chartCtx = _ref.chartCtx,
- ttCtx = _ref.ttCtx,
- opt = _ref.opt,
- e = _ref.e;
- var w = chartCtx.w;
- var tooltipEl = this.getElTooltip();
- ttCtx.tooltipRect = {
- x: 0,
- y: 0,
- ttWidth: tooltipEl.getBoundingClientRect().width,
- ttHeight: tooltipEl.getBoundingClientRect().height
- };
- ttCtx.e = e;
- if (ttCtx.tooltipUtil.hasBars() && !w.globals.comboCharts && !ttCtx.isBarShared) {
- if (this.tConfig.onDatasetHover.highlightDataSeries) {
- var series = new Series(chartCtx);
- series.toggleSeriesOnHover(e, e.target.parentNode);
- }
- }
- if (ttCtx.fixedTooltip) {
- ttCtx.drawFixedTooltipRect();
- }
- if (w.globals.axisCharts) {
- ttCtx.axisChartsTooltips({
- e: e,
- opt: opt,
- tooltipRect: ttCtx.tooltipRect
- });
- } else {
-
- ttCtx.nonAxisChartsTooltips({
- e: e,
- opt: opt,
- tooltipRect: ttCtx.tooltipRect
- });
- }
- }
- }, {
- key: "axisChartsTooltips",
- value: function axisChartsTooltips(_ref2) {
- var e = _ref2.e,
- opt = _ref2.opt;
- var w = this.w;
- var x, y;
- var seriesBound = opt.elGrid.getBoundingClientRect();
- var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
- var clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
- this.clientY = clientY;
- this.clientX = clientX;
- w.globals.capturedSeriesIndex = -1;
- w.globals.capturedDataPointIndex = -1;
- if (clientY < seriesBound.top || clientY > seriesBound.top + seriesBound.height) {
- this.handleMouseOut(opt);
- return;
- }
- if (Array.isArray(this.tConfig.enabledOnSeries) && !w.config.tooltip.shared) {
- var index = parseInt(opt.paths.getAttribute('index'), 10);
- if (this.tConfig.enabledOnSeries.indexOf(index) < 0) {
- this.handleMouseOut(opt);
- return;
- }
- }
- var tooltipEl = this.getElTooltip();
- var xcrosshairs = this.getElXCrosshairs();
- var isStickyTooltip = w.globals.xyCharts || w.config.chart.type === 'bar' && !w.globals.isBarHorizontal && this.tooltipUtil.hasBars() && this.tConfig.shared || w.globals.comboCharts && this.tooltipUtil.hasBars();
- if (w.globals.isBarHorizontal && this.tooltipUtil.hasBars()) {
- isStickyTooltip = false;
- }
- if (e.type === 'mousemove' || e.type === 'touchmove' || e.type === 'mouseup') {
- if (xcrosshairs !== null) {
- xcrosshairs.classList.add('apexcharts-active');
- }
- if (this.ycrosshairs !== null && this.blyaxisTooltip) {
- this.ycrosshairs.classList.add('apexcharts-active');
- }
- if (isStickyTooltip && !this.showOnIntersect) {
- this.handleStickyTooltip(e, clientX, clientY, opt);
- } else {
- if (w.config.chart.type === 'heatmap') {
- var markerXY = this.intersect.handleHeatTooltip({
- e: e,
- opt: opt,
- x: x,
- y: y
- });
- x = markerXY.x;
- y = markerXY.y;
- tooltipEl.style.left = x + 'px';
- tooltipEl.style.top = y + 'px';
- } else {
- if (this.tooltipUtil.hasBars()) {
- this.intersect.handleBarTooltip({
- e: e,
- opt: opt
- });
- }
- if (this.tooltipUtil.hasMarkers()) {
-
- this.intersect.handleMarkerTooltip({
- e: e,
- opt: opt,
- x: x,
- y: y
- });
- }
- }
- }
- if (this.blyaxisTooltip) {
- for (var yt = 0; yt < w.config.yaxis.length; yt++) {
- this.axesTooltip.drawYaxisTooltipText(yt, clientY, this.xyRatios);
- }
- }
- opt.tooltipEl.classList.add('apexcharts-active');
- } else if (e.type === 'mouseout' || e.type === 'touchend') {
- this.handleMouseOut(opt);
- }
- }
- }, {
- key: "nonAxisChartsTooltips",
- value: function nonAxisChartsTooltips(_ref3) {
- var e = _ref3.e,
- opt = _ref3.opt,
- tooltipRect = _ref3.tooltipRect;
- var w = this.w;
- var rel = opt.paths.getAttribute('rel');
- var tooltipEl = this.getElTooltip();
- var seriesBound = w.globals.dom.elWrap.getBoundingClientRect();
- if (e.type === 'mousemove' || e.type === 'touchmove') {
- tooltipEl.classList.add('apexcharts-active');
- this.tooltipLabels.drawSeriesTexts({
- ttItems: opt.ttItems,
- i: parseInt(rel, 10) - 1,
- shared: false
- });
- var x = w.globals.clientX - seriesBound.left - tooltipRect.ttWidth / 2;
- var y = w.globals.clientY - seriesBound.top - tooltipRect.ttHeight - 10;
- tooltipEl.style.left = x + 'px';
- tooltipEl.style.top = y + 'px';
- } else if (e.type === 'mouseout' || e.type === 'touchend') {
- tooltipEl.classList.remove('apexcharts-active');
- }
- }
- }, {
- key: "handleStickyTooltip",
- value: function handleStickyTooltip(e, clientX, clientY, opt) {
- var w = this.w;
- var capj = this.tooltipUtil.getNearestValues({
- context: this,
- hoverArea: opt.hoverArea,
- elGrid: opt.elGrid,
- clientX: clientX,
- clientY: clientY
- });
- var j = capj.j;
- var capturedSeries = capj.capturedSeries;
- if (capj.hoverX < 0 || capj.hoverX > w.globals.gridWidth) {
- this.handleMouseOut(opt);
- return;
- }
- if (capturedSeries !== null) {
- this.handleStickyCapturedSeries(e, capturedSeries, opt, j);
- } else {
-
-
- if (this.tooltipUtil.isXoverlap(j)) {
- this.create(e, this, 0, j, opt.ttItems);
- }
- }
- }
- }, {
- key: "handleStickyCapturedSeries",
- value: function handleStickyCapturedSeries(e, capturedSeries, opt, j) {
- var w = this.w;
- var ignoreNull = w.globals.series[capturedSeries][j] === null;
- if (ignoreNull) {
- this.handleMouseOut(opt);
- return;
- }
- if (typeof w.globals.series[capturedSeries][j] !== 'undefined') {
- if (this.tConfig.shared && this.tooltipUtil.isXoverlap(j) && this.tooltipUtil.isInitialSeriesSameLen()) {
- this.create(e, this, capturedSeries, j, opt.ttItems);
- } else {
- this.create(e, this, capturedSeries, j, opt.ttItems, false);
- }
- } else {
- if (this.tooltipUtil.isXoverlap(j)) {
- this.create(e, this, 0, j, opt.ttItems);
- }
- }
- }
- }, {
- key: "deactivateHoverFilter",
- value: function deactivateHoverFilter() {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var allPaths = w.globals.dom.Paper.select(".apexcharts-bar-area");
- for (var b = 0; b < allPaths.length; b++) {
- graphics.pathMouseLeave(allPaths[b]);
- }
- }
- }, {
- key: "handleMouseOut",
- value: function handleMouseOut(opt) {
- var w = this.w;
- var xcrosshairs = this.getElXCrosshairs();
- opt.tooltipEl.classList.remove('apexcharts-active');
- this.deactivateHoverFilter();
- if (w.config.chart.type !== 'bubble') {
- this.marker.resetPointsSize();
- }
- if (xcrosshairs !== null) {
- xcrosshairs.classList.remove('apexcharts-active');
- }
- if (this.ycrosshairs !== null) {
- this.ycrosshairs.classList.remove('apexcharts-active');
- }
- if (this.blxaxisTooltip) {
- this.xaxisTooltip.classList.remove('apexcharts-active');
- }
- if (this.blyaxisTooltip) {
- if (this.yaxisTTEls === null) {
- this.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
- }
- for (var i = 0; i < this.yaxisTTEls.length; i++) {
- this.yaxisTTEls[i].classList.remove('apexcharts-active');
- }
- }
- if (w.config.legend.tooltipHoverFormatter) {
- this.legendLabels.forEach(function (l) {
- var defaultText = l.getAttribute('data:default-text');
- l.innerHTML = decodeURIComponent(defaultText);
- });
- }
- }
- }, {
- key: "markerClick",
- value: function markerClick(e, seriesIndex, dataPointIndex) {
- var w = this.w;
- if (typeof w.config.chart.events.markerClick === 'function') {
- w.config.chart.events.markerClick(e, this.ctx, {
- seriesIndex: seriesIndex,
- dataPointIndex: dataPointIndex,
- w: w
- });
- }
- this.ctx.events.fireEvent('markerClick', [e, this.ctx, {
- seriesIndex: seriesIndex,
- dataPointIndex: dataPointIndex,
- w: w
- }]);
- }
- }, {
- key: "create",
- value: function create(e, context, capturedSeries, j, ttItems) {
- var shared = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
- var w = this.w;
- var ttCtx = context;
- if (e.type === 'mouseup') {
- this.markerClick(e, capturedSeries, j);
- }
- if (shared === null) shared = this.tConfig.shared;
- var hasMarkers = this.tooltipUtil.hasMarkers();
- var bars = this.tooltipUtil.getElBars();
- if (w.config.legend.tooltipHoverFormatter) {
- var legendFormatter = w.config.legend.tooltipHoverFormatter;
- var els = Array.from(this.legendLabels);
- els.forEach(function (l) {
- var legendName = l.getAttribute('data:default-text');
- l.innerHTML = decodeURIComponent(legendName);
- });
- for (var i = 0; i < els.length; i++) {
- var l = els[i];
- var lsIndex = parseInt(l.getAttribute('i'), 10);
- var legendName = decodeURIComponent(l.getAttribute('data:default-text'));
- var text = legendFormatter(legendName, {
- seriesIndex: shared ? lsIndex : capturedSeries,
- dataPointIndex: j,
- w: w
- });
- if (!shared) {
- l.innerHTML = lsIndex === capturedSeries ? text : legendName;
- if (capturedSeries === lsIndex) {
- break;
- }
- } else {
- l.innerHTML = w.globals.collapsedSeriesIndices.indexOf(lsIndex) < 0 ? text : legendName;
- }
- }
- }
- if (shared) {
- ttCtx.tooltipLabels.drawSeriesTexts({
- ttItems: ttItems,
- i: capturedSeries,
- j: j,
- shared: this.showOnIntersect ? false : this.tConfig.shared
- });
- if (hasMarkers) {
- if (w.globals.markers.largestSize > 0) {
- ttCtx.marker.enlargePoints(j);
- } else {
- ttCtx.tooltipPosition.moveDynamicPointsOnHover(j);
- }
- }
- if (this.tooltipUtil.hasBars()) {
- this.barSeriesHeight = this.tooltipUtil.getBarsHeight(bars);
- if (this.barSeriesHeight > 0) {
-
- var graphics = new Graphics(this.ctx);
- var paths = w.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(j, "']"));
- this.deactivateHoverFilter();
- this.tooltipPosition.moveStickyTooltipOverBars(j);
- for (var b = 0; b < paths.length; b++) {
- graphics.pathMouseEnter(paths[b]);
- }
- }
- }
- } else {
- ttCtx.tooltipLabels.drawSeriesTexts({
- shared: false,
- ttItems: ttItems,
- i: capturedSeries,
- j: j
- });
- if (this.tooltipUtil.hasBars()) {
- ttCtx.tooltipPosition.moveStickyTooltipOverBars(j);
- }
- if (hasMarkers) {
- ttCtx.tooltipPosition.moveMarkers(capturedSeries, j);
- }
- }
- }
- }]);
- return Tooltip;
- }();
- var BarDataLabels = function () {
- function BarDataLabels(barCtx) {
- _classCallCheck(this, BarDataLabels);
- this.w = barCtx.w;
- this.barCtx = barCtx;
- }
-
- _createClass(BarDataLabels, [{
- key: "handleBarDataLabels",
- value: function handleBarDataLabels(opts) {
- var x = opts.x,
- y = opts.y,
- y1 = opts.y1,
- y2 = opts.y2,
- i = opts.i,
- j = opts.j,
- realIndex = opts.realIndex,
- series = opts.series,
- barHeight = opts.barHeight,
- barWidth = opts.barWidth,
- barYPosition = opts.barYPosition,
- visibleSeries = opts.visibleSeries,
- renderedPath = opts.renderedPath;
- var w = this.w;
- var graphics = new Graphics(this.barCtx.ctx);
- var strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
- var bcx = x + parseFloat(barWidth * visibleSeries);
- var bcy = y + parseFloat(barHeight * visibleSeries);
- if (w.globals.isXNumeric && !w.globals.isBarHorizontal) {
- bcx = x + parseFloat(barWidth * (visibleSeries + 1));
- bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth;
- }
- var dataLabels = null;
- var dataLabelsX = x;
- var dataLabelsY = y;
- var dataLabelsPos = {};
- var dataLabelsConfig = w.config.dataLabels;
- var barDataLabelsConfig = this.barCtx.barOptions.dataLabels;
- if (typeof barYPosition !== 'undefined' && this.barCtx.isTimelineBar) {
- bcy = barYPosition;
- dataLabelsY = barYPosition;
- }
- var offX = dataLabelsConfig.offsetX;
- var offY = dataLabelsConfig.offsetY;
- var textRects = {
- width: 0,
- height: 0
- };
- if (w.config.dataLabels.enabled) {
- textRects = graphics.getTextRects(w.globals.yLabelFormatters[0](w.globals.maxY), parseFloat(dataLabelsConfig.style.fontSize));
- }
- var params = {
- x: x,
- y: y,
- i: i,
- j: j,
- renderedPath: renderedPath,
- bcx: bcx,
- bcy: bcy,
- barHeight: barHeight,
- barWidth: barWidth,
- textRects: textRects,
- strokeWidth: strokeWidth,
- dataLabelsX: dataLabelsX,
- dataLabelsY: dataLabelsY,
- barDataLabelsConfig: barDataLabelsConfig,
- offX: offX,
- offY: offY
- };
- if (this.barCtx.isHorizontal) {
- dataLabelsPos = this.calculateBarsDataLabelsPosition(params);
- } else {
- dataLabelsPos = this.calculateColumnsDataLabelsPosition(params);
- }
- renderedPath.attr({
- cy: dataLabelsPos.bcy,
- cx: dataLabelsPos.bcx,
- j: j,
- val: series[i][j],
- barHeight: barHeight,
- barWidth: barWidth
- });
- dataLabels = this.drawCalculatedDataLabels({
- x: dataLabelsPos.dataLabelsX,
- y: dataLabelsPos.dataLabelsY,
- val: this.barCtx.isTimelineBar ? [y1, y2] : series[i][j],
- i: realIndex,
- j: j,
- barWidth: barWidth,
- barHeight: barHeight,
- textRects: textRects,
- dataLabelsConfig: dataLabelsConfig
- });
- return dataLabels;
- }
- }, {
- key: "calculateColumnsDataLabelsPosition",
- value: function calculateColumnsDataLabelsPosition(opts) {
- var w = this.w;
- var i = opts.i,
- j = opts.j,
- y = opts.y,
- bcx = opts.bcx,
- barWidth = opts.barWidth,
- barHeight = opts.barHeight,
- textRects = opts.textRects,
- dataLabelsY = opts.dataLabelsY,
- barDataLabelsConfig = opts.barDataLabelsConfig,
- strokeWidth = opts.strokeWidth,
- offX = opts.offX,
- offY = opts.offY;
- var dataLabelsX;
- barHeight = Math.abs(barHeight);
- var vertical = w.config.plotOptions.bar.dataLabels.orientation === 'vertical';
- bcx = bcx - strokeWidth / 2;
- var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
- if (w.globals.isXNumeric) {
- dataLabelsX = bcx - barWidth / 2 + offX;
- } else {
- dataLabelsX = bcx - dataPointsDividedWidth + barWidth / 2 + offX;
- }
- if (vertical) {
- var offsetDLX = 2;
- dataLabelsX = dataLabelsX + textRects.height / 2 - strokeWidth / 2 - offsetDLX;
- }
- var valIsNegative = this.barCtx.series[i][j] < 0;
- if (this.barCtx.isReversed) {
- y = y - barHeight;
- }
- switch (barDataLabelsConfig.position) {
- case 'center':
- if (vertical) {
- if (valIsNegative) {
- dataLabelsY = y + barHeight / 2 + offY;
- } else {
- dataLabelsY = y + barHeight / 2 - offY;
- }
- } else {
- if (valIsNegative) {
- dataLabelsY = y + barHeight / 2 + textRects.height / 2 + offY;
- } else {
- dataLabelsY = y + barHeight / 2 + textRects.height / 2 - offY;
- }
- }
- break;
- case 'bottom':
- if (vertical) {
- if (valIsNegative) {
- dataLabelsY = y + barHeight + offY;
- } else {
- dataLabelsY = y + barHeight - offY;
- }
- } else {
- if (valIsNegative) {
- dataLabelsY = y + barHeight + textRects.height + strokeWidth + offY;
- } else {
- dataLabelsY = y + barHeight - textRects.height / 2 + strokeWidth - offY;
- }
- }
- break;
- case 'top':
- if (vertical) {
- if (valIsNegative) {
- dataLabelsY = y + offY;
- } else {
- dataLabelsY = y - offY;
- }
- } else {
- if (valIsNegative) {
- dataLabelsY = y - textRects.height / 2 - offY;
- } else {
- dataLabelsY = y + textRects.height + offY;
- }
- }
- break;
- }
- if (!w.config.chart.stacked) {
- if (dataLabelsY < 0) {
- dataLabelsY = 0 + strokeWidth;
- } else if (dataLabelsY + textRects.height / 3 > w.globals.gridHeight) {
- dataLabelsY = w.globals.gridHeight - strokeWidth;
- }
- }
- return {
- bcx: bcx,
- bcy: y,
- dataLabelsX: dataLabelsX,
- dataLabelsY: dataLabelsY
- };
- }
- }, {
- key: "calculateBarsDataLabelsPosition",
- value: function calculateBarsDataLabelsPosition(opts) {
- var w = this.w;
- var x = opts.x,
- i = opts.i,
- j = opts.j,
- bcy = opts.bcy,
- barHeight = opts.barHeight,
- barWidth = opts.barWidth,
- textRects = opts.textRects,
- dataLabelsX = opts.dataLabelsX,
- strokeWidth = opts.strokeWidth,
- barDataLabelsConfig = opts.barDataLabelsConfig,
- offX = opts.offX,
- offY = opts.offY;
- var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
- barWidth = Math.abs(barWidth);
- var dataLabelsY = bcy - (this.barCtx.isTimelineBar ? 0 : dataPointsDividedHeight) + barHeight / 2 + textRects.height / 2 + offY - 3;
- var valIsNegative = this.barCtx.series[i][j] < 0;
- var newX = x;
- if (this.barCtx.isReversed) {
- newX = x + barWidth;
- x = w.globals.gridWidth - barWidth;
- }
- switch (barDataLabelsConfig.position) {
- case 'center':
- if (valIsNegative) {
- dataLabelsX = newX - barWidth / 2 - offX;
- } else {
- dataLabelsX = newX - barWidth / 2 + offX;
- }
- break;
- case 'bottom':
- if (valIsNegative) {
- dataLabelsX = newX + barWidth - strokeWidth - Math.round(textRects.width / 2) - offX;
- } else {
- dataLabelsX = newX - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX;
- }
- break;
- case 'top':
- if (valIsNegative) {
- dataLabelsX = newX - strokeWidth + Math.round(textRects.width / 2) - offX;
- } else {
- dataLabelsX = newX - strokeWidth - Math.round(textRects.width / 2) + offX;
- }
- break;
- }
- if (!w.config.chart.stacked) {
- if (dataLabelsX < 0) {
- dataLabelsX = dataLabelsX + textRects.width + strokeWidth;
- } else if (dataLabelsX + textRects.width / 2 > w.globals.gridWidth) {
- dataLabelsX = w.globals.gridWidth - textRects.width - strokeWidth;
- }
- }
- return {
- bcx: x,
- bcy: bcy,
- dataLabelsX: dataLabelsX,
- dataLabelsY: dataLabelsY
- };
- }
- }, {
- key: "drawCalculatedDataLabels",
- value: function drawCalculatedDataLabels(_ref) {
- var x = _ref.x,
- y = _ref.y,
- val = _ref.val,
- i = _ref.i,
- j = _ref.j,
- textRects = _ref.textRects,
- barHeight = _ref.barHeight,
- barWidth = _ref.barWidth,
- dataLabelsConfig = _ref.dataLabelsConfig;
- var w = this.w;
- var rotate = 'rotate(0)';
- if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') rotate = "rotate(-90, ".concat(x, ", ").concat(y, ")");
- var dataLabels = new DataLabels(this.barCtx.ctx);
- var graphics = new Graphics(this.barCtx.ctx);
- var formatter = dataLabelsConfig.formatter;
- var elDataLabelsWrap = null;
- var isSeriesNotCollapsed = w.globals.collapsedSeriesIndices.indexOf(i) > -1;
- if (dataLabelsConfig.enabled && !isSeriesNotCollapsed) {
- elDataLabelsWrap = graphics.group({
- class: 'apexcharts-data-labels',
- transform: rotate
- });
- var text = '';
- if (typeof val !== 'undefined') {
- text = formatter(val, {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- }
- if (val === 0 && w.config.chart.stacked) {
-
- text = '';
- }
- var valIsNegative = w.globals.series[i][j] <= 0;
- var position = w.config.plotOptions.bar.dataLabels.position;
- if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
- if (position === 'top') {
- if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
- }
- if (position === 'center') {
- dataLabelsConfig.textAnchor = 'middle';
- }
- if (position === 'bottom') {
- if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
- }
- }
- if (this.barCtx.isTimelineBar && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
-
- var txRect = graphics.getTextRects(text, parseFloat(dataLabelsConfig.style.fontSize));
- if (barWidth < txRect.width) {
- text = '';
- }
- }
- if (w.config.chart.stacked && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
-
-
- if (this.barCtx.isHorizontal) {
- barWidth = Math.abs(w.globals.series[i][j]) / this.barCtx.invertedYRatio[this.barCtx.yaxisIndex];
-
-
- if (barWidth > 0 && textRects.width / 1.6 > barWidth || barWidth < 0 && textRects.width / 1.6 < barWidth) {
- text = '';
- }
- } else {
- barHeight = Math.abs(w.globals.series[i][j]) / this.barCtx.yRatio[this.barCtx.yaxisIndex];
- if (textRects.height / 1.6 > barHeight) {
- text = '';
- }
- }
- }
- var modifiedDataLabelsConfig = _objectSpread2({}, dataLabelsConfig);
- if (this.barCtx.isHorizontal) {
- if (val < 0) {
- if (dataLabelsConfig.textAnchor === 'start') {
- modifiedDataLabelsConfig.textAnchor = 'end';
- } else if (dataLabelsConfig.textAnchor === 'end') {
- modifiedDataLabelsConfig.textAnchor = 'start';
- }
- }
- }
- dataLabels.plotDataLabelsText({
- x: x,
- y: y,
- text: text,
- i: i,
- j: j,
- parent: elDataLabelsWrap,
- dataLabelsConfig: modifiedDataLabelsConfig,
- alwaysDrawDataLabel: true,
- offsetCorrection: true
- });
- }
- return elDataLabelsWrap;
- }
- }]);
- return BarDataLabels;
- }();
- var Helpers$3 = function () {
- function Helpers(barCtx) {
- _classCallCheck(this, Helpers);
- this.w = barCtx.w;
- this.barCtx = barCtx;
- }
- _createClass(Helpers, [{
- key: "initVariables",
- value: function initVariables(series) {
- var w = this.w;
- this.barCtx.series = series;
- this.barCtx.totalItems = 0;
- this.barCtx.seriesLen = 0;
- this.barCtx.visibleI = -1;
- this.barCtx.visibleItems = 1;
- for (var sl = 0; sl < series.length; sl++) {
- if (series[sl].length > 0) {
- this.barCtx.seriesLen = this.barCtx.seriesLen + 1;
- this.barCtx.totalItems += series[sl].length;
- }
- if (w.globals.isXNumeric) {
-
- for (var j = 0; j < series[sl].length; j++) {
- if (w.globals.seriesX[sl][j] > w.globals.minX && w.globals.seriesX[sl][j] < w.globals.maxX) {
- this.barCtx.visibleItems++;
- }
- }
- } else {
- this.barCtx.visibleItems = w.globals.dataPoints;
- }
- }
- if (this.barCtx.seriesLen === 0) {
-
- this.barCtx.seriesLen = 1;
- }
- }
- }, {
- key: "initialPositions",
- value: function initialPositions() {
- var w = this.w;
- var x, y, yDivision, xDivision, barHeight, barWidth, zeroH, zeroW;
- var dataPoints = w.globals.dataPoints;
- if (this.barCtx.isTimelineBar) {
-
- dataPoints = w.globals.labels.length;
- }
- if (this.barCtx.isHorizontal) {
-
- yDivision = w.globals.gridHeight / dataPoints;
- barHeight = yDivision / this.barCtx.seriesLen;
- if (w.globals.isXNumeric) {
- yDivision = w.globals.gridHeight / this.barCtx.totalItems;
- barHeight = yDivision / this.barCtx.seriesLen;
- }
- barHeight = barHeight * parseInt(this.barCtx.barOptions.barHeight, 10) / 100;
- zeroW = this.barCtx.baseLineInvertedY + w.globals.padHorizontal + (this.barCtx.isReversed ? w.globals.gridWidth : 0) - (this.barCtx.isReversed ? this.barCtx.baseLineInvertedY * 2 : 0);
- y = (yDivision - barHeight * this.barCtx.seriesLen) / 2;
- } else {
-
- xDivision = w.globals.gridWidth / this.barCtx.visibleItems;
- if (w.config.xaxis.convertedCatToNumeric) {
- xDivision = w.globals.gridWidth / w.globals.dataPoints;
- }
- barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
- if (w.globals.isXNumeric) {
-
- var xRatio = this.barCtx.xRatio;
- if (w.config.xaxis.convertedCatToNumeric) {
- xRatio = this.barCtx.initialXRatio;
- }
- if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
- xDivision = w.globals.minXDiff / xRatio;
- }
- barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
- if (barWidth < 1) {
- barWidth = 1;
- }
- }
- zeroH = w.globals.gridHeight - this.barCtx.baseLineY[this.barCtx.yaxisIndex] - (this.barCtx.isReversed ? w.globals.gridHeight : 0) + (this.barCtx.isReversed ? this.barCtx.baseLineY[this.barCtx.yaxisIndex] * 2 : 0);
- x = w.globals.padHorizontal + (xDivision - barWidth * this.barCtx.seriesLen) / 2;
- }
- return {
- x: x,
- y: y,
- yDivision: yDivision,
- xDivision: xDivision,
- barHeight: barHeight,
- barWidth: barWidth,
- zeroH: zeroH,
- zeroW: zeroW
- };
- }
- }, {
- key: "getPathFillColor",
- value: function getPathFillColor(series, i, j, realIndex) {
- var w = this.w;
- var fill = new Fill(this.barCtx.ctx);
- var fillColor = null;
- var seriesNumber = this.barCtx.barOptions.distributed ? j : i;
- if (this.barCtx.barOptions.colors.ranges.length > 0) {
- var colorRange = this.barCtx.barOptions.colors.ranges;
- colorRange.map(function (range) {
- if (series[i][j] >= range.from && series[i][j] <= range.to) {
- fillColor = range.color;
- }
- });
- }
- if (w.config.series[i].data[j] && w.config.series[i].data[j].fillColor) {
- fillColor = w.config.series[i].data[j].fillColor;
- }
- var pathFill = fill.fillPath({
- seriesNumber: this.barCtx.barOptions.distributed ? seriesNumber : realIndex,
- dataPointIndex: j,
- color: fillColor,
- value: series[i][j]
- });
- return pathFill;
- }
- }, {
- key: "getStrokeWidth",
- value: function getStrokeWidth(i, j, realIndex) {
- var strokeWidth = 0;
- var w = this.w;
- if (typeof this.barCtx.series[i][j] === 'undefined' || this.barCtx.series[i][j] === null) {
- this.barCtx.isNullValue = true;
- } else {
- this.barCtx.isNullValue = false;
- }
- if (w.config.stroke.show) {
- if (!this.barCtx.isNullValue) {
- strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
- }
- }
- return strokeWidth;
- }
- }, {
- key: "barBackground",
- value: function barBackground(_ref) {
- var bc = _ref.bc,
- i = _ref.i,
- x1 = _ref.x1,
- x2 = _ref.x2,
- y1 = _ref.y1,
- y2 = _ref.y2,
- elSeries = _ref.elSeries;
- var w = this.w;
- var graphics = new Graphics(this.barCtx.ctx);
- var sr = new Series(this.barCtx.ctx);
- var activeSeriesIndex = sr.getActiveConfigSeriesIndex();
- if (this.barCtx.barOptions.colors.backgroundBarColors.length > 0 && activeSeriesIndex === i) {
- if (bc >= this.barCtx.barOptions.colors.backgroundBarColors.length) {
- bc = 0;
- }
- var bcolor = this.barCtx.barOptions.colors.backgroundBarColors[bc];
- var rect = graphics.drawRect(typeof x1 !== 'undefined' ? x1 : 0, typeof y1 !== 'undefined' ? y1 : 0, typeof x2 !== 'undefined' ? x2 : w.globals.gridWidth, typeof y2 !== 'undefined' ? y2 : w.globals.gridHeight, this.barCtx.barOptions.colors.backgroundBarRadius, bcolor, this.barCtx.barOptions.colors.backgroundBarOpacity);
- elSeries.add(rect);
- rect.node.classList.add('apexcharts-backgroundBar');
- }
- }
- }, {
- key: "getColumnPaths",
- value: function getColumnPaths(_ref2) {
- var barWidth = _ref2.barWidth,
- barXPosition = _ref2.barXPosition,
- yRatio = _ref2.yRatio,
- y1 = _ref2.y1,
- y2 = _ref2.y2,
- strokeWidth = _ref2.strokeWidth,
- series = _ref2.series,
- realIndex = _ref2.realIndex,
- i = _ref2.i,
- j = _ref2.j,
- w = _ref2.w;
- var graphics = new Graphics(this.barCtx.ctx);
- strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
- if (!strokeWidth) strokeWidth = 0;
- var shapeOpts = {
- barWidth: barWidth,
- strokeWidth: strokeWidth,
- yRatio: yRatio,
- barXPosition: barXPosition,
- y1: y1,
- y2: y2
- };
- var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
- var x1 = barXPosition;
- var x2 = barXPosition + barWidth;
- var pathTo = graphics.move(x1, newPath.y1);
- var pathFrom = graphics.move(x1, newPath.y1);
- if (w.globals.previousPaths.length > 0) {
- pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
- }
- pathTo = pathTo + graphics.line(x1, newPath.y2) + newPath.endingPath + graphics.line(x2 - strokeWidth, newPath.y2) + graphics.line(x2 - strokeWidth, newPath.y1) + newPath.startingPath + 'z';
- pathFrom = pathFrom + graphics.line(x1, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x1, y1);
- return {
- pathTo: pathTo,
- pathFrom: pathFrom
- };
- }
- }, {
- key: "getBarpaths",
- value: function getBarpaths(_ref3) {
- var barYPosition = _ref3.barYPosition,
- barHeight = _ref3.barHeight,
- x1 = _ref3.x1,
- x2 = _ref3.x2,
- strokeWidth = _ref3.strokeWidth,
- series = _ref3.series,
- realIndex = _ref3.realIndex,
- i = _ref3.i,
- j = _ref3.j,
- w = _ref3.w;
- var graphics = new Graphics(this.barCtx.ctx);
- strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
- if (!strokeWidth) strokeWidth = 0;
- var shapeOpts = {
- barHeight: barHeight,
- strokeWidth: strokeWidth,
- barYPosition: barYPosition,
- x2: x2,
- x1: x1
- };
- var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
- var pathTo = graphics.move(newPath.x1, barYPosition);
- var pathFrom = graphics.move(newPath.x1, barYPosition);
- if (w.globals.previousPaths.length > 0) {
- pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
- }
- var y1 = barYPosition;
- var y2 = barYPosition + barHeight;
- pathTo = pathTo + graphics.line(newPath.x2, y1) + newPath.endingPath + graphics.line(newPath.x2, y2 - strokeWidth) + graphics.line(newPath.x1, y2 - strokeWidth) + newPath.startingPath + 'z';
- pathFrom = pathFrom + graphics.line(x1, y1) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y1);
- return {
- pathTo: pathTo,
- pathFrom: pathFrom
- };
- }
-
- }, {
- key: "getRoundedBars",
- value: function getRoundedBars(w, opts, series, i, j) {
- var graphics = new Graphics(this.barCtx.ctx);
- var strokeWidth = Array.isArray(opts.strokeWidth) ? opts.strokeWidth[i] : opts.strokeWidth;
- if (!strokeWidth) strokeWidth = 0;
- if (this.barCtx.isHorizontal) {
- var endingShape = null;
- var startingShape = '';
- var x2 = opts.x2;
- var x1 = opts.x1;
- if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
- var inverse = series[i][j] < 0;
- var eX = opts.barHeight / 2 - strokeWidth;
- if (inverse) eX = -opts.barHeight / 2 - strokeWidth;
- if (eX > Math.abs(x2 - x1)) {
- eX = Math.abs(x2 - x1);
- }
- if (this.barCtx.barOptions.endingShape === 'rounded') {
- x2 = opts.x2 - eX / 2;
- }
- if (this.barCtx.barOptions.startingShape === 'rounded') {
- x1 = opts.x1 + eX / 2;
- }
- switch (this.barCtx.barOptions.endingShape) {
- case 'flat':
- endingShape = graphics.line(x2, opts.barYPosition + opts.barHeight - strokeWidth);
- break;
- case 'rounded':
- endingShape = graphics.quadraticCurve(x2 + eX, opts.barYPosition + (opts.barHeight - strokeWidth) / 2, x2, opts.barYPosition + opts.barHeight - strokeWidth);
- break;
- }
- switch (this.barCtx.barOptions.startingShape) {
- case 'flat':
- startingShape = graphics.line(x1, opts.barYPosition + opts.barHeight - strokeWidth);
- break;
- case 'rounded':
- startingShape = graphics.quadraticCurve(x1 - eX, opts.barYPosition + opts.barHeight / 2, x1, opts.barYPosition);
- break;
- }
- }
- return {
- endingPath: endingShape,
- startingPath: startingShape,
- x2: x2,
- x1: x1
- };
- } else {
- var _endingShape = null;
- var _startingShape = '';
- var y2 = opts.y2;
- var y1 = opts.y1;
- if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
- var _inverse = series[i][j] < 0;
- var eY = opts.barWidth / 2 - strokeWidth;
- if (_inverse) eY = -opts.barWidth / 2 - strokeWidth;
- if (eY > Math.abs(y2 - y1)) {
- eY = Math.abs(y2 - y1);
- }
- if (this.barCtx.barOptions.endingShape === 'rounded') {
-
- y2 = y2 + eY / 2;
- }
- if (this.barCtx.barOptions.startingShape === 'rounded') {
- y1 = y1 - eY / 2;
- }
- switch (this.barCtx.barOptions.endingShape) {
- case 'flat':
- _endingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y2);
- break;
- case 'rounded':
- _endingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y2 - eY, opts.barXPosition + opts.barWidth - strokeWidth, y2);
- break;
- }
- switch (this.barCtx.barOptions.startingShape) {
- case 'flat':
- _startingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y1);
- break;
- case 'rounded':
- _startingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y1 + eY, opts.barXPosition, y1);
- break;
- }
- }
- return {
- endingPath: _endingShape,
- startingPath: _startingShape,
- y2: y2,
- y1: y1
- };
- }
- }
- }]);
- return Helpers;
- }();
-
- var Bar = function () {
- function Bar(ctx, xyRatios) {
- _classCallCheck(this, Bar);
- this.ctx = ctx;
- this.w = ctx.w;
- var w = this.w;
- this.barOptions = w.config.plotOptions.bar;
- this.isHorizontal = this.barOptions.horizontal;
- this.strokeWidth = w.config.stroke.width;
- this.isNullValue = false;
- this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
- this.xyRatios = xyRatios;
- if (this.xyRatios !== null) {
- this.xRatio = xyRatios.xRatio;
- this.initialXRatio = xyRatios.initialXRatio;
- this.yRatio = xyRatios.yRatio;
- this.invertedXRatio = xyRatios.invertedXRatio;
- this.invertedYRatio = xyRatios.invertedYRatio;
- this.baseLineY = xyRatios.baseLineY;
- this.baseLineInvertedY = xyRatios.baseLineInvertedY;
- }
- this.yaxisIndex = 0;
- this.seriesLen = 0;
- this.barHelpers = new Helpers$3(this);
- }
-
- _createClass(Bar, [{
- key: "draw",
- value: function draw(series, seriesIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var coreUtils = new CoreUtils(this.ctx, w);
- series = coreUtils.getLogSeries(series);
- this.series = series;
- this.yRatio = coreUtils.getLogYRatios(this.yRatio);
- this.barHelpers.initVariables(series);
- var ret = graphics.group({
- class: 'apexcharts-bar-series apexcharts-plot-series'
- });
- if (w.config.dataLabels.enabled) {
- if (this.totalItems > this.barOptions.dataLabels.maxItems) {
- console.warn('WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.');
- }
- }
- for (var i = 0, bc = 0; i < series.length; i++, bc++) {
- var x = void 0,
- y = void 0,
- xDivision = void 0,
-
- yDivision = void 0,
-
- zeroH = void 0,
-
- zeroW = void 0;
- var yArrj = [];
- var xArrj = [];
- var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
- var elSeries = graphics.group({
- class: "apexcharts-series",
- rel: i + 1,
- seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
- 'data:realIndex': realIndex
- });
- this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
- if (series[i].length > 0) {
- this.visibleI = this.visibleI + 1;
- }
- var barHeight = 0;
- var barWidth = 0;
- if (this.yRatio.length > 1) {
- this.yaxisIndex = realIndex;
- }
- this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
- var initPositions = this.barHelpers.initialPositions();
- y = initPositions.y;
- barHeight = initPositions.barHeight;
- yDivision = initPositions.yDivision;
- zeroW = initPositions.zeroW;
- x = initPositions.x;
- barWidth = initPositions.barWidth;
- xDivision = initPositions.xDivision;
- zeroH = initPositions.zeroH;
- if (!this.horizontal) {
- xArrj.push(x + barWidth / 2);
- }
- var elDataLabelsWrap = graphics.group({
- class: 'apexcharts-datalabels',
- 'data:realIndex': realIndex
- });
- for (var j = 0; j < w.globals.dataPoints; j++) {
- var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
- var paths = null;
- var pathsParams = {
- indexes: {
- i: i,
- j: j,
- realIndex: realIndex,
- bc: bc
- },
- x: x,
- y: y,
- strokeWidth: strokeWidth,
- elSeries: elSeries
- };
- if (this.isHorizontal) {
- paths = this.drawBarPaths(_objectSpread2({}, pathsParams, {
- barHeight: barHeight,
- zeroW: zeroW,
- yDivision: yDivision
- }));
- barWidth = this.series[i][j] / this.invertedYRatio;
- } else {
- paths = this.drawColumnPaths(_objectSpread2({}, pathsParams, {
- xDivision: xDivision,
- barWidth: barWidth,
- zeroH: zeroH
- }));
- barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex];
- }
- y = paths.y;
- x = paths.x;
- if (j > 0) {
- xArrj.push(x + barWidth / 2);
- }
- yArrj.push(y);
- var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
- this.renderSeries({
- realIndex: realIndex,
- pathFill: pathFill,
- j: j,
- i: i,
- pathFrom: paths.pathFrom,
- pathTo: paths.pathTo,
- strokeWidth: strokeWidth,
- elSeries: elSeries,
- x: x,
- y: y,
- series: series,
- barHeight: barHeight,
- barWidth: barWidth,
- elDataLabelsWrap: elDataLabelsWrap,
- visibleSeries: this.visibleI,
- type: 'bar'
- });
- }
- w.globals.seriesXvalues[realIndex] = xArrj;
- w.globals.seriesYvalues[realIndex] = yArrj;
- ret.add(elSeries);
- }
- return ret;
- }
- }, {
- key: "renderSeries",
- value: function renderSeries(_ref) {
- var realIndex = _ref.realIndex,
- pathFill = _ref.pathFill,
- lineFill = _ref.lineFill,
- j = _ref.j,
- i = _ref.i,
- pathFrom = _ref.pathFrom,
- pathTo = _ref.pathTo,
- strokeWidth = _ref.strokeWidth,
- elSeries = _ref.elSeries,
- x = _ref.x,
- y = _ref.y,
- y1 = _ref.y1,
- y2 = _ref.y2,
- series = _ref.series,
- barHeight = _ref.barHeight,
- barWidth = _ref.barWidth,
- barYPosition = _ref.barYPosition,
- elDataLabelsWrap = _ref.elDataLabelsWrap,
- visibleSeries = _ref.visibleSeries,
- type = _ref.type;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- if (!lineFill) {
-
- lineFill = this.barOptions.distributed ? w.globals.stroke.colors[j] : w.globals.stroke.colors[realIndex];
- }
- if (w.config.series[i].data[j] && w.config.series[i].data[j].strokeColor) {
- lineFill = w.config.series[i].data[j].strokeColor;
- }
- if (this.isNullValue) {
- pathFill = 'none';
- }
- var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4;
- var renderedPath = graphics.renderPaths({
- i: i,
- j: j,
- realIndex: realIndex,
- pathFrom: pathFrom,
- pathTo: pathTo,
- stroke: lineFill,
- strokeWidth: strokeWidth,
- strokeLineCap: w.config.stroke.lineCap,
- fill: pathFill,
- animationDelay: delay,
- initialSpeed: w.config.chart.animations.speed,
- dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
- className: "apexcharts-".concat(type, "-area")
- });
- renderedPath.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
- if (typeof y1 !== 'undefined' && typeof y2 !== 'undefined') {
- renderedPath.attr('data-range-y1', y1);
- renderedPath.attr('data-range-y2', y2);
- }
- var filters = new Filters(this.ctx);
- filters.setSelectionFilter(renderedPath, realIndex, j);
- elSeries.add(renderedPath);
- var barDataLabels = new BarDataLabels(this);
- var dataLabels = barDataLabels.handleBarDataLabels({
- x: x,
- y: y,
- y1: y1,
- y2: y2,
- i: i,
- j: j,
- series: series,
- realIndex: realIndex,
- barHeight: barHeight,
- barWidth: barWidth,
- barYPosition: barYPosition,
- renderedPath: renderedPath,
- visibleSeries: visibleSeries
- });
- if (dataLabels !== null) {
- elDataLabelsWrap.add(dataLabels);
- }
- elSeries.add(elDataLabelsWrap);
- return elSeries;
- }
- }, {
- key: "drawBarPaths",
- value: function drawBarPaths(_ref2) {
- var indexes = _ref2.indexes,
- barHeight = _ref2.barHeight,
- strokeWidth = _ref2.strokeWidth,
- zeroW = _ref2.zeroW,
- x = _ref2.x,
- y = _ref2.y,
- yDivision = _ref2.yDivision,
- elSeries = _ref2.elSeries;
- var w = this.w;
- var i = indexes.i;
- var j = indexes.j;
- var bc = indexes.bc;
- if (w.globals.isXNumeric) {
- y = (w.globals.seriesX[i][j] - w.globals.minX) / this.invertedXRatio - barHeight;
- }
- var barYPosition = y + barHeight * this.visibleI;
- if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
- x = zeroW;
- } else {
- x = zeroW + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
- }
- var paths = this.barHelpers.getBarpaths({
- barYPosition: barYPosition,
- barHeight: barHeight,
- x1: zeroW,
- x2: x,
- strokeWidth: strokeWidth,
- series: this.series,
- realIndex: indexes.realIndex,
- i: i,
- j: j,
- w: w
- });
- if (!w.globals.isXNumeric) {
- y = y + yDivision;
- }
- this.barHelpers.barBackground({
- bc: bc,
- i: i,
- y1: barYPosition - barHeight * this.visibleI,
- y2: barHeight * this.seriesLen,
- elSeries: elSeries
- });
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- x: x,
- y: y,
- barYPosition: barYPosition
- };
- }
- }, {
- key: "drawColumnPaths",
- value: function drawColumnPaths(_ref3) {
- var indexes = _ref3.indexes,
- x = _ref3.x,
- y = _ref3.y,
- xDivision = _ref3.xDivision,
- barWidth = _ref3.barWidth,
- zeroH = _ref3.zeroH,
- strokeWidth = _ref3.strokeWidth,
- elSeries = _ref3.elSeries;
- var w = this.w;
- var i = indexes.i;
- var j = indexes.j;
- var bc = indexes.bc;
- if (w.globals.isXNumeric) {
- var sxI = i;
- if (!w.globals.seriesX[i].length) {
- sxI = w.globals.maxValsInArrayIndex;
- }
- x = (w.globals.seriesX[sxI][j] - w.globals.minX) / this.xRatio - barWidth * this.seriesLen / 2;
- }
- var barXPosition = x + barWidth * this.visibleI;
- if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
- y = zeroH;
- } else {
- y = zeroH - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
- }
- var paths = this.barHelpers.getColumnPaths({
- barXPosition: barXPosition,
- barWidth: barWidth,
- y1: zeroH,
- y2: y,
- strokeWidth: strokeWidth,
- series: this.series,
- realIndex: indexes.realIndex,
- i: i,
- j: j,
- w: w
- });
- if (!w.globals.isXNumeric) {
- x = x + xDivision;
- }
- this.barHelpers.barBackground({
- bc: bc,
- i: i,
- x1: barXPosition - strokeWidth / 2 - barWidth * this.visibleI,
- x2: barWidth * this.seriesLen + strokeWidth / 2,
- elSeries: elSeries
- });
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- x: x,
- y: y,
- barXPosition: barXPosition
- };
- }
-
- }, {
- key: "getPreviousPath",
- value: function getPreviousPath(realIndex, j) {
- var w = this.w;
- var pathFrom;
- for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
- var gpp = w.globals.previousPaths[pp];
- if (gpp.paths && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
- if (typeof w.globals.previousPaths[pp].paths[j] !== 'undefined') {
- pathFrom = w.globals.previousPaths[pp].paths[j].d;
- }
- }
- }
- return pathFrom;
- }
- }]);
- return Bar;
- }();
-
- var BarStacked = function (_Bar) {
- _inherits(BarStacked, _Bar);
- function BarStacked() {
- _classCallCheck(this, BarStacked);
- return _possibleConstructorReturn(this, _getPrototypeOf(BarStacked).apply(this, arguments));
- }
- _createClass(BarStacked, [{
- key: "draw",
- value: function draw(series, seriesIndex) {
- var _this = this;
- var w = this.w;
- this.graphics = new Graphics(this.ctx);
- this.bar = new Bar(this.ctx, this.xyRatios);
- var coreUtils = new CoreUtils(this.ctx, w);
- series = coreUtils.getLogSeries(series);
- this.yRatio = coreUtils.getLogYRatios(this.yRatio);
- this.barHelpers.initVariables(series);
- if (w.config.chart.stackType === '100%') {
- series = w.globals.seriesPercent.slice();
- }
- this.series = series;
- this.totalItems = 0;
- this.prevY = [];
- this.prevX = [];
- this.prevYF = [];
- this.prevXF = [];
- this.prevYVal = [];
- this.prevXVal = [];
- this.xArrj = [];
- this.xArrjF = [];
- this.xArrjVal = [];
- this.yArrj = [];
- this.yArrjF = [];
- this.yArrjVal = [];
- for (var sl = 0; sl < series.length; sl++) {
- if (series[sl].length > 0) {
- this.totalItems += series[sl].length;
- }
- }
- var ret = this.graphics.group({
- class: 'apexcharts-bar-series apexcharts-plot-series'
- });
- var x = 0;
- var y = 0;
- var _loop = function _loop(i, bc) {
- var xDivision = void 0;
- var yDivision = void 0;
- var zeroH = void 0;
- var zeroW = void 0;
- var xArrValues = [];
- var yArrValues = [];
- var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
- if (_this.yRatio.length > 1) {
- _this.yaxisIndex = realIndex;
- }
- _this.isReversed = w.config.yaxis[_this.yaxisIndex] && w.config.yaxis[_this.yaxisIndex].reversed;
- var elSeries = _this.graphics.group({
- class: "apexcharts-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
- rel: i + 1,
- 'data:realIndex': realIndex
- });
- var elDataLabelsWrap = _this.graphics.group({
- class: 'apexcharts-datalabels',
- 'data:realIndex': realIndex
- });
- var barHeight = 0;
- var barWidth = 0;
- var initPositions = _this.initialPositions(x, y, xDivision, yDivision, zeroH, zeroW);
- y = initPositions.y;
- barHeight = initPositions.barHeight;
- yDivision = initPositions.yDivision;
- zeroW = initPositions.zeroW;
- x = initPositions.x;
- barWidth = initPositions.barWidth;
- xDivision = initPositions.xDivision;
- zeroH = initPositions.zeroH;
- _this.yArrj = [];
- _this.yArrjF = [];
- _this.yArrjVal = [];
- _this.xArrj = [];
- _this.xArrjF = [];
- _this.xArrjVal = [];
-
-
-
-
-
- if (_this.prevY.length === 1 && _this.prevY[0].every(function (val) {
- return isNaN(val);
- })) {
-
- _this.prevY[0] = _this.prevY[0].map(function (val) {
- return zeroH;
- });
- _this.prevYF[0] = _this.prevYF[0].map(function (val) {
- return 0;
- });
- }
- for (var j = 0; j < w.globals.dataPoints; j++) {
- var strokeWidth = _this.barHelpers.getStrokeWidth(i, j, realIndex);
- var commonPathOpts = {
- indexes: {
- i: i,
- j: j,
- realIndex: realIndex,
- bc: bc
- },
- strokeWidth: strokeWidth,
- x: x,
- y: y,
- elSeries: elSeries
- };
- var paths = null;
- if (_this.isHorizontal) {
- paths = _this.drawStackedBarPaths(_objectSpread2({}, commonPathOpts, {
- zeroW: zeroW,
- barHeight: barHeight,
- yDivision: yDivision
- }));
- barWidth = _this.series[i][j] / _this.invertedYRatio;
- } else {
- paths = _this.drawStackedColumnPaths(_objectSpread2({}, commonPathOpts, {
- xDivision: xDivision,
- barWidth: barWidth,
- zeroH: zeroH
- }));
- barHeight = _this.series[i][j] / _this.yRatio[_this.yaxisIndex];
- }
- y = paths.y;
- x = paths.x;
- xArrValues.push(x);
- yArrValues.push(y);
- var pathFill = _this.barHelpers.getPathFillColor(series, i, j, realIndex);
- elSeries = _this.renderSeries({
- realIndex: realIndex,
- pathFill: pathFill,
- j: j,
- i: i,
- pathFrom: paths.pathFrom,
- pathTo: paths.pathTo,
- strokeWidth: strokeWidth,
- elSeries: elSeries,
- x: x,
- y: y,
- series: series,
- barHeight: barHeight,
- barWidth: barWidth,
- elDataLabelsWrap: elDataLabelsWrap,
- type: 'bar',
- visibleSeries: 0
- });
- }
- w.globals.seriesXvalues[realIndex] = xArrValues;
- w.globals.seriesYvalues[realIndex] = yArrValues;
- _this.prevY.push(_this.yArrj);
- _this.prevYF.push(_this.yArrjF);
- _this.prevYVal.push(_this.yArrjVal);
- _this.prevX.push(_this.xArrj);
- _this.prevXF.push(_this.xArrjF);
- _this.prevXVal.push(_this.xArrjVal);
- ret.add(elSeries);
- };
- for (var i = 0, bc = 0; i < series.length; i++, bc++) {
- _loop(i, bc);
- }
- return ret;
- }
- }, {
- key: "initialPositions",
- value: function initialPositions(x, y, xDivision, yDivision, zeroH, zeroW) {
- var w = this.w;
- var barHeight, barWidth;
- if (this.isHorizontal) {
-
- yDivision = w.globals.gridHeight / w.globals.dataPoints;
- barHeight = yDivision;
- barHeight = barHeight * parseInt(w.config.plotOptions.bar.barHeight, 10) / 100;
- zeroW = this.baseLineInvertedY + w.globals.padHorizontal + (this.isReversed ? w.globals.gridWidth : 0) - (this.isReversed ? this.baseLineInvertedY * 2 : 0);
- y = (yDivision - barHeight) / 2;
- } else {
-
- xDivision = w.globals.gridWidth / w.globals.dataPoints;
- barWidth = xDivision;
- if (w.globals.isXNumeric) {
- xDivision = w.globals.minXDiff / this.xRatio;
- barWidth = xDivision * parseInt(this.barOptions.columnWidth, 10) / 100;
- } else {
- barWidth = barWidth * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
- }
- zeroH = this.baseLineY[this.yaxisIndex] + (this.isReversed ? w.globals.gridHeight : 0) - (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0);
- x = w.globals.padHorizontal + (xDivision - barWidth) / 2;
- }
- return {
- x: x,
- y: y,
- yDivision: yDivision,
- xDivision: xDivision,
- barHeight: barHeight,
- barWidth: barWidth,
- zeroH: zeroH,
- zeroW: zeroW
- };
- }
- }, {
- key: "drawStackedBarPaths",
- value: function drawStackedBarPaths(_ref) {
- var indexes = _ref.indexes,
- barHeight = _ref.barHeight,
- strokeWidth = _ref.strokeWidth,
- zeroW = _ref.zeroW,
- x = _ref.x,
- y = _ref.y,
- yDivision = _ref.yDivision,
- elSeries = _ref.elSeries;
- var w = this.w;
- var barYPosition = y;
- var barXPosition;
- var i = indexes.i;
- var j = indexes.j;
- var bc = indexes.bc;
- var prevBarW = 0;
- for (var k = 0; k < this.prevXF.length; k++) {
- prevBarW = prevBarW + this.prevXF[k][j];
- }
- if (i > 0) {
- var bXP = zeroW;
- if (this.prevXVal[i - 1][j] < 0) {
- bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] + prevBarW - (this.isReversed ? prevBarW : 0) * 2 : this.prevX[i - 1][j];
- } else if (this.prevXVal[i - 1][j] >= 0) {
- bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] : this.prevX[i - 1][j] - prevBarW + (this.isReversed ? prevBarW : 0) * 2;
- }
- barXPosition = bXP;
- } else {
-
- barXPosition = zeroW;
- }
- if (this.series[i][j] === null) {
- x = barXPosition;
- } else {
- x = barXPosition + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
- }
- this.xArrj.push(x);
- this.xArrjF.push(Math.abs(barXPosition - x));
- this.xArrjVal.push(this.series[i][j]);
- var paths = this.barHelpers.getBarpaths({
- barYPosition: barYPosition,
- barHeight: barHeight,
- x1: barXPosition,
- x2: x,
- strokeWidth: strokeWidth,
- series: this.series,
- realIndex: indexes.realIndex,
- i: i,
- j: j,
- w: w
- });
- this.barHelpers.barBackground({
- bc: bc,
- i: i,
- y1: barYPosition,
- y2: barHeight,
- elSeries: elSeries
- });
- y = y + yDivision;
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- x: x,
- y: y
- };
- }
- }, {
- key: "drawStackedColumnPaths",
- value: function drawStackedColumnPaths(_ref2) {
- var indexes = _ref2.indexes,
- x = _ref2.x,
- y = _ref2.y,
- xDivision = _ref2.xDivision,
- barWidth = _ref2.barWidth,
- zeroH = _ref2.zeroH,
- strokeWidth = _ref2.strokeWidth,
- elSeries = _ref2.elSeries;
- var w = this.w;
- var i = indexes.i;
- var j = indexes.j;
- var bc = indexes.bc;
- if (w.globals.isXNumeric) {
- var seriesVal = w.globals.seriesX[i][j];
- if (!seriesVal) seriesVal = 0;
- x = (seriesVal - w.globals.minX) / this.xRatio - barWidth / 2;
- }
- var barXPosition = x;
- var barYPosition;
- var prevBarH = 0;
- for (var k = 0; k < this.prevYF.length; k++) {
-
-
- prevBarH = prevBarH + (!isNaN(this.prevYF[k][j]) ? this.prevYF[k][j] : 0);
- }
- if (i > 0 && !w.globals.isXNumeric || i > 0 && w.globals.isXNumeric && w.globals.seriesX[i - 1][j] === w.globals.seriesX[i][j]) {
- var bYP;
- var prevYValue;
- var p = Math.min(this.yRatio.length + 1, i + 1);
- if (this.prevY[i - 1] !== undefined) {
- for (var ii = 1; ii < p; ii++) {
- if (!isNaN(this.prevY[i - ii][j])) {
-
- prevYValue = this.prevY[i - ii][j];
- break;
- }
- }
- }
- for (var _ii = 1; _ii < p; _ii++) {
-
- if (this.prevYVal[i - _ii][j] < 0) {
- bYP = this.series[i][j] >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue;
- break;
- } else if (this.prevYVal[i - _ii][j] >= 0) {
- bYP = this.series[i][j] >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2;
- break;
- }
- }
- if (typeof bYP === 'undefined') bYP = w.globals.gridHeight;
-
- if (this.prevYF[0].every(function (val) {
- return val === 0;
- }) && this.prevYF.slice(1, i).every(function (arr) {
- return arr.every(function (val) {
- return isNaN(val);
- });
- })) {
-
- barYPosition = w.globals.gridHeight - zeroH;
- } else {
-
- barYPosition = bYP;
- }
- } else {
-
- barYPosition = w.globals.gridHeight - zeroH;
- }
- y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
- this.yArrj.push(y);
- this.yArrjF.push(Math.abs(barYPosition - y));
- this.yArrjVal.push(this.series[i][j]);
- var paths = this.barHelpers.getColumnPaths({
- barXPosition: barXPosition,
- barWidth: barWidth,
- y1: barYPosition,
- y2: y,
- yRatio: this.yRatio[this.yaxisIndex],
- strokeWidth: this.strokeWidth,
- series: this.series,
- realIndex: indexes.realIndex,
- i: i,
- j: j,
- w: w
- });
- this.barHelpers.barBackground({
- bc: bc,
- i: i,
- x1: barXPosition,
- x2: barWidth,
- elSeries: elSeries
- });
- x = x + xDivision;
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- x: w.globals.isXNumeric ? x - xDivision : x,
- y: y
- };
- }
- }]);
- return BarStacked;
- }(Bar);
-
- var CandleStick = function (_Bar) {
- _inherits(CandleStick, _Bar);
- function CandleStick() {
- _classCallCheck(this, CandleStick);
- return _possibleConstructorReturn(this, _getPrototypeOf(CandleStick).apply(this, arguments));
- }
- _createClass(CandleStick, [{
- key: "draw",
- value: function draw(series, seriesIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var fill = new Fill(this.ctx);
- this.candlestickOptions = this.w.config.plotOptions.candlestick;
- var coreUtils = new CoreUtils(this.ctx, w);
- series = coreUtils.getLogSeries(series);
- this.series = series;
- this.yRatio = coreUtils.getLogYRatios(this.yRatio);
- this.barHelpers.initVariables(series);
- var ret = graphics.group({
- class: 'apexcharts-candlestick-series apexcharts-plot-series'
- });
- for (var i = 0; i < series.length; i++) {
- var x = void 0,
- y = void 0,
- xDivision = void 0,
-
- zeroH = void 0;
- var yArrj = [];
- var xArrj = [];
- var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
- var elSeries = graphics.group({
- class: "apexcharts-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
- rel: i + 1,
- 'data:realIndex': realIndex
- });
- if (series[i].length > 0) {
- this.visibleI = this.visibleI + 1;
- }
- var barHeight = 0;
- var barWidth = 0;
- if (this.yRatio.length > 1) {
- this.yaxisIndex = realIndex;
- }
- var initPositions = this.barHelpers.initialPositions();
- y = initPositions.y;
- barHeight = initPositions.barHeight;
- x = initPositions.x;
- barWidth = initPositions.barWidth;
- xDivision = initPositions.xDivision;
- zeroH = initPositions.zeroH;
- xArrj.push(x + barWidth / 2);
- var elDataLabelsWrap = graphics.group({
- class: 'apexcharts-datalabels',
- 'data:realIndex': realIndex
- });
- for (var j = 0; j < w.globals.dataPoints; j++) {
- var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
- var color = void 0;
- var paths = this.drawCandleStickPaths({
- indexes: {
- i: i,
- j: j,
- realIndex: realIndex
- },
- x: x,
- y: y,
- xDivision: xDivision,
- barWidth: barWidth,
- zeroH: zeroH,
- strokeWidth: strokeWidth,
- elSeries: elSeries
- });
- y = paths.y;
- x = paths.x;
- color = paths.color;
- if (j > 0) {
- xArrj.push(x + barWidth / 2);
- }
- yArrj.push(y);
- var pathFill = fill.fillPath({
- seriesNumber: realIndex,
- dataPointIndex: j,
- color: color,
- value: series[i][j]
- });
- var lineFill = this.candlestickOptions.wick.useFillColor ? color : undefined;
- this.renderSeries({
- realIndex: realIndex,
- pathFill: pathFill,
- lineFill: lineFill,
- j: j,
- i: i,
- pathFrom: paths.pathFrom,
- pathTo: paths.pathTo,
- strokeWidth: strokeWidth,
- elSeries: elSeries,
- x: x,
- y: y,
- series: series,
- barHeight: barHeight,
- barWidth: barWidth,
- elDataLabelsWrap: elDataLabelsWrap,
- visibleSeries: this.visibleI,
- type: 'candlestick'
- });
- }
- w.globals.seriesXvalues[realIndex] = xArrj;
- w.globals.seriesYvalues[realIndex] = yArrj;
- ret.add(elSeries);
- }
- return ret;
- }
- }, {
- key: "drawCandleStickPaths",
- value: function drawCandleStickPaths(_ref) {
- var indexes = _ref.indexes,
- x = _ref.x,
- y = _ref.y,
- xDivision = _ref.xDivision,
- barWidth = _ref.barWidth,
- zeroH = _ref.zeroH,
- strokeWidth = _ref.strokeWidth;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var i = indexes.i;
- var j = indexes.j;
- var isPositive = true;
- var colorPos = w.config.plotOptions.candlestick.colors.upward;
- var colorNeg = w.config.plotOptions.candlestick.colors.downward;
- var yRatio = this.yRatio[this.yaxisIndex];
- var realIndex = indexes.realIndex;
- var ohlc = this.getOHLCValue(realIndex, j);
- var l1 = zeroH;
- var l2 = zeroH;
- if (ohlc.o > ohlc.c) {
- isPositive = false;
- }
- var y1 = Math.min(ohlc.o, ohlc.c);
- var y2 = Math.max(ohlc.o, ohlc.c);
- if (w.globals.isXNumeric) {
- x = (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio - barWidth / 2;
- }
- var barXPosition = x + barWidth * this.visibleI;
- if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
- y1 = zeroH;
- } else {
- y1 = zeroH - y1 / yRatio;
- y2 = zeroH - y2 / yRatio;
- l1 = zeroH - ohlc.h / yRatio;
- l2 = zeroH - ohlc.l / yRatio;
- }
- var pathTo = graphics.move(barXPosition, zeroH);
- var pathFrom = graphics.move(barXPosition, y1);
- if (w.globals.previousPaths.length > 0) {
- pathFrom = this.getPreviousPath(realIndex, j, true);
- }
- pathTo = graphics.move(barXPosition, y2) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition + barWidth / 2, l1) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition + barWidth, y2) + graphics.line(barXPosition + barWidth, y1) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition + barWidth / 2, l2) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition, y1) + graphics.line(barXPosition, y2 - strokeWidth / 2);
- pathFrom = pathFrom + graphics.move(barXPosition, y1);
- if (!w.globals.isXNumeric) {
- x = x + xDivision;
- }
- return {
- pathTo: pathTo,
- pathFrom: pathFrom,
- x: x,
- y: y2,
- barXPosition: barXPosition,
- color: isPositive ? colorPos : colorNeg
- };
- }
- }, {
- key: "getOHLCValue",
- value: function getOHLCValue(i, j) {
- var w = this.w;
- return {
- o: w.globals.seriesCandleO[i][j],
- h: w.globals.seriesCandleH[i][j],
- l: w.globals.seriesCandleL[i][j],
- c: w.globals.seriesCandleC[i][j]
- };
- }
- }]);
- return CandleStick;
- }(Bar);
-
- var HeatMap = function () {
- function HeatMap(ctx, xyRatios) {
- _classCallCheck(this, HeatMap);
- this.ctx = ctx;
- this.w = ctx.w;
- this.xRatio = xyRatios.xRatio;
- this.yRatio = xyRatios.yRatio;
- this.negRange = false;
- this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation;
- this.rectRadius = this.w.config.plotOptions.heatmap.radius;
- this.strokeWidth = this.w.config.stroke.show ? this.w.config.stroke.width : 0;
- }
- _createClass(HeatMap, [{
- key: "draw",
- value: function draw(series) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var ret = graphics.group({
- class: 'apexcharts-heatmap'
- });
- ret.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
- var xDivision = w.globals.gridWidth / w.globals.dataPoints;
- var yDivision = w.globals.gridHeight / w.globals.series.length;
- var y1 = 0;
- var rev = false;
- this.checkColorRange();
- var heatSeries = series.slice();
- if (w.config.yaxis[0].reversed) {
- rev = true;
- heatSeries.reverse();
- }
- for (var i = rev ? 0 : heatSeries.length - 1; rev ? i < heatSeries.length : i >= 0; rev ? i++ : i--) {
-
- var elSeries = graphics.group({
- class: "apexcharts-series apexcharts-heatmap-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[i]),
- rel: i + 1,
- 'data:realIndex': i
- });
- if (w.config.chart.dropShadow.enabled) {
- var shadow = w.config.chart.dropShadow;
- var filters = new Filters(this.ctx);
- filters.dropShadow(elSeries, shadow, i);
- }
- var x1 = 0;
- for (var j = 0; j < heatSeries[i].length; j++) {
- var colorShadePercent = 1;
- var shadeIntensity = w.config.plotOptions.heatmap.shadeIntensity;
- var heatColorProps = this.determineHeatColor(i, j);
- if (w.globals.hasNegs || this.negRange) {
- if (w.config.plotOptions.heatmap.reverseNegativeShade) {
- if (heatColorProps.percent < 0) {
- colorShadePercent = heatColorProps.percent / 100 * (shadeIntensity * 1.25);
- } else {
- colorShadePercent = (1 - heatColorProps.percent / 100) * (shadeIntensity * 1.25);
- }
- } else {
- if (heatColorProps.percent <= 0) {
- colorShadePercent = 1 - (1 + heatColorProps.percent / 100) * shadeIntensity;
- } else {
- colorShadePercent = (1 - heatColorProps.percent / 100) * shadeIntensity;
- }
- }
- } else {
- colorShadePercent = 1 - heatColorProps.percent / 100;
- }
- var color = heatColorProps.color;
- var utils = new Utils();
- if (w.config.plotOptions.heatmap.enableShades) {
- if (colorShadePercent < 0) colorShadePercent = 0;
- color = Utils.hexToRgba(utils.shadeColor(colorShadePercent, heatColorProps.color), w.config.fill.opacity);
- }
- if (w.config.fill.type === 'image') {
- var fill = new Fill(this.ctx);
- color = fill.fillPath({
- seriesNumber: i,
- dataPointIndex: j,
- opacity: w.globals.hasNegs ? heatColorProps.percent < 0 ? 1 - (1 + heatColorProps.percent / 100) : shadeIntensity + heatColorProps.percent / 100 : heatColorProps.percent / 100,
- patternID: Utils.randomId(),
- width: w.config.fill.image.width ? w.config.fill.image.width : xDivision,
- height: w.config.fill.image.height ? w.config.fill.image.height : yDivision
- });
- }
- var radius = this.rectRadius;
- var rect = graphics.drawRect(x1, y1, xDivision, yDivision, radius);
- rect.attr({
- cx: x1,
- cy: y1
- });
- rect.node.classList.add('apexcharts-heatmap-rect');
- elSeries.add(rect);
- rect.attr({
- fill: color,
- i: i,
- index: i,
- j: j,
- val: heatSeries[i][j],
- 'stroke-width': this.strokeWidth,
- stroke: w.config.plotOptions.heatmap.useFillColorAsStroke ? color : w.globals.stroke.colors[0],
- color: color
- });
- rect.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, rect));
- rect.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, rect));
- rect.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, rect));
- if (w.config.chart.animations.enabled && !w.globals.dataChanged) {
- var speed = 1;
- if (!w.globals.resized) {
- speed = w.config.chart.animations.speed;
- }
- this.animateHeatMap(rect, x1, y1, xDivision, yDivision, speed);
- }
- if (w.globals.dataChanged) {
- var _speed = 1;
- if (this.dynamicAnim.enabled && w.globals.shouldAnimate) {
- _speed = this.dynamicAnim.speed;
- var colorFrom = w.globals.previousPaths[i] && w.globals.previousPaths[i][j] && w.globals.previousPaths[i][j].color;
- if (!colorFrom) colorFrom = 'rgba(255, 255, 255, 0)';
- this.animateHeatColor(rect, Utils.isColorHex(colorFrom) ? colorFrom : Utils.rgb2hex(colorFrom), Utils.isColorHex(color) ? color : Utils.rgb2hex(color), _speed);
- }
- }
- var dataLabels = this.calculateHeatmapDataLabels({
- x: x1,
- y: y1,
- i: i,
- j: j,
- heatColorProps: heatColorProps,
- series: heatSeries,
- rectHeight: yDivision,
- rectWidth: xDivision
- });
- if (dataLabels !== null) {
- elSeries.add(dataLabels);
- }
- x1 = x1 + xDivision;
- }
- y1 = y1 + yDivision;
- ret.add(elSeries);
- }
- var yAxisScale = w.globals.yAxisScale[0].result.slice();
- if (w.config.yaxis[0].reversed) {
- yAxisScale.unshift('');
- } else {
- yAxisScale.push('');
- }
- w.globals.yAxisScale[0].result = yAxisScale;
- var divisor = w.globals.gridHeight / w.globals.series.length;
- w.config.yaxis[0].labels.offsetY = -(divisor / 2);
- return ret;
- }
- }, {
- key: "checkColorRange",
- value: function checkColorRange() {
- var _this = this;
- var w = this.w;
- var heatmap = w.config.plotOptions.heatmap;
- if (heatmap.colorScale.ranges.length > 0) {
- heatmap.colorScale.ranges.map(function (range, index) {
- if (range.from <= 0) {
- _this.negRange = true;
- }
- });
- }
- }
- }, {
- key: "determineHeatColor",
- value: function determineHeatColor(i, j) {
- var w = this.w;
- var val = w.globals.series[i][j];
- var heatmap = w.config.plotOptions.heatmap;
- var seriesNumber = heatmap.colorScale.inverse ? j : i;
- var color = w.globals.colors[seriesNumber];
- var foreColor = null;
- var min = Math.min.apply(Math, _toConsumableArray(w.globals.series[i]));
- var max = Math.max.apply(Math, _toConsumableArray(w.globals.series[i]));
- if (!heatmap.distributed) {
- min = w.globals.minY;
- max = w.globals.maxY;
- }
- if (typeof heatmap.colorScale.min !== 'undefined') {
- min = heatmap.colorScale.min < w.globals.minY ? heatmap.colorScale.min : w.globals.minY;
- max = heatmap.colorScale.max > w.globals.maxY ? heatmap.colorScale.max : w.globals.maxY;
- }
- var total = Math.abs(max) + Math.abs(min);
- var percent = 100 * val / (total === 0 ? total - 0.000001 : total);
- if (heatmap.colorScale.ranges.length > 0) {
- var colorRange = heatmap.colorScale.ranges;
- colorRange.map(function (range, index) {
- if (val >= range.from && val <= range.to) {
- color = range.color;
- foreColor = range.foreColor ? range.foreColor : null;
- min = range.from;
- max = range.to;
- var rTotal = Math.abs(max) + Math.abs(min);
- percent = 100 * val / (rTotal === 0 ? rTotal - 0.000001 : rTotal);
- }
- });
- }
- return {
- color: color,
- foreColor: foreColor,
- percent: percent
- };
- }
- }, {
- key: "calculateHeatmapDataLabels",
- value: function calculateHeatmapDataLabels(_ref) {
- var x = _ref.x,
- y = _ref.y,
- i = _ref.i,
- j = _ref.j,
- heatColorProps = _ref.heatColorProps,
- series = _ref.series,
- rectHeight = _ref.rectHeight,
- rectWidth = _ref.rectWidth;
- var w = this.w;
- var dataLabelsConfig = w.config.dataLabels;
- var graphics = new Graphics(this.ctx);
- var dataLabels = new DataLabels(this.ctx);
- var formatter = dataLabelsConfig.formatter;
- var elDataLabelsWrap = null;
- if (dataLabelsConfig.enabled) {
- elDataLabelsWrap = graphics.group({
- class: 'apexcharts-data-labels'
- });
- var offX = dataLabelsConfig.offsetX;
- var offY = dataLabelsConfig.offsetY;
- var dataLabelsX = x + rectWidth / 2 + offX;
- var dataLabelsY = y + rectHeight / 2 + parseFloat(dataLabelsConfig.style.fontSize) / 3 + offY;
- var text = formatter(w.globals.series[i][j], {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- dataLabels.plotDataLabelsText({
- x: dataLabelsX,
- y: dataLabelsY,
- text: text,
- i: i,
- j: j,
- color: heatColorProps.foreColor,
- parent: elDataLabelsWrap,
- dataLabelsConfig: dataLabelsConfig
- });
- }
- return elDataLabelsWrap;
- }
- }, {
- key: "animateHeatMap",
- value: function animateHeatMap(el, x, y, width, height, speed) {
- var animations = new Animations(this.ctx);
- animations.animateRect(el, {
- x: x + width / 2,
- y: y + height / 2,
- width: 0,
- height: 0
- }, {
- x: x,
- y: y,
- width: width,
- height: height
- }, speed, function () {
- animations.animationCompleted(el);
- });
- }
- }, {
- key: "animateHeatColor",
- value: function animateHeatColor(el, colorFrom, colorTo, speed) {
- el.attr({
- fill: colorFrom
- }).animate(speed).attr({
- fill: colorTo
- });
- }
- }]);
- return HeatMap;
- }();
-
- var Radar = function () {
- function Radar(ctx) {
- _classCallCheck(this, Radar);
- this.ctx = ctx;
- this.w = ctx.w;
- this.chartType = this.w.config.chart.type;
- this.initialAnim = this.w.config.chart.animations.enabled;
- this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
- this.animDur = 0;
- var w = this.w;
- this.graphics = new Graphics(this.ctx);
- this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
- this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight + w.globals.goldenPadding * 1.5 : w.globals.gridWidth;
- this.maxValue = this.w.globals.maxY;
- this.minValue = this.w.globals.minY;
- this.polygons = w.config.plotOptions.radar.polygons;
- var longestXaxisLabel = w.globals.labels.slice().sort(function (a, b) {
- return b.length - a.length;
- })[0];
- var labelWidth = this.graphics.getTextRects(longestXaxisLabel, w.config.xaxis.labels.style.fontSize);
- this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
- this.size = this.defaultSize / 2.1 - this.strokeWidth - w.config.chart.dropShadow.blur;
- if (w.config.xaxis.labels.show) {
- this.size = this.size - labelWidth.width / 1.75;
- }
- if (w.config.plotOptions.radar.size !== undefined) {
- this.size = w.config.plotOptions.radar.size;
- }
- this.dataRadiusOfPercent = [];
- this.dataRadius = [];
- this.angleArr = [];
- this.yaxisLabelsTextsPos = [];
- }
- _createClass(Radar, [{
- key: "draw",
- value: function draw(series) {
- var _this = this;
- var w = this.w;
- var fill = new Fill(this.ctx);
- var allSeries = [];
- var dataLabels = new DataLabels(this.ctx);
- if (series.length) {
- this.dataPointsLen = series[w.globals.maxValsInArrayIndex].length;
- }
- this.disAngle = Math.PI * 2 / this.dataPointsLen;
- var halfW = w.globals.gridWidth / 2;
- var halfH = w.globals.gridHeight / 2;
- var translateX = halfW + w.config.plotOptions.radar.offsetX;
- var translateY = halfH + w.config.plotOptions.radar.offsetY;
- var ret = this.graphics.group({
- class: 'apexcharts-radar-series apexcharts-plot-series',
- transform: "translate(".concat(translateX || 0, ", ").concat(translateY || 0, ")")
- });
- var dataPointsPos = [];
- var elPointsMain = null;
- var elDataPointsMain = null;
- this.yaxisLabels = this.graphics.group({
- class: 'apexcharts-yaxis'
- });
- series.forEach(function (s, i) {
- var longestSeries = s.length === w.globals.dataPoints;
- var elSeries = _this.graphics.group().attr({
- class: "apexcharts-series",
- 'data:longestSeries': longestSeries,
- seriesName: Utils.escapeString(w.globals.seriesNames[i]),
- rel: i + 1,
- 'data:realIndex': i
- });
- _this.dataRadiusOfPercent[i] = [];
- _this.dataRadius[i] = [];
- _this.angleArr[i] = [];
- s.forEach(function (dv, j) {
- var range = Math.abs(_this.maxValue - _this.minValue);
- dv = dv + Math.abs(_this.minValue);
- _this.dataRadiusOfPercent[i][j] = dv / range;
- _this.dataRadius[i][j] = _this.dataRadiusOfPercent[i][j] * _this.size;
- _this.angleArr[i][j] = j * _this.disAngle;
- });
- dataPointsPos = _this.getDataPointsPos(_this.dataRadius[i], _this.angleArr[i]);
- var paths = _this.createPaths(dataPointsPos, {
- x: 0,
- y: 0
- });
- elPointsMain = _this.graphics.group({
- class: 'apexcharts-series-markers-wrap apexcharts-element-hidden'
- });
- elDataPointsMain = _this.graphics.group({
- class: "apexcharts-datalabels",
- 'data:realIndex': i
- });
- w.globals.delayedElements.push({
- el: elPointsMain.node,
- index: i
- });
- var defaultRenderedPathOptions = {
- i: i,
- realIndex: i,
- animationDelay: i,
- initialSpeed: w.config.chart.animations.speed,
- dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
- className: "apexcharts-radar",
- shouldClipToGrid: false,
- bindEventsOnPaths: false,
- stroke: w.globals.stroke.colors[i],
- strokeLineCap: w.config.stroke.lineCap
- };
- var pathFrom = null;
- if (w.globals.previousPaths.length > 0) {
- pathFrom = _this.getPreviousPath(i);
- }
- for (var p = 0; p < paths.linePathsTo.length; p++) {
- var renderedLinePath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
- pathFrom: pathFrom === null ? paths.linePathsFrom[p] : pathFrom,
- pathTo: paths.linePathsTo[p],
- strokeWidth: Array.isArray(_this.strokeWidth) ? _this.strokeWidth[i] : _this.strokeWidth,
- fill: 'none',
- drawShadow: false
- }));
- elSeries.add(renderedLinePath);
- var pathFill = fill.fillPath({
- seriesNumber: i
- });
- var renderedAreaPath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
- pathFrom: pathFrom === null ? paths.areaPathsFrom[p] : pathFrom,
- pathTo: paths.areaPathsTo[p],
- strokeWidth: 0,
- fill: pathFill,
- drawShadow: false
- }));
- if (w.config.chart.dropShadow.enabled) {
- var filters = new Filters(_this.ctx);
- var shadow = w.config.chart.dropShadow;
- filters.dropShadow(renderedAreaPath, Object.assign({}, shadow, {
- noUserSpaceOnUse: true
- }), i);
- }
- elSeries.add(renderedAreaPath);
- }
- s.forEach(function (sj, j) {
- var markers = new Markers(_this.ctx);
- var opts = markers.getMarkerConfig('apexcharts-marker', i, j);
- var point = _this.graphics.drawMarker(dataPointsPos[j].x, dataPointsPos[j].y, opts);
- point.attr('rel', j);
- point.attr('j', j);
- point.attr('index', i);
- point.node.setAttribute('default-marker-size', opts.pSize);
- var elPointsWrap = _this.graphics.group({
- class: 'apexcharts-series-markers'
- });
- if (elPointsWrap) {
- elPointsWrap.add(point);
- }
- elPointsMain.add(elPointsWrap);
- elSeries.add(elPointsMain);
- var dataLabelsConfig = w.config.dataLabels;
- if (dataLabelsConfig.enabled) {
- var text = dataLabelsConfig.formatter(w.globals.series[i][j], {
- seriesIndex: i,
- dataPointIndex: j,
- w: w
- });
- dataLabels.plotDataLabelsText({
- x: dataPointsPos[j].x,
- y: dataPointsPos[j].y,
- text: text,
- textAnchor: 'middle',
- i: i,
- j: i,
- parent: elDataPointsMain,
- offsetCorrection: false,
- dataLabelsConfig: _objectSpread2({}, dataLabelsConfig)
- });
- }
- elSeries.add(elDataPointsMain);
- });
- allSeries.push(elSeries);
- });
- this.drawPolygons({
- parent: ret
- });
- if (w.config.xaxis.labels.show) {
- var xaxisTexts = this.drawXAxisTexts();
- ret.add(xaxisTexts);
- }
- ret.add(this.yaxisLabels);
- allSeries.forEach(function (elS) {
- ret.add(elS);
- });
- return ret;
- }
- }, {
- key: "drawPolygons",
- value: function drawPolygons(opts) {
- var _this2 = this;
- var w = this.w;
- var parent = opts.parent;
- var yaxisTexts = w.globals.yAxisScale[0].result.reverse();
- var layers = yaxisTexts.length;
- var radiusSizes = [];
- var layerDis = this.size / (layers - 1);
- for (var i = 0; i < layers; i++) {
- radiusSizes[i] = layerDis * i;
- }
- radiusSizes.reverse();
- var polygonStrings = [];
- var lines = [];
- radiusSizes.forEach(function (radiusSize, r) {
- var polygon = _this2.getPolygonPos(radiusSize);
- var string = '';
- polygon.forEach(function (p, i) {
- if (r === 0) {
- var line = _this2.graphics.drawLine(p.x, p.y, 0, 0, Array.isArray(_this2.polygons.connectorColors) ? _this2.polygons.connectorColors[i] : _this2.polygons.connectorColors);
- lines.push(line);
- }
- if (i === 0) {
- _this2.yaxisLabelsTextsPos.push({
- x: p.x,
- y: p.y
- });
- }
- string += p.x + ',' + p.y + ' ';
- });
- polygonStrings.push(string);
- });
- polygonStrings.forEach(function (p, i) {
- var strokeColors = _this2.polygons.strokeColors;
- var polygon = _this2.graphics.drawPolygon(p, Array.isArray(strokeColors) ? strokeColors[i] : strokeColors, w.globals.radarPolygons.fill.colors[i]);
- parent.add(polygon);
- });
- lines.forEach(function (l) {
- parent.add(l);
- });
- if (w.config.yaxis[0].show) {
- this.yaxisLabelsTextsPos.forEach(function (p, i) {
- var yText = _this2.drawYAxisTexts(p.x, p.y, i, yaxisTexts[i]);
- _this2.yaxisLabels.add(yText);
- });
- }
- }
- }, {
- key: "drawYAxisTexts",
- value: function drawYAxisTexts(x, y, i, text) {
- var w = this.w;
- var yaxisConfig = w.config.yaxis[0];
- var formatter = w.globals.yLabelFormatters[0];
- var yaxisLabel = this.graphics.drawText({
- x: x + yaxisConfig.labels.offsetX,
- y: y + yaxisConfig.labels.offsetY,
- text: formatter(text, i),
- textAnchor: 'middle',
- fontSize: yaxisConfig.labels.style.fontSize,
- fontFamily: yaxisConfig.labels.style.fontFamily,
- foreColor: yaxisConfig.labels.style.color
- });
- return yaxisLabel;
- }
- }, {
- key: "drawXAxisTexts",
- value: function drawXAxisTexts() {
- var _this3 = this;
- var w = this.w;
- var xaxisLabelsConfig = w.config.xaxis.labels;
- var elXAxisWrap = this.graphics.group({
- class: 'apexcharts-xaxis'
- });
- var polygonPos = this.getPolygonPos(this.size);
- w.globals.labels.forEach(function (label, i) {
- var formatter = w.config.xaxis.labels.formatter;
- var dataLabels = new DataLabels(_this3.ctx);
- if (polygonPos[i]) {
- var textPos = _this3.getTextPos(polygonPos[i], _this3.size);
- var text = formatter(label, {
- seriesIndex: -1,
- dataPointIndex: i,
- w: w
- });
- dataLabels.plotDataLabelsText({
- x: textPos.newX,
- y: textPos.newY,
- text: text,
- textAnchor: textPos.textAnchor,
- i: i,
- j: i,
- parent: elXAxisWrap,
- color: xaxisLabelsConfig.style.colors[i] ? xaxisLabelsConfig.style.colors[i] : '#a8a8a8',
- dataLabelsConfig: _objectSpread2({
- textAnchor: textPos.textAnchor,
- dropShadow: {
- enabled: false
- }
- }, xaxisLabelsConfig),
- offsetCorrection: false
- });
- }
- });
- return elXAxisWrap;
- }
- }, {
- key: "createPaths",
- value: function createPaths(pos, origin) {
- var _this4 = this;
- var linePathsTo = [];
- var linePathsFrom = [];
- var areaPathsTo = [];
- var areaPathsFrom = [];
- if (pos.length) {
- linePathsFrom = [this.graphics.move(origin.x, origin.y)];
- areaPathsFrom = [this.graphics.move(origin.x, origin.y)];
- var linePathTo = this.graphics.move(pos[0].x, pos[0].y);
- var areaPathTo = this.graphics.move(pos[0].x, pos[0].y);
- pos.forEach(function (p, i) {
- linePathTo += _this4.graphics.line(p.x, p.y);
- areaPathTo += _this4.graphics.line(p.x, p.y);
- if (i === pos.length - 1) {
- linePathTo += 'Z';
- areaPathTo += 'Z';
- }
- });
- linePathsTo.push(linePathTo);
- areaPathsTo.push(areaPathTo);
- }
- return {
- linePathsFrom: linePathsFrom,
- linePathsTo: linePathsTo,
- areaPathsFrom: areaPathsFrom,
- areaPathsTo: areaPathsTo
- };
- }
- }, {
- key: "getTextPos",
- value: function getTextPos(pos, polygonSize) {
- var limit = 10;
- var textAnchor = 'middle';
- var newX = pos.x;
- var newY = pos.y;
- if (Math.abs(pos.x) >= limit) {
- if (pos.x > 0) {
- textAnchor = 'start';
- newX += 10;
- } else if (pos.x < 0) {
- textAnchor = 'end';
- newX -= 10;
- }
- } else {
- textAnchor = 'middle';
- }
- if (Math.abs(pos.y) >= polygonSize - limit) {
- if (pos.y < 0) {
- newY -= 10;
- } else if (pos.y > 0) {
- newY += 10;
- }
- }
- return {
- textAnchor: textAnchor,
- newX: newX,
- newY: newY
- };
- }
- }, {
- key: "getPreviousPath",
- value: function getPreviousPath(realIndex) {
- var w = this.w;
- var pathFrom = null;
- for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
- var gpp = w.globals.previousPaths[pp];
- if (gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
- if (typeof w.globals.previousPaths[pp].paths[0] !== 'undefined') {
- pathFrom = w.globals.previousPaths[pp].paths[0].d;
- }
- }
- }
- return pathFrom;
- }
- }, {
- key: "getDataPointsPos",
- value: function getDataPointsPos(dataRadiusArr, angleArr) {
- var dataPointsLen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.dataPointsLen;
- dataRadiusArr = dataRadiusArr || [];
- angleArr = angleArr || [];
- var dataPointsPosArray = [];
- for (var j = 0; j < dataPointsLen; j++) {
- var curPointPos = {};
- curPointPos.x = dataRadiusArr[j] * Math.sin(angleArr[j]);
- curPointPos.y = -dataRadiusArr[j] * Math.cos(angleArr[j]);
- dataPointsPosArray.push(curPointPos);
- }
- return dataPointsPosArray;
- }
- }, {
- key: "getPolygonPos",
- value: function getPolygonPos(size) {
- var dotsArray = [];
- var angle = Math.PI * 2 / this.dataPointsLen;
- for (var i = 0; i < this.dataPointsLen; i++) {
- var curPos = {};
- curPos.x = size * Math.sin(i * angle);
- curPos.y = -size * Math.cos(i * angle);
- dotsArray.push(curPos);
- }
- return dotsArray;
- }
- }]);
- return Radar;
- }();
-
- var Radial = function (_Pie) {
- _inherits(Radial, _Pie);
- function Radial(ctx) {
- var _this;
- _classCallCheck(this, Radial);
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Radial).call(this, ctx));
- _this.ctx = ctx;
- _this.w = ctx.w;
- _this.animBeginArr = [0];
- _this.animDur = 0;
- var w = _this.w;
- _this.startAngle = w.config.plotOptions.radialBar.startAngle;
- _this.endAngle = w.config.plotOptions.radialBar.endAngle;
- _this.totalAngle = Math.abs(w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle);
- _this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle;
- _this.trackEndAngle = w.config.plotOptions.radialBar.track.endAngle;
- _this.radialDataLabels = w.config.plotOptions.radialBar.dataLabels;
- if (!_this.trackStartAngle) _this.trackStartAngle = _this.startAngle;
- if (!_this.trackEndAngle) _this.trackEndAngle = _this.endAngle;
- if (_this.endAngle === 360) _this.endAngle = 359.99;
- _this.fullAngle = 360 - w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle;
- _this.margin = parseInt(w.config.plotOptions.radialBar.track.margin, 10);
- return _this;
- }
- _createClass(Radial, [{
- key: "draw",
- value: function draw(series) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var ret = graphics.group({
- class: 'apexcharts-radialbar'
- });
- if (w.globals.noData) return ret;
- var elSeries = graphics.group();
- var centerY = this.defaultSize / 2;
- var centerX = w.globals.gridWidth / 2;
- var size = this.defaultSize / 2.05;
- if (!w.config.chart.sparkline.enabled) {
- size = size - w.config.stroke.width - w.config.chart.dropShadow.blur;
- }
- var colorArr = w.globals.fill.colors;
- if (w.config.plotOptions.radialBar.track.show) {
- var elTracks = this.drawTracks({
- size: size,
- centerX: centerX,
- centerY: centerY,
- colorArr: colorArr,
- series: series
- });
- elSeries.add(elTracks);
- }
- var elG = this.drawArcs({
- size: size,
- centerX: centerX,
- centerY: centerY,
- colorArr: colorArr,
- series: series
- });
- var totalAngle = 360;
- if (w.config.plotOptions.radialBar.startAngle < 0) {
- totalAngle = this.totalAngle;
- }
- var angleRatio = (360 - totalAngle) / 360;
- w.globals.radialSize = size - size * angleRatio;
- if (this.radialDataLabels.value.show) {
- var offset = Math.max(this.radialDataLabels.value.offsetY, this.radialDataLabels.name.offsetY);
- w.globals.radialSize += offset * angleRatio;
- }
- elSeries.add(elG.g);
- if (w.config.plotOptions.radialBar.hollow.position === 'front') {
- elG.g.add(elG.elHollow);
- if (elG.dataLabels) {
- elG.g.add(elG.dataLabels);
- }
- }
- ret.add(elSeries);
- return ret;
- }
- }, {
- key: "drawTracks",
- value: function drawTracks(opts) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var g = graphics.group({
- class: 'apexcharts-tracks'
- });
- var filters = new Filters(this.ctx);
- var fill = new Fill(this.ctx);
- var strokeWidth = this.getStrokeWidth(opts);
- opts.size = opts.size - strokeWidth / 2;
- for (var i = 0; i < opts.series.length; i++) {
- var elRadialBarTrack = graphics.group({
- class: 'apexcharts-radialbar-track apexcharts-track'
- });
- g.add(elRadialBarTrack);
- elRadialBarTrack.attr({
- rel: i + 1
- });
- opts.size = opts.size - strokeWidth - this.margin;
- var trackConfig = w.config.plotOptions.radialBar.track;
- var pathFill = fill.fillPath({
- seriesNumber: 0,
- size: opts.size,
- fillColors: Array.isArray(trackConfig.background) ? trackConfig.background[i] : trackConfig.background,
- solid: true
- });
- var startAngle = this.trackStartAngle;
- var endAngle = this.trackEndAngle;
- if (Math.abs(endAngle) + Math.abs(startAngle) >= 360) endAngle = 360 - Math.abs(this.startAngle) - 0.1;
- var elPath = graphics.drawPath({
- d: '',
- stroke: pathFill,
- strokeWidth: strokeWidth * parseInt(trackConfig.strokeWidth, 10) / 100,
- fill: 'none',
- strokeOpacity: trackConfig.opacity,
- classes: 'apexcharts-radialbar-area'
- });
- if (trackConfig.dropShadow.enabled) {
- var shadow = trackConfig.dropShadow;
- filters.dropShadow(elPath, shadow);
- }
- elRadialBarTrack.add(elPath);
- elPath.attr('id', 'apexcharts-radialbarTrack-' + i);
- this.animatePaths(elPath, {
- centerX: opts.centerX,
- centerY: opts.centerY,
- endAngle: endAngle,
- startAngle: startAngle,
- size: opts.size,
- i: i,
- totalItems: 2,
- animBeginArr: 0,
- dur: 0,
- isTrack: true,
- easing: w.globals.easing
- });
- }
- return g;
- }
- }, {
- key: "drawArcs",
- value: function drawArcs(opts) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var fill = new Fill(this.ctx);
- var filters = new Filters(this.ctx);
- var g = graphics.group();
- var strokeWidth = this.getStrokeWidth(opts);
- opts.size = opts.size - strokeWidth / 2;
- var hollowFillID = w.config.plotOptions.radialBar.hollow.background;
- var hollowSize = opts.size - strokeWidth * opts.series.length - this.margin * opts.series.length - strokeWidth * parseInt(w.config.plotOptions.radialBar.track.strokeWidth, 10) / 100 / 2;
- var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin;
- if (w.config.plotOptions.radialBar.hollow.image !== undefined) {
- hollowFillID = this.drawHollowImage(opts, g, hollowSize, hollowFillID);
- }
- var elHollow = this.drawHollow({
- size: hollowRadius,
- centerX: opts.centerX,
- centerY: opts.centerY,
- fill: hollowFillID ? hollowFillID : 'transparent'
- });
- if (w.config.plotOptions.radialBar.hollow.dropShadow.enabled) {
- var shadow = w.config.plotOptions.radialBar.hollow.dropShadow;
- filters.dropShadow(elHollow, shadow);
- }
- var shown = 1;
- if (!this.radialDataLabels.total.show && w.globals.series.length > 1) {
- shown = 0;
- }
- var dataLabels = null;
- if (this.radialDataLabels.show) {
- dataLabels = this.renderInnerDataLabels(this.radialDataLabels, {
- hollowSize: hollowSize,
- centerX: opts.centerX,
- centerY: opts.centerY,
- opacity: shown
- });
- }
- if (w.config.plotOptions.radialBar.hollow.position === 'back') {
- g.add(elHollow);
- if (dataLabels) {
- g.add(dataLabels);
- }
- }
- var reverseLoop = false;
- if (w.config.plotOptions.radialBar.inverseOrder) {
- reverseLoop = true;
- }
- for (var i = reverseLoop ? opts.series.length - 1 : 0; reverseLoop ? i >= 0 : i < opts.series.length; reverseLoop ? i-- : i++) {
- var elRadialBarArc = graphics.group({
- class: "apexcharts-series apexcharts-radial-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[i])
- });
- g.add(elRadialBarArc);
- elRadialBarArc.attr({
- rel: i + 1,
- 'data:realIndex': i
- });
- this.ctx.series.addCollapsedClassToSeries(elRadialBarArc, i);
- opts.size = opts.size - strokeWidth - this.margin;
- var pathFill = fill.fillPath({
- seriesNumber: i,
- size: opts.size,
- value: opts.series[i]
- });
- var startAngle = this.startAngle;
- var prevStartAngle = void 0;
- var dataValue = Utils.negToZero(opts.series[i] > 100 ? 100 : opts.series[i]) / 100;
- var endAngle = Math.round(this.totalAngle * dataValue) + this.startAngle;
- var prevEndAngle = void 0;
- if (w.globals.dataChanged) {
- prevStartAngle = this.startAngle;
- prevEndAngle = Math.round(this.totalAngle * Utils.negToZero(w.globals.previousPaths[i]) / 100) + prevStartAngle;
- }
- var currFullAngle = Math.abs(endAngle) + Math.abs(startAngle);
- if (currFullAngle >= 360) {
- endAngle = endAngle - 0.01;
- }
- var prevFullAngle = Math.abs(prevEndAngle) + Math.abs(prevStartAngle);
- if (prevFullAngle >= 360) {
- prevEndAngle = prevEndAngle - 0.01;
- }
- var angle = endAngle - startAngle;
- var dashArray = Array.isArray(w.config.stroke.dashArray) ? w.config.stroke.dashArray[i] : w.config.stroke.dashArray;
- var elPath = graphics.drawPath({
- d: '',
- stroke: pathFill,
- strokeWidth: strokeWidth,
- fill: 'none',
- fillOpacity: w.config.fill.opacity,
- classes: 'apexcharts-radialbar-area apexcharts-radialbar-slice-' + i,
- strokeDashArray: dashArray
- });
- Graphics.setAttrs(elPath.node, {
- 'data:angle': angle,
- 'data:value': opts.series[i]
- });
- if (w.config.chart.dropShadow.enabled) {
- var _shadow = w.config.chart.dropShadow;
- filters.dropShadow(elPath, _shadow, i);
- }
- this.addListeners(elPath, this.radialDataLabels);
- elRadialBarArc.add(elPath);
- elPath.attr({
- index: 0,
- j: i
- });
- var dur = 0;
- if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
- dur = (endAngle - startAngle) / 360 * w.config.chart.animations.speed;
- this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
- this.animBeginArr.push(this.animDur);
- }
- if (w.globals.dataChanged) {
- dur = (endAngle - startAngle) / 360 * w.config.chart.animations.dynamicAnimation.speed;
- this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
- this.animBeginArr.push(this.animDur);
- }
- this.animatePaths(elPath, {
- centerX: opts.centerX,
- centerY: opts.centerY,
- endAngle: endAngle,
- startAngle: startAngle,
- prevEndAngle: prevEndAngle,
- prevStartAngle: prevStartAngle,
- size: opts.size,
- i: i,
- totalItems: 2,
- animBeginArr: this.animBeginArr,
- dur: dur,
- shouldSetPrevPaths: true,
- easing: w.globals.easing
- });
- }
- return {
- g: g,
- elHollow: elHollow,
- dataLabels: dataLabels
- };
- }
- }, {
- key: "drawHollow",
- value: function drawHollow(opts) {
- var graphics = new Graphics(this.ctx);
- var circle = graphics.drawCircle(opts.size * 2);
- circle.attr({
- class: 'apexcharts-radialbar-hollow',
- cx: opts.centerX,
- cy: opts.centerY,
- r: opts.size,
- fill: opts.fill
- });
- return circle;
- }
- }, {
- key: "drawHollowImage",
- value: function drawHollowImage(opts, g, hollowSize, hollowFillID) {
- var w = this.w;
- var fill = new Fill(this.ctx);
- var randID = Utils.randomId();
- var hollowFillImg = w.config.plotOptions.radialBar.hollow.image;
- if (w.config.plotOptions.radialBar.hollow.imageClipped) {
- fill.clippedImgArea({
- width: hollowSize,
- height: hollowSize,
- image: hollowFillImg,
- patternID: "pattern".concat(w.globals.cuid).concat(randID)
- });
- hollowFillID = "url(#pattern".concat(w.globals.cuid).concat(randID, ")");
- } else {
- var imgWidth = w.config.plotOptions.radialBar.hollow.imageWidth;
- var imgHeight = w.config.plotOptions.radialBar.hollow.imageHeight;
- if (imgWidth === undefined && imgHeight === undefined) {
- var image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
- this.move(opts.centerX - loader.width / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - loader.height / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
- });
- g.add(image);
- } else {
- var _image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
- this.move(opts.centerX - imgWidth / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - imgHeight / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
- this.size(imgWidth, imgHeight);
- });
- g.add(_image);
- }
- }
- return hollowFillID;
- }
- }, {
- key: "getStrokeWidth",
- value: function getStrokeWidth(opts) {
- var w = this.w;
- return opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size, 10)) / 100 / (opts.series.length + 1) - this.margin;
- }
- }]);
- return Radial;
- }(Pie);
-
- var RangeBar = function (_Bar) {
- _inherits(RangeBar, _Bar);
- function RangeBar() {
- _classCallCheck(this, RangeBar);
- return _possibleConstructorReturn(this, _getPrototypeOf(RangeBar).apply(this, arguments));
- }
- _createClass(RangeBar, [{
- key: "draw",
- value: function draw(series, seriesIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- this.rangeBarOptions = this.w.config.plotOptions.rangeBar;
- this.series = series;
- this.seriesRangeStart = w.globals.seriesRangeStart;
- this.seriesRangeEnd = w.globals.seriesRangeEnd;
- this.barHelpers.initVariables(series);
- var ret = graphics.group({
- class: 'apexcharts-rangebar-series apexcharts-plot-series'
- });
- for (var i = 0; i < series.length; i++) {
- var x = void 0,
- y = void 0,
- xDivision = void 0,
-
- yDivision = void 0,
-
- zeroH = void 0,
-
- zeroW = void 0;
- var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
- var elSeries = graphics.group({
- class: "apexcharts-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
- rel: i + 1,
- 'data:realIndex': realIndex
- });
- if (series[i].length > 0) {
- this.visibleI = this.visibleI + 1;
- }
- var barHeight = 0;
- var barWidth = 0;
- if (this.yRatio.length > 1) {
- this.yaxisIndex = realIndex;
- }
- var initPositions = this.barHelpers.initialPositions();
- y = initPositions.y;
- zeroW = initPositions.zeroW;
- x = initPositions.x;
- barWidth = initPositions.barWidth;
- xDivision = initPositions.xDivision;
- zeroH = initPositions.zeroH;
- var elDataLabelsWrap = graphics.group({
- class: 'apexcharts-datalabels',
- 'data:realIndex': realIndex
- });
- for (var j = 0; j < w.globals.dataPoints; j++) {
- var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
- var y1 = this.seriesRangeStart[i][j];
- var y2 = this.seriesRangeEnd[i][j];
- var paths = null;
- var barYPosition = null;
- var params = {
- x: x,
- y: y,
- strokeWidth: strokeWidth,
- elSeries: elSeries
- };
- yDivision = initPositions.yDivision;
- barHeight = initPositions.barHeight;
- if (this.isHorizontal) {
- barYPosition = y + barHeight * this.visibleI;
- var srty = (yDivision - barHeight * this.seriesLen) / 2;
- if (typeof w.config.series[i].data[j] === 'undefined') {
-
-
- break;
- }
- if (this.isTimelineBar && w.config.series[i].data[j].x) {
- var positions = this.detectOverlappingBars({
- i: i,
- j: j,
- barYPosition: barYPosition,
- srty: srty,
- barHeight: barHeight,
- yDivision: yDivision,
- initPositions: initPositions
- });
- barHeight = positions.barHeight;
- barYPosition = positions.barYPosition;
- }
- paths = this.drawRangeBarPaths(_objectSpread2({
- indexes: {
- i: i,
- j: j,
- realIndex: realIndex
- },
- barHeight: barHeight,
- barYPosition: barYPosition,
- zeroW: zeroW,
- yDivision: yDivision,
- y1: y1,
- y2: y2
- }, params));
- barWidth = paths.barWidth;
- } else {
- paths = this.drawRangeColumnPaths(_objectSpread2({
- indexes: {
- i: i,
- j: j,
- realIndex: realIndex
- },
- zeroH: zeroH,
- barWidth: barWidth,
- xDivision: xDivision
- }, params));
- barHeight = paths.barHeight;
- }
- y = paths.y;
- x = paths.x;
- var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
- var lineFill = w.globals.stroke.colors[realIndex];
- this.renderSeries({
- realIndex: realIndex,
- pathFill: pathFill,
- lineFill: lineFill,
- j: j,
- i: i,
- x: x,
- y: y,
- y1: y1,
- y2: y2,
- pathFrom: paths.pathFrom,
- pathTo: paths.pathTo,
- strokeWidth: strokeWidth,
- elSeries: elSeries,
- series: series,
- barHeight: barHeight,
- barYPosition: barYPosition,
- barWidth: barWidth,
- elDataLabelsWrap: elDataLabelsWrap,
- visibleSeries: this.visibleI,
- type: 'rangebar'
- });
- }
- ret.add(elSeries);
- }
- return ret;
- }
- }, {
- key: "detectOverlappingBars",
- value: function detectOverlappingBars(_ref) {
- var i = _ref.i,
- j = _ref.j,
- barYPosition = _ref.barYPosition,
- srty = _ref.srty,
- barHeight = _ref.barHeight,
- yDivision = _ref.yDivision,
- initPositions = _ref.initPositions;
- var w = this.w;
- var overlaps = [];
- var rangeName = w.config.series[i].data[j].rangeName;
- var labelX = w.config.series[i].data[j].x;
- var rowIndex = w.globals.labels.indexOf(labelX);
- var overlappedIndex = w.globals.seriesRangeBarTimeline[i].findIndex(function (tx) {
- return tx.x === labelX && tx.overlaps.length > 0;
- });
- barYPosition = srty + barHeight * this.visibleI + yDivision * rowIndex;
- if (overlappedIndex > -1) {
- overlaps = w.globals.seriesRangeBarTimeline[i][overlappedIndex].overlaps;
- if (overlaps.indexOf(rangeName) > -1) {
- barHeight = initPositions.barHeight / overlaps.length;
- barYPosition = barHeight * this.visibleI + yDivision * (100 - parseInt(this.barOptions.barHeight, 10)) / 100 / 2 + barHeight * (this.visibleI + overlaps.indexOf(rangeName)) + yDivision * rowIndex;
- }
- }
- return {
- barYPosition: barYPosition,
- barHeight: barHeight
- };
- }
- }, {
- key: "drawRangeColumnPaths",
- value: function drawRangeColumnPaths(_ref2) {
- var indexes = _ref2.indexes,
- x = _ref2.x,
- strokeWidth = _ref2.strokeWidth,
- xDivision = _ref2.xDivision,
- barWidth = _ref2.barWidth,
- zeroH = _ref2.zeroH;
- var w = this.w;
- var i = indexes.i;
- var j = indexes.j;
- var yRatio = this.yRatio[this.yaxisIndex];
- var realIndex = indexes.realIndex;
- var range = this.getRangeValue(realIndex, j);
- var y1 = Math.min(range.start, range.end);
- var y2 = Math.max(range.start, range.end);
- if (w.globals.isXNumeric) {
- x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2;
- }
- var barXPosition = x + barWidth * this.visibleI;
- if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
- y1 = zeroH;
- } else {
- y1 = zeroH - y1 / yRatio;
- y2 = zeroH - y2 / yRatio;
- }
- var barHeight = Math.abs(y2 - y1);
- var paths = this.barHelpers.getColumnPaths({
- barXPosition: barXPosition,
- barWidth: barWidth,
- y1: y1,
- y2: y2,
- strokeWidth: this.strokeWidth,
- series: this.seriesRangeEnd,
- i: realIndex,
- j: j,
- w: w
- });
- if (!w.globals.isXNumeric) {
- x = x + xDivision;
- }
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- barHeight: barHeight,
- x: x,
- y: y2,
- barXPosition: barXPosition
- };
- }
- }, {
- key: "drawRangeBarPaths",
- value: function drawRangeBarPaths(_ref3) {
- var indexes = _ref3.indexes,
- y = _ref3.y,
- y1 = _ref3.y1,
- y2 = _ref3.y2,
- yDivision = _ref3.yDivision,
- barHeight = _ref3.barHeight,
- barYPosition = _ref3.barYPosition,
- zeroW = _ref3.zeroW;
- var w = this.w;
- var x1 = zeroW + y1 / this.invertedYRatio;
- var x2 = zeroW + y2 / this.invertedYRatio;
- var barWidth = Math.abs(x2 - x1);
- var paths = this.barHelpers.getBarpaths({
- barYPosition: barYPosition,
- barHeight: barHeight,
- x1: x1,
- x2: x2,
- strokeWidth: this.strokeWidth,
- series: this.seriesRangeEnd,
- i: indexes.realIndex,
- j: indexes.j,
- w: w
- });
- if (!w.globals.isXNumeric) {
- y = y + yDivision;
- }
- return {
- pathTo: paths.pathTo,
- pathFrom: paths.pathFrom,
- barWidth: barWidth,
- x: x2,
- y: y
- };
- }
- }, {
- key: "getRangeValue",
- value: function getRangeValue(i, j) {
- var w = this.w;
- return {
- start: w.globals.seriesRangeStart[i][j],
- end: w.globals.seriesRangeEnd[i][j]
- };
- }
- }]);
- return RangeBar;
- }(Bar);
- var Helpers$4 = function () {
- function Helpers(lineCtx) {
- _classCallCheck(this, Helpers);
- this.w = lineCtx.w;
- this.lineCtx = lineCtx;
- }
- _createClass(Helpers, [{
- key: "sameValueSeriesFix",
- value: function sameValueSeriesFix(i, series) {
- var w = this.w;
- if (w.config.chart.type === 'line' && (w.config.fill.type === 'gradient' || w.config.fill.type[i] === 'gradient')) {
- var coreUtils = new CoreUtils(this.lineCtx.ctx, w);
-
- if (coreUtils.seriesHaveSameValues(i)) {
- var gSeries = series[i].slice();
- gSeries[gSeries.length - 1] = gSeries[gSeries.length - 1] + 0.000001;
- series[i] = gSeries;
- }
- }
- return series;
- }
- }, {
- key: "calculatePoints",
- value: function calculatePoints(_ref) {
- var series = _ref.series,
- realIndex = _ref.realIndex,
- x = _ref.x,
- y = _ref.y,
- i = _ref.i,
- j = _ref.j,
- prevY = _ref.prevY;
- var w = this.w;
- var ptX = [];
- var ptY = [];
- if (j === 0) {
- var xPT1st = this.lineCtx.categoryAxisCorrection + w.config.markers.offsetX;
-
-
- if (w.globals.isXNumeric) {
- xPT1st = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.lineCtx.xRatio + w.config.markers.offsetX;
- }
- ptX.push(xPT1st);
- ptY.push(Utils.isNumber(series[i][0]) ? prevY + w.config.markers.offsetY : null);
- ptX.push(x + w.config.markers.offsetX);
- ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
- } else {
- ptX.push(x + w.config.markers.offsetX);
- ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
- }
- var pointsPos = {
- x: ptX,
- y: ptY
- };
- return pointsPos;
- }
- }, {
- key: "checkPreviousPaths",
- value: function checkPreviousPaths(_ref2) {
- var pathFromLine = _ref2.pathFromLine,
- pathFromArea = _ref2.pathFromArea,
- realIndex = _ref2.realIndex;
- var w = this.w;
- for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
- var gpp = w.globals.previousPaths[pp];
- if ((gpp.type === 'line' || gpp.type === 'area') && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
- if (gpp.type === 'line') {
- this.lineCtx.appendPathFrom = false;
- pathFromLine = w.globals.previousPaths[pp].paths[0].d;
- } else if (gpp.type === 'area') {
- this.lineCtx.appendPathFrom = false;
- pathFromArea = w.globals.previousPaths[pp].paths[0].d;
- if (w.config.stroke.show && w.globals.previousPaths[pp].paths[1]) {
- pathFromLine = w.globals.previousPaths[pp].paths[1].d;
- }
- }
- }
- }
- return {
- pathFromLine: pathFromLine,
- pathFromArea: pathFromArea
- };
- }
- }, {
- key: "determineFirstPrevY",
- value: function determineFirstPrevY(_ref3) {
- var i = _ref3.i,
- series = _ref3.series,
- prevY = _ref3.prevY,
- lineYPosition = _ref3.lineYPosition;
- var w = this.w;
- if (typeof series[i][0] !== 'undefined') {
- if (w.config.chart.stacked) {
- if (i > 0) {
-
- lineYPosition = this.lineCtx.prevSeriesY[i - 1][0];
- } else {
-
- lineYPosition = this.lineCtx.zeroY;
- }
- } else {
- lineYPosition = this.lineCtx.zeroY;
- }
- prevY = lineYPosition - series[i][0] / this.lineCtx.yRatio[this.lineCtx.yaxisIndex] + (this.lineCtx.isReversed ? series[i][0] / this.lineCtx.yRatio[this.lineCtx.yaxisIndex] : 0) * 2;
- } else {
-
- if (w.config.chart.stacked && i > 0 && typeof series[i][0] === 'undefined') {
-
- for (var s = i - 1; s >= 0; s--) {
-
- if (series[s][0] !== null && typeof series[s][0] !== 'undefined') {
- lineYPosition = this.lineCtx.prevSeriesY[s][0];
- prevY = lineYPosition;
- break;
- }
- }
- }
- }
- return {
- prevY: prevY,
- lineYPosition: lineYPosition
- };
- }
- }]);
- return Helpers;
- }();
-
- var Line = function () {
- function Line(ctx, xyRatios, isPointsChart) {
- _classCallCheck(this, Line);
- this.ctx = ctx;
- this.w = ctx.w;
- this.xyRatios = xyRatios;
- this.pointsChart = !(this.w.config.chart.type !== 'bubble' && this.w.config.chart.type !== 'scatter') || isPointsChart;
- this.scatter = new Scatter(this.ctx);
- this.noNegatives = this.w.globals.minX === Number.MAX_VALUE;
- this.lineHelpers = new Helpers$4(this);
- this.markers = new Markers(this.ctx);
- this.prevSeriesY = [];
- this.categoryAxisCorrection = 0;
- this.yaxisIndex = 0;
- }
- _createClass(Line, [{
- key: "draw",
- value: function draw(series, ptype, seriesIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var type = w.globals.comboCharts ? ptype : w.config.chart.type;
- var ret = graphics.group({
- class: "apexcharts-".concat(type, "-series apexcharts-plot-series")
- });
- var coreUtils = new CoreUtils(this.ctx, w);
- this.yRatio = this.xyRatios.yRatio;
- this.zRatio = this.xyRatios.zRatio;
- this.xRatio = this.xyRatios.xRatio;
- this.baseLineY = this.xyRatios.baseLineY;
- series = coreUtils.getLogSeries(series);
- this.yRatio = coreUtils.getLogYRatios(this.yRatio);
- var allSeries = [];
- for (var i = 0; i < series.length; i++) {
- series = this.lineHelpers.sameValueSeriesFix(i, series);
- var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
- this._initSerieVariables(series, i, realIndex);
- var yArrj = [];
- var xArrj = [];
- var x = w.globals.padHorizontal + this.categoryAxisCorrection;
- var y = 1;
- var linePaths = [];
- var areaPaths = [];
- this.ctx.series.addCollapsedClassToSeries(this.elSeries, realIndex);
- if (w.globals.isXNumeric && w.globals.seriesX.length > 0) {
- x = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.xRatio;
- }
- xArrj.push(x);
- var pX = x;
- var pY = void 0;
- var prevX = pX;
- var prevY = this.zeroY;
- var lineYPosition = 0;
- var firstPrevY = this.lineHelpers.determineFirstPrevY({
- i: i,
- series: series,
- prevY: prevY,
- lineYPosition: lineYPosition
- });
- prevY = firstPrevY.prevY;
- yArrj.push(prevY);
- pY = prevY;
- var pathsFrom = this._calculatePathsFrom({
- series: series,
- i: i,
- realIndex: realIndex,
- prevX: prevX,
- prevY: prevY
- });
- var paths = this._iterateOverDataPoints({
- series: series,
- realIndex: realIndex,
- i: i,
- x: x,
- y: y,
- pX: pX,
- pY: pY,
- pathsFrom: pathsFrom,
- linePaths: linePaths,
- areaPaths: areaPaths,
- seriesIndex: seriesIndex,
- lineYPosition: lineYPosition,
- xArrj: xArrj,
- yArrj: yArrj
- });
- this._handlePaths({
- type: type,
- realIndex: realIndex,
- i: i,
- paths: paths
- });
- this.elSeries.add(this.elPointsMain);
- this.elSeries.add(this.elDataLabelsWrap);
- allSeries.push(this.elSeries);
- }
- for (var s = allSeries.length; s > 0; s--) {
- ret.add(allSeries[s - 1]);
- }
- return ret;
- }
- }, {
- key: "_initSerieVariables",
- value: function _initSerieVariables(series, i, realIndex) {
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- this.xDivision = w.globals.gridWidth / (w.globals.dataPoints - (w.config.xaxis.tickPlacement === 'on' ? 1 : 0));
- this.strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width;
- if (this.yRatio.length > 1) {
- this.yaxisIndex = realIndex;
- }
- this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
- this.zeroY = w.globals.gridHeight - this.baseLineY[this.yaxisIndex] - (this.isReversed ? w.globals.gridHeight : 0) + (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0);
- this.areaBottomY = this.zeroY;
- if (this.zeroY > w.globals.gridHeight) {
- this.areaBottomY = w.globals.gridHeight;
- }
- this.categoryAxisCorrection = this.xDivision / 2;
- this.elSeries = graphics.group({
- class: "apexcharts-series",
- seriesName: Utils.escapeString(w.globals.seriesNames[realIndex])
- });
- this.elPointsMain = graphics.group({
- class: 'apexcharts-series-markers-wrap',
- 'data:realIndex': realIndex
- });
- this.elDataLabelsWrap = graphics.group({
- class: 'apexcharts-datalabels',
- 'data:realIndex': realIndex
- });
- var longestSeries = series[i].length === w.globals.dataPoints;
- this.elSeries.attr({
- 'data:longestSeries': longestSeries,
- rel: i + 1,
- 'data:realIndex': realIndex
- });
- this.appendPathFrom = true;
- }
- }, {
- key: "_calculatePathsFrom",
- value: function _calculatePathsFrom(_ref) {
- var series = _ref.series,
- i = _ref.i,
- realIndex = _ref.realIndex,
- prevX = _ref.prevX,
- prevY = _ref.prevY;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var linePath, areaPath, pathFromLine, pathFromArea;
- if (series[i][0] === null) {
-
- for (var s = 0; s < series[i].length; s++) {
- if (series[i][s] !== null) {
- prevX = this.xDivision * s;
- prevY = this.zeroY - series[i][s] / this.yRatio[this.yaxisIndex];
- linePath = graphics.move(prevX, prevY);
- areaPath = graphics.move(prevX, this.areaBottomY);
- break;
- }
- }
- } else {
- linePath = graphics.move(prevX, prevY);
- areaPath = graphics.move(prevX, this.areaBottomY) + graphics.line(prevX, prevY);
- }
- pathFromLine = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
- pathFromArea = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
- if (w.globals.previousPaths.length > 0) {
- var pathFrom = this.lineHelpers.checkPreviousPaths({
- pathFromLine: pathFromLine,
- pathFromArea: pathFromArea,
- realIndex: realIndex
- });
- pathFromLine = pathFrom.pathFromLine;
- pathFromArea = pathFrom.pathFromArea;
- }
- return {
- prevX: prevX,
- prevY: prevY,
- linePath: linePath,
- areaPath: areaPath,
- pathFromLine: pathFromLine,
- pathFromArea: pathFromArea
- };
- }
- }, {
- key: "_handlePaths",
- value: function _handlePaths(_ref2) {
- var type = _ref2.type,
- realIndex = _ref2.realIndex,
- i = _ref2.i,
- paths = _ref2.paths;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var fill = new Fill(this.ctx);
- this.prevSeriesY.push(paths.yArrj);
- w.globals.seriesXvalues[realIndex] = paths.xArrj;
- w.globals.seriesYvalues[realIndex] = paths.yArrj;
- if (!this.pointsChart) {
- w.globals.delayedElements.push({
- el: this.elPointsMain.node,
- index: realIndex
- });
- }
- var defaultRenderedPathOptions = {
- i: i,
- realIndex: realIndex,
- animationDelay: i,
- initialSpeed: w.config.chart.animations.speed,
- dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
- className: "apexcharts-".concat(type)
- };
- if (type === 'area') {
- var pathFill = fill.fillPath({
- seriesNumber: realIndex
- });
- for (var p = 0; p < paths.areaPaths.length; p++) {
- var renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
- pathFrom: paths.pathFromArea,
- pathTo: paths.areaPaths[p],
- stroke: 'none',
- strokeWidth: 0,
- strokeLineCap: null,
- fill: pathFill
- }));
- this.elSeries.add(renderedPath);
- }
- }
- if (w.config.stroke.show && !this.pointsChart) {
- var lineFill = null;
- if (type === 'line') {
-
- lineFill = fill.fillPath({
- seriesNumber: realIndex,
- i: i
- });
- } else {
- lineFill = w.globals.stroke.colors[realIndex];
- }
- for (var _p = 0; _p < paths.linePaths.length; _p++) {
- var _renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
- pathFrom: paths.pathFromLine,
- pathTo: paths.linePaths[_p],
- stroke: lineFill,
- strokeWidth: this.strokeWidth,
- strokeLineCap: w.config.stroke.lineCap,
- fill: 'none'
- }));
- this.elSeries.add(_renderedPath);
- }
- }
- }
- }, {
- key: "_iterateOverDataPoints",
- value: function _iterateOverDataPoints(_ref3) {
- var series = _ref3.series,
- realIndex = _ref3.realIndex,
- i = _ref3.i,
- x = _ref3.x,
- y = _ref3.y,
- pX = _ref3.pX,
- pY = _ref3.pY,
- pathsFrom = _ref3.pathsFrom,
- linePaths = _ref3.linePaths,
- areaPaths = _ref3.areaPaths,
- seriesIndex = _ref3.seriesIndex,
- lineYPosition = _ref3.lineYPosition,
- xArrj = _ref3.xArrj,
- yArrj = _ref3.yArrj;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var yRatio = this.yRatio;
- var prevY = pathsFrom.prevY,
- linePath = pathsFrom.linePath,
- areaPath = pathsFrom.areaPath,
- pathFromLine = pathsFrom.pathFromLine,
- pathFromArea = pathsFrom.pathFromArea;
- var minY = Utils.isNumber(w.globals.minYArr[realIndex]) ? w.globals.minYArr[realIndex] : w.globals.minY;
- var iterations = w.globals.dataPoints > 1 ? w.globals.dataPoints - 1 : w.globals.dataPoints;
- for (var j = 0; j < iterations; j++) {
- var isNull = typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null;
- if (w.globals.isXNumeric) {
- var sX = w.globals.seriesX[realIndex][j + 1];
- if (typeof w.globals.seriesX[realIndex][j + 1] === 'undefined') {
-
- sX = w.globals.seriesX[realIndex][iterations - 1];
- }
- x = (sX - w.globals.minX) / this.xRatio;
- } else {
- x = x + this.xDivision;
- }
- if (w.config.chart.stacked) {
- if (i > 0 && w.globals.collapsedSeries.length < w.config.series.length - 1) {
-
- var prevIndex = function prevIndex(pi) {
- var pii = pi;
- for (var cpi = 0; cpi < w.globals.series.length; cpi++) {
- if (w.globals.collapsedSeriesIndices.indexOf(pi) > -1) {
- pii--;
- break;
- }
- }
- return pii >= 0 ? pii : 0;
- };
- lineYPosition = this.prevSeriesY[prevIndex(i - 1)][j + 1];
- } else {
-
- lineYPosition = this.zeroY;
- }
- } else {
- lineYPosition = this.zeroY;
- }
- if (isNull) {
- y = lineYPosition - minY / yRatio[this.yaxisIndex] + (this.isReversed ? minY / yRatio[this.yaxisIndex] : 0) * 2;
- } else {
- y = lineYPosition - series[i][j + 1] / yRatio[this.yaxisIndex] + (this.isReversed ? series[i][j + 1] / yRatio[this.yaxisIndex] : 0) * 2;
- }
- xArrj.push(x);
- yArrj.push(y);
- var pointsPos = this.lineHelpers.calculatePoints({
- series: series,
- x: x,
- y: y,
- realIndex: realIndex,
- i: i,
- j: j,
- prevY: prevY
- });
- var calculatedPaths = this._createPaths({
- series: series,
- i: i,
- realIndex: realIndex,
- j: j,
- x: x,
- y: y,
- pX: pX,
- pY: pY,
- linePath: linePath,
- areaPath: areaPath,
- linePaths: linePaths,
- areaPaths: areaPaths,
- seriesIndex: seriesIndex
- });
- areaPaths = calculatedPaths.areaPaths;
- linePaths = calculatedPaths.linePaths;
- pX = calculatedPaths.pX;
- pY = calculatedPaths.pY;
- areaPath = calculatedPaths.areaPath;
- linePath = calculatedPaths.linePath;
- if (this.appendPathFrom) {
- pathFromLine = pathFromLine + graphics.line(x, this.zeroY);
- pathFromArea = pathFromArea + graphics.line(x, this.zeroY);
- }
- this.handleNullDataPoints(series, pointsPos, i, j, realIndex);
- this._handleMarkersAndLabels({
- pointsPos: pointsPos,
- series: series,
- x: x,
- y: y,
- prevY: prevY,
- i: i,
- j: j,
- realIndex: realIndex
- });
- }
- return {
- yArrj: yArrj,
- xArrj: xArrj,
- pathFromArea: pathFromArea,
- areaPaths: areaPaths,
- pathFromLine: pathFromLine,
- linePaths: linePaths
- };
- }
- }, {
- key: "_handleMarkersAndLabels",
- value: function _handleMarkersAndLabels(_ref4) {
- var pointsPos = _ref4.pointsPos,
- series = _ref4.series,
- x = _ref4.x,
- y = _ref4.y,
- prevY = _ref4.prevY,
- i = _ref4.i,
- j = _ref4.j,
- realIndex = _ref4.realIndex;
- var w = this.w;
- var dataLabels = new DataLabels(this.ctx);
- if (!this.pointsChart) {
- if (w.globals.series[i].length > 1) {
- this.elPointsMain.node.classList.add('apexcharts-element-hidden');
- }
- var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1);
- if (elPointsWrap !== null) {
- this.elPointsMain.add(elPointsWrap);
- }
- } else {
-
- this.scatter.draw(this.elSeries, j, {
- realIndex: realIndex,
- pointsPos: pointsPos,
- zRatio: this.zRatio,
- elParent: this.elPointsMain
- });
- }
- var drawnLabels = dataLabels.drawDataLabel(pointsPos, realIndex, j + 1, null);
- if (drawnLabels !== null) {
- this.elDataLabelsWrap.add(drawnLabels);
- }
- }
- }, {
- key: "_createPaths",
- value: function _createPaths(_ref5) {
- var series = _ref5.series,
- i = _ref5.i,
- realIndex = _ref5.realIndex,
- j = _ref5.j,
- x = _ref5.x,
- y = _ref5.y,
- pX = _ref5.pX,
- pY = _ref5.pY,
- linePath = _ref5.linePath,
- areaPath = _ref5.areaPath,
- linePaths = _ref5.linePaths,
- areaPaths = _ref5.areaPaths,
- seriesIndex = _ref5.seriesIndex;
- var w = this.w;
- var graphics = new Graphics(this.ctx);
- var curve = w.config.stroke.curve;
- var areaBottomY = this.areaBottomY;
- if (Array.isArray(w.config.stroke.curve)) {
- if (Array.isArray(seriesIndex)) {
- curve = w.config.stroke.curve[seriesIndex[i]];
- } else {
- curve = w.config.stroke.curve[i];
- }
- }
-
- if (curve === 'smooth') {
- var length = (x - pX) * 0.35;
- if (w.globals.hasNullValues) {
- if (series[i][j] !== null) {
- if (series[i][j + 1] !== null) {
- linePath = graphics.move(pX, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y);
- areaPath = graphics.move(pX + 1, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y) + graphics.line(x, areaBottomY) + graphics.line(pX, areaBottomY) + 'z';
- } else {
- linePath = graphics.move(pX, pY);
- areaPath = graphics.move(pX, pY) + 'z';
- }
- }
- linePaths.push(linePath);
- areaPaths.push(areaPath);
- } else {
- linePath = linePath + graphics.curve(pX + length, pY, x - length, y, x, y);
- areaPath = areaPath + graphics.curve(pX + length, pY, x - length, y, x, y);
- }
- pX = x;
- pY = y;
- if (j === series[i].length - 2) {
-
- areaPath = areaPath + graphics.curve(pX, pY, x, y, x, areaBottomY) + graphics.move(x, y) + 'z';
- if (!w.globals.hasNullValues) {
- linePaths.push(linePath);
- areaPaths.push(areaPath);
- }
- }
- } else {
- if (series[i][j + 1] === null) {
- linePath = linePath + graphics.move(x, y);
- var numericOrCatX = w.globals.isXNumeric ? (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio : x - this.xDivision;
- areaPath = areaPath + graphics.line(numericOrCatX, areaBottomY) + graphics.move(x, y) + 'z';
- }
- if (series[i][j] === null) {
- linePath = linePath + graphics.move(x, y);
- areaPath = areaPath + graphics.move(x, areaBottomY);
- }
- if (curve === 'stepline') {
- linePath = linePath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
- areaPath = areaPath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
- } else if (curve === 'straight') {
- linePath = linePath + graphics.line(x, y);
- areaPath = areaPath + graphics.line(x, y);
- }
- if (j === series[i].length - 2) {
-
- areaPath = areaPath + graphics.line(x, areaBottomY) + graphics.move(x, y) + 'z';
- linePaths.push(linePath);
- areaPaths.push(areaPath);
- }
- }
- return {
- linePaths: linePaths,
- areaPaths: areaPaths,
- pX: pX,
- pY: pY,
- linePath: linePath,
- areaPath: areaPath
- };
- }
- }, {
- key: "handleNullDataPoints",
- value: function handleNullDataPoints(series, pointsPos, i, j, realIndex) {
- var w = this.w;
- if (series[i][j] === null && w.config.markers.showNullDataPoints || series[i].length === 1) {
-
- var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1, this.strokeWidth - w.config.markers.strokeWidth / 2, true);
- if (elPointsWrap !== null) {
- this.elPointsMain.add(elPointsWrap);
- }
- }
- }
- }]);
- return Line;
- }();
-
- var TimeScale = function () {
- function TimeScale(ctx) {
- _classCallCheck(this, TimeScale);
- this.ctx = ctx;
- this.w = ctx.w;
- this.timeScaleArray = [];
- this.utc = this.w.config.xaxis.labels.datetimeUTC;
- }
- _createClass(TimeScale, [{
- key: "calculateTimeScaleTicks",
- value: function calculateTimeScaleTicks(minX, maxX) {
- var _this = this;
- var w = this.w;
- if (w.globals.allSeriesCollapsed) {
- w.globals.labels = [];
- w.globals.timescaleLabels = [];
- return [];
- }
- var dt = new DateTime(this.ctx);
- var daysDiff = (maxX - minX) / (1000 * 60 * 60 * 24);
- this.determineInterval(daysDiff);
- w.globals.disableZoomIn = false;
- w.globals.disableZoomOut = false;
- if (daysDiff < 0.005) {
- w.globals.disableZoomIn = true;
- } else if (daysDiff > 50000) {
- w.globals.disableZoomOut = true;
- }
- var timeIntervals = dt.getTimeUnitsfromTimestamp(minX, maxX, this.utc);
- var daysWidthOnXAxis = w.globals.gridWidth / daysDiff;
- var hoursWidthOnXAxis = daysWidthOnXAxis / 24;
- var minutesWidthOnXAxis = hoursWidthOnXAxis / 60;
- var numberOfHours = Math.floor(daysDiff * 24);
- var numberOfMinutes = Math.floor(daysDiff * 24 * 60);
- var numberOfDays = Math.floor(daysDiff);
- var numberOfMonths = Math.floor(daysDiff / 30);
- var numberOfYears = Math.floor(daysDiff / 365);
- var firstVal = {
- minMinute: timeIntervals.minMinute,
- minHour: timeIntervals.minHour,
- minDate: timeIntervals.minDate,
- minMonth: timeIntervals.minMonth,
- minYear: timeIntervals.minYear
- };
- var currentMinute = firstVal.minMinute;
- var currentHour = firstVal.minHour;
- var currentMonthDate = firstVal.minDate;
- var currentDate = firstVal.minDate;
- var currentMonth = firstVal.minMonth;
- var currentYear = firstVal.minYear;
- var params = {
- firstVal: firstVal,
- currentMinute: currentMinute,
- currentHour: currentHour,
- currentMonthDate: currentMonthDate,
- currentDate: currentDate,
- currentMonth: currentMonth,
- currentYear: currentYear,
- daysWidthOnXAxis: daysWidthOnXAxis,
- hoursWidthOnXAxis: hoursWidthOnXAxis,
- minutesWidthOnXAxis: minutesWidthOnXAxis,
- numberOfMinutes: numberOfMinutes,
- numberOfHours: numberOfHours,
- numberOfDays: numberOfDays,
- numberOfMonths: numberOfMonths,
- numberOfYears: numberOfYears
- };
- switch (this.tickInterval) {
- case 'years':
- {
- this.generateYearScale(params);
- break;
- }
- case 'months':
- case 'half_year':
- {
- this.generateMonthScale(params);
- break;
- }
- case 'months_days':
- case 'months_fortnight':
- case 'days':
- case 'week_days':
- {
- this.generateDayScale(params);
- break;
- }
- case 'hours':
- {
- this.generateHourScale(params);
- break;
- }
- case 'minutes':
- this.generateMinuteScale(params);
- break;
- }
-
-
- var adjustedMonthInTimeScaleArray = this.timeScaleArray.map(function (ts) {
- var defaultReturn = {
- position: ts.position,
- unit: ts.unit,
- year: ts.year,
- day: ts.day ? ts.day : 1,
- hour: ts.hour ? ts.hour : 0,
- month: ts.month + 1
- };
- if (ts.unit === 'month') {
- return _objectSpread2({}, defaultReturn, {
- day: 1,
- value: ts.value + 1
- });
- } else if (ts.unit === 'day' || ts.unit === 'hour') {
- return _objectSpread2({}, defaultReturn, {
- value: ts.value
- });
- } else if (ts.unit === 'minute') {
- return _objectSpread2({}, defaultReturn, {
- value: ts.value,
- minute: ts.value
- });
- }
- return ts;
- });
- var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts) {
- var modulo = 1;
- var ticks = Math.ceil(w.globals.gridWidth / 120);
- var value = ts.value;
- if (w.config.xaxis.tickAmount !== undefined) {
- ticks = w.config.xaxis.tickAmount;
- }
- if (adjustedMonthInTimeScaleArray.length > ticks) {
- modulo = Math.floor(adjustedMonthInTimeScaleArray.length / ticks);
- }
- var shouldNotSkipUnit = false;
- var shouldNotPrint = false;
- switch (_this.tickInterval) {
- case 'years':
-
- if (ts.unit === 'year') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'half_year':
- modulo = 7;
- if (ts.unit === 'year') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'months':
- modulo = 1;
- if (ts.unit === 'year') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'months_fortnight':
- modulo = 15;
- if (ts.unit === 'year' || ts.unit === 'month') {
- shouldNotSkipUnit = true;
- }
- if (value === 30) {
- shouldNotPrint = true;
- }
- break;
- case 'months_days':
- modulo = 10;
- if (ts.unit === 'month') {
- shouldNotSkipUnit = true;
- }
- if (value === 30) {
- shouldNotPrint = true;
- }
- break;
- case 'week_days':
- modulo = 8;
- if (ts.unit === 'month') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'days':
- modulo = 1;
- if (ts.unit === 'month') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'hours':
- if (ts.unit === 'day') {
- shouldNotSkipUnit = true;
- }
- break;
- case 'minutes':
- if (value % 5 !== 0) {
- shouldNotPrint = true;
- }
- break;
- }
- if (_this.tickInterval === 'minutes' || _this.tickInterval === 'hours') {
- if (!shouldNotPrint) {
- return true;
- }
- } else {
- if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) {
- return true;
- }
- }
- });
- return filteredTimeScale;
- }
- }, {
- key: "recalcDimensionsBasedOnFormat",
- value: function recalcDimensionsBasedOnFormat(filteredTimeScale, inverted) {
- var w = this.w;
- var reformattedTimescaleArray = this.formatDates(filteredTimeScale);
- var removedOverlappingTS = this.removeOverlappingTS(reformattedTimescaleArray);
- w.globals.timescaleLabels = removedOverlappingTS.slice();
-
-
-
- var dimensions = new Dimensions(this.ctx);
- dimensions.plotCoords();
- }
- }, {
- key: "determineInterval",
- value: function determineInterval(daysDiff) {
- switch (true) {
- case daysDiff > 1825:
-
- this.tickInterval = 'years';
- break;
- case daysDiff > 800 && daysDiff <= 1825:
- this.tickInterval = 'half_year';
- break;
- case daysDiff > 180 && daysDiff <= 800:
- this.tickInterval = 'months';
- break;
- case daysDiff > 90 && daysDiff <= 180:
- this.tickInterval = 'months_fortnight';
- break;
- case daysDiff > 60 && daysDiff <= 90:
- this.tickInterval = 'months_days';
- break;
- case daysDiff > 30 && daysDiff <= 60:
- this.tickInterval = 'week_days';
- break;
- case daysDiff > 2 && daysDiff <= 30:
- this.tickInterval = 'days';
- break;
- case daysDiff > 0.1 && daysDiff <= 2:
-
- this.tickInterval = 'hours';
- break;
- case daysDiff < 0.1:
- this.tickInterval = 'minutes';
- break;
- default:
- this.tickInterval = 'days';
- break;
- }
- }
- }, {
- key: "generateYearScale",
- value: function generateYearScale(_ref) {
- var firstVal = _ref.firstVal,
- currentMonth = _ref.currentMonth,
- currentYear = _ref.currentYear,
- daysWidthOnXAxis = _ref.daysWidthOnXAxis,
- numberOfYears = _ref.numberOfYears;
- var firstTickValue = firstVal.minYear;
- var firstTickPosition = 0;
- var dt = new DateTime(this.ctx);
- var unit = 'year';
- if (firstVal.minDate > 1 && firstVal.minMonth > 0) {
- var remainingDays = dt.determineRemainingDaysOfYear(firstVal.minYear, firstVal.minMonth, firstVal.minDate);
- var remainingDaysOfFirstYear = dt.determineDaysOfYear(firstVal.minYear) - remainingDays + 1;
- firstTickPosition = remainingDaysOfFirstYear * daysWidthOnXAxis;
- firstTickValue = firstVal.minYear + 1;
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: firstTickValue,
- unit: unit,
- year: firstTickValue,
- month: Utils.monthMod(currentMonth + 1)
- });
- } else if (firstVal.minDate === 1 && firstVal.minMonth === 0) {
-
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: firstTickValue,
- unit: unit,
- year: currentYear,
- month: Utils.monthMod(currentMonth + 1)
- });
- }
- var year = firstTickValue;
- var pos = firstTickPosition;
- for (var i = 0; i < numberOfYears; i++) {
- year++;
- pos = dt.determineDaysOfYear(year - 1) * daysWidthOnXAxis + pos;
- this.timeScaleArray.push({
- position: pos,
- value: year,
- unit: unit,
- year: year,
- month: 1
- });
- }
- }
- }, {
- key: "generateMonthScale",
- value: function generateMonthScale(_ref2) {
- var firstVal = _ref2.firstVal,
- currentMonthDate = _ref2.currentMonthDate,
- currentMonth = _ref2.currentMonth,
- currentYear = _ref2.currentYear,
- daysWidthOnXAxis = _ref2.daysWidthOnXAxis,
- numberOfMonths = _ref2.numberOfMonths;
- var firstTickValue = currentMonth;
- var firstTickPosition = 0;
- var dt = new DateTime(this.ctx);
- var unit = 'month';
- var yrCounter = 0;
- if (firstVal.minDate > 1) {
-
- var remainingDaysOfFirstMonth = dt.determineDaysOfMonths(currentMonth + 1, firstVal.minYear) - currentMonthDate + 1;
- firstTickPosition = remainingDaysOfFirstMonth * daysWidthOnXAxis;
- firstTickValue = Utils.monthMod(currentMonth + 1);
- var year = currentYear + yrCounter;
- var _month = Utils.monthMod(firstTickValue);
- var value = firstTickValue;
- if (firstTickValue === 0) {
- unit = 'year';
- value = year;
- _month = 1;
- yrCounter += 1;
- year = year + yrCounter;
- }
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: value,
- unit: unit,
- year: year,
- month: _month
- });
- } else {
-
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: firstTickValue,
- unit: unit,
- year: currentYear,
- month: Utils.monthMod(currentMonth)
- });
- }
- var month = firstTickValue + 1;
- var pos = firstTickPosition;
- for (var i = 0, j = 1; i < numberOfMonths; i++, j++) {
- month = Utils.monthMod(month);
- if (month === 0) {
- unit = 'year';
- yrCounter += 1;
- } else {
- unit = 'month';
- }
- var _year = this._getYear(currentYear, month, yrCounter);
- pos = dt.determineDaysOfMonths(month, _year) * daysWidthOnXAxis + pos;
- var monthVal = month === 0 ? _year : month;
- this.timeScaleArray.push({
- position: pos,
- value: monthVal,
- unit: unit,
- year: _year,
- month: month === 0 ? 1 : month
- });
- month++;
- }
- }
- }, {
- key: "generateDayScale",
- value: function generateDayScale(_ref3) {
- var firstVal = _ref3.firstVal,
- currentMonth = _ref3.currentMonth,
- currentYear = _ref3.currentYear,
- hoursWidthOnXAxis = _ref3.hoursWidthOnXAxis,
- numberOfDays = _ref3.numberOfDays;
- var dt = new DateTime(this.ctx);
- var unit = 'day';
- var firstTickValue = firstVal.minDate + 1;
- var date = firstTickValue;
- var changeMonth = function changeMonth(dateVal, month, year) {
- var monthdays = dt.determineDaysOfMonths(month + 1, year);
- if (dateVal > monthdays) {
- month = month + 1;
- date = 1;
- unit = 'month';
- val = month;
- return month;
- }
- return month;
- };
- var remainingHours = 24 - firstVal.minHour;
- var yrCounter = 0;
- var firstTickPosition = remainingHours * hoursWidthOnXAxis;
- var val = firstTickValue;
- var month = changeMonth(date, currentMonth, currentYear);
- if (firstVal.minHour === 0 && firstVal.minDate === 1) {
-
- firstTickPosition = 0;
- val = Utils.monthMod(firstVal.minMonth);
- unit = 'month';
- date = firstVal.minDate;
- numberOfDays++;
- }
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: val,
- unit: unit,
- year: this._getYear(currentYear, month, yrCounter),
- month: Utils.monthMod(month),
- day: date
- });
- var pos = firstTickPosition;
- for (var i = 0; i < numberOfDays; i++) {
- date += 1;
- unit = 'day';
- month = changeMonth(date, month, this._getYear(currentYear, month, yrCounter));
- var year = this._getYear(currentYear, month, yrCounter);
- pos = 24 * hoursWidthOnXAxis + pos;
- var value = date === 1 ? Utils.monthMod(month) : date;
- this.timeScaleArray.push({
- position: pos,
- value: value,
- unit: unit,
- year: year,
- month: Utils.monthMod(month),
- day: value
- });
- }
- }
- }, {
- key: "generateHourScale",
- value: function generateHourScale(_ref4) {
- var firstVal = _ref4.firstVal,
- currentDate = _ref4.currentDate,
- currentMonth = _ref4.currentMonth,
- currentYear = _ref4.currentYear,
- minutesWidthOnXAxis = _ref4.minutesWidthOnXAxis,
- numberOfHours = _ref4.numberOfHours;
- var dt = new DateTime(this.ctx);
- var yrCounter = 0;
- var unit = 'hour';
- var changeDate = function changeDate(dateVal, month) {
- var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
- if (dateVal > monthdays) {
- date = 1;
- month = month + 1;
- }
- return {
- month: month,
- date: date
- };
- };
- var changeMonth = function changeMonth(dateVal, month) {
- var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
- if (dateVal > monthdays) {
- month = month + 1;
- return month;
- }
- return month;
- };
- var remainingMins = 60 - firstVal.minMinute;
- var firstTickPosition = remainingMins * minutesWidthOnXAxis;
- var firstTickValue = firstVal.minHour + 1;
- var hour = firstTickValue + 1;
- if (remainingMins === 60) {
- firstTickPosition = 0;
- firstTickValue = firstVal.minHour;
- hour = firstTickValue + 1;
- }
- var date = currentDate;
- var month = changeMonth(date, currentMonth);
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: firstTickValue,
- unit: unit,
- day: date,
- hour: hour,
- year: currentYear,
- month: Utils.monthMod(month)
- });
- var pos = firstTickPosition;
- for (var i = 0; i < numberOfHours; i++) {
- unit = 'hour';
- if (hour >= 24) {
- hour = 0;
- date += 1;
- unit = 'day';
- var checkNextMonth = changeDate(date, month);
- month = checkNextMonth.month;
- month = changeMonth(date, month);
- }
- var year = this._getYear(currentYear, month, yrCounter);
- pos = hour === 0 && i === 0 ? remainingMins * minutesWidthOnXAxis : 60 * minutesWidthOnXAxis + pos;
- var val = hour === 0 ? date : hour;
- this.timeScaleArray.push({
- position: pos,
- value: val,
- unit: unit,
- hour: hour,
- day: date,
- year: year,
- month: Utils.monthMod(month)
- });
- hour++;
- }
- }
- }, {
- key: "generateMinuteScale",
- value: function generateMinuteScale(_ref5) {
- var firstVal = _ref5.firstVal,
- currentMinute = _ref5.currentMinute,
- currentHour = _ref5.currentHour,
- currentDate = _ref5.currentDate,
- currentMonth = _ref5.currentMonth,
- currentYear = _ref5.currentYear,
- minutesWidthOnXAxis = _ref5.minutesWidthOnXAxis,
- numberOfMinutes = _ref5.numberOfMinutes;
- var yrCounter = 0;
- var unit = 'minute';
- var remainingMins = currentMinute - firstVal.minMinute;
- var firstTickPosition = minutesWidthOnXAxis - remainingMins;
- var firstTickValue = firstVal.minMinute + 1;
- var minute = firstTickValue + 1;
- var date = currentDate;
- var month = currentMonth;
- var year = currentYear;
- var hour = currentHour;
- this.timeScaleArray.push({
- position: firstTickPosition,
- value: firstTickValue,
- unit: unit,
- day: date,
- hour: hour,
- minute: minute,
- year: year,
- month: Utils.monthMod(month)
- });
- var pos = firstTickPosition;
- for (var i = 0; i < numberOfMinutes; i++) {
- if (minute >= 60) {
- minute = 0;
- hour += 1;
- if (hour === 24) {
- hour = 0;
- }
- }
- pos = minutesWidthOnXAxis + pos;
- this.timeScaleArray.push({
- position: pos,
- value: minute,
- unit: unit,
- hour: hour,
- minute: minute,
- day: date,
- year: this._getYear(currentYear, month, yrCounter),
- month: Utils.monthMod(month)
- });
- minute++;
- }
- }
- }, {
- key: "createRawDateString",
- value: function createRawDateString(ts, value) {
- var raw = ts.year;
- raw += '-' + ('0' + ts.month.toString()).slice(-2);
- if (ts.unit === 'day') {
- raw += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01';
- } else {
- raw += '-' + ('0' + (ts.day ? ts.day : '1')).slice(-2);
- }
- if (ts.unit === 'hour') {
- raw += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) : 'T00';
- } else {
- raw += 'T' + ('0' + (ts.hour ? ts.hour : '0')).slice(-2);
- }
- raw += ts.unit === 'minute' ? ':' + ('0' + value).slice(-2) + ':00' : ':00:00';
- if (this.utc) {
- raw += '.000Z';
- }
- return raw;
- }
- }, {
- key: "formatDates",
- value: function formatDates(filteredTimeScale) {
- var _this2 = this;
- var w = this.w;
- var reformattedTimescaleArray = filteredTimeScale.map(function (ts) {
- var value = ts.value.toString();
- var dt = new DateTime(_this2.ctx);
- var raw = _this2.createRawDateString(ts, value);
- var dateToFormat = dt.getDate(raw);
- if (w.config.xaxis.labels.format === undefined) {
- var customFormat = 'dd MMM';
- var dtFormatter = w.config.xaxis.labels.datetimeFormatter;
- if (ts.unit === 'year') customFormat = dtFormatter.year;
- if (ts.unit === 'month') customFormat = dtFormatter.month;
- if (ts.unit === 'day') customFormat = dtFormatter.day;
- if (ts.unit === 'hour') customFormat = dtFormatter.hour;
- if (ts.unit === 'minute') customFormat = dtFormatter.minute;
- value = dt.formatDate(dateToFormat, customFormat);
- } else {
- value = dt.formatDate(dateToFormat, w.config.xaxis.labels.format);
- }
- return {
- dateString: raw,
- position: ts.position,
- value: value,
- unit: ts.unit,
- year: ts.year,
- month: ts.month
- };
- });
- return reformattedTimescaleArray;
- }
- }, {
- key: "removeOverlappingTS",
- value: function removeOverlappingTS(arr) {
- var _this3 = this;
- var graphics = new Graphics(this.ctx);
- var equalLabelLengthFlag = false;
- var constantLabelWidth;
- if (arr.length > 0 &&
- arr[0].value &&
- arr.every(function (lb) {
- return lb.value.length === arr[0].value.length;
- })
- ) {
- equalLabelLengthFlag = true;
- constantLabelWidth = graphics.getTextRects(arr[0].value).width;
- }
- var lastDrawnIndex = 0;
- var filteredArray = arr.map(function (item, index) {
- if (index > 0 && _this3.w.config.xaxis.labels.hideOverlappingLabels) {
- var prevLabelWidth = !equalLabelLengthFlag
- ? graphics.getTextRects(arr[lastDrawnIndex].value).width
- : constantLabelWidth;
- var prevPos = arr[lastDrawnIndex].position;
- var pos = item.position;
- if (pos > prevPos + prevLabelWidth + 10) {
- lastDrawnIndex = index;
- return item;
- } else {
- return null;
- }
- } else {
- return item;
- }
- });
- filteredArray = filteredArray.filter(function (f) {
- return f !== null;
- });
- return filteredArray;
- }
- }, {
- key: "_getYear",
- value: function _getYear(currentYear, month, yrCounter) {
- return currentYear + Math.floor(month / 12) + yrCounter;
- }
- }]);
- return TimeScale;
- }();
-
- var Core = function () {
- function Core(el, ctx) {
- _classCallCheck(this, Core);
- this.ctx = ctx;
- this.w = ctx.w;
- this.el = el;
- }
- _createClass(Core, [{
- key: "setupElements",
- value: function setupElements() {
- var gl = this.w.globals;
- var cnf = this.w.config;
- var ct = cnf.chart.type;
- var axisChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble', 'radar', 'heatmap'];
- var xyChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble'];
- gl.axisCharts = axisChartsArrTypes.indexOf(ct) > -1;
- gl.xyCharts = xyChartsArrTypes.indexOf(ct) > -1;
- gl.isBarHorizontal = (cnf.chart.type === 'bar' || cnf.chart.type === 'rangeBar') && cnf.plotOptions.bar.horizontal;
- gl.chartClass = '.apexcharts' + gl.cuid;
- gl.dom.baseEl = this.el;
- gl.dom.elWrap = document.createElement('div');
- Graphics.setAttrs(gl.dom.elWrap, {
- id: gl.chartClass.substring(1),
- class: 'apexcharts-canvas ' + gl.chartClass.substring(1)
- });
- this.el.appendChild(gl.dom.elWrap);
- gl.dom.Paper = new window.SVG.Doc(gl.dom.elWrap);
- gl.dom.Paper.attr({
- class: 'apexcharts-svg',
- 'xmlns:data': 'ApexChartsNS',
- transform: "translate(".concat(cnf.chart.offsetX, ", ").concat(cnf.chart.offsetY, ")")
- });
- gl.dom.Paper.node.style.background = cnf.chart.background;
- this.setSVGDimensions();
- gl.dom.elGraphical = gl.dom.Paper.group().attr({
- class: 'apexcharts-inner apexcharts-graphical'
- });
- gl.dom.elAnnotations = gl.dom.Paper.group().attr({
- class: 'apexcharts-annotations'
- });
- gl.dom.elDefs = gl.dom.Paper.defs();
- gl.dom.elLegendWrap = document.createElement('div');
- gl.dom.elLegendWrap.classList.add('apexcharts-legend');
- gl.dom.elWrap.appendChild(gl.dom.elLegendWrap);
- gl.dom.Paper.add(gl.dom.elGraphical);
- gl.dom.elGraphical.add(gl.dom.elDefs);
- }
- }, {
- key: "plotChartType",
- value: function plotChartType(ser, xyRatios) {
- var w = this.w;
- var cnf = w.config;
- var gl = w.globals;
- var lineSeries = {
- series: [],
- i: []
- };
- var areaSeries = {
- series: [],
- i: []
- };
- var scatterSeries = {
- series: [],
- i: []
- };
- var bubbleSeries = {
- series: [],
- i: []
- };
- var columnSeries = {
- series: [],
- i: []
- };
- var candlestickSeries = {
- series: [],
- i: []
- };
- gl.series.map(function (series, st) {
-
- if (typeof ser[st].type !== 'undefined') {
- if (ser[st].type === 'column' || ser[st].type === 'bar') {
- if (gl.series.length > 1 && cnf.plotOptions.bar.horizontal) {
-
- console.warn('Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`');
- }
- columnSeries.series.push(series);
- columnSeries.i.push(st);
- w.globals.columnSeries = columnSeries.series;
- } else if (ser[st].type === 'area') {
- areaSeries.series.push(series);
- areaSeries.i.push(st);
- } else if (ser[st].type === 'line') {
- lineSeries.series.push(series);
- lineSeries.i.push(st);
- } else if (ser[st].type === 'scatter') {
- scatterSeries.series.push(series);
- scatterSeries.i.push(st);
- } else if (ser[st].type === 'bubble') {
- bubbleSeries.series.push(series);
- bubbleSeries.i.push(st);
- } else if (ser[st].type === 'candlestick') {
- candlestickSeries.series.push(series);
- candlestickSeries.i.push(st);
- } else {
-
- console.warn('You have specified an unrecognized chart type. Available types for this propery are line/area/column/bar/scatter/bubble');
- }
- gl.comboCharts = true;
- } else {
- lineSeries.series.push(series);
- lineSeries.i.push(st);
- }
- });
- var line = new Line(this.ctx, xyRatios);
- var candlestick = new CandleStick(this.ctx, xyRatios);
- var pie = new Pie(this.ctx);
- var radialBar = new Radial(this.ctx);
- var rangeBar = new RangeBar(this.ctx, xyRatios);
- var radar = new Radar(this.ctx);
- var elGraph = [];
- if (gl.comboCharts) {
- if (areaSeries.series.length > 0) {
- elGraph.push(line.draw(areaSeries.series, 'area', areaSeries.i));
- }
- if (columnSeries.series.length > 0) {
- if (w.config.chart.stacked) {
- var barStacked = new BarStacked(this.ctx, xyRatios);
- elGraph.push(barStacked.draw(columnSeries.series, columnSeries.i));
- } else {
- var bar = new Bar(this.ctx, xyRatios);
- elGraph.push(bar.draw(columnSeries.series, columnSeries.i));
- }
- }
- if (lineSeries.series.length > 0) {
- elGraph.push(line.draw(lineSeries.series, 'line', lineSeries.i));
- }
- if (candlestickSeries.series.length > 0) {
- elGraph.push(candlestick.draw(candlestickSeries.series, candlestickSeries.i));
- }
- if (scatterSeries.series.length > 0) {
- var scatterLine = new Line(this.ctx, xyRatios, true);
- elGraph.push(scatterLine.draw(scatterSeries.series, 'scatter', scatterSeries.i));
- }
- if (bubbleSeries.series.length > 0) {
- var bubbleLine = new Line(this.ctx, xyRatios, true);
- elGraph.push(bubbleLine.draw(bubbleSeries.series, 'bubble', bubbleSeries.i));
- }
- } else {
- switch (cnf.chart.type) {
- case 'line':
- elGraph = line.draw(gl.series, 'line');
- break;
- case 'area':
- elGraph = line.draw(gl.series, 'area');
- break;
- case 'bar':
- if (cnf.chart.stacked) {
- var _barStacked = new BarStacked(this.ctx, xyRatios);
- elGraph = _barStacked.draw(gl.series);
- } else {
- var _bar = new Bar(this.ctx, xyRatios);
- elGraph = _bar.draw(gl.series);
- }
- break;
- case 'candlestick':
- var candleStick = new CandleStick(this.ctx, xyRatios);
- elGraph = candleStick.draw(gl.series);
- break;
- case 'rangeBar':
- elGraph = rangeBar.draw(gl.series);
- break;
- case 'heatmap':
- var heatmap = new HeatMap(this.ctx, xyRatios);
- elGraph = heatmap.draw(gl.series);
- break;
- case 'pie':
- case 'donut':
- elGraph = pie.draw(gl.series);
- break;
- case 'radialBar':
- elGraph = radialBar.draw(gl.series);
- break;
- case 'radar':
- elGraph = radar.draw(gl.series);
- break;
- default:
- elGraph = line.draw(gl.series);
- }
- }
- return elGraph;
- }
- }, {
- key: "setSVGDimensions",
- value: function setSVGDimensions() {
- var gl = this.w.globals;
- var cnf = this.w.config;
- gl.svgWidth = cnf.chart.width;
- gl.svgHeight = cnf.chart.height;
- var elDim = Utils.getDimensions(this.el);
- var widthUnit = cnf.chart.width.toString().split(/[0-9]+/g).pop();
- if (widthUnit === '%') {
- if (Utils.isNumber(elDim[0])) {
- if (elDim[0].width === 0) {
- elDim = Utils.getDimensions(this.el.parentNode);
- }
- gl.svgWidth = elDim[0] * parseInt(cnf.chart.width, 10) / 100;
- }
- } else if (widthUnit === 'px' || widthUnit === '') {
- gl.svgWidth = parseInt(cnf.chart.width, 10);
- }
- if (gl.svgHeight !== 'auto' && gl.svgHeight !== '') {
- var heightUnit = cnf.chart.height.toString().split(/[0-9]+/g).pop();
- if (heightUnit === '%') {
- var elParentDim = Utils.getDimensions(this.el.parentNode);
- gl.svgHeight = elParentDim[1] * parseInt(cnf.chart.height, 10) / 100;
- } else {
- gl.svgHeight = parseInt(cnf.chart.height, 10);
- }
- } else {
- if (gl.axisCharts) {
- gl.svgHeight = gl.svgWidth / 1.61;
- } else {
- gl.svgHeight = gl.svgWidth / 1.2;
- }
- }
- if (gl.svgWidth < 0) gl.svgWidth = 0;
- if (gl.svgHeight < 0) gl.svgHeight = 0;
- Graphics.setAttrs(gl.dom.Paper.node, {
- width: gl.svgWidth,
- height: gl.svgHeight
- });
- var offsetY = cnf.chart.sparkline.enabled ? 0 : gl.axisCharts ? cnf.chart.parentHeightOffset : 0;
- gl.dom.Paper.node.parentNode.parentNode.style.minHeight = gl.svgHeight + offsetY + 'px';
- gl.dom.elWrap.style.width = gl.svgWidth + 'px';
- gl.dom.elWrap.style.height = gl.svgHeight + 'px';
- }
- }, {
- key: "shiftGraphPosition",
- value: function shiftGraphPosition() {
- var gl = this.w.globals;
- var tY = gl.translateY;
- var tX = gl.translateX;
- var scalingAttrs = {
- transform: 'translate(' + tX + ', ' + tY + ')'
- };
- Graphics.setAttrs(gl.dom.elGraphical.node, scalingAttrs);
- gl.x2SpaceAvailable = gl.svgWidth - gl.dom.elGraphical.x() - gl.gridWidth;
- }
- }, {
- key: "resizeNonAxisCharts",
- value: function resizeNonAxisCharts() {
- var w = this.w;
- var gl = w.globals;
- var legendHeight = 0;
- var offY = w.config.chart.sparkline.enabled ? 1 : 15;
- offY = offY + w.config.grid.padding.bottom;
- if ((w.config.legend.position === 'top' || w.config.legend.position === 'bottom') && w.config.legend.show && !w.config.legend.floating) {
- legendHeight = new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10;
- }
- var radialEl = w.globals.dom.baseEl.querySelector('.apexcharts-radialbar');
- var chartInnerDimensions = w.globals.radialSize * 2.05;
- if (radialEl && !w.config.chart.sparkline.enabled) {
- var elRadialRect = Utils.getBoundingClientRect(radialEl);
- chartInnerDimensions = elRadialRect.bottom;
- var maxHeight = elRadialRect.bottom - elRadialRect.top;
- chartInnerDimensions = Math.max(w.globals.radialSize * 2.05, maxHeight);
- }
- var newHeight = chartInnerDimensions + gl.translateY + legendHeight + offY;
- if (gl.dom.elLegendForeign) {
- gl.dom.elLegendForeign.setAttribute('height', newHeight);
- }
- gl.dom.elWrap.style.height = newHeight + 'px';
- Graphics.setAttrs(gl.dom.Paper.node, {
- height: newHeight
- });
- gl.dom.Paper.node.parentNode.parentNode.style.minHeight = newHeight + 'px';
- }
-
- }, {
- key: "coreCalculations",
- value: function coreCalculations() {
- var range = new Range$1(this.ctx);
- range.init();
- }
- }, {
- key: "resetGlobals",
- value: function resetGlobals() {
- var _this = this;
- var resetxyValues = function resetxyValues() {
- return _this.w.config.series.map(function (s) {
- return [];
- });
- };
- var globalObj = new Globals();
- var gl = this.w.globals;
- globalObj.initGlobalVars(gl);
- gl.seriesXvalues = resetxyValues();
- gl.seriesYvalues = resetxyValues();
- }
- }, {
- key: "isMultipleY",
- value: function isMultipleY() {
-
- if (this.w.config.yaxis.constructor === Array && this.w.config.yaxis.length > 1) {
- this.w.globals.isMultipleYAxis = true;
- return true;
- }
- }
- }, {
- key: "xySettings",
- value: function xySettings() {
- var xyRatios = null;
- var w = this.w;
- if (w.globals.axisCharts) {
- if (w.config.xaxis.crosshairs.position === 'back') {
- var crosshairs = new Crosshairs(this.ctx);
- crosshairs.drawXCrosshairs();
- }
- if (w.config.yaxis[0].crosshairs.position === 'back') {
- var _crosshairs = new Crosshairs(this.ctx);
- _crosshairs.drawYCrosshairs();
- }
- if (w.config.xaxis.type === 'datetime' && w.config.xaxis.labels.formatter === undefined) {
- var ts = new TimeScale(this.ctx);
- var formattedTimeScale = [];
- if (isFinite(w.globals.minX) && isFinite(w.globals.maxX) && !w.globals.isBarHorizontal) {
- formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minX, w.globals.maxX);
- } else if (w.globals.isBarHorizontal) {
- formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minY, w.globals.maxY);
- }
- ts.recalcDimensionsBasedOnFormat(formattedTimeScale);
- }
- var coreUtils = new CoreUtils(this.ctx);
- xyRatios = coreUtils.getCalculatedRatios();
- }
- return xyRatios;
- }
- }, {
- key: "setupBrushHandler",
- value: function setupBrushHandler() {
- var _this2 = this;
- var w = this.w;
- if (!w.config.chart.brush.enabled) {
- return;
- }
-
- if (typeof w.config.chart.events.selection !== 'function') {
- var targets = w.config.chart.brush.targets || [w.config.chart.brush.target];
- targets.forEach(function (target) {
- var targetChart = ApexCharts.getChartByID(target);
- targetChart.w.globals.brushSource = _this2.ctx;
- var updateSourceChart = function updateSourceChart() {
- _this2.ctx.updateHelpers._updateOptions({
- chart: {
- selection: {
- xaxis: {
- min: targetChart.w.globals.minX,
- max: targetChart.w.globals.maxX
- }
- }
- }
- }, false, false);
- };
- if (typeof targetChart.w.config.chart.events.zoomed !== 'function') {
- targetChart.w.config.chart.events.zoomed = function () {
- updateSourceChart();
- };
- }
- if (typeof targetChart.w.config.chart.events.scrolled !== 'function') {
- targetChart.w.config.chart.events.scrolled = function () {
- updateSourceChart();
- };
- }
- });
- w.config.chart.events.selection = function (chart, e) {
- targets.forEach(function (target) {
- var targetChart = ApexCharts.getChartByID(target);
- var yaxis = Utils.clone(w.config.yaxis);
- if (w.config.chart.brush.autoScaleYaxis && targetChart.w.globals.series.length === 1) {
- var scale = new Range(targetChart);
- yaxis = scale.autoScaleY(targetChart, yaxis, e);
- }
- targetChart.ctx.updateHelpers._updateOptions({
- xaxis: {
- min: e.xaxis.min,
- max: e.xaxis.max
- },
- yaxis: _objectSpread2({}, targetChart.w.config.yaxis[0], {
- min: yaxis[0].min,
- max: yaxis[0].max
- })
- }, false, false, false, false);
- });
- };
- }
- }
- }]);
- return Core;
- }();
- var UpdateHelpers = function () {
- function UpdateHelpers(ctx) {
- _classCallCheck(this, UpdateHelpers);
- this.ctx = ctx;
- this.w = ctx.w;
- }
-
- _createClass(UpdateHelpers, [{
- key: "_updateOptions",
- value: function _updateOptions(options) {
- var _this = this;
- var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
- var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
- var charts = [this.ctx];
- if (updateSyncedCharts) {
- charts = this.ctx.getSyncedCharts();
- }
- if (this.ctx.w.globals.isExecCalled) {
-
- charts = [this.ctx];
- this.ctx.w.globals.isExecCalled = false;
- }
- charts.forEach(function (ch) {
- var w = ch.w;
- w.globals.shouldAnimate = animate;
- if (!redraw) {
- w.globals.resized = true;
- w.globals.dataChanged = true;
- if (animate) {
- ch.series.getPreviousPaths();
- }
- }
- if (options && _typeof(options) === 'object') {
- ch.config = new Config(options);
- options = CoreUtils.extendArrayProps(ch.config, options);
- if (ch.w.globals.chartID !== _this.ctx.w.globals.chartID) {
-
- delete options.series;
- }
- w.config = Utils.extend(w.config, options);
- if (overwriteInitialConfig) {
-
- w.globals.lastXAxis = [];
- w.globals.lastYAxis = [];
- w.globals.initialConfig = Utils.extend({}, w.config);
- w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
- }
- }
- return ch.update(options);
- });
- }
-
- }, {
- key: "_updateSeries",
- value: function _updateSeries(newSeries, animate) {
- var _this2 = this;
- var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var w = this.w;
- w.globals.shouldAnimate = animate;
- w.globals.dataChanged = true;
- if (animate) {
- this.ctx.series.getPreviousPaths();
- }
- var existingSeries;
- if (w.globals.axisCharts) {
- existingSeries = newSeries.map(function (s, i) {
- return _this2._extendSeries(s, i);
- });
- if (existingSeries.length === 0) {
- existingSeries = [{
- data: []
- }];
- }
- w.config.series = existingSeries;
- } else {
-
- w.config.series = newSeries.slice();
- }
- if (overwriteInitialSeries) {
- w.globals.initialConfig.series = JSON.parse(JSON.stringify(w.config.series));
- w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
- }
- return this.ctx.update();
- }
- }, {
- key: "_extendSeries",
- value: function _extendSeries(s, i) {
- var w = this.w;
- return _objectSpread2({}, w.config.series[i], {
- name: s.name ? s.name : w.config.series[i] && w.config.series[i].name,
- type: s.type ? s.type : w.config.series[i] && w.config.series[i].type,
- data: s.data ? s.data : w.config.series[i] && w.config.series[i].data
- });
- }
- }, {
- key: "toggleDataPointSelection",
- value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
- var w = this.w;
- var elPath = null;
- var parent = ".apexcharts-series[data\\:realIndex='".concat(seriesIndex, "']");
- if (w.globals.axisCharts) {
- elPath = w.globals.dom.Paper.select("".concat(parent, " path[j='").concat(dataPointIndex, "'], ").concat(parent, " circle[j='").concat(dataPointIndex, "'], ").concat(parent, " rect[j='").concat(dataPointIndex, "']")).members[0];
- } else {
-
- if (typeof dataPointIndex === 'undefined') {
- elPath = w.globals.dom.Paper.select("".concat(parent, " path[j='").concat(seriesIndex, "']")).members[0];
- if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') {
- var pie = new Pie(this.ctx);
- pie.pieClicked(seriesIndex);
- }
- }
- }
- if (elPath) {
- var graphics = new Graphics(this.ctx);
- graphics.pathMouseDown(elPath, null);
- } else {
- console.warn('toggleDataPointSelection: Element not found');
- return null;
- }
- return elPath.node ? elPath.node : null;
- }
- }, {
- key: "forceXAxisUpdate",
- value: function forceXAxisUpdate(options) {
- var w = this.w;
- var minmax = ['min', 'max'];
- minmax.forEach(function (a) {
- if (typeof options.xaxis[a] !== 'undefined') {
- w.config.xaxis[a] = options.xaxis[a];
- w.globals.lastXAxis[a] = options.xaxis[a];
- }
- });
- if (options.xaxis.categories && options.xaxis.categories.length) {
- w.config.xaxis.categories = options.xaxis.categories;
- }
- if (w.config.xaxis.convertedCatToNumeric) {
- var defaults = new Defaults(options);
- options = defaults.convertCatToNumericXaxis(options, this.ctx);
- }
- return options;
- }
- }, {
- key: "forceYAxisUpdate",
- value: function forceYAxisUpdate(options) {
- var w = this.w;
- if (w.config.chart.stacked && w.config.chart.stackType === '100%') {
- if (Array.isArray(options.yaxis)) {
- options.yaxis.forEach(function (yaxe, index) {
- options.yaxis[index].min = 0;
- options.yaxis[index].max = 100;
- });
- } else {
- options.yaxis.min = 0;
- options.yaxis.max = 100;
- }
- }
- return options;
- }
-
- }, {
- key: "revertDefaultAxisMinMax",
- value: function revertDefaultAxisMinMax() {
- var _this3 = this;
- var w = this.w;
- w.config.xaxis.min = w.globals.lastXAxis.min;
- w.config.xaxis.max = w.globals.lastXAxis.max;
- w.config.yaxis.map(function (yaxe, index) {
- if (w.globals.zoomed) {
-
- if (typeof w.globals.lastYAxis[index] !== 'undefined') {
- yaxe.min = w.globals.lastYAxis[index].min;
- yaxe.max = w.globals.lastYAxis[index].max;
- }
- } else {
-
- if (typeof _this3.ctx.opts.yaxis[index] !== 'undefined') {
- yaxe.min = _this3.ctx.opts.yaxis[index].min;
- yaxe.max = _this3.ctx.opts.yaxis[index].max;
- }
- }
- });
- }
- }]);
- return UpdateHelpers;
- }();
- (function (root, factory) {
-
- if (typeof define === 'function' && define.amd) {
- define(function () {
- return factory(root, root.document);
- });
-
- } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
- module.exports = root.document ? factory(root, root.document) : function (w) {
- return factory(w, w.document);
- };
- } else {
- root.SVG = factory(root, root.document);
- }
- })(typeof window !== 'undefined' ? window : undefined, function (window, document) {
-
-
- var globalRef = typeof this !== 'undefined' ? this : window;
- var SVG = globalRef.SVG = function (element) {
- if (SVG.supported) {
- element = new SVG.Doc(element);
- if (!SVG.parser.draw) {
- SVG.prepare();
- }
- return element;
- }
- };
- SVG.ns = 'http://www.w3.org/2000/svg';
- SVG.xmlns = 'http://www.w3.org/2000/xmlns/';
- SVG.xlink = 'http://www.w3.org/1999/xlink';
- SVG.svgjs = 'http://svgjs.com/svgjs';
- SVG.supported = function () {
- return true;
-
- }();
- if (!SVG.supported) return false;
- SVG.did = 1000;
- SVG.eid = function (name) {
- return 'Svgjs' + capitalize(name) + SVG.did++;
- };
- SVG.create = function (name) {
-
- var element = document.createElementNS(this.ns, name);
- element.setAttribute('id', this.eid(name));
- return element;
- };
- SVG.extend = function () {
- var modules, methods;
- modules = [].slice.call(arguments);
- methods = modules.pop();
- for (var i = modules.length - 1; i >= 0; i--) {
- if (modules[i]) {
- for (var key in methods) {
- modules[i].prototype[key] = methods[key];
- }
- }
- }
- if (SVG.Set && SVG.Set.inherit) {
- SVG.Set.inherit();
- }
- };
- SVG.invent = function (config) {
-
- var initializer = typeof config.create === 'function' ? config.create : function () {
- this.constructor.call(this, SVG.create(config.create));
- };
- if (config.inherit) {
- initializer.prototype = new config.inherit();
- }
- if (config.extend) {
- SVG.extend(initializer, config.extend);
- }
- if (config.construct) {
- SVG.extend(config.parent || SVG.Container, config.construct);
- }
- return initializer;
- };
- SVG.adopt = function (node) {
-
- if (!node) return null;
- if (node.instance) return node.instance;
- var element;
- if (node.nodeName == 'svg') {
- element = node.parentNode instanceof window.SVGElement ? new SVG.Nested() : new SVG.Doc();
- } else if (node.nodeName == 'linearGradient') {
- element = new SVG.Gradient('linear');
- } else if (node.nodeName == 'radialGradient') {
- element = new SVG.Gradient('radial');
- } else if (SVG[capitalize(node.nodeName)]) {
- element = new SVG[capitalize(node.nodeName)]();
- } else {
- element = new SVG.Element(node);
- }
- element.type = node.nodeName;
- element.node = node;
- node.instance = element;
- if (element instanceof SVG.Doc) {
- element.namespace().defs();
- }
- element.setData(JSON.parse(node.getAttribute('svgjs:data')) || {});
- return element;
- };
- SVG.prepare = function () {
-
- var body = document.getElementsByTagName('body')[0],
- draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0);
- SVG.parser = {
- body: body || document.documentElement,
- draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node,
- poly: draw.polyline().node,
- path: draw.path().node,
- native: SVG.create('svg')
- };
- };
- SVG.parser = {
- native: SVG.create('svg')
- };
- document.addEventListener('DOMContentLoaded', function () {
- if (!SVG.parser.draw) {
- SVG.prepare();
- }
- }, false);
- SVG.regex = {
-
- numberAndUnit: /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,
-
- hex: /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
-
- rgb: /rgb\((\d+),(\d+),(\d+)\)/,
-
- reference: /#([a-z0-9\-_]+)/i,
-
- transforms: /\)\s*,?\s*/,
-
- whitespace: /\s/g,
-
- isHex: /^#[a-f0-9]{3,6}$/i,
-
- isRgb: /^rgb\(/,
-
- isCss: /[^:]+:[^;]+;?/,
-
- isBlank: /^(\s+)?$/,
-
- isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
-
- isPercent: /^-?[\d\.]+%$/,
-
- isImage: /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,
-
- delimiter: /[\s,]+/,
-
-
- hyphen: /([^e])\-/gi,
-
- pathLetters: /[MLHVCSQTAZ]/gi,
-
- isPathLetter: /[MLHVCSQTAZ]/i,
-
- numbersWithDots: /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,
-
- dots: /\./g
- };
- SVG.utils = {
-
- map: function map(array, block) {
- var il = array.length,
- result = [];
- for (var i = 0; i < il; i++) {
- result.push(block(array[i]));
- }
- return result;
- },
-
- filter: function filter(array, block) {
- var il = array.length,
- result = [];
- for (var i = 0; i < il; i++) {
- if (block(array[i])) {
- result.push(array[i]);
- }
- }
- return result;
- },
- filterSVGElements: function filterSVGElements(nodes) {
- return this.filter(nodes, function (el) {
- return el instanceof window.SVGElement;
- });
- }
- };
- SVG.defaults = {
-
- attrs: {
-
- 'fill-opacity': 1,
- 'stroke-opacity': 1,
- 'stroke-width': 0,
- 'stroke-linejoin': 'miter',
- 'stroke-linecap': 'butt',
- fill: '#000000',
- stroke: '#000000',
- opacity: 1,
-
- x: 0,
- y: 0,
- cx: 0,
- cy: 0,
-
- width: 0,
- height: 0,
-
- r: 0,
- rx: 0,
- ry: 0,
-
- offset: 0,
- 'stop-opacity': 1,
- 'stop-color': '#000000',
-
- 'font-size': 16,
- 'font-family': 'Helvetica, Arial, sans-serif',
- 'text-anchor': 'start'
- }
- };
- SVG.Color = function (color) {
- var match;
- this.r = 0;
- this.g = 0;
- this.b = 0;
- if (!color) return;
- if (typeof color === 'string') {
- if (SVG.regex.isRgb.test(color)) {
-
- match = SVG.regex.rgb.exec(color.replace(SVG.regex.whitespace, ''));
- this.r = parseInt(match[1]);
- this.g = parseInt(match[2]);
- this.b = parseInt(match[3]);
- } else if (SVG.regex.isHex.test(color)) {
-
- match = SVG.regex.hex.exec(fullHex(color));
- this.r = parseInt(match[1], 16);
- this.g = parseInt(match[2], 16);
- this.b = parseInt(match[3], 16);
- }
- } else if (_typeof(color) === 'object') {
- this.r = color.r;
- this.g = color.g;
- this.b = color.b;
- }
- };
- SVG.extend(SVG.Color, {
-
- toString: function toString() {
- return this.toHex();
- },
-
- toHex: function toHex() {
- return '#' + compToHex(this.r) + compToHex(this.g) + compToHex(this.b);
- },
-
- toRgb: function toRgb() {
- return 'rgb(' + [this.r, this.g, this.b].join() + ')';
- },
-
- brightness: function brightness() {
- return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11;
- },
-
- morph: function morph(color) {
- this.destination = new SVG.Color(color);
- return this;
- },
-
- at: function at(pos) {
-
- if (!this.destination) return this;
- pos = pos < 0 ? 0 : pos > 1 ? 1 : pos;
- return new SVG.Color({
- r: ~~(this.r + (this.destination.r - this.r) * pos),
- g: ~~(this.g + (this.destination.g - this.g) * pos),
- b: ~~(this.b + (this.destination.b - this.b) * pos)
- });
- }
- });
-
- SVG.Color.test = function (color) {
- color += '';
- return SVG.regex.isHex.test(color) || SVG.regex.isRgb.test(color);
- };
- SVG.Color.isRgb = function (color) {
- return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number';
- };
- SVG.Color.isColor = function (color) {
- return SVG.Color.isRgb(color) || SVG.Color.test(color);
- };
- SVG.Array = function (array, fallback) {
- array = (array || []).valueOf();
- if (array.length == 0 && fallback) {
- array = fallback.valueOf();
- }
- this.value = this.parse(array);
- };
- SVG.extend(SVG.Array, {
-
- toString: function toString() {
- return this.value.join(' ');
- },
-
- valueOf: function valueOf() {
- return this.value;
- },
-
- parse: function parse(array) {
- array = array.valueOf();
- if (Array.isArray(array)) return array;
- return this.split(array);
- }
- });
- SVG.PointArray = function (array, fallback) {
- SVG.Array.call(this, array, fallback || [[0, 0]]);
- };
- SVG.PointArray.prototype = new SVG.Array();
- SVG.PointArray.prototype.constructor = SVG.PointArray;
- var pathHandlers = {
- M: function M(c, p, p0) {
- p.x = p0.x = c[0];
- p.y = p0.y = c[1];
- return ['M', p.x, p.y];
- },
- L: function L(c, p) {
- p.x = c[0];
- p.y = c[1];
- return ['L', c[0], c[1]];
- },
- H: function H(c, p) {
- p.x = c[0];
- return ['H', c[0]];
- },
- V: function V(c, p) {
- p.y = c[0];
- return ['V', c[0]];
- },
- C: function C(c, p) {
- p.x = c[4];
- p.y = c[5];
- return ['C', c[0], c[1], c[2], c[3], c[4], c[5]];
- },
- Q: function Q(c, p) {
- p.x = c[2];
- p.y = c[3];
- return ['Q', c[0], c[1], c[2], c[3]];
- },
- Z: function Z(c, p, p0) {
- p.x = p0.x;
- p.y = p0.y;
- return ['Z'];
- }
- };
- var mlhvqtcsa = 'mlhvqtcsaz'.split('');
- for (var i = 0, il = mlhvqtcsa.length; i < il; ++i) {
- pathHandlers[mlhvqtcsa[i]] = function (i) {
- return function (c, p, p0) {
- if (i == 'H') c[0] = c[0] + p.x;else if (i == 'V') c[0] = c[0] + p.y;else if (i == 'A') {
- c[5] = c[5] + p.x, c[6] = c[6] + p.y;
- } else {
- for (var j = 0, jl = c.length; j < jl; ++j) {
- c[j] = c[j] + (j % 2 ? p.y : p.x);
- }
- }
- return pathHandlers[i](c, p, p0);
- };
- }(mlhvqtcsa[i].toUpperCase());
- }
- SVG.PathArray = function (array, fallback) {
- SVG.Array.call(this, array, fallback || [['M', 0, 0]]);
- };
- SVG.PathArray.prototype = new SVG.Array();
- SVG.PathArray.prototype.constructor = SVG.PathArray;
- SVG.extend(SVG.PathArray, {
-
- toString: function toString() {
- return arrayToString(this.value);
- },
-
- move: function move(x, y) {
-
- var box = this.bbox();
- x -= box.x;
- y -= box.y;
- return this;
- },
-
- at: function at(pos) {
-
- if (!this.destination) return this;
- var sourceArray = this.value,
- destinationArray = this.destination.value,
- array = [],
- pathArray = new SVG.PathArray(),
- il,
- jl;
-
- for (var i = 0, il = sourceArray.length; i < il; i++) {
- array[i] = [sourceArray[i][0]];
- for (var j = 1, jl = sourceArray[i].length; j < jl; j++) {
- array[i][j] = sourceArray[i][j] + (destinationArray[i][j] - sourceArray[i][j]) * pos;
- }
-
-
-
-
- if (array[i][0] === 'A') {
- array[i][4] = +(array[i][4] != 0);
- array[i][5] = +(array[i][5] != 0);
- }
- }
- pathArray.value = array;
- return pathArray;
- },
-
- parse: function parse(array) {
-
- if (array instanceof SVG.PathArray) return array.valueOf();
- var s,
- arr,
- paramCnt = {
- 'M': 2,
- 'L': 2,
- 'H': 1,
- 'V': 1,
- 'C': 6,
- 'S': 4,
- 'Q': 4,
- 'T': 2,
- 'A': 7,
- 'Z': 0
- };
- if (typeof array === 'string') {
- array = array.replace(SVG.regex.numbersWithDots, pathRegReplace)
- .replace(SVG.regex.pathLetters, ' $& ')
- .replace(SVG.regex.hyphen, '$1 -')
- .trim()
- .split(SVG.regex.delimiter);
- } else {
- array = array.reduce(function (prev, curr) {
- return [].concat.call(prev, curr);
- }, []);
- }
- var arr = [],
- p = new SVG.Point(),
- p0 = new SVG.Point(),
- index = 0,
- len = array.length;
- do {
-
- if (SVG.regex.isPathLetter.test(array[index])) {
- s = array[index];
- ++index;
- } else if (s == 'M') {
- s = 'L';
- } else if (s == 'm') {
- s = 'l';
- }
- arr.push(pathHandlers[s].call(null, array.slice(index, index = index + paramCnt[s.toUpperCase()]).map(parseFloat), p, p0));
- } while (len > index);
- return arr;
- },
-
- bbox: function bbox() {
- if (!SVG.parser.draw) {
- SVG.prepare();
- }
- SVG.parser.path.setAttribute('d', this.toString());
- return SVG.parser.path.getBBox();
- }
- });
- SVG.Number = SVG.invent({
-
- create: function create(value, unit) {
-
- this.value = 0;
- this.unit = unit || '';
- if (typeof value === 'number') {
-
- this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -3.4e+38 : +3.4e+38 : value;
- } else if (typeof value === 'string') {
- unit = value.match(SVG.regex.numberAndUnit);
- if (unit) {
-
- this.value = parseFloat(unit[1]);
- if (unit[5] == '%') {
- this.value /= 100;
- } else if (unit[5] == 's') {
- this.value *= 1000;
- }
- this.unit = unit[5];
- }
- } else {
- if (value instanceof SVG.Number) {
- this.value = value.valueOf();
- this.unit = value.unit;
- }
- }
- },
-
- extend: {
-
- toString: function toString() {
- return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.unit == 's' ? this.value / 1e3 : this.value) + this.unit;
- },
- toJSON: function toJSON() {
- return this.toString();
- },
-
- valueOf: function valueOf() {
- return this.value;
- },
-
- plus: function plus(number) {
- number = new SVG.Number(number);
- return new SVG.Number(this + number, this.unit || number.unit);
- },
-
- minus: function minus(number) {
- number = new SVG.Number(number);
- return new SVG.Number(this - number, this.unit || number.unit);
- },
-
- times: function times(number) {
- number = new SVG.Number(number);
- return new SVG.Number(this * number, this.unit || number.unit);
- },
-
- divide: function divide(number) {
- number = new SVG.Number(number);
- return new SVG.Number(this / number, this.unit || number.unit);
- },
-
- to: function to(unit) {
- var number = new SVG.Number(this);
- if (typeof unit === 'string') {
- number.unit = unit;
- }
- return number;
- },
-
- morph: function morph(number) {
- this.destination = new SVG.Number(number);
- if (number.relative) {
- this.destination.value += this.value;
- }
- return this;
- },
-
- at: function at(pos) {
-
- if (!this.destination) return this;
- return new SVG.Number(this.destination).minus(this).times(pos).plus(this);
- }
- }
- });
- SVG.Element = SVG.invent({
-
- create: function create(node) {
-
- this._stroke = SVG.defaults.attrs.stroke;
- this._event = null;
- this.dom = {};
- if (this.node = node) {
- this.type = node.nodeName;
- this.node.instance = this;
- this._stroke = node.getAttribute('stroke') || this._stroke;
- }
- },
-
- extend: {
-
- x: function x(_x) {
- return this.attr('x', _x);
- },
-
- y: function y(_y) {
- return this.attr('y', _y);
- },
-
- cx: function cx(x) {
- return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2);
- },
-
- cy: function cy(y) {
- return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2);
- },
-
- move: function move(x, y) {
- return this.x(x).y(y);
- },
-
- center: function center(x, y) {
- return this.cx(x).cy(y);
- },
-
- width: function width(_width) {
- return this.attr('width', _width);
- },
-
- height: function height(_height) {
- return this.attr('height', _height);
- },
-
- size: function size(width, height) {
- var p = proportionalSize(this, width, height);
- return this.width(new SVG.Number(p.width)).height(new SVG.Number(p.height));
- },
-
- clone: function clone(parent) {
-
- this.writeDataToDom();
- var clone = assignNewId(this.node.cloneNode(true));
- if (parent) parent.add(clone);else this.after(clone);
- return clone;
- },
-
- remove: function remove() {
- if (this.parent()) {
- this.parent().removeElement(this);
- }
- return this;
- },
-
- replace: function replace(element) {
- this.after(element).remove();
- return element;
- },
-
- addTo: function addTo(parent) {
- return parent.put(this);
- },
-
- putIn: function putIn(parent) {
- return parent.add(this);
- },
-
- id: function id(_id) {
- return this.attr('id', _id);
- },
-
- show: function show() {
- return this.style('display', '');
- },
-
- hide: function hide() {
- return this.style('display', 'none');
- },
-
- visible: function visible() {
- return this.style('display') != 'none';
- },
-
- toString: function toString() {
- return this.attr('id');
- },
-
- classes: function classes() {
- var attr = this.attr('class');
- return attr == null ? [] : attr.trim().split(SVG.regex.delimiter);
- },
-
- hasClass: function hasClass(name) {
- return this.classes().indexOf(name) != -1;
- },
-
- addClass: function addClass(name) {
- if (!this.hasClass(name)) {
- var array = this.classes();
- array.push(name);
- this.attr('class', array.join(' '));
- }
- return this;
- },
-
- removeClass: function removeClass(name) {
- if (this.hasClass(name)) {
- this.attr('class', this.classes().filter(function (c) {
- return c != name;
- }).join(' '));
- }
- return this;
- },
-
- toggleClass: function toggleClass(name) {
- return this.hasClass(name) ? this.removeClass(name) : this.addClass(name);
- },
-
- reference: function reference(attr) {
- return SVG.get(this.attr(attr));
- },
-
- parent: function parent(type) {
- var parent = this;
- if (!parent.node.parentNode) return null;
- parent = SVG.adopt(parent.node.parentNode);
- if (!type) return parent;
- while (parent && parent.node instanceof window.SVGElement) {
- if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent;
- if (!parent.node.parentNode || parent.node.parentNode.nodeName == '#document') return null;
- parent = SVG.adopt(parent.node.parentNode);
- }
- },
-
- doc: function doc() {
- return this instanceof SVG.Doc ? this : this.parent(SVG.Doc);
- },
-
- parents: function parents(type) {
- var parents = [],
- parent = this;
- do {
- parent = parent.parent(type);
- if (!parent || !parent.node) break;
- parents.push(parent);
- } while (parent.parent);
- return parents;
- },
-
- matches: function matches(selector) {
- return _matches(this.node, selector);
- },
-
- native: function native() {
- return this.node;
- },
-
- svg: function svg(_svg) {
-
- var well = document.createElement('svg');
- if (_svg && this instanceof SVG.Parent) {
-
- well.innerHTML = '<svg>' + _svg.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2></$1>') + '</svg>';
- for (var i = 0, il = well.firstChild.childNodes.length; i < il; i++) {
- this.node.appendChild(well.firstChild.firstChild);
- }
- } else {
-
- well.appendChild(_svg = document.createElement('svg'));
- this.writeDataToDom();
- _svg.appendChild(this.node.cloneNode(true));
- return well.innerHTML.replace(/^<svg>/, '').replace(/<\/svg>$/, '');
- }
- return this;
- },
-
- writeDataToDom: function writeDataToDom() {
-
- if (this.each || this.lines) {
- var fn = this.each ? this : this.lines();
- fn.each(function () {
- this.writeDataToDom();
- });
- }
- this.node.removeAttribute('svgjs:data');
- if (Object.keys(this.dom).length) {
- this.node.setAttribute('svgjs:data', JSON.stringify(this.dom));
- }
- return this;
- },
-
- setData: function setData(o) {
- this.dom = o;
- return this;
- },
- is: function is(obj) {
- return _is(this, obj);
- }
- }
- });
- SVG.easing = {
- '-': function _(pos) {
- return pos;
- },
- '<>': function _(pos) {
- return -Math.cos(pos * Math.PI) / 2 + 0.5;
- },
- '>': function _(pos) {
- return Math.sin(pos * Math.PI / 2);
- },
- '<': function _(pos) {
- return -Math.cos(pos * Math.PI / 2) + 1;
- }
- };
- SVG.morph = function (pos) {
- return function (from, to) {
- return new SVG.MorphObj(from, to).at(pos);
- };
- };
- SVG.Situation = SVG.invent({
- create: function create(o) {
- this.init = false;
- this.reversed = false;
- this.reversing = false;
- this.duration = new SVG.Number(o.duration).valueOf();
- this.delay = new SVG.Number(o.delay).valueOf();
- this.start = +new Date() + this.delay;
- this.finish = this.start + this.duration;
- this.ease = o.ease;
-
- this.loop = 0;
- this.loops = false;
- this.animations = {
-
- };
- this.attrs = {
-
- };
- this.styles = {
-
- };
- this.transforms = [
-
- ];
- this.once = {
-
- };
- }
- });
- SVG.FX = SVG.invent({
- create: function create(element) {
- this._target = element;
- this.situations = [];
- this.active = false;
- this.situation = null;
- this.paused = false;
- this.lastPos = 0;
- this.pos = 0;
-
- this.absPos = 0;
- this._speed = 1;
- },
- extend: {
-
- animate: function animate(o, ease, delay) {
- if (_typeof(o) === 'object') {
- ease = o.ease;
- delay = o.delay;
- o = o.duration;
- }
- var situation = new SVG.Situation({
- duration: o || 1000,
- delay: delay || 0,
- ease: SVG.easing[ease || '-'] || ease
- });
- this.queue(situation);
- return this;
- },
-
-
- target: function target(_target) {
- if (_target && _target instanceof SVG.Element) {
- this._target = _target;
- return this;
- }
- return this._target;
- },
-
- timeToAbsPos: function timeToAbsPos(timestamp) {
- return (timestamp - this.situation.start) / (this.situation.duration / this._speed);
- },
-
- absPosToTime: function absPosToTime(absPos) {
- return this.situation.duration / this._speed * absPos + this.situation.start;
- },
-
- startAnimFrame: function startAnimFrame() {
- this.stopAnimFrame();
- this.animationFrame = window.requestAnimationFrame(function () {
- this.step();
- }.bind(this));
- },
-
- stopAnimFrame: function stopAnimFrame() {
- window.cancelAnimationFrame(this.animationFrame);
- },
-
- start: function start() {
-
- if (!this.active && this.situation) {
- this.active = true;
- this.startCurrent();
- }
- return this;
- },
-
- startCurrent: function startCurrent() {
- this.situation.start = +new Date() + this.situation.delay / this._speed;
- this.situation.finish = this.situation.start + this.situation.duration / this._speed;
- return this.initAnimations().step();
- },
-
- queue: function queue(fn) {
- if (typeof fn === 'function' || fn instanceof SVG.Situation) {
- this.situations.push(fn);
- }
- if (!this.situation) this.situation = this.situations.shift();
- return this;
- },
-
- dequeue: function dequeue() {
-
- this.stop();
- this.situation = this.situations.shift();
- if (this.situation) {
- if (this.situation instanceof SVG.Situation) {
- this.start();
- } else {
-
- this.situation.call(this);
- }
- }
- return this;
- },
-
-
- initAnimations: function initAnimations() {
- var source;
- var s = this.situation;
- if (s.init) return this;
- for (var i in s.animations) {
- source = this.target()[i]();
- if (!Array.isArray(source)) {
- source = [source];
- }
- if (!Array.isArray(s.animations[i])) {
- s.animations[i] = [s.animations[i]];
- }
-
-
- for (var j = source.length; j--;) {
-
-
- if (s.animations[i][j] instanceof SVG.Number) {
- source[j] = new SVG.Number(source[j]);
- }
- s.animations[i][j] = source[j].morph(s.animations[i][j]);
- }
- }
- for (var i in s.attrs) {
- s.attrs[i] = new SVG.MorphObj(this.target().attr(i), s.attrs[i]);
- }
- for (var i in s.styles) {
- s.styles[i] = new SVG.MorphObj(this.target().style(i), s.styles[i]);
- }
- s.initialTransformation = this.target().matrixify();
- s.init = true;
- return this;
- },
- clearQueue: function clearQueue() {
- this.situations = [];
- return this;
- },
- clearCurrent: function clearCurrent() {
- this.situation = null;
- return this;
- },
-
- stop: function stop(jumpToEnd, clearQueue) {
- var active = this.active;
- this.active = false;
- if (clearQueue) {
- this.clearQueue();
- }
- if (jumpToEnd && this.situation) {
-
- !active && this.startCurrent();
- this.atEnd();
- }
- this.stopAnimFrame();
- return this.clearCurrent();
- },
- after: function after(fn) {
- var c = this.last(),
- wrapper = function wrapper(e) {
- if (e.detail.situation == c) {
- fn.call(this, c);
- this.off('finished.fx', wrapper);
- }
- };
- this.target().on('finished.fx', wrapper);
- return this._callStart();
- },
-
- during: function during(fn) {
- var c = this.last(),
- wrapper = function wrapper(e) {
- if (e.detail.situation == c) {
- fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, c);
- }
- };
- this.target().off('during.fx', wrapper).on('during.fx', wrapper);
- this.after(function () {
- this.off('during.fx', wrapper);
- });
- return this._callStart();
- },
-
- afterAll: function afterAll(fn) {
- var wrapper = function wrapper(e) {
- fn.call(this);
- this.off('allfinished.fx', wrapper);
- };
- this.target().off('allfinished.fx', wrapper).on('allfinished.fx', wrapper);
- return this._callStart();
- },
- last: function last() {
- return this.situations.length ? this.situations[this.situations.length - 1] : this.situation;
- },
-
- add: function add(method, args, type) {
- this.last()[type || 'animations'][method] = args;
- return this._callStart();
- },
-
- step: function step(ignoreTime) {
-
- if (!ignoreTime) this.absPos = this.timeToAbsPos(+new Date());
- if (this.situation.loops !== false) {
- var absPos, absPosInt, lastLoop;
- absPos = Math.max(this.absPos, 0);
- absPosInt = Math.floor(absPos);
- if (this.situation.loops === true || absPosInt < this.situation.loops) {
- this.pos = absPos - absPosInt;
- lastLoop = this.situation.loop;
- this.situation.loop = absPosInt;
- } else {
- this.absPos = this.situation.loops;
- this.pos = 1;
- lastLoop = this.situation.loop - 1;
- this.situation.loop = this.situation.loops;
- }
- if (this.situation.reversing) {
-
- this.situation.reversed = this.situation.reversed != Boolean((this.situation.loop - lastLoop) % 2);
- }
- } else {
-
- this.absPos = Math.min(this.absPos, 1);
- this.pos = this.absPos;
- }
- if (this.pos < 0) this.pos = 0;
- if (this.situation.reversed) this.pos = 1 - this.pos;
- var eased = this.situation.ease(this.pos);
- for (var i in this.situation.once) {
- if (i > this.lastPos && i <= eased) {
- this.situation.once[i].call(this.target(), this.pos, eased);
- delete this.situation.once[i];
- }
- }
- if (this.active) this.target().fire('during', {
- pos: this.pos,
- eased: eased,
- fx: this,
- situation: this.situation
- });
-
- if (!this.situation) {
- return this;
- }
- this.eachAt();
- if (this.pos == 1 && !this.situation.reversed || this.situation.reversed && this.pos == 0) {
-
- this.stopAnimFrame();
- this.target().fire('finished', {
- fx: this,
- situation: this.situation
- });
- if (!this.situations.length) {
- this.target().fire('allfinished');
- if (!this.situations.length) {
- this.target().off('.fx');
- this.active = false;
- }
- }
- if (this.active) this.dequeue();else this.clearCurrent();
- } else if (!this.paused && this.active) {
-
- this.startAnimFrame();
- }
- this.lastPos = eased;
- return this;
- },
-
- eachAt: function eachAt() {
- var len,
- at,
- self = this,
- target = this.target(),
- s = this.situation;
- for (var i in s.animations) {
- at = [].concat(s.animations[i]).map(function (el) {
- return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
- });
- target[i].apply(target, at);
- }
- for (var i in s.attrs) {
- at = [i].concat(s.attrs[i]).map(function (el) {
- return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
- });
- target.attr.apply(target, at);
- }
- for (var i in s.styles) {
- at = [i].concat(s.styles[i]).map(function (el) {
- return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
- });
- target.style.apply(target, at);
- }
- if (s.transforms.length) {
-
- at = s.initialTransformation;
- for (var i = 0, len = s.transforms.length; i < len; i++) {
-
- var a = s.transforms[i];
- if (a instanceof SVG.Matrix) {
- if (a.relative) {
- at = at.multiply(new SVG.Matrix().morph(a).at(s.ease(this.pos)));
- } else {
- at = at.morph(a).at(s.ease(this.pos));
- }
- continue;
- }
- if (!a.relative) {
- a.undo(at.extract());
- }
- at = at.multiply(a.at(s.ease(this.pos)));
- }
- target.matrix(at);
- }
- return this;
- },
-
- once: function once(pos, fn, isEased) {
- var c = this.last();
- if (!isEased) pos = c.ease(pos);
- c.once[pos] = fn;
- return this;
- },
- _callStart: function _callStart() {
- setTimeout(function () {
- this.start();
- }.bind(this), 0);
- return this;
- }
- },
- parent: SVG.Element,
-
- construct: {
-
- animate: function animate(o, ease, delay) {
- return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay);
- },
- delay: function delay(_delay) {
- return (this.fx || (this.fx = new SVG.FX(this))).delay(_delay);
- },
- stop: function stop(jumpToEnd, clearQueue) {
- if (this.fx) {
- this.fx.stop(jumpToEnd, clearQueue);
- }
- return this;
- },
- finish: function finish() {
- if (this.fx) {
- this.fx.finish();
- }
- return this;
- }
- }
- });
- SVG.MorphObj = SVG.invent({
- create: function create(from, to) {
-
- if (SVG.Color.isColor(to)) return new SVG.Color(from).morph(to);
- if (SVG.regex.delimiter.test(from)) {
-
- if (SVG.regex.pathLetters.test(from)) return new SVG.PathArray(from).morph(to);
- else return new SVG.Array(from).morph(to);
- }
- if (SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to);
- this.value = from;
- this.destination = to;
- },
- extend: {
- at: function at(pos, real) {
- return real < 1 ? this.value : this.destination;
- },
- valueOf: function valueOf() {
- return this.value;
- }
- }
- });
- SVG.extend(SVG.FX, {
-
- attr: function attr(a, v, relative) {
-
- if (_typeof(a) === 'object') {
- for (var key in a) {
- this.attr(key, a[key]);
- }
- } else {
- this.add(a, v, 'attrs');
- }
- return this;
- },
-
- plot: function plot(a, b, c, d) {
-
- if (arguments.length == 4) {
- return this.plot([a, b, c, d]);
- }
- return this.add('plot', new (this.target().morphArray)(a));
- }
- });
- SVG.Box = SVG.invent({
- create: function create(x, y, width, height) {
- if (_typeof(x) === 'object' && !(x instanceof SVG.Element)) {
-
- return SVG.Box.call(this, x.left != null ? x.left : x.x, x.top != null ? x.top : x.y, x.width, x.height);
- } else if (arguments.length == 4) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
- fullBox(this);
- }
- });
- SVG.BBox = SVG.invent({
-
- create: function create(element) {
- SVG.Box.apply(this, [].slice.call(arguments));
- if (element instanceof SVG.Element) {
- var box;
- try {
- if (!document.documentElement.contains) {
-
- var topParent = element.node;
- while (topParent.parentNode) {
- topParent = topParent.parentNode;
- }
- if (topParent != document) throw new Error('Element not in the dom');
- } else {}
-
-
-
- box = element.node.getBBox();
- } catch (e) {
- if (element instanceof SVG.Shape) {
- if (!SVG.parser.draw) {
-
- SVG.prepare();
- }
- var clone = element.clone(SVG.parser.draw.instance).show();
- box = clone.node.getBBox();
- clone.remove();
- } else {
- box = {
- x: element.node.clientLeft,
- y: element.node.clientTop,
- width: element.node.clientWidth,
- height: element.node.clientHeight
- };
- }
- }
- SVG.Box.call(this, box);
- }
- },
-
- inherit: SVG.Box,
-
- parent: SVG.Element,
-
- construct: {
-
- bbox: function bbox() {
- return new SVG.BBox(this);
- }
- }
- });
- SVG.BBox.prototype.constructor = SVG.BBox;
- SVG.Matrix = SVG.invent({
-
- create: function create(source) {
- var base = arrayToMatrix([1, 0, 0, 1, 0, 0]);
- source = source instanceof SVG.Element ? source.matrixify() : typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat)) : arguments.length == 6 ? arrayToMatrix([].slice.call(arguments)) : Array.isArray(source) ? arrayToMatrix(source) : _typeof(source) === 'object' ? source : base;
- for (var i = abcdef.length - 1; i >= 0; --i) {
- this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]];
- }
- },
-
- extend: {
-
- extract: function extract() {
-
- var px = deltaTransformPoint(this, 0, 1),
- py = deltaTransformPoint(this, 1, 0),
- skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90;
- return {
-
- x: this.e,
- y: this.f,
- transformedX: (this.e * Math.cos(skewX * Math.PI / 180) + this.f * Math.sin(skewX * Math.PI / 180)) / Math.sqrt(this.a * this.a + this.b * this.b),
- transformedY: (this.f * Math.cos(skewX * Math.PI / 180) + this.e * Math.sin(-skewX * Math.PI / 180)) / Math.sqrt(this.c * this.c + this.d * this.d),
-
- rotation: skewX,
- a: this.a,
- b: this.b,
- c: this.c,
- d: this.d,
- e: this.e,
- f: this.f,
- matrix: new SVG.Matrix(this)
- };
- },
-
- clone: function clone() {
- return new SVG.Matrix(this);
- },
-
- morph: function morph(matrix) {
-
- this.destination = new SVG.Matrix(matrix);
- return this;
- },
-
- multiply: function multiply(matrix) {
- return new SVG.Matrix(this.native().multiply(parseMatrix(matrix).native()));
- },
-
- inverse: function inverse() {
- return new SVG.Matrix(this.native().inverse());
- },
-
- translate: function translate(x, y) {
- return new SVG.Matrix(this.native().translate(x || 0, y || 0));
- },
-
- native: function native() {
-
- var matrix = SVG.parser.native.createSVGMatrix();
- for (var i = abcdef.length - 1; i >= 0; i--) {
- matrix[abcdef[i]] = this[abcdef[i]];
- }
- return matrix;
- },
-
- toString: function toString() {
-
- return 'matrix(' + float32String(this.a) + ',' + float32String(this.b) + ',' + float32String(this.c) + ',' + float32String(this.d) + ',' + float32String(this.e) + ',' + float32String(this.f) + ')';
- }
- },
-
- parent: SVG.Element,
-
- construct: {
-
- ctm: function ctm() {
- return new SVG.Matrix(this.node.getCTM());
- },
-
- screenCTM: function screenCTM() {
-
- if (this instanceof SVG.Nested) {
- var rect = this.rect(1, 1);
- var m = rect.node.getScreenCTM();
- rect.remove();
- return new SVG.Matrix(m);
- }
- return new SVG.Matrix(this.node.getScreenCTM());
- }
- }
- });
- SVG.Point = SVG.invent({
-
- create: function create(x, y) {
- var source,
- base = {
- x: 0,
- y: 0
- };
- source = Array.isArray(x) ? {
- x: x[0],
- y: x[1]
- } : _typeof(x) === 'object' ? {
- x: x.x,
- y: x.y
- } : x != null ? {
- x: x,
- y: y != null ? y : x
- } : base;
-
- this.x = source.x;
- this.y = source.y;
- },
-
- extend: {
-
- clone: function clone() {
- return new SVG.Point(this);
- },
-
- morph: function morph(x, y) {
-
- this.destination = new SVG.Point(x, y);
- return this;
- }
- }
- });
- SVG.extend(SVG.Element, {
-
- point: function point(x, y) {
- return new SVG.Point(x, y).transform(this.screenCTM().inverse());
- }
- });
- SVG.extend(SVG.Element, {
-
- attr: function attr(a, v, n) {
-
- if (a == null) {
-
- a = {};
- v = this.node.attributes;
- for (var n = v.length - 1; n >= 0; n--) {
- a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue;
- }
- return a;
- } else if (_typeof(a) === 'object') {
-
- for (var v_ in a) {
- this.attr(v_, a[v_]);
- }
- } else if (v === null) {
-
- this.node.removeAttribute(a);
- } else if (v == null) {
-
- v = this.node.getAttribute(a);
- return v == null ? SVG.defaults.attrs[a] : SVG.regex.isNumber.test(v) ? parseFloat(v) : v;
- } else {
-
- if (a == 'stroke-width') {
- this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null);
- } else if (a == 'stroke') {
- this._stroke = v;
- }
- if (a == 'fill' || a == 'stroke') {
- if (SVG.regex.isImage.test(v)) {
- v = this.doc().defs().image(v, 0, 0);
- }
- if (v instanceof SVG.Image) {
- v = this.doc().defs().pattern(0, 0, function () {
- this.add(v);
- });
- }
- }
- if (typeof v === 'number') {
- v = new SVG.Number(v);
- }
- else if (SVG.Color.isColor(v)) {
- v = new SVG.Color(v);
- }
- else if (Array.isArray(v)) {
- v = new SVG.Array(v);
- }
- if (a == 'leading') {
-
- if (this.leading) {
- this.leading(v);
- }
- } else {
-
- typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString());
- }
- if (this.rebuild && (a == 'font-size' || a == 'x')) {
- this.rebuild(a, v);
- }
- }
- return this;
- }
- });
- SVG.extend(SVG.Element, {
-
- transform: function transform(o, relative) {
-
- var target = this,
- matrix;
-
- if (_typeof(o) !== 'object') {
-
- matrix = new SVG.Matrix(target).extract();
- return typeof o === 'string' ? matrix[o] : matrix;
- }
- matrix = new SVG.Matrix(target);
- relative = !!relative || !!o.relative;
- if (o.a != null) {
- matrix = relative
- ? matrix.multiply(new SVG.Matrix(o))
- : new SVG.Matrix(o);
- }
- return this.attr('transform', matrix);
- }
- });
- SVG.extend(SVG.Element, {
-
- untransform: function untransform() {
- return this.attr('transform', null);
- },
-
- matrixify: function matrixify() {
- var matrix = (this.attr('transform') || '').
- split(SVG.regex.transforms).slice(0, -1).map(function (str) {
-
- var kv = str.trim().split('(');
- return [kv[0], kv[1].split(SVG.regex.delimiter).map(function (str) {
- return parseFloat(str);
- })];
- })
- .reduce(function (matrix, transform) {
- if (transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]));
- return matrix[transform[0]].apply(matrix, transform[1]);
- }, new SVG.Matrix());
- return matrix;
- },
-
- toParent: function toParent(parent) {
- if (this == parent) return this;
- var ctm = this.screenCTM();
- var pCtm = parent.screenCTM().inverse();
- this.addTo(parent).untransform().transform(pCtm.multiply(ctm));
- return this;
- },
-
- toDoc: function toDoc() {
- return this.toParent(this.doc());
- }
- });
- SVG.Transformation = SVG.invent({
- create: function create(source, inversed) {
- if (arguments.length > 1 && typeof inversed !== 'boolean') {
- return this.constructor.call(this, [].slice.call(arguments));
- }
- if (Array.isArray(source)) {
- for (var i = 0, len = this.arguments.length; i < len; ++i) {
- this[this.arguments[i]] = source[i];
- }
- } else if (_typeof(source) === 'object') {
- for (var i = 0, len = this.arguments.length; i < len; ++i) {
- this[this.arguments[i]] = source[this.arguments[i]];
- }
- }
- this.inversed = false;
- if (inversed === true) {
- this.inversed = true;
- }
- }
- });
- SVG.Translate = SVG.invent({
- parent: SVG.Matrix,
- inherit: SVG.Transformation,
- create: function create(source, inversed) {
- this.constructor.apply(this, [].slice.call(arguments));
- },
- extend: {
- arguments: ['transformedX', 'transformedY'],
- method: 'translate'
- }
- });
- SVG.extend(SVG.Element, {
-
- style: function style(s, v) {
- if (arguments.length == 0) {
-
- return this.node.style.cssText || '';
- } else if (arguments.length < 2) {
-
- if (_typeof(s) === 'object') {
- for (var v_ in s) {
- this.style(v_, s[v_]);
- }
- } else if (SVG.regex.isCss.test(s)) {
-
- s = s.split(/\s*;\s*/)
- .filter(function (e) {
- return !!e;
- }).map(function (e) {
- return e.split(/\s*:\s*/);
- });
- while (v = s.pop()) {
- this.style(v[0], v[1]);
- }
- } else {
-
- return this.node.style[camelCase(s)];
- }
- } else {
- this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v;
- }
- return this;
- }
- });
- SVG.Parent = SVG.invent({
-
- create: function create(element) {
- this.constructor.call(this, element);
- },
-
- inherit: SVG.Element,
-
- extend: {
-
- children: function children() {
- return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function (node) {
- return SVG.adopt(node);
- });
- },
-
- add: function add(element, i) {
- if (i == null) {
- this.node.appendChild(element.node);
- } else if (element.node != this.node.childNodes[i]) {
- this.node.insertBefore(element.node, this.node.childNodes[i]);
- }
- return this;
- },
-
- put: function put(element, i) {
- this.add(element, i);
- return element;
- },
-
- has: function has(element) {
- return this.index(element) >= 0;
- },
-
- index: function index(element) {
- return [].slice.call(this.node.childNodes).indexOf(element.node);
- },
-
- get: function get(i) {
- return SVG.adopt(this.node.childNodes[i]);
- },
-
- first: function first() {
- return this.get(0);
- },
-
- last: function last() {
- return this.get(this.node.childNodes.length - 1);
- },
-
- each: function each(block, deep) {
- var il,
- children = this.children();
- for (var i = 0, il = children.length; i < il; i++) {
- if (children[i] instanceof SVG.Element) {
- block.apply(children[i], [i, children]);
- }
- if (deep && children[i] instanceof SVG.Container) {
- children[i].each(block, deep);
- }
- }
- return this;
- },
-
- removeElement: function removeElement(element) {
- this.node.removeChild(element.node);
- return this;
- },
-
- clear: function clear() {
-
- while (this.node.hasChildNodes()) {
- this.node.removeChild(this.node.lastChild);
- }
- delete this._defs;
- return this;
- },
-
- defs: function defs() {
- return this.doc().defs();
- }
- }
- });
- SVG.extend(SVG.Parent, {
- ungroup: function ungroup(parent, depth) {
- if (depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this;
- parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent));
- depth = depth || Infinity;
- this.each(function () {
- if (this instanceof SVG.Defs) return this;
- if (this instanceof SVG.Parent) return this.ungroup(parent, depth - 1);
- return this.toParent(parent);
- });
- this.node.firstChild || this.remove();
- return this;
- },
- flatten: function flatten(parent, depth) {
- return this.ungroup(parent, depth);
- }
- });
- SVG.Container = SVG.invent({
-
- create: function create(element) {
- this.constructor.call(this, element);
- },
-
- inherit: SVG.Parent
- });
- SVG.ViewBox = SVG.invent({
-
- parent: SVG.Container,
-
- construct: {}
- })
- ;
- ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove',
-
- 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].forEach(function (event) {
-
- SVG.Element.prototype[event] = function (f) {
-
- SVG.on(this.node, event, f);
- return this;
- };
- });
- SVG.listeners = [];
- SVG.handlerMap = [];
- SVG.listenerId = 0;
- SVG.on = function (node, event, listener, binding, options) {
-
- var l = listener.bind(binding || node.instance || node),
- index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1,
- ev = event.split('.')[0],
- ns = event.split('.')[1] || '*';
- SVG.listeners[index] = SVG.listeners[index] || {};
- SVG.listeners[index][ev] = SVG.listeners[index][ev] || {};
- SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {};
- if (!listener._svgjsListenerId) {
- listener._svgjsListenerId = ++SVG.listenerId;
- }
- SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l;
- node.addEventListener(ev, l, options || false);
- };
- SVG.off = function (node, event, listener) {
- var index = SVG.handlerMap.indexOf(node),
- ev = event && event.split('.')[0],
- ns = event && event.split('.')[1],
- namespace = '';
- if (index == -1) return;
- if (listener) {
- if (typeof listener === 'function') listener = listener._svgjsListenerId;
- if (!listener) return;
- if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) {
-
- node.removeEventListener(ev, SVG.listeners[index][ev][ns || '*'][listener], false);
- delete SVG.listeners[index][ev][ns || '*'][listener];
- }
- } else if (ns && ev) {
-
- if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns]) {
- for (var listener_ in SVG.listeners[index][ev][ns]) {
- SVG.off(node, [ev, ns].join('.'), listener_);
- }
- delete SVG.listeners[index][ev][ns];
- }
- } else if (ns) {
-
- for (var event_ in SVG.listeners[index]) {
- for (var namespace in SVG.listeners[index][event_]) {
- if (ns === namespace) {
- SVG.off(node, [event_, ns].join('.'));
- }
- }
- }
- } else if (ev) {
-
- if (SVG.listeners[index][ev]) {
- for (var namespace in SVG.listeners[index][ev]) {
- SVG.off(node, [ev, namespace].join('.'));
- }
- delete SVG.listeners[index][ev];
- }
- } else {
-
- for (var event_ in SVG.listeners[index]) {
- SVG.off(node, event_);
- }
- delete SVG.listeners[index];
- delete SVG.handlerMap[index];
- }
- };
- SVG.extend(SVG.Element, {
-
- on: function on(event, listener, binding, options) {
- SVG.on(this.node, event, listener, binding, options);
- return this;
- },
-
- off: function off(event, listener) {
- SVG.off(this.node, event, listener);
- return this;
- },
-
- fire: function fire(event, data) {
-
- if (event instanceof window.Event) {
- this.node.dispatchEvent(event);
- } else {
- this.node.dispatchEvent(event = new SVG.CustomEvent(event, {
- detail: data,
- cancelable: true
- }));
- }
- this._event = event;
- return this;
- },
- event: function event() {
- return this._event;
- }
- });
- SVG.Defs = SVG.invent({
-
- create: 'defs',
-
- inherit: SVG.Container
- });
- SVG.G = SVG.invent({
-
- create: 'g',
-
- inherit: SVG.Container,
-
- extend: {
-
- x: function x(_x2) {
- return _x2 == null ? this.transform('x') : this.transform({
- x: _x2 - this.x()
- }, true);
- }
- },
-
- construct: {
-
- group: function group() {
- return this.put(new SVG.G());
- }
- }
- });
- SVG.Doc = SVG.invent({
-
- create: function create(element) {
- if (element) {
-
- element = typeof element === 'string' ? document.getElementById(element) : element;
-
- if (element.nodeName == 'svg') {
- this.constructor.call(this, element);
- } else {
- this.constructor.call(this, SVG.create('svg'));
- element.appendChild(this.node);
- this.size('100%', '100%');
- }
- this.namespace().defs();
- }
- },
-
- inherit: SVG.Container,
-
- extend: {
-
- namespace: function namespace() {
- return this.attr({
- xmlns: SVG.ns,
- version: '1.1'
- }).attr('xmlns:xlink', SVG.xlink, SVG.xmlns).attr('xmlns:svgjs', SVG.svgjs, SVG.xmlns);
- },
-
- defs: function defs() {
- if (!this._defs) {
- var defs;
- if (defs = this.node.getElementsByTagName('defs')[0]) {
- this._defs = SVG.adopt(defs);
- } else {
- this._defs = new SVG.Defs();
- }
- this.node.appendChild(this._defs.node);
- }
- return this._defs;
- },
-
- parent: function parent() {
- if (!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null;
- return this.node.parentNode;
- },
-
- remove: function remove() {
- if (this.parent()) {
- this.parent().removeChild(this.node);
- }
- return this;
- },
- clear: function clear() {
-
- while (this.node.hasChildNodes()) {
- this.node.removeChild(this.node.lastChild);
- }
- delete this._defs;
- if (SVG.parser.draw && !SVG.parser.draw.parentNode) {
- this.node.appendChild(SVG.parser.draw);
- }
- return this;
- },
- clone: function clone(parent) {
-
- this.writeDataToDom();
- var node = this.node;
- var clone = assignNewId(node.cloneNode(true));
- if (parent) {
- (parent.node || parent).appendChild(clone.node);
- } else {
- node.parentNode.insertBefore(clone.node, node.nextSibling);
- }
- return clone;
- }
- }
- });
-
- SVG.extend(SVG.Element, {
- });
- SVG.Gradient = SVG.invent({
-
- create: function create(type) {
- this.constructor.call(this, SVG.create(type + 'Gradient'));
- this.type = type;
- },
-
- inherit: SVG.Container,
-
- extend: {
-
- at: function at(offset, color, opacity) {
- return this.put(new SVG.Stop()).update(offset, color, opacity);
- },
-
- update: function update(block) {
-
- this.clear();
- if (typeof block === 'function') {
- block.call(this, this);
- }
- return this;
- },
-
- fill: function fill() {
- return 'url(#' + this.id() + ')';
- },
-
- toString: function toString() {
- return this.fill();
- },
-
- attr: function attr(a, b, c) {
- if (a == 'transform') a = 'gradientTransform';
- return SVG.Container.prototype.attr.call(this, a, b, c);
- }
- },
-
- construct: {
-
- gradient: function gradient(type, block) {
- return this.defs().gradient(type, block);
- }
- }
- });
- SVG.extend(SVG.Gradient, SVG.FX, {
-
- from: function from(x, y) {
- return (this._target || this).type == 'radial' ? this.attr({
- fx: new SVG.Number(x),
- fy: new SVG.Number(y)
- }) : this.attr({
- x1: new SVG.Number(x),
- y1: new SVG.Number(y)
- });
- },
-
- to: function to(x, y) {
- return (this._target || this).type == 'radial' ? this.attr({
- cx: new SVG.Number(x),
- cy: new SVG.Number(y)
- }) : this.attr({
- x2: new SVG.Number(x),
- y2: new SVG.Number(y)
- });
- }
- });
- SVG.extend(SVG.Defs, {
-
- gradient: function gradient(type, block) {
- return this.put(new SVG.Gradient(type)).update(block);
- }
- });
- SVG.Stop = SVG.invent({
-
- create: 'stop',
-
- inherit: SVG.Element,
-
- extend: {
-
- update: function update(o) {
- if (typeof o === 'number' || o instanceof SVG.Number) {
- o = {
- offset: arguments[0],
- color: arguments[1],
- opacity: arguments[2]
- };
- }
- if (o.opacity != null) this.attr('stop-opacity', o.opacity);
- if (o.color != null) this.attr('stop-color', o.color);
- if (o.offset != null) this.attr('offset', new SVG.Number(o.offset));
- return this;
- }
- }
- });
- SVG.Pattern = SVG.invent({
-
- create: 'pattern',
-
- inherit: SVG.Container,
-
- extend: {
-
- fill: function fill() {
- return 'url(#' + this.id() + ')';
- },
-
- update: function update(block) {
-
- this.clear();
- if (typeof block === 'function') {
- block.call(this, this);
- }
- return this;
- },
-
- toString: function toString() {
- return this.fill();
- },
-
- attr: function attr(a, b, c) {
- if (a == 'transform') a = 'patternTransform';
- return SVG.Container.prototype.attr.call(this, a, b, c);
- }
- },
-
- construct: {
-
- pattern: function pattern(width, height, block) {
- return this.defs().pattern(width, height, block);
- }
- }
- });
- SVG.extend(SVG.Defs, {
-
- pattern: function pattern(width, height, block) {
- return this.put(new SVG.Pattern()).update(block).attr({
- x: 0,
- y: 0,
- width: width,
- height: height,
- patternUnits: 'userSpaceOnUse'
- });
- }
- });
- SVG.Shape = SVG.invent({
-
- create: function create(element) {
- this.constructor.call(this, element);
- },
-
- inherit: SVG.Element
- });
- SVG.Symbol = SVG.invent({
-
- create: 'symbol',
-
- inherit: SVG.Container,
- construct: {
-
- symbol: function symbol() {
- return this.put(new SVG.Symbol());
- }
- }
- });
- SVG.Use = SVG.invent({
-
- create: 'use',
-
- inherit: SVG.Shape,
-
- extend: {
-
- element: function element(_element, file) {
-
- return this.attr('href', (file || '') + '#' + _element, SVG.xlink);
- }
- },
-
- construct: {
-
- use: function use(element, file) {
- return this.put(new SVG.Use()).element(element, file);
- }
- }
- });
- SVG.Rect = SVG.invent({
-
- create: 'rect',
-
- inherit: SVG.Shape,
-
- construct: {
-
- rect: function rect(width, height) {
- return this.put(new SVG.Rect()).size(width, height);
- }
- }
- });
- SVG.Circle = SVG.invent({
-
- create: 'circle',
-
- inherit: SVG.Shape,
-
- construct: {
-
- circle: function circle(size) {
- return this.put(new SVG.Circle()).rx(new SVG.Number(size).divide(2)).move(0, 0);
- }
- }
- });
- SVG.extend(SVG.Circle, SVG.FX, {
-
- rx: function rx(_rx) {
- return this.attr('r', _rx);
- },
-
- ry: function ry(_ry) {
- return this.rx(_ry);
- }
- });
- SVG.Ellipse = SVG.invent({
-
- create: 'ellipse',
-
- inherit: SVG.Shape,
-
- construct: {
-
- ellipse: function ellipse(width, height) {
- return this.put(new SVG.Ellipse()).size(width, height).move(0, 0);
- }
- }
- });
- SVG.extend(SVG.Ellipse, SVG.Rect, SVG.FX, {
-
- rx: function rx(_rx2) {
- return this.attr('rx', _rx2);
- },
-
- ry: function ry(_ry2) {
- return this.attr('ry', _ry2);
- }
- });
- SVG.extend(SVG.Circle, SVG.Ellipse, {
-
- x: function x(_x3) {
- return _x3 == null ? this.cx() - this.rx() : this.cx(_x3 + this.rx());
- },
-
- y: function y(_y2) {
- return _y2 == null ? this.cy() - this.ry() : this.cy(_y2 + this.ry());
- },
-
- cx: function cx(x) {
- return x == null ? this.attr('cx') : this.attr('cx', x);
- },
-
- cy: function cy(y) {
- return y == null ? this.attr('cy') : this.attr('cy', y);
- },
-
- width: function width(_width2) {
- return _width2 == null ? this.rx() * 2 : this.rx(new SVG.Number(_width2).divide(2));
- },
-
- height: function height(_height2) {
- return _height2 == null ? this.ry() * 2 : this.ry(new SVG.Number(_height2).divide(2));
- },
-
- size: function size(width, height) {
- var p = proportionalSize(this, width, height);
- return this.rx(new SVG.Number(p.width).divide(2)).ry(new SVG.Number(p.height).divide(2));
- }
- });
- SVG.Line = SVG.invent({
-
- create: 'line',
-
- inherit: SVG.Shape,
-
- extend: {
-
- array: function array() {
- return new SVG.PointArray([[this.attr('x1'), this.attr('y1')], [this.attr('x2'), this.attr('y2')]]);
- },
-
- plot: function plot(x1, y1, x2, y2) {
- if (x1 == null) {
- return this.array();
- } else if (typeof y1 !== 'undefined') {
- x1 = {
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2
- };
- } else {
- x1 = new SVG.PointArray(x1).toLine();
- }
- return this.attr(x1);
- },
-
- move: function move(x, y) {
- return this.attr(this.array().move(x, y).toLine());
- },
-
- size: function size(width, height) {
- var p = proportionalSize(this, width, height);
- return this.attr(this.array().size(p.width, p.height).toLine());
- }
- },
-
- construct: {
-
- line: function line(x1, y1, x2, y2) {
-
-
- return SVG.Line.prototype.plot.apply(this.put(new SVG.Line()), x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]);
- }
- }
- });
- SVG.Polyline = SVG.invent({
-
- create: 'polyline',
-
- inherit: SVG.Shape,
-
- construct: {
-
- polyline: function polyline(p) {
-
- return this.put(new SVG.Polyline()).plot(p || new SVG.PointArray());
- }
- }
- });
- SVG.Polygon = SVG.invent({
-
- create: 'polygon',
-
- inherit: SVG.Shape,
-
- construct: {
-
- polygon: function polygon(p) {
-
- return this.put(new SVG.Polygon()).plot(p || new SVG.PointArray());
- }
- }
- });
- SVG.extend(SVG.Polyline, SVG.Polygon, {
-
- array: function array() {
- return this._array || (this._array = new SVG.PointArray(this.attr('points')));
- },
-
- plot: function plot(p) {
- return p == null ? this.array() : this.clear().attr('points', typeof p === 'string' ? p : this._array = new SVG.PointArray(p));
- },
-
- clear: function clear() {
- delete this._array;
- return this;
- },
-
- move: function move(x, y) {
- return this.attr('points', this.array().move(x, y));
- },
-
- size: function size(width, height) {
- var p = proportionalSize(this, width, height);
- return this.attr('points', this.array().size(p.width, p.height));
- }
- });
- SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, {
-
- morphArray: SVG.PointArray,
-
- x: function x(_x4) {
- return _x4 == null ? this.bbox().x : this.move(_x4, this.bbox().y);
- },
-
- y: function y(_y3) {
- return _y3 == null ? this.bbox().y : this.move(this.bbox().x, _y3);
- },
-
- width: function width(_width3) {
- var b = this.bbox();
- return _width3 == null ? b.width : this.size(_width3, b.height);
- },
-
- height: function height(_height3) {
- var b = this.bbox();
- return _height3 == null ? b.height : this.size(b.width, _height3);
- }
- });
- SVG.Path = SVG.invent({
-
- create: 'path',
-
- inherit: SVG.Shape,
-
- extend: {
-
- morphArray: SVG.PathArray,
-
- array: function array() {
- return this._array || (this._array = new SVG.PathArray(this.attr('d')));
- },
-
- plot: function plot(d) {
- return d == null ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : this._array = new SVG.PathArray(d));
- },
-
- clear: function clear() {
- delete this._array;
- return this;
- }
- },
-
- construct: {
-
- path: function path(d) {
-
- return this.put(new SVG.Path()).plot(d || new SVG.PathArray());
- }
- }
- });
- SVG.Image = SVG.invent({
-
- create: 'image',
-
- inherit: SVG.Shape,
-
- extend: {
-
- load: function load(url) {
- if (!url) return this;
- var self = this,
- img = new window.Image();
- SVG.on(img, 'load', function () {
- SVG.off(img);
- var p = self.parent(SVG.Pattern);
- if (p === null) return;
- if (self.width() == 0 && self.height() == 0) {
- self.size(img.width, img.height);
- }
- if (p && p.width() == 0 && p.height() == 0) {
- p.size(self.width(), self.height());
- }
- if (typeof self._loaded === 'function') {
- self._loaded.call(self, {
- width: img.width,
- height: img.height,
- ratio: img.width / img.height,
- url: url
- });
- }
- });
- SVG.on(img, 'error', function (e) {
- SVG.off(img);
- if (typeof self._error === 'function') {
- self._error.call(self, e);
- }
- });
- return this.attr('href', img.src = this.src = url, SVG.xlink);
- },
-
- loaded: function loaded(_loaded) {
- this._loaded = _loaded;
- return this;
- },
- error: function error(_error) {
- this._error = _error;
- return this;
- }
- },
-
- construct: {
-
- image: function image(source, width, height) {
- return this.put(new SVG.Image()).load(source).size(width || 0, height || width || 0);
- }
- }
- });
- SVG.Text = SVG.invent({
-
- create: function create() {
- this.constructor.call(this, SVG.create('text'));
- this.dom.leading = new SVG.Number(1.3);
- this._rebuild = true;
- this._build = false;
-
- this.attr('font-family', SVG.defaults.attrs['font-family']);
- },
-
- inherit: SVG.Shape,
-
- extend: {
-
- x: function x(_x5) {
-
- if (_x5 == null) {
- return this.attr('x');
- }
- return this.attr('x', _x5);
- },
-
- text: function text(_text) {
-
- if (typeof _text === 'undefined') {
- var _text = '';
- var children = this.node.childNodes;
- for (var i = 0, len = children.length; i < len; ++i) {
-
- if (i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true) {
- _text += '\n';
- }
- _text += children[i].textContent;
- }
- return _text;
- }
- this.clear().build(true);
- if (typeof _text === 'function') {
-
- _text.call(this, this);
- } else {
-
- _text = _text.split('\n');
- for (var i = 0, il = _text.length; i < il; i++) {
- this.tspan(_text[i]).newLine();
- }
- }
- return this.build(false).rebuild();
- },
-
- size: function size(_size) {
- return this.attr('font-size', _size).rebuild();
- },
-
- leading: function leading(value) {
-
- if (value == null) {
- return this.dom.leading;
- }
- this.dom.leading = new SVG.Number(value);
- return this.rebuild();
- },
-
- lines: function lines() {
- var node = (this.textPath && this.textPath() || this).node;
- var lines = SVG.utils.map(SVG.utils.filterSVGElements(node.childNodes), function (el) {
- return SVG.adopt(el);
- });
- return new SVG.Set(lines);
- },
-
- rebuild: function rebuild(_rebuild) {
-
- if (typeof _rebuild === 'boolean') {
- this._rebuild = _rebuild;
- }
- if (this._rebuild) {
- var self = this,
- blankLineOffset = 0,
- dy = this.dom.leading * new SVG.Number(this.attr('font-size'));
- this.lines().each(function () {
- if (this.dom.newLined) {
- if (!self.textPath()) {
- this.attr('x', self.attr('x'));
- }
- if (this.text() == '\n') {
- blankLineOffset += dy;
- } else {
- this.attr('dy', dy + blankLineOffset);
- blankLineOffset = 0;
- }
- }
- });
- this.fire('rebuild');
- }
- return this;
- },
-
- build: function build(_build) {
- this._build = !!_build;
- return this;
- },
-
- setData: function setData(o) {
- this.dom = o;
- this.dom.leading = new SVG.Number(o.leading || 1.3);
- return this;
- }
- },
-
- construct: {
-
- text: function text(_text2) {
- return this.put(new SVG.Text()).text(_text2);
- },
-
- plain: function plain(text) {
- return this.put(new SVG.Text()).plain(text);
- }
- }
- });
- SVG.Tspan = SVG.invent({
-
- create: 'tspan',
-
- inherit: SVG.Shape,
-
- extend: {
-
- text: function text(_text3) {
- if (_text3 == null) return this.node.textContent + (this.dom.newLined ? '\n' : '');
- typeof _text3 === 'function' ? _text3.call(this, this) : this.plain(_text3);
- return this;
- },
-
- dx: function dx(_dx) {
- return this.attr('dx', _dx);
- },
-
- dy: function dy(_dy) {
- return this.attr('dy', _dy);
- },
-
- newLine: function newLine() {
-
- var t = this.parent(SVG.Text);
- this.dom.newLined = true;
- return this.dy(t.dom.leading * t.attr('font-size')).attr('x', t.x());
- }
- }
- });
- SVG.extend(SVG.Text, SVG.Tspan, {
-
- plain: function plain(text) {
-
- if (this._build === false) {
- this.clear();
- }
- this.node.appendChild(document.createTextNode(text));
- return this;
- },
-
- tspan: function tspan(text) {
- var node = (this.textPath && this.textPath() || this).node,
- tspan = new SVG.Tspan();
- if (this._build === false) {
- this.clear();
- }
- node.appendChild(tspan.node);
- return tspan.text(text);
- },
-
- clear: function clear() {
- var node = (this.textPath && this.textPath() || this).node;
- while (node.hasChildNodes()) {
- node.removeChild(node.lastChild);
- }
- return this;
- },
-
- length: function length() {
- return this.node.getComputedTextLength();
- }
- });
- SVG.TextPath = SVG.invent({
-
- create: 'textPath',
-
- inherit: SVG.Parent,
-
- parent: SVG.Text,
-
- construct: {
- morphArray: SVG.PathArray,
-
- array: function array() {
- var track = this.track();
- return track ? track.array() : null;
- },
-
- plot: function plot(d) {
- var track = this.track(),
- pathArray = null;
- if (track) {
- pathArray = track.plot(d);
- }
- return d == null ? pathArray : this;
- },
-
- track: function track() {
- var path = this.textPath();
- if (path) {
- return path.reference('href');
- }
- },
-
- textPath: function textPath() {
- if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') {
- return SVG.adopt(this.node.firstChild);
- }
- }
- }
- });
- SVG.Nested = SVG.invent({
-
- create: function create() {
- this.constructor.call(this, SVG.create('svg'));
- this.style('overflow', 'visible');
- },
-
- inherit: SVG.Container,
-
- construct: {
-
- nested: function nested() {
- return this.put(new SVG.Nested());
- }
- }
- });
- var sugar = {
- stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
- fill: ['color', 'opacity', 'rule'],
- prefix: function prefix(t, a) {
- return a == 'color' ? t : t + '-' + a;
- }
- }
- ;
- ['fill', 'stroke'].forEach(function (m) {
- var extension = {};
- extension[m] = function (o) {
- if (typeof o === 'undefined') {
- return this;
- }
- if (typeof o === 'string' || SVG.Color.isRgb(o) || o && typeof o.fill === 'function') {
- this.attr(m, o);
- } else
- {
- for (var i = sugar[m].length - 1; i >= 0; i--) {
- if (o[sugar[m][i]] != null) {
- this.attr(sugar.prefix(m, sugar[m][i]), o[sugar[m][i]]);
- }
- }
- }
- return this;
- };
- SVG.extend(SVG.Element, SVG.FX, extension);
- });
- SVG.extend(SVG.Element, SVG.FX, {
-
- translate: function translate(x, y) {
- return this.transform({
- x: x,
- y: y
- });
- },
-
- matrix: function matrix(m) {
- return this.attr('transform', new SVG.Matrix(arguments.length == 6 ? [].slice.call(arguments) : m));
- },
-
- opacity: function opacity(value) {
- return this.attr('opacity', value);
- },
-
- dx: function dx(x) {
- return this.x(new SVG.Number(x).plus(this instanceof SVG.FX ? 0 : this.x()), true);
- },
-
- dy: function dy(y) {
- return this.y(new SVG.Number(y).plus(this instanceof SVG.FX ? 0 : this.y()), true);
- }
- });
- SVG.extend(SVG.Path, {
-
- length: function length() {
- return this.node.getTotalLength();
- },
-
- pointAt: function pointAt(length) {
- return this.node.getPointAtLength(length);
- }
- });
- SVG.Set = SVG.invent({
-
- create: function create(members) {
-
- Array.isArray(members) ? this.members = members : this.clear();
- },
-
- extend: {
-
- add: function add() {
- var il,
- elements = [].slice.call(arguments);
- for (var i = 0, il = elements.length; i < il; i++) {
- this.members.push(elements[i]);
- }
- return this;
- },
-
- remove: function remove(element) {
- var i = this.index(element);
- if (i > -1) {
- this.members.splice(i, 1);
- }
- return this;
- },
-
- each: function each(block) {
- for (var i = 0, il = this.members.length; i < il; i++) {
- block.apply(this.members[i], [i, this.members]);
- }
- return this;
- },
-
- clear: function clear() {
-
- this.members = [];
- return this;
- },
-
- length: function length() {
- return this.members.length;
- },
-
- has: function has(element) {
- return this.index(element) >= 0;
- },
-
- index: function index(element) {
- return this.members.indexOf(element);
- },
-
- get: function get(i) {
- return this.members[i];
- },
-
- first: function first() {
- return this.get(0);
- },
-
- last: function last() {
- return this.get(this.members.length - 1);
- },
-
- valueOf: function valueOf() {
- return this.members;
- }
- },
-
- construct: {
-
- set: function set(members) {
- return new SVG.Set(members);
- }
- }
- });
- SVG.FX.Set = SVG.invent({
-
- create: function create(set) {
-
- this.set = set;
- }
- }); // Alias methods
- SVG.Set.inherit = function () {
- var methods = [];
- for (var m in SVG.Shape.prototype) {
- if (typeof SVG.Shape.prototype[m] === 'function' && typeof SVG.Set.prototype[m] !== 'function') {
- methods.push(m);
- }
- }
- methods.forEach(function (method) {
- SVG.Set.prototype[method] = function () {
- for (var i = 0, il = this.members.length; i < il; i++) {
- if (this.members[i] && typeof this.members[i][method] === 'function') {
- this.members[i][method].apply(this.members[i], arguments);
- }
- }
- return method == 'animate' ? this.fx || (this.fx = new SVG.FX.Set(this)) : this;
- };
- });
- methods = [];
- for (var m in SVG.FX.prototype) {
- if (typeof SVG.FX.prototype[m] === 'function' && typeof SVG.FX.Set.prototype[m] !== 'function') {
- methods.push(m);
- }
- }
- methods.forEach(function (method) {
- SVG.FX.Set.prototype[method] = function () {
- for (var i = 0, il = this.set.members.length; i < il; i++) {
- this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments);
- }
- return this;
- };
- });
- };
- SVG.extend(SVG.Element, {});
- SVG.extend(SVG.Element, {
-
- remember: function remember(k, v) {
-
- if (_typeof(arguments[0]) === 'object') {
- for (var v_ in k) {
- this.remember(v_, k[v_]);
- }
- }
- else if (arguments.length == 1) {
- return this.memory()[k];
- }
- else {
- this.memory()[k] = v;
- }
- return this;
- },
-
- forget: function forget() {
- if (arguments.length == 0) {
- this._memory = {};
- } else {
- for (var i = arguments.length - 1; i >= 0; i--) {
- delete this.memory()[arguments[i]];
- }
- }
- return this;
- },
-
- memory: function memory() {
- return this._memory || (this._memory = {});
- }
- });
- SVG.get = function (id) {
- var node = document.getElementById(idFromReference(id) || id);
- return SVG.adopt(node);
- };
- SVG.select = function (query, parent) {
- return new SVG.Set(SVG.utils.map((parent || document).querySelectorAll(query), function (node) {
- return SVG.adopt(node);
- }));
- };
- SVG.extend(SVG.Parent, {
-
- select: function select(query) {
- return SVG.select(query, this.node);
- }
- });
- function pathRegReplace(a, b, c, d) {
- return c + d.replace(SVG.regex.dots, ' .');
- }
- function _is(el, obj) {
- return el instanceof obj;
- }
- function _matches(el, selector) {
- return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
- }
- function camelCase(s) {
- return s.toLowerCase().replace(/-(.)/g, function (m, g) {
- return g.toUpperCase();
- });
- }
- function capitalize(s) {
- return s.charAt(0).toUpperCase() + s.slice(1);
- }
- function fullHex(hex) {
- return hex.length == 4 ? ['#', hex.substring(1, 2), hex.substring(1, 2), hex.substring(2, 3), hex.substring(2, 3), hex.substring(3, 4), hex.substring(3, 4)].join('') : hex;
- }
- function compToHex(comp) {
- var hex = comp.toString(16);
- return hex.length == 1 ? '0' + hex : hex;
- }
- function proportionalSize(element, width, height) {
- if (width == null || height == null) {
- var box = element.bbox();
- if (width == null) {
- width = box.width / box.height * height;
- } else if (height == null) {
- height = box.height / box.width * width;
- }
- }
- return {
- width: width,
- height: height
- };
- }
- function deltaTransformPoint(matrix, x, y) {
- return {
- x: x * matrix.a + y * matrix.c + 0,
- y: x * matrix.b + y * matrix.d + 0
- };
- }
- function arrayToMatrix(a) {
- return {
- a: a[0],
- b: a[1],
- c: a[2],
- d: a[3],
- e: a[4],
- f: a[5]
- };
- }
- function parseMatrix(matrix) {
- if (!(matrix instanceof SVG.Matrix)) {
- matrix = new SVG.Matrix(matrix);
- }
- return matrix;
- }
- function arrayToString(a) {
- for (var i = 0, il = a.length, s = ''; i < il; i++) {
- s += a[i][0];
- if (a[i][1] != null) {
- s += a[i][1];
- if (a[i][2] != null) {
- s += ' ';
- s += a[i][2];
- if (a[i][3] != null) {
- s += ' ';
- s += a[i][3];
- s += ' ';
- s += a[i][4];
- if (a[i][5] != null) {
- s += ' ';
- s += a[i][5];
- s += ' ';
- s += a[i][6];
- if (a[i][7] != null) {
- s += ' ';
- s += a[i][7];
- }
- }
- }
- }
- }
- }
- return s + ' ';
- }
- function assignNewId(node) {
-
- for (var i = node.childNodes.length - 1; i >= 0; i--) {
- if (node.childNodes[i] instanceof window.SVGElement) {
- assignNewId(node.childNodes[i]);
- }
- }
- return SVG.adopt(node).id(SVG.eid(node.nodeName));
- }
- function fullBox(b) {
- if (b.x == null) {
- b.x = 0;
- b.y = 0;
- b.width = 0;
- b.height = 0;
- }
- b.w = b.width;
- b.h = b.height;
- b.x2 = b.x + b.width;
- b.y2 = b.y + b.height;
- b.cx = b.x + b.width / 2;
- b.cy = b.y + b.height / 2;
- return b;
- }
- function idFromReference(url) {
- var m = (url || '').toString().match(SVG.regex.reference);
- if (m) return m[1];
- }
-
- function float32String(v) {
- return Math.abs(v) > 1e-37 ? v : 0;
- }
- var abcdef = 'abcdef'.split('');
- if (typeof window.CustomEvent !== 'function') {
-
- var CustomEventPoly = function CustomEventPoly(event, options) {
- options = options || {
- bubbles: false,
- cancelable: false,
- detail: undefined
- };
- var e = document.createEvent('CustomEvent');
- e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail);
- return e;
- };
- CustomEventPoly.prototype = window.Event.prototype;
- SVG.CustomEvent = CustomEventPoly;
- } else {
- SVG.CustomEvent = window.CustomEvent;
- }
- return SVG;
- });
-
- (function() {
-
- SVG.Filter = SVG.invent({
- create: 'filter',
- inherit: SVG.Parent,
- extend: {
-
- source: 'SourceGraphic',
- sourceAlpha: 'SourceAlpha',
- background: 'BackgroundImage',
- backgroundAlpha: 'BackgroundAlpha',
- fill: 'FillPaint',
- stroke: 'StrokePaint',
- autoSetIn: true,
-
- put: function(element, i) {
- this.add(element, i);
- if(!element.attr('in') && this.autoSetIn){
- element.attr('in',this.source);
- }
- if(!element.attr('result')){
- element.attr('result',element);
- }
- return element
- },
-
- blend: function(in1, in2, mode) {
- return this.put(new SVG.BlendEffect(in1, in2, mode))
- },
-
- colorMatrix: function(type, values) {
- return this.put(new SVG.ColorMatrixEffect(type, values))
- },
-
- convolveMatrix: function(matrix) {
- return this.put(new SVG.ConvolveMatrixEffect(matrix))
- },
-
- componentTransfer: function(components) {
- return this.put(new SVG.ComponentTransferEffect(components))
- },
-
- composite: function(in1, in2, operator) {
- return this.put(new SVG.CompositeEffect(in1, in2, operator))
- },
-
- flood: function(color, opacity) {
- return this.put(new SVG.FloodEffect(color, opacity))
- },
-
- offset: function(x, y) {
- return this.put(new SVG.OffsetEffect(x,y))
- },
-
- image: function(src) {
- return this.put(new SVG.ImageEffect(src))
- },
-
- merge: function() {
-
- var args = [undefined];
- for(var i in arguments) args.push(arguments[i]);
- return this.put(new (SVG.MergeEffect.bind.apply(SVG.MergeEffect,args)))
- },
-
- gaussianBlur: function(x,y) {
- return this.put(new SVG.GaussianBlurEffect(x,y))
- },
-
- morphology: function(operator,radius){
- return this.put(new SVG.MorphologyEffect(operator,radius))
- },
-
- diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
- return this.put(new SVG.DiffuseLightingEffect(surfaceScale,diffuseConstant,kernelUnitLength))
- },
-
- displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
- return this.put(new SVG.DisplacementMapEffect(in1,in2,scale,xChannelSelector,yChannelSelector))
- },
-
- specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
- return this.put(new SVG.SpecularLightingEffect(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength))
- },
-
- tile: function(){
- return this.put(new SVG.TileEffect());
- },
-
- turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
- return this.put(new SVG.TurbulenceEffect(baseFrequency,numOctaves,seed,stitchTiles,type))
- },
-
- toString: function() {
- return 'url(#' + this.attr('id') + ')'
- }
- }
- });
-
- SVG.extend(SVG.Defs, {
-
- filter: function(block) {
- var filter = this.put(new SVG.Filter);
-
- if (typeof block === 'function')
- block.call(filter, filter);
- return filter
- }
- });
- SVG.extend(SVG.Container, {
-
- filter: function(block) {
- return this.defs().filter(block)
- }
- });
- SVG.extend(SVG.Element, SVG.G, SVG.Nested, {
-
- filter: function(block) {
- this.filterer = block instanceof SVG.Element ?
- block : this.doc().filter(block);
- if(this.doc() && this.filterer.doc() !== this.doc()){
- this.doc().defs().add(this.filterer);
- }
- this.attr('filter', this.filterer);
- return this.filterer
- },
-
- unfilter: function(remove) {
-
- if (this.filterer && remove === true)
- this.filterer.remove();
-
- delete this.filterer;
-
- return this.attr('filter', null)
- }
- });
-
- SVG.Effect = SVG.invent({
- create: function(){
- this.constructor.call(this);
- },
- inherit: SVG.Element,
- extend: {
-
- in: function(effect) {
- return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
- },
-
- result: function(result) {
- return result == null? this.attr('result') : this.attr('result',result)
- },
-
- toString: function() {
- return this.result()
- }
- }
- });
-
-
- SVG.ParentEffect = SVG.invent({
- create: function(){
- this.constructor.call(this);
- },
- inherit: SVG.Parent,
- extend: {
-
- in: function(effect) {
- return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
- },
-
- result: function(result) {
- return result == null? this.attr('result') : this.attr('result',result)
- },
-
- toString: function() {
- return this.result()
- }
- }
- });
-
- var chainingEffects = {
-
- blend: function(in2, mode) {
- return this.parent() && this.parent().blend(this, in2, mode)
- },
-
- colorMatrix: function(type, values) {
- return this.parent() && this.parent().colorMatrix(type, values).in(this)
- },
-
- convolveMatrix: function(matrix) {
- return this.parent() && this.parent().convolveMatrix(matrix).in(this)
- },
-
- componentTransfer: function(components) {
- return this.parent() && this.parent().componentTransfer(components).in(this)
- },
-
- composite: function(in2, operator) {
- return this.parent() && this.parent().composite(this, in2, operator)
- },
-
- flood: function(color, opacity) {
- return this.parent() && this.parent().flood(color, opacity)
- },
-
- offset: function(x, y) {
- return this.parent() && this.parent().offset(x,y).in(this)
- },
-
- image: function(src) {
- return this.parent() && this.parent().image(src)
- },
-
- merge: function() {
- return this.parent() && this.parent().merge.apply(this.parent(),[this].concat(arguments))
- },
-
- gaussianBlur: function(x,y) {
- return this.parent() && this.parent().gaussianBlur(x,y).in(this)
- },
-
- morphology: function(operator,radius){
- return this.parent() && this.parent().morphology(operator,radius).in(this)
- },
-
- diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
- return this.parent() && this.parent().diffuseLighting(surfaceScale,diffuseConstant,kernelUnitLength).in(this)
- },
-
- displacementMap: function(in2,scale,xChannelSelector,yChannelSelector){
- return this.parent() && this.parent().displacementMap(this,in2,scale,xChannelSelector,yChannelSelector)
- },
-
- specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
- return this.parent() && this.parent().specularLighting(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength).in(this)
- },
-
- tile: function(){
- return this.parent() && this.parent().tile().in(this)
- },
-
- turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
- return this.parent() && this.parent().turbulence(baseFrequency,numOctaves,seed,stitchTiles,type).in(this)
- }
- };
- SVG.extend(SVG.Effect,chainingEffects);
- SVG.extend(SVG.ParentEffect,chainingEffects);
-
- SVG.ChildEffect = SVG.invent({
- create: function(){
- this.constructor.call(this);
- },
- inherit: SVG.Element,
- extend: {
- in: function(effect){
- this.attr('in',effect);
- }
-
- }
- });
-
- var effects = {
- blend: function(in1,in2,mode){
- this.attr({
- in: in1,
- in2: in2,
- mode: mode || 'normal'
- });
- },
- colorMatrix: function(type,values){
- if (type == 'matrix')
- values = normaliseMatrix(values);
- this.attr({
- type: type
- , values: typeof values == 'undefined' ? null : values
- });
- },
- convolveMatrix: function(matrix){
- matrix = normaliseMatrix(matrix);
- this.attr({
- order: Math.sqrt(matrix.split(' ').length)
- , kernelMatrix: matrix
- });
- },
- composite: function(in1, in2, operator){
- this.attr({
- in: in1,
- in2: in2,
- operator: operator
- });
- },
- flood: function(color,opacity){
- this.attr('flood-color',color);
- if(opacity != null) this.attr('flood-opacity',opacity);
- },
- offset: function(x,y){
- this.attr({
- dx: x,
- dy: y
- });
- },
- image: function(src){
- this.attr('href', src, SVG.xlink);
- },
- displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
- this.attr({
- in: in1,
- in2: in2,
- scale: scale,
- xChannelSelector: xChannelSelector,
- yChannelSelector: yChannelSelector
- });
- },
- gaussianBlur: function(x,y){
- if(x != null || y != null)
- this.attr('stdDeviation', listString(Array.prototype.slice.call(arguments)));
- else
- this.attr('stdDeviation', '0 0');
- },
- morphology: function(operator,radius){
- this.attr({
- operator: operator,
- radius: radius
- });
- },
- tile: function(){
- },
- turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
- this.attr({
- numOctaves: numOctaves,
- seed: seed,
- stitchTiles: stitchTiles,
- baseFrequency: baseFrequency,
- type: type
- });
- }
- };
-
- var parentEffects = {
- merge: function(){
- var children;
-
- if(arguments[0] instanceof SVG.Set){
- var that = this;
- arguments[0].each(function(i){
- if(this instanceof SVG.MergeNode)
- that.put(this);
- else if(this instanceof SVG.Effect || this instanceof SVG.ParentEffect)
- that.put(new SVG.MergeNode(this));
- });
- }
- else{
-
- if(Array.isArray(arguments[0]))
- children = arguments[0];
- else
- children = arguments;
- for(var i = 0; i < children.length; i++){
- if(children[i] instanceof SVG.MergeNode){
- this.put(children[i]);
- }
- else this.put(new SVG.MergeNode(children[i]));
- }
- }
- },
- componentTransfer: function(compontents){
-
- this.rgb = new SVG.Set
-
- ;(['r', 'g', 'b', 'a']).forEach(function(c) {
-
- this[c] = new SVG['Func' + c.toUpperCase()]('identity');
-
- this.rgb.add(this[c]);
-
- this.node.appendChild(this[c].node);
- }.bind(this));
-
- if (compontents) {
- if (compontents.rgb) {
- (['r', 'g', 'b']).forEach(function(c) {
- this[c].attr(compontents.rgb);
- }.bind(this));
- delete compontents.rgb;
- }
-
- for (var c in compontents)
- this[c].attr(compontents[c]);
- }
- },
- diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
- this.attr({
- surfaceScale: surfaceScale,
- diffuseConstant: diffuseConstant,
- kernelUnitLength: kernelUnitLength
- });
- },
- specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
- this.attr({
- surfaceScale: surfaceScale,
- diffuseConstant: diffuseConstant,
- specularExponent: specularExponent,
- kernelUnitLength: kernelUnitLength
- });
- },
- };
-
- var childEffects = {
- distantLight: function(azimuth, elevation){
- this.attr({
- azimuth: azimuth,
- elevation: elevation
- });
- },
- pointLight: function(x,y,z){
- this.attr({
- x: x,
- y: y,
- z: z
- });
- },
- spotLight: function(x,y,z,pointsAtX,pointsAtY,pointsAtZ){
- this.attr({
- x: x,
- y: y,
- z: z,
- pointsAtX: pointsAtX,
- pointsAtY: pointsAtY,
- pointsAtZ: pointsAtZ
- });
- },
- mergeNode: function(in1){
- this.attr('in',in1);
- }
- }
-
- ;(['r', 'g', 'b', 'a']).forEach(function(c) {
-
- childEffects['Func' + c.toUpperCase()] = function(type) {
- this.attr('type',type);
-
- switch(type){
- case 'table':
- this.attr('tableValues',arguments[1]);
- break
- case 'linear':
- this.attr('slope',arguments[1]);
- this.attr('intercept',arguments[2]);
- break
- case 'gamma':
- this.attr('amplitude',arguments[1]);
- this.attr('exponent',arguments[2]);
- this.attr('offset',arguments[2]);
- break
- }
- };
- });
-
- foreach(effects,function(effect,i){
-
- var name = i.charAt(0).toUpperCase() + i.slice(1);
- var proto = {};
-
- SVG[name + 'Effect'] = SVG.invent({
- create: function() {
-
- this.constructor.call(this, SVG.create('fe' + name));
-
- effect.apply(this,arguments);
-
- this.result(this.attr('id') + 'Out');
- },
- inherit: SVG.Effect,
- extend: proto
- });
- });
-
- foreach(parentEffects,function(effect,i){
-
- var name = i.charAt(0).toUpperCase() + i.slice(1);
- var proto = {};
-
- SVG[name + 'Effect'] = SVG.invent({
- create: function() {
-
- this.constructor.call(this, SVG.create('fe' + name));
-
- effect.apply(this,arguments);
-
- this.result(this.attr('id') + 'Out');
- },
- inherit: SVG.ParentEffect,
- extend: proto
- });
- });
-
- foreach(childEffects,function(effect,i){
-
- var name = i.charAt(0).toUpperCase() + i.slice(1);
- var proto = {};
-
- SVG[name] = SVG.invent({
- create: function() {
-
- this.constructor.call(this, SVG.create('fe' + name));
-
- effect.apply(this,arguments);
- },
- inherit: SVG.ChildEffect,
- extend: proto
- });
- });
-
- SVG.extend(SVG.MergeEffect,{
- in: function(effect){
- if(effect instanceof SVG.MergeNode)
- this.add(effect,0);
- else
- this.add(new SVG.MergeNode(effect),0);
- return this
- }
- });
- SVG.extend(SVG.CompositeEffect,SVG.BlendEffect,SVG.DisplacementMapEffect,{
- in2: function(effect){
- return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in2')+'"]').get(0) || this.attr('in2') : this.attr('in2', effect)
- }
- });
-
- SVG.filter = {
- sepiatone: [ .343, .669, .119, 0, 0
- , .249, .626, .130, 0, 0
- , .172, .334, .111, 0, 0
- , .000, .000, .000, 1, 0 ]
- };
-
- function normaliseMatrix(matrix) {
-
- if (Array.isArray(matrix))
- matrix = new SVG.Array(matrix);
-
- return matrix.toString().replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' ')
- }
- function listString(list) {
- if (!Array.isArray(list))
- return list
- for (var i = 0, l = list.length, s = []; i < l; i++)
- s.push(list[i]);
- return s.join(' ')
- }
- function foreach(){
- var fn = function(){};
- if(typeof arguments[arguments.length-1] == 'function'){
- fn = arguments[arguments.length-1];
- Array.prototype.splice.call(arguments,arguments.length-1,1);
- }
- for(var k in arguments){
- for(var i in arguments[k]){
- fn(arguments[k][i],i,arguments[k]);
- }
- }
- }
- }).call(undefined);
- (function() {
- SVG.extend(SVG.PathArray, {
- morph: function(array) {
- var startArr = this.value
- , destArr = this.parse(array);
- var startOffsetM = 0
- , destOffsetM = 0;
- var startOffsetNextM = false
- , destOffsetNextM = false;
- while(true){
-
- if(startOffsetM === false && destOffsetM === false) break
-
- startOffsetNextM = findNextM(startArr, startOffsetM === false ? false : startOffsetM+1);
- destOffsetNextM = findNextM( destArr, destOffsetM === false ? false : destOffsetM+1);
-
- if(startOffsetM === false){
- var bbox = new SVG.PathArray(result.start).bbox();
-
- if(bbox.height == 0 || bbox.width == 0){
- startOffsetM = startArr.push(startArr[0]) - 1;
- }else{
-
- startOffsetM = startArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
- }
- }
-
- if( destOffsetM === false){
- var bbox = new SVG.PathArray(result.dest).bbox();
- if(bbox.height == 0 || bbox.width == 0){
- destOffsetM = destArr.push(destArr[0]) - 1;
- }else{
- destOffsetM = destArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
- }
- }
-
- var result = handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM);
-
- startArr = startArr.slice(0, startOffsetM).concat(result.start, startOffsetNextM === false ? [] : startArr.slice(startOffsetNextM));
- destArr = destArr.slice(0, destOffsetM).concat(result.dest , destOffsetNextM === false ? [] : destArr.slice( destOffsetNextM));
-
- startOffsetM = startOffsetNextM === false ? false : startOffsetM + result.start.length;
- destOffsetM = destOffsetNextM === false ? false : destOffsetM + result.dest.length;
- }
-
- this.value = startArr;
- this.destination = new SVG.PathArray();
- this.destination.value = destArr;
- return this
- }
- });
-
-
- function handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM, undefined$1){
-
- var startArrTemp = startArr.slice(startOffsetM, startOffsetNextM || undefined$1)
- , destArrTemp = destArr.slice( destOffsetM, destOffsetNextM || undefined$1);
- var i = 0
- , posStart = {pos:[0,0], start:[0,0]}
- , posDest = {pos:[0,0], start:[0,0]};
- do{
-
- startArrTemp[i] = simplyfy.call(posStart, startArrTemp[i]);
- destArrTemp[i] = simplyfy.call(posDest , destArrTemp[i]);
-
-
-
- if(startArrTemp[i][0] != destArrTemp[i][0] || startArrTemp[i][0] == 'M' ||
- (startArrTemp[i][0] == 'A' &&
- (startArrTemp[i][4] != destArrTemp[i][4] || startArrTemp[i][5] != destArrTemp[i][5])
- )
- ) {
-
- Array.prototype.splice.apply(startArrTemp, [i, 1].concat(toBeziere.call(posStart, startArrTemp[i])));
- Array.prototype.splice.apply(destArrTemp, [i, 1].concat(toBeziere.call(posDest, destArrTemp[i])));
- } else {
-
- startArrTemp[i] = setPosAndReflection.call(posStart, startArrTemp[i]);
- destArrTemp[i] = setPosAndReflection.call(posDest , destArrTemp[i]);
- }
-
- if(++i == startArrTemp.length && i == destArrTemp.length) break
-
- if(i == startArrTemp.length){
- startArrTemp.push([
- 'C',
- posStart.pos[0],
- posStart.pos[1],
- posStart.pos[0],
- posStart.pos[1],
- posStart.pos[0],
- posStart.pos[1],
- ]);
- }
-
- if(i == destArrTemp.length){
- destArrTemp.push([
- 'C',
- posDest.pos[0],
- posDest.pos[1],
- posDest.pos[0],
- posDest.pos[1],
- posDest.pos[0],
- posDest.pos[1]
- ]);
- }
- }while(true)
-
- return {start:startArrTemp, dest:destArrTemp}
- }
-
- function simplyfy(val){
- switch(val[0]){
- case 'z':
- case 'Z':
- val[0] = 'L';
- val[1] = this.start[0];
- val[2] = this.start[1];
- break
- case 'H':
- val[0] = 'L';
- val[2] = this.pos[1];
- break
- case 'V':
- val[0] = 'L';
- val[2] = val[1];
- val[1] = this.pos[0];
- break
- case 'T':
- val[0] = 'Q';
- val[3] = val[1];
- val[4] = val[2];
- val[1] = this.reflection[1];
- val[2] = this.reflection[0];
- break
- case 'S':
- val[0] = 'C';
- val[6] = val[4];
- val[5] = val[3];
- val[4] = val[2];
- val[3] = val[1];
- val[2] = this.reflection[1];
- val[1] = this.reflection[0];
- break
- }
- return val
- }
-
- function setPosAndReflection(val){
- var len = val.length;
- this.pos = [ val[len-2], val[len-1] ];
- if('SCQT'.indexOf(val[0]) != -1)
- this.reflection = [ 2 * this.pos[0] - val[len-4], 2 * this.pos[1] - val[len-3] ];
- return val
- }
-
- function toBeziere(val){
- var retVal = [val];
- switch(val[0]){
- case 'M':
- this.pos = this.start = [val[1], val[2]];
- return retVal
- case 'L':
- val[5] = val[3] = val[1];
- val[6] = val[4] = val[2];
- val[1] = this.pos[0];
- val[2] = this.pos[1];
- break
- case 'Q':
- val[6] = val[4];
- val[5] = val[3];
- val[4] = val[4] * 1/3 + val[2] * 2/3;
- val[3] = val[3] * 1/3 + val[1] * 2/3;
- val[2] = this.pos[1] * 1/3 + val[2] * 2/3;
- val[1] = this.pos[0] * 1/3 + val[1] * 2/3;
- break
- case 'A':
- retVal = arcToBeziere(this.pos, val);
- val = retVal[0];
- break
- }
- val[0] = 'C';
- this.pos = [val[5], val[6]];
- this.reflection = [2 * val[5] - val[3], 2 * val[6] - val[4]];
- return retVal
- }
-
- function findNextM(arr, offset){
- if(offset === false) return false
- for(var i = offset, len = arr.length;i < len;++i){
- if(arr[i][0] == 'M') return i
- }
- return false
- }
-
-
-
-
-
- function arcToBeziere(pos, val) {
-
-
- var rx = Math.abs(val[1]), ry = Math.abs(val[2]), xAxisRotation = val[3] % 360
- , largeArcFlag = val[4], sweepFlag = val[5], x = val[6], y = val[7]
- , A = new SVG.Point(pos), B = new SVG.Point(x, y)
- , primedCoord, lambda, mat, k, c, cSquare, t, O, OA, OB, tetaStart, tetaEnd
- , deltaTeta, nbSectors, f, arcSegPoints, angle, sinAngle, cosAngle, pt, i, il
- , retVal = [], x1, y1, x2, y2;
-
- if(rx === 0 || ry === 0 || (A.x === B.x && A.y === B.y)) {
-
- return [['C', A.x, A.y, B.x, B.y, B.x, B.y]]
- }
-
-
- primedCoord = new SVG.Point((A.x-B.x)/2, (A.y-B.y)/2).transform(new SVG.Matrix().rotate(xAxisRotation));
- lambda = (primedCoord.x * primedCoord.x) / (rx * rx) + (primedCoord.y * primedCoord.y) / (ry * ry);
- if(lambda > 1) {
- lambda = Math.sqrt(lambda);
- rx = lambda*rx;
- ry = lambda*ry;
- }
-
- mat = new SVG.Matrix().rotate(xAxisRotation).scale(1/rx, 1/ry).rotate(-xAxisRotation);
- A = A.transform(mat);
- B = B.transform(mat);
-
- k = [B.x-A.x, B.y-A.y];
-
- cSquare = k[0]*k[0] + k[1]*k[1];
- c = Math.sqrt(cSquare);
-
- k[0] /= c;
- k[1] /= c;
-
-
-
-
-
-
-
-
- t = (cSquare < 4) ? Math.sqrt(1 - cSquare/4) : 0;
-
-
-
-
-
-
- if(largeArcFlag === sweepFlag) {
- t *= -1;
- }
-
-
-
-
-
-
-
-
- O = new SVG.Point((B.x+A.x)/2 + t*-k[1], (B.y+A.y)/2 + t*k[0]);
-
- OA = new SVG.Point(A.x-O.x, A.y-O.y);
- OB = new SVG.Point(B.x-O.x, B.y-O.y);
-
- tetaStart = Math.acos(OA.x/Math.sqrt(OA.x*OA.x + OA.y*OA.y));
- if (OA.y < 0) {
- tetaStart *= -1;
- }
- tetaEnd = Math.acos(OB.x/Math.sqrt(OB.x*OB.x + OB.y*OB.y));
- if (OB.y < 0) {
- tetaEnd *= -1;
- }
-
-
- if (sweepFlag && tetaStart > tetaEnd) {
- tetaEnd += 2*Math.PI;
- }
-
-
- if (!sweepFlag && tetaStart < tetaEnd) {
- tetaEnd -= 2*Math.PI;
- }
-
-
- nbSectors = Math.ceil(Math.abs(tetaStart-tetaEnd) * 2/Math.PI);
-
-
- arcSegPoints = [];
- angle = tetaStart;
- deltaTeta = (tetaEnd-tetaStart)/nbSectors;
- f = 4*Math.tan(deltaTeta/4)/3;
- for (i = 0; i <= nbSectors; i++) {
- cosAngle = Math.cos(angle);
- sinAngle = Math.sin(angle);
- pt = new SVG.Point(O.x+cosAngle, O.y+sinAngle);
- arcSegPoints[i] = [new SVG.Point(pt.x+f*sinAngle, pt.y-f*cosAngle), pt, new SVG.Point(pt.x-f*sinAngle, pt.y+f*cosAngle)];
- angle += deltaTeta;
- }
-
-
- arcSegPoints[0][0] = arcSegPoints[0][1].clone();
- arcSegPoints[arcSegPoints.length-1][2] = arcSegPoints[arcSegPoints.length-1][1].clone();
-
- mat = new SVG.Matrix().rotate(xAxisRotation).scale(rx, ry).rotate(-xAxisRotation);
- for (i = 0, il = arcSegPoints.length; i < il; i++) {
- arcSegPoints[i][0] = arcSegPoints[i][0].transform(mat);
- arcSegPoints[i][1] = arcSegPoints[i][1].transform(mat);
- arcSegPoints[i][2] = arcSegPoints[i][2].transform(mat);
- }
-
- for (i = 1, il = arcSegPoints.length; i < il; i++) {
- pt = arcSegPoints[i-1][2];
- x1 = pt.x;
- y1 = pt.y;
- pt = arcSegPoints[i][0];
- x2 = pt.x;
- y2 = pt.y;
- pt = arcSegPoints[i][1];
- x = pt.x;
- y = pt.y;
- retVal.push(['C', x1, y1, x2, y2, x, y]);
- }
- return retVal
- }
- }());
-
- (function() {
-
- function DragHandler(el){
- el.remember('_draggable', this);
- this.el = el;
- }
-
- DragHandler.prototype.init = function(constraint, val){
- var _this = this;
- this.constraint = constraint;
- this.value = val;
- this.el.on('mousedown.drag', function(e){ _this.start(e); });
- this.el.on('touchstart.drag', function(e){ _this.start(e); });
- };
-
- DragHandler.prototype.transformPoint = function(event, offset){
- event = event || window.event;
- var touches = event.changedTouches && event.changedTouches[0] || event;
- this.p.x = touches.clientX - (offset || 0);
- this.p.y = touches.clientY;
- return this.p.matrixTransform(this.m)
- };
-
- DragHandler.prototype.getBBox = function(){
- var box = this.el.bbox();
- if(this.el instanceof SVG.Nested) box = this.el.rbox();
- if (this.el instanceof SVG.G || this.el instanceof SVG.Use || this.el instanceof SVG.Nested) {
- box.x = this.el.x();
- box.y = this.el.y();
- }
- return box
- };
-
- DragHandler.prototype.start = function(e){
-
- if(e.type == 'click'|| e.type == 'mousedown' || e.type == 'mousemove'){
- if((e.which || e.buttons) != 1){
- return
- }
- }
- var _this = this;
-
- this.el.fire('beforedrag', { event: e, handler: this });
- if(this.el.event().defaultPrevented) return;
-
- e.preventDefault();
-
- e.stopPropagation();
-
-
- this.parent = this.parent || this.el.parent(SVG.Nested) || this.el.parent(SVG.Doc);
- this.p = this.parent.node.createSVGPoint();
-
- this.m = this.el.node.getScreenCTM().inverse();
- var box = this.getBBox();
- var anchorOffset;
-
- if(this.el instanceof SVG.Text){
- anchorOffset = this.el.node.getComputedTextLength();
- switch(this.el.attr('text-anchor')){
- case 'middle':
- anchorOffset /= 2;
- break
- case 'start':
- anchorOffset = 0;
- break;
- }
- }
- this.startPoints = {
-
- point: this.transformPoint(e, anchorOffset),
- box: box,
- transform: this.el.transform()
- };
-
- SVG.on(window, 'mousemove.drag', function(e){ _this.drag(e); });
- SVG.on(window, 'touchmove.drag', function(e){ _this.drag(e); });
- SVG.on(window, 'mouseup.drag', function(e){ _this.end(e); });
- SVG.on(window, 'touchend.drag', function(e){ _this.end(e); });
-
- this.el.fire('dragstart', {event: e, p: this.startPoints.point, m: this.m, handler: this});
- };
-
- DragHandler.prototype.drag = function(e){
- var box = this.getBBox()
- , p = this.transformPoint(e)
- , x = this.startPoints.box.x + p.x - this.startPoints.point.x
- , y = this.startPoints.box.y + p.y - this.startPoints.point.y
- , c = this.constraint
- , gx = p.x - this.startPoints.point.x
- , gy = p.y - this.startPoints.point.y;
- this.el.fire('dragmove', {
- event: e
- , p: p
- , m: this.m
- , handler: this
- });
- if(this.el.event().defaultPrevented) return p
-
- if (typeof c == 'function') {
- var coord = c.call(this.el, x, y, this.m);
-
- if (typeof coord == 'boolean') {
- coord = {
- x: coord,
- y: coord
- };
- }
-
- if (coord.x === true) {
- this.el.x(x);
- } else if (coord.x !== false) {
- this.el.x(coord.x);
- }
- if (coord.y === true) {
- this.el.y(y);
- } else if (coord.y !== false) {
- this.el.y(coord.y);
- }
- } else if (typeof c == 'object') {
-
- if (c.minX != null && x < c.minX) {
- x = c.minX;
- gx = x - this.startPoints.box.x;
- } else if (c.maxX != null && x > c.maxX - box.width) {
- x = c.maxX - box.width;
- gx = x - this.startPoints.box.x;
- } if (c.minY != null && y < c.minY) {
- y = c.minY;
- gy = y - this.startPoints.box.y;
- } else if (c.maxY != null && y > c.maxY - box.height) {
- y = c.maxY - box.height;
- gy = y - this.startPoints.box.y;
- }
- if (c.snapToGrid != null) {
- x = x - (x % c.snapToGrid);
- y = y - (y % c.snapToGrid);
- gx = gx - (gx % c.snapToGrid);
- gy = gy - (gy % c.snapToGrid);
- }
- if(this.el instanceof SVG.G)
- this.el.matrix(this.startPoints.transform).transform({x:gx, y: gy}, true);
- else
- this.el.move(x, y);
- }
-
- return p
- };
- DragHandler.prototype.end = function(e){
-
- var p = this.drag(e);
-
- this.el.fire('dragend', { event: e, p: p, m: this.m, handler: this });
-
- SVG.off(window, 'mousemove.drag');
- SVG.off(window, 'touchmove.drag');
- SVG.off(window, 'mouseup.drag');
- SVG.off(window, 'touchend.drag');
- };
- SVG.extend(SVG.Element, {
-
-
-
- draggable: function(value, constraint) {
-
- if (typeof value == 'function' || typeof value == 'object') {
- constraint = value;
- value = true;
- }
- var dragHandler = this.remember('_draggable') || new DragHandler(this);
-
- value = typeof value === 'undefined' ? true : value;
- if(value) dragHandler.init(constraint || {}, value);
- else {
- this.off('mousedown.drag');
- this.off('touchstart.drag');
- }
- return this
- }
- });
- }).call(undefined);
- (function() {
- function SelectHandler(el) {
- this.el = el;
- el.remember('_selectHandler', this);
- this.pointSelection = {isSelected: false};
- this.rectSelection = {isSelected: false};
-
- this.pointsList = {
- lt: [ 0, 0 ],
- rt: [ 'width', 0 ],
- rb: [ 'width', 'height' ],
- lb: [ 0, 'height' ],
- t: [ 'width', 0 ],
- r: [ 'width', 'height' ],
- b: [ 'width', 'height' ],
- l: [ 0, 'height' ]
- };
-
- this.pointCoord = function (setting, object, isPointCentered) {
- var coord = typeof setting !== 'string' ? setting : object[setting];
-
- return isPointCentered ? coord / 2 : coord
- };
- this.pointCoords = function (point, object) {
- var settings = this.pointsList[point];
- return {
- x: this.pointCoord(settings[0], object, (point === 't' || point === 'b')),
- y: this.pointCoord(settings[1], object, (point === 'r' || point === 'l'))
- }
- };
- }
- SelectHandler.prototype.init = function (value, options) {
- var bbox = this.el.bbox();
- this.options = {};
-
- var points = this.el.selectize.defaults.points;
-
- for (var i in this.el.selectize.defaults) {
- this.options[i] = this.el.selectize.defaults[i];
- if (options[i] !== undefined) {
- this.options[i] = options[i];
- }
- }
-
- var pointsLists = ['points', 'pointsExclude'];
- for (var i in pointsLists) {
- var option = this.options[pointsLists[i]];
- if (typeof option === 'string') {
- if (option.length > 0) {
-
- option = option.split(/\s*,\s*/i);
- } else {
- option = [];
- }
- } else if (typeof option === 'boolean' && pointsLists[i] === 'points') {
-
- option = option ? points : [];
- }
- this.options[pointsLists[i]] = option;
- }
-
-
- this.options.points = [ points, this.options.points ].reduce(
- function (a, b) {
- return a.filter(
- function (c) {
- return b.indexOf(c) > -1;
- }
- )
- }
- );
-
- this.options.points = [ this.options.points, this.options.pointsExclude ].reduce(
- function (a, b) {
- return a.filter(
- function (c) {
- return b.indexOf(c) < 0;
- }
- )
- }
- );
- this.parent = this.el.parent();
- this.nested = (this.nested || this.parent.group());
- this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
-
- if (this.options.deepSelect && ['line', 'polyline', 'polygon'].indexOf(this.el.type) !== -1) {
- this.selectPoints(value);
- } else {
- this.selectRect(value);
- }
- this.observe();
- this.cleanup();
- };
- SelectHandler.prototype.selectPoints = function (value) {
- this.pointSelection.isSelected = value;
-
- if (this.pointSelection.set) {
- return this;
- }
-
- this.pointSelection.set = this.parent.set();
-
- this.drawPoints();
- return this;
- };
-
- SelectHandler.prototype.getPointArray = function () {
- var bbox = this.el.bbox();
- return this.el.array().valueOf().map(function (el) {
- return [el[0] - bbox.x, el[1] - bbox.y];
- });
- };
-
- SelectHandler.prototype.drawPoints = function () {
- var _this = this, array = this.getPointArray();
-
- for (var i = 0, len = array.length; i < len; ++i) {
- var curriedEvent = (function (k) {
- return function (ev) {
- ev = ev || window.event;
- ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
- ev.stopPropagation();
- var x = ev.pageX || ev.touches[0].pageX;
- var y = ev.pageY || ev.touches[0].pageY;
- _this.el.fire('point', {x: x, y: y, i: k, event: ev});
- };
- })(i);
-
-
- var point = this.drawPoint(array[i][0], array[i][1])
- .addClass(this.options.classPoints)
- .addClass(this.options.classPoints + '_point')
- .on('touchstart', curriedEvent)
- .on('mousedown', curriedEvent);
- this.pointSelection.set.add(point);
- }
- };
-
- SelectHandler.prototype.drawPoint = function (cx, cy) {
- var pointType = this.options.pointType;
- switch (pointType) {
- case 'circle':
- return this.drawCircle(cx, cy);
- case 'rect':
- return this.drawRect(cx, cy);
- default:
- if (typeof pointType === 'function') {
- return pointType.call(this, cx, cy);
- }
- throw new Error('Unknown ' + pointType + ' point type!');
- }
- };
-
- SelectHandler.prototype.drawCircle = function (cx, cy) {
- return this.nested.circle(this.options.pointSize)
- .center(cx, cy);
- };
-
- SelectHandler.prototype.drawRect = function (cx, cy) {
- return this.nested.rect(this.options.pointSize, this.options.pointSize)
- .center(cx, cy);
- };
-
- SelectHandler.prototype.updatePointSelection = function () {
- var array = this.getPointArray();
- this.pointSelection.set.each(function (i) {
- if (this.cx() === array[i][0] && this.cy() === array[i][1]) {
- return;
- }
- this.center(array[i][0], array[i][1]);
- });
- };
- SelectHandler.prototype.updateRectSelection = function () {
- var _this = this, bbox = this.el.bbox();
- this.rectSelection.set.get(0).attr({
- width: bbox.width,
- height: bbox.height
- });
-
- if (this.options.points.length) {
- this.options.points.map(function (point, index) {
- var coords = _this.pointCoords(point, bbox);
- _this.rectSelection.set.get(index + 1).center(coords.x, coords.y);
- });
- }
- if (this.options.rotationPoint) {
- var length = this.rectSelection.set.length();
- this.rectSelection.set.get(length - 1).center(bbox.width / 2, 20);
- }
- };
- SelectHandler.prototype.selectRect = function (value) {
- var _this = this, bbox = this.el.bbox();
- this.rectSelection.isSelected = value;
-
- this.rectSelection.set = this.rectSelection.set || this.parent.set();
-
- function getMoseDownFunc(eventName) {
- return function (ev) {
- ev = ev || window.event;
- ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
- ev.stopPropagation();
- var x = ev.pageX || ev.touches[0].pageX;
- var y = ev.pageY || ev.touches[0].pageY;
- _this.el.fire(eventName, {x: x, y: y, event: ev});
- };
- }
-
- if (!this.rectSelection.set.get(0)) {
- this.rectSelection.set.add(this.nested.rect(bbox.width, bbox.height).addClass(this.options.classRect));
- }
-
- if (this.options.points.length && this.rectSelection.set.length() < 2) {
- var ename ="touchstart", mname = "mousedown";
- this.options.points.map(function (point, index) {
- var coords = _this.pointCoords(point, bbox);
- var pointElement = _this.drawPoint(coords.x, coords.y)
- .attr('class', _this.options.classPoints + '_' + point)
- .on(mname, getMoseDownFunc(point))
- .on(ename, getMoseDownFunc(point));
- _this.rectSelection.set.add(pointElement);
- });
- this.rectSelection.set.each(function () {
- this.addClass(_this.options.classPoints);
- });
- }
-
- if (this.options.rotationPoint && ((this.options.points && !this.rectSelection.set.get(9)) || (!this.options.points && !this.rectSelection.set.get(1)))) {
- var curriedEvent = function (ev) {
- ev = ev || window.event;
- ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
- ev.stopPropagation();
- var x = ev.pageX || ev.touches[0].pageX;
- var y = ev.pageY || ev.touches[0].pageY;
- _this.el.fire('rot', {x: x, y: y, event: ev});
- };
- var pointElement = this.drawPoint(bbox.width / 2, 20)
- .attr('class', this.options.classPoints + '_rot')
- .on("touchstart", curriedEvent)
- .on("mousedown", curriedEvent);
- this.rectSelection.set.add(pointElement);
- }
- };
- SelectHandler.prototype.handler = function () {
- var bbox = this.el.bbox();
- this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
- if (this.rectSelection.isSelected) {
- this.updateRectSelection();
- }
- if (this.pointSelection.isSelected) {
- this.updatePointSelection();
- }
- };
- SelectHandler.prototype.observe = function () {
- var _this = this;
- if (MutationObserver) {
- if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
- this.observerInst = this.observerInst || new MutationObserver(function () {
- _this.handler();
- });
- this.observerInst.observe(this.el.node, {attributes: true});
- } else {
- try {
- this.observerInst.disconnect();
- delete this.observerInst;
- } catch (e) {
- }
- }
- } else {
- this.el.off('DOMAttrModified.select');
- if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
- this.el.on('DOMAttrModified.select', function () {
- _this.handler();
- });
- }
- }
- };
- SelectHandler.prototype.cleanup = function () {
-
- if (!this.rectSelection.isSelected && this.rectSelection.set) {
-
- this.rectSelection.set.each(function () {
- this.remove();
- });
- this.rectSelection.set.clear();
- delete this.rectSelection.set;
- }
- if (!this.pointSelection.isSelected && this.pointSelection.set) {
-
- this.pointSelection.set.each(function () {
- this.remove();
- });
- this.pointSelection.set.clear();
- delete this.pointSelection.set;
- }
- if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
- this.nested.remove();
- delete this.nested;
- }
- };
- SVG.extend(SVG.Element, {
-
- selectize: function (value, options) {
-
- if (typeof value === 'object') {
- options = value;
- value = true;
- }
- var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
- selectHandler.init(value === undefined ? true : value, options || {});
- return this;
- }
- });
- SVG.Element.prototype.selectize.defaults = {
- points: ['lt', 'rt', 'rb', 'lb', 't', 'r', 'b', 'l'],
- pointsExclude: [],
- classRect: 'svg_select_boundingRect',
- classPoints: 'svg_select_points',
- pointSize: 7,
- rotationPoint: true,
- deepSelect: false,
- pointType: 'circle'
- };
- }());
- (function() {
- (function () {
- function ResizeHandler(el) {
- el.remember('_resizeHandler', this);
- this.el = el;
- this.parameters = {};
- this.lastUpdateCall = null;
- this.p = el.doc().node.createSVGPoint();
- }
- ResizeHandler.prototype.transformPoint = function(x, y, m){
- this.p.x = x - (this.offset.x - window.pageXOffset);
- this.p.y = y - (this.offset.y - window.pageYOffset);
- return this.p.matrixTransform(m || this.m);
- };
- ResizeHandler.prototype._extractPosition = function(event) {
-
-
- return {
- x: event.clientX != null ? event.clientX : event.touches[0].clientX,
- y: event.clientY != null ? event.clientY : event.touches[0].clientY
- }
- };
- ResizeHandler.prototype.init = function (options) {
- var _this = this;
- this.stop();
- if (options === 'stop') {
- return;
- }
- this.options = {};
-
- for (var i in this.el.resize.defaults) {
- this.options[i] = this.el.resize.defaults[i];
- if (typeof options[i] !== 'undefined') {
- this.options[i] = options[i];
- }
- }
-
- this.el.on('lt.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('rt.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('rb.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('lb.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('t.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('r.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('b.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('l.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('rot.resize', function(e){ _this.resize(e || window.event); });
- this.el.on('point.resize', function(e){ _this.resize(e || window.event); });
-
- this.update();
- };
- ResizeHandler.prototype.stop = function(){
- this.el.off('lt.resize');
- this.el.off('rt.resize');
- this.el.off('rb.resize');
- this.el.off('lb.resize');
- this.el.off('t.resize');
- this.el.off('r.resize');
- this.el.off('b.resize');
- this.el.off('l.resize');
- this.el.off('rot.resize');
- this.el.off('point.resize');
- return this;
- };
- ResizeHandler.prototype.resize = function (event) {
- var _this = this;
- this.m = this.el.node.getScreenCTM().inverse();
- this.offset = { x: window.pageXOffset, y: window.pageYOffset };
- var txPt = this._extractPosition(event.detail.event);
- this.parameters = {
- type: this.el.type,
- p: this.transformPoint(txPt.x, txPt.y),
- x: event.detail.x,
- y: event.detail.y,
- box: this.el.bbox(),
- rotation: this.el.transform().rotation
- };
-
- if (this.el.type === "text") {
- this.parameters.fontSize = this.el.attr()["font-size"];
- }
-
- if (event.detail.i !== undefined) {
-
- var array = this.el.array().valueOf();
-
- this.parameters.i = event.detail.i;
- this.parameters.pointCoords = [array[event.detail.i][0], array[event.detail.i][1]];
- }
-
- switch (event.type) {
-
- case 'lt':
-
- this.calc = function (diffX, diffY) {
-
-
- var snap = this.snapToGrid(diffX, diffY);
-
- if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
-
-
- if (this.parameters.type === "text") {
- this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
- this.el.attr("font-size", this.parameters.fontSize - snap[0]);
- return;
- }
- snap = this.checkAspectRatio(snap);
- this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y + snap[1]).size(this.parameters.box.width - snap[0], this.parameters.box.height - snap[1]);
- }
- };
- break;
-
- case 'rt':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 1 << 1);
- if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
- if (this.parameters.type === "text") {
- this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
- this.el.attr("font-size", this.parameters.fontSize + snap[0]);
- return;
- }
- snap = this.checkAspectRatio(snap, true);
- this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).size(this.parameters.box.width + snap[0], this.parameters.box.height - snap[1]);
- }
- };
- break;
-
- case 'rb':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 0);
- if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
- if (this.parameters.type === "text") {
- this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
- this.el.attr("font-size", this.parameters.fontSize + snap[0]);
- return;
- }
- snap = this.checkAspectRatio(snap);
- this.el.move(this.parameters.box.x, this.parameters.box.y).size(this.parameters.box.width + snap[0], this.parameters.box.height + snap[1]);
- }
- };
- break;
-
- case 'lb':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 1);
- if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
- if (this.parameters.type === "text") {
- this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
- this.el.attr("font-size", this.parameters.fontSize - snap[0]);
- return;
- }
- snap = this.checkAspectRatio(snap, true);
- this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).size(this.parameters.box.width - snap[0], this.parameters.box.height + snap[1]);
- }
- };
- break;
-
- case 't':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 1 << 1);
- if (this.parameters.box.height - snap[1] > 0) {
-
- if (this.parameters.type === "text") {
- return;
- }
- this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).height(this.parameters.box.height - snap[1]);
- }
- };
- break;
-
- case 'r':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 0);
- if (this.parameters.box.width + snap[0] > 0) {
- if (this.parameters.type === "text") {
- return;
- }
- this.el.move(this.parameters.box.x, this.parameters.box.y).width(this.parameters.box.width + snap[0]);
- }
- };
- break;
-
- case 'b':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 0);
- if (this.parameters.box.height + snap[1] > 0) {
- if (this.parameters.type === "text") {
- return;
- }
- this.el.move(this.parameters.box.x, this.parameters.box.y).height(this.parameters.box.height + snap[1]);
- }
- };
- break;
-
- case 'l':
-
- this.calc = function (diffX, diffY) {
- var snap = this.snapToGrid(diffX, diffY, 1);
- if (this.parameters.box.width - snap[0] > 0) {
- if (this.parameters.type === "text") {
- return;
- }
- this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).width(this.parameters.box.width - snap[0]);
- }
- };
- break;
-
- case 'rot':
-
- this.calc = function (diffX, diffY) {
-
- var current = {x: diffX + this.parameters.p.x, y: diffY + this.parameters.p.y};
-
- var sAngle = Math.atan2((this.parameters.p.y - this.parameters.box.y - this.parameters.box.height / 2), (this.parameters.p.x - this.parameters.box.x - this.parameters.box.width / 2));
-
- var pAngle = Math.atan2((current.y - this.parameters.box.y - this.parameters.box.height / 2), (current.x - this.parameters.box.x - this.parameters.box.width / 2));
- var angle = this.parameters.rotation + (pAngle - sAngle) * 180 / Math.PI + this.options.snapToAngle / 2;
-
-
-
- this.el.center(this.parameters.box.cx, this.parameters.box.cy).rotate(angle - (angle % this.options.snapToAngle), this.parameters.box.cx, this.parameters.box.cy);
- };
- break;
-
- case 'point':
- this.calc = function (diffX, diffY) {
-
- var snap = this.snapToGrid(diffX, diffY, this.parameters.pointCoords[0], this.parameters.pointCoords[1]);
-
- var array = this.el.array().valueOf();
-
- array[this.parameters.i][0] = this.parameters.pointCoords[0] + snap[0];
- array[this.parameters.i][1] = this.parameters.pointCoords[1] + snap[1];
-
- this.el.plot(array);
- };
- }
- this.el.fire('resizestart', {dx: this.parameters.x, dy: this.parameters.y, event: event});
-
-
- SVG.on(window, 'touchmove.resize', function(e) {
- _this.update(e || window.event);
- });
- SVG.on(window, 'touchend.resize', function() {
- _this.done();
- });
-
- SVG.on(window, 'mousemove.resize', function (e) {
- _this.update(e || window.event);
- });
- SVG.on(window, 'mouseup.resize', function () {
- _this.done();
- });
- };
-
- ResizeHandler.prototype.update = function (event) {
- if (!event) {
- if (this.lastUpdateCall) {
- this.calc(this.lastUpdateCall[0], this.lastUpdateCall[1]);
- }
- return;
- }
-
- var txPt = this._extractPosition(event);
- var p = this.transformPoint(txPt.x, txPt.y);
- var diffX = p.x - this.parameters.p.x,
- diffY = p.y - this.parameters.p.y;
- this.lastUpdateCall = [diffX, diffY];
-
- this.calc(diffX, diffY);
-
- this.el.fire('resizing', {dx: diffX, dy: diffY, event: event});
- };
-
-
- ResizeHandler.prototype.done = function () {
- this.lastUpdateCall = null;
- SVG.off(window, 'mousemove.resize');
- SVG.off(window, 'mouseup.resize');
- SVG.off(window, 'touchmove.resize');
- SVG.off(window, 'touchend.resize');
- this.el.fire('resizedone');
- };
-
-
- ResizeHandler.prototype.snapToGrid = function (diffX, diffY, flag, pointCoordsY) {
- var temp;
-
- if (typeof pointCoordsY !== 'undefined') {
-
- temp = [(flag + diffX) % this.options.snapToGrid, (pointCoordsY + diffY) % this.options.snapToGrid];
- } else {
-
- flag = flag == null ? 1 | 1 << 1 : flag;
- temp = [(this.parameters.box.x + diffX + (flag & 1 ? 0 : this.parameters.box.width)) % this.options.snapToGrid, (this.parameters.box.y + diffY + (flag & (1 << 1) ? 0 : this.parameters.box.height)) % this.options.snapToGrid];
- }
- if(diffX < 0) {
- temp[0] -= this.options.snapToGrid;
- }
- if(diffY < 0) {
- temp[1] -= this.options.snapToGrid;
- }
- diffX -= (Math.abs(temp[0]) < this.options.snapToGrid / 2 ?
- temp[0] :
- temp[0] - (diffX < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
- diffY -= (Math.abs(temp[1]) < this.options.snapToGrid / 2 ?
- temp[1] :
- temp[1] - (diffY < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
- return this.constraintToBox(diffX, diffY, flag, pointCoordsY);
- };
-
- ResizeHandler.prototype.constraintToBox = function (diffX, diffY, flag, pointCoordsY) {
-
- var c = this.options.constraint || {};
- var orgX, orgY;
- if (typeof pointCoordsY !== 'undefined') {
- orgX = flag;
- orgY = pointCoordsY;
- } else {
- orgX = this.parameters.box.x + (flag & 1 ? 0 : this.parameters.box.width);
- orgY = this.parameters.box.y + (flag & (1<<1) ? 0 : this.parameters.box.height);
- }
- if (typeof c.minX !== 'undefined' && orgX + diffX < c.minX) {
- diffX = c.minX - orgX;
- }
- if (typeof c.maxX !== 'undefined' && orgX + diffX > c.maxX) {
- diffX = c.maxX - orgX;
- }
- if (typeof c.minY !== 'undefined' && orgY + diffY < c.minY) {
- diffY = c.minY - orgY;
- }
- if (typeof c.maxY !== 'undefined' && orgY + diffY > c.maxY) {
- diffY = c.maxY - orgY;
- }
- return [diffX, diffY];
- };
- ResizeHandler.prototype.checkAspectRatio = function (snap, isReverse) {
- if (!this.options.saveAspectRatio) {
- return snap;
- }
- var updatedSnap = snap.slice();
- var aspectRatio = this.parameters.box.width / this.parameters.box.height;
- var newW = this.parameters.box.width + snap[0];
- var newH = this.parameters.box.height - snap[1];
- var newAspectRatio = newW / newH;
- if (newAspectRatio < aspectRatio) {
-
- updatedSnap[1] = newW / aspectRatio - this.parameters.box.height;
- isReverse && (updatedSnap[1] = -updatedSnap[1]);
- } else if (newAspectRatio > aspectRatio) {
-
- updatedSnap[0] = this.parameters.box.width - newH * aspectRatio;
- isReverse && (updatedSnap[0] = -updatedSnap[0]);
- }
- return updatedSnap;
- };
- SVG.extend(SVG.Element, {
-
- resize: function (options) {
- (this.remember('_resizeHandler') || new ResizeHandler(this)).init(options || {});
- return this;
- }
- });
- SVG.Element.prototype.resize.defaults = {
- snapToAngle: 0.1,
- snapToGrid: 1,
- constraint: {},
- saveAspectRatio: false
- };
- }).call(this);
- }());
- function styleInject(css, ref) {
- if ( ref === void 0 ) ref = {};
- var insertAt = ref.insertAt;
- if (!css || typeof document === 'undefined') { return; }
- var head = document.head || document.getElementsByTagName('head')[0];
- var style = document.createElement('style');
- style.type = 'text/css';
- if (insertAt === 'top') {
- if (head.firstChild) {
- head.insertBefore(style, head.firstChild);
- } else {
- head.appendChild(style);
- }
- } else {
- head.appendChild(style);
- }
- if (style.styleSheet) {
- style.styleSheet.cssText = css;
- } else {
- style.appendChild(document.createTextNode(css));
- }
- }
- var css = ".apexcharts-canvas {\n position: relative;\n user-select: none;\n /* cannot give overflow: hidden as it will crop tooltips which overflow outside chart area */\n}\n\n\n/* scrollbar is not visible by default for legend, hence forcing the visibility */\n.apexcharts-canvas ::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 6px;\n}\n\n.apexcharts-canvas ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0, 0, 0, .5);\n box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n}\n\n.apexcharts-canvas.apexcharts-theme-dark {\n background: #343F57;\n}\n\n.apexcharts-inner {\n position: relative;\n}\n\n.apexcharts-text tspan {\n font-family: inherit;\n}\n\n.legend-mouseover-inactive {\n transition: 0.15s ease all;\n opacity: 0.20;\n}\n\n.apexcharts-series-collapsed {\n opacity: 0;\n}\n\n.apexcharts-tooltip {\n border-radius: 5px;\n box-shadow: 2px 2px 6px -4px #999;\n cursor: default;\n font-size: 14px;\n left: 62px;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n top: 20px;\n overflow: hidden;\n white-space: nowrap;\n z-index: 12;\n transition: 0.15s ease all;\n}\n\n.apexcharts-tooltip.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-tooltip.apexcharts-theme-light {\n border: 1px solid #e3e3e3;\n background: rgba(255, 255, 255, 0.96);\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark {\n color: #fff;\n background: rgba(30, 30, 30, 0.8);\n}\n\n.apexcharts-tooltip * {\n font-family: inherit;\n}\n\n\n.apexcharts-tooltip-title {\n padding: 6px;\n font-size: 15px;\n margin-bottom: 4px;\n}\n\n.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title {\n background: #ECEFF1;\n border-bottom: 1px solid #ddd;\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title {\n background: rgba(0, 0, 0, 0.7);\n border-bottom: 1px solid #333;\n}\n\n.apexcharts-tooltip-text-value,\n.apexcharts-tooltip-text-z-value {\n display: inline-block;\n font-weight: 600;\n margin-left: 5px;\n}\n\n.apexcharts-tooltip-text-z-label:empty,\n.apexcharts-tooltip-text-z-value:empty {\n display: none;\n}\n\n.apexcharts-tooltip-text-value,\n.apexcharts-tooltip-text-z-value {\n font-weight: 600;\n}\n\n.apexcharts-tooltip-marker {\n width: 12px;\n height: 12px;\n position: relative;\n top: 0px;\n margin-right: 10px;\n border-radius: 50%;\n}\n\n.apexcharts-tooltip-series-group {\n padding: 0 10px;\n display: none;\n text-align: left;\n justify-content: left;\n align-items: center;\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active .apexcharts-tooltip-marker {\n opacity: 1;\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active,\n.apexcharts-tooltip-series-group:last-child {\n padding-bottom: 4px;\n}\n\n.apexcharts-tooltip-series-group-hidden {\n opacity: 0;\n height: 0;\n line-height: 0;\n padding: 0 !important;\n}\n\n.apexcharts-tooltip-y-group {\n padding: 6px 0 5px;\n}\n\n.apexcharts-tooltip-candlestick {\n padding: 4px 8px;\n}\n\n.apexcharts-tooltip-candlestick>div {\n margin: 4px 0;\n}\n\n.apexcharts-tooltip-candlestick span.value {\n font-weight: bold;\n}\n\n.apexcharts-tooltip-rangebar {\n padding: 5px 8px;\n}\n\n.apexcharts-tooltip-rangebar .category {\n font-weight: 600;\n color: #777;\n}\n\n.apexcharts-tooltip-rangebar .series-name {\n font-weight: bold;\n display: block;\n margin-bottom: 5px;\n}\n\n.apexcharts-xaxistooltip {\n opacity: 0;\n padding: 9px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #ECEFF1;\n border: 1px solid #90A4AE;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xaxistooltip.apexcharts-theme-dark {\n background: rgba(0, 0, 0, 0.7);\n border: 1px solid rgba(0, 0, 0, 0.5);\n color: #fff;\n}\n\n.apexcharts-xaxistooltip:after,\n.apexcharts-xaxistooltip:before {\n left: 50%;\n border: solid transparent;\n content: \" \";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n}\n\n.apexcharts-xaxistooltip:after {\n border-color: rgba(236, 239, 241, 0);\n border-width: 6px;\n margin-left: -6px;\n}\n\n.apexcharts-xaxistooltip:before {\n border-color: rgba(144, 164, 174, 0);\n border-width: 7px;\n margin-left: -7px;\n}\n\n.apexcharts-xaxistooltip-bottom:after,\n.apexcharts-xaxistooltip-bottom:before {\n bottom: 100%;\n}\n\n.apexcharts-xaxistooltip-top:after,\n.apexcharts-xaxistooltip-top:before {\n top: 100%;\n}\n\n.apexcharts-xaxistooltip-bottom:after {\n border-bottom-color: #ECEFF1;\n}\n\n.apexcharts-xaxistooltip-bottom:before {\n border-bottom-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:after {\n border-bottom-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:before {\n border-bottom-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-top:after {\n border-top-color: #ECEFF1\n}\n\n.apexcharts-xaxistooltip-top:before {\n border-top-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:after {\n border-top-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:before {\n border-top-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-yaxistooltip {\n opacity: 0;\n padding: 4px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #ECEFF1;\n border: 1px solid #90A4AE;\n}\n\n.apexcharts-yaxistooltip.apexcharts-theme-dark {\n background: rgba(0, 0, 0, 0.7);\n border: 1px solid rgba(0, 0, 0, 0.5);\n color: #fff;\n}\n\n.apexcharts-yaxistooltip:after,\n.apexcharts-yaxistooltip:before {\n top: 50%;\n border: solid transparent;\n content: \" \";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n}\n\n.apexcharts-yaxistooltip:after {\n border-color: rgba(236, 239, 241, 0);\n border-width: 6px;\n margin-top: -6px;\n}\n\n.apexcharts-yaxistooltip:before {\n border-color: rgba(144, 164, 174, 0);\n border-width: 7px;\n margin-top: -7px;\n}\n\n.apexcharts-yaxistooltip-left:after,\n.apexcharts-yaxistooltip-left:before {\n left: 100%;\n}\n\n.apexcharts-yaxistooltip-right:after,\n.apexcharts-yaxistooltip-right:before {\n right: 100%;\n}\n\n.apexcharts-yaxistooltip-left:after {\n border-left-color: #ECEFF1;\n}\n\n.apexcharts-yaxistooltip-left:before {\n border-left-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:after {\n border-left-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:before {\n border-left-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-right:after {\n border-right-color: #ECEFF1;\n}\n\n.apexcharts-yaxistooltip-right:before {\n border-right-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:after {\n border-right-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:before {\n border-right-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip.apexcharts-active {\n opacity: 1;\n}\n\n.apexcharts-yaxistooltip-hidden {\n display: none;\n}\n\n.apexcharts-xcrosshairs,\n.apexcharts-ycrosshairs {\n pointer-events: none;\n opacity: 0;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xcrosshairs.apexcharts-active,\n.apexcharts-ycrosshairs.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-ycrosshairs-hidden {\n opacity: 0;\n}\n\n.apexcharts-selection-rect {\n cursor: move;\n}\n\n.svg_select_boundingRect, .svg_select_points_rot {\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n}\n.apexcharts-selection-rect + g .svg_select_boundingRect,\n.apexcharts-selection-rect + g .svg_select_points_rot {\n opacity: 0;\n visibility: hidden;\n}\n\n.apexcharts-selection-rect + g .svg_select_points_l,\n.apexcharts-selection-rect + g .svg_select_points_r {\n cursor: ew-resize;\n opacity: 1;\n visibility: visible;\n}\n\n.svg_select_points {\n fill: #efefef;\n stroke: #333;\n rx: 2;\n}\n\n.apexcharts-canvas.apexcharts-zoomable .hovering-zoom {\n cursor: crosshair\n}\n\n.apexcharts-canvas.apexcharts-zoomable .hovering-pan {\n cursor: move\n}\n\n.apexcharts-zoom-icon,\n.apexcharts-zoomin-icon,\n.apexcharts-zoomout-icon,\n.apexcharts-reset-icon,\n.apexcharts-pan-icon,\n.apexcharts-selection-icon,\n.apexcharts-menu-icon,\n.apexcharts-toolbar-custom-icon {\n cursor: pointer;\n width: 20px;\n height: 20px;\n line-height: 24px;\n color: #6E8192;\n text-align: center;\n}\n\n.apexcharts-zoom-icon svg,\n.apexcharts-zoomin-icon svg,\n.apexcharts-zoomout-icon svg,\n.apexcharts-reset-icon svg,\n.apexcharts-menu-icon svg {\n fill: #6E8192;\n}\n\n.apexcharts-selection-icon svg {\n fill: #444;\n transform: scale(0.76)\n}\n\n.apexcharts-theme-dark .apexcharts-zoom-icon svg,\n.apexcharts-theme-dark .apexcharts-zoomin-icon svg,\n.apexcharts-theme-dark .apexcharts-zoomout-icon svg,\n.apexcharts-theme-dark .apexcharts-reset-icon svg,\n.apexcharts-theme-dark .apexcharts-pan-icon svg,\n.apexcharts-theme-dark .apexcharts-selection-icon svg,\n.apexcharts-theme-dark .apexcharts-menu-icon svg,\n.apexcharts-theme-dark .apexcharts-toolbar-custom-icon svg {\n fill: #f3f4f5;\n}\n\n.apexcharts-canvas .apexcharts-zoom-icon.apexcharts-selected svg,\n.apexcharts-canvas .apexcharts-selection-icon.apexcharts-selected svg,\n.apexcharts-canvas .apexcharts-reset-zoom-icon.apexcharts-selected svg {\n fill: #008FFB;\n}\n\n.apexcharts-theme-light .apexcharts-selection-icon:not(.apexcharts-selected):hover svg,\n.apexcharts-theme-light .apexcharts-zoom-icon:not(.apexcharts-selected):hover svg,\n.apexcharts-theme-light .apexcharts-zoomin-icon:hover svg,\n.apexcharts-theme-light .apexcharts-zoomout-icon:hover svg,\n.apexcharts-theme-light .apexcharts-reset-icon:hover svg,\n.apexcharts-theme-light .apexcharts-menu-icon:hover svg {\n fill: #333;\n}\n\n.apexcharts-selection-icon,\n.apexcharts-menu-icon {\n position: relative;\n}\n\n.apexcharts-reset-icon {\n margin-left: 5px;\n}\n\n.apexcharts-zoom-icon,\n.apexcharts-reset-icon,\n.apexcharts-menu-icon {\n transform: scale(0.85);\n}\n\n.apexcharts-zoomin-icon,\n.apexcharts-zoomout-icon {\n transform: scale(0.7)\n}\n\n.apexcharts-zoomout-icon {\n margin-right: 3px;\n}\n\n.apexcharts-pan-icon {\n transform: scale(0.62);\n position: relative;\n left: 1px;\n top: 0px;\n}\n\n.apexcharts-pan-icon svg {\n fill: #fff;\n stroke: #6E8192;\n stroke-width: 2;\n}\n\n.apexcharts-pan-icon.apexcharts-selected svg {\n stroke: #008FFB;\n}\n\n.apexcharts-pan-icon:not(.apexcharts-selected):hover svg {\n stroke: #333;\n}\n\n.apexcharts-toolbar {\n position: absolute;\n z-index: 11;\n max-width: 176px;\n text-align: right;\n border-radius: 3px;\n padding: 0px 6px 2px 6px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.apexcharts-menu {\n background: #fff;\n position: absolute;\n top: 100%;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 3px;\n right: 10px;\n opacity: 0;\n min-width: 110px;\n transition: 0.15s ease all;\n pointer-events: none;\n}\n\n.apexcharts-menu.apexcharts-menu-open {\n opacity: 1;\n pointer-events: all;\n transition: 0.15s ease all;\n}\n\n.apexcharts-menu-item {\n padding: 6px 7px;\n font-size: 12px;\n cursor: pointer;\n}\n\n.apexcharts-theme-light .apexcharts-menu-item:hover {\n background: #eee;\n}\n\n.apexcharts-theme-dark .apexcharts-menu {\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n}\n\n@media screen and (min-width: 768px) {\n .apexcharts-canvas:hover .apexcharts-toolbar {\n opacity: 1;\n }\n}\n\n.apexcharts-datalabel.apexcharts-element-hidden {\n opacity: 0;\n}\n\n.apexcharts-pie-label,\n.apexcharts-datalabels,\n.apexcharts-datalabel,\n.apexcharts-datalabel-label,\n.apexcharts-datalabel-value {\n cursor: default;\n pointer-events: none;\n}\n\n.apexcharts-pie-label-delay {\n opacity: 0;\n animation-name: opaque;\n animation-duration: 0.3s;\n animation-fill-mode: forwards;\n animation-timing-function: ease;\n}\n\n.apexcharts-canvas .apexcharts-element-hidden {\n opacity: 0;\n}\n\n.apexcharts-hide .apexcharts-series-points {\n opacity: 0;\n}\n\n.apexcharts-gridline,\n.apexcharts-annotation-rect,\n.apexcharts-tooltip .apexcharts-marker,\n.apexcharts-area-series .apexcharts-area,\n.apexcharts-line,\n.apexcharts-zoom-rect,\n.apexcharts-toolbar svg,\n.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\n.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\n.apexcharts-radar-series path,\n.apexcharts-radar-series polygon {\n pointer-events: none;\n}\n\n\n/* markers */\n\n.apexcharts-marker {\n transition: 0.15s ease all;\n}\n\n@keyframes opaque {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n\n/* Resize generated styles */\n\n@keyframes resizeanim {\n from {\n opacity: 0;\n }\n to {\n opacity: 0;\n }\n}\n\n.resize-triggers {\n animation: 1ms resizeanim;\n visibility: hidden;\n opacity: 0;\n}\n\n.resize-triggers,\n.resize-triggers>div,\n.contract-trigger:before {\n content: \" \";\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n overflow: hidden;\n}\n\n.resize-triggers>div {\n background: #eee;\n overflow: auto;\n}\n\n.contract-trigger:before {\n width: 200%;\n height: 200%;\n}";
- styleInject(css);
-
- (function () {
- function resetTriggers(element) {
- var triggers = element.__resizeTriggers__,
- expand = triggers.firstElementChild,
- contract = triggers.lastElementChild,
- expandChild = expand ? expand.firstElementChild : null;
- if (contract) {
- contract.scrollLeft = contract.scrollWidth;
- contract.scrollTop = contract.scrollHeight;
- }
- if (expandChild) {
- expandChild.style.width = expand.offsetWidth + 1 + 'px';
- expandChild.style.height = expand.offsetHeight + 1 + 'px';
- }
- if (expand) {
- expand.scrollLeft = expand.scrollWidth;
- expand.scrollTop = expand.scrollHeight;
- }
- }
- function checkTriggers(element) {
- return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
- }
- function scrollListener(e) {
- var element = this;
- resetTriggers(this);
- if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
- this.__resizeRAF__ = requestFrame(function () {
- if (checkTriggers(element)) {
- element.__resizeLast__.width = element.offsetWidth;
- element.__resizeLast__.height = element.offsetHeight;
- element.__resizeListeners__.forEach(function (fn) {
- fn.call(e);
- });
- }
- });
- }
- var requestFrame = function () {
- var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
- return window.setTimeout(fn, 20);
- };
- return function (fn) {
- return raf(fn);
- };
- }();
- var cancelFrame = function () {
- var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.clearTimeout;
- return function (id) {
- return cancel(id);
- };
- }();
-
- var animation = false,
- animationstartevent = 'animationstart',
- domPrefixes = 'Webkit Moz O ms'.split(' '),
- startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' ');
- {
- var elm = document.createElement('fakeelement');
- if (elm.style.animationName !== undefined) {
- animation = true;
- }
- if (animation === false) {
- for (var i = 0; i < domPrefixes.length; i++) {
- if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
- animationstartevent = startEvents[i];
- break;
- }
- }
- }
- }
- var animationName = 'resizeanim';
- window.addResizeListener = function (element, fn) {
- if (!element.__resizeTriggers__) {
- if (getComputedStyle(element).position == 'static') element.style.position = 'relative';
- element.__resizeLast__ = {};
- element.__resizeListeners__ = [];
- (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
- element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
- element.appendChild(element.__resizeTriggers__);
- resetTriggers(element);
- element.addEventListener('scroll', scrollListener, true);
-
- animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
- if (e.animationName == animationName) {
- resetTriggers(element);
- }
- });
- }
- element.__resizeListeners__.push(fn);
- };
- window.removeResizeListener = function (element, fn) {
- if (element) {
- element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
- if (!element.__resizeListeners__.length) {
- element.removeEventListener('scroll', scrollListener);
- if (element.__resizeTriggers__.parentNode) {
- element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
- }
- }
- }
- };
- })();
- window.Apex = {};
- var InitCtxVariables = function () {
- function InitCtxVariables(ctx) {
- _classCallCheck(this, InitCtxVariables);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(InitCtxVariables, [{
- key: "initModules",
- value: function initModules() {
- this.ctx.publicMethods = ['updateOptions', 'updateSeries', 'appendData', 'appendSeries', 'toggleSeries', 'showSeries', 'hideSeries', 'setLocale', 'resetSeries', 'toggleDataPointSelection', 'dataURI', 'addXaxisAnnotation', 'addYaxisAnnotation', 'addPointAnnotation', 'clearAnnotations', 'removeAnnotation', 'paper', 'destroy'];
- this.ctx.eventList = ['click', 'mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
- this.ctx.animations = new Animations(this.ctx);
- this.ctx.axes = new Axes(this.ctx);
- this.ctx.core = new Core(this.ctx.el, this.ctx);
- this.ctx.config = new Config({});
- this.ctx.data = new Data(this.ctx);
- this.ctx.grid = new Grid(this.ctx);
- this.ctx.graphics = new Graphics(this.ctx);
- this.ctx.coreUtils = new CoreUtils(this.ctx);
- this.ctx.crosshairs = new Crosshairs(this.ctx);
- this.ctx.events = new Events(this.ctx);
- this.ctx.exports = new Exports(this.ctx);
- this.ctx.localization = new Localization(this.ctx);
- this.ctx.options = new Options();
- this.ctx.responsive = new Responsive(this.ctx);
- this.ctx.series = new Series(this.ctx);
- this.ctx.theme = new Theme(this.ctx);
- this.ctx.formatters = new Formatters(this.ctx);
- this.ctx.titleSubtitle = new TitleSubtitle(this.ctx);
- this.ctx.legend = new Legend(this.ctx);
- this.ctx.toolbar = new Toolbar(this.ctx);
- this.ctx.dimensions = new Dimensions(this.ctx);
- this.ctx.updateHelpers = new UpdateHelpers(this.ctx);
- this.ctx.zoomPanSelection = new ZoomPanSelection(this.ctx);
- this.ctx.w.globals.tooltip = new Tooltip(this.ctx);
- }
- }]);
- return InitCtxVariables;
- }();
- var Destroy = function () {
- function Destroy(ctx) {
- _classCallCheck(this, Destroy);
- this.ctx = ctx;
- this.w = ctx.w;
- }
- _createClass(Destroy, [{
- key: "clear",
- value: function clear() {
- if (this.ctx.zoomPanSelection) {
- this.ctx.zoomPanSelection.destroy();
- }
- if (this.ctx.toolbar) {
- this.ctx.toolbar.destroy();
- }
- this.ctx.animations = null;
- this.ctx.axes = null;
- this.ctx.annotations = null;
- this.ctx.core = null;
- this.ctx.data = null;
- this.ctx.grid = null;
- this.ctx.series = null;
- this.ctx.responsive = null;
- this.ctx.theme = null;
- this.ctx.formatters = null;
- this.ctx.titleSubtitle = null;
- this.ctx.legend = null;
- this.ctx.dimensions = null;
- this.ctx.options = null;
- this.ctx.crosshairs = null;
- this.ctx.zoomPanSelection = null;
- this.ctx.updateHelpers = null;
- this.ctx.toolbar = null;
- this.ctx.localization = null;
- this.ctx.w.globals.tooltip = null;
- this.clearDomElements();
- }
- }, {
- key: "killSVG",
- value: function killSVG(draw) {
- draw.each(function (i, children) {
- this.removeClass('*');
- this.off();
- this.stop();
- }, true);
- draw.ungroup();
- draw.clear();
- }
- }, {
- key: "clearDomElements",
- value: function clearDomElements() {
- var _this = this;
-
- this.ctx.eventList.forEach(function (event) {
- document.removeEventListener(event, _this.ctx.events.documentEvent);
- });
- var domEls = this.w.globals.dom;
- if (this.ctx.el !== null) {
-
- while (this.ctx.el.firstChild) {
- this.ctx.el.removeChild(this.ctx.el.firstChild);
- }
- }
- this.killSVG(domEls.Paper);
- domEls.Paper.remove();
- domEls.elWrap = null;
- domEls.elGraphical = null;
- domEls.elAnnotations = null;
- domEls.elLegendWrap = null;
- domEls.baseEl = null;
- domEls.elGridRect = null;
- domEls.elGridRectMask = null;
- domEls.elGridRectMarkerMask = null;
- domEls.elDefs = null;
- }
- }]);
- return Destroy;
- }();
-
- var ApexCharts$1 = function () {
- function ApexCharts(el, opts) {
- _classCallCheck(this, ApexCharts);
- this.opts = opts;
- this.ctx = this;
- this.w = new Base(opts).init();
- this.el = el;
- this.w.globals.cuid = Utils.randomId();
- this.w.globals.chartID = this.w.config.chart.id ? this.w.config.chart.id : this.w.globals.cuid;
- var initCtx = new InitCtxVariables(this);
- initCtx.initModules();
- this.create = Utils.bind(this.create, this);
- this.windowResizeHandler = this._windowResize.bind(this);
- }
-
- _createClass(ApexCharts, [{
- key: "render",
- value: function render() {
- var _this = this;
-
- return new Promise(function (resolve, reject) {
-
- if (_this.el !== null) {
- if (typeof Apex._chartInstances === 'undefined') {
- Apex._chartInstances = [];
- }
- if (_this.w.config.chart.id) {
- Apex._chartInstances.push({
- id: _this.w.globals.chartID,
- group: _this.w.config.chart.group,
- chart: _this
- });
- }
- _this.setLocale(_this.w.config.chart.defaultLocale);
- var beforeMount = _this.w.config.chart.events.beforeMount;
- if (typeof beforeMount === 'function') {
- beforeMount(_this, _this.w);
- }
- _this.events.fireEvent('beforeMount', [_this, _this.w]);
- window.addEventListener('resize', _this.windowResizeHandler);
- window.addResizeListener(_this.el.parentNode, _this._parentResizeCallback.bind(_this));
- var graphData = _this.create(_this.w.config.series, {});
- if (!graphData) return resolve(_this);
- _this.mount(graphData).then(function () {
- if (typeof _this.w.config.chart.events.mounted === 'function') {
- _this.w.config.chart.events.mounted(_this, _this.w);
- }
- _this.events.fireEvent('mounted', [_this, _this.w]);
- resolve(graphData);
- }).catch(function (e) {
- reject(e);
- });
- } else {
- reject(new Error('Element not found'));
- }
- });
- }
- }, {
- key: "create",
- value: function create(ser, opts) {
- var w = this.w;
- var initCtx = new InitCtxVariables(this);
- initCtx.initModules();
- var gl = this.w.globals;
- gl.noData = false;
- gl.animationEnded = false;
- this.responsive.checkResponsiveConfig(opts);
- if (w.config.xaxis.convertedCatToNumeric) {
- var defaults = new Defaults(w.config);
- defaults.convertCatToNumericXaxis(w.config, this.ctx);
- }
- if (this.el === null) {
- gl.animationEnded = true;
- return null;
- }
- this.core.setupElements();
- if (gl.svgWidth === 0) {
-
- gl.animationEnded = true;
- return null;
- }
- var combo = CoreUtils.checkComboSeries(ser);
- gl.comboCharts = combo.comboCharts;
- gl.comboBarCount = combo.comboBarCount;
- if (ser.length === 0 || ser.length === 1 && ser[0].data && ser[0].data.length === 0) {
- this.series.handleNoData();
- }
- this.events.setupEventHandlers();
- this.data.parseData(ser);
- this.theme.init();
- var markers = new Markers(this);
- markers.setGlobalMarkerSize();
- this.formatters.setLabelFormatters();
- this.titleSubtitle.draw();
-
- if (!gl.noData || gl.collapsedSeries.length === gl.series.length) {
- this.legend.init();
- }
- this.series.hasAllSeriesEqualX();
- if (gl.axisCharts) {
- this.core.coreCalculations();
- if (w.config.xaxis.type !== 'category') {
-
- this.formatters.setLabelFormatters();
- }
- }
-
- this.formatters.heatmapLabelFormatters();
- this.dimensions.plotCoords();
- var xyRatios = this.core.xySettings();
- this.grid.createGridMask();
- var elGraph = this.core.plotChartType(ser, xyRatios);
- var dataLabels = new DataLabels(this);
- dataLabels.bringForward();
- if (w.config.dataLabels.background.enabled) {
- dataLabels.dataLabelsBackground();
- }
- this.core.shiftGraphPosition();
- var dim = {
- plot: {
- left: w.globals.translateX,
- top: w.globals.translateY,
- width: w.globals.gridWidth,
- height: w.globals.gridHeight
- }
- };
- return {
- elGraph: elGraph,
- xyRatios: xyRatios,
- elInner: w.globals.dom.elGraphical,
- dimensions: dim
- };
- }
- }, {
- key: "mount",
- value: function mount() {
- var _this2 = this;
- var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var me = this;
- var w = me.w;
- return new Promise(function (resolve, reject) {
-
- if (me.el === null) {
- return reject(new Error('Not enough data to display or target element not found'));
- } else if (graphData === null || w.globals.allSeriesCollapsed) {
- me.series.handleNoData();
- }
- me.axes.drawAxis(w.config.chart.type, graphData.xyRatios);
- me.grid = new Grid(me);
- var elgrid = me.grid.drawGrid();
- me.annotations = new Annotations(me);
- me.annotations.drawShapeAnnos();
- me.annotations.drawImageAnnos();
- me.annotations.drawTextAnnos();
- if (w.config.grid.position === 'back' && elgrid) {
- w.globals.dom.elGraphical.add(elgrid.el);
- }
- var xAxis = new XAxis(_this2.ctx);
- var yaxis = new YAxis(_this2.ctx);
- if (elgrid !== null) {
- xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth);
- yaxis.setYAxisTextAlignments();
- }
- if (w.config.annotations.position === 'back') {
- w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
- me.annotations.drawAxesAnnotations();
- }
- if (graphData.elGraph instanceof Array) {
- for (var g = 0; g < graphData.elGraph.length; g++) {
- w.globals.dom.elGraphical.add(graphData.elGraph[g]);
- }
- } else {
- w.globals.dom.elGraphical.add(graphData.elGraph);
- }
- if (w.config.grid.position === 'front' && elgrid) {
- w.globals.dom.elGraphical.add(elgrid.el);
- }
- if (w.config.xaxis.crosshairs.position === 'front') {
- me.crosshairs.drawXCrosshairs();
- }
- if (w.config.yaxis[0].crosshairs.position === 'front') {
- me.crosshairs.drawYCrosshairs();
- }
- if (w.config.annotations.position === 'front') {
- w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
- me.annotations.drawAxesAnnotations();
- }
- if (!w.globals.noData) {
-
- if (w.config.tooltip.enabled && !w.globals.noData) {
- me.w.globals.tooltip.drawTooltip(graphData.xyRatios);
- }
- if (w.globals.axisCharts && (w.globals.isXNumeric || w.config.xaxis.convertedCatToNumeric)) {
- if (w.config.chart.zoom.enabled || w.config.chart.selection && w.config.chart.selection.enabled || w.config.chart.pan && w.config.chart.pan.enabled) {
- me.zoomPanSelection.init({
- xyRatios: graphData.xyRatios
- });
- }
- } else {
- var tools = w.config.chart.toolbar.tools;
- var toolsArr = ['zoom', 'zoomin', 'zoomout', 'selection', 'pan', 'reset'];
- toolsArr.forEach(function (t) {
- tools[t] = false;
- });
- }
- if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) {
- me.toolbar.createToolbar();
- }
- }
- if (w.globals.memory.methodsToExec.length > 0) {
- w.globals.memory.methodsToExec.forEach(function (fn) {
- fn.method(fn.params, false, fn.context);
- });
- }
- if (!w.globals.axisCharts && !w.globals.noData) {
- me.core.resizeNonAxisCharts();
- }
- resolve(me);
- });
- }
-
- }, {
- key: "destroy",
- value: function destroy() {
- window.removeEventListener('resize', this.windowResizeHandler);
- window.removeResizeListener(this.el.parentNode, this._parentResizeCallback.bind(this));
- var chartID = this.w.config.chart.id;
- if (chartID) {
- Apex._chartInstances.forEach(function (c, i) {
- if (c.id === chartID) {
- Apex._chartInstances.splice(i, 1);
- }
- });
- }
- new Destroy(this.ctx).clear();
- }
-
- }, {
- key: "updateOptions",
- value: function updateOptions(options) {
- var _this3 = this;
- var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
- var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
- var w = this.w;
- if (options.series) {
- this.series.resetSeries(false, true, false);
- if (options.series.length && options.series[0].data) {
- options.series = options.series.map(function (s, i) {
- return _this3.updateHelpers._extendSeries(s, i);
- });
- }
-
- this.updateHelpers.revertDefaultAxisMinMax();
- }
- if (options.xaxis) {
- options = this.updateHelpers.forceXAxisUpdate(options);
- }
- if (options.yaxis) {
- options = this.updateHelpers.forceYAxisUpdate(options);
- }
- if (w.globals.collapsedSeriesIndices.length > 0) {
- this.series.clearPreviousPaths();
- }
-
- if (options.theme) {
- options = this.theme.updateThemeOptions(options);
- }
- return this.updateHelpers._updateOptions(options, redraw, animate, updateSyncedCharts, overwriteInitialConfig);
- }
-
- }, {
- key: "updateSeries",
- value: function updateSeries() {
- var newSeries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- this.series.resetSeries(false);
- this.updateHelpers.revertDefaultAxisMinMax();
- return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
- }
-
- }, {
- key: "appendSeries",
- value: function appendSeries(newSerie) {
- var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var newSeries = this.w.config.series.slice();
- newSeries.push(newSerie);
- this.series.resetSeries(false);
- this.updateHelpers.revertDefaultAxisMinMax();
- return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
- }
-
- }, {
- key: "appendData",
- value: function appendData(newData) {
- var overwriteInitialSeries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var me = this;
- me.w.globals.dataChanged = true;
- me.series.getPreviousPaths();
- var newSeries = me.w.config.series.slice();
- for (var i = 0; i < newSeries.length; i++) {
- if (typeof newData[i] !== 'undefined') {
- for (var j = 0; j < newData[i].data.length; j++) {
- newSeries[i].data.push(newData[i].data[j]);
- }
- }
- }
- me.w.config.series = newSeries;
- if (overwriteInitialSeries) {
- me.w.globals.initialSeries = JSON.parse(JSON.stringify(me.w.config.series));
- }
- return this.update();
- }
- }, {
- key: "update",
- value: function update(options) {
- var _this4 = this;
- return new Promise(function (resolve, reject) {
- new Destroy(_this4.ctx).clear();
- var graphData = _this4.create(_this4.w.config.series, options);
- if (!graphData) return resolve(_this4);
- _this4.mount(graphData).then(function () {
- if (typeof _this4.w.config.chart.events.updated === 'function') {
- _this4.w.config.chart.events.updated(_this4, _this4.w);
- }
- _this4.events.fireEvent('updated', [_this4, _this4.w]);
- _this4.w.globals.isDirty = true;
- resolve(_this4);
- }).catch(function (e) {
- reject(e);
- });
- });
- }
-
- }, {
- key: "getSyncedCharts",
- value: function getSyncedCharts() {
- var chartGroups = this.getGroupedCharts();
- var allCharts = [this];
- if (chartGroups.length) {
- allCharts = [];
- chartGroups.forEach(function (ch) {
- allCharts.push(ch);
- });
- }
- return allCharts;
- }
-
- }, {
- key: "getGroupedCharts",
- value: function getGroupedCharts() {
- var _this5 = this;
- return Apex._chartInstances.filter(function (ch) {
- if (ch.group) {
- return true;
- }
- }).map(function (ch) {
- return _this5.w.config.chart.group === ch.group ? ch.chart : _this5;
- });
- }
- }, {
- key: "toggleSeries",
- value: function toggleSeries(seriesName) {
- return this.series.toggleSeries(seriesName);
- }
- }, {
- key: "showSeries",
- value: function showSeries(seriesName) {
- this.series.showSeries(seriesName);
- }
- }, {
- key: "hideSeries",
- value: function hideSeries(seriesName) {
- this.series.hideSeries(seriesName);
- }
- }, {
- key: "resetSeries",
- value: function resetSeries() {
- var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
- this.series.resetSeries(shouldUpdateChart);
- }
- }, {
- key: "addEventListener",
- value: function addEventListener(name, handler) {
- this.events.addEventListener(name, handler);
- }
- }, {
- key: "removeEventListener",
- value: function removeEventListener(name, handler) {
- this.events.removeEventListener(name, handler);
- }
- }, {
- key: "addXaxisAnnotation",
- value: function addXaxisAnnotation(opts) {
- var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
- var me = this;
- if (context) {
- me = context;
- }
- me.annotations.addXaxisAnnotationExternal(opts, pushToMemory, me);
- }
- }, {
- key: "addYaxisAnnotation",
- value: function addYaxisAnnotation(opts) {
- var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
- var me = this;
- if (context) {
- me = context;
- }
- me.annotations.addYaxisAnnotationExternal(opts, pushToMemory, me);
- }
- }, {
- key: "addPointAnnotation",
- value: function addPointAnnotation(opts) {
- var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
- var me = this;
- if (context) {
- me = context;
- }
- me.annotations.addPointAnnotationExternal(opts, pushToMemory, me);
- }
- }, {
- key: "clearAnnotations",
- value: function clearAnnotations() {
- var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
- var me = this;
- if (context) {
- me = context;
- }
- me.annotations.clearAnnotations(me);
- }
- }, {
- key: "removeAnnotation",
- value: function removeAnnotation(id) {
- var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
- var me = this;
- if (context) {
- me = context;
- }
- me.annotations.removeAnnotation(me, id);
- }
- }, {
- key: "getChartArea",
- value: function getChartArea() {
- var el = this.w.globals.dom.baseEl.querySelector('.apexcharts-inner');
- return el;
- }
- }, {
- key: "getSeriesTotalXRange",
- value: function getSeriesTotalXRange(minX, maxX) {
- return this.coreUtils.getSeriesTotalsXRange(minX, maxX);
- }
- }, {
- key: "getHighestValueInSeries",
- value: function getHighestValueInSeries() {
- var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
- var range = new Range$1(this.ctx);
- return range.getMinYMaxY(seriesIndex).highestY;
- }
- }, {
- key: "getLowestValueInSeries",
- value: function getLowestValueInSeries() {
- var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
- var range = new Range$1(this.ctx);
- return range.getMinYMaxY(seriesIndex).lowestY;
- }
- }, {
- key: "getSeriesTotal",
- value: function getSeriesTotal() {
- return this.w.globals.seriesTotals;
- }
- }, {
- key: "toggleDataPointSelection",
- value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
- return this.updateHelpers.toggleDataPointSelection(seriesIndex, dataPointIndex);
- }
- }, {
- key: "setLocale",
- value: function setLocale(localeName) {
- this.localization.setCurrentLocaleValues(localeName);
- }
- }, {
- key: "dataURI",
- value: function dataURI() {
- var exp = new Exports(this.ctx);
- return exp.dataURI();
- }
- }, {
- key: "paper",
- value: function paper() {
- return this.w.globals.dom.Paper;
- }
- }, {
- key: "_parentResizeCallback",
- value: function _parentResizeCallback() {
- if (!this.w.globals.noData && this.w.globals.animationEnded && this.w.config.chart.redrawOnParentResize) {
- this._windowResize();
- }
- }
-
- }, {
- key: "_windowResize",
- value: function _windowResize() {
- var _this6 = this;
- clearTimeout(this.w.globals.resizeTimer);
- this.w.globals.resizeTimer = window.setTimeout(function () {
- _this6.w.globals.resized = true;
- _this6.w.globals.dataChanged = false;
- _this6.ctx.update();
- }, 150);
- }
- }], [{
- key: "getChartByID",
- value: function getChartByID(chartID) {
- var c = Apex._chartInstances.filter(function (ch) {
- return ch.id === chartID;
- })[0];
- return c && c.chart;
- }
-
- }, {
- key: "initOnLoad",
- value: function initOnLoad() {
- var els = document.querySelectorAll('[data-apexcharts]');
- for (var i = 0; i < els.length; i++) {
- var el = els[i];
- var options = JSON.parse(els[i].getAttribute('data-options'));
- var apexChart = new ApexCharts(el, options);
- apexChart.render();
- }
- }
-
- }, {
- key: "exec",
- value: function exec(chartID, fn) {
- var chart = this.getChartByID(chartID);
- if (!chart) return;
- chart.w.globals.isExecCalled = true;
- var ret = null;
- if (chart.publicMethods.indexOf(fn) !== -1) {
- for (var _len = arguments.length, opts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- opts[_key - 2] = arguments[_key];
- }
- ret = chart[fn].apply(chart, opts);
- }
- return ret;
- }
- }, {
- key: "merge",
- value: function merge(target, source) {
- return Utils.extend(target, source);
- }
- }]);
- return ApexCharts;
- }();
- return ApexCharts$1;
- })));
|