apexcharts.js 994 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316
  1. /*!
  2. * ApexCharts v3.17.1
  3. * (c) 2018-2020 Juned Chhipa
  4. * Released under the MIT License.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global = global || self, global.ApexCharts = factory());
  10. }(this, (function () { 'use strict';
  11. function _typeof(obj) {
  12. "@babel/helpers - typeof";
  13. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  14. _typeof = function (obj) {
  15. return typeof obj;
  16. };
  17. } else {
  18. _typeof = function (obj) {
  19. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  20. };
  21. }
  22. return _typeof(obj);
  23. }
  24. function _classCallCheck(instance, Constructor) {
  25. if (!(instance instanceof Constructor)) {
  26. throw new TypeError("Cannot call a class as a function");
  27. }
  28. }
  29. function _defineProperties(target, props) {
  30. for (var i = 0; i < props.length; i++) {
  31. var descriptor = props[i];
  32. descriptor.enumerable = descriptor.enumerable || false;
  33. descriptor.configurable = true;
  34. if ("value" in descriptor) descriptor.writable = true;
  35. Object.defineProperty(target, descriptor.key, descriptor);
  36. }
  37. }
  38. function _createClass(Constructor, protoProps, staticProps) {
  39. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  40. if (staticProps) _defineProperties(Constructor, staticProps);
  41. return Constructor;
  42. }
  43. function _defineProperty(obj, key, value) {
  44. if (key in obj) {
  45. Object.defineProperty(obj, key, {
  46. value: value,
  47. enumerable: true,
  48. configurable: true,
  49. writable: true
  50. });
  51. } else {
  52. obj[key] = value;
  53. }
  54. return obj;
  55. }
  56. function ownKeys(object, enumerableOnly) {
  57. var keys = Object.keys(object);
  58. if (Object.getOwnPropertySymbols) {
  59. var symbols = Object.getOwnPropertySymbols(object);
  60. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  61. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  62. });
  63. keys.push.apply(keys, symbols);
  64. }
  65. return keys;
  66. }
  67. function _objectSpread2(target) {
  68. for (var i = 1; i < arguments.length; i++) {
  69. var source = arguments[i] != null ? arguments[i] : {};
  70. if (i % 2) {
  71. ownKeys(Object(source), true).forEach(function (key) {
  72. _defineProperty(target, key, source[key]);
  73. });
  74. } else if (Object.getOwnPropertyDescriptors) {
  75. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  76. } else {
  77. ownKeys(Object(source)).forEach(function (key) {
  78. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  79. });
  80. }
  81. }
  82. return target;
  83. }
  84. function _inherits(subClass, superClass) {
  85. if (typeof superClass !== "function" && superClass !== null) {
  86. throw new TypeError("Super expression must either be null or a function");
  87. }
  88. subClass.prototype = Object.create(superClass && superClass.prototype, {
  89. constructor: {
  90. value: subClass,
  91. writable: true,
  92. configurable: true
  93. }
  94. });
  95. if (superClass) _setPrototypeOf(subClass, superClass);
  96. }
  97. function _getPrototypeOf(o) {
  98. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  99. return o.__proto__ || Object.getPrototypeOf(o);
  100. };
  101. return _getPrototypeOf(o);
  102. }
  103. function _setPrototypeOf(o, p) {
  104. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  105. o.__proto__ = p;
  106. return o;
  107. };
  108. return _setPrototypeOf(o, p);
  109. }
  110. function _assertThisInitialized(self) {
  111. if (self === void 0) {
  112. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  113. }
  114. return self;
  115. }
  116. function _possibleConstructorReturn(self, call) {
  117. if (call && (typeof call === "object" || typeof call === "function")) {
  118. return call;
  119. }
  120. return _assertThisInitialized(self);
  121. }
  122. function _toConsumableArray(arr) {
  123. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  124. }
  125. function _arrayWithoutHoles(arr) {
  126. if (Array.isArray(arr)) {
  127. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  128. return arr2;
  129. }
  130. }
  131. function _iterableToArray(iter) {
  132. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  133. }
  134. function _nonIterableSpread() {
  135. throw new TypeError("Invalid attempt to spread non-iterable instance");
  136. }
  137. /*
  138. ** Generic functions which are not dependent on ApexCharts
  139. */
  140. var Utils = /*#__PURE__*/function () {
  141. function Utils() {
  142. _classCallCheck(this, Utils);
  143. }
  144. _createClass(Utils, [{
  145. key: "shadeRGBColor",
  146. value: function shadeRGBColor(percent, color) {
  147. var f = color.split(','),
  148. t = percent < 0 ? 0 : 255,
  149. p = percent < 0 ? percent * -1 : percent,
  150. R = parseInt(f[0].slice(4), 10),
  151. G = parseInt(f[1], 10),
  152. B = parseInt(f[2], 10);
  153. return 'rgb(' + (Math.round((t - R) * p) + R) + ',' + (Math.round((t - G) * p) + G) + ',' + (Math.round((t - B) * p) + B) + ')';
  154. }
  155. }, {
  156. key: "shadeHexColor",
  157. value: function shadeHexColor(percent, color) {
  158. var f = parseInt(color.slice(1), 16),
  159. t = percent < 0 ? 0 : 255,
  160. p = percent < 0 ? percent * -1 : percent,
  161. R = f >> 16,
  162. G = f >> 8 & 0x00ff,
  163. B = f & 0x0000ff;
  164. 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);
  165. } // beautiful color shading blending code
  166. // http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
  167. }, {
  168. key: "shadeColor",
  169. value: function shadeColor(p, color) {
  170. if (Utils.isColorHex(color)) {
  171. return this.shadeHexColor(p, color);
  172. } else {
  173. return this.shadeRGBColor(p, color);
  174. }
  175. }
  176. }], [{
  177. key: "bind",
  178. value: function bind(fn, me) {
  179. return function () {
  180. return fn.apply(me, arguments);
  181. };
  182. }
  183. }, {
  184. key: "isObject",
  185. value: function isObject(item) {
  186. return item && _typeof(item) === 'object' && !Array.isArray(item) && item != null;
  187. }
  188. }, {
  189. key: "listToArray",
  190. value: function listToArray(list) {
  191. var i,
  192. array = [];
  193. for (i = 0; i < list.length; i++) {
  194. array[i] = list[i];
  195. }
  196. return array;
  197. } // to extend defaults with user options
  198. // credit: http://stackoverflow.com/questions/27936772/deep-object-merging-in-es6-es7#answer-34749873
  199. }, {
  200. key: "extend",
  201. value: function extend(target, source) {
  202. var _this = this;
  203. if (typeof Object.assign !== 'function') {
  204. (function () {
  205. Object.assign = function (target) {
  206. if (target === undefined || target === null) {
  207. throw new TypeError('Cannot convert undefined or null to object');
  208. }
  209. var output = Object(target);
  210. for (var index = 1; index < arguments.length; index++) {
  211. var _source = arguments[index];
  212. if (_source !== undefined && _source !== null) {
  213. for (var nextKey in _source) {
  214. if (_source.hasOwnProperty(nextKey)) {
  215. output[nextKey] = _source[nextKey];
  216. }
  217. }
  218. }
  219. }
  220. return output;
  221. };
  222. })();
  223. }
  224. var output = Object.assign({}, target);
  225. if (this.isObject(target) && this.isObject(source)) {
  226. Object.keys(source).forEach(function (key) {
  227. if (_this.isObject(source[key])) {
  228. if (!(key in target)) {
  229. Object.assign(output, _defineProperty({}, key, source[key]));
  230. } else {
  231. output[key] = _this.extend(target[key], source[key]);
  232. }
  233. } else {
  234. Object.assign(output, _defineProperty({}, key, source[key]));
  235. }
  236. });
  237. }
  238. return output;
  239. }
  240. }, {
  241. key: "extendArray",
  242. value: function extendArray(arrToExtend, resultArr) {
  243. var extendedArr = [];
  244. arrToExtend.map(function (item) {
  245. extendedArr.push(Utils.extend(resultArr, item));
  246. });
  247. arrToExtend = extendedArr;
  248. return arrToExtend;
  249. } // If month counter exceeds 12, it starts again from 1
  250. }, {
  251. key: "monthMod",
  252. value: function monthMod(month) {
  253. return month % 12;
  254. }
  255. }, {
  256. key: "clone",
  257. value: function clone(source) {
  258. if (Object.prototype.toString.call(source) === '[object Array]') {
  259. var cloneResult = [];
  260. for (var i = 0; i < source.length; i++) {
  261. cloneResult[i] = this.clone(source[i]);
  262. }
  263. return cloneResult;
  264. } else if (_typeof(source) === 'object') {
  265. var _cloneResult = {};
  266. for (var prop in source) {
  267. if (source.hasOwnProperty(prop)) {
  268. _cloneResult[prop] = this.clone(source[prop]);
  269. }
  270. }
  271. return _cloneResult;
  272. } else {
  273. return source;
  274. }
  275. }
  276. }, {
  277. key: "log10",
  278. value: function log10(x) {
  279. return Math.log(x) / Math.LN10;
  280. }
  281. }, {
  282. key: "roundToBase10",
  283. value: function roundToBase10(x) {
  284. return Math.pow(10, Math.floor(Math.log10(x)));
  285. }
  286. }, {
  287. key: "roundToBase",
  288. value: function roundToBase(x, base) {
  289. return Math.pow(base, Math.floor(Math.log(x) / Math.log(base)));
  290. }
  291. }, {
  292. key: "parseNumber",
  293. value: function parseNumber(val) {
  294. if (val === null) return val;
  295. return parseFloat(val);
  296. }
  297. }, {
  298. key: "randomId",
  299. value: function randomId() {
  300. return (new Date() % 9e6).toString(16);
  301. }
  302. }, {
  303. key: "noExponents",
  304. value: function noExponents(val) {
  305. var data = String(val).split(/[eE]/);
  306. if (data.length === 1) return data[0];
  307. var z = '',
  308. sign = val < 0 ? '-' : '',
  309. str = data[0].replace('.', ''),
  310. mag = Number(data[1]) + 1;
  311. if (mag < 0) {
  312. z = sign + '0.';
  313. while (mag++) {
  314. z += '0';
  315. }
  316. return z + str.replace(/^-/, '');
  317. }
  318. mag -= str.length;
  319. while (mag--) {
  320. z += '0';
  321. }
  322. return str + z;
  323. }
  324. }, {
  325. key: "getDimensions",
  326. value: function getDimensions(el) {
  327. var computedStyle = getComputedStyle(el);
  328. var ret = [];
  329. var elementHeight = el.clientHeight;
  330. var elementWidth = el.clientWidth;
  331. elementHeight -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
  332. elementWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
  333. ret.push(elementWidth);
  334. ret.push(elementHeight);
  335. return ret;
  336. }
  337. }, {
  338. key: "getBoundingClientRect",
  339. value: function getBoundingClientRect(element) {
  340. var rect = element.getBoundingClientRect();
  341. return {
  342. top: rect.top,
  343. right: rect.right,
  344. bottom: rect.bottom,
  345. left: rect.left,
  346. width: element.clientWidth,
  347. height: element.clientHeight,
  348. x: rect.left,
  349. y: rect.top
  350. };
  351. }
  352. }, {
  353. key: "getLargestStringFromArr",
  354. value: function getLargestStringFromArr(arr) {
  355. return arr.reduce(function (a, b) {
  356. if (Array.isArray(b)) {
  357. b = b.reduce(function (aa, bb) {
  358. return aa.length > bb.length ? aa : bb;
  359. });
  360. }
  361. return a.length > b.length ? a : b;
  362. }, 0);
  363. } // http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-12342275
  364. }, {
  365. key: "hexToRgba",
  366. value: function hexToRgba() {
  367. var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#999999';
  368. var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
  369. if (hex.substring(0, 1) !== '#') {
  370. hex = '#999999';
  371. }
  372. var h = hex.replace('#', '');
  373. h = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g'));
  374. for (var i = 0; i < h.length; i++) {
  375. h[i] = parseInt(h[i].length === 1 ? h[i] + h[i] : h[i], 16);
  376. }
  377. if (typeof opacity !== 'undefined') h.push(opacity);
  378. return 'rgba(' + h.join(',') + ')';
  379. }
  380. }, {
  381. key: "getOpacityFromRGBA",
  382. value: function getOpacityFromRGBA(rgba) {
  383. return parseFloat(rgba.replace(/^.*,(.+)\)/, '$1'));
  384. }
  385. }, {
  386. key: "rgb2hex",
  387. value: function rgb2hex(rgb) {
  388. rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  389. 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) : '';
  390. }
  391. }, {
  392. key: "isColorHex",
  393. value: function isColorHex(color) {
  394. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)|(^#[0-9A-F]{8}$)/i.test(color);
  395. }
  396. }, {
  397. key: "polarToCartesian",
  398. value: function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
  399. var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
  400. return {
  401. x: centerX + radius * Math.cos(angleInRadians),
  402. y: centerY + radius * Math.sin(angleInRadians)
  403. };
  404. }
  405. }, {
  406. key: "escapeString",
  407. value: function escapeString(str) {
  408. var escapeWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';
  409. var newStr = str.toString().slice();
  410. newStr = newStr.replace(/[` ~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, escapeWith);
  411. return newStr;
  412. }
  413. }, {
  414. key: "negToZero",
  415. value: function negToZero(val) {
  416. return val < 0 ? 0 : val;
  417. }
  418. }, {
  419. key: "moveIndexInArray",
  420. value: function moveIndexInArray(arr, old_index, new_index) {
  421. if (new_index >= arr.length) {
  422. var k = new_index - arr.length + 1;
  423. while (k--) {
  424. arr.push(undefined);
  425. }
  426. }
  427. arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
  428. return arr;
  429. }
  430. }, {
  431. key: "extractNumber",
  432. value: function extractNumber(s) {
  433. return parseFloat(s.replace(/[^\d.]*/g, ''));
  434. }
  435. }, {
  436. key: "findAncestor",
  437. value: function findAncestor(el, cls) {
  438. while ((el = el.parentElement) && !el.classList.contains(cls)) {
  439. }
  440. return el;
  441. }
  442. }, {
  443. key: "setELstyles",
  444. value: function setELstyles(el, styles) {
  445. for (var key in styles) {
  446. if (styles.hasOwnProperty(key)) {
  447. el.style.key = styles[key];
  448. }
  449. }
  450. }
  451. }, {
  452. key: "isNumber",
  453. value: function isNumber(value) {
  454. return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
  455. }
  456. }, {
  457. key: "isFloat",
  458. value: function isFloat(n) {
  459. return Number(n) === n && n % 1 !== 0;
  460. }
  461. }, {
  462. key: "isSafari",
  463. value: function isSafari() {
  464. return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  465. }
  466. }, {
  467. key: "isFirefox",
  468. value: function isFirefox() {
  469. return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  470. }
  471. }, {
  472. key: "isIE11",
  473. value: function isIE11() {
  474. if (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.appVersion.indexOf('Trident/') > -1) {
  475. return true;
  476. }
  477. }
  478. }, {
  479. key: "isIE",
  480. value: function isIE() {
  481. var ua = window.navigator.userAgent;
  482. var msie = ua.indexOf('MSIE ');
  483. if (msie > 0) {
  484. // IE 10 or older => return version number
  485. return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
  486. }
  487. var trident = ua.indexOf('Trident/');
  488. if (trident > 0) {
  489. // IE 11 => return version number
  490. var rv = ua.indexOf('rv:');
  491. return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
  492. }
  493. var edge = ua.indexOf('Edge/');
  494. if (edge > 0) {
  495. // Edge (IE 12+) => return version number
  496. return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
  497. } // other browser
  498. return false;
  499. }
  500. }]);
  501. return Utils;
  502. }();
  503. /**
  504. * ApexCharts Filters Class for setting hover/active states on the paths.
  505. *
  506. * @module Formatters
  507. **/
  508. var Filters = /*#__PURE__*/function () {
  509. function Filters(ctx) {
  510. _classCallCheck(this, Filters);
  511. this.ctx = ctx;
  512. this.w = ctx.w;
  513. } // create a re-usable filter which can be appended other filter effects and applied to multiple elements
  514. _createClass(Filters, [{
  515. key: "getDefaultFilter",
  516. value: function getDefaultFilter(el, i) {
  517. var w = this.w;
  518. el.unfilter(true);
  519. var filter = new window.SVG.Filter();
  520. filter.size('120%', '180%', '-5%', '-40%');
  521. if (w.config.states.normal.filter !== 'none') {
  522. this.applyFilter(el, i, w.config.states.normal.filter.type, w.config.states.normal.filter.value);
  523. } else {
  524. if (w.config.chart.dropShadow.enabled) {
  525. this.dropShadow(el, w.config.chart.dropShadow, i);
  526. }
  527. }
  528. }
  529. }, {
  530. key: "addNormalFilter",
  531. value: function addNormalFilter(el, i) {
  532. var w = this.w; // revert shadow if it was there
  533. // but, ignore marker as marker don't have dropshadow yet
  534. if (w.config.chart.dropShadow.enabled && !el.node.classList.contains('apexcharts-marker')) {
  535. this.dropShadow(el, w.config.chart.dropShadow, i);
  536. }
  537. } // appends dropShadow to the filter object which can be chained with other filter effects
  538. }, {
  539. key: "addLightenFilter",
  540. value: function addLightenFilter(el, i, attrs) {
  541. var _this = this;
  542. var w = this.w;
  543. var intensity = attrs.intensity;
  544. if (Utils.isFirefox()) {
  545. return;
  546. }
  547. el.unfilter(true);
  548. var filter = new window.SVG.Filter();
  549. el.filter(function (add) {
  550. var shadowAttr = w.config.chart.dropShadow;
  551. if (shadowAttr.enabled) {
  552. filter = _this.addShadow(add, i, shadowAttr);
  553. } else {
  554. filter = add;
  555. }
  556. filter.componentTransfer({
  557. rgb: {
  558. type: 'linear',
  559. slope: 1.5,
  560. intercept: intensity
  561. }
  562. });
  563. });
  564. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  565. this._scaleFilterSize(el.filterer.node);
  566. } // appends dropShadow to the filter object which can be chained with other filter effects
  567. }, {
  568. key: "addDarkenFilter",
  569. value: function addDarkenFilter(el, i, attrs) {
  570. var _this2 = this;
  571. var w = this.w;
  572. var intensity = attrs.intensity;
  573. if (Utils.isFirefox()) {
  574. return;
  575. }
  576. el.unfilter(true);
  577. var filter = new window.SVG.Filter();
  578. el.filter(function (add) {
  579. var shadowAttr = w.config.chart.dropShadow;
  580. if (shadowAttr.enabled) {
  581. filter = _this2.addShadow(add, i, shadowAttr);
  582. } else {
  583. filter = add;
  584. }
  585. filter.componentTransfer({
  586. rgb: {
  587. type: 'linear',
  588. slope: intensity
  589. }
  590. });
  591. });
  592. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  593. this._scaleFilterSize(el.filterer.node);
  594. }
  595. }, {
  596. key: "applyFilter",
  597. value: function applyFilter(el, i, filter) {
  598. var intensity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
  599. switch (filter) {
  600. case 'none':
  601. {
  602. this.addNormalFilter(el, i);
  603. break;
  604. }
  605. case 'lighten':
  606. {
  607. this.addLightenFilter(el, i, {
  608. intensity: intensity
  609. });
  610. break;
  611. }
  612. case 'darken':
  613. {
  614. this.addDarkenFilter(el, i, {
  615. intensity: intensity
  616. });
  617. break;
  618. }
  619. }
  620. } // appends dropShadow to the filter object which can be chained with other filter effects
  621. }, {
  622. key: "addShadow",
  623. value: function addShadow(add, i, attrs) {
  624. var blur = attrs.blur,
  625. top = attrs.top,
  626. left = attrs.left,
  627. color = attrs.color,
  628. opacity = attrs.opacity;
  629. var shadowBlur = add.flood(Array.isArray(color) ? color[i] : color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  630. return add.blend(add.source, shadowBlur);
  631. } // directly adds dropShadow to the element and returns the same element.
  632. // the only way it is different from the addShadow() function is that addShadow is chainable to other filters, while this function discards all filters and add dropShadow
  633. }, {
  634. key: "dropShadow",
  635. value: function dropShadow(el, attrs) {
  636. var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  637. var top = attrs.top,
  638. left = attrs.left,
  639. blur = attrs.blur,
  640. color = attrs.color,
  641. opacity = attrs.opacity,
  642. noUserSpaceOnUse = attrs.noUserSpaceOnUse;
  643. var w = this.w;
  644. el.unfilter(true);
  645. if (Utils.isIE() && w.config.chart.type === 'radialBar') {
  646. // in radialbar charts, dropshadow is clipping actual drawing in IE
  647. return el;
  648. }
  649. color = Array.isArray(color) ? color[i] : color;
  650. el.filter(function (add) {
  651. var shadowBlur = null;
  652. if (Utils.isSafari() || Utils.isFirefox() || Utils.isIE()) {
  653. // safari/firefox has some alternative way to use this filter
  654. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur);
  655. } else {
  656. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  657. }
  658. add.blend(add.source, shadowBlur);
  659. });
  660. if (!noUserSpaceOnUse) {
  661. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  662. }
  663. this._scaleFilterSize(el.filterer.node);
  664. return el;
  665. }
  666. }, {
  667. key: "setSelectionFilter",
  668. value: function setSelectionFilter(el, realIndex, dataPointIndex) {
  669. var w = this.w;
  670. if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') {
  671. if (w.globals.selectedDataPoints[realIndex].indexOf(dataPointIndex) > -1) {
  672. el.node.setAttribute('selected', true);
  673. var activeFilter = w.config.states.active.filter;
  674. if (activeFilter !== 'none') {
  675. this.applyFilter(el, realIndex, activeFilter.type, activeFilter.value);
  676. }
  677. }
  678. }
  679. }
  680. }, {
  681. key: "_scaleFilterSize",
  682. value: function _scaleFilterSize(el) {
  683. var setAttributes = function setAttributes(attrs) {
  684. for (var key in attrs) {
  685. if (attrs.hasOwnProperty(key)) {
  686. el.setAttribute(key, attrs[key]);
  687. }
  688. }
  689. };
  690. setAttributes({
  691. width: '200%',
  692. height: '200%',
  693. x: '-50%',
  694. y: '-50%'
  695. });
  696. }
  697. }]);
  698. return Filters;
  699. }();
  700. /**
  701. * ApexCharts Animation Class.
  702. *
  703. * @module Animations
  704. **/
  705. var Animations = /*#__PURE__*/function () {
  706. function Animations(ctx) {
  707. _classCallCheck(this, Animations);
  708. this.ctx = ctx;
  709. this.w = ctx.w;
  710. this.setEasingFunctions();
  711. }
  712. _createClass(Animations, [{
  713. key: "setEasingFunctions",
  714. value: function setEasingFunctions() {
  715. var easing;
  716. if (this.w.globals.easing) return;
  717. var userDefinedEasing = this.w.config.chart.animations.easing;
  718. switch (userDefinedEasing) {
  719. case 'linear':
  720. {
  721. easing = '-';
  722. break;
  723. }
  724. case 'easein':
  725. {
  726. easing = '<';
  727. break;
  728. }
  729. case 'easeout':
  730. {
  731. easing = '>';
  732. break;
  733. }
  734. case 'easeinout':
  735. {
  736. easing = '<>';
  737. break;
  738. }
  739. case 'swing':
  740. {
  741. easing = function easing(pos) {
  742. var s = 1.70158;
  743. var ret = (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
  744. return ret;
  745. };
  746. break;
  747. }
  748. case 'bounce':
  749. {
  750. easing = function easing(pos) {
  751. var ret = '';
  752. if (pos < 1 / 2.75) {
  753. ret = 7.5625 * pos * pos;
  754. } else if (pos < 2 / 2.75) {
  755. ret = 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75;
  756. } else if (pos < 2.5 / 2.75) {
  757. ret = 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375;
  758. } else {
  759. ret = 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375;
  760. }
  761. return ret;
  762. };
  763. break;
  764. }
  765. case 'elastic':
  766. {
  767. easing = function easing(pos) {
  768. if (pos === !!pos) return pos;
  769. return Math.pow(2, -10 * pos) * Math.sin((pos - 0.075) * (2 * Math.PI) / 0.3) + 1;
  770. };
  771. break;
  772. }
  773. default:
  774. {
  775. easing = '<>';
  776. }
  777. }
  778. this.w.globals.easing = easing;
  779. }
  780. }, {
  781. key: "animateLine",
  782. value: function animateLine(el, from, to, speed) {
  783. el.attr(from).animate(speed).attr(to);
  784. }
  785. /*
  786. ** Animate radius of a circle element
  787. */
  788. }, {
  789. key: "animateCircleRadius",
  790. value: function animateCircleRadius(el, from, to, speed, easing, cb) {
  791. if (!from) from = 0;
  792. el.attr({
  793. r: from
  794. }).animate(speed, easing).attr({
  795. r: to
  796. }).afterAll(function () {
  797. cb();
  798. });
  799. }
  800. /*
  801. ** Animate radius and position of a circle element
  802. */
  803. }, {
  804. key: "animateCircle",
  805. value: function animateCircle(el, from, to, speed, easing) {
  806. el.attr({
  807. r: from.r,
  808. cx: from.cx,
  809. cy: from.cy
  810. }).animate(speed, easing).attr({
  811. r: to.r,
  812. cx: to.cx,
  813. cy: to.cy
  814. });
  815. }
  816. /*
  817. ** Animate rect properties
  818. */
  819. }, {
  820. key: "animateRect",
  821. value: function animateRect(el, from, to, speed, fn) {
  822. el.attr(from).animate(speed).attr(to).afterAll(function () {
  823. return fn();
  824. });
  825. }
  826. }, {
  827. key: "animatePathsGradually",
  828. value: function animatePathsGradually(params) {
  829. var el = params.el,
  830. realIndex = params.realIndex,
  831. j = params.j,
  832. fill = params.fill,
  833. pathFrom = params.pathFrom,
  834. pathTo = params.pathTo,
  835. speed = params.speed,
  836. delay = params.delay;
  837. var me = this;
  838. var w = this.w;
  839. var delayFactor = 0;
  840. if (w.config.chart.animations.animateGradually.enabled) {
  841. delayFactor = w.config.chart.animations.animateGradually.delay;
  842. }
  843. if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged && w.config.chart.type !== 'bar') {
  844. // disabled due to this bug - https://github.com/apexcharts/vue-apexcharts/issues/75
  845. delayFactor = 0;
  846. }
  847. me.morphSVG(el, realIndex, j, w.config.chart.type === 'line' && !w.globals.comboCharts ? 'stroke' : fill, pathFrom, pathTo, speed, delay * delayFactor);
  848. }
  849. }, {
  850. key: "showDelayedElements",
  851. value: function showDelayedElements() {
  852. this.w.globals.delayedElements.forEach(function (d) {
  853. var ele = d.el;
  854. ele.classList.remove('apexcharts-element-hidden');
  855. });
  856. }
  857. }, {
  858. key: "animationCompleted",
  859. value: function animationCompleted(el) {
  860. var w = this.w;
  861. if (w.globals.animationEnded) return;
  862. w.globals.animationEnded = true;
  863. this.showDelayedElements();
  864. if (typeof w.config.chart.events.animationEnd === 'function') {
  865. w.config.chart.events.animationEnd(this.ctx, {
  866. el: el,
  867. w: w
  868. });
  869. }
  870. } // SVG.js animation for morphing one path to another
  871. }, {
  872. key: "morphSVG",
  873. value: function morphSVG(el, realIndex, j, fill, pathFrom, pathTo, speed, delay) {
  874. var _this = this;
  875. var w = this.w;
  876. if (!pathFrom) {
  877. pathFrom = el.attr('pathFrom');
  878. }
  879. if (!pathTo) {
  880. pathTo = el.attr('pathTo');
  881. }
  882. var disableAnimationForCorrupPath = function disableAnimationForCorrupPath(path) {
  883. if (w.config.chart.type === 'radar') {
  884. // radar chart drops the path to bottom and hence a corrup path looks ugly
  885. // therefore, disable animation for such a case
  886. speed = 1;
  887. }
  888. return "M 0 ".concat(w.globals.gridHeight);
  889. };
  890. if (!pathFrom || pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) {
  891. pathFrom = disableAnimationForCorrupPath();
  892. }
  893. if (pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) {
  894. pathTo = disableAnimationForCorrupPath();
  895. }
  896. if (!w.globals.shouldAnimate) {
  897. speed = 1;
  898. }
  899. el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo).afterAll(function () {
  900. // a flag to indicate that the original mount function can return true now as animation finished here
  901. if (Utils.isNumber(j)) {
  902. if (j === w.globals.series[w.globals.maxValsInArrayIndex].length - 2 && w.globals.shouldAnimate) {
  903. _this.animationCompleted(el);
  904. }
  905. } else if (fill !== 'none' && w.globals.shouldAnimate) {
  906. if (!w.globals.comboCharts && realIndex === w.globals.series.length - 1 || w.globals.comboCharts) {
  907. _this.animationCompleted(el);
  908. }
  909. }
  910. _this.showDelayedElements();
  911. });
  912. }
  913. }]);
  914. return Animations;
  915. }();
  916. /**
  917. * ApexCharts Graphics Class for all drawing operations.
  918. *
  919. * @module Graphics
  920. **/
  921. var Graphics = /*#__PURE__*/function () {
  922. function Graphics(ctx) {
  923. _classCallCheck(this, Graphics);
  924. this.ctx = ctx;
  925. this.w = ctx.w;
  926. }
  927. _createClass(Graphics, [{
  928. key: "drawLine",
  929. value: function drawLine(x1, y1, x2, y2) {
  930. var lineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#a8a8a8';
  931. var dashArray = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  932. var strokeWidth = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  933. var w = this.w;
  934. var line = w.globals.dom.Paper.line().attr({
  935. x1: x1,
  936. y1: y1,
  937. x2: x2,
  938. y2: y2,
  939. stroke: lineColor,
  940. 'stroke-dasharray': dashArray,
  941. 'stroke-width': strokeWidth
  942. });
  943. return line;
  944. }
  945. }, {
  946. key: "drawRect",
  947. value: function drawRect() {
  948. var x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  949. var y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  950. var x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  951. var y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  952. var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  953. var color = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '#fefefe';
  954. var opacity = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1;
  955. var strokeWidth = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  956. var strokeColor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  957. var strokeDashArray = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 0;
  958. var w = this.w;
  959. var rect = w.globals.dom.Paper.rect();
  960. rect.attr({
  961. x: x1,
  962. y: y1,
  963. width: x2 > 0 ? x2 : 0,
  964. height: y2 > 0 ? y2 : 0,
  965. rx: radius,
  966. ry: radius,
  967. opacity: opacity,
  968. 'stroke-width': strokeWidth !== null ? strokeWidth : 0,
  969. stroke: strokeColor !== null ? strokeColor : 'none',
  970. 'stroke-dasharray': strokeDashArray
  971. }); // fix apexcharts.js#1410
  972. rect.node.setAttribute('fill', color);
  973. return rect;
  974. }
  975. }, {
  976. key: "drawPolygon",
  977. value: function drawPolygon(polygonString) {
  978. var stroke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#e1e1e1';
  979. var fill = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'none';
  980. var w = this.w;
  981. var polygon = w.globals.dom.Paper.polygon(polygonString).attr({
  982. fill: fill,
  983. stroke: stroke
  984. });
  985. return polygon;
  986. }
  987. }, {
  988. key: "drawCircle",
  989. value: function drawCircle(radius) {
  990. var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  991. var w = this.w;
  992. var c = w.globals.dom.Paper.circle(radius * 2);
  993. if (attrs !== null) {
  994. c.attr(attrs);
  995. }
  996. return c;
  997. }
  998. }, {
  999. key: "drawPath",
  1000. value: function drawPath(_ref) {
  1001. var _ref$d = _ref.d,
  1002. d = _ref$d === void 0 ? '' : _ref$d,
  1003. _ref$stroke = _ref.stroke,
  1004. stroke = _ref$stroke === void 0 ? '#a8a8a8' : _ref$stroke,
  1005. _ref$strokeWidth = _ref.strokeWidth,
  1006. strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
  1007. fill = _ref.fill,
  1008. _ref$fillOpacity = _ref.fillOpacity,
  1009. fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
  1010. _ref$strokeOpacity = _ref.strokeOpacity,
  1011. strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
  1012. classes = _ref.classes,
  1013. _ref$strokeLinecap = _ref.strokeLinecap,
  1014. strokeLinecap = _ref$strokeLinecap === void 0 ? null : _ref$strokeLinecap,
  1015. _ref$strokeDashArray = _ref.strokeDashArray,
  1016. strokeDashArray = _ref$strokeDashArray === void 0 ? 0 : _ref$strokeDashArray;
  1017. var w = this.w;
  1018. if (strokeLinecap === null) {
  1019. strokeLinecap = w.config.stroke.lineCap;
  1020. }
  1021. if (d.indexOf('undefined') > -1 || d.indexOf('NaN') > -1) {
  1022. d = "M 0 ".concat(w.globals.gridHeight);
  1023. }
  1024. var p = w.globals.dom.Paper.path(d).attr({
  1025. fill: fill,
  1026. 'fill-opacity': fillOpacity,
  1027. stroke: stroke,
  1028. 'stroke-opacity': strokeOpacity,
  1029. 'stroke-linecap': strokeLinecap,
  1030. 'stroke-width': strokeWidth,
  1031. 'stroke-dasharray': strokeDashArray,
  1032. class: classes
  1033. });
  1034. return p;
  1035. }
  1036. }, {
  1037. key: "group",
  1038. value: function group() {
  1039. var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1040. var w = this.w;
  1041. var g = w.globals.dom.Paper.group();
  1042. if (attrs !== null) {
  1043. g.attr(attrs);
  1044. }
  1045. return g;
  1046. }
  1047. }, {
  1048. key: "move",
  1049. value: function move(x, y) {
  1050. var move = ['M', x, y].join(' ');
  1051. return move;
  1052. }
  1053. }, {
  1054. key: "line",
  1055. value: function line(x, y) {
  1056. var hORv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1057. var line = null;
  1058. if (hORv === null) {
  1059. line = ['L', x, y].join(' ');
  1060. } else if (hORv === 'H') {
  1061. line = ['H', x].join(' ');
  1062. } else if (hORv === 'V') {
  1063. line = ['V', y].join(' ');
  1064. }
  1065. return line;
  1066. }
  1067. }, {
  1068. key: "curve",
  1069. value: function curve(x1, y1, x2, y2, x, y) {
  1070. var curve = ['C', x1, y1, x2, y2, x, y].join(' ');
  1071. return curve;
  1072. }
  1073. }, {
  1074. key: "quadraticCurve",
  1075. value: function quadraticCurve(x1, y1, x, y) {
  1076. var curve = ['Q', x1, y1, x, y].join(' ');
  1077. return curve;
  1078. }
  1079. }, {
  1080. key: "arc",
  1081. value: function arc(rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y) {
  1082. var relative = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
  1083. var coord = 'A';
  1084. if (relative) coord = 'a';
  1085. var arc = [coord, rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y].join(' ');
  1086. return arc;
  1087. }
  1088. /**
  1089. * @memberof Graphics
  1090. * @param {object}
  1091. * i = series's index
  1092. * realIndex = realIndex is series's actual index when it was drawn time. After several redraws, the iterating "i" may change in loops, but realIndex doesn't
  1093. * pathFrom = existing pathFrom to animateTo
  1094. * pathTo = new Path to which d attr will be animated from pathFrom to pathTo
  1095. * stroke = line Color
  1096. * strokeWidth = width of path Line
  1097. * fill = it can be gradient, single color, pattern or image
  1098. * animationDelay = how much to delay when starting animation (in milliseconds)
  1099. * dataChangeSpeed = for dynamic animations, when data changes
  1100. * className = class attribute to add
  1101. * @return {object} svg.js path object
  1102. **/
  1103. }, {
  1104. key: "renderPaths",
  1105. value: function renderPaths(_ref2) {
  1106. var j = _ref2.j,
  1107. realIndex = _ref2.realIndex,
  1108. pathFrom = _ref2.pathFrom,
  1109. pathTo = _ref2.pathTo,
  1110. stroke = _ref2.stroke,
  1111. strokeWidth = _ref2.strokeWidth,
  1112. strokeLinecap = _ref2.strokeLinecap,
  1113. fill = _ref2.fill,
  1114. animationDelay = _ref2.animationDelay,
  1115. initialSpeed = _ref2.initialSpeed,
  1116. dataChangeSpeed = _ref2.dataChangeSpeed,
  1117. className = _ref2.className,
  1118. _ref2$shouldClipToGri = _ref2.shouldClipToGrid,
  1119. shouldClipToGrid = _ref2$shouldClipToGri === void 0 ? true : _ref2$shouldClipToGri,
  1120. _ref2$bindEventsOnPat = _ref2.bindEventsOnPaths,
  1121. bindEventsOnPaths = _ref2$bindEventsOnPat === void 0 ? true : _ref2$bindEventsOnPat,
  1122. _ref2$drawShadow = _ref2.drawShadow,
  1123. drawShadow = _ref2$drawShadow === void 0 ? true : _ref2$drawShadow;
  1124. var w = this.w;
  1125. var filters = new Filters(this.ctx);
  1126. var anim = new Animations(this.ctx);
  1127. var initialAnim = this.w.config.chart.animations.enabled;
  1128. var dynamicAnim = initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  1129. var d;
  1130. var shouldAnimate = !!(initialAnim && !w.globals.resized || dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate);
  1131. if (shouldAnimate) {
  1132. d = pathFrom;
  1133. } else {
  1134. d = pathTo;
  1135. w.globals.animationEnded = true;
  1136. }
  1137. var strokeDashArrayOpt = w.config.stroke.dashArray;
  1138. var strokeDashArray = 0;
  1139. if (Array.isArray(strokeDashArrayOpt)) {
  1140. strokeDashArray = strokeDashArrayOpt[realIndex];
  1141. } else {
  1142. strokeDashArray = w.config.stroke.dashArray;
  1143. }
  1144. var el = this.drawPath({
  1145. d: d,
  1146. stroke: stroke,
  1147. strokeWidth: strokeWidth,
  1148. fill: fill,
  1149. fillOpacity: 1,
  1150. classes: className,
  1151. strokeLinecap: strokeLinecap,
  1152. strokeDashArray: strokeDashArray
  1153. });
  1154. el.attr('index', realIndex);
  1155. if (shouldClipToGrid) {
  1156. el.attr({
  1157. 'clip-path': "url(#gridRectMask".concat(w.globals.cuid, ")")
  1158. });
  1159. } // const defaultFilter = el.filterer
  1160. if (w.config.states.normal.filter.type !== 'none') {
  1161. filters.getDefaultFilter(el, realIndex);
  1162. } else {
  1163. if (w.config.chart.dropShadow.enabled && drawShadow) {
  1164. if (!w.config.chart.dropShadow.enabledOnSeries || w.config.chart.dropShadow.enabledOnSeries && w.config.chart.dropShadow.enabledOnSeries.indexOf(realIndex) !== -1) {
  1165. var shadow = w.config.chart.dropShadow;
  1166. filters.dropShadow(el, shadow, realIndex);
  1167. }
  1168. }
  1169. }
  1170. if (bindEventsOnPaths) {
  1171. el.node.addEventListener('mouseenter', this.pathMouseEnter.bind(this, el));
  1172. el.node.addEventListener('mouseleave', this.pathMouseLeave.bind(this, el));
  1173. el.node.addEventListener('mousedown', this.pathMouseDown.bind(this, el));
  1174. }
  1175. el.attr({
  1176. pathTo: pathTo,
  1177. pathFrom: pathFrom
  1178. });
  1179. var defaultAnimateOpts = {
  1180. el: el,
  1181. j: j,
  1182. realIndex: realIndex,
  1183. pathFrom: pathFrom,
  1184. pathTo: pathTo,
  1185. fill: fill,
  1186. strokeWidth: strokeWidth,
  1187. delay: animationDelay
  1188. };
  1189. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  1190. anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
  1191. speed: initialSpeed
  1192. }));
  1193. } else {
  1194. if (w.globals.resized || !w.globals.dataChanged) {
  1195. anim.showDelayedElements();
  1196. }
  1197. }
  1198. if (w.globals.dataChanged && dynamicAnim && shouldAnimate) {
  1199. anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
  1200. speed: dataChangeSpeed
  1201. }));
  1202. }
  1203. return el;
  1204. }
  1205. }, {
  1206. key: "drawPattern",
  1207. value: function drawPattern(style, width, height) {
  1208. var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8';
  1209. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  1210. var w = this.w;
  1211. var p = w.globals.dom.Paper.pattern(width, height, function (add) {
  1212. if (style === 'horizontalLines') {
  1213. add.line(0, 0, height, 0).stroke({
  1214. color: stroke,
  1215. width: strokeWidth + 1
  1216. });
  1217. } else if (style === 'verticalLines') {
  1218. add.line(0, 0, 0, width).stroke({
  1219. color: stroke,
  1220. width: strokeWidth + 1
  1221. });
  1222. } else if (style === 'slantedLines') {
  1223. add.line(0, 0, width, height).stroke({
  1224. color: stroke,
  1225. width: strokeWidth
  1226. });
  1227. } else if (style === 'squares') {
  1228. add.rect(width, height).fill('none').stroke({
  1229. color: stroke,
  1230. width: strokeWidth
  1231. });
  1232. } else if (style === 'circles') {
  1233. add.circle(width).fill('none').stroke({
  1234. color: stroke,
  1235. width: strokeWidth
  1236. });
  1237. }
  1238. });
  1239. return p;
  1240. }
  1241. }, {
  1242. key: "drawGradient",
  1243. value: function drawGradient(style, gfrom, gto, opacityFrom, opacityTo) {
  1244. var size = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  1245. var stops = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  1246. var colorStops = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  1247. var i = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
  1248. var w = this.w;
  1249. var g;
  1250. if (gfrom.length < 9 && gfrom.indexOf('#') === 0) {
  1251. // if the hex contains alpha and is of 9 digit, skip the opacity
  1252. gfrom = Utils.hexToRgba(gfrom, opacityFrom);
  1253. }
  1254. if (gto.length < 9 && gto.indexOf('#') === 0) {
  1255. gto = Utils.hexToRgba(gto, opacityTo);
  1256. }
  1257. var stop1 = 0;
  1258. var stop2 = 1;
  1259. var stop3 = 1;
  1260. var stop4 = null;
  1261. if (stops !== null) {
  1262. stop1 = typeof stops[0] !== 'undefined' ? stops[0] / 100 : 0;
  1263. stop2 = typeof stops[1] !== 'undefined' ? stops[1] / 100 : 1;
  1264. stop3 = typeof stops[2] !== 'undefined' ? stops[2] / 100 : 1;
  1265. stop4 = typeof stops[3] !== 'undefined' ? stops[3] / 100 : null;
  1266. }
  1267. var radial = !!(w.config.chart.type === 'donut' || w.config.chart.type === 'pie' || w.config.chart.type === 'bubble');
  1268. if (colorStops === null || colorStops.length === 0) {
  1269. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1270. stop.at(stop1, gfrom, opacityFrom);
  1271. stop.at(stop2, gto, opacityTo);
  1272. stop.at(stop3, gto, opacityTo);
  1273. if (stop4 !== null) {
  1274. stop.at(stop4, gfrom, opacityFrom);
  1275. }
  1276. });
  1277. } else {
  1278. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1279. var gradientStops = Array.isArray(colorStops[i]) ? colorStops[i] : colorStops;
  1280. gradientStops.forEach(function (s) {
  1281. stop.at(s.offset / 100, s.color, s.opacity);
  1282. });
  1283. });
  1284. }
  1285. if (!radial) {
  1286. if (style === 'vertical') {
  1287. g.from(0, 0).to(0, 1);
  1288. } else if (style === 'diagonal') {
  1289. g.from(0, 0).to(1, 1);
  1290. } else if (style === 'horizontal') {
  1291. g.from(0, 1).to(1, 1);
  1292. } else if (style === 'diagonal2') {
  1293. g.from(1, 0).to(0, 1);
  1294. }
  1295. } else {
  1296. var offx = w.globals.gridWidth / 2;
  1297. var offy = w.globals.gridHeight / 2;
  1298. if (w.config.chart.type !== 'bubble') {
  1299. g.attr({
  1300. gradientUnits: 'userSpaceOnUse',
  1301. cx: offx,
  1302. cy: offy,
  1303. r: size
  1304. });
  1305. } else {
  1306. g.attr({
  1307. cx: 0.5,
  1308. cy: 0.5,
  1309. r: 0.8,
  1310. fx: 0.2,
  1311. fy: 0.2
  1312. });
  1313. }
  1314. }
  1315. return g;
  1316. }
  1317. }, {
  1318. key: "drawText",
  1319. value: function drawText(_ref3) {
  1320. var x = _ref3.x,
  1321. y = _ref3.y,
  1322. text = _ref3.text,
  1323. textAnchor = _ref3.textAnchor,
  1324. fontSize = _ref3.fontSize,
  1325. fontFamily = _ref3.fontFamily,
  1326. fontWeight = _ref3.fontWeight,
  1327. foreColor = _ref3.foreColor,
  1328. opacity = _ref3.opacity,
  1329. _ref3$cssClass = _ref3.cssClass,
  1330. cssClass = _ref3$cssClass === void 0 ? '' : _ref3$cssClass,
  1331. _ref3$isPlainText = _ref3.isPlainText,
  1332. isPlainText = _ref3$isPlainText === void 0 ? true : _ref3$isPlainText;
  1333. var w = this.w;
  1334. if (typeof text === 'undefined') text = '';
  1335. if (!textAnchor) {
  1336. textAnchor = 'start';
  1337. }
  1338. if (!foreColor || !foreColor.length) {
  1339. foreColor = w.config.chart.foreColor;
  1340. }
  1341. fontFamily = fontFamily || w.config.chart.fontFamily;
  1342. fontWeight = fontWeight || 'regular';
  1343. var elText;
  1344. if (Array.isArray(text)) {
  1345. elText = w.globals.dom.Paper.text(function (add) {
  1346. for (var i = 0; i < text.length; i++) {
  1347. i === 0 ? add.tspan(text[i]) : add.tspan(text[i]).newLine();
  1348. }
  1349. });
  1350. } else {
  1351. elText = isPlainText ? w.globals.dom.Paper.plain(text) : w.globals.dom.Paper.text(function (add) {
  1352. return add.tspan(text);
  1353. });
  1354. }
  1355. elText.attr({
  1356. x: x,
  1357. y: y,
  1358. 'text-anchor': textAnchor,
  1359. 'dominant-baseline': 'auto',
  1360. 'font-size': fontSize,
  1361. 'font-family': fontFamily,
  1362. 'font-weight': fontWeight,
  1363. fill: foreColor,
  1364. class: 'apexcharts-text ' + cssClass
  1365. });
  1366. elText.node.style.fontFamily = fontFamily;
  1367. elText.node.style.opacity = opacity;
  1368. return elText;
  1369. }
  1370. }, {
  1371. key: "drawMarker",
  1372. value: function drawMarker(x, y, opts) {
  1373. x = x || 0;
  1374. var size = opts.pSize || 0;
  1375. var elPoint = null;
  1376. if (opts.shape === 'square') {
  1377. var radius = opts.pRadius === undefined ? size / 2 : opts.pRadius;
  1378. if (y === null || !size) {
  1379. size = 0;
  1380. radius = 0;
  1381. }
  1382. var nSize = size * 1.2 + radius;
  1383. var p = this.drawRect(nSize, nSize, nSize, nSize, radius);
  1384. p.attr({
  1385. x: x - nSize / 2,
  1386. y: y - nSize / 2,
  1387. cx: x,
  1388. cy: y,
  1389. class: opts.class ? opts.class : '',
  1390. fill: opts.pointFillColor,
  1391. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1392. stroke: opts.pointStrokeColor,
  1393. 'stroke-width': opts.pWidth ? opts.pWidth : 0,
  1394. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1395. });
  1396. elPoint = p;
  1397. } else if (opts.shape === 'circle' || !opts.shape) {
  1398. if (!Utils.isNumber(y)) {
  1399. size = 0;
  1400. y = 0;
  1401. } // let nSize = size - opts.pRadius / 2 < 0 ? 0 : size - opts.pRadius / 2
  1402. elPoint = this.drawCircle(size, {
  1403. cx: x,
  1404. cy: y,
  1405. class: opts.class ? opts.class : '',
  1406. stroke: opts.pointStrokeColor,
  1407. fill: opts.pointFillColor,
  1408. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1409. 'stroke-width': opts.pWidth ? opts.pWidth : 0,
  1410. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1411. });
  1412. }
  1413. return elPoint;
  1414. }
  1415. }, {
  1416. key: "pathMouseEnter",
  1417. value: function pathMouseEnter(path, e) {
  1418. var w = this.w;
  1419. var filters = new Filters(this.ctx);
  1420. var i = parseInt(path.node.getAttribute('index'), 10);
  1421. var j = parseInt(path.node.getAttribute('j'), 10);
  1422. if (typeof w.config.chart.events.dataPointMouseEnter === 'function') {
  1423. w.config.chart.events.dataPointMouseEnter(e, this.ctx, {
  1424. seriesIndex: i,
  1425. dataPointIndex: j,
  1426. w: w
  1427. });
  1428. }
  1429. this.ctx.events.fireEvent('dataPointMouseEnter', [e, this.ctx, {
  1430. seriesIndex: i,
  1431. dataPointIndex: j,
  1432. w: w
  1433. }]);
  1434. if (w.config.states.active.filter.type !== 'none') {
  1435. if (path.node.getAttribute('selected') === 'true') {
  1436. return;
  1437. }
  1438. }
  1439. if (w.config.states.hover.filter.type !== 'none') {
  1440. if (w.config.states.active.filter.type !== 'none' && !w.globals.isTouchDevice) {
  1441. var hoverFilter = w.config.states.hover.filter;
  1442. filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value);
  1443. }
  1444. }
  1445. }
  1446. }, {
  1447. key: "pathMouseLeave",
  1448. value: function pathMouseLeave(path, e) {
  1449. var w = this.w;
  1450. var filters = new Filters(this.ctx);
  1451. var i = parseInt(path.node.getAttribute('index'), 10);
  1452. var j = parseInt(path.node.getAttribute('j'), 10);
  1453. if (typeof w.config.chart.events.dataPointMouseLeave === 'function') {
  1454. w.config.chart.events.dataPointMouseLeave(e, this.ctx, {
  1455. seriesIndex: i,
  1456. dataPointIndex: j,
  1457. w: w
  1458. });
  1459. }
  1460. this.ctx.events.fireEvent('dataPointMouseLeave', [e, this.ctx, {
  1461. seriesIndex: i,
  1462. dataPointIndex: j,
  1463. w: w
  1464. }]);
  1465. if (w.config.states.active.filter.type !== 'none') {
  1466. if (path.node.getAttribute('selected') === 'true') {
  1467. return;
  1468. }
  1469. }
  1470. if (w.config.states.hover.filter.type !== 'none') {
  1471. filters.getDefaultFilter(path, i);
  1472. }
  1473. }
  1474. }, {
  1475. key: "pathMouseDown",
  1476. value: function pathMouseDown(path, e) {
  1477. var w = this.w;
  1478. var filters = new Filters(this.ctx);
  1479. var i = parseInt(path.node.getAttribute('index'), 10);
  1480. var j = parseInt(path.node.getAttribute('j'), 10);
  1481. var selected = 'false';
  1482. if (path.node.getAttribute('selected') === 'true') {
  1483. path.node.setAttribute('selected', 'false');
  1484. if (w.globals.selectedDataPoints[i].indexOf(j) > -1) {
  1485. var index = w.globals.selectedDataPoints[i].indexOf(j);
  1486. w.globals.selectedDataPoints[i].splice(index, 1);
  1487. }
  1488. } else {
  1489. if (!w.config.states.active.allowMultipleDataPointsSelection && w.globals.selectedDataPoints.length > 0) {
  1490. w.globals.selectedDataPoints = [];
  1491. var elPaths = w.globals.dom.Paper.select('.apexcharts-series path').members;
  1492. var elCircles = w.globals.dom.Paper.select('.apexcharts-series circle, .apexcharts-series rect').members;
  1493. var deSelect = function deSelect(els) {
  1494. Array.prototype.forEach.call(els, function (el) {
  1495. el.node.setAttribute('selected', 'false');
  1496. filters.getDefaultFilter(el, i);
  1497. });
  1498. };
  1499. deSelect(elPaths);
  1500. deSelect(elCircles);
  1501. }
  1502. path.node.setAttribute('selected', 'true');
  1503. selected = 'true';
  1504. if (typeof w.globals.selectedDataPoints[i] === 'undefined') {
  1505. w.globals.selectedDataPoints[i] = [];
  1506. }
  1507. w.globals.selectedDataPoints[i].push(j);
  1508. }
  1509. if (selected === 'true') {
  1510. var activeFilter = w.config.states.active.filter;
  1511. if (activeFilter !== 'none') {
  1512. filters.applyFilter(path, i, activeFilter.type, activeFilter.value);
  1513. }
  1514. } else {
  1515. if (w.config.states.active.filter.type !== 'none') {
  1516. filters.getDefaultFilter(path, i);
  1517. }
  1518. }
  1519. if (typeof w.config.chart.events.dataPointSelection === 'function') {
  1520. w.config.chart.events.dataPointSelection(e, this.ctx, {
  1521. selectedDataPoints: w.globals.selectedDataPoints,
  1522. seriesIndex: i,
  1523. dataPointIndex: j,
  1524. w: w
  1525. });
  1526. }
  1527. if (e) {
  1528. this.ctx.events.fireEvent('dataPointSelection', [e, this.ctx, {
  1529. selectedDataPoints: w.globals.selectedDataPoints,
  1530. seriesIndex: i,
  1531. dataPointIndex: j,
  1532. w: w
  1533. }]);
  1534. }
  1535. }
  1536. }, {
  1537. key: "rotateAroundCenter",
  1538. value: function rotateAroundCenter(el) {
  1539. var coord = el.getBBox();
  1540. var x = coord.x + coord.width / 2;
  1541. var y = coord.y + coord.height / 2;
  1542. return {
  1543. x: x,
  1544. y: y
  1545. };
  1546. }
  1547. }, {
  1548. key: "getTextRects",
  1549. value: function getTextRects(text, fontSize, fontFamily, transform) {
  1550. var useBBox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  1551. var w = this.w;
  1552. var virtualText = this.drawText({
  1553. x: -200,
  1554. y: -200,
  1555. text: text,
  1556. textAnchor: 'start',
  1557. fontSize: fontSize,
  1558. fontFamily: fontFamily,
  1559. foreColor: '#fff',
  1560. opacity: 0
  1561. });
  1562. if (transform) {
  1563. virtualText.attr('transform', transform);
  1564. }
  1565. w.globals.dom.Paper.add(virtualText);
  1566. var rect = virtualText.bbox();
  1567. if (!useBBox) {
  1568. rect = virtualText.node.getBoundingClientRect();
  1569. }
  1570. virtualText.remove();
  1571. return {
  1572. width: rect.width,
  1573. height: rect.height
  1574. };
  1575. }
  1576. /**
  1577. * append ... to long text
  1578. * http://stackoverflow.com/questions/9241315/trimming-text-to-a-given-pixel-width-in-svg
  1579. * @memberof Graphics
  1580. **/
  1581. }, {
  1582. key: "placeTextWithEllipsis",
  1583. value: function placeTextWithEllipsis(textObj, textString, width) {
  1584. if (typeof textObj.getComputedTextLength !== 'function') return;
  1585. textObj.textContent = textString;
  1586. if (textString.length > 0) {
  1587. // ellipsis is needed
  1588. if (textObj.getComputedTextLength() >= width / 0.8) {
  1589. for (var x = textString.length - 3; x > 0; x -= 3) {
  1590. if (textObj.getSubStringLength(0, x) <= width / 0.8) {
  1591. textObj.textContent = textString.substring(0, x) + '...';
  1592. return;
  1593. }
  1594. }
  1595. textObj.textContent = '.'; // can't place at all
  1596. }
  1597. }
  1598. }
  1599. }], [{
  1600. key: "setAttrs",
  1601. value: function setAttrs(el, attrs) {
  1602. for (var key in attrs) {
  1603. if (attrs.hasOwnProperty(key)) {
  1604. el.setAttribute(key, attrs[key]);
  1605. }
  1606. }
  1607. }
  1608. }]);
  1609. return Graphics;
  1610. }();
  1611. var Helpers = /*#__PURE__*/function () {
  1612. function Helpers(annoCtx) {
  1613. _classCallCheck(this, Helpers);
  1614. this.w = annoCtx.w;
  1615. this.annoCtx = annoCtx;
  1616. }
  1617. _createClass(Helpers, [{
  1618. key: "setOrientations",
  1619. value: function setOrientations(anno) {
  1620. var annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1621. var w = this.w;
  1622. if (anno.label.orientation === 'vertical') {
  1623. var i = annoIndex !== null ? annoIndex : 0;
  1624. var xAnno = w.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(i, "']"));
  1625. if (xAnno !== null) {
  1626. var xAnnoCoord = xAnno.getBoundingClientRect();
  1627. xAnno.setAttribute('x', parseFloat(xAnno.getAttribute('x')) - xAnnoCoord.height + 4);
  1628. if (anno.label.position === 'top') {
  1629. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) + xAnnoCoord.width);
  1630. } else {
  1631. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) - xAnnoCoord.width);
  1632. }
  1633. var annoRotatingCenter = this.annoCtx.graphics.rotateAroundCenter(xAnno);
  1634. var x = annoRotatingCenter.x;
  1635. var y = annoRotatingCenter.y;
  1636. xAnno.setAttribute('transform', "rotate(-90 ".concat(x, " ").concat(y, ")"));
  1637. }
  1638. }
  1639. }
  1640. }, {
  1641. key: "addBackgroundToAnno",
  1642. value: function addBackgroundToAnno(annoEl, anno) {
  1643. var w = this.w;
  1644. if (!anno.label.text || anno.label.text && !anno.label.text.trim()) return null;
  1645. var elGridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid').getBoundingClientRect();
  1646. var coords = annoEl.getBoundingClientRect();
  1647. var pleft = anno.label.style.padding.left;
  1648. var pright = anno.label.style.padding.right;
  1649. var ptop = anno.label.style.padding.top;
  1650. var pbottom = anno.label.style.padding.bottom;
  1651. if (anno.label.orientation === 'vertical') {
  1652. ptop = anno.label.style.padding.left;
  1653. pbottom = anno.label.style.padding.right;
  1654. pleft = anno.label.style.padding.top;
  1655. pright = anno.label.style.padding.bottom;
  1656. }
  1657. var x1 = coords.left - elGridRect.left - pleft;
  1658. var y1 = coords.top - elGridRect.top - ptop;
  1659. 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);
  1660. if (anno.id) {
  1661. elRect.node.classList.add(anno.id);
  1662. }
  1663. return elRect;
  1664. }
  1665. }, {
  1666. key: "annotationsBackground",
  1667. value: function annotationsBackground() {
  1668. var _this = this;
  1669. var w = this.w;
  1670. var add = function add(anno, i, type) {
  1671. var annoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(i, "']"));
  1672. if (annoLabel) {
  1673. var parent = annoLabel.parentNode;
  1674. var elRect = _this.addBackgroundToAnno(annoLabel, anno);
  1675. if (elRect) {
  1676. parent.insertBefore(elRect.node, annoLabel);
  1677. }
  1678. }
  1679. };
  1680. w.config.annotations.xaxis.map(function (anno, i) {
  1681. add(anno, i, 'xaxis');
  1682. });
  1683. w.config.annotations.yaxis.map(function (anno, i) {
  1684. add(anno, i, 'yaxis');
  1685. });
  1686. w.config.annotations.points.map(function (anno, i) {
  1687. add(anno, i, 'point');
  1688. });
  1689. }
  1690. }, {
  1691. key: "makeAnnotationDraggable",
  1692. value: function makeAnnotationDraggable(el, annoType, index) {
  1693. var w = this.w;
  1694. var anno = w.config.annotations[annoType][index]; // in the draggable annotations, we will mutate the original config
  1695. // object and store the values directly there
  1696. el.draggable().on('dragend', function (de) {
  1697. var x = de.target.getAttribute('x');
  1698. var y = de.target.getAttribute('y');
  1699. var cx = de.target.getAttribute('cx');
  1700. var cy = de.target.getAttribute('cy');
  1701. anno.x = x;
  1702. anno.y = y;
  1703. if (cx && cy) {
  1704. anno.x = cx;
  1705. anno.y = cy;
  1706. }
  1707. });
  1708. el.node.addEventListener('mousedown', function (e) {
  1709. e.stopPropagation();
  1710. el.selectize({
  1711. pointSize: 8,
  1712. rotationPoint: false,
  1713. pointType: 'rect'
  1714. });
  1715. el.resize().on('resizedone', function (re) {
  1716. var width = re.target.getAttribute('width');
  1717. var height = re.target.getAttribute('height');
  1718. var r = re.target.getAttribute('r');
  1719. anno.width = width;
  1720. anno.height = height;
  1721. if (r) {
  1722. anno.radius = r;
  1723. }
  1724. });
  1725. });
  1726. }
  1727. }, {
  1728. key: "getStringX",
  1729. value: function getStringX(x) {
  1730. var w = this.w;
  1731. var rX = x;
  1732. if (w.config.xaxis.convertedCatToNumeric && w.globals.categoryLabels.length) {
  1733. x = w.globals.categoryLabels.indexOf(x) + 1;
  1734. }
  1735. var catIndex = w.globals.labels.indexOf(x);
  1736. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  1737. if (xLabel) {
  1738. rX = parseFloat(xLabel.getAttribute('x'));
  1739. }
  1740. return rX;
  1741. }
  1742. }]);
  1743. return Helpers;
  1744. }();
  1745. var XAnnotations = /*#__PURE__*/function () {
  1746. function XAnnotations(annoCtx) {
  1747. _classCallCheck(this, XAnnotations);
  1748. this.w = annoCtx.w;
  1749. this.annoCtx = annoCtx;
  1750. this.invertAxis = this.annoCtx.invertAxis;
  1751. }
  1752. _createClass(XAnnotations, [{
  1753. key: "addXaxisAnnotation",
  1754. value: function addXaxisAnnotation(anno, parent, index) {
  1755. var w = this.w;
  1756. var min = this.invertAxis ? w.globals.minY : w.globals.minX;
  1757. var max = this.invertAxis ? w.globals.maxY : w.globals.maxX;
  1758. var range = this.invertAxis ? w.globals.yRange[0] : w.globals.xRange;
  1759. var x1 = (anno.x - min) / (range / w.globals.gridWidth);
  1760. if (this.annoCtx.inversedReversedAxis) {
  1761. x1 = (max - anno.x) / (range / w.globals.gridWidth);
  1762. }
  1763. var text = anno.label.text;
  1764. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
  1765. x1 = this.annoCtx.helpers.getStringX(anno.x);
  1766. }
  1767. var strokeDashArray = anno.strokeDashArray;
  1768. if (!Utils.isNumber(x1)) return;
  1769. if (anno.x2 === null || typeof anno.x2 === 'undefined') {
  1770. var line = this.annoCtx.graphics.drawLine(x1 + anno.offsetX, // x1
  1771. 0 + anno.offsetY, // y1
  1772. x1 + anno.offsetX, // x2
  1773. w.globals.gridHeight + anno.offsetY, // y2
  1774. anno.borderColor, // lineColor
  1775. strokeDashArray, //dashArray
  1776. anno.borderWidth);
  1777. parent.appendChild(line.node);
  1778. if (anno.id) {
  1779. line.node.classList.add(anno.id);
  1780. }
  1781. } else {
  1782. var x2 = (anno.x2 - min) / (range / w.globals.gridWidth);
  1783. if (this.annoCtx.inversedReversedAxis) {
  1784. x2 = (max - anno.x2) / (range / w.globals.gridWidth);
  1785. }
  1786. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
  1787. x2 = this.annoCtx.helpers.getStringX(anno.x2);
  1788. }
  1789. if (x2 < x1) {
  1790. var temp = x1;
  1791. x1 = x2;
  1792. x2 = temp;
  1793. }
  1794. var rect = this.annoCtx.graphics.drawRect(x1 + anno.offsetX, // x1
  1795. 0 + anno.offsetY, // y1
  1796. x2 - x1, // x2
  1797. w.globals.gridHeight + anno.offsetY, // y2
  1798. 0, // radius
  1799. anno.fillColor, // color
  1800. anno.opacity, // opacity,
  1801. 1, // strokeWidth
  1802. anno.borderColor, // strokeColor
  1803. strokeDashArray // stokeDashArray
  1804. );
  1805. rect.node.classList.add('apexcharts-annotation-rect');
  1806. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  1807. parent.appendChild(rect.node);
  1808. if (anno.id) {
  1809. rect.node.classList.add(anno.id);
  1810. }
  1811. }
  1812. var textY = anno.label.position === 'top' ? 4 : w.globals.gridHeight;
  1813. var textRects = this.annoCtx.graphics.getTextRects(text, parseFloat(anno.label.style.fontSize));
  1814. var elText = this.annoCtx.graphics.drawText({
  1815. x: x1 + anno.label.offsetX,
  1816. y: textY + anno.label.offsetY - (anno.label.orientation === 'vertical' ? anno.label.position === 'top' ? textRects.width / 2 - 12 : -textRects.width / 2 : 0),
  1817. text: text,
  1818. textAnchor: anno.label.textAnchor,
  1819. fontSize: anno.label.style.fontSize,
  1820. fontFamily: anno.label.style.fontFamily,
  1821. fontWeight: anno.label.style.fontWeight,
  1822. foreColor: anno.label.style.color,
  1823. cssClass: "apexcharts-xaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  1824. });
  1825. elText.attr({
  1826. rel: index
  1827. });
  1828. parent.appendChild(elText.node); // after placing the annotations on svg, set any vertically placed annotations
  1829. this.annoCtx.helpers.setOrientations(anno, index);
  1830. }
  1831. }, {
  1832. key: "drawXAxisAnnotations",
  1833. value: function drawXAxisAnnotations() {
  1834. var _this = this;
  1835. var w = this.w;
  1836. var elg = this.annoCtx.graphics.group({
  1837. class: 'apexcharts-xaxis-annotations'
  1838. });
  1839. w.config.annotations.xaxis.map(function (anno, index) {
  1840. _this.addXaxisAnnotation(anno, elg.node, index);
  1841. });
  1842. return elg;
  1843. }
  1844. }]);
  1845. return XAnnotations;
  1846. }();
  1847. var YAnnotations = /*#__PURE__*/function () {
  1848. function YAnnotations(annoCtx) {
  1849. _classCallCheck(this, YAnnotations);
  1850. this.w = annoCtx.w;
  1851. this.annoCtx = annoCtx;
  1852. }
  1853. _createClass(YAnnotations, [{
  1854. key: "addYaxisAnnotation",
  1855. value: function addYaxisAnnotation(anno, parent, index) {
  1856. var w = this.w;
  1857. var strokeDashArray = anno.strokeDashArray;
  1858. var y1 = this._getY1Y2('y1', anno);
  1859. var y2;
  1860. var text = anno.label.text;
  1861. if (anno.y2 === null || typeof anno.y2 === 'undefined') {
  1862. var line = this.annoCtx.graphics.drawLine(0 + anno.offsetX, // x1
  1863. y1 + anno.offsetY, // y1
  1864. w.globals.gridWidth + anno.offsetX, // x2
  1865. y1 + anno.offsetY, // y2
  1866. anno.borderColor, // lineColor
  1867. strokeDashArray, // dashArray
  1868. anno.borderWidth);
  1869. parent.appendChild(line.node);
  1870. if (anno.id) {
  1871. line.node.classList.add(anno.id);
  1872. }
  1873. } else {
  1874. y2 = this._getY1Y2('y2', anno);
  1875. if (y2 > y1) {
  1876. var temp = y1;
  1877. y1 = y2;
  1878. y2 = temp;
  1879. }
  1880. var rect = this.annoCtx.graphics.drawRect(0 + anno.offsetX, // x1
  1881. y2 + anno.offsetY, // y1
  1882. w.globals.gridWidth + anno.offsetX, // x2
  1883. y1 - y2, // y2
  1884. 0, // radius
  1885. anno.fillColor, // color
  1886. anno.opacity, // opacity,
  1887. 1, // strokeWidth
  1888. anno.borderColor, // strokeColor
  1889. strokeDashArray // stokeDashArray
  1890. );
  1891. rect.node.classList.add('apexcharts-annotation-rect');
  1892. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  1893. parent.appendChild(rect.node);
  1894. if (anno.id) {
  1895. rect.node.classList.add(anno.id);
  1896. }
  1897. }
  1898. var textX = anno.label.position === 'right' ? w.globals.gridWidth : 0;
  1899. var elText = this.annoCtx.graphics.drawText({
  1900. x: textX + anno.label.offsetX,
  1901. y: (y2 || y1) + anno.label.offsetY - 3,
  1902. text: text,
  1903. textAnchor: anno.label.textAnchor,
  1904. fontSize: anno.label.style.fontSize,
  1905. fontFamily: anno.label.style.fontFamily,
  1906. fontWeight: anno.label.style.fontWeight,
  1907. foreColor: anno.label.style.color,
  1908. cssClass: "apexcharts-yaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  1909. });
  1910. elText.attr({
  1911. rel: index
  1912. });
  1913. parent.appendChild(elText.node);
  1914. }
  1915. }, {
  1916. key: "_getY1Y2",
  1917. value: function _getY1Y2(type, anno) {
  1918. var y = type === 'y1' ? anno.y : anno.y2;
  1919. var yP;
  1920. var w = this.w;
  1921. if (this.annoCtx.invertAxis) {
  1922. var catIndex = w.globals.labels.indexOf(y);
  1923. if (w.config.xaxis.convertedCatToNumeric) {
  1924. catIndex = w.globals.categoryLabels.indexOf(y);
  1925. }
  1926. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  1927. if (xLabel) {
  1928. yP = parseFloat(xLabel.getAttribute('y'));
  1929. }
  1930. } else {
  1931. yP = w.globals.gridHeight - (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1932. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  1933. yP = (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1934. }
  1935. }
  1936. return yP;
  1937. }
  1938. }, {
  1939. key: "drawYAxisAnnotations",
  1940. value: function drawYAxisAnnotations() {
  1941. var _this = this;
  1942. var w = this.w;
  1943. var elg = this.annoCtx.graphics.group({
  1944. class: 'apexcharts-yaxis-annotations'
  1945. });
  1946. w.config.annotations.yaxis.map(function (anno, index) {
  1947. _this.addYaxisAnnotation(anno, elg.node, index);
  1948. });
  1949. return elg;
  1950. }
  1951. }]);
  1952. return YAnnotations;
  1953. }();
  1954. var PointAnnotations = /*#__PURE__*/function () {
  1955. function PointAnnotations(annoCtx) {
  1956. _classCallCheck(this, PointAnnotations);
  1957. this.w = annoCtx.w;
  1958. this.annoCtx = annoCtx;
  1959. }
  1960. _createClass(PointAnnotations, [{
  1961. key: "addPointAnnotation",
  1962. value: function addPointAnnotation(anno, parent, index) {
  1963. var w = this.w;
  1964. var x = 0;
  1965. var y = 0;
  1966. var pointY = 0;
  1967. if (this.annoCtx.invertAxis) {
  1968. console.warn('Point annotation is not supported in horizontal bar charts.');
  1969. }
  1970. if (typeof anno.x === 'string') {
  1971. var catIndex = w.globals.labels.indexOf(anno.x);
  1972. if (w.config.xaxis.convertedCatToNumeric) {
  1973. catIndex = w.globals.categoryLabels.indexOf(anno.x);
  1974. }
  1975. x = this.annoCtx.helpers.getStringX(anno.x);
  1976. var annoY = anno.y;
  1977. if (anno.y === null) {
  1978. annoY = w.globals.series[anno.seriesIndex][catIndex];
  1979. }
  1980. 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;
  1981. pointY = w.globals.gridHeight - (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1982. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  1983. y = (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) + parseFloat(anno.label.style.fontSize) + anno.marker.size;
  1984. pointY = (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1985. }
  1986. } else {
  1987. x = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth);
  1988. 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;
  1989. pointY = w.globals.gridHeight - (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1990. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  1991. 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;
  1992. pointY = (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  1993. }
  1994. }
  1995. if (!Utils.isNumber(x)) return;
  1996. var optsPoints = {
  1997. pSize: anno.marker.size,
  1998. pWidth: anno.marker.strokeWidth,
  1999. pointFillColor: anno.marker.fillColor,
  2000. pointStrokeColor: anno.marker.strokeColor,
  2001. shape: anno.marker.shape,
  2002. pRadius: anno.marker.radius,
  2003. class: "apexcharts-point-annotation-marker ".concat(anno.marker.cssClass, " ").concat(anno.id ? anno.id : '')
  2004. };
  2005. var point = this.annoCtx.graphics.drawMarker(x + anno.marker.offsetX, pointY + anno.marker.offsetY, optsPoints);
  2006. parent.appendChild(point.node);
  2007. var text = anno.label.text ? anno.label.text : '';
  2008. var elText = this.annoCtx.graphics.drawText({
  2009. x: x + anno.label.offsetX,
  2010. y: y + anno.label.offsetY,
  2011. text: text,
  2012. textAnchor: anno.label.textAnchor,
  2013. fontSize: anno.label.style.fontSize,
  2014. fontFamily: anno.label.style.fontFamily,
  2015. fontWeight: anno.label.style.fontWeight,
  2016. foreColor: anno.label.style.color,
  2017. cssClass: "apexcharts-point-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2018. });
  2019. elText.attr({
  2020. rel: index
  2021. });
  2022. parent.appendChild(elText.node); // TODO: deprecate this as we will use custom
  2023. if (anno.customSVG.SVG) {
  2024. var g = this.annoCtx.graphics.group({
  2025. class: 'apexcharts-point-annotations-custom-svg ' + anno.customSVG.cssClass
  2026. });
  2027. g.attr({
  2028. transform: "translate(".concat(x + anno.customSVG.offsetX, ", ").concat(y + anno.customSVG.offsetY, ")")
  2029. });
  2030. g.node.innerHTML = anno.customSVG.SVG;
  2031. parent.appendChild(g.node);
  2032. }
  2033. if (anno.image.path) {
  2034. var imgWidth = anno.image.width ? anno.image.width : 20;
  2035. var imgHeight = anno.image.height ? anno.image.height : 20;
  2036. this.annoCtx.addImage({
  2037. x: x + anno.image.offsetX - imgWidth / 2,
  2038. y: y + anno.image.offsetY - imgHeight / 2,
  2039. width: imgWidth,
  2040. height: imgHeight,
  2041. path: anno.image.path,
  2042. appendTo: '.apexcharts-point-annotations'
  2043. });
  2044. }
  2045. }
  2046. }, {
  2047. key: "drawPointAnnotations",
  2048. value: function drawPointAnnotations() {
  2049. var _this = this;
  2050. var w = this.w;
  2051. var elg = this.annoCtx.graphics.group({
  2052. class: 'apexcharts-point-annotations'
  2053. });
  2054. w.config.annotations.points.map(function (anno, index) {
  2055. _this.addPointAnnotation(anno, elg.node, index);
  2056. });
  2057. return elg;
  2058. }
  2059. }]);
  2060. return PointAnnotations;
  2061. }();
  2062. const name = "en";
  2063. const options = {
  2064. months: [
  2065. "January",
  2066. "February",
  2067. "March",
  2068. "April",
  2069. "May",
  2070. "June",
  2071. "July",
  2072. "August",
  2073. "September",
  2074. "October",
  2075. "November",
  2076. "December"
  2077. ],
  2078. shortMonths: [
  2079. "Jan",
  2080. "Feb",
  2081. "Mar",
  2082. "Apr",
  2083. "May",
  2084. "Jun",
  2085. "Jul",
  2086. "Aug",
  2087. "Sep",
  2088. "Oct",
  2089. "Nov",
  2090. "Dec"
  2091. ],
  2092. days: [
  2093. "Sunday",
  2094. "Monday",
  2095. "Tuesday",
  2096. "Wednesday",
  2097. "Thursday",
  2098. "Friday",
  2099. "Saturday"
  2100. ],
  2101. shortDays: [
  2102. "Sun",
  2103. "Mon",
  2104. "Tue",
  2105. "Wed",
  2106. "Thu",
  2107. "Fri",
  2108. "Sat"
  2109. ],
  2110. toolbar: {
  2111. exportToSVG: "Download SVG",
  2112. exportToPNG: "Download PNG",
  2113. exportToCSV: "Download CSV",
  2114. menu: "Menu",
  2115. selection: "Selection",
  2116. selectionZoom: "Selection Zoom",
  2117. zoomIn: "Zoom In",
  2118. zoomOut: "Zoom Out",
  2119. pan: "Panning",
  2120. reset: "Reset Zoom"
  2121. }
  2122. };
  2123. var en = {
  2124. name: name,
  2125. options: options
  2126. };
  2127. var Options = /*#__PURE__*/function () {
  2128. function Options() {
  2129. _classCallCheck(this, Options);
  2130. this.yAxis = {
  2131. show: true,
  2132. showAlways: false,
  2133. showForNullSeries: true,
  2134. seriesName: undefined,
  2135. opposite: false,
  2136. reversed: false,
  2137. logarithmic: false,
  2138. tickAmount: undefined,
  2139. forceNiceScale: false,
  2140. max: undefined,
  2141. min: undefined,
  2142. floating: false,
  2143. decimalsInFloat: undefined,
  2144. labels: {
  2145. show: true,
  2146. minWidth: 0,
  2147. maxWidth: 160,
  2148. offsetX: 0,
  2149. offsetY: 0,
  2150. align: undefined,
  2151. rotate: 0,
  2152. padding: 20,
  2153. style: {
  2154. colors: [],
  2155. fontSize: '11px',
  2156. fontWeight: 400,
  2157. fontFamily: undefined,
  2158. cssClass: ''
  2159. },
  2160. formatter: undefined
  2161. },
  2162. axisBorder: {
  2163. show: false,
  2164. color: '#e0e0e0',
  2165. width: 1,
  2166. offsetX: 0,
  2167. offsetY: 0
  2168. },
  2169. axisTicks: {
  2170. show: false,
  2171. color: '#e0e0e0',
  2172. width: 6,
  2173. offsetX: 0,
  2174. offsetY: 0
  2175. },
  2176. title: {
  2177. text: undefined,
  2178. rotate: 90,
  2179. offsetY: 0,
  2180. offsetX: 0,
  2181. style: {
  2182. color: undefined,
  2183. fontSize: '11px',
  2184. fontWeight: 900,
  2185. fontFamily: undefined,
  2186. cssClass: ''
  2187. }
  2188. },
  2189. tooltip: {
  2190. enabled: false,
  2191. offsetX: 0
  2192. },
  2193. crosshairs: {
  2194. show: true,
  2195. position: 'front',
  2196. stroke: {
  2197. color: '#b6b6b6',
  2198. width: 1,
  2199. dashArray: 0
  2200. }
  2201. }
  2202. };
  2203. this.pointAnnotation = {
  2204. x: 0,
  2205. y: null,
  2206. yAxisIndex: 0,
  2207. seriesIndex: 0,
  2208. marker: {
  2209. size: 4,
  2210. fillColor: '#fff',
  2211. strokeWidth: 2,
  2212. strokeColor: '#333',
  2213. shape: 'circle',
  2214. offsetX: 0,
  2215. offsetY: 0,
  2216. radius: 2,
  2217. cssClass: ''
  2218. },
  2219. label: {
  2220. borderColor: '#c2c2c2',
  2221. borderWidth: 1,
  2222. text: undefined,
  2223. textAnchor: 'middle',
  2224. offsetX: 0,
  2225. offsetY: -15,
  2226. style: {
  2227. background: '#fff',
  2228. color: undefined,
  2229. fontSize: '11px',
  2230. fontFamily: undefined,
  2231. fontWeight: 400,
  2232. cssClass: '',
  2233. padding: {
  2234. left: 5,
  2235. right: 5,
  2236. top: 2,
  2237. bottom: 2
  2238. }
  2239. }
  2240. },
  2241. customSVG: {
  2242. // this will be deprecated in the next major version as it is going to be replaced with a better alternative below
  2243. SVG: undefined,
  2244. cssClass: undefined,
  2245. offsetX: 0,
  2246. offsetY: 0
  2247. },
  2248. image: {
  2249. path: undefined,
  2250. width: 20,
  2251. height: 20,
  2252. offsetX: 0,
  2253. offsetY: 0
  2254. }
  2255. };
  2256. this.yAxisAnnotation = {
  2257. y: 0,
  2258. y2: null,
  2259. strokeDashArray: 1,
  2260. fillColor: '#c2c2c2',
  2261. borderColor: '#c2c2c2',
  2262. borderWidth: 1,
  2263. opacity: 0.3,
  2264. offsetX: 0,
  2265. offsetY: 0,
  2266. yAxisIndex: 0,
  2267. label: {
  2268. borderColor: '#c2c2c2',
  2269. borderWidth: 1,
  2270. text: undefined,
  2271. textAnchor: 'end',
  2272. position: 'right',
  2273. offsetX: 0,
  2274. offsetY: -3,
  2275. style: {
  2276. background: '#fff',
  2277. color: undefined,
  2278. fontSize: '11px',
  2279. fontFamily: undefined,
  2280. fontWeight: 400,
  2281. cssClass: '',
  2282. padding: {
  2283. left: 5,
  2284. right: 5,
  2285. top: 2,
  2286. bottom: 2
  2287. }
  2288. }
  2289. }
  2290. };
  2291. this.xAxisAnnotation = {
  2292. x: 0,
  2293. x2: null,
  2294. strokeDashArray: 1,
  2295. fillColor: '#c2c2c2',
  2296. borderColor: '#c2c2c2',
  2297. borderWidth: 1,
  2298. opacity: 0.3,
  2299. offsetX: 0,
  2300. offsetY: 0,
  2301. label: {
  2302. borderColor: '#c2c2c2',
  2303. borderWidth: 1,
  2304. text: undefined,
  2305. textAnchor: 'middle',
  2306. orientation: 'vertical',
  2307. position: 'top',
  2308. offsetX: 0,
  2309. offsetY: 0,
  2310. style: {
  2311. background: '#fff',
  2312. color: undefined,
  2313. fontSize: '11px',
  2314. fontFamily: undefined,
  2315. fontWeight: 400,
  2316. cssClass: '',
  2317. padding: {
  2318. left: 5,
  2319. right: 5,
  2320. top: 2,
  2321. bottom: 2
  2322. }
  2323. }
  2324. }
  2325. };
  2326. this.text = {
  2327. x: 0,
  2328. y: 0,
  2329. text: '',
  2330. textAnchor: 'start',
  2331. foreColor: undefined,
  2332. fontSize: '13px',
  2333. fontFamily: undefined,
  2334. fontWeight: 400,
  2335. appendTo: '.apexcharts-annotations',
  2336. backgroundColor: 'transparent',
  2337. borderColor: '#c2c2c2',
  2338. borderRadius: 0,
  2339. borderWidth: 0,
  2340. paddingLeft: 4,
  2341. paddingRight: 4,
  2342. paddingTop: 2,
  2343. paddingBottom: 2
  2344. };
  2345. this.shape = {
  2346. x: 0,
  2347. y: 0,
  2348. type: 'rect',
  2349. width: '100%',
  2350. // accepts percentage as well as fixed numbers
  2351. height: 50,
  2352. appendTo: '.apexcharts-annotations',
  2353. backgroundColor: '#fff',
  2354. opacity: 1,
  2355. borderWidth: 0,
  2356. borderRadius: 4,
  2357. borderColor: '#c2c2c2'
  2358. };
  2359. }
  2360. _createClass(Options, [{
  2361. key: "init",
  2362. value: function init() {
  2363. return {
  2364. annotations: {
  2365. position: 'front',
  2366. yaxis: [this.yAxisAnnotation],
  2367. xaxis: [this.xAxisAnnotation],
  2368. points: [this.pointAnnotation],
  2369. texts: [],
  2370. images: [],
  2371. shapes: []
  2372. },
  2373. chart: {
  2374. animations: {
  2375. enabled: true,
  2376. easing: 'easeinout',
  2377. // linear, easeout, easein, easeinout, swing, bounce, elastic
  2378. speed: 800,
  2379. animateGradually: {
  2380. delay: 150,
  2381. enabled: true
  2382. },
  2383. dynamicAnimation: {
  2384. enabled: true,
  2385. speed: 350
  2386. }
  2387. },
  2388. background: 'transparent',
  2389. locales: [en],
  2390. defaultLocale: 'en',
  2391. dropShadow: {
  2392. enabled: false,
  2393. enabledOnSeries: undefined,
  2394. top: 2,
  2395. left: 2,
  2396. blur: 4,
  2397. color: '#000',
  2398. opacity: 0.35
  2399. },
  2400. events: {
  2401. animationEnd: undefined,
  2402. beforeMount: undefined,
  2403. mounted: undefined,
  2404. updated: undefined,
  2405. click: undefined,
  2406. mouseMove: undefined,
  2407. legendClick: undefined,
  2408. markerClick: undefined,
  2409. selection: undefined,
  2410. dataPointSelection: undefined,
  2411. dataPointMouseEnter: undefined,
  2412. dataPointMouseLeave: undefined,
  2413. beforeZoom: undefined,
  2414. zoomed: undefined,
  2415. scrolled: undefined
  2416. },
  2417. foreColor: '#373d3f',
  2418. fontFamily: 'Helvetica, Arial, sans-serif',
  2419. height: 'auto',
  2420. parentHeightOffset: 15,
  2421. redrawOnParentResize: true,
  2422. id: undefined,
  2423. group: undefined,
  2424. offsetX: 0,
  2425. offsetY: 0,
  2426. selection: {
  2427. enabled: false,
  2428. type: 'x',
  2429. // selectedPoints: undefined, // default datapoints that should be selected automatically
  2430. fill: {
  2431. color: '#24292e',
  2432. opacity: 0.1
  2433. },
  2434. stroke: {
  2435. width: 1,
  2436. color: '#24292e',
  2437. opacity: 0.4,
  2438. dashArray: 3
  2439. },
  2440. xaxis: {
  2441. min: undefined,
  2442. max: undefined
  2443. },
  2444. yaxis: {
  2445. min: undefined,
  2446. max: undefined
  2447. }
  2448. },
  2449. sparkline: {
  2450. enabled: false
  2451. },
  2452. brush: {
  2453. enabled: false,
  2454. autoScaleYaxis: true,
  2455. target: undefined
  2456. },
  2457. stacked: false,
  2458. stackType: 'normal',
  2459. toolbar: {
  2460. show: true,
  2461. offsetX: 0,
  2462. offsetY: 0,
  2463. tools: {
  2464. download: true,
  2465. selection: true,
  2466. zoom: true,
  2467. zoomin: true,
  2468. zoomout: true,
  2469. pan: true,
  2470. reset: true,
  2471. customIcons: []
  2472. },
  2473. autoSelected: 'zoom' // accepts -> zoom, pan, selection
  2474. },
  2475. type: 'line',
  2476. width: '100%',
  2477. zoom: {
  2478. enabled: true,
  2479. type: 'x',
  2480. autoScaleYaxis: false,
  2481. zoomedArea: {
  2482. fill: {
  2483. color: '#90CAF9',
  2484. opacity: 0.4
  2485. },
  2486. stroke: {
  2487. color: '#0D47A1',
  2488. opacity: 0.4,
  2489. width: 1
  2490. }
  2491. }
  2492. }
  2493. },
  2494. plotOptions: {
  2495. bar: {
  2496. horizontal: false,
  2497. columnWidth: '70%',
  2498. // should be in percent 0 - 100
  2499. barHeight: '70%',
  2500. // should be in percent 0 - 100
  2501. distributed: false,
  2502. startingShape: 'flat',
  2503. endingShape: 'flat',
  2504. colors: {
  2505. ranges: [],
  2506. backgroundBarColors: [],
  2507. backgroundBarOpacity: 1,
  2508. backgroundBarRadius: 0
  2509. },
  2510. dataLabels: {
  2511. position: 'top',
  2512. // top, center, bottom
  2513. maxItems: 100,
  2514. hideOverflowingLabels: true,
  2515. orientation: 'horizontal' // TODO: provide stackedLabels for stacked charts which gives additions of values
  2516. }
  2517. },
  2518. bubble: {
  2519. minBubbleRadius: undefined,
  2520. maxBubbleRadius: undefined
  2521. },
  2522. candlestick: {
  2523. colors: {
  2524. upward: '#00B746',
  2525. downward: '#EF403C'
  2526. },
  2527. wick: {
  2528. useFillColor: true
  2529. }
  2530. },
  2531. heatmap: {
  2532. radius: 2,
  2533. enableShades: true,
  2534. shadeIntensity: 0.5,
  2535. reverseNegativeShade: false,
  2536. distributed: false,
  2537. useFillColorAsStroke: false,
  2538. colorScale: {
  2539. inverse: false,
  2540. ranges: [],
  2541. min: undefined,
  2542. max: undefined
  2543. }
  2544. },
  2545. radialBar: {
  2546. inverseOrder: false,
  2547. startAngle: 0,
  2548. endAngle: 360,
  2549. offsetX: 0,
  2550. offsetY: 0,
  2551. hollow: {
  2552. margin: 5,
  2553. size: '50%',
  2554. background: 'transparent',
  2555. image: undefined,
  2556. imageWidth: 150,
  2557. imageHeight: 150,
  2558. imageOffsetX: 0,
  2559. imageOffsetY: 0,
  2560. imageClipped: true,
  2561. position: 'front',
  2562. dropShadow: {
  2563. enabled: false,
  2564. top: 0,
  2565. left: 0,
  2566. blur: 3,
  2567. color: '#000',
  2568. opacity: 0.5
  2569. }
  2570. },
  2571. track: {
  2572. show: true,
  2573. startAngle: undefined,
  2574. endAngle: undefined,
  2575. background: '#f2f2f2',
  2576. strokeWidth: '97%',
  2577. opacity: 1,
  2578. margin: 5,
  2579. // margin is in pixels
  2580. dropShadow: {
  2581. enabled: false,
  2582. top: 0,
  2583. left: 0,
  2584. blur: 3,
  2585. color: '#000',
  2586. opacity: 0.5
  2587. }
  2588. },
  2589. dataLabels: {
  2590. show: true,
  2591. name: {
  2592. show: true,
  2593. fontSize: '16px',
  2594. fontFamily: undefined,
  2595. fontWeight: 600,
  2596. color: undefined,
  2597. offsetY: 0,
  2598. formatter: function formatter(val) {
  2599. return val;
  2600. }
  2601. },
  2602. value: {
  2603. show: true,
  2604. fontSize: '14px',
  2605. fontFamily: undefined,
  2606. fontWeight: 400,
  2607. color: undefined,
  2608. offsetY: 16,
  2609. formatter: function formatter(val) {
  2610. return val + '%';
  2611. }
  2612. },
  2613. total: {
  2614. show: false,
  2615. label: 'Total',
  2616. fontSize: '16px',
  2617. fontWeight: 600,
  2618. fontFamily: undefined,
  2619. color: undefined,
  2620. formatter: function formatter(w) {
  2621. return w.globals.seriesTotals.reduce(function (a, b) {
  2622. return a + b;
  2623. }, 0) / w.globals.series.length + '%';
  2624. }
  2625. }
  2626. }
  2627. },
  2628. pie: {
  2629. customScale: 1,
  2630. offsetX: 0,
  2631. offsetY: 0,
  2632. expandOnClick: true,
  2633. dataLabels: {
  2634. // These are the percentage values which are displayed on slice
  2635. offset: 0,
  2636. // offset by which labels will move outside
  2637. minAngleToShowLabel: 10
  2638. },
  2639. donut: {
  2640. size: '65%',
  2641. background: 'transparent',
  2642. labels: {
  2643. // These are the inner labels appearing inside donut
  2644. show: false,
  2645. name: {
  2646. show: true,
  2647. fontSize: '16px',
  2648. fontFamily: undefined,
  2649. fontWeight: 600,
  2650. color: undefined,
  2651. offsetY: -10,
  2652. formatter: function formatter(val) {
  2653. return val;
  2654. }
  2655. },
  2656. value: {
  2657. show: true,
  2658. fontSize: '20px',
  2659. fontFamily: undefined,
  2660. fontWeight: 400,
  2661. color: undefined,
  2662. offsetY: 10,
  2663. formatter: function formatter(val) {
  2664. return val;
  2665. }
  2666. },
  2667. total: {
  2668. show: false,
  2669. showAlways: false,
  2670. label: 'Total',
  2671. fontSize: '16px',
  2672. fontWeight: 400,
  2673. fontFamily: undefined,
  2674. color: undefined,
  2675. formatter: function formatter(w) {
  2676. return w.globals.seriesTotals.reduce(function (a, b) {
  2677. return a + b;
  2678. }, 0);
  2679. }
  2680. }
  2681. }
  2682. }
  2683. },
  2684. radar: {
  2685. size: undefined,
  2686. offsetX: 0,
  2687. offsetY: 0,
  2688. polygons: {
  2689. // strokeColor: '#e8e8e8', // should be deprecated in the minor version i.e 3.2
  2690. strokeColors: '#e8e8e8',
  2691. connectorColors: '#e8e8e8',
  2692. fill: {
  2693. colors: undefined
  2694. }
  2695. }
  2696. }
  2697. },
  2698. colors: undefined,
  2699. dataLabels: {
  2700. enabled: true,
  2701. enabledOnSeries: undefined,
  2702. formatter: function formatter(val) {
  2703. return val !== null ? val : '';
  2704. },
  2705. textAnchor: 'middle',
  2706. distributed: false,
  2707. offsetX: 0,
  2708. offsetY: 0,
  2709. style: {
  2710. fontSize: '12px',
  2711. fontFamily: undefined,
  2712. fontWeight: 600,
  2713. colors: undefined
  2714. },
  2715. background: {
  2716. enabled: true,
  2717. foreColor: '#fff',
  2718. borderRadius: 2,
  2719. padding: 4,
  2720. opacity: 0.9,
  2721. borderWidth: 1,
  2722. borderColor: '#fff',
  2723. dropShadow: {
  2724. enabled: false,
  2725. top: 1,
  2726. left: 1,
  2727. blur: 1,
  2728. color: '#000',
  2729. opacity: 0.45
  2730. }
  2731. },
  2732. dropShadow: {
  2733. enabled: false,
  2734. top: 1,
  2735. left: 1,
  2736. blur: 1,
  2737. color: '#000',
  2738. opacity: 0.45
  2739. }
  2740. },
  2741. fill: {
  2742. type: 'solid',
  2743. colors: undefined,
  2744. // array of colors
  2745. opacity: 0.85,
  2746. gradient: {
  2747. shade: 'dark',
  2748. type: 'horizontal',
  2749. shadeIntensity: 0.5,
  2750. gradientToColors: undefined,
  2751. inverseColors: true,
  2752. opacityFrom: 1,
  2753. opacityTo: 1,
  2754. stops: [0, 50, 100],
  2755. colorStops: []
  2756. },
  2757. image: {
  2758. src: [],
  2759. width: undefined,
  2760. // optional
  2761. height: undefined // optional
  2762. },
  2763. pattern: {
  2764. style: 'squares',
  2765. // String | Array of Strings
  2766. width: 6,
  2767. height: 6,
  2768. strokeWidth: 2
  2769. }
  2770. },
  2771. grid: {
  2772. show: true,
  2773. borderColor: '#e0e0e0',
  2774. strokeDashArray: 0,
  2775. position: 'back',
  2776. xaxis: {
  2777. lines: {
  2778. show: false
  2779. }
  2780. },
  2781. yaxis: {
  2782. lines: {
  2783. show: true
  2784. }
  2785. },
  2786. row: {
  2787. colors: undefined,
  2788. // takes as array which will be repeated on rows
  2789. opacity: 0.5
  2790. },
  2791. column: {
  2792. colors: undefined,
  2793. // takes an array which will be repeated on columns
  2794. opacity: 0.5
  2795. },
  2796. padding: {
  2797. top: 0,
  2798. right: 10,
  2799. bottom: 0,
  2800. left: 12
  2801. }
  2802. },
  2803. labels: [],
  2804. legend: {
  2805. show: true,
  2806. showForSingleSeries: false,
  2807. showForNullSeries: true,
  2808. showForZeroSeries: true,
  2809. floating: false,
  2810. position: 'bottom',
  2811. // whether to position legends in 1 of 4
  2812. // direction - top, bottom, left, right
  2813. horizontalAlign: 'center',
  2814. // when position top/bottom, you can specify whether to align legends left, right or center
  2815. inverseOrder: false,
  2816. fontSize: '12px',
  2817. fontFamily: undefined,
  2818. fontWeight: 400,
  2819. width: undefined,
  2820. height: undefined,
  2821. formatter: undefined,
  2822. tooltipHoverFormatter: undefined,
  2823. offsetX: -20,
  2824. offsetY: 0,
  2825. labels: {
  2826. colors: undefined,
  2827. useSeriesColors: false
  2828. },
  2829. markers: {
  2830. width: 12,
  2831. height: 12,
  2832. strokeWidth: 0,
  2833. fillColors: undefined,
  2834. strokeColor: '#fff',
  2835. radius: 12,
  2836. customHTML: undefined,
  2837. offsetX: 0,
  2838. offsetY: 0,
  2839. onClick: undefined
  2840. },
  2841. itemMargin: {
  2842. horizontal: 5,
  2843. vertical: 0
  2844. },
  2845. onItemClick: {
  2846. toggleDataSeries: true
  2847. },
  2848. onItemHover: {
  2849. highlightDataSeries: true
  2850. }
  2851. },
  2852. markers: {
  2853. discrete: [],
  2854. size: 0,
  2855. colors: undefined,
  2856. //strokeColor: '#fff', // TODO: deprecate in major version 4.0
  2857. strokeColors: '#fff',
  2858. strokeWidth: 2,
  2859. strokeOpacity: 0.9,
  2860. strokeDashArray: 0,
  2861. fillOpacity: 1,
  2862. shape: 'circle',
  2863. radius: 2,
  2864. offsetX: 0,
  2865. offsetY: 0,
  2866. onClick: undefined,
  2867. onDblClick: undefined,
  2868. showNullDataPoints: true,
  2869. hover: {
  2870. size: undefined,
  2871. sizeOffset: 3
  2872. }
  2873. },
  2874. noData: {
  2875. text: undefined,
  2876. align: 'center',
  2877. verticalAlign: 'middle',
  2878. offsetX: 0,
  2879. offsetY: 0,
  2880. style: {
  2881. color: undefined,
  2882. fontSize: '14px',
  2883. fontFamily: undefined
  2884. }
  2885. },
  2886. responsive: [],
  2887. // breakpoints should follow ascending order 400, then 700, then 1000
  2888. series: undefined,
  2889. states: {
  2890. normal: {
  2891. filter: {
  2892. type: 'none',
  2893. value: 0
  2894. }
  2895. },
  2896. hover: {
  2897. filter: {
  2898. type: 'lighten',
  2899. value: 0.15
  2900. }
  2901. },
  2902. active: {
  2903. allowMultipleDataPointsSelection: false,
  2904. filter: {
  2905. type: 'darken',
  2906. value: 0.65
  2907. }
  2908. }
  2909. },
  2910. title: {
  2911. text: undefined,
  2912. align: 'left',
  2913. margin: 5,
  2914. offsetX: 0,
  2915. offsetY: 0,
  2916. floating: false,
  2917. style: {
  2918. fontSize: '14px',
  2919. fontWeight: 900,
  2920. fontFamily: undefined,
  2921. color: undefined
  2922. }
  2923. },
  2924. subtitle: {
  2925. text: undefined,
  2926. align: 'left',
  2927. margin: 5,
  2928. offsetX: 0,
  2929. offsetY: 30,
  2930. floating: false,
  2931. style: {
  2932. fontSize: '12px',
  2933. fontWeight: 400,
  2934. fontFamily: undefined,
  2935. color: undefined
  2936. }
  2937. },
  2938. stroke: {
  2939. show: true,
  2940. curve: 'smooth',
  2941. // "smooth" / "straight" / "stepline"
  2942. lineCap: 'butt',
  2943. // round, butt , square
  2944. width: 2,
  2945. colors: undefined,
  2946. // array of colors
  2947. dashArray: 0 // single value or array of values
  2948. },
  2949. tooltip: {
  2950. enabled: true,
  2951. enabledOnSeries: undefined,
  2952. shared: true,
  2953. followCursor: false,
  2954. // when disabled, the tooltip will show on top of the series instead of mouse position
  2955. intersect: false,
  2956. // when enabled, tooltip will only show when user directly hovers over point
  2957. inverseOrder: false,
  2958. custom: undefined,
  2959. fillSeriesColor: false,
  2960. theme: 'light',
  2961. style: {
  2962. fontSize: '12px',
  2963. fontFamily: undefined
  2964. },
  2965. onDatasetHover: {
  2966. highlightDataSeries: false
  2967. },
  2968. x: {
  2969. // x value
  2970. show: true,
  2971. format: 'dd MMM',
  2972. // dd/MM, dd MMM yy, dd MMM yyyy
  2973. formatter: undefined // a custom user supplied formatter function
  2974. },
  2975. y: {
  2976. formatter: undefined,
  2977. title: {
  2978. formatter: function formatter(seriesName) {
  2979. return seriesName;
  2980. }
  2981. }
  2982. },
  2983. z: {
  2984. formatter: undefined,
  2985. title: 'Size: '
  2986. },
  2987. marker: {
  2988. show: true,
  2989. fillColors: undefined
  2990. },
  2991. items: {
  2992. display: 'flex'
  2993. },
  2994. fixed: {
  2995. enabled: false,
  2996. position: 'topRight',
  2997. // topRight, topLeft, bottomRight, bottomLeft
  2998. offsetX: 0,
  2999. offsetY: 0
  3000. }
  3001. },
  3002. xaxis: {
  3003. type: 'category',
  3004. categories: [],
  3005. convertedCatToNumeric: false,
  3006. // internal property which should not be altered outside
  3007. sorted: true,
  3008. offsetX: 0,
  3009. offsetY: 0,
  3010. labels: {
  3011. show: true,
  3012. rotate: -45,
  3013. rotateAlways: false,
  3014. hideOverlappingLabels: true,
  3015. trim: false,
  3016. minHeight: undefined,
  3017. maxHeight: 120,
  3018. showDuplicates: true,
  3019. style: {
  3020. colors: [],
  3021. fontSize: '12px',
  3022. fontWeight: 400,
  3023. fontFamily: undefined,
  3024. cssClass: ''
  3025. },
  3026. offsetX: 0,
  3027. offsetY: 0,
  3028. format: undefined,
  3029. formatter: undefined,
  3030. // custom formatter function which will override format
  3031. datetimeUTC: true,
  3032. datetimeFormatter: {
  3033. year: 'yyyy',
  3034. month: "MMM 'yy",
  3035. day: 'dd MMM',
  3036. hour: 'HH:mm',
  3037. minute: 'HH:mm:ss'
  3038. }
  3039. },
  3040. axisBorder: {
  3041. show: true,
  3042. color: '#e0e0e0',
  3043. width: '100%',
  3044. height: 1,
  3045. offsetX: 0,
  3046. offsetY: 0
  3047. },
  3048. axisTicks: {
  3049. show: true,
  3050. color: '#e0e0e0',
  3051. height: 6,
  3052. offsetX: 0,
  3053. offsetY: 0
  3054. },
  3055. tickAmount: undefined,
  3056. tickPlacement: 'on',
  3057. min: undefined,
  3058. max: undefined,
  3059. range: undefined,
  3060. floating: false,
  3061. position: 'bottom',
  3062. title: {
  3063. text: undefined,
  3064. offsetX: 0,
  3065. offsetY: 0,
  3066. style: {
  3067. color: undefined,
  3068. fontSize: '12px',
  3069. fontWeight: 900,
  3070. fontFamily: undefined,
  3071. cssClass: ''
  3072. }
  3073. },
  3074. crosshairs: {
  3075. show: true,
  3076. width: 1,
  3077. // tickWidth/barWidth or an integer
  3078. position: 'back',
  3079. opacity: 0.9,
  3080. stroke: {
  3081. color: '#b6b6b6',
  3082. width: 1,
  3083. dashArray: 3
  3084. },
  3085. fill: {
  3086. type: 'solid',
  3087. // solid, gradient
  3088. color: '#B1B9C4',
  3089. gradient: {
  3090. colorFrom: '#D8E3F0',
  3091. colorTo: '#BED1E6',
  3092. stops: [0, 100],
  3093. opacityFrom: 0.4,
  3094. opacityTo: 0.5
  3095. }
  3096. },
  3097. dropShadow: {
  3098. enabled: false,
  3099. left: 0,
  3100. top: 0,
  3101. blur: 1,
  3102. opacity: 0.4
  3103. }
  3104. },
  3105. tooltip: {
  3106. enabled: true,
  3107. offsetY: 0,
  3108. formatter: undefined,
  3109. style: {
  3110. fontSize: '12px',
  3111. fontFamily: undefined
  3112. }
  3113. }
  3114. },
  3115. yaxis: this.yAxis,
  3116. theme: {
  3117. mode: 'light',
  3118. palette: 'palette1',
  3119. // If defined, it will overwrite globals.colors variable
  3120. monochrome: {
  3121. // monochrome allows you to select just 1 color and fill out the rest with light/dark shade (intensity can be selected)
  3122. enabled: false,
  3123. color: '#008FFB',
  3124. shadeTo: 'light',
  3125. shadeIntensity: 0.65
  3126. }
  3127. }
  3128. };
  3129. }
  3130. }]);
  3131. return Options;
  3132. }();
  3133. /**
  3134. * ApexCharts Annotations Class for drawing lines/rects on both xaxis and yaxis.
  3135. *
  3136. * @module Annotations
  3137. **/
  3138. var Annotations = /*#__PURE__*/function () {
  3139. function Annotations(ctx) {
  3140. _classCallCheck(this, Annotations);
  3141. this.ctx = ctx;
  3142. this.w = ctx.w;
  3143. this.graphics = new Graphics(this.ctx);
  3144. if (this.w.globals.isBarHorizontal) {
  3145. this.invertAxis = true;
  3146. }
  3147. this.helpers = new Helpers(this);
  3148. this.xAxisAnnotations = new XAnnotations(this);
  3149. this.yAxisAnnotations = new YAnnotations(this);
  3150. this.pointsAnnotations = new PointAnnotations(this);
  3151. if (this.w.globals.isBarHorizontal && this.w.config.yaxis[0].reversed) {
  3152. this.inversedReversedAxis = true;
  3153. }
  3154. this.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints;
  3155. }
  3156. _createClass(Annotations, [{
  3157. key: "drawAxesAnnotations",
  3158. value: function drawAxesAnnotations() {
  3159. var w = this.w;
  3160. if (w.globals.axisCharts) {
  3161. var yAnnotations = this.yAxisAnnotations.drawYAxisAnnotations();
  3162. var xAnnotations = this.xAxisAnnotations.drawXAxisAnnotations();
  3163. var pointAnnotations = this.pointsAnnotations.drawPointAnnotations();
  3164. var initialAnim = w.config.chart.animations.enabled;
  3165. var annoArray = [yAnnotations, xAnnotations, pointAnnotations];
  3166. var annoElArray = [xAnnotations.node, yAnnotations.node, pointAnnotations.node];
  3167. for (var i = 0; i < 3; i++) {
  3168. w.globals.dom.elGraphical.add(annoArray[i]);
  3169. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  3170. // fixes apexcharts/apexcharts.js#685
  3171. if (w.config.chart.type !== 'scatter' && w.config.chart.type !== 'bubble' && w.globals.dataPoints > 1) {
  3172. annoElArray[i].classList.add('apexcharts-element-hidden');
  3173. }
  3174. }
  3175. w.globals.delayedElements.push({
  3176. el: annoElArray[i],
  3177. index: 0
  3178. });
  3179. } // background sizes needs to be calculated after text is drawn, so calling them last
  3180. this.helpers.annotationsBackground();
  3181. }
  3182. }
  3183. }, {
  3184. key: "drawShapeAnnos",
  3185. value: function drawShapeAnnos() {
  3186. var _this = this;
  3187. var w = this.w;
  3188. w.config.annotations.shapes.map(function (s, index) {
  3189. _this.addShape(s, index);
  3190. });
  3191. }
  3192. }, {
  3193. key: "drawImageAnnos",
  3194. value: function drawImageAnnos() {
  3195. var _this2 = this;
  3196. var w = this.w;
  3197. w.config.annotations.images.map(function (s, index) {
  3198. _this2.addImage(s, index);
  3199. });
  3200. }
  3201. }, {
  3202. key: "drawTextAnnos",
  3203. value: function drawTextAnnos() {
  3204. var _this3 = this;
  3205. var w = this.w;
  3206. w.config.annotations.texts.map(function (t, index) {
  3207. _this3.addText(t, index);
  3208. });
  3209. }
  3210. }, {
  3211. key: "addXaxisAnnotation",
  3212. value: function addXaxisAnnotation(anno, parent, index) {
  3213. this.xAxisAnnotations.addXaxisAnnotation(anno, parent, index);
  3214. }
  3215. }, {
  3216. key: "addYaxisAnnotation",
  3217. value: function addYaxisAnnotation(anno, parent, index) {
  3218. this.yAxisAnnotations.addYaxisAnnotation(anno, parent, index);
  3219. }
  3220. }, {
  3221. key: "addPointAnnotation",
  3222. value: function addPointAnnotation(anno, parent, index) {
  3223. this.pointsAnnotations.addPointAnnotation(anno, parent, index);
  3224. }
  3225. }, {
  3226. key: "addText",
  3227. value: function addText(params, index) {
  3228. var x = params.x,
  3229. y = params.y,
  3230. text = params.text,
  3231. textAnchor = params.textAnchor,
  3232. foreColor = params.foreColor,
  3233. fontSize = params.fontSize,
  3234. fontFamily = params.fontFamily,
  3235. fontWeight = params.fontWeight,
  3236. cssClass = params.cssClass,
  3237. backgroundColor = params.backgroundColor,
  3238. borderWidth = params.borderWidth,
  3239. strokeDashArray = params.strokeDashArray,
  3240. borderRadius = params.borderRadius,
  3241. borderColor = params.borderColor,
  3242. _params$appendTo = params.appendTo,
  3243. appendTo = _params$appendTo === void 0 ? '.apexcharts-annotations' : _params$appendTo,
  3244. _params$paddingLeft = params.paddingLeft,
  3245. paddingLeft = _params$paddingLeft === void 0 ? 4 : _params$paddingLeft,
  3246. _params$paddingRight = params.paddingRight,
  3247. paddingRight = _params$paddingRight === void 0 ? 4 : _params$paddingRight,
  3248. _params$paddingBottom = params.paddingBottom,
  3249. paddingBottom = _params$paddingBottom === void 0 ? 2 : _params$paddingBottom,
  3250. _params$paddingTop = params.paddingTop,
  3251. paddingTop = _params$paddingTop === void 0 ? 2 : _params$paddingTop;
  3252. var w = this.w;
  3253. var elText = this.graphics.drawText({
  3254. x: x,
  3255. y: y,
  3256. text: text,
  3257. textAnchor: textAnchor || 'start',
  3258. fontSize: fontSize || '12px',
  3259. fontWeight: fontWeight || 'regular',
  3260. fontFamily: fontFamily || w.config.chart.fontFamily,
  3261. foreColor: foreColor || w.config.chart.foreColor,
  3262. cssClass: 'apexcharts-text ' + cssClass ? cssClass : ''
  3263. });
  3264. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3265. if (parent) {
  3266. parent.appendChild(elText.node);
  3267. }
  3268. var textRect = elText.bbox();
  3269. if (params.draggable) {
  3270. this.helpers.makeAnnotationDraggable(elText, 'texts', index);
  3271. }
  3272. if (text) {
  3273. 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);
  3274. parent.insertBefore(elRect.node, elText.node);
  3275. }
  3276. }
  3277. }, {
  3278. key: "addShape",
  3279. value: function addShape(params, index) {
  3280. var opts = {
  3281. type: params.type,
  3282. x: params.x || 0,
  3283. y: params.y || 0,
  3284. width: params.width || '100%',
  3285. height: params.height || 50,
  3286. circleRadius: params.radius || 25,
  3287. backgroundColor: params.backgroundColor || '#fff',
  3288. opacity: params.opacity || 1,
  3289. borderWidth: params.borderWidth || 0,
  3290. borderRadius: params.borderRadius || 4,
  3291. borderColor: params.borderColor || '#c2c2c2',
  3292. appendTo: params.appendTo || '.apexcharts-annotations'
  3293. };
  3294. var w = this.w;
  3295. if (String(opts.width).indexOf('%') > -1) {
  3296. opts.width = parseInt(opts.width, 10) * parseInt(w.globals.svgWidth, 10) / 100;
  3297. }
  3298. var elShape = null;
  3299. if (opts.type === 'circle') {
  3300. elShape = this.graphics.drawCircle(opts.circleRadius, {
  3301. fill: opts.backgroundColor,
  3302. stroke: opts.borderColor,
  3303. 'stroke-width': opts.borderWidth,
  3304. opacity: opts.opacity,
  3305. cx: opts.x,
  3306. cy: opts.y
  3307. });
  3308. } else {
  3309. elShape = this.graphics.drawRect(opts.x, opts.y, opts.width, opts.height, opts.borderRadius, opts.backgroundColor, opts.opacity, opts.borderWidth, opts.borderColor);
  3310. }
  3311. var parent = w.globals.dom.baseEl.querySelector(opts.appendTo);
  3312. if (parent) {
  3313. parent.appendChild(elShape.node);
  3314. }
  3315. if (params.draggable) {
  3316. this.helpers.makeAnnotationDraggable(elShape, 'shapes', index);
  3317. elShape.node.classList.add('apexcharts-resizable-element');
  3318. }
  3319. }
  3320. }, {
  3321. key: "addImage",
  3322. value: function addImage(params, index) {
  3323. var w = this.w;
  3324. var path = params.path,
  3325. _params$x = params.x,
  3326. x = _params$x === void 0 ? 0 : _params$x,
  3327. _params$y = params.y,
  3328. y = _params$y === void 0 ? 0 : _params$y,
  3329. _params$width = params.width,
  3330. width = _params$width === void 0 ? 20 : _params$width,
  3331. _params$height = params.height,
  3332. height = _params$height === void 0 ? 20 : _params$height,
  3333. _params$appendTo2 = params.appendTo,
  3334. appendTo = _params$appendTo2 === void 0 ? '.apexcharts-annotations' : _params$appendTo2;
  3335. var img = w.globals.dom.Paper.image(path);
  3336. img.size(width, height).move(x, y);
  3337. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3338. if (parent) {
  3339. parent.appendChild(img.node);
  3340. }
  3341. if (params.draggable) {
  3342. this.helpers.makeAnnotationDraggable(img, 'images', index);
  3343. img.node.classList.add('apexcharts-resizable-element');
  3344. }
  3345. } // The addXaxisAnnotation method requires a parent class, and user calling this method externally on the chart instance may not specify parent, hence a different method
  3346. }, {
  3347. key: "addXaxisAnnotationExternal",
  3348. value: function addXaxisAnnotationExternal(params, pushToMemory, context) {
  3349. this.addAnnotationExternal({
  3350. params: params,
  3351. pushToMemory: pushToMemory,
  3352. context: context,
  3353. type: 'xaxis',
  3354. contextMethod: context.addXaxisAnnotation
  3355. });
  3356. return context;
  3357. }
  3358. }, {
  3359. key: "addYaxisAnnotationExternal",
  3360. value: function addYaxisAnnotationExternal(params, pushToMemory, context) {
  3361. this.addAnnotationExternal({
  3362. params: params,
  3363. pushToMemory: pushToMemory,
  3364. context: context,
  3365. type: 'yaxis',
  3366. contextMethod: context.addYaxisAnnotation
  3367. });
  3368. return context;
  3369. }
  3370. }, {
  3371. key: "addPointAnnotationExternal",
  3372. value: function addPointAnnotationExternal(params, pushToMemory, context) {
  3373. if (typeof this.invertAxis === 'undefined') {
  3374. this.invertAxis = context.w.globals.isBarHorizontal;
  3375. }
  3376. this.addAnnotationExternal({
  3377. params: params,
  3378. pushToMemory: pushToMemory,
  3379. context: context,
  3380. type: 'point',
  3381. contextMethod: context.addPointAnnotation
  3382. });
  3383. return context;
  3384. }
  3385. }, {
  3386. key: "addAnnotationExternal",
  3387. value: function addAnnotationExternal(_ref) {
  3388. var params = _ref.params,
  3389. pushToMemory = _ref.pushToMemory,
  3390. context = _ref.context,
  3391. type = _ref.type,
  3392. contextMethod = _ref.contextMethod;
  3393. var me = context;
  3394. var w = me.w;
  3395. var parent = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations"));
  3396. var index = parent.childNodes.length + 1;
  3397. var options = new Options();
  3398. var axesAnno = Object.assign({}, type === 'xaxis' ? options.xAxisAnnotation : type === 'yaxis' ? options.yAxisAnnotation : options.pointAnnotation);
  3399. var anno = Utils.extend(axesAnno, params);
  3400. switch (type) {
  3401. case 'xaxis':
  3402. this.addXaxisAnnotation(anno, parent, index);
  3403. break;
  3404. case 'yaxis':
  3405. this.addYaxisAnnotation(anno, parent, index);
  3406. break;
  3407. case 'point':
  3408. this.addPointAnnotation(anno, parent, index);
  3409. break;
  3410. } // add background
  3411. var axesAnnoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(index, "']"));
  3412. var elRect = this.helpers.addBackgroundToAnno(axesAnnoLabel, anno);
  3413. if (elRect) {
  3414. parent.insertBefore(elRect.node, axesAnnoLabel);
  3415. }
  3416. if (pushToMemory) {
  3417. w.globals.memory.methodsToExec.push({
  3418. context: me,
  3419. id: anno.id ? anno.id : Utils.randomId(),
  3420. method: contextMethod,
  3421. label: 'addAnnotation',
  3422. params: params
  3423. });
  3424. }
  3425. return context;
  3426. }
  3427. }, {
  3428. key: "clearAnnotations",
  3429. value: function clearAnnotations(ctx) {
  3430. var w = ctx.w;
  3431. var annos = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations'); // annotations added externally should be cleared out too
  3432. w.globals.memory.methodsToExec.map(function (m, i) {
  3433. if (m.label === 'addText' || m.label === 'addAnnotation') {
  3434. w.globals.memory.methodsToExec.splice(i, 1);
  3435. }
  3436. });
  3437. annos = Utils.listToArray(annos); // delete the DOM elements
  3438. Array.prototype.forEach.call(annos, function (a) {
  3439. while (a.firstChild) {
  3440. a.removeChild(a.firstChild);
  3441. }
  3442. });
  3443. }
  3444. }, {
  3445. key: "removeAnnotation",
  3446. value: function removeAnnotation(ctx, id) {
  3447. var w = ctx.w;
  3448. var annos = w.globals.dom.baseEl.querySelectorAll(".".concat(id));
  3449. if (annos) {
  3450. w.globals.memory.methodsToExec.map(function (m, i) {
  3451. if (m.id === id) {
  3452. w.globals.memory.methodsToExec.splice(i, 1);
  3453. }
  3454. });
  3455. Array.prototype.forEach.call(annos, function (a) {
  3456. a.parentElement.removeChild(a);
  3457. });
  3458. }
  3459. }
  3460. }]);
  3461. return Annotations;
  3462. }();
  3463. /**
  3464. * DateTime Class to manipulate datetime values.
  3465. *
  3466. * @module DateTime
  3467. **/
  3468. var DateTime = /*#__PURE__*/function () {
  3469. function DateTime(ctx) {
  3470. _classCallCheck(this, DateTime);
  3471. this.ctx = ctx;
  3472. this.w = ctx.w;
  3473. this.months31 = [1, 3, 5, 7, 8, 10, 12];
  3474. this.months30 = [2, 4, 6, 9, 11];
  3475. this.daysCntOfYear = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
  3476. }
  3477. _createClass(DateTime, [{
  3478. key: "isValidDate",
  3479. value: function isValidDate(date) {
  3480. return !isNaN(this.parseDate(date));
  3481. }
  3482. }, {
  3483. key: "getTimeStamp",
  3484. value: function getTimeStamp(dateStr) {
  3485. if (!Date.parse(dateStr)) {
  3486. return dateStr;
  3487. }
  3488. var utc = this.w.config.xaxis.labels.datetimeUTC;
  3489. return !utc ? new Date(dateStr).getTime() : new Date(new Date(dateStr).toISOString().substr(0, 25)).getTime();
  3490. }
  3491. }, {
  3492. key: "getDate",
  3493. value: function getDate(timestamp) {
  3494. var utc = this.w.config.xaxis.labels.datetimeUTC;
  3495. return utc ? new Date(new Date(timestamp).toUTCString()) : new Date(timestamp);
  3496. }
  3497. }, {
  3498. key: "parseDate",
  3499. value: function parseDate(dateStr) {
  3500. var parsed = Date.parse(dateStr);
  3501. if (!isNaN(parsed)) {
  3502. return this.getTimeStamp(dateStr);
  3503. }
  3504. var output = Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' '));
  3505. output = this.getTimeStamp(output);
  3506. return output;
  3507. } // http://stackoverflow.com/questions/14638018/current-time-formatting-with-javascript#answer-14638191
  3508. }, {
  3509. key: "formatDate",
  3510. value: function formatDate(date, format) {
  3511. var locale = this.w.globals.locale;
  3512. var utc = this.w.config.xaxis.labels.datetimeUTC;
  3513. var MMMM = ['\x00'].concat(_toConsumableArray(locale.months));
  3514. var MMM = ['\x01'].concat(_toConsumableArray(locale.shortMonths));
  3515. var dddd = ['\x02'].concat(_toConsumableArray(locale.days));
  3516. var ddd = ['\x03'].concat(_toConsumableArray(locale.shortDays));
  3517. function ii(i, len) {
  3518. var s = i + '';
  3519. len = len || 2;
  3520. while (s.length < len) {
  3521. s = '0' + s;
  3522. }
  3523. return s;
  3524. }
  3525. var y = utc ? date.getUTCFullYear() : date.getFullYear();
  3526. format = format.replace(/(^|[^\\])yyyy+/g, '$1' + y);
  3527. format = format.replace(/(^|[^\\])yy/g, '$1' + y.toString().substr(2, 2));
  3528. format = format.replace(/(^|[^\\])y/g, '$1' + y);
  3529. var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
  3530. format = format.replace(/(^|[^\\])MMMM+/g, '$1' + MMMM[0]);
  3531. format = format.replace(/(^|[^\\])MMM/g, '$1' + MMM[0]);
  3532. format = format.replace(/(^|[^\\])MM/g, '$1' + ii(M));
  3533. format = format.replace(/(^|[^\\])M/g, '$1' + M);
  3534. var d = utc ? date.getUTCDate() : date.getDate();
  3535. format = format.replace(/(^|[^\\])dddd+/g, '$1' + dddd[0]);
  3536. format = format.replace(/(^|[^\\])ddd/g, '$1' + ddd[0]);
  3537. format = format.replace(/(^|[^\\])dd/g, '$1' + ii(d));
  3538. format = format.replace(/(^|[^\\])d/g, '$1' + d);
  3539. var H = utc ? date.getUTCHours() : date.getHours();
  3540. format = format.replace(/(^|[^\\])HH+/g, '$1' + ii(H));
  3541. format = format.replace(/(^|[^\\])H/g, '$1' + H);
  3542. var h = H > 12 ? H - 12 : H === 0 ? 12 : H;
  3543. format = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h));
  3544. format = format.replace(/(^|[^\\])h/g, '$1' + h);
  3545. var m = utc ? date.getUTCMinutes() : date.getMinutes();
  3546. format = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m));
  3547. format = format.replace(/(^|[^\\])m/g, '$1' + m);
  3548. var s = utc ? date.getUTCSeconds() : date.getSeconds();
  3549. format = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s));
  3550. format = format.replace(/(^|[^\\])s/g, '$1' + s);
  3551. var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
  3552. format = format.replace(/(^|[^\\])fff+/g, '$1' + ii(f, 3));
  3553. f = Math.round(f / 10);
  3554. format = format.replace(/(^|[^\\])ff/g, '$1' + ii(f));
  3555. f = Math.round(f / 10);
  3556. format = format.replace(/(^|[^\\])f/g, '$1' + f);
  3557. var T = H < 12 ? 'AM' : 'PM';
  3558. format = format.replace(/(^|[^\\])TT+/g, '$1' + T);
  3559. format = format.replace(/(^|[^\\])T/g, '$1' + T.charAt(0));
  3560. var t = T.toLowerCase();
  3561. format = format.replace(/(^|[^\\])tt+/g, '$1' + t);
  3562. format = format.replace(/(^|[^\\])t/g, '$1' + t.charAt(0));
  3563. var tz = -date.getTimezoneOffset();
  3564. var K = utc || !tz ? 'Z' : tz > 0 ? '+' : '-';
  3565. if (!utc) {
  3566. tz = Math.abs(tz);
  3567. var tzHrs = Math.floor(tz / 60);
  3568. var tzMin = tz % 60;
  3569. K += ii(tzHrs) + ':' + ii(tzMin);
  3570. }
  3571. format = format.replace(/(^|[^\\])K/g, '$1' + K);
  3572. var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
  3573. format = format.replace(new RegExp(dddd[0], 'g'), dddd[day]);
  3574. format = format.replace(new RegExp(ddd[0], 'g'), ddd[day]);
  3575. format = format.replace(new RegExp(MMMM[0], 'g'), MMMM[M]);
  3576. format = format.replace(new RegExp(MMM[0], 'g'), MMM[M]);
  3577. format = format.replace(/\\(.)/g, '$1');
  3578. return format;
  3579. }
  3580. }, {
  3581. key: "getTimeUnitsfromTimestamp",
  3582. value: function getTimeUnitsfromTimestamp(minX, maxX, utc) {
  3583. var w = this.w;
  3584. if (w.config.xaxis.min !== undefined) {
  3585. minX = w.config.xaxis.min;
  3586. }
  3587. if (w.config.xaxis.max !== undefined) {
  3588. maxX = w.config.xaxis.max;
  3589. }
  3590. var tsMin = this.getDate(minX);
  3591. var tsMax = this.getDate(maxX);
  3592. var minD = this.formatDate(tsMin, 'yyyy MM dd HH mm').split(' ');
  3593. var maxD = this.formatDate(tsMax, 'yyyy MM dd HH mm').split(' ');
  3594. return {
  3595. minMinute: parseInt(minD[4], 10),
  3596. maxMinute: parseInt(maxD[4], 10),
  3597. minHour: parseInt(minD[3], 10),
  3598. maxHour: parseInt(maxD[3], 10),
  3599. minDate: parseInt(minD[2], 10),
  3600. maxDate: parseInt(maxD[2], 10),
  3601. minMonth: parseInt(minD[1], 10) - 1,
  3602. maxMonth: parseInt(maxD[1], 10) - 1,
  3603. minYear: parseInt(minD[0], 10),
  3604. maxYear: parseInt(maxD[0], 10)
  3605. };
  3606. }
  3607. }, {
  3608. key: "isLeapYear",
  3609. value: function isLeapYear(year) {
  3610. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  3611. }
  3612. }, {
  3613. key: "calculcateLastDaysOfMonth",
  3614. value: function calculcateLastDaysOfMonth(month, year, subtract) {
  3615. var days = this.determineDaysOfMonths(month, year); // whatever days we get, subtract the number of days asked
  3616. return days - subtract;
  3617. }
  3618. }, {
  3619. key: "determineDaysOfYear",
  3620. value: function determineDaysOfYear(year) {
  3621. var days = 365;
  3622. if (this.isLeapYear(year)) {
  3623. days = 366;
  3624. }
  3625. return days;
  3626. }
  3627. }, {
  3628. key: "determineRemainingDaysOfYear",
  3629. value: function determineRemainingDaysOfYear(year, month, date) {
  3630. var dayOfYear = this.daysCntOfYear[month] + date;
  3631. if (month > 1 && this.isLeapYear()) dayOfYear++;
  3632. return dayOfYear;
  3633. }
  3634. }, {
  3635. key: "determineDaysOfMonths",
  3636. value: function determineDaysOfMonths(month, year) {
  3637. var days = 30;
  3638. month = Utils.monthMod(month);
  3639. switch (true) {
  3640. case this.months30.indexOf(month) > -1:
  3641. if (month === 2) {
  3642. if (this.isLeapYear(year)) {
  3643. days = 29;
  3644. } else {
  3645. days = 28;
  3646. }
  3647. }
  3648. break;
  3649. case this.months31.indexOf(month) > -1:
  3650. days = 31;
  3651. break;
  3652. default:
  3653. days = 31;
  3654. break;
  3655. }
  3656. return days;
  3657. }
  3658. }]);
  3659. return DateTime;
  3660. }();
  3661. /**
  3662. * ApexCharts Default Class for setting default options for all chart types.
  3663. *
  3664. * @module Defaults
  3665. **/
  3666. var Defaults = /*#__PURE__*/function () {
  3667. function Defaults(opts) {
  3668. _classCallCheck(this, Defaults);
  3669. this.opts = opts;
  3670. }
  3671. _createClass(Defaults, [{
  3672. key: "line",
  3673. value: function line() {
  3674. return {
  3675. chart: {
  3676. animations: {
  3677. easing: 'swing'
  3678. }
  3679. },
  3680. dataLabels: {
  3681. enabled: false
  3682. },
  3683. stroke: {
  3684. width: 5,
  3685. curve: 'straight'
  3686. },
  3687. markers: {
  3688. size: 0,
  3689. hover: {
  3690. sizeOffset: 6
  3691. }
  3692. },
  3693. xaxis: {
  3694. crosshairs: {
  3695. width: 1
  3696. }
  3697. }
  3698. };
  3699. }
  3700. }, {
  3701. key: "sparkline",
  3702. value: function sparkline(defaults) {
  3703. this.opts.yaxis[0].show = false;
  3704. this.opts.yaxis[0].title.text = '';
  3705. this.opts.yaxis[0].axisBorder.show = false;
  3706. this.opts.yaxis[0].axisTicks.show = false;
  3707. this.opts.yaxis[0].floating = true;
  3708. var ret = {
  3709. grid: {
  3710. show: false,
  3711. padding: {
  3712. left: 0,
  3713. right: 0,
  3714. top: 0,
  3715. bottom: 0
  3716. }
  3717. },
  3718. legend: {
  3719. show: false
  3720. },
  3721. xaxis: {
  3722. labels: {
  3723. show: false
  3724. },
  3725. tooltip: {
  3726. enabled: false
  3727. },
  3728. axisBorder: {
  3729. show: false
  3730. },
  3731. axisTicks: {
  3732. show: false
  3733. }
  3734. },
  3735. chart: {
  3736. toolbar: {
  3737. show: false
  3738. },
  3739. zoom: {
  3740. enabled: false
  3741. }
  3742. },
  3743. dataLabels: {
  3744. enabled: false
  3745. }
  3746. };
  3747. return Utils.extend(defaults, ret);
  3748. }
  3749. }, {
  3750. key: "bar",
  3751. value: function bar() {
  3752. return {
  3753. chart: {
  3754. stacked: false,
  3755. animations: {
  3756. easing: 'swing'
  3757. }
  3758. },
  3759. plotOptions: {
  3760. bar: {
  3761. dataLabels: {
  3762. position: 'center'
  3763. }
  3764. }
  3765. },
  3766. dataLabels: {
  3767. style: {
  3768. colors: ['#fff']
  3769. },
  3770. background: {
  3771. enabled: false
  3772. }
  3773. },
  3774. stroke: {
  3775. width: 0,
  3776. lineCap: 'square'
  3777. },
  3778. fill: {
  3779. opacity: 0.85
  3780. },
  3781. legend: {
  3782. markers: {
  3783. shape: 'square',
  3784. radius: 2,
  3785. size: 8
  3786. }
  3787. },
  3788. tooltip: {
  3789. shared: false
  3790. },
  3791. xaxis: {
  3792. tooltip: {
  3793. enabled: false
  3794. },
  3795. tickPlacement: 'between',
  3796. crosshairs: {
  3797. width: 'barWidth',
  3798. position: 'back',
  3799. fill: {
  3800. type: 'gradient'
  3801. },
  3802. dropShadow: {
  3803. enabled: false
  3804. },
  3805. stroke: {
  3806. width: 0
  3807. }
  3808. }
  3809. }
  3810. };
  3811. }
  3812. }, {
  3813. key: "candlestick",
  3814. value: function candlestick() {
  3815. return {
  3816. stroke: {
  3817. width: 1,
  3818. colors: ['#333']
  3819. },
  3820. fill: {
  3821. opacity: 1
  3822. },
  3823. dataLabels: {
  3824. enabled: false
  3825. },
  3826. tooltip: {
  3827. shared: true,
  3828. custom: function custom(_ref) {
  3829. var seriesIndex = _ref.seriesIndex,
  3830. dataPointIndex = _ref.dataPointIndex,
  3831. w = _ref.w;
  3832. var o = w.globals.seriesCandleO[seriesIndex][dataPointIndex];
  3833. var h = w.globals.seriesCandleH[seriesIndex][dataPointIndex];
  3834. var l = w.globals.seriesCandleL[seriesIndex][dataPointIndex];
  3835. var c = w.globals.seriesCandleC[seriesIndex][dataPointIndex];
  3836. 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>';
  3837. }
  3838. },
  3839. states: {
  3840. active: {
  3841. filter: {
  3842. type: 'none'
  3843. }
  3844. }
  3845. },
  3846. xaxis: {
  3847. crosshairs: {
  3848. width: 1
  3849. }
  3850. }
  3851. };
  3852. }
  3853. }, {
  3854. key: "rangeBar",
  3855. value: function rangeBar() {
  3856. return {
  3857. stroke: {
  3858. width: 0,
  3859. lineCap: 'square'
  3860. },
  3861. plotOptions: {
  3862. bar: {
  3863. dataLabels: {
  3864. position: 'center'
  3865. }
  3866. }
  3867. },
  3868. dataLabels: {
  3869. enabled: false,
  3870. formatter: function formatter(val, _ref2) {
  3871. var ctx = _ref2.ctx,
  3872. seriesIndex = _ref2.seriesIndex,
  3873. dataPointIndex = _ref2.dataPointIndex,
  3874. w = _ref2.w;
  3875. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  3876. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  3877. return end - start;
  3878. },
  3879. background: {
  3880. enabled: false
  3881. },
  3882. style: {
  3883. colors: ['#fff']
  3884. }
  3885. },
  3886. tooltip: {
  3887. shared: false,
  3888. followCursor: true,
  3889. custom: function custom(_ref3) {
  3890. var ctx = _ref3.ctx,
  3891. seriesIndex = _ref3.seriesIndex,
  3892. dataPointIndex = _ref3.dataPointIndex,
  3893. y1 = _ref3.y1,
  3894. y2 = _ref3.y2,
  3895. w = _ref3.w;
  3896. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  3897. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  3898. var ylabel = w.globals.labels[dataPointIndex];
  3899. var seriesName = w.config.series[seriesIndex].name;
  3900. var yLbFormatter = w.config.tooltip.y.formatter;
  3901. var yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  3902. var opts = {
  3903. w: w,
  3904. seriesIndex: seriesIndex,
  3905. dataPointIndex: dataPointIndex
  3906. };
  3907. if (typeof yLbTitleFormatter === 'function') {
  3908. seriesName = yLbTitleFormatter(seriesName, opts);
  3909. }
  3910. if (y1 && y2) {
  3911. start = y1;
  3912. end = y2;
  3913. if (w.config.series[seriesIndex].data[dataPointIndex].x) {
  3914. ylabel = w.config.series[seriesIndex].data[dataPointIndex].x + ':';
  3915. }
  3916. if (typeof yLbFormatter === 'function') {
  3917. ylabel = yLbFormatter(ylabel, opts);
  3918. }
  3919. }
  3920. var startVal = '';
  3921. var endVal = '';
  3922. var color = w.globals.colors[seriesIndex];
  3923. if (w.config.tooltip.x.formatter === undefined) {
  3924. if (w.config.xaxis.type === 'datetime') {
  3925. var datetimeObj = new DateTime(ctx);
  3926. startVal = datetimeObj.formatDate(datetimeObj.getDate(start), w.config.tooltip.x.format);
  3927. endVal = datetimeObj.formatDate(datetimeObj.getDate(end), w.config.tooltip.x.format);
  3928. } else {
  3929. startVal = start;
  3930. endVal = end;
  3931. }
  3932. } else {
  3933. startVal = w.config.tooltip.x.formatter(start);
  3934. endVal = w.config.tooltip.x.formatter(end);
  3935. }
  3936. 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>';
  3937. }
  3938. },
  3939. xaxis: {
  3940. tickPlacement: 'between',
  3941. tooltip: {
  3942. enabled: false
  3943. },
  3944. crosshairs: {
  3945. stroke: {
  3946. width: 0
  3947. }
  3948. }
  3949. }
  3950. };
  3951. }
  3952. }, {
  3953. key: "area",
  3954. value: function area() {
  3955. return {
  3956. stroke: {
  3957. width: 4
  3958. },
  3959. fill: {
  3960. type: 'gradient',
  3961. gradient: {
  3962. inverseColors: false,
  3963. shade: 'light',
  3964. type: 'vertical',
  3965. opacityFrom: 0.65,
  3966. opacityTo: 0.5,
  3967. stops: [0, 100, 100]
  3968. }
  3969. },
  3970. markers: {
  3971. size: 0,
  3972. hover: {
  3973. sizeOffset: 6
  3974. }
  3975. },
  3976. tooltip: {
  3977. followCursor: false
  3978. }
  3979. };
  3980. }
  3981. }, {
  3982. key: "brush",
  3983. value: function brush(defaults) {
  3984. var ret = {
  3985. chart: {
  3986. toolbar: {
  3987. autoSelected: 'selection',
  3988. show: false
  3989. },
  3990. zoom: {
  3991. enabled: false
  3992. }
  3993. },
  3994. dataLabels: {
  3995. enabled: false
  3996. },
  3997. stroke: {
  3998. width: 1
  3999. },
  4000. tooltip: {
  4001. enabled: false
  4002. },
  4003. xaxis: {
  4004. tooltip: {
  4005. enabled: false
  4006. }
  4007. }
  4008. };
  4009. return Utils.extend(defaults, ret);
  4010. }
  4011. }, {
  4012. key: "stacked100",
  4013. value: function stacked100(opts) {
  4014. opts.dataLabels = opts.dataLabels || {};
  4015. opts.dataLabels.formatter = opts.dataLabels.formatter || undefined;
  4016. var existingDataLabelFormatter = opts.dataLabels.formatter;
  4017. opts.yaxis.forEach(function (yaxe, index) {
  4018. opts.yaxis[index].min = 0;
  4019. opts.yaxis[index].max = 100;
  4020. });
  4021. var isBar = opts.chart.type === 'bar';
  4022. if (isBar) {
  4023. opts.dataLabels.formatter = existingDataLabelFormatter || function (val) {
  4024. if (typeof val === 'number') {
  4025. return val ? val.toFixed(0) + '%' : val;
  4026. }
  4027. return val;
  4028. };
  4029. }
  4030. return opts;
  4031. } // This function removes the left and right spacing in chart for line/area/scatter if xaxis type = category for those charts by converting xaxis = numeric. Numeric/Datetime xaxis prevents the unnecessary spacing in the left/right of the chart area
  4032. }, {
  4033. key: "convertCatToNumeric",
  4034. value: function convertCatToNumeric(opts) {
  4035. opts.xaxis.convertedCatToNumeric = true;
  4036. return opts;
  4037. }
  4038. }, {
  4039. key: "convertCatToNumericXaxis",
  4040. value: function convertCatToNumericXaxis(opts, ctx, cats) {
  4041. opts.xaxis.type = 'numeric';
  4042. opts.xaxis.labels = opts.xaxis.labels || {};
  4043. opts.xaxis.labels.formatter = opts.xaxis.labels.formatter || function (val) {
  4044. return Utils.isNumber(val) ? Math.floor(val) : val;
  4045. };
  4046. var defaultFormatter = opts.xaxis.labels.formatter;
  4047. var labels = opts.xaxis.categories && opts.xaxis.categories.length ? opts.xaxis.categories : opts.labels;
  4048. if (cats && cats.length) {
  4049. labels = cats.map(function (c) {
  4050. return c.toString();
  4051. });
  4052. }
  4053. if (labels && labels.length) {
  4054. opts.xaxis.labels.formatter = function (val) {
  4055. return Utils.isNumber(val) ? defaultFormatter(labels[Math.floor(val) - 1]) : defaultFormatter(val);
  4056. };
  4057. }
  4058. opts.xaxis.categories = [];
  4059. opts.labels = [];
  4060. opts.xaxis.tickAmount = opts.xaxis.tickAmount || 'dataPoints';
  4061. return opts;
  4062. }
  4063. }, {
  4064. key: "bubble",
  4065. value: function bubble() {
  4066. return {
  4067. dataLabels: {
  4068. style: {
  4069. colors: ['#fff']
  4070. }
  4071. },
  4072. tooltip: {
  4073. shared: false,
  4074. intersect: true
  4075. },
  4076. xaxis: {
  4077. crosshairs: {
  4078. width: 0
  4079. }
  4080. },
  4081. fill: {
  4082. type: 'solid',
  4083. gradient: {
  4084. shade: 'light',
  4085. inverse: true,
  4086. shadeIntensity: 0.55,
  4087. opacityFrom: 0.4,
  4088. opacityTo: 0.8
  4089. }
  4090. }
  4091. };
  4092. }
  4093. }, {
  4094. key: "scatter",
  4095. value: function scatter() {
  4096. return {
  4097. dataLabels: {
  4098. enabled: false
  4099. },
  4100. tooltip: {
  4101. shared: false,
  4102. intersect: true
  4103. },
  4104. markers: {
  4105. size: 6,
  4106. strokeWidth: 1,
  4107. hover: {
  4108. sizeOffset: 2
  4109. }
  4110. }
  4111. };
  4112. }
  4113. }, {
  4114. key: "heatmap",
  4115. value: function heatmap() {
  4116. return {
  4117. chart: {
  4118. stacked: false
  4119. },
  4120. fill: {
  4121. opacity: 1
  4122. },
  4123. dataLabels: {
  4124. style: {
  4125. colors: ['#fff']
  4126. }
  4127. },
  4128. stroke: {
  4129. colors: ['#fff']
  4130. },
  4131. tooltip: {
  4132. followCursor: true,
  4133. marker: {
  4134. show: false
  4135. },
  4136. x: {
  4137. show: false
  4138. }
  4139. },
  4140. legend: {
  4141. position: 'top',
  4142. markers: {
  4143. shape: 'square',
  4144. size: 10,
  4145. offsetY: 2
  4146. }
  4147. },
  4148. grid: {
  4149. padding: {
  4150. right: 20
  4151. }
  4152. }
  4153. };
  4154. }
  4155. }, {
  4156. key: "pie",
  4157. value: function pie() {
  4158. return {
  4159. chart: {
  4160. toolbar: {
  4161. show: false
  4162. }
  4163. },
  4164. plotOptions: {
  4165. pie: {
  4166. donut: {
  4167. labels: {
  4168. show: false
  4169. }
  4170. }
  4171. }
  4172. },
  4173. dataLabels: {
  4174. formatter: function formatter(val) {
  4175. return val.toFixed(1) + '%';
  4176. },
  4177. style: {
  4178. colors: ['#fff']
  4179. },
  4180. dropShadow: {
  4181. enabled: true
  4182. }
  4183. },
  4184. stroke: {
  4185. colors: ['#fff']
  4186. },
  4187. fill: {
  4188. opacity: 1,
  4189. gradient: {
  4190. shade: 'light',
  4191. stops: [0, 100]
  4192. }
  4193. },
  4194. tooltip: {
  4195. theme: 'dark',
  4196. fillSeriesColor: true
  4197. },
  4198. legend: {
  4199. position: 'right'
  4200. }
  4201. };
  4202. }
  4203. }, {
  4204. key: "donut",
  4205. value: function donut() {
  4206. return {
  4207. chart: {
  4208. toolbar: {
  4209. show: false
  4210. }
  4211. },
  4212. dataLabels: {
  4213. formatter: function formatter(val) {
  4214. return val.toFixed(1) + '%';
  4215. },
  4216. style: {
  4217. colors: ['#fff']
  4218. },
  4219. dropShadow: {
  4220. enabled: true
  4221. }
  4222. },
  4223. stroke: {
  4224. colors: ['#fff']
  4225. },
  4226. fill: {
  4227. opacity: 1,
  4228. gradient: {
  4229. shade: 'light',
  4230. shadeIntensity: 0.35,
  4231. stops: [80, 100],
  4232. opacityFrom: 1,
  4233. opacityTo: 1
  4234. }
  4235. },
  4236. tooltip: {
  4237. theme: 'dark',
  4238. fillSeriesColor: true
  4239. },
  4240. legend: {
  4241. position: 'right'
  4242. }
  4243. };
  4244. }
  4245. }, {
  4246. key: "radar",
  4247. value: function radar() {
  4248. this.opts.yaxis[0].labels.offsetY = this.opts.yaxis[0].labels.offsetY ? this.opts.yaxis[0].labels.offsetY : 6;
  4249. return {
  4250. dataLabels: {
  4251. enabled: false,
  4252. style: {
  4253. fontSize: '11px'
  4254. }
  4255. },
  4256. stroke: {
  4257. width: 2
  4258. },
  4259. markers: {
  4260. size: 3,
  4261. strokeWidth: 1,
  4262. strokeOpacity: 1
  4263. },
  4264. fill: {
  4265. opacity: 0.2
  4266. },
  4267. tooltip: {
  4268. shared: false,
  4269. intersect: true,
  4270. followCursor: true
  4271. },
  4272. grid: {
  4273. show: false
  4274. },
  4275. xaxis: {
  4276. labels: {
  4277. formatter: function formatter(val) {
  4278. return val;
  4279. },
  4280. style: {
  4281. colors: ['#a8a8a8'],
  4282. fontSize: '11px'
  4283. }
  4284. },
  4285. tooltip: {
  4286. enabled: false
  4287. },
  4288. crosshairs: {
  4289. show: false
  4290. }
  4291. }
  4292. };
  4293. }
  4294. }, {
  4295. key: "radialBar",
  4296. value: function radialBar() {
  4297. return {
  4298. chart: {
  4299. animations: {
  4300. dynamicAnimation: {
  4301. enabled: true,
  4302. speed: 800
  4303. }
  4304. },
  4305. toolbar: {
  4306. show: false
  4307. }
  4308. },
  4309. fill: {
  4310. gradient: {
  4311. shade: 'dark',
  4312. shadeIntensity: 0.4,
  4313. inverseColors: false,
  4314. type: 'diagonal2',
  4315. opacityFrom: 1,
  4316. opacityTo: 1,
  4317. stops: [70, 98, 100]
  4318. }
  4319. },
  4320. legend: {
  4321. show: false,
  4322. position: 'right'
  4323. },
  4324. tooltip: {
  4325. enabled: false,
  4326. fillSeriesColor: true
  4327. }
  4328. };
  4329. }
  4330. }]);
  4331. return Defaults;
  4332. }();
  4333. /**
  4334. * ApexCharts Config Class for extending user options with pre-defined ApexCharts config.
  4335. *
  4336. * @module Config
  4337. **/
  4338. var Config = /*#__PURE__*/function () {
  4339. function Config(opts) {
  4340. _classCallCheck(this, Config);
  4341. this.opts = opts;
  4342. }
  4343. _createClass(Config, [{
  4344. key: "init",
  4345. value: function init(_ref) {
  4346. var responsiveOverride = _ref.responsiveOverride;
  4347. var opts = this.opts;
  4348. var options = new Options();
  4349. var defaults = new Defaults(opts);
  4350. this.chartType = opts.chart.type;
  4351. if (this.chartType === 'histogram') {
  4352. // technically, a histogram can be drawn by a column chart with no spaces in between
  4353. opts.chart.type = 'bar';
  4354. opts = Utils.extend({
  4355. plotOptions: {
  4356. bar: {
  4357. columnWidth: '99.99%'
  4358. }
  4359. }
  4360. }, opts);
  4361. }
  4362. opts = this.extendYAxis(opts);
  4363. opts = this.extendAnnotations(opts);
  4364. var config = options.init();
  4365. var newDefaults = {};
  4366. if (opts && _typeof(opts) === 'object') {
  4367. var chartDefaults = {};
  4368. var chartTypes = ['line', 'area', 'bar', 'candlestick', 'rangeBar', 'histogram', 'bubble', 'scatter', 'heatmap', 'pie', 'donut', 'radar', 'radialBar'];
  4369. if (chartTypes.indexOf(opts.chart.type) !== -1) {
  4370. chartDefaults = defaults[opts.chart.type]();
  4371. } else {
  4372. chartDefaults = defaults.line();
  4373. }
  4374. if (opts.chart.brush && opts.chart.brush.enabled) {
  4375. chartDefaults = defaults.brush(chartDefaults);
  4376. }
  4377. if (opts.chart.stacked && opts.chart.stackType === '100%') {
  4378. opts = defaults.stacked100(opts);
  4379. } // If user has specified a dark theme, make the tooltip dark too
  4380. this.checkForDarkTheme(window.Apex); // check global window Apex options
  4381. this.checkForDarkTheme(opts); // check locally passed options
  4382. opts.xaxis = opts.xaxis || window.Apex.xaxis || {}; // an important boolean needs to be set here
  4383. // otherwise all the charts will have this flag set to true window.Apex.xaxis is set globally
  4384. if (!responsiveOverride) {
  4385. opts.xaxis.convertedCatToNumeric = false;
  4386. }
  4387. opts = this.checkForCatToNumericXAxis(this.chartType, chartDefaults, opts);
  4388. if (opts.chart.sparkline && opts.chart.sparkline.enabled || window.Apex.chart && window.Apex.chart.sparkline && window.Apex.chart.sparkline.enabled) {
  4389. chartDefaults = defaults.sparkline(chartDefaults);
  4390. }
  4391. newDefaults = Utils.extend(config, chartDefaults);
  4392. } // config should cascade in this fashion
  4393. // default-config < global-apex-variable-config < user-defined-config
  4394. // get GLOBALLY defined options and merge with the default config
  4395. var mergedWithDefaultConfig = Utils.extend(newDefaults, window.Apex); // get the merged config and extend with user defined config
  4396. config = Utils.extend(mergedWithDefaultConfig, opts); // some features are not supported. those mismatches should be handled
  4397. config = this.handleUserInputErrors(config);
  4398. return config;
  4399. }
  4400. }, {
  4401. key: "checkForCatToNumericXAxis",
  4402. value: function checkForCatToNumericXAxis(chartType, chartDefaults, opts) {
  4403. var defaults = new Defaults(opts);
  4404. var isBarHorizontal = chartType === 'bar' && opts.plotOptions && opts.plotOptions.bar && opts.plotOptions.bar.horizontal;
  4405. var unsupportedZoom = chartType === 'pie' || chartType === 'donut' || chartType === 'radar' || chartType === 'radialBar' || chartType === 'heatmap';
  4406. var notNumericXAxis = opts.xaxis.type !== 'datetime' && opts.xaxis.type !== 'numeric';
  4407. var tickPlacement = opts.xaxis.tickPlacement ? opts.xaxis.tickPlacement : chartDefaults.xaxis && chartDefaults.xaxis.tickPlacement;
  4408. if (!isBarHorizontal && !unsupportedZoom && notNumericXAxis && tickPlacement !== 'between') {
  4409. opts = defaults.convertCatToNumeric(opts);
  4410. }
  4411. return opts;
  4412. }
  4413. }, {
  4414. key: "extendYAxis",
  4415. value: function extendYAxis(opts) {
  4416. var options = new Options();
  4417. if (typeof opts.yaxis === 'undefined' || !opts.yaxis || Array.isArray(opts.yaxis) && opts.yaxis.length === 0) {
  4418. opts.yaxis = {};
  4419. } // extend global yaxis config (only if object is provided / not an array)
  4420. if (opts.yaxis.constructor !== Array && window.Apex.yaxis && window.Apex.yaxis.constructor !== Array) {
  4421. opts.yaxis = Utils.extend(opts.yaxis, window.Apex.yaxis);
  4422. } // as we can't extend nested object's array with extend, we need to do it first
  4423. // user can provide either an array or object in yaxis config
  4424. if (opts.yaxis.constructor !== Array) {
  4425. // convert the yaxis to array if user supplied object
  4426. opts.yaxis = [Utils.extend(options.yAxis, opts.yaxis)];
  4427. } else {
  4428. opts.yaxis = Utils.extendArray(opts.yaxis, options.yAxis);
  4429. }
  4430. var isLogY = false;
  4431. opts.yaxis.forEach(function (y) {
  4432. if (y.logarithmic) {
  4433. isLogY = true;
  4434. }
  4435. }); // A logarithmic chart works correctly when each series has a corresponding y-axis
  4436. // If this is not the case, we manually create yaxis for multi-series log chart
  4437. if (isLogY && opts.series.length !== opts.yaxis.length && opts.series.length) {
  4438. opts.yaxis = opts.series.map(function (s, i) {
  4439. if (!s.name) {
  4440. opts.series[i].name = "series-".concat(i + 1);
  4441. }
  4442. if (opts.yaxis[i]) {
  4443. opts.yaxis[i].seriesName = opts.series[i].name;
  4444. return opts.yaxis[i];
  4445. } else {
  4446. var newYaxis = Utils.extend(options.yAxis, opts.yaxis[0]);
  4447. newYaxis.show = false;
  4448. return newYaxis;
  4449. }
  4450. });
  4451. }
  4452. if (isLogY && opts.series.length > 1 && opts.series.length !== opts.yaxis.length) {
  4453. console.warn('A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both.');
  4454. }
  4455. return opts;
  4456. } // annotations also accepts array, so we need to extend them manually
  4457. }, {
  4458. key: "extendAnnotations",
  4459. value: function extendAnnotations(opts) {
  4460. if (typeof opts.annotations === 'undefined') {
  4461. opts.annotations = {};
  4462. opts.annotations.yaxis = [];
  4463. opts.annotations.xaxis = [];
  4464. opts.annotations.points = [];
  4465. }
  4466. opts = this.extendYAxisAnnotations(opts);
  4467. opts = this.extendXAxisAnnotations(opts);
  4468. opts = this.extendPointAnnotations(opts);
  4469. return opts;
  4470. }
  4471. }, {
  4472. key: "extendYAxisAnnotations",
  4473. value: function extendYAxisAnnotations(opts) {
  4474. var options = new Options();
  4475. opts.annotations.yaxis = Utils.extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], options.yAxisAnnotation);
  4476. return opts;
  4477. }
  4478. }, {
  4479. key: "extendXAxisAnnotations",
  4480. value: function extendXAxisAnnotations(opts) {
  4481. var options = new Options();
  4482. opts.annotations.xaxis = Utils.extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], options.xAxisAnnotation);
  4483. return opts;
  4484. }
  4485. }, {
  4486. key: "extendPointAnnotations",
  4487. value: function extendPointAnnotations(opts) {
  4488. var options = new Options();
  4489. opts.annotations.points = Utils.extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], options.pointAnnotation);
  4490. return opts;
  4491. }
  4492. }, {
  4493. key: "checkForDarkTheme",
  4494. value: function checkForDarkTheme(opts) {
  4495. if (opts.theme && opts.theme.mode === 'dark') {
  4496. if (!opts.tooltip) {
  4497. opts.tooltip = {};
  4498. }
  4499. if (opts.tooltip.theme !== 'light') {
  4500. opts.tooltip.theme = 'dark';
  4501. }
  4502. if (!opts.chart.foreColor) {
  4503. opts.chart.foreColor = '#f6f7f8';
  4504. }
  4505. if (!opts.theme.palette) {
  4506. opts.theme.palette = 'palette4';
  4507. }
  4508. }
  4509. }
  4510. }, {
  4511. key: "handleUserInputErrors",
  4512. value: function handleUserInputErrors(opts) {
  4513. var config = opts; // conflicting tooltip option. intersect makes sure to focus on 1 point at a time. Shared cannot be used along with it
  4514. if (config.tooltip.shared && config.tooltip.intersect) {
  4515. throw new Error('tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.');
  4516. }
  4517. if ((config.chart.type === 'bar' || config.chart.type === 'rangeBar') && config.plotOptions.bar.horizontal) {
  4518. // No multiple yaxis for bars
  4519. if (config.yaxis.length > 1) {
  4520. throw new Error('Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false');
  4521. } // if yaxis is reversed in horizontal bar chart, you should draw the y-axis on right side
  4522. if (config.yaxis[0].reversed) {
  4523. config.yaxis[0].opposite = true;
  4524. }
  4525. config.xaxis.tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  4526. config.yaxis[0].tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  4527. config.chart.zoom.enabled = false; // no zooming for horz bars
  4528. }
  4529. if (config.chart.type === 'bar' || config.chart.type === 'rangeBar') {
  4530. if (config.tooltip.shared) {
  4531. if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) {
  4532. console.warn('crosshairs.width = "barWidth" is only supported in single series, not in a multi-series barChart.');
  4533. config.xaxis.crosshairs.width = 'tickWidth';
  4534. }
  4535. if (config.plotOptions.bar.horizontal) {
  4536. config.states.hover.type = 'none';
  4537. config.tooltip.shared = false;
  4538. }
  4539. if (!config.tooltip.followCursor) {
  4540. console.warn('followCursor option in shared columns cannot be turned off. Please set %ctooltip.followCursor: true', 'color: blue;');
  4541. config.tooltip.followCursor = true;
  4542. }
  4543. }
  4544. }
  4545. if (config.chart.type === 'candlestick') {
  4546. if (config.yaxis[0].reversed) {
  4547. console.warn('Reversed y-axis in candlestick chart is not supported.');
  4548. config.yaxis[0].reversed = false;
  4549. }
  4550. }
  4551. if (config.chart.group && config.yaxis[0].labels.minWidth === 0) {
  4552. 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.');
  4553. } // if user supplied array for stroke width, it will only be applicable to line/area charts, for any other charts, revert back to Number
  4554. if (Array.isArray(config.stroke.width)) {
  4555. if (config.chart.type !== 'line' && config.chart.type !== 'area') {
  4556. console.warn('stroke.width option accepts array only for line and area charts. Reverted back to Number');
  4557. config.stroke.width = config.stroke.width[0];
  4558. }
  4559. }
  4560. return config;
  4561. }
  4562. }]);
  4563. return Config;
  4564. }();
  4565. var Globals = /*#__PURE__*/function () {
  4566. function Globals() {
  4567. _classCallCheck(this, Globals);
  4568. }
  4569. _createClass(Globals, [{
  4570. key: "initGlobalVars",
  4571. value: function initGlobalVars(gl) {
  4572. gl.series = []; // the MAIN series array (y values)
  4573. gl.seriesCandleO = [];
  4574. gl.seriesCandleH = [];
  4575. gl.seriesCandleL = [];
  4576. gl.seriesCandleC = [];
  4577. gl.seriesRangeStart = [];
  4578. gl.seriesRangeEnd = [];
  4579. gl.seriesRangeBarTimeline = [];
  4580. gl.seriesPercent = [];
  4581. gl.seriesX = [];
  4582. gl.seriesZ = [];
  4583. gl.seriesNames = [];
  4584. gl.seriesTotals = [];
  4585. gl.seriesLog = [];
  4586. gl.stackedSeriesTotals = [];
  4587. gl.seriesXvalues = []; // we will need this in tooltip (it's x position)
  4588. // when we will have unequal x values, we will need
  4589. // some way to get x value depending on mouse pointer
  4590. gl.seriesYvalues = []; // we will need this when deciding which series
  4591. // user hovered on
  4592. gl.labels = [];
  4593. gl.categoryLabels = [];
  4594. gl.timescaleLabels = [];
  4595. gl.noLabelsProvided = false;
  4596. gl.resizeTimer = null;
  4597. gl.selectionResizeTimer = null;
  4598. gl.delayedElements = [];
  4599. gl.pointsArray = [];
  4600. gl.dataLabelsRects = [];
  4601. gl.isXNumeric = false;
  4602. gl.xaxisLabelsCount = 0;
  4603. gl.skipLastTimelinelabel = false;
  4604. gl.skipFirstTimelinelabel = false;
  4605. gl.x2SpaceAvailable = 0;
  4606. gl.isDataXYZ = false;
  4607. gl.isMultiLineX = false;
  4608. gl.isMultipleYAxis = false;
  4609. gl.maxY = -Number.MAX_VALUE;
  4610. gl.minY = Number.MIN_VALUE;
  4611. gl.minYArr = [];
  4612. gl.maxYArr = [];
  4613. gl.maxX = -Number.MAX_VALUE;
  4614. gl.minX = Number.MAX_VALUE;
  4615. gl.initialMaxX = -Number.MAX_VALUE;
  4616. gl.initialMinX = Number.MAX_VALUE;
  4617. gl.maxDate = 0;
  4618. gl.minDate = Number.MAX_VALUE;
  4619. gl.minZ = Number.MAX_VALUE;
  4620. gl.maxZ = -Number.MAX_VALUE;
  4621. gl.minXDiff = Number.MAX_VALUE;
  4622. gl.yAxisScale = [];
  4623. gl.xAxisScale = null;
  4624. gl.xAxisTicksPositions = [];
  4625. gl.yLabelsCoords = [];
  4626. gl.yTitleCoords = [];
  4627. gl.barPadForNumericAxis = 0;
  4628. gl.padHorizontal = 0;
  4629. gl.xRange = 0;
  4630. gl.yRange = [];
  4631. gl.zRange = 0;
  4632. gl.dataPoints = 0;
  4633. gl.xTickAmount = 0;
  4634. }
  4635. }, {
  4636. key: "globalVars",
  4637. value: function globalVars(config) {
  4638. return {
  4639. chartID: null,
  4640. // chart ID - apexcharts-cuid
  4641. cuid: null,
  4642. // chart ID - random numbers excluding "apexcharts" part
  4643. events: {
  4644. beforeMount: [],
  4645. mounted: [],
  4646. updated: [],
  4647. clicked: [],
  4648. selection: [],
  4649. dataPointSelection: [],
  4650. zoomed: [],
  4651. scrolled: []
  4652. },
  4653. colors: [],
  4654. clientX: null,
  4655. clientY: null,
  4656. fill: {
  4657. colors: []
  4658. },
  4659. stroke: {
  4660. colors: []
  4661. },
  4662. dataLabels: {
  4663. style: {
  4664. colors: []
  4665. }
  4666. },
  4667. radarPolygons: {
  4668. fill: {
  4669. colors: []
  4670. }
  4671. },
  4672. markers: {
  4673. colors: [],
  4674. size: config.markers.size,
  4675. largestSize: 0
  4676. },
  4677. animationEnded: false,
  4678. isTouchDevice: 'ontouchstart' in window || navigator.msMaxTouchPoints,
  4679. isDirty: false,
  4680. // chart has been updated after the initial render. This is different than dataChanged property. isDirty means user manually called some method to update
  4681. isExecCalled: false,
  4682. // whether user updated the chart through the exec method
  4683. initialConfig: null,
  4684. // we will store the first config user has set to go back when user finishes interactions like zooming and come out of it
  4685. lastXAxis: [],
  4686. lastYAxis: [],
  4687. columnSeries: null,
  4688. labels: [],
  4689. // store the text to draw on x axis
  4690. // Don't mutate the labels, many things including tooltips depends on it!
  4691. timescaleLabels: [],
  4692. // store the timescaleLabels Labels in another variable
  4693. noLabelsProvided: false,
  4694. // if user didn't provide any categories/labels or x values, fallback to 1,2,3,4...
  4695. allSeriesCollapsed: false,
  4696. collapsedSeries: [],
  4697. // when user collapses a series, it goes into this array
  4698. collapsedSeriesIndices: [],
  4699. // this stores the index of the collapsedSeries instead of whole object for quick access
  4700. ancillaryCollapsedSeries: [],
  4701. // when user collapses an "alwaysVisible" series, it goes into this array
  4702. ancillaryCollapsedSeriesIndices: [],
  4703. // this stores the index of the ancillaryCollapsedSeries whose y-axis is always visible
  4704. risingSeries: [],
  4705. // when user re-opens a collapsed series, it goes here
  4706. dataFormatXNumeric: false,
  4707. // boolean value to indicate user has passed numeric x values
  4708. capturedSeriesIndex: -1,
  4709. capturedDataPointIndex: -1,
  4710. selectedDataPoints: [],
  4711. goldenPadding: 35,
  4712. // this value is used at a lot of places for spacing purpose
  4713. invalidLogScale: false,
  4714. // if a user enabled log scale but the data provided is not valid to generate a log scale, turn on this flag
  4715. ignoreYAxisIndexes: [],
  4716. // when series are being collapsed in multiple y axes, ignore certain index
  4717. yAxisSameScaleIndices: [],
  4718. maxValsInArrayIndex: 0,
  4719. radialSize: 0,
  4720. zoomEnabled: config.chart.toolbar.autoSelected === 'zoom' && config.chart.toolbar.tools.zoom && config.chart.zoom.enabled,
  4721. panEnabled: config.chart.toolbar.autoSelected === 'pan' && config.chart.toolbar.tools.pan,
  4722. selectionEnabled: config.chart.toolbar.autoSelected === 'selection' && config.chart.toolbar.tools.selection,
  4723. yaxis: null,
  4724. mousedown: false,
  4725. lastClientPosition: {},
  4726. // don't reset this variable this the chart is destroyed. It is used to detect right or left mousemove in panning
  4727. visibleXRange: undefined,
  4728. yValueDecimal: 0,
  4729. // are there floating numbers in the series. If yes, this represent the len of the decimals
  4730. total: 0,
  4731. SVGNS: 'http://www.w3.org/2000/svg',
  4732. // svg namespace
  4733. svgWidth: 0,
  4734. // the whole svg width
  4735. svgHeight: 0,
  4736. // the whole svg height
  4737. noData: false,
  4738. // whether there is any data to display or not
  4739. locale: {},
  4740. // the current locale values will be preserved here for global access
  4741. dom: {},
  4742. // for storing all dom nodes in this particular property
  4743. memory: {
  4744. methodsToExec: []
  4745. },
  4746. shouldAnimate: true,
  4747. skipLastTimelinelabel: false,
  4748. // when last label is cropped, skip drawing it
  4749. skipFirstTimelinelabel: false,
  4750. // when first label is cropped, skip drawing it
  4751. delayedElements: [],
  4752. // element which appear after animation has finished
  4753. axisCharts: true,
  4754. // chart type = line or area or bar
  4755. // (refer them also as plot charts in the code)
  4756. isDataXYZ: false,
  4757. // bool: data was provided in a {[x,y,z]} pattern
  4758. resized: false,
  4759. // bool: user has resized
  4760. resizeTimer: null,
  4761. // timeout function to make a small delay before
  4762. // drawing when user resized
  4763. comboCharts: false,
  4764. // bool: whether it's a combination of line/column
  4765. dataChanged: false,
  4766. // bool: has data changed dynamically
  4767. previousPaths: [],
  4768. // array: when data is changed, it will animate from
  4769. // previous paths
  4770. allSeriesHasEqualX: true,
  4771. pointsArray: [],
  4772. // store the points positions here to draw later on hover
  4773. // format is - [[x,y],[x,y]... [x,y]]
  4774. dataLabelsRects: [],
  4775. // store the positions of datalabels to prevent collision
  4776. lastDrawnDataLabelsIndexes: [],
  4777. x2SpaceAvailable: 0,
  4778. // space available on the right side after grid area
  4779. hasNullValues: false,
  4780. // bool: whether series contains null values
  4781. easing: null,
  4782. // function: animation effect to apply
  4783. zoomed: false,
  4784. // whether user has zoomed or not
  4785. gridWidth: 0,
  4786. // drawable width of actual graphs (series paths)
  4787. gridHeight: 0,
  4788. // drawable height of actual graphs (series paths)
  4789. rotateXLabels: false,
  4790. defaultLabels: false,
  4791. xLabelFormatter: undefined,
  4792. // formatter for x axis labels
  4793. yLabelFormatters: [],
  4794. xaxisTooltipFormatter: undefined,
  4795. // formatter for x axis tooltip
  4796. ttKeyFormatter: undefined,
  4797. ttVal: undefined,
  4798. ttZFormatter: undefined,
  4799. LINE_HEIGHT_RATIO: 1.618,
  4800. xAxisLabelsHeight: 0,
  4801. yAxisLabelsWidth: 0,
  4802. scaleX: 1,
  4803. scaleY: 1,
  4804. translateX: 0,
  4805. translateY: 0,
  4806. translateYAxisX: [],
  4807. yAxisWidths: [],
  4808. translateXAxisY: 0,
  4809. translateXAxisX: 0,
  4810. tooltip: null
  4811. };
  4812. }
  4813. }, {
  4814. key: "init",
  4815. value: function init(config) {
  4816. var globals = this.globalVars(config);
  4817. this.initGlobalVars(globals);
  4818. globals.initialConfig = Utils.extend({}, config);
  4819. globals.initialSeries = JSON.parse(JSON.stringify(globals.initialConfig.series));
  4820. globals.lastXAxis = JSON.parse(JSON.stringify(globals.initialConfig.xaxis));
  4821. globals.lastYAxis = JSON.parse(JSON.stringify(globals.initialConfig.yaxis));
  4822. return globals;
  4823. }
  4824. }]);
  4825. return Globals;
  4826. }();
  4827. /**
  4828. * ApexCharts Base Class for extending user options with pre-defined ApexCharts config.
  4829. *
  4830. * @module Base
  4831. **/
  4832. var Base = /*#__PURE__*/function () {
  4833. function Base(opts) {
  4834. _classCallCheck(this, Base);
  4835. this.opts = opts;
  4836. }
  4837. _createClass(Base, [{
  4838. key: "init",
  4839. value: function init() {
  4840. var config = new Config(this.opts).init({
  4841. responsiveOverride: false
  4842. });
  4843. var globals = new Globals().init(config);
  4844. var w = {
  4845. config: config,
  4846. globals: globals
  4847. };
  4848. return w;
  4849. }
  4850. }]);
  4851. return Base;
  4852. }();
  4853. /*
  4854. ** Util functions which are dependent on ApexCharts instance
  4855. */
  4856. var CoreUtils = /*#__PURE__*/function () {
  4857. function CoreUtils(ctx) {
  4858. _classCallCheck(this, CoreUtils);
  4859. this.ctx = ctx;
  4860. this.w = ctx.w;
  4861. }
  4862. _createClass(CoreUtils, [{
  4863. key: "getStackedSeriesTotals",
  4864. /**
  4865. * @memberof CoreUtils
  4866. * returns the sum of all individual values in a multiple stacked series
  4867. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  4868. * @return [34,36,48,13]
  4869. **/
  4870. value: function getStackedSeriesTotals() {
  4871. var w = this.w;
  4872. var total = [];
  4873. if (w.globals.series.length === 0) return total;
  4874. for (var i = 0; i < w.globals.series[w.globals.maxValsInArrayIndex].length; i++) {
  4875. var t = 0;
  4876. for (var j = 0; j < w.globals.series.length; j++) {
  4877. if (typeof w.globals.series[j][i] !== 'undefined') {
  4878. t += w.globals.series[j][i];
  4879. }
  4880. }
  4881. total.push(t);
  4882. }
  4883. w.globals.stackedSeriesTotals = total;
  4884. return total;
  4885. } // get total of the all values inside all series
  4886. }, {
  4887. key: "getSeriesTotalByIndex",
  4888. value: function getSeriesTotalByIndex() {
  4889. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4890. if (index === null) {
  4891. // non-plot chart types - pie / donut / circle
  4892. return this.w.config.series.reduce(function (acc, cur) {
  4893. return acc + cur;
  4894. }, 0);
  4895. } else {
  4896. // axis charts - supporting multiple series
  4897. return this.w.globals.series[index].reduce(function (acc, cur) {
  4898. return acc + cur;
  4899. }, 0);
  4900. }
  4901. }
  4902. }, {
  4903. key: "isSeriesNull",
  4904. value: function isSeriesNull() {
  4905. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4906. var r = [];
  4907. if (index === null) {
  4908. // non-plot chart types - pie / donut / circle
  4909. r = this.w.config.series.filter(function (d) {
  4910. return d !== null;
  4911. });
  4912. } else {
  4913. // axis charts - supporting multiple series
  4914. r = this.w.config.series[index].data.filter(function (d) {
  4915. return d !== null;
  4916. });
  4917. }
  4918. return r.length === 0;
  4919. }
  4920. }, {
  4921. key: "seriesHaveSameValues",
  4922. value: function seriesHaveSameValues(index) {
  4923. return this.w.globals.series[index].every(function (val, i, arr) {
  4924. return val === arr[0];
  4925. });
  4926. }
  4927. }, {
  4928. key: "getCategoryLabels",
  4929. value: function getCategoryLabels(labels) {
  4930. var w = this.w;
  4931. var catLabels = labels.slice();
  4932. if (w.config.xaxis.convertedCatToNumeric) {
  4933. catLabels = labels.map(function (i) {
  4934. return w.config.xaxis.labels.formatter(i - w.globals.minX + 1);
  4935. });
  4936. }
  4937. return catLabels;
  4938. } // maxValsInArrayIndex is the index of series[] which has the largest number of items
  4939. }, {
  4940. key: "getLargestSeries",
  4941. value: function getLargestSeries() {
  4942. var w = this.w;
  4943. w.globals.maxValsInArrayIndex = w.globals.series.map(function (a) {
  4944. return a.length;
  4945. }).indexOf(Math.max.apply(Math, w.globals.series.map(function (a) {
  4946. return a.length;
  4947. })));
  4948. }
  4949. }, {
  4950. key: "getLargestMarkerSize",
  4951. value: function getLargestMarkerSize() {
  4952. var w = this.w;
  4953. var size = 0;
  4954. w.globals.markers.size.forEach(function (m) {
  4955. size = Math.max(size, m);
  4956. });
  4957. w.globals.markers.largestSize = size;
  4958. return size;
  4959. }
  4960. /**
  4961. * @memberof Core
  4962. * returns the sum of all values in a series
  4963. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  4964. * @return [120, 11]
  4965. **/
  4966. }, {
  4967. key: "getSeriesTotals",
  4968. value: function getSeriesTotals() {
  4969. var w = this.w;
  4970. w.globals.seriesTotals = w.globals.series.map(function (ser, index) {
  4971. var total = 0;
  4972. if (Array.isArray(ser)) {
  4973. for (var j = 0; j < ser.length; j++) {
  4974. total += ser[j];
  4975. }
  4976. } else {
  4977. // for pie/donuts/gauges
  4978. total += ser;
  4979. }
  4980. return total;
  4981. });
  4982. }
  4983. }, {
  4984. key: "getSeriesTotalsXRange",
  4985. value: function getSeriesTotalsXRange(minX, maxX) {
  4986. var w = this.w;
  4987. var seriesTotalsXRange = w.globals.series.map(function (ser, index) {
  4988. var total = 0;
  4989. for (var j = 0; j < ser.length; j++) {
  4990. if (w.globals.seriesX[index][j] > minX && w.globals.seriesX[index][j] < maxX) {
  4991. total += ser[j];
  4992. }
  4993. }
  4994. return total;
  4995. });
  4996. return seriesTotalsXRange;
  4997. }
  4998. /**
  4999. * @memberof CoreUtils
  5000. * returns the percentage value of all individual values which can be used in a 100% stacked series
  5001. * Eg. w.globals.series = [[32, 33, 43, 12], [2, 3, 5, 1]]
  5002. * @return [[94.11, 91.66, 89.58, 92.30], [5.88, 8.33, 10.41, 7.7]]
  5003. **/
  5004. }, {
  5005. key: "getPercentSeries",
  5006. value: function getPercentSeries() {
  5007. var w = this.w;
  5008. w.globals.seriesPercent = w.globals.series.map(function (ser, index) {
  5009. var seriesPercent = [];
  5010. if (Array.isArray(ser)) {
  5011. for (var j = 0; j < ser.length; j++) {
  5012. var total = w.globals.stackedSeriesTotals[j];
  5013. var percent = 0;
  5014. if (total) {
  5015. percent = 100 * ser[j] / total;
  5016. }
  5017. seriesPercent.push(percent);
  5018. }
  5019. } else {
  5020. var _total = w.globals.seriesTotals.reduce(function (acc, val) {
  5021. return acc + val;
  5022. }, 0);
  5023. var _percent = 100 * ser / _total;
  5024. seriesPercent.push(_percent);
  5025. }
  5026. return seriesPercent;
  5027. });
  5028. }
  5029. }, {
  5030. key: "getCalculatedRatios",
  5031. value: function getCalculatedRatios() {
  5032. var gl = this.w.globals;
  5033. var yRatio = [];
  5034. var invertedYRatio = 0;
  5035. var xRatio = 0;
  5036. var initialXRatio = 0;
  5037. var invertedXRatio = 0;
  5038. var zRatio = 0;
  5039. var baseLineY = [];
  5040. var baseLineInvertedY = 0.1;
  5041. var baseLineX = 0;
  5042. gl.yRange = [];
  5043. if (gl.isMultipleYAxis) {
  5044. for (var i = 0; i < gl.minYArr.length; i++) {
  5045. gl.yRange.push(Math.abs(gl.minYArr[i] - gl.maxYArr[i]));
  5046. baseLineY.push(0);
  5047. }
  5048. } else {
  5049. gl.yRange.push(Math.abs(gl.minY - gl.maxY));
  5050. }
  5051. gl.xRange = Math.abs(gl.maxX - gl.minX);
  5052. gl.zRange = Math.abs(gl.maxZ - gl.minZ); // multiple y axis
  5053. for (var _i = 0; _i < gl.yRange.length; _i++) {
  5054. yRatio.push(gl.yRange[_i] / gl.gridHeight);
  5055. }
  5056. xRatio = gl.xRange / gl.gridWidth;
  5057. initialXRatio = Math.abs(gl.initialMaxX - gl.initialMinX) / gl.gridWidth;
  5058. invertedYRatio = gl.yRange / gl.gridWidth;
  5059. invertedXRatio = gl.xRange / gl.gridHeight;
  5060. zRatio = gl.zRange / gl.gridHeight * 16;
  5061. if (!zRatio) {
  5062. zRatio = 1;
  5063. }
  5064. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  5065. // Negative numbers present in series
  5066. gl.hasNegs = true;
  5067. }
  5068. if (gl.isMultipleYAxis) {
  5069. baseLineY = []; // baseline variables is the 0 of the yaxis which will be needed when there are negatives
  5070. for (var _i2 = 0; _i2 < yRatio.length; _i2++) {
  5071. baseLineY.push(-gl.minYArr[_i2] / yRatio[_i2]);
  5072. }
  5073. } else {
  5074. baseLineY.push(-gl.minY / yRatio[0]);
  5075. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  5076. baseLineInvertedY = -gl.minY / invertedYRatio; // this is for bar chart
  5077. baseLineX = gl.minX / xRatio;
  5078. }
  5079. }
  5080. return {
  5081. yRatio: yRatio,
  5082. invertedYRatio: invertedYRatio,
  5083. zRatio: zRatio,
  5084. xRatio: xRatio,
  5085. initialXRatio: initialXRatio,
  5086. invertedXRatio: invertedXRatio,
  5087. baseLineInvertedY: baseLineInvertedY,
  5088. baseLineY: baseLineY,
  5089. baseLineX: baseLineX
  5090. };
  5091. }
  5092. }, {
  5093. key: "getLogSeries",
  5094. value: function getLogSeries(series) {
  5095. var w = this.w;
  5096. w.globals.seriesLog = series.map(function (s, i) {
  5097. if (w.config.yaxis[i] && w.config.yaxis[i].logarithmic) {
  5098. return s.map(function (d) {
  5099. if (d === null) return null;
  5100. var logVal = (Math.log(d) - Math.log(w.globals.minYArr[i])) / (Math.log(w.globals.maxYArr[i]) - Math.log(w.globals.minYArr[i]));
  5101. return logVal;
  5102. });
  5103. } else {
  5104. return s;
  5105. }
  5106. });
  5107. return w.globals.invalidLogScale ? series : w.globals.seriesLog;
  5108. }
  5109. }, {
  5110. key: "getLogYRatios",
  5111. value: function getLogYRatios(yRatio) {
  5112. var _this = this;
  5113. var w = this.w;
  5114. var gl = this.w.globals;
  5115. gl.yLogRatio = yRatio.slice();
  5116. gl.logYRange = gl.yRange.map(function (yRange, i) {
  5117. if (w.config.yaxis[i] && _this.w.config.yaxis[i].logarithmic) {
  5118. var maxY = -Number.MAX_VALUE;
  5119. var minY = Number.MIN_VALUE;
  5120. var range = 1;
  5121. gl.seriesLog.forEach(function (s, si) {
  5122. s.forEach(function (v) {
  5123. if (w.config.yaxis[si] && w.config.yaxis[si].logarithmic) {
  5124. maxY = Math.max(v, maxY);
  5125. minY = Math.min(v, minY);
  5126. }
  5127. });
  5128. });
  5129. range = Math.pow(gl.yRange[i], Math.abs(minY - maxY) / gl.yRange[i]);
  5130. gl.yLogRatio[i] = range / gl.gridHeight;
  5131. return range;
  5132. }
  5133. });
  5134. return gl.invalidLogScale ? yRatio.slice() : gl.yLogRatio;
  5135. } // Some config objects can be array - and we need to extend them correctly
  5136. }], [{
  5137. key: "checkComboSeries",
  5138. value: function checkComboSeries(series) {
  5139. var comboCharts = false;
  5140. var comboBarCount = 0; // if user specified a type in series too, turn on comboCharts flag
  5141. if (series.length && typeof series[0].type !== 'undefined') {
  5142. comboCharts = true;
  5143. series.forEach(function (s) {
  5144. if (s.type === 'bar' || s.type === 'column' || s.type === 'candlestick') {
  5145. comboBarCount++;
  5146. }
  5147. });
  5148. }
  5149. return {
  5150. comboBarCount: comboBarCount,
  5151. comboCharts: comboCharts
  5152. };
  5153. }
  5154. }, {
  5155. key: "extendArrayProps",
  5156. value: function extendArrayProps(configInstance, options) {
  5157. if (options.yaxis) {
  5158. options = configInstance.extendYAxis(options);
  5159. }
  5160. if (options.annotations) {
  5161. if (options.annotations.yaxis) {
  5162. options = configInstance.extendYAxisAnnotations(options);
  5163. }
  5164. if (options.annotations.xaxis) {
  5165. options = configInstance.extendXAxisAnnotations(options);
  5166. }
  5167. if (options.annotations.points) {
  5168. options = configInstance.extendPointAnnotations(options);
  5169. }
  5170. }
  5171. return options;
  5172. }
  5173. }]);
  5174. return CoreUtils;
  5175. }();
  5176. /**
  5177. * ApexCharts Fill Class for setting fill options of the paths.
  5178. *
  5179. * @module Fill
  5180. **/
  5181. var Fill = /*#__PURE__*/function () {
  5182. function Fill(ctx) {
  5183. _classCallCheck(this, Fill);
  5184. this.ctx = ctx;
  5185. this.w = ctx.w;
  5186. this.opts = null;
  5187. this.seriesIndex = 0;
  5188. }
  5189. _createClass(Fill, [{
  5190. key: "clippedImgArea",
  5191. value: function clippedImgArea(params) {
  5192. var w = this.w;
  5193. var cnf = w.config;
  5194. var svgW = parseInt(w.globals.gridWidth, 10);
  5195. var svgH = parseInt(w.globals.gridHeight, 10);
  5196. var size = svgW > svgH ? svgW : svgH;
  5197. var fillImg = params.image;
  5198. var imgWidth = 0;
  5199. var imgHeight = 0;
  5200. if (typeof params.width === 'undefined' && typeof params.height === 'undefined') {
  5201. if (cnf.fill.image.width !== undefined && cnf.fill.image.height !== undefined) {
  5202. imgWidth = cnf.fill.image.width + 1;
  5203. imgHeight = cnf.fill.image.height;
  5204. } else {
  5205. imgWidth = size + 1;
  5206. imgHeight = size;
  5207. }
  5208. } else {
  5209. imgWidth = params.width;
  5210. imgHeight = params.height;
  5211. }
  5212. var elPattern = document.createElementNS(w.globals.SVGNS, 'pattern');
  5213. Graphics.setAttrs(elPattern, {
  5214. id: params.patternID,
  5215. patternUnits: params.patternUnits ? params.patternUnits : 'userSpaceOnUse',
  5216. width: imgWidth + 'px',
  5217. height: imgHeight + 'px'
  5218. });
  5219. var elImage = document.createElementNS(w.globals.SVGNS, 'image');
  5220. elPattern.appendChild(elImage);
  5221. elImage.setAttributeNS(window.SVG.xlink, 'href', fillImg);
  5222. Graphics.setAttrs(elImage, {
  5223. x: 0,
  5224. y: 0,
  5225. preserveAspectRatio: 'none',
  5226. width: imgWidth + 'px',
  5227. height: imgHeight + 'px'
  5228. });
  5229. elImage.style.opacity = params.opacity;
  5230. w.globals.dom.elDefs.node.appendChild(elPattern);
  5231. }
  5232. }, {
  5233. key: "getSeriesIndex",
  5234. value: function getSeriesIndex(opts) {
  5235. var w = this.w;
  5236. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap') {
  5237. this.seriesIndex = opts.seriesNumber;
  5238. } else {
  5239. this.seriesIndex = opts.seriesNumber % w.globals.series.length;
  5240. }
  5241. return this.seriesIndex;
  5242. }
  5243. }, {
  5244. key: "fillPath",
  5245. value: function fillPath(opts) {
  5246. var w = this.w;
  5247. this.opts = opts;
  5248. var cnf = this.w.config;
  5249. var pathFill;
  5250. var patternFill, gradientFill;
  5251. this.seriesIndex = this.getSeriesIndex(opts);
  5252. var fillColors = this.getFillColors();
  5253. var fillColor = fillColors[this.seriesIndex];
  5254. if (typeof fillColor === 'function') {
  5255. fillColor = fillColor({
  5256. seriesIndex: this.seriesIndex,
  5257. dataPointIndex: opts.dataPointIndex,
  5258. value: opts.value,
  5259. w: w
  5260. });
  5261. }
  5262. var fillType = this.getFillType(this.seriesIndex);
  5263. var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[this.seriesIndex] : cnf.fill.opacity;
  5264. var defaultColor = fillColor;
  5265. if (opts.color) {
  5266. fillColor = opts.color;
  5267. }
  5268. if (fillColor.indexOf('rgb') === -1) {
  5269. if (fillColor.length < 9) {
  5270. // if the hex contains alpha and is of 9 digit, skip the opacity
  5271. defaultColor = Utils.hexToRgba(fillColor, fillOpacity);
  5272. }
  5273. } else {
  5274. if (fillColor.indexOf('rgba') > -1) {
  5275. fillOpacity = Utils.getOpacityFromRGBA(fillColor);
  5276. }
  5277. }
  5278. if (opts.opacity) fillOpacity = opts.opacity;
  5279. if (fillType === 'pattern') {
  5280. patternFill = this.handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor);
  5281. }
  5282. if (fillType === 'gradient') {
  5283. gradientFill = this.handleGradientFill(fillColor, fillOpacity, this.seriesIndex);
  5284. }
  5285. if (fillType === 'image') {
  5286. var imgSrc = cnf.fill.image.src;
  5287. var patternID = opts.patternID ? opts.patternID : '';
  5288. this.clippedImgArea({
  5289. opacity: fillOpacity,
  5290. image: Array.isArray(imgSrc) ? opts.seriesNumber < imgSrc.length ? imgSrc[opts.seriesNumber] : imgSrc[0] : imgSrc,
  5291. width: opts.width ? opts.width : undefined,
  5292. height: opts.height ? opts.height : undefined,
  5293. patternUnits: opts.patternUnits,
  5294. patternID: "pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID)
  5295. });
  5296. pathFill = "url(#pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID, ")");
  5297. } else if (fillType === 'gradient') {
  5298. pathFill = gradientFill;
  5299. } else if (fillType === 'pattern') {
  5300. pathFill = patternFill;
  5301. } else {
  5302. pathFill = defaultColor;
  5303. } // override pattern/gradient if opts.solid is true
  5304. if (opts.solid) {
  5305. pathFill = defaultColor;
  5306. }
  5307. return pathFill;
  5308. }
  5309. }, {
  5310. key: "getFillType",
  5311. value: function getFillType(seriesIndex) {
  5312. var w = this.w;
  5313. if (Array.isArray(w.config.fill.type)) {
  5314. return w.config.fill.type[seriesIndex];
  5315. } else {
  5316. return w.config.fill.type;
  5317. }
  5318. }
  5319. }, {
  5320. key: "getFillColors",
  5321. value: function getFillColors() {
  5322. var w = this.w;
  5323. var cnf = w.config;
  5324. var opts = this.opts;
  5325. var fillColors = [];
  5326. if (w.globals.comboCharts) {
  5327. if (w.config.series[this.seriesIndex].type === 'line') {
  5328. if (w.globals.stroke.colors instanceof Array) {
  5329. fillColors = w.globals.stroke.colors;
  5330. } else {
  5331. fillColors.push(w.globals.stroke.colors);
  5332. }
  5333. } else {
  5334. if (w.globals.fill.colors instanceof Array) {
  5335. fillColors = w.globals.fill.colors;
  5336. } else {
  5337. fillColors.push(w.globals.fill.colors);
  5338. }
  5339. }
  5340. } else {
  5341. if (cnf.chart.type === 'line') {
  5342. if (w.globals.stroke.colors instanceof Array) {
  5343. fillColors = w.globals.stroke.colors;
  5344. } else {
  5345. fillColors.push(w.globals.stroke.colors);
  5346. }
  5347. } else {
  5348. if (w.globals.fill.colors instanceof Array) {
  5349. fillColors = w.globals.fill.colors;
  5350. } else {
  5351. fillColors.push(w.globals.fill.colors);
  5352. }
  5353. }
  5354. } // colors passed in arguments
  5355. if (typeof opts.fillColors !== 'undefined') {
  5356. fillColors = [];
  5357. if (opts.fillColors instanceof Array) {
  5358. fillColors = opts.fillColors.slice();
  5359. } else {
  5360. fillColors.push(opts.fillColors);
  5361. }
  5362. }
  5363. return fillColors;
  5364. }
  5365. }, {
  5366. key: "handlePatternFill",
  5367. value: function handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor) {
  5368. var cnf = this.w.config;
  5369. var opts = this.opts;
  5370. var graphics = new Graphics(this.ctx);
  5371. 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;
  5372. var patternLineColor = fillColor;
  5373. if (cnf.fill.pattern.style instanceof Array) {
  5374. if (typeof cnf.fill.pattern.style[opts.seriesNumber] !== 'undefined') {
  5375. var pf = graphics.drawPattern(cnf.fill.pattern.style[opts.seriesNumber], cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  5376. patternFill = pf;
  5377. } else {
  5378. patternFill = defaultColor;
  5379. }
  5380. } else {
  5381. patternFill = graphics.drawPattern(cnf.fill.pattern.style, cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  5382. }
  5383. return patternFill;
  5384. }
  5385. }, {
  5386. key: "handleGradientFill",
  5387. value: function handleGradientFill(fillColor, fillOpacity, i) {
  5388. var cnf = this.w.config;
  5389. var opts = this.opts;
  5390. var graphics = new Graphics(this.ctx);
  5391. var utils = new Utils();
  5392. var type = cnf.fill.gradient.type;
  5393. var gradientFrom = fillColor;
  5394. var gradientTo;
  5395. var opacityFrom = cnf.fill.gradient.opacityFrom === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityFrom) ? cnf.fill.gradient.opacityFrom[i] : cnf.fill.gradient.opacityFrom;
  5396. if (gradientFrom.indexOf('rgba') > -1) {
  5397. opacityFrom = Utils.getOpacityFromRGBA(gradientFrom);
  5398. }
  5399. var opacityTo = cnf.fill.gradient.opacityTo === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityTo) ? cnf.fill.gradient.opacityTo[i] : cnf.fill.gradient.opacityTo;
  5400. if (cnf.fill.gradient.gradientToColors === undefined || cnf.fill.gradient.gradientToColors.length === 0) {
  5401. if (cnf.fill.gradient.shade === 'dark') {
  5402. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity) * -1, fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
  5403. } else {
  5404. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity), fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
  5405. }
  5406. } else {
  5407. var gToColor = cnf.fill.gradient.gradientToColors[opts.seriesNumber];
  5408. gradientTo = gToColor;
  5409. if (gToColor.indexOf('rgba') > -1) {
  5410. opacityTo = Utils.getOpacityFromRGBA(gToColor);
  5411. }
  5412. }
  5413. if (cnf.fill.gradient.inverseColors) {
  5414. var t = gradientFrom;
  5415. gradientFrom = gradientTo;
  5416. gradientTo = t;
  5417. }
  5418. if (gradientFrom.indexOf('rgb') > -1) {
  5419. gradientFrom = Utils.rgb2hex(gradientFrom);
  5420. }
  5421. if (gradientTo.indexOf('rgb') > -1) {
  5422. gradientTo = Utils.rgb2hex(gradientTo);
  5423. }
  5424. return graphics.drawGradient(type, gradientFrom, gradientTo, opacityFrom, opacityTo, opts.size, cnf.fill.gradient.stops, cnf.fill.gradient.colorStops, i);
  5425. }
  5426. }]);
  5427. return Fill;
  5428. }();
  5429. /**
  5430. * ApexCharts Markers Class for drawing points on y values in axes charts.
  5431. *
  5432. * @module Markers
  5433. **/
  5434. var Markers = /*#__PURE__*/function () {
  5435. function Markers(ctx, opts) {
  5436. _classCallCheck(this, Markers);
  5437. this.ctx = ctx;
  5438. this.w = ctx.w;
  5439. }
  5440. _createClass(Markers, [{
  5441. key: "setGlobalMarkerSize",
  5442. value: function setGlobalMarkerSize() {
  5443. var w = this.w;
  5444. w.globals.markers.size = Array.isArray(w.config.markers.size) ? w.config.markers.size : [w.config.markers.size];
  5445. if (w.globals.markers.size.length > 0) {
  5446. if (w.globals.markers.size.length < w.globals.series.length + 1) {
  5447. for (var i = 0; i <= w.globals.series.length; i++) {
  5448. if (typeof w.globals.markers.size[i] === 'undefined') {
  5449. w.globals.markers.size.push(w.globals.markers.size[0]);
  5450. }
  5451. }
  5452. }
  5453. } else {
  5454. w.globals.markers.size = w.config.series.map(function (s) {
  5455. return w.config.markers.size;
  5456. });
  5457. }
  5458. }
  5459. }, {
  5460. key: "plotChartMarkers",
  5461. value: function plotChartMarkers(pointsPos, seriesIndex, j, pSize) {
  5462. var alwaysDrawMarker = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  5463. var w = this.w;
  5464. var i = seriesIndex;
  5465. var p = pointsPos;
  5466. var elPointsWrap = null;
  5467. var graphics = new Graphics(this.ctx);
  5468. var point;
  5469. if (w.globals.markers.size[seriesIndex] > 0 || alwaysDrawMarker) {
  5470. elPointsWrap = graphics.group({
  5471. class: alwaysDrawMarker ? '' : 'apexcharts-series-markers'
  5472. });
  5473. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  5474. }
  5475. if (p.x instanceof Array) {
  5476. for (var q = 0; q < p.x.length; q++) {
  5477. var dataPointIndex = j; // a small hack as we have 2 points for the first val to connect it
  5478. if (j === 1 && q === 0) dataPointIndex = 0;
  5479. if (j === 1 && q === 1) dataPointIndex = 1;
  5480. var PointClasses = 'apexcharts-marker';
  5481. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  5482. PointClasses += ' no-pointer-events';
  5483. }
  5484. var shouldMarkerDraw = Array.isArray(w.config.markers.size) ? w.globals.markers.size[seriesIndex] > 0 : w.config.markers.size > 0;
  5485. if (shouldMarkerDraw || alwaysDrawMarker) {
  5486. if (Utils.isNumber(p.y[q])) {
  5487. PointClasses += " w".concat(Utils.randomId());
  5488. } else {
  5489. PointClasses = 'apexcharts-nullpoint';
  5490. }
  5491. var opts = this.getMarkerConfig(PointClasses, seriesIndex, dataPointIndex);
  5492. if (w.config.series[i].data[j]) {
  5493. if (w.config.series[i].data[j].fillColor) {
  5494. opts.pointFillColor = w.config.series[i].data[j].fillColor;
  5495. }
  5496. if (w.config.series[i].data[j].strokeColor) {
  5497. opts.pointStrokeColor = w.config.series[i].data[j].strokeColor;
  5498. }
  5499. }
  5500. if (pSize) {
  5501. opts.pSize = pSize;
  5502. }
  5503. point = graphics.drawMarker(p.x[q], p.y[q], opts);
  5504. point.attr('rel', dataPointIndex);
  5505. point.attr('j', dataPointIndex);
  5506. point.attr('index', seriesIndex);
  5507. point.node.setAttribute('default-marker-size', opts.pSize);
  5508. var filters = new Filters(this.ctx);
  5509. filters.setSelectionFilter(point, seriesIndex, dataPointIndex);
  5510. this.addEvents(point);
  5511. if (elPointsWrap) {
  5512. elPointsWrap.add(point);
  5513. }
  5514. } else {
  5515. // dynamic array creation - multidimensional
  5516. if (typeof w.globals.pointsArray[seriesIndex] === 'undefined') w.globals.pointsArray[seriesIndex] = [];
  5517. w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]);
  5518. }
  5519. }
  5520. }
  5521. return elPointsWrap;
  5522. }
  5523. }, {
  5524. key: "getMarkerConfig",
  5525. value: function getMarkerConfig(cssClass, seriesIndex) {
  5526. var dataPointIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5527. var w = this.w;
  5528. var pStyle = this.getMarkerStyle(seriesIndex);
  5529. var pSize = w.globals.markers.size[seriesIndex];
  5530. var m = w.config.markers; // discrete markers is an option where user can specify a particular marker with different size and color
  5531. if (dataPointIndex !== null && m.discrete.length) {
  5532. m.discrete.map(function (marker) {
  5533. if (marker.seriesIndex === seriesIndex && marker.dataPointIndex === dataPointIndex) {
  5534. pStyle.pointStrokeColor = marker.strokeColor;
  5535. pStyle.pointFillColor = marker.fillColor;
  5536. pSize = marker.size;
  5537. }
  5538. });
  5539. }
  5540. return {
  5541. pSize: pSize,
  5542. pRadius: m.radius,
  5543. pWidth: m.strokeWidth instanceof Array ? m.strokeWidth[seriesIndex] : m.strokeWidth,
  5544. pointStrokeColor: pStyle.pointStrokeColor,
  5545. pointFillColor: pStyle.pointFillColor,
  5546. shape: m.shape instanceof Array ? m.shape[seriesIndex] : m.shape,
  5547. class: cssClass,
  5548. pointStrokeOpacity: m.strokeOpacity instanceof Array ? m.strokeOpacity[seriesIndex] : m.strokeOpacity,
  5549. pointStrokeDashArray: m.strokeDashArray instanceof Array ? m.strokeDashArray[seriesIndex] : m.strokeDashArray,
  5550. pointFillOpacity: m.fillOpacity instanceof Array ? m.fillOpacity[seriesIndex] : m.fillOpacity,
  5551. seriesIndex: seriesIndex
  5552. };
  5553. }
  5554. }, {
  5555. key: "addEvents",
  5556. value: function addEvents(circle) {
  5557. var w = this.w;
  5558. var graphics = new Graphics(this.ctx);
  5559. circle.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this.ctx, circle));
  5560. circle.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this.ctx, circle));
  5561. circle.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this.ctx, circle));
  5562. circle.node.addEventListener('click', w.config.markers.onClick);
  5563. circle.node.addEventListener('dblclick', w.config.markers.onDblClick);
  5564. circle.node.addEventListener('touchstart', graphics.pathMouseDown.bind(this.ctx, circle), {
  5565. passive: true
  5566. });
  5567. }
  5568. }, {
  5569. key: "getMarkerStyle",
  5570. value: function getMarkerStyle(seriesIndex) {
  5571. var w = this.w;
  5572. var colors = w.globals.markers.colors;
  5573. var strokeColors = w.config.markers.strokeColor || w.config.markers.strokeColors;
  5574. var pointStrokeColor = strokeColors instanceof Array ? strokeColors[seriesIndex] : strokeColors;
  5575. var pointFillColor = colors instanceof Array ? colors[seriesIndex] : colors;
  5576. return {
  5577. pointStrokeColor: pointStrokeColor,
  5578. pointFillColor: pointFillColor
  5579. };
  5580. }
  5581. }]);
  5582. return Markers;
  5583. }();
  5584. /**
  5585. * ApexCharts Scatter Class.
  5586. * This Class also handles bubbles chart as currently there is no major difference in drawing them,
  5587. * @module Scatter
  5588. **/
  5589. var Scatter = /*#__PURE__*/function () {
  5590. function Scatter(ctx) {
  5591. _classCallCheck(this, Scatter);
  5592. this.ctx = ctx;
  5593. this.w = ctx.w;
  5594. this.initialAnim = this.w.config.chart.animations.enabled;
  5595. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  5596. }
  5597. _createClass(Scatter, [{
  5598. key: "draw",
  5599. value: function draw(elSeries, j, opts) {
  5600. var w = this.w;
  5601. var graphics = new Graphics(this.ctx);
  5602. var realIndex = opts.realIndex;
  5603. var pointsPos = opts.pointsPos;
  5604. var zRatio = opts.zRatio;
  5605. var elPointsMain = opts.elParent;
  5606. var elPointsWrap = graphics.group({
  5607. class: "apexcharts-series-markers apexcharts-series-".concat(w.config.chart.type)
  5608. });
  5609. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  5610. if (pointsPos.x instanceof Array) {
  5611. for (var q = 0; q < pointsPos.x.length; q++) {
  5612. var dataPointIndex = j + 1;
  5613. var shouldDraw = true; // a small hack as we have 2 points for the first val to connect it
  5614. if (j === 0 && q === 0) dataPointIndex = 0;
  5615. if (j === 0 && q === 1) dataPointIndex = 1;
  5616. var radius = 0;
  5617. var finishRadius = w.globals.markers.size[realIndex];
  5618. if (zRatio !== Infinity) {
  5619. // means we have a bubble
  5620. finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] / zRatio;
  5621. var bubble = w.config.plotOptions.bubble;
  5622. if (bubble.minBubbleRadius && finishRadius < bubble.minBubbleRadius) {
  5623. finishRadius = bubble.minBubbleRadius;
  5624. }
  5625. if (bubble.maxBubbleRadius && finishRadius > bubble.maxBubbleRadius) {
  5626. finishRadius = bubble.maxBubbleRadius;
  5627. }
  5628. }
  5629. if (!w.config.chart.animations.enabled) {
  5630. radius = finishRadius;
  5631. }
  5632. var x = pointsPos.x[q];
  5633. var y = pointsPos.y[q];
  5634. radius = radius || 0;
  5635. if (y === null || typeof w.globals.series[realIndex][dataPointIndex] === 'undefined') {
  5636. shouldDraw = false;
  5637. }
  5638. if (shouldDraw) {
  5639. var circle = this.drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j);
  5640. elPointsWrap.add(circle);
  5641. }
  5642. elPointsMain.add(elPointsWrap);
  5643. }
  5644. }
  5645. }
  5646. }, {
  5647. key: "drawPoint",
  5648. value: function drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j) {
  5649. var w = this.w;
  5650. var i = realIndex;
  5651. var anim = new Animations(this.ctx);
  5652. var filters = new Filters(this.ctx);
  5653. var fill = new Fill(this.ctx);
  5654. var markers = new Markers(this.ctx);
  5655. var graphics = new Graphics(this.ctx);
  5656. var markerConfig = markers.getMarkerConfig('apexcharts-marker', i);
  5657. var pathFillCircle = fill.fillPath({
  5658. seriesNumber: realIndex,
  5659. dataPointIndex: dataPointIndex,
  5660. patternUnits: 'objectBoundingBox',
  5661. value: w.globals.series[realIndex][j]
  5662. });
  5663. var circle = graphics.drawCircle(radius);
  5664. if (w.config.series[i].data[dataPointIndex]) {
  5665. if (w.config.series[i].data[dataPointIndex].fillColor) {
  5666. pathFillCircle = w.config.series[i].data[dataPointIndex].fillColor;
  5667. }
  5668. }
  5669. circle.attr({
  5670. cx: x,
  5671. cy: y,
  5672. fill: pathFillCircle,
  5673. stroke: markerConfig.pointStrokeColor,
  5674. 'stroke-width': markerConfig.pWidth,
  5675. 'stroke-dasharray': markerConfig.pointStrokeDashArray,
  5676. 'stroke-opacity': markerConfig.pointStrokeOpacity
  5677. });
  5678. if (w.config.chart.dropShadow.enabled) {
  5679. var dropShadow = w.config.chart.dropShadow;
  5680. filters.dropShadow(circle, dropShadow, realIndex);
  5681. }
  5682. if (this.initialAnim && !w.globals.dataChanged) {
  5683. var speed = 1;
  5684. if (!w.globals.resized) {
  5685. speed = w.config.chart.animations.speed;
  5686. }
  5687. anim.animateCircleRadius(circle, 0, finishRadius, speed, w.globals.easing, function () {
  5688. window.setTimeout(function () {
  5689. anim.animationCompleted(circle);
  5690. }, 100);
  5691. });
  5692. }
  5693. if (w.globals.dataChanged) {
  5694. if (this.dynamicAnim) {
  5695. var _speed = w.config.chart.animations.dynamicAnimation.speed;
  5696. var prevX, prevY, prevR;
  5697. var prevPathJ = null;
  5698. prevPathJ = w.globals.previousPaths[realIndex] && w.globals.previousPaths[realIndex][j];
  5699. if (typeof prevPathJ !== 'undefined' && prevPathJ !== null) {
  5700. // series containing less elements will ignore these values and revert to 0
  5701. prevX = prevPathJ.x;
  5702. prevY = prevPathJ.y;
  5703. prevR = typeof prevPathJ.r !== 'undefined' ? prevPathJ.r : finishRadius;
  5704. }
  5705. for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) {
  5706. if (w.globals.collapsedSeries[cs].index === realIndex) {
  5707. _speed = 1;
  5708. finishRadius = 0;
  5709. }
  5710. }
  5711. if (x === 0 && y === 0) finishRadius = 0;
  5712. anim.animateCircle(circle, {
  5713. cx: prevX,
  5714. cy: prevY,
  5715. r: prevR
  5716. }, {
  5717. cx: x,
  5718. cy: y,
  5719. r: finishRadius
  5720. }, _speed, w.globals.easing);
  5721. } else {
  5722. circle.attr({
  5723. r: finishRadius
  5724. });
  5725. }
  5726. }
  5727. circle.attr({
  5728. rel: dataPointIndex,
  5729. j: dataPointIndex,
  5730. index: realIndex,
  5731. 'default-marker-size': finishRadius
  5732. });
  5733. filters.setSelectionFilter(circle, realIndex, dataPointIndex);
  5734. markers.addEvents(circle);
  5735. circle.node.classList.add('apexcharts-marker');
  5736. return circle;
  5737. }
  5738. }, {
  5739. key: "centerTextInBubble",
  5740. value: function centerTextInBubble(y) {
  5741. var w = this.w;
  5742. y = y + parseInt(w.config.dataLabels.style.fontSize, 10) / 4;
  5743. return {
  5744. y: y
  5745. };
  5746. }
  5747. }]);
  5748. return Scatter;
  5749. }();
  5750. /**
  5751. * ApexCharts DataLabels Class for drawing dataLabels on Axes based Charts.
  5752. *
  5753. * @module DataLabels
  5754. **/
  5755. var DataLabels = /*#__PURE__*/function () {
  5756. function DataLabels(ctx) {
  5757. _classCallCheck(this, DataLabels);
  5758. this.ctx = ctx;
  5759. this.w = ctx.w;
  5760. } // When there are many datalabels to be printed, and some of them overlaps each other in the same series, this method will take care of that
  5761. // Also, when datalabels exceeds the drawable area and get clipped off, we need to adjust and move some pixels to make them visible again
  5762. _createClass(DataLabels, [{
  5763. key: "dataLabelsCorrection",
  5764. value: function dataLabelsCorrection(x, y, val, i, dataPointIndex, alwaysDrawDataLabel, fontSize) {
  5765. var w = this.w;
  5766. var graphics = new Graphics(this.ctx);
  5767. var drawnextLabel = false; //
  5768. var textRects = graphics.getTextRects(val, fontSize);
  5769. var width = textRects.width;
  5770. var height = textRects.height; // first value in series, so push an empty array
  5771. if (typeof w.globals.dataLabelsRects[i] === 'undefined') w.globals.dataLabelsRects[i] = []; // then start pushing actual rects in that sub-array
  5772. w.globals.dataLabelsRects[i].push({
  5773. x: x,
  5774. y: y,
  5775. width: width,
  5776. height: height
  5777. });
  5778. var len = w.globals.dataLabelsRects[i].length - 2;
  5779. var lastDrawnIndex = typeof w.globals.lastDrawnDataLabelsIndexes[i] !== 'undefined' ? w.globals.lastDrawnDataLabelsIndexes[i][w.globals.lastDrawnDataLabelsIndexes[i].length - 1] : 0;
  5780. if (typeof w.globals.dataLabelsRects[i][len] !== 'undefined') {
  5781. var lastDataLabelRect = w.globals.dataLabelsRects[i][lastDrawnIndex];
  5782. if ( // next label forward and x not intersecting
  5783. x > lastDataLabelRect.x + lastDataLabelRect.width + 2 || y > lastDataLabelRect.y + lastDataLabelRect.height + 2 || x + width < lastDataLabelRect.x // next label is going to be drawn backwards
  5784. ) {
  5785. // the 2 indexes don't override, so OK to draw next label
  5786. drawnextLabel = true;
  5787. }
  5788. }
  5789. if (dataPointIndex === 0 || alwaysDrawDataLabel) {
  5790. drawnextLabel = true;
  5791. }
  5792. return {
  5793. x: x,
  5794. y: y,
  5795. textRects: textRects,
  5796. drawnextLabel: drawnextLabel
  5797. };
  5798. }
  5799. }, {
  5800. key: "drawDataLabel",
  5801. value: function drawDataLabel(pos, i, j) {
  5802. var _this = this;
  5803. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
  5804. // this method handles line, area, bubble, scatter charts as those charts contains markers/points which have pre-defined x/y positions
  5805. // all other charts like radar / bars / heatmaps will define their own drawDataLabel routine
  5806. var w = this.w;
  5807. var graphics = new Graphics(this.ctx);
  5808. var dataLabelsConfig = w.config.dataLabels;
  5809. var x = 0;
  5810. var y = 0;
  5811. var dataPointIndex = j;
  5812. var elDataLabelsWrap = null;
  5813. if (!dataLabelsConfig.enabled || pos.x instanceof Array !== true) {
  5814. return elDataLabelsWrap;
  5815. }
  5816. elDataLabelsWrap = graphics.group({
  5817. class: 'apexcharts-data-labels'
  5818. });
  5819. for (var q = 0; q < pos.x.length; q++) {
  5820. x = pos.x[q] + dataLabelsConfig.offsetX;
  5821. y = pos.y[q] + dataLabelsConfig.offsetY + strokeWidth;
  5822. if (!isNaN(x)) {
  5823. // a small hack as we have 2 points for the first val to connect it
  5824. if (j === 1 && q === 0) dataPointIndex = 0;
  5825. if (j === 1 && q === 1) dataPointIndex = 1;
  5826. var val = w.globals.series[i][dataPointIndex];
  5827. var text = '';
  5828. var getText = function getText(v) {
  5829. return w.config.dataLabels.formatter(v, {
  5830. ctx: _this.ctx,
  5831. seriesIndex: i,
  5832. dataPointIndex: dataPointIndex,
  5833. w: w
  5834. });
  5835. };
  5836. if (w.config.chart.type === 'bubble') {
  5837. val = w.globals.seriesZ[i][dataPointIndex];
  5838. text = getText(val);
  5839. y = pos.y[q];
  5840. var scatter = new Scatter(this.ctx);
  5841. var centerTextInBubbleCoords = scatter.centerTextInBubble(y, i, dataPointIndex);
  5842. y = centerTextInBubbleCoords.y;
  5843. } else {
  5844. if (typeof val !== 'undefined') {
  5845. text = getText(val);
  5846. }
  5847. }
  5848. this.plotDataLabelsText({
  5849. x: x,
  5850. y: y,
  5851. text: text,
  5852. i: i,
  5853. j: dataPointIndex,
  5854. parent: elDataLabelsWrap,
  5855. offsetCorrection: true,
  5856. dataLabelsConfig: w.config.dataLabels
  5857. });
  5858. }
  5859. }
  5860. return elDataLabelsWrap;
  5861. }
  5862. }, {
  5863. key: "plotDataLabelsText",
  5864. value: function plotDataLabelsText(opts) {
  5865. var w = this.w;
  5866. var graphics = new Graphics(this.ctx);
  5867. var x = opts.x,
  5868. y = opts.y,
  5869. i = opts.i,
  5870. j = opts.j,
  5871. text = opts.text,
  5872. textAnchor = opts.textAnchor,
  5873. parent = opts.parent,
  5874. dataLabelsConfig = opts.dataLabelsConfig,
  5875. color = opts.color,
  5876. alwaysDrawDataLabel = opts.alwaysDrawDataLabel,
  5877. offsetCorrection = opts.offsetCorrection;
  5878. if (Array.isArray(w.config.dataLabels.enabledOnSeries)) {
  5879. if (w.config.dataLabels.enabledOnSeries.indexOf(i) < 0) {
  5880. return;
  5881. }
  5882. }
  5883. var correctedLabels = {
  5884. x: x,
  5885. y: y,
  5886. drawnextLabel: true
  5887. };
  5888. if (offsetCorrection) {
  5889. correctedLabels = this.dataLabelsCorrection(x, y, text, i, j, alwaysDrawDataLabel, parseInt(dataLabelsConfig.style.fontSize, 10));
  5890. } // when zoomed, we don't need to correct labels offsets,
  5891. // but if normally, labels get cropped, correct them
  5892. if (!w.globals.zoomed) {
  5893. x = correctedLabels.x;
  5894. y = correctedLabels.y;
  5895. }
  5896. if (correctedLabels.textRects) {
  5897. if (x + correctedLabels.textRects.width < -20 || x > w.globals.gridWidth + 20) {
  5898. // datalabels fall outside drawing area, so draw a blank label
  5899. text = '';
  5900. }
  5901. }
  5902. var dataLabelColor = w.globals.dataLabels.style.colors[i];
  5903. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.dataLabels.distributed) {
  5904. dataLabelColor = w.globals.dataLabels.style.colors[j];
  5905. }
  5906. if (color) {
  5907. dataLabelColor = color;
  5908. }
  5909. var offX = dataLabelsConfig.offsetX;
  5910. var offY = dataLabelsConfig.offsetY;
  5911. if (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') {
  5912. // for certain chart types, we handle offsets while calculating datalabels pos
  5913. // why? because bars/column may have negative values and based on that
  5914. // offsets becomes reversed
  5915. offX = 0;
  5916. offY = 0;
  5917. }
  5918. if (correctedLabels.drawnextLabel) {
  5919. var dataLabelText = graphics.drawText({
  5920. width: 100,
  5921. height: parseInt(dataLabelsConfig.style.fontSize, 10),
  5922. x: x + offX,
  5923. y: y + offY,
  5924. foreColor: dataLabelColor,
  5925. textAnchor: textAnchor || dataLabelsConfig.textAnchor,
  5926. text: text,
  5927. fontSize: dataLabelsConfig.style.fontSize,
  5928. fontFamily: dataLabelsConfig.style.fontFamily,
  5929. fontWeight: dataLabelsConfig.style.fontWeight || 'normal'
  5930. });
  5931. dataLabelText.attr({
  5932. class: 'apexcharts-datalabel',
  5933. cx: x,
  5934. cy: y
  5935. });
  5936. if (dataLabelsConfig.dropShadow.enabled) {
  5937. var textShadow = dataLabelsConfig.dropShadow;
  5938. var filters = new Filters(this.ctx);
  5939. filters.dropShadow(dataLabelText, textShadow);
  5940. }
  5941. parent.add(dataLabelText);
  5942. if (typeof w.globals.lastDrawnDataLabelsIndexes[i] === 'undefined') {
  5943. w.globals.lastDrawnDataLabelsIndexes[i] = [];
  5944. }
  5945. w.globals.lastDrawnDataLabelsIndexes[i].push(j);
  5946. }
  5947. }
  5948. }, {
  5949. key: "addBackgroundToDataLabel",
  5950. value: function addBackgroundToDataLabel(el, coords) {
  5951. var w = this.w;
  5952. var bCnf = w.config.dataLabels.background;
  5953. var paddingH = bCnf.padding;
  5954. var paddingV = bCnf.padding / 2;
  5955. var width = coords.width;
  5956. var height = coords.height;
  5957. var graphics = new Graphics(this.ctx);
  5958. 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);
  5959. if (bCnf.dropShadow.enabled) {
  5960. var filters = new Filters(this.ctx);
  5961. filters.dropShadow(elRect, bCnf.dropShadow);
  5962. }
  5963. return elRect;
  5964. }
  5965. }, {
  5966. key: "dataLabelsBackground",
  5967. value: function dataLabelsBackground() {
  5968. var w = this.w;
  5969. if (w.config.chart.type === 'bubble') return;
  5970. var elDataLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-datalabels text');
  5971. for (var i = 0; i < elDataLabels.length; i++) {
  5972. var el = elDataLabels[i];
  5973. var coords = el.getBBox();
  5974. var elRect = null;
  5975. if (coords.width && coords.height) {
  5976. elRect = this.addBackgroundToDataLabel(el, coords);
  5977. }
  5978. if (elRect) {
  5979. el.parentNode.insertBefore(elRect.node, el);
  5980. var background = el.getAttribute('fill');
  5981. var shouldAnim = w.config.chart.animations.enabled && !w.globals.resized && !w.globals.dataChanged;
  5982. if (shouldAnim) {
  5983. elRect.animate().attr({
  5984. fill: background
  5985. });
  5986. } else {
  5987. elRect.attr({
  5988. fill: background
  5989. });
  5990. }
  5991. el.setAttribute('fill', w.config.dataLabels.background.foreColor);
  5992. }
  5993. }
  5994. }
  5995. }, {
  5996. key: "bringForward",
  5997. value: function bringForward() {
  5998. var w = this.w;
  5999. var elDataLabelsNodes = w.globals.dom.baseEl.getElementsByClassName('apexcharts-datalabels');
  6000. var elSeries = w.globals.dom.baseEl.querySelector('.apexcharts-plot-series:last-child');
  6001. for (var i = 0; i < elDataLabelsNodes.length; i++) {
  6002. if (elSeries) {
  6003. elSeries.insertBefore(elDataLabelsNodes[i], elSeries.nextSibling);
  6004. }
  6005. }
  6006. }
  6007. }]);
  6008. return DataLabels;
  6009. }();
  6010. /**
  6011. * ApexCharts Series Class for interation with the Series of the chart.
  6012. *
  6013. * @module Series
  6014. **/
  6015. var Series = /*#__PURE__*/function () {
  6016. function Series(ctx) {
  6017. _classCallCheck(this, Series);
  6018. this.ctx = ctx;
  6019. this.w = ctx.w;
  6020. this.legendInactiveClass = 'legend-mouseover-inactive';
  6021. }
  6022. _createClass(Series, [{
  6023. key: "getAllSeriesEls",
  6024. value: function getAllSeriesEls() {
  6025. return this.w.globals.dom.baseEl.getElementsByClassName("apexcharts-series");
  6026. }
  6027. }, {
  6028. key: "getSeriesByName",
  6029. value: function getSeriesByName(seriesName) {
  6030. return this.w.globals.dom.baseEl.querySelector("[seriesName='".concat(Utils.escapeString(seriesName), "']"));
  6031. }
  6032. }, {
  6033. key: "isSeriesHidden",
  6034. value: function isSeriesHidden(seriesName) {
  6035. var targetElement = this.getSeriesByName(seriesName);
  6036. var realIndex = parseInt(targetElement.getAttribute('data:realIndex'), 10);
  6037. var isHidden = targetElement.classList.contains('apexcharts-series-collapsed');
  6038. return {
  6039. isHidden: isHidden,
  6040. realIndex: realIndex
  6041. };
  6042. }
  6043. }, {
  6044. key: "addCollapsedClassToSeries",
  6045. value: function addCollapsedClassToSeries(elSeries, index) {
  6046. var w = this.w;
  6047. function iterateOnAllCollapsedSeries(series) {
  6048. for (var cs = 0; cs < series.length; cs++) {
  6049. if (series[cs].index === index) {
  6050. elSeries.node.classList.add('apexcharts-series-collapsed');
  6051. }
  6052. }
  6053. }
  6054. iterateOnAllCollapsedSeries(w.globals.collapsedSeries);
  6055. iterateOnAllCollapsedSeries(w.globals.ancillaryCollapsedSeries);
  6056. }
  6057. }, {
  6058. key: "toggleSeries",
  6059. value: function toggleSeries(seriesName) {
  6060. var isSeriesHidden = this.isSeriesHidden(seriesName);
  6061. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, isSeriesHidden.isHidden);
  6062. return isSeriesHidden.isHidden;
  6063. }
  6064. }, {
  6065. key: "showSeries",
  6066. value: function showSeries(seriesName) {
  6067. var isSeriesHidden = this.isSeriesHidden(seriesName);
  6068. if (isSeriesHidden.isHidden) {
  6069. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, true);
  6070. }
  6071. }
  6072. }, {
  6073. key: "hideSeries",
  6074. value: function hideSeries(seriesName) {
  6075. var isSeriesHidden = this.isSeriesHidden(seriesName);
  6076. if (!isSeriesHidden.isHidden) {
  6077. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, false);
  6078. }
  6079. }
  6080. }, {
  6081. key: "resetSeries",
  6082. value: function resetSeries() {
  6083. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  6084. var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  6085. var shouldResetCollapsed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  6086. var w = this.w;
  6087. var series = w.globals.initialSeries.slice();
  6088. w.config.series = series;
  6089. w.globals.previousPaths = [];
  6090. if (shouldResetCollapsed) {
  6091. w.globals.collapsedSeries = [];
  6092. w.globals.ancillaryCollapsedSeries = [];
  6093. w.globals.collapsedSeriesIndices = [];
  6094. w.globals.ancillaryCollapsedSeriesIndices = [];
  6095. }
  6096. if (shouldUpdateChart) {
  6097. if (shouldResetZoom) {
  6098. w.globals.zoomed = false;
  6099. this.ctx.updateHelpers.revertDefaultAxisMinMax();
  6100. }
  6101. this.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  6102. }
  6103. }
  6104. }, {
  6105. key: "toggleSeriesOnHover",
  6106. value: function toggleSeriesOnHover(e, targetElement) {
  6107. var w = this.w;
  6108. var allSeriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");
  6109. if (e.type === 'mousemove') {
  6110. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  6111. var seriesEl = null;
  6112. var dataLabelEl = null;
  6113. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  6114. if (w.globals.axisCharts) {
  6115. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  6116. dataLabelEl = w.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(seriesCnt, "']"));
  6117. } else {
  6118. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  6119. }
  6120. } else {
  6121. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  6122. }
  6123. for (var se = 0; se < allSeriesEls.length; se++) {
  6124. allSeriesEls[se].classList.add(this.legendInactiveClass);
  6125. }
  6126. if (seriesEl !== null) {
  6127. if (!w.globals.axisCharts) {
  6128. seriesEl.parentNode.classList.remove(this.legendInactiveClass);
  6129. }
  6130. seriesEl.classList.remove(this.legendInactiveClass);
  6131. if (dataLabelEl !== null) {
  6132. dataLabelEl.classList.remove(this.legendInactiveClass);
  6133. }
  6134. }
  6135. } else if (e.type === 'mouseout') {
  6136. for (var _se = 0; _se < allSeriesEls.length; _se++) {
  6137. allSeriesEls[_se].classList.remove(this.legendInactiveClass);
  6138. }
  6139. }
  6140. }
  6141. }, {
  6142. key: "highlightRangeInSeries",
  6143. value: function highlightRangeInSeries(e, targetElement) {
  6144. var _this = this;
  6145. var w = this.w;
  6146. var allHeatMapElements = w.globals.dom.baseEl.getElementsByClassName('apexcharts-heatmap-rect');
  6147. var activeInactive = function activeInactive(action) {
  6148. for (var i = 0; i < allHeatMapElements.length; i++) {
  6149. allHeatMapElements[i].classList[action](_this.legendInactiveClass);
  6150. }
  6151. };
  6152. var removeInactiveClassFromHoveredRange = function removeInactiveClassFromHoveredRange(range) {
  6153. for (var i = 0; i < allHeatMapElements.length; i++) {
  6154. var val = parseInt(allHeatMapElements[i].getAttribute('val'), 10);
  6155. if (val >= range.from && val <= range.to) {
  6156. allHeatMapElements[i].classList.remove(_this.legendInactiveClass);
  6157. }
  6158. }
  6159. };
  6160. if (e.type === 'mousemove') {
  6161. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  6162. activeInactive('add');
  6163. var range = w.config.plotOptions.heatmap.colorScale.ranges[seriesCnt];
  6164. removeInactiveClassFromHoveredRange(range);
  6165. } else if (e.type === 'mouseout') {
  6166. activeInactive('remove');
  6167. }
  6168. }
  6169. }, {
  6170. key: "getActiveConfigSeriesIndex",
  6171. value: function getActiveConfigSeriesIndex() {
  6172. var ignoreBars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6173. var w = this.w;
  6174. var activeIndex = 0;
  6175. if (w.config.series.length > 1) {
  6176. // active series flag is required to know if user has not deactivated via legend click
  6177. var firstActiveSeriesIndex = w.config.series.map(function (series, index) {
  6178. var hasBars = false;
  6179. if (ignoreBars) {
  6180. hasBars = w.config.series[index].type === 'bar' || w.config.series[index].type === 'column';
  6181. }
  6182. return series.data && series.data.length > 0 && !hasBars ? index : -1;
  6183. });
  6184. for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
  6185. if (firstActiveSeriesIndex[a] !== -1) {
  6186. activeIndex = firstActiveSeriesIndex[a];
  6187. break;
  6188. }
  6189. }
  6190. }
  6191. return activeIndex;
  6192. }
  6193. }, {
  6194. key: "getPreviousPaths",
  6195. value: function getPreviousPaths() {
  6196. var w = this.w;
  6197. w.globals.previousPaths = [];
  6198. function pushPaths(seriesEls, i, type) {
  6199. var paths = seriesEls[i].childNodes;
  6200. var dArr = {
  6201. type: type,
  6202. paths: [],
  6203. realIndex: seriesEls[i].getAttribute('data:realIndex')
  6204. };
  6205. for (var j = 0; j < paths.length; j++) {
  6206. if (paths[j].hasAttribute('pathTo')) {
  6207. var d = paths[j].getAttribute('pathTo');
  6208. dArr.paths.push({
  6209. d: d
  6210. });
  6211. }
  6212. }
  6213. w.globals.previousPaths.push(dArr);
  6214. }
  6215. var getPaths = function getPaths(chartType) {
  6216. return w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(chartType, "-series .apexcharts-series"));
  6217. };
  6218. var chartTypes = ['line', 'area', 'bar', 'candlestick', 'radar'];
  6219. chartTypes.forEach(function (type) {
  6220. var paths = getPaths(type);
  6221. for (var p = 0; p < paths.length; p++) {
  6222. pushPaths(paths, p, type);
  6223. }
  6224. });
  6225. this.handlePrevBubbleScatterPaths('bubble');
  6226. this.handlePrevBubbleScatterPaths('scatter');
  6227. var heatmapColors = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap .apexcharts-series');
  6228. if (heatmapColors.length > 0) {
  6229. for (var h = 0; h < heatmapColors.length; h++) {
  6230. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-heatmap .apexcharts-series[data\\:realIndex='".concat(h, "'] rect"));
  6231. var dArr = [];
  6232. for (var i = 0; i < seriesEls.length; i++) {
  6233. dArr.push({
  6234. color: seriesEls[i].getAttribute('color')
  6235. });
  6236. }
  6237. w.globals.previousPaths.push(dArr);
  6238. }
  6239. }
  6240. if (!w.globals.axisCharts) {
  6241. // for non-axis charts (i.e., circular charts, pathFrom is not usable. We need whole series)
  6242. w.globals.previousPaths = w.globals.series;
  6243. }
  6244. }
  6245. }, {
  6246. key: "handlePrevBubbleScatterPaths",
  6247. value: function handlePrevBubbleScatterPaths(type) {
  6248. var w = this.w;
  6249. var paths = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series"));
  6250. if (paths.length > 0) {
  6251. for (var s = 0; s < paths.length; s++) {
  6252. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series[data\\:realIndex='").concat(s, "'] circle"));
  6253. var dArr = [];
  6254. for (var i = 0; i < seriesEls.length; i++) {
  6255. dArr.push({
  6256. x: seriesEls[i].getAttribute('cx'),
  6257. y: seriesEls[i].getAttribute('cy'),
  6258. r: seriesEls[i].getAttribute('r')
  6259. });
  6260. }
  6261. w.globals.previousPaths.push(dArr);
  6262. }
  6263. }
  6264. }
  6265. }, {
  6266. key: "clearPreviousPaths",
  6267. value: function clearPreviousPaths() {
  6268. var w = this.w;
  6269. w.globals.previousPaths = [];
  6270. w.globals.allSeriesCollapsed = false;
  6271. }
  6272. }, {
  6273. key: "handleNoData",
  6274. value: function handleNoData() {
  6275. var w = this.w;
  6276. var me = this;
  6277. var noDataOpts = w.config.noData;
  6278. var graphics = new Graphics(me.ctx);
  6279. var x = w.globals.svgWidth / 2;
  6280. var y = w.globals.svgHeight / 2;
  6281. var textAnchor = 'middle';
  6282. w.globals.noData = true;
  6283. w.globals.animationEnded = true;
  6284. if (noDataOpts.align === 'left') {
  6285. x = 10;
  6286. textAnchor = 'start';
  6287. } else if (noDataOpts.align === 'right') {
  6288. x = w.globals.svgWidth - 10;
  6289. textAnchor = 'end';
  6290. }
  6291. if (noDataOpts.verticalAlign === 'top') {
  6292. y = 50;
  6293. } else if (noDataOpts.verticalAlign === 'bottom') {
  6294. y = w.globals.svgHeight - 50;
  6295. }
  6296. x = x + noDataOpts.offsetX;
  6297. y = y + parseInt(noDataOpts.style.fontSize, 10) + 2 + noDataOpts.offsetY;
  6298. if (noDataOpts.text !== undefined && noDataOpts.text !== '') {
  6299. var titleText = graphics.drawText({
  6300. x: x,
  6301. y: y,
  6302. text: noDataOpts.text,
  6303. textAnchor: textAnchor,
  6304. fontSize: noDataOpts.style.fontSize,
  6305. fontFamily: noDataOpts.style.fontFamily,
  6306. foreColor: noDataOpts.style.color,
  6307. opacity: 1,
  6308. class: 'apexcharts-text-nodata'
  6309. });
  6310. w.globals.dom.Paper.add(titleText);
  6311. }
  6312. } // When user clicks on legends, the collapsed series is filled with [0,0,0,...,0]
  6313. // This is because we don't want to alter the series' length as it is used at many places
  6314. }, {
  6315. key: "setNullSeriesToZeroValues",
  6316. value: function setNullSeriesToZeroValues(series) {
  6317. var w = this.w;
  6318. for (var sl = 0; sl < series.length; sl++) {
  6319. if (series[sl].length === 0) {
  6320. for (var j = 0; j < series[w.globals.maxValsInArrayIndex].length; j++) {
  6321. series[sl].push(0);
  6322. }
  6323. }
  6324. }
  6325. return series;
  6326. }
  6327. }, {
  6328. key: "hasAllSeriesEqualX",
  6329. value: function hasAllSeriesEqualX() {
  6330. var equalLen = true;
  6331. var w = this.w;
  6332. var filteredSerX = this.filteredSeriesX();
  6333. for (var i = 0; i < filteredSerX.length - 1; i++) {
  6334. if (filteredSerX[i][0] !== filteredSerX[i + 1][0]) {
  6335. equalLen = false;
  6336. break;
  6337. }
  6338. }
  6339. w.globals.allSeriesHasEqualX = equalLen;
  6340. return equalLen;
  6341. }
  6342. }, {
  6343. key: "filteredSeriesX",
  6344. value: function filteredSeriesX() {
  6345. var w = this.w;
  6346. var filteredSeriesX = w.globals.seriesX.map(function (ser) {
  6347. return ser.length > 0 ? ser : [];
  6348. });
  6349. return filteredSeriesX;
  6350. }
  6351. }]);
  6352. return Series;
  6353. }();
  6354. var Data = /*#__PURE__*/function () {
  6355. function Data(ctx) {
  6356. _classCallCheck(this, Data);
  6357. this.ctx = ctx;
  6358. this.w = ctx.w;
  6359. this.twoDSeries = [];
  6360. this.threeDSeries = [];
  6361. this.twoDSeriesX = [];
  6362. this.coreUtils = new CoreUtils(this.ctx);
  6363. }
  6364. _createClass(Data, [{
  6365. key: "isMultiFormat",
  6366. value: function isMultiFormat() {
  6367. return this.isFormatXY() || this.isFormat2DArray();
  6368. } // given format is [{x, y}, {x, y}]
  6369. }, {
  6370. key: "isFormatXY",
  6371. value: function isFormatXY() {
  6372. var series = this.w.config.series.slice();
  6373. var sr = new Series(this.ctx);
  6374. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  6375. 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) {
  6376. return true;
  6377. }
  6378. } // given format is [[x, y], [x, y]]
  6379. }, {
  6380. key: "isFormat2DArray",
  6381. value: function isFormat2DArray() {
  6382. var series = this.w.config.series.slice();
  6383. var sr = new Series(this.ctx);
  6384. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  6385. 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) {
  6386. return true;
  6387. }
  6388. }
  6389. }, {
  6390. key: "handleFormat2DArray",
  6391. value: function handleFormat2DArray(ser, i) {
  6392. var cnf = this.w.config;
  6393. var gl = this.w.globals;
  6394. if (cnf.xaxis.sorted) {
  6395. if (cnf.xaxis.type === 'datetime') {
  6396. ser[i].data.sort(function (a, b) {
  6397. return new Date(a[0]).getTime() - new Date(b[0]).getTime();
  6398. });
  6399. } else if (cnf.xaxis.type === 'numeric') {
  6400. ser[i].data.sort(function (a, b) {
  6401. return a[0] - b[0];
  6402. });
  6403. }
  6404. }
  6405. for (var j = 0; j < ser[i].data.length; j++) {
  6406. if (typeof ser[i].data[j][1] !== 'undefined') {
  6407. if (Array.isArray(ser[i].data[j][1]) && ser[i].data[j][1].length === 4) {
  6408. // candlestick nested ohlc format
  6409. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1][3]));
  6410. } else if (ser[i].data[j].length === 5) {
  6411. // candlestick non-nested ohlc format
  6412. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][4]));
  6413. } else {
  6414. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1]));
  6415. }
  6416. gl.dataFormatXNumeric = true;
  6417. }
  6418. if (cnf.xaxis.type === 'datetime') {
  6419. // if timestamps are provided and xaxis type is datettime,
  6420. var ts = new Date(ser[i].data[j][0]);
  6421. ts = new Date(ts).getTime();
  6422. this.twoDSeriesX.push(ts);
  6423. } else {
  6424. this.twoDSeriesX.push(ser[i].data[j][0]);
  6425. }
  6426. }
  6427. for (var _j = 0; _j < ser[i].data.length; _j++) {
  6428. if (typeof ser[i].data[_j][2] !== 'undefined') {
  6429. this.threeDSeries.push(ser[i].data[_j][2]);
  6430. gl.isDataXYZ = true;
  6431. }
  6432. }
  6433. }
  6434. }, {
  6435. key: "handleFormatXY",
  6436. value: function handleFormatXY(ser, i) {
  6437. var cnf = this.w.config;
  6438. var gl = this.w.globals;
  6439. var dt = new DateTime(this.ctx);
  6440. var activeI = i;
  6441. if (gl.collapsedSeriesIndices.indexOf(i) > -1) {
  6442. // fix #368
  6443. activeI = this.activeSeriesIndex;
  6444. }
  6445. if (cnf.xaxis.sorted) {
  6446. if (cnf.xaxis.type === 'datetime') {
  6447. ser[i].data.sort(function (a, b) {
  6448. return new Date(a.x).getTime() - new Date(b.x).getTime();
  6449. });
  6450. } else if (cnf.xaxis.type === 'numeric') {
  6451. ser[i].data.sort(function (a, b) {
  6452. return a.x - b.x;
  6453. });
  6454. }
  6455. } // get series
  6456. for (var j = 0; j < ser[i].data.length; j++) {
  6457. if (typeof ser[i].data[j].y !== 'undefined') {
  6458. if (Array.isArray(ser[i].data[j].y)) {
  6459. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y[ser[i].data[j].y.length - 1]));
  6460. } else {
  6461. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y));
  6462. }
  6463. }
  6464. } // get seriesX
  6465. for (var _j2 = 0; _j2 < ser[activeI].data.length; _j2++) {
  6466. var isXString = typeof ser[activeI].data[_j2].x === 'string';
  6467. var isXArr = Array.isArray(ser[activeI].data[_j2].x);
  6468. var isXDate = !isXArr && !!dt.isValidDate(ser[activeI].data[_j2].x.toString());
  6469. if (isXString || isXDate) {
  6470. // user supplied '01/01/2017' or a date string (a JS date object is not supported)
  6471. if (isXString || cnf.xaxis.convertedCatToNumeric) {
  6472. if (cnf.xaxis.type === 'datetime' && !gl.isRangeData) {
  6473. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x));
  6474. } else {
  6475. // a category and not a numeric x value
  6476. this.fallbackToCategory = true;
  6477. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  6478. }
  6479. } else {
  6480. if (cnf.xaxis.type === 'datetime') {
  6481. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x.toString()));
  6482. } else {
  6483. gl.dataFormatXNumeric = true;
  6484. gl.isXNumeric = true;
  6485. this.twoDSeriesX.push(parseFloat(ser[activeI].data[_j2].x));
  6486. }
  6487. }
  6488. } else if (isXArr) {
  6489. // a multiline label described in array format
  6490. this.fallbackToCategory = true;
  6491. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  6492. } else {
  6493. // a numeric value in x property
  6494. gl.isXNumeric = true;
  6495. gl.dataFormatXNumeric = true;
  6496. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  6497. }
  6498. }
  6499. if (ser[i].data[0] && typeof ser[i].data[0].z !== 'undefined') {
  6500. for (var t = 0; t < ser[i].data.length; t++) {
  6501. this.threeDSeries.push(ser[i].data[t].z);
  6502. }
  6503. gl.isDataXYZ = true;
  6504. }
  6505. }
  6506. }, {
  6507. key: "handleRangeData",
  6508. value: function handleRangeData(ser, i) {
  6509. var cnf = this.w.config;
  6510. var gl = this.w.globals;
  6511. var range = {};
  6512. if (this.isFormat2DArray()) {
  6513. range = this.handleRangeDataFormat('array', ser, i);
  6514. } else if (this.isFormatXY()) {
  6515. range = this.handleRangeDataFormat('xy', ser, i);
  6516. }
  6517. gl.seriesRangeStart.push(range.start);
  6518. gl.seriesRangeEnd.push(range.end);
  6519. if (cnf.xaxis.type === 'datetime') {
  6520. gl.seriesRangeBarTimeline.push(range.rangeUniques);
  6521. } // check for overlaps to avoid clashes in a timeline chart
  6522. gl.seriesRangeBarTimeline.forEach(function (sr, si) {
  6523. if (sr) {
  6524. sr.forEach(function (sarr, sarri) {
  6525. sarr.y.forEach(function (arr, arri) {
  6526. for (var sri = 0; sri < sarr.y.length; sri++) {
  6527. if (arri !== sri) {
  6528. var range1y1 = arr.y1;
  6529. var range1y2 = arr.y2;
  6530. var range2y1 = sarr.y[sri].y1;
  6531. var range2y2 = sarr.y[sri].y2;
  6532. if (range1y1 <= range2y2 && range2y1 <= range1y2) {
  6533. if (sarr.overlaps.indexOf(arr.rangeName) < 0) {
  6534. sarr.overlaps.push(arr.rangeName);
  6535. }
  6536. if (sarr.overlaps.indexOf(sarr.y[sri].rangeName) < 0) {
  6537. sarr.overlaps.push(sarr.y[sri].rangeName);
  6538. }
  6539. }
  6540. }
  6541. }
  6542. });
  6543. });
  6544. }
  6545. });
  6546. return range;
  6547. }
  6548. }, {
  6549. key: "handleCandleStickData",
  6550. value: function handleCandleStickData(ser, i) {
  6551. var gl = this.w.globals;
  6552. var ohlc = {};
  6553. if (this.isFormat2DArray()) {
  6554. ohlc = this.handleCandleStickDataFormat('array', ser, i);
  6555. } else if (this.isFormatXY()) {
  6556. ohlc = this.handleCandleStickDataFormat('xy', ser, i);
  6557. }
  6558. gl.seriesCandleO[i] = ohlc.o;
  6559. gl.seriesCandleH[i] = ohlc.h;
  6560. gl.seriesCandleL[i] = ohlc.l;
  6561. gl.seriesCandleC[i] = ohlc.c;
  6562. return ohlc;
  6563. }
  6564. }, {
  6565. key: "handleRangeDataFormat",
  6566. value: function handleRangeDataFormat(format, ser, i) {
  6567. var rangeStart = [];
  6568. var rangeEnd = [];
  6569. var uniqueKeys = ser[i].data.filter(function (thing, index, self) {
  6570. return index === self.findIndex(function (t) {
  6571. return t.x === thing.x;
  6572. });
  6573. }).map(function (r, index) {
  6574. return {
  6575. x: r.x,
  6576. overlaps: [],
  6577. y: []
  6578. };
  6579. });
  6580. var err = 'Please provide [Start, End] values in valid format. Read more https://apexcharts.com/docs/series/#rangecharts';
  6581. var serObj = new Series(this.ctx);
  6582. var activeIndex = serObj.getActiveConfigSeriesIndex();
  6583. if (format === 'array') {
  6584. if (ser[activeIndex].data[0][1].length !== 2) {
  6585. throw new Error(err);
  6586. }
  6587. for (var j = 0; j < ser[i].data.length; j++) {
  6588. rangeStart.push(ser[i].data[j][1][0]);
  6589. rangeEnd.push(ser[i].data[j][1][1]);
  6590. }
  6591. } else if (format === 'xy') {
  6592. if (ser[activeIndex].data[0].y.length !== 2) {
  6593. throw new Error(err);
  6594. }
  6595. var _loop = function _loop(_j3) {
  6596. var id = Utils.randomId();
  6597. var x = ser[i].data[_j3].x;
  6598. var y = {
  6599. y1: ser[i].data[_j3].y[0],
  6600. y2: ser[i].data[_j3].y[1],
  6601. rangeName: id
  6602. }; // mutating config object by adding a new property
  6603. // TODO: As this is specifically for timeline rangebar charts, update the docs mentioning the series only supports xy format
  6604. ser[i].data[_j3].rangeName = id;
  6605. var uI = uniqueKeys.findIndex(function (t) {
  6606. return t.x === x;
  6607. });
  6608. uniqueKeys[uI].y.push(y);
  6609. rangeStart.push(y.y1);
  6610. rangeEnd.push(y.y2);
  6611. };
  6612. for (var _j3 = 0; _j3 < ser[i].data.length; _j3++) {
  6613. _loop(_j3);
  6614. }
  6615. }
  6616. return {
  6617. start: rangeStart,
  6618. end: rangeEnd,
  6619. rangeUniques: uniqueKeys
  6620. };
  6621. }
  6622. }, {
  6623. key: "handleCandleStickDataFormat",
  6624. value: function handleCandleStickDataFormat(format, ser, i) {
  6625. var serO = [];
  6626. var serH = [];
  6627. var serL = [];
  6628. var serC = [];
  6629. var err = 'Please provide [Open, High, Low and Close] values in valid format. Read more https://apexcharts.com/docs/series/#candlestick';
  6630. if (format === 'array') {
  6631. 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) {
  6632. throw new Error(err);
  6633. }
  6634. if (ser[i].data[0].length === 5) {
  6635. for (var j = 0; j < ser[i].data.length; j++) {
  6636. serO.push(ser[i].data[j][1]);
  6637. serH.push(ser[i].data[j][2]);
  6638. serL.push(ser[i].data[j][3]);
  6639. serC.push(ser[i].data[j][4]);
  6640. }
  6641. } else {
  6642. for (var _j4 = 0; _j4 < ser[i].data.length; _j4++) {
  6643. serO.push(ser[i].data[_j4][1][0]);
  6644. serH.push(ser[i].data[_j4][1][1]);
  6645. serL.push(ser[i].data[_j4][1][2]);
  6646. serC.push(ser[i].data[_j4][1][3]);
  6647. }
  6648. }
  6649. } else if (format === 'xy') {
  6650. if (ser[i].data[0].y.length !== 4) {
  6651. throw new Error(err);
  6652. }
  6653. for (var _j5 = 0; _j5 < ser[i].data.length; _j5++) {
  6654. serO.push(ser[i].data[_j5].y[0]);
  6655. serH.push(ser[i].data[_j5].y[1]);
  6656. serL.push(ser[i].data[_j5].y[2]);
  6657. serC.push(ser[i].data[_j5].y[3]);
  6658. }
  6659. }
  6660. return {
  6661. o: serO,
  6662. h: serH,
  6663. l: serL,
  6664. c: serC
  6665. };
  6666. }
  6667. }, {
  6668. key: "parseDataAxisCharts",
  6669. value: function parseDataAxisCharts(ser) {
  6670. var _this = this;
  6671. var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.ctx;
  6672. var cnf = this.w.config;
  6673. var gl = this.w.globals;
  6674. var dt = new DateTime(ctx);
  6675. var xlabels = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice();
  6676. var handleDates = function handleDates() {
  6677. for (var j = 0; j < xlabels.length; j++) {
  6678. if (typeof xlabels[j] === 'string') {
  6679. // user provided date strings
  6680. var isDate = dt.isValidDate(xlabels[j]);
  6681. if (isDate) {
  6682. _this.twoDSeriesX.push(dt.parseDate(xlabels[j]));
  6683. } else {
  6684. throw new Error('You have provided invalid Date format. Please provide a valid JavaScript Date');
  6685. }
  6686. } else {
  6687. // user provided timestamps
  6688. if (String(xlabels[j]).length !== 13) {
  6689. throw new Error('Please provide a valid JavaScript timestamp');
  6690. } else {
  6691. _this.twoDSeriesX.push(xlabels[j]);
  6692. }
  6693. }
  6694. }
  6695. };
  6696. for (var i = 0; i < ser.length; i++) {
  6697. this.twoDSeries = [];
  6698. this.twoDSeriesX = [];
  6699. this.threeDSeries = [];
  6700. if (typeof ser[i].data === 'undefined') {
  6701. console.error("It is a possibility that you may have not included 'data' property in series.");
  6702. return;
  6703. }
  6704. if (cnf.chart.type === 'rangeBar' || cnf.chart.type === 'rangeArea' || ser[i].type === 'rangeBar' || ser[i].type === 'rangeArea') {
  6705. gl.isRangeData = true;
  6706. this.handleRangeData(ser, i);
  6707. }
  6708. if (this.isMultiFormat()) {
  6709. if (this.isFormat2DArray()) {
  6710. this.handleFormat2DArray(ser, i);
  6711. } else if (this.isFormatXY()) {
  6712. this.handleFormatXY(ser, i);
  6713. }
  6714. if (cnf.chart.type === 'candlestick' || ser[i].type === 'candlestick') {
  6715. this.handleCandleStickData(ser, i);
  6716. }
  6717. gl.series.push(this.twoDSeries);
  6718. gl.labels.push(this.twoDSeriesX);
  6719. gl.seriesX.push(this.twoDSeriesX);
  6720. if (i === this.activeSeriesIndex && !this.fallbackToCategory) {
  6721. gl.isXNumeric = true;
  6722. }
  6723. } else {
  6724. if (cnf.xaxis.type === 'datetime') {
  6725. // user didn't supplied [{x,y}] or [[x,y]], but single array in data.
  6726. // Also labels/categories were supplied differently
  6727. gl.isXNumeric = true;
  6728. handleDates();
  6729. gl.seriesX.push(this.twoDSeriesX);
  6730. } else if (cnf.xaxis.type === 'numeric') {
  6731. gl.isXNumeric = true;
  6732. if (xlabels.length > 0) {
  6733. this.twoDSeriesX = xlabels;
  6734. gl.seriesX.push(this.twoDSeriesX);
  6735. }
  6736. }
  6737. gl.labels.push(this.twoDSeriesX);
  6738. var singleArray = ser[i].data.map(function (d) {
  6739. return Utils.parseNumber(d);
  6740. });
  6741. gl.series.push(singleArray);
  6742. }
  6743. gl.seriesZ.push(this.threeDSeries);
  6744. if (ser[i].name !== undefined) {
  6745. gl.seriesNames.push(ser[i].name);
  6746. } else {
  6747. gl.seriesNames.push('series-' + parseInt(i + 1, 10));
  6748. }
  6749. }
  6750. return this.w;
  6751. }
  6752. }, {
  6753. key: "parseDataNonAxisCharts",
  6754. value: function parseDataNonAxisCharts(ser) {
  6755. var gl = this.w.globals;
  6756. var cnf = this.w.config;
  6757. gl.series = ser.slice();
  6758. gl.seriesNames = cnf.labels.slice();
  6759. for (var i = 0; i < gl.series.length; i++) {
  6760. if (gl.seriesNames[i] === undefined) {
  6761. gl.seriesNames.push('series-' + (i + 1));
  6762. }
  6763. }
  6764. return this.w;
  6765. }
  6766. /** User possibly set string categories in xaxis.categories or labels prop
  6767. * Or didn't set xaxis labels at all - in which case we manually do it.
  6768. * If user passed series data as [[3, 2], [4, 5]] or [{ x: 3, y: 55 }],
  6769. * this shouldn't be called
  6770. * @param {array} ser - the series which user passed to the config
  6771. */
  6772. }, {
  6773. key: "handleExternalLabelsData",
  6774. value: function handleExternalLabelsData(ser) {
  6775. var cnf = this.w.config;
  6776. var gl = this.w.globals;
  6777. if (cnf.xaxis.categories.length > 0) {
  6778. // user provided labels in xaxis.category prop
  6779. gl.labels = cnf.xaxis.categories;
  6780. } else if (cnf.labels.length > 0) {
  6781. // user provided labels in labels props
  6782. gl.labels = cnf.labels.slice();
  6783. } else if (this.fallbackToCategory) {
  6784. // user provided labels in x prop in [{ x: 3, y: 55 }] data, and those labels are already stored in gl.labels[0], so just re-arrange the gl.labels array
  6785. gl.labels = gl.labels[0];
  6786. if (gl.seriesRangeBarTimeline.length) {
  6787. gl.seriesRangeBarTimeline.map(function (srt) {
  6788. srt.forEach(function (sr) {
  6789. if (gl.labels.indexOf(sr.x) < 0 && sr.x) {
  6790. gl.labels.push(sr.x);
  6791. }
  6792. });
  6793. });
  6794. gl.labels = gl.labels.filter(function (elem, pos, arr) {
  6795. return arr.indexOf(elem) === pos;
  6796. });
  6797. }
  6798. if (cnf.xaxis.convertedCatToNumeric) {
  6799. var defaults = new Defaults(cnf);
  6800. defaults.convertCatToNumericXaxis(cnf, this.ctx, gl.seriesX[0]);
  6801. this._generateExternalLabels(ser);
  6802. }
  6803. } else {
  6804. this._generateExternalLabels(ser);
  6805. }
  6806. }
  6807. }, {
  6808. key: "_generateExternalLabels",
  6809. value: function _generateExternalLabels(ser) {
  6810. var gl = this.w.globals;
  6811. var cnf = this.w.config; // user didn't provided any labels, fallback to 1-2-3-4-5
  6812. var labelArr = [];
  6813. if (gl.axisCharts) {
  6814. if (gl.series.length > 0) {
  6815. for (var i = 0; i < gl.series[gl.maxValsInArrayIndex].length; i++) {
  6816. labelArr.push(i + 1);
  6817. }
  6818. }
  6819. gl.seriesX = []; // create gl.seriesX as it will be used in calculations of x positions
  6820. for (var _i = 0; _i < ser.length; _i++) {
  6821. gl.seriesX.push(labelArr);
  6822. } // turn on the isXNumeric flag to allow minX and maxX to function properly
  6823. gl.isXNumeric = true;
  6824. } // no series to pull labels from, put a 0-10 series
  6825. // possibly, user collapsed all series. Hence we can't work with above calc
  6826. if (labelArr.length === 0) {
  6827. labelArr = gl.axisCharts ? [] : gl.series.map(function (gls, glsi) {
  6828. return glsi + 1;
  6829. });
  6830. for (var _i2 = 0; _i2 < ser.length; _i2++) {
  6831. gl.seriesX.push(labelArr);
  6832. }
  6833. } // Finally, pass the labelArr in gl.labels which will be printed on x-axis
  6834. gl.labels = labelArr;
  6835. if (cnf.xaxis.convertedCatToNumeric) {
  6836. gl.categoryLabels = labelArr.map(function (l) {
  6837. return cnf.xaxis.labels.formatter(l);
  6838. });
  6839. } // Turn on this global flag to indicate no labels were provided by user
  6840. gl.noLabelsProvided = true;
  6841. } // Segregate user provided data into appropriate vars
  6842. }, {
  6843. key: "parseData",
  6844. value: function parseData(ser) {
  6845. var w = this.w;
  6846. var cnf = w.config;
  6847. var gl = w.globals;
  6848. this.excludeCollapsedSeriesInYAxis(); // If we detected string in X prop of series, we fallback to category x-axis
  6849. this.fallbackToCategory = false;
  6850. this.ctx.core.resetGlobals();
  6851. this.ctx.core.isMultipleY();
  6852. if (gl.axisCharts) {
  6853. // axisCharts includes line / area / column / scatter
  6854. this.parseDataAxisCharts(ser);
  6855. } else {
  6856. // non-axis charts are pie / donut
  6857. this.parseDataNonAxisCharts(ser);
  6858. }
  6859. this.coreUtils.getLargestSeries(); // set Null values to 0 in all series when user hides/shows some series
  6860. if (cnf.chart.type === 'bar' && cnf.chart.stacked) {
  6861. var series = new Series(this.ctx);
  6862. gl.series = series.setNullSeriesToZeroValues(gl.series);
  6863. }
  6864. this.coreUtils.getSeriesTotals();
  6865. if (gl.axisCharts) {
  6866. this.coreUtils.getStackedSeriesTotals();
  6867. }
  6868. this.coreUtils.getPercentSeries();
  6869. if (!gl.dataFormatXNumeric && (!gl.isXNumeric || cnf.xaxis.type === 'numeric' && cnf.labels.length === 0 && cnf.xaxis.categories.length === 0)) {
  6870. // x-axis labels couldn't be detected; hence try searching every option in config
  6871. this.handleExternalLabelsData(ser);
  6872. } // check for multiline xaxis
  6873. var catLabels = this.coreUtils.getCategoryLabels(gl.labels);
  6874. for (var l = 0; l < catLabels.length; l++) {
  6875. if (Array.isArray(catLabels[l])) {
  6876. gl.isMultiLineX = true;
  6877. break;
  6878. }
  6879. }
  6880. }
  6881. }, {
  6882. key: "excludeCollapsedSeriesInYAxis",
  6883. value: function excludeCollapsedSeriesInYAxis() {
  6884. var _this2 = this;
  6885. var w = this.w;
  6886. w.globals.ignoreYAxisIndexes = w.globals.collapsedSeries.map(function (collapsed, i) {
  6887. // fix issue #1215
  6888. // if stacked, not returning collapsed.index to preserve yaxis
  6889. if (_this2.w.globals.isMultipleYAxis && !w.config.chart.stacked) {
  6890. return collapsed.index;
  6891. }
  6892. });
  6893. }
  6894. }]);
  6895. return Data;
  6896. }();
  6897. /**
  6898. * ApexCharts Formatter Class for setting value formatters for axes as well as tooltips.
  6899. *
  6900. * @module Formatters
  6901. **/
  6902. var Formatters = /*#__PURE__*/function () {
  6903. function Formatters(ctx) {
  6904. _classCallCheck(this, Formatters);
  6905. this.ctx = ctx;
  6906. this.w = ctx.w;
  6907. this.tooltipKeyFormat = 'dd MMM';
  6908. }
  6909. _createClass(Formatters, [{
  6910. key: "xLabelFormat",
  6911. value: function xLabelFormat(fn, val, timestamp) {
  6912. var w = this.w;
  6913. if (w.config.xaxis.type === 'datetime') {
  6914. if (w.config.xaxis.labels.formatter === undefined) {
  6915. // if user has not specified a custom formatter, use the default tooltip.x.format
  6916. if (w.config.tooltip.x.formatter === undefined) {
  6917. var datetimeObj = new DateTime(this.ctx);
  6918. return datetimeObj.formatDate(datetimeObj.getDate(val), w.config.tooltip.x.format);
  6919. }
  6920. }
  6921. }
  6922. return fn(val, timestamp);
  6923. }
  6924. }, {
  6925. key: "defaultGeneralFormatter",
  6926. value: function defaultGeneralFormatter(val) {
  6927. if (Array.isArray(val)) {
  6928. return val.map(function (v) {
  6929. return v;
  6930. });
  6931. } else {
  6932. return val;
  6933. }
  6934. }
  6935. }, {
  6936. key: "defaultYFormatter",
  6937. value: function defaultYFormatter(v, yaxe, i) {
  6938. var w = this.w;
  6939. if (Utils.isNumber(v)) {
  6940. if (w.globals.yValueDecimal !== 0) {
  6941. v = v.toFixed(yaxe.decimalsInFloat !== undefined ? yaxe.decimalsInFloat : w.globals.yValueDecimal);
  6942. } else if (w.globals.maxYArr[i] - w.globals.minYArr[i] < 10) {
  6943. v = v.toFixed(1);
  6944. } else {
  6945. v = v.toFixed(0);
  6946. }
  6947. }
  6948. return v;
  6949. }
  6950. }, {
  6951. key: "setLabelFormatters",
  6952. value: function setLabelFormatters() {
  6953. var _this = this;
  6954. var w = this.w;
  6955. w.globals.xLabelFormatter = function (val) {
  6956. return _this.defaultGeneralFormatter(val);
  6957. };
  6958. w.globals.xaxisTooltipFormatter = function (val) {
  6959. return _this.defaultGeneralFormatter(val);
  6960. };
  6961. w.globals.ttKeyFormatter = function (val) {
  6962. return _this.defaultGeneralFormatter(val);
  6963. };
  6964. w.globals.ttZFormatter = function (val) {
  6965. return val;
  6966. };
  6967. w.globals.legendFormatter = function (val) {
  6968. return _this.defaultGeneralFormatter(val);
  6969. }; // formatter function will always overwrite format property
  6970. if (w.config.xaxis.labels.formatter !== undefined) {
  6971. w.globals.xLabelFormatter = w.config.xaxis.labels.formatter;
  6972. } else {
  6973. w.globals.xLabelFormatter = function (val) {
  6974. if (Utils.isNumber(val)) {
  6975. // numeric xaxis may have smaller range, so defaulting to 1 decimal
  6976. if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric' && w.globals.dataPoints < 50) {
  6977. return val.toFixed(1);
  6978. }
  6979. if (w.globals.isBarHorizontal) {
  6980. var range = w.globals.maxY - w.globals.minYArr;
  6981. if (range < 4) {
  6982. return val.toFixed(1);
  6983. }
  6984. }
  6985. return val.toFixed(0);
  6986. }
  6987. return val;
  6988. };
  6989. }
  6990. if (typeof w.config.tooltip.x.formatter === 'function') {
  6991. w.globals.ttKeyFormatter = w.config.tooltip.x.formatter;
  6992. } else {
  6993. w.globals.ttKeyFormatter = w.globals.xLabelFormatter;
  6994. }
  6995. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  6996. w.globals.xaxisTooltipFormatter = w.config.xaxis.tooltip.formatter;
  6997. }
  6998. if (Array.isArray(w.config.tooltip.y)) {
  6999. w.globals.ttVal = w.config.tooltip.y;
  7000. } else {
  7001. if (w.config.tooltip.y.formatter !== undefined) {
  7002. w.globals.ttVal = w.config.tooltip.y;
  7003. }
  7004. }
  7005. if (w.config.tooltip.z.formatter !== undefined) {
  7006. w.globals.ttZFormatter = w.config.tooltip.z.formatter;
  7007. } // legend formatter - if user wants to append any global values of series to legend text
  7008. if (w.config.legend.formatter !== undefined) {
  7009. w.globals.legendFormatter = w.config.legend.formatter;
  7010. } // formatter function will always overwrite format property
  7011. w.config.yaxis.forEach(function (yaxe, i) {
  7012. if (yaxe.labels.formatter !== undefined) {
  7013. w.globals.yLabelFormatters[i] = yaxe.labels.formatter;
  7014. } else {
  7015. w.globals.yLabelFormatters[i] = function (val) {
  7016. if (!w.globals.xyCharts) return val;
  7017. if (Array.isArray(val)) {
  7018. return val.map(function (v) {
  7019. return _this.defaultYFormatter(v, yaxe, i);
  7020. });
  7021. } else {
  7022. return _this.defaultYFormatter(val, yaxe, i);
  7023. }
  7024. };
  7025. }
  7026. });
  7027. return w.globals;
  7028. }
  7029. }, {
  7030. key: "heatmapLabelFormatters",
  7031. value: function heatmapLabelFormatters() {
  7032. var w = this.w;
  7033. if (w.config.chart.type === 'heatmap') {
  7034. w.globals.yAxisScale[0].result = w.globals.seriesNames.slice(); // get the longest string from the labels array and also apply label formatter to it
  7035. var longest = w.globals.seriesNames.reduce(function (a, b) {
  7036. return a.length > b.length ? a : b;
  7037. }, 0);
  7038. w.globals.yAxisScale[0].niceMax = longest;
  7039. w.globals.yAxisScale[0].niceMin = longest;
  7040. }
  7041. }
  7042. }]);
  7043. return Formatters;
  7044. }();
  7045. var AxesUtils = /*#__PURE__*/function () {
  7046. function AxesUtils(ctx) {
  7047. _classCallCheck(this, AxesUtils);
  7048. this.ctx = ctx;
  7049. this.w = ctx.w;
  7050. } // Based on the formatter function, get the label text and position
  7051. _createClass(AxesUtils, [{
  7052. key: "getLabel",
  7053. value: function getLabel(labels, timescaleLabels, x, i) {
  7054. var drawnLabels = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
  7055. var fontSize = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '12px';
  7056. var w = this.w;
  7057. var rawLabel = typeof labels[i] === 'undefined' ? '' : labels[i];
  7058. var label = rawLabel;
  7059. var xlbFormatter = w.globals.xLabelFormatter;
  7060. var customFormatter = w.config.xaxis.labels.formatter;
  7061. var isBold = false;
  7062. var xFormat = new Formatters(this.ctx);
  7063. var timestamp = rawLabel;
  7064. label = xFormat.xLabelFormat(xlbFormatter, rawLabel, timestamp);
  7065. if (customFormatter !== undefined) {
  7066. label = customFormatter(rawLabel, labels[i], i);
  7067. }
  7068. var determineHighestUnit = function determineHighestUnit(unit) {
  7069. var highestUnit = null;
  7070. timescaleLabels.forEach(function (t) {
  7071. if (t.unit === 'month') {
  7072. highestUnit = 'year';
  7073. } else if (t.unit === 'day') {
  7074. highestUnit = 'month';
  7075. } else if (t.unit === 'hour') {
  7076. highestUnit = 'day';
  7077. } else if (t.unit === 'minute') {
  7078. highestUnit = 'hour';
  7079. }
  7080. });
  7081. return highestUnit === unit;
  7082. };
  7083. if (timescaleLabels.length > 0) {
  7084. isBold = determineHighestUnit(timescaleLabels[i].unit);
  7085. x = timescaleLabels[i].position;
  7086. label = timescaleLabels[i].value;
  7087. } else {
  7088. if (w.config.xaxis.type === 'datetime' && customFormatter === undefined) {
  7089. label = '';
  7090. }
  7091. }
  7092. if (typeof label === 'undefined') label = '';
  7093. label = Array.isArray(label) ? label : label.toString();
  7094. var graphics = new Graphics(this.ctx);
  7095. var textRect = {};
  7096. if (w.globals.rotateXLabels) {
  7097. textRect = graphics.getTextRects(label, parseInt(fontSize, 10), null, "rotate(".concat(w.config.xaxis.labels.rotate, " 0 0)"), false);
  7098. } else {
  7099. textRect = graphics.getTextRects(label, parseInt(fontSize, 10));
  7100. }
  7101. 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)) {
  7102. label = '';
  7103. }
  7104. return {
  7105. x: x,
  7106. text: label,
  7107. textRect: textRect,
  7108. isBold: isBold
  7109. };
  7110. }
  7111. }, {
  7112. key: "checkForOverflowingLabels",
  7113. value: function checkForOverflowingLabels(i, label, labelsLen, drawnLabels, drawnLabelsRects) {
  7114. var w = this.w;
  7115. if (i === 0) {
  7116. // check if first label is being truncated
  7117. if (w.globals.skipFirstTimelinelabel) {
  7118. label.text = '';
  7119. }
  7120. }
  7121. if (i === labelsLen - 1) {
  7122. // check if last label is being truncated
  7123. if (w.globals.skipLastTimelinelabel) {
  7124. label.text = '';
  7125. }
  7126. }
  7127. if (w.config.xaxis.labels.hideOverlappingLabels && drawnLabels.length > 0) {
  7128. var prev = drawnLabelsRects[drawnLabelsRects.length - 1];
  7129. if (label.x < prev.textRect.width / (w.globals.rotateXLabels ? Math.abs(w.config.xaxis.labels.rotate) / 12 : 1.01) + prev.x) {
  7130. label.text = '';
  7131. }
  7132. }
  7133. return label;
  7134. }
  7135. }, {
  7136. key: "checkForReversedLabels",
  7137. value: function checkForReversedLabels(i, labels) {
  7138. var w = this.w;
  7139. if (w.config.yaxis[i] && w.config.yaxis[i].reversed) {
  7140. labels.reverse();
  7141. }
  7142. return labels;
  7143. }
  7144. }, {
  7145. key: "isYAxisHidden",
  7146. value: function isYAxisHidden(index) {
  7147. var w = this.w;
  7148. var coreUtils = new CoreUtils(this.ctx);
  7149. return !w.config.yaxis[index].show || !w.config.yaxis[index].showForNullSeries && coreUtils.isSeriesNull(index) && w.globals.collapsedSeriesIndices.indexOf(index) === -1;
  7150. }
  7151. }, {
  7152. key: "drawYAxisTicks",
  7153. value: function drawYAxisTicks(x, tickAmount, axisBorder, axisTicks, realIndex, labelsDivider, elYaxis) {
  7154. var w = this.w;
  7155. var graphics = new Graphics(this.ctx); // initial label position = 0;
  7156. var t = w.globals.translateY;
  7157. if (axisTicks.show && tickAmount > 0) {
  7158. if (w.config.yaxis[realIndex].opposite === true) x = x + axisTicks.width;
  7159. for (var i = tickAmount; i >= 0; i--) {
  7160. var tY = t + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY - 1;
  7161. if (w.globals.isBarHorizontal) {
  7162. tY = labelsDivider * i;
  7163. }
  7164. if (w.config.chart.type === 'heatmap') {
  7165. tY = tY + labelsDivider / 2;
  7166. }
  7167. var elTick = graphics.drawLine(x + axisBorder.offsetX - axisTicks.width + axisTicks.offsetX, tY + axisTicks.offsetY, x + axisBorder.offsetX + axisTicks.offsetX, tY + axisTicks.offsetY, axisTicks.color);
  7168. elYaxis.add(elTick);
  7169. t = t + labelsDivider;
  7170. }
  7171. }
  7172. }
  7173. }]);
  7174. return AxesUtils;
  7175. }();
  7176. var Exports = /*#__PURE__*/function () {
  7177. function Exports(ctx) {
  7178. _classCallCheck(this, Exports);
  7179. this.ctx = ctx;
  7180. this.w = ctx.w;
  7181. }
  7182. _createClass(Exports, [{
  7183. key: "fixSvgStringForIe11",
  7184. value: function fixSvgStringForIe11(svgData) {
  7185. // IE11 generates broken SVG that we have to fix by using regex
  7186. if (!Utils.isIE11()) {
  7187. // not IE11 - noop
  7188. return svgData;
  7189. } // replace second occurence of "xmlns" attribute with "xmlns:xlink" with correct url + add xmlns:svgjs
  7190. var nXmlnsSeen = 0;
  7191. var result = svgData.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g, function (match) {
  7192. nXmlnsSeen++;
  7193. return nXmlnsSeen === 2 ? 'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs"' : match;
  7194. }); // remove the invalid empty namespace declarations
  7195. result = result.replace(/xmlns:NS\d+=""/g, ''); // remove these broken namespaces from attributes
  7196. result = result.replace(/NS\d+:(\w+:\w+=")/g, '$1');
  7197. return result;
  7198. }
  7199. }, {
  7200. key: "getSvgString",
  7201. value: function getSvgString() {
  7202. var svgString = this.w.globals.dom.Paper.svg();
  7203. return this.fixSvgStringForIe11(svgString);
  7204. }
  7205. }, {
  7206. key: "cleanup",
  7207. value: function cleanup() {
  7208. var w = this.w; // hide some elements to avoid printing them on exported svg
  7209. var xcrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-xcrosshairs');
  7210. var ycrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-ycrosshairs');
  7211. var zoomSelectionRects = w.globals.dom.baseEl.querySelectorAll('.apexcharts-zoom-rect, .apexcharts-selection-rect');
  7212. Array.prototype.forEach.call(zoomSelectionRects, function (z) {
  7213. z.setAttribute('width', 0);
  7214. });
  7215. if (xcrosshairs) {
  7216. xcrosshairs[0].setAttribute('x', -500);
  7217. xcrosshairs[0].setAttribute('x1', -500);
  7218. xcrosshairs[0].setAttribute('x2', -500);
  7219. }
  7220. if (ycrosshairs) {
  7221. ycrosshairs[0].setAttribute('y', -100);
  7222. ycrosshairs[0].setAttribute('y1', -100);
  7223. ycrosshairs[0].setAttribute('y2', -100);
  7224. }
  7225. }
  7226. }, {
  7227. key: "svgUrl",
  7228. value: function svgUrl() {
  7229. this.cleanup();
  7230. var svgData = this.getSvgString();
  7231. var svgBlob = new Blob([svgData], {
  7232. type: 'image/svg+xml;charset=utf-8'
  7233. });
  7234. return URL.createObjectURL(svgBlob);
  7235. }
  7236. }, {
  7237. key: "dataURI",
  7238. value: function dataURI() {
  7239. var _this = this;
  7240. return new Promise(function (resolve) {
  7241. var w = _this.w;
  7242. _this.cleanup();
  7243. var canvas = document.createElement('canvas');
  7244. canvas.width = w.globals.svgWidth;
  7245. canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10); // because of resizeNonAxisCharts
  7246. var canvasBg = w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background;
  7247. var ctx = canvas.getContext('2d');
  7248. ctx.fillStyle = canvasBg;
  7249. ctx.fillRect(0, 0, canvas.width, canvas.height);
  7250. var svgData = _this.getSvgString();
  7251. if (window.canvg && Utils.isIE11()) {
  7252. // use canvg as a polyfill to workaround ie11 considering a canvas with loaded svg 'unsafe'
  7253. // without ignoreClear we lose our background color; without ignoreDimensions some grid lines become invisible
  7254. var v = window.canvg.Canvg.fromString(ctx, svgData, {
  7255. ignoreClear: true,
  7256. ignoreDimensions: true
  7257. }); // render the svg to canvas
  7258. v.start();
  7259. var blob = canvas.msToBlob(); // dispose - missing this will cause a memory leak
  7260. v.stop();
  7261. resolve({
  7262. blob: blob
  7263. });
  7264. } else {
  7265. var svgUrl = 'data:image/svg+xml,' + encodeURIComponent(svgData);
  7266. var img = new Image();
  7267. img.crossOrigin = 'anonymous';
  7268. img.onload = function () {
  7269. ctx.drawImage(img, 0, 0);
  7270. if (canvas.msToBlob) {
  7271. // IE and Edge can't navigate to data urls, so we return the blob instead
  7272. var _blob = canvas.msToBlob();
  7273. resolve({
  7274. blob: _blob
  7275. });
  7276. } else {
  7277. var imgURI = canvas.toDataURL('image/png');
  7278. resolve({
  7279. imgURI: imgURI
  7280. });
  7281. }
  7282. };
  7283. img.src = svgUrl;
  7284. }
  7285. });
  7286. }
  7287. }, {
  7288. key: "exportToSVG",
  7289. value: function exportToSVG() {
  7290. this.triggerDownload(this.svgUrl(), '.svg');
  7291. }
  7292. }, {
  7293. key: "exportToPng",
  7294. value: function exportToPng() {
  7295. var _this2 = this;
  7296. this.dataURI().then(function (_ref) {
  7297. var imgURI = _ref.imgURI,
  7298. blob = _ref.blob;
  7299. if (blob) {
  7300. navigator.msSaveOrOpenBlob(blob, _this2.w.globals.chartID + '.png');
  7301. } else {
  7302. _this2.triggerDownload(imgURI, '.png');
  7303. }
  7304. });
  7305. }
  7306. }, {
  7307. key: "exportToCSV",
  7308. value: function exportToCSV(_ref2) {
  7309. var _this3 = this;
  7310. var series = _ref2.series,
  7311. _ref2$columnDelimiter = _ref2.columnDelimiter,
  7312. columnDelimiter = _ref2$columnDelimiter === void 0 ? ',' : _ref2$columnDelimiter,
  7313. _ref2$lineDelimiter = _ref2.lineDelimiter,
  7314. lineDelimiter = _ref2$lineDelimiter === void 0 ? '\n' : _ref2$lineDelimiter;
  7315. var w = this.w;
  7316. var columns = [];
  7317. var rows = [];
  7318. var result = 'data:text/csv;charset=utf-8,';
  7319. var dataFormat = new Data(this.ctx);
  7320. var axesUtils = new AxesUtils(this.ctx);
  7321. var getCat = function getCat(i) {
  7322. var cat = ''; // pie / donut/ radial
  7323. if (!w.globals.axisCharts) {
  7324. cat = w.config.labels[i];
  7325. } else {
  7326. // xy charts
  7327. // non datetime
  7328. if (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) {
  7329. if (w.globals.isBarHorizontal) {
  7330. var lbFormatter = w.globals.yLabelFormatters[0];
  7331. var sr = new Series(_this3.ctx);
  7332. var activeSeries = sr.getActiveConfigSeriesIndex();
  7333. cat = lbFormatter(w.globals.labels[i], {
  7334. seriesIndex: activeSeries,
  7335. dataPointIndex: i,
  7336. w: w
  7337. });
  7338. } else {
  7339. cat = axesUtils.getLabel(w.globals.labels, w.globals.timescaleLabels, 0, i).text;
  7340. }
  7341. } // datetime, but labels specified in categories or labels
  7342. if (w.config.xaxis.type === 'datetime') {
  7343. if (w.config.xaxis.categories.length) {
  7344. cat = w.config.xaxis.categories[i];
  7345. } else if (w.config.labels.length) {
  7346. cat = w.config.labels[i];
  7347. }
  7348. }
  7349. }
  7350. return cat;
  7351. };
  7352. var handleAxisRowsColumns = function handleAxisRowsColumns(s, sI) {
  7353. if (columns.length) {
  7354. rows.push(columns.join(columnDelimiter));
  7355. }
  7356. if (s.data && s.data.length) {
  7357. for (var i = 0; i < s.data.length; i++) {
  7358. columns = [];
  7359. var cat = getCat(i);
  7360. if (!cat) {
  7361. if (dataFormat.isFormatXY()) {
  7362. cat = series[sI].data[i].x;
  7363. } else if (dataFormat.isFormat2DArray()) {
  7364. cat = series[sI].data[i] ? series[sI].data[i][0] : '';
  7365. }
  7366. }
  7367. if (sI === 0) {
  7368. columns.push(cat);
  7369. for (var ci = 0; ci < w.globals.series.length; ci++) {
  7370. columns.push(w.globals.series[ci][i]);
  7371. }
  7372. }
  7373. if (w.config.chart.type === 'candlestick' || s.type && s.type === 'candlestick') {
  7374. columns.pop();
  7375. columns.push(w.globals.seriesCandleO[sI][i]);
  7376. columns.push(w.globals.seriesCandleH[sI][i]);
  7377. columns.push(w.globals.seriesCandleL[sI][i]);
  7378. columns.push(w.globals.seriesCandleC[sI][i]);
  7379. }
  7380. if (w.config.chart.type === 'rangeBar') {
  7381. columns.pop();
  7382. columns.push(w.globals.seriesRangeStart[sI][i]);
  7383. columns.push(w.globals.seriesRangeEnd[sI][i]);
  7384. }
  7385. if (columns.length) {
  7386. rows.push(columns.join(columnDelimiter));
  7387. }
  7388. }
  7389. }
  7390. };
  7391. columns.push('category');
  7392. series.map(function (s, sI) {
  7393. if (w.globals.axisCharts) {
  7394. columns.push(s.name ? s.name : "series-".concat(sI));
  7395. }
  7396. });
  7397. if (!w.globals.axisCharts) {
  7398. columns.push('value');
  7399. rows.push(columns.join(columnDelimiter));
  7400. }
  7401. series.map(function (s, sI) {
  7402. if (w.globals.axisCharts) {
  7403. handleAxisRowsColumns(s, sI);
  7404. } else {
  7405. columns = [];
  7406. columns.push(w.globals.labels[sI]);
  7407. columns.push(w.globals.series[sI]);
  7408. rows.push(columns.join(columnDelimiter));
  7409. }
  7410. });
  7411. result += rows.join(lineDelimiter);
  7412. this.triggerDownload(encodeURI(result), '.csv');
  7413. }
  7414. }, {
  7415. key: "triggerDownload",
  7416. value: function triggerDownload(href, ext) {
  7417. var downloadLink = document.createElement('a');
  7418. downloadLink.href = href;
  7419. downloadLink.download = this.w.globals.chartID + ext;
  7420. document.body.appendChild(downloadLink);
  7421. downloadLink.click();
  7422. document.body.removeChild(downloadLink);
  7423. }
  7424. }]);
  7425. return Exports;
  7426. }();
  7427. /**
  7428. * ApexCharts XAxis Class for drawing X-Axis.
  7429. *
  7430. * @module XAxis
  7431. **/
  7432. var XAxis = /*#__PURE__*/function () {
  7433. function XAxis(ctx) {
  7434. _classCallCheck(this, XAxis);
  7435. this.ctx = ctx;
  7436. this.w = ctx.w;
  7437. var w = this.w;
  7438. this.axesUtils = new AxesUtils(ctx);
  7439. this.xaxisLabels = w.globals.labels.slice();
  7440. if (w.globals.timescaleLabels.length > 0 && !w.globals.isBarHorizontal) {
  7441. // timeline labels are there and chart is not rangeabr timeline
  7442. this.xaxisLabels = w.globals.timescaleLabels.slice();
  7443. }
  7444. this.drawnLabels = [];
  7445. this.drawnLabelsRects = [];
  7446. if (w.config.xaxis.position === 'top') {
  7447. this.offY = 0;
  7448. } else {
  7449. this.offY = w.globals.gridHeight + 1;
  7450. }
  7451. this.offY = this.offY + w.config.xaxis.axisBorder.offsetY;
  7452. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  7453. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  7454. this.xaxisFontFamily = w.config.xaxis.labels.style.fontFamily;
  7455. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  7456. this.xaxisBorderWidth = w.config.xaxis.axisBorder.width;
  7457. if (this.isCategoryBarHorizontal) {
  7458. this.xaxisBorderWidth = w.config.yaxis[0].axisBorder.width.toString();
  7459. }
  7460. if (this.xaxisBorderWidth.indexOf('%') > -1) {
  7461. this.xaxisBorderWidth = w.globals.gridWidth * parseInt(this.xaxisBorderWidth, 10) / 100;
  7462. } else {
  7463. this.xaxisBorderWidth = parseInt(this.xaxisBorderWidth, 10);
  7464. }
  7465. this.xaxisBorderHeight = w.config.xaxis.axisBorder.height; // For bars, we will only consider single y xais,
  7466. // as we are not providing multiple yaxis for bar charts
  7467. this.yaxis = w.config.yaxis[0];
  7468. }
  7469. _createClass(XAxis, [{
  7470. key: "drawXaxis",
  7471. value: function drawXaxis() {
  7472. var _this = this;
  7473. var w = this.w;
  7474. var graphics = new Graphics(this.ctx);
  7475. var elXaxis = graphics.group({
  7476. class: 'apexcharts-xaxis',
  7477. transform: "translate(".concat(w.config.xaxis.offsetX, ", ").concat(w.config.xaxis.offsetY, ")")
  7478. });
  7479. var elXaxisTexts = graphics.group({
  7480. class: 'apexcharts-xaxis-texts-g',
  7481. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  7482. });
  7483. elXaxis.add(elXaxisTexts);
  7484. var colWidth; // initial x Position (keep adding column width in the loop)
  7485. var xPos = w.globals.padHorizontal;
  7486. var labels = [];
  7487. for (var i = 0; i < this.xaxisLabels.length; i++) {
  7488. labels.push(this.xaxisLabels[i]);
  7489. }
  7490. var labelsLen = labels.length;
  7491. if (w.globals.isXNumeric) {
  7492. var len = labelsLen > 1 ? labelsLen - 1 : labelsLen;
  7493. colWidth = w.globals.gridWidth / len;
  7494. xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX;
  7495. } else {
  7496. colWidth = w.globals.gridWidth / labels.length;
  7497. xPos = xPos + colWidth + w.config.xaxis.labels.offsetX;
  7498. }
  7499. if (w.config.xaxis.labels.show) {
  7500. var _loop = function _loop(_i) {
  7501. var x = xPos - colWidth / 2 + w.config.xaxis.labels.offsetX;
  7502. if (_i === 0 && labelsLen === 1 && colWidth / 2 === xPos && w.globals.dataPoints === 1) {
  7503. // single datapoint
  7504. x = w.globals.gridWidth / 2;
  7505. }
  7506. var label = _this.axesUtils.getLabel(labels, w.globals.timescaleLabels, x, _i, _this.drawnLabels, _this.xaxisFontSize);
  7507. var offsetYCorrection = 28;
  7508. if (w.globals.rotateXLabels) {
  7509. offsetYCorrection = 22;
  7510. }
  7511. label = _this.axesUtils.checkForOverflowingLabels(_i, label, labelsLen, _this.drawnLabels, _this.drawnLabelsRects);
  7512. var getCatForeColor = function getCatForeColor() {
  7513. return w.config.xaxis.convertedCatToNumeric ? _this.xaxisForeColors[w.globals.minX + _i - 1] : _this.xaxisForeColors[_i];
  7514. };
  7515. if (label.text) {
  7516. w.globals.xaxisLabelsCount++;
  7517. }
  7518. var elText = graphics.drawText({
  7519. x: label.x,
  7520. y: _this.offY + w.config.xaxis.labels.offsetY + offsetYCorrection - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  7521. text: label.text,
  7522. textAnchor: 'middle',
  7523. fontWeight: label.isBold ? 600 : w.config.xaxis.labels.style.fontWeight,
  7524. fontSize: _this.xaxisFontSize,
  7525. fontFamily: _this.xaxisFontFamily,
  7526. foreColor: Array.isArray(_this.xaxisForeColors) ? getCatForeColor() : _this.xaxisForeColors,
  7527. isPlainText: false,
  7528. cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
  7529. });
  7530. elXaxisTexts.add(elText);
  7531. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  7532. elTooltipTitle.textContent = label.text;
  7533. elText.node.appendChild(elTooltipTitle);
  7534. if (label.text !== '') {
  7535. _this.drawnLabels.push(label.text);
  7536. _this.drawnLabelsRects.push(label);
  7537. }
  7538. xPos = xPos + colWidth;
  7539. };
  7540. for (var _i = 0; _i <= labelsLen - 1; _i++) {
  7541. _loop(_i);
  7542. }
  7543. }
  7544. if (w.config.xaxis.title.text !== undefined) {
  7545. var elXaxisTitle = graphics.group({
  7546. class: 'apexcharts-xaxis-title'
  7547. });
  7548. var elXAxisTitleText = graphics.drawText({
  7549. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  7550. y: this.offY - parseFloat(this.xaxisFontSize) + w.globals.xAxisLabelsHeight + w.config.xaxis.title.offsetY,
  7551. text: w.config.xaxis.title.text,
  7552. textAnchor: 'middle',
  7553. fontSize: w.config.xaxis.title.style.fontSize,
  7554. fontFamily: w.config.xaxis.title.style.fontFamily,
  7555. fontWeight: w.config.xaxis.title.style.fontWeight,
  7556. foreColor: w.config.xaxis.title.style.color,
  7557. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  7558. });
  7559. elXaxisTitle.add(elXAxisTitleText);
  7560. elXaxis.add(elXaxisTitle);
  7561. }
  7562. if (w.config.xaxis.axisBorder.show) {
  7563. var lineCorrection = 0;
  7564. if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
  7565. lineCorrection = lineCorrection - 15;
  7566. }
  7567. 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);
  7568. elXaxis.add(elHorzLine);
  7569. }
  7570. return elXaxis;
  7571. } // this actually becomes the vertical axis (for bar charts)
  7572. }, {
  7573. key: "drawXaxisInversed",
  7574. value: function drawXaxisInversed(realIndex) {
  7575. var w = this.w;
  7576. var graphics = new Graphics(this.ctx);
  7577. var translateYAxisX = w.config.yaxis[0].opposite ? w.globals.translateYAxisX[realIndex] : 0;
  7578. var elYaxis = graphics.group({
  7579. class: 'apexcharts-yaxis apexcharts-xaxis-inversed',
  7580. rel: realIndex
  7581. });
  7582. var elYaxisTexts = graphics.group({
  7583. class: 'apexcharts-yaxis-texts-g apexcharts-xaxis-inversed-texts-g',
  7584. transform: 'translate(' + translateYAxisX + ', 0)'
  7585. });
  7586. elYaxis.add(elYaxisTexts);
  7587. var colHeight; // initial x Position (keep adding column width in the loop)
  7588. var yPos;
  7589. var labels = [];
  7590. if (w.config.yaxis[realIndex].show) {
  7591. for (var i = 0; i < this.xaxisLabels.length; i++) {
  7592. labels.push(this.xaxisLabels[i]);
  7593. }
  7594. }
  7595. colHeight = w.globals.gridHeight / labels.length;
  7596. yPos = -(colHeight / 2.2);
  7597. var lbFormatter = w.globals.yLabelFormatters[0];
  7598. var ylabels = w.config.yaxis[0].labels;
  7599. if (ylabels.show) {
  7600. for (var _i2 = 0; _i2 <= labels.length - 1; _i2++) {
  7601. var label = typeof labels[_i2] === 'undefined' ? '' : labels[_i2];
  7602. label = lbFormatter(label, {
  7603. seriesIndex: realIndex,
  7604. dataPointIndex: _i2,
  7605. w: w
  7606. });
  7607. var multiY = 0;
  7608. if (Array.isArray(label)) {
  7609. multiY = label.length / 2 * parseInt(ylabels.style.fontSize, 10);
  7610. }
  7611. var elLabel = graphics.drawText({
  7612. x: ylabels.offsetX - 15,
  7613. y: yPos + colHeight + ylabels.offsetY - multiY,
  7614. text: label,
  7615. textAnchor: this.yaxis.opposite ? 'start' : 'end',
  7616. foreColor: Array.isArray(ylabels.style.colors) ? ylabels.style.colors[_i2] : ylabels.style.colors,
  7617. fontSize: ylabels.style.fontSize,
  7618. fontFamily: ylabels.style.fontFamily,
  7619. fontWeight: ylabels.style.fontWeight,
  7620. isPlainText: false,
  7621. cssClass: 'apexcharts-yaxis-label ' + ylabels.style.cssClass
  7622. });
  7623. elYaxisTexts.add(elLabel);
  7624. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  7625. elTooltipTitle.textContent = label.text;
  7626. elLabel.node.appendChild(elTooltipTitle);
  7627. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  7628. var labelRotatingCenter = graphics.rotateAroundCenter(elLabel.node);
  7629. elLabel.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " 0 ").concat(labelRotatingCenter.y, ")"));
  7630. }
  7631. yPos = yPos + colHeight;
  7632. }
  7633. }
  7634. if (w.config.yaxis[0].title.text !== undefined) {
  7635. var elXaxisTitle = graphics.group({
  7636. class: 'apexcharts-yaxis-title apexcharts-xaxis-title-inversed',
  7637. transform: 'translate(' + translateYAxisX + ', 0)'
  7638. });
  7639. var elXAxisTitleText = graphics.drawText({
  7640. x: 0,
  7641. y: w.globals.gridHeight / 2,
  7642. text: w.config.yaxis[0].title.text,
  7643. textAnchor: 'middle',
  7644. foreColor: w.config.yaxis[0].title.style.color,
  7645. fontSize: w.config.yaxis[0].title.style.fontSize,
  7646. fontWeight: w.config.yaxis[0].title.style.fontWeight,
  7647. fontFamily: w.config.yaxis[0].title.style.fontFamily,
  7648. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[0].title.style.cssClass
  7649. });
  7650. elXaxisTitle.add(elXAxisTitleText);
  7651. elYaxis.add(elXaxisTitle);
  7652. }
  7653. var offX = 0;
  7654. if (this.isCategoryBarHorizontal && w.config.yaxis[0].opposite) {
  7655. offX = w.globals.gridWidth;
  7656. }
  7657. var axisBorder = w.config.xaxis.axisBorder;
  7658. if (axisBorder.show) {
  7659. 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);
  7660. elYaxis.add(elVerticalLine);
  7661. }
  7662. if (w.config.yaxis[0].axisTicks.show) {
  7663. this.axesUtils.drawYAxisTicks(offX, labels.length, w.config.yaxis[0].axisBorder, w.config.yaxis[0].axisTicks, 0, colHeight, elYaxis);
  7664. }
  7665. return elYaxis;
  7666. }
  7667. }, {
  7668. key: "drawXaxisTicks",
  7669. value: function drawXaxisTicks(x1, appendToElement) {
  7670. var w = this.w;
  7671. var x2 = x1;
  7672. if (x1 < 0 || x1 - 2 > w.globals.gridWidth) return;
  7673. var y1 = this.offY + w.config.xaxis.axisTicks.offsetY;
  7674. var y2 = y1 + w.config.xaxis.axisTicks.height;
  7675. if (w.config.xaxis.position === 'top') {
  7676. y2 = y1 - w.config.xaxis.axisTicks.height;
  7677. }
  7678. if (w.config.xaxis.axisTicks.show) {
  7679. var graphics = new Graphics(this.ctx);
  7680. 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); // we are not returning anything, but appending directly to the element pased in param
  7681. appendToElement.add(line);
  7682. line.node.classList.add('apexcharts-xaxis-tick');
  7683. }
  7684. }
  7685. }, {
  7686. key: "getXAxisTicksPositions",
  7687. value: function getXAxisTicksPositions() {
  7688. var w = this.w;
  7689. var xAxisTicksPositions = [];
  7690. var xCount = this.xaxisLabels.length;
  7691. var x1 = w.globals.padHorizontal;
  7692. if (w.globals.timescaleLabels.length > 0) {
  7693. for (var i = 0; i < xCount; i++) {
  7694. x1 = this.xaxisLabels[i].position;
  7695. xAxisTicksPositions.push(x1);
  7696. }
  7697. } else {
  7698. var xCountForCategoryCharts = xCount;
  7699. for (var _i3 = 0; _i3 < xCountForCategoryCharts; _i3++) {
  7700. var x1Count = xCountForCategoryCharts;
  7701. if (w.globals.isXNumeric && w.config.chart.type !== 'bar') {
  7702. x1Count -= 1;
  7703. }
  7704. x1 = x1 + w.globals.gridWidth / x1Count;
  7705. xAxisTicksPositions.push(x1);
  7706. }
  7707. }
  7708. return xAxisTicksPositions;
  7709. } // to rotate x-axis labels or to put ... for longer text in xaxis
  7710. }, {
  7711. key: "xAxisLabelCorrections",
  7712. value: function xAxisLabelCorrections() {
  7713. var w = this.w;
  7714. var graphics = new Graphics(this.ctx);
  7715. var xAxis = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g');
  7716. var xAxisTexts = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-texts-g text');
  7717. var yAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-inversed text');
  7718. var xAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-inversed-texts-g text tspan');
  7719. if (w.globals.rotateXLabels || w.config.xaxis.labels.rotateAlways) {
  7720. for (var xat = 0; xat < xAxisTexts.length; xat++) {
  7721. var textRotatingCenter = graphics.rotateAroundCenter(xAxisTexts[xat]);
  7722. textRotatingCenter.y = textRotatingCenter.y - 1; // + tickWidth/4;
  7723. textRotatingCenter.x = textRotatingCenter.x + 1;
  7724. xAxisTexts[xat].setAttribute('transform', "rotate(".concat(w.config.xaxis.labels.rotate, " ").concat(textRotatingCenter.x, " ").concat(textRotatingCenter.y, ")"));
  7725. xAxisTexts[xat].setAttribute('text-anchor', "end");
  7726. var offsetHeight = 10;
  7727. xAxis.setAttribute('transform', "translate(0, ".concat(-offsetHeight, ")"));
  7728. var tSpan = xAxisTexts[xat].childNodes;
  7729. if (w.config.xaxis.labels.trim) {
  7730. Array.prototype.forEach.call(tSpan, function (ts) {
  7731. graphics.placeTextWithEllipsis(ts, ts.textContent, w.config.xaxis.labels.maxHeight - (w.config.legend.position === 'bottom' ? 20 : 10));
  7732. });
  7733. }
  7734. }
  7735. } else {
  7736. (function () {
  7737. var width = w.globals.gridWidth / (w.globals.labels.length + 1);
  7738. for (var _xat = 0; _xat < xAxisTexts.length; _xat++) {
  7739. var _tSpan = xAxisTexts[_xat].childNodes;
  7740. if (w.config.xaxis.labels.trim && w.config.xaxis.type !== 'datetime') {
  7741. Array.prototype.forEach.call(_tSpan, function (ts) {
  7742. graphics.placeTextWithEllipsis(ts, ts.textContent, width);
  7743. });
  7744. }
  7745. }
  7746. })();
  7747. }
  7748. if (yAxisTextsInversed.length > 0) {
  7749. // truncate rotated y axis in bar chart (x axis)
  7750. var firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox();
  7751. var lastLabelPosX = yAxisTextsInversed[0].getBBox();
  7752. if (firstLabelPosX.x < -20) {
  7753. yAxisTextsInversed[yAxisTextsInversed.length - 1].parentNode.removeChild(yAxisTextsInversed[yAxisTextsInversed.length - 1]);
  7754. }
  7755. if (lastLabelPosX.x + lastLabelPosX.width > w.globals.gridWidth && !w.globals.isBarHorizontal) {
  7756. yAxisTextsInversed[0].parentNode.removeChild(yAxisTextsInversed[0]);
  7757. } // truncate rotated x axis in bar chart (y axis)
  7758. for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) {
  7759. graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 - 20);
  7760. }
  7761. }
  7762. } // renderXAxisBands() {
  7763. // let w = this.w;
  7764. // let plotBand = document.createElementNS(w.globals.SVGNS, 'rect')
  7765. // w.globals.dom.elGraphical.add(plotBand)
  7766. // }
  7767. }]);
  7768. return XAxis;
  7769. }();
  7770. /**
  7771. * ApexCharts Grid Class for drawing Cartesian Grid.
  7772. *
  7773. * @module Grid
  7774. **/
  7775. var Grid = /*#__PURE__*/function () {
  7776. function Grid(ctx) {
  7777. _classCallCheck(this, Grid);
  7778. this.ctx = ctx;
  7779. this.w = ctx.w;
  7780. var w = this.w;
  7781. this.xaxisLabels = w.globals.labels.slice();
  7782. this.axesUtils = new AxesUtils(ctx);
  7783. this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
  7784. if (w.globals.timescaleLabels.length > 0) {
  7785. // timescaleLabels labels are there
  7786. this.xaxisLabels = w.globals.timescaleLabels.slice();
  7787. }
  7788. } // when using sparklines or when showing no grid, we need to have a grid area which is reused at many places for other calculations as well
  7789. _createClass(Grid, [{
  7790. key: "drawGridArea",
  7791. value: function drawGridArea() {
  7792. var elGrid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7793. var w = this.w;
  7794. var graphics = new Graphics(this.ctx);
  7795. if (elGrid === null) {
  7796. elGrid = graphics.group({
  7797. class: 'apexcharts-grid'
  7798. });
  7799. }
  7800. var elVerticalLine = graphics.drawLine(w.globals.padHorizontal, 1, w.globals.padHorizontal, w.globals.gridHeight, 'transparent');
  7801. var elHorzLine = graphics.drawLine(w.globals.padHorizontal, w.globals.gridHeight, w.globals.gridWidth, w.globals.gridHeight, 'transparent');
  7802. elGrid.add(elHorzLine);
  7803. elGrid.add(elVerticalLine);
  7804. return elGrid;
  7805. }
  7806. }, {
  7807. key: "drawGrid",
  7808. value: function drawGrid() {
  7809. var gl = this.w.globals;
  7810. var elgrid = null;
  7811. if (gl.axisCharts) {
  7812. // grid is drawn after xaxis and yaxis are drawn
  7813. elgrid = this.renderGrid();
  7814. this.drawGridArea(elgrid.el);
  7815. }
  7816. return elgrid;
  7817. } // This mask will clip off overflowing graphics from the drawable area
  7818. }, {
  7819. key: "createGridMask",
  7820. value: function createGridMask() {
  7821. var w = this.w;
  7822. var gl = w.globals;
  7823. var graphics = new Graphics(this.ctx);
  7824. var strokeSize = Array.isArray(w.config.stroke.width) ? 0 : w.config.stroke.width;
  7825. if (Array.isArray(w.config.stroke.width)) {
  7826. var strokeMaxSize = 0;
  7827. w.config.stroke.width.forEach(function (m) {
  7828. strokeMaxSize = Math.max(strokeMaxSize, m);
  7829. });
  7830. strokeSize = strokeMaxSize;
  7831. }
  7832. gl.dom.elGridRectMask = document.createElementNS(gl.SVGNS, 'clipPath');
  7833. gl.dom.elGridRectMask.setAttribute('id', "gridRectMask".concat(gl.cuid));
  7834. gl.dom.elGridRectMarkerMask = document.createElementNS(gl.SVGNS, 'clipPath');
  7835. gl.dom.elGridRectMarkerMask.setAttribute('id', "gridRectMarkerMask".concat(gl.cuid)); // let barHalfWidth = 0
  7836. var type = w.config.chart.type;
  7837. var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
  7838. var barWidthLeft = 0;
  7839. var barWidthRight = 0;
  7840. if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  7841. barWidthLeft = w.config.grid.padding.left;
  7842. barWidthRight = w.config.grid.padding.right;
  7843. if (gl.barPadForNumericAxis > barWidthLeft) {
  7844. barWidthLeft = gl.barPadForNumericAxis;
  7845. barWidthRight = gl.barPadForNumericAxis;
  7846. }
  7847. }
  7848. gl.dom.elGridRect = graphics.drawRect(-strokeSize / 2 - barWidthLeft - 2, -strokeSize / 2, gl.gridWidth + strokeSize + barWidthRight + barWidthLeft + 4, gl.gridHeight + strokeSize, 0, '#fff');
  7849. var coreUtils = new CoreUtils(this);
  7850. coreUtils.getLargestMarkerSize();
  7851. var markerSize = w.globals.markers.largestSize + 1;
  7852. gl.dom.elGridRectMarker = graphics.drawRect(-markerSize * 2, -markerSize * 2, gl.gridWidth + markerSize * 4, gl.gridHeight + markerSize * 4, 0, '#fff');
  7853. gl.dom.elGridRectMask.appendChild(gl.dom.elGridRect.node);
  7854. gl.dom.elGridRectMarkerMask.appendChild(gl.dom.elGridRectMarker.node);
  7855. var defs = gl.dom.baseEl.querySelector('defs');
  7856. defs.appendChild(gl.dom.elGridRectMask);
  7857. defs.appendChild(gl.dom.elGridRectMarkerMask);
  7858. }
  7859. }, {
  7860. key: "_drawGridLines",
  7861. value: function _drawGridLines(_ref) {
  7862. var i = _ref.i,
  7863. x1 = _ref.x1,
  7864. y1 = _ref.y1,
  7865. x2 = _ref.x2,
  7866. y2 = _ref.y2,
  7867. xCount = _ref.xCount,
  7868. parent = _ref.parent;
  7869. var w = this.w;
  7870. var shouldDraw = function shouldDraw() {
  7871. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  7872. return false;
  7873. }
  7874. if (i === xCount - 1 && w.globals.skipLastTimelinelabel) {
  7875. return false;
  7876. }
  7877. if (w.config.chart.type === 'radar') {
  7878. return false;
  7879. }
  7880. return true;
  7881. };
  7882. if (shouldDraw()) {
  7883. if (w.config.grid.xaxis.lines.show) {
  7884. this._drawGridLine({
  7885. x1: x1,
  7886. y1: y1,
  7887. x2: x2,
  7888. y2: y2,
  7889. parent: parent
  7890. });
  7891. }
  7892. var xAxis = new XAxis(this.ctx);
  7893. xAxis.drawXaxisTicks(x1, this.elg);
  7894. }
  7895. }
  7896. }, {
  7897. key: "_drawGridLine",
  7898. value: function _drawGridLine(_ref2) {
  7899. var x1 = _ref2.x1,
  7900. y1 = _ref2.y1,
  7901. x2 = _ref2.x2,
  7902. y2 = _ref2.y2,
  7903. parent = _ref2.parent;
  7904. var w = this.w;
  7905. var strokeDashArray = w.config.grid.strokeDashArray;
  7906. var graphics = new Graphics(this);
  7907. var line = graphics.drawLine(x1, y1, x2, y2, w.config.grid.borderColor, strokeDashArray);
  7908. line.node.classList.add('apexcharts-gridline');
  7909. parent.add(line);
  7910. }
  7911. }, {
  7912. key: "_drawGridBandRect",
  7913. value: function _drawGridBandRect(_ref3) {
  7914. var c = _ref3.c,
  7915. x1 = _ref3.x1,
  7916. y1 = _ref3.y1,
  7917. x2 = _ref3.x2,
  7918. y2 = _ref3.y2,
  7919. type = _ref3.type;
  7920. var w = this.w;
  7921. var graphics = new Graphics(this.ctx);
  7922. if (type === 'column' && w.config.xaxis.type === 'datetime') return;
  7923. var color = w.config.grid[type].colors[c];
  7924. var rect = graphics.drawRect(x1, y1, x2, y2, 0, color, w.config.grid[type].opacity);
  7925. this.elg.add(rect);
  7926. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  7927. rect.node.classList.add("apexcharts-grid-".concat(type));
  7928. }
  7929. }, {
  7930. key: "_drawXYLines",
  7931. value: function _drawXYLines(_ref4) {
  7932. var _this = this;
  7933. var xCount = _ref4.xCount,
  7934. tickAmount = _ref4.tickAmount;
  7935. var w = this.w;
  7936. var datetimeLines = function datetimeLines(_ref5) {
  7937. var xC = _ref5.xC,
  7938. x1 = _ref5.x1,
  7939. y1 = _ref5.y1,
  7940. x2 = _ref5.x2,
  7941. y2 = _ref5.y2;
  7942. for (var i = 0; i < xC; i++) {
  7943. x1 = _this.xaxisLabels[i].position;
  7944. x2 = _this.xaxisLabels[i].position;
  7945. _this._drawGridLines({
  7946. i: i,
  7947. x1: x1,
  7948. y1: y1,
  7949. x2: x2,
  7950. y2: y2,
  7951. xCount: xCount,
  7952. parent: _this.elgridLinesV
  7953. });
  7954. }
  7955. };
  7956. var categoryLines = function categoryLines(_ref6) {
  7957. var xC = _ref6.xC,
  7958. x1 = _ref6.x1,
  7959. y1 = _ref6.y1,
  7960. x2 = _ref6.x2,
  7961. y2 = _ref6.y2;
  7962. for (var i = 0; i < xC + (w.globals.isXNumeric ? 0 : 1); i++) {
  7963. if (i === 0 && xC === 1 && w.globals.dataPoints === 1) {
  7964. // single datapoint
  7965. x1 = w.globals.gridWidth / 2;
  7966. x2 = x1;
  7967. }
  7968. _this._drawGridLines({
  7969. i: i,
  7970. x1: x1,
  7971. y1: y1,
  7972. x2: x2,
  7973. y2: y2,
  7974. xCount: xCount,
  7975. parent: _this.elgridLinesV
  7976. });
  7977. x1 = x1 + w.globals.gridWidth / (w.globals.isXNumeric ? xC - 1 : xC);
  7978. x2 = x1;
  7979. }
  7980. }; // draw vertical lines
  7981. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  7982. var x1 = w.globals.padHorizontal;
  7983. var y1 = 0;
  7984. var x2;
  7985. var y2 = w.globals.gridHeight;
  7986. if (w.globals.timescaleLabels.length) {
  7987. datetimeLines({
  7988. xC: xCount,
  7989. x1: x1,
  7990. y1: y1,
  7991. x2: x2,
  7992. y2: y2
  7993. });
  7994. } else {
  7995. if (w.globals.isXNumeric) {
  7996. xCount = w.globals.xAxisScale.result.length;
  7997. }
  7998. if (w.config.xaxis.convertedCatToNumeric) {
  7999. // in case of a convertedCatToNumeric, some labels might be skipped due to hideOverLapping labels, hence use this var to get the visible ticks
  8000. xCount = w.globals.xaxisLabelsCount;
  8001. }
  8002. categoryLines({
  8003. xC: xCount,
  8004. x1: x1,
  8005. y1: y1,
  8006. x2: x2,
  8007. y2: y2
  8008. });
  8009. }
  8010. } // draw horizontal lines
  8011. if (w.config.grid.yaxis.lines.show) {
  8012. var _x = 0;
  8013. var _y = 0;
  8014. var _y2 = 0;
  8015. var _x2 = w.globals.gridWidth;
  8016. var tA = tickAmount + 1;
  8017. if (this.isTimelineBar) {
  8018. tA = w.globals.labels.length;
  8019. }
  8020. for (var i = 0; i < tA + (this.isTimelineBar ? 1 : 0); i++) {
  8021. this._drawGridLine({
  8022. x1: _x,
  8023. y1: _y,
  8024. x2: _x2,
  8025. y2: _y2,
  8026. parent: this.elgridLinesH
  8027. });
  8028. _y = _y + w.globals.gridHeight / (this.isTimelineBar ? tA : tickAmount);
  8029. _y2 = _y;
  8030. }
  8031. }
  8032. }
  8033. }, {
  8034. key: "_drawInvertedXYLines",
  8035. value: function _drawInvertedXYLines(_ref7) {
  8036. var xCount = _ref7.xCount;
  8037. var w = this.w; // draw vertical lines
  8038. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  8039. var x1 = w.globals.padHorizontal;
  8040. var y1 = 0;
  8041. var x2;
  8042. var y2 = w.globals.gridHeight;
  8043. for (var i = 0; i < xCount + 1; i++) {
  8044. if (w.config.grid.xaxis.lines.show) {
  8045. this._drawGridLine({
  8046. x1: x1,
  8047. y1: y1,
  8048. x2: x2,
  8049. y2: y2,
  8050. parent: this.elgridLinesV
  8051. });
  8052. }
  8053. var xAxis = new XAxis(this.ctx);
  8054. xAxis.drawXaxisTicks(x1, this.elg);
  8055. x1 = x1 + w.globals.gridWidth / xCount + 0.3;
  8056. x2 = x1;
  8057. }
  8058. } // draw horizontal lines
  8059. if (w.config.grid.yaxis.lines.show) {
  8060. var _x3 = 0;
  8061. var _y3 = 0;
  8062. var _y4 = 0;
  8063. var _x4 = w.globals.gridWidth;
  8064. for (var _i = 0; _i < w.globals.dataPoints + 1; _i++) {
  8065. this._drawGridLine({
  8066. x1: _x3,
  8067. y1: _y3,
  8068. x2: _x4,
  8069. y2: _y4,
  8070. parent: this.elgridLinesH
  8071. });
  8072. _y3 = _y3 + w.globals.gridHeight / w.globals.dataPoints;
  8073. _y4 = _y3;
  8074. }
  8075. }
  8076. } // actual grid rendering
  8077. }, {
  8078. key: "renderGrid",
  8079. value: function renderGrid() {
  8080. var w = this.w;
  8081. var graphics = new Graphics(this.ctx);
  8082. this.elg = graphics.group({
  8083. class: 'apexcharts-grid'
  8084. });
  8085. this.elgridLinesH = graphics.group({
  8086. class: 'apexcharts-gridlines-horizontal'
  8087. });
  8088. this.elgridLinesV = graphics.group({
  8089. class: 'apexcharts-gridlines-vertical'
  8090. });
  8091. this.elg.add(this.elgridLinesH);
  8092. this.elg.add(this.elgridLinesV);
  8093. if (!w.config.grid.show) {
  8094. this.elgridLinesV.hide();
  8095. this.elgridLinesH.hide();
  8096. }
  8097. var yTickAmount = w.globals.yAxisScale.length ? w.globals.yAxisScale[0].result.length - 1 : 5;
  8098. for (var i = 0; i < w.globals.series.length; i++) {
  8099. if (typeof w.globals.yAxisScale[i] !== 'undefined') {
  8100. yTickAmount = w.globals.yAxisScale[i].result.length - 1;
  8101. }
  8102. if (yTickAmount > 2) break;
  8103. }
  8104. var xCount;
  8105. if (!w.globals.isBarHorizontal || this.isTimelineBar) {
  8106. xCount = this.xaxisLabels.length;
  8107. if (this.isTimelineBar) {
  8108. yTickAmount = w.globals.labels.length;
  8109. }
  8110. this._drawXYLines({
  8111. xCount: xCount,
  8112. tickAmount: yTickAmount
  8113. });
  8114. } else {
  8115. xCount = yTickAmount; // for horizontal bar chart, get the xaxis tickamount
  8116. yTickAmount = w.globals.xTickAmount;
  8117. this._drawInvertedXYLines({
  8118. xCount: xCount,
  8119. tickAmount: yTickAmount
  8120. });
  8121. }
  8122. this.drawGridBands(xCount, yTickAmount);
  8123. return {
  8124. el: this.elg,
  8125. xAxisTickWidth: w.globals.gridWidth / xCount
  8126. };
  8127. }
  8128. }, {
  8129. key: "drawGridBands",
  8130. value: function drawGridBands(xCount, tickAmount) {
  8131. var w = this.w; // rows background bands
  8132. if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) {
  8133. var x1 = 0;
  8134. var y1 = 0;
  8135. var y2 = w.globals.gridHeight / tickAmount;
  8136. var x2 = w.globals.gridWidth;
  8137. for (var i = 0, c = 0; i < tickAmount; i++, c++) {
  8138. if (c >= w.config.grid.row.colors.length) {
  8139. c = 0;
  8140. }
  8141. this._drawGridBandRect({
  8142. c: c,
  8143. x1: x1,
  8144. y1: y1,
  8145. x2: x2,
  8146. y2: y2,
  8147. type: 'row'
  8148. });
  8149. y1 = y1 + w.globals.gridHeight / tickAmount;
  8150. }
  8151. } // columns background bands
  8152. if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) {
  8153. var xc = !w.globals.isBarHorizontal && (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) ? xCount - 1 : xCount;
  8154. var _x5 = w.globals.padHorizontal;
  8155. var _y5 = 0;
  8156. var _x6 = w.globals.padHorizontal + w.globals.gridWidth / xc;
  8157. var _y6 = w.globals.gridHeight;
  8158. for (var _i2 = 0, _c = 0; _i2 < xCount; _i2++, _c++) {
  8159. if (_c >= w.config.grid.column.colors.length) {
  8160. _c = 0;
  8161. }
  8162. this._drawGridBandRect({
  8163. c: _c,
  8164. x1: _x5,
  8165. y1: _y5,
  8166. x2: _x6,
  8167. y2: _y6,
  8168. type: 'column'
  8169. });
  8170. _x5 = _x5 + w.globals.gridWidth / xc;
  8171. }
  8172. }
  8173. }
  8174. }]);
  8175. return Grid;
  8176. }();
  8177. var Range = /*#__PURE__*/function () {
  8178. function Range(ctx) {
  8179. _classCallCheck(this, Range);
  8180. this.ctx = ctx;
  8181. this.w = ctx.w;
  8182. } // http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axiss
  8183. // This routine creates the Y axis values for a graph.
  8184. _createClass(Range, [{
  8185. key: "niceScale",
  8186. value: function niceScale(yMin, yMax, diff) {
  8187. var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  8188. var ticks = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
  8189. var NO_MIN_MAX_PROVIDED = arguments.length > 5 ? arguments[5] : undefined;
  8190. var w = this.w;
  8191. if (ticks === 'dataPoints') {
  8192. ticks = w.globals.dataPoints - 1;
  8193. }
  8194. if (yMin === Number.MIN_VALUE && yMax === 0 || !Utils.isNumber(yMin) && !Utils.isNumber(yMax) || yMin === Number.MIN_VALUE && yMax === -Number.MAX_VALUE) {
  8195. // when all values are 0
  8196. yMin = 0;
  8197. yMax = ticks;
  8198. var linearScale = this.linearScale(yMin, yMax, ticks);
  8199. return linearScale;
  8200. }
  8201. if (yMin > yMax) {
  8202. // if somehow due to some wrong config, user sent max less than min,
  8203. // adjust the min/max again
  8204. console.warn('axis.min cannot be greater than axis.max');
  8205. yMax = yMin + 0.1;
  8206. } else if (yMin === yMax) {
  8207. // If yMin and yMax are identical, then
  8208. // adjust the yMin and yMax values to actually
  8209. // make a graph. Also avoids division by zero errors.
  8210. yMin = yMin === 0 ? 0 : yMin - 0.5; // some small value
  8211. yMax = yMax === 0 ? 2 : yMax + 0.5; // some small value
  8212. } // Calculate Min amd Max graphical labels and graph
  8213. // increments. The number of ticks defaults to
  8214. // 10 which is the SUGGESTED value. Any tick value
  8215. // entered is used as a suggested value which is
  8216. // adjusted to be a 'pretty' value.
  8217. //
  8218. // Output will be an array of the Y axis values that
  8219. // encompass the Y values.
  8220. var result = []; // Determine Range
  8221. var range = Math.abs(yMax - yMin);
  8222. if (range < 1 && NO_MIN_MAX_PROVIDED && (w.config.chart.type === 'candlestick' || w.config.series[index].type === 'candlestick' || w.globals.isRangeData)) {
  8223. /* fix https://github.com/apexcharts/apexcharts.js/issues/430 */
  8224. yMax = yMax * 1.01;
  8225. }
  8226. var tiks = ticks + 1; // Adjust ticks if needed
  8227. if (tiks < 2) {
  8228. tiks = 2;
  8229. } else if (tiks > 2) {
  8230. tiks -= 2;
  8231. } // Get raw step value
  8232. var tempStep = range / tiks; // Calculate pretty step value
  8233. var mag = Math.floor(Utils.log10(tempStep));
  8234. var magPow = Math.pow(10, mag);
  8235. var magMsd = Math.round(tempStep / magPow);
  8236. if (magMsd < 1) {
  8237. magMsd = 1;
  8238. }
  8239. var stepSize = magMsd * magPow; // build Y label array.
  8240. // Lower and upper bounds calculations
  8241. var lb = stepSize * Math.floor(yMin / stepSize);
  8242. var ub = stepSize * Math.ceil(yMax / stepSize); // Build array
  8243. var val = lb;
  8244. if (NO_MIN_MAX_PROVIDED && range > 2) {
  8245. while (1) {
  8246. result.push(val);
  8247. val += stepSize;
  8248. if (val > ub) {
  8249. break;
  8250. }
  8251. }
  8252. return {
  8253. result: result,
  8254. niceMin: result[0],
  8255. niceMax: result[result.length - 1]
  8256. };
  8257. } else {
  8258. result = [];
  8259. var v = yMin;
  8260. result.push(v);
  8261. var valuesDivider = Math.abs(yMax - yMin) / ticks;
  8262. for (var i = 0; i <= ticks; i++) {
  8263. v = v + valuesDivider;
  8264. result.push(v);
  8265. }
  8266. if (result[result.length - 2] >= yMax) {
  8267. result.pop();
  8268. }
  8269. return {
  8270. result: result,
  8271. niceMin: result[0],
  8272. niceMax: result[result.length - 1]
  8273. };
  8274. }
  8275. }
  8276. }, {
  8277. key: "linearScale",
  8278. value: function linearScale(yMin, yMax) {
  8279. var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  8280. var range = Math.abs(yMax - yMin);
  8281. var step = range / ticks;
  8282. if (ticks === Number.MAX_VALUE) {
  8283. ticks = 10;
  8284. step = 1;
  8285. }
  8286. var result = [];
  8287. var v = yMin;
  8288. while (ticks >= 0) {
  8289. result.push(v);
  8290. v = v + step;
  8291. ticks -= 1;
  8292. }
  8293. return {
  8294. result: result,
  8295. niceMin: result[0],
  8296. niceMax: result[result.length - 1]
  8297. };
  8298. }
  8299. }, {
  8300. key: "logarithmicScale",
  8301. value: function logarithmicScale(index, yMin, yMax, ticks) {
  8302. if (yMin < 0 || yMin === Number.MIN_VALUE) yMin = 0.01;
  8303. var base = 10;
  8304. var min = Math.log(yMin) / Math.log(base);
  8305. var max = Math.log(yMax) / Math.log(base);
  8306. var range = Math.abs(yMax - yMin);
  8307. var step = range / ticks;
  8308. var result = [];
  8309. var v = yMin;
  8310. while (ticks >= 0) {
  8311. result.push(v);
  8312. v = v + step;
  8313. ticks -= 1;
  8314. }
  8315. var logs = result.map(function (niceNumber, i) {
  8316. if (niceNumber <= 0) {
  8317. niceNumber = 0.01;
  8318. } // calculate adjustment factor
  8319. var scale = (max - min) / (yMax - yMin);
  8320. var logVal = Math.pow(base, min + scale * (niceNumber - min));
  8321. return Math.round(logVal / Utils.roundToBase(logVal, base)) * Utils.roundToBase(logVal, base);
  8322. }); // Math.floor may have rounded the value to 0, revert back to 1
  8323. if (logs[0] === 0) logs[0] = 1;
  8324. return {
  8325. result: logs,
  8326. niceMin: logs[0],
  8327. niceMax: logs[logs.length - 1]
  8328. };
  8329. }
  8330. }, {
  8331. key: "setYScaleForIndex",
  8332. value: function setYScaleForIndex(index, minY, maxY) {
  8333. var gl = this.w.globals;
  8334. var cnf = this.w.config;
  8335. var y = gl.isBarHorizontal ? cnf.xaxis : cnf.yaxis[index];
  8336. if (typeof gl.yAxisScale[index] === 'undefined') {
  8337. gl.yAxisScale[index] = [];
  8338. }
  8339. var diff = Math.abs(maxY - minY);
  8340. if (y.logarithmic && diff <= 5) {
  8341. gl.invalidLogScale = true;
  8342. }
  8343. if (y.logarithmic && diff > 5) {
  8344. gl.allSeriesCollapsed = false;
  8345. gl.yAxisScale[index] = this.logarithmicScale(index, minY, maxY, y.tickAmount ? y.tickAmount : Math.floor(Math.log10(maxY)));
  8346. } else {
  8347. if (maxY === -Number.MAX_VALUE || !Utils.isNumber(maxY)) {
  8348. // no data in the chart. Either all series collapsed or user passed a blank array
  8349. gl.yAxisScale[index] = this.linearScale(0, 5, 5);
  8350. } else {
  8351. // there is some data. Turn off the allSeriesCollapsed flag
  8352. gl.allSeriesCollapsed = false;
  8353. if ((y.min !== undefined || y.max !== undefined) && !y.forceNiceScale) {
  8354. // fix https://github.com/apexcharts/apexcharts.js/issues/492
  8355. gl.yAxisScale[index] = this.linearScale(minY, maxY, y.tickAmount);
  8356. } else {
  8357. var noMinMaxProvided = cnf.yaxis[index].max === undefined && cnf.yaxis[index].min === undefined || cnf.yaxis[index].forceNiceScale;
  8358. gl.yAxisScale[index] = this.niceScale(minY, maxY, diff, index, // fix https://github.com/apexcharts/apexcharts.js/issues/397
  8359. y.tickAmount ? y.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5, noMinMaxProvided);
  8360. }
  8361. }
  8362. }
  8363. }
  8364. }, {
  8365. key: "setXScale",
  8366. value: function setXScale(minX, maxX) {
  8367. var w = this.w;
  8368. var gl = w.globals;
  8369. var x = w.config.xaxis;
  8370. var diff = Math.abs(maxX - minX);
  8371. if (maxX === -Number.MAX_VALUE || !Utils.isNumber(maxX)) {
  8372. // no data in the chart. Either all series collapsed or user passed a blank array
  8373. gl.xAxisScale = this.linearScale(0, 5, 5);
  8374. } else {
  8375. gl.xAxisScale = this.niceScale(minX, maxX, diff, 0, x.tickAmount ? x.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5);
  8376. }
  8377. return gl.xAxisScale;
  8378. }
  8379. }, {
  8380. key: "setMultipleYScales",
  8381. value: function setMultipleYScales() {
  8382. var _this = this;
  8383. var gl = this.w.globals;
  8384. var cnf = this.w.config;
  8385. var minYArr = gl.minYArr.concat([]);
  8386. var maxYArr = gl.maxYArr.concat([]);
  8387. var scalesIndices = []; // here, we loop through the yaxis array and find the item which has "seriesName" property
  8388. cnf.yaxis.forEach(function (yaxe, i) {
  8389. var index = i;
  8390. cnf.series.forEach(function (s, si) {
  8391. // if seriesName matches and that series is not collapsed, we use that scale
  8392. // fix issue #1215
  8393. // proceed even if si is in gl.collapsedSeriesIndices
  8394. if (s.name === yaxe.seriesName) {
  8395. index = si;
  8396. if (i !== si) {
  8397. scalesIndices.push({
  8398. index: si,
  8399. similarIndex: i,
  8400. alreadyExists: true
  8401. });
  8402. } else {
  8403. scalesIndices.push({
  8404. index: si
  8405. });
  8406. }
  8407. }
  8408. });
  8409. var minY = minYArr[index];
  8410. var maxY = maxYArr[index];
  8411. _this.setYScaleForIndex(i, minY, maxY);
  8412. });
  8413. this.sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices);
  8414. }
  8415. }, {
  8416. key: "sameScaleInMultipleAxes",
  8417. value: function sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) {
  8418. var _this2 = this;
  8419. var cnf = this.w.config;
  8420. var gl = this.w.globals; // we got the scalesIndices array in the above code, but we need to filter out the items which doesn't have same scales
  8421. var similarIndices = [];
  8422. scalesIndices.forEach(function (scale) {
  8423. if (scale.alreadyExists) {
  8424. if (typeof similarIndices[scale.index] === 'undefined') {
  8425. similarIndices[scale.index] = [];
  8426. }
  8427. similarIndices[scale.index].push(scale.index);
  8428. similarIndices[scale.index].push(scale.similarIndex);
  8429. }
  8430. });
  8431. function intersect(a, b) {
  8432. return a.filter(function (value) {
  8433. return b.indexOf(value) !== -1;
  8434. });
  8435. }
  8436. gl.yAxisSameScaleIndices = similarIndices;
  8437. similarIndices.forEach(function (si, i) {
  8438. similarIndices.forEach(function (sj, j) {
  8439. if (i !== j) {
  8440. if (intersect(si, sj).length > 0) {
  8441. similarIndices[i] = similarIndices[i].concat(similarIndices[j]);
  8442. }
  8443. }
  8444. });
  8445. }); // then, we remove duplicates from the similarScale array
  8446. var uniqueSimilarIndices = similarIndices.map(function (item) {
  8447. return item.filter(function (i, pos) {
  8448. return item.indexOf(i) === pos;
  8449. });
  8450. }); // sort further to remove whole duplicate arrays later
  8451. var sortedIndices = uniqueSimilarIndices.map(function (s) {
  8452. return s.sort();
  8453. }); // remove undefined items
  8454. similarIndices = similarIndices.filter(function (s) {
  8455. return !!s;
  8456. });
  8457. var indices = sortedIndices.slice();
  8458. var stringIndices = indices.map(function (ind) {
  8459. return JSON.stringify(ind);
  8460. });
  8461. indices = indices.filter(function (ind, p) {
  8462. return stringIndices.indexOf(JSON.stringify(ind)) === p;
  8463. });
  8464. var sameScaleMinYArr = [];
  8465. var sameScaleMaxYArr = [];
  8466. minYArr.forEach(function (minYValue, yi) {
  8467. indices.forEach(function (scale, i) {
  8468. // we compare only the yIndex which exists in the indices array
  8469. if (scale.indexOf(yi) > -1) {
  8470. if (typeof sameScaleMinYArr[i] === 'undefined') {
  8471. sameScaleMinYArr[i] = [];
  8472. sameScaleMaxYArr[i] = [];
  8473. }
  8474. sameScaleMinYArr[i].push({
  8475. key: yi,
  8476. value: minYValue
  8477. });
  8478. sameScaleMaxYArr[i].push({
  8479. key: yi,
  8480. value: maxYArr[yi]
  8481. });
  8482. }
  8483. });
  8484. });
  8485. var sameScaleMin = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, Number.MIN_VALUE);
  8486. var sameScaleMax = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, -Number.MAX_VALUE);
  8487. sameScaleMinYArr.forEach(function (s, i) {
  8488. s.forEach(function (sc, j) {
  8489. sameScaleMin[i] = Math.min(sc.value, sameScaleMin[i]);
  8490. });
  8491. });
  8492. sameScaleMaxYArr.forEach(function (s, i) {
  8493. s.forEach(function (sc, j) {
  8494. sameScaleMax[i] = Math.max(sc.value, sameScaleMax[i]);
  8495. });
  8496. });
  8497. minYArr.forEach(function (min, i) {
  8498. sameScaleMaxYArr.forEach(function (s, si) {
  8499. var minY = sameScaleMin[si];
  8500. var maxY = sameScaleMax[si];
  8501. if (cnf.chart.stacked) {
  8502. // for stacked charts, we need to add the values
  8503. maxY = 0;
  8504. s.forEach(function (ind, k) {
  8505. // fix incorrectly adjust y scale issue #1215
  8506. if (ind.value !== -Number.MAX_VALUE) {
  8507. maxY += ind.value;
  8508. }
  8509. if (minY !== Number.MIN_VALUE) {
  8510. minY += sameScaleMinYArr[si][k].value;
  8511. }
  8512. });
  8513. }
  8514. s.forEach(function (ind, k) {
  8515. if (s[k].key === i) {
  8516. if (cnf.yaxis[i].min !== undefined) {
  8517. if (typeof cnf.yaxis[i].min === 'function') {
  8518. minY = cnf.yaxis[i].min(gl.minY);
  8519. } else {
  8520. minY = cnf.yaxis[i].min;
  8521. }
  8522. }
  8523. if (cnf.yaxis[i].max !== undefined) {
  8524. if (typeof cnf.yaxis[i].max === 'function') {
  8525. maxY = cnf.yaxis[i].max(gl.maxY);
  8526. } else {
  8527. maxY = cnf.yaxis[i].max;
  8528. }
  8529. }
  8530. _this2.setYScaleForIndex(i, minY, maxY);
  8531. }
  8532. });
  8533. });
  8534. });
  8535. } // experimental feature which scales the y-axis to a min/max based on x-axis range
  8536. }, {
  8537. key: "autoScaleY",
  8538. value: function autoScaleY(ctx, yaxis, e) {
  8539. if (!ctx) {
  8540. ctx = this;
  8541. }
  8542. var w = ctx.w;
  8543. if (w.globals.isMultipleYAxis || w.globals.collapsedSeries.length) {
  8544. // The autoScale option for multiple y-axis is turned off as it leads to buggy behavior.
  8545. // Also, when a series is collapsed, it results in incorrect behavior. Hence turned it off for that too - fixes apexcharts.js#795
  8546. console.warn('autoScaleYaxis is not supported in a multi-yaxis chart.');
  8547. return yaxis;
  8548. }
  8549. var seriesX = w.globals.seriesX[0];
  8550. var isStacked = w.config.chart.stacked;
  8551. yaxis.forEach(function (yaxe, yi) {
  8552. var firstXIndex = 0;
  8553. for (var xi = 0; xi < seriesX.length; xi++) {
  8554. if (seriesX[xi] >= e.xaxis.min) {
  8555. firstXIndex = xi;
  8556. break;
  8557. }
  8558. }
  8559. var initialMin = w.globals.minYArr[yi];
  8560. var initialMax = w.globals.maxYArr[yi];
  8561. var min, max;
  8562. var stackedSer = w.globals.stackedSeriesTotals;
  8563. w.globals.series.forEach(function (serie, sI) {
  8564. var firstValue = serie[firstXIndex];
  8565. if (isStacked) {
  8566. firstValue = stackedSer[firstXIndex];
  8567. min = max = firstValue;
  8568. stackedSer.forEach(function (y, yI) {
  8569. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  8570. if (y > max && y !== null) max = y;
  8571. if (serie[yI] < min && serie[yI] !== null) min = serie[yI];
  8572. }
  8573. });
  8574. } else {
  8575. min = max = firstValue;
  8576. serie.forEach(function (y, yI) {
  8577. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  8578. var valMin = y;
  8579. var valMax = y;
  8580. w.globals.series.forEach(function (wS, wSI) {
  8581. if (y !== null) {
  8582. valMin = Math.min(wS[yI], valMin);
  8583. valMax = Math.max(wS[yI], valMax);
  8584. }
  8585. });
  8586. if (valMax > max && valMax !== null) max = valMax;
  8587. if (valMin < min && valMin !== null) min = valMin;
  8588. }
  8589. });
  8590. }
  8591. if (min === undefined && max === undefined) {
  8592. min = initialMin;
  8593. max = initialMax;
  8594. }
  8595. min *= min < 0 ? 1.1 : 0.9;
  8596. max *= max < 0 ? 0.9 : 1.1;
  8597. if (max < 0 && max < initialMax) {
  8598. max = initialMax;
  8599. }
  8600. if (min < 0 && min > initialMin) {
  8601. min = initialMin;
  8602. }
  8603. if (yaxis.length > 1) {
  8604. yaxis[sI].min = yaxe.min === undefined ? min : yaxe.min;
  8605. yaxis[sI].max = yaxe.max === undefined ? max : yaxe.max;
  8606. } else {
  8607. yaxis[0].min = yaxe.min === undefined ? min : yaxe.min;
  8608. yaxis[0].max = yaxe.max === undefined ? max : yaxe.max;
  8609. }
  8610. });
  8611. });
  8612. return yaxis;
  8613. }
  8614. }]);
  8615. return Range;
  8616. }();
  8617. /**
  8618. * Range is used to generates values between min and max.
  8619. *
  8620. * @module Range
  8621. **/
  8622. var Range$1 = /*#__PURE__*/function () {
  8623. function Range$1(ctx) {
  8624. _classCallCheck(this, Range$1);
  8625. this.ctx = ctx;
  8626. this.w = ctx.w;
  8627. this.scales = new Range(ctx);
  8628. }
  8629. _createClass(Range$1, [{
  8630. key: "init",
  8631. value: function init() {
  8632. this.setYRange();
  8633. this.setXRange();
  8634. this.setZRange();
  8635. }
  8636. }, {
  8637. key: "getMinYMaxY",
  8638. value: function getMinYMaxY(startingIndex) {
  8639. var lowestY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  8640. var highestY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -Number.MAX_VALUE;
  8641. var len = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  8642. var cnf = this.w.config;
  8643. var gl = this.w.globals;
  8644. var maxY = -Number.MAX_VALUE;
  8645. var minY = Number.MIN_VALUE;
  8646. if (len === null) {
  8647. len = startingIndex + 1;
  8648. }
  8649. var series = gl.series;
  8650. var seriesMin = series;
  8651. var seriesMax = series;
  8652. if (cnf.chart.type === 'candlestick') {
  8653. seriesMin = gl.seriesCandleL;
  8654. seriesMax = gl.seriesCandleH;
  8655. } else if (gl.isRangeData) {
  8656. seriesMin = gl.seriesRangeStart;
  8657. seriesMax = gl.seriesRangeEnd;
  8658. }
  8659. for (var i = startingIndex; i < len; i++) {
  8660. gl.dataPoints = Math.max(gl.dataPoints, series[i].length);
  8661. for (var j = 0; j < gl.series[i].length; j++) {
  8662. var val = series[i][j];
  8663. if (val !== null && Utils.isNumber(val)) {
  8664. maxY = Math.max(maxY, seriesMax[i][j]);
  8665. lowestY = Math.min(lowestY, seriesMin[i][j]);
  8666. highestY = Math.max(highestY, seriesMin[i][j]);
  8667. if (this.w.config.chart.type === 'candlestick') {
  8668. maxY = Math.max(maxY, gl.seriesCandleO[i][j]);
  8669. maxY = Math.max(maxY, gl.seriesCandleH[i][j]);
  8670. maxY = Math.max(maxY, gl.seriesCandleL[i][j]);
  8671. maxY = Math.max(maxY, gl.seriesCandleC[i][j]);
  8672. highestY = maxY;
  8673. }
  8674. if (Utils.isFloat(val)) {
  8675. val = Utils.noExponents(val);
  8676. gl.yValueDecimal = Math.max(gl.yValueDecimal, val.toString().split('.')[1].length);
  8677. }
  8678. if (minY > seriesMin[i][j] && seriesMin[i][j] < 0) {
  8679. minY = seriesMin[i][j];
  8680. }
  8681. } else {
  8682. gl.hasNullValues = true;
  8683. }
  8684. }
  8685. }
  8686. if (cnf.chart.type === 'rangeBar' && gl.seriesRangeStart.length && cnf.xaxis.type === 'datetime') {
  8687. minY = lowestY;
  8688. }
  8689. if (cnf.chart.type === 'bar') {
  8690. if (minY < 0 && maxY < 0) {
  8691. // all negative values in a bar chart, hence make the max to 0
  8692. maxY = 0;
  8693. }
  8694. if (minY === Number.MIN_VALUE) {
  8695. minY = 0;
  8696. }
  8697. }
  8698. return {
  8699. minY: minY,
  8700. maxY: maxY,
  8701. lowestY: lowestY,
  8702. highestY: highestY
  8703. };
  8704. }
  8705. }, {
  8706. key: "setYRange",
  8707. value: function setYRange() {
  8708. var gl = this.w.globals;
  8709. var cnf = this.w.config;
  8710. gl.maxY = -Number.MAX_VALUE;
  8711. gl.minY = Number.MIN_VALUE;
  8712. var lowestYInAllSeries = Number.MAX_VALUE;
  8713. if (gl.isMultipleYAxis) {
  8714. // we need to get minY and maxY for multiple y axis
  8715. for (var i = 0; i < gl.series.length; i++) {
  8716. var minYMaxYArr = this.getMinYMaxY(i, lowestYInAllSeries, null, i + 1);
  8717. gl.minYArr.push(minYMaxYArr.minY);
  8718. gl.maxYArr.push(minYMaxYArr.maxY);
  8719. lowestYInAllSeries = minYMaxYArr.lowestY;
  8720. }
  8721. } // and then, get the minY and maxY from all series
  8722. var minYMaxY = this.getMinYMaxY(0, lowestYInAllSeries, null, gl.series.length);
  8723. gl.minY = minYMaxY.minY;
  8724. gl.maxY = minYMaxY.maxY;
  8725. lowestYInAllSeries = minYMaxY.lowestY;
  8726. if (cnf.chart.stacked) {
  8727. this._setStackedMinMax();
  8728. } // if the numbers are too big, reduce the range
  8729. // for eg, if number is between 100000-110000, putting 0 as the lowest value is not so good idea. So change the gl.minY for line/area/candlesticks
  8730. if (cnf.chart.type === 'line' || cnf.chart.type === 'area' || cnf.chart.type === 'candlestick') {
  8731. if (gl.minY === Number.MIN_VALUE && lowestYInAllSeries !== -Number.MAX_VALUE && lowestYInAllSeries !== gl.maxY // single value possibility
  8732. ) {
  8733. var diff = gl.maxY - lowestYInAllSeries;
  8734. if (lowestYInAllSeries >= 0 && lowestYInAllSeries <= 10) {
  8735. // if minY is already 0/low value, we don't want to go negatives here - so this check is essential.
  8736. diff = 0;
  8737. }
  8738. gl.minY = lowestYInAllSeries - diff * 5 / 100;
  8739. /* fix https://github.com/apexcharts/apexcharts.js/issues/614 */
  8740. /* fix https://github.com/apexcharts/apexcharts.js/issues/968 */
  8741. if (lowestYInAllSeries > 0 && gl.minY < 0) {
  8742. gl.minY = 0;
  8743. }
  8744. /* fix https://github.com/apexcharts/apexcharts.js/issues/426 */
  8745. gl.maxY = gl.maxY + diff * 5 / 100;
  8746. }
  8747. }
  8748. cnf.yaxis.forEach(function (yaxe, index) {
  8749. // override all min/max values by user defined values (y axis)
  8750. if (yaxe.max !== undefined) {
  8751. if (typeof yaxe.max === 'number') {
  8752. gl.maxYArr[index] = yaxe.max;
  8753. } else if (typeof yaxe.max === 'function') {
  8754. gl.maxYArr[index] = yaxe.max(gl.maxY);
  8755. } // gl.maxY is for single y-axis chart, it will be ignored in multi-yaxis
  8756. gl.maxY = gl.maxYArr[index];
  8757. }
  8758. if (yaxe.min !== undefined) {
  8759. if (typeof yaxe.min === 'number') {
  8760. gl.minYArr[index] = yaxe.min;
  8761. } else if (typeof yaxe.min === 'function') {
  8762. gl.minYArr[index] = yaxe.min(gl.minY);
  8763. } // gl.minY is for single y-axis chart, it will be ignored in multi-yaxis
  8764. gl.minY = gl.minYArr[index];
  8765. }
  8766. }); // for horizontal bar charts, we need to check xaxis min/max as user may have specified there
  8767. if (gl.isBarHorizontal) {
  8768. var minmax = ['min', 'max'];
  8769. minmax.forEach(function (m) {
  8770. if (cnf.xaxis[m] !== undefined && typeof cnf.xaxis[m] === 'number') {
  8771. m === 'min' ? gl.minY = cnf.xaxis[m] : gl.maxY = cnf.xaxis[m];
  8772. }
  8773. });
  8774. } // for multi y-axis we need different scales for each
  8775. if (gl.isMultipleYAxis) {
  8776. this.scales.setMultipleYScales();
  8777. gl.minY = lowestYInAllSeries;
  8778. gl.yAxisScale.forEach(function (scale, i) {
  8779. gl.minYArr[i] = scale.niceMin;
  8780. gl.maxYArr[i] = scale.niceMax;
  8781. });
  8782. } else {
  8783. this.scales.setYScaleForIndex(0, gl.minY, gl.maxY);
  8784. gl.minY = gl.yAxisScale[0].niceMin;
  8785. gl.maxY = gl.yAxisScale[0].niceMax;
  8786. gl.minYArr[0] = gl.yAxisScale[0].niceMin;
  8787. gl.maxYArr[0] = gl.yAxisScale[0].niceMax;
  8788. }
  8789. return {
  8790. minY: gl.minY,
  8791. maxY: gl.maxY,
  8792. minYArr: gl.minYArr,
  8793. maxYArr: gl.maxYArr
  8794. };
  8795. }
  8796. }, {
  8797. key: "setXRange",
  8798. value: function setXRange() {
  8799. var gl = this.w.globals;
  8800. var cnf = this.w.config;
  8801. var isXNumeric = cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'datetime' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided || gl.noLabelsProvided || gl.isXNumeric;
  8802. var getInitialMinXMaxX = function getInitialMinXMaxX() {
  8803. for (var i = 0; i < gl.series.length; i++) {
  8804. if (gl.labels[i]) {
  8805. for (var j = 0; j < gl.labels[i].length; j++) {
  8806. if (gl.labels[i][j] !== null && Utils.isNumber(gl.labels[i][j])) {
  8807. gl.maxX = Math.max(gl.maxX, gl.labels[i][j]);
  8808. gl.initialMaxX = Math.max(gl.maxX, gl.labels[i][j]);
  8809. gl.minX = Math.min(gl.minX, gl.labels[i][j]);
  8810. gl.initialMinX = Math.min(gl.minX, gl.labels[i][j]);
  8811. }
  8812. }
  8813. }
  8814. }
  8815. }; // minX maxX starts here
  8816. if (gl.isXNumeric) {
  8817. getInitialMinXMaxX();
  8818. }
  8819. if (gl.noLabelsProvided) {
  8820. if (cnf.xaxis.categories.length === 0) {
  8821. gl.maxX = gl.labels[gl.labels.length - 1];
  8822. gl.initialMaxX = gl.labels[gl.labels.length - 1];
  8823. gl.minX = 1;
  8824. gl.initialMinX = 1;
  8825. }
  8826. }
  8827. if (gl.isXNumeric || gl.noLabelsProvided || gl.dataFormatXNumeric) {
  8828. var ticks;
  8829. if (cnf.xaxis.tickAmount === undefined) {
  8830. ticks = Math.round(gl.svgWidth / 150); // no labels provided and total number of dataPoints is less than 30
  8831. if (cnf.xaxis.type === 'numeric' && gl.dataPoints < 30) {
  8832. ticks = gl.dataPoints - 1;
  8833. } // this check is for when ticks exceeds total datapoints and that would result in duplicate labels
  8834. if (ticks > gl.dataPoints && gl.dataPoints !== 0) {
  8835. ticks = gl.dataPoints - 1;
  8836. }
  8837. } else if (cnf.xaxis.tickAmount === 'dataPoints') {
  8838. if (gl.series.length > 1) {
  8839. ticks = gl.series[gl.maxValsInArrayIndex].length - 1;
  8840. }
  8841. if (gl.isXNumeric) {
  8842. ticks = gl.maxX - gl.minX - 1;
  8843. }
  8844. } else {
  8845. ticks = cnf.xaxis.tickAmount;
  8846. }
  8847. gl.xTickAmount = ticks; // override all min/max values by user defined values (x axis)
  8848. if (cnf.xaxis.max !== undefined && typeof cnf.xaxis.max === 'number') {
  8849. gl.maxX = cnf.xaxis.max;
  8850. }
  8851. if (cnf.xaxis.min !== undefined && typeof cnf.xaxis.min === 'number') {
  8852. gl.minX = cnf.xaxis.min;
  8853. } // if range is provided, adjust the new minX
  8854. if (cnf.xaxis.range !== undefined) {
  8855. gl.minX = gl.maxX - cnf.xaxis.range;
  8856. }
  8857. if (gl.minX !== Number.MAX_VALUE && gl.maxX !== -Number.MAX_VALUE) {
  8858. if (cnf.xaxis.convertedCatToNumeric && !gl.dataFormatXNumeric) {
  8859. var catScale = [];
  8860. for (var i = gl.minX - 1; i < gl.maxX; i++) {
  8861. catScale.push(i + 1);
  8862. }
  8863. gl.xAxisScale = {
  8864. result: catScale,
  8865. niceMin: catScale[0],
  8866. niceMax: catScale[catScale.length - 1]
  8867. };
  8868. } else {
  8869. gl.xAxisScale = this.scales.setXScale(gl.minX, gl.maxX);
  8870. }
  8871. } else {
  8872. gl.xAxisScale = this.scales.linearScale(1, ticks, ticks);
  8873. if (gl.noLabelsProvided && gl.labels.length > 0) {
  8874. gl.xAxisScale = this.scales.linearScale(1, gl.labels.length, ticks - 1); // this is the only place seriesX is again mutated
  8875. gl.seriesX = gl.labels.slice();
  8876. }
  8877. } // we will still store these labels as the count for this will be different (to draw grid and labels placement)
  8878. if (isXNumeric) {
  8879. gl.labels = gl.xAxisScale.result.slice();
  8880. }
  8881. }
  8882. if (gl.isBarHorizontal && gl.labels.length) {
  8883. gl.xTickAmount = gl.labels.length;
  8884. } // single dataPoint
  8885. this._handleSingleDataPoint(); // minimum x difference to calculate bar width in numeric bars
  8886. this._getMinXDiff();
  8887. return {
  8888. minX: gl.minX,
  8889. maxX: gl.maxX
  8890. };
  8891. }
  8892. }, {
  8893. key: "setZRange",
  8894. value: function setZRange() {
  8895. // minZ, maxZ starts here
  8896. var gl = this.w.globals;
  8897. if (!gl.isDataXYZ) return;
  8898. for (var i = 0; i < gl.series.length; i++) {
  8899. if (typeof gl.seriesZ[i] !== 'undefined') {
  8900. for (var j = 0; j < gl.seriesZ[i].length; j++) {
  8901. if (gl.seriesZ[i][j] !== null && Utils.isNumber(gl.seriesZ[i][j])) {
  8902. gl.maxZ = Math.max(gl.maxZ, gl.seriesZ[i][j]);
  8903. gl.minZ = Math.min(gl.minZ, gl.seriesZ[i][j]);
  8904. }
  8905. }
  8906. }
  8907. }
  8908. }
  8909. }, {
  8910. key: "_handleSingleDataPoint",
  8911. value: function _handleSingleDataPoint() {
  8912. var gl = this.w.globals;
  8913. var cnf = this.w.config;
  8914. if (gl.minX === gl.maxX) {
  8915. var datetimeObj = new DateTime(this.ctx);
  8916. if (cnf.xaxis.type === 'datetime') {
  8917. var newMinX = datetimeObj.getDate(gl.minX);
  8918. newMinX.setUTCDate(newMinX.getDate() - 2);
  8919. gl.minX = new Date(newMinX).getTime();
  8920. var newMaxX = datetimeObj.getDate(gl.maxX);
  8921. newMaxX.setUTCDate(newMaxX.getDate() + 2);
  8922. gl.maxX = new Date(newMaxX).getTime();
  8923. } else if (cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided) {
  8924. gl.minX = gl.minX - 2;
  8925. gl.initialMinX = gl.minX;
  8926. gl.maxX = gl.maxX + 2;
  8927. gl.initialMaxX = gl.maxX;
  8928. }
  8929. }
  8930. }
  8931. }, {
  8932. key: "_getMinXDiff",
  8933. value: function _getMinXDiff() {
  8934. var gl = this.w.globals;
  8935. if (gl.isXNumeric) {
  8936. // get the least x diff if numeric x axis is present
  8937. gl.seriesX.forEach(function (sX, i) {
  8938. if (sX.length === 1) {
  8939. // a small hack to prevent overlapping multiple bars when there is just 1 datapoint in bar series.
  8940. // fix #811
  8941. sX.push(gl.seriesX[gl.maxValsInArrayIndex][gl.seriesX[gl.maxValsInArrayIndex].length - 1]);
  8942. } // fix #983 (clone the array to avoid side effects)
  8943. var seriesX = sX.slice();
  8944. seriesX.sort(function (a, b) {
  8945. return a - b;
  8946. });
  8947. seriesX.forEach(function (s, j) {
  8948. if (j > 0) {
  8949. var xDiff = s - gl.seriesX[i][j - 1];
  8950. if (xDiff > 0) {
  8951. gl.minXDiff = Math.min(xDiff, gl.minXDiff);
  8952. }
  8953. }
  8954. });
  8955. if (gl.dataPoints === 1 && gl.minXDiff === Number.MAX_VALUE) {
  8956. gl.minXDiff = 0.5;
  8957. }
  8958. });
  8959. }
  8960. }
  8961. }, {
  8962. key: "_setStackedMinMax",
  8963. value: function _setStackedMinMax() {
  8964. var gl = this.w.globals; // for stacked charts, we calculate each series's parallel values. i.e, series[0][j] + series[1][j] .... [series[i.length][j]] and get the max out of it
  8965. var stackedPoss = [];
  8966. var stackedNegs = [];
  8967. if (gl.series.length) {
  8968. for (var j = 0; j < gl.series[gl.maxValsInArrayIndex].length; j++) {
  8969. var poss = 0;
  8970. var negs = 0;
  8971. for (var i = 0; i < gl.series.length; i++) {
  8972. if (gl.series[i][j] !== null && Utils.isNumber(gl.series[i][j])) {
  8973. // 0.0001 fixes #185 when values are very small
  8974. gl.series[i][j] > 0 ? poss = poss + parseFloat(gl.series[i][j]) + 0.0001 : negs = negs + parseFloat(gl.series[i][j]);
  8975. }
  8976. if (i === gl.series.length - 1) {
  8977. // push all the totals to the array for future use
  8978. stackedPoss.push(poss);
  8979. stackedNegs.push(negs);
  8980. }
  8981. }
  8982. }
  8983. } // get the max/min out of the added parallel values
  8984. for (var z = 0; z < stackedPoss.length; z++) {
  8985. gl.maxY = Math.max(gl.maxY, stackedPoss[z]);
  8986. gl.minY = Math.min(gl.minY, stackedNegs[z]);
  8987. }
  8988. }
  8989. }]);
  8990. return Range$1;
  8991. }();
  8992. /**
  8993. * ApexCharts YAxis Class for drawing Y-Axis.
  8994. *
  8995. * @module YAxis
  8996. **/
  8997. var YAxis = /*#__PURE__*/function () {
  8998. function YAxis(ctx) {
  8999. _classCallCheck(this, YAxis);
  9000. this.ctx = ctx;
  9001. this.w = ctx.w;
  9002. var w = this.w;
  9003. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  9004. this.axisFontFamily = w.config.xaxis.labels.style.fontFamily;
  9005. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  9006. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  9007. this.xAxisoffX = 0;
  9008. if (w.config.xaxis.position === 'bottom') {
  9009. this.xAxisoffX = w.globals.gridHeight;
  9010. }
  9011. this.drawnLabels = [];
  9012. this.axesUtils = new AxesUtils(ctx);
  9013. }
  9014. _createClass(YAxis, [{
  9015. key: "drawYaxis",
  9016. value: function drawYaxis(realIndex) {
  9017. var w = this.w;
  9018. var graphics = new Graphics(this.ctx);
  9019. var yaxisStyle = w.config.yaxis[realIndex].labels.style;
  9020. var yaxisFontSize = yaxisStyle.fontSize;
  9021. var yaxisFontFamily = yaxisStyle.fontFamily;
  9022. var yaxisFontWeight = yaxisStyle.fontWeight;
  9023. var elYaxis = graphics.group({
  9024. class: 'apexcharts-yaxis',
  9025. rel: realIndex,
  9026. transform: 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)'
  9027. });
  9028. if (this.axesUtils.isYAxisHidden(realIndex)) {
  9029. return elYaxis;
  9030. }
  9031. var elYaxisTexts = graphics.group({
  9032. class: 'apexcharts-yaxis-texts-g'
  9033. });
  9034. elYaxis.add(elYaxisTexts);
  9035. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg height/number of ticks
  9036. var labelsDivider = w.globals.gridHeight / tickAmount; // initial label position = 0;
  9037. var l = w.globals.translateY;
  9038. var lbFormatter = w.globals.yLabelFormatters[realIndex];
  9039. var labels = w.globals.yAxisScale[realIndex].result.slice();
  9040. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  9041. var firstLabel = '';
  9042. if (w.config.yaxis[realIndex].labels.show) {
  9043. var _loop = function _loop(i) {
  9044. var val = labels[i];
  9045. val = lbFormatter(val, i);
  9046. var xPad = w.config.yaxis[realIndex].labels.padding;
  9047. if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
  9048. xPad = xPad * -1;
  9049. }
  9050. var getForeColor = function getForeColor() {
  9051. return Array.isArray(yaxisStyle.colors) ? yaxisStyle.colors[i] : yaxisStyle.colors;
  9052. };
  9053. var label = graphics.drawText({
  9054. x: xPad,
  9055. y: l + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY + 1,
  9056. text: val,
  9057. textAnchor: w.config.yaxis[realIndex].opposite ? 'start' : 'end',
  9058. fontSize: yaxisFontSize,
  9059. fontFamily: yaxisFontFamily,
  9060. fontWeight: yaxisFontWeight,
  9061. foreColor: getForeColor(),
  9062. isPlainText: false,
  9063. cssClass: 'apexcharts-yaxis-label ' + yaxisStyle.cssClass
  9064. });
  9065. if (i === tickAmount) {
  9066. firstLabel = label;
  9067. }
  9068. elYaxisTexts.add(label);
  9069. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  9070. var firstabelRotatingCenter = graphics.rotateAroundCenter(firstLabel.node);
  9071. var labelRotatingCenter = graphics.rotateAroundCenter(label.node);
  9072. label.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " ").concat(firstabelRotatingCenter.x, " ").concat(labelRotatingCenter.y, ")"));
  9073. }
  9074. l = l + labelsDivider;
  9075. };
  9076. for (var i = tickAmount; i >= 0; i--) {
  9077. _loop(i);
  9078. }
  9079. }
  9080. if (w.config.yaxis[realIndex].title.text !== undefined) {
  9081. var elYaxisTitle = graphics.group({
  9082. class: 'apexcharts-yaxis-title'
  9083. });
  9084. var _x = 0;
  9085. if (w.config.yaxis[realIndex].opposite) {
  9086. _x = w.globals.translateYAxisX[realIndex];
  9087. }
  9088. var elYAxisTitleText = graphics.drawText({
  9089. x: _x,
  9090. y: w.globals.gridHeight / 2 + w.globals.translateY + w.config.yaxis[realIndex].title.offsetY,
  9091. text: w.config.yaxis[realIndex].title.text,
  9092. textAnchor: 'end',
  9093. foreColor: w.config.yaxis[realIndex].title.style.color,
  9094. fontSize: w.config.yaxis[realIndex].title.style.fontSize,
  9095. fontWeight: w.config.yaxis[realIndex].title.style.fontWeight,
  9096. fontFamily: w.config.yaxis[realIndex].title.style.fontFamily,
  9097. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[realIndex].title.style.cssClass
  9098. });
  9099. elYaxisTitle.add(elYAxisTitleText);
  9100. elYaxis.add(elYaxisTitle);
  9101. }
  9102. var axisBorder = w.config.yaxis[realIndex].axisBorder;
  9103. var x = 31 + axisBorder.offsetX;
  9104. if (w.config.yaxis[realIndex].opposite) {
  9105. x = -31 - axisBorder.offsetX;
  9106. }
  9107. if (axisBorder.show) {
  9108. 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);
  9109. elYaxis.add(elVerticalLine);
  9110. }
  9111. if (w.config.yaxis[realIndex].axisTicks.show) {
  9112. this.axesUtils.drawYAxisTicks(x, tickAmount, axisBorder, w.config.yaxis[realIndex].axisTicks, realIndex, labelsDivider, elYaxis);
  9113. }
  9114. return elYaxis;
  9115. } // This actually becomes horizonal axis (for bar charts)
  9116. }, {
  9117. key: "drawYaxisInversed",
  9118. value: function drawYaxisInversed(realIndex) {
  9119. var w = this.w;
  9120. var graphics = new Graphics(this.ctx);
  9121. var elXaxis = graphics.group({
  9122. class: 'apexcharts-xaxis apexcharts-yaxis-inversed'
  9123. });
  9124. var elXaxisTexts = graphics.group({
  9125. class: 'apexcharts-xaxis-texts-g',
  9126. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  9127. });
  9128. elXaxis.add(elXaxisTexts);
  9129. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg width/number of ticks
  9130. var labelsDivider = w.globals.gridWidth / tickAmount + 0.1; // initial label position;
  9131. var l = labelsDivider + w.config.xaxis.labels.offsetX;
  9132. var lbFormatter = w.globals.xLabelFormatter;
  9133. var labels = w.globals.yAxisScale[realIndex].result.slice();
  9134. var timescaleLabels = w.globals.timescaleLabels;
  9135. if (timescaleLabels.length > 0) {
  9136. this.xaxisLabels = timescaleLabels.slice();
  9137. labels = timescaleLabels.slice();
  9138. tickAmount = labels.length;
  9139. }
  9140. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  9141. var tl = timescaleLabels.length;
  9142. if (w.config.xaxis.labels.show) {
  9143. for (var i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
  9144. var val = labels[i];
  9145. val = lbFormatter(val, i);
  9146. var x = w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX);
  9147. if (timescaleLabels.length) {
  9148. var label = this.axesUtils.getLabel(labels, timescaleLabels, x, i, this.drawnLabels, this.xaxisFontSize);
  9149. x = label.x;
  9150. val = label.text;
  9151. this.drawnLabels.push(label.text);
  9152. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  9153. val = '';
  9154. }
  9155. if (i === labels.length - 1 && w.globals.skipLastTimelinelabel) {
  9156. val = '';
  9157. }
  9158. }
  9159. var elTick = graphics.drawText({
  9160. x: x,
  9161. y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30 - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  9162. text: val,
  9163. textAnchor: 'middle',
  9164. foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors,
  9165. fontSize: this.xaxisFontSize,
  9166. fontFamily: this.xaxisFontFamily,
  9167. fontWeight: w.config.xaxis.labels.style.fontWeight,
  9168. isPlainText: false,
  9169. cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
  9170. });
  9171. elXaxisTexts.add(elTick);
  9172. elTick.tspan(val);
  9173. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  9174. elTooltipTitle.textContent = val;
  9175. elTick.node.appendChild(elTooltipTitle);
  9176. l = l + labelsDivider;
  9177. }
  9178. }
  9179. this.inversedYAxisTitleText(elXaxis);
  9180. this.inversedYAxisBorder(elXaxis);
  9181. return elXaxis;
  9182. }
  9183. }, {
  9184. key: "inversedYAxisBorder",
  9185. value: function inversedYAxisBorder(parent) {
  9186. var w = this.w;
  9187. var graphics = new Graphics(this.ctx);
  9188. var axisBorder = w.config.xaxis.axisBorder;
  9189. if (axisBorder.show) {
  9190. var lineCorrection = 0;
  9191. if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
  9192. lineCorrection = lineCorrection - 15;
  9193. }
  9194. var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + axisBorder.offsetX, this.xAxisoffX, w.globals.gridWidth, this.xAxisoffX, axisBorder.color, 0, axisBorder.height);
  9195. parent.add(elHorzLine);
  9196. }
  9197. }
  9198. }, {
  9199. key: "inversedYAxisTitleText",
  9200. value: function inversedYAxisTitleText(parent) {
  9201. var w = this.w;
  9202. var graphics = new Graphics(this.ctx);
  9203. if (w.config.xaxis.title.text !== undefined) {
  9204. var elYaxisTitle = graphics.group({
  9205. class: 'apexcharts-xaxis-title apexcharts-yaxis-title-inversed'
  9206. });
  9207. var elYAxisTitleText = graphics.drawText({
  9208. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  9209. y: this.xAxisoffX + parseFloat(this.xaxisFontSize) + parseFloat(w.config.xaxis.title.style.fontSize) + w.config.xaxis.title.offsetY + 20,
  9210. text: w.config.xaxis.title.text,
  9211. textAnchor: 'middle',
  9212. fontSize: w.config.xaxis.title.style.fontSize,
  9213. fontFamily: w.config.xaxis.title.style.fontFamily,
  9214. fontWeight: w.config.xaxis.title.style.fontWeight,
  9215. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  9216. });
  9217. elYaxisTitle.add(elYAxisTitleText);
  9218. parent.add(elYaxisTitle);
  9219. }
  9220. }
  9221. }, {
  9222. key: "yAxisTitleRotate",
  9223. value: function yAxisTitleRotate(realIndex, yAxisOpposite) {
  9224. var w = this.w;
  9225. var graphics = new Graphics(this.ctx);
  9226. var yAxisLabelsCoord = {
  9227. width: 0,
  9228. height: 0
  9229. };
  9230. var yAxisTitleCoord = {
  9231. width: 0,
  9232. height: 0
  9233. };
  9234. var elYAxisLabelsWrap = w.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-texts-g"));
  9235. if (elYAxisLabelsWrap !== null) {
  9236. yAxisLabelsCoord = elYAxisLabelsWrap.getBoundingClientRect();
  9237. }
  9238. var yAxisTitle = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-title text"));
  9239. if (yAxisTitle !== null) {
  9240. yAxisTitleCoord = yAxisTitle.getBoundingClientRect();
  9241. }
  9242. if (yAxisTitle !== null) {
  9243. var x = this.xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite);
  9244. yAxisTitle.setAttribute('x', x.xPos - (yAxisOpposite ? 10 : 0));
  9245. }
  9246. if (yAxisTitle !== null) {
  9247. var titleRotatingCenter = graphics.rotateAroundCenter(yAxisTitle);
  9248. yAxisTitle.setAttribute('transform', "rotate(".concat(yAxisOpposite ? '' : '-').concat(w.config.yaxis[realIndex].title.rotate, " ").concat(titleRotatingCenter.x, " ").concat(titleRotatingCenter.y, ")"));
  9249. }
  9250. }
  9251. }, {
  9252. key: "xPaddingForYAxisTitle",
  9253. value: function xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite) {
  9254. var w = this.w;
  9255. var oppositeAxisCount = 0;
  9256. var x = 0;
  9257. var padd = 10;
  9258. if (w.config.yaxis[realIndex].title.text === undefined || realIndex < 0) {
  9259. return {
  9260. xPos: x,
  9261. padd: 0
  9262. };
  9263. }
  9264. if (yAxisOpposite) {
  9265. x = yAxisLabelsCoord.width + w.config.yaxis[realIndex].title.offsetX + yAxisTitleCoord.width / 2 + padd / 2;
  9266. oppositeAxisCount += 1;
  9267. if (oppositeAxisCount === 0) {
  9268. x = x - padd / 2;
  9269. }
  9270. } else {
  9271. x = yAxisLabelsCoord.width * -1 + w.config.yaxis[realIndex].title.offsetX + padd / 2 + yAxisTitleCoord.width / 2;
  9272. if (w.globals.isBarHorizontal) {
  9273. padd = 25;
  9274. x = yAxisLabelsCoord.width * -1 - w.config.yaxis[realIndex].title.offsetX - padd;
  9275. }
  9276. }
  9277. return {
  9278. xPos: x,
  9279. padd: padd
  9280. };
  9281. } // sets the x position of the y-axis by counting the labels width, title width and any offset
  9282. }, {
  9283. key: "setYAxisXPosition",
  9284. value: function setYAxisXPosition(yaxisLabelCoords, yTitleCoords) {
  9285. var w = this.w;
  9286. var xLeft = 0;
  9287. var xRight = 0;
  9288. var leftOffsetX = 18;
  9289. var rightOffsetX = 1;
  9290. if (w.config.yaxis.length > 1) {
  9291. this.multipleYs = true;
  9292. }
  9293. w.config.yaxis.map(function (yaxe, index) {
  9294. var shouldNotDrawAxis = w.globals.ignoreYAxisIndexes.indexOf(index) > -1 || !yaxe.show || yaxe.floating || yaxisLabelCoords[index].width === 0;
  9295. var axisWidth = yaxisLabelCoords[index].width + yTitleCoords[index].width;
  9296. if (!yaxe.opposite) {
  9297. xLeft = w.globals.translateX - leftOffsetX;
  9298. if (!shouldNotDrawAxis) {
  9299. leftOffsetX = leftOffsetX + axisWidth + 20;
  9300. }
  9301. w.globals.translateYAxisX[index] = xLeft + yaxe.labels.offsetX;
  9302. } else {
  9303. if (w.globals.isBarHorizontal) {
  9304. xRight = w.globals.gridWidth + w.globals.translateX - 1;
  9305. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX;
  9306. } else {
  9307. xRight = w.globals.gridWidth + w.globals.translateX + rightOffsetX;
  9308. if (!shouldNotDrawAxis) {
  9309. rightOffsetX = rightOffsetX + axisWidth + 20;
  9310. }
  9311. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX + 20;
  9312. }
  9313. }
  9314. });
  9315. }
  9316. }, {
  9317. key: "setYAxisTextAlignments",
  9318. value: function setYAxisTextAlignments() {
  9319. var w = this.w;
  9320. var yaxis = w.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");
  9321. yaxis = Utils.listToArray(yaxis);
  9322. yaxis.forEach(function (y, index) {
  9323. var yaxe = w.config.yaxis[index]; // proceed only if user has specified alignment
  9324. if (yaxe.labels.align !== undefined) {
  9325. var yAxisInner = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-texts-g"));
  9326. var yAxisTexts = w.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-label"));
  9327. yAxisTexts = Utils.listToArray(yAxisTexts);
  9328. var rect = yAxisInner.getBoundingClientRect();
  9329. if (yaxe.labels.align === 'left') {
  9330. yAxisTexts.forEach(function (label, lI) {
  9331. label.setAttribute('text-anchor', 'start');
  9332. });
  9333. if (!yaxe.opposite) {
  9334. yAxisInner.setAttribute('transform', "translate(-".concat(rect.width, ", 0)"));
  9335. }
  9336. } else if (yaxe.labels.align === 'center') {
  9337. yAxisTexts.forEach(function (label, lI) {
  9338. label.setAttribute('text-anchor', 'middle');
  9339. });
  9340. yAxisInner.setAttribute('transform', "translate(".concat(rect.width / 2 * (!yaxe.opposite ? -1 : 1), ", 0)"));
  9341. } else if (yaxe.labels.align === 'right') {
  9342. yAxisTexts.forEach(function (label, lI) {
  9343. label.setAttribute('text-anchor', 'end');
  9344. });
  9345. if (yaxe.opposite) {
  9346. yAxisInner.setAttribute('transform', "translate(".concat(rect.width, ", 0)"));
  9347. }
  9348. }
  9349. }
  9350. });
  9351. }
  9352. }]);
  9353. return YAxis;
  9354. }();
  9355. var Events = /*#__PURE__*/function () {
  9356. function Events(ctx) {
  9357. _classCallCheck(this, Events);
  9358. this.ctx = ctx;
  9359. this.w = ctx.w;
  9360. this.documentEvent = Utils.bind(this.documentEvent, this);
  9361. }
  9362. _createClass(Events, [{
  9363. key: "addEventListener",
  9364. value: function addEventListener(name, handler) {
  9365. var w = this.w;
  9366. if (w.globals.events.hasOwnProperty(name)) {
  9367. w.globals.events[name].push(handler);
  9368. } else {
  9369. w.globals.events[name] = [handler];
  9370. }
  9371. }
  9372. }, {
  9373. key: "removeEventListener",
  9374. value: function removeEventListener(name, handler) {
  9375. var w = this.w;
  9376. if (!w.globals.events.hasOwnProperty(name)) {
  9377. return;
  9378. }
  9379. var index = w.globals.events[name].indexOf(handler);
  9380. if (index !== -1) {
  9381. w.globals.events[name].splice(index, 1);
  9382. }
  9383. }
  9384. }, {
  9385. key: "fireEvent",
  9386. value: function fireEvent(name, args) {
  9387. var w = this.w;
  9388. if (!w.globals.events.hasOwnProperty(name)) {
  9389. return;
  9390. }
  9391. if (!args || !args.length) {
  9392. args = [];
  9393. }
  9394. var evs = w.globals.events[name];
  9395. var l = evs.length;
  9396. for (var i = 0; i < l; i++) {
  9397. evs[i].apply(null, args);
  9398. }
  9399. }
  9400. }, {
  9401. key: "setupEventHandlers",
  9402. value: function setupEventHandlers() {
  9403. var _this = this;
  9404. var w = this.w;
  9405. var me = this.ctx;
  9406. var clickableArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
  9407. this.ctx.eventList.forEach(function (event) {
  9408. clickableArea.addEventListener(event, function (e) {
  9409. var opts = Object.assign({}, w, {
  9410. seriesIndex: w.globals.capturedSeriesIndex,
  9411. dataPointIndex: w.globals.capturedDataPointIndex
  9412. });
  9413. if (e.type === 'mousemove' || e.type === 'touchmove') {
  9414. if (typeof w.config.chart.events.mouseMove === 'function') {
  9415. w.config.chart.events.mouseMove(e, me, opts);
  9416. }
  9417. } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') {
  9418. if (typeof w.config.chart.events.click === 'function') {
  9419. w.config.chart.events.click(e, me, opts);
  9420. }
  9421. me.ctx.events.fireEvent('click', [e, me, opts]);
  9422. }
  9423. }, {
  9424. capture: false,
  9425. passive: true
  9426. });
  9427. });
  9428. this.ctx.eventList.forEach(function (event) {
  9429. document.addEventListener(event, _this.documentEvent);
  9430. });
  9431. this.ctx.core.setupBrushHandler();
  9432. }
  9433. }, {
  9434. key: "documentEvent",
  9435. value: function documentEvent(e) {
  9436. var w = this.w;
  9437. var target = e.target.className;
  9438. if (e.type === 'click') {
  9439. var elMenu = w.globals.dom.baseEl.querySelector('.apexcharts-menu');
  9440. if (elMenu && elMenu.classList.contains('apexcharts-menu-open') && target !== 'apexcharts-menu-icon') {
  9441. elMenu.classList.remove('apexcharts-menu-open');
  9442. }
  9443. }
  9444. if (e.type === 'mousedown') {
  9445. var elAnnos = w.globals.dom.Paper.select('.apexcharts-resizable-element').members;
  9446. Array.prototype.forEach.call(elAnnos, function (el) {
  9447. // any shape annotations that might have selected by user for resizing, should be deselected
  9448. if (!e.target.classList.contains('apexcharts-resizable-element') && !e.target.classList.contains('svg_select_points')) {
  9449. el.selectize(false);
  9450. }
  9451. });
  9452. }
  9453. w.globals.clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  9454. w.globals.clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  9455. }
  9456. }]);
  9457. return Events;
  9458. }();
  9459. var Localization = /*#__PURE__*/function () {
  9460. function Localization(ctx) {
  9461. _classCallCheck(this, Localization);
  9462. this.ctx = ctx;
  9463. this.w = ctx.w;
  9464. }
  9465. _createClass(Localization, [{
  9466. key: "setCurrentLocaleValues",
  9467. value: function setCurrentLocaleValues(localeName) {
  9468. var locales = this.w.config.chart.locales; // check if user has specified locales in global Apex variable
  9469. // if yes - then extend those with local chart's locale
  9470. if (window.Apex.chart && window.Apex.chart.locales && window.Apex.chart.locales.length > 0) {
  9471. locales = this.w.config.chart.locales.concat(window.Apex.chart.locales);
  9472. } // find the locale from the array of locales which user has set (either by chart.defaultLocale or by calling setLocale() method.)
  9473. var selectedLocale = locales.filter(function (c) {
  9474. return c.name === localeName;
  9475. })[0];
  9476. if (selectedLocale) {
  9477. // create a complete locale object by extending defaults so you don't get undefined errors.
  9478. var ret = Utils.extend(en, selectedLocale); // store these locale options in global var for ease access
  9479. this.w.globals.locale = ret.options;
  9480. } else {
  9481. throw new Error('Wrong locale name provided. Please make sure you set the correct locale name in options');
  9482. }
  9483. }
  9484. }]);
  9485. return Localization;
  9486. }();
  9487. var Axes = /*#__PURE__*/function () {
  9488. function Axes(ctx) {
  9489. _classCallCheck(this, Axes);
  9490. this.ctx = ctx;
  9491. this.w = ctx.w;
  9492. }
  9493. _createClass(Axes, [{
  9494. key: "drawAxis",
  9495. value: function drawAxis(type, xyRatios) {
  9496. var gl = this.w.globals;
  9497. var cnf = this.w.config;
  9498. var xAxis = new XAxis(this.ctx);
  9499. var yAxis = new YAxis(this.ctx);
  9500. if (gl.axisCharts && type !== 'radar') {
  9501. var elXaxis, elYaxis;
  9502. if (gl.isBarHorizontal) {
  9503. elYaxis = yAxis.drawYaxisInversed(0);
  9504. elXaxis = xAxis.drawXaxisInversed(0);
  9505. gl.dom.elGraphical.add(elXaxis);
  9506. gl.dom.elGraphical.add(elYaxis);
  9507. } else {
  9508. elXaxis = xAxis.drawXaxis();
  9509. gl.dom.elGraphical.add(elXaxis);
  9510. cnf.yaxis.map(function (yaxe, index) {
  9511. if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
  9512. elYaxis = yAxis.drawYaxis(index);
  9513. gl.dom.Paper.add(elYaxis);
  9514. }
  9515. });
  9516. }
  9517. }
  9518. cnf.yaxis.map(function (yaxe, index) {
  9519. if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
  9520. yAxis.yAxisTitleRotate(index, yaxe.opposite);
  9521. }
  9522. });
  9523. }
  9524. }]);
  9525. return Axes;
  9526. }();
  9527. var Crosshairs = /*#__PURE__*/function () {
  9528. function Crosshairs(ctx) {
  9529. _classCallCheck(this, Crosshairs);
  9530. this.ctx = ctx;
  9531. this.w = ctx.w;
  9532. }
  9533. _createClass(Crosshairs, [{
  9534. key: "drawXCrosshairs",
  9535. value: function drawXCrosshairs() {
  9536. var w = this.w;
  9537. var graphics = new Graphics(this.ctx);
  9538. var filters = new Filters(this.ctx);
  9539. var crosshairGradient = w.config.xaxis.crosshairs.fill.gradient;
  9540. var crosshairShadow = w.config.xaxis.crosshairs.dropShadow;
  9541. var fillType = w.config.xaxis.crosshairs.fill.type;
  9542. var gradientFrom = crosshairGradient.colorFrom;
  9543. var gradientTo = crosshairGradient.colorTo;
  9544. var opacityFrom = crosshairGradient.opacityFrom;
  9545. var opacityTo = crosshairGradient.opacityTo;
  9546. var stops = crosshairGradient.stops;
  9547. var shadow = 'none';
  9548. var dropShadow = crosshairShadow.enabled;
  9549. var shadowLeft = crosshairShadow.left;
  9550. var shadowTop = crosshairShadow.top;
  9551. var shadowBlur = crosshairShadow.blur;
  9552. var shadowColor = crosshairShadow.color;
  9553. var shadowOpacity = crosshairShadow.opacity;
  9554. var xcrosshairsFill = w.config.xaxis.crosshairs.fill.color;
  9555. if (w.config.xaxis.crosshairs.show) {
  9556. if (fillType === 'gradient') {
  9557. xcrosshairsFill = graphics.drawGradient('vertical', gradientFrom, gradientTo, opacityFrom, opacityTo, null, stops, null);
  9558. }
  9559. var xcrosshairs = graphics.drawRect();
  9560. if (w.config.xaxis.crosshairs.width === 1) {
  9561. // to prevent drawing 2 lines, convert rect to line
  9562. xcrosshairs = graphics.drawLine();
  9563. }
  9564. xcrosshairs.attr({
  9565. class: 'apexcharts-xcrosshairs',
  9566. x: 0,
  9567. y: 0,
  9568. y2: w.globals.gridHeight,
  9569. width: Utils.isNumber(w.config.xaxis.crosshairs.width) ? w.config.xaxis.crosshairs.width : 0,
  9570. height: w.globals.gridHeight,
  9571. fill: xcrosshairsFill,
  9572. filter: shadow,
  9573. 'fill-opacity': w.config.xaxis.crosshairs.opacity,
  9574. stroke: w.config.xaxis.crosshairs.stroke.color,
  9575. 'stroke-width': w.config.xaxis.crosshairs.stroke.width,
  9576. 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray
  9577. });
  9578. if (dropShadow) {
  9579. xcrosshairs = filters.dropShadow(xcrosshairs, {
  9580. left: shadowLeft,
  9581. top: shadowTop,
  9582. blur: shadowBlur,
  9583. color: shadowColor,
  9584. opacity: shadowOpacity
  9585. });
  9586. }
  9587. w.globals.dom.elGraphical.add(xcrosshairs);
  9588. }
  9589. }
  9590. }, {
  9591. key: "drawYCrosshairs",
  9592. value: function drawYCrosshairs() {
  9593. var w = this.w;
  9594. var graphics = new Graphics(this.ctx);
  9595. var crosshair = w.config.yaxis[0].crosshairs;
  9596. if (w.config.yaxis[0].crosshairs.show) {
  9597. var ycrosshairs = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width);
  9598. ycrosshairs.attr({
  9599. class: 'apexcharts-ycrosshairs'
  9600. });
  9601. w.globals.dom.elGraphical.add(ycrosshairs);
  9602. } // draw an invisible crosshair to help in positioning the yaxis tooltip
  9603. var ycrosshairsHidden = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, 0, 0);
  9604. ycrosshairsHidden.attr({
  9605. class: 'apexcharts-ycrosshairs-hidden'
  9606. });
  9607. w.globals.dom.elGraphical.add(ycrosshairsHidden);
  9608. }
  9609. }]);
  9610. return Crosshairs;
  9611. }();
  9612. /**
  9613. * ApexCharts Responsive Class to override options for different screen sizes.
  9614. *
  9615. * @module Responsive
  9616. **/
  9617. var Responsive = /*#__PURE__*/function () {
  9618. function Responsive(ctx) {
  9619. _classCallCheck(this, Responsive);
  9620. this.ctx = ctx;
  9621. this.w = ctx.w;
  9622. } // the opts parameter if not null has to be set overriding everything
  9623. // as the opts is set by user externally
  9624. _createClass(Responsive, [{
  9625. key: "checkResponsiveConfig",
  9626. value: function checkResponsiveConfig(opts) {
  9627. var _this = this;
  9628. var w = this.w;
  9629. var cnf = w.config; // check if responsive config exists
  9630. if (cnf.responsive.length === 0) return;
  9631. var res = cnf.responsive.slice();
  9632. res.sort(function (a, b) {
  9633. return a.breakpoint > b.breakpoint ? 1 : b.breakpoint > a.breakpoint ? -1 : 0;
  9634. }).reverse();
  9635. var config = new Config({});
  9636. var iterateResponsiveOptions = function iterateResponsiveOptions() {
  9637. var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9638. var largestBreakpoint = res[0].breakpoint;
  9639. var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
  9640. if (width > largestBreakpoint) {
  9641. var options = CoreUtils.extendArrayProps(config, w.globals.initialConfig);
  9642. newOptions = Utils.extend(options, newOptions);
  9643. newOptions = Utils.extend(w.config, newOptions);
  9644. _this.overrideResponsiveOptions(newOptions);
  9645. } else {
  9646. for (var i = 0; i < res.length; i++) {
  9647. if (width < res[i].breakpoint) {
  9648. newOptions = CoreUtils.extendArrayProps(config, res[i].options);
  9649. newOptions = Utils.extend(w.config, newOptions);
  9650. _this.overrideResponsiveOptions(newOptions);
  9651. }
  9652. }
  9653. }
  9654. };
  9655. if (opts) {
  9656. var options = CoreUtils.extendArrayProps(config, opts);
  9657. options = Utils.extend(w.config, options);
  9658. options = Utils.extend(options, opts);
  9659. iterateResponsiveOptions(options);
  9660. } else {
  9661. iterateResponsiveOptions({});
  9662. }
  9663. }
  9664. }, {
  9665. key: "overrideResponsiveOptions",
  9666. value: function overrideResponsiveOptions(newOptions) {
  9667. var newConfig = new Config(newOptions).init({
  9668. responsiveOverride: true
  9669. });
  9670. this.w.config = newConfig;
  9671. }
  9672. }]);
  9673. return Responsive;
  9674. }();
  9675. /**
  9676. * ApexCharts Theme Class for setting the colors and palettes.
  9677. *
  9678. * @module Theme
  9679. **/
  9680. var Theme = /*#__PURE__*/function () {
  9681. function Theme(ctx) {
  9682. _classCallCheck(this, Theme);
  9683. this.ctx = ctx;
  9684. this.colors = [];
  9685. this.w = ctx.w;
  9686. var w = this.w;
  9687. this.isColorFn = false;
  9688. this.isBarDistributed = w.config.plotOptions.bar.distributed && (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar');
  9689. }
  9690. _createClass(Theme, [{
  9691. key: "init",
  9692. value: function init() {
  9693. this.setDefaultColors();
  9694. }
  9695. }, {
  9696. key: "setDefaultColors",
  9697. value: function setDefaultColors() {
  9698. var _this = this;
  9699. var w = this.w;
  9700. var utils = new Utils();
  9701. w.globals.dom.elWrap.classList.add("apexcharts-theme-".concat(w.config.theme.mode));
  9702. if (w.config.colors === undefined) {
  9703. w.globals.colors = this.predefined();
  9704. } else {
  9705. w.globals.colors = w.config.colors; // if user provided a function in colors, we need to eval here
  9706. 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 // colors & series length needs same
  9707. ) {
  9708. w.globals.colors = w.config.colors.map(function (c, i) {
  9709. if (typeof c === 'function') {
  9710. _this.isColorFn = true;
  9711. return c({
  9712. value: w.globals.axisCharts ? w.globals.series[i][0] ? w.globals.series[i][0] : 0 : w.globals.series[i],
  9713. seriesIndex: i,
  9714. dataPointIndex: i,
  9715. w: w
  9716. });
  9717. }
  9718. return c;
  9719. });
  9720. }
  9721. }
  9722. if (w.config.theme.monochrome.enabled) {
  9723. var monoArr = [];
  9724. var glsCnt = w.globals.series.length;
  9725. if (this.isBarDistributed) {
  9726. glsCnt = w.globals.series[0].length * w.globals.series.length;
  9727. }
  9728. var mainColor = w.config.theme.monochrome.color;
  9729. var part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity);
  9730. var shade = w.config.theme.monochrome.shadeTo;
  9731. var percent = 0;
  9732. for (var gsl = 0; gsl < glsCnt; gsl++) {
  9733. var newColor = void 0;
  9734. if (shade === 'dark') {
  9735. newColor = utils.shadeColor(percent * -1, mainColor);
  9736. percent = percent + part;
  9737. } else {
  9738. newColor = utils.shadeColor(percent, mainColor);
  9739. percent = percent + part;
  9740. }
  9741. monoArr.push(newColor);
  9742. }
  9743. w.globals.colors = monoArr.slice();
  9744. }
  9745. var defaultColors = w.globals.colors.slice(); // if user specfied less colors than no. of series, push the same colors again
  9746. this.pushExtraColors(w.globals.colors);
  9747. var colorTypes = ['fill', 'stroke'];
  9748. colorTypes.forEach(function (c) {
  9749. if (w.config[c].colors === undefined) {
  9750. w.globals[c].colors = _this.isColorFn ? w.config.colors : defaultColors;
  9751. } else {
  9752. w.globals[c].colors = w.config[c].colors.slice();
  9753. }
  9754. _this.pushExtraColors(w.globals[c].colors);
  9755. });
  9756. if (w.config.dataLabels.style.colors === undefined) {
  9757. w.globals.dataLabels.style.colors = defaultColors;
  9758. } else {
  9759. w.globals.dataLabels.style.colors = w.config.dataLabels.style.colors.slice();
  9760. }
  9761. this.pushExtraColors(w.globals.dataLabels.style.colors, 50);
  9762. if (w.config.plotOptions.radar.polygons.fill.colors === undefined) {
  9763. w.globals.radarPolygons.fill.colors = [w.config.theme.mode === 'dark' ? '#202D48' : '#fff'];
  9764. } else {
  9765. w.globals.radarPolygons.fill.colors = w.config.plotOptions.radar.polygons.fill.colors.slice();
  9766. }
  9767. this.pushExtraColors(w.globals.radarPolygons.fill.colors, 20); // The point colors
  9768. if (w.config.markers.colors === undefined) {
  9769. w.globals.markers.colors = defaultColors;
  9770. } else {
  9771. w.globals.markers.colors = w.config.markers.colors.slice();
  9772. }
  9773. this.pushExtraColors(w.globals.markers.colors);
  9774. } // When the number of colors provided is less than the number of series, this method
  9775. // will push same colors to the list
  9776. // params:
  9777. // distributed is only valid for distributed column/bar charts
  9778. }, {
  9779. key: "pushExtraColors",
  9780. value: function pushExtraColors(colorSeries, length) {
  9781. var distributed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  9782. var w = this.w;
  9783. var len = length || w.globals.series.length;
  9784. if (distributed === null) {
  9785. distributed = this.isBarDistributed || w.config.chart.type === 'heatmap' && w.config.plotOptions.heatmap.colorScale.inverse;
  9786. }
  9787. if (distributed) {
  9788. len = w.globals.series[0].length * w.globals.series.length;
  9789. }
  9790. if (colorSeries.length < len) {
  9791. var diff = len - colorSeries.length;
  9792. for (var i = 0; i < diff; i++) {
  9793. colorSeries.push(colorSeries[i]);
  9794. }
  9795. }
  9796. }
  9797. }, {
  9798. key: "updateThemeOptions",
  9799. value: function updateThemeOptions(options) {
  9800. options.chart = options.chart || {};
  9801. options.tooltip = options.tooltip || {};
  9802. var mode = options.theme.mode || 'light';
  9803. var palette = options.theme.palette ? options.theme.palette : mode === 'dark' ? 'palette4' : 'palette1';
  9804. var foreColor = options.chart.foreColor ? options.chart.foreColor : mode === 'dark' ? '#f6f7f8' : '#373d3f';
  9805. options.tooltip.theme = mode;
  9806. options.chart.foreColor = foreColor;
  9807. options.theme.palette = palette;
  9808. return options;
  9809. }
  9810. }, {
  9811. key: "predefined",
  9812. value: function predefined() {
  9813. var palette = this.w.config.theme.palette; // D6E3F8, FCEFEF, DCE0D9, A5978B, EDDDD4, D6E3F8, FEF5EF
  9814. switch (palette) {
  9815. case 'palette1':
  9816. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  9817. break;
  9818. case 'palette2':
  9819. this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800'];
  9820. break;
  9821. case 'palette3':
  9822. this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B'];
  9823. break;
  9824. case 'palette4':
  9825. this.colors = ['#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a', '#546E7A'];
  9826. break;
  9827. case 'palette5':
  9828. this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7'];
  9829. break;
  9830. case 'palette6':
  9831. this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D'];
  9832. break;
  9833. case 'palette7':
  9834. this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#E2C044'];
  9835. break;
  9836. case 'palette8':
  9837. this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD'];
  9838. break;
  9839. case 'palette9':
  9840. this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF'];
  9841. break;
  9842. case 'palette10':
  9843. this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2'];
  9844. break;
  9845. default:
  9846. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  9847. break;
  9848. }
  9849. return this.colors;
  9850. }
  9851. }]);
  9852. return Theme;
  9853. }();
  9854. var TitleSubtitle = /*#__PURE__*/function () {
  9855. function TitleSubtitle(ctx) {
  9856. _classCallCheck(this, TitleSubtitle);
  9857. this.ctx = ctx;
  9858. this.w = ctx.w;
  9859. }
  9860. _createClass(TitleSubtitle, [{
  9861. key: "draw",
  9862. value: function draw() {
  9863. this.drawTitleSubtitle('title');
  9864. this.drawTitleSubtitle('subtitle');
  9865. }
  9866. }, {
  9867. key: "drawTitleSubtitle",
  9868. value: function drawTitleSubtitle(type) {
  9869. var w = this.w;
  9870. var tsConfig = type === 'title' ? w.config.title : w.config.subtitle;
  9871. var x = w.globals.svgWidth / 2;
  9872. var y = tsConfig.offsetY;
  9873. var textAnchor = 'middle';
  9874. if (tsConfig.align === 'left') {
  9875. x = 10;
  9876. textAnchor = 'start';
  9877. } else if (tsConfig.align === 'right') {
  9878. x = w.globals.svgWidth - 10;
  9879. textAnchor = 'end';
  9880. }
  9881. x = x + tsConfig.offsetX;
  9882. y = y + parseInt(tsConfig.style.fontSize, 10) + tsConfig.margin / 2;
  9883. if (tsConfig.text !== undefined) {
  9884. var graphics = new Graphics(this.ctx);
  9885. var titleText = graphics.drawText({
  9886. x: x,
  9887. y: y,
  9888. text: tsConfig.text,
  9889. textAnchor: textAnchor,
  9890. fontSize: tsConfig.style.fontSize,
  9891. fontFamily: tsConfig.style.fontFamily,
  9892. fontWeight: tsConfig.style.fontWeight,
  9893. foreColor: tsConfig.style.color,
  9894. opacity: 1
  9895. });
  9896. titleText.node.setAttribute('class', "apexcharts-".concat(type, "-text"));
  9897. w.globals.dom.Paper.add(titleText);
  9898. }
  9899. }
  9900. }]);
  9901. return TitleSubtitle;
  9902. }();
  9903. var Helpers$1 = /*#__PURE__*/function () {
  9904. function Helpers(dCtx) {
  9905. _classCallCheck(this, Helpers);
  9906. this.w = dCtx.w;
  9907. this.dCtx = dCtx;
  9908. }
  9909. /**
  9910. * Get Chart Title/Subtitle Dimensions
  9911. * @memberof Dimensions
  9912. * @return {{width, height}}
  9913. **/
  9914. _createClass(Helpers, [{
  9915. key: "getTitleSubtitleCoords",
  9916. value: function getTitleSubtitleCoords(type) {
  9917. var w = this.w;
  9918. var width = 0;
  9919. var height = 0;
  9920. var floating = type === 'title' ? w.config.title.floating : w.config.subtitle.floating;
  9921. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-text"));
  9922. if (el !== null && !floating) {
  9923. var coord = el.getBoundingClientRect();
  9924. width = coord.width;
  9925. height = w.globals.axisCharts ? coord.height + 5 : coord.height;
  9926. }
  9927. return {
  9928. width: width,
  9929. height: height
  9930. };
  9931. }
  9932. }, {
  9933. key: "getLegendsRect",
  9934. value: function getLegendsRect() {
  9935. var w = this.w;
  9936. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  9937. var lgRect = Object.assign({}, Utils.getBoundingClientRect(elLegendWrap));
  9938. if (elLegendWrap !== null && !w.config.legend.floating && w.config.legend.show) {
  9939. this.dCtx.lgRect = {
  9940. x: lgRect.x,
  9941. y: lgRect.y,
  9942. height: lgRect.height,
  9943. width: lgRect.height === 0 ? 0 : lgRect.width
  9944. };
  9945. } else {
  9946. this.dCtx.lgRect = {
  9947. x: 0,
  9948. y: 0,
  9949. height: 0,
  9950. width: 0
  9951. };
  9952. } // if legend takes up all of the chart space, we need to restrict it.
  9953. if (w.config.legend.position === 'left' || w.config.legend.position === 'right') {
  9954. if (this.dCtx.lgRect.width * 1.5 > w.globals.svgWidth) {
  9955. this.dCtx.lgRect.width = w.globals.svgWidth / 1.5;
  9956. }
  9957. }
  9958. return this.dCtx.lgRect;
  9959. }
  9960. }, {
  9961. key: "getLargestStringFromMultiArr",
  9962. value: function getLargestStringFromMultiArr(val, arr) {
  9963. var w = this.w;
  9964. var valArr = val;
  9965. if (w.globals.isMultiLineX) {
  9966. // if the xaxis labels has multiline texts (array)
  9967. var maxArrs = arr.map(function (xl, idx) {
  9968. return Array.isArray(xl) ? xl.length : 1;
  9969. });
  9970. var maxArrLen = Math.max.apply(Math, _toConsumableArray(maxArrs));
  9971. var maxArrIndex = maxArrs.indexOf(maxArrLen);
  9972. valArr = arr[maxArrIndex];
  9973. }
  9974. return valArr;
  9975. }
  9976. }]);
  9977. return Helpers;
  9978. }();
  9979. var DimXAxis = /*#__PURE__*/function () {
  9980. function DimXAxis(dCtx) {
  9981. _classCallCheck(this, DimXAxis);
  9982. this.w = dCtx.w;
  9983. this.dCtx = dCtx;
  9984. }
  9985. /**
  9986. * Get X Axis Dimensions
  9987. * @memberof Dimensions
  9988. * @return {{width, height}}
  9989. **/
  9990. _createClass(DimXAxis, [{
  9991. key: "getxAxisLabelsCoords",
  9992. value: function getxAxisLabelsCoords() {
  9993. var w = this.w;
  9994. var xaxisLabels = w.globals.labels.slice();
  9995. if (w.config.xaxis.convertedCatToNumeric && xaxisLabels.length === 0) {
  9996. xaxisLabels = w.globals.categoryLabels;
  9997. }
  9998. var rect;
  9999. if (w.globals.timescaleLabels.length > 0) {
  10000. var coords = this.getxAxisTimeScaleLabelsCoords();
  10001. rect = {
  10002. width: coords.width,
  10003. height: coords.height
  10004. };
  10005. w.globals.rotateXLabels = false;
  10006. } else {
  10007. this.dCtx.lgWidthForSideLegends = (w.config.legend.position === 'left' || w.config.legend.position === 'right') && !w.config.legend.floating ? this.dCtx.lgRect.width : 0; // get the longest string from the labels array and also apply label formatter
  10008. var xlbFormatter = w.globals.xLabelFormatter; // prevent changing xaxisLabels to avoid issues in multi-yaxes - fix #522
  10009. var val = Utils.getLargestStringFromArr(xaxisLabels);
  10010. var valArr = this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, xaxisLabels); // the labels gets changed for bar charts
  10011. if (w.globals.isBarHorizontal) {
  10012. val = w.globals.yAxisScale[0].result.reduce(function (a, b) {
  10013. return a.length > b.length ? a : b;
  10014. }, 0);
  10015. valArr = val;
  10016. }
  10017. var xFormat = new Formatters(this.dCtx.ctx);
  10018. var timestamp = val;
  10019. val = xFormat.xLabelFormat(xlbFormatter, val, timestamp);
  10020. valArr = xFormat.xLabelFormat(xlbFormatter, valArr, timestamp);
  10021. if (w.config.xaxis.convertedCatToNumeric && typeof val === 'undefined' || String(val).trim() === '') {
  10022. val = '1';
  10023. valArr = val;
  10024. }
  10025. var graphics = new Graphics(this.dCtx.ctx);
  10026. var xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  10027. var xArrLabelrect = xLabelrect;
  10028. if (val !== valArr) {
  10029. xArrLabelrect = graphics.getTextRects(valArr, w.config.xaxis.labels.style.fontSize);
  10030. }
  10031. rect = {
  10032. width: xLabelrect.width >= xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width,
  10033. height: xLabelrect.height >= xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height
  10034. };
  10035. 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) {
  10036. if (!w.globals.isBarHorizontal) {
  10037. w.globals.rotateXLabels = true;
  10038. var getRotatedTextRects = function getRotatedTextRects(text) {
  10039. 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);
  10040. };
  10041. xLabelrect = getRotatedTextRects(val);
  10042. if (val !== valArr) {
  10043. xArrLabelrect = getRotatedTextRects(valArr);
  10044. }
  10045. rect.height = (xLabelrect.height > xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height) / 1.5;
  10046. rect.width = xLabelrect.width > xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width;
  10047. }
  10048. } else {
  10049. w.globals.rotateXLabels = false;
  10050. }
  10051. }
  10052. if (!w.config.xaxis.labels.show) {
  10053. rect = {
  10054. width: 0,
  10055. height: 0
  10056. };
  10057. }
  10058. return {
  10059. width: rect.width,
  10060. height: rect.height
  10061. };
  10062. }
  10063. /**
  10064. * Get X Axis Title Dimensions
  10065. * @memberof Dimensions
  10066. * @return {{width, height}}
  10067. **/
  10068. }, {
  10069. key: "getxAxisTitleCoords",
  10070. value: function getxAxisTitleCoords() {
  10071. var w = this.w;
  10072. var width = 0;
  10073. var height = 0;
  10074. if (w.config.xaxis.title.text !== undefined) {
  10075. var graphics = new Graphics(this.dCtx.ctx);
  10076. var rect = graphics.getTextRects(w.config.xaxis.title.text, w.config.xaxis.title.style.fontSize);
  10077. width = rect.width;
  10078. height = rect.height;
  10079. }
  10080. return {
  10081. width: width,
  10082. height: height
  10083. };
  10084. }
  10085. }, {
  10086. key: "getxAxisTimeScaleLabelsCoords",
  10087. value: function getxAxisTimeScaleLabelsCoords() {
  10088. var w = this.w;
  10089. var rect;
  10090. this.dCtx.timescaleLabels = w.globals.timescaleLabels.slice();
  10091. var labels = this.dCtx.timescaleLabels.map(function (label) {
  10092. return label.value;
  10093. }); // get the longest string from the labels array and also apply label formatter to it
  10094. var val = labels.reduce(function (a, b) {
  10095. // if undefined, maybe user didn't pass the datetime(x) values
  10096. if (typeof a === 'undefined') {
  10097. console.error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date');
  10098. return 0;
  10099. } else {
  10100. return a.length > b.length ? a : b;
  10101. }
  10102. }, 0);
  10103. var graphics = new Graphics(this.dCtx.ctx);
  10104. rect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  10105. var totalWidthRotated = rect.width * 1.05 * labels.length;
  10106. if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) {
  10107. w.globals.overlappingXLabels = true;
  10108. }
  10109. return rect;
  10110. } // In certain cases, the last labels gets cropped in xaxis.
  10111. // Hence, we add some additional padding based on the label length to avoid the last label being cropped or we don't draw it at all
  10112. }, {
  10113. key: "additionalPaddingXLabels",
  10114. value: function additionalPaddingXLabels(xaxisLabelCoords) {
  10115. var _this = this;
  10116. var w = this.w;
  10117. var gl = w.globals;
  10118. var cnf = w.config;
  10119. var xtype = cnf.xaxis.type; // const predictedGridWidth =
  10120. // gl.svgWidth -
  10121. // this.dCtx.lgWidthForSideLegends -
  10122. // this.dCtx.yAxisWidth -
  10123. // this.dCtx.gridPad.left -
  10124. // this.dCtx.gridPad.right
  10125. var lbWidth = xaxisLabelCoords.width;
  10126. gl.skipLastTimelinelabel = false;
  10127. gl.skipFirstTimelinelabel = false;
  10128. var isBarOpposite = w.config.yaxis[0].opposite && w.globals.isBarHorizontal;
  10129. var isCollapsed = function isCollapsed(i) {
  10130. return gl.collapsedSeriesIndices.indexOf(i) !== -1;
  10131. };
  10132. var rightPad = function rightPad(yaxe) {
  10133. if (_this.dCtx.timescaleLabels && _this.dCtx.timescaleLabels.length) {
  10134. // for timeline labels, we take the last label and check if it exceeds gridWidth
  10135. var firstimescaleLabel = _this.dCtx.timescaleLabels[0];
  10136. var lastTimescaleLabel = _this.dCtx.timescaleLabels[_this.dCtx.timescaleLabels.length - 1];
  10137. var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 - // replace + with - ;
  10138. // allow the last label to intersect with the right y axis
  10139. _this.dCtx.yAxisWidthRight;
  10140. var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 + // remove conditional since the first label is always at the very left
  10141. // allow the first label to intersect with the left y axes
  10142. _this.dCtx.yAxisWidthLeft;
  10143. if (lastLabelPosition > gl.gridWidth) {
  10144. gl.skipLastTimelinelabel = true;
  10145. }
  10146. if (firstLabelPosition < 0) {
  10147. gl.skipFirstTimelinelabel = true;
  10148. }
  10149. } else if (xtype === 'datetime') {
  10150. // If user has enabled DateTime, but uses own's formatter
  10151. if (_this.dCtx.gridPad.right < lbWidth && !gl.rotateXLabels) {
  10152. gl.skipLastTimelinelabel = true;
  10153. }
  10154. } else if (xtype !== 'datetime') {
  10155. if (_this.dCtx.gridPad.right < lbWidth / 2 - _this.dCtx.yAxisWidthRight && !gl.rotateXLabels && (w.config.xaxis.tickPlacement !== 'between' || w.globals.isBarHorizontal)) {
  10156. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  10157. }
  10158. }
  10159. };
  10160. var padYAxe = function padYAxe(yaxe, i) {
  10161. if (isCollapsed(i)) return;
  10162. if (xtype !== 'datetime') {
  10163. if (_this.dCtx.gridPad.left < lbWidth / 2 - _this.dCtx.yAxisWidthLeft && !gl.rotateXLabels && !cnf.xaxis.labels.trim) {
  10164. _this.dCtx.xPadLeft = lbWidth / 2 + 1;
  10165. }
  10166. }
  10167. rightPad();
  10168. };
  10169. cnf.yaxis.forEach(function (yaxe, i) {
  10170. if (isBarOpposite) {
  10171. if (_this.dCtx.gridPad.left < lbWidth) {
  10172. _this.dCtx.xPadLeft = lbWidth / 2 + 1;
  10173. }
  10174. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  10175. } else {
  10176. padYAxe(yaxe, i);
  10177. }
  10178. });
  10179. }
  10180. }]);
  10181. return DimXAxis;
  10182. }();
  10183. var DimYAxis = /*#__PURE__*/function () {
  10184. function DimYAxis(dCtx) {
  10185. _classCallCheck(this, DimYAxis);
  10186. this.w = dCtx.w;
  10187. this.dCtx = dCtx;
  10188. }
  10189. /**
  10190. * Get Y Axis Dimensions
  10191. * @memberof Dimensions
  10192. * @return {{width, height}}
  10193. **/
  10194. _createClass(DimYAxis, [{
  10195. key: "getyAxisLabelsCoords",
  10196. value: function getyAxisLabelsCoords() {
  10197. var _this = this;
  10198. var w = this.w;
  10199. var width = 0;
  10200. var height = 0;
  10201. var ret = [];
  10202. var labelPad = 10;
  10203. var axesUtils = new AxesUtils(this.dCtx.ctx);
  10204. w.config.yaxis.map(function (yaxe, index) {
  10205. if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && w.globals.yAxisScale[index].result.length) {
  10206. var lbFormatter = w.globals.yLabelFormatters[index]; // the second parameter -1 is the index of tick which user can use in the formatter
  10207. var val = lbFormatter(w.globals.yAxisScale[index].niceMax, {
  10208. seriesIndex: index,
  10209. dataPointIndex: -1,
  10210. w: w
  10211. });
  10212. var valArr = val; // if user has specified a custom formatter, and the result is null or empty, we need to discard the formatter and take the value as it is.
  10213. if (typeof val === 'undefined' || val.length === 0) {
  10214. val = w.globals.yAxisScale[index].niceMax;
  10215. }
  10216. if (w.globals.isBarHorizontal) {
  10217. labelPad = 0;
  10218. var barYaxisLabels = w.globals.labels.slice(); // get the longest string from the labels array and also apply label formatter to it
  10219. val = Utils.getLargestStringFromArr(barYaxisLabels);
  10220. val = lbFormatter(val, {
  10221. seriesIndex: index,
  10222. dataPointIndex: -1,
  10223. w: w
  10224. });
  10225. valArr = _this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, barYaxisLabels);
  10226. }
  10227. var graphics = new Graphics(_this.dCtx.ctx);
  10228. var rect = graphics.getTextRects(val, yaxe.labels.style.fontSize);
  10229. var arrLabelrect = rect;
  10230. if (val !== valArr) {
  10231. arrLabelrect = graphics.getTextRects(valArr, yaxe.labels.style.fontSize);
  10232. }
  10233. ret.push({
  10234. width: (arrLabelrect.width > rect.width ? arrLabelrect.width : rect.width) + labelPad,
  10235. height: arrLabelrect.height > rect.height ? arrLabelrect.height : rect.height
  10236. });
  10237. } else {
  10238. ret.push({
  10239. width: width,
  10240. height: height
  10241. });
  10242. }
  10243. });
  10244. return ret;
  10245. }
  10246. /**
  10247. * Get Y Axis Dimensions
  10248. * @memberof Dimensions
  10249. * @return {{width, height}}
  10250. **/
  10251. }, {
  10252. key: "getyAxisTitleCoords",
  10253. value: function getyAxisTitleCoords() {
  10254. var _this2 = this;
  10255. var w = this.w;
  10256. var ret = [];
  10257. w.config.yaxis.map(function (yaxe, index) {
  10258. if (yaxe.show && yaxe.title.text !== undefined) {
  10259. var graphics = new Graphics(_this2.dCtx.ctx);
  10260. var rect = graphics.getTextRects(yaxe.title.text, yaxe.title.style.fontSize, yaxe.title.style.fontFamily, 'rotate(-90 0 0)', false);
  10261. ret.push({
  10262. width: rect.width,
  10263. height: rect.height
  10264. });
  10265. } else {
  10266. ret.push({
  10267. width: 0,
  10268. height: 0
  10269. });
  10270. }
  10271. });
  10272. return ret;
  10273. }
  10274. }, {
  10275. key: "getTotalYAxisWidth",
  10276. value: function getTotalYAxisWidth() {
  10277. var w = this.w;
  10278. var yAxisWidth = 0;
  10279. var yAxisWidthLeft = 0;
  10280. var yAxisWidthRight = 0;
  10281. var padding = w.globals.yAxisScale.length > 1 ? 10 : 0;
  10282. var axesUtils = new AxesUtils(this.dCtx.ctx);
  10283. var isHiddenYAxis = function isHiddenYAxis(index) {
  10284. return w.globals.ignoreYAxisIndexes.indexOf(index) > -1;
  10285. };
  10286. var padForLabelTitle = function padForLabelTitle(coord, index) {
  10287. var floating = w.config.yaxis[index].floating;
  10288. var width = 0;
  10289. if (coord.width > 0 && !floating) {
  10290. width = coord.width + padding;
  10291. if (isHiddenYAxis(index)) {
  10292. width = width - coord.width - padding;
  10293. }
  10294. } else {
  10295. width = floating || axesUtils.isYAxisHidden(index) ? 0 : 5;
  10296. }
  10297. w.config.yaxis[index].opposite ? yAxisWidthRight = yAxisWidthRight + width : yAxisWidthLeft = yAxisWidthLeft + width;
  10298. yAxisWidth = yAxisWidth + width;
  10299. };
  10300. w.globals.yLabelsCoords.map(function (yLabelCoord, index) {
  10301. padForLabelTitle(yLabelCoord, index);
  10302. });
  10303. w.globals.yTitleCoords.map(function (yTitleCoord, index) {
  10304. padForLabelTitle(yTitleCoord, index);
  10305. });
  10306. if (w.globals.isBarHorizontal) {
  10307. yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15;
  10308. }
  10309. this.dCtx.yAxisWidthLeft = yAxisWidthLeft;
  10310. this.dCtx.yAxisWidthRight = yAxisWidthRight;
  10311. return yAxisWidth;
  10312. }
  10313. }]);
  10314. return DimYAxis;
  10315. }();
  10316. var DimGrid = /*#__PURE__*/function () {
  10317. function DimGrid(dCtx) {
  10318. _classCallCheck(this, DimGrid);
  10319. this.w = dCtx.w;
  10320. this.dCtx = dCtx;
  10321. }
  10322. _createClass(DimGrid, [{
  10323. key: "gridPadForColumnsInNumericAxis",
  10324. value: function gridPadForColumnsInNumericAxis(gridWidth) {
  10325. var w = this.w;
  10326. if (w.globals.noData || w.globals.allSeriesCollapsed) {
  10327. return 0;
  10328. }
  10329. var type = w.config.chart.type;
  10330. var barWidth = 0;
  10331. var seriesLen = type === 'bar' || type === 'rangeBar' ? w.config.series.length : 1;
  10332. if (w.globals.comboBarCount > 0) {
  10333. seriesLen = w.globals.comboBarCount;
  10334. }
  10335. w.globals.collapsedSeries.forEach(function (c) {
  10336. if (c.type === 'bar' || c.type === 'rangeBar') {
  10337. seriesLen = seriesLen - 1;
  10338. }
  10339. });
  10340. if (w.config.chart.stacked) {
  10341. seriesLen = 1;
  10342. }
  10343. var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
  10344. if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal && seriesLen > 0) {
  10345. var xRatio = 0;
  10346. var xRange = Math.abs(w.globals.initialMaxX - w.globals.initialMinX);
  10347. if (xRange <= 3) {
  10348. xRange = w.globals.dataPoints;
  10349. }
  10350. xRatio = xRange / gridWidth;
  10351. var xDivision; // max barwidth should be equal to minXDiff to avoid overlap
  10352. if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
  10353. xDivision = w.globals.minXDiff / xRatio;
  10354. }
  10355. barWidth = xDivision / seriesLen * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  10356. if (barWidth < 1) {
  10357. barWidth = 1;
  10358. }
  10359. barWidth = barWidth / (seriesLen > 1 ? 1 : 1.5) + 5;
  10360. w.globals.barPadForNumericAxis = barWidth;
  10361. }
  10362. return barWidth;
  10363. }
  10364. }, {
  10365. key: "gridPadFortitleSubtitle",
  10366. value: function gridPadFortitleSubtitle() {
  10367. var _this = this;
  10368. var w = this.w;
  10369. var gl = w.globals;
  10370. var gridShrinkOffset = this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 10;
  10371. var titleSubtitle = ['title', 'subtitle'];
  10372. titleSubtitle.forEach(function (t) {
  10373. if (w.config[t].text !== undefined) {
  10374. gridShrinkOffset += w.config[t].margin;
  10375. } else {
  10376. gridShrinkOffset += _this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 5;
  10377. }
  10378. });
  10379. var nonAxisOrMultiSeriesCharts = w.config.series.length > 1 || !w.globals.axisCharts || w.config.legend.showForSingleSeries;
  10380. if (w.config.legend.show && w.config.legend.position === 'bottom' && !w.config.legend.floating && nonAxisOrMultiSeriesCharts) {
  10381. gridShrinkOffset += 10;
  10382. }
  10383. var titleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('title');
  10384. var subtitleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('subtitle');
  10385. gl.gridHeight = gl.gridHeight - titleCoords.height - subtitleCoords.height - gridShrinkOffset;
  10386. gl.translateY = gl.translateY + titleCoords.height + subtitleCoords.height + gridShrinkOffset;
  10387. }
  10388. }, {
  10389. key: "setGridXPosForDualYAxis",
  10390. value: function setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords) {
  10391. var w = this.w;
  10392. var axesUtils = new AxesUtils(this.dCtx.ctx);
  10393. w.config.yaxis.map(function (yaxe, index) {
  10394. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1 && !yaxe.floating && !axesUtils.isYAxisHidden(index)) {
  10395. if (yaxe.opposite) {
  10396. w.globals.translateX = w.globals.translateX - (yaxisLabelCoords[index].width + yTitleCoords[index].width) - parseInt(w.config.yaxis[index].labels.style.fontSize, 10) / 1.2 - 12;
  10397. }
  10398. }
  10399. });
  10400. }
  10401. }]);
  10402. return DimGrid;
  10403. }();
  10404. /**
  10405. * ApexCharts Dimensions Class for calculating rects of all elements that are drawn and will be drawn.
  10406. *
  10407. * @module Dimensions
  10408. **/
  10409. var Dimensions = /*#__PURE__*/function () {
  10410. function Dimensions(ctx) {
  10411. _classCallCheck(this, Dimensions);
  10412. this.ctx = ctx;
  10413. this.w = ctx.w;
  10414. this.lgRect = {};
  10415. this.yAxisWidth = 0;
  10416. this.yAxisWidthLeft = 0;
  10417. this.yAxisWidthRight = 0;
  10418. this.xAxisHeight = 0;
  10419. this.isSparkline = this.w.config.chart.sparkline.enabled;
  10420. this.dimHelpers = new Helpers$1(this);
  10421. this.dimYAxis = new DimYAxis(this);
  10422. this.dimXAxis = new DimXAxis(this);
  10423. this.dimGrid = new DimGrid(this);
  10424. this.lgWidthForSideLegends = 0;
  10425. this.gridPad = this.w.config.grid.padding;
  10426. this.xPadRight = 0;
  10427. this.xPadLeft = 0;
  10428. }
  10429. /**
  10430. * @memberof Dimensions
  10431. * @param {object} w - chart context
  10432. **/
  10433. _createClass(Dimensions, [{
  10434. key: "plotCoords",
  10435. value: function plotCoords() {
  10436. var w = this.w;
  10437. var gl = w.globals;
  10438. this.lgRect = this.dimHelpers.getLegendsRect();
  10439. if (gl.axisCharts) {
  10440. // for line / area / scatter / column
  10441. this.setDimensionsForAxisCharts();
  10442. } else {
  10443. // for pie / donuts / circle
  10444. this.setDimensionsForNonAxisCharts();
  10445. }
  10446. this.dimGrid.gridPadFortitleSubtitle(); // after calculating everything, apply padding set by user
  10447. gl.gridHeight = gl.gridHeight - this.gridPad.top - this.gridPad.bottom;
  10448. gl.gridWidth = gl.gridWidth - this.gridPad.left - this.gridPad.right - this.xPadRight - this.xPadLeft;
  10449. var barWidth = this.dimGrid.gridPadForColumnsInNumericAxis(gl.gridWidth);
  10450. gl.gridWidth = gl.gridWidth - barWidth * 2;
  10451. gl.translateX = gl.translateX + this.gridPad.left + this.xPadLeft + (barWidth > 0 ? barWidth + 4 : 0);
  10452. gl.translateY = gl.translateY + this.gridPad.top;
  10453. }
  10454. }, {
  10455. key: "setDimensionsForAxisCharts",
  10456. value: function setDimensionsForAxisCharts() {
  10457. var _this = this;
  10458. var w = this.w;
  10459. var gl = w.globals;
  10460. var yaxisLabelCoords = this.dimYAxis.getyAxisLabelsCoords();
  10461. var yTitleCoords = this.dimYAxis.getyAxisTitleCoords();
  10462. w.globals.yLabelsCoords = [];
  10463. w.globals.yTitleCoords = [];
  10464. w.config.yaxis.map(function (yaxe, index) {
  10465. // store the labels and titles coords in global vars
  10466. w.globals.yLabelsCoords.push({
  10467. width: yaxisLabelCoords[index].width,
  10468. index: index
  10469. });
  10470. w.globals.yTitleCoords.push({
  10471. width: yTitleCoords[index].width,
  10472. index: index
  10473. });
  10474. });
  10475. this.yAxisWidth = this.dimYAxis.getTotalYAxisWidth();
  10476. var xaxisLabelCoords = this.dimXAxis.getxAxisLabelsCoords();
  10477. var xtitleCoords = this.dimXAxis.getxAxisTitleCoords();
  10478. this.conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords);
  10479. gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4;
  10480. gl.translateXAxisX = w.globals.rotateXLabels && w.globals.isXNumeric && w.config.xaxis.labels.rotate <= -45 ? -this.xAxisWidth / 4 : 0;
  10481. if (w.globals.isBarHorizontal) {
  10482. gl.rotateXLabels = false;
  10483. gl.translateXAxisY = -1 * (parseInt(w.config.xaxis.labels.style.fontSize, 10) / 1.5);
  10484. }
  10485. gl.translateXAxisY = gl.translateXAxisY + w.config.xaxis.labels.offsetY;
  10486. gl.translateXAxisX = gl.translateXAxisX + w.config.xaxis.labels.offsetX;
  10487. var yAxisWidth = this.yAxisWidth;
  10488. var xAxisHeight = this.xAxisHeight;
  10489. gl.xAxisLabelsHeight = this.xAxisHeight;
  10490. gl.xAxisHeight = this.xAxisHeight;
  10491. var translateY = 10;
  10492. if (w.config.chart.type === 'radar' || this.isSparkline) {
  10493. yAxisWidth = 0;
  10494. xAxisHeight = gl.goldenPadding;
  10495. }
  10496. if (this.isSparkline) {
  10497. this.lgRect = {
  10498. height: 0,
  10499. width: 0
  10500. };
  10501. xAxisHeight = 0;
  10502. yAxisWidth = 0;
  10503. translateY = 0;
  10504. }
  10505. this.dimXAxis.additionalPaddingXLabels(xaxisLabelCoords);
  10506. var legendTopBottom = function legendTopBottom() {
  10507. gl.translateX = yAxisWidth;
  10508. gl.gridHeight = gl.svgHeight - _this.lgRect.height - xAxisHeight - (!_this.isSparkline ? w.globals.rotateXLabels ? 10 : 15 : 0);
  10509. gl.gridWidth = gl.svgWidth - yAxisWidth;
  10510. };
  10511. if (w.config.xaxis.position === 'top') translateY = gl.xAxisHeight - w.config.xaxis.axisTicks.height - 5;
  10512. switch (w.config.legend.position) {
  10513. case 'bottom':
  10514. gl.translateY = translateY;
  10515. legendTopBottom();
  10516. break;
  10517. case 'top':
  10518. gl.translateY = this.lgRect.height + translateY;
  10519. legendTopBottom();
  10520. break;
  10521. case 'left':
  10522. gl.translateY = translateY;
  10523. gl.translateX = this.lgRect.width + yAxisWidth;
  10524. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  10525. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth;
  10526. break;
  10527. case 'right':
  10528. gl.translateY = translateY;
  10529. gl.translateX = yAxisWidth;
  10530. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  10531. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth - 5;
  10532. break;
  10533. default:
  10534. throw new Error('Legend position not supported');
  10535. }
  10536. this.dimGrid.setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords); // after drawing everything, set the Y axis positions
  10537. var objyAxis = new YAxis(this.ctx);
  10538. objyAxis.setYAxisXPosition(yaxisLabelCoords, yTitleCoords);
  10539. }
  10540. }, {
  10541. key: "setDimensionsForNonAxisCharts",
  10542. value: function setDimensionsForNonAxisCharts() {
  10543. var w = this.w;
  10544. var gl = w.globals;
  10545. var cnf = w.config;
  10546. var xPad = 0;
  10547. if (w.config.legend.show && !w.config.legend.floating) {
  10548. xPad = 20;
  10549. }
  10550. var type = cnf.chart.type === 'pie' || cnf.chart.type === 'donut' ? 'pie' : 'radialBar';
  10551. var offY = cnf.plotOptions[type].offsetY;
  10552. var offX = cnf.plotOptions[type].offsetX;
  10553. if (!cnf.legend.show || cnf.legend.floating) {
  10554. gl.gridHeight = gl.svgHeight - cnf.grid.padding.left + cnf.grid.padding.right;
  10555. gl.gridWidth = gl.gridHeight;
  10556. gl.translateY = offY;
  10557. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  10558. return;
  10559. }
  10560. switch (cnf.legend.position) {
  10561. case 'bottom':
  10562. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  10563. gl.gridWidth = gl.gridHeight;
  10564. gl.translateY = offY - 10;
  10565. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  10566. break;
  10567. case 'top':
  10568. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  10569. gl.gridWidth = gl.gridHeight;
  10570. gl.translateY = this.lgRect.height + offY + 10;
  10571. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  10572. break;
  10573. case 'left':
  10574. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad;
  10575. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  10576. gl.translateY = offY;
  10577. gl.translateX = offX + this.lgRect.width + xPad;
  10578. break;
  10579. case 'right':
  10580. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad - 5;
  10581. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  10582. gl.translateY = offY;
  10583. gl.translateX = offX + 10;
  10584. break;
  10585. default:
  10586. throw new Error('Legend position not supported');
  10587. }
  10588. }
  10589. }, {
  10590. key: "conditionalChecksForAxisCoords",
  10591. value: function conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords) {
  10592. var w = this.w;
  10593. this.xAxisHeight = (xaxisLabelCoords.height + xtitleCoords.height) * (w.globals.isMultiLineX ? 1.2 : w.globals.LINE_HEIGHT_RATIO) + (w.globals.rotateXLabels ? 22 : 10);
  10594. this.xAxisWidth = xaxisLabelCoords.width;
  10595. if (this.xAxisHeight - xtitleCoords.height > w.config.xaxis.labels.maxHeight) {
  10596. this.xAxisHeight = w.config.xaxis.labels.maxHeight;
  10597. }
  10598. if (w.config.xaxis.labels.minHeight && this.xAxisHeight < w.config.xaxis.labels.minHeight) {
  10599. this.xAxisHeight = w.config.xaxis.labels.minHeight;
  10600. }
  10601. if (w.config.xaxis.floating) {
  10602. this.xAxisHeight = 0;
  10603. }
  10604. var minYAxisWidth = 0;
  10605. var maxYAxisWidth = 0;
  10606. w.config.yaxis.forEach(function (y) {
  10607. minYAxisWidth += y.labels.minWidth;
  10608. maxYAxisWidth += y.labels.maxWidth;
  10609. });
  10610. if (this.yAxisWidth < minYAxisWidth) {
  10611. this.yAxisWidth = minYAxisWidth;
  10612. }
  10613. if (this.yAxisWidth > maxYAxisWidth) {
  10614. this.yAxisWidth = maxYAxisWidth;
  10615. }
  10616. }
  10617. }]);
  10618. return Dimensions;
  10619. }();
  10620. /**
  10621. * ApexCharts Pie Class for drawing Pie / Donut Charts.
  10622. * @module Pie
  10623. **/
  10624. var Pie = /*#__PURE__*/function () {
  10625. function Pie(ctx) {
  10626. _classCallCheck(this, Pie);
  10627. this.ctx = ctx;
  10628. this.w = ctx.w;
  10629. this.chartType = this.w.config.chart.type;
  10630. this.initialAnim = this.w.config.chart.animations.enabled;
  10631. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  10632. this.animBeginArr = [0];
  10633. this.animDur = 0;
  10634. this.donutDataLabels = this.w.config.plotOptions.pie.donut.labels;
  10635. var w = this.w;
  10636. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  10637. this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight : w.globals.gridWidth;
  10638. this.centerY = this.defaultSize / 2;
  10639. this.centerX = w.globals.gridWidth / 2;
  10640. this.fullAngle = 360;
  10641. w.globals.radialSize = this.defaultSize / 2.05 - w.config.stroke.width - (!w.config.chart.sparkline.enabled ? w.config.chart.dropShadow.blur : 0);
  10642. this.donutSize = w.globals.radialSize * parseInt(w.config.plotOptions.pie.donut.size, 10) / 100;
  10643. this.sliceLabels = [];
  10644. this.prevSectorAngleArr = []; // for dynamic animations
  10645. }
  10646. _createClass(Pie, [{
  10647. key: "draw",
  10648. value: function draw(series) {
  10649. var self = this;
  10650. var w = this.w;
  10651. var graphics = new Graphics(this.ctx);
  10652. var ret = graphics.group({
  10653. class: 'apexcharts-pie'
  10654. });
  10655. if (w.globals.noData) return ret;
  10656. var total = 0;
  10657. for (var k = 0; k < series.length; k++) {
  10658. // CALCULATE THE TOTAL
  10659. total += Utils.negToZero(series[k]);
  10660. }
  10661. var sectorAngleArr = []; // el to which series will be drawn
  10662. var elSeries = graphics.group(); // prevent division by zero error if there is no data
  10663. if (total === 0) {
  10664. total = 0.00001;
  10665. }
  10666. for (var i = 0; i < series.length; i++) {
  10667. // CALCULATE THE ANGLES
  10668. var angle = this.fullAngle * Utils.negToZero(series[i]) / total;
  10669. sectorAngleArr.push(angle);
  10670. }
  10671. if (w.globals.dataChanged) {
  10672. var prevTotal = 0;
  10673. for (var _k = 0; _k < w.globals.previousPaths.length; _k++) {
  10674. // CALCULATE THE PREV TOTAL
  10675. prevTotal += Utils.negToZero(w.globals.previousPaths[_k]);
  10676. }
  10677. var previousAngle;
  10678. for (var _i = 0; _i < w.globals.previousPaths.length; _i++) {
  10679. // CALCULATE THE PREVIOUS ANGLES
  10680. previousAngle = this.fullAngle * Utils.negToZero(w.globals.previousPaths[_i]) / prevTotal;
  10681. this.prevSectorAngleArr.push(previousAngle);
  10682. }
  10683. } // on small chart size after few count of resizes browser window donutSize can be negative
  10684. if (this.donutSize < 0) {
  10685. this.donutSize = 0;
  10686. }
  10687. var scaleSize = w.config.plotOptions.pie.customScale;
  10688. var halfW = w.globals.gridWidth / 2;
  10689. var halfH = w.globals.gridHeight / 2;
  10690. var translateX = halfW - w.globals.gridWidth / 2 * scaleSize;
  10691. var translateY = halfH - w.globals.gridHeight / 2 * scaleSize;
  10692. if (w.config.chart.type === 'donut') {
  10693. // draw the inner circle and add some text to it
  10694. var circle = graphics.drawCircle(this.donutSize);
  10695. circle.attr({
  10696. cx: this.centerX,
  10697. cy: this.centerY,
  10698. fill: w.config.plotOptions.pie.donut.background ? w.config.plotOptions.pie.donut.background : 'transparent'
  10699. });
  10700. elSeries.add(circle);
  10701. }
  10702. var elG = self.drawArcs(sectorAngleArr, series); // add slice dataLabels at the end
  10703. this.sliceLabels.forEach(function (s) {
  10704. elG.add(s);
  10705. });
  10706. elSeries.attr({
  10707. transform: "translate(".concat(translateX, ", ").concat(translateY, ") scale(").concat(scaleSize, ")")
  10708. });
  10709. elSeries.add(elG);
  10710. ret.add(elSeries);
  10711. if (this.donutDataLabels.show) {
  10712. var dataLabels = this.renderInnerDataLabels(this.donutDataLabels, {
  10713. hollowSize: this.donutSize,
  10714. centerX: this.centerX,
  10715. centerY: this.centerY,
  10716. opacity: this.donutDataLabels.show,
  10717. translateX: translateX,
  10718. translateY: translateY
  10719. });
  10720. ret.add(dataLabels);
  10721. }
  10722. return ret;
  10723. } // core function for drawing pie arcs
  10724. }, {
  10725. key: "drawArcs",
  10726. value: function drawArcs(sectorAngleArr, series) {
  10727. var w = this.w;
  10728. var filters = new Filters(this.ctx);
  10729. var graphics = new Graphics(this.ctx);
  10730. var fill = new Fill(this.ctx);
  10731. var g = graphics.group({
  10732. class: 'apexcharts-slices'
  10733. });
  10734. var startAngle = 0;
  10735. var prevStartAngle = 0;
  10736. var endAngle = 0;
  10737. var prevEndAngle = 0;
  10738. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  10739. for (var i = 0; i < sectorAngleArr.length; i++) {
  10740. var elPieArc = graphics.group({
  10741. class: "apexcharts-series apexcharts-pie-series",
  10742. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  10743. rel: i + 1,
  10744. 'data:realIndex': i
  10745. });
  10746. g.add(elPieArc);
  10747. startAngle = endAngle;
  10748. prevStartAngle = prevEndAngle;
  10749. endAngle = startAngle + sectorAngleArr[i];
  10750. prevEndAngle = prevStartAngle + this.prevSectorAngleArr[i];
  10751. var angle = endAngle - startAngle;
  10752. var pathFill = fill.fillPath({
  10753. seriesNumber: i,
  10754. size: w.globals.radialSize,
  10755. value: series[i]
  10756. }); // additionaly, pass size for gradient drawing in the fillPath function
  10757. var path = this.getChangedPath(prevStartAngle, prevEndAngle);
  10758. var elPath = graphics.drawPath({
  10759. d: path,
  10760. stroke: this.lineColorArr instanceof Array ? this.lineColorArr[i] : this.lineColorArr,
  10761. strokeWidth: 0,
  10762. fill: pathFill,
  10763. fillOpacity: w.config.fill.opacity,
  10764. classes: "apexcharts-pie-area apexcharts-".concat(w.config.chart.type, "-slice-").concat(i)
  10765. });
  10766. elPath.attr({
  10767. index: 0,
  10768. j: i
  10769. });
  10770. if (w.config.chart.dropShadow.enabled) {
  10771. var shadow = w.config.chart.dropShadow;
  10772. filters.dropShadow(elPath, shadow, i);
  10773. }
  10774. this.addListeners(elPath, this.donutDataLabels);
  10775. Graphics.setAttrs(elPath.node, {
  10776. 'data:angle': angle,
  10777. 'data:startAngle': startAngle,
  10778. 'data:strokeWidth': this.strokeWidth,
  10779. 'data:value': series[i]
  10780. });
  10781. var labelPosition = {
  10782. x: 0,
  10783. y: 0
  10784. };
  10785. if (w.config.chart.type === 'pie') {
  10786. labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, w.globals.radialSize / 1.25 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
  10787. } else if (w.config.chart.type === 'donut') {
  10788. labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, (w.globals.radialSize + this.donutSize) / 2 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
  10789. }
  10790. elPieArc.add(elPath); // Animation code starts
  10791. var dur = 0;
  10792. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  10793. dur = (endAngle - startAngle) / this.fullAngle * w.config.chart.animations.speed;
  10794. if (dur === 0) dur = 1;
  10795. this.animDur = dur + this.animDur;
  10796. this.animBeginArr.push(this.animDur);
  10797. } else {
  10798. this.animBeginArr.push(0);
  10799. }
  10800. if (this.dynamicAnim && w.globals.dataChanged) {
  10801. this.animatePaths(elPath, {
  10802. size: w.globals.radialSize,
  10803. endAngle: endAngle,
  10804. startAngle: startAngle,
  10805. prevStartAngle: prevStartAngle,
  10806. prevEndAngle: prevEndAngle,
  10807. animateStartingPos: true,
  10808. i: i,
  10809. animBeginArr: this.animBeginArr,
  10810. shouldSetPrevPaths: true,
  10811. dur: w.config.chart.animations.dynamicAnimation.speed
  10812. });
  10813. } else {
  10814. this.animatePaths(elPath, {
  10815. size: w.globals.radialSize,
  10816. endAngle: endAngle,
  10817. startAngle: startAngle,
  10818. i: i,
  10819. totalItems: sectorAngleArr.length - 1,
  10820. animBeginArr: this.animBeginArr,
  10821. dur: dur
  10822. });
  10823. } // animation code ends
  10824. if (w.config.plotOptions.pie.expandOnClick) {
  10825. elPath.click(this.pieClicked.bind(this, i));
  10826. }
  10827. if (w.config.dataLabels.enabled) {
  10828. var xPos = labelPosition.x;
  10829. var yPos = labelPosition.y;
  10830. var text = 100 * (endAngle - startAngle) / 360 + '%';
  10831. if (angle !== 0 && w.config.plotOptions.pie.dataLabels.minAngleToShowLabel < sectorAngleArr[i]) {
  10832. var formatter = w.config.dataLabels.formatter;
  10833. if (formatter !== undefined) {
  10834. text = formatter(w.globals.seriesPercent[i][0], {
  10835. seriesIndex: i,
  10836. w: w
  10837. });
  10838. }
  10839. var foreColor = w.globals.dataLabels.style.colors[i];
  10840. var elPieLabel = graphics.drawText({
  10841. x: xPos,
  10842. y: yPos,
  10843. text: text,
  10844. textAnchor: 'middle',
  10845. fontSize: w.config.dataLabels.style.fontSize,
  10846. fontFamily: w.config.dataLabels.style.fontFamily,
  10847. fontWeight: w.config.dataLabels.style.fontWeight,
  10848. foreColor: foreColor
  10849. });
  10850. if (w.config.dataLabels.dropShadow.enabled) {
  10851. var textShadow = w.config.dataLabels.dropShadow;
  10852. filters.dropShadow(elPieLabel, textShadow);
  10853. }
  10854. elPieLabel.node.classList.add('apexcharts-pie-label');
  10855. if (w.config.chart.animations.animate && w.globals.resized === false) {
  10856. elPieLabel.node.classList.add('apexcharts-pie-label-delay');
  10857. elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + 's';
  10858. }
  10859. this.sliceLabels.push(elPieLabel);
  10860. }
  10861. }
  10862. }
  10863. return g;
  10864. }
  10865. }, {
  10866. key: "addListeners",
  10867. value: function addListeners(elPath, dataLabels) {
  10868. var graphics = new Graphics(this.ctx); // append filters on mouseenter and mouseleave
  10869. elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath));
  10870. elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elPath));
  10871. elPath.node.addEventListener('mouseleave', this.revertDataLabelsInner.bind(this, elPath.node, dataLabels));
  10872. elPath.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elPath));
  10873. if (!this.donutDataLabels.total.showAlways) {
  10874. elPath.node.addEventListener('mouseenter', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  10875. elPath.node.addEventListener('mousedown', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  10876. }
  10877. } // This function can be used for other circle charts too
  10878. }, {
  10879. key: "animatePaths",
  10880. value: function animatePaths(el, opts) {
  10881. var w = this.w;
  10882. var me = this;
  10883. var angle = opts.endAngle - opts.startAngle;
  10884. var prevAngle = angle;
  10885. var fromStartAngle = opts.startAngle;
  10886. var toStartAngle = opts.startAngle;
  10887. if (opts.prevStartAngle !== undefined && opts.prevEndAngle !== undefined) {
  10888. fromStartAngle = opts.prevEndAngle;
  10889. prevAngle = opts.prevEndAngle - opts.prevStartAngle;
  10890. }
  10891. if (opts.i === w.config.series.length - 1) {
  10892. // some adjustments for the last overlapping paths
  10893. if (angle + toStartAngle > this.fullAngle) {
  10894. opts.endAngle = opts.endAngle - (angle + toStartAngle);
  10895. } else if (angle + toStartAngle < this.fullAngle) {
  10896. opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle));
  10897. }
  10898. }
  10899. if (angle === this.fullAngle) angle = this.fullAngle - 0.01;
  10900. me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts);
  10901. }
  10902. }, {
  10903. key: "animateArc",
  10904. value: function animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts) {
  10905. var me = this;
  10906. var w = this.w;
  10907. var animations = new Animations(this.ctx);
  10908. var size = opts.size;
  10909. var path;
  10910. if (isNaN(fromStartAngle) || isNaN(prevAngle)) {
  10911. fromStartAngle = toStartAngle;
  10912. prevAngle = angle;
  10913. opts.dur = 0;
  10914. }
  10915. var currAngle = angle;
  10916. var startAngle = toStartAngle;
  10917. var fromAngle = fromStartAngle - toStartAngle;
  10918. if (w.globals.dataChanged && opts.shouldSetPrevPaths) {
  10919. // to avoid flicker when updating, set prev path first and then animate from there
  10920. if (opts.prevEndAngle) {
  10921. path = me.getPiePath({
  10922. me: me,
  10923. startAngle: opts.prevStartAngle,
  10924. angle: opts.prevEndAngle - opts.prevStartAngle,
  10925. size: size
  10926. });
  10927. el.attr({
  10928. d: path
  10929. });
  10930. }
  10931. }
  10932. if (opts.dur !== 0) {
  10933. el.animate(opts.dur, w.globals.easing, opts.animBeginArr[opts.i]).afterAll(function () {
  10934. if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') {
  10935. this.animate(w.config.chart.animations.dynamicAnimation.speed).attr({
  10936. 'stroke-width': me.strokeWidth
  10937. });
  10938. }
  10939. if (opts.i === w.config.series.length - 1) {
  10940. animations.animationCompleted(el);
  10941. }
  10942. }).during(function (pos) {
  10943. currAngle = fromAngle + (angle - fromAngle) * pos;
  10944. if (opts.animateStartingPos) {
  10945. currAngle = prevAngle + (angle - prevAngle) * pos;
  10946. startAngle = fromStartAngle - prevAngle + (toStartAngle - (fromStartAngle - prevAngle)) * pos;
  10947. }
  10948. path = me.getPiePath({
  10949. me: me,
  10950. startAngle: startAngle,
  10951. angle: currAngle,
  10952. size: size
  10953. });
  10954. el.node.setAttribute('data:pathOrig', path);
  10955. el.attr({
  10956. d: path
  10957. });
  10958. });
  10959. } else {
  10960. path = me.getPiePath({
  10961. me: me,
  10962. startAngle: startAngle,
  10963. angle: angle,
  10964. size: size
  10965. });
  10966. if (!opts.isTrack) {
  10967. w.globals.animationEnded = true;
  10968. }
  10969. el.node.setAttribute('data:pathOrig', path);
  10970. el.attr({
  10971. d: path,
  10972. 'stroke-width': me.strokeWidth
  10973. });
  10974. }
  10975. }
  10976. }, {
  10977. key: "pieClicked",
  10978. value: function pieClicked(i) {
  10979. var w = this.w;
  10980. var me = this;
  10981. var path;
  10982. var size = me.w.globals.radialSize + (w.config.plotOptions.pie.expandOnClick ? 4 : 0);
  10983. var elPath = w.globals.dom.Paper.select(".apexcharts-".concat(w.config.chart.type.toLowerCase(), "-slice-").concat(i)).members[0];
  10984. if (elPath.attr('data:pieClicked') === 'true') {
  10985. elPath.attr({
  10986. 'data:pieClicked': 'false'
  10987. });
  10988. this.revertDataLabelsInner(elPath.node, this.donutDataLabels);
  10989. var origPath = elPath.attr('data:pathOrig');
  10990. elPath.attr({
  10991. d: origPath
  10992. });
  10993. return;
  10994. } else {
  10995. // reset all elems
  10996. var allEls = w.globals.dom.baseEl.getElementsByClassName('apexcharts-pie-area');
  10997. Array.prototype.forEach.call(allEls, function (pieSlice) {
  10998. pieSlice.setAttribute('data:pieClicked', 'false');
  10999. var origPath = pieSlice.getAttribute('data:pathOrig');
  11000. pieSlice.setAttribute('d', origPath);
  11001. });
  11002. elPath.attr('data:pieClicked', 'true');
  11003. }
  11004. var startAngle = parseInt(elPath.attr('data:startAngle'), 10);
  11005. var angle = parseInt(elPath.attr('data:angle'), 10);
  11006. path = me.getPiePath({
  11007. me: me,
  11008. startAngle: startAngle,
  11009. angle: angle,
  11010. size: size
  11011. });
  11012. if (angle === 360) return;
  11013. elPath.plot(path);
  11014. }
  11015. }, {
  11016. key: "getChangedPath",
  11017. value: function getChangedPath(prevStartAngle, prevEndAngle) {
  11018. var path = '';
  11019. if (this.dynamicAnim && this.w.globals.dataChanged) {
  11020. path = this.getPiePath({
  11021. me: this,
  11022. startAngle: prevStartAngle,
  11023. angle: prevEndAngle - prevStartAngle,
  11024. size: this.size
  11025. });
  11026. }
  11027. return path;
  11028. }
  11029. }, {
  11030. key: "getPiePath",
  11031. value: function getPiePath(_ref) {
  11032. var me = _ref.me,
  11033. startAngle = _ref.startAngle,
  11034. angle = _ref.angle,
  11035. size = _ref.size;
  11036. var w = this.w;
  11037. var path;
  11038. var startDeg = startAngle;
  11039. var startRadians = Math.PI * (startDeg - 90) / 180;
  11040. var endDeg = angle + startAngle;
  11041. if (Math.ceil(endDeg) >= 360) endDeg = 359.99;
  11042. var endRadians = Math.PI * (endDeg - 90) / 180;
  11043. var x1 = me.centerX + size * Math.cos(startRadians);
  11044. var y1 = me.centerY + size * Math.sin(startRadians);
  11045. var x2 = me.centerX + size * Math.cos(endRadians);
  11046. var y2 = me.centerY + size * Math.sin(endRadians);
  11047. var startInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, endDeg);
  11048. var endInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, startDeg);
  11049. var largeArc = angle > 180 ? 1 : 0;
  11050. var pathBeginning = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2];
  11051. if (w.config.chart.type === 'donut') {
  11052. 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(' ');
  11053. } else if (w.config.chart.type === 'pie') {
  11054. path = [].concat(pathBeginning, ['L', me.centerX, me.centerY, 'L', x1, y1]).join(' ');
  11055. } else {
  11056. path = [].concat(pathBeginning).join(' ');
  11057. }
  11058. return path;
  11059. }
  11060. }, {
  11061. key: "renderInnerDataLabels",
  11062. value: function renderInnerDataLabels(dataLabelsConfig, opts) {
  11063. var w = this.w;
  11064. var graphics = new Graphics(this.ctx);
  11065. var g = graphics.group({
  11066. class: 'apexcharts-datalabels-group',
  11067. transform: "translate(".concat(opts.translateX ? opts.translateX : 0, ", ").concat(opts.translateY ? opts.translateY : 0, ") scale(").concat(w.config.plotOptions.pie.customScale, ")")
  11068. });
  11069. var showTotal = dataLabelsConfig.total.show;
  11070. g.node.style.opacity = opts.opacity;
  11071. var x = opts.centerX;
  11072. var y = opts.centerY;
  11073. var labelColor, valueColor;
  11074. if (dataLabelsConfig.name.color === undefined) {
  11075. labelColor = w.globals.colors[0];
  11076. } else {
  11077. labelColor = dataLabelsConfig.name.color;
  11078. }
  11079. var labelFontSize = dataLabelsConfig.name.fontSize;
  11080. var labelFontFamily = dataLabelsConfig.name.fontFamily;
  11081. var labelFontWeight = dataLabelsConfig.value.fontWeight;
  11082. if (dataLabelsConfig.value.color === undefined) {
  11083. valueColor = w.config.chart.foreColor;
  11084. } else {
  11085. valueColor = dataLabelsConfig.value.color;
  11086. }
  11087. var lbFormatter = dataLabelsConfig.value.formatter;
  11088. var val = '';
  11089. var name = '';
  11090. if (showTotal) {
  11091. labelColor = dataLabelsConfig.total.color;
  11092. labelFontSize = dataLabelsConfig.total.fontSize;
  11093. labelFontFamily = dataLabelsConfig.total.fontFamily;
  11094. labelFontWeight = dataLabelsConfig.total.fontWeight;
  11095. name = dataLabelsConfig.total.label;
  11096. val = dataLabelsConfig.total.formatter(w);
  11097. } else {
  11098. if (w.globals.series.length === 1) {
  11099. val = lbFormatter(w.globals.series[0], w);
  11100. name = w.globals.seriesNames[0];
  11101. }
  11102. }
  11103. if (name) {
  11104. name = dataLabelsConfig.name.formatter(name, dataLabelsConfig.total.show, w);
  11105. }
  11106. if (dataLabelsConfig.name.show) {
  11107. var elLabel = graphics.drawText({
  11108. x: x,
  11109. y: y + parseFloat(dataLabelsConfig.name.offsetY),
  11110. text: name,
  11111. textAnchor: 'middle',
  11112. foreColor: labelColor,
  11113. fontSize: labelFontSize,
  11114. fontWeight: labelFontWeight,
  11115. fontFamily: labelFontFamily
  11116. });
  11117. elLabel.node.classList.add('apexcharts-datalabel-label');
  11118. g.add(elLabel);
  11119. }
  11120. if (dataLabelsConfig.value.show) {
  11121. var valOffset = dataLabelsConfig.name.show ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
  11122. var elValue = graphics.drawText({
  11123. x: x,
  11124. y: y + valOffset,
  11125. text: val,
  11126. textAnchor: 'middle',
  11127. foreColor: valueColor,
  11128. fontWeight: dataLabelsConfig.value.fontWeight,
  11129. fontSize: dataLabelsConfig.value.fontSize,
  11130. fontFamily: dataLabelsConfig.value.fontFamily
  11131. });
  11132. elValue.node.classList.add('apexcharts-datalabel-value');
  11133. g.add(elValue);
  11134. } // for a multi-series circle chart, we need to show total value instead of first series labels
  11135. return g;
  11136. }
  11137. /**
  11138. *
  11139. * @param {string} name - The name of the series
  11140. * @param {string} val - The value of that series
  11141. * @param {object} el - Optional el (indicates which series was hovered/clicked). If this param is not present, means we need to show total
  11142. */
  11143. }, {
  11144. key: "printInnerLabels",
  11145. value: function printInnerLabels(labelsConfig, name, val, el) {
  11146. var w = this.w;
  11147. var labelColor;
  11148. if (el) {
  11149. if (labelsConfig.name.color === undefined) {
  11150. labelColor = w.globals.colors[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  11151. } else {
  11152. labelColor = labelsConfig.name.color;
  11153. }
  11154. } else {
  11155. if (w.globals.series.length > 1 && labelsConfig.total.show) {
  11156. labelColor = labelsConfig.total.color;
  11157. }
  11158. }
  11159. var elLabel = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-label');
  11160. var elValue = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-value');
  11161. var lbFormatter = labelsConfig.value.formatter;
  11162. val = lbFormatter(val, w); // we need to show Total Val - so get the formatter of it
  11163. if (!el && typeof labelsConfig.total.formatter === 'function') {
  11164. val = labelsConfig.total.formatter(w);
  11165. }
  11166. var isTotal = name === labelsConfig.total.label;
  11167. name = labelsConfig.name.formatter(name, isTotal, w);
  11168. if (elLabel !== null) {
  11169. elLabel.textContent = name;
  11170. }
  11171. if (elValue !== null) {
  11172. elValue.textContent = val;
  11173. }
  11174. if (elLabel !== null) {
  11175. elLabel.style.fill = labelColor;
  11176. }
  11177. }
  11178. }, {
  11179. key: "printDataLabelsInner",
  11180. value: function printDataLabelsInner(el, dataLabelsConfig) {
  11181. var w = this.w;
  11182. var val = el.getAttribute('data:value');
  11183. var name = w.globals.seriesNames[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  11184. if (w.globals.series.length > 1) {
  11185. this.printInnerLabels(dataLabelsConfig, name, val, el);
  11186. }
  11187. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  11188. if (dataLabelsGroup !== null) {
  11189. dataLabelsGroup.style.opacity = 1;
  11190. }
  11191. }
  11192. }, {
  11193. key: "revertDataLabelsInner",
  11194. value: function revertDataLabelsInner(elem, dataLabelsConfig, event) {
  11195. var _this = this;
  11196. var w = this.w;
  11197. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  11198. var sliceOut = false;
  11199. var slices = w.globals.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
  11200. var selectSlice = function selectSlice(_ref2) {
  11201. var makeSliceOut = _ref2.makeSliceOut,
  11202. printLabel = _ref2.printLabel;
  11203. Array.prototype.forEach.call(slices, function (s) {
  11204. if (s.getAttribute('data:pieClicked') === 'true') {
  11205. if (makeSliceOut) {
  11206. sliceOut = true;
  11207. }
  11208. if (printLabel) {
  11209. _this.printDataLabelsInner(s, dataLabelsConfig);
  11210. }
  11211. }
  11212. });
  11213. };
  11214. selectSlice({
  11215. makeSliceOut: true,
  11216. printLabel: false
  11217. });
  11218. if (dataLabelsConfig.total.show && w.globals.series.length > 1) {
  11219. if (sliceOut && !dataLabelsConfig.total.showAlways) {
  11220. selectSlice({
  11221. makeSliceOut: false,
  11222. printLabel: true
  11223. });
  11224. } else {
  11225. this.printInnerLabels(dataLabelsConfig, dataLabelsConfig.total.label, dataLabelsConfig.total.formatter(w));
  11226. }
  11227. } else {
  11228. selectSlice({
  11229. makeSliceOut: false,
  11230. printLabel: true
  11231. });
  11232. if (!sliceOut) {
  11233. if (w.globals.selectedDataPoints.length && w.globals.series.length > 1) {
  11234. if (w.globals.selectedDataPoints[0].length > 0) {
  11235. var index = w.globals.selectedDataPoints[0];
  11236. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(w.config.chart.type.toLowerCase(), "-slice-").concat(index));
  11237. this.printDataLabelsInner(el, dataLabelsConfig);
  11238. } else if (dataLabelsGroup && w.globals.selectedDataPoints.length && w.globals.selectedDataPoints[0].length === 0) {
  11239. dataLabelsGroup.style.opacity = 0;
  11240. }
  11241. } else {
  11242. if (dataLabelsGroup && w.globals.series.length > 1) {
  11243. dataLabelsGroup.style.opacity = 0;
  11244. }
  11245. }
  11246. }
  11247. }
  11248. }
  11249. }]);
  11250. return Pie;
  11251. }();
  11252. var Helpers$2 = /*#__PURE__*/function () {
  11253. function Helpers(lgCtx) {
  11254. _classCallCheck(this, Helpers);
  11255. this.w = lgCtx.w;
  11256. this.lgCtx = lgCtx;
  11257. }
  11258. _createClass(Helpers, [{
  11259. key: "getLegendStyles",
  11260. value: function getLegendStyles() {
  11261. var stylesheet = document.createElement('style');
  11262. stylesheet.setAttribute('type', 'text/css');
  11263. 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 }";
  11264. var rules = document.createTextNode(text);
  11265. stylesheet.appendChild(rules);
  11266. return stylesheet;
  11267. }
  11268. }, {
  11269. key: "getLegendBBox",
  11270. value: function getLegendBBox() {
  11271. var w = this.w;
  11272. var currLegendsWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  11273. var currLegendsWrapRect = currLegendsWrap.getBoundingClientRect();
  11274. var currLegendsWrapWidth = currLegendsWrapRect.width;
  11275. var currLegendsWrapHeight = currLegendsWrapRect.height;
  11276. return {
  11277. clwh: currLegendsWrapHeight,
  11278. clww: currLegendsWrapWidth
  11279. };
  11280. }
  11281. }, {
  11282. key: "appendToForeignObject",
  11283. value: function appendToForeignObject() {
  11284. var gl = this.w.globals;
  11285. gl.dom.elLegendForeign = document.createElementNS(gl.SVGNS, 'foreignObject');
  11286. var elForeign = gl.dom.elLegendForeign;
  11287. elForeign.setAttribute('x', 0);
  11288. elForeign.setAttribute('y', 0);
  11289. elForeign.setAttribute('width', gl.svgWidth);
  11290. elForeign.setAttribute('height', gl.svgHeight);
  11291. gl.dom.elLegendWrap.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
  11292. elForeign.appendChild(gl.dom.elLegendWrap);
  11293. elForeign.appendChild(this.getLegendStyles());
  11294. gl.dom.Paper.node.insertBefore(elForeign, gl.dom.elGraphical.node);
  11295. }
  11296. }, {
  11297. key: "toggleDataSeries",
  11298. value: function toggleDataSeries(seriesCnt, isHidden) {
  11299. var _this = this;
  11300. var w = this.w;
  11301. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  11302. w.globals.resized = true; // we don't want initial animations again
  11303. var seriesEl = null;
  11304. var realIndex = null; // yes, make it null. 1 series will rise at a time
  11305. w.globals.risingSeries = [];
  11306. if (w.globals.axisCharts) {
  11307. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  11308. realIndex = parseInt(seriesEl.getAttribute('data:realIndex'), 10);
  11309. } else {
  11310. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  11311. realIndex = parseInt(seriesEl.getAttribute('rel'), 10) - 1;
  11312. }
  11313. if (isHidden) {
  11314. var seriesToMakeVisible = [{
  11315. cs: w.globals.collapsedSeries,
  11316. csi: w.globals.collapsedSeriesIndices
  11317. }, {
  11318. cs: w.globals.ancillaryCollapsedSeries,
  11319. csi: w.globals.ancillaryCollapsedSeriesIndices
  11320. }];
  11321. seriesToMakeVisible.forEach(function (r) {
  11322. _this.riseCollapsedSeries(r.cs, r.csi, realIndex);
  11323. });
  11324. } else {
  11325. this.hideSeries({
  11326. seriesEl: seriesEl,
  11327. realIndex: realIndex
  11328. });
  11329. }
  11330. } else {
  11331. // for non-axis charts i.e pie / donuts
  11332. var _seriesEl = w.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  11333. var type = w.config.chart.type;
  11334. if (type === 'pie' || type === 'donut') {
  11335. var dataLabels = w.config.plotOptions.pie.donut.labels;
  11336. var graphics = new Graphics(this.lgCtx.ctx);
  11337. var pie = new Pie(this.lgCtx.ctx);
  11338. graphics.pathMouseDown(_seriesEl.members[0], null);
  11339. pie.printDataLabelsInner(_seriesEl.members[0].node, dataLabels);
  11340. }
  11341. _seriesEl.fire('click');
  11342. }
  11343. }
  11344. }, {
  11345. key: "hideSeries",
  11346. value: function hideSeries(_ref) {
  11347. var seriesEl = _ref.seriesEl,
  11348. realIndex = _ref.realIndex;
  11349. var w = this.w;
  11350. if (w.globals.axisCharts) {
  11351. var shouldNotHideYAxis = false;
  11352. if (w.config.yaxis[realIndex] && w.config.yaxis[realIndex].show && w.config.yaxis[realIndex].showAlways) {
  11353. shouldNotHideYAxis = true;
  11354. if (w.globals.ancillaryCollapsedSeriesIndices.indexOf(realIndex) < 0) {
  11355. w.globals.ancillaryCollapsedSeries.push({
  11356. index: realIndex,
  11357. data: w.config.series[realIndex].data.slice(),
  11358. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  11359. });
  11360. w.globals.ancillaryCollapsedSeriesIndices.push(realIndex);
  11361. }
  11362. }
  11363. if (!shouldNotHideYAxis) {
  11364. w.globals.collapsedSeries.push({
  11365. index: realIndex,
  11366. data: w.config.series[realIndex].data.slice(),
  11367. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  11368. });
  11369. w.globals.collapsedSeriesIndices.push(realIndex);
  11370. var removeIndexOfRising = w.globals.risingSeries.indexOf(realIndex);
  11371. w.globals.risingSeries.splice(removeIndexOfRising, 1);
  11372. } // TODO: AVOID mutating the user's config object below
  11373. w.config.series[realIndex].data = [];
  11374. } else {
  11375. w.globals.collapsedSeries.push({
  11376. index: realIndex,
  11377. data: w.config.series[realIndex]
  11378. });
  11379. w.globals.collapsedSeriesIndices.push(realIndex);
  11380. w.config.series[realIndex] = 0;
  11381. }
  11382. var seriesChildren = seriesEl.childNodes;
  11383. for (var sc = 0; sc < seriesChildren.length; sc++) {
  11384. if (seriesChildren[sc].classList.contains('apexcharts-series-markers-wrap')) {
  11385. if (seriesChildren[sc].classList.contains('apexcharts-hide')) {
  11386. seriesChildren[sc].classList.remove('apexcharts-hide');
  11387. } else {
  11388. seriesChildren[sc].classList.add('apexcharts-hide');
  11389. }
  11390. }
  11391. }
  11392. w.globals.allSeriesCollapsed = w.globals.collapsedSeries.length === w.config.series.length;
  11393. this.lgCtx.ctx.updateHelpers._updateSeries(w.config.series, w.config.chart.animations.dynamicAnimation.enabled);
  11394. }
  11395. }, {
  11396. key: "riseCollapsedSeries",
  11397. value: function riseCollapsedSeries(series, seriesIndices, realIndex) {
  11398. var w = this.w;
  11399. if (series.length > 0) {
  11400. for (var c = 0; c < series.length; c++) {
  11401. if (series[c].index === realIndex) {
  11402. if (w.globals.axisCharts) {
  11403. w.config.series[realIndex].data = series[c].data.slice();
  11404. series.splice(c, 1);
  11405. seriesIndices.splice(c, 1);
  11406. w.globals.risingSeries.push(realIndex);
  11407. } else {
  11408. w.config.series[realIndex] = series[c].data;
  11409. series.splice(c, 1);
  11410. seriesIndices.splice(c, 1);
  11411. w.globals.risingSeries.push(realIndex);
  11412. }
  11413. this.lgCtx.ctx.updateHelpers._updateSeries(w.config.series, w.config.chart.animations.dynamicAnimation.enabled);
  11414. }
  11415. }
  11416. }
  11417. }
  11418. }]);
  11419. return Helpers;
  11420. }();
  11421. /**
  11422. * ApexCharts Legend Class to draw legend.
  11423. *
  11424. * @module Legend
  11425. **/
  11426. var Legend = /*#__PURE__*/function () {
  11427. function Legend(ctx, opts) {
  11428. _classCallCheck(this, Legend);
  11429. this.ctx = ctx;
  11430. this.w = ctx.w;
  11431. this.onLegendClick = this.onLegendClick.bind(this);
  11432. this.onLegendHovered = this.onLegendHovered.bind(this);
  11433. this.isBarsDistributed = this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.distributed && this.w.config.series.length === 1;
  11434. this.legendHelpers = new Helpers$2(this);
  11435. }
  11436. _createClass(Legend, [{
  11437. key: "init",
  11438. value: function init() {
  11439. var w = this.w;
  11440. var gl = w.globals;
  11441. var cnf = w.config;
  11442. var showLegendAlways = cnf.legend.showForSingleSeries && gl.series.length === 1 || this.isBarsDistributed || gl.series.length > 1;
  11443. if ((showLegendAlways || !gl.axisCharts) && cnf.legend.show) {
  11444. while (gl.dom.elLegendWrap.firstChild) {
  11445. gl.dom.elLegendWrap.removeChild(gl.dom.elLegendWrap.firstChild);
  11446. }
  11447. this.drawLegends();
  11448. if (!Utils.isIE11()) {
  11449. this.legendHelpers.appendToForeignObject();
  11450. } else {
  11451. // IE11 doesn't supports foreignObject, hence append it to <head>
  11452. document.getElementsByTagName('head')[0].appendChild(this.legendHelpers.getLegendStyles());
  11453. }
  11454. if (cnf.legend.position === 'bottom' || cnf.legend.position === 'top') {
  11455. this.legendAlignHorizontal();
  11456. } else if (cnf.legend.position === 'right' || cnf.legend.position === 'left') {
  11457. this.legendAlignVertical();
  11458. }
  11459. }
  11460. }
  11461. }, {
  11462. key: "drawLegends",
  11463. value: function drawLegends() {
  11464. var self = this;
  11465. var w = this.w;
  11466. var fontFamily = w.config.legend.fontFamily;
  11467. var legendNames = w.globals.seriesNames;
  11468. var fillcolor = w.globals.colors.slice();
  11469. if (w.config.chart.type === 'heatmap') {
  11470. var ranges = w.config.plotOptions.heatmap.colorScale.ranges;
  11471. legendNames = ranges.map(function (colorScale) {
  11472. return colorScale.name ? colorScale.name : colorScale.from + ' - ' + colorScale.to;
  11473. });
  11474. fillcolor = ranges.map(function (color) {
  11475. return color.color;
  11476. });
  11477. } else if (this.isBarsDistributed) {
  11478. legendNames = w.globals.labels.slice();
  11479. }
  11480. var legendFormatter = w.globals.legendFormatter;
  11481. var isLegendInversed = w.config.legend.inverseOrder;
  11482. for (var i = isLegendInversed ? legendNames.length - 1 : 0; isLegendInversed ? i >= 0 : i <= legendNames.length - 1; isLegendInversed ? i-- : i++) {
  11483. var text = legendFormatter(legendNames[i], {
  11484. seriesIndex: i,
  11485. w: w
  11486. });
  11487. var collapsedSeries = false;
  11488. var ancillaryCollapsedSeries = false;
  11489. if (w.globals.collapsedSeries.length > 0) {
  11490. for (var c = 0; c < w.globals.collapsedSeries.length; c++) {
  11491. if (w.globals.collapsedSeries[c].index === i) {
  11492. collapsedSeries = true;
  11493. }
  11494. }
  11495. }
  11496. if (w.globals.ancillaryCollapsedSeriesIndices.length > 0) {
  11497. for (var _c = 0; _c < w.globals.ancillaryCollapsedSeriesIndices.length; _c++) {
  11498. if (w.globals.ancillaryCollapsedSeriesIndices[_c] === i) {
  11499. ancillaryCollapsedSeries = true;
  11500. }
  11501. }
  11502. }
  11503. var elMarker = document.createElement('span');
  11504. elMarker.classList.add('apexcharts-legend-marker');
  11505. var mOffsetX = w.config.legend.markers.offsetX;
  11506. var mOffsetY = w.config.legend.markers.offsetY;
  11507. var mHeight = w.config.legend.markers.height;
  11508. var mWidth = w.config.legend.markers.width;
  11509. var mBorderWidth = w.config.legend.markers.strokeWidth;
  11510. var mBorderColor = w.config.legend.markers.strokeColor;
  11511. var mBorderRadius = w.config.legend.markers.radius;
  11512. var mStyle = elMarker.style;
  11513. mStyle.background = fillcolor[i];
  11514. mStyle.color = fillcolor[i]; // override fill color with custom legend.markers.fillColors
  11515. if (w.config.legend.markers.fillColors && w.config.legend.markers.fillColors[i]) {
  11516. mStyle.background = w.config.legend.markers.fillColors[i];
  11517. }
  11518. mStyle.height = Array.isArray(mHeight) ? parseFloat(mHeight[i]) + 'px' : parseFloat(mHeight) + 'px';
  11519. mStyle.width = Array.isArray(mWidth) ? parseFloat(mWidth[i]) + 'px' : parseFloat(mWidth) + 'px';
  11520. mStyle.left = Array.isArray(mOffsetX) ? mOffsetX[i] : mOffsetX;
  11521. mStyle.top = Array.isArray(mOffsetY) ? mOffsetY[i] : mOffsetY;
  11522. mStyle.borderWidth = Array.isArray(mBorderWidth) ? mBorderWidth[i] : mBorderWidth;
  11523. mStyle.borderColor = Array.isArray(mBorderColor) ? mBorderColor[i] : mBorderColor;
  11524. mStyle.borderRadius = Array.isArray(mBorderRadius) ? parseFloat(mBorderRadius[i]) + 'px' : parseFloat(mBorderRadius) + 'px';
  11525. if (w.config.legend.markers.customHTML) {
  11526. if (Array.isArray(w.config.legend.markers.customHTML)) {
  11527. elMarker.innerHTML = w.config.legend.markers.customHTML[i]();
  11528. } else {
  11529. elMarker.innerHTML = w.config.legend.markers.customHTML();
  11530. }
  11531. }
  11532. Graphics.setAttrs(elMarker, {
  11533. rel: i + 1,
  11534. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  11535. });
  11536. if (collapsedSeries || ancillaryCollapsedSeries) {
  11537. elMarker.classList.add('apexcharts-inactive-legend');
  11538. }
  11539. var elLegend = document.createElement('div');
  11540. var elLegendText = document.createElement('span');
  11541. elLegendText.classList.add('apexcharts-legend-text');
  11542. elLegendText.innerHTML = Array.isArray(text) ? text.join(' ') : text;
  11543. var textColor = w.config.legend.labels.useSeriesColors ? w.globals.colors[i] : w.config.legend.labels.colors;
  11544. if (!textColor) {
  11545. textColor = w.config.chart.foreColor;
  11546. }
  11547. elLegendText.style.color = textColor;
  11548. elLegendText.style.fontSize = parseFloat(w.config.legend.fontSize) + 'px';
  11549. elLegendText.style.fontWeight = w.config.legend.fontWeight;
  11550. elLegendText.style.fontFamily = fontFamily || w.config.chart.fontFamily;
  11551. Graphics.setAttrs(elLegendText, {
  11552. rel: i + 1,
  11553. i: i,
  11554. 'data:default-text': encodeURIComponent(text),
  11555. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  11556. });
  11557. elLegend.appendChild(elMarker);
  11558. elLegend.appendChild(elLegendText);
  11559. var coreUtils = new CoreUtils(this.ctx);
  11560. if (!w.config.legend.showForZeroSeries) {
  11561. var total = coreUtils.getSeriesTotalByIndex(i);
  11562. if (total === 0 && coreUtils.seriesHaveSameValues(i) && !coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  11563. elLegend.classList.add('apexcharts-hidden-zero-series');
  11564. }
  11565. }
  11566. if (!w.config.legend.showForNullSeries) {
  11567. if (coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  11568. elLegend.classList.add('apexcharts-hidden-null-series');
  11569. }
  11570. }
  11571. w.globals.dom.elLegendWrap.appendChild(elLegend);
  11572. w.globals.dom.elLegendWrap.classList.add("apexcharts-align-".concat(w.config.legend.horizontalAlign));
  11573. w.globals.dom.elLegendWrap.classList.add('position-' + w.config.legend.position);
  11574. elLegend.classList.add('apexcharts-legend-series');
  11575. elLegend.style.margin = "".concat(w.config.legend.itemMargin.vertical, "px ").concat(w.config.legend.itemMargin.horizontal, "px");
  11576. w.globals.dom.elLegendWrap.style.width = w.config.legend.width ? w.config.legend.width + 'px' : '';
  11577. w.globals.dom.elLegendWrap.style.height = w.config.legend.height ? w.config.legend.height + 'px' : '';
  11578. Graphics.setAttrs(elLegend, {
  11579. rel: i + 1,
  11580. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  11581. });
  11582. if (collapsedSeries || ancillaryCollapsedSeries) {
  11583. elLegend.classList.add('apexcharts-inactive-legend');
  11584. }
  11585. if (!w.config.legend.onItemClick.toggleDataSeries) {
  11586. elLegend.classList.add('apexcharts-no-click');
  11587. }
  11588. } // for now - just prevent click on heatmap legend - and allow hover only
  11589. var clickAllowed = w.config.chart.type !== 'heatmap' && !this.isBarsDistributed;
  11590. if (clickAllowed && w.config.legend.onItemClick.toggleDataSeries) {
  11591. w.globals.dom.elWrap.addEventListener('click', self.onLegendClick, true);
  11592. }
  11593. if (w.config.legend.onItemHover.highlightDataSeries) {
  11594. w.globals.dom.elWrap.addEventListener('mousemove', self.onLegendHovered, true);
  11595. w.globals.dom.elWrap.addEventListener('mouseout', self.onLegendHovered, true);
  11596. }
  11597. }
  11598. }, {
  11599. key: "setLegendWrapXY",
  11600. value: function setLegendWrapXY(offsetX, offsetY) {
  11601. var w = this.w;
  11602. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  11603. var legendRect = elLegendWrap.getBoundingClientRect();
  11604. var x = 0;
  11605. var y = 0;
  11606. if (w.config.legend.position === 'bottom') {
  11607. y = y + (w.globals.svgHeight - legendRect.height / 2);
  11608. } else if (w.config.legend.position === 'top') {
  11609. var dim = new Dimensions(this.ctx);
  11610. var titleH = dim.dimHelpers.getTitleSubtitleCoords('title').height;
  11611. var subtitleH = dim.dimHelpers.getTitleSubtitleCoords('subtitle').height;
  11612. y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0);
  11613. }
  11614. elLegendWrap.style.position = 'absolute';
  11615. x = x + offsetX + w.config.legend.offsetX;
  11616. y = y + offsetY + w.config.legend.offsetY;
  11617. elLegendWrap.style.left = x + 'px';
  11618. elLegendWrap.style.top = y + 'px';
  11619. if (w.config.legend.position === 'bottom') {
  11620. elLegendWrap.style.top = 'auto';
  11621. elLegendWrap.style.bottom = 5 - w.config.legend.offsetY + 'px';
  11622. } else if (w.config.legend.position === 'right') {
  11623. elLegendWrap.style.left = 'auto';
  11624. elLegendWrap.style.right = 25 + w.config.legend.offsetX + 'px';
  11625. }
  11626. var fixedHeigthWidth = ['width', 'height'];
  11627. fixedHeigthWidth.forEach(function (hw) {
  11628. if (elLegendWrap.style[hw]) {
  11629. elLegendWrap.style[hw] = parseInt(w.config.legend[hw], 10) + 'px';
  11630. }
  11631. });
  11632. }
  11633. }, {
  11634. key: "legendAlignHorizontal",
  11635. value: function legendAlignHorizontal() {
  11636. var w = this.w;
  11637. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  11638. elLegendWrap.style.right = 0;
  11639. var lRect = this.legendHelpers.getLegendBBox();
  11640. var dimensions = new Dimensions(this.ctx);
  11641. var titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title');
  11642. var subtitleRect = dimensions.dimHelpers.getTitleSubtitleCoords('subtitle');
  11643. var offsetX = 20;
  11644. var offsetY = 0; // the whole legend box is set to bottom
  11645. if (w.config.legend.position === 'bottom') {
  11646. offsetY = -lRect.clwh / 1.8;
  11647. } else if (w.config.legend.position === 'top') {
  11648. offsetY = titleRect.height + subtitleRect.height + w.config.title.margin + w.config.subtitle.margin - 10;
  11649. }
  11650. this.setLegendWrapXY(offsetX, offsetY);
  11651. }
  11652. }, {
  11653. key: "legendAlignVertical",
  11654. value: function legendAlignVertical() {
  11655. var w = this.w;
  11656. var lRect = this.legendHelpers.getLegendBBox();
  11657. var offsetY = 20;
  11658. var offsetX = 0;
  11659. if (w.config.legend.position === 'left') {
  11660. offsetX = 20;
  11661. }
  11662. if (w.config.legend.position === 'right') {
  11663. offsetX = w.globals.svgWidth - lRect.clww - 10;
  11664. }
  11665. this.setLegendWrapXY(offsetX, offsetY);
  11666. }
  11667. }, {
  11668. key: "onLegendHovered",
  11669. value: function onLegendHovered(e) {
  11670. var w = this.w;
  11671. var hoverOverLegend = e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker');
  11672. if (w.config.chart.type !== 'heatmap' && !this.isBarsDistributed) {
  11673. if (!e.target.classList.contains('apexcharts-inactive-legend') && hoverOverLegend) {
  11674. var series = new Series(this.ctx);
  11675. series.toggleSeriesOnHover(e, e.target);
  11676. }
  11677. } else {
  11678. // for heatmap handling
  11679. if (hoverOverLegend) {
  11680. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  11681. this.ctx.events.fireEvent('legendHover', [this.ctx, seriesCnt, this.w]);
  11682. var _series = new Series(this.ctx);
  11683. _series.highlightRangeInSeries(e, e.target);
  11684. }
  11685. }
  11686. }
  11687. }, {
  11688. key: "onLegendClick",
  11689. value: function onLegendClick(e) {
  11690. if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker')) {
  11691. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  11692. var isHidden = e.target.getAttribute('data:collapsed') === 'true';
  11693. var legendClick = this.w.config.chart.events.legendClick;
  11694. if (typeof legendClick === 'function') {
  11695. legendClick(this.ctx, seriesCnt, this.w);
  11696. }
  11697. this.ctx.events.fireEvent('legendClick', [this.ctx, seriesCnt, this.w]);
  11698. var markerClick = this.w.config.legend.markers.onClick;
  11699. if (typeof markerClick === 'function' && e.target.classList.contains('apexcharts-legend-marker')) {
  11700. markerClick(this.ctx, seriesCnt, this.w);
  11701. this.ctx.events.fireEvent('legendMarkerClick', [this.ctx, seriesCnt, this.w]);
  11702. }
  11703. this.legendHelpers.toggleDataSeries(seriesCnt, isHidden);
  11704. }
  11705. }
  11706. }]);
  11707. return Legend;
  11708. }();
  11709. 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>";
  11710. 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>";
  11711. 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>";
  11712. 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";
  11713. 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";
  11714. 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>";
  11715. 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>";
  11716. /**
  11717. * ApexCharts Toolbar Class for creating toolbar in axis based charts.
  11718. *
  11719. * @module Toolbar
  11720. **/
  11721. var Toolbar = /*#__PURE__*/function () {
  11722. function Toolbar(ctx) {
  11723. _classCallCheck(this, Toolbar);
  11724. this.ctx = ctx;
  11725. this.w = ctx.w;
  11726. this.ev = this.w.config.chart.events;
  11727. this.selectedClass = 'apexcharts-selected';
  11728. this.localeValues = this.w.globals.locale.toolbar;
  11729. }
  11730. _createClass(Toolbar, [{
  11731. key: "createToolbar",
  11732. value: function createToolbar() {
  11733. var _this = this;
  11734. var w = this.w;
  11735. var createDiv = function createDiv() {
  11736. return document.createElement('div');
  11737. };
  11738. var elToolbarWrap = createDiv();
  11739. elToolbarWrap.setAttribute('class', 'apexcharts-toolbar');
  11740. elToolbarWrap.style.top = w.config.chart.toolbar.offsetY + 'px';
  11741. elToolbarWrap.style.right = -w.config.chart.toolbar.offsetX + 3 + 'px';
  11742. w.globals.dom.elWrap.appendChild(elToolbarWrap);
  11743. this.elZoom = createDiv();
  11744. this.elZoomIn = createDiv();
  11745. this.elZoomOut = createDiv();
  11746. this.elPan = createDiv();
  11747. this.elSelection = createDiv();
  11748. this.elZoomReset = createDiv();
  11749. this.elMenuIcon = createDiv();
  11750. this.elMenu = createDiv();
  11751. this.elCustomIcons = [];
  11752. this.t = w.config.chart.toolbar.tools;
  11753. if (Array.isArray(this.t.customIcons)) {
  11754. for (var i = 0; i < this.t.customIcons.length; i++) {
  11755. this.elCustomIcons.push(createDiv());
  11756. }
  11757. }
  11758. var toolbarControls = [];
  11759. var appendZoomControl = function appendZoomControl(type, el, ico) {
  11760. var tool = type.toLowerCase();
  11761. if (_this.t[tool] && w.config.chart.zoom.enabled) {
  11762. toolbarControls.push({
  11763. el: el,
  11764. icon: typeof _this.t[tool] === 'string' ? _this.t[tool] : ico,
  11765. title: _this.localeValues[type],
  11766. class: "apexcharts-".concat(tool, "-icon")
  11767. });
  11768. }
  11769. };
  11770. appendZoomControl('zoomIn', this.elZoomIn, icoZoomIn);
  11771. appendZoomControl('zoomOut', this.elZoomOut, icoZoomOut);
  11772. var zoomSelectionCtrls = function zoomSelectionCtrls(z) {
  11773. if (_this.t[z] && w.config.chart[z].enabled) {
  11774. toolbarControls.push({
  11775. el: z === 'zoom' ? _this.elZoom : _this.elSelection,
  11776. icon: typeof _this.t[z] === 'string' ? _this.t[z] : z === 'zoom' ? icoZoom : icoSelect,
  11777. title: _this.localeValues[z === 'zoom' ? 'selectionZoom' : 'selection'],
  11778. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : "apexcharts-".concat(z, "-icon")
  11779. });
  11780. }
  11781. };
  11782. zoomSelectionCtrls('zoom');
  11783. zoomSelectionCtrls('selection');
  11784. if (this.t.pan && w.config.chart.zoom.enabled) {
  11785. toolbarControls.push({
  11786. el: this.elPan,
  11787. icon: typeof this.t.pan === 'string' ? this.t.pan : icoPan,
  11788. title: this.localeValues.pan,
  11789. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : 'apexcharts-pan-icon'
  11790. });
  11791. }
  11792. appendZoomControl('reset', this.elZoomReset, icoReset);
  11793. if (this.t.download) {
  11794. toolbarControls.push({
  11795. el: this.elMenuIcon,
  11796. icon: typeof this.t.download === 'string' ? this.t.download : icoMenu,
  11797. title: this.localeValues.menu,
  11798. class: 'apexcharts-menu-icon'
  11799. });
  11800. }
  11801. for (var _i = 0; _i < this.elCustomIcons.length; _i++) {
  11802. toolbarControls.push({
  11803. el: this.elCustomIcons[_i],
  11804. icon: this.t.customIcons[_i].icon,
  11805. title: this.t.customIcons[_i].title,
  11806. index: this.t.customIcons[_i].index,
  11807. class: 'apexcharts-toolbar-custom-icon ' + this.t.customIcons[_i].class
  11808. });
  11809. }
  11810. toolbarControls.forEach(function (t, index) {
  11811. if (t.index) {
  11812. Utils.moveIndexInArray(toolbarControls, index, t.index);
  11813. }
  11814. });
  11815. for (var _i2 = 0; _i2 < toolbarControls.length; _i2++) {
  11816. Graphics.setAttrs(toolbarControls[_i2].el, {
  11817. class: toolbarControls[_i2].class,
  11818. title: toolbarControls[_i2].title
  11819. });
  11820. toolbarControls[_i2].el.innerHTML = toolbarControls[_i2].icon;
  11821. elToolbarWrap.appendChild(toolbarControls[_i2].el);
  11822. }
  11823. this._createHamburgerMenu(elToolbarWrap);
  11824. if (w.globals.zoomEnabled) {
  11825. this.elZoom.classList.add(this.selectedClass);
  11826. } else if (w.globals.panEnabled) {
  11827. this.elPan.classList.add(this.selectedClass);
  11828. } else if (w.globals.selectionEnabled) {
  11829. this.elSelection.classList.add(this.selectedClass);
  11830. }
  11831. this.addToolbarEventListeners();
  11832. }
  11833. }, {
  11834. key: "_createHamburgerMenu",
  11835. value: function _createHamburgerMenu(parent) {
  11836. this.elMenuItems = [];
  11837. parent.appendChild(this.elMenu);
  11838. Graphics.setAttrs(this.elMenu, {
  11839. class: 'apexcharts-menu'
  11840. });
  11841. var menuItems = [{
  11842. name: 'exportSVG',
  11843. title: this.localeValues.exportToSVG
  11844. }, {
  11845. name: 'exportPNG',
  11846. title: this.localeValues.exportToPNG
  11847. }, {
  11848. name: 'exportCSV',
  11849. title: this.localeValues.exportToCSV
  11850. }];
  11851. if (!this.w.globals.allSeriesHasEqualX) {
  11852. // if it is a multi series, and all series have variable x values, export CSV won't work
  11853. menuItems.splice(2, 1);
  11854. }
  11855. for (var i = 0; i < menuItems.length; i++) {
  11856. this.elMenuItems.push(document.createElement('div'));
  11857. this.elMenuItems[i].innerHTML = menuItems[i].title;
  11858. Graphics.setAttrs(this.elMenuItems[i], {
  11859. class: "apexcharts-menu-item ".concat(menuItems[i].name),
  11860. title: menuItems[i].title
  11861. });
  11862. this.elMenu.appendChild(this.elMenuItems[i]);
  11863. }
  11864. }
  11865. }, {
  11866. key: "addToolbarEventListeners",
  11867. value: function addToolbarEventListeners() {
  11868. var _this2 = this;
  11869. this.elZoomReset.addEventListener('click', this.handleZoomReset.bind(this));
  11870. this.elSelection.addEventListener('click', this.toggleZoomSelection.bind(this, 'selection'));
  11871. this.elZoom.addEventListener('click', this.toggleZoomSelection.bind(this, 'zoom'));
  11872. this.elZoomIn.addEventListener('click', this.handleZoomIn.bind(this));
  11873. this.elZoomOut.addEventListener('click', this.handleZoomOut.bind(this));
  11874. this.elPan.addEventListener('click', this.togglePanning.bind(this));
  11875. this.elMenuIcon.addEventListener('click', this.toggleMenu.bind(this));
  11876. this.elMenuItems.forEach(function (m) {
  11877. if (m.classList.contains('exportSVG')) {
  11878. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'svg'));
  11879. } else if (m.classList.contains('exportPNG')) {
  11880. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'png'));
  11881. } else if (m.classList.contains('exportCSV')) {
  11882. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'csv'));
  11883. }
  11884. });
  11885. for (var i = 0; i < this.t.customIcons.length; i++) {
  11886. this.elCustomIcons[i].addEventListener('click', this.t.customIcons[i].click.bind(this, this.ctx, this.ctx.w));
  11887. }
  11888. }
  11889. }, {
  11890. key: "toggleZoomSelection",
  11891. value: function toggleZoomSelection(type) {
  11892. this.toggleOtherControls();
  11893. var el = type === 'selection' ? this.elSelection : this.elZoom;
  11894. var enabledType = type === 'selection' ? 'selectionEnabled' : 'zoomEnabled';
  11895. this.w.globals[enabledType] = !this.w.globals[enabledType];
  11896. if (!el.classList.contains(this.selectedClass)) {
  11897. el.classList.add(this.selectedClass);
  11898. } else {
  11899. el.classList.remove(this.selectedClass);
  11900. }
  11901. }
  11902. }, {
  11903. key: "getToolbarIconsReference",
  11904. value: function getToolbarIconsReference() {
  11905. var w = this.w;
  11906. if (!this.elZoom) {
  11907. this.elZoom = w.globals.dom.baseEl.querySelector('.apexcharts-zoom-icon');
  11908. }
  11909. if (!this.elPan) {
  11910. this.elPan = w.globals.dom.baseEl.querySelector('.apexcharts-pan-icon');
  11911. }
  11912. if (!this.elSelection) {
  11913. this.elSelection = w.globals.dom.baseEl.querySelector('.apexcharts-selection-icon');
  11914. }
  11915. }
  11916. }, {
  11917. key: "enableZoomPanFromToolbar",
  11918. value: function enableZoomPanFromToolbar(type) {
  11919. this.toggleOtherControls();
  11920. type === 'pan' ? this.w.globals.panEnabled = true : this.w.globals.zoomEnabled = true;
  11921. var el = type === 'pan' ? this.elPan : this.elZoom;
  11922. var el2 = type === 'pan' ? this.elZoom : this.elPan;
  11923. if (el) {
  11924. el.classList.add(this.selectedClass);
  11925. }
  11926. if (el2) {
  11927. el2.classList.remove(this.selectedClass);
  11928. }
  11929. }
  11930. }, {
  11931. key: "togglePanning",
  11932. value: function togglePanning() {
  11933. this.toggleOtherControls();
  11934. this.w.globals.panEnabled = !this.w.globals.panEnabled;
  11935. if (!this.elPan.classList.contains(this.selectedClass)) {
  11936. this.elPan.classList.add(this.selectedClass);
  11937. } else {
  11938. this.elPan.classList.remove(this.selectedClass);
  11939. }
  11940. }
  11941. }, {
  11942. key: "toggleOtherControls",
  11943. value: function toggleOtherControls() {
  11944. var _this3 = this;
  11945. var w = this.w;
  11946. w.globals.panEnabled = false;
  11947. w.globals.zoomEnabled = false;
  11948. w.globals.selectionEnabled = false;
  11949. this.getToolbarIconsReference();
  11950. var toggleEls = [this.elPan, this.elSelection, this.elZoom];
  11951. toggleEls.forEach(function (el) {
  11952. if (el) {
  11953. el.classList.remove(_this3.selectedClass);
  11954. }
  11955. });
  11956. }
  11957. }, {
  11958. key: "handleZoomIn",
  11959. value: function handleZoomIn() {
  11960. var w = this.w;
  11961. var centerX = (w.globals.minX + w.globals.maxX) / 2;
  11962. var newMinX = (w.globals.minX + centerX) / 2;
  11963. var newMaxX = (w.globals.maxX + centerX) / 2;
  11964. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  11965. if (!w.globals.disableZoomIn) {
  11966. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  11967. }
  11968. }
  11969. }, {
  11970. key: "handleZoomOut",
  11971. value: function handleZoomOut() {
  11972. var w = this.w; // avoid zooming out beyond 1000 which may result in NaN values being printed on x-axis
  11973. if (w.config.xaxis.type === 'datetime' && new Date(w.globals.minX).getUTCFullYear() < 1000) {
  11974. return;
  11975. }
  11976. var centerX = (w.globals.minX + w.globals.maxX) / 2;
  11977. var newMinX = w.globals.minX - (centerX - w.globals.minX);
  11978. var newMaxX = w.globals.maxX - (centerX - w.globals.maxX);
  11979. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  11980. if (!w.globals.disableZoomOut) {
  11981. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  11982. }
  11983. }
  11984. }, {
  11985. key: "_getNewMinXMaxX",
  11986. value: function _getNewMinXMaxX(newMinX, newMaxX) {
  11987. var shouldFloor = this.w.config.xaxis.convertedCatToNumeric;
  11988. return {
  11989. minX: shouldFloor ? Math.floor(newMinX) : newMinX,
  11990. maxX: shouldFloor ? Math.floor(newMaxX) : newMaxX
  11991. };
  11992. }
  11993. }, {
  11994. key: "zoomUpdateOptions",
  11995. value: function zoomUpdateOptions(newMinX, newMaxX) {
  11996. var w = this.w;
  11997. if (w.config.xaxis.convertedCatToNumeric) {
  11998. // in category charts, avoid zooming out beyond min and max
  11999. if (newMinX < 1) {
  12000. newMinX = 1;
  12001. newMaxX = w.globals.dataPoints;
  12002. }
  12003. if (newMaxX - newMinX < 2) {
  12004. return;
  12005. }
  12006. }
  12007. var xaxis = {
  12008. min: newMinX,
  12009. max: newMaxX
  12010. };
  12011. var beforeZoomRange = this.getBeforeZoomRange(xaxis);
  12012. if (beforeZoomRange) {
  12013. xaxis = beforeZoomRange.xaxis;
  12014. }
  12015. var options = {
  12016. xaxis: xaxis
  12017. };
  12018. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  12019. if (w.config.chart.zoom.autoScaleYaxis) {
  12020. var scale = new Range(this.ctx);
  12021. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  12022. xaxis: xaxis
  12023. });
  12024. }
  12025. if (!w.config.chart.group) {
  12026. // if chart in a group, prevent yaxis update here
  12027. // fix issue #650
  12028. options.yaxis = yaxis;
  12029. }
  12030. this.w.globals.zoomed = true;
  12031. this.ctx.updateHelpers._updateOptions(options, false, this.w.config.chart.animations.dynamicAnimation.enabled);
  12032. this.zoomCallback(xaxis, yaxis);
  12033. }
  12034. }, {
  12035. key: "zoomCallback",
  12036. value: function zoomCallback(xaxis, yaxis) {
  12037. if (typeof this.ev.zoomed === 'function') {
  12038. this.ev.zoomed(this.ctx, {
  12039. xaxis: xaxis,
  12040. yaxis: yaxis
  12041. });
  12042. }
  12043. }
  12044. }, {
  12045. key: "getBeforeZoomRange",
  12046. value: function getBeforeZoomRange(xaxis, yaxis) {
  12047. var newRange = null;
  12048. if (typeof this.ev.beforeZoom === 'function') {
  12049. newRange = this.ev.beforeZoom(this, {
  12050. xaxis: xaxis,
  12051. yaxis: yaxis
  12052. });
  12053. }
  12054. return newRange;
  12055. }
  12056. }, {
  12057. key: "toggleMenu",
  12058. value: function toggleMenu() {
  12059. var _this4 = this;
  12060. window.setTimeout(function () {
  12061. if (_this4.elMenu.classList.contains('apexcharts-menu-open')) {
  12062. _this4.elMenu.classList.remove('apexcharts-menu-open');
  12063. } else {
  12064. _this4.elMenu.classList.add('apexcharts-menu-open');
  12065. }
  12066. }, 0);
  12067. }
  12068. }, {
  12069. key: "handleDownload",
  12070. value: function handleDownload(type) {
  12071. var w = this.w;
  12072. var exprt = new Exports(this.ctx);
  12073. switch (type) {
  12074. case 'svg':
  12075. exprt.exportToSVG(this.ctx);
  12076. break;
  12077. case 'png':
  12078. exprt.exportToPng(this.ctx);
  12079. break;
  12080. case 'csv':
  12081. exprt.exportToCSV({
  12082. series: w.config.series
  12083. });
  12084. break;
  12085. }
  12086. }
  12087. }, {
  12088. key: "handleZoomReset",
  12089. value: function handleZoomReset(e) {
  12090. var _this5 = this;
  12091. var charts = this.ctx.getSyncedCharts();
  12092. charts.forEach(function (ch) {
  12093. var w = ch.w;
  12094. ch.updateHelpers.revertDefaultAxisMinMax();
  12095. if (typeof w.config.chart.events.zoomed === 'function') {
  12096. _this5.zoomCallback({
  12097. min: w.config.xaxis.min,
  12098. max: w.config.xaxis.max
  12099. });
  12100. }
  12101. w.globals.zoomed = false;
  12102. ch.updateHelpers._updateSeries(w.globals.initialSeries, w.config.chart.animations.dynamicAnimation.enabled);
  12103. });
  12104. }
  12105. }, {
  12106. key: "destroy",
  12107. value: function destroy() {
  12108. this.elZoom = null;
  12109. this.elZoomIn = null;
  12110. this.elZoomOut = null;
  12111. this.elPan = null;
  12112. this.elSelection = null;
  12113. this.elZoomReset = null;
  12114. this.elMenuIcon = null;
  12115. }
  12116. }]);
  12117. return Toolbar;
  12118. }();
  12119. /**
  12120. * ApexCharts Zoom Class for handling zooming and panning on axes based charts.
  12121. *
  12122. * @module ZoomPanSelection
  12123. **/
  12124. var ZoomPanSelection = /*#__PURE__*/function (_Toolbar) {
  12125. _inherits(ZoomPanSelection, _Toolbar);
  12126. function ZoomPanSelection(ctx) {
  12127. var _this;
  12128. _classCallCheck(this, ZoomPanSelection);
  12129. _this = _possibleConstructorReturn(this, _getPrototypeOf(ZoomPanSelection).call(this, ctx));
  12130. _this.ctx = ctx;
  12131. _this.w = ctx.w;
  12132. _this.dragged = false;
  12133. _this.graphics = new Graphics(_this.ctx);
  12134. _this.eventList = ['mousedown', 'mouseleave', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
  12135. _this.clientX = 0;
  12136. _this.clientY = 0;
  12137. _this.startX = 0;
  12138. _this.endX = 0;
  12139. _this.dragX = 0;
  12140. _this.startY = 0;
  12141. _this.endY = 0;
  12142. _this.dragY = 0;
  12143. _this.moveDirection = 'none';
  12144. return _this;
  12145. }
  12146. _createClass(ZoomPanSelection, [{
  12147. key: "init",
  12148. value: function init(_ref) {
  12149. var _this2 = this;
  12150. var xyRatios = _ref.xyRatios;
  12151. var w = this.w;
  12152. var me = this;
  12153. this.xyRatios = xyRatios;
  12154. this.zoomRect = this.graphics.drawRect(0, 0, 0, 0);
  12155. this.selectionRect = this.graphics.drawRect(0, 0, 0, 0);
  12156. this.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  12157. this.zoomRect.node.classList.add('apexcharts-zoom-rect');
  12158. this.selectionRect.node.classList.add('apexcharts-selection-rect');
  12159. w.globals.dom.elGraphical.add(this.zoomRect);
  12160. w.globals.dom.elGraphical.add(this.selectionRect);
  12161. if (w.config.chart.selection.type === 'x') {
  12162. this.slDraggableRect = this.selectionRect.draggable({
  12163. minX: 0,
  12164. minY: 0,
  12165. maxX: w.globals.gridWidth,
  12166. maxY: w.globals.gridHeight
  12167. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  12168. } else if (w.config.chart.selection.type === 'y') {
  12169. this.slDraggableRect = this.selectionRect.draggable({
  12170. minX: 0,
  12171. maxX: w.globals.gridWidth
  12172. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  12173. } else {
  12174. this.slDraggableRect = this.selectionRect.draggable().on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  12175. }
  12176. this.preselectedSelection();
  12177. this.hoverArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
  12178. this.hoverArea.classList.add('apexcharts-zoomable');
  12179. this.eventList.forEach(function (event) {
  12180. _this2.hoverArea.addEventListener(event, me.svgMouseEvents.bind(me, xyRatios), {
  12181. capture: false,
  12182. passive: true
  12183. });
  12184. });
  12185. } // remove the event listeners which were previously added on hover area
  12186. }, {
  12187. key: "destroy",
  12188. value: function destroy() {
  12189. if (this.slDraggableRect) {
  12190. this.slDraggableRect.draggable(false);
  12191. this.slDraggableRect.off();
  12192. this.selectionRect.off();
  12193. }
  12194. this.selectionRect = null;
  12195. this.zoomRect = null;
  12196. this.gridRect = null;
  12197. }
  12198. }, {
  12199. key: "svgMouseEvents",
  12200. value: function svgMouseEvents(xyRatios, e) {
  12201. var w = this.w;
  12202. var me = this;
  12203. var toolbar = this.ctx.toolbar;
  12204. var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type;
  12205. if (e.shiftKey) {
  12206. this.shiftWasPressed = true;
  12207. toolbar.enableZoomPanFromToolbar('pan');
  12208. } else {
  12209. if (this.shiftWasPressed) {
  12210. toolbar.enableZoomPanFromToolbar('zoom');
  12211. this.shiftWasPressed = false;
  12212. }
  12213. }
  12214. var falsePositives = e.target.classList.contains('apexcharts-selection-rect') || e.target.parentNode.classList.contains('apexcharts-toolbar');
  12215. if (falsePositives) return;
  12216. me.clientX = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientX : e.type === 'touchend' ? e.changedTouches[0].clientX : e.clientX;
  12217. me.clientY = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientY : e.type === 'touchend' ? e.changedTouches[0].clientY : e.clientY;
  12218. if (e.type === 'mousedown' && e.which === 1) {
  12219. var gridRectDim = me.gridRect.getBoundingClientRect();
  12220. me.startX = me.clientX - gridRectDim.left;
  12221. me.startY = me.clientY - gridRectDim.top;
  12222. me.dragged = false;
  12223. me.w.globals.mousedown = true;
  12224. }
  12225. if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') {
  12226. me.dragged = true;
  12227. if (w.globals.panEnabled) {
  12228. w.globals.selection = null;
  12229. if (me.w.globals.mousedown) {
  12230. me.panDragging({
  12231. context: me,
  12232. zoomtype: zoomtype,
  12233. xyRatios: xyRatios
  12234. });
  12235. }
  12236. } else {
  12237. if (me.w.globals.mousedown && w.globals.zoomEnabled || me.w.globals.mousedown && w.globals.selectionEnabled) {
  12238. me.selection = me.selectionDrawing({
  12239. context: me,
  12240. zoomtype: zoomtype
  12241. });
  12242. }
  12243. }
  12244. }
  12245. if (e.type === 'mouseup' || e.type === 'touchend' || e.type === 'mouseleave') {
  12246. // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup
  12247. var _gridRectDim = me.gridRect.getBoundingClientRect();
  12248. if (me.w.globals.mousedown) {
  12249. // user released the drag, now do all the calculations
  12250. me.endX = me.clientX - _gridRectDim.left;
  12251. me.endY = me.clientY - _gridRectDim.top;
  12252. me.dragX = Math.abs(me.endX - me.startX);
  12253. me.dragY = Math.abs(me.endY - me.startY);
  12254. if (w.globals.zoomEnabled || w.globals.selectionEnabled) {
  12255. me.selectionDrawn({
  12256. context: me,
  12257. zoomtype: zoomtype
  12258. });
  12259. }
  12260. if (w.globals.panEnabled && w.config.xaxis.convertedCatToNumeric) {
  12261. me.delayedPanScrolled();
  12262. }
  12263. }
  12264. if (w.globals.zoomEnabled) {
  12265. me.hideSelectionRect(this.selectionRect);
  12266. }
  12267. me.dragged = false;
  12268. me.w.globals.mousedown = false;
  12269. }
  12270. this.makeSelectionRectDraggable();
  12271. }
  12272. }, {
  12273. key: "makeSelectionRectDraggable",
  12274. value: function makeSelectionRectDraggable() {
  12275. var w = this.w;
  12276. if (!this.selectionRect) return;
  12277. var rectDim = this.selectionRect.node.getBoundingClientRect();
  12278. if (rectDim.width > 0 && rectDim.height > 0) {
  12279. this.slDraggableRect.selectize({
  12280. points: 'l, r',
  12281. pointSize: 8,
  12282. pointType: 'rect'
  12283. }).resize({
  12284. constraint: {
  12285. minX: 0,
  12286. minY: 0,
  12287. maxX: w.globals.gridWidth,
  12288. maxY: w.globals.gridHeight
  12289. }
  12290. }).on('resizing', this.selectionDragging.bind(this, 'resizing'));
  12291. }
  12292. }
  12293. }, {
  12294. key: "preselectedSelection",
  12295. value: function preselectedSelection() {
  12296. var w = this.w;
  12297. var xyRatios = this.xyRatios;
  12298. if (!w.globals.zoomEnabled) {
  12299. if (typeof w.globals.selection !== 'undefined' && w.globals.selection !== null) {
  12300. this.drawSelectionRect(w.globals.selection);
  12301. } else {
  12302. if (w.config.chart.selection.xaxis.min !== undefined && w.config.chart.selection.xaxis.max !== undefined) {
  12303. var x = (w.config.chart.selection.xaxis.min - w.globals.minX) / xyRatios.xRatio;
  12304. var width = w.globals.gridWidth - (w.globals.maxX - w.config.chart.selection.xaxis.max) / xyRatios.xRatio - x;
  12305. var selectionRect = {
  12306. x: x,
  12307. y: 0,
  12308. width: width,
  12309. height: w.globals.gridHeight,
  12310. translateX: 0,
  12311. translateY: 0,
  12312. selectionEnabled: true
  12313. };
  12314. this.drawSelectionRect(selectionRect);
  12315. this.makeSelectionRectDraggable();
  12316. if (typeof w.config.chart.events.selection === 'function') {
  12317. w.config.chart.events.selection(this.ctx, {
  12318. xaxis: {
  12319. min: w.config.chart.selection.xaxis.min,
  12320. max: w.config.chart.selection.xaxis.max
  12321. },
  12322. yaxis: {}
  12323. });
  12324. }
  12325. }
  12326. }
  12327. }
  12328. }
  12329. }, {
  12330. key: "drawSelectionRect",
  12331. value: function drawSelectionRect(_ref2) {
  12332. var x = _ref2.x,
  12333. y = _ref2.y,
  12334. width = _ref2.width,
  12335. height = _ref2.height,
  12336. translateX = _ref2.translateX,
  12337. translateY = _ref2.translateY;
  12338. var w = this.w;
  12339. var zoomRect = this.zoomRect;
  12340. var selectionRect = this.selectionRect;
  12341. if (this.dragged || w.globals.selection !== null) {
  12342. var scalingAttrs = {
  12343. transform: 'translate(' + translateX + ', ' + translateY + ')'
  12344. }; // change styles based on zoom or selection
  12345. // zoom is Enabled and user has dragged, so draw blue rect
  12346. if (w.globals.zoomEnabled && this.dragged) {
  12347. if (width < 0) width = 1; // fixes apexcharts.js#1168
  12348. zoomRect.attr({
  12349. x: x,
  12350. y: y,
  12351. width: width,
  12352. height: height,
  12353. fill: w.config.chart.zoom.zoomedArea.fill.color,
  12354. 'fill-opacity': w.config.chart.zoom.zoomedArea.fill.opacity,
  12355. stroke: w.config.chart.zoom.zoomedArea.stroke.color,
  12356. 'stroke-width': w.config.chart.zoom.zoomedArea.stroke.width,
  12357. 'stroke-opacity': w.config.chart.zoom.zoomedArea.stroke.opacity
  12358. });
  12359. Graphics.setAttrs(zoomRect.node, scalingAttrs);
  12360. } // selection is enabled
  12361. if (w.globals.selectionEnabled) {
  12362. selectionRect.attr({
  12363. x: x,
  12364. y: y,
  12365. width: width > 0 ? width : 0,
  12366. height: height > 0 ? height : 0,
  12367. fill: w.config.chart.selection.fill.color,
  12368. 'fill-opacity': w.config.chart.selection.fill.opacity,
  12369. stroke: w.config.chart.selection.stroke.color,
  12370. 'stroke-width': w.config.chart.selection.stroke.width,
  12371. 'stroke-dasharray': w.config.chart.selection.stroke.dashArray,
  12372. 'stroke-opacity': w.config.chart.selection.stroke.opacity
  12373. });
  12374. Graphics.setAttrs(selectionRect.node, scalingAttrs);
  12375. }
  12376. }
  12377. }
  12378. }, {
  12379. key: "hideSelectionRect",
  12380. value: function hideSelectionRect(rect) {
  12381. if (rect) {
  12382. rect.attr({
  12383. x: 0,
  12384. y: 0,
  12385. width: 0,
  12386. height: 0
  12387. });
  12388. }
  12389. }
  12390. }, {
  12391. key: "selectionDrawing",
  12392. value: function selectionDrawing(_ref3) {
  12393. var context = _ref3.context,
  12394. zoomtype = _ref3.zoomtype;
  12395. var w = this.w;
  12396. var me = context;
  12397. var gridRectDim = this.gridRect.getBoundingClientRect();
  12398. var startX = me.startX - 1;
  12399. var startY = me.startY;
  12400. var selectionWidth = me.clientX - gridRectDim.left - startX;
  12401. var selectionHeight = me.clientY - gridRectDim.top - startY;
  12402. var translateX = 0;
  12403. var translateY = 0;
  12404. var selectionRect = {};
  12405. if (Math.abs(selectionWidth + startX) > w.globals.gridWidth) {
  12406. // user dragged the mouse outside drawing area to the right
  12407. selectionWidth = w.globals.gridWidth - startX;
  12408. } else if (me.clientX - gridRectDim.left < 0) {
  12409. // user dragged the mouse outside drawing area to the left
  12410. selectionWidth = startX;
  12411. } // inverse selection X
  12412. if (startX > me.clientX - gridRectDim.left) {
  12413. selectionWidth = Math.abs(selectionWidth);
  12414. translateX = -selectionWidth;
  12415. } // inverse selection Y
  12416. if (startY > me.clientY - gridRectDim.top) {
  12417. selectionHeight = Math.abs(selectionHeight);
  12418. translateY = -selectionHeight;
  12419. }
  12420. if (zoomtype === 'x') {
  12421. selectionRect = {
  12422. x: startX,
  12423. y: 0,
  12424. width: selectionWidth,
  12425. height: w.globals.gridHeight,
  12426. translateX: translateX,
  12427. translateY: 0
  12428. };
  12429. } else if (zoomtype === 'y') {
  12430. selectionRect = {
  12431. x: 0,
  12432. y: startY,
  12433. width: w.globals.gridWidth,
  12434. height: selectionHeight,
  12435. translateX: 0,
  12436. translateY: translateY
  12437. };
  12438. } else {
  12439. selectionRect = {
  12440. x: startX,
  12441. y: startY,
  12442. width: selectionWidth,
  12443. height: selectionHeight,
  12444. translateX: translateX,
  12445. translateY: translateY
  12446. };
  12447. }
  12448. me.drawSelectionRect(selectionRect);
  12449. me.selectionDragging('resizing');
  12450. return selectionRect;
  12451. }
  12452. }, {
  12453. key: "selectionDragging",
  12454. value: function selectionDragging(type, e) {
  12455. var _this3 = this;
  12456. var w = this.w;
  12457. var xyRatios = this.xyRatios;
  12458. var selRect = this.selectionRect;
  12459. var timerInterval = 0;
  12460. if (type === 'resizing') {
  12461. timerInterval = 30;
  12462. }
  12463. if (typeof w.config.chart.events.selection === 'function' && w.globals.selectionEnabled) {
  12464. // a small debouncer is required when resizing to avoid freezing the chart
  12465. clearTimeout(this.w.globals.selectionResizeTimer);
  12466. this.w.globals.selectionResizeTimer = window.setTimeout(function () {
  12467. var gridRectDim = _this3.gridRect.getBoundingClientRect();
  12468. var selectionRect = selRect.node.getBoundingClientRect();
  12469. var minX = w.globals.xAxisScale.niceMin + (selectionRect.left - gridRectDim.left) * xyRatios.xRatio;
  12470. var maxX = w.globals.xAxisScale.niceMin + (selectionRect.right - gridRectDim.left) * xyRatios.xRatio;
  12471. var minY = w.globals.yAxisScale[0].niceMin + (gridRectDim.bottom - selectionRect.bottom) * xyRatios.yRatio[0];
  12472. var maxY = w.globals.yAxisScale[0].niceMax - (selectionRect.top - gridRectDim.top) * xyRatios.yRatio[0];
  12473. w.config.chart.events.selection(_this3.ctx, {
  12474. xaxis: {
  12475. min: minX,
  12476. max: maxX
  12477. },
  12478. yaxis: {
  12479. min: minY,
  12480. max: maxY
  12481. }
  12482. });
  12483. }, timerInterval);
  12484. }
  12485. }
  12486. }, {
  12487. key: "selectionDrawn",
  12488. value: function selectionDrawn(_ref4) {
  12489. var context = _ref4.context,
  12490. zoomtype = _ref4.zoomtype;
  12491. var w = this.w;
  12492. var me = context;
  12493. var xyRatios = this.xyRatios;
  12494. var toolbar = this.ctx.toolbar;
  12495. if (me.startX > me.endX) {
  12496. var tempX = me.startX;
  12497. me.startX = me.endX;
  12498. me.endX = tempX;
  12499. }
  12500. if (me.startY > me.endY) {
  12501. var tempY = me.startY;
  12502. me.startY = me.endY;
  12503. me.endY = tempY;
  12504. }
  12505. var xLowestValue = w.globals.xAxisScale.niceMin + me.startX * xyRatios.xRatio;
  12506. var xHighestValue = w.globals.xAxisScale.niceMin + me.endX * xyRatios.xRatio; // TODO: we will consider the 1st y axis values here for getting highest and lowest y
  12507. var yHighestValue = [];
  12508. var yLowestValue = [];
  12509. w.config.yaxis.forEach(function (yaxe, index) {
  12510. yHighestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.startY);
  12511. yLowestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.endY);
  12512. });
  12513. if (me.dragged && (me.dragX > 10 || me.dragY > 10) && xLowestValue !== xHighestValue) {
  12514. if (w.globals.zoomEnabled) {
  12515. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  12516. var xaxis = Utils.clone(w.globals.initialConfig.xaxis);
  12517. w.globals.zoomed = true; // before zooming in/out, store the last yaxis and xaxis range, so that when user hits the RESET button, we get the original range
  12518. // also - make sure user is not already zoomed in/out - otherwise we will store zoomed values in lastAxis
  12519. // DEAD code - the below condition will never run now as zoomed is made false above
  12520. if (!w.globals.zoomed) {
  12521. w.globals.lastXAxis = Utils.clone(w.config.xaxis);
  12522. w.globals.lastYAxis = Utils.clone(w.config.yaxis);
  12523. }
  12524. if (w.config.xaxis.convertedCatToNumeric) {
  12525. xLowestValue = Math.floor(xLowestValue);
  12526. xHighestValue = Math.floor(xHighestValue);
  12527. if (xLowestValue < 1) {
  12528. xLowestValue = 1;
  12529. xHighestValue = w.globals.dataPoints;
  12530. }
  12531. if (xHighestValue - xLowestValue < 2) {
  12532. xHighestValue = xLowestValue + 1;
  12533. }
  12534. }
  12535. if (zoomtype === 'xy' || zoomtype === 'x') {
  12536. xaxis = {
  12537. min: xLowestValue,
  12538. max: xHighestValue
  12539. };
  12540. }
  12541. if (zoomtype === 'xy' || zoomtype === 'y') {
  12542. yaxis.forEach(function (yaxe, index) {
  12543. yaxis[index].min = yLowestValue[index];
  12544. yaxis[index].max = yHighestValue[index];
  12545. });
  12546. }
  12547. if (w.config.chart.zoom.autoScaleYaxis) {
  12548. var scale = new Range(me.ctx);
  12549. yaxis = scale.autoScaleY(me.ctx, yaxis, {
  12550. xaxis: xaxis
  12551. });
  12552. }
  12553. if (toolbar) {
  12554. var beforeZoomRange = toolbar.getBeforeZoomRange(xaxis, yaxis);
  12555. if (beforeZoomRange) {
  12556. xaxis = beforeZoomRange.xaxis ? beforeZoomRange.xaxis : xaxis;
  12557. yaxis = beforeZoomRange.yaxis ? beforeZoomRange.yaxe : yaxis;
  12558. }
  12559. }
  12560. var options = {
  12561. xaxis: xaxis
  12562. };
  12563. if (!w.config.chart.group) {
  12564. // if chart in a group, prevent yaxis update here
  12565. // fix issue #650
  12566. options.yaxis = yaxis;
  12567. }
  12568. me.ctx.updateHelpers._updateOptions(options, false, me.w.config.chart.animations.dynamicAnimation.enabled);
  12569. if (typeof w.config.chart.events.zoomed === 'function') {
  12570. toolbar.zoomCallback(xaxis, yaxis);
  12571. }
  12572. } else if (w.globals.selectionEnabled) {
  12573. var _yaxis = null;
  12574. var _xaxis = null;
  12575. _xaxis = {
  12576. min: xLowestValue,
  12577. max: xHighestValue
  12578. };
  12579. if (zoomtype === 'xy' || zoomtype === 'y') {
  12580. _yaxis = Utils.clone(w.config.yaxis);
  12581. _yaxis.forEach(function (yaxe, index) {
  12582. _yaxis[index].min = yLowestValue[index];
  12583. _yaxis[index].max = yHighestValue[index];
  12584. });
  12585. }
  12586. w.globals.selection = me.selection;
  12587. if (typeof w.config.chart.events.selection === 'function') {
  12588. w.config.chart.events.selection(me.ctx, {
  12589. xaxis: _xaxis,
  12590. yaxis: _yaxis
  12591. });
  12592. }
  12593. }
  12594. }
  12595. }
  12596. }, {
  12597. key: "panDragging",
  12598. value: function panDragging(_ref5) {
  12599. var context = _ref5.context;
  12600. var w = this.w;
  12601. var me = context; // check to make sure there is data to compare against
  12602. if (typeof w.globals.lastClientPosition.x !== 'undefined') {
  12603. // get the change from last position to this position
  12604. var deltaX = w.globals.lastClientPosition.x - me.clientX;
  12605. var deltaY = w.globals.lastClientPosition.y - me.clientY; // check which direction had the highest amplitude and then figure out direction by checking if the value is greater or less than zero
  12606. if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) {
  12607. this.moveDirection = 'left';
  12608. } else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) {
  12609. this.moveDirection = 'right';
  12610. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
  12611. this.moveDirection = 'up';
  12612. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) {
  12613. this.moveDirection = 'down';
  12614. }
  12615. } // set the new last position to the current for next time (to get the position of drag)
  12616. w.globals.lastClientPosition = {
  12617. x: me.clientX,
  12618. y: me.clientY
  12619. };
  12620. var xLowestValue = w.globals.minX;
  12621. var xHighestValue = w.globals.maxX; // on a category, we don't pan continuosly as it causes bugs
  12622. if (!w.config.xaxis.convertedCatToNumeric) {
  12623. me.panScrolled(xLowestValue, xHighestValue);
  12624. }
  12625. }
  12626. }, {
  12627. key: "delayedPanScrolled",
  12628. value: function delayedPanScrolled() {
  12629. var w = this.w;
  12630. var newMinX = w.globals.minX;
  12631. var newMaxX = w.globals.maxX;
  12632. var centerX = (w.globals.maxX - w.globals.minX) / 2;
  12633. if (this.moveDirection === 'left') {
  12634. newMinX = w.globals.minX + centerX;
  12635. newMaxX = w.globals.maxX + centerX;
  12636. } else if (this.moveDirection === 'right') {
  12637. newMinX = w.globals.minX - centerX;
  12638. newMaxX = w.globals.maxX - centerX;
  12639. }
  12640. newMinX = Math.floor(newMinX);
  12641. newMaxX = Math.floor(newMaxX);
  12642. this.updateScrolledChart({
  12643. xaxis: {
  12644. min: newMinX,
  12645. max: newMaxX
  12646. }
  12647. }, newMinX, newMaxX);
  12648. }
  12649. }, {
  12650. key: "panScrolled",
  12651. value: function panScrolled(xLowestValue, xHighestValue) {
  12652. var w = this.w;
  12653. var xyRatios = this.xyRatios;
  12654. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  12655. if (this.moveDirection === 'left') {
  12656. xLowestValue = w.globals.minX + w.globals.gridWidth / 15 * xyRatios.xRatio;
  12657. xHighestValue = w.globals.maxX + w.globals.gridWidth / 15 * xyRatios.xRatio;
  12658. } else if (this.moveDirection === 'right') {
  12659. xLowestValue = w.globals.minX - w.globals.gridWidth / 15 * xyRatios.xRatio;
  12660. xHighestValue = w.globals.maxX - w.globals.gridWidth / 15 * xyRatios.xRatio;
  12661. }
  12662. if (xLowestValue < w.globals.initialMinX || xHighestValue > w.globals.initialMaxX) {
  12663. xLowestValue = w.globals.minX;
  12664. xHighestValue = w.globals.maxX;
  12665. }
  12666. var xaxis = {
  12667. min: xLowestValue,
  12668. max: xHighestValue
  12669. };
  12670. if (w.config.chart.zoom.autoScaleYaxis) {
  12671. var scale = new Range(this.ctx);
  12672. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  12673. xaxis: xaxis
  12674. });
  12675. }
  12676. var options = {
  12677. xaxis: {
  12678. min: xLowestValue,
  12679. max: xHighestValue
  12680. }
  12681. };
  12682. if (!w.config.chart.group) {
  12683. // if chart in a group, prevent yaxis update here
  12684. // fix issue #650
  12685. options.yaxis = yaxis;
  12686. }
  12687. this.updateScrolledChart(options, xLowestValue, xHighestValue);
  12688. }
  12689. }, {
  12690. key: "updateScrolledChart",
  12691. value: function updateScrolledChart(options, xLowestValue, xHighestValue) {
  12692. var w = this.w;
  12693. this.ctx.updateHelpers._updateOptions(options, false, false);
  12694. if (typeof w.config.chart.events.scrolled === 'function') {
  12695. w.config.chart.events.scrolled(this.ctx, {
  12696. xaxis: {
  12697. min: xLowestValue,
  12698. max: xHighestValue
  12699. }
  12700. });
  12701. }
  12702. }
  12703. }]);
  12704. return ZoomPanSelection;
  12705. }(Toolbar);
  12706. var Utils$1 = /*#__PURE__*/function () {
  12707. function Utils$1(tooltipContext) {
  12708. _classCallCheck(this, Utils$1);
  12709. this.w = tooltipContext.w;
  12710. this.ttCtx = tooltipContext;
  12711. this.ctx = tooltipContext.ctx;
  12712. }
  12713. /**
  12714. ** When hovering over series, you need to capture which series is being hovered on.
  12715. ** This function will return both capturedseries index as well as inner index of that series
  12716. * @memberof Utils
  12717. * @param {object}
  12718. * - hoverArea = the rect on which user hovers
  12719. * - elGrid = dimensions of the hover rect (it can be different than hoverarea)
  12720. */
  12721. _createClass(Utils$1, [{
  12722. key: "getNearestValues",
  12723. value: function getNearestValues(_ref) {
  12724. var hoverArea = _ref.hoverArea,
  12725. elGrid = _ref.elGrid,
  12726. clientX = _ref.clientX,
  12727. clientY = _ref.clientY;
  12728. var w = this.w;
  12729. var hoverWidth = w.globals.gridWidth;
  12730. var xDivisor = hoverWidth / (w.globals.dataPoints - 1);
  12731. var seriesBound = elGrid.getBoundingClientRect();
  12732. var hasBars = this.hasBars();
  12733. if (w.globals.comboCharts || hasBars) {
  12734. xDivisor = hoverWidth / w.globals.dataPoints;
  12735. }
  12736. var hoverX = clientX - seriesBound.left;
  12737. var hoverY = clientY - seriesBound.top;
  12738. var notInRect = hoverX < 0 || hoverY < 0 || hoverX > w.globals.gridWidth || hoverY > w.globals.gridHeight;
  12739. if (notInRect) {
  12740. hoverArea.classList.remove('hovering-zoom');
  12741. hoverArea.classList.remove('hovering-pan');
  12742. } else {
  12743. if (w.globals.zoomEnabled) {
  12744. hoverArea.classList.remove('hovering-pan');
  12745. hoverArea.classList.add('hovering-zoom');
  12746. } else if (w.globals.panEnabled) {
  12747. hoverArea.classList.remove('hovering-zoom');
  12748. hoverArea.classList.add('hovering-pan');
  12749. }
  12750. }
  12751. var j = Math.round(hoverX / xDivisor);
  12752. if (hasBars) {
  12753. j = Math.ceil(hoverX / xDivisor);
  12754. j = j - 1;
  12755. }
  12756. var capturedSeries = null;
  12757. var closest = null;
  12758. var seriesXValArr = [];
  12759. var seriesYValArr = [];
  12760. for (var s = 0; s < w.globals.seriesXvalues.length; s++) {
  12761. seriesXValArr.push([w.globals.seriesXvalues[s][0] - 0.000001].concat(w.globals.seriesXvalues[s]));
  12762. }
  12763. seriesXValArr = seriesXValArr.map(function (seriesXVal) {
  12764. return seriesXVal.filter(function (s) {
  12765. return s;
  12766. });
  12767. });
  12768. seriesYValArr = w.globals.seriesYvalues.map(function (seriesYVal) {
  12769. return seriesYVal.filter(function (s) {
  12770. return Utils.isNumber(s);
  12771. });
  12772. }); // if X axis type is not category and tooltip is not shared, then we need to find the cursor position and get the nearest value
  12773. if (w.globals.isXNumeric) {
  12774. closest = this.closestInMultiArray(hoverX, hoverY, seriesXValArr, seriesYValArr);
  12775. capturedSeries = closest.index;
  12776. j = closest.j;
  12777. if (capturedSeries !== null) {
  12778. // initial push, it should be a little smaller than the 1st val
  12779. seriesXValArr = w.globals.seriesXvalues[capturedSeries];
  12780. closest = this.closestInArray(hoverX, seriesXValArr);
  12781. j = closest.index;
  12782. }
  12783. }
  12784. w.globals.capturedSeriesIndex = capturedSeries === null ? -1 : capturedSeries;
  12785. if (!j || j < 1) j = 0;
  12786. w.globals.capturedDataPointIndex = j;
  12787. return {
  12788. capturedSeries: capturedSeries,
  12789. j: j,
  12790. hoverX: hoverX,
  12791. hoverY: hoverY
  12792. };
  12793. }
  12794. }, {
  12795. key: "closestInMultiArray",
  12796. value: function closestInMultiArray(hoverX, hoverY, Xarrays, Yarrays) {
  12797. var w = this.w;
  12798. var activeIndex = 0;
  12799. var currIndex = null;
  12800. var j = -1;
  12801. if (w.globals.series.length > 1) {
  12802. activeIndex = this.getFirstActiveXArray(Xarrays);
  12803. } else {
  12804. currIndex = 0;
  12805. }
  12806. var currY = Yarrays[activeIndex][0];
  12807. var currX = Xarrays[activeIndex][0];
  12808. var diffX = Math.abs(hoverX - currX);
  12809. var diffY = Math.abs(hoverY - currY);
  12810. var diff = diffY + diffX;
  12811. Yarrays.map(function (arrY, arrIndex) {
  12812. arrY.map(function (y, innerKey) {
  12813. var newdiffY = Math.abs(hoverY - Yarrays[arrIndex][innerKey]);
  12814. var newdiffX = Math.abs(hoverX - Xarrays[arrIndex][innerKey]);
  12815. var newdiff = newdiffX + newdiffY;
  12816. if (newdiff < diff) {
  12817. diff = newdiff;
  12818. diffX = newdiffX;
  12819. diffY = newdiffY;
  12820. currIndex = arrIndex;
  12821. j = innerKey;
  12822. }
  12823. });
  12824. });
  12825. return {
  12826. index: currIndex,
  12827. j: j
  12828. };
  12829. }
  12830. }, {
  12831. key: "getFirstActiveXArray",
  12832. value: function getFirstActiveXArray(Xarrays) {
  12833. var activeIndex = 0;
  12834. var coreUtils = new CoreUtils(this.ctx);
  12835. var firstActiveSeriesIndex = Xarrays.map(function (xarr, index) {
  12836. return xarr.length > 0 ? index : -1;
  12837. });
  12838. for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
  12839. var total = coreUtils.getSeriesTotalByIndex(a);
  12840. if (firstActiveSeriesIndex[a] !== -1 && total !== 0 && !coreUtils.seriesHaveSameValues(a)) {
  12841. activeIndex = firstActiveSeriesIndex[a];
  12842. break;
  12843. }
  12844. }
  12845. return activeIndex;
  12846. }
  12847. }, {
  12848. key: "closestInArray",
  12849. value: function closestInArray(val, arr) {
  12850. var curr = arr[0];
  12851. var currIndex = null;
  12852. var diff = Math.abs(val - curr);
  12853. for (var i = 0; i < arr.length; i++) {
  12854. var newdiff = Math.abs(val - arr[i]);
  12855. if (newdiff < diff) {
  12856. diff = newdiff;
  12857. currIndex = i;
  12858. }
  12859. }
  12860. return {
  12861. index: currIndex
  12862. };
  12863. }
  12864. /**
  12865. * When there are multiple series, it is possible to have different x values for each series.
  12866. * But it may be possible in those multiple series, that there is same x value for 2 or more
  12867. * series.
  12868. * @memberof Utils
  12869. * @param {int}
  12870. * - j = is the inner index of series -> (series[i][j])
  12871. * @return {bool}
  12872. */
  12873. }, {
  12874. key: "isXoverlap",
  12875. value: function isXoverlap(j) {
  12876. var w = this.w;
  12877. var xSameForAllSeriesJArr = [];
  12878. var seriesX = w.globals.seriesX.filter(function (s) {
  12879. return typeof s[0] !== 'undefined';
  12880. });
  12881. if (seriesX.length > 0) {
  12882. for (var i = 0; i < seriesX.length - 1; i++) {
  12883. if (typeof seriesX[i][j] !== 'undefined' && typeof seriesX[i + 1][j] !== 'undefined') {
  12884. if (seriesX[i][j] !== seriesX[i + 1][j]) {
  12885. xSameForAllSeriesJArr.push('unEqual');
  12886. }
  12887. }
  12888. }
  12889. }
  12890. if (xSameForAllSeriesJArr.length === 0) {
  12891. return true;
  12892. }
  12893. return false;
  12894. }
  12895. }, {
  12896. key: "isInitialSeriesSameLen",
  12897. value: function isInitialSeriesSameLen() {
  12898. var sameLen = true;
  12899. var initialSeries = this.w.globals.initialSeries;
  12900. for (var i = 0; i < initialSeries.length - 1; i++) {
  12901. if (initialSeries[i].data.length !== initialSeries[i + 1].data.length) {
  12902. sameLen = false;
  12903. break;
  12904. }
  12905. }
  12906. return sameLen;
  12907. }
  12908. }, {
  12909. key: "getBarsHeight",
  12910. value: function getBarsHeight(allbars) {
  12911. var bars = _toConsumableArray(allbars);
  12912. var totalHeight = bars.reduce(function (acc, bar) {
  12913. return acc + bar.getBBox().height;
  12914. }, 0);
  12915. return totalHeight;
  12916. }
  12917. }, {
  12918. key: "getElMarkers",
  12919. value: function getElMarkers() {
  12920. return this.w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers');
  12921. }
  12922. }, {
  12923. key: "getAllMarkers",
  12924. value: function getAllMarkers() {
  12925. // first get all marker parents. This parent class contains series-index
  12926. // which helps to sort the markers as they are dynamic
  12927. var markersWraps = this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers-wrap');
  12928. markersWraps = _toConsumableArray(markersWraps);
  12929. markersWraps.sort(function (a, b) {
  12930. return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
  12931. });
  12932. var markers = [];
  12933. markersWraps.forEach(function (m) {
  12934. markers.push(m.querySelector('.apexcharts-marker'));
  12935. });
  12936. return markers;
  12937. }
  12938. }, {
  12939. key: "hasMarkers",
  12940. value: function hasMarkers() {
  12941. var markers = this.getElMarkers();
  12942. return markers.length > 0;
  12943. }
  12944. }, {
  12945. key: "getElBars",
  12946. value: function getElBars() {
  12947. return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-rangebar-series');
  12948. }
  12949. }, {
  12950. key: "hasBars",
  12951. value: function hasBars() {
  12952. var bars = this.getElBars();
  12953. return bars.length > 0;
  12954. }
  12955. }, {
  12956. key: "getHoverMarkerSize",
  12957. value: function getHoverMarkerSize(index) {
  12958. var w = this.w;
  12959. var hoverSize = w.config.markers.hover.size;
  12960. if (hoverSize === undefined) {
  12961. hoverSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  12962. }
  12963. return hoverSize;
  12964. }
  12965. }, {
  12966. key: "toggleAllTooltipSeriesGroups",
  12967. value: function toggleAllTooltipSeriesGroups(state) {
  12968. var w = this.w;
  12969. var ttCtx = this.ttCtx;
  12970. if (ttCtx.allTooltipSeriesGroups.length === 0) {
  12971. ttCtx.allTooltipSeriesGroups = w.globals.dom.baseEl.querySelectorAll('.apexcharts-tooltip-series-group');
  12972. }
  12973. var allTooltipSeriesGroups = ttCtx.allTooltipSeriesGroups;
  12974. for (var i = 0; i < allTooltipSeriesGroups.length; i++) {
  12975. if (state === 'enable') {
  12976. allTooltipSeriesGroups[i].classList.add('apexcharts-active');
  12977. allTooltipSeriesGroups[i].style.display = w.config.tooltip.items.display;
  12978. } else {
  12979. allTooltipSeriesGroups[i].classList.remove('apexcharts-active');
  12980. allTooltipSeriesGroups[i].style.display = 'none';
  12981. }
  12982. }
  12983. }
  12984. }]);
  12985. return Utils$1;
  12986. }();
  12987. /**
  12988. * ApexCharts Tooltip.Labels Class to draw texts on the tooltip.
  12989. *
  12990. * @module Tooltip.Labels
  12991. **/
  12992. var Labels = /*#__PURE__*/function () {
  12993. function Labels(tooltipContext) {
  12994. _classCallCheck(this, Labels);
  12995. this.w = tooltipContext.w;
  12996. this.ctx = tooltipContext.ctx;
  12997. this.ttCtx = tooltipContext;
  12998. this.tooltipUtil = new Utils$1(tooltipContext);
  12999. }
  13000. _createClass(Labels, [{
  13001. key: "drawSeriesTexts",
  13002. value: function drawSeriesTexts(_ref) {
  13003. var _ref$shared = _ref.shared,
  13004. shared = _ref$shared === void 0 ? true : _ref$shared,
  13005. ttItems = _ref.ttItems,
  13006. _ref$i = _ref.i,
  13007. i = _ref$i === void 0 ? 0 : _ref$i,
  13008. _ref$j = _ref.j,
  13009. j = _ref$j === void 0 ? null : _ref$j,
  13010. y1 = _ref.y1,
  13011. y2 = _ref.y2;
  13012. var w = this.w;
  13013. if (w.config.tooltip.custom !== undefined) {
  13014. this.handleCustomTooltip({
  13015. i: i,
  13016. j: j,
  13017. y1: y1,
  13018. y2: y2,
  13019. w: w
  13020. });
  13021. } else {
  13022. this.toggleActiveInactiveSeries(shared);
  13023. }
  13024. var values = this.getValuesToPrint({
  13025. i: i,
  13026. j: j
  13027. });
  13028. this.printLabels({
  13029. i: i,
  13030. j: j,
  13031. values: values,
  13032. ttItems: ttItems,
  13033. shared: shared
  13034. }); // Re-calculate tooltip dimensions now that we have drawn the text
  13035. var tooltipEl = this.ttCtx.getElTooltip();
  13036. this.ttCtx.tooltipRect.ttWidth = tooltipEl.getBoundingClientRect().width;
  13037. this.ttCtx.tooltipRect.ttHeight = tooltipEl.getBoundingClientRect().height;
  13038. }
  13039. }, {
  13040. key: "printLabels",
  13041. value: function printLabels(_ref2) {
  13042. var _this = this;
  13043. var i = _ref2.i,
  13044. j = _ref2.j,
  13045. values = _ref2.values,
  13046. ttItems = _ref2.ttItems,
  13047. shared = _ref2.shared;
  13048. var w = this.w;
  13049. var val;
  13050. var xVal = values.xVal,
  13051. zVal = values.zVal,
  13052. xAxisTTVal = values.xAxisTTVal;
  13053. var seriesName = '';
  13054. var pColor = w.globals.colors[i];
  13055. if (j !== null && w.config.plotOptions.bar.distributed) {
  13056. pColor = w.globals.colors[j];
  13057. }
  13058. var _loop = function _loop(t, inverset) {
  13059. var f = _this.getFormatters(i);
  13060. seriesName = _this.getSeriesName({
  13061. fn: f.yLbTitleFormatter,
  13062. index: i,
  13063. seriesIndex: i,
  13064. j: j
  13065. });
  13066. var tIndex = w.config.tooltip.inverseOrder ? inverset : t;
  13067. if (w.globals.axisCharts) {
  13068. var generalFormatter = function generalFormatter(index) {
  13069. return f.yLbFormatter(w.globals.series[index][j], {
  13070. series: w.globals.series,
  13071. seriesIndex: index,
  13072. dataPointIndex: j,
  13073. w: w
  13074. });
  13075. };
  13076. if (shared) {
  13077. f = _this.getFormatters(tIndex);
  13078. seriesName = _this.getSeriesName({
  13079. fn: f.yLbTitleFormatter,
  13080. index: tIndex,
  13081. seriesIndex: i,
  13082. j: j
  13083. });
  13084. pColor = w.globals.colors[tIndex];
  13085. val = generalFormatter(tIndex);
  13086. } else {
  13087. val = generalFormatter(i);
  13088. }
  13089. } // for pie / donuts
  13090. if (j === null) {
  13091. val = f.yLbFormatter(w.globals.series[i], w);
  13092. }
  13093. _this.DOMHandling({
  13094. i: i,
  13095. t: tIndex,
  13096. j: j,
  13097. ttItems: ttItems,
  13098. values: {
  13099. val: val,
  13100. xVal: xVal,
  13101. xAxisTTVal: xAxisTTVal,
  13102. zVal: zVal
  13103. },
  13104. seriesName: seriesName,
  13105. shared: shared,
  13106. pColor: pColor
  13107. });
  13108. };
  13109. for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) {
  13110. _loop(t, inverset);
  13111. }
  13112. }
  13113. }, {
  13114. key: "getFormatters",
  13115. value: function getFormatters(i) {
  13116. var w = this.w;
  13117. var yLbFormatter = w.globals.yLabelFormatters[i];
  13118. var yLbTitleFormatter;
  13119. if (w.globals.ttVal !== undefined) {
  13120. if (Array.isArray(w.globals.ttVal)) {
  13121. yLbFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].formatter;
  13122. yLbTitleFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].title && w.globals.ttVal[i].title.formatter;
  13123. } else {
  13124. yLbFormatter = w.globals.ttVal.formatter;
  13125. if (typeof w.globals.ttVal.title.formatter === 'function') {
  13126. yLbTitleFormatter = w.globals.ttVal.title.formatter;
  13127. }
  13128. }
  13129. } else {
  13130. yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  13131. }
  13132. if (typeof yLbFormatter !== 'function') {
  13133. if (w.globals.yLabelFormatters[0]) {
  13134. yLbFormatter = w.globals.yLabelFormatters[0];
  13135. } else {
  13136. yLbFormatter = function yLbFormatter(label) {
  13137. return label;
  13138. };
  13139. }
  13140. }
  13141. if (typeof yLbTitleFormatter !== 'function') {
  13142. yLbTitleFormatter = function yLbTitleFormatter(label) {
  13143. return label;
  13144. };
  13145. }
  13146. return {
  13147. yLbFormatter: yLbFormatter,
  13148. yLbTitleFormatter: yLbTitleFormatter
  13149. };
  13150. }
  13151. }, {
  13152. key: "getSeriesName",
  13153. value: function getSeriesName(_ref3) {
  13154. var fn = _ref3.fn,
  13155. index = _ref3.index,
  13156. seriesIndex = _ref3.seriesIndex,
  13157. j = _ref3.j;
  13158. var w = this.w;
  13159. return fn(String(w.globals.seriesNames[index]), {
  13160. series: w.globals.series,
  13161. seriesIndex: seriesIndex,
  13162. dataPointIndex: j,
  13163. w: w
  13164. });
  13165. }
  13166. }, {
  13167. key: "DOMHandling",
  13168. value: function DOMHandling(_ref4) {
  13169. var i = _ref4.i,
  13170. t = _ref4.t,
  13171. j = _ref4.j,
  13172. ttItems = _ref4.ttItems,
  13173. values = _ref4.values,
  13174. seriesName = _ref4.seriesName,
  13175. shared = _ref4.shared,
  13176. pColor = _ref4.pColor;
  13177. var w = this.w;
  13178. var ttCtx = this.ttCtx;
  13179. var val = values.val,
  13180. xVal = values.xVal,
  13181. xAxisTTVal = values.xAxisTTVal,
  13182. zVal = values.zVal;
  13183. var ttItemsChildren = null;
  13184. ttItemsChildren = ttItems[t].children;
  13185. if (w.config.tooltip.fillSeriesColor) {
  13186. // elTooltip.style.backgroundColor = pColor
  13187. ttItems[t].style.backgroundColor = pColor;
  13188. ttItemsChildren[0].style.display = 'none';
  13189. }
  13190. if (ttCtx.showTooltipTitle) {
  13191. if (ttCtx.tooltipTitle === null) {
  13192. // get it once if null, and store it in class property
  13193. ttCtx.tooltipTitle = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-title');
  13194. }
  13195. ttCtx.tooltipTitle.innerHTML = xVal;
  13196. } // if xaxis tooltip is constructed, we need to replace the innerHTML
  13197. if (ttCtx.blxaxisTooltip) {
  13198. ttCtx.xaxisTooltipText.innerHTML = xAxisTTVal !== '' ? xAxisTTVal : xVal;
  13199. }
  13200. var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-label');
  13201. if (ttYLabel) {
  13202. ttYLabel.innerHTML = seriesName ? seriesName + ': ' : '';
  13203. }
  13204. var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-value');
  13205. if (ttYVal) {
  13206. ttYVal.innerHTML = typeof val !== 'undefined' ? val : '';
  13207. }
  13208. if (ttItemsChildren[0] && ttItemsChildren[0].classList.contains('apexcharts-tooltip-marker')) {
  13209. if (w.config.tooltip.marker.fillColors && Array.isArray(w.config.tooltip.marker.fillColors)) {
  13210. pColor = w.config.tooltip.marker.fillColors[i];
  13211. }
  13212. ttItemsChildren[0].style.backgroundColor = pColor;
  13213. }
  13214. if (!w.config.tooltip.marker.show) {
  13215. ttItemsChildren[0].style.display = 'none';
  13216. }
  13217. if (zVal !== null) {
  13218. var ttZLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-z-label');
  13219. ttZLabel.innerHTML = w.config.tooltip.z.title;
  13220. var ttZVal = ttItems[t].querySelector('.apexcharts-tooltip-text-z-value');
  13221. ttZVal.innerHTML = typeof zVal !== 'undefined' ? zVal : '';
  13222. }
  13223. if (shared && ttItemsChildren[0]) {
  13224. // hide when no Val or series collapsed
  13225. if (typeof val === 'undefined' || val === null || w.globals.collapsedSeriesIndices.indexOf(t) > -1) {
  13226. ttItemsChildren[0].parentNode.style.display = 'none';
  13227. } else {
  13228. ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display;
  13229. } // TODO: issue #1240 needs to be looked at again. commenting it because this also hides single series values with 0 in it (shared tooltip)
  13230. // if (w.globals.stackedSeriesTotals[j] === 0) {
  13231. // // shared tooltip and all values are null, so we need to hide the x value too
  13232. // let allYZeroForJ = false
  13233. // for (let si = 1; si < w.globals.seriesYvalues.length; si++) {
  13234. // if (
  13235. // w.globals.seriesYvalues[si][j] ===
  13236. // w.globals.seriesYvalues[si - 1][j]
  13237. // ) {
  13238. // allYZeroForJ = true
  13239. // }
  13240. // }
  13241. // if (allYZeroForJ) {
  13242. // ttCtx.tooltipTitle.style.display = 'none'
  13243. // } else {
  13244. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  13245. // }
  13246. // } else {
  13247. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  13248. // }
  13249. }
  13250. }
  13251. }, {
  13252. key: "toggleActiveInactiveSeries",
  13253. value: function toggleActiveInactiveSeries(shared) {
  13254. var w = this.w;
  13255. if (shared) {
  13256. // make all tooltips active
  13257. this.tooltipUtil.toggleAllTooltipSeriesGroups('enable');
  13258. } else {
  13259. // disable all tooltip text groups
  13260. this.tooltipUtil.toggleAllTooltipSeriesGroups('disable'); // enable the first tooltip text group
  13261. var firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-series-group');
  13262. if (firstTooltipSeriesGroup) {
  13263. firstTooltipSeriesGroup.classList.add('apexcharts-active');
  13264. firstTooltipSeriesGroup.style.display = w.config.tooltip.items.display;
  13265. }
  13266. }
  13267. }
  13268. }, {
  13269. key: "getValuesToPrint",
  13270. value: function getValuesToPrint(_ref5) {
  13271. var i = _ref5.i,
  13272. j = _ref5.j;
  13273. var w = this.w;
  13274. var filteredSeriesX = this.ctx.series.filteredSeriesX();
  13275. var xVal = '';
  13276. var xAxisTTVal = '';
  13277. var zVal = null;
  13278. var val = null;
  13279. var customFormatterOpts = {
  13280. series: w.globals.series,
  13281. seriesIndex: i,
  13282. dataPointIndex: j,
  13283. w: w
  13284. };
  13285. var zFormatter = w.globals.ttZFormatter;
  13286. if (j === null) {
  13287. val = w.globals.series[i];
  13288. } else {
  13289. if (w.globals.isXNumeric) {
  13290. xVal = filteredSeriesX[i][j];
  13291. if (filteredSeriesX[i].length === 0) {
  13292. // a series (possibly the first one) might be collapsed, so get the next active index
  13293. var firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(filteredSeriesX);
  13294. xVal = filteredSeriesX[firstActiveSeriesIndex][j];
  13295. }
  13296. } else {
  13297. xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : '';
  13298. }
  13299. }
  13300. var bufferXVal = xVal;
  13301. if (w.globals.isXNumeric && w.config.xaxis.type === 'datetime') {
  13302. var xFormat = new Formatters(this.ctx);
  13303. xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal, bufferXVal);
  13304. } else {
  13305. if (!w.globals.isBarHorizontal) {
  13306. xVal = w.globals.xLabelFormatter(bufferXVal, customFormatterOpts);
  13307. }
  13308. } // override default x-axis formatter with tooltip formatter
  13309. if (w.config.tooltip.x.formatter !== undefined) {
  13310. xVal = w.globals.ttKeyFormatter(bufferXVal, customFormatterOpts);
  13311. }
  13312. if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[0].length > 0) {
  13313. zVal = zFormatter(w.globals.seriesZ[i][j], w);
  13314. }
  13315. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  13316. xAxisTTVal = w.globals.xaxisTooltipFormatter(bufferXVal, customFormatterOpts);
  13317. } else {
  13318. xAxisTTVal = xVal;
  13319. }
  13320. return {
  13321. val: Array.isArray(val) ? val.join(' ') : val,
  13322. xVal: Array.isArray(xVal) ? xVal.join(' ') : xVal,
  13323. xAxisTTVal: Array.isArray(xAxisTTVal) ? xAxisTTVal.join(' ') : xAxisTTVal,
  13324. zVal: zVal
  13325. };
  13326. }
  13327. }, {
  13328. key: "handleCustomTooltip",
  13329. value: function handleCustomTooltip(_ref6) {
  13330. var i = _ref6.i,
  13331. j = _ref6.j,
  13332. y1 = _ref6.y1,
  13333. y2 = _ref6.y2,
  13334. w = _ref6.w;
  13335. var tooltipEl = this.ttCtx.getElTooltip();
  13336. var fn = w.config.tooltip.custom;
  13337. if (Array.isArray(fn) && fn[i]) {
  13338. fn = fn[i];
  13339. } // override everything with a custom html tooltip and replace it
  13340. tooltipEl.innerHTML = fn({
  13341. ctx: this.ctx,
  13342. series: w.globals.series,
  13343. seriesIndex: i,
  13344. dataPointIndex: j,
  13345. y1: y1,
  13346. y2: y2,
  13347. w: w
  13348. });
  13349. }
  13350. }]);
  13351. return Labels;
  13352. }();
  13353. /**
  13354. * ApexCharts Tooltip.Position Class to move the tooltip based on x and y position.
  13355. *
  13356. * @module Tooltip.Position
  13357. **/
  13358. var Position = /*#__PURE__*/function () {
  13359. function Position(tooltipContext) {
  13360. _classCallCheck(this, Position);
  13361. this.ttCtx = tooltipContext;
  13362. this.ctx = tooltipContext.ctx;
  13363. this.w = tooltipContext.w;
  13364. }
  13365. /**
  13366. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  13367. * Along with this, this function also calls the xaxisMove function
  13368. * @memberof Position
  13369. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  13370. */
  13371. _createClass(Position, [{
  13372. key: "moveXCrosshairs",
  13373. value: function moveXCrosshairs(cx) {
  13374. var j = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  13375. var ttCtx = this.ttCtx;
  13376. var w = this.w;
  13377. var xcrosshairs = ttCtx.getElXCrosshairs();
  13378. var x = cx - ttCtx.xcrosshairsWidth / 2;
  13379. var tickAmount = w.globals.labels.slice().length;
  13380. if (j !== null) {
  13381. x = w.globals.gridWidth / tickAmount * j;
  13382. }
  13383. if (xcrosshairs !== null) {
  13384. xcrosshairs.setAttribute('x', x);
  13385. xcrosshairs.setAttribute('x1', x);
  13386. xcrosshairs.setAttribute('x2', x);
  13387. xcrosshairs.setAttribute('y2', w.globals.gridHeight);
  13388. xcrosshairs.classList.add('apexcharts-active');
  13389. }
  13390. if (x < 0) {
  13391. x = 0;
  13392. }
  13393. if (x > w.globals.gridWidth) {
  13394. x = w.globals.gridWidth;
  13395. }
  13396. if (ttCtx.blxaxisTooltip) {
  13397. var tx = x;
  13398. if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') {
  13399. tx = x + ttCtx.xcrosshairsWidth / 2;
  13400. }
  13401. this.moveXAxisTooltip(tx);
  13402. }
  13403. }
  13404. /**
  13405. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  13406. * Along with this, this function also calls the xaxisMove function
  13407. * @memberof Position
  13408. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  13409. */
  13410. }, {
  13411. key: "moveYCrosshairs",
  13412. value: function moveYCrosshairs(cy) {
  13413. var ttCtx = this.ttCtx;
  13414. if (ttCtx.ycrosshairs !== null) {
  13415. Graphics.setAttrs(ttCtx.ycrosshairs, {
  13416. y1: cy,
  13417. y2: cy
  13418. });
  13419. Graphics.setAttrs(ttCtx.ycrosshairsHidden, {
  13420. y1: cy,
  13421. y2: cy
  13422. });
  13423. }
  13424. }
  13425. /**
  13426. ** AxisTooltip is the small rectangle which appears on x axis with x value, when user moves
  13427. * @memberof Position
  13428. * @param {int} - cx = point's x position, wherever point's x is, you need to move
  13429. */
  13430. }, {
  13431. key: "moveXAxisTooltip",
  13432. value: function moveXAxisTooltip(cx) {
  13433. var w = this.w;
  13434. var ttCtx = this.ttCtx;
  13435. if (ttCtx.xaxisTooltip !== null) {
  13436. ttCtx.xaxisTooltip.classList.add('apexcharts-active');
  13437. var cy = ttCtx.xaxisOffY + w.config.xaxis.tooltip.offsetY + w.globals.translateY + 1 + w.config.xaxis.offsetY;
  13438. var xaxisTTText = ttCtx.xaxisTooltip.getBoundingClientRect();
  13439. var xaxisTTTextWidth = xaxisTTText.width;
  13440. cx = cx - xaxisTTTextWidth / 2;
  13441. if (!isNaN(cx)) {
  13442. cx = cx + w.globals.translateX;
  13443. var textRect = 0;
  13444. var graphics = new Graphics(this.ctx);
  13445. textRect = graphics.getTextRects(ttCtx.xaxisTooltipText.innerHTML);
  13446. ttCtx.xaxisTooltipText.style.minWidth = textRect.width + 'px';
  13447. ttCtx.xaxisTooltip.style.left = cx + 'px';
  13448. ttCtx.xaxisTooltip.style.top = cy + 'px';
  13449. }
  13450. }
  13451. }
  13452. }, {
  13453. key: "moveYAxisTooltip",
  13454. value: function moveYAxisTooltip(index) {
  13455. var w = this.w;
  13456. var ttCtx = this.ttCtx;
  13457. if (ttCtx.yaxisTTEls === null) {
  13458. ttCtx.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  13459. }
  13460. var ycrosshairsHiddenRectY1 = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1'), 10);
  13461. var cy = w.globals.translateY + ycrosshairsHiddenRectY1;
  13462. var yAxisTTRect = ttCtx.yaxisTTEls[index].getBoundingClientRect();
  13463. var yAxisTTHeight = yAxisTTRect.height;
  13464. var cx = w.globals.translateYAxisX[index] - 2;
  13465. if (w.config.yaxis[index].opposite) {
  13466. cx = cx - 26;
  13467. }
  13468. cy = cy - yAxisTTHeight / 2;
  13469. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1) {
  13470. ttCtx.yaxisTTEls[index].classList.add('apexcharts-active');
  13471. ttCtx.yaxisTTEls[index].style.top = cy + 'px';
  13472. ttCtx.yaxisTTEls[index].style.left = cx + w.config.yaxis[index].tooltip.offsetX + 'px';
  13473. } else {
  13474. ttCtx.yaxisTTEls[index].classList.remove('apexcharts-active');
  13475. }
  13476. }
  13477. /**
  13478. ** moves the whole tooltip by changing x, y attrs
  13479. * @memberof Position
  13480. * @param {int} - cx = point's x position, wherever point's x is, you need to move tooltip
  13481. * @param {int} - cy = point's y position, wherever point's y is, you need to move tooltip
  13482. * @param {int} - r = point's radius
  13483. */
  13484. }, {
  13485. key: "moveTooltip",
  13486. value: function moveTooltip(cx, cy) {
  13487. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  13488. var w = this.w;
  13489. var ttCtx = this.ttCtx;
  13490. var tooltipEl = ttCtx.getElTooltip();
  13491. var tooltipRect = ttCtx.tooltipRect;
  13492. var pointR = r !== null ? parseFloat(r) : 1;
  13493. var x = parseFloat(cx) + pointR + 5;
  13494. var y = parseFloat(cy) + pointR / 2; // - tooltipRect.ttHeight / 2
  13495. if (x > w.globals.gridWidth / 2) {
  13496. x = x - tooltipRect.ttWidth - pointR - 15;
  13497. }
  13498. if (x > w.globals.gridWidth - tooltipRect.ttWidth - 10) {
  13499. x = w.globals.gridWidth - tooltipRect.ttWidth;
  13500. }
  13501. if (x < -20) {
  13502. x = -20;
  13503. }
  13504. if (w.config.tooltip.followCursor) {
  13505. var elGrid = ttCtx.getElGrid();
  13506. var seriesBound = elGrid.getBoundingClientRect();
  13507. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top - tooltipRect.ttHeight / 2;
  13508. }
  13509. if (!w.config.tooltip.followCursor) {
  13510. var newPositions = this.positionChecks(tooltipRect, x, y);
  13511. x = newPositions.x;
  13512. y = newPositions.y;
  13513. }
  13514. if (!isNaN(x)) {
  13515. x = x + w.globals.translateX;
  13516. tooltipEl.style.left = x + 'px';
  13517. tooltipEl.style.top = y + 'px';
  13518. }
  13519. }
  13520. }, {
  13521. key: "positionChecks",
  13522. value: function positionChecks(tooltipRect, x, y) {
  13523. var w = this.w;
  13524. if (tooltipRect.ttHeight / 2 + y > w.globals.gridHeight) {
  13525. y = w.globals.gridHeight - tooltipRect.ttHeight + w.globals.translateY;
  13526. }
  13527. if (y < 0) {
  13528. y = 0;
  13529. }
  13530. return {
  13531. x: x,
  13532. y: y
  13533. };
  13534. }
  13535. }, {
  13536. key: "moveMarkers",
  13537. value: function moveMarkers(i, j) {
  13538. var w = this.w;
  13539. var ttCtx = this.ttCtx;
  13540. if (w.globals.markers.size[i] > 0) {
  13541. var allPoints = w.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(i, "'] .apexcharts-marker"));
  13542. for (var p = 0; p < allPoints.length; p++) {
  13543. if (parseInt(allPoints[p].getAttribute('rel'), 10) === j) {
  13544. ttCtx.marker.resetPointsSize();
  13545. ttCtx.marker.enlargeCurrentPoint(j, allPoints[p]);
  13546. }
  13547. }
  13548. } else {
  13549. ttCtx.marker.resetPointsSize();
  13550. this.moveDynamicPointOnHover(j, i);
  13551. }
  13552. } // This function is used when you need to show markers/points only on hover -
  13553. // DIFFERENT X VALUES in multiple series
  13554. }, {
  13555. key: "moveDynamicPointOnHover",
  13556. value: function moveDynamicPointOnHover(j, capturedSeries) {
  13557. var w = this.w;
  13558. var ttCtx = this.ttCtx;
  13559. var cx = 0;
  13560. var cy = 0;
  13561. var pointsArr = w.globals.pointsArray;
  13562. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(capturedSeries);
  13563. var serType = w.config.series[capturedSeries].type;
  13564. if (serType && (serType === 'column' || serType === 'candlestick')) {
  13565. // fix error mentioned in #811
  13566. return;
  13567. }
  13568. cx = pointsArr[capturedSeries][j][0];
  13569. cy = pointsArr[capturedSeries][j][1] ? pointsArr[capturedSeries][j][1] : 0;
  13570. var point = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(capturedSeries, "'] .apexcharts-series-markers circle"));
  13571. if (point) {
  13572. point.setAttribute('r', hoverSize);
  13573. point.setAttribute('cx', cx);
  13574. point.setAttribute('cy', cy);
  13575. } // point.style.opacity = w.config.markers.hover.opacity
  13576. this.moveXCrosshairs(cx);
  13577. if (!ttCtx.fixedTooltip) {
  13578. this.moveTooltip(cx, cy, hoverSize);
  13579. }
  13580. } // This function is used when you need to show markers/points only on hover -
  13581. // SAME X VALUES in multiple series
  13582. }, {
  13583. key: "moveDynamicPointsOnHover",
  13584. value: function moveDynamicPointsOnHover(j) {
  13585. var ttCtx = this.ttCtx;
  13586. var w = ttCtx.w;
  13587. var cx = 0;
  13588. var cy = 0;
  13589. var activeSeries = 0;
  13590. var pointsArr = w.globals.pointsArray;
  13591. var series = new Series(this.ctx);
  13592. activeSeries = series.getActiveConfigSeriesIndex(true);
  13593. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(activeSeries);
  13594. if (pointsArr[activeSeries]) {
  13595. cx = pointsArr[activeSeries][j][0];
  13596. cy = pointsArr[activeSeries][j][1];
  13597. }
  13598. var points = ttCtx.tooltipUtil.getAllMarkers();
  13599. if (points !== null) {
  13600. for (var p = 0; p < w.globals.series.length; p++) {
  13601. var pointArr = pointsArr[p];
  13602. if (w.globals.comboCharts) {
  13603. // in a combo chart, if column charts are present, markers will not match with the number of series, hence this patch to push a null value in points array
  13604. if (typeof pointArr === 'undefined') {
  13605. // nodelist to array
  13606. points.splice(p, 0, null);
  13607. }
  13608. }
  13609. if (pointArr && pointArr.length) {
  13610. var pcy = pointsArr[p][j][1];
  13611. points[p].setAttribute('cx', cx);
  13612. if (pcy !== null && !isNaN(pcy)) {
  13613. points[p] && points[p].setAttribute('r', hoverSize);
  13614. points[p] && points[p].setAttribute('cy', pcy);
  13615. } else {
  13616. points[p] && points[p].setAttribute('r', 0);
  13617. }
  13618. }
  13619. }
  13620. }
  13621. this.moveXCrosshairs(cx);
  13622. if (!ttCtx.fixedTooltip) {
  13623. var tcy = cy || w.globals.gridHeight;
  13624. this.moveTooltip(cx, tcy, hoverSize);
  13625. }
  13626. }
  13627. }, {
  13628. key: "moveStickyTooltipOverBars",
  13629. value: function moveStickyTooltipOverBars(j) {
  13630. var w = this.w;
  13631. var ttCtx = this.ttCtx;
  13632. var barLen = w.globals.columnSeries ? w.globals.columnSeries.length : w.globals.series.length;
  13633. var i = barLen >= 2 && barLen % 2 === 0 ? Math.floor(barLen / 2) : Math.floor(barLen / 2) + 1;
  13634. 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, "']"));
  13635. var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0;
  13636. var bcy = 0;
  13637. var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0;
  13638. if (w.globals.isXNumeric) {
  13639. bcx = bcx - (barLen % 2 !== 0 ? bw / 2 : 0);
  13640. } else {
  13641. bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2;
  13642. if (isNaN(bcx)) {
  13643. bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2;
  13644. }
  13645. } // tooltip will move vertically along with mouse as it is a shared tooltip
  13646. var elGrid = ttCtx.getElGrid();
  13647. var seriesBound = elGrid.getBoundingClientRect();
  13648. bcy = ttCtx.e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2;
  13649. this.moveXCrosshairs(bcx);
  13650. if (!ttCtx.fixedTooltip) {
  13651. var tcy = bcy || w.globals.gridHeight;
  13652. this.moveTooltip(bcx, tcy);
  13653. }
  13654. }
  13655. }]);
  13656. return Position;
  13657. }();
  13658. /**
  13659. * ApexCharts Tooltip.Marker Class to draw texts on the tooltip.
  13660. *
  13661. * @module Tooltip.Marker
  13662. **/
  13663. var Marker = /*#__PURE__*/function () {
  13664. function Marker(tooltipContext) {
  13665. _classCallCheck(this, Marker);
  13666. this.w = tooltipContext.w;
  13667. this.ttCtx = tooltipContext;
  13668. this.ctx = tooltipContext.ctx;
  13669. this.tooltipPosition = new Position(tooltipContext);
  13670. }
  13671. _createClass(Marker, [{
  13672. key: "drawDynamicPoints",
  13673. value: function drawDynamicPoints() {
  13674. var w = this.w;
  13675. var graphics = new Graphics(this.ctx);
  13676. var marker = new Markers(this.ctx);
  13677. var elsSeries = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  13678. elsSeries = _toConsumableArray(elsSeries);
  13679. elsSeries.sort(function (a, b) {
  13680. return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
  13681. });
  13682. for (var i = 0; i < elsSeries.length; i++) {
  13683. var pointsMain = elsSeries[i].querySelector(".apexcharts-series-markers-wrap");
  13684. if (pointsMain !== null) {
  13685. // it can be null as we have tooltips in donut/bar charts
  13686. var point = void 0;
  13687. var PointClasses = "apexcharts-marker w".concat((Math.random() + 1).toString(36).substring(4));
  13688. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  13689. PointClasses += ' no-pointer-events';
  13690. }
  13691. var elPointOptions = marker.getMarkerConfig(PointClasses, i);
  13692. point = graphics.drawMarker(0, 0, elPointOptions);
  13693. point.node.setAttribute('default-marker-size', 0);
  13694. var elPointsG = document.createElementNS(w.globals.SVGNS, 'g');
  13695. elPointsG.classList.add('apexcharts-series-markers');
  13696. elPointsG.appendChild(point.node);
  13697. pointsMain.appendChild(elPointsG);
  13698. }
  13699. }
  13700. }
  13701. }, {
  13702. key: "enlargeCurrentPoint",
  13703. value: function enlargeCurrentPoint(rel, point) {
  13704. var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  13705. var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  13706. var w = this.w;
  13707. if (w.config.chart.type !== 'bubble') {
  13708. this.newPointSize(rel, point);
  13709. }
  13710. var cx = point.getAttribute('cx');
  13711. var cy = point.getAttribute('cy');
  13712. if (x !== null && y !== null) {
  13713. cx = x;
  13714. cy = y;
  13715. }
  13716. this.tooltipPosition.moveXCrosshairs(cx);
  13717. if (!this.fixedTooltip) {
  13718. if (w.config.chart.type === 'radar') {
  13719. var elGrid = this.ttCtx.getElGrid();
  13720. var seriesBound = elGrid.getBoundingClientRect();
  13721. cx = this.ttCtx.e.clientX - seriesBound.left;
  13722. }
  13723. this.tooltipPosition.moveTooltip(cx, cy, w.config.markers.hover.size);
  13724. }
  13725. }
  13726. }, {
  13727. key: "enlargePoints",
  13728. value: function enlargePoints(j) {
  13729. var w = this.w;
  13730. var me = this;
  13731. var ttCtx = this.ttCtx;
  13732. var col = j;
  13733. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  13734. var newSize = w.config.markers.hover.size;
  13735. for (var p = 0; p < points.length; p++) {
  13736. var rel = points[p].getAttribute('rel');
  13737. var index = points[p].getAttribute('index');
  13738. if (newSize === undefined) {
  13739. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  13740. }
  13741. if (col === parseInt(rel, 10)) {
  13742. me.newPointSize(col, points[p]);
  13743. var cx = points[p].getAttribute('cx');
  13744. var cy = points[p].getAttribute('cy');
  13745. me.tooltipPosition.moveXCrosshairs(cx);
  13746. if (!ttCtx.fixedTooltip) {
  13747. me.tooltipPosition.moveTooltip(cx, cy, newSize);
  13748. }
  13749. } else {
  13750. me.oldPointSize(points[p]);
  13751. }
  13752. }
  13753. }
  13754. }, {
  13755. key: "newPointSize",
  13756. value: function newPointSize(rel, point) {
  13757. var w = this.w;
  13758. var newSize = w.config.markers.hover.size;
  13759. var elPoint = rel === 0 ? point.parentNode.firstChild : point.parentNode.lastChild;
  13760. if (elPoint.getAttribute('default-marker-size') !== '0') {
  13761. var index = parseInt(elPoint.getAttribute('index'), 10);
  13762. if (newSize === undefined) {
  13763. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  13764. }
  13765. elPoint.setAttribute('r', newSize);
  13766. }
  13767. }
  13768. }, {
  13769. key: "oldPointSize",
  13770. value: function oldPointSize(point) {
  13771. var size = parseFloat(point.getAttribute('default-marker-size'));
  13772. point.setAttribute('r', size);
  13773. }
  13774. }, {
  13775. key: "resetPointsSize",
  13776. value: function resetPointsSize() {
  13777. var w = this.w;
  13778. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  13779. for (var p = 0; p < points.length; p++) {
  13780. var size = parseFloat(points[p].getAttribute('default-marker-size'));
  13781. if (Utils.isNumber(size)) {
  13782. points[p].setAttribute('r', size);
  13783. } else {
  13784. points[p].setAttribute('r', 0);
  13785. }
  13786. }
  13787. }
  13788. }]);
  13789. return Marker;
  13790. }();
  13791. /**
  13792. * ApexCharts Tooltip.Intersect Class.
  13793. *
  13794. * @module Tooltip.Intersect
  13795. **/
  13796. var Intersect = /*#__PURE__*/function () {
  13797. function Intersect(tooltipContext) {
  13798. _classCallCheck(this, Intersect);
  13799. this.w = tooltipContext.w;
  13800. this.ttCtx = tooltipContext;
  13801. }
  13802. _createClass(Intersect, [{
  13803. key: "getAttr",
  13804. value: function getAttr(e, attr) {
  13805. return parseFloat(e.target.getAttribute(attr));
  13806. }
  13807. }, {
  13808. key: "handleHeatTooltip",
  13809. value: function handleHeatTooltip(_ref) {
  13810. var e = _ref.e,
  13811. opt = _ref.opt,
  13812. x = _ref.x,
  13813. y = _ref.y;
  13814. var ttCtx = this.ttCtx;
  13815. var w = this.w;
  13816. if (e.target.classList.contains('apexcharts-heatmap-rect')) {
  13817. var i = this.getAttr(e, 'i');
  13818. var j = this.getAttr(e, 'j');
  13819. var cx = this.getAttr(e, 'cx');
  13820. var cy = this.getAttr(e, 'cy');
  13821. var width = this.getAttr(e, 'width');
  13822. var height = this.getAttr(e, 'height');
  13823. ttCtx.tooltipLabels.drawSeriesTexts({
  13824. ttItems: opt.ttItems,
  13825. i: i,
  13826. j: j,
  13827. shared: false
  13828. });
  13829. w.globals.capturedSeriesIndex = i;
  13830. w.globals.capturedDataPointIndex = j;
  13831. x = cx + ttCtx.tooltipRect.ttWidth / 2 + width;
  13832. y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2;
  13833. ttCtx.tooltipPosition.moveXCrosshairs(cx + width / 2);
  13834. if (x > w.globals.gridWidth / 2) {
  13835. x = cx - ttCtx.tooltipRect.ttWidth / 2 + width;
  13836. }
  13837. if (ttCtx.w.config.tooltip.followCursor) {
  13838. var elGrid = ttCtx.getElGrid();
  13839. var seriesBound = elGrid.getBoundingClientRect(); // x = ttCtx.e.clientX - seriesBound.left
  13840. y = ttCtx.e.clientY - seriesBound.top + w.globals.translateY / 2 - 10;
  13841. }
  13842. }
  13843. return {
  13844. x: x,
  13845. y: y
  13846. };
  13847. }
  13848. }, {
  13849. key: "handleMarkerTooltip",
  13850. value: function handleMarkerTooltip(_ref2) {
  13851. var e = _ref2.e,
  13852. opt = _ref2.opt,
  13853. x = _ref2.x,
  13854. y = _ref2.y;
  13855. var w = this.w;
  13856. var ttCtx = this.ttCtx;
  13857. var i;
  13858. var j;
  13859. if (e.target.classList.contains('apexcharts-marker')) {
  13860. var cx = parseInt(opt.paths.getAttribute('cx'), 10);
  13861. var cy = parseInt(opt.paths.getAttribute('cy'), 10);
  13862. var val = parseFloat(opt.paths.getAttribute('val'));
  13863. j = parseInt(opt.paths.getAttribute('rel'), 10);
  13864. i = parseInt(opt.paths.parentNode.parentNode.parentNode.getAttribute('rel'), 10) - 1;
  13865. if (ttCtx.intersect) {
  13866. var el = Utils.findAncestor(opt.paths, 'apexcharts-series');
  13867. if (el) {
  13868. i = parseInt(el.getAttribute('data:realIndex'), 10);
  13869. }
  13870. }
  13871. ttCtx.tooltipLabels.drawSeriesTexts({
  13872. ttItems: opt.ttItems,
  13873. i: i,
  13874. j: j,
  13875. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
  13876. });
  13877. if (e.type === 'mouseup') {
  13878. ttCtx.markerClick(e, i, j);
  13879. }
  13880. w.globals.capturedSeriesIndex = i;
  13881. w.globals.capturedDataPointIndex = j;
  13882. x = cx;
  13883. y = cy + w.globals.translateY - ttCtx.tooltipRect.ttHeight * 1.4;
  13884. if (ttCtx.w.config.tooltip.followCursor) {
  13885. var elGrid = ttCtx.getElGrid();
  13886. var seriesBound = elGrid.getBoundingClientRect();
  13887. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top;
  13888. }
  13889. if (val < 0) {
  13890. y = cy;
  13891. }
  13892. ttCtx.marker.enlargeCurrentPoint(j, opt.paths, x, y);
  13893. }
  13894. return {
  13895. x: x,
  13896. y: y
  13897. };
  13898. }
  13899. }, {
  13900. key: "handleBarTooltip",
  13901. value: function handleBarTooltip(_ref3) {
  13902. var e = _ref3.e,
  13903. opt = _ref3.opt;
  13904. var w = this.w;
  13905. var ttCtx = this.ttCtx;
  13906. var tooltipEl = ttCtx.getElTooltip();
  13907. var bx = 0;
  13908. var x = 0;
  13909. var y = 0;
  13910. var i = 0;
  13911. var strokeWidth;
  13912. var barXY = this.getBarTooltipXY({
  13913. e: e,
  13914. opt: opt
  13915. });
  13916. i = barXY.i;
  13917. var barHeight = barXY.barHeight;
  13918. var j = barXY.j;
  13919. w.globals.capturedSeriesIndex = i;
  13920. w.globals.capturedDataPointIndex = j;
  13921. if (w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars() || !w.config.tooltip.shared) {
  13922. x = barXY.x;
  13923. y = barXY.y;
  13924. strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[i] : w.config.stroke.width;
  13925. bx = x;
  13926. } else {
  13927. if (!w.globals.comboCharts && !w.config.tooltip.shared) {
  13928. bx = bx / 2;
  13929. }
  13930. } // y is NaN, make it touch the bottom of grid area
  13931. if (isNaN(y)) {
  13932. y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight;
  13933. } else if (y < 0) {
  13934. y = 0;
  13935. }
  13936. if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth) {
  13937. x = x - ttCtx.tooltipRect.ttWidth;
  13938. } else if (x < 0) {
  13939. x = 0;
  13940. }
  13941. if (ttCtx.w.config.tooltip.followCursor) {
  13942. var elGrid = ttCtx.getElGrid();
  13943. var seriesBound = elGrid.getBoundingClientRect();
  13944. y = ttCtx.e.clientY - seriesBound.top;
  13945. } // if tooltip is still null, querySelector
  13946. if (ttCtx.tooltip === null) {
  13947. ttCtx.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  13948. }
  13949. if (!w.config.tooltip.shared) {
  13950. if (w.globals.comboBarCount > 0) {
  13951. ttCtx.tooltipPosition.moveXCrosshairs(bx + strokeWidth / 2);
  13952. } else {
  13953. ttCtx.tooltipPosition.moveXCrosshairs(bx);
  13954. }
  13955. } // move tooltip here
  13956. if (!ttCtx.fixedTooltip && (!w.config.tooltip.shared || w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  13957. var isReversed = w.globals.isMultipleYAxis ? w.config.yaxis[seriesIndex] && w.config.yaxis[seriesIndex].reversed : w.config.yaxis[0].reversed;
  13958. if (isReversed) {
  13959. x = x - ttCtx.tooltipRect.ttWidth;
  13960. if (x < 0) {
  13961. x = 0;
  13962. }
  13963. }
  13964. tooltipEl.style.left = x + w.globals.translateX + 'px';
  13965. var seriesIndex = parseInt(opt.paths.parentNode.getAttribute('data:realIndex'), 10);
  13966. if (isReversed && !(w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  13967. y = y + barHeight - (w.globals.series[i][j] < 0 ? barHeight : 0) * 2;
  13968. }
  13969. if (ttCtx.tooltipRect.ttHeight + y > w.globals.gridHeight) {
  13970. y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight + w.globals.translateY;
  13971. tooltipEl.style.top = y + 'px';
  13972. } else {
  13973. tooltipEl.style.top = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2 + 'px';
  13974. }
  13975. }
  13976. }
  13977. }, {
  13978. key: "getBarTooltipXY",
  13979. value: function getBarTooltipXY(_ref4) {
  13980. var e = _ref4.e,
  13981. opt = _ref4.opt;
  13982. var w = this.w;
  13983. var j = null;
  13984. var ttCtx = this.ttCtx;
  13985. var i = 0;
  13986. var x = 0;
  13987. var y = 0;
  13988. var barWidth = 0;
  13989. var barHeight = 0;
  13990. var cl = e.target.classList;
  13991. if (cl.contains('apexcharts-bar-area') || cl.contains('apexcharts-candlestick-area') || cl.contains('apexcharts-rangebar-area')) {
  13992. var bar = e.target;
  13993. var barRect = bar.getBoundingClientRect();
  13994. var seriesBound = opt.elGrid.getBoundingClientRect();
  13995. var bh = barRect.height;
  13996. barHeight = barRect.height;
  13997. var bw = barRect.width;
  13998. var cx = parseInt(bar.getAttribute('cx'), 10);
  13999. var cy = parseInt(bar.getAttribute('cy'), 10);
  14000. barWidth = parseFloat(bar.getAttribute('barWidth'));
  14001. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  14002. j = parseInt(bar.getAttribute('j'), 10);
  14003. i = parseInt(bar.parentNode.getAttribute('rel'), 10) - 1;
  14004. var y1 = bar.getAttribute('data-range-y1');
  14005. var y2 = bar.getAttribute('data-range-y2');
  14006. if (w.globals.comboCharts) {
  14007. i = parseInt(bar.parentNode.getAttribute('data:realIndex'), 10);
  14008. } // if (w.config.tooltip.shared) {
  14009. // this check not needed at the moment
  14010. // const yDivisor = w.globals.gridHeight / (w.globals.series.length)
  14011. // const hoverY = ttCtx.clientY - ttCtx.seriesBound.top
  14012. // j = Math.ceil(hoverY / yDivisor)
  14013. // }
  14014. ttCtx.tooltipLabels.drawSeriesTexts({
  14015. ttItems: opt.ttItems,
  14016. i: i,
  14017. j: j,
  14018. y1: y1 ? parseInt(y1, 10) : null,
  14019. y2: y2 ? parseInt(y2, 10) : null,
  14020. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
  14021. });
  14022. if (w.config.tooltip.followCursor) {
  14023. if (w.globals.isBarHorizontal) {
  14024. x = clientX - seriesBound.left + 15;
  14025. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  14026. } else {
  14027. if (w.globals.isXNumeric) {
  14028. x = cx - bw / 2;
  14029. } else {
  14030. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  14031. }
  14032. y = e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2 - 15;
  14033. }
  14034. } else {
  14035. if (w.globals.isBarHorizontal) {
  14036. x = cx;
  14037. if (x < ttCtx.xyRatios.baseLineInvertedY) {
  14038. x = cx - ttCtx.tooltipRect.ttWidth;
  14039. }
  14040. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  14041. } else {
  14042. // if columns
  14043. if (w.globals.isXNumeric) {
  14044. x = cx - bw / 2;
  14045. } else {
  14046. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  14047. }
  14048. y = cy; // - ttCtx.tooltipRect.ttHeight / 2 + 10
  14049. }
  14050. }
  14051. }
  14052. return {
  14053. x: x,
  14054. y: y,
  14055. barHeight: barHeight,
  14056. barWidth: barWidth,
  14057. i: i,
  14058. j: j
  14059. };
  14060. }
  14061. }]);
  14062. return Intersect;
  14063. }();
  14064. /**
  14065. * ApexCharts Tooltip.AxesTooltip Class.
  14066. *
  14067. * @module Tooltip.AxesTooltip
  14068. **/
  14069. var AxesTooltip = /*#__PURE__*/function () {
  14070. function AxesTooltip(tooltipContext) {
  14071. _classCallCheck(this, AxesTooltip);
  14072. this.w = tooltipContext.w;
  14073. this.ttCtx = tooltipContext;
  14074. }
  14075. /**
  14076. * This method adds the secondary tooltip which appears below x axis
  14077. * @memberof Tooltip
  14078. **/
  14079. _createClass(AxesTooltip, [{
  14080. key: "drawXaxisTooltip",
  14081. value: function drawXaxisTooltip() {
  14082. var w = this.w;
  14083. var ttCtx = this.ttCtx;
  14084. var isBottom = w.config.xaxis.position === 'bottom';
  14085. ttCtx.xaxisOffY = isBottom ? w.globals.gridHeight + 1 : -w.globals.xAxisHeight - w.config.xaxis.axisTicks.height + 3;
  14086. var tooltipCssClass = isBottom ? 'apexcharts-xaxistooltip apexcharts-xaxistooltip-bottom' : 'apexcharts-xaxistooltip apexcharts-xaxistooltip-top';
  14087. var renderTo = w.globals.dom.elWrap;
  14088. if (ttCtx.blxaxisTooltip) {
  14089. var xaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-xaxistooltip');
  14090. if (xaxisTooltip === null) {
  14091. ttCtx.xaxisTooltip = document.createElement('div');
  14092. ttCtx.xaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  14093. renderTo.appendChild(ttCtx.xaxisTooltip);
  14094. ttCtx.xaxisTooltipText = document.createElement('div');
  14095. ttCtx.xaxisTooltipText.classList.add('apexcharts-xaxistooltip-text');
  14096. ttCtx.xaxisTooltipText.style.fontFamily = w.config.xaxis.tooltip.style.fontFamily || w.config.chart.fontFamily;
  14097. ttCtx.xaxisTooltipText.style.fontSize = w.config.xaxis.tooltip.style.fontSize;
  14098. ttCtx.xaxisTooltip.appendChild(ttCtx.xaxisTooltipText);
  14099. }
  14100. }
  14101. }
  14102. /**
  14103. * This method adds the secondary tooltip which appears below x axis
  14104. * @memberof Tooltip
  14105. **/
  14106. }, {
  14107. key: "drawYaxisTooltip",
  14108. value: function drawYaxisTooltip() {
  14109. var w = this.w;
  14110. var ttCtx = this.ttCtx;
  14111. var _loop = function _loop(i) {
  14112. var isRight = w.config.yaxis[i].opposite || w.config.yaxis[i].crosshairs.opposite;
  14113. ttCtx.yaxisOffX = isRight ? w.globals.gridWidth + 1 : 1;
  14114. var tooltipCssClass = isRight ? "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-right") : "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-left");
  14115. w.globals.yAxisSameScaleIndices.map(function (samescales, ssi) {
  14116. samescales.map(function (s, si) {
  14117. if (si === i) {
  14118. tooltipCssClass += w.config.yaxis[si].show ? " " : " apexcharts-yaxistooltip-hidden";
  14119. }
  14120. });
  14121. });
  14122. var renderTo = w.globals.dom.elWrap;
  14123. if (ttCtx.blyaxisTooltip) {
  14124. var yaxisTooltip = w.globals.dom.baseEl.querySelector(".apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i));
  14125. if (yaxisTooltip === null) {
  14126. ttCtx.yaxisTooltip = document.createElement('div');
  14127. ttCtx.yaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  14128. renderTo.appendChild(ttCtx.yaxisTooltip);
  14129. if (i === 0) ttCtx.yaxisTooltipText = [];
  14130. ttCtx.yaxisTooltipText.push(document.createElement('div'));
  14131. ttCtx.yaxisTooltipText[i].classList.add('apexcharts-yaxistooltip-text');
  14132. ttCtx.yaxisTooltip.appendChild(ttCtx.yaxisTooltipText[i]);
  14133. }
  14134. }
  14135. };
  14136. for (var i = 0; i < w.config.yaxis.length; i++) {
  14137. _loop(i);
  14138. }
  14139. }
  14140. /**
  14141. * @memberof Tooltip
  14142. **/
  14143. }, {
  14144. key: "setXCrosshairWidth",
  14145. value: function setXCrosshairWidth() {
  14146. var w = this.w;
  14147. var ttCtx = this.ttCtx; // set xcrosshairs width
  14148. var xcrosshairs = ttCtx.getElXCrosshairs();
  14149. ttCtx.xcrosshairsWidth = parseInt(w.config.xaxis.crosshairs.width, 10);
  14150. if (!w.globals.comboCharts) {
  14151. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  14152. var count = w.globals.labels.length;
  14153. ttCtx.xcrosshairsWidth = w.globals.gridWidth / count;
  14154. } else if (w.config.xaxis.crosshairs.width === 'barWidth') {
  14155. var bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  14156. if (bar !== null) {
  14157. var barWidth = parseFloat(bar.getAttribute('barWidth'));
  14158. ttCtx.xcrosshairsWidth = barWidth;
  14159. } else {
  14160. ttCtx.xcrosshairsWidth = 1;
  14161. }
  14162. }
  14163. } else {
  14164. var _bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  14165. if (_bar !== null && w.config.xaxis.crosshairs.width === 'barWidth') {
  14166. var _barWidth = parseFloat(_bar.getAttribute('barWidth'));
  14167. ttCtx.xcrosshairsWidth = _barWidth;
  14168. } else {
  14169. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  14170. var _count = w.globals.labels.length;
  14171. ttCtx.xcrosshairsWidth = w.globals.gridWidth / _count;
  14172. }
  14173. }
  14174. }
  14175. if (w.globals.isBarHorizontal) {
  14176. ttCtx.xcrosshairsWidth = 0;
  14177. }
  14178. if (xcrosshairs !== null && ttCtx.xcrosshairsWidth > 0) {
  14179. xcrosshairs.setAttribute('width', ttCtx.xcrosshairsWidth);
  14180. }
  14181. }
  14182. }, {
  14183. key: "handleYCrosshair",
  14184. value: function handleYCrosshair() {
  14185. var w = this.w;
  14186. var ttCtx = this.ttCtx; // set ycrosshairs height
  14187. ttCtx.ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs');
  14188. ttCtx.ycrosshairsHidden = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs-hidden');
  14189. }
  14190. }, {
  14191. key: "drawYaxisTooltipText",
  14192. value: function drawYaxisTooltipText(index, clientY, xyRatios) {
  14193. var ttCtx = this.ttCtx;
  14194. var w = this.w;
  14195. var lbFormatter = w.globals.yLabelFormatters[index];
  14196. if (ttCtx.blyaxisTooltip) {
  14197. var elGrid = ttCtx.getElGrid();
  14198. var seriesBound = elGrid.getBoundingClientRect();
  14199. var hoverY = (clientY - seriesBound.top) * xyRatios.yRatio[index];
  14200. var height = w.globals.maxYArr[index] - w.globals.minYArr[index];
  14201. var val = w.globals.minYArr[index] + (height - hoverY);
  14202. ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top);
  14203. ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val);
  14204. ttCtx.tooltipPosition.moveYAxisTooltip(index);
  14205. }
  14206. }
  14207. }]);
  14208. return AxesTooltip;
  14209. }();
  14210. /**
  14211. * ApexCharts Core Tooltip Class to handle the tooltip generation.
  14212. *
  14213. * @module Tooltip
  14214. **/
  14215. var Tooltip = /*#__PURE__*/function () {
  14216. function Tooltip(ctx) {
  14217. _classCallCheck(this, Tooltip);
  14218. this.ctx = ctx;
  14219. this.w = ctx.w;
  14220. var w = this.w;
  14221. this.tConfig = w.config.tooltip;
  14222. this.tooltipUtil = new Utils$1(this);
  14223. this.tooltipLabels = new Labels(this);
  14224. this.tooltipPosition = new Position(this);
  14225. this.marker = new Marker(this);
  14226. this.intersect = new Intersect(this);
  14227. this.axesTooltip = new AxesTooltip(this);
  14228. this.showOnIntersect = this.tConfig.intersect;
  14229. this.showTooltipTitle = this.tConfig.x.show;
  14230. this.fixedTooltip = this.tConfig.fixed.enabled;
  14231. this.xaxisTooltip = null;
  14232. this.yaxisTTEls = null;
  14233. this.isBarShared = !w.globals.isBarHorizontal && this.tConfig.shared;
  14234. }
  14235. _createClass(Tooltip, [{
  14236. key: "getElTooltip",
  14237. value: function getElTooltip(ctx) {
  14238. if (!ctx) ctx = this;
  14239. return ctx.w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  14240. }
  14241. }, {
  14242. key: "getElXCrosshairs",
  14243. value: function getElXCrosshairs() {
  14244. return this.w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs');
  14245. }
  14246. }, {
  14247. key: "getElGrid",
  14248. value: function getElGrid() {
  14249. return this.w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  14250. }
  14251. }, {
  14252. key: "drawTooltip",
  14253. value: function drawTooltip(xyRatios) {
  14254. var w = this.w;
  14255. this.xyRatios = xyRatios;
  14256. this.blxaxisTooltip = w.config.xaxis.tooltip.enabled && w.globals.axisCharts;
  14257. this.blyaxisTooltip = w.config.yaxis[0].tooltip.enabled && w.globals.axisCharts;
  14258. this.allTooltipSeriesGroups = [];
  14259. if (!w.globals.axisCharts) {
  14260. this.showTooltipTitle = false;
  14261. }
  14262. var tooltipEl = document.createElement('div');
  14263. tooltipEl.classList.add('apexcharts-tooltip');
  14264. tooltipEl.classList.add("apexcharts-theme-".concat(this.tConfig.theme));
  14265. w.globals.dom.elWrap.appendChild(tooltipEl);
  14266. if (w.globals.axisCharts) {
  14267. this.axesTooltip.drawXaxisTooltip();
  14268. this.axesTooltip.drawYaxisTooltip();
  14269. this.axesTooltip.setXCrosshairWidth();
  14270. this.axesTooltip.handleYCrosshair();
  14271. var xAxis = new XAxis(this.ctx);
  14272. this.xAxisTicksPositions = xAxis.getXAxisTicksPositions();
  14273. } // we forcefully set intersect true for these conditions
  14274. if ((w.globals.comboCharts || this.tConfig.intersect || w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && !this.tConfig.shared) {
  14275. this.showOnIntersect = true;
  14276. }
  14277. if (w.config.markers.size === 0 || w.globals.markers.largestSize === 0) {
  14278. // when user don't want to show points all the time, but only on when hovering on series
  14279. this.marker.drawDynamicPoints(this);
  14280. } // no visible series, exit
  14281. if (w.globals.collapsedSeries.length === w.globals.series.length) return;
  14282. this.dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  14283. this.dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  14284. if (this.showTooltipTitle) {
  14285. this.tooltipTitle = document.createElement('div');
  14286. this.tooltipTitle.classList.add('apexcharts-tooltip-title');
  14287. this.tooltipTitle.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  14288. this.tooltipTitle.style.fontSize = this.tConfig.style.fontSize;
  14289. tooltipEl.appendChild(this.tooltipTitle);
  14290. }
  14291. var ttItemsCnt = w.globals.series.length; // whether shared or not, default is shared
  14292. if ((w.globals.xyCharts || w.globals.comboCharts) && this.tConfig.shared) {
  14293. if (!this.showOnIntersect) {
  14294. ttItemsCnt = w.globals.series.length;
  14295. } else {
  14296. ttItemsCnt = 1;
  14297. }
  14298. }
  14299. this.legendLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-text');
  14300. this.ttItems = this.createTTElements(ttItemsCnt);
  14301. this.addSVGEvents();
  14302. }
  14303. }, {
  14304. key: "createTTElements",
  14305. value: function createTTElements(ttItemsCnt) {
  14306. var w = this.w;
  14307. var ttItems = [];
  14308. var tooltipEl = this.getElTooltip();
  14309. for (var i = 0; i < ttItemsCnt; i++) {
  14310. var gTxt = document.createElement('div');
  14311. gTxt.classList.add('apexcharts-tooltip-series-group');
  14312. if (this.tConfig.shared && this.tConfig.enabledOnSeries && Array.isArray(this.tConfig.enabledOnSeries)) {
  14313. if (this.tConfig.enabledOnSeries.indexOf(i) < 0) {
  14314. gTxt.classList.add('apexcharts-tooltip-series-group-hidden');
  14315. }
  14316. }
  14317. var point = document.createElement('span');
  14318. point.classList.add('apexcharts-tooltip-marker');
  14319. point.style.backgroundColor = w.globals.colors[i];
  14320. gTxt.appendChild(point);
  14321. var gYZ = document.createElement('div');
  14322. gYZ.classList.add('apexcharts-tooltip-text');
  14323. gYZ.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  14324. gYZ.style.fontSize = this.tConfig.style.fontSize; // y values group
  14325. var gYValText = document.createElement('div');
  14326. gYValText.classList.add('apexcharts-tooltip-y-group');
  14327. var txtLabel = document.createElement('span');
  14328. txtLabel.classList.add('apexcharts-tooltip-text-label');
  14329. gYValText.appendChild(txtLabel);
  14330. var txtValue = document.createElement('span');
  14331. txtValue.classList.add('apexcharts-tooltip-text-value');
  14332. gYValText.appendChild(txtValue); // z values group
  14333. var gZValText = document.createElement('div');
  14334. gZValText.classList.add('apexcharts-tooltip-z-group');
  14335. var txtZLabel = document.createElement('span');
  14336. txtZLabel.classList.add('apexcharts-tooltip-text-z-label');
  14337. gZValText.appendChild(txtZLabel);
  14338. var txtZValue = document.createElement('span');
  14339. txtZValue.classList.add('apexcharts-tooltip-text-z-value');
  14340. gZValText.appendChild(txtZValue);
  14341. gYZ.appendChild(gYValText);
  14342. gYZ.appendChild(gZValText);
  14343. gTxt.appendChild(gYZ);
  14344. tooltipEl.appendChild(gTxt);
  14345. ttItems.push(gTxt);
  14346. }
  14347. return ttItems;
  14348. }
  14349. }, {
  14350. key: "addSVGEvents",
  14351. value: function addSVGEvents() {
  14352. var w = this.w;
  14353. var type = w.config.chart.type;
  14354. var tooltipEl = this.getElTooltip();
  14355. var commonBar = !!(type === 'bar' || type === 'candlestick' || type === 'rangeBar');
  14356. var chartWithmarkers = type === 'area' || type === 'line' || type === 'scatter' || type === 'bubble' || type === 'radar';
  14357. var hoverArea = w.globals.dom.Paper.node;
  14358. var elGrid = this.getElGrid();
  14359. if (elGrid) {
  14360. this.seriesBound = elGrid.getBoundingClientRect();
  14361. }
  14362. var tooltipY = [];
  14363. var tooltipX = [];
  14364. var seriesHoverParams = {
  14365. hoverArea: hoverArea,
  14366. elGrid: elGrid,
  14367. tooltipEl: tooltipEl,
  14368. tooltipY: tooltipY,
  14369. tooltipX: tooltipX,
  14370. ttItems: this.ttItems
  14371. };
  14372. var points;
  14373. if (w.globals.axisCharts) {
  14374. if (chartWithmarkers) {
  14375. points = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series[data\\:longestSeries='true'] .apexcharts-marker");
  14376. } else if (commonBar) {
  14377. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area, .apexcharts-series .apexcharts-candlestick-area, .apexcharts-series .apexcharts-rangebar-area');
  14378. } else if (type === 'heatmap') {
  14379. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap');
  14380. }
  14381. if (points && points.length) {
  14382. for (var p = 0; p < points.length; p++) {
  14383. tooltipY.push(points[p].getAttribute('cy'));
  14384. tooltipX.push(points[p].getAttribute('cx'));
  14385. }
  14386. }
  14387. }
  14388. var validSharedChartTypes = w.globals.xyCharts && !this.showOnIntersect || w.globals.comboCharts && !this.showOnIntersect || commonBar && this.tooltipUtil.hasBars() && this.tConfig.shared;
  14389. if (validSharedChartTypes) {
  14390. this.addPathsEventListeners([hoverArea], seriesHoverParams);
  14391. } else if (commonBar && !w.globals.comboCharts || chartWithmarkers && this.showOnIntersect) {
  14392. this.addDatapointEventsListeners(seriesHoverParams);
  14393. } else if (!w.globals.axisCharts || type === 'heatmap') {
  14394. var seriesAll = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  14395. this.addPathsEventListeners(seriesAll, seriesHoverParams);
  14396. }
  14397. if (this.showOnIntersect) {
  14398. var lineAreaPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-marker, .apexcharts-area-series .apexcharts-marker');
  14399. if (lineAreaPoints.length > 0) {
  14400. // if we find any lineSeries, addEventListeners for them
  14401. this.addPathsEventListeners(lineAreaPoints, seriesHoverParams);
  14402. } // combo charts may have bars, so add event listeners here too
  14403. if (this.tooltipUtil.hasBars() && !this.tConfig.shared) {
  14404. this.addDatapointEventsListeners(seriesHoverParams);
  14405. }
  14406. }
  14407. }
  14408. }, {
  14409. key: "drawFixedTooltipRect",
  14410. value: function drawFixedTooltipRect() {
  14411. var w = this.w;
  14412. var tooltipEl = this.getElTooltip();
  14413. var tooltipRect = tooltipEl.getBoundingClientRect();
  14414. var ttWidth = tooltipRect.width + 10;
  14415. var ttHeight = tooltipRect.height + 10;
  14416. var x = this.tConfig.fixed.offsetX;
  14417. var y = this.tConfig.fixed.offsetY;
  14418. var fixed = this.tConfig.fixed.position.toLowerCase();
  14419. if (fixed.indexOf('right') > -1) {
  14420. x = x + w.globals.svgWidth - ttWidth + 10;
  14421. }
  14422. if (fixed.indexOf('bottom') > -1) {
  14423. y = y + w.globals.svgHeight - ttHeight - 10;
  14424. }
  14425. tooltipEl.style.left = x + 'px';
  14426. tooltipEl.style.top = y + 'px';
  14427. return {
  14428. x: x,
  14429. y: y,
  14430. ttWidth: ttWidth,
  14431. ttHeight: ttHeight
  14432. };
  14433. }
  14434. }, {
  14435. key: "addDatapointEventsListeners",
  14436. value: function addDatapointEventsListeners(seriesHoverParams) {
  14437. var w = this.w;
  14438. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-rangebar-area');
  14439. this.addPathsEventListeners(points, seriesHoverParams);
  14440. }
  14441. }, {
  14442. key: "addPathsEventListeners",
  14443. value: function addPathsEventListeners(paths, opts) {
  14444. var self = this;
  14445. var _loop = function _loop(p) {
  14446. var extendedOpts = {
  14447. paths: paths[p],
  14448. tooltipEl: opts.tooltipEl,
  14449. tooltipY: opts.tooltipY,
  14450. tooltipX: opts.tooltipX,
  14451. elGrid: opts.elGrid,
  14452. hoverArea: opts.hoverArea,
  14453. ttItems: opts.ttItems
  14454. };
  14455. var events = ['mousemove', 'mouseup', 'touchmove', 'mouseout', 'touchend'];
  14456. events.map(function (ev) {
  14457. return paths[p].addEventListener(ev, self.seriesHover.bind(self, extendedOpts), {
  14458. capture: false,
  14459. passive: true
  14460. });
  14461. });
  14462. };
  14463. for (var p = 0; p < paths.length; p++) {
  14464. _loop(p);
  14465. }
  14466. }
  14467. /*
  14468. ** The actual series hover function
  14469. */
  14470. }, {
  14471. key: "seriesHover",
  14472. value: function seriesHover(opt, e) {
  14473. var _this = this;
  14474. var chartGroups = [];
  14475. var w = this.w; // if user has more than one charts in group, we need to sync
  14476. if (w.config.chart.group) {
  14477. chartGroups = this.ctx.getGroupedCharts();
  14478. }
  14479. if (w.globals.axisCharts && (w.globals.minX === -Infinity && w.globals.maxX === Infinity || w.globals.dataPoints === 0)) {
  14480. return;
  14481. }
  14482. if (chartGroups.length) {
  14483. chartGroups.forEach(function (ch) {
  14484. var tooltipEl = _this.getElTooltip(ch);
  14485. var newOpts = {
  14486. paths: opt.paths,
  14487. tooltipEl: tooltipEl,
  14488. tooltipY: opt.tooltipY,
  14489. tooltipX: opt.tooltipX,
  14490. elGrid: opt.elGrid,
  14491. hoverArea: opt.hoverArea,
  14492. ttItems: ch.w.globals.tooltip.ttItems
  14493. }; // all the charts should have the same minX and maxX (same xaxis) for multiple tooltips to work correctly
  14494. if (ch.w.globals.minX === _this.w.globals.minX && ch.w.globals.maxX === _this.w.globals.maxX) {
  14495. ch.w.globals.tooltip.seriesHoverByContext({
  14496. chartCtx: ch,
  14497. ttCtx: ch.w.globals.tooltip,
  14498. opt: newOpts,
  14499. e: e
  14500. });
  14501. }
  14502. });
  14503. } else {
  14504. this.seriesHoverByContext({
  14505. chartCtx: this.ctx,
  14506. ttCtx: this.w.globals.tooltip,
  14507. opt: opt,
  14508. e: e
  14509. });
  14510. }
  14511. }
  14512. }, {
  14513. key: "seriesHoverByContext",
  14514. value: function seriesHoverByContext(_ref) {
  14515. var chartCtx = _ref.chartCtx,
  14516. ttCtx = _ref.ttCtx,
  14517. opt = _ref.opt,
  14518. e = _ref.e;
  14519. var w = chartCtx.w;
  14520. var tooltipEl = this.getElTooltip(); // tooltipRect is calculated on every mousemove, because the text is dynamic
  14521. ttCtx.tooltipRect = {
  14522. x: 0,
  14523. y: 0,
  14524. ttWidth: tooltipEl.getBoundingClientRect().width,
  14525. ttHeight: tooltipEl.getBoundingClientRect().height
  14526. };
  14527. ttCtx.e = e; // highlight the current hovered bars
  14528. if (ttCtx.tooltipUtil.hasBars() && !w.globals.comboCharts && !ttCtx.isBarShared) {
  14529. if (this.tConfig.onDatasetHover.highlightDataSeries) {
  14530. var series = new Series(chartCtx);
  14531. series.toggleSeriesOnHover(e, e.target.parentNode);
  14532. }
  14533. }
  14534. if (ttCtx.fixedTooltip) {
  14535. ttCtx.drawFixedTooltipRect();
  14536. }
  14537. if (w.globals.axisCharts) {
  14538. ttCtx.axisChartsTooltips({
  14539. e: e,
  14540. opt: opt,
  14541. tooltipRect: ttCtx.tooltipRect
  14542. });
  14543. } else {
  14544. // non-plot charts i.e pie/donut/circle
  14545. ttCtx.nonAxisChartsTooltips({
  14546. e: e,
  14547. opt: opt,
  14548. tooltipRect: ttCtx.tooltipRect
  14549. });
  14550. }
  14551. } // tooltip handling for line/area/bar/columns/scatter
  14552. }, {
  14553. key: "axisChartsTooltips",
  14554. value: function axisChartsTooltips(_ref2) {
  14555. var e = _ref2.e,
  14556. opt = _ref2.opt;
  14557. var w = this.w;
  14558. var x, y;
  14559. var seriesBound = opt.elGrid.getBoundingClientRect();
  14560. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  14561. var clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  14562. this.clientY = clientY;
  14563. this.clientX = clientX;
  14564. w.globals.capturedSeriesIndex = -1;
  14565. w.globals.capturedDataPointIndex = -1;
  14566. if (clientY < seriesBound.top || clientY > seriesBound.top + seriesBound.height) {
  14567. this.handleMouseOut(opt);
  14568. return;
  14569. }
  14570. if (Array.isArray(this.tConfig.enabledOnSeries) && !w.config.tooltip.shared) {
  14571. var index = parseInt(opt.paths.getAttribute('index'), 10);
  14572. if (this.tConfig.enabledOnSeries.indexOf(index) < 0) {
  14573. this.handleMouseOut(opt);
  14574. return;
  14575. }
  14576. }
  14577. var tooltipEl = this.getElTooltip();
  14578. var xcrosshairs = this.getElXCrosshairs();
  14579. 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();
  14580. if (w.globals.isBarHorizontal && this.tooltipUtil.hasBars()) {
  14581. isStickyTooltip = false;
  14582. }
  14583. if (e.type === 'mousemove' || e.type === 'touchmove' || e.type === 'mouseup') {
  14584. if (xcrosshairs !== null) {
  14585. xcrosshairs.classList.add('apexcharts-active');
  14586. }
  14587. if (this.ycrosshairs !== null && this.blyaxisTooltip) {
  14588. this.ycrosshairs.classList.add('apexcharts-active');
  14589. }
  14590. if (isStickyTooltip && !this.showOnIntersect) {
  14591. this.handleStickyTooltip(e, clientX, clientY, opt);
  14592. } else {
  14593. if (w.config.chart.type === 'heatmap') {
  14594. var markerXY = this.intersect.handleHeatTooltip({
  14595. e: e,
  14596. opt: opt,
  14597. x: x,
  14598. y: y
  14599. });
  14600. x = markerXY.x;
  14601. y = markerXY.y;
  14602. tooltipEl.style.left = x + 'px';
  14603. tooltipEl.style.top = y + 'px';
  14604. } else {
  14605. if (this.tooltipUtil.hasBars()) {
  14606. this.intersect.handleBarTooltip({
  14607. e: e,
  14608. opt: opt
  14609. });
  14610. }
  14611. if (this.tooltipUtil.hasMarkers()) {
  14612. // intersect - line/area/scatter/bubble
  14613. this.intersect.handleMarkerTooltip({
  14614. e: e,
  14615. opt: opt,
  14616. x: x,
  14617. y: y
  14618. });
  14619. }
  14620. }
  14621. }
  14622. if (this.blyaxisTooltip) {
  14623. for (var yt = 0; yt < w.config.yaxis.length; yt++) {
  14624. this.axesTooltip.drawYaxisTooltipText(yt, clientY, this.xyRatios);
  14625. }
  14626. }
  14627. opt.tooltipEl.classList.add('apexcharts-active');
  14628. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  14629. this.handleMouseOut(opt);
  14630. }
  14631. } // tooltip handling for pie/donuts
  14632. }, {
  14633. key: "nonAxisChartsTooltips",
  14634. value: function nonAxisChartsTooltips(_ref3) {
  14635. var e = _ref3.e,
  14636. opt = _ref3.opt,
  14637. tooltipRect = _ref3.tooltipRect;
  14638. var w = this.w;
  14639. var rel = opt.paths.getAttribute('rel');
  14640. var tooltipEl = this.getElTooltip();
  14641. var seriesBound = w.globals.dom.elWrap.getBoundingClientRect();
  14642. if (e.type === 'mousemove' || e.type === 'touchmove') {
  14643. tooltipEl.classList.add('apexcharts-active');
  14644. this.tooltipLabels.drawSeriesTexts({
  14645. ttItems: opt.ttItems,
  14646. i: parseInt(rel, 10) - 1,
  14647. shared: false
  14648. });
  14649. var x = w.globals.clientX - seriesBound.left - tooltipRect.ttWidth / 2;
  14650. var y = w.globals.clientY - seriesBound.top - tooltipRect.ttHeight - 10;
  14651. tooltipEl.style.left = x + 'px';
  14652. tooltipEl.style.top = y + 'px';
  14653. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  14654. tooltipEl.classList.remove('apexcharts-active');
  14655. }
  14656. }
  14657. }, {
  14658. key: "handleStickyTooltip",
  14659. value: function handleStickyTooltip(e, clientX, clientY, opt) {
  14660. var w = this.w;
  14661. var capj = this.tooltipUtil.getNearestValues({
  14662. context: this,
  14663. hoverArea: opt.hoverArea,
  14664. elGrid: opt.elGrid,
  14665. clientX: clientX,
  14666. clientY: clientY
  14667. });
  14668. var j = capj.j;
  14669. var capturedSeries = capj.capturedSeries;
  14670. if (capj.hoverX < 0 || capj.hoverX > w.globals.gridWidth) {
  14671. this.handleMouseOut(opt);
  14672. return;
  14673. }
  14674. if (capturedSeries !== null) {
  14675. this.handleStickyCapturedSeries(e, capturedSeries, opt, j);
  14676. } else {
  14677. // couldn't capture any series. check if shared X is same,
  14678. // if yes, draw a grouped tooltip
  14679. if (this.tooltipUtil.isXoverlap(j)) {
  14680. this.create(e, this, 0, j, opt.ttItems);
  14681. }
  14682. }
  14683. }
  14684. }, {
  14685. key: "handleStickyCapturedSeries",
  14686. value: function handleStickyCapturedSeries(e, capturedSeries, opt, j) {
  14687. var w = this.w;
  14688. var ignoreNull = w.globals.series[capturedSeries][j] === null;
  14689. if (ignoreNull) {
  14690. this.handleMouseOut(opt);
  14691. return;
  14692. }
  14693. if (typeof w.globals.series[capturedSeries][j] !== 'undefined') {
  14694. if (this.tConfig.shared && this.tooltipUtil.isXoverlap(j) && this.tooltipUtil.isInitialSeriesSameLen()) {
  14695. this.create(e, this, capturedSeries, j, opt.ttItems);
  14696. } else {
  14697. this.create(e, this, capturedSeries, j, opt.ttItems, false);
  14698. }
  14699. } else {
  14700. if (this.tooltipUtil.isXoverlap(j)) {
  14701. this.create(e, this, 0, j, opt.ttItems);
  14702. }
  14703. }
  14704. }
  14705. }, {
  14706. key: "deactivateHoverFilter",
  14707. value: function deactivateHoverFilter() {
  14708. var w = this.w;
  14709. var graphics = new Graphics(this.ctx);
  14710. var allPaths = w.globals.dom.Paper.select(".apexcharts-bar-area");
  14711. for (var b = 0; b < allPaths.length; b++) {
  14712. graphics.pathMouseLeave(allPaths[b]);
  14713. }
  14714. }
  14715. }, {
  14716. key: "handleMouseOut",
  14717. value: function handleMouseOut(opt) {
  14718. var w = this.w;
  14719. var xcrosshairs = this.getElXCrosshairs();
  14720. opt.tooltipEl.classList.remove('apexcharts-active');
  14721. this.deactivateHoverFilter();
  14722. if (w.config.chart.type !== 'bubble') {
  14723. this.marker.resetPointsSize();
  14724. }
  14725. if (xcrosshairs !== null) {
  14726. xcrosshairs.classList.remove('apexcharts-active');
  14727. }
  14728. if (this.ycrosshairs !== null) {
  14729. this.ycrosshairs.classList.remove('apexcharts-active');
  14730. }
  14731. if (this.blxaxisTooltip) {
  14732. this.xaxisTooltip.classList.remove('apexcharts-active');
  14733. }
  14734. if (this.blyaxisTooltip) {
  14735. if (this.yaxisTTEls === null) {
  14736. this.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  14737. }
  14738. for (var i = 0; i < this.yaxisTTEls.length; i++) {
  14739. this.yaxisTTEls[i].classList.remove('apexcharts-active');
  14740. }
  14741. }
  14742. if (w.config.legend.tooltipHoverFormatter) {
  14743. this.legendLabels.forEach(function (l) {
  14744. var defaultText = l.getAttribute('data:default-text');
  14745. l.innerHTML = decodeURIComponent(defaultText);
  14746. });
  14747. }
  14748. }
  14749. }, {
  14750. key: "markerClick",
  14751. value: function markerClick(e, seriesIndex, dataPointIndex) {
  14752. var w = this.w;
  14753. if (typeof w.config.chart.events.markerClick === 'function') {
  14754. w.config.chart.events.markerClick(e, this.ctx, {
  14755. seriesIndex: seriesIndex,
  14756. dataPointIndex: dataPointIndex,
  14757. w: w
  14758. });
  14759. }
  14760. this.ctx.events.fireEvent('markerClick', [e, this.ctx, {
  14761. seriesIndex: seriesIndex,
  14762. dataPointIndex: dataPointIndex,
  14763. w: w
  14764. }]);
  14765. }
  14766. }, {
  14767. key: "create",
  14768. value: function create(e, context, capturedSeries, j, ttItems) {
  14769. var shared = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  14770. var w = this.w;
  14771. var ttCtx = context;
  14772. if (e.type === 'mouseup') {
  14773. this.markerClick(e, capturedSeries, j);
  14774. }
  14775. if (shared === null) shared = this.tConfig.shared;
  14776. var hasMarkers = this.tooltipUtil.hasMarkers();
  14777. var bars = this.tooltipUtil.getElBars();
  14778. if (w.config.legend.tooltipHoverFormatter) {
  14779. var legendFormatter = w.config.legend.tooltipHoverFormatter;
  14780. var els = Array.from(this.legendLabels); // reset all legend values first
  14781. els.forEach(function (l) {
  14782. var legendName = l.getAttribute('data:default-text');
  14783. l.innerHTML = decodeURIComponent(legendName);
  14784. }); // for irregular time series
  14785. for (var i = 0; i < els.length; i++) {
  14786. var l = els[i];
  14787. var lsIndex = parseInt(l.getAttribute('i'), 10);
  14788. var legendName = decodeURIComponent(l.getAttribute('data:default-text'));
  14789. var text = legendFormatter(legendName, {
  14790. seriesIndex: shared ? lsIndex : capturedSeries,
  14791. dataPointIndex: j,
  14792. w: w
  14793. });
  14794. if (!shared) {
  14795. l.innerHTML = lsIndex === capturedSeries ? text : legendName;
  14796. if (capturedSeries === lsIndex) {
  14797. break;
  14798. }
  14799. } else {
  14800. l.innerHTML = w.globals.collapsedSeriesIndices.indexOf(lsIndex) < 0 ? text : legendName;
  14801. }
  14802. }
  14803. }
  14804. if (shared) {
  14805. ttCtx.tooltipLabels.drawSeriesTexts({
  14806. ttItems: ttItems,
  14807. i: capturedSeries,
  14808. j: j,
  14809. shared: this.showOnIntersect ? false : this.tConfig.shared
  14810. });
  14811. if (hasMarkers) {
  14812. if (w.globals.markers.largestSize > 0) {
  14813. ttCtx.marker.enlargePoints(j);
  14814. } else {
  14815. ttCtx.tooltipPosition.moveDynamicPointsOnHover(j);
  14816. }
  14817. }
  14818. if (this.tooltipUtil.hasBars()) {
  14819. this.barSeriesHeight = this.tooltipUtil.getBarsHeight(bars);
  14820. if (this.barSeriesHeight > 0) {
  14821. // hover state, activate snap filter
  14822. var graphics = new Graphics(this.ctx);
  14823. var paths = w.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(j, "']")); // de-activate first
  14824. this.deactivateHoverFilter();
  14825. this.tooltipPosition.moveStickyTooltipOverBars(j);
  14826. for (var b = 0; b < paths.length; b++) {
  14827. graphics.pathMouseEnter(paths[b]);
  14828. }
  14829. }
  14830. }
  14831. } else {
  14832. ttCtx.tooltipLabels.drawSeriesTexts({
  14833. shared: false,
  14834. ttItems: ttItems,
  14835. i: capturedSeries,
  14836. j: j
  14837. });
  14838. if (this.tooltipUtil.hasBars()) {
  14839. ttCtx.tooltipPosition.moveStickyTooltipOverBars(j);
  14840. }
  14841. if (hasMarkers) {
  14842. ttCtx.tooltipPosition.moveMarkers(capturedSeries, j);
  14843. }
  14844. }
  14845. }
  14846. }]);
  14847. return Tooltip;
  14848. }();
  14849. var BarDataLabels = /*#__PURE__*/function () {
  14850. function BarDataLabels(barCtx) {
  14851. _classCallCheck(this, BarDataLabels);
  14852. this.w = barCtx.w;
  14853. this.barCtx = barCtx;
  14854. }
  14855. /** handleBarDataLabels is used to calculate the positions for the data-labels
  14856. * It also sets the element's data attr for bars and calls drawCalculatedBarDataLabels()
  14857. * After calculating, it also calls the function to draw data labels
  14858. * @memberof Bar
  14859. * @param {object} {barProps} most of the bar properties used throughout the bar
  14860. * drawing function
  14861. * @return {object} dataLabels node-element which you can append later
  14862. **/
  14863. _createClass(BarDataLabels, [{
  14864. key: "handleBarDataLabels",
  14865. value: function handleBarDataLabels(opts) {
  14866. var x = opts.x,
  14867. y = opts.y,
  14868. y1 = opts.y1,
  14869. y2 = opts.y2,
  14870. i = opts.i,
  14871. j = opts.j,
  14872. realIndex = opts.realIndex,
  14873. series = opts.series,
  14874. barHeight = opts.barHeight,
  14875. barWidth = opts.barWidth,
  14876. barYPosition = opts.barYPosition,
  14877. visibleSeries = opts.visibleSeries,
  14878. renderedPath = opts.renderedPath;
  14879. var w = this.w;
  14880. var graphics = new Graphics(this.barCtx.ctx);
  14881. var strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  14882. var bcx = x + parseFloat(barWidth * visibleSeries);
  14883. var bcy = y + parseFloat(barHeight * visibleSeries);
  14884. if (w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  14885. bcx = x + parseFloat(barWidth * (visibleSeries + 1));
  14886. bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth;
  14887. }
  14888. var dataLabels = null;
  14889. var dataLabelsX = x;
  14890. var dataLabelsY = y;
  14891. var dataLabelsPos = {};
  14892. var dataLabelsConfig = w.config.dataLabels;
  14893. var barDataLabelsConfig = this.barCtx.barOptions.dataLabels;
  14894. if (typeof barYPosition !== 'undefined' && this.barCtx.isTimelineBar) {
  14895. bcy = barYPosition;
  14896. dataLabelsY = barYPosition;
  14897. }
  14898. var offX = dataLabelsConfig.offsetX;
  14899. var offY = dataLabelsConfig.offsetY;
  14900. var textRects = {
  14901. width: 0,
  14902. height: 0
  14903. };
  14904. if (w.config.dataLabels.enabled) {
  14905. textRects = graphics.getTextRects(w.globals.yLabelFormatters[0](w.globals.maxY), parseFloat(dataLabelsConfig.style.fontSize));
  14906. }
  14907. var params = {
  14908. x: x,
  14909. y: y,
  14910. i: i,
  14911. j: j,
  14912. renderedPath: renderedPath,
  14913. bcx: bcx,
  14914. bcy: bcy,
  14915. barHeight: barHeight,
  14916. barWidth: barWidth,
  14917. textRects: textRects,
  14918. strokeWidth: strokeWidth,
  14919. dataLabelsX: dataLabelsX,
  14920. dataLabelsY: dataLabelsY,
  14921. barDataLabelsConfig: barDataLabelsConfig,
  14922. offX: offX,
  14923. offY: offY
  14924. };
  14925. if (this.barCtx.isHorizontal) {
  14926. dataLabelsPos = this.calculateBarsDataLabelsPosition(params);
  14927. } else {
  14928. dataLabelsPos = this.calculateColumnsDataLabelsPosition(params);
  14929. }
  14930. renderedPath.attr({
  14931. cy: dataLabelsPos.bcy,
  14932. cx: dataLabelsPos.bcx,
  14933. j: j,
  14934. val: series[i][j],
  14935. barHeight: barHeight,
  14936. barWidth: barWidth
  14937. });
  14938. dataLabels = this.drawCalculatedDataLabels({
  14939. x: dataLabelsPos.dataLabelsX,
  14940. y: dataLabelsPos.dataLabelsY,
  14941. val: this.barCtx.isTimelineBar ? [y1, y2] : series[i][j],
  14942. i: realIndex,
  14943. j: j,
  14944. barWidth: barWidth,
  14945. barHeight: barHeight,
  14946. textRects: textRects,
  14947. dataLabelsConfig: dataLabelsConfig
  14948. });
  14949. return dataLabels;
  14950. }
  14951. }, {
  14952. key: "calculateColumnsDataLabelsPosition",
  14953. value: function calculateColumnsDataLabelsPosition(opts) {
  14954. var w = this.w;
  14955. var i = opts.i,
  14956. j = opts.j,
  14957. y = opts.y,
  14958. bcx = opts.bcx,
  14959. barWidth = opts.barWidth,
  14960. barHeight = opts.barHeight,
  14961. textRects = opts.textRects,
  14962. dataLabelsY = opts.dataLabelsY,
  14963. barDataLabelsConfig = opts.barDataLabelsConfig,
  14964. strokeWidth = opts.strokeWidth,
  14965. offX = opts.offX,
  14966. offY = opts.offY;
  14967. var dataLabelsX;
  14968. barHeight = Math.abs(barHeight);
  14969. var vertical = w.config.plotOptions.bar.dataLabels.orientation === 'vertical';
  14970. bcx = bcx - strokeWidth / 2;
  14971. var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  14972. if (w.globals.isXNumeric) {
  14973. dataLabelsX = bcx - barWidth / 2 + offX;
  14974. } else {
  14975. dataLabelsX = bcx - dataPointsDividedWidth + barWidth / 2 + offX;
  14976. }
  14977. if (vertical) {
  14978. var offsetDLX = 2;
  14979. dataLabelsX = dataLabelsX + textRects.height / 2 - strokeWidth / 2 - offsetDLX;
  14980. }
  14981. var valIsNegative = this.barCtx.series[i][j] < 0;
  14982. if (this.barCtx.isReversed) {
  14983. y = y - barHeight;
  14984. }
  14985. switch (barDataLabelsConfig.position) {
  14986. case 'center':
  14987. if (vertical) {
  14988. if (valIsNegative) {
  14989. dataLabelsY = y + barHeight / 2 + offY;
  14990. } else {
  14991. dataLabelsY = y + barHeight / 2 - offY;
  14992. }
  14993. } else {
  14994. if (valIsNegative) {
  14995. dataLabelsY = y + barHeight / 2 + textRects.height / 2 + offY;
  14996. } else {
  14997. dataLabelsY = y + barHeight / 2 + textRects.height / 2 - offY;
  14998. }
  14999. }
  15000. break;
  15001. case 'bottom':
  15002. if (vertical) {
  15003. if (valIsNegative) {
  15004. dataLabelsY = y + barHeight + offY;
  15005. } else {
  15006. dataLabelsY = y + barHeight - offY;
  15007. }
  15008. } else {
  15009. if (valIsNegative) {
  15010. dataLabelsY = y + barHeight + textRects.height + strokeWidth + offY;
  15011. } else {
  15012. dataLabelsY = y + barHeight - textRects.height / 2 + strokeWidth - offY;
  15013. }
  15014. }
  15015. break;
  15016. case 'top':
  15017. if (vertical) {
  15018. if (valIsNegative) {
  15019. dataLabelsY = y + offY;
  15020. } else {
  15021. dataLabelsY = y - offY;
  15022. }
  15023. } else {
  15024. if (valIsNegative) {
  15025. dataLabelsY = y - textRects.height / 2 - offY;
  15026. } else {
  15027. dataLabelsY = y + textRects.height + offY;
  15028. }
  15029. }
  15030. break;
  15031. }
  15032. if (!w.config.chart.stacked) {
  15033. if (dataLabelsY < 0) {
  15034. dataLabelsY = 0 + strokeWidth;
  15035. } else if (dataLabelsY + textRects.height / 3 > w.globals.gridHeight) {
  15036. dataLabelsY = w.globals.gridHeight - strokeWidth;
  15037. }
  15038. }
  15039. return {
  15040. bcx: bcx,
  15041. bcy: y,
  15042. dataLabelsX: dataLabelsX,
  15043. dataLabelsY: dataLabelsY
  15044. };
  15045. }
  15046. }, {
  15047. key: "calculateBarsDataLabelsPosition",
  15048. value: function calculateBarsDataLabelsPosition(opts) {
  15049. var w = this.w;
  15050. var x = opts.x,
  15051. i = opts.i,
  15052. j = opts.j,
  15053. bcy = opts.bcy,
  15054. barHeight = opts.barHeight,
  15055. barWidth = opts.barWidth,
  15056. textRects = opts.textRects,
  15057. dataLabelsX = opts.dataLabelsX,
  15058. strokeWidth = opts.strokeWidth,
  15059. barDataLabelsConfig = opts.barDataLabelsConfig,
  15060. offX = opts.offX,
  15061. offY = opts.offY;
  15062. var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  15063. barWidth = Math.abs(barWidth);
  15064. var dataLabelsY = bcy - (this.barCtx.isTimelineBar ? 0 : dataPointsDividedHeight) + barHeight / 2 + textRects.height / 2 + offY - 3;
  15065. var valIsNegative = this.barCtx.series[i][j] < 0;
  15066. var newX = x;
  15067. if (this.barCtx.isReversed) {
  15068. newX = x + barWidth;
  15069. x = w.globals.gridWidth - barWidth;
  15070. }
  15071. switch (barDataLabelsConfig.position) {
  15072. case 'center':
  15073. if (valIsNegative) {
  15074. dataLabelsX = newX - barWidth / 2 - offX;
  15075. } else {
  15076. dataLabelsX = newX - barWidth / 2 + offX;
  15077. }
  15078. break;
  15079. case 'bottom':
  15080. if (valIsNegative) {
  15081. dataLabelsX = newX + barWidth - strokeWidth - Math.round(textRects.width / 2) - offX;
  15082. } else {
  15083. dataLabelsX = newX - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX;
  15084. }
  15085. break;
  15086. case 'top':
  15087. if (valIsNegative) {
  15088. dataLabelsX = newX - strokeWidth + Math.round(textRects.width / 2) - offX;
  15089. } else {
  15090. dataLabelsX = newX - strokeWidth - Math.round(textRects.width / 2) + offX;
  15091. }
  15092. break;
  15093. }
  15094. if (!w.config.chart.stacked) {
  15095. if (dataLabelsX < 0) {
  15096. dataLabelsX = dataLabelsX + textRects.width + strokeWidth;
  15097. } else if (dataLabelsX + textRects.width / 2 > w.globals.gridWidth) {
  15098. dataLabelsX = w.globals.gridWidth - textRects.width - strokeWidth;
  15099. }
  15100. }
  15101. return {
  15102. bcx: x,
  15103. bcy: bcy,
  15104. dataLabelsX: dataLabelsX,
  15105. dataLabelsY: dataLabelsY
  15106. };
  15107. }
  15108. }, {
  15109. key: "drawCalculatedDataLabels",
  15110. value: function drawCalculatedDataLabels(_ref) {
  15111. var x = _ref.x,
  15112. y = _ref.y,
  15113. val = _ref.val,
  15114. i = _ref.i,
  15115. j = _ref.j,
  15116. textRects = _ref.textRects,
  15117. barHeight = _ref.barHeight,
  15118. barWidth = _ref.barWidth,
  15119. dataLabelsConfig = _ref.dataLabelsConfig;
  15120. var w = this.w;
  15121. var rotate = 'rotate(0)';
  15122. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') rotate = "rotate(-90, ".concat(x, ", ").concat(y, ")");
  15123. var dataLabels = new DataLabels(this.barCtx.ctx);
  15124. var graphics = new Graphics(this.barCtx.ctx);
  15125. var formatter = dataLabelsConfig.formatter;
  15126. var elDataLabelsWrap = null;
  15127. var isSeriesNotCollapsed = w.globals.collapsedSeriesIndices.indexOf(i) > -1;
  15128. if (dataLabelsConfig.enabled && !isSeriesNotCollapsed) {
  15129. elDataLabelsWrap = graphics.group({
  15130. class: 'apexcharts-data-labels',
  15131. transform: rotate
  15132. });
  15133. var text = '';
  15134. if (typeof val !== 'undefined') {
  15135. text = formatter(val, {
  15136. seriesIndex: i,
  15137. dataPointIndex: j,
  15138. w: w
  15139. });
  15140. }
  15141. if (val === 0 && w.config.chart.stacked) {
  15142. // in a stacked bar/column chart, 0 value should be neglected as it will overlap on the next element
  15143. text = '';
  15144. }
  15145. var valIsNegative = w.globals.series[i][j] <= 0;
  15146. var position = w.config.plotOptions.bar.dataLabels.position;
  15147. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
  15148. if (position === 'top') {
  15149. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  15150. }
  15151. if (position === 'center') {
  15152. dataLabelsConfig.textAnchor = 'middle';
  15153. }
  15154. if (position === 'bottom') {
  15155. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  15156. }
  15157. }
  15158. if (this.barCtx.isTimelineBar && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  15159. // hide the datalabel if it cannot fit into the rect
  15160. var txRect = graphics.getTextRects(text, parseFloat(dataLabelsConfig.style.fontSize));
  15161. if (barWidth < txRect.width) {
  15162. text = '';
  15163. }
  15164. }
  15165. if (w.config.chart.stacked && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  15166. // if there is not enough space to draw the label in the bar/column rect, check hideOverflowingLabels property to prevent overflowing on wrong rect
  15167. // Note: This issue is only seen in stacked charts
  15168. if (this.barCtx.isHorizontal) {
  15169. barWidth = Math.abs(w.globals.series[i][j]) / this.barCtx.invertedYRatio[this.barCtx.yaxisIndex]; // FIXED: Don't always hide the stacked negative side label
  15170. // A negative value will result in a negative bar width
  15171. // Only hide the text when the width is smaller (a higher negative number) than the negative bar width.
  15172. if (barWidth > 0 && textRects.width / 1.6 > barWidth || barWidth < 0 && textRects.width / 1.6 < barWidth) {
  15173. text = '';
  15174. }
  15175. } else {
  15176. barHeight = Math.abs(w.globals.series[i][j]) / this.barCtx.yRatio[this.barCtx.yaxisIndex];
  15177. if (textRects.height / 1.6 > barHeight) {
  15178. text = '';
  15179. }
  15180. }
  15181. }
  15182. var modifiedDataLabelsConfig = _objectSpread2({}, dataLabelsConfig);
  15183. if (this.barCtx.isHorizontal) {
  15184. if (val < 0) {
  15185. if (dataLabelsConfig.textAnchor === 'start') {
  15186. modifiedDataLabelsConfig.textAnchor = 'end';
  15187. } else if (dataLabelsConfig.textAnchor === 'end') {
  15188. modifiedDataLabelsConfig.textAnchor = 'start';
  15189. }
  15190. }
  15191. }
  15192. dataLabels.plotDataLabelsText({
  15193. x: x,
  15194. y: y,
  15195. text: text,
  15196. i: i,
  15197. j: j,
  15198. parent: elDataLabelsWrap,
  15199. dataLabelsConfig: modifiedDataLabelsConfig,
  15200. alwaysDrawDataLabel: true,
  15201. offsetCorrection: true
  15202. });
  15203. }
  15204. return elDataLabelsWrap;
  15205. }
  15206. }]);
  15207. return BarDataLabels;
  15208. }();
  15209. var Helpers$3 = /*#__PURE__*/function () {
  15210. function Helpers(barCtx) {
  15211. _classCallCheck(this, Helpers);
  15212. this.w = barCtx.w;
  15213. this.barCtx = barCtx;
  15214. }
  15215. _createClass(Helpers, [{
  15216. key: "initVariables",
  15217. value: function initVariables(series) {
  15218. var w = this.w;
  15219. this.barCtx.series = series;
  15220. this.barCtx.totalItems = 0;
  15221. this.barCtx.seriesLen = 0;
  15222. this.barCtx.visibleI = -1; // visible Series
  15223. this.barCtx.visibleItems = 1; // number of visible bars after user zoomed in/out
  15224. for (var sl = 0; sl < series.length; sl++) {
  15225. if (series[sl].length > 0) {
  15226. this.barCtx.seriesLen = this.barCtx.seriesLen + 1;
  15227. this.barCtx.totalItems += series[sl].length;
  15228. }
  15229. if (w.globals.isXNumeric) {
  15230. // get max visible items
  15231. for (var j = 0; j < series[sl].length; j++) {
  15232. if (w.globals.seriesX[sl][j] > w.globals.minX && w.globals.seriesX[sl][j] < w.globals.maxX) {
  15233. this.barCtx.visibleItems++;
  15234. }
  15235. }
  15236. } else {
  15237. this.barCtx.visibleItems = w.globals.dataPoints;
  15238. }
  15239. }
  15240. if (this.barCtx.seriesLen === 0) {
  15241. // A small adjustment when combo charts are used
  15242. this.barCtx.seriesLen = 1;
  15243. }
  15244. }
  15245. }, {
  15246. key: "initialPositions",
  15247. value: function initialPositions() {
  15248. var w = this.w;
  15249. var x, y, yDivision, xDivision, barHeight, barWidth, zeroH, zeroW;
  15250. var dataPoints = w.globals.dataPoints;
  15251. if (this.barCtx.isTimelineBar) {
  15252. // timeline rangebar chart
  15253. dataPoints = w.globals.labels.length;
  15254. }
  15255. if (this.barCtx.isHorizontal) {
  15256. // height divided into equal parts
  15257. yDivision = w.globals.gridHeight / dataPoints;
  15258. barHeight = yDivision / this.barCtx.seriesLen;
  15259. if (w.globals.isXNumeric) {
  15260. yDivision = w.globals.gridHeight / this.barCtx.totalItems;
  15261. barHeight = yDivision / this.barCtx.seriesLen;
  15262. }
  15263. barHeight = barHeight * parseInt(this.barCtx.barOptions.barHeight, 10) / 100;
  15264. zeroW = this.barCtx.baseLineInvertedY + w.globals.padHorizontal + (this.barCtx.isReversed ? w.globals.gridWidth : 0) - (this.barCtx.isReversed ? this.barCtx.baseLineInvertedY * 2 : 0);
  15265. y = (yDivision - barHeight * this.barCtx.seriesLen) / 2;
  15266. } else {
  15267. // width divided into equal parts
  15268. xDivision = w.globals.gridWidth / this.barCtx.visibleItems;
  15269. if (w.config.xaxis.convertedCatToNumeric) {
  15270. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  15271. }
  15272. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  15273. if (w.globals.isXNumeric) {
  15274. // max barwidth should be equal to minXDiff to avoid overlap
  15275. var xRatio = this.barCtx.xRatio;
  15276. if (w.config.xaxis.convertedCatToNumeric) {
  15277. xRatio = this.barCtx.initialXRatio;
  15278. }
  15279. if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
  15280. xDivision = w.globals.minXDiff / xRatio;
  15281. }
  15282. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  15283. if (barWidth < 1) {
  15284. barWidth = 1;
  15285. }
  15286. }
  15287. 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);
  15288. x = w.globals.padHorizontal + (xDivision - barWidth * this.barCtx.seriesLen) / 2;
  15289. }
  15290. return {
  15291. x: x,
  15292. y: y,
  15293. yDivision: yDivision,
  15294. xDivision: xDivision,
  15295. barHeight: barHeight,
  15296. barWidth: barWidth,
  15297. zeroH: zeroH,
  15298. zeroW: zeroW
  15299. };
  15300. }
  15301. }, {
  15302. key: "getPathFillColor",
  15303. value: function getPathFillColor(series, i, j, realIndex) {
  15304. var w = this.w;
  15305. var fill = new Fill(this.barCtx.ctx);
  15306. var fillColor = null;
  15307. var seriesNumber = this.barCtx.barOptions.distributed ? j : i;
  15308. if (this.barCtx.barOptions.colors.ranges.length > 0) {
  15309. var colorRange = this.barCtx.barOptions.colors.ranges;
  15310. colorRange.map(function (range) {
  15311. if (series[i][j] >= range.from && series[i][j] <= range.to) {
  15312. fillColor = range.color;
  15313. }
  15314. });
  15315. }
  15316. if (w.config.series[i].data[j] && w.config.series[i].data[j].fillColor) {
  15317. fillColor = w.config.series[i].data[j].fillColor;
  15318. }
  15319. var pathFill = fill.fillPath({
  15320. seriesNumber: this.barCtx.barOptions.distributed ? seriesNumber : realIndex,
  15321. dataPointIndex: j,
  15322. color: fillColor,
  15323. value: series[i][j]
  15324. });
  15325. return pathFill;
  15326. }
  15327. }, {
  15328. key: "getStrokeWidth",
  15329. value: function getStrokeWidth(i, j, realIndex) {
  15330. var strokeWidth = 0;
  15331. var w = this.w;
  15332. if (typeof this.barCtx.series[i][j] === 'undefined' || this.barCtx.series[i][j] === null) {
  15333. this.barCtx.isNullValue = true;
  15334. } else {
  15335. this.barCtx.isNullValue = false;
  15336. }
  15337. if (w.config.stroke.show) {
  15338. if (!this.barCtx.isNullValue) {
  15339. strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  15340. }
  15341. }
  15342. return strokeWidth;
  15343. }
  15344. }, {
  15345. key: "barBackground",
  15346. value: function barBackground(_ref) {
  15347. var bc = _ref.bc,
  15348. i = _ref.i,
  15349. x1 = _ref.x1,
  15350. x2 = _ref.x2,
  15351. y1 = _ref.y1,
  15352. y2 = _ref.y2,
  15353. elSeries = _ref.elSeries;
  15354. var w = this.w;
  15355. var graphics = new Graphics(this.barCtx.ctx);
  15356. var sr = new Series(this.barCtx.ctx);
  15357. var activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  15358. if (this.barCtx.barOptions.colors.backgroundBarColors.length > 0 && activeSeriesIndex === i) {
  15359. if (bc >= this.barCtx.barOptions.colors.backgroundBarColors.length) {
  15360. bc = 0;
  15361. }
  15362. var bcolor = this.barCtx.barOptions.colors.backgroundBarColors[bc];
  15363. 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);
  15364. elSeries.add(rect);
  15365. rect.node.classList.add('apexcharts-backgroundBar');
  15366. }
  15367. }
  15368. }, {
  15369. key: "getColumnPaths",
  15370. value: function getColumnPaths(_ref2) {
  15371. var barWidth = _ref2.barWidth,
  15372. barXPosition = _ref2.barXPosition,
  15373. yRatio = _ref2.yRatio,
  15374. y1 = _ref2.y1,
  15375. y2 = _ref2.y2,
  15376. strokeWidth = _ref2.strokeWidth,
  15377. series = _ref2.series,
  15378. realIndex = _ref2.realIndex,
  15379. i = _ref2.i,
  15380. j = _ref2.j,
  15381. w = _ref2.w;
  15382. var graphics = new Graphics(this.barCtx.ctx);
  15383. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  15384. if (!strokeWidth) strokeWidth = 0;
  15385. var shapeOpts = {
  15386. barWidth: barWidth,
  15387. strokeWidth: strokeWidth,
  15388. yRatio: yRatio,
  15389. barXPosition: barXPosition,
  15390. y1: y1,
  15391. y2: y2
  15392. };
  15393. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  15394. var x1 = barXPosition;
  15395. var x2 = barXPosition + barWidth;
  15396. var pathTo = graphics.move(x1, newPath.y1);
  15397. var pathFrom = graphics.move(x1, newPath.y1);
  15398. if (w.globals.previousPaths.length > 0) {
  15399. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  15400. }
  15401. pathTo = pathTo + graphics.line(x1, newPath.y2) + newPath.endingPath + graphics.line(x2 - strokeWidth, newPath.y2) + graphics.line(x2 - strokeWidth, newPath.y1) + newPath.startingPath + 'z';
  15402. 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);
  15403. return {
  15404. pathTo: pathTo,
  15405. pathFrom: pathFrom
  15406. };
  15407. }
  15408. }, {
  15409. key: "getBarpaths",
  15410. value: function getBarpaths(_ref3) {
  15411. var barYPosition = _ref3.barYPosition,
  15412. barHeight = _ref3.barHeight,
  15413. x1 = _ref3.x1,
  15414. x2 = _ref3.x2,
  15415. strokeWidth = _ref3.strokeWidth,
  15416. series = _ref3.series,
  15417. realIndex = _ref3.realIndex,
  15418. i = _ref3.i,
  15419. j = _ref3.j,
  15420. w = _ref3.w;
  15421. var graphics = new Graphics(this.barCtx.ctx);
  15422. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  15423. if (!strokeWidth) strokeWidth = 0;
  15424. var shapeOpts = {
  15425. barHeight: barHeight,
  15426. strokeWidth: strokeWidth,
  15427. barYPosition: barYPosition,
  15428. x2: x2,
  15429. x1: x1
  15430. };
  15431. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  15432. var pathTo = graphics.move(newPath.x1, barYPosition);
  15433. var pathFrom = graphics.move(newPath.x1, barYPosition);
  15434. if (w.globals.previousPaths.length > 0) {
  15435. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  15436. }
  15437. var y1 = barYPosition;
  15438. var y2 = barYPosition + barHeight;
  15439. pathTo = pathTo + graphics.line(newPath.x2, y1) + newPath.endingPath + graphics.line(newPath.x2, y2 - strokeWidth) + graphics.line(newPath.x1, y2 - strokeWidth) + newPath.startingPath + 'z';
  15440. 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);
  15441. return {
  15442. pathTo: pathTo,
  15443. pathFrom: pathFrom
  15444. };
  15445. }
  15446. /** getRoundedBars draws border radius for bars/columns
  15447. * @memberof Bar
  15448. * @param {object} w - chart context
  15449. * @param {object} opts - consists several properties like barHeight/barWidth
  15450. * @param {array} series - global primary series
  15451. * @param {int} i - current iterating series's index
  15452. * @param {int} j - series's j of i
  15453. * @return {object} endingPath - ending shape path string
  15454. * startingPath - starting shape path string
  15455. * newY/newX - which is calculated from existing x/y based on rounded border
  15456. **/
  15457. }, {
  15458. key: "getRoundedBars",
  15459. value: function getRoundedBars(w, opts, series, i, j) {
  15460. var graphics = new Graphics(this.barCtx.ctx);
  15461. var strokeWidth = Array.isArray(opts.strokeWidth) ? opts.strokeWidth[i] : opts.strokeWidth;
  15462. if (!strokeWidth) strokeWidth = 0;
  15463. if (this.barCtx.isHorizontal) {
  15464. var endingShape = null;
  15465. var startingShape = '';
  15466. var x2 = opts.x2;
  15467. var x1 = opts.x1;
  15468. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  15469. var inverse = series[i][j] < 0;
  15470. var eX = opts.barHeight / 2 - strokeWidth;
  15471. if (inverse) eX = -opts.barHeight / 2 - strokeWidth;
  15472. if (eX > Math.abs(x2 - x1)) {
  15473. eX = Math.abs(x2 - x1);
  15474. }
  15475. if (this.barCtx.barOptions.endingShape === 'rounded') {
  15476. x2 = opts.x2 - eX / 2;
  15477. }
  15478. if (this.barCtx.barOptions.startingShape === 'rounded') {
  15479. x1 = opts.x1 + eX / 2;
  15480. }
  15481. switch (this.barCtx.barOptions.endingShape) {
  15482. case 'flat':
  15483. endingShape = graphics.line(x2, opts.barYPosition + opts.barHeight - strokeWidth);
  15484. break;
  15485. case 'rounded':
  15486. endingShape = graphics.quadraticCurve(x2 + eX, opts.barYPosition + (opts.barHeight - strokeWidth) / 2, x2, opts.barYPosition + opts.barHeight - strokeWidth);
  15487. break;
  15488. }
  15489. switch (this.barCtx.barOptions.startingShape) {
  15490. case 'flat':
  15491. startingShape = graphics.line(x1, opts.barYPosition + opts.barHeight - strokeWidth);
  15492. break;
  15493. case 'rounded':
  15494. startingShape = graphics.quadraticCurve(x1 - eX, opts.barYPosition + opts.barHeight / 2, x1, opts.barYPosition);
  15495. break;
  15496. }
  15497. }
  15498. return {
  15499. endingPath: endingShape,
  15500. startingPath: startingShape,
  15501. x2: x2,
  15502. x1: x1
  15503. };
  15504. } else {
  15505. var _endingShape = null;
  15506. var _startingShape = '';
  15507. var y2 = opts.y2;
  15508. var y1 = opts.y1;
  15509. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  15510. var _inverse = series[i][j] < 0;
  15511. var eY = opts.barWidth / 2 - strokeWidth;
  15512. if (_inverse) eY = -opts.barWidth / 2 - strokeWidth;
  15513. if (eY > Math.abs(y2 - y1)) {
  15514. eY = Math.abs(y2 - y1);
  15515. }
  15516. if (this.barCtx.barOptions.endingShape === 'rounded') {
  15517. // the shape exceeds the chart height, hence reduce y
  15518. y2 = y2 + eY / 2;
  15519. }
  15520. if (this.barCtx.barOptions.startingShape === 'rounded') {
  15521. y1 = y1 - eY / 2;
  15522. }
  15523. switch (this.barCtx.barOptions.endingShape) {
  15524. case 'flat':
  15525. _endingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y2);
  15526. break;
  15527. case 'rounded':
  15528. _endingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y2 - eY, opts.barXPosition + opts.barWidth - strokeWidth, y2);
  15529. break;
  15530. }
  15531. switch (this.barCtx.barOptions.startingShape) {
  15532. case 'flat':
  15533. _startingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y1);
  15534. break;
  15535. case 'rounded':
  15536. _startingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y1 + eY, opts.barXPosition, y1);
  15537. break;
  15538. }
  15539. }
  15540. return {
  15541. endingPath: _endingShape,
  15542. startingPath: _startingShape,
  15543. y2: y2,
  15544. y1: y1
  15545. };
  15546. }
  15547. }
  15548. }]);
  15549. return Helpers;
  15550. }();
  15551. /**
  15552. * ApexCharts Bar Class responsible for drawing both Columns and Bars.
  15553. *
  15554. * @module Bar
  15555. **/
  15556. var Bar = /*#__PURE__*/function () {
  15557. function Bar(ctx, xyRatios) {
  15558. _classCallCheck(this, Bar);
  15559. this.ctx = ctx;
  15560. this.w = ctx.w;
  15561. var w = this.w;
  15562. this.barOptions = w.config.plotOptions.bar;
  15563. this.isHorizontal = this.barOptions.horizontal;
  15564. this.strokeWidth = w.config.stroke.width;
  15565. this.isNullValue = false;
  15566. this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
  15567. this.xyRatios = xyRatios;
  15568. if (this.xyRatios !== null) {
  15569. this.xRatio = xyRatios.xRatio;
  15570. this.initialXRatio = xyRatios.initialXRatio;
  15571. this.yRatio = xyRatios.yRatio;
  15572. this.invertedXRatio = xyRatios.invertedXRatio;
  15573. this.invertedYRatio = xyRatios.invertedYRatio;
  15574. this.baseLineY = xyRatios.baseLineY;
  15575. this.baseLineInvertedY = xyRatios.baseLineInvertedY;
  15576. }
  15577. this.yaxisIndex = 0;
  15578. this.seriesLen = 0;
  15579. this.barHelpers = new Helpers$3(this);
  15580. }
  15581. /** primary draw method which is called on bar object
  15582. * @memberof Bar
  15583. * @param {array} series - user supplied series values
  15584. * @param {int} seriesIndex - the index by which series will be drawn on the svg
  15585. * @return {node} element which is supplied to parent chart draw method for appending
  15586. **/
  15587. _createClass(Bar, [{
  15588. key: "draw",
  15589. value: function draw(series, seriesIndex) {
  15590. var w = this.w;
  15591. var graphics = new Graphics(this.ctx);
  15592. var coreUtils = new CoreUtils(this.ctx, w);
  15593. series = coreUtils.getLogSeries(series);
  15594. this.series = series;
  15595. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  15596. this.barHelpers.initVariables(series);
  15597. var ret = graphics.group({
  15598. class: 'apexcharts-bar-series apexcharts-plot-series'
  15599. });
  15600. if (w.config.dataLabels.enabled) {
  15601. if (this.totalItems > this.barOptions.dataLabels.maxItems) {
  15602. console.warn('WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.');
  15603. }
  15604. }
  15605. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  15606. var x = void 0,
  15607. y = void 0,
  15608. xDivision = void 0,
  15609. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  15610. yDivision = void 0,
  15611. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  15612. zeroH = void 0,
  15613. // zeroH is the baseline where 0 meets y axis
  15614. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  15615. var yArrj = []; // hold y values of current iterating series
  15616. var xArrj = []; // hold x values of current iterating series
  15617. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  15618. var elSeries = graphics.group({
  15619. class: "apexcharts-series",
  15620. rel: i + 1,
  15621. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  15622. 'data:realIndex': realIndex
  15623. });
  15624. this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
  15625. if (series[i].length > 0) {
  15626. this.visibleI = this.visibleI + 1;
  15627. }
  15628. var barHeight = 0;
  15629. var barWidth = 0;
  15630. if (this.yRatio.length > 1) {
  15631. this.yaxisIndex = realIndex;
  15632. }
  15633. this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
  15634. var initPositions = this.barHelpers.initialPositions();
  15635. y = initPositions.y;
  15636. barHeight = initPositions.barHeight;
  15637. yDivision = initPositions.yDivision;
  15638. zeroW = initPositions.zeroW;
  15639. x = initPositions.x;
  15640. barWidth = initPositions.barWidth;
  15641. xDivision = initPositions.xDivision;
  15642. zeroH = initPositions.zeroH;
  15643. if (!this.horizontal) {
  15644. xArrj.push(x + barWidth / 2);
  15645. } // eldatalabels
  15646. var elDataLabelsWrap = graphics.group({
  15647. class: 'apexcharts-datalabels',
  15648. 'data:realIndex': realIndex
  15649. });
  15650. for (var j = 0; j < w.globals.dataPoints; j++) {
  15651. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  15652. var paths = null;
  15653. var pathsParams = {
  15654. indexes: {
  15655. i: i,
  15656. j: j,
  15657. realIndex: realIndex,
  15658. bc: bc
  15659. },
  15660. x: x,
  15661. y: y,
  15662. strokeWidth: strokeWidth,
  15663. elSeries: elSeries
  15664. };
  15665. if (this.isHorizontal) {
  15666. paths = this.drawBarPaths(_objectSpread2({}, pathsParams, {
  15667. barHeight: barHeight,
  15668. zeroW: zeroW,
  15669. yDivision: yDivision
  15670. }));
  15671. barWidth = this.series[i][j] / this.invertedYRatio;
  15672. } else {
  15673. paths = this.drawColumnPaths(_objectSpread2({}, pathsParams, {
  15674. xDivision: xDivision,
  15675. barWidth: barWidth,
  15676. zeroH: zeroH
  15677. }));
  15678. barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex];
  15679. }
  15680. y = paths.y;
  15681. x = paths.x; // push current X
  15682. if (j > 0) {
  15683. xArrj.push(x + barWidth / 2);
  15684. }
  15685. yArrj.push(y);
  15686. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  15687. this.renderSeries({
  15688. realIndex: realIndex,
  15689. pathFill: pathFill,
  15690. j: j,
  15691. i: i,
  15692. pathFrom: paths.pathFrom,
  15693. pathTo: paths.pathTo,
  15694. strokeWidth: strokeWidth,
  15695. elSeries: elSeries,
  15696. x: x,
  15697. y: y,
  15698. series: series,
  15699. barHeight: barHeight,
  15700. barWidth: barWidth,
  15701. elDataLabelsWrap: elDataLabelsWrap,
  15702. visibleSeries: this.visibleI,
  15703. type: 'bar'
  15704. });
  15705. } // push all x val arrays into main xArr
  15706. w.globals.seriesXvalues[realIndex] = xArrj;
  15707. w.globals.seriesYvalues[realIndex] = yArrj;
  15708. ret.add(elSeries);
  15709. }
  15710. return ret;
  15711. }
  15712. }, {
  15713. key: "renderSeries",
  15714. value: function renderSeries(_ref) {
  15715. var realIndex = _ref.realIndex,
  15716. pathFill = _ref.pathFill,
  15717. lineFill = _ref.lineFill,
  15718. j = _ref.j,
  15719. i = _ref.i,
  15720. pathFrom = _ref.pathFrom,
  15721. pathTo = _ref.pathTo,
  15722. strokeWidth = _ref.strokeWidth,
  15723. elSeries = _ref.elSeries,
  15724. x = _ref.x,
  15725. y = _ref.y,
  15726. y1 = _ref.y1,
  15727. y2 = _ref.y2,
  15728. series = _ref.series,
  15729. barHeight = _ref.barHeight,
  15730. barWidth = _ref.barWidth,
  15731. barYPosition = _ref.barYPosition,
  15732. elDataLabelsWrap = _ref.elDataLabelsWrap,
  15733. visibleSeries = _ref.visibleSeries,
  15734. type = _ref.type;
  15735. var w = this.w;
  15736. var graphics = new Graphics(this.ctx);
  15737. if (!lineFill) {
  15738. /* fix apexcharts#341 */
  15739. lineFill = this.barOptions.distributed ? w.globals.stroke.colors[j] : w.globals.stroke.colors[realIndex];
  15740. }
  15741. if (w.config.series[i].data[j] && w.config.series[i].data[j].strokeColor) {
  15742. lineFill = w.config.series[i].data[j].strokeColor;
  15743. }
  15744. if (this.isNullValue) {
  15745. pathFill = 'none';
  15746. }
  15747. var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4;
  15748. var renderedPath = graphics.renderPaths({
  15749. i: i,
  15750. j: j,
  15751. realIndex: realIndex,
  15752. pathFrom: pathFrom,
  15753. pathTo: pathTo,
  15754. stroke: lineFill,
  15755. strokeWidth: strokeWidth,
  15756. strokeLineCap: w.config.stroke.lineCap,
  15757. fill: pathFill,
  15758. animationDelay: delay,
  15759. initialSpeed: w.config.chart.animations.speed,
  15760. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  15761. className: "apexcharts-".concat(type, "-area")
  15762. });
  15763. renderedPath.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  15764. if (typeof y1 !== 'undefined' && typeof y2 !== 'undefined') {
  15765. renderedPath.attr('data-range-y1', y1);
  15766. renderedPath.attr('data-range-y2', y2);
  15767. }
  15768. var filters = new Filters(this.ctx);
  15769. filters.setSelectionFilter(renderedPath, realIndex, j);
  15770. elSeries.add(renderedPath);
  15771. var barDataLabels = new BarDataLabels(this);
  15772. var dataLabels = barDataLabels.handleBarDataLabels({
  15773. x: x,
  15774. y: y,
  15775. y1: y1,
  15776. y2: y2,
  15777. i: i,
  15778. j: j,
  15779. series: series,
  15780. realIndex: realIndex,
  15781. barHeight: barHeight,
  15782. barWidth: barWidth,
  15783. barYPosition: barYPosition,
  15784. renderedPath: renderedPath,
  15785. visibleSeries: visibleSeries
  15786. });
  15787. if (dataLabels !== null) {
  15788. elDataLabelsWrap.add(dataLabels);
  15789. }
  15790. elSeries.add(elDataLabelsWrap);
  15791. return elSeries;
  15792. }
  15793. }, {
  15794. key: "drawBarPaths",
  15795. value: function drawBarPaths(_ref2) {
  15796. var indexes = _ref2.indexes,
  15797. barHeight = _ref2.barHeight,
  15798. strokeWidth = _ref2.strokeWidth,
  15799. zeroW = _ref2.zeroW,
  15800. x = _ref2.x,
  15801. y = _ref2.y,
  15802. yDivision = _ref2.yDivision,
  15803. elSeries = _ref2.elSeries;
  15804. var w = this.w;
  15805. var i = indexes.i;
  15806. var j = indexes.j;
  15807. var bc = indexes.bc;
  15808. if (w.globals.isXNumeric) {
  15809. y = (w.globals.seriesX[i][j] - w.globals.minX) / this.invertedXRatio - barHeight;
  15810. }
  15811. var barYPosition = y + barHeight * this.visibleI;
  15812. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  15813. x = zeroW;
  15814. } else {
  15815. x = zeroW + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
  15816. }
  15817. var paths = this.barHelpers.getBarpaths({
  15818. barYPosition: barYPosition,
  15819. barHeight: barHeight,
  15820. x1: zeroW,
  15821. x2: x,
  15822. strokeWidth: strokeWidth,
  15823. series: this.series,
  15824. realIndex: indexes.realIndex,
  15825. i: i,
  15826. j: j,
  15827. w: w
  15828. });
  15829. if (!w.globals.isXNumeric) {
  15830. y = y + yDivision;
  15831. }
  15832. this.barHelpers.barBackground({
  15833. bc: bc,
  15834. i: i,
  15835. y1: barYPosition - barHeight * this.visibleI,
  15836. y2: barHeight * this.seriesLen,
  15837. elSeries: elSeries
  15838. });
  15839. return {
  15840. pathTo: paths.pathTo,
  15841. pathFrom: paths.pathFrom,
  15842. x: x,
  15843. y: y,
  15844. barYPosition: barYPosition
  15845. };
  15846. }
  15847. }, {
  15848. key: "drawColumnPaths",
  15849. value: function drawColumnPaths(_ref3) {
  15850. var indexes = _ref3.indexes,
  15851. x = _ref3.x,
  15852. y = _ref3.y,
  15853. xDivision = _ref3.xDivision,
  15854. barWidth = _ref3.barWidth,
  15855. zeroH = _ref3.zeroH,
  15856. strokeWidth = _ref3.strokeWidth,
  15857. elSeries = _ref3.elSeries;
  15858. var w = this.w;
  15859. var i = indexes.i;
  15860. var j = indexes.j;
  15861. var bc = indexes.bc;
  15862. if (w.globals.isXNumeric) {
  15863. var sxI = i;
  15864. if (!w.globals.seriesX[i].length) {
  15865. sxI = w.globals.maxValsInArrayIndex;
  15866. }
  15867. x = (w.globals.seriesX[sxI][j] - w.globals.minX) / this.xRatio - barWidth * this.seriesLen / 2;
  15868. }
  15869. var barXPosition = x + barWidth * this.visibleI;
  15870. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  15871. y = zeroH;
  15872. } else {
  15873. y = zeroH - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
  15874. }
  15875. var paths = this.barHelpers.getColumnPaths({
  15876. barXPosition: barXPosition,
  15877. barWidth: barWidth,
  15878. y1: zeroH,
  15879. y2: y,
  15880. strokeWidth: strokeWidth,
  15881. series: this.series,
  15882. realIndex: indexes.realIndex,
  15883. i: i,
  15884. j: j,
  15885. w: w
  15886. });
  15887. if (!w.globals.isXNumeric) {
  15888. x = x + xDivision;
  15889. }
  15890. this.barHelpers.barBackground({
  15891. bc: bc,
  15892. i: i,
  15893. x1: barXPosition - strokeWidth / 2 - barWidth * this.visibleI,
  15894. x2: barWidth * this.seriesLen + strokeWidth / 2,
  15895. elSeries: elSeries
  15896. });
  15897. return {
  15898. pathTo: paths.pathTo,
  15899. pathFrom: paths.pathFrom,
  15900. x: x,
  15901. y: y,
  15902. barXPosition: barXPosition
  15903. };
  15904. }
  15905. /** getPreviousPath is a common function for bars/columns which is used to get previous paths when data changes.
  15906. * @memberof Bar
  15907. * @param {int} realIndex - current iterating i
  15908. * @param {int} j - current iterating series's j index
  15909. * @return {string} pathFrom is the string which will be appended in animations
  15910. **/
  15911. }, {
  15912. key: "getPreviousPath",
  15913. value: function getPreviousPath(realIndex, j) {
  15914. var w = this.w;
  15915. var pathFrom;
  15916. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  15917. var gpp = w.globals.previousPaths[pp];
  15918. if (gpp.paths && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  15919. if (typeof w.globals.previousPaths[pp].paths[j] !== 'undefined') {
  15920. pathFrom = w.globals.previousPaths[pp].paths[j].d;
  15921. }
  15922. }
  15923. }
  15924. return pathFrom;
  15925. }
  15926. }]);
  15927. return Bar;
  15928. }();
  15929. /**
  15930. * ApexCharts BarStacked Class responsible for drawing both Stacked Columns and Bars.
  15931. *
  15932. * @module BarStacked
  15933. * The whole calculation for stacked bar/column is different from normal bar/column,
  15934. * hence it makes sense to derive a new class for it extending most of the props of Parent Bar
  15935. **/
  15936. var BarStacked = /*#__PURE__*/function (_Bar) {
  15937. _inherits(BarStacked, _Bar);
  15938. function BarStacked() {
  15939. _classCallCheck(this, BarStacked);
  15940. return _possibleConstructorReturn(this, _getPrototypeOf(BarStacked).apply(this, arguments));
  15941. }
  15942. _createClass(BarStacked, [{
  15943. key: "draw",
  15944. value: function draw(series, seriesIndex) {
  15945. var _this = this;
  15946. var w = this.w;
  15947. this.graphics = new Graphics(this.ctx);
  15948. this.bar = new Bar(this.ctx, this.xyRatios);
  15949. var coreUtils = new CoreUtils(this.ctx, w);
  15950. series = coreUtils.getLogSeries(series);
  15951. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  15952. this.barHelpers.initVariables(series);
  15953. if (w.config.chart.stackType === '100%') {
  15954. series = w.globals.seriesPercent.slice();
  15955. }
  15956. this.series = series;
  15957. this.totalItems = 0;
  15958. this.prevY = []; // y position on chart
  15959. this.prevX = []; // x position on chart
  15960. this.prevYF = []; // y position including shapes on chart
  15961. this.prevXF = []; // x position including shapes on chart
  15962. this.prevYVal = []; // y values (series[i][j]) in columns
  15963. this.prevXVal = []; // x values (series[i][j]) in bars
  15964. this.xArrj = []; // xj indicates x position on graph in bars
  15965. this.xArrjF = []; // xjF indicates bar's x position + roundedShape's positions in bars
  15966. this.xArrjVal = []; // x val means the actual series's y values in horizontal/bars
  15967. this.yArrj = []; // yj indicates y position on graph in columns
  15968. this.yArrjF = []; // yjF indicates bar's y position + roundedShape's positions in columns
  15969. this.yArrjVal = []; // y val means the actual series's y values in columns
  15970. for (var sl = 0; sl < series.length; sl++) {
  15971. if (series[sl].length > 0) {
  15972. this.totalItems += series[sl].length;
  15973. }
  15974. }
  15975. var ret = this.graphics.group({
  15976. class: 'apexcharts-bar-series apexcharts-plot-series'
  15977. });
  15978. var x = 0;
  15979. var y = 0;
  15980. var _loop = function _loop(i, bc) {
  15981. var xDivision = void 0; // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  15982. var yDivision = void 0; // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  15983. var zeroH = void 0; // zeroH is the baseline where 0 meets y axis
  15984. var zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  15985. var xArrValues = [];
  15986. var yArrValues = [];
  15987. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  15988. if (_this.yRatio.length > 1) {
  15989. _this.yaxisIndex = realIndex;
  15990. }
  15991. _this.isReversed = w.config.yaxis[_this.yaxisIndex] && w.config.yaxis[_this.yaxisIndex].reversed; // el to which series will be drawn
  15992. var elSeries = _this.graphics.group({
  15993. class: "apexcharts-series",
  15994. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  15995. rel: i + 1,
  15996. 'data:realIndex': realIndex
  15997. }); // eldatalabels
  15998. var elDataLabelsWrap = _this.graphics.group({
  15999. class: 'apexcharts-datalabels',
  16000. 'data:realIndex': realIndex
  16001. });
  16002. var barHeight = 0;
  16003. var barWidth = 0;
  16004. var initPositions = _this.initialPositions(x, y, xDivision, yDivision, zeroH, zeroW);
  16005. y = initPositions.y;
  16006. barHeight = initPositions.barHeight;
  16007. yDivision = initPositions.yDivision;
  16008. zeroW = initPositions.zeroW;
  16009. x = initPositions.x;
  16010. barWidth = initPositions.barWidth;
  16011. xDivision = initPositions.xDivision;
  16012. zeroH = initPositions.zeroH;
  16013. _this.yArrj = [];
  16014. _this.yArrjF = [];
  16015. _this.yArrjVal = [];
  16016. _this.xArrj = [];
  16017. _this.xArrjF = [];
  16018. _this.xArrjVal = []; // if (!this.horizontal) {
  16019. // this.xArrj.push(x + barWidth / 2)
  16020. // }
  16021. // fix issue #1215;
  16022. // where all stack bar disappear after collapsing the first series
  16023. // sol: if only 1 arr in this.prevY(this.prevY.length === 1) and all are NaN
  16024. if (_this.prevY.length === 1 && _this.prevY[0].every(function (val) {
  16025. return isNaN(val);
  16026. })) {
  16027. // make this.prevY[0] all zeroH
  16028. _this.prevY[0] = _this.prevY[0].map(function (val) {
  16029. return zeroH;
  16030. }); // make this.prevYF[0] all 0
  16031. _this.prevYF[0] = _this.prevYF[0].map(function (val) {
  16032. return 0;
  16033. });
  16034. }
  16035. for (var j = 0; j < w.globals.dataPoints; j++) {
  16036. var strokeWidth = _this.barHelpers.getStrokeWidth(i, j, realIndex);
  16037. var commonPathOpts = {
  16038. indexes: {
  16039. i: i,
  16040. j: j,
  16041. realIndex: realIndex,
  16042. bc: bc
  16043. },
  16044. strokeWidth: strokeWidth,
  16045. x: x,
  16046. y: y,
  16047. elSeries: elSeries
  16048. };
  16049. var paths = null;
  16050. if (_this.isHorizontal) {
  16051. paths = _this.drawStackedBarPaths(_objectSpread2({}, commonPathOpts, {
  16052. zeroW: zeroW,
  16053. barHeight: barHeight,
  16054. yDivision: yDivision
  16055. }));
  16056. barWidth = _this.series[i][j] / _this.invertedYRatio;
  16057. } else {
  16058. paths = _this.drawStackedColumnPaths(_objectSpread2({}, commonPathOpts, {
  16059. xDivision: xDivision,
  16060. barWidth: barWidth,
  16061. zeroH: zeroH
  16062. }));
  16063. barHeight = _this.series[i][j] / _this.yRatio[_this.yaxisIndex];
  16064. }
  16065. y = paths.y;
  16066. x = paths.x;
  16067. xArrValues.push(x);
  16068. yArrValues.push(y);
  16069. var pathFill = _this.barHelpers.getPathFillColor(series, i, j, realIndex);
  16070. elSeries = _this.renderSeries({
  16071. realIndex: realIndex,
  16072. pathFill: pathFill,
  16073. j: j,
  16074. i: i,
  16075. pathFrom: paths.pathFrom,
  16076. pathTo: paths.pathTo,
  16077. strokeWidth: strokeWidth,
  16078. elSeries: elSeries,
  16079. x: x,
  16080. y: y,
  16081. series: series,
  16082. barHeight: barHeight,
  16083. barWidth: barWidth,
  16084. elDataLabelsWrap: elDataLabelsWrap,
  16085. type: 'bar',
  16086. visibleSeries: 0
  16087. });
  16088. } // push all x val arrays into main xArr
  16089. w.globals.seriesXvalues[realIndex] = xArrValues;
  16090. w.globals.seriesYvalues[realIndex] = yArrValues; // push all current y values array to main PrevY Array
  16091. _this.prevY.push(_this.yArrj);
  16092. _this.prevYF.push(_this.yArrjF);
  16093. _this.prevYVal.push(_this.yArrjVal);
  16094. _this.prevX.push(_this.xArrj);
  16095. _this.prevXF.push(_this.xArrjF);
  16096. _this.prevXVal.push(_this.xArrjVal);
  16097. ret.add(elSeries);
  16098. };
  16099. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  16100. _loop(i, bc);
  16101. }
  16102. return ret;
  16103. }
  16104. }, {
  16105. key: "initialPositions",
  16106. value: function initialPositions(x, y, xDivision, yDivision, zeroH, zeroW) {
  16107. var w = this.w;
  16108. var barHeight, barWidth;
  16109. if (this.isHorizontal) {
  16110. // height divided into equal parts
  16111. yDivision = w.globals.gridHeight / w.globals.dataPoints;
  16112. barHeight = yDivision;
  16113. barHeight = barHeight * parseInt(w.config.plotOptions.bar.barHeight, 10) / 100;
  16114. zeroW = this.baseLineInvertedY + w.globals.padHorizontal + (this.isReversed ? w.globals.gridWidth : 0) - (this.isReversed ? this.baseLineInvertedY * 2 : 0); // initial y position is half of barHeight * half of number of Bars
  16115. y = (yDivision - barHeight) / 2;
  16116. } else {
  16117. // width divided into equal parts
  16118. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  16119. barWidth = xDivision;
  16120. if (w.globals.isXNumeric) {
  16121. xDivision = w.globals.minXDiff / this.xRatio;
  16122. barWidth = xDivision * parseInt(this.barOptions.columnWidth, 10) / 100;
  16123. } else {
  16124. barWidth = barWidth * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  16125. }
  16126. zeroH = this.baseLineY[this.yaxisIndex] + (this.isReversed ? w.globals.gridHeight : 0) - (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0); // initial x position is one third of barWidth
  16127. x = w.globals.padHorizontal + (xDivision - barWidth) / 2;
  16128. }
  16129. return {
  16130. x: x,
  16131. y: y,
  16132. yDivision: yDivision,
  16133. xDivision: xDivision,
  16134. barHeight: barHeight,
  16135. barWidth: barWidth,
  16136. zeroH: zeroH,
  16137. zeroW: zeroW
  16138. };
  16139. }
  16140. }, {
  16141. key: "drawStackedBarPaths",
  16142. value: function drawStackedBarPaths(_ref) {
  16143. var indexes = _ref.indexes,
  16144. barHeight = _ref.barHeight,
  16145. strokeWidth = _ref.strokeWidth,
  16146. zeroW = _ref.zeroW,
  16147. x = _ref.x,
  16148. y = _ref.y,
  16149. yDivision = _ref.yDivision,
  16150. elSeries = _ref.elSeries;
  16151. var w = this.w;
  16152. var barYPosition = y;
  16153. var barXPosition;
  16154. var i = indexes.i;
  16155. var j = indexes.j;
  16156. var bc = indexes.bc;
  16157. var prevBarW = 0;
  16158. for (var k = 0; k < this.prevXF.length; k++) {
  16159. prevBarW = prevBarW + this.prevXF[k][j];
  16160. }
  16161. if (i > 0) {
  16162. var bXP = zeroW;
  16163. if (this.prevXVal[i - 1][j] < 0) {
  16164. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] + prevBarW - (this.isReversed ? prevBarW : 0) * 2 : this.prevX[i - 1][j];
  16165. } else if (this.prevXVal[i - 1][j] >= 0) {
  16166. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] : this.prevX[i - 1][j] - prevBarW + (this.isReversed ? prevBarW : 0) * 2;
  16167. }
  16168. barXPosition = bXP;
  16169. } else {
  16170. // the first series will not have prevX values
  16171. barXPosition = zeroW;
  16172. }
  16173. if (this.series[i][j] === null) {
  16174. x = barXPosition;
  16175. } else {
  16176. x = barXPosition + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
  16177. }
  16178. this.xArrj.push(x);
  16179. this.xArrjF.push(Math.abs(barXPosition - x));
  16180. this.xArrjVal.push(this.series[i][j]);
  16181. var paths = this.barHelpers.getBarpaths({
  16182. barYPosition: barYPosition,
  16183. barHeight: barHeight,
  16184. x1: barXPosition,
  16185. x2: x,
  16186. strokeWidth: strokeWidth,
  16187. series: this.series,
  16188. realIndex: indexes.realIndex,
  16189. i: i,
  16190. j: j,
  16191. w: w
  16192. });
  16193. this.barHelpers.barBackground({
  16194. bc: bc,
  16195. i: i,
  16196. y1: barYPosition,
  16197. y2: barHeight,
  16198. elSeries: elSeries
  16199. });
  16200. y = y + yDivision;
  16201. return {
  16202. pathTo: paths.pathTo,
  16203. pathFrom: paths.pathFrom,
  16204. x: x,
  16205. y: y
  16206. };
  16207. }
  16208. }, {
  16209. key: "drawStackedColumnPaths",
  16210. value: function drawStackedColumnPaths(_ref2) {
  16211. var indexes = _ref2.indexes,
  16212. x = _ref2.x,
  16213. y = _ref2.y,
  16214. xDivision = _ref2.xDivision,
  16215. barWidth = _ref2.barWidth,
  16216. zeroH = _ref2.zeroH,
  16217. strokeWidth = _ref2.strokeWidth,
  16218. elSeries = _ref2.elSeries;
  16219. var w = this.w;
  16220. var i = indexes.i;
  16221. var j = indexes.j;
  16222. var bc = indexes.bc;
  16223. if (w.globals.isXNumeric) {
  16224. var seriesVal = w.globals.seriesX[i][j];
  16225. if (!seriesVal) seriesVal = 0;
  16226. x = (seriesVal - w.globals.minX) / this.xRatio - barWidth / 2;
  16227. }
  16228. var barXPosition = x;
  16229. var barYPosition;
  16230. var prevBarH = 0;
  16231. for (var k = 0; k < this.prevYF.length; k++) {
  16232. // fix issue #1215
  16233. // in case where this.prevYF[k][j] is NaN, use 0 instead
  16234. prevBarH = prevBarH + (!isNaN(this.prevYF[k][j]) ? this.prevYF[k][j] : 0);
  16235. }
  16236. if (i > 0 && !w.globals.isXNumeric || i > 0 && w.globals.isXNumeric && w.globals.seriesX[i - 1][j] === w.globals.seriesX[i][j]) {
  16237. var bYP;
  16238. var prevYValue;
  16239. var p = Math.min(this.yRatio.length + 1, i + 1);
  16240. if (this.prevY[i - 1] !== undefined) {
  16241. for (var ii = 1; ii < p; ii++) {
  16242. if (!isNaN(this.prevY[i - ii][j])) {
  16243. // find the previous available value to give prevYValue
  16244. prevYValue = this.prevY[i - ii][j]; // if found it, break the loop
  16245. break;
  16246. }
  16247. }
  16248. }
  16249. for (var _ii = 1; _ii < p; _ii++) {
  16250. // find the previous available value(non-NaN) to give bYP
  16251. if (this.prevYVal[i - _ii][j] < 0) {
  16252. bYP = this.series[i][j] >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue; // found it? break the loop
  16253. break;
  16254. } else if (this.prevYVal[i - _ii][j] >= 0) {
  16255. bYP = this.series[i][j] >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2; // found it? break the loop
  16256. break;
  16257. }
  16258. }
  16259. if (typeof bYP === 'undefined') bYP = w.globals.gridHeight; // if this.prevYF[0] is all 0 resulted from line #486
  16260. // AND every arr starting from the second only contains NaN
  16261. if (this.prevYF[0].every(function (val) {
  16262. return val === 0;
  16263. }) && this.prevYF.slice(1, i).every(function (arr) {
  16264. return arr.every(function (val) {
  16265. return isNaN(val);
  16266. });
  16267. })) {
  16268. // Use the same calc way as line #485
  16269. barYPosition = w.globals.gridHeight - zeroH;
  16270. } else {
  16271. // Nothing special
  16272. barYPosition = bYP;
  16273. }
  16274. } else {
  16275. // the first series will not have prevY values, also if the prev index's series X doesn't matches the current index's series X, then start from zero
  16276. barYPosition = w.globals.gridHeight - zeroH;
  16277. }
  16278. y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
  16279. this.yArrj.push(y);
  16280. this.yArrjF.push(Math.abs(barYPosition - y));
  16281. this.yArrjVal.push(this.series[i][j]);
  16282. var paths = this.barHelpers.getColumnPaths({
  16283. barXPosition: barXPosition,
  16284. barWidth: barWidth,
  16285. y1: barYPosition,
  16286. y2: y,
  16287. yRatio: this.yRatio[this.yaxisIndex],
  16288. strokeWidth: this.strokeWidth,
  16289. series: this.series,
  16290. realIndex: indexes.realIndex,
  16291. i: i,
  16292. j: j,
  16293. w: w
  16294. });
  16295. this.barHelpers.barBackground({
  16296. bc: bc,
  16297. i: i,
  16298. x1: barXPosition,
  16299. x2: barWidth,
  16300. elSeries: elSeries
  16301. });
  16302. x = x + xDivision;
  16303. return {
  16304. pathTo: paths.pathTo,
  16305. pathFrom: paths.pathFrom,
  16306. x: w.globals.isXNumeric ? x - xDivision : x,
  16307. y: y
  16308. };
  16309. }
  16310. }]);
  16311. return BarStacked;
  16312. }(Bar);
  16313. /**
  16314. * ApexCharts CandleStick Class responsible for drawing both Stacked Columns and Bars.
  16315. *
  16316. * @module CandleStick
  16317. **/
  16318. var CandleStick = /*#__PURE__*/function (_Bar) {
  16319. _inherits(CandleStick, _Bar);
  16320. function CandleStick() {
  16321. _classCallCheck(this, CandleStick);
  16322. return _possibleConstructorReturn(this, _getPrototypeOf(CandleStick).apply(this, arguments));
  16323. }
  16324. _createClass(CandleStick, [{
  16325. key: "draw",
  16326. value: function draw(series, seriesIndex) {
  16327. var w = this.w;
  16328. var graphics = new Graphics(this.ctx);
  16329. var fill = new Fill(this.ctx);
  16330. this.candlestickOptions = this.w.config.plotOptions.candlestick;
  16331. var coreUtils = new CoreUtils(this.ctx, w);
  16332. series = coreUtils.getLogSeries(series);
  16333. this.series = series;
  16334. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  16335. this.barHelpers.initVariables(series);
  16336. var ret = graphics.group({
  16337. class: 'apexcharts-candlestick-series apexcharts-plot-series'
  16338. });
  16339. for (var i = 0; i < series.length; i++) {
  16340. var x = void 0,
  16341. y = void 0,
  16342. xDivision = void 0,
  16343. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  16344. zeroH = void 0; // zeroH is the baseline where 0 meets y axis
  16345. var yArrj = []; // hold y values of current iterating series
  16346. var xArrj = []; // hold x values of current iterating series
  16347. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  16348. var elSeries = graphics.group({
  16349. class: "apexcharts-series",
  16350. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  16351. rel: i + 1,
  16352. 'data:realIndex': realIndex
  16353. });
  16354. if (series[i].length > 0) {
  16355. this.visibleI = this.visibleI + 1;
  16356. }
  16357. var barHeight = 0;
  16358. var barWidth = 0;
  16359. if (this.yRatio.length > 1) {
  16360. this.yaxisIndex = realIndex;
  16361. }
  16362. var initPositions = this.barHelpers.initialPositions();
  16363. y = initPositions.y;
  16364. barHeight = initPositions.barHeight;
  16365. x = initPositions.x;
  16366. barWidth = initPositions.barWidth;
  16367. xDivision = initPositions.xDivision;
  16368. zeroH = initPositions.zeroH;
  16369. xArrj.push(x + barWidth / 2); // eldatalabels
  16370. var elDataLabelsWrap = graphics.group({
  16371. class: 'apexcharts-datalabels',
  16372. 'data:realIndex': realIndex
  16373. });
  16374. for (var j = 0; j < w.globals.dataPoints; j++) {
  16375. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  16376. var color = void 0;
  16377. var paths = this.drawCandleStickPaths({
  16378. indexes: {
  16379. i: i,
  16380. j: j,
  16381. realIndex: realIndex
  16382. },
  16383. x: x,
  16384. y: y,
  16385. xDivision: xDivision,
  16386. barWidth: barWidth,
  16387. zeroH: zeroH,
  16388. strokeWidth: strokeWidth,
  16389. elSeries: elSeries
  16390. });
  16391. y = paths.y;
  16392. x = paths.x;
  16393. color = paths.color; // push current X
  16394. if (j > 0) {
  16395. xArrj.push(x + barWidth / 2);
  16396. }
  16397. yArrj.push(y);
  16398. var pathFill = fill.fillPath({
  16399. seriesNumber: realIndex,
  16400. dataPointIndex: j,
  16401. color: color,
  16402. value: series[i][j]
  16403. });
  16404. var lineFill = this.candlestickOptions.wick.useFillColor ? color : undefined;
  16405. this.renderSeries({
  16406. realIndex: realIndex,
  16407. pathFill: pathFill,
  16408. lineFill: lineFill,
  16409. j: j,
  16410. i: i,
  16411. pathFrom: paths.pathFrom,
  16412. pathTo: paths.pathTo,
  16413. strokeWidth: strokeWidth,
  16414. elSeries: elSeries,
  16415. x: x,
  16416. y: y,
  16417. series: series,
  16418. barHeight: barHeight,
  16419. barWidth: barWidth,
  16420. elDataLabelsWrap: elDataLabelsWrap,
  16421. visibleSeries: this.visibleI,
  16422. type: 'candlestick'
  16423. });
  16424. } // push all x val arrays into main xArr
  16425. w.globals.seriesXvalues[realIndex] = xArrj;
  16426. w.globals.seriesYvalues[realIndex] = yArrj;
  16427. ret.add(elSeries);
  16428. }
  16429. return ret;
  16430. }
  16431. }, {
  16432. key: "drawCandleStickPaths",
  16433. value: function drawCandleStickPaths(_ref) {
  16434. var indexes = _ref.indexes,
  16435. x = _ref.x,
  16436. y = _ref.y,
  16437. xDivision = _ref.xDivision,
  16438. barWidth = _ref.barWidth,
  16439. zeroH = _ref.zeroH,
  16440. strokeWidth = _ref.strokeWidth;
  16441. var w = this.w;
  16442. var graphics = new Graphics(this.ctx);
  16443. var i = indexes.i;
  16444. var j = indexes.j;
  16445. var isPositive = true;
  16446. var colorPos = w.config.plotOptions.candlestick.colors.upward;
  16447. var colorNeg = w.config.plotOptions.candlestick.colors.downward;
  16448. var yRatio = this.yRatio[this.yaxisIndex];
  16449. var realIndex = indexes.realIndex;
  16450. var ohlc = this.getOHLCValue(realIndex, j);
  16451. var l1 = zeroH;
  16452. var l2 = zeroH;
  16453. if (ohlc.o > ohlc.c) {
  16454. isPositive = false;
  16455. }
  16456. var y1 = Math.min(ohlc.o, ohlc.c);
  16457. var y2 = Math.max(ohlc.o, ohlc.c);
  16458. if (w.globals.isXNumeric) {
  16459. x = (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  16460. }
  16461. var barXPosition = x + barWidth * this.visibleI;
  16462. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  16463. y1 = zeroH;
  16464. } else {
  16465. y1 = zeroH - y1 / yRatio;
  16466. y2 = zeroH - y2 / yRatio;
  16467. l1 = zeroH - ohlc.h / yRatio;
  16468. l2 = zeroH - ohlc.l / yRatio;
  16469. }
  16470. var pathTo = graphics.move(barXPosition, zeroH);
  16471. var pathFrom = graphics.move(barXPosition, y1);
  16472. if (w.globals.previousPaths.length > 0) {
  16473. pathFrom = this.getPreviousPath(realIndex, j, true);
  16474. }
  16475. 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);
  16476. pathFrom = pathFrom + graphics.move(barXPosition, y1);
  16477. if (!w.globals.isXNumeric) {
  16478. x = x + xDivision;
  16479. }
  16480. return {
  16481. pathTo: pathTo,
  16482. pathFrom: pathFrom,
  16483. x: x,
  16484. y: y2,
  16485. barXPosition: barXPosition,
  16486. color: isPositive ? colorPos : colorNeg
  16487. };
  16488. }
  16489. }, {
  16490. key: "getOHLCValue",
  16491. value: function getOHLCValue(i, j) {
  16492. var w = this.w;
  16493. return {
  16494. o: w.globals.seriesCandleO[i][j],
  16495. h: w.globals.seriesCandleH[i][j],
  16496. l: w.globals.seriesCandleL[i][j],
  16497. c: w.globals.seriesCandleC[i][j]
  16498. };
  16499. }
  16500. }]);
  16501. return CandleStick;
  16502. }(Bar);
  16503. /**
  16504. * ApexCharts HeatMap Class.
  16505. * @module HeatMap
  16506. **/
  16507. var HeatMap = /*#__PURE__*/function () {
  16508. function HeatMap(ctx, xyRatios) {
  16509. _classCallCheck(this, HeatMap);
  16510. this.ctx = ctx;
  16511. this.w = ctx.w;
  16512. this.xRatio = xyRatios.xRatio;
  16513. this.yRatio = xyRatios.yRatio;
  16514. this.negRange = false;
  16515. this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation;
  16516. this.rectRadius = this.w.config.plotOptions.heatmap.radius;
  16517. this.strokeWidth = this.w.config.stroke.show ? this.w.config.stroke.width : 0;
  16518. }
  16519. _createClass(HeatMap, [{
  16520. key: "draw",
  16521. value: function draw(series) {
  16522. var w = this.w;
  16523. var graphics = new Graphics(this.ctx);
  16524. var ret = graphics.group({
  16525. class: 'apexcharts-heatmap'
  16526. });
  16527. ret.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")")); // width divided into equal parts
  16528. var xDivision = w.globals.gridWidth / w.globals.dataPoints;
  16529. var yDivision = w.globals.gridHeight / w.globals.series.length;
  16530. var y1 = 0;
  16531. var rev = false;
  16532. this.checkColorRange();
  16533. var heatSeries = series.slice();
  16534. if (w.config.yaxis[0].reversed) {
  16535. rev = true;
  16536. heatSeries.reverse();
  16537. }
  16538. for (var i = rev ? 0 : heatSeries.length - 1; rev ? i < heatSeries.length : i >= 0; rev ? i++ : i--) {
  16539. // el to which series will be drawn
  16540. var elSeries = graphics.group({
  16541. class: "apexcharts-series apexcharts-heatmap-series",
  16542. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  16543. rel: i + 1,
  16544. 'data:realIndex': i
  16545. });
  16546. if (w.config.chart.dropShadow.enabled) {
  16547. var shadow = w.config.chart.dropShadow;
  16548. var filters = new Filters(this.ctx);
  16549. filters.dropShadow(elSeries, shadow, i);
  16550. }
  16551. var x1 = 0;
  16552. for (var j = 0; j < heatSeries[i].length; j++) {
  16553. var colorShadePercent = 1;
  16554. var shadeIntensity = w.config.plotOptions.heatmap.shadeIntensity;
  16555. var heatColorProps = this.determineHeatColor(i, j);
  16556. if (w.globals.hasNegs || this.negRange) {
  16557. if (w.config.plotOptions.heatmap.reverseNegativeShade) {
  16558. if (heatColorProps.percent < 0) {
  16559. colorShadePercent = heatColorProps.percent / 100 * (shadeIntensity * 1.25);
  16560. } else {
  16561. colorShadePercent = (1 - heatColorProps.percent / 100) * (shadeIntensity * 1.25);
  16562. }
  16563. } else {
  16564. if (heatColorProps.percent <= 0) {
  16565. colorShadePercent = 1 - (1 + heatColorProps.percent / 100) * shadeIntensity;
  16566. } else {
  16567. colorShadePercent = (1 - heatColorProps.percent / 100) * shadeIntensity;
  16568. }
  16569. }
  16570. } else {
  16571. colorShadePercent = 1 - heatColorProps.percent / 100;
  16572. }
  16573. var color = heatColorProps.color;
  16574. var utils = new Utils();
  16575. if (w.config.plotOptions.heatmap.enableShades) {
  16576. if (colorShadePercent < 0) colorShadePercent = 0;
  16577. color = Utils.hexToRgba(utils.shadeColor(colorShadePercent, heatColorProps.color), w.config.fill.opacity);
  16578. }
  16579. if (w.config.fill.type === 'image') {
  16580. var fill = new Fill(this.ctx);
  16581. color = fill.fillPath({
  16582. seriesNumber: i,
  16583. dataPointIndex: j,
  16584. opacity: w.globals.hasNegs ? heatColorProps.percent < 0 ? 1 - (1 + heatColorProps.percent / 100) : shadeIntensity + heatColorProps.percent / 100 : heatColorProps.percent / 100,
  16585. patternID: Utils.randomId(),
  16586. width: w.config.fill.image.width ? w.config.fill.image.width : xDivision,
  16587. height: w.config.fill.image.height ? w.config.fill.image.height : yDivision
  16588. });
  16589. }
  16590. var radius = this.rectRadius;
  16591. var rect = graphics.drawRect(x1, y1, xDivision, yDivision, radius);
  16592. rect.attr({
  16593. cx: x1,
  16594. cy: y1
  16595. });
  16596. rect.node.classList.add('apexcharts-heatmap-rect');
  16597. elSeries.add(rect);
  16598. rect.attr({
  16599. fill: color,
  16600. i: i,
  16601. index: i,
  16602. j: j,
  16603. val: heatSeries[i][j],
  16604. 'stroke-width': this.strokeWidth,
  16605. stroke: w.config.plotOptions.heatmap.useFillColorAsStroke ? color : w.globals.stroke.colors[0],
  16606. color: color
  16607. });
  16608. rect.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, rect));
  16609. rect.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, rect));
  16610. rect.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, rect));
  16611. if (w.config.chart.animations.enabled && !w.globals.dataChanged) {
  16612. var speed = 1;
  16613. if (!w.globals.resized) {
  16614. speed = w.config.chart.animations.speed;
  16615. }
  16616. this.animateHeatMap(rect, x1, y1, xDivision, yDivision, speed);
  16617. }
  16618. if (w.globals.dataChanged) {
  16619. var _speed = 1;
  16620. if (this.dynamicAnim.enabled && w.globals.shouldAnimate) {
  16621. _speed = this.dynamicAnim.speed;
  16622. var colorFrom = w.globals.previousPaths[i] && w.globals.previousPaths[i][j] && w.globals.previousPaths[i][j].color;
  16623. if (!colorFrom) colorFrom = 'rgba(255, 255, 255, 0)';
  16624. this.animateHeatColor(rect, Utils.isColorHex(colorFrom) ? colorFrom : Utils.rgb2hex(colorFrom), Utils.isColorHex(color) ? color : Utils.rgb2hex(color), _speed);
  16625. }
  16626. }
  16627. var dataLabels = this.calculateHeatmapDataLabels({
  16628. x: x1,
  16629. y: y1,
  16630. i: i,
  16631. j: j,
  16632. heatColorProps: heatColorProps,
  16633. series: heatSeries,
  16634. rectHeight: yDivision,
  16635. rectWidth: xDivision
  16636. });
  16637. if (dataLabels !== null) {
  16638. elSeries.add(dataLabels);
  16639. }
  16640. x1 = x1 + xDivision;
  16641. }
  16642. y1 = y1 + yDivision;
  16643. ret.add(elSeries);
  16644. } // adjust yaxis labels for heatmap
  16645. var yAxisScale = w.globals.yAxisScale[0].result.slice();
  16646. if (w.config.yaxis[0].reversed) {
  16647. yAxisScale.unshift('');
  16648. } else {
  16649. yAxisScale.push('');
  16650. }
  16651. w.globals.yAxisScale[0].result = yAxisScale;
  16652. var divisor = w.globals.gridHeight / w.globals.series.length;
  16653. w.config.yaxis[0].labels.offsetY = -(divisor / 2);
  16654. return ret;
  16655. }
  16656. }, {
  16657. key: "checkColorRange",
  16658. value: function checkColorRange() {
  16659. var _this = this;
  16660. var w = this.w;
  16661. var heatmap = w.config.plotOptions.heatmap;
  16662. if (heatmap.colorScale.ranges.length > 0) {
  16663. heatmap.colorScale.ranges.map(function (range, index) {
  16664. if (range.from <= 0) {
  16665. _this.negRange = true;
  16666. }
  16667. });
  16668. }
  16669. }
  16670. }, {
  16671. key: "determineHeatColor",
  16672. value: function determineHeatColor(i, j) {
  16673. var w = this.w;
  16674. var val = w.globals.series[i][j];
  16675. var heatmap = w.config.plotOptions.heatmap;
  16676. var seriesNumber = heatmap.colorScale.inverse ? j : i;
  16677. var color = w.globals.colors[seriesNumber];
  16678. var foreColor = null;
  16679. var min = Math.min.apply(Math, _toConsumableArray(w.globals.series[i]));
  16680. var max = Math.max.apply(Math, _toConsumableArray(w.globals.series[i]));
  16681. if (!heatmap.distributed) {
  16682. min = w.globals.minY;
  16683. max = w.globals.maxY;
  16684. }
  16685. if (typeof heatmap.colorScale.min !== 'undefined') {
  16686. min = heatmap.colorScale.min < w.globals.minY ? heatmap.colorScale.min : w.globals.minY;
  16687. max = heatmap.colorScale.max > w.globals.maxY ? heatmap.colorScale.max : w.globals.maxY;
  16688. }
  16689. var total = Math.abs(max) + Math.abs(min);
  16690. var percent = 100 * val / (total === 0 ? total - 0.000001 : total);
  16691. if (heatmap.colorScale.ranges.length > 0) {
  16692. var colorRange = heatmap.colorScale.ranges;
  16693. colorRange.map(function (range, index) {
  16694. if (val >= range.from && val <= range.to) {
  16695. color = range.color;
  16696. foreColor = range.foreColor ? range.foreColor : null;
  16697. min = range.from;
  16698. max = range.to;
  16699. var rTotal = Math.abs(max) + Math.abs(min);
  16700. percent = 100 * val / (rTotal === 0 ? rTotal - 0.000001 : rTotal);
  16701. }
  16702. });
  16703. }
  16704. return {
  16705. color: color,
  16706. foreColor: foreColor,
  16707. percent: percent
  16708. };
  16709. }
  16710. }, {
  16711. key: "calculateHeatmapDataLabels",
  16712. value: function calculateHeatmapDataLabels(_ref) {
  16713. var x = _ref.x,
  16714. y = _ref.y,
  16715. i = _ref.i,
  16716. j = _ref.j,
  16717. heatColorProps = _ref.heatColorProps,
  16718. series = _ref.series,
  16719. rectHeight = _ref.rectHeight,
  16720. rectWidth = _ref.rectWidth;
  16721. var w = this.w; // let graphics = new Graphics(this.ctx)
  16722. var dataLabelsConfig = w.config.dataLabels;
  16723. var graphics = new Graphics(this.ctx);
  16724. var dataLabels = new DataLabels(this.ctx);
  16725. var formatter = dataLabelsConfig.formatter;
  16726. var elDataLabelsWrap = null;
  16727. if (dataLabelsConfig.enabled) {
  16728. elDataLabelsWrap = graphics.group({
  16729. class: 'apexcharts-data-labels'
  16730. });
  16731. var offX = dataLabelsConfig.offsetX;
  16732. var offY = dataLabelsConfig.offsetY;
  16733. var dataLabelsX = x + rectWidth / 2 + offX;
  16734. var dataLabelsY = y + rectHeight / 2 + parseFloat(dataLabelsConfig.style.fontSize) / 3 + offY;
  16735. var text = formatter(w.globals.series[i][j], {
  16736. seriesIndex: i,
  16737. dataPointIndex: j,
  16738. w: w
  16739. });
  16740. dataLabels.plotDataLabelsText({
  16741. x: dataLabelsX,
  16742. y: dataLabelsY,
  16743. text: text,
  16744. i: i,
  16745. j: j,
  16746. color: heatColorProps.foreColor,
  16747. parent: elDataLabelsWrap,
  16748. dataLabelsConfig: dataLabelsConfig
  16749. });
  16750. }
  16751. return elDataLabelsWrap;
  16752. }
  16753. }, {
  16754. key: "animateHeatMap",
  16755. value: function animateHeatMap(el, x, y, width, height, speed) {
  16756. var animations = new Animations(this.ctx);
  16757. animations.animateRect(el, {
  16758. x: x + width / 2,
  16759. y: y + height / 2,
  16760. width: 0,
  16761. height: 0
  16762. }, {
  16763. x: x,
  16764. y: y,
  16765. width: width,
  16766. height: height
  16767. }, speed, function () {
  16768. animations.animationCompleted(el);
  16769. });
  16770. }
  16771. }, {
  16772. key: "animateHeatColor",
  16773. value: function animateHeatColor(el, colorFrom, colorTo, speed) {
  16774. el.attr({
  16775. fill: colorFrom
  16776. }).animate(speed).attr({
  16777. fill: colorTo
  16778. });
  16779. }
  16780. }]);
  16781. return HeatMap;
  16782. }();
  16783. /**
  16784. * ApexCharts Radar Class for Spider/Radar Charts.
  16785. * @module Radar
  16786. **/
  16787. var Radar = /*#__PURE__*/function () {
  16788. function Radar(ctx) {
  16789. _classCallCheck(this, Radar);
  16790. this.ctx = ctx;
  16791. this.w = ctx.w;
  16792. this.chartType = this.w.config.chart.type;
  16793. this.initialAnim = this.w.config.chart.animations.enabled;
  16794. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  16795. this.animDur = 0;
  16796. var w = this.w;
  16797. this.graphics = new Graphics(this.ctx);
  16798. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  16799. this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight + w.globals.goldenPadding * 1.5 : w.globals.gridWidth;
  16800. this.maxValue = this.w.globals.maxY;
  16801. this.minValue = this.w.globals.minY;
  16802. this.polygons = w.config.plotOptions.radar.polygons;
  16803. var longestXaxisLabel = w.globals.labels.slice().sort(function (a, b) {
  16804. return b.length - a.length;
  16805. })[0];
  16806. var labelWidth = this.graphics.getTextRects(longestXaxisLabel, w.config.xaxis.labels.style.fontSize);
  16807. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  16808. this.size = this.defaultSize / 2.1 - this.strokeWidth - w.config.chart.dropShadow.blur;
  16809. if (w.config.xaxis.labels.show) {
  16810. this.size = this.size - labelWidth.width / 1.75;
  16811. }
  16812. if (w.config.plotOptions.radar.size !== undefined) {
  16813. this.size = w.config.plotOptions.radar.size;
  16814. }
  16815. this.dataRadiusOfPercent = [];
  16816. this.dataRadius = [];
  16817. this.angleArr = [];
  16818. this.yaxisLabelsTextsPos = [];
  16819. }
  16820. _createClass(Radar, [{
  16821. key: "draw",
  16822. value: function draw(series) {
  16823. var _this = this;
  16824. var w = this.w;
  16825. var fill = new Fill(this.ctx);
  16826. var allSeries = [];
  16827. var dataLabels = new DataLabels(this.ctx);
  16828. if (series.length) {
  16829. this.dataPointsLen = series[w.globals.maxValsInArrayIndex].length;
  16830. }
  16831. this.disAngle = Math.PI * 2 / this.dataPointsLen;
  16832. var halfW = w.globals.gridWidth / 2;
  16833. var halfH = w.globals.gridHeight / 2;
  16834. var translateX = halfW + w.config.plotOptions.radar.offsetX;
  16835. var translateY = halfH + w.config.plotOptions.radar.offsetY;
  16836. var ret = this.graphics.group({
  16837. class: 'apexcharts-radar-series apexcharts-plot-series',
  16838. transform: "translate(".concat(translateX || 0, ", ").concat(translateY || 0, ")")
  16839. });
  16840. var dataPointsPos = [];
  16841. var elPointsMain = null;
  16842. var elDataPointsMain = null;
  16843. this.yaxisLabels = this.graphics.group({
  16844. class: 'apexcharts-yaxis'
  16845. });
  16846. series.forEach(function (s, i) {
  16847. var longestSeries = s.length === w.globals.dataPoints; // el to which series will be drawn
  16848. var elSeries = _this.graphics.group().attr({
  16849. class: "apexcharts-series",
  16850. 'data:longestSeries': longestSeries,
  16851. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  16852. rel: i + 1,
  16853. 'data:realIndex': i
  16854. });
  16855. _this.dataRadiusOfPercent[i] = [];
  16856. _this.dataRadius[i] = [];
  16857. _this.angleArr[i] = [];
  16858. s.forEach(function (dv, j) {
  16859. var range = Math.abs(_this.maxValue - _this.minValue);
  16860. dv = dv + Math.abs(_this.minValue);
  16861. _this.dataRadiusOfPercent[i][j] = dv / range;
  16862. _this.dataRadius[i][j] = _this.dataRadiusOfPercent[i][j] * _this.size;
  16863. _this.angleArr[i][j] = j * _this.disAngle;
  16864. });
  16865. dataPointsPos = _this.getDataPointsPos(_this.dataRadius[i], _this.angleArr[i]);
  16866. var paths = _this.createPaths(dataPointsPos, {
  16867. x: 0,
  16868. y: 0
  16869. }); // points
  16870. elPointsMain = _this.graphics.group({
  16871. class: 'apexcharts-series-markers-wrap apexcharts-element-hidden'
  16872. }); // datapoints
  16873. elDataPointsMain = _this.graphics.group({
  16874. class: "apexcharts-datalabels",
  16875. 'data:realIndex': i
  16876. });
  16877. w.globals.delayedElements.push({
  16878. el: elPointsMain.node,
  16879. index: i
  16880. });
  16881. var defaultRenderedPathOptions = {
  16882. i: i,
  16883. realIndex: i,
  16884. animationDelay: i,
  16885. initialSpeed: w.config.chart.animations.speed,
  16886. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  16887. className: "apexcharts-radar",
  16888. shouldClipToGrid: false,
  16889. bindEventsOnPaths: false,
  16890. stroke: w.globals.stroke.colors[i],
  16891. strokeLineCap: w.config.stroke.lineCap
  16892. };
  16893. var pathFrom = null;
  16894. if (w.globals.previousPaths.length > 0) {
  16895. pathFrom = _this.getPreviousPath(i);
  16896. }
  16897. for (var p = 0; p < paths.linePathsTo.length; p++) {
  16898. var renderedLinePath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  16899. pathFrom: pathFrom === null ? paths.linePathsFrom[p] : pathFrom,
  16900. pathTo: paths.linePathsTo[p],
  16901. strokeWidth: Array.isArray(_this.strokeWidth) ? _this.strokeWidth[i] : _this.strokeWidth,
  16902. fill: 'none',
  16903. drawShadow: false
  16904. }));
  16905. elSeries.add(renderedLinePath);
  16906. var pathFill = fill.fillPath({
  16907. seriesNumber: i
  16908. });
  16909. var renderedAreaPath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  16910. pathFrom: pathFrom === null ? paths.areaPathsFrom[p] : pathFrom,
  16911. pathTo: paths.areaPathsTo[p],
  16912. strokeWidth: 0,
  16913. fill: pathFill,
  16914. drawShadow: false
  16915. }));
  16916. if (w.config.chart.dropShadow.enabled) {
  16917. var filters = new Filters(_this.ctx);
  16918. var shadow = w.config.chart.dropShadow;
  16919. filters.dropShadow(renderedAreaPath, Object.assign({}, shadow, {
  16920. noUserSpaceOnUse: true
  16921. }), i);
  16922. }
  16923. elSeries.add(renderedAreaPath);
  16924. }
  16925. s.forEach(function (sj, j) {
  16926. var markers = new Markers(_this.ctx);
  16927. var opts = markers.getMarkerConfig('apexcharts-marker', i, j);
  16928. var point = _this.graphics.drawMarker(dataPointsPos[j].x, dataPointsPos[j].y, opts);
  16929. point.attr('rel', j);
  16930. point.attr('j', j);
  16931. point.attr('index', i);
  16932. point.node.setAttribute('default-marker-size', opts.pSize);
  16933. var elPointsWrap = _this.graphics.group({
  16934. class: 'apexcharts-series-markers'
  16935. });
  16936. if (elPointsWrap) {
  16937. elPointsWrap.add(point);
  16938. }
  16939. elPointsMain.add(elPointsWrap);
  16940. elSeries.add(elPointsMain);
  16941. var dataLabelsConfig = w.config.dataLabels;
  16942. if (dataLabelsConfig.enabled) {
  16943. var text = dataLabelsConfig.formatter(w.globals.series[i][j], {
  16944. seriesIndex: i,
  16945. dataPointIndex: j,
  16946. w: w
  16947. });
  16948. dataLabels.plotDataLabelsText({
  16949. x: dataPointsPos[j].x,
  16950. y: dataPointsPos[j].y,
  16951. text: text,
  16952. textAnchor: 'middle',
  16953. i: i,
  16954. j: i,
  16955. parent: elDataPointsMain,
  16956. offsetCorrection: false,
  16957. dataLabelsConfig: _objectSpread2({}, dataLabelsConfig)
  16958. });
  16959. }
  16960. elSeries.add(elDataPointsMain);
  16961. });
  16962. allSeries.push(elSeries);
  16963. });
  16964. this.drawPolygons({
  16965. parent: ret
  16966. });
  16967. if (w.config.xaxis.labels.show) {
  16968. var xaxisTexts = this.drawXAxisTexts();
  16969. ret.add(xaxisTexts);
  16970. }
  16971. ret.add(this.yaxisLabels);
  16972. allSeries.forEach(function (elS) {
  16973. ret.add(elS);
  16974. });
  16975. return ret;
  16976. }
  16977. }, {
  16978. key: "drawPolygons",
  16979. value: function drawPolygons(opts) {
  16980. var _this2 = this;
  16981. var w = this.w;
  16982. var parent = opts.parent;
  16983. var yaxisTexts = w.globals.yAxisScale[0].result.reverse();
  16984. var layers = yaxisTexts.length;
  16985. var radiusSizes = [];
  16986. var layerDis = this.size / (layers - 1);
  16987. for (var i = 0; i < layers; i++) {
  16988. radiusSizes[i] = layerDis * i;
  16989. }
  16990. radiusSizes.reverse();
  16991. var polygonStrings = [];
  16992. var lines = [];
  16993. radiusSizes.forEach(function (radiusSize, r) {
  16994. var polygon = _this2.getPolygonPos(radiusSize);
  16995. var string = '';
  16996. polygon.forEach(function (p, i) {
  16997. if (r === 0) {
  16998. var line = _this2.graphics.drawLine(p.x, p.y, 0, 0, Array.isArray(_this2.polygons.connectorColors) ? _this2.polygons.connectorColors[i] : _this2.polygons.connectorColors);
  16999. lines.push(line);
  17000. }
  17001. if (i === 0) {
  17002. _this2.yaxisLabelsTextsPos.push({
  17003. x: p.x,
  17004. y: p.y
  17005. });
  17006. }
  17007. string += p.x + ',' + p.y + ' ';
  17008. });
  17009. polygonStrings.push(string);
  17010. });
  17011. polygonStrings.forEach(function (p, i) {
  17012. var strokeColors = _this2.polygons.strokeColors;
  17013. var polygon = _this2.graphics.drawPolygon(p, Array.isArray(strokeColors) ? strokeColors[i] : strokeColors, w.globals.radarPolygons.fill.colors[i]);
  17014. parent.add(polygon);
  17015. });
  17016. lines.forEach(function (l) {
  17017. parent.add(l);
  17018. });
  17019. if (w.config.yaxis[0].show) {
  17020. this.yaxisLabelsTextsPos.forEach(function (p, i) {
  17021. var yText = _this2.drawYAxisTexts(p.x, p.y, i, yaxisTexts[i]);
  17022. _this2.yaxisLabels.add(yText);
  17023. });
  17024. }
  17025. }
  17026. }, {
  17027. key: "drawYAxisTexts",
  17028. value: function drawYAxisTexts(x, y, i, text) {
  17029. var w = this.w;
  17030. var yaxisConfig = w.config.yaxis[0];
  17031. var formatter = w.globals.yLabelFormatters[0];
  17032. var yaxisLabel = this.graphics.drawText({
  17033. x: x + yaxisConfig.labels.offsetX,
  17034. y: y + yaxisConfig.labels.offsetY,
  17035. text: formatter(text, i),
  17036. textAnchor: 'middle',
  17037. fontSize: yaxisConfig.labels.style.fontSize,
  17038. fontFamily: yaxisConfig.labels.style.fontFamily,
  17039. foreColor: yaxisConfig.labels.style.color
  17040. });
  17041. return yaxisLabel;
  17042. }
  17043. }, {
  17044. key: "drawXAxisTexts",
  17045. value: function drawXAxisTexts() {
  17046. var _this3 = this;
  17047. var w = this.w;
  17048. var xaxisLabelsConfig = w.config.xaxis.labels;
  17049. var elXAxisWrap = this.graphics.group({
  17050. class: 'apexcharts-xaxis'
  17051. });
  17052. var polygonPos = this.getPolygonPos(this.size);
  17053. w.globals.labels.forEach(function (label, i) {
  17054. var formatter = w.config.xaxis.labels.formatter;
  17055. var dataLabels = new DataLabels(_this3.ctx);
  17056. if (polygonPos[i]) {
  17057. var textPos = _this3.getTextPos(polygonPos[i], _this3.size);
  17058. var text = formatter(label, {
  17059. seriesIndex: -1,
  17060. dataPointIndex: i,
  17061. w: w
  17062. });
  17063. dataLabels.plotDataLabelsText({
  17064. x: textPos.newX,
  17065. y: textPos.newY,
  17066. text: text,
  17067. textAnchor: textPos.textAnchor,
  17068. i: i,
  17069. j: i,
  17070. parent: elXAxisWrap,
  17071. color: xaxisLabelsConfig.style.colors[i] ? xaxisLabelsConfig.style.colors[i] : '#a8a8a8',
  17072. dataLabelsConfig: _objectSpread2({
  17073. textAnchor: textPos.textAnchor,
  17074. dropShadow: {
  17075. enabled: false
  17076. }
  17077. }, xaxisLabelsConfig),
  17078. offsetCorrection: false
  17079. });
  17080. }
  17081. });
  17082. return elXAxisWrap;
  17083. }
  17084. }, {
  17085. key: "createPaths",
  17086. value: function createPaths(pos, origin) {
  17087. var _this4 = this;
  17088. var linePathsTo = [];
  17089. var linePathsFrom = [];
  17090. var areaPathsTo = [];
  17091. var areaPathsFrom = [];
  17092. if (pos.length) {
  17093. linePathsFrom = [this.graphics.move(origin.x, origin.y)];
  17094. areaPathsFrom = [this.graphics.move(origin.x, origin.y)];
  17095. var linePathTo = this.graphics.move(pos[0].x, pos[0].y);
  17096. var areaPathTo = this.graphics.move(pos[0].x, pos[0].y);
  17097. pos.forEach(function (p, i) {
  17098. linePathTo += _this4.graphics.line(p.x, p.y);
  17099. areaPathTo += _this4.graphics.line(p.x, p.y);
  17100. if (i === pos.length - 1) {
  17101. linePathTo += 'Z';
  17102. areaPathTo += 'Z';
  17103. }
  17104. });
  17105. linePathsTo.push(linePathTo);
  17106. areaPathsTo.push(areaPathTo);
  17107. }
  17108. return {
  17109. linePathsFrom: linePathsFrom,
  17110. linePathsTo: linePathsTo,
  17111. areaPathsFrom: areaPathsFrom,
  17112. areaPathsTo: areaPathsTo
  17113. };
  17114. }
  17115. }, {
  17116. key: "getTextPos",
  17117. value: function getTextPos(pos, polygonSize) {
  17118. var limit = 10;
  17119. var textAnchor = 'middle';
  17120. var newX = pos.x;
  17121. var newY = pos.y;
  17122. if (Math.abs(pos.x) >= limit) {
  17123. if (pos.x > 0) {
  17124. textAnchor = 'start';
  17125. newX += 10;
  17126. } else if (pos.x < 0) {
  17127. textAnchor = 'end';
  17128. newX -= 10;
  17129. }
  17130. } else {
  17131. textAnchor = 'middle';
  17132. }
  17133. if (Math.abs(pos.y) >= polygonSize - limit) {
  17134. if (pos.y < 0) {
  17135. newY -= 10;
  17136. } else if (pos.y > 0) {
  17137. newY += 10;
  17138. }
  17139. }
  17140. return {
  17141. textAnchor: textAnchor,
  17142. newX: newX,
  17143. newY: newY
  17144. };
  17145. }
  17146. }, {
  17147. key: "getPreviousPath",
  17148. value: function getPreviousPath(realIndex) {
  17149. var w = this.w;
  17150. var pathFrom = null;
  17151. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  17152. var gpp = w.globals.previousPaths[pp];
  17153. if (gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  17154. if (typeof w.globals.previousPaths[pp].paths[0] !== 'undefined') {
  17155. pathFrom = w.globals.previousPaths[pp].paths[0].d;
  17156. }
  17157. }
  17158. }
  17159. return pathFrom;
  17160. }
  17161. }, {
  17162. key: "getDataPointsPos",
  17163. value: function getDataPointsPos(dataRadiusArr, angleArr) {
  17164. var dataPointsLen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.dataPointsLen;
  17165. dataRadiusArr = dataRadiusArr || [];
  17166. angleArr = angleArr || [];
  17167. var dataPointsPosArray = [];
  17168. for (var j = 0; j < dataPointsLen; j++) {
  17169. var curPointPos = {};
  17170. curPointPos.x = dataRadiusArr[j] * Math.sin(angleArr[j]);
  17171. curPointPos.y = -dataRadiusArr[j] * Math.cos(angleArr[j]);
  17172. dataPointsPosArray.push(curPointPos);
  17173. }
  17174. return dataPointsPosArray;
  17175. }
  17176. }, {
  17177. key: "getPolygonPos",
  17178. value: function getPolygonPos(size) {
  17179. var dotsArray = [];
  17180. var angle = Math.PI * 2 / this.dataPointsLen;
  17181. for (var i = 0; i < this.dataPointsLen; i++) {
  17182. var curPos = {};
  17183. curPos.x = size * Math.sin(i * angle);
  17184. curPos.y = -size * Math.cos(i * angle);
  17185. dotsArray.push(curPos);
  17186. }
  17187. return dotsArray;
  17188. }
  17189. }]);
  17190. return Radar;
  17191. }();
  17192. /**
  17193. * ApexCharts Radial Class for drawing Circle / Semi Circle Charts.
  17194. * @module Radial
  17195. **/
  17196. var Radial = /*#__PURE__*/function (_Pie) {
  17197. _inherits(Radial, _Pie);
  17198. function Radial(ctx) {
  17199. var _this;
  17200. _classCallCheck(this, Radial);
  17201. _this = _possibleConstructorReturn(this, _getPrototypeOf(Radial).call(this, ctx));
  17202. _this.ctx = ctx;
  17203. _this.w = ctx.w;
  17204. _this.animBeginArr = [0];
  17205. _this.animDur = 0;
  17206. var w = _this.w;
  17207. _this.startAngle = w.config.plotOptions.radialBar.startAngle;
  17208. _this.endAngle = w.config.plotOptions.radialBar.endAngle;
  17209. _this.totalAngle = Math.abs(w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle);
  17210. _this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle;
  17211. _this.trackEndAngle = w.config.plotOptions.radialBar.track.endAngle;
  17212. _this.radialDataLabels = w.config.plotOptions.radialBar.dataLabels;
  17213. if (!_this.trackStartAngle) _this.trackStartAngle = _this.startAngle;
  17214. if (!_this.trackEndAngle) _this.trackEndAngle = _this.endAngle;
  17215. if (_this.endAngle === 360) _this.endAngle = 359.99;
  17216. _this.fullAngle = 360 - w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle;
  17217. _this.margin = parseInt(w.config.plotOptions.radialBar.track.margin, 10);
  17218. return _this;
  17219. }
  17220. _createClass(Radial, [{
  17221. key: "draw",
  17222. value: function draw(series) {
  17223. var w = this.w;
  17224. var graphics = new Graphics(this.ctx);
  17225. var ret = graphics.group({
  17226. class: 'apexcharts-radialbar'
  17227. });
  17228. if (w.globals.noData) return ret;
  17229. var elSeries = graphics.group();
  17230. var centerY = this.defaultSize / 2;
  17231. var centerX = w.globals.gridWidth / 2;
  17232. var size = this.defaultSize / 2.05;
  17233. if (!w.config.chart.sparkline.enabled) {
  17234. size = size - w.config.stroke.width - w.config.chart.dropShadow.blur;
  17235. }
  17236. var colorArr = w.globals.fill.colors;
  17237. if (w.config.plotOptions.radialBar.track.show) {
  17238. var elTracks = this.drawTracks({
  17239. size: size,
  17240. centerX: centerX,
  17241. centerY: centerY,
  17242. colorArr: colorArr,
  17243. series: series
  17244. });
  17245. elSeries.add(elTracks);
  17246. }
  17247. var elG = this.drawArcs({
  17248. size: size,
  17249. centerX: centerX,
  17250. centerY: centerY,
  17251. colorArr: colorArr,
  17252. series: series
  17253. });
  17254. var totalAngle = 360;
  17255. if (w.config.plotOptions.radialBar.startAngle < 0) {
  17256. totalAngle = this.totalAngle;
  17257. }
  17258. var angleRatio = (360 - totalAngle) / 360;
  17259. w.globals.radialSize = size - size * angleRatio;
  17260. if (this.radialDataLabels.value.show) {
  17261. var offset = Math.max(this.radialDataLabels.value.offsetY, this.radialDataLabels.name.offsetY);
  17262. w.globals.radialSize += offset * angleRatio;
  17263. }
  17264. elSeries.add(elG.g);
  17265. if (w.config.plotOptions.radialBar.hollow.position === 'front') {
  17266. elG.g.add(elG.elHollow);
  17267. if (elG.dataLabels) {
  17268. elG.g.add(elG.dataLabels);
  17269. }
  17270. }
  17271. ret.add(elSeries);
  17272. return ret;
  17273. }
  17274. }, {
  17275. key: "drawTracks",
  17276. value: function drawTracks(opts) {
  17277. var w = this.w;
  17278. var graphics = new Graphics(this.ctx);
  17279. var g = graphics.group({
  17280. class: 'apexcharts-tracks'
  17281. });
  17282. var filters = new Filters(this.ctx);
  17283. var fill = new Fill(this.ctx);
  17284. var strokeWidth = this.getStrokeWidth(opts);
  17285. opts.size = opts.size - strokeWidth / 2;
  17286. for (var i = 0; i < opts.series.length; i++) {
  17287. var elRadialBarTrack = graphics.group({
  17288. class: 'apexcharts-radialbar-track apexcharts-track'
  17289. });
  17290. g.add(elRadialBarTrack);
  17291. elRadialBarTrack.attr({
  17292. rel: i + 1
  17293. });
  17294. opts.size = opts.size - strokeWidth - this.margin;
  17295. var trackConfig = w.config.plotOptions.radialBar.track;
  17296. var pathFill = fill.fillPath({
  17297. seriesNumber: 0,
  17298. size: opts.size,
  17299. fillColors: Array.isArray(trackConfig.background) ? trackConfig.background[i] : trackConfig.background,
  17300. solid: true
  17301. });
  17302. var startAngle = this.trackStartAngle;
  17303. var endAngle = this.trackEndAngle;
  17304. if (Math.abs(endAngle) + Math.abs(startAngle) >= 360) endAngle = 360 - Math.abs(this.startAngle) - 0.1;
  17305. var elPath = graphics.drawPath({
  17306. d: '',
  17307. stroke: pathFill,
  17308. strokeWidth: strokeWidth * parseInt(trackConfig.strokeWidth, 10) / 100,
  17309. fill: 'none',
  17310. strokeOpacity: trackConfig.opacity,
  17311. classes: 'apexcharts-radialbar-area'
  17312. });
  17313. if (trackConfig.dropShadow.enabled) {
  17314. var shadow = trackConfig.dropShadow;
  17315. filters.dropShadow(elPath, shadow);
  17316. }
  17317. elRadialBarTrack.add(elPath);
  17318. elPath.attr('id', 'apexcharts-radialbarTrack-' + i);
  17319. this.animatePaths(elPath, {
  17320. centerX: opts.centerX,
  17321. centerY: opts.centerY,
  17322. endAngle: endAngle,
  17323. startAngle: startAngle,
  17324. size: opts.size,
  17325. i: i,
  17326. totalItems: 2,
  17327. animBeginArr: 0,
  17328. dur: 0,
  17329. isTrack: true,
  17330. easing: w.globals.easing
  17331. });
  17332. }
  17333. return g;
  17334. }
  17335. }, {
  17336. key: "drawArcs",
  17337. value: function drawArcs(opts) {
  17338. var w = this.w; // size, donutSize, centerX, centerY, colorArr, lineColorArr, sectorAngleArr, series
  17339. var graphics = new Graphics(this.ctx);
  17340. var fill = new Fill(this.ctx);
  17341. var filters = new Filters(this.ctx);
  17342. var g = graphics.group();
  17343. var strokeWidth = this.getStrokeWidth(opts);
  17344. opts.size = opts.size - strokeWidth / 2;
  17345. var hollowFillID = w.config.plotOptions.radialBar.hollow.background;
  17346. var hollowSize = opts.size - strokeWidth * opts.series.length - this.margin * opts.series.length - strokeWidth * parseInt(w.config.plotOptions.radialBar.track.strokeWidth, 10) / 100 / 2;
  17347. var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin;
  17348. if (w.config.plotOptions.radialBar.hollow.image !== undefined) {
  17349. hollowFillID = this.drawHollowImage(opts, g, hollowSize, hollowFillID);
  17350. }
  17351. var elHollow = this.drawHollow({
  17352. size: hollowRadius,
  17353. centerX: opts.centerX,
  17354. centerY: opts.centerY,
  17355. fill: hollowFillID ? hollowFillID : 'transparent'
  17356. });
  17357. if (w.config.plotOptions.radialBar.hollow.dropShadow.enabled) {
  17358. var shadow = w.config.plotOptions.radialBar.hollow.dropShadow;
  17359. filters.dropShadow(elHollow, shadow);
  17360. }
  17361. var shown = 1;
  17362. if (!this.radialDataLabels.total.show && w.globals.series.length > 1) {
  17363. shown = 0;
  17364. }
  17365. var dataLabels = null;
  17366. if (this.radialDataLabels.show) {
  17367. dataLabels = this.renderInnerDataLabels(this.radialDataLabels, {
  17368. hollowSize: hollowSize,
  17369. centerX: opts.centerX,
  17370. centerY: opts.centerY,
  17371. opacity: shown
  17372. });
  17373. }
  17374. if (w.config.plotOptions.radialBar.hollow.position === 'back') {
  17375. g.add(elHollow);
  17376. if (dataLabels) {
  17377. g.add(dataLabels);
  17378. }
  17379. }
  17380. var reverseLoop = false;
  17381. if (w.config.plotOptions.radialBar.inverseOrder) {
  17382. reverseLoop = true;
  17383. }
  17384. for (var i = reverseLoop ? opts.series.length - 1 : 0; reverseLoop ? i >= 0 : i < opts.series.length; reverseLoop ? i-- : i++) {
  17385. var elRadialBarArc = graphics.group({
  17386. class: "apexcharts-series apexcharts-radial-series",
  17387. seriesName: Utils.escapeString(w.globals.seriesNames[i])
  17388. });
  17389. g.add(elRadialBarArc);
  17390. elRadialBarArc.attr({
  17391. rel: i + 1,
  17392. 'data:realIndex': i
  17393. });
  17394. this.ctx.series.addCollapsedClassToSeries(elRadialBarArc, i);
  17395. opts.size = opts.size - strokeWidth - this.margin;
  17396. var pathFill = fill.fillPath({
  17397. seriesNumber: i,
  17398. size: opts.size,
  17399. value: opts.series[i]
  17400. });
  17401. var startAngle = this.startAngle;
  17402. var prevStartAngle = void 0; // if data exceeds 100, make it 100
  17403. var dataValue = Utils.negToZero(opts.series[i] > 100 ? 100 : opts.series[i]) / 100;
  17404. var endAngle = Math.round(this.totalAngle * dataValue) + this.startAngle;
  17405. var prevEndAngle = void 0;
  17406. if (w.globals.dataChanged) {
  17407. prevStartAngle = this.startAngle;
  17408. prevEndAngle = Math.round(this.totalAngle * Utils.negToZero(w.globals.previousPaths[i]) / 100) + prevStartAngle;
  17409. }
  17410. var currFullAngle = Math.abs(endAngle) + Math.abs(startAngle);
  17411. if (currFullAngle >= 360) {
  17412. endAngle = endAngle - 0.01;
  17413. }
  17414. var prevFullAngle = Math.abs(prevEndAngle) + Math.abs(prevStartAngle);
  17415. if (prevFullAngle >= 360) {
  17416. prevEndAngle = prevEndAngle - 0.01;
  17417. }
  17418. var angle = endAngle - startAngle;
  17419. var dashArray = Array.isArray(w.config.stroke.dashArray) ? w.config.stroke.dashArray[i] : w.config.stroke.dashArray;
  17420. var elPath = graphics.drawPath({
  17421. d: '',
  17422. stroke: pathFill,
  17423. strokeWidth: strokeWidth,
  17424. fill: 'none',
  17425. fillOpacity: w.config.fill.opacity,
  17426. classes: 'apexcharts-radialbar-area apexcharts-radialbar-slice-' + i,
  17427. strokeDashArray: dashArray
  17428. });
  17429. Graphics.setAttrs(elPath.node, {
  17430. 'data:angle': angle,
  17431. 'data:value': opts.series[i]
  17432. });
  17433. if (w.config.chart.dropShadow.enabled) {
  17434. var _shadow = w.config.chart.dropShadow;
  17435. filters.dropShadow(elPath, _shadow, i);
  17436. }
  17437. this.addListeners(elPath, this.radialDataLabels);
  17438. elRadialBarArc.add(elPath);
  17439. elPath.attr({
  17440. index: 0,
  17441. j: i
  17442. });
  17443. var dur = 0;
  17444. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  17445. dur = (endAngle - startAngle) / 360 * w.config.chart.animations.speed;
  17446. this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
  17447. this.animBeginArr.push(this.animDur);
  17448. }
  17449. if (w.globals.dataChanged) {
  17450. dur = (endAngle - startAngle) / 360 * w.config.chart.animations.dynamicAnimation.speed;
  17451. this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
  17452. this.animBeginArr.push(this.animDur);
  17453. }
  17454. this.animatePaths(elPath, {
  17455. centerX: opts.centerX,
  17456. centerY: opts.centerY,
  17457. endAngle: endAngle,
  17458. startAngle: startAngle,
  17459. prevEndAngle: prevEndAngle,
  17460. prevStartAngle: prevStartAngle,
  17461. size: opts.size,
  17462. i: i,
  17463. totalItems: 2,
  17464. animBeginArr: this.animBeginArr,
  17465. dur: dur,
  17466. shouldSetPrevPaths: true,
  17467. easing: w.globals.easing
  17468. });
  17469. }
  17470. return {
  17471. g: g,
  17472. elHollow: elHollow,
  17473. dataLabels: dataLabels
  17474. };
  17475. }
  17476. }, {
  17477. key: "drawHollow",
  17478. value: function drawHollow(opts) {
  17479. var graphics = new Graphics(this.ctx);
  17480. var circle = graphics.drawCircle(opts.size * 2);
  17481. circle.attr({
  17482. class: 'apexcharts-radialbar-hollow',
  17483. cx: opts.centerX,
  17484. cy: opts.centerY,
  17485. r: opts.size,
  17486. fill: opts.fill
  17487. });
  17488. return circle;
  17489. }
  17490. }, {
  17491. key: "drawHollowImage",
  17492. value: function drawHollowImage(opts, g, hollowSize, hollowFillID) {
  17493. var w = this.w;
  17494. var fill = new Fill(this.ctx);
  17495. var randID = Utils.randomId();
  17496. var hollowFillImg = w.config.plotOptions.radialBar.hollow.image;
  17497. if (w.config.plotOptions.radialBar.hollow.imageClipped) {
  17498. fill.clippedImgArea({
  17499. width: hollowSize,
  17500. height: hollowSize,
  17501. image: hollowFillImg,
  17502. patternID: "pattern".concat(w.globals.cuid).concat(randID)
  17503. });
  17504. hollowFillID = "url(#pattern".concat(w.globals.cuid).concat(randID, ")");
  17505. } else {
  17506. var imgWidth = w.config.plotOptions.radialBar.hollow.imageWidth;
  17507. var imgHeight = w.config.plotOptions.radialBar.hollow.imageHeight;
  17508. if (imgWidth === undefined && imgHeight === undefined) {
  17509. var image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  17510. this.move(opts.centerX - loader.width / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - loader.height / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  17511. });
  17512. g.add(image);
  17513. } else {
  17514. var _image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  17515. this.move(opts.centerX - imgWidth / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - imgHeight / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  17516. this.size(imgWidth, imgHeight);
  17517. });
  17518. g.add(_image);
  17519. }
  17520. }
  17521. return hollowFillID;
  17522. }
  17523. }, {
  17524. key: "getStrokeWidth",
  17525. value: function getStrokeWidth(opts) {
  17526. var w = this.w;
  17527. return opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size, 10)) / 100 / (opts.series.length + 1) - this.margin;
  17528. }
  17529. }]);
  17530. return Radial;
  17531. }(Pie);
  17532. /**
  17533. * ApexCharts RangeBar Class responsible for drawing Range/Timeline Bars.
  17534. *
  17535. * @module RangeBar
  17536. **/
  17537. var RangeBar = /*#__PURE__*/function (_Bar) {
  17538. _inherits(RangeBar, _Bar);
  17539. function RangeBar() {
  17540. _classCallCheck(this, RangeBar);
  17541. return _possibleConstructorReturn(this, _getPrototypeOf(RangeBar).apply(this, arguments));
  17542. }
  17543. _createClass(RangeBar, [{
  17544. key: "draw",
  17545. value: function draw(series, seriesIndex) {
  17546. var w = this.w;
  17547. var graphics = new Graphics(this.ctx);
  17548. this.rangeBarOptions = this.w.config.plotOptions.rangeBar;
  17549. this.series = series;
  17550. this.seriesRangeStart = w.globals.seriesRangeStart;
  17551. this.seriesRangeEnd = w.globals.seriesRangeEnd;
  17552. this.barHelpers.initVariables(series);
  17553. var ret = graphics.group({
  17554. class: 'apexcharts-rangebar-series apexcharts-plot-series'
  17555. });
  17556. for (var i = 0; i < series.length; i++) {
  17557. var x = void 0,
  17558. y = void 0,
  17559. xDivision = void 0,
  17560. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  17561. yDivision = void 0,
  17562. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  17563. zeroH = void 0,
  17564. // zeroH is the baseline where 0 meets y axis
  17565. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  17566. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  17567. var elSeries = graphics.group({
  17568. class: "apexcharts-series",
  17569. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  17570. rel: i + 1,
  17571. 'data:realIndex': realIndex
  17572. });
  17573. if (series[i].length > 0) {
  17574. this.visibleI = this.visibleI + 1;
  17575. }
  17576. var barHeight = 0;
  17577. var barWidth = 0;
  17578. if (this.yRatio.length > 1) {
  17579. this.yaxisIndex = realIndex;
  17580. }
  17581. var initPositions = this.barHelpers.initialPositions();
  17582. y = initPositions.y;
  17583. zeroW = initPositions.zeroW;
  17584. x = initPositions.x;
  17585. barWidth = initPositions.barWidth;
  17586. xDivision = initPositions.xDivision;
  17587. zeroH = initPositions.zeroH; // eldatalabels
  17588. var elDataLabelsWrap = graphics.group({
  17589. class: 'apexcharts-datalabels',
  17590. 'data:realIndex': realIndex
  17591. });
  17592. for (var j = 0; j < w.globals.dataPoints; j++) {
  17593. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  17594. var y1 = this.seriesRangeStart[i][j];
  17595. var y2 = this.seriesRangeEnd[i][j];
  17596. var paths = null;
  17597. var barYPosition = null;
  17598. var params = {
  17599. x: x,
  17600. y: y,
  17601. strokeWidth: strokeWidth,
  17602. elSeries: elSeries
  17603. };
  17604. yDivision = initPositions.yDivision;
  17605. barHeight = initPositions.barHeight;
  17606. if (this.isHorizontal) {
  17607. barYPosition = y + barHeight * this.visibleI;
  17608. var srty = (yDivision - barHeight * this.seriesLen) / 2;
  17609. if (typeof w.config.series[i].data[j] === 'undefined') {
  17610. // no data exists for further indexes, hence we need to get out the innr loop.
  17611. // As we are iterating over total datapoints, there is a possiblity the series might not have data for j index
  17612. break;
  17613. }
  17614. if (this.isTimelineBar && w.config.series[i].data[j].x) {
  17615. var positions = this.detectOverlappingBars({
  17616. i: i,
  17617. j: j,
  17618. barYPosition: barYPosition,
  17619. srty: srty,
  17620. barHeight: barHeight,
  17621. yDivision: yDivision,
  17622. initPositions: initPositions
  17623. });
  17624. barHeight = positions.barHeight;
  17625. barYPosition = positions.barYPosition;
  17626. }
  17627. paths = this.drawRangeBarPaths(_objectSpread2({
  17628. indexes: {
  17629. i: i,
  17630. j: j,
  17631. realIndex: realIndex
  17632. },
  17633. barHeight: barHeight,
  17634. barYPosition: barYPosition,
  17635. zeroW: zeroW,
  17636. yDivision: yDivision,
  17637. y1: y1,
  17638. y2: y2
  17639. }, params));
  17640. barWidth = paths.barWidth;
  17641. } else {
  17642. paths = this.drawRangeColumnPaths(_objectSpread2({
  17643. indexes: {
  17644. i: i,
  17645. j: j,
  17646. realIndex: realIndex
  17647. },
  17648. zeroH: zeroH,
  17649. barWidth: barWidth,
  17650. xDivision: xDivision
  17651. }, params));
  17652. barHeight = paths.barHeight;
  17653. }
  17654. y = paths.y;
  17655. x = paths.x;
  17656. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  17657. var lineFill = w.globals.stroke.colors[realIndex];
  17658. this.renderSeries({
  17659. realIndex: realIndex,
  17660. pathFill: pathFill,
  17661. lineFill: lineFill,
  17662. j: j,
  17663. i: i,
  17664. x: x,
  17665. y: y,
  17666. y1: y1,
  17667. y2: y2,
  17668. pathFrom: paths.pathFrom,
  17669. pathTo: paths.pathTo,
  17670. strokeWidth: strokeWidth,
  17671. elSeries: elSeries,
  17672. series: series,
  17673. barHeight: barHeight,
  17674. barYPosition: barYPosition,
  17675. barWidth: barWidth,
  17676. elDataLabelsWrap: elDataLabelsWrap,
  17677. visibleSeries: this.visibleI,
  17678. type: 'rangebar'
  17679. });
  17680. }
  17681. ret.add(elSeries);
  17682. }
  17683. return ret;
  17684. }
  17685. }, {
  17686. key: "detectOverlappingBars",
  17687. value: function detectOverlappingBars(_ref) {
  17688. var i = _ref.i,
  17689. j = _ref.j,
  17690. barYPosition = _ref.barYPosition,
  17691. srty = _ref.srty,
  17692. barHeight = _ref.barHeight,
  17693. yDivision = _ref.yDivision,
  17694. initPositions = _ref.initPositions;
  17695. var w = this.w;
  17696. var overlaps = [];
  17697. var rangeName = w.config.series[i].data[j].rangeName;
  17698. var labelX = w.config.series[i].data[j].x;
  17699. var rowIndex = w.globals.labels.indexOf(labelX);
  17700. var overlappedIndex = w.globals.seriesRangeBarTimeline[i].findIndex(function (tx) {
  17701. return tx.x === labelX && tx.overlaps.length > 0;
  17702. });
  17703. barYPosition = srty + barHeight * this.visibleI + yDivision * rowIndex;
  17704. if (overlappedIndex > -1) {
  17705. overlaps = w.globals.seriesRangeBarTimeline[i][overlappedIndex].overlaps;
  17706. if (overlaps.indexOf(rangeName) > -1) {
  17707. barHeight = initPositions.barHeight / overlaps.length;
  17708. barYPosition = barHeight * this.visibleI + yDivision * (100 - parseInt(this.barOptions.barHeight, 10)) / 100 / 2 + barHeight * (this.visibleI + overlaps.indexOf(rangeName)) + yDivision * rowIndex;
  17709. }
  17710. }
  17711. return {
  17712. barYPosition: barYPosition,
  17713. barHeight: barHeight
  17714. };
  17715. }
  17716. }, {
  17717. key: "drawRangeColumnPaths",
  17718. value: function drawRangeColumnPaths(_ref2) {
  17719. var indexes = _ref2.indexes,
  17720. x = _ref2.x,
  17721. strokeWidth = _ref2.strokeWidth,
  17722. xDivision = _ref2.xDivision,
  17723. barWidth = _ref2.barWidth,
  17724. zeroH = _ref2.zeroH;
  17725. var w = this.w;
  17726. var i = indexes.i;
  17727. var j = indexes.j;
  17728. var yRatio = this.yRatio[this.yaxisIndex];
  17729. var realIndex = indexes.realIndex;
  17730. var range = this.getRangeValue(realIndex, j);
  17731. var y1 = Math.min(range.start, range.end);
  17732. var y2 = Math.max(range.start, range.end);
  17733. if (w.globals.isXNumeric) {
  17734. x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  17735. }
  17736. var barXPosition = x + barWidth * this.visibleI;
  17737. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  17738. y1 = zeroH;
  17739. } else {
  17740. y1 = zeroH - y1 / yRatio;
  17741. y2 = zeroH - y2 / yRatio;
  17742. }
  17743. var barHeight = Math.abs(y2 - y1);
  17744. var paths = this.barHelpers.getColumnPaths({
  17745. barXPosition: barXPosition,
  17746. barWidth: barWidth,
  17747. y1: y1,
  17748. y2: y2,
  17749. strokeWidth: this.strokeWidth,
  17750. series: this.seriesRangeEnd,
  17751. i: realIndex,
  17752. j: j,
  17753. w: w
  17754. });
  17755. if (!w.globals.isXNumeric) {
  17756. x = x + xDivision;
  17757. }
  17758. return {
  17759. pathTo: paths.pathTo,
  17760. pathFrom: paths.pathFrom,
  17761. barHeight: barHeight,
  17762. x: x,
  17763. y: y2,
  17764. barXPosition: barXPosition
  17765. };
  17766. }
  17767. }, {
  17768. key: "drawRangeBarPaths",
  17769. value: function drawRangeBarPaths(_ref3) {
  17770. var indexes = _ref3.indexes,
  17771. y = _ref3.y,
  17772. y1 = _ref3.y1,
  17773. y2 = _ref3.y2,
  17774. yDivision = _ref3.yDivision,
  17775. barHeight = _ref3.barHeight,
  17776. barYPosition = _ref3.barYPosition,
  17777. zeroW = _ref3.zeroW;
  17778. var w = this.w;
  17779. var x1 = zeroW + y1 / this.invertedYRatio;
  17780. var x2 = zeroW + y2 / this.invertedYRatio;
  17781. var barWidth = Math.abs(x2 - x1);
  17782. var paths = this.barHelpers.getBarpaths({
  17783. barYPosition: barYPosition,
  17784. barHeight: barHeight,
  17785. x1: x1,
  17786. x2: x2,
  17787. strokeWidth: this.strokeWidth,
  17788. series: this.seriesRangeEnd,
  17789. i: indexes.realIndex,
  17790. j: indexes.j,
  17791. w: w
  17792. });
  17793. if (!w.globals.isXNumeric) {
  17794. y = y + yDivision;
  17795. }
  17796. return {
  17797. pathTo: paths.pathTo,
  17798. pathFrom: paths.pathFrom,
  17799. barWidth: barWidth,
  17800. x: x2,
  17801. y: y
  17802. };
  17803. }
  17804. }, {
  17805. key: "getRangeValue",
  17806. value: function getRangeValue(i, j) {
  17807. var w = this.w;
  17808. return {
  17809. start: w.globals.seriesRangeStart[i][j],
  17810. end: w.globals.seriesRangeEnd[i][j]
  17811. };
  17812. }
  17813. }]);
  17814. return RangeBar;
  17815. }(Bar);
  17816. var Helpers$4 = /*#__PURE__*/function () {
  17817. function Helpers(lineCtx) {
  17818. _classCallCheck(this, Helpers);
  17819. this.w = lineCtx.w;
  17820. this.lineCtx = lineCtx;
  17821. }
  17822. _createClass(Helpers, [{
  17823. key: "sameValueSeriesFix",
  17824. value: function sameValueSeriesFix(i, series) {
  17825. var w = this.w;
  17826. if (w.config.chart.type === 'line' && (w.config.fill.type === 'gradient' || w.config.fill.type[i] === 'gradient')) {
  17827. var coreUtils = new CoreUtils(this.lineCtx.ctx, w); // a small adjustment to allow gradient line to draw correctly for all same values
  17828. /* #fix https://github.com/apexcharts/apexcharts.js/issues/358 */
  17829. if (coreUtils.seriesHaveSameValues(i)) {
  17830. var gSeries = series[i].slice();
  17831. gSeries[gSeries.length - 1] = gSeries[gSeries.length - 1] + 0.000001;
  17832. series[i] = gSeries;
  17833. }
  17834. }
  17835. return series;
  17836. }
  17837. }, {
  17838. key: "calculatePoints",
  17839. value: function calculatePoints(_ref) {
  17840. var series = _ref.series,
  17841. realIndex = _ref.realIndex,
  17842. x = _ref.x,
  17843. y = _ref.y,
  17844. i = _ref.i,
  17845. j = _ref.j,
  17846. prevY = _ref.prevY;
  17847. var w = this.w;
  17848. var ptX = [];
  17849. var ptY = [];
  17850. if (j === 0) {
  17851. var xPT1st = this.lineCtx.categoryAxisCorrection + w.config.markers.offsetX; // the first point for line series
  17852. // we need to check whether it's not a time series, because a time series may
  17853. // start from the middle of the x axis
  17854. if (w.globals.isXNumeric) {
  17855. xPT1st = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.lineCtx.xRatio + w.config.markers.offsetX;
  17856. } // push 2 points for the first data values
  17857. ptX.push(xPT1st);
  17858. ptY.push(Utils.isNumber(series[i][0]) ? prevY + w.config.markers.offsetY : null);
  17859. ptX.push(x + w.config.markers.offsetX);
  17860. ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  17861. } else {
  17862. ptX.push(x + w.config.markers.offsetX);
  17863. ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  17864. }
  17865. var pointsPos = {
  17866. x: ptX,
  17867. y: ptY
  17868. };
  17869. return pointsPos;
  17870. }
  17871. }, {
  17872. key: "checkPreviousPaths",
  17873. value: function checkPreviousPaths(_ref2) {
  17874. var pathFromLine = _ref2.pathFromLine,
  17875. pathFromArea = _ref2.pathFromArea,
  17876. realIndex = _ref2.realIndex;
  17877. var w = this.w;
  17878. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  17879. var gpp = w.globals.previousPaths[pp];
  17880. if ((gpp.type === 'line' || gpp.type === 'area') && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  17881. if (gpp.type === 'line') {
  17882. this.lineCtx.appendPathFrom = false;
  17883. pathFromLine = w.globals.previousPaths[pp].paths[0].d;
  17884. } else if (gpp.type === 'area') {
  17885. this.lineCtx.appendPathFrom = false;
  17886. pathFromArea = w.globals.previousPaths[pp].paths[0].d;
  17887. if (w.config.stroke.show && w.globals.previousPaths[pp].paths[1]) {
  17888. pathFromLine = w.globals.previousPaths[pp].paths[1].d;
  17889. }
  17890. }
  17891. }
  17892. }
  17893. return {
  17894. pathFromLine: pathFromLine,
  17895. pathFromArea: pathFromArea
  17896. };
  17897. }
  17898. }, {
  17899. key: "determineFirstPrevY",
  17900. value: function determineFirstPrevY(_ref3) {
  17901. var i = _ref3.i,
  17902. series = _ref3.series,
  17903. prevY = _ref3.prevY,
  17904. lineYPosition = _ref3.lineYPosition;
  17905. var w = this.w;
  17906. if (typeof series[i][0] !== 'undefined') {
  17907. if (w.config.chart.stacked) {
  17908. if (i > 0) {
  17909. // 1st y value of previous series
  17910. lineYPosition = this.lineCtx.prevSeriesY[i - 1][0];
  17911. } else {
  17912. // the first series will not have prevY values
  17913. lineYPosition = this.lineCtx.zeroY;
  17914. }
  17915. } else {
  17916. lineYPosition = this.lineCtx.zeroY;
  17917. }
  17918. 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;
  17919. } else {
  17920. // the first value in the current series is null
  17921. if (w.config.chart.stacked && i > 0 && typeof series[i][0] === 'undefined') {
  17922. // check for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses)
  17923. for (var s = i - 1; s >= 0; s--) {
  17924. // for loop to get to 1st previous value until we get it
  17925. if (series[s][0] !== null && typeof series[s][0] !== 'undefined') {
  17926. lineYPosition = this.lineCtx.prevSeriesY[s][0];
  17927. prevY = lineYPosition;
  17928. break;
  17929. }
  17930. }
  17931. }
  17932. }
  17933. return {
  17934. prevY: prevY,
  17935. lineYPosition: lineYPosition
  17936. };
  17937. }
  17938. }]);
  17939. return Helpers;
  17940. }();
  17941. /**
  17942. * ApexCharts Line Class responsible for drawing Line / Area Charts.
  17943. * This class is also responsible for generating values for Bubble/Scatter charts, so need to rename it to Axis Charts to avoid confusions
  17944. * @module Line
  17945. **/
  17946. var Line = /*#__PURE__*/function () {
  17947. function Line(ctx, xyRatios, isPointsChart) {
  17948. _classCallCheck(this, Line);
  17949. this.ctx = ctx;
  17950. this.w = ctx.w;
  17951. this.xyRatios = xyRatios;
  17952. this.pointsChart = !(this.w.config.chart.type !== 'bubble' && this.w.config.chart.type !== 'scatter') || isPointsChart;
  17953. this.scatter = new Scatter(this.ctx);
  17954. this.noNegatives = this.w.globals.minX === Number.MAX_VALUE;
  17955. this.lineHelpers = new Helpers$4(this);
  17956. this.markers = new Markers(this.ctx);
  17957. this.prevSeriesY = [];
  17958. this.categoryAxisCorrection = 0;
  17959. this.yaxisIndex = 0;
  17960. }
  17961. _createClass(Line, [{
  17962. key: "draw",
  17963. value: function draw(series, ptype, seriesIndex) {
  17964. var w = this.w;
  17965. var graphics = new Graphics(this.ctx);
  17966. var type = w.globals.comboCharts ? ptype : w.config.chart.type;
  17967. var ret = graphics.group({
  17968. class: "apexcharts-".concat(type, "-series apexcharts-plot-series")
  17969. });
  17970. var coreUtils = new CoreUtils(this.ctx, w);
  17971. this.yRatio = this.xyRatios.yRatio;
  17972. this.zRatio = this.xyRatios.zRatio;
  17973. this.xRatio = this.xyRatios.xRatio;
  17974. this.baseLineY = this.xyRatios.baseLineY;
  17975. series = coreUtils.getLogSeries(series);
  17976. this.yRatio = coreUtils.getLogYRatios(this.yRatio); // push all series in an array, so we can draw in reverse order (for stacked charts)
  17977. var allSeries = [];
  17978. for (var i = 0; i < series.length; i++) {
  17979. series = this.lineHelpers.sameValueSeriesFix(i, series);
  17980. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  17981. this._initSerieVariables(series, i, realIndex);
  17982. var yArrj = []; // hold y values of current iterating series
  17983. var xArrj = []; // hold x values of current iterating series
  17984. var x = w.globals.padHorizontal + this.categoryAxisCorrection;
  17985. var y = 1;
  17986. var linePaths = [];
  17987. var areaPaths = [];
  17988. this.ctx.series.addCollapsedClassToSeries(this.elSeries, realIndex);
  17989. if (w.globals.isXNumeric && w.globals.seriesX.length > 0) {
  17990. x = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.xRatio;
  17991. }
  17992. xArrj.push(x);
  17993. var pX = x;
  17994. var pY = void 0;
  17995. var prevX = pX;
  17996. var prevY = this.zeroY;
  17997. var lineYPosition = 0; // the first value in the current series is not null or undefined
  17998. var firstPrevY = this.lineHelpers.determineFirstPrevY({
  17999. i: i,
  18000. series: series,
  18001. prevY: prevY,
  18002. lineYPosition: lineYPosition
  18003. });
  18004. prevY = firstPrevY.prevY;
  18005. yArrj.push(prevY);
  18006. pY = prevY;
  18007. var pathsFrom = this._calculatePathsFrom({
  18008. series: series,
  18009. i: i,
  18010. realIndex: realIndex,
  18011. prevX: prevX,
  18012. prevY: prevY
  18013. });
  18014. var paths = this._iterateOverDataPoints({
  18015. series: series,
  18016. realIndex: realIndex,
  18017. i: i,
  18018. x: x,
  18019. y: y,
  18020. pX: pX,
  18021. pY: pY,
  18022. pathsFrom: pathsFrom,
  18023. linePaths: linePaths,
  18024. areaPaths: areaPaths,
  18025. seriesIndex: seriesIndex,
  18026. lineYPosition: lineYPosition,
  18027. xArrj: xArrj,
  18028. yArrj: yArrj
  18029. });
  18030. this._handlePaths({
  18031. type: type,
  18032. realIndex: realIndex,
  18033. i: i,
  18034. paths: paths
  18035. });
  18036. this.elSeries.add(this.elPointsMain);
  18037. this.elSeries.add(this.elDataLabelsWrap);
  18038. allSeries.push(this.elSeries);
  18039. }
  18040. for (var s = allSeries.length; s > 0; s--) {
  18041. ret.add(allSeries[s - 1]);
  18042. }
  18043. return ret;
  18044. }
  18045. }, {
  18046. key: "_initSerieVariables",
  18047. value: function _initSerieVariables(series, i, realIndex) {
  18048. var w = this.w;
  18049. var graphics = new Graphics(this.ctx); // width divided into equal parts
  18050. this.xDivision = w.globals.gridWidth / (w.globals.dataPoints - (w.config.xaxis.tickPlacement === 'on' ? 1 : 0));
  18051. this.strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width;
  18052. if (this.yRatio.length > 1) {
  18053. this.yaxisIndex = realIndex;
  18054. }
  18055. this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed; // zeroY is the 0 value in y series which can be used in negative charts
  18056. this.zeroY = w.globals.gridHeight - this.baseLineY[this.yaxisIndex] - (this.isReversed ? w.globals.gridHeight : 0) + (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0);
  18057. this.areaBottomY = this.zeroY;
  18058. if (this.zeroY > w.globals.gridHeight) {
  18059. this.areaBottomY = w.globals.gridHeight;
  18060. }
  18061. this.categoryAxisCorrection = this.xDivision / 2; // el to which series will be drawn
  18062. this.elSeries = graphics.group({
  18063. class: "apexcharts-series",
  18064. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex])
  18065. }); // points
  18066. this.elPointsMain = graphics.group({
  18067. class: 'apexcharts-series-markers-wrap',
  18068. 'data:realIndex': realIndex
  18069. }); // eldatalabels
  18070. this.elDataLabelsWrap = graphics.group({
  18071. class: 'apexcharts-datalabels',
  18072. 'data:realIndex': realIndex
  18073. });
  18074. var longestSeries = series[i].length === w.globals.dataPoints;
  18075. this.elSeries.attr({
  18076. 'data:longestSeries': longestSeries,
  18077. rel: i + 1,
  18078. 'data:realIndex': realIndex
  18079. });
  18080. this.appendPathFrom = true;
  18081. }
  18082. }, {
  18083. key: "_calculatePathsFrom",
  18084. value: function _calculatePathsFrom(_ref) {
  18085. var series = _ref.series,
  18086. i = _ref.i,
  18087. realIndex = _ref.realIndex,
  18088. prevX = _ref.prevX,
  18089. prevY = _ref.prevY;
  18090. var w = this.w;
  18091. var graphics = new Graphics(this.ctx);
  18092. var linePath, areaPath, pathFromLine, pathFromArea;
  18093. if (series[i][0] === null) {
  18094. // when the first value itself is null, we need to move the pointer to a location where a null value is not found
  18095. for (var s = 0; s < series[i].length; s++) {
  18096. if (series[i][s] !== null) {
  18097. prevX = this.xDivision * s;
  18098. prevY = this.zeroY - series[i][s] / this.yRatio[this.yaxisIndex];
  18099. linePath = graphics.move(prevX, prevY);
  18100. areaPath = graphics.move(prevX, this.areaBottomY);
  18101. break;
  18102. }
  18103. }
  18104. } else {
  18105. linePath = graphics.move(prevX, prevY);
  18106. areaPath = graphics.move(prevX, this.areaBottomY) + graphics.line(prevX, prevY);
  18107. }
  18108. pathFromLine = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  18109. pathFromArea = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  18110. if (w.globals.previousPaths.length > 0) {
  18111. var pathFrom = this.lineHelpers.checkPreviousPaths({
  18112. pathFromLine: pathFromLine,
  18113. pathFromArea: pathFromArea,
  18114. realIndex: realIndex
  18115. });
  18116. pathFromLine = pathFrom.pathFromLine;
  18117. pathFromArea = pathFrom.pathFromArea;
  18118. }
  18119. return {
  18120. prevX: prevX,
  18121. prevY: prevY,
  18122. linePath: linePath,
  18123. areaPath: areaPath,
  18124. pathFromLine: pathFromLine,
  18125. pathFromArea: pathFromArea
  18126. };
  18127. }
  18128. }, {
  18129. key: "_handlePaths",
  18130. value: function _handlePaths(_ref2) {
  18131. var type = _ref2.type,
  18132. realIndex = _ref2.realIndex,
  18133. i = _ref2.i,
  18134. paths = _ref2.paths;
  18135. var w = this.w;
  18136. var graphics = new Graphics(this.ctx);
  18137. var fill = new Fill(this.ctx); // push all current y values array to main PrevY Array
  18138. this.prevSeriesY.push(paths.yArrj); // push all x val arrays into main xArr
  18139. w.globals.seriesXvalues[realIndex] = paths.xArrj;
  18140. w.globals.seriesYvalues[realIndex] = paths.yArrj; // these elements will be shown after area path animation completes
  18141. if (!this.pointsChart) {
  18142. w.globals.delayedElements.push({
  18143. el: this.elPointsMain.node,
  18144. index: realIndex
  18145. });
  18146. }
  18147. var defaultRenderedPathOptions = {
  18148. i: i,
  18149. realIndex: realIndex,
  18150. animationDelay: i,
  18151. initialSpeed: w.config.chart.animations.speed,
  18152. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  18153. className: "apexcharts-".concat(type)
  18154. };
  18155. if (type === 'area') {
  18156. var pathFill = fill.fillPath({
  18157. seriesNumber: realIndex
  18158. });
  18159. for (var p = 0; p < paths.areaPaths.length; p++) {
  18160. var renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  18161. pathFrom: paths.pathFromArea,
  18162. pathTo: paths.areaPaths[p],
  18163. stroke: 'none',
  18164. strokeWidth: 0,
  18165. strokeLineCap: null,
  18166. fill: pathFill
  18167. }));
  18168. this.elSeries.add(renderedPath);
  18169. }
  18170. }
  18171. if (w.config.stroke.show && !this.pointsChart) {
  18172. var lineFill = null;
  18173. if (type === 'line') {
  18174. // fillable lines only for lineChart
  18175. lineFill = fill.fillPath({
  18176. seriesNumber: realIndex,
  18177. i: i
  18178. });
  18179. } else {
  18180. lineFill = w.globals.stroke.colors[realIndex];
  18181. }
  18182. for (var _p = 0; _p < paths.linePaths.length; _p++) {
  18183. var _renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  18184. pathFrom: paths.pathFromLine,
  18185. pathTo: paths.linePaths[_p],
  18186. stroke: lineFill,
  18187. strokeWidth: this.strokeWidth,
  18188. strokeLineCap: w.config.stroke.lineCap,
  18189. fill: 'none'
  18190. }));
  18191. this.elSeries.add(_renderedPath);
  18192. }
  18193. }
  18194. }
  18195. }, {
  18196. key: "_iterateOverDataPoints",
  18197. value: function _iterateOverDataPoints(_ref3) {
  18198. var series = _ref3.series,
  18199. realIndex = _ref3.realIndex,
  18200. i = _ref3.i,
  18201. x = _ref3.x,
  18202. y = _ref3.y,
  18203. pX = _ref3.pX,
  18204. pY = _ref3.pY,
  18205. pathsFrom = _ref3.pathsFrom,
  18206. linePaths = _ref3.linePaths,
  18207. areaPaths = _ref3.areaPaths,
  18208. seriesIndex = _ref3.seriesIndex,
  18209. lineYPosition = _ref3.lineYPosition,
  18210. xArrj = _ref3.xArrj,
  18211. yArrj = _ref3.yArrj;
  18212. var w = this.w;
  18213. var graphics = new Graphics(this.ctx);
  18214. var yRatio = this.yRatio;
  18215. var prevY = pathsFrom.prevY,
  18216. linePath = pathsFrom.linePath,
  18217. areaPath = pathsFrom.areaPath,
  18218. pathFromLine = pathsFrom.pathFromLine,
  18219. pathFromArea = pathsFrom.pathFromArea;
  18220. var minY = Utils.isNumber(w.globals.minYArr[realIndex]) ? w.globals.minYArr[realIndex] : w.globals.minY;
  18221. var iterations = w.globals.dataPoints > 1 ? w.globals.dataPoints - 1 : w.globals.dataPoints;
  18222. for (var j = 0; j < iterations; j++) {
  18223. var isNull = typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null;
  18224. if (w.globals.isXNumeric) {
  18225. var sX = w.globals.seriesX[realIndex][j + 1];
  18226. if (typeof w.globals.seriesX[realIndex][j + 1] === 'undefined') {
  18227. /* fix #374 */
  18228. sX = w.globals.seriesX[realIndex][iterations - 1];
  18229. }
  18230. x = (sX - w.globals.minX) / this.xRatio;
  18231. } else {
  18232. x = x + this.xDivision;
  18233. }
  18234. if (w.config.chart.stacked) {
  18235. if (i > 0 && w.globals.collapsedSeries.length < w.config.series.length - 1) {
  18236. // a collapsed series in a stacked bar chart may provide wrong result for the next series, hence find the prevIndex of prev series which is not collapsed - fixes apexcharts.js#1372
  18237. var prevIndex = function prevIndex(pi) {
  18238. var pii = pi;
  18239. for (var cpi = 0; cpi < w.globals.series.length; cpi++) {
  18240. if (w.globals.collapsedSeriesIndices.indexOf(pi) > -1) {
  18241. pii--;
  18242. break;
  18243. }
  18244. }
  18245. return pii >= 0 ? pii : 0;
  18246. };
  18247. lineYPosition = this.prevSeriesY[prevIndex(i - 1)][j + 1];
  18248. } else {
  18249. // the first series will not have prevY values
  18250. lineYPosition = this.zeroY;
  18251. }
  18252. } else {
  18253. lineYPosition = this.zeroY;
  18254. }
  18255. if (isNull) {
  18256. y = lineYPosition - minY / yRatio[this.yaxisIndex] + (this.isReversed ? minY / yRatio[this.yaxisIndex] : 0) * 2;
  18257. } else {
  18258. y = lineYPosition - series[i][j + 1] / yRatio[this.yaxisIndex] + (this.isReversed ? series[i][j + 1] / yRatio[this.yaxisIndex] : 0) * 2;
  18259. } // push current X
  18260. xArrj.push(x); // push current Y that will be used as next series's bottom position
  18261. yArrj.push(y);
  18262. var pointsPos = this.lineHelpers.calculatePoints({
  18263. series: series,
  18264. x: x,
  18265. y: y,
  18266. realIndex: realIndex,
  18267. i: i,
  18268. j: j,
  18269. prevY: prevY
  18270. });
  18271. var calculatedPaths = this._createPaths({
  18272. series: series,
  18273. i: i,
  18274. realIndex: realIndex,
  18275. j: j,
  18276. x: x,
  18277. y: y,
  18278. pX: pX,
  18279. pY: pY,
  18280. linePath: linePath,
  18281. areaPath: areaPath,
  18282. linePaths: linePaths,
  18283. areaPaths: areaPaths,
  18284. seriesIndex: seriesIndex
  18285. });
  18286. areaPaths = calculatedPaths.areaPaths;
  18287. linePaths = calculatedPaths.linePaths;
  18288. pX = calculatedPaths.pX;
  18289. pY = calculatedPaths.pY;
  18290. areaPath = calculatedPaths.areaPath;
  18291. linePath = calculatedPaths.linePath;
  18292. if (this.appendPathFrom) {
  18293. pathFromLine = pathFromLine + graphics.line(x, this.zeroY);
  18294. pathFromArea = pathFromArea + graphics.line(x, this.zeroY);
  18295. }
  18296. this.handleNullDataPoints(series, pointsPos, i, j, realIndex);
  18297. this._handleMarkersAndLabels({
  18298. pointsPos: pointsPos,
  18299. series: series,
  18300. x: x,
  18301. y: y,
  18302. prevY: prevY,
  18303. i: i,
  18304. j: j,
  18305. realIndex: realIndex
  18306. });
  18307. }
  18308. return {
  18309. yArrj: yArrj,
  18310. xArrj: xArrj,
  18311. pathFromArea: pathFromArea,
  18312. areaPaths: areaPaths,
  18313. pathFromLine: pathFromLine,
  18314. linePaths: linePaths
  18315. };
  18316. }
  18317. }, {
  18318. key: "_handleMarkersAndLabels",
  18319. value: function _handleMarkersAndLabels(_ref4) {
  18320. var pointsPos = _ref4.pointsPos,
  18321. series = _ref4.series,
  18322. x = _ref4.x,
  18323. y = _ref4.y,
  18324. prevY = _ref4.prevY,
  18325. i = _ref4.i,
  18326. j = _ref4.j,
  18327. realIndex = _ref4.realIndex;
  18328. var w = this.w;
  18329. var dataLabels = new DataLabels(this.ctx);
  18330. if (!this.pointsChart) {
  18331. if (w.globals.series[i].length > 1) {
  18332. this.elPointsMain.node.classList.add('apexcharts-element-hidden');
  18333. }
  18334. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1);
  18335. if (elPointsWrap !== null) {
  18336. this.elPointsMain.add(elPointsWrap);
  18337. }
  18338. } else {
  18339. // scatter / bubble chart points creation
  18340. this.scatter.draw(this.elSeries, j, {
  18341. realIndex: realIndex,
  18342. pointsPos: pointsPos,
  18343. zRatio: this.zRatio,
  18344. elParent: this.elPointsMain
  18345. });
  18346. }
  18347. var drawnLabels = dataLabels.drawDataLabel(pointsPos, realIndex, j + 1, null);
  18348. if (drawnLabels !== null) {
  18349. this.elDataLabelsWrap.add(drawnLabels);
  18350. }
  18351. }
  18352. }, {
  18353. key: "_createPaths",
  18354. value: function _createPaths(_ref5) {
  18355. var series = _ref5.series,
  18356. i = _ref5.i,
  18357. realIndex = _ref5.realIndex,
  18358. j = _ref5.j,
  18359. x = _ref5.x,
  18360. y = _ref5.y,
  18361. pX = _ref5.pX,
  18362. pY = _ref5.pY,
  18363. linePath = _ref5.linePath,
  18364. areaPath = _ref5.areaPath,
  18365. linePaths = _ref5.linePaths,
  18366. areaPaths = _ref5.areaPaths,
  18367. seriesIndex = _ref5.seriesIndex;
  18368. var w = this.w;
  18369. var graphics = new Graphics(this.ctx);
  18370. var curve = w.config.stroke.curve;
  18371. var areaBottomY = this.areaBottomY;
  18372. if (Array.isArray(w.config.stroke.curve)) {
  18373. if (Array.isArray(seriesIndex)) {
  18374. curve = w.config.stroke.curve[seriesIndex[i]];
  18375. } else {
  18376. curve = w.config.stroke.curve[i];
  18377. }
  18378. } // logic of smooth curve derived from chartist
  18379. // CREDITS: https://gionkunz.github.io/chartist-js/
  18380. if (curve === 'smooth') {
  18381. var length = (x - pX) * 0.35;
  18382. if (w.globals.hasNullValues) {
  18383. if (series[i][j] !== null) {
  18384. if (series[i][j + 1] !== null) {
  18385. linePath = graphics.move(pX, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y);
  18386. 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';
  18387. } else {
  18388. linePath = graphics.move(pX, pY);
  18389. areaPath = graphics.move(pX, pY) + 'z';
  18390. }
  18391. }
  18392. linePaths.push(linePath);
  18393. areaPaths.push(areaPath);
  18394. } else {
  18395. linePath = linePath + graphics.curve(pX + length, pY, x - length, y, x, y);
  18396. areaPath = areaPath + graphics.curve(pX + length, pY, x - length, y, x, y);
  18397. }
  18398. pX = x;
  18399. pY = y;
  18400. if (j === series[i].length - 2) {
  18401. // last loop, close path
  18402. areaPath = areaPath + graphics.curve(pX, pY, x, y, x, areaBottomY) + graphics.move(x, y) + 'z';
  18403. if (!w.globals.hasNullValues) {
  18404. linePaths.push(linePath);
  18405. areaPaths.push(areaPath);
  18406. }
  18407. }
  18408. } else {
  18409. if (series[i][j + 1] === null) {
  18410. linePath = linePath + graphics.move(x, y);
  18411. var numericOrCatX = w.globals.isXNumeric ? (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio : x - this.xDivision;
  18412. areaPath = areaPath + graphics.line(numericOrCatX, areaBottomY) + graphics.move(x, y) + 'z';
  18413. }
  18414. if (series[i][j] === null) {
  18415. linePath = linePath + graphics.move(x, y);
  18416. areaPath = areaPath + graphics.move(x, areaBottomY);
  18417. }
  18418. if (curve === 'stepline') {
  18419. linePath = linePath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  18420. areaPath = areaPath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  18421. } else if (curve === 'straight') {
  18422. linePath = linePath + graphics.line(x, y);
  18423. areaPath = areaPath + graphics.line(x, y);
  18424. }
  18425. if (j === series[i].length - 2) {
  18426. // last loop, close path
  18427. areaPath = areaPath + graphics.line(x, areaBottomY) + graphics.move(x, y) + 'z';
  18428. linePaths.push(linePath);
  18429. areaPaths.push(areaPath);
  18430. }
  18431. }
  18432. return {
  18433. linePaths: linePaths,
  18434. areaPaths: areaPaths,
  18435. pX: pX,
  18436. pY: pY,
  18437. linePath: linePath,
  18438. areaPath: areaPath
  18439. };
  18440. }
  18441. }, {
  18442. key: "handleNullDataPoints",
  18443. value: function handleNullDataPoints(series, pointsPos, i, j, realIndex) {
  18444. var w = this.w;
  18445. if (series[i][j] === null && w.config.markers.showNullDataPoints || series[i].length === 1) {
  18446. // fixes apexcharts.js#1282, #1252
  18447. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1, this.strokeWidth - w.config.markers.strokeWidth / 2, true);
  18448. if (elPointsWrap !== null) {
  18449. this.elPointsMain.add(elPointsWrap);
  18450. }
  18451. }
  18452. }
  18453. }]);
  18454. return Line;
  18455. }();
  18456. /**
  18457. * ApexCharts TimeScale Class for generating time ticks for x-axis.
  18458. *
  18459. * @module TimeScale
  18460. **/
  18461. var TimeScale = /*#__PURE__*/function () {
  18462. function TimeScale(ctx) {
  18463. _classCallCheck(this, TimeScale);
  18464. this.ctx = ctx;
  18465. this.w = ctx.w;
  18466. this.timeScaleArray = [];
  18467. this.utc = this.w.config.xaxis.labels.datetimeUTC;
  18468. }
  18469. _createClass(TimeScale, [{
  18470. key: "calculateTimeScaleTicks",
  18471. value: function calculateTimeScaleTicks(minX, maxX) {
  18472. var _this = this;
  18473. var w = this.w; // null check when no series to show
  18474. if (w.globals.allSeriesCollapsed) {
  18475. w.globals.labels = [];
  18476. w.globals.timescaleLabels = [];
  18477. return [];
  18478. }
  18479. var dt = new DateTime(this.ctx);
  18480. var daysDiff = (maxX - minX) / (1000 * 60 * 60 * 24);
  18481. this.determineInterval(daysDiff);
  18482. w.globals.disableZoomIn = false;
  18483. w.globals.disableZoomOut = false;
  18484. if (daysDiff < 0.005) {
  18485. w.globals.disableZoomIn = true;
  18486. } else if (daysDiff > 50000) {
  18487. w.globals.disableZoomOut = true;
  18488. }
  18489. var timeIntervals = dt.getTimeUnitsfromTimestamp(minX, maxX, this.utc);
  18490. var daysWidthOnXAxis = w.globals.gridWidth / daysDiff;
  18491. var hoursWidthOnXAxis = daysWidthOnXAxis / 24;
  18492. var minutesWidthOnXAxis = hoursWidthOnXAxis / 60;
  18493. var numberOfHours = Math.floor(daysDiff * 24);
  18494. var numberOfMinutes = Math.floor(daysDiff * 24 * 60);
  18495. var numberOfDays = Math.floor(daysDiff);
  18496. var numberOfMonths = Math.floor(daysDiff / 30);
  18497. var numberOfYears = Math.floor(daysDiff / 365);
  18498. var firstVal = {
  18499. minMinute: timeIntervals.minMinute,
  18500. minHour: timeIntervals.minHour,
  18501. minDate: timeIntervals.minDate,
  18502. minMonth: timeIntervals.minMonth,
  18503. minYear: timeIntervals.minYear
  18504. };
  18505. var currentMinute = firstVal.minMinute;
  18506. var currentHour = firstVal.minHour;
  18507. var currentMonthDate = firstVal.minDate;
  18508. var currentDate = firstVal.minDate;
  18509. var currentMonth = firstVal.minMonth;
  18510. var currentYear = firstVal.minYear;
  18511. var params = {
  18512. firstVal: firstVal,
  18513. currentMinute: currentMinute,
  18514. currentHour: currentHour,
  18515. currentMonthDate: currentMonthDate,
  18516. currentDate: currentDate,
  18517. currentMonth: currentMonth,
  18518. currentYear: currentYear,
  18519. daysWidthOnXAxis: daysWidthOnXAxis,
  18520. hoursWidthOnXAxis: hoursWidthOnXAxis,
  18521. minutesWidthOnXAxis: minutesWidthOnXAxis,
  18522. numberOfMinutes: numberOfMinutes,
  18523. numberOfHours: numberOfHours,
  18524. numberOfDays: numberOfDays,
  18525. numberOfMonths: numberOfMonths,
  18526. numberOfYears: numberOfYears
  18527. };
  18528. switch (this.tickInterval) {
  18529. case 'years':
  18530. {
  18531. this.generateYearScale(params);
  18532. break;
  18533. }
  18534. case 'months':
  18535. case 'half_year':
  18536. {
  18537. this.generateMonthScale(params);
  18538. break;
  18539. }
  18540. case 'months_days':
  18541. case 'months_fortnight':
  18542. case 'days':
  18543. case 'week_days':
  18544. {
  18545. this.generateDayScale(params);
  18546. break;
  18547. }
  18548. case 'hours':
  18549. {
  18550. this.generateHourScale(params);
  18551. break;
  18552. }
  18553. case 'minutes':
  18554. this.generateMinuteScale(params);
  18555. break;
  18556. } // first, we will adjust the month values index
  18557. // as in the upper function, it is starting from 0
  18558. // we will start them from 1
  18559. var adjustedMonthInTimeScaleArray = this.timeScaleArray.map(function (ts) {
  18560. var defaultReturn = {
  18561. position: ts.position,
  18562. unit: ts.unit,
  18563. year: ts.year,
  18564. day: ts.day ? ts.day : 1,
  18565. hour: ts.hour ? ts.hour : 0,
  18566. month: ts.month + 1
  18567. };
  18568. if (ts.unit === 'month') {
  18569. return _objectSpread2({}, defaultReturn, {
  18570. day: 1,
  18571. value: ts.value + 1
  18572. });
  18573. } else if (ts.unit === 'day' || ts.unit === 'hour') {
  18574. return _objectSpread2({}, defaultReturn, {
  18575. value: ts.value
  18576. });
  18577. } else if (ts.unit === 'minute') {
  18578. return _objectSpread2({}, defaultReturn, {
  18579. value: ts.value,
  18580. minute: ts.value
  18581. });
  18582. }
  18583. return ts;
  18584. });
  18585. var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts) {
  18586. var modulo = 1;
  18587. var ticks = Math.ceil(w.globals.gridWidth / 120);
  18588. var value = ts.value;
  18589. if (w.config.xaxis.tickAmount !== undefined) {
  18590. ticks = w.config.xaxis.tickAmount;
  18591. }
  18592. if (adjustedMonthInTimeScaleArray.length > ticks) {
  18593. modulo = Math.floor(adjustedMonthInTimeScaleArray.length / ticks);
  18594. }
  18595. var shouldNotSkipUnit = false; // there is a big change in unit i.e days to months
  18596. var shouldNotPrint = false; // should skip these values
  18597. switch (_this.tickInterval) {
  18598. case 'years':
  18599. // make years label denser
  18600. if (ts.unit === 'year') {
  18601. shouldNotSkipUnit = true;
  18602. }
  18603. break;
  18604. case 'half_year':
  18605. modulo = 7;
  18606. if (ts.unit === 'year') {
  18607. shouldNotSkipUnit = true;
  18608. }
  18609. break;
  18610. case 'months':
  18611. modulo = 1;
  18612. if (ts.unit === 'year') {
  18613. shouldNotSkipUnit = true;
  18614. }
  18615. break;
  18616. case 'months_fortnight':
  18617. modulo = 15;
  18618. if (ts.unit === 'year' || ts.unit === 'month') {
  18619. shouldNotSkipUnit = true;
  18620. }
  18621. if (value === 30) {
  18622. shouldNotPrint = true;
  18623. }
  18624. break;
  18625. case 'months_days':
  18626. modulo = 10;
  18627. if (ts.unit === 'month') {
  18628. shouldNotSkipUnit = true;
  18629. }
  18630. if (value === 30) {
  18631. shouldNotPrint = true;
  18632. }
  18633. break;
  18634. case 'week_days':
  18635. modulo = 8;
  18636. if (ts.unit === 'month') {
  18637. shouldNotSkipUnit = true;
  18638. }
  18639. break;
  18640. case 'days':
  18641. modulo = 1;
  18642. if (ts.unit === 'month') {
  18643. shouldNotSkipUnit = true;
  18644. }
  18645. break;
  18646. case 'hours':
  18647. if (ts.unit === 'day') {
  18648. shouldNotSkipUnit = true;
  18649. }
  18650. break;
  18651. case 'minutes':
  18652. if (value % 5 !== 0) {
  18653. shouldNotPrint = true;
  18654. }
  18655. break;
  18656. }
  18657. if (_this.tickInterval === 'minutes' || _this.tickInterval === 'hours') {
  18658. if (!shouldNotPrint) {
  18659. return true;
  18660. }
  18661. } else {
  18662. if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) {
  18663. return true;
  18664. }
  18665. }
  18666. });
  18667. return filteredTimeScale;
  18668. }
  18669. }, {
  18670. key: "recalcDimensionsBasedOnFormat",
  18671. value: function recalcDimensionsBasedOnFormat(filteredTimeScale, inverted) {
  18672. var w = this.w;
  18673. var reformattedTimescaleArray = this.formatDates(filteredTimeScale);
  18674. var removedOverlappingTS = this.removeOverlappingTS(reformattedTimescaleArray);
  18675. w.globals.timescaleLabels = removedOverlappingTS.slice(); // at this stage, we need to re-calculate coords of the grid as timeline labels may have altered the xaxis labels coords
  18676. // The reason we can't do this prior to this stage is because timeline labels depends on gridWidth, and as the ticks are calculated based on available gridWidth, there can be unknown number of ticks generated for different minX and maxX
  18677. // Dependency on Dimensions(), need to refactor correctly
  18678. // TODO - find an alternate way to avoid calling this Heavy method twice
  18679. var dimensions = new Dimensions(this.ctx);
  18680. dimensions.plotCoords();
  18681. }
  18682. }, {
  18683. key: "determineInterval",
  18684. value: function determineInterval(daysDiff) {
  18685. switch (true) {
  18686. case daysDiff > 1825:
  18687. // difference is more than 5 years
  18688. this.tickInterval = 'years';
  18689. break;
  18690. case daysDiff > 800 && daysDiff <= 1825:
  18691. this.tickInterval = 'half_year';
  18692. break;
  18693. case daysDiff > 180 && daysDiff <= 800:
  18694. this.tickInterval = 'months';
  18695. break;
  18696. case daysDiff > 90 && daysDiff <= 180:
  18697. this.tickInterval = 'months_fortnight';
  18698. break;
  18699. case daysDiff > 60 && daysDiff <= 90:
  18700. this.tickInterval = 'months_days';
  18701. break;
  18702. case daysDiff > 30 && daysDiff <= 60:
  18703. this.tickInterval = 'week_days';
  18704. break;
  18705. case daysDiff > 2 && daysDiff <= 30:
  18706. this.tickInterval = 'days';
  18707. break;
  18708. case daysDiff > 0.1 && daysDiff <= 2:
  18709. // less than 2 days
  18710. this.tickInterval = 'hours';
  18711. break;
  18712. case daysDiff < 0.1:
  18713. this.tickInterval = 'minutes';
  18714. break;
  18715. default:
  18716. this.tickInterval = 'days';
  18717. break;
  18718. }
  18719. }
  18720. }, {
  18721. key: "generateYearScale",
  18722. value: function generateYearScale(_ref) {
  18723. var firstVal = _ref.firstVal,
  18724. currentMonth = _ref.currentMonth,
  18725. currentYear = _ref.currentYear,
  18726. daysWidthOnXAxis = _ref.daysWidthOnXAxis,
  18727. numberOfYears = _ref.numberOfYears;
  18728. var firstTickValue = firstVal.minYear;
  18729. var firstTickPosition = 0;
  18730. var dt = new DateTime(this.ctx);
  18731. var unit = 'year';
  18732. if (firstVal.minDate > 1 && firstVal.minMonth > 0) {
  18733. var remainingDays = dt.determineRemainingDaysOfYear(firstVal.minYear, firstVal.minMonth, firstVal.minDate); // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  18734. var remainingDaysOfFirstYear = dt.determineDaysOfYear(firstVal.minYear) - remainingDays + 1; // calculate the first tick position
  18735. firstTickPosition = remainingDaysOfFirstYear * daysWidthOnXAxis;
  18736. firstTickValue = firstVal.minYear + 1; // push the first tick in the array
  18737. this.timeScaleArray.push({
  18738. position: firstTickPosition,
  18739. value: firstTickValue,
  18740. unit: unit,
  18741. year: firstTickValue,
  18742. month: Utils.monthMod(currentMonth + 1)
  18743. });
  18744. } else if (firstVal.minDate === 1 && firstVal.minMonth === 0) {
  18745. // push the first tick in the array
  18746. this.timeScaleArray.push({
  18747. position: firstTickPosition,
  18748. value: firstTickValue,
  18749. unit: unit,
  18750. year: currentYear,
  18751. month: Utils.monthMod(currentMonth + 1)
  18752. });
  18753. }
  18754. var year = firstTickValue;
  18755. var pos = firstTickPosition; // keep drawing rest of the ticks
  18756. for (var i = 0; i < numberOfYears; i++) {
  18757. year++;
  18758. pos = dt.determineDaysOfYear(year - 1) * daysWidthOnXAxis + pos;
  18759. this.timeScaleArray.push({
  18760. position: pos,
  18761. value: year,
  18762. unit: unit,
  18763. year: year,
  18764. month: 1
  18765. });
  18766. }
  18767. }
  18768. }, {
  18769. key: "generateMonthScale",
  18770. value: function generateMonthScale(_ref2) {
  18771. var firstVal = _ref2.firstVal,
  18772. currentMonthDate = _ref2.currentMonthDate,
  18773. currentMonth = _ref2.currentMonth,
  18774. currentYear = _ref2.currentYear,
  18775. daysWidthOnXAxis = _ref2.daysWidthOnXAxis,
  18776. numberOfMonths = _ref2.numberOfMonths;
  18777. var firstTickValue = currentMonth;
  18778. var firstTickPosition = 0;
  18779. var dt = new DateTime(this.ctx);
  18780. var unit = 'month';
  18781. var yrCounter = 0;
  18782. if (firstVal.minDate > 1) {
  18783. // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  18784. var remainingDaysOfFirstMonth = dt.determineDaysOfMonths(currentMonth + 1, firstVal.minYear) - currentMonthDate + 1; // calculate the first tick position
  18785. firstTickPosition = remainingDaysOfFirstMonth * daysWidthOnXAxis;
  18786. firstTickValue = Utils.monthMod(currentMonth + 1);
  18787. var year = currentYear + yrCounter;
  18788. var _month = Utils.monthMod(firstTickValue);
  18789. var value = firstTickValue; // it's Jan, so update the year
  18790. if (firstTickValue === 0) {
  18791. unit = 'year';
  18792. value = year;
  18793. _month = 1;
  18794. yrCounter += 1;
  18795. year = year + yrCounter;
  18796. } // push the first tick in the array
  18797. this.timeScaleArray.push({
  18798. position: firstTickPosition,
  18799. value: value,
  18800. unit: unit,
  18801. year: year,
  18802. month: _month
  18803. });
  18804. } else {
  18805. // push the first tick in the array
  18806. this.timeScaleArray.push({
  18807. position: firstTickPosition,
  18808. value: firstTickValue,
  18809. unit: unit,
  18810. year: currentYear,
  18811. month: Utils.monthMod(currentMonth)
  18812. });
  18813. }
  18814. var month = firstTickValue + 1;
  18815. var pos = firstTickPosition; // keep drawing rest of the ticks
  18816. for (var i = 0, j = 1; i < numberOfMonths; i++, j++) {
  18817. month = Utils.monthMod(month);
  18818. if (month === 0) {
  18819. unit = 'year';
  18820. yrCounter += 1;
  18821. } else {
  18822. unit = 'month';
  18823. }
  18824. var _year = this._getYear(currentYear, month, yrCounter);
  18825. pos = dt.determineDaysOfMonths(month, _year) * daysWidthOnXAxis + pos;
  18826. var monthVal = month === 0 ? _year : month;
  18827. this.timeScaleArray.push({
  18828. position: pos,
  18829. value: monthVal,
  18830. unit: unit,
  18831. year: _year,
  18832. month: month === 0 ? 1 : month
  18833. });
  18834. month++;
  18835. }
  18836. }
  18837. }, {
  18838. key: "generateDayScale",
  18839. value: function generateDayScale(_ref3) {
  18840. var firstVal = _ref3.firstVal,
  18841. currentMonth = _ref3.currentMonth,
  18842. currentYear = _ref3.currentYear,
  18843. hoursWidthOnXAxis = _ref3.hoursWidthOnXAxis,
  18844. numberOfDays = _ref3.numberOfDays;
  18845. var dt = new DateTime(this.ctx);
  18846. var unit = 'day';
  18847. var firstTickValue = firstVal.minDate + 1;
  18848. var date = firstTickValue;
  18849. var changeMonth = function changeMonth(dateVal, month, year) {
  18850. var monthdays = dt.determineDaysOfMonths(month + 1, year);
  18851. if (dateVal > monthdays) {
  18852. month = month + 1;
  18853. date = 1;
  18854. unit = 'month';
  18855. val = month;
  18856. return month;
  18857. }
  18858. return month;
  18859. };
  18860. var remainingHours = 24 - firstVal.minHour;
  18861. var yrCounter = 0; // calculate the first tick position
  18862. var firstTickPosition = remainingHours * hoursWidthOnXAxis;
  18863. var val = firstTickValue;
  18864. var month = changeMonth(date, currentMonth, currentYear);
  18865. if (firstVal.minHour === 0 && firstVal.minDate === 1) {
  18866. // the first value is the first day of month
  18867. firstTickPosition = 0;
  18868. val = Utils.monthMod(firstVal.minMonth);
  18869. unit = 'month';
  18870. date = firstVal.minDate;
  18871. numberOfDays++;
  18872. } // push the first tick in the array
  18873. this.timeScaleArray.push({
  18874. position: firstTickPosition,
  18875. value: val,
  18876. unit: unit,
  18877. year: this._getYear(currentYear, month, yrCounter),
  18878. month: Utils.monthMod(month),
  18879. day: date
  18880. });
  18881. var pos = firstTickPosition; // keep drawing rest of the ticks
  18882. for (var i = 0; i < numberOfDays; i++) {
  18883. date += 1;
  18884. unit = 'day';
  18885. month = changeMonth(date, month, this._getYear(currentYear, month, yrCounter));
  18886. var year = this._getYear(currentYear, month, yrCounter);
  18887. pos = 24 * hoursWidthOnXAxis + pos;
  18888. var value = date === 1 ? Utils.monthMod(month) : date;
  18889. this.timeScaleArray.push({
  18890. position: pos,
  18891. value: value,
  18892. unit: unit,
  18893. year: year,
  18894. month: Utils.monthMod(month),
  18895. day: value
  18896. });
  18897. }
  18898. }
  18899. }, {
  18900. key: "generateHourScale",
  18901. value: function generateHourScale(_ref4) {
  18902. var firstVal = _ref4.firstVal,
  18903. currentDate = _ref4.currentDate,
  18904. currentMonth = _ref4.currentMonth,
  18905. currentYear = _ref4.currentYear,
  18906. minutesWidthOnXAxis = _ref4.minutesWidthOnXAxis,
  18907. numberOfHours = _ref4.numberOfHours;
  18908. var dt = new DateTime(this.ctx);
  18909. var yrCounter = 0;
  18910. var unit = 'hour';
  18911. var changeDate = function changeDate(dateVal, month) {
  18912. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  18913. if (dateVal > monthdays) {
  18914. date = 1;
  18915. month = month + 1;
  18916. }
  18917. return {
  18918. month: month,
  18919. date: date
  18920. };
  18921. };
  18922. var changeMonth = function changeMonth(dateVal, month) {
  18923. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  18924. if (dateVal > monthdays) {
  18925. month = month + 1;
  18926. return month;
  18927. }
  18928. return month;
  18929. };
  18930. var remainingMins = 60 - firstVal.minMinute;
  18931. var firstTickPosition = remainingMins * minutesWidthOnXAxis;
  18932. var firstTickValue = firstVal.minHour + 1;
  18933. var hour = firstTickValue + 1;
  18934. if (remainingMins === 60) {
  18935. firstTickPosition = 0;
  18936. firstTickValue = firstVal.minHour;
  18937. hour = firstTickValue + 1;
  18938. }
  18939. var date = currentDate;
  18940. var month = changeMonth(date, currentMonth); // push the first tick in the array
  18941. this.timeScaleArray.push({
  18942. position: firstTickPosition,
  18943. value: firstTickValue,
  18944. unit: unit,
  18945. day: date,
  18946. hour: hour,
  18947. year: currentYear,
  18948. month: Utils.monthMod(month)
  18949. });
  18950. var pos = firstTickPosition; // keep drawing rest of the ticks
  18951. for (var i = 0; i < numberOfHours; i++) {
  18952. unit = 'hour';
  18953. if (hour >= 24) {
  18954. hour = 0;
  18955. date += 1;
  18956. unit = 'day';
  18957. var checkNextMonth = changeDate(date, month);
  18958. month = checkNextMonth.month;
  18959. month = changeMonth(date, month);
  18960. }
  18961. var year = this._getYear(currentYear, month, yrCounter);
  18962. pos = hour === 0 && i === 0 ? remainingMins * minutesWidthOnXAxis : 60 * minutesWidthOnXAxis + pos;
  18963. var val = hour === 0 ? date : hour;
  18964. this.timeScaleArray.push({
  18965. position: pos,
  18966. value: val,
  18967. unit: unit,
  18968. hour: hour,
  18969. day: date,
  18970. year: year,
  18971. month: Utils.monthMod(month)
  18972. });
  18973. hour++;
  18974. }
  18975. }
  18976. }, {
  18977. key: "generateMinuteScale",
  18978. value: function generateMinuteScale(_ref5) {
  18979. var firstVal = _ref5.firstVal,
  18980. currentMinute = _ref5.currentMinute,
  18981. currentHour = _ref5.currentHour,
  18982. currentDate = _ref5.currentDate,
  18983. currentMonth = _ref5.currentMonth,
  18984. currentYear = _ref5.currentYear,
  18985. minutesWidthOnXAxis = _ref5.minutesWidthOnXAxis,
  18986. numberOfMinutes = _ref5.numberOfMinutes;
  18987. var yrCounter = 0;
  18988. var unit = 'minute';
  18989. var remainingMins = currentMinute - firstVal.minMinute;
  18990. var firstTickPosition = minutesWidthOnXAxis - remainingMins;
  18991. var firstTickValue = firstVal.minMinute + 1;
  18992. var minute = firstTickValue + 1;
  18993. var date = currentDate;
  18994. var month = currentMonth;
  18995. var year = currentYear;
  18996. var hour = currentHour; // push the first tick in the array
  18997. this.timeScaleArray.push({
  18998. position: firstTickPosition,
  18999. value: firstTickValue,
  19000. unit: unit,
  19001. day: date,
  19002. hour: hour,
  19003. minute: minute,
  19004. year: year,
  19005. month: Utils.monthMod(month)
  19006. });
  19007. var pos = firstTickPosition; // keep drawing rest of the ticks
  19008. for (var i = 0; i < numberOfMinutes; i++) {
  19009. if (minute >= 60) {
  19010. minute = 0;
  19011. hour += 1;
  19012. if (hour === 24) {
  19013. hour = 0;
  19014. }
  19015. }
  19016. pos = minutesWidthOnXAxis + pos;
  19017. this.timeScaleArray.push({
  19018. position: pos,
  19019. value: minute,
  19020. unit: unit,
  19021. hour: hour,
  19022. minute: minute,
  19023. day: date,
  19024. year: this._getYear(currentYear, month, yrCounter),
  19025. month: Utils.monthMod(month)
  19026. });
  19027. minute++;
  19028. }
  19029. }
  19030. }, {
  19031. key: "createRawDateString",
  19032. value: function createRawDateString(ts, value) {
  19033. var raw = ts.year;
  19034. raw += '-' + ('0' + ts.month.toString()).slice(-2); // unit is day
  19035. if (ts.unit === 'day') {
  19036. raw += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01';
  19037. } else {
  19038. raw += '-' + ('0' + (ts.day ? ts.day : '1')).slice(-2);
  19039. } // unit is hour
  19040. if (ts.unit === 'hour') {
  19041. raw += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) : 'T00';
  19042. } else {
  19043. raw += 'T' + ('0' + (ts.hour ? ts.hour : '0')).slice(-2);
  19044. } // unit is minute
  19045. raw += ts.unit === 'minute' ? ':' + ('0' + value).slice(-2) + ':00' : ':00:00';
  19046. if (this.utc) {
  19047. raw += '.000Z';
  19048. }
  19049. return raw;
  19050. }
  19051. }, {
  19052. key: "formatDates",
  19053. value: function formatDates(filteredTimeScale) {
  19054. var _this2 = this;
  19055. var w = this.w;
  19056. var reformattedTimescaleArray = filteredTimeScale.map(function (ts) {
  19057. var value = ts.value.toString();
  19058. var dt = new DateTime(_this2.ctx);
  19059. var raw = _this2.createRawDateString(ts, value);
  19060. var dateToFormat = dt.getDate(raw);
  19061. if (w.config.xaxis.labels.format === undefined) {
  19062. var customFormat = 'dd MMM';
  19063. var dtFormatter = w.config.xaxis.labels.datetimeFormatter;
  19064. if (ts.unit === 'year') customFormat = dtFormatter.year;
  19065. if (ts.unit === 'month') customFormat = dtFormatter.month;
  19066. if (ts.unit === 'day') customFormat = dtFormatter.day;
  19067. if (ts.unit === 'hour') customFormat = dtFormatter.hour;
  19068. if (ts.unit === 'minute') customFormat = dtFormatter.minute;
  19069. value = dt.formatDate(dateToFormat, customFormat);
  19070. } else {
  19071. value = dt.formatDate(dateToFormat, w.config.xaxis.labels.format);
  19072. }
  19073. return {
  19074. dateString: raw,
  19075. position: ts.position,
  19076. value: value,
  19077. unit: ts.unit,
  19078. year: ts.year,
  19079. month: ts.month
  19080. };
  19081. });
  19082. return reformattedTimescaleArray;
  19083. }
  19084. }, {
  19085. key: "removeOverlappingTS",
  19086. value: function removeOverlappingTS(arr) {
  19087. var _this3 = this;
  19088. var graphics = new Graphics(this.ctx);
  19089. var equalLabelLengthFlag = false; // These labels got same length?
  19090. var constantLabelWidth; // If true, what is the constant length to use
  19091. if (arr.length > 0 && // check arr length
  19092. arr[0].value && // check arr[0] contains value
  19093. arr.every(function (lb) {
  19094. return lb.value.length === arr[0].value.length;
  19095. }) // check every arr label value is the same as the first one
  19096. ) {
  19097. equalLabelLengthFlag = true; // These labels got same length
  19098. constantLabelWidth = graphics.getTextRects(arr[0].value).width; // The constant label width to use
  19099. }
  19100. var lastDrawnIndex = 0;
  19101. var filteredArray = arr.map(function (item, index) {
  19102. if (index > 0 && _this3.w.config.xaxis.labels.hideOverlappingLabels) {
  19103. var prevLabelWidth = !equalLabelLengthFlag // if vary in label length
  19104. ? graphics.getTextRects(arr[lastDrawnIndex].value).width // get individual length
  19105. : constantLabelWidth; // else: use constant length
  19106. var prevPos = arr[lastDrawnIndex].position;
  19107. var pos = item.position;
  19108. if (pos > prevPos + prevLabelWidth + 10) {
  19109. lastDrawnIndex = index;
  19110. return item;
  19111. } else {
  19112. return null;
  19113. }
  19114. } else {
  19115. return item;
  19116. }
  19117. });
  19118. filteredArray = filteredArray.filter(function (f) {
  19119. return f !== null;
  19120. });
  19121. return filteredArray;
  19122. }
  19123. }, {
  19124. key: "_getYear",
  19125. value: function _getYear(currentYear, month, yrCounter) {
  19126. return currentYear + Math.floor(month / 12) + yrCounter;
  19127. }
  19128. }]);
  19129. return TimeScale;
  19130. }();
  19131. /**
  19132. * ApexCharts Core Class responsible for major calculations and creating elements.
  19133. *
  19134. * @module Core
  19135. **/
  19136. var Core = /*#__PURE__*/function () {
  19137. function Core(el, ctx) {
  19138. _classCallCheck(this, Core);
  19139. this.ctx = ctx;
  19140. this.w = ctx.w;
  19141. this.el = el;
  19142. } // get data and store into appropriate vars
  19143. _createClass(Core, [{
  19144. key: "setupElements",
  19145. value: function setupElements() {
  19146. var gl = this.w.globals;
  19147. var cnf = this.w.config; // const graphics = new Graphics(this.ctx)
  19148. var ct = cnf.chart.type;
  19149. var axisChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble', 'radar', 'heatmap'];
  19150. var xyChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble'];
  19151. gl.axisCharts = axisChartsArrTypes.indexOf(ct) > -1;
  19152. gl.xyCharts = xyChartsArrTypes.indexOf(ct) > -1;
  19153. gl.isBarHorizontal = (cnf.chart.type === 'bar' || cnf.chart.type === 'rangeBar') && cnf.plotOptions.bar.horizontal;
  19154. gl.chartClass = '.apexcharts' + gl.cuid;
  19155. gl.dom.baseEl = this.el;
  19156. gl.dom.elWrap = document.createElement('div');
  19157. Graphics.setAttrs(gl.dom.elWrap, {
  19158. id: gl.chartClass.substring(1),
  19159. class: 'apexcharts-canvas ' + gl.chartClass.substring(1)
  19160. });
  19161. this.el.appendChild(gl.dom.elWrap);
  19162. gl.dom.Paper = new window.SVG.Doc(gl.dom.elWrap);
  19163. gl.dom.Paper.attr({
  19164. class: 'apexcharts-svg',
  19165. 'xmlns:data': 'ApexChartsNS',
  19166. transform: "translate(".concat(cnf.chart.offsetX, ", ").concat(cnf.chart.offsetY, ")")
  19167. });
  19168. gl.dom.Paper.node.style.background = cnf.chart.background;
  19169. this.setSVGDimensions();
  19170. gl.dom.elGraphical = gl.dom.Paper.group().attr({
  19171. class: 'apexcharts-inner apexcharts-graphical'
  19172. });
  19173. gl.dom.elAnnotations = gl.dom.Paper.group().attr({
  19174. class: 'apexcharts-annotations'
  19175. });
  19176. gl.dom.elDefs = gl.dom.Paper.defs();
  19177. gl.dom.elLegendWrap = document.createElement('div');
  19178. gl.dom.elLegendWrap.classList.add('apexcharts-legend');
  19179. gl.dom.elWrap.appendChild(gl.dom.elLegendWrap);
  19180. gl.dom.Paper.add(gl.dom.elGraphical);
  19181. gl.dom.elGraphical.add(gl.dom.elDefs);
  19182. }
  19183. }, {
  19184. key: "plotChartType",
  19185. value: function plotChartType(ser, xyRatios) {
  19186. var w = this.w;
  19187. var cnf = w.config;
  19188. var gl = w.globals;
  19189. var lineSeries = {
  19190. series: [],
  19191. i: []
  19192. };
  19193. var areaSeries = {
  19194. series: [],
  19195. i: []
  19196. };
  19197. var scatterSeries = {
  19198. series: [],
  19199. i: []
  19200. };
  19201. var bubbleSeries = {
  19202. series: [],
  19203. i: []
  19204. };
  19205. var columnSeries = {
  19206. series: [],
  19207. i: []
  19208. };
  19209. var candlestickSeries = {
  19210. series: [],
  19211. i: []
  19212. };
  19213. gl.series.map(function (series, st) {
  19214. // if user has specified a particular type for particular series
  19215. if (typeof ser[st].type !== 'undefined') {
  19216. if (ser[st].type === 'column' || ser[st].type === 'bar') {
  19217. if (gl.series.length > 1 && cnf.plotOptions.bar.horizontal) {
  19218. // horizontal bars not supported in mixed charts, hence show a warning
  19219. console.warn('Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`');
  19220. }
  19221. columnSeries.series.push(series);
  19222. columnSeries.i.push(st);
  19223. w.globals.columnSeries = columnSeries.series;
  19224. } else if (ser[st].type === 'area') {
  19225. areaSeries.series.push(series);
  19226. areaSeries.i.push(st);
  19227. } else if (ser[st].type === 'line') {
  19228. lineSeries.series.push(series);
  19229. lineSeries.i.push(st);
  19230. } else if (ser[st].type === 'scatter') {
  19231. scatterSeries.series.push(series);
  19232. scatterSeries.i.push(st);
  19233. } else if (ser[st].type === 'bubble') {
  19234. bubbleSeries.series.push(series);
  19235. bubbleSeries.i.push(st);
  19236. } else if (ser[st].type === 'candlestick') {
  19237. candlestickSeries.series.push(series);
  19238. candlestickSeries.i.push(st);
  19239. } else {
  19240. // user has specified type, but it is not valid (other than line/area/column)
  19241. console.warn('You have specified an unrecognized chart type. Available types for this propery are line/area/column/bar/scatter/bubble');
  19242. }
  19243. gl.comboCharts = true;
  19244. } else {
  19245. lineSeries.series.push(series);
  19246. lineSeries.i.push(st);
  19247. }
  19248. });
  19249. var line = new Line(this.ctx, xyRatios);
  19250. var candlestick = new CandleStick(this.ctx, xyRatios);
  19251. var pie = new Pie(this.ctx);
  19252. var radialBar = new Radial(this.ctx);
  19253. var rangeBar = new RangeBar(this.ctx, xyRatios);
  19254. var radar = new Radar(this.ctx);
  19255. var elGraph = [];
  19256. if (gl.comboCharts) {
  19257. if (areaSeries.series.length > 0) {
  19258. elGraph.push(line.draw(areaSeries.series, 'area', areaSeries.i));
  19259. }
  19260. if (columnSeries.series.length > 0) {
  19261. if (w.config.chart.stacked) {
  19262. var barStacked = new BarStacked(this.ctx, xyRatios);
  19263. elGraph.push(barStacked.draw(columnSeries.series, columnSeries.i));
  19264. } else {
  19265. var bar = new Bar(this.ctx, xyRatios);
  19266. elGraph.push(bar.draw(columnSeries.series, columnSeries.i));
  19267. }
  19268. }
  19269. if (lineSeries.series.length > 0) {
  19270. elGraph.push(line.draw(lineSeries.series, 'line', lineSeries.i));
  19271. }
  19272. if (candlestickSeries.series.length > 0) {
  19273. elGraph.push(candlestick.draw(candlestickSeries.series, candlestickSeries.i));
  19274. }
  19275. if (scatterSeries.series.length > 0) {
  19276. var scatterLine = new Line(this.ctx, xyRatios, true);
  19277. elGraph.push(scatterLine.draw(scatterSeries.series, 'scatter', scatterSeries.i));
  19278. }
  19279. if (bubbleSeries.series.length > 0) {
  19280. var bubbleLine = new Line(this.ctx, xyRatios, true);
  19281. elGraph.push(bubbleLine.draw(bubbleSeries.series, 'bubble', bubbleSeries.i));
  19282. }
  19283. } else {
  19284. switch (cnf.chart.type) {
  19285. case 'line':
  19286. elGraph = line.draw(gl.series, 'line');
  19287. break;
  19288. case 'area':
  19289. elGraph = line.draw(gl.series, 'area');
  19290. break;
  19291. case 'bar':
  19292. if (cnf.chart.stacked) {
  19293. var _barStacked = new BarStacked(this.ctx, xyRatios);
  19294. elGraph = _barStacked.draw(gl.series);
  19295. } else {
  19296. var _bar = new Bar(this.ctx, xyRatios);
  19297. elGraph = _bar.draw(gl.series);
  19298. }
  19299. break;
  19300. case 'candlestick':
  19301. var candleStick = new CandleStick(this.ctx, xyRatios);
  19302. elGraph = candleStick.draw(gl.series);
  19303. break;
  19304. case 'rangeBar':
  19305. elGraph = rangeBar.draw(gl.series);
  19306. break;
  19307. case 'heatmap':
  19308. var heatmap = new HeatMap(this.ctx, xyRatios);
  19309. elGraph = heatmap.draw(gl.series);
  19310. break;
  19311. case 'pie':
  19312. case 'donut':
  19313. elGraph = pie.draw(gl.series);
  19314. break;
  19315. case 'radialBar':
  19316. elGraph = radialBar.draw(gl.series);
  19317. break;
  19318. case 'radar':
  19319. elGraph = radar.draw(gl.series);
  19320. break;
  19321. default:
  19322. elGraph = line.draw(gl.series);
  19323. }
  19324. }
  19325. return elGraph;
  19326. }
  19327. }, {
  19328. key: "setSVGDimensions",
  19329. value: function setSVGDimensions() {
  19330. var gl = this.w.globals;
  19331. var cnf = this.w.config;
  19332. gl.svgWidth = cnf.chart.width;
  19333. gl.svgHeight = cnf.chart.height;
  19334. var elDim = Utils.getDimensions(this.el);
  19335. var widthUnit = cnf.chart.width.toString().split(/[0-9]+/g).pop();
  19336. if (widthUnit === '%') {
  19337. if (Utils.isNumber(elDim[0])) {
  19338. if (elDim[0].width === 0) {
  19339. elDim = Utils.getDimensions(this.el.parentNode);
  19340. }
  19341. gl.svgWidth = elDim[0] * parseInt(cnf.chart.width, 10) / 100;
  19342. }
  19343. } else if (widthUnit === 'px' || widthUnit === '') {
  19344. gl.svgWidth = parseInt(cnf.chart.width, 10);
  19345. }
  19346. if (gl.svgHeight !== 'auto' && gl.svgHeight !== '') {
  19347. var heightUnit = cnf.chart.height.toString().split(/[0-9]+/g).pop();
  19348. if (heightUnit === '%') {
  19349. var elParentDim = Utils.getDimensions(this.el.parentNode);
  19350. gl.svgHeight = elParentDim[1] * parseInt(cnf.chart.height, 10) / 100;
  19351. } else {
  19352. gl.svgHeight = parseInt(cnf.chart.height, 10);
  19353. }
  19354. } else {
  19355. if (gl.axisCharts) {
  19356. gl.svgHeight = gl.svgWidth / 1.61;
  19357. } else {
  19358. gl.svgHeight = gl.svgWidth / 1.2;
  19359. }
  19360. }
  19361. if (gl.svgWidth < 0) gl.svgWidth = 0;
  19362. if (gl.svgHeight < 0) gl.svgHeight = 0;
  19363. Graphics.setAttrs(gl.dom.Paper.node, {
  19364. width: gl.svgWidth,
  19365. height: gl.svgHeight
  19366. }); // gl.dom.Paper.node.parentNode.parentNode.style.minWidth = gl.svgWidth + "px";
  19367. var offsetY = cnf.chart.sparkline.enabled ? 0 : gl.axisCharts ? cnf.chart.parentHeightOffset : 0;
  19368. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = gl.svgHeight + offsetY + 'px';
  19369. gl.dom.elWrap.style.width = gl.svgWidth + 'px';
  19370. gl.dom.elWrap.style.height = gl.svgHeight + 'px';
  19371. }
  19372. }, {
  19373. key: "shiftGraphPosition",
  19374. value: function shiftGraphPosition() {
  19375. var gl = this.w.globals;
  19376. var tY = gl.translateY;
  19377. var tX = gl.translateX;
  19378. var scalingAttrs = {
  19379. transform: 'translate(' + tX + ', ' + tY + ')'
  19380. };
  19381. Graphics.setAttrs(gl.dom.elGraphical.node, scalingAttrs);
  19382. gl.x2SpaceAvailable = gl.svgWidth - gl.dom.elGraphical.x() - gl.gridWidth;
  19383. } // To prevent extra spacings in the bottom of the chart, we need to recalculate the height for pie/donut/radialbar charts
  19384. }, {
  19385. key: "resizeNonAxisCharts",
  19386. value: function resizeNonAxisCharts() {
  19387. var w = this.w;
  19388. var gl = w.globals;
  19389. var legendHeight = 0;
  19390. var offY = w.config.chart.sparkline.enabled ? 1 : 15;
  19391. offY = offY + w.config.grid.padding.bottom;
  19392. if ((w.config.legend.position === 'top' || w.config.legend.position === 'bottom') && w.config.legend.show && !w.config.legend.floating) {
  19393. legendHeight = new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10;
  19394. }
  19395. var radialEl = w.globals.dom.baseEl.querySelector('.apexcharts-radialbar');
  19396. var chartInnerDimensions = w.globals.radialSize * 2.05;
  19397. if (radialEl && !w.config.chart.sparkline.enabled) {
  19398. var elRadialRect = Utils.getBoundingClientRect(radialEl);
  19399. chartInnerDimensions = elRadialRect.bottom;
  19400. var maxHeight = elRadialRect.bottom - elRadialRect.top;
  19401. chartInnerDimensions = Math.max(w.globals.radialSize * 2.05, maxHeight);
  19402. }
  19403. var newHeight = chartInnerDimensions + gl.translateY + legendHeight + offY;
  19404. if (gl.dom.elLegendForeign) {
  19405. gl.dom.elLegendForeign.setAttribute('height', newHeight);
  19406. }
  19407. gl.dom.elWrap.style.height = newHeight + 'px';
  19408. Graphics.setAttrs(gl.dom.Paper.node, {
  19409. height: newHeight
  19410. });
  19411. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = newHeight + 'px';
  19412. }
  19413. /*
  19414. ** All the calculations for setting range in charts will be done here
  19415. */
  19416. }, {
  19417. key: "coreCalculations",
  19418. value: function coreCalculations() {
  19419. var range = new Range$1(this.ctx);
  19420. range.init();
  19421. }
  19422. }, {
  19423. key: "resetGlobals",
  19424. value: function resetGlobals() {
  19425. var _this = this;
  19426. var resetxyValues = function resetxyValues() {
  19427. return _this.w.config.series.map(function (s) {
  19428. return [];
  19429. });
  19430. };
  19431. var globalObj = new Globals();
  19432. var gl = this.w.globals;
  19433. globalObj.initGlobalVars(gl);
  19434. gl.seriesXvalues = resetxyValues();
  19435. gl.seriesYvalues = resetxyValues();
  19436. }
  19437. }, {
  19438. key: "isMultipleY",
  19439. value: function isMultipleY() {
  19440. // user has supplied an array in yaxis property. So, turn on multipleYAxis flag
  19441. if (this.w.config.yaxis.constructor === Array && this.w.config.yaxis.length > 1) {
  19442. this.w.globals.isMultipleYAxis = true;
  19443. return true;
  19444. }
  19445. }
  19446. }, {
  19447. key: "xySettings",
  19448. value: function xySettings() {
  19449. var xyRatios = null;
  19450. var w = this.w;
  19451. if (w.globals.axisCharts) {
  19452. if (w.config.xaxis.crosshairs.position === 'back') {
  19453. var crosshairs = new Crosshairs(this.ctx);
  19454. crosshairs.drawXCrosshairs();
  19455. }
  19456. if (w.config.yaxis[0].crosshairs.position === 'back') {
  19457. var _crosshairs = new Crosshairs(this.ctx);
  19458. _crosshairs.drawYCrosshairs();
  19459. }
  19460. if (w.config.xaxis.type === 'datetime' && w.config.xaxis.labels.formatter === undefined) {
  19461. var ts = new TimeScale(this.ctx);
  19462. var formattedTimeScale = [];
  19463. if (isFinite(w.globals.minX) && isFinite(w.globals.maxX) && !w.globals.isBarHorizontal) {
  19464. formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minX, w.globals.maxX);
  19465. } else if (w.globals.isBarHorizontal) {
  19466. formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minY, w.globals.maxY);
  19467. }
  19468. ts.recalcDimensionsBasedOnFormat(formattedTimeScale);
  19469. }
  19470. var coreUtils = new CoreUtils(this.ctx);
  19471. xyRatios = coreUtils.getCalculatedRatios();
  19472. }
  19473. return xyRatios;
  19474. }
  19475. }, {
  19476. key: "setupBrushHandler",
  19477. value: function setupBrushHandler() {
  19478. var _this2 = this;
  19479. var w = this.w; // only for brush charts
  19480. if (!w.config.chart.brush.enabled) {
  19481. return;
  19482. } // if user has not defined a custom function for selection - we handle the brush chart
  19483. // otherwise we leave it to the user to define the functionality for selection
  19484. if (typeof w.config.chart.events.selection !== 'function') {
  19485. var targets = w.config.chart.brush.targets || [w.config.chart.brush.target]; // retro compatibility with single target option
  19486. targets.forEach(function (target) {
  19487. var targetChart = ApexCharts.getChartByID(target);
  19488. targetChart.w.globals.brushSource = _this2.ctx;
  19489. var updateSourceChart = function updateSourceChart() {
  19490. _this2.ctx.updateHelpers._updateOptions({
  19491. chart: {
  19492. selection: {
  19493. xaxis: {
  19494. min: targetChart.w.globals.minX,
  19495. max: targetChart.w.globals.maxX
  19496. }
  19497. }
  19498. }
  19499. }, false, false);
  19500. };
  19501. if (typeof targetChart.w.config.chart.events.zoomed !== 'function') {
  19502. targetChart.w.config.chart.events.zoomed = function () {
  19503. updateSourceChart();
  19504. };
  19505. }
  19506. if (typeof targetChart.w.config.chart.events.scrolled !== 'function') {
  19507. targetChart.w.config.chart.events.scrolled = function () {
  19508. updateSourceChart();
  19509. };
  19510. }
  19511. });
  19512. w.config.chart.events.selection = function (chart, e) {
  19513. targets.forEach(function (target) {
  19514. var targetChart = ApexCharts.getChartByID(target);
  19515. var yaxis = Utils.clone(w.config.yaxis);
  19516. if (w.config.chart.brush.autoScaleYaxis && targetChart.w.globals.series.length === 1) {
  19517. var scale = new Range(targetChart);
  19518. yaxis = scale.autoScaleY(targetChart, yaxis, e);
  19519. }
  19520. targetChart.ctx.updateHelpers._updateOptions({
  19521. xaxis: {
  19522. min: e.xaxis.min,
  19523. max: e.xaxis.max
  19524. },
  19525. yaxis: _objectSpread2({}, targetChart.w.config.yaxis[0], {
  19526. min: yaxis[0].min,
  19527. max: yaxis[0].max
  19528. })
  19529. }, false, false, false, false);
  19530. });
  19531. };
  19532. }
  19533. }
  19534. }]);
  19535. return Core;
  19536. }();
  19537. var UpdateHelpers = /*#__PURE__*/function () {
  19538. function UpdateHelpers(ctx) {
  19539. _classCallCheck(this, UpdateHelpers);
  19540. this.ctx = ctx;
  19541. this.w = ctx.w;
  19542. }
  19543. /**
  19544. * private method to update Options.
  19545. *
  19546. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  19547. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  19548. * @param {boolean} animate - should animate or not on updating Options
  19549. * @param {boolean} overwriteInitialConfig - should update the initial config or not
  19550. */
  19551. _createClass(UpdateHelpers, [{
  19552. key: "_updateOptions",
  19553. value: function _updateOptions(options) {
  19554. var _this = this;
  19555. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19556. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  19557. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  19558. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  19559. var charts = [this.ctx];
  19560. if (updateSyncedCharts) {
  19561. charts = this.ctx.getSyncedCharts();
  19562. }
  19563. if (this.ctx.w.globals.isExecCalled) {
  19564. // If the user called exec method, we don't want to get grouped charts as user specifically provided a chartID to update
  19565. charts = [this.ctx];
  19566. this.ctx.w.globals.isExecCalled = false;
  19567. }
  19568. charts.forEach(function (ch) {
  19569. var w = ch.w;
  19570. w.globals.shouldAnimate = animate;
  19571. if (!redraw) {
  19572. w.globals.resized = true;
  19573. w.globals.dataChanged = true;
  19574. if (animate) {
  19575. ch.series.getPreviousPaths();
  19576. }
  19577. }
  19578. if (options && _typeof(options) === 'object') {
  19579. ch.config = new Config(options);
  19580. options = CoreUtils.extendArrayProps(ch.config, options); // fixes #914, #623
  19581. if (ch.w.globals.chartID !== _this.ctx.w.globals.chartID) {
  19582. // don't overwrite series of synchronized charts
  19583. delete options.series;
  19584. }
  19585. w.config = Utils.extend(w.config, options);
  19586. if (overwriteInitialConfig) {
  19587. // we need to forget the lastXAxis and lastYAxis is user forcefully overwriteInitialConfig. If we do not do this, and next time when user zooms the chart after setting yaxis.min/max or xaxis.min/max - the stored lastXAxis will never allow the chart to use the updated min/max by user.
  19588. w.globals.lastXAxis = [];
  19589. w.globals.lastYAxis = []; // After forgetting lastAxes, we need to restore the new config in initialConfig/initialSeries
  19590. w.globals.initialConfig = Utils.extend({}, w.config);
  19591. w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
  19592. }
  19593. }
  19594. return ch.update(options);
  19595. });
  19596. }
  19597. /**
  19598. * Private method to update Series.
  19599. *
  19600. * @param {array} series - New series which will override the existing
  19601. */
  19602. }, {
  19603. key: "_updateSeries",
  19604. value: function _updateSeries(newSeries, animate) {
  19605. var _this2 = this;
  19606. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19607. var w = this.w;
  19608. w.globals.shouldAnimate = animate;
  19609. w.globals.dataChanged = true;
  19610. if (animate) {
  19611. this.ctx.series.getPreviousPaths();
  19612. }
  19613. var existingSeries; // axis charts
  19614. if (w.globals.axisCharts) {
  19615. existingSeries = newSeries.map(function (s, i) {
  19616. return _this2._extendSeries(s, i);
  19617. });
  19618. if (existingSeries.length === 0) {
  19619. existingSeries = [{
  19620. data: []
  19621. }];
  19622. }
  19623. w.config.series = existingSeries;
  19624. } else {
  19625. // non-axis chart (pie/radialbar)
  19626. w.config.series = newSeries.slice();
  19627. }
  19628. if (overwriteInitialSeries) {
  19629. w.globals.initialConfig.series = JSON.parse(JSON.stringify(w.config.series));
  19630. w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
  19631. }
  19632. return this.ctx.update();
  19633. }
  19634. }, {
  19635. key: "_extendSeries",
  19636. value: function _extendSeries(s, i) {
  19637. var w = this.w;
  19638. return _objectSpread2({}, w.config.series[i], {
  19639. name: s.name ? s.name : w.config.series[i] && w.config.series[i].name,
  19640. type: s.type ? s.type : w.config.series[i] && w.config.series[i].type,
  19641. data: s.data ? s.data : w.config.series[i] && w.config.series[i].data
  19642. });
  19643. }
  19644. }, {
  19645. key: "toggleDataPointSelection",
  19646. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  19647. var w = this.w;
  19648. var elPath = null;
  19649. var parent = ".apexcharts-series[data\\:realIndex='".concat(seriesIndex, "']");
  19650. if (w.globals.axisCharts) {
  19651. 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];
  19652. } else {
  19653. // dataPointIndex will be undefined here, hence using seriesIndex
  19654. if (typeof dataPointIndex === 'undefined') {
  19655. elPath = w.globals.dom.Paper.select("".concat(parent, " path[j='").concat(seriesIndex, "']")).members[0];
  19656. if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') {
  19657. var pie = new Pie(this.ctx);
  19658. pie.pieClicked(seriesIndex);
  19659. }
  19660. }
  19661. }
  19662. if (elPath) {
  19663. var graphics = new Graphics(this.ctx);
  19664. graphics.pathMouseDown(elPath, null);
  19665. } else {
  19666. console.warn('toggleDataPointSelection: Element not found');
  19667. return null;
  19668. }
  19669. return elPath.node ? elPath.node : null;
  19670. }
  19671. }, {
  19672. key: "forceXAxisUpdate",
  19673. value: function forceXAxisUpdate(options) {
  19674. var w = this.w;
  19675. var minmax = ['min', 'max'];
  19676. minmax.forEach(function (a) {
  19677. if (typeof options.xaxis[a] !== 'undefined') {
  19678. w.config.xaxis[a] = options.xaxis[a];
  19679. w.globals.lastXAxis[a] = options.xaxis[a];
  19680. }
  19681. });
  19682. if (options.xaxis.categories && options.xaxis.categories.length) {
  19683. w.config.xaxis.categories = options.xaxis.categories;
  19684. }
  19685. if (w.config.xaxis.convertedCatToNumeric) {
  19686. var defaults = new Defaults(options);
  19687. options = defaults.convertCatToNumericXaxis(options, this.ctx);
  19688. }
  19689. return options;
  19690. }
  19691. }, {
  19692. key: "forceYAxisUpdate",
  19693. value: function forceYAxisUpdate(options) {
  19694. var w = this.w;
  19695. if (w.config.chart.stacked && w.config.chart.stackType === '100%') {
  19696. if (Array.isArray(options.yaxis)) {
  19697. options.yaxis.forEach(function (yaxe, index) {
  19698. options.yaxis[index].min = 0;
  19699. options.yaxis[index].max = 100;
  19700. });
  19701. } else {
  19702. options.yaxis.min = 0;
  19703. options.yaxis.max = 100;
  19704. }
  19705. }
  19706. return options;
  19707. }
  19708. /**
  19709. * This function reverts the yaxis and xaxis min/max values to what it was when the chart was defined.
  19710. * This function fixes an important bug where a user might load a new series after zooming in/out of previous series which resulted in wrong min/max
  19711. * Also, this should never be called internally on zoom/pan - the reset should only happen when user calls the updateSeries() function externally
  19712. */
  19713. }, {
  19714. key: "revertDefaultAxisMinMax",
  19715. value: function revertDefaultAxisMinMax() {
  19716. var _this3 = this;
  19717. var w = this.w;
  19718. w.config.xaxis.min = w.globals.lastXAxis.min;
  19719. w.config.xaxis.max = w.globals.lastXAxis.max;
  19720. w.config.yaxis.map(function (yaxe, index) {
  19721. if (w.globals.zoomed) {
  19722. // user has zoomed, check the last yaxis
  19723. if (typeof w.globals.lastYAxis[index] !== 'undefined') {
  19724. yaxe.min = w.globals.lastYAxis[index].min;
  19725. yaxe.max = w.globals.lastYAxis[index].max;
  19726. }
  19727. } else {
  19728. // user hasn't zoomed, check the original yaxis
  19729. if (typeof _this3.ctx.opts.yaxis[index] !== 'undefined') {
  19730. yaxe.min = _this3.ctx.opts.yaxis[index].min;
  19731. yaxe.max = _this3.ctx.opts.yaxis[index].max;
  19732. }
  19733. }
  19734. });
  19735. }
  19736. }]);
  19737. return UpdateHelpers;
  19738. }();
  19739. (function (root, factory) {
  19740. /* istanbul ignore next */
  19741. if (typeof define === 'function' && define.amd) {
  19742. define(function () {
  19743. return factory(root, root.document);
  19744. });
  19745. /* below check fixes #412 */
  19746. } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
  19747. module.exports = root.document ? factory(root, root.document) : function (w) {
  19748. return factory(w, w.document);
  19749. };
  19750. } else {
  19751. root.SVG = factory(root, root.document);
  19752. }
  19753. })(typeof window !== 'undefined' ? window : undefined, function (window, document) {
  19754. // Find global reference - uses 'this' by default when available,
  19755. // falls back to 'window' otherwise (for bundlers like Webpack)
  19756. var globalRef = typeof this !== 'undefined' ? this : window; // The main wrapping element
  19757. var SVG = globalRef.SVG = function (element) {
  19758. if (SVG.supported) {
  19759. element = new SVG.Doc(element);
  19760. if (!SVG.parser.draw) {
  19761. SVG.prepare();
  19762. }
  19763. return element;
  19764. }
  19765. }; // Default namespaces
  19766. SVG.ns = 'http://www.w3.org/2000/svg';
  19767. SVG.xmlns = 'http://www.w3.org/2000/xmlns/';
  19768. SVG.xlink = 'http://www.w3.org/1999/xlink';
  19769. SVG.svgjs = 'http://svgjs.com/svgjs'; // Svg support test
  19770. SVG.supported = function () {
  19771. return true; // !!document.createElementNS &&
  19772. // !! document.createElementNS(SVG.ns,'svg').createSVGRect
  19773. }(); // Don't bother to continue if SVG is not supported
  19774. if (!SVG.supported) return false; // Element id sequence
  19775. SVG.did = 1000; // Get next named element id
  19776. SVG.eid = function (name) {
  19777. return 'Svgjs' + capitalize(name) + SVG.did++;
  19778. }; // Method for element creation
  19779. SVG.create = function (name) {
  19780. // create element
  19781. var element = document.createElementNS(this.ns, name); // apply unique id
  19782. element.setAttribute('id', this.eid(name));
  19783. return element;
  19784. }; // Method for extending objects
  19785. SVG.extend = function () {
  19786. var modules, methods; // Get list of modules
  19787. modules = [].slice.call(arguments); // Get object with extensions
  19788. methods = modules.pop();
  19789. for (var i = modules.length - 1; i >= 0; i--) {
  19790. if (modules[i]) {
  19791. for (var key in methods) {
  19792. modules[i].prototype[key] = methods[key];
  19793. }
  19794. }
  19795. } // Make sure SVG.Set inherits any newly added methods
  19796. if (SVG.Set && SVG.Set.inherit) {
  19797. SVG.Set.inherit();
  19798. }
  19799. }; // Invent new element
  19800. SVG.invent = function (config) {
  19801. // Create element initializer
  19802. var initializer = typeof config.create === 'function' ? config.create : function () {
  19803. this.constructor.call(this, SVG.create(config.create));
  19804. }; // Inherit prototype
  19805. if (config.inherit) {
  19806. initializer.prototype = new config.inherit();
  19807. } // Extend with methods
  19808. if (config.extend) {
  19809. SVG.extend(initializer, config.extend);
  19810. } // Attach construct method to parent
  19811. if (config.construct) {
  19812. SVG.extend(config.parent || SVG.Container, config.construct);
  19813. }
  19814. return initializer;
  19815. }; // Adopt existing svg elements
  19816. SVG.adopt = function (node) {
  19817. // check for presence of node
  19818. if (!node) return null; // make sure a node isn't already adopted
  19819. if (node.instance) return node.instance; // initialize variables
  19820. var element; // adopt with element-specific settings
  19821. if (node.nodeName == 'svg') {
  19822. element = node.parentNode instanceof window.SVGElement ? new SVG.Nested() : new SVG.Doc();
  19823. } else if (node.nodeName == 'linearGradient') {
  19824. element = new SVG.Gradient('linear');
  19825. } else if (node.nodeName == 'radialGradient') {
  19826. element = new SVG.Gradient('radial');
  19827. } else if (SVG[capitalize(node.nodeName)]) {
  19828. element = new SVG[capitalize(node.nodeName)]();
  19829. } else {
  19830. element = new SVG.Element(node);
  19831. } // ensure references
  19832. element.type = node.nodeName;
  19833. element.node = node;
  19834. node.instance = element; // SVG.Class specific preparations
  19835. if (element instanceof SVG.Doc) {
  19836. element.namespace().defs();
  19837. } // pull svgjs data from the dom (getAttributeNS doesn't work in html5)
  19838. element.setData(JSON.parse(node.getAttribute('svgjs:data')) || {});
  19839. return element;
  19840. }; // Initialize parsing element
  19841. SVG.prepare = function () {
  19842. // Select document body and create invisible svg element
  19843. var body = document.getElementsByTagName('body')[0],
  19844. draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0); // Create parser object
  19845. SVG.parser = {
  19846. body: body || document.documentElement,
  19847. draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node,
  19848. poly: draw.polyline().node,
  19849. path: draw.path().node,
  19850. native: SVG.create('svg')
  19851. };
  19852. };
  19853. SVG.parser = {
  19854. native: SVG.create('svg')
  19855. };
  19856. document.addEventListener('DOMContentLoaded', function () {
  19857. if (!SVG.parser.draw) {
  19858. SVG.prepare();
  19859. }
  19860. }, false); // Storage for regular expressions
  19861. SVG.regex = {
  19862. // Parse unit value
  19863. numberAndUnit: /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,
  19864. // Parse hex value
  19865. hex: /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
  19866. // Parse rgb value
  19867. rgb: /rgb\((\d+),(\d+),(\d+)\)/,
  19868. // Parse reference id
  19869. reference: /#([a-z0-9\-_]+)/i,
  19870. // splits a transformation chain
  19871. transforms: /\)\s*,?\s*/,
  19872. // Whitespace
  19873. whitespace: /\s/g,
  19874. // Test hex value
  19875. isHex: /^#[a-f0-9]{3,6}$/i,
  19876. // Test rgb value
  19877. isRgb: /^rgb\(/,
  19878. // Test css declaration
  19879. isCss: /[^:]+:[^;]+;?/,
  19880. // Test for blank string
  19881. isBlank: /^(\s+)?$/,
  19882. // Test for numeric string
  19883. isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  19884. // Test for percent value
  19885. isPercent: /^-?[\d\.]+%$/,
  19886. // Test for image url
  19887. isImage: /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,
  19888. // split at whitespace and comma
  19889. delimiter: /[\s,]+/,
  19890. // The following regex are used to parse the d attribute of a path
  19891. // Matches all hyphens which are not after an exponent
  19892. hyphen: /([^e])\-/gi,
  19893. // Replaces and tests for all path letters
  19894. pathLetters: /[MLHVCSQTAZ]/gi,
  19895. // yes we need this one, too
  19896. isPathLetter: /[MLHVCSQTAZ]/i,
  19897. // matches 0.154.23.45
  19898. numbersWithDots: /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,
  19899. // matches .
  19900. dots: /\./g
  19901. };
  19902. SVG.utils = {
  19903. // Map function
  19904. map: function map(array, block) {
  19905. var il = array.length,
  19906. result = [];
  19907. for (var i = 0; i < il; i++) {
  19908. result.push(block(array[i]));
  19909. }
  19910. return result;
  19911. },
  19912. // Filter function
  19913. filter: function filter(array, block) {
  19914. var il = array.length,
  19915. result = [];
  19916. for (var i = 0; i < il; i++) {
  19917. if (block(array[i])) {
  19918. result.push(array[i]);
  19919. }
  19920. }
  19921. return result;
  19922. },
  19923. filterSVGElements: function filterSVGElements(nodes) {
  19924. return this.filter(nodes, function (el) {
  19925. return el instanceof window.SVGElement;
  19926. });
  19927. }
  19928. };
  19929. SVG.defaults = {
  19930. // Default attribute values
  19931. attrs: {
  19932. // fill and stroke
  19933. 'fill-opacity': 1,
  19934. 'stroke-opacity': 1,
  19935. 'stroke-width': 0,
  19936. 'stroke-linejoin': 'miter',
  19937. 'stroke-linecap': 'butt',
  19938. fill: '#000000',
  19939. stroke: '#000000',
  19940. opacity: 1,
  19941. // position
  19942. x: 0,
  19943. y: 0,
  19944. cx: 0,
  19945. cy: 0,
  19946. // size
  19947. width: 0,
  19948. height: 0,
  19949. // radius
  19950. r: 0,
  19951. rx: 0,
  19952. ry: 0,
  19953. // gradient
  19954. offset: 0,
  19955. 'stop-opacity': 1,
  19956. 'stop-color': '#000000',
  19957. // text
  19958. 'font-size': 16,
  19959. 'font-family': 'Helvetica, Arial, sans-serif',
  19960. 'text-anchor': 'start'
  19961. }
  19962. }; // Module for color convertions
  19963. SVG.Color = function (color) {
  19964. var match; // initialize defaults
  19965. this.r = 0;
  19966. this.g = 0;
  19967. this.b = 0;
  19968. if (!color) return; // parse color
  19969. if (typeof color === 'string') {
  19970. if (SVG.regex.isRgb.test(color)) {
  19971. // get rgb values
  19972. match = SVG.regex.rgb.exec(color.replace(SVG.regex.whitespace, '')); // parse numeric values
  19973. this.r = parseInt(match[1]);
  19974. this.g = parseInt(match[2]);
  19975. this.b = parseInt(match[3]);
  19976. } else if (SVG.regex.isHex.test(color)) {
  19977. // get hex values
  19978. match = SVG.regex.hex.exec(fullHex(color)); // parse numeric values
  19979. this.r = parseInt(match[1], 16);
  19980. this.g = parseInt(match[2], 16);
  19981. this.b = parseInt(match[3], 16);
  19982. }
  19983. } else if (_typeof(color) === 'object') {
  19984. this.r = color.r;
  19985. this.g = color.g;
  19986. this.b = color.b;
  19987. }
  19988. };
  19989. SVG.extend(SVG.Color, {
  19990. // Default to hex conversion
  19991. toString: function toString() {
  19992. return this.toHex();
  19993. },
  19994. // Build hex value
  19995. toHex: function toHex() {
  19996. return '#' + compToHex(this.r) + compToHex(this.g) + compToHex(this.b);
  19997. },
  19998. // Build rgb value
  19999. toRgb: function toRgb() {
  20000. return 'rgb(' + [this.r, this.g, this.b].join() + ')';
  20001. },
  20002. // Calculate true brightness
  20003. brightness: function brightness() {
  20004. return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11;
  20005. },
  20006. // Make color morphable
  20007. morph: function morph(color) {
  20008. this.destination = new SVG.Color(color);
  20009. return this;
  20010. },
  20011. // Get morphed color at given position
  20012. at: function at(pos) {
  20013. // make sure a destination is defined
  20014. if (!this.destination) return this; // normalise pos
  20015. pos = pos < 0 ? 0 : pos > 1 ? 1 : pos; // generate morphed color
  20016. return new SVG.Color({
  20017. r: ~~(this.r + (this.destination.r - this.r) * pos),
  20018. g: ~~(this.g + (this.destination.g - this.g) * pos),
  20019. b: ~~(this.b + (this.destination.b - this.b) * pos)
  20020. });
  20021. }
  20022. }); // Testers
  20023. // Test if given value is a color string
  20024. SVG.Color.test = function (color) {
  20025. color += '';
  20026. return SVG.regex.isHex.test(color) || SVG.regex.isRgb.test(color);
  20027. }; // Test if given value is a rgb object
  20028. SVG.Color.isRgb = function (color) {
  20029. return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number';
  20030. }; // Test if given value is a color
  20031. SVG.Color.isColor = function (color) {
  20032. return SVG.Color.isRgb(color) || SVG.Color.test(color);
  20033. }; // Module for array conversion
  20034. SVG.Array = function (array, fallback) {
  20035. array = (array || []).valueOf(); // if array is empty and fallback is provided, use fallback
  20036. if (array.length == 0 && fallback) {
  20037. array = fallback.valueOf();
  20038. } // parse array
  20039. this.value = this.parse(array);
  20040. };
  20041. SVG.extend(SVG.Array, {
  20042. // Convert array to string
  20043. toString: function toString() {
  20044. return this.value.join(' ');
  20045. },
  20046. // Real value
  20047. valueOf: function valueOf() {
  20048. return this.value;
  20049. },
  20050. // Parse whitespace separated string
  20051. parse: function parse(array) {
  20052. array = array.valueOf(); // if already is an array, no need to parse it
  20053. if (Array.isArray(array)) return array;
  20054. return this.split(array);
  20055. }
  20056. }); // Poly points array
  20057. SVG.PointArray = function (array, fallback) {
  20058. SVG.Array.call(this, array, fallback || [[0, 0]]);
  20059. }; // Inherit from SVG.Array
  20060. SVG.PointArray.prototype = new SVG.Array();
  20061. SVG.PointArray.prototype.constructor = SVG.PointArray;
  20062. var pathHandlers = {
  20063. M: function M(c, p, p0) {
  20064. p.x = p0.x = c[0];
  20065. p.y = p0.y = c[1];
  20066. return ['M', p.x, p.y];
  20067. },
  20068. L: function L(c, p) {
  20069. p.x = c[0];
  20070. p.y = c[1];
  20071. return ['L', c[0], c[1]];
  20072. },
  20073. H: function H(c, p) {
  20074. p.x = c[0];
  20075. return ['H', c[0]];
  20076. },
  20077. V: function V(c, p) {
  20078. p.y = c[0];
  20079. return ['V', c[0]];
  20080. },
  20081. C: function C(c, p) {
  20082. p.x = c[4];
  20083. p.y = c[5];
  20084. return ['C', c[0], c[1], c[2], c[3], c[4], c[5]];
  20085. },
  20086. Q: function Q(c, p) {
  20087. p.x = c[2];
  20088. p.y = c[3];
  20089. return ['Q', c[0], c[1], c[2], c[3]];
  20090. },
  20091. Z: function Z(c, p, p0) {
  20092. p.x = p0.x;
  20093. p.y = p0.y;
  20094. return ['Z'];
  20095. }
  20096. };
  20097. var mlhvqtcsa = 'mlhvqtcsaz'.split('');
  20098. for (var i = 0, il = mlhvqtcsa.length; i < il; ++i) {
  20099. pathHandlers[mlhvqtcsa[i]] = function (i) {
  20100. return function (c, p, p0) {
  20101. if (i == 'H') c[0] = c[0] + p.x;else if (i == 'V') c[0] = c[0] + p.y;else if (i == 'A') {
  20102. c[5] = c[5] + p.x, c[6] = c[6] + p.y;
  20103. } else {
  20104. for (var j = 0, jl = c.length; j < jl; ++j) {
  20105. c[j] = c[j] + (j % 2 ? p.y : p.x);
  20106. }
  20107. }
  20108. return pathHandlers[i](c, p, p0);
  20109. };
  20110. }(mlhvqtcsa[i].toUpperCase());
  20111. } // Path points array
  20112. SVG.PathArray = function (array, fallback) {
  20113. SVG.Array.call(this, array, fallback || [['M', 0, 0]]);
  20114. }; // Inherit from SVG.Array
  20115. SVG.PathArray.prototype = new SVG.Array();
  20116. SVG.PathArray.prototype.constructor = SVG.PathArray;
  20117. SVG.extend(SVG.PathArray, {
  20118. // Convert array to string
  20119. toString: function toString() {
  20120. return arrayToString(this.value);
  20121. },
  20122. // Move path string
  20123. move: function move(x, y) {
  20124. // get bounding box of current situation
  20125. var box = this.bbox(); // get relative offset
  20126. x -= box.x;
  20127. y -= box.y;
  20128. return this;
  20129. },
  20130. // Get morphed path array at given position
  20131. at: function at(pos) {
  20132. // make sure a destination is defined
  20133. if (!this.destination) return this;
  20134. var sourceArray = this.value,
  20135. destinationArray = this.destination.value,
  20136. array = [],
  20137. pathArray = new SVG.PathArray(),
  20138. il,
  20139. jl; // Animate has specified in the SVG spec
  20140. // See: https://www.w3.org/TR/SVG11/paths.html#PathElement
  20141. for (var i = 0, il = sourceArray.length; i < il; i++) {
  20142. array[i] = [sourceArray[i][0]];
  20143. for (var j = 1, jl = sourceArray[i].length; j < jl; j++) {
  20144. array[i][j] = sourceArray[i][j] + (destinationArray[i][j] - sourceArray[i][j]) * pos;
  20145. } // For the two flags of the elliptical arc command, the SVG spec say:
  20146. // Flags and booleans are interpolated as fractions between zero and one, with any non-zero value considered to be a value of one/true
  20147. // Elliptical arc command as an array followed by corresponding indexes:
  20148. // ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
  20149. // 0 1 2 3 4 5 6 7
  20150. if (array[i][0] === 'A') {
  20151. array[i][4] = +(array[i][4] != 0);
  20152. array[i][5] = +(array[i][5] != 0);
  20153. }
  20154. } // Directly modify the value of a path array, this is done this way for performance
  20155. pathArray.value = array;
  20156. return pathArray;
  20157. },
  20158. // Absolutize and parse path to array
  20159. parse: function parse(array) {
  20160. // if it's already a patharray, no need to parse it
  20161. if (array instanceof SVG.PathArray) return array.valueOf(); // prepare for parsing
  20162. var s,
  20163. arr,
  20164. paramCnt = {
  20165. 'M': 2,
  20166. 'L': 2,
  20167. 'H': 1,
  20168. 'V': 1,
  20169. 'C': 6,
  20170. 'S': 4,
  20171. 'Q': 4,
  20172. 'T': 2,
  20173. 'A': 7,
  20174. 'Z': 0
  20175. };
  20176. if (typeof array === 'string') {
  20177. array = array.replace(SVG.regex.numbersWithDots, pathRegReplace) // convert 45.123.123 to 45.123 .123
  20178. .replace(SVG.regex.pathLetters, ' $& ') // put some room between letters and numbers
  20179. .replace(SVG.regex.hyphen, '$1 -') // add space before hyphen
  20180. .trim() // trim
  20181. .split(SVG.regex.delimiter); // split into array
  20182. } else {
  20183. array = array.reduce(function (prev, curr) {
  20184. return [].concat.call(prev, curr);
  20185. }, []);
  20186. } // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...]
  20187. var arr = [],
  20188. p = new SVG.Point(),
  20189. p0 = new SVG.Point(),
  20190. index = 0,
  20191. len = array.length;
  20192. do {
  20193. // Test if we have a path letter
  20194. if (SVG.regex.isPathLetter.test(array[index])) {
  20195. s = array[index];
  20196. ++index; // If last letter was a move command and we got no new, it defaults to [L]ine
  20197. } else if (s == 'M') {
  20198. s = 'L';
  20199. } else if (s == 'm') {
  20200. s = 'l';
  20201. }
  20202. arr.push(pathHandlers[s].call(null, array.slice(index, index = index + paramCnt[s.toUpperCase()]).map(parseFloat), p, p0));
  20203. } while (len > index);
  20204. return arr;
  20205. },
  20206. // Get bounding box of path
  20207. bbox: function bbox() {
  20208. if (!SVG.parser.draw) {
  20209. SVG.prepare();
  20210. }
  20211. SVG.parser.path.setAttribute('d', this.toString());
  20212. return SVG.parser.path.getBBox();
  20213. }
  20214. }); // Module for unit convertions
  20215. SVG.Number = SVG.invent({
  20216. // Initialize
  20217. create: function create(value, unit) {
  20218. // initialize defaults
  20219. this.value = 0;
  20220. this.unit = unit || ''; // parse value
  20221. if (typeof value === 'number') {
  20222. // ensure a valid numeric value
  20223. this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -3.4e+38 : +3.4e+38 : value;
  20224. } else if (typeof value === 'string') {
  20225. unit = value.match(SVG.regex.numberAndUnit);
  20226. if (unit) {
  20227. // make value numeric
  20228. this.value = parseFloat(unit[1]); // normalize
  20229. if (unit[5] == '%') {
  20230. this.value /= 100;
  20231. } else if (unit[5] == 's') {
  20232. this.value *= 1000;
  20233. } // store unit
  20234. this.unit = unit[5];
  20235. }
  20236. } else {
  20237. if (value instanceof SVG.Number) {
  20238. this.value = value.valueOf();
  20239. this.unit = value.unit;
  20240. }
  20241. }
  20242. },
  20243. // Add methods
  20244. extend: {
  20245. // Stringalize
  20246. toString: function toString() {
  20247. return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.unit == 's' ? this.value / 1e3 : this.value) + this.unit;
  20248. },
  20249. toJSON: function toJSON() {
  20250. return this.toString();
  20251. },
  20252. // Convert to primitive
  20253. valueOf: function valueOf() {
  20254. return this.value;
  20255. },
  20256. // Add number
  20257. plus: function plus(number) {
  20258. number = new SVG.Number(number);
  20259. return new SVG.Number(this + number, this.unit || number.unit);
  20260. },
  20261. // Subtract number
  20262. minus: function minus(number) {
  20263. number = new SVG.Number(number);
  20264. return new SVG.Number(this - number, this.unit || number.unit);
  20265. },
  20266. // Multiply number
  20267. times: function times(number) {
  20268. number = new SVG.Number(number);
  20269. return new SVG.Number(this * number, this.unit || number.unit);
  20270. },
  20271. // Divide number
  20272. divide: function divide(number) {
  20273. number = new SVG.Number(number);
  20274. return new SVG.Number(this / number, this.unit || number.unit);
  20275. },
  20276. // Convert to different unit
  20277. to: function to(unit) {
  20278. var number = new SVG.Number(this);
  20279. if (typeof unit === 'string') {
  20280. number.unit = unit;
  20281. }
  20282. return number;
  20283. },
  20284. // Make number morphable
  20285. morph: function morph(number) {
  20286. this.destination = new SVG.Number(number);
  20287. if (number.relative) {
  20288. this.destination.value += this.value;
  20289. }
  20290. return this;
  20291. },
  20292. // Get morphed number at given position
  20293. at: function at(pos) {
  20294. // Make sure a destination is defined
  20295. if (!this.destination) return this; // Generate new morphed number
  20296. return new SVG.Number(this.destination).minus(this).times(pos).plus(this);
  20297. }
  20298. }
  20299. });
  20300. SVG.Element = SVG.invent({
  20301. // Initialize node
  20302. create: function create(node) {
  20303. // make stroke value accessible dynamically
  20304. this._stroke = SVG.defaults.attrs.stroke;
  20305. this._event = null; // initialize data object
  20306. this.dom = {}; // create circular reference
  20307. if (this.node = node) {
  20308. this.type = node.nodeName;
  20309. this.node.instance = this; // store current attribute value
  20310. this._stroke = node.getAttribute('stroke') || this._stroke;
  20311. }
  20312. },
  20313. // Add class methods
  20314. extend: {
  20315. // Move over x-axis
  20316. x: function x(_x) {
  20317. return this.attr('x', _x);
  20318. },
  20319. // Move over y-axis
  20320. y: function y(_y) {
  20321. return this.attr('y', _y);
  20322. },
  20323. // Move by center over x-axis
  20324. cx: function cx(x) {
  20325. return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2);
  20326. },
  20327. // Move by center over y-axis
  20328. cy: function cy(y) {
  20329. return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2);
  20330. },
  20331. // Move element to given x and y values
  20332. move: function move(x, y) {
  20333. return this.x(x).y(y);
  20334. },
  20335. // Move element by its center
  20336. center: function center(x, y) {
  20337. return this.cx(x).cy(y);
  20338. },
  20339. // Set width of element
  20340. width: function width(_width) {
  20341. return this.attr('width', _width);
  20342. },
  20343. // Set height of element
  20344. height: function height(_height) {
  20345. return this.attr('height', _height);
  20346. },
  20347. // Set element size to given width and height
  20348. size: function size(width, height) {
  20349. var p = proportionalSize(this, width, height);
  20350. return this.width(new SVG.Number(p.width)).height(new SVG.Number(p.height));
  20351. },
  20352. // Clone element
  20353. clone: function clone(parent) {
  20354. // write dom data to the dom so the clone can pickup the data
  20355. this.writeDataToDom(); // clone element and assign new id
  20356. var clone = assignNewId(this.node.cloneNode(true)); // insert the clone in the given parent or after myself
  20357. if (parent) parent.add(clone);else this.after(clone);
  20358. return clone;
  20359. },
  20360. // Remove element
  20361. remove: function remove() {
  20362. if (this.parent()) {
  20363. this.parent().removeElement(this);
  20364. }
  20365. return this;
  20366. },
  20367. // Replace element
  20368. replace: function replace(element) {
  20369. this.after(element).remove();
  20370. return element;
  20371. },
  20372. // Add element to given container and return self
  20373. addTo: function addTo(parent) {
  20374. return parent.put(this);
  20375. },
  20376. // Add element to given container and return container
  20377. putIn: function putIn(parent) {
  20378. return parent.add(this);
  20379. },
  20380. // Get / set id
  20381. id: function id(_id) {
  20382. return this.attr('id', _id);
  20383. },
  20384. // Show element
  20385. show: function show() {
  20386. return this.style('display', '');
  20387. },
  20388. // Hide element
  20389. hide: function hide() {
  20390. return this.style('display', 'none');
  20391. },
  20392. // Is element visible?
  20393. visible: function visible() {
  20394. return this.style('display') != 'none';
  20395. },
  20396. // Return id on string conversion
  20397. toString: function toString() {
  20398. return this.attr('id');
  20399. },
  20400. // Return array of classes on the node
  20401. classes: function classes() {
  20402. var attr = this.attr('class');
  20403. return attr == null ? [] : attr.trim().split(SVG.regex.delimiter);
  20404. },
  20405. // Return true if class exists on the node, false otherwise
  20406. hasClass: function hasClass(name) {
  20407. return this.classes().indexOf(name) != -1;
  20408. },
  20409. // Add class to the node
  20410. addClass: function addClass(name) {
  20411. if (!this.hasClass(name)) {
  20412. var array = this.classes();
  20413. array.push(name);
  20414. this.attr('class', array.join(' '));
  20415. }
  20416. return this;
  20417. },
  20418. // Remove class from the node
  20419. removeClass: function removeClass(name) {
  20420. if (this.hasClass(name)) {
  20421. this.attr('class', this.classes().filter(function (c) {
  20422. return c != name;
  20423. }).join(' '));
  20424. }
  20425. return this;
  20426. },
  20427. // Toggle the presence of a class on the node
  20428. toggleClass: function toggleClass(name) {
  20429. return this.hasClass(name) ? this.removeClass(name) : this.addClass(name);
  20430. },
  20431. // Get referenced element form attribute value
  20432. reference: function reference(attr) {
  20433. return SVG.get(this.attr(attr));
  20434. },
  20435. // Returns the parent element instance
  20436. parent: function parent(type) {
  20437. var parent = this; // check for parent
  20438. if (!parent.node.parentNode) return null; // get parent element
  20439. parent = SVG.adopt(parent.node.parentNode);
  20440. if (!type) return parent; // loop trough ancestors if type is given
  20441. while (parent && parent.node instanceof window.SVGElement) {
  20442. if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent;
  20443. if (!parent.node.parentNode || parent.node.parentNode.nodeName == '#document') return null; // #759, #720
  20444. parent = SVG.adopt(parent.node.parentNode);
  20445. }
  20446. },
  20447. // Get parent document
  20448. doc: function doc() {
  20449. return this instanceof SVG.Doc ? this : this.parent(SVG.Doc);
  20450. },
  20451. // return array of all ancestors of given type up to the root svg
  20452. parents: function parents(type) {
  20453. var parents = [],
  20454. parent = this;
  20455. do {
  20456. parent = parent.parent(type);
  20457. if (!parent || !parent.node) break;
  20458. parents.push(parent);
  20459. } while (parent.parent);
  20460. return parents;
  20461. },
  20462. // matches the element vs a css selector
  20463. matches: function matches(selector) {
  20464. return _matches(this.node, selector);
  20465. },
  20466. // Returns the svg node to call native svg methods on it
  20467. native: function native() {
  20468. return this.node;
  20469. },
  20470. // Import raw svg
  20471. svg: function svg(_svg) {
  20472. // create temporary holder
  20473. var well = document.createElement('svg'); // act as a setter if svg is given
  20474. if (_svg && this instanceof SVG.Parent) {
  20475. // dump raw svg
  20476. well.innerHTML = '<svg>' + _svg.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2></$1>') + '</svg>'; // transplant nodes
  20477. for (var i = 0, il = well.firstChild.childNodes.length; i < il; i++) {
  20478. this.node.appendChild(well.firstChild.firstChild);
  20479. } // otherwise act as a getter
  20480. } else {
  20481. // create a wrapping svg element in case of partial content
  20482. well.appendChild(_svg = document.createElement('svg')); // write svgjs data to the dom
  20483. this.writeDataToDom(); // insert a copy of this node
  20484. _svg.appendChild(this.node.cloneNode(true)); // return target element
  20485. return well.innerHTML.replace(/^<svg>/, '').replace(/<\/svg>$/, '');
  20486. }
  20487. return this;
  20488. },
  20489. // write svgjs data to the dom
  20490. writeDataToDom: function writeDataToDom() {
  20491. // dump variables recursively
  20492. if (this.each || this.lines) {
  20493. var fn = this.each ? this : this.lines();
  20494. fn.each(function () {
  20495. this.writeDataToDom();
  20496. });
  20497. } // remove previously set data
  20498. this.node.removeAttribute('svgjs:data');
  20499. if (Object.keys(this.dom).length) {
  20500. this.node.setAttribute('svgjs:data', JSON.stringify(this.dom));
  20501. } // see #428
  20502. return this;
  20503. },
  20504. // set given data to the elements data property
  20505. setData: function setData(o) {
  20506. this.dom = o;
  20507. return this;
  20508. },
  20509. is: function is(obj) {
  20510. return _is(this, obj);
  20511. }
  20512. }
  20513. });
  20514. SVG.easing = {
  20515. '-': function _(pos) {
  20516. return pos;
  20517. },
  20518. '<>': function _(pos) {
  20519. return -Math.cos(pos * Math.PI) / 2 + 0.5;
  20520. },
  20521. '>': function _(pos) {
  20522. return Math.sin(pos * Math.PI / 2);
  20523. },
  20524. '<': function _(pos) {
  20525. return -Math.cos(pos * Math.PI / 2) + 1;
  20526. }
  20527. };
  20528. SVG.morph = function (pos) {
  20529. return function (from, to) {
  20530. return new SVG.MorphObj(from, to).at(pos);
  20531. };
  20532. };
  20533. SVG.Situation = SVG.invent({
  20534. create: function create(o) {
  20535. this.init = false;
  20536. this.reversed = false;
  20537. this.reversing = false;
  20538. this.duration = new SVG.Number(o.duration).valueOf();
  20539. this.delay = new SVG.Number(o.delay).valueOf();
  20540. this.start = +new Date() + this.delay;
  20541. this.finish = this.start + this.duration;
  20542. this.ease = o.ease; // this.loop is incremented from 0 to this.loops
  20543. // it is also incremented when in an infinite loop (when this.loops is true)
  20544. this.loop = 0;
  20545. this.loops = false;
  20546. this.animations = {// functionToCall: [list of morphable objects]
  20547. // e.g. move: [SVG.Number, SVG.Number]
  20548. };
  20549. this.attrs = {// holds all attributes which are not represented from a function svg.js provides
  20550. // e.g. someAttr: SVG.Number
  20551. };
  20552. this.styles = {// holds all styles which should be animated
  20553. // e.g. fill-color: SVG.Color
  20554. };
  20555. this.transforms = [// holds all transformations as transformation objects
  20556. // e.g. [SVG.Rotate, SVG.Translate, SVG.Matrix]
  20557. ];
  20558. this.once = {// functions to fire at a specific position
  20559. // e.g. "0.5": function foo(){}
  20560. };
  20561. }
  20562. });
  20563. SVG.FX = SVG.invent({
  20564. create: function create(element) {
  20565. this._target = element;
  20566. this.situations = [];
  20567. this.active = false;
  20568. this.situation = null;
  20569. this.paused = false;
  20570. this.lastPos = 0;
  20571. this.pos = 0; // The absolute position of an animation is its position in the context of its complete duration (including delay and loops)
  20572. // When performing a delay, absPos is below 0 and when performing a loop, its value is above 1
  20573. this.absPos = 0;
  20574. this._speed = 1;
  20575. },
  20576. extend: {
  20577. /**
  20578. * sets or returns the target of this animation
  20579. * @param o object || number In case of Object it holds all parameters. In case of number its the duration of the animation
  20580. * @param ease function || string Function which should be used for easing or easing keyword
  20581. * @param delay Number indicating the delay before the animation starts
  20582. * @return target || this
  20583. */
  20584. animate: function animate(o, ease, delay) {
  20585. if (_typeof(o) === 'object') {
  20586. ease = o.ease;
  20587. delay = o.delay;
  20588. o = o.duration;
  20589. }
  20590. var situation = new SVG.Situation({
  20591. duration: o || 1000,
  20592. delay: delay || 0,
  20593. ease: SVG.easing[ease || '-'] || ease
  20594. });
  20595. this.queue(situation);
  20596. return this;
  20597. },
  20598. /**
  20599. * sets a delay before the next element of the queue is called
  20600. * @param delay Duration of delay in milliseconds
  20601. * @return this.target()
  20602. */
  20603. /**
  20604. * sets or returns the target of this animation
  20605. * @param null || target SVG.Element which should be set as new target
  20606. * @return target || this
  20607. */
  20608. target: function target(_target) {
  20609. if (_target && _target instanceof SVG.Element) {
  20610. this._target = _target;
  20611. return this;
  20612. }
  20613. return this._target;
  20614. },
  20615. // returns the absolute position at a given time
  20616. timeToAbsPos: function timeToAbsPos(timestamp) {
  20617. return (timestamp - this.situation.start) / (this.situation.duration / this._speed);
  20618. },
  20619. // returns the timestamp from a given absolute positon
  20620. absPosToTime: function absPosToTime(absPos) {
  20621. return this.situation.duration / this._speed * absPos + this.situation.start;
  20622. },
  20623. // starts the animationloop
  20624. startAnimFrame: function startAnimFrame() {
  20625. this.stopAnimFrame();
  20626. this.animationFrame = window.requestAnimationFrame(function () {
  20627. this.step();
  20628. }.bind(this));
  20629. },
  20630. // cancels the animationframe
  20631. stopAnimFrame: function stopAnimFrame() {
  20632. window.cancelAnimationFrame(this.animationFrame);
  20633. },
  20634. // kicks off the animation - only does something when the queue is currently not active and at least one situation is set
  20635. start: function start() {
  20636. // dont start if already started
  20637. if (!this.active && this.situation) {
  20638. this.active = true;
  20639. this.startCurrent();
  20640. }
  20641. return this;
  20642. },
  20643. // start the current situation
  20644. startCurrent: function startCurrent() {
  20645. this.situation.start = +new Date() + this.situation.delay / this._speed;
  20646. this.situation.finish = this.situation.start + this.situation.duration / this._speed;
  20647. return this.initAnimations().step();
  20648. },
  20649. /**
  20650. * adds a function / Situation to the animation queue
  20651. * @param fn function / situation to add
  20652. * @return this
  20653. */
  20654. queue: function queue(fn) {
  20655. if (typeof fn === 'function' || fn instanceof SVG.Situation) {
  20656. this.situations.push(fn);
  20657. }
  20658. if (!this.situation) this.situation = this.situations.shift();
  20659. return this;
  20660. },
  20661. /**
  20662. * pulls next element from the queue and execute it
  20663. * @return this
  20664. */
  20665. dequeue: function dequeue() {
  20666. // stop current animation
  20667. this.stop(); // get next animation from queue
  20668. this.situation = this.situations.shift();
  20669. if (this.situation) {
  20670. if (this.situation instanceof SVG.Situation) {
  20671. this.start();
  20672. } else {
  20673. // If it is not a SVG.Situation, then it is a function, we execute it
  20674. this.situation.call(this);
  20675. }
  20676. }
  20677. return this;
  20678. },
  20679. // updates all animations to the current state of the element
  20680. // this is important when one property could be changed from another property
  20681. initAnimations: function initAnimations() {
  20682. var source;
  20683. var s = this.situation;
  20684. if (s.init) return this;
  20685. for (var i in s.animations) {
  20686. source = this.target()[i]();
  20687. if (!Array.isArray(source)) {
  20688. source = [source];
  20689. }
  20690. if (!Array.isArray(s.animations[i])) {
  20691. s.animations[i] = [s.animations[i]];
  20692. } // if(s.animations[i].length > source.length) {
  20693. // source.concat = source.concat(s.animations[i].slice(source.length, s.animations[i].length))
  20694. // }
  20695. for (var j = source.length; j--;) {
  20696. // The condition is because some methods return a normal number instead
  20697. // of a SVG.Number
  20698. if (s.animations[i][j] instanceof SVG.Number) {
  20699. source[j] = new SVG.Number(source[j]);
  20700. }
  20701. s.animations[i][j] = source[j].morph(s.animations[i][j]);
  20702. }
  20703. }
  20704. for (var i in s.attrs) {
  20705. s.attrs[i] = new SVG.MorphObj(this.target().attr(i), s.attrs[i]);
  20706. }
  20707. for (var i in s.styles) {
  20708. s.styles[i] = new SVG.MorphObj(this.target().style(i), s.styles[i]);
  20709. }
  20710. s.initialTransformation = this.target().matrixify();
  20711. s.init = true;
  20712. return this;
  20713. },
  20714. clearQueue: function clearQueue() {
  20715. this.situations = [];
  20716. return this;
  20717. },
  20718. clearCurrent: function clearCurrent() {
  20719. this.situation = null;
  20720. return this;
  20721. },
  20722. /** stops the animation immediately
  20723. * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately.
  20724. * @param clearQueue A Boolean indicating whether to remove queued animation as well.
  20725. * @return this
  20726. */
  20727. stop: function stop(jumpToEnd, clearQueue) {
  20728. var active = this.active;
  20729. this.active = false;
  20730. if (clearQueue) {
  20731. this.clearQueue();
  20732. }
  20733. if (jumpToEnd && this.situation) {
  20734. // initialize the situation if it was not
  20735. !active && this.startCurrent();
  20736. this.atEnd();
  20737. }
  20738. this.stopAnimFrame();
  20739. return this.clearCurrent();
  20740. },
  20741. after: function after(fn) {
  20742. var c = this.last(),
  20743. wrapper = function wrapper(e) {
  20744. if (e.detail.situation == c) {
  20745. fn.call(this, c);
  20746. this.off('finished.fx', wrapper); // prevent memory leak
  20747. }
  20748. };
  20749. this.target().on('finished.fx', wrapper);
  20750. return this._callStart();
  20751. },
  20752. // adds a callback which is called whenever one animation step is performed
  20753. during: function during(fn) {
  20754. var c = this.last(),
  20755. wrapper = function wrapper(e) {
  20756. if (e.detail.situation == c) {
  20757. fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, c);
  20758. }
  20759. }; // see above
  20760. this.target().off('during.fx', wrapper).on('during.fx', wrapper);
  20761. this.after(function () {
  20762. this.off('during.fx', wrapper);
  20763. });
  20764. return this._callStart();
  20765. },
  20766. // calls after ALL animations in the queue are finished
  20767. afterAll: function afterAll(fn) {
  20768. var wrapper = function wrapper(e) {
  20769. fn.call(this);
  20770. this.off('allfinished.fx', wrapper);
  20771. }; // see above
  20772. this.target().off('allfinished.fx', wrapper).on('allfinished.fx', wrapper);
  20773. return this._callStart();
  20774. },
  20775. last: function last() {
  20776. return this.situations.length ? this.situations[this.situations.length - 1] : this.situation;
  20777. },
  20778. // adds one property to the animations
  20779. add: function add(method, args, type) {
  20780. this.last()[type || 'animations'][method] = args;
  20781. return this._callStart();
  20782. },
  20783. /** perform one step of the animation
  20784. * @param ignoreTime Boolean indicating whether to ignore time and use position directly or recalculate position based on time
  20785. * @return this
  20786. */
  20787. step: function step(ignoreTime) {
  20788. // convert current time to an absolute position
  20789. if (!ignoreTime) this.absPos = this.timeToAbsPos(+new Date()); // This part convert an absolute position to a position
  20790. if (this.situation.loops !== false) {
  20791. var absPos, absPosInt, lastLoop; // If the absolute position is below 0, we just treat it as if it was 0
  20792. absPos = Math.max(this.absPos, 0);
  20793. absPosInt = Math.floor(absPos);
  20794. if (this.situation.loops === true || absPosInt < this.situation.loops) {
  20795. this.pos = absPos - absPosInt;
  20796. lastLoop = this.situation.loop;
  20797. this.situation.loop = absPosInt;
  20798. } else {
  20799. this.absPos = this.situation.loops;
  20800. this.pos = 1; // The -1 here is because we don't want to toggle reversed when all the loops have been completed
  20801. lastLoop = this.situation.loop - 1;
  20802. this.situation.loop = this.situation.loops;
  20803. }
  20804. if (this.situation.reversing) {
  20805. // Toggle reversed if an odd number of loops as occured since the last call of step
  20806. this.situation.reversed = this.situation.reversed != Boolean((this.situation.loop - lastLoop) % 2);
  20807. }
  20808. } else {
  20809. // If there are no loop, the absolute position must not be above 1
  20810. this.absPos = Math.min(this.absPos, 1);
  20811. this.pos = this.absPos;
  20812. } // while the absolute position can be below 0, the position must not be below 0
  20813. if (this.pos < 0) this.pos = 0;
  20814. if (this.situation.reversed) this.pos = 1 - this.pos; // apply easing
  20815. var eased = this.situation.ease(this.pos); // call once-callbacks
  20816. for (var i in this.situation.once) {
  20817. if (i > this.lastPos && i <= eased) {
  20818. this.situation.once[i].call(this.target(), this.pos, eased);
  20819. delete this.situation.once[i];
  20820. }
  20821. } // fire during callback with position, eased position and current situation as parameter
  20822. if (this.active) this.target().fire('during', {
  20823. pos: this.pos,
  20824. eased: eased,
  20825. fx: this,
  20826. situation: this.situation
  20827. }); // the user may call stop or finish in the during callback
  20828. // so make sure that we still have a valid situation
  20829. if (!this.situation) {
  20830. return this;
  20831. } // apply the actual animation to every property
  20832. this.eachAt(); // do final code when situation is finished
  20833. if (this.pos == 1 && !this.situation.reversed || this.situation.reversed && this.pos == 0) {
  20834. // stop animation callback
  20835. this.stopAnimFrame(); // fire finished callback with current situation as parameter
  20836. this.target().fire('finished', {
  20837. fx: this,
  20838. situation: this.situation
  20839. });
  20840. if (!this.situations.length) {
  20841. this.target().fire('allfinished'); // Recheck the length since the user may call animate in the afterAll callback
  20842. if (!this.situations.length) {
  20843. this.target().off('.fx'); // there shouldnt be any binding left, but to make sure...
  20844. this.active = false;
  20845. }
  20846. } // start next animation
  20847. if (this.active) this.dequeue();else this.clearCurrent();
  20848. } else if (!this.paused && this.active) {
  20849. // we continue animating when we are not at the end
  20850. this.startAnimFrame();
  20851. } // save last eased position for once callback triggering
  20852. this.lastPos = eased;
  20853. return this;
  20854. },
  20855. // calculates the step for every property and calls block with it
  20856. eachAt: function eachAt() {
  20857. var len,
  20858. at,
  20859. self = this,
  20860. target = this.target(),
  20861. s = this.situation; // apply animations which can be called trough a method
  20862. for (var i in s.animations) {
  20863. at = [].concat(s.animations[i]).map(function (el) {
  20864. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  20865. });
  20866. target[i].apply(target, at);
  20867. } // apply animation which has to be applied with attr()
  20868. for (var i in s.attrs) {
  20869. at = [i].concat(s.attrs[i]).map(function (el) {
  20870. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  20871. });
  20872. target.attr.apply(target, at);
  20873. } // apply animation which has to be applied with style()
  20874. for (var i in s.styles) {
  20875. at = [i].concat(s.styles[i]).map(function (el) {
  20876. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  20877. });
  20878. target.style.apply(target, at);
  20879. } // animate initialTransformation which has to be chained
  20880. if (s.transforms.length) {
  20881. // get initial initialTransformation
  20882. at = s.initialTransformation;
  20883. for (var i = 0, len = s.transforms.length; i < len; i++) {
  20884. // get next transformation in chain
  20885. var a = s.transforms[i]; // multiply matrix directly
  20886. if (a instanceof SVG.Matrix) {
  20887. if (a.relative) {
  20888. at = at.multiply(new SVG.Matrix().morph(a).at(s.ease(this.pos)));
  20889. } else {
  20890. at = at.morph(a).at(s.ease(this.pos));
  20891. }
  20892. continue;
  20893. } // when transformation is absolute we have to reset the needed transformation first
  20894. if (!a.relative) {
  20895. a.undo(at.extract());
  20896. } // and reapply it after
  20897. at = at.multiply(a.at(s.ease(this.pos)));
  20898. } // set new matrix on element
  20899. target.matrix(at);
  20900. }
  20901. return this;
  20902. },
  20903. // adds an once-callback which is called at a specific position and never again
  20904. once: function once(pos, fn, isEased) {
  20905. var c = this.last();
  20906. if (!isEased) pos = c.ease(pos);
  20907. c.once[pos] = fn;
  20908. return this;
  20909. },
  20910. _callStart: function _callStart() {
  20911. setTimeout(function () {
  20912. this.start();
  20913. }.bind(this), 0);
  20914. return this;
  20915. }
  20916. },
  20917. parent: SVG.Element,
  20918. // Add method to parent elements
  20919. construct: {
  20920. // Get fx module or create a new one, then animate with given duration and ease
  20921. animate: function animate(o, ease, delay) {
  20922. return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay);
  20923. },
  20924. delay: function delay(_delay) {
  20925. return (this.fx || (this.fx = new SVG.FX(this))).delay(_delay);
  20926. },
  20927. stop: function stop(jumpToEnd, clearQueue) {
  20928. if (this.fx) {
  20929. this.fx.stop(jumpToEnd, clearQueue);
  20930. }
  20931. return this;
  20932. },
  20933. finish: function finish() {
  20934. if (this.fx) {
  20935. this.fx.finish();
  20936. }
  20937. return this;
  20938. }
  20939. }
  20940. }); // MorphObj is used whenever no morphable object is given
  20941. SVG.MorphObj = SVG.invent({
  20942. create: function create(from, to) {
  20943. // prepare color for morphing
  20944. if (SVG.Color.isColor(to)) return new SVG.Color(from).morph(to); // check if we have a list of values
  20945. if (SVG.regex.delimiter.test(from)) {
  20946. // prepare path for morphing
  20947. if (SVG.regex.pathLetters.test(from)) return new SVG.PathArray(from).morph(to); // prepare value list for morphing
  20948. else return new SVG.Array(from).morph(to);
  20949. } // prepare number for morphing
  20950. if (SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to); // prepare for plain morphing
  20951. this.value = from;
  20952. this.destination = to;
  20953. },
  20954. extend: {
  20955. at: function at(pos, real) {
  20956. return real < 1 ? this.value : this.destination;
  20957. },
  20958. valueOf: function valueOf() {
  20959. return this.value;
  20960. }
  20961. }
  20962. });
  20963. SVG.extend(SVG.FX, {
  20964. // Add animatable attributes
  20965. attr: function attr(a, v, relative) {
  20966. // apply attributes individually
  20967. if (_typeof(a) === 'object') {
  20968. for (var key in a) {
  20969. this.attr(key, a[key]);
  20970. }
  20971. } else {
  20972. this.add(a, v, 'attrs');
  20973. }
  20974. return this;
  20975. },
  20976. // Add animatable plot
  20977. plot: function plot(a, b, c, d) {
  20978. // Lines can be plotted with 4 arguments
  20979. if (arguments.length == 4) {
  20980. return this.plot([a, b, c, d]);
  20981. }
  20982. return this.add('plot', new (this.target().morphArray)(a));
  20983. }
  20984. });
  20985. SVG.Box = SVG.invent({
  20986. create: function create(x, y, width, height) {
  20987. if (_typeof(x) === 'object' && !(x instanceof SVG.Element)) {
  20988. // chromes getBoundingClientRect has no x and y property
  20989. return SVG.Box.call(this, x.left != null ? x.left : x.x, x.top != null ? x.top : x.y, x.width, x.height);
  20990. } else if (arguments.length == 4) {
  20991. this.x = x;
  20992. this.y = y;
  20993. this.width = width;
  20994. this.height = height;
  20995. } // add center, right, bottom...
  20996. fullBox(this);
  20997. }
  20998. });
  20999. SVG.BBox = SVG.invent({
  21000. // Initialize
  21001. create: function create(element) {
  21002. SVG.Box.apply(this, [].slice.call(arguments)); // get values if element is given
  21003. if (element instanceof SVG.Element) {
  21004. var box; // yes this is ugly, but Firefox can be a pain when it comes to elements that are not yet rendered
  21005. try {
  21006. if (!document.documentElement.contains) {
  21007. // This is IE - it does not support contains() for top-level SVGs
  21008. var topParent = element.node;
  21009. while (topParent.parentNode) {
  21010. topParent = topParent.parentNode;
  21011. }
  21012. if (topParent != document) throw new Error('Element not in the dom');
  21013. } else {} // the element is NOT in the dom, throw error
  21014. // disabling the check below which fixes issue #76
  21015. // if (!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
  21016. // find native bbox
  21017. box = element.node.getBBox();
  21018. } catch (e) {
  21019. if (element instanceof SVG.Shape) {
  21020. if (!SVG.parser.draw) {
  21021. // fixes apexcharts/vue-apexcharts #14
  21022. SVG.prepare();
  21023. }
  21024. var clone = element.clone(SVG.parser.draw.instance).show();
  21025. box = clone.node.getBBox();
  21026. clone.remove();
  21027. } else {
  21028. box = {
  21029. x: element.node.clientLeft,
  21030. y: element.node.clientTop,
  21031. width: element.node.clientWidth,
  21032. height: element.node.clientHeight
  21033. };
  21034. }
  21035. }
  21036. SVG.Box.call(this, box);
  21037. }
  21038. },
  21039. // Define ancestor
  21040. inherit: SVG.Box,
  21041. // Define Parent
  21042. parent: SVG.Element,
  21043. // Constructor
  21044. construct: {
  21045. // Get bounding box
  21046. bbox: function bbox() {
  21047. return new SVG.BBox(this);
  21048. }
  21049. }
  21050. });
  21051. SVG.BBox.prototype.constructor = SVG.BBox;
  21052. SVG.Matrix = SVG.invent({
  21053. // Initialize
  21054. create: function create(source) {
  21055. var base = arrayToMatrix([1, 0, 0, 1, 0, 0]); // ensure source as object
  21056. 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; // merge source
  21057. for (var i = abcdef.length - 1; i >= 0; --i) {
  21058. this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]];
  21059. }
  21060. },
  21061. // Add methods
  21062. extend: {
  21063. // Extract individual transformations
  21064. extract: function extract() {
  21065. // find delta transform points
  21066. var px = deltaTransformPoint(this, 0, 1),
  21067. py = deltaTransformPoint(this, 1, 0),
  21068. skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90;
  21069. return {
  21070. // translation
  21071. x: this.e,
  21072. y: this.f,
  21073. 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),
  21074. 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),
  21075. // rotation
  21076. rotation: skewX,
  21077. a: this.a,
  21078. b: this.b,
  21079. c: this.c,
  21080. d: this.d,
  21081. e: this.e,
  21082. f: this.f,
  21083. matrix: new SVG.Matrix(this)
  21084. };
  21085. },
  21086. // Clone matrix
  21087. clone: function clone() {
  21088. return new SVG.Matrix(this);
  21089. },
  21090. // Morph one matrix into another
  21091. morph: function morph(matrix) {
  21092. // store new destination
  21093. this.destination = new SVG.Matrix(matrix);
  21094. return this;
  21095. },
  21096. // Multiplies by given matrix
  21097. multiply: function multiply(matrix) {
  21098. return new SVG.Matrix(this.native().multiply(parseMatrix(matrix).native()));
  21099. },
  21100. // Inverses matrix
  21101. inverse: function inverse() {
  21102. return new SVG.Matrix(this.native().inverse());
  21103. },
  21104. // Translate matrix
  21105. translate: function translate(x, y) {
  21106. return new SVG.Matrix(this.native().translate(x || 0, y || 0));
  21107. },
  21108. // Convert to native SVGMatrix
  21109. native: function native() {
  21110. // create new matrix
  21111. var matrix = SVG.parser.native.createSVGMatrix(); // update with current values
  21112. for (var i = abcdef.length - 1; i >= 0; i--) {
  21113. matrix[abcdef[i]] = this[abcdef[i]];
  21114. }
  21115. return matrix;
  21116. },
  21117. // Convert matrix to string
  21118. toString: function toString() {
  21119. // Construct the matrix directly, avoid values that are too small
  21120. return 'matrix(' + float32String(this.a) + ',' + float32String(this.b) + ',' + float32String(this.c) + ',' + float32String(this.d) + ',' + float32String(this.e) + ',' + float32String(this.f) + ')';
  21121. }
  21122. },
  21123. // Define parent
  21124. parent: SVG.Element,
  21125. // Add parent method
  21126. construct: {
  21127. // Get current matrix
  21128. ctm: function ctm() {
  21129. return new SVG.Matrix(this.node.getCTM());
  21130. },
  21131. // Get current screen matrix
  21132. screenCTM: function screenCTM() {
  21133. /* https://bugzilla.mozilla.org/show_bug.cgi?id=1344537
  21134. This is needed because FF does not return the transformation matrix
  21135. for the inner coordinate system when getScreenCTM() is called on nested svgs.
  21136. However all other Browsers do that */
  21137. if (this instanceof SVG.Nested) {
  21138. var rect = this.rect(1, 1);
  21139. var m = rect.node.getScreenCTM();
  21140. rect.remove();
  21141. return new SVG.Matrix(m);
  21142. }
  21143. return new SVG.Matrix(this.node.getScreenCTM());
  21144. }
  21145. }
  21146. });
  21147. SVG.Point = SVG.invent({
  21148. // Initialize
  21149. create: function create(x, y) {
  21150. var source,
  21151. base = {
  21152. x: 0,
  21153. y: 0
  21154. }; // ensure source as object
  21155. source = Array.isArray(x) ? {
  21156. x: x[0],
  21157. y: x[1]
  21158. } : _typeof(x) === 'object' ? {
  21159. x: x.x,
  21160. y: x.y
  21161. } : x != null ? {
  21162. x: x,
  21163. y: y != null ? y : x
  21164. } : base; // If y has no value, then x is used has its value
  21165. // merge source
  21166. this.x = source.x;
  21167. this.y = source.y;
  21168. },
  21169. // Add methods
  21170. extend: {
  21171. // Clone point
  21172. clone: function clone() {
  21173. return new SVG.Point(this);
  21174. },
  21175. // Morph one point into another
  21176. morph: function morph(x, y) {
  21177. // store new destination
  21178. this.destination = new SVG.Point(x, y);
  21179. return this;
  21180. }
  21181. }
  21182. });
  21183. SVG.extend(SVG.Element, {
  21184. // Get point
  21185. point: function point(x, y) {
  21186. return new SVG.Point(x, y).transform(this.screenCTM().inverse());
  21187. }
  21188. });
  21189. SVG.extend(SVG.Element, {
  21190. // Set svg element attribute
  21191. attr: function attr(a, v, n) {
  21192. // act as full getter
  21193. if (a == null) {
  21194. // get an object of attributes
  21195. a = {};
  21196. v = this.node.attributes;
  21197. for (var n = v.length - 1; n >= 0; n--) {
  21198. a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue;
  21199. }
  21200. return a;
  21201. } else if (_typeof(a) === 'object') {
  21202. // apply every attribute individually if an object is passed
  21203. for (var v_ in a) {
  21204. this.attr(v_, a[v_]);
  21205. }
  21206. } else if (v === null) {
  21207. // remove value
  21208. this.node.removeAttribute(a);
  21209. } else if (v == null) {
  21210. // act as a getter if the first and only argument is not an object
  21211. v = this.node.getAttribute(a);
  21212. return v == null ? SVG.defaults.attrs[a] : SVG.regex.isNumber.test(v) ? parseFloat(v) : v;
  21213. } else {
  21214. // BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0
  21215. if (a == 'stroke-width') {
  21216. this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null);
  21217. } else if (a == 'stroke') {
  21218. this._stroke = v;
  21219. } // convert image fill and stroke to patterns
  21220. if (a == 'fill' || a == 'stroke') {
  21221. if (SVG.regex.isImage.test(v)) {
  21222. v = this.doc().defs().image(v, 0, 0);
  21223. }
  21224. if (v instanceof SVG.Image) {
  21225. v = this.doc().defs().pattern(0, 0, function () {
  21226. this.add(v);
  21227. });
  21228. }
  21229. } // ensure correct numeric values (also accepts NaN and Infinity)
  21230. if (typeof v === 'number') {
  21231. v = new SVG.Number(v);
  21232. } // ensure full hex color
  21233. else if (SVG.Color.isColor(v)) {
  21234. v = new SVG.Color(v);
  21235. } // parse array values
  21236. else if (Array.isArray(v)) {
  21237. v = new SVG.Array(v);
  21238. } // if the passed attribute is leading...
  21239. if (a == 'leading') {
  21240. // ... call the leading method instead
  21241. if (this.leading) {
  21242. this.leading(v);
  21243. }
  21244. } else {
  21245. // set given attribute on node
  21246. typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString());
  21247. } // rebuild if required
  21248. if (this.rebuild && (a == 'font-size' || a == 'x')) {
  21249. this.rebuild(a, v);
  21250. }
  21251. }
  21252. return this;
  21253. }
  21254. });
  21255. SVG.extend(SVG.Element, {
  21256. // Add transformations
  21257. transform: function transform(o, relative) {
  21258. // get target in case of the fx module, otherwise reference this
  21259. var target = this,
  21260. matrix;
  21261. // act as a getter
  21262. if (_typeof(o) !== 'object') {
  21263. // get current matrix
  21264. matrix = new SVG.Matrix(target).extract();
  21265. return typeof o === 'string' ? matrix[o] : matrix;
  21266. } // get current matrix
  21267. matrix = new SVG.Matrix(target); // ensure relative flag
  21268. relative = !!relative || !!o.relative; // act on matrix
  21269. if (o.a != null) {
  21270. matrix = relative // relative
  21271. ? matrix.multiply(new SVG.Matrix(o)) // absolute
  21272. : new SVG.Matrix(o);
  21273. }
  21274. return this.attr('transform', matrix);
  21275. }
  21276. });
  21277. SVG.extend(SVG.Element, {
  21278. // Reset all transformations
  21279. untransform: function untransform() {
  21280. return this.attr('transform', null);
  21281. },
  21282. // merge the whole transformation chain into one matrix and returns it
  21283. matrixify: function matrixify() {
  21284. var matrix = (this.attr('transform') || ''). // split transformations
  21285. split(SVG.regex.transforms).slice(0, -1).map(function (str) {
  21286. // generate key => value pairs
  21287. var kv = str.trim().split('(');
  21288. return [kv[0], kv[1].split(SVG.regex.delimiter).map(function (str) {
  21289. return parseFloat(str);
  21290. })];
  21291. }) // merge every transformation into one matrix
  21292. .reduce(function (matrix, transform) {
  21293. if (transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]));
  21294. return matrix[transform[0]].apply(matrix, transform[1]);
  21295. }, new SVG.Matrix());
  21296. return matrix;
  21297. },
  21298. // add an element to another parent without changing the visual representation on the screen
  21299. toParent: function toParent(parent) {
  21300. if (this == parent) return this;
  21301. var ctm = this.screenCTM();
  21302. var pCtm = parent.screenCTM().inverse();
  21303. this.addTo(parent).untransform().transform(pCtm.multiply(ctm));
  21304. return this;
  21305. },
  21306. // same as above with parent equals root-svg
  21307. toDoc: function toDoc() {
  21308. return this.toParent(this.doc());
  21309. }
  21310. });
  21311. SVG.Transformation = SVG.invent({
  21312. create: function create(source, inversed) {
  21313. if (arguments.length > 1 && typeof inversed !== 'boolean') {
  21314. return this.constructor.call(this, [].slice.call(arguments));
  21315. }
  21316. if (Array.isArray(source)) {
  21317. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  21318. this[this.arguments[i]] = source[i];
  21319. }
  21320. } else if (_typeof(source) === 'object') {
  21321. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  21322. this[this.arguments[i]] = source[this.arguments[i]];
  21323. }
  21324. }
  21325. this.inversed = false;
  21326. if (inversed === true) {
  21327. this.inversed = true;
  21328. }
  21329. }
  21330. });
  21331. SVG.Translate = SVG.invent({
  21332. parent: SVG.Matrix,
  21333. inherit: SVG.Transformation,
  21334. create: function create(source, inversed) {
  21335. this.constructor.apply(this, [].slice.call(arguments));
  21336. },
  21337. extend: {
  21338. arguments: ['transformedX', 'transformedY'],
  21339. method: 'translate'
  21340. }
  21341. });
  21342. SVG.extend(SVG.Element, {
  21343. // Dynamic style generator
  21344. style: function style(s, v) {
  21345. if (arguments.length == 0) {
  21346. // get full style
  21347. return this.node.style.cssText || '';
  21348. } else if (arguments.length < 2) {
  21349. // apply every style individually if an object is passed
  21350. if (_typeof(s) === 'object') {
  21351. for (var v_ in s) {
  21352. this.style(v_, s[v_]);
  21353. }
  21354. } else if (SVG.regex.isCss.test(s)) {
  21355. // parse css string
  21356. s = s.split(/\s*;\s*/) // filter out suffix ; and stuff like ;;
  21357. .filter(function (e) {
  21358. return !!e;
  21359. }).map(function (e) {
  21360. return e.split(/\s*:\s*/);
  21361. }); // apply every definition individually
  21362. while (v = s.pop()) {
  21363. this.style(v[0], v[1]);
  21364. }
  21365. } else {
  21366. // act as a getter if the first and only argument is not an object
  21367. return this.node.style[camelCase(s)];
  21368. }
  21369. } else {
  21370. this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v;
  21371. }
  21372. return this;
  21373. }
  21374. });
  21375. SVG.Parent = SVG.invent({
  21376. // Initialize node
  21377. create: function create(element) {
  21378. this.constructor.call(this, element);
  21379. },
  21380. // Inherit from
  21381. inherit: SVG.Element,
  21382. // Add class methods
  21383. extend: {
  21384. // Returns all child elements
  21385. children: function children() {
  21386. return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function (node) {
  21387. return SVG.adopt(node);
  21388. });
  21389. },
  21390. // Add given element at a position
  21391. add: function add(element, i) {
  21392. if (i == null) {
  21393. this.node.appendChild(element.node);
  21394. } else if (element.node != this.node.childNodes[i]) {
  21395. this.node.insertBefore(element.node, this.node.childNodes[i]);
  21396. }
  21397. return this;
  21398. },
  21399. // Basically does the same as `add()` but returns the added element instead
  21400. put: function put(element, i) {
  21401. this.add(element, i);
  21402. return element;
  21403. },
  21404. // Checks if the given element is a child
  21405. has: function has(element) {
  21406. return this.index(element) >= 0;
  21407. },
  21408. // Gets index of given element
  21409. index: function index(element) {
  21410. return [].slice.call(this.node.childNodes).indexOf(element.node);
  21411. },
  21412. // Get a element at the given index
  21413. get: function get(i) {
  21414. return SVG.adopt(this.node.childNodes[i]);
  21415. },
  21416. // Get first child
  21417. first: function first() {
  21418. return this.get(0);
  21419. },
  21420. // Get the last child
  21421. last: function last() {
  21422. return this.get(this.node.childNodes.length - 1);
  21423. },
  21424. // Iterates over all children and invokes a given block
  21425. each: function each(block, deep) {
  21426. var il,
  21427. children = this.children();
  21428. for (var i = 0, il = children.length; i < il; i++) {
  21429. if (children[i] instanceof SVG.Element) {
  21430. block.apply(children[i], [i, children]);
  21431. }
  21432. if (deep && children[i] instanceof SVG.Container) {
  21433. children[i].each(block, deep);
  21434. }
  21435. }
  21436. return this;
  21437. },
  21438. // Remove a given child
  21439. removeElement: function removeElement(element) {
  21440. this.node.removeChild(element.node);
  21441. return this;
  21442. },
  21443. // Remove all elements in this container
  21444. clear: function clear() {
  21445. // remove children
  21446. while (this.node.hasChildNodes()) {
  21447. this.node.removeChild(this.node.lastChild);
  21448. } // remove defs reference
  21449. delete this._defs;
  21450. return this;
  21451. },
  21452. // Get defs
  21453. defs: function defs() {
  21454. return this.doc().defs();
  21455. }
  21456. }
  21457. });
  21458. SVG.extend(SVG.Parent, {
  21459. ungroup: function ungroup(parent, depth) {
  21460. if (depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this;
  21461. parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent));
  21462. depth = depth || Infinity;
  21463. this.each(function () {
  21464. if (this instanceof SVG.Defs) return this;
  21465. if (this instanceof SVG.Parent) return this.ungroup(parent, depth - 1);
  21466. return this.toParent(parent);
  21467. });
  21468. this.node.firstChild || this.remove();
  21469. return this;
  21470. },
  21471. flatten: function flatten(parent, depth) {
  21472. return this.ungroup(parent, depth);
  21473. }
  21474. });
  21475. SVG.Container = SVG.invent({
  21476. // Initialize node
  21477. create: function create(element) {
  21478. this.constructor.call(this, element);
  21479. },
  21480. // Inherit from
  21481. inherit: SVG.Parent
  21482. });
  21483. SVG.ViewBox = SVG.invent({
  21484. // Define parent
  21485. parent: SVG.Container,
  21486. // Add parent method
  21487. construct: {}
  21488. }) // Add events to elements
  21489. ;
  21490. ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove', // , 'mouseenter' -> not supported by IE
  21491. // , 'mouseleave' -> not supported by IE
  21492. 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].forEach(function (event) {
  21493. // add event to SVG.Element
  21494. SVG.Element.prototype[event] = function (f) {
  21495. // bind event to element rather than element node
  21496. SVG.on(this.node, event, f);
  21497. return this;
  21498. };
  21499. }); // Initialize listeners stack
  21500. SVG.listeners = [];
  21501. SVG.handlerMap = [];
  21502. SVG.listenerId = 0; // Add event binder in the SVG namespace
  21503. SVG.on = function (node, event, listener, binding, options) {
  21504. // create listener, get object-index
  21505. var l = listener.bind(binding || node.instance || node),
  21506. index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1,
  21507. ev = event.split('.')[0],
  21508. ns = event.split('.')[1] || '*'; // ensure valid object
  21509. SVG.listeners[index] = SVG.listeners[index] || {};
  21510. SVG.listeners[index][ev] = SVG.listeners[index][ev] || {};
  21511. SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {};
  21512. if (!listener._svgjsListenerId) {
  21513. listener._svgjsListenerId = ++SVG.listenerId;
  21514. } // reference listener
  21515. SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l; // add listener
  21516. node.addEventListener(ev, l, options || false);
  21517. }; // Add event unbinder in the SVG namespace
  21518. SVG.off = function (node, event, listener) {
  21519. var index = SVG.handlerMap.indexOf(node),
  21520. ev = event && event.split('.')[0],
  21521. ns = event && event.split('.')[1],
  21522. namespace = '';
  21523. if (index == -1) return;
  21524. if (listener) {
  21525. if (typeof listener === 'function') listener = listener._svgjsListenerId;
  21526. if (!listener) return; // remove listener reference
  21527. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) {
  21528. // remove listener
  21529. node.removeEventListener(ev, SVG.listeners[index][ev][ns || '*'][listener], false);
  21530. delete SVG.listeners[index][ev][ns || '*'][listener];
  21531. }
  21532. } else if (ns && ev) {
  21533. // remove all listeners for a namespaced event
  21534. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns]) {
  21535. for (var listener_ in SVG.listeners[index][ev][ns]) {
  21536. SVG.off(node, [ev, ns].join('.'), listener_);
  21537. }
  21538. delete SVG.listeners[index][ev][ns];
  21539. }
  21540. } else if (ns) {
  21541. // remove all listeners for a specific namespace
  21542. for (var event_ in SVG.listeners[index]) {
  21543. for (var namespace in SVG.listeners[index][event_]) {
  21544. if (ns === namespace) {
  21545. SVG.off(node, [event_, ns].join('.'));
  21546. }
  21547. }
  21548. }
  21549. } else if (ev) {
  21550. // remove all listeners for the event
  21551. if (SVG.listeners[index][ev]) {
  21552. for (var namespace in SVG.listeners[index][ev]) {
  21553. SVG.off(node, [ev, namespace].join('.'));
  21554. }
  21555. delete SVG.listeners[index][ev];
  21556. }
  21557. } else {
  21558. // remove all listeners on a given node
  21559. for (var event_ in SVG.listeners[index]) {
  21560. SVG.off(node, event_);
  21561. }
  21562. delete SVG.listeners[index];
  21563. delete SVG.handlerMap[index];
  21564. }
  21565. }; //
  21566. SVG.extend(SVG.Element, {
  21567. // Bind given event to listener
  21568. on: function on(event, listener, binding, options) {
  21569. SVG.on(this.node, event, listener, binding, options);
  21570. return this;
  21571. },
  21572. // Unbind event from listener
  21573. off: function off(event, listener) {
  21574. SVG.off(this.node, event, listener);
  21575. return this;
  21576. },
  21577. // Fire given event
  21578. fire: function fire(event, data) {
  21579. // Dispatch event
  21580. if (event instanceof window.Event) {
  21581. this.node.dispatchEvent(event);
  21582. } else {
  21583. this.node.dispatchEvent(event = new SVG.CustomEvent(event, {
  21584. detail: data,
  21585. cancelable: true
  21586. }));
  21587. }
  21588. this._event = event;
  21589. return this;
  21590. },
  21591. event: function event() {
  21592. return this._event;
  21593. }
  21594. });
  21595. SVG.Defs = SVG.invent({
  21596. // Initialize node
  21597. create: 'defs',
  21598. // Inherit from
  21599. inherit: SVG.Container
  21600. });
  21601. SVG.G = SVG.invent({
  21602. // Initialize node
  21603. create: 'g',
  21604. // Inherit from
  21605. inherit: SVG.Container,
  21606. // Add class methods
  21607. extend: {
  21608. // Move over x-axis
  21609. x: function x(_x2) {
  21610. return _x2 == null ? this.transform('x') : this.transform({
  21611. x: _x2 - this.x()
  21612. }, true);
  21613. }
  21614. },
  21615. // Add parent method
  21616. construct: {
  21617. // Create a group element
  21618. group: function group() {
  21619. return this.put(new SVG.G());
  21620. }
  21621. }
  21622. });
  21623. SVG.Doc = SVG.invent({
  21624. // Initialize node
  21625. create: function create(element) {
  21626. if (element) {
  21627. // ensure the presence of a dom element
  21628. element = typeof element === 'string' ? document.getElementById(element) : element; // If the target is an svg element, use that element as the main wrapper.
  21629. // This allows svg.js to work with svg documents as well.
  21630. if (element.nodeName == 'svg') {
  21631. this.constructor.call(this, element);
  21632. } else {
  21633. this.constructor.call(this, SVG.create('svg'));
  21634. element.appendChild(this.node);
  21635. this.size('100%', '100%');
  21636. } // set svg element attributes and ensure defs node
  21637. this.namespace().defs();
  21638. }
  21639. },
  21640. // Inherit from
  21641. inherit: SVG.Container,
  21642. // Add class methods
  21643. extend: {
  21644. // Add namespaces
  21645. namespace: function namespace() {
  21646. return this.attr({
  21647. xmlns: SVG.ns,
  21648. version: '1.1'
  21649. }).attr('xmlns:xlink', SVG.xlink, SVG.xmlns).attr('xmlns:svgjs', SVG.svgjs, SVG.xmlns);
  21650. },
  21651. // Creates and returns defs element
  21652. defs: function defs() {
  21653. if (!this._defs) {
  21654. var defs; // Find or create a defs element in this instance
  21655. if (defs = this.node.getElementsByTagName('defs')[0]) {
  21656. this._defs = SVG.adopt(defs);
  21657. } else {
  21658. this._defs = new SVG.Defs();
  21659. } // Make sure the defs node is at the end of the stack
  21660. this.node.appendChild(this._defs.node);
  21661. }
  21662. return this._defs;
  21663. },
  21664. // custom parent method
  21665. parent: function parent() {
  21666. if (!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null;
  21667. return this.node.parentNode;
  21668. },
  21669. // Removes the doc from the DOM
  21670. remove: function remove() {
  21671. if (this.parent()) {
  21672. this.parent().removeChild(this.node);
  21673. }
  21674. return this;
  21675. },
  21676. clear: function clear() {
  21677. // remove children
  21678. while (this.node.hasChildNodes()) {
  21679. this.node.removeChild(this.node.lastChild);
  21680. } // remove defs reference
  21681. delete this._defs; // add back parser
  21682. if (SVG.parser.draw && !SVG.parser.draw.parentNode) {
  21683. this.node.appendChild(SVG.parser.draw);
  21684. }
  21685. return this;
  21686. },
  21687. clone: function clone(parent) {
  21688. // write dom data to the dom so the clone can pickup the data
  21689. this.writeDataToDom(); // get reference to node
  21690. var node = this.node; // clone element and assign new id
  21691. var clone = assignNewId(node.cloneNode(true)); // insert the clone in the given parent or after myself
  21692. if (parent) {
  21693. (parent.node || parent).appendChild(clone.node);
  21694. } else {
  21695. node.parentNode.insertBefore(clone.node, node.nextSibling);
  21696. }
  21697. return clone;
  21698. }
  21699. }
  21700. }); // ### This module adds backward / forward functionality to elements.
  21701. //
  21702. SVG.extend(SVG.Element, {// Get all siblings, including myself
  21703. });
  21704. SVG.Gradient = SVG.invent({
  21705. // Initialize node
  21706. create: function create(type) {
  21707. this.constructor.call(this, SVG.create(type + 'Gradient')); // store type
  21708. this.type = type;
  21709. },
  21710. // Inherit from
  21711. inherit: SVG.Container,
  21712. // Add class methods
  21713. extend: {
  21714. // Add a color stop
  21715. at: function at(offset, color, opacity) {
  21716. return this.put(new SVG.Stop()).update(offset, color, opacity);
  21717. },
  21718. // Update gradient
  21719. update: function update(block) {
  21720. // remove all stops
  21721. this.clear(); // invoke passed block
  21722. if (typeof block === 'function') {
  21723. block.call(this, this);
  21724. }
  21725. return this;
  21726. },
  21727. // Return the fill id
  21728. fill: function fill() {
  21729. return 'url(#' + this.id() + ')';
  21730. },
  21731. // Alias string convertion to fill
  21732. toString: function toString() {
  21733. return this.fill();
  21734. },
  21735. // custom attr to handle transform
  21736. attr: function attr(a, b, c) {
  21737. if (a == 'transform') a = 'gradientTransform';
  21738. return SVG.Container.prototype.attr.call(this, a, b, c);
  21739. }
  21740. },
  21741. // Add parent method
  21742. construct: {
  21743. // Create gradient element in defs
  21744. gradient: function gradient(type, block) {
  21745. return this.defs().gradient(type, block);
  21746. }
  21747. }
  21748. }); // Add animatable methods to both gradient and fx module
  21749. SVG.extend(SVG.Gradient, SVG.FX, {
  21750. // From position
  21751. from: function from(x, y) {
  21752. return (this._target || this).type == 'radial' ? this.attr({
  21753. fx: new SVG.Number(x),
  21754. fy: new SVG.Number(y)
  21755. }) : this.attr({
  21756. x1: new SVG.Number(x),
  21757. y1: new SVG.Number(y)
  21758. });
  21759. },
  21760. // To position
  21761. to: function to(x, y) {
  21762. return (this._target || this).type == 'radial' ? this.attr({
  21763. cx: new SVG.Number(x),
  21764. cy: new SVG.Number(y)
  21765. }) : this.attr({
  21766. x2: new SVG.Number(x),
  21767. y2: new SVG.Number(y)
  21768. });
  21769. }
  21770. }); // Base gradient generation
  21771. SVG.extend(SVG.Defs, {
  21772. // define gradient
  21773. gradient: function gradient(type, block) {
  21774. return this.put(new SVG.Gradient(type)).update(block);
  21775. }
  21776. });
  21777. SVG.Stop = SVG.invent({
  21778. // Initialize node
  21779. create: 'stop',
  21780. // Inherit from
  21781. inherit: SVG.Element,
  21782. // Add class methods
  21783. extend: {
  21784. // add color stops
  21785. update: function update(o) {
  21786. if (typeof o === 'number' || o instanceof SVG.Number) {
  21787. o = {
  21788. offset: arguments[0],
  21789. color: arguments[1],
  21790. opacity: arguments[2]
  21791. };
  21792. } // set attributes
  21793. if (o.opacity != null) this.attr('stop-opacity', o.opacity);
  21794. if (o.color != null) this.attr('stop-color', o.color);
  21795. if (o.offset != null) this.attr('offset', new SVG.Number(o.offset));
  21796. return this;
  21797. }
  21798. }
  21799. });
  21800. SVG.Pattern = SVG.invent({
  21801. // Initialize node
  21802. create: 'pattern',
  21803. // Inherit from
  21804. inherit: SVG.Container,
  21805. // Add class methods
  21806. extend: {
  21807. // Return the fill id
  21808. fill: function fill() {
  21809. return 'url(#' + this.id() + ')';
  21810. },
  21811. // Update pattern by rebuilding
  21812. update: function update(block) {
  21813. // remove content
  21814. this.clear(); // invoke passed block
  21815. if (typeof block === 'function') {
  21816. block.call(this, this);
  21817. }
  21818. return this;
  21819. },
  21820. // Alias string convertion to fill
  21821. toString: function toString() {
  21822. return this.fill();
  21823. },
  21824. // custom attr to handle transform
  21825. attr: function attr(a, b, c) {
  21826. if (a == 'transform') a = 'patternTransform';
  21827. return SVG.Container.prototype.attr.call(this, a, b, c);
  21828. }
  21829. },
  21830. // Add parent method
  21831. construct: {
  21832. // Create pattern element in defs
  21833. pattern: function pattern(width, height, block) {
  21834. return this.defs().pattern(width, height, block);
  21835. }
  21836. }
  21837. });
  21838. SVG.extend(SVG.Defs, {
  21839. // Define gradient
  21840. pattern: function pattern(width, height, block) {
  21841. return this.put(new SVG.Pattern()).update(block).attr({
  21842. x: 0,
  21843. y: 0,
  21844. width: width,
  21845. height: height,
  21846. patternUnits: 'userSpaceOnUse'
  21847. });
  21848. }
  21849. });
  21850. SVG.Shape = SVG.invent({
  21851. // Initialize node
  21852. create: function create(element) {
  21853. this.constructor.call(this, element);
  21854. },
  21855. // Inherit from
  21856. inherit: SVG.Element
  21857. });
  21858. SVG.Symbol = SVG.invent({
  21859. // Initialize node
  21860. create: 'symbol',
  21861. // Inherit from
  21862. inherit: SVG.Container,
  21863. construct: {
  21864. // create symbol
  21865. symbol: function symbol() {
  21866. return this.put(new SVG.Symbol());
  21867. }
  21868. }
  21869. });
  21870. SVG.Use = SVG.invent({
  21871. // Initialize node
  21872. create: 'use',
  21873. // Inherit from
  21874. inherit: SVG.Shape,
  21875. // Add class methods
  21876. extend: {
  21877. // Use element as a reference
  21878. element: function element(_element, file) {
  21879. // Set lined element
  21880. return this.attr('href', (file || '') + '#' + _element, SVG.xlink);
  21881. }
  21882. },
  21883. // Add parent method
  21884. construct: {
  21885. // Create a use element
  21886. use: function use(element, file) {
  21887. return this.put(new SVG.Use()).element(element, file);
  21888. }
  21889. }
  21890. });
  21891. SVG.Rect = SVG.invent({
  21892. // Initialize node
  21893. create: 'rect',
  21894. // Inherit from
  21895. inherit: SVG.Shape,
  21896. // Add parent method
  21897. construct: {
  21898. // Create a rect element
  21899. rect: function rect(width, height) {
  21900. return this.put(new SVG.Rect()).size(width, height);
  21901. }
  21902. }
  21903. });
  21904. SVG.Circle = SVG.invent({
  21905. // Initialize node
  21906. create: 'circle',
  21907. // Inherit from
  21908. inherit: SVG.Shape,
  21909. // Add parent method
  21910. construct: {
  21911. // Create circle element, based on ellipse
  21912. circle: function circle(size) {
  21913. return this.put(new SVG.Circle()).rx(new SVG.Number(size).divide(2)).move(0, 0);
  21914. }
  21915. }
  21916. });
  21917. SVG.extend(SVG.Circle, SVG.FX, {
  21918. // Radius x value
  21919. rx: function rx(_rx) {
  21920. return this.attr('r', _rx);
  21921. },
  21922. // Alias radius x value
  21923. ry: function ry(_ry) {
  21924. return this.rx(_ry);
  21925. }
  21926. });
  21927. SVG.Ellipse = SVG.invent({
  21928. // Initialize node
  21929. create: 'ellipse',
  21930. // Inherit from
  21931. inherit: SVG.Shape,
  21932. // Add parent method
  21933. construct: {
  21934. // Create an ellipse
  21935. ellipse: function ellipse(width, height) {
  21936. return this.put(new SVG.Ellipse()).size(width, height).move(0, 0);
  21937. }
  21938. }
  21939. });
  21940. SVG.extend(SVG.Ellipse, SVG.Rect, SVG.FX, {
  21941. // Radius x value
  21942. rx: function rx(_rx2) {
  21943. return this.attr('rx', _rx2);
  21944. },
  21945. // Radius y value
  21946. ry: function ry(_ry2) {
  21947. return this.attr('ry', _ry2);
  21948. }
  21949. }); // Add common method
  21950. SVG.extend(SVG.Circle, SVG.Ellipse, {
  21951. // Move over x-axis
  21952. x: function x(_x3) {
  21953. return _x3 == null ? this.cx() - this.rx() : this.cx(_x3 + this.rx());
  21954. },
  21955. // Move over y-axis
  21956. y: function y(_y2) {
  21957. return _y2 == null ? this.cy() - this.ry() : this.cy(_y2 + this.ry());
  21958. },
  21959. // Move by center over x-axis
  21960. cx: function cx(x) {
  21961. return x == null ? this.attr('cx') : this.attr('cx', x);
  21962. },
  21963. // Move by center over y-axis
  21964. cy: function cy(y) {
  21965. return y == null ? this.attr('cy') : this.attr('cy', y);
  21966. },
  21967. // Set width of element
  21968. width: function width(_width2) {
  21969. return _width2 == null ? this.rx() * 2 : this.rx(new SVG.Number(_width2).divide(2));
  21970. },
  21971. // Set height of element
  21972. height: function height(_height2) {
  21973. return _height2 == null ? this.ry() * 2 : this.ry(new SVG.Number(_height2).divide(2));
  21974. },
  21975. // Custom size function
  21976. size: function size(width, height) {
  21977. var p = proportionalSize(this, width, height);
  21978. return this.rx(new SVG.Number(p.width).divide(2)).ry(new SVG.Number(p.height).divide(2));
  21979. }
  21980. });
  21981. SVG.Line = SVG.invent({
  21982. // Initialize node
  21983. create: 'line',
  21984. // Inherit from
  21985. inherit: SVG.Shape,
  21986. // Add class methods
  21987. extend: {
  21988. // Get array
  21989. array: function array() {
  21990. return new SVG.PointArray([[this.attr('x1'), this.attr('y1')], [this.attr('x2'), this.attr('y2')]]);
  21991. },
  21992. // Overwrite native plot() method
  21993. plot: function plot(x1, y1, x2, y2) {
  21994. if (x1 == null) {
  21995. return this.array();
  21996. } else if (typeof y1 !== 'undefined') {
  21997. x1 = {
  21998. x1: x1,
  21999. y1: y1,
  22000. x2: x2,
  22001. y2: y2
  22002. };
  22003. } else {
  22004. x1 = new SVG.PointArray(x1).toLine();
  22005. }
  22006. return this.attr(x1);
  22007. },
  22008. // Move by left top corner
  22009. move: function move(x, y) {
  22010. return this.attr(this.array().move(x, y).toLine());
  22011. },
  22012. // Set element size to given width and height
  22013. size: function size(width, height) {
  22014. var p = proportionalSize(this, width, height);
  22015. return this.attr(this.array().size(p.width, p.height).toLine());
  22016. }
  22017. },
  22018. // Add parent method
  22019. construct: {
  22020. // Create a line element
  22021. line: function line(x1, y1, x2, y2) {
  22022. // make sure plot is called as a setter
  22023. // x1 is not necessarily a number, it can also be an array, a string and a SVG.PointArray
  22024. return SVG.Line.prototype.plot.apply(this.put(new SVG.Line()), x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]);
  22025. }
  22026. }
  22027. });
  22028. SVG.Polyline = SVG.invent({
  22029. // Initialize node
  22030. create: 'polyline',
  22031. // Inherit from
  22032. inherit: SVG.Shape,
  22033. // Add parent method
  22034. construct: {
  22035. // Create a wrapped polyline element
  22036. polyline: function polyline(p) {
  22037. // make sure plot is called as a setter
  22038. return this.put(new SVG.Polyline()).plot(p || new SVG.PointArray());
  22039. }
  22040. }
  22041. });
  22042. SVG.Polygon = SVG.invent({
  22043. // Initialize node
  22044. create: 'polygon',
  22045. // Inherit from
  22046. inherit: SVG.Shape,
  22047. // Add parent method
  22048. construct: {
  22049. // Create a wrapped polygon element
  22050. polygon: function polygon(p) {
  22051. // make sure plot is called as a setter
  22052. return this.put(new SVG.Polygon()).plot(p || new SVG.PointArray());
  22053. }
  22054. }
  22055. }); // Add polygon-specific functions
  22056. SVG.extend(SVG.Polyline, SVG.Polygon, {
  22057. // Get array
  22058. array: function array() {
  22059. return this._array || (this._array = new SVG.PointArray(this.attr('points')));
  22060. },
  22061. // Plot new path
  22062. plot: function plot(p) {
  22063. return p == null ? this.array() : this.clear().attr('points', typeof p === 'string' ? p : this._array = new SVG.PointArray(p));
  22064. },
  22065. // Clear array cache
  22066. clear: function clear() {
  22067. delete this._array;
  22068. return this;
  22069. },
  22070. // Move by left top corner
  22071. move: function move(x, y) {
  22072. return this.attr('points', this.array().move(x, y));
  22073. },
  22074. // Set element size to given width and height
  22075. size: function size(width, height) {
  22076. var p = proportionalSize(this, width, height);
  22077. return this.attr('points', this.array().size(p.width, p.height));
  22078. }
  22079. }); // unify all point to point elements
  22080. SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, {
  22081. // Define morphable array
  22082. morphArray: SVG.PointArray,
  22083. // Move by left top corner over x-axis
  22084. x: function x(_x4) {
  22085. return _x4 == null ? this.bbox().x : this.move(_x4, this.bbox().y);
  22086. },
  22087. // Move by left top corner over y-axis
  22088. y: function y(_y3) {
  22089. return _y3 == null ? this.bbox().y : this.move(this.bbox().x, _y3);
  22090. },
  22091. // Set width of element
  22092. width: function width(_width3) {
  22093. var b = this.bbox();
  22094. return _width3 == null ? b.width : this.size(_width3, b.height);
  22095. },
  22096. // Set height of element
  22097. height: function height(_height3) {
  22098. var b = this.bbox();
  22099. return _height3 == null ? b.height : this.size(b.width, _height3);
  22100. }
  22101. });
  22102. SVG.Path = SVG.invent({
  22103. // Initialize node
  22104. create: 'path',
  22105. // Inherit from
  22106. inherit: SVG.Shape,
  22107. // Add class methods
  22108. extend: {
  22109. // Define morphable array
  22110. morphArray: SVG.PathArray,
  22111. // Get array
  22112. array: function array() {
  22113. return this._array || (this._array = new SVG.PathArray(this.attr('d')));
  22114. },
  22115. // Plot new path
  22116. plot: function plot(d) {
  22117. return d == null ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : this._array = new SVG.PathArray(d));
  22118. },
  22119. // Clear array cache
  22120. clear: function clear() {
  22121. delete this._array;
  22122. return this;
  22123. }
  22124. },
  22125. // Add parent method
  22126. construct: {
  22127. // Create a wrapped path element
  22128. path: function path(d) {
  22129. // make sure plot is called as a setter
  22130. return this.put(new SVG.Path()).plot(d || new SVG.PathArray());
  22131. }
  22132. }
  22133. });
  22134. SVG.Image = SVG.invent({
  22135. // Initialize node
  22136. create: 'image',
  22137. // Inherit from
  22138. inherit: SVG.Shape,
  22139. // Add class methods
  22140. extend: {
  22141. // (re)load image
  22142. load: function load(url) {
  22143. if (!url) return this;
  22144. var self = this,
  22145. img = new window.Image(); // preload image
  22146. SVG.on(img, 'load', function () {
  22147. SVG.off(img);
  22148. var p = self.parent(SVG.Pattern);
  22149. if (p === null) return; // ensure image size
  22150. if (self.width() == 0 && self.height() == 0) {
  22151. self.size(img.width, img.height);
  22152. } // ensure pattern size if not set
  22153. if (p && p.width() == 0 && p.height() == 0) {
  22154. p.size(self.width(), self.height());
  22155. } // callback
  22156. if (typeof self._loaded === 'function') {
  22157. self._loaded.call(self, {
  22158. width: img.width,
  22159. height: img.height,
  22160. ratio: img.width / img.height,
  22161. url: url
  22162. });
  22163. }
  22164. });
  22165. SVG.on(img, 'error', function (e) {
  22166. SVG.off(img);
  22167. if (typeof self._error === 'function') {
  22168. self._error.call(self, e);
  22169. }
  22170. });
  22171. return this.attr('href', img.src = this.src = url, SVG.xlink);
  22172. },
  22173. // Add loaded callback
  22174. loaded: function loaded(_loaded) {
  22175. this._loaded = _loaded;
  22176. return this;
  22177. },
  22178. error: function error(_error) {
  22179. this._error = _error;
  22180. return this;
  22181. }
  22182. },
  22183. // Add parent method
  22184. construct: {
  22185. // create image element, load image and set its size
  22186. image: function image(source, width, height) {
  22187. return this.put(new SVG.Image()).load(source).size(width || 0, height || width || 0);
  22188. }
  22189. }
  22190. });
  22191. SVG.Text = SVG.invent({
  22192. // Initialize node
  22193. create: function create() {
  22194. this.constructor.call(this, SVG.create('text'));
  22195. this.dom.leading = new SVG.Number(1.3); // store leading value for rebuilding
  22196. this._rebuild = true; // enable automatic updating of dy values
  22197. this._build = false; // disable build mode for adding multiple lines
  22198. // set default font
  22199. this.attr('font-family', SVG.defaults.attrs['font-family']);
  22200. },
  22201. // Inherit from
  22202. inherit: SVG.Shape,
  22203. // Add class methods
  22204. extend: {
  22205. // Move over x-axis
  22206. x: function x(_x5) {
  22207. // act as getter
  22208. if (_x5 == null) {
  22209. return this.attr('x');
  22210. }
  22211. return this.attr('x', _x5);
  22212. },
  22213. // Set the text content
  22214. text: function text(_text) {
  22215. // act as getter
  22216. if (typeof _text === 'undefined') {
  22217. var _text = '';
  22218. var children = this.node.childNodes;
  22219. for (var i = 0, len = children.length; i < len; ++i) {
  22220. // add newline if its not the first child and newLined is set to true
  22221. if (i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true) {
  22222. _text += '\n';
  22223. } // add content of this node
  22224. _text += children[i].textContent;
  22225. }
  22226. return _text;
  22227. } // remove existing content
  22228. this.clear().build(true);
  22229. if (typeof _text === 'function') {
  22230. // call block
  22231. _text.call(this, this);
  22232. } else {
  22233. // store text and make sure text is not blank
  22234. _text = _text.split('\n'); // build new lines
  22235. for (var i = 0, il = _text.length; i < il; i++) {
  22236. this.tspan(_text[i]).newLine();
  22237. }
  22238. } // disable build mode and rebuild lines
  22239. return this.build(false).rebuild();
  22240. },
  22241. // Set font size
  22242. size: function size(_size) {
  22243. return this.attr('font-size', _size).rebuild();
  22244. },
  22245. // Set / get leading
  22246. leading: function leading(value) {
  22247. // act as getter
  22248. if (value == null) {
  22249. return this.dom.leading;
  22250. } // act as setter
  22251. this.dom.leading = new SVG.Number(value);
  22252. return this.rebuild();
  22253. },
  22254. // Get all the first level lines
  22255. lines: function lines() {
  22256. var node = (this.textPath && this.textPath() || this).node; // filter tspans and map them to SVG.js instances
  22257. var lines = SVG.utils.map(SVG.utils.filterSVGElements(node.childNodes), function (el) {
  22258. return SVG.adopt(el);
  22259. }); // return an instance of SVG.set
  22260. return new SVG.Set(lines);
  22261. },
  22262. // Rebuild appearance type
  22263. rebuild: function rebuild(_rebuild) {
  22264. // store new rebuild flag if given
  22265. if (typeof _rebuild === 'boolean') {
  22266. this._rebuild = _rebuild;
  22267. } // define position of all lines
  22268. if (this._rebuild) {
  22269. var self = this,
  22270. blankLineOffset = 0,
  22271. dy = this.dom.leading * new SVG.Number(this.attr('font-size'));
  22272. this.lines().each(function () {
  22273. if (this.dom.newLined) {
  22274. if (!self.textPath()) {
  22275. this.attr('x', self.attr('x'));
  22276. }
  22277. if (this.text() == '\n') {
  22278. blankLineOffset += dy;
  22279. } else {
  22280. this.attr('dy', dy + blankLineOffset);
  22281. blankLineOffset = 0;
  22282. }
  22283. }
  22284. });
  22285. this.fire('rebuild');
  22286. }
  22287. return this;
  22288. },
  22289. // Enable / disable build mode
  22290. build: function build(_build) {
  22291. this._build = !!_build;
  22292. return this;
  22293. },
  22294. // overwrite method from parent to set data properly
  22295. setData: function setData(o) {
  22296. this.dom = o;
  22297. this.dom.leading = new SVG.Number(o.leading || 1.3);
  22298. return this;
  22299. }
  22300. },
  22301. // Add parent method
  22302. construct: {
  22303. // Create text element
  22304. text: function text(_text2) {
  22305. return this.put(new SVG.Text()).text(_text2);
  22306. },
  22307. // Create plain text element
  22308. plain: function plain(text) {
  22309. return this.put(new SVG.Text()).plain(text);
  22310. }
  22311. }
  22312. });
  22313. SVG.Tspan = SVG.invent({
  22314. // Initialize node
  22315. create: 'tspan',
  22316. // Inherit from
  22317. inherit: SVG.Shape,
  22318. // Add class methods
  22319. extend: {
  22320. // Set text content
  22321. text: function text(_text3) {
  22322. if (_text3 == null) return this.node.textContent + (this.dom.newLined ? '\n' : '');
  22323. typeof _text3 === 'function' ? _text3.call(this, this) : this.plain(_text3);
  22324. return this;
  22325. },
  22326. // Shortcut dx
  22327. dx: function dx(_dx) {
  22328. return this.attr('dx', _dx);
  22329. },
  22330. // Shortcut dy
  22331. dy: function dy(_dy) {
  22332. return this.attr('dy', _dy);
  22333. },
  22334. // Create new line
  22335. newLine: function newLine() {
  22336. // fetch text parent
  22337. var t = this.parent(SVG.Text); // mark new line
  22338. this.dom.newLined = true; // apply new hy¡n
  22339. return this.dy(t.dom.leading * t.attr('font-size')).attr('x', t.x());
  22340. }
  22341. }
  22342. });
  22343. SVG.extend(SVG.Text, SVG.Tspan, {
  22344. // Create plain text node
  22345. plain: function plain(text) {
  22346. // clear if build mode is disabled
  22347. if (this._build === false) {
  22348. this.clear();
  22349. } // create text node
  22350. this.node.appendChild(document.createTextNode(text));
  22351. return this;
  22352. },
  22353. // Create a tspan
  22354. tspan: function tspan(text) {
  22355. var node = (this.textPath && this.textPath() || this).node,
  22356. tspan = new SVG.Tspan(); // clear if build mode is disabled
  22357. if (this._build === false) {
  22358. this.clear();
  22359. } // add new tspan
  22360. node.appendChild(tspan.node);
  22361. return tspan.text(text);
  22362. },
  22363. // Clear all lines
  22364. clear: function clear() {
  22365. var node = (this.textPath && this.textPath() || this).node; // remove existing child nodes
  22366. while (node.hasChildNodes()) {
  22367. node.removeChild(node.lastChild);
  22368. }
  22369. return this;
  22370. },
  22371. // Get length of text element
  22372. length: function length() {
  22373. return this.node.getComputedTextLength();
  22374. }
  22375. });
  22376. SVG.TextPath = SVG.invent({
  22377. // Initialize node
  22378. create: 'textPath',
  22379. // Inherit from
  22380. inherit: SVG.Parent,
  22381. // Define parent class
  22382. parent: SVG.Text,
  22383. // Add parent method
  22384. construct: {
  22385. morphArray: SVG.PathArray,
  22386. // return the array of the path track element
  22387. array: function array() {
  22388. var track = this.track();
  22389. return track ? track.array() : null;
  22390. },
  22391. // Plot path if any
  22392. plot: function plot(d) {
  22393. var track = this.track(),
  22394. pathArray = null;
  22395. if (track) {
  22396. pathArray = track.plot(d);
  22397. }
  22398. return d == null ? pathArray : this;
  22399. },
  22400. // Get the path track element
  22401. track: function track() {
  22402. var path = this.textPath();
  22403. if (path) {
  22404. return path.reference('href');
  22405. }
  22406. },
  22407. // Get the textPath child
  22408. textPath: function textPath() {
  22409. if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') {
  22410. return SVG.adopt(this.node.firstChild);
  22411. }
  22412. }
  22413. }
  22414. });
  22415. SVG.Nested = SVG.invent({
  22416. // Initialize node
  22417. create: function create() {
  22418. this.constructor.call(this, SVG.create('svg'));
  22419. this.style('overflow', 'visible');
  22420. },
  22421. // Inherit from
  22422. inherit: SVG.Container,
  22423. // Add parent method
  22424. construct: {
  22425. // Create nested svg document
  22426. nested: function nested() {
  22427. return this.put(new SVG.Nested());
  22428. }
  22429. }
  22430. }); // Define list of available attributes for stroke and fill
  22431. var sugar = {
  22432. stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
  22433. fill: ['color', 'opacity', 'rule'],
  22434. prefix: function prefix(t, a) {
  22435. return a == 'color' ? t : t + '-' + a;
  22436. }
  22437. } // Add sugar for fill and stroke
  22438. ;
  22439. ['fill', 'stroke'].forEach(function (m) {
  22440. var extension = {};
  22441. extension[m] = function (o) {
  22442. if (typeof o === 'undefined') {
  22443. return this;
  22444. }
  22445. if (typeof o === 'string' || SVG.Color.isRgb(o) || o && typeof o.fill === 'function') {
  22446. this.attr(m, o);
  22447. } else // set all attributes from sugar.fill and sugar.stroke list
  22448. {
  22449. for (var i = sugar[m].length - 1; i >= 0; i--) {
  22450. if (o[sugar[m][i]] != null) {
  22451. this.attr(sugar.prefix(m, sugar[m][i]), o[sugar[m][i]]);
  22452. }
  22453. }
  22454. }
  22455. return this;
  22456. };
  22457. SVG.extend(SVG.Element, SVG.FX, extension);
  22458. });
  22459. SVG.extend(SVG.Element, SVG.FX, {
  22460. // Map translate to transform
  22461. translate: function translate(x, y) {
  22462. return this.transform({
  22463. x: x,
  22464. y: y
  22465. });
  22466. },
  22467. // Map matrix to transform
  22468. matrix: function matrix(m) {
  22469. return this.attr('transform', new SVG.Matrix(arguments.length == 6 ? [].slice.call(arguments) : m));
  22470. },
  22471. // Opacity
  22472. opacity: function opacity(value) {
  22473. return this.attr('opacity', value);
  22474. },
  22475. // Relative move over x axis
  22476. dx: function dx(x) {
  22477. return this.x(new SVG.Number(x).plus(this instanceof SVG.FX ? 0 : this.x()), true);
  22478. },
  22479. // Relative move over y axis
  22480. dy: function dy(y) {
  22481. return this.y(new SVG.Number(y).plus(this instanceof SVG.FX ? 0 : this.y()), true);
  22482. }
  22483. });
  22484. SVG.extend(SVG.Path, {
  22485. // Get path length
  22486. length: function length() {
  22487. return this.node.getTotalLength();
  22488. },
  22489. // Get point at length
  22490. pointAt: function pointAt(length) {
  22491. return this.node.getPointAtLength(length);
  22492. }
  22493. });
  22494. SVG.Set = SVG.invent({
  22495. // Initialize
  22496. create: function create(members) {
  22497. // Set initial state
  22498. Array.isArray(members) ? this.members = members : this.clear();
  22499. },
  22500. // Add class methods
  22501. extend: {
  22502. // Add element to set
  22503. add: function add() {
  22504. var il,
  22505. elements = [].slice.call(arguments);
  22506. for (var i = 0, il = elements.length; i < il; i++) {
  22507. this.members.push(elements[i]);
  22508. }
  22509. return this;
  22510. },
  22511. // Remove element from set
  22512. remove: function remove(element) {
  22513. var i = this.index(element); // remove given child
  22514. if (i > -1) {
  22515. this.members.splice(i, 1);
  22516. }
  22517. return this;
  22518. },
  22519. // Iterate over all members
  22520. each: function each(block) {
  22521. for (var i = 0, il = this.members.length; i < il; i++) {
  22522. block.apply(this.members[i], [i, this.members]);
  22523. }
  22524. return this;
  22525. },
  22526. // Restore to defaults
  22527. clear: function clear() {
  22528. // initialize store
  22529. this.members = [];
  22530. return this;
  22531. },
  22532. // Get the length of a set
  22533. length: function length() {
  22534. return this.members.length;
  22535. },
  22536. // Checks if a given element is present in set
  22537. has: function has(element) {
  22538. return this.index(element) >= 0;
  22539. },
  22540. // retuns index of given element in set
  22541. index: function index(element) {
  22542. return this.members.indexOf(element);
  22543. },
  22544. // Get member at given index
  22545. get: function get(i) {
  22546. return this.members[i];
  22547. },
  22548. // Get first member
  22549. first: function first() {
  22550. return this.get(0);
  22551. },
  22552. // Get last member
  22553. last: function last() {
  22554. return this.get(this.members.length - 1);
  22555. },
  22556. // Default value
  22557. valueOf: function valueOf() {
  22558. return this.members;
  22559. }
  22560. },
  22561. // Add parent method
  22562. construct: {
  22563. // Create a new set
  22564. set: function set(members) {
  22565. return new SVG.Set(members);
  22566. }
  22567. }
  22568. });
  22569. SVG.FX.Set = SVG.invent({
  22570. // Initialize node
  22571. create: function create(set) {
  22572. // store reference to set
  22573. this.set = set;
  22574. }
  22575. }); // Alias methods
  22576. SVG.Set.inherit = function () {
  22577. var methods = []; // gather shape methods
  22578. for (var m in SVG.Shape.prototype) {
  22579. if (typeof SVG.Shape.prototype[m] === 'function' && typeof SVG.Set.prototype[m] !== 'function') {
  22580. methods.push(m);
  22581. }
  22582. } // apply shape aliasses
  22583. methods.forEach(function (method) {
  22584. SVG.Set.prototype[method] = function () {
  22585. for (var i = 0, il = this.members.length; i < il; i++) {
  22586. if (this.members[i] && typeof this.members[i][method] === 'function') {
  22587. this.members[i][method].apply(this.members[i], arguments);
  22588. }
  22589. }
  22590. return method == 'animate' ? this.fx || (this.fx = new SVG.FX.Set(this)) : this;
  22591. };
  22592. }); // clear methods for the next round
  22593. methods = []; // gather fx methods
  22594. for (var m in SVG.FX.prototype) {
  22595. if (typeof SVG.FX.prototype[m] === 'function' && typeof SVG.FX.Set.prototype[m] !== 'function') {
  22596. methods.push(m);
  22597. }
  22598. } // apply fx aliasses
  22599. methods.forEach(function (method) {
  22600. SVG.FX.Set.prototype[method] = function () {
  22601. for (var i = 0, il = this.set.members.length; i < il; i++) {
  22602. this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments);
  22603. }
  22604. return this;
  22605. };
  22606. });
  22607. };
  22608. SVG.extend(SVG.Element, {});
  22609. SVG.extend(SVG.Element, {
  22610. // Remember arbitrary data
  22611. remember: function remember(k, v) {
  22612. // remember every item in an object individually
  22613. if (_typeof(arguments[0]) === 'object') {
  22614. for (var v_ in k) {
  22615. this.remember(v_, k[v_]);
  22616. }
  22617. } // retrieve memory
  22618. else if (arguments.length == 1) {
  22619. return this.memory()[k];
  22620. } // store memory
  22621. else {
  22622. this.memory()[k] = v;
  22623. }
  22624. return this;
  22625. },
  22626. // Erase a given memory
  22627. forget: function forget() {
  22628. if (arguments.length == 0) {
  22629. this._memory = {};
  22630. } else {
  22631. for (var i = arguments.length - 1; i >= 0; i--) {
  22632. delete this.memory()[arguments[i]];
  22633. }
  22634. }
  22635. return this;
  22636. },
  22637. // Initialize or return local memory object
  22638. memory: function memory() {
  22639. return this._memory || (this._memory = {});
  22640. }
  22641. }); // Method for getting an element by id
  22642. SVG.get = function (id) {
  22643. var node = document.getElementById(idFromReference(id) || id);
  22644. return SVG.adopt(node);
  22645. }; // Select elements by query string
  22646. SVG.select = function (query, parent) {
  22647. return new SVG.Set(SVG.utils.map((parent || document).querySelectorAll(query), function (node) {
  22648. return SVG.adopt(node);
  22649. }));
  22650. };
  22651. SVG.extend(SVG.Parent, {
  22652. // Scoped select method
  22653. select: function select(query) {
  22654. return SVG.select(query, this.node);
  22655. }
  22656. });
  22657. function pathRegReplace(a, b, c, d) {
  22658. return c + d.replace(SVG.regex.dots, ' .');
  22659. } // creates deep clone of array
  22660. function _is(el, obj) {
  22661. return el instanceof obj;
  22662. } // tests if a given selector matches an element
  22663. function _matches(el, selector) {
  22664. return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
  22665. } // Convert dash-separated-string to camelCase
  22666. function camelCase(s) {
  22667. return s.toLowerCase().replace(/-(.)/g, function (m, g) {
  22668. return g.toUpperCase();
  22669. });
  22670. } // Capitalize first letter of a string
  22671. function capitalize(s) {
  22672. return s.charAt(0).toUpperCase() + s.slice(1);
  22673. } // Ensure to six-based hex
  22674. function fullHex(hex) {
  22675. 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;
  22676. } // Component to hex value
  22677. function compToHex(comp) {
  22678. var hex = comp.toString(16);
  22679. return hex.length == 1 ? '0' + hex : hex;
  22680. } // Calculate proportional width and height values when necessary
  22681. function proportionalSize(element, width, height) {
  22682. if (width == null || height == null) {
  22683. var box = element.bbox();
  22684. if (width == null) {
  22685. width = box.width / box.height * height;
  22686. } else if (height == null) {
  22687. height = box.height / box.width * width;
  22688. }
  22689. }
  22690. return {
  22691. width: width,
  22692. height: height
  22693. };
  22694. } // Delta transform point
  22695. function deltaTransformPoint(matrix, x, y) {
  22696. return {
  22697. x: x * matrix.a + y * matrix.c + 0,
  22698. y: x * matrix.b + y * matrix.d + 0
  22699. };
  22700. } // Map matrix array to object
  22701. function arrayToMatrix(a) {
  22702. return {
  22703. a: a[0],
  22704. b: a[1],
  22705. c: a[2],
  22706. d: a[3],
  22707. e: a[4],
  22708. f: a[5]
  22709. };
  22710. } // Parse matrix if required
  22711. function parseMatrix(matrix) {
  22712. if (!(matrix instanceof SVG.Matrix)) {
  22713. matrix = new SVG.Matrix(matrix);
  22714. }
  22715. return matrix;
  22716. } // Add centre point to transform object
  22717. function arrayToString(a) {
  22718. for (var i = 0, il = a.length, s = ''; i < il; i++) {
  22719. s += a[i][0];
  22720. if (a[i][1] != null) {
  22721. s += a[i][1];
  22722. if (a[i][2] != null) {
  22723. s += ' ';
  22724. s += a[i][2];
  22725. if (a[i][3] != null) {
  22726. s += ' ';
  22727. s += a[i][3];
  22728. s += ' ';
  22729. s += a[i][4];
  22730. if (a[i][5] != null) {
  22731. s += ' ';
  22732. s += a[i][5];
  22733. s += ' ';
  22734. s += a[i][6];
  22735. if (a[i][7] != null) {
  22736. s += ' ';
  22737. s += a[i][7];
  22738. }
  22739. }
  22740. }
  22741. }
  22742. }
  22743. }
  22744. return s + ' ';
  22745. } // Deep new id assignment
  22746. function assignNewId(node) {
  22747. // do the same for SVG child nodes as well
  22748. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  22749. if (node.childNodes[i] instanceof window.SVGElement) {
  22750. assignNewId(node.childNodes[i]);
  22751. }
  22752. }
  22753. return SVG.adopt(node).id(SVG.eid(node.nodeName));
  22754. } // Add more bounding box properties
  22755. function fullBox(b) {
  22756. if (b.x == null) {
  22757. b.x = 0;
  22758. b.y = 0;
  22759. b.width = 0;
  22760. b.height = 0;
  22761. }
  22762. b.w = b.width;
  22763. b.h = b.height;
  22764. b.x2 = b.x + b.width;
  22765. b.y2 = b.y + b.height;
  22766. b.cx = b.x + b.width / 2;
  22767. b.cy = b.y + b.height / 2;
  22768. return b;
  22769. } // Get id from reference string
  22770. function idFromReference(url) {
  22771. var m = (url || '').toString().match(SVG.regex.reference);
  22772. if (m) return m[1];
  22773. } // If values like 1e-88 are passed, this is not a valid 32 bit float,
  22774. // but in those cases, we are so close to 0 that 0 works well!
  22775. function float32String(v) {
  22776. return Math.abs(v) > 1e-37 ? v : 0;
  22777. } // Create matrix array for looping
  22778. var abcdef = 'abcdef'.split(''); // Add CustomEvent to IE9 and IE10
  22779. if (typeof window.CustomEvent !== 'function') {
  22780. // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
  22781. var CustomEventPoly = function CustomEventPoly(event, options) {
  22782. options = options || {
  22783. bubbles: false,
  22784. cancelable: false,
  22785. detail: undefined
  22786. };
  22787. var e = document.createEvent('CustomEvent');
  22788. e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail);
  22789. return e;
  22790. };
  22791. CustomEventPoly.prototype = window.Event.prototype;
  22792. SVG.CustomEvent = CustomEventPoly;
  22793. } else {
  22794. SVG.CustomEvent = window.CustomEvent;
  22795. }
  22796. return SVG;
  22797. });
  22798. /*! svg.filter.js - v2.0.2 - 2016-02-24
  22799. * https://github.com/wout/svg.filter.js
  22800. * Copyright (c) 2016 Wout Fierens; Licensed MIT */
  22801. (function() {
  22802. // Main filter class
  22803. SVG.Filter = SVG.invent({
  22804. create: 'filter',
  22805. inherit: SVG.Parent,
  22806. extend: {
  22807. // Static strings
  22808. source: 'SourceGraphic',
  22809. sourceAlpha: 'SourceAlpha',
  22810. background: 'BackgroundImage',
  22811. backgroundAlpha: 'BackgroundAlpha',
  22812. fill: 'FillPaint',
  22813. stroke: 'StrokePaint',
  22814. autoSetIn: true,
  22815. // Custom put method for leaner code
  22816. put: function(element, i) {
  22817. this.add(element, i);
  22818. if(!element.attr('in') && this.autoSetIn){
  22819. element.attr('in',this.source);
  22820. }
  22821. if(!element.attr('result')){
  22822. element.attr('result',element);
  22823. }
  22824. return element
  22825. },
  22826. // Blend effect
  22827. blend: function(in1, in2, mode) {
  22828. return this.put(new SVG.BlendEffect(in1, in2, mode))
  22829. },
  22830. // ColorMatrix effect
  22831. colorMatrix: function(type, values) {
  22832. return this.put(new SVG.ColorMatrixEffect(type, values))
  22833. },
  22834. // ConvolveMatrix effect
  22835. convolveMatrix: function(matrix) {
  22836. return this.put(new SVG.ConvolveMatrixEffect(matrix))
  22837. },
  22838. // ComponentTransfer effect
  22839. componentTransfer: function(components) {
  22840. return this.put(new SVG.ComponentTransferEffect(components))
  22841. },
  22842. // Composite effect
  22843. composite: function(in1, in2, operator) {
  22844. return this.put(new SVG.CompositeEffect(in1, in2, operator))
  22845. },
  22846. // Flood effect
  22847. flood: function(color, opacity) {
  22848. return this.put(new SVG.FloodEffect(color, opacity))
  22849. },
  22850. // Offset effect
  22851. offset: function(x, y) {
  22852. return this.put(new SVG.OffsetEffect(x,y))
  22853. },
  22854. // Image effect
  22855. image: function(src) {
  22856. return this.put(new SVG.ImageEffect(src))
  22857. },
  22858. // Merge effect
  22859. merge: function() {
  22860. //pass the array of arguments to the constructor because we dont know if the user gave us an array as the first arguemnt or wether they listed the effects in the arguments
  22861. var args = [undefined];
  22862. for(var i in arguments) args.push(arguments[i]);
  22863. return this.put(new (SVG.MergeEffect.bind.apply(SVG.MergeEffect,args)))
  22864. },
  22865. // Gaussian Blur effect
  22866. gaussianBlur: function(x,y) {
  22867. return this.put(new SVG.GaussianBlurEffect(x,y))
  22868. },
  22869. // Morphology effect
  22870. morphology: function(operator,radius){
  22871. return this.put(new SVG.MorphologyEffect(operator,radius))
  22872. },
  22873. // DiffuseLighting effect
  22874. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  22875. return this.put(new SVG.DiffuseLightingEffect(surfaceScale,diffuseConstant,kernelUnitLength))
  22876. },
  22877. // DisplacementMap effect
  22878. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  22879. return this.put(new SVG.DisplacementMapEffect(in1,in2,scale,xChannelSelector,yChannelSelector))
  22880. },
  22881. // SpecularLighting effect
  22882. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  22883. return this.put(new SVG.SpecularLightingEffect(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength))
  22884. },
  22885. // Tile effect
  22886. tile: function(){
  22887. return this.put(new SVG.TileEffect());
  22888. },
  22889. // Turbulence effect
  22890. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  22891. return this.put(new SVG.TurbulenceEffect(baseFrequency,numOctaves,seed,stitchTiles,type))
  22892. },
  22893. // Default string value
  22894. toString: function() {
  22895. return 'url(#' + this.attr('id') + ')'
  22896. }
  22897. }
  22898. });
  22899. //add .filter function
  22900. SVG.extend(SVG.Defs, {
  22901. // Define filter
  22902. filter: function(block) {
  22903. var filter = this.put(new SVG.Filter);
  22904. /* invoke passed block */
  22905. if (typeof block === 'function')
  22906. block.call(filter, filter);
  22907. return filter
  22908. }
  22909. });
  22910. SVG.extend(SVG.Container, {
  22911. // Define filter on defs
  22912. filter: function(block) {
  22913. return this.defs().filter(block)
  22914. }
  22915. });
  22916. SVG.extend(SVG.Element, SVG.G, SVG.Nested, {
  22917. // Create filter element in defs and store reference
  22918. filter: function(block) {
  22919. this.filterer = block instanceof SVG.Element ?
  22920. block : this.doc().filter(block);
  22921. if(this.doc() && this.filterer.doc() !== this.doc()){
  22922. this.doc().defs().add(this.filterer);
  22923. }
  22924. this.attr('filter', this.filterer);
  22925. return this.filterer
  22926. },
  22927. // Remove filter
  22928. unfilter: function(remove) {
  22929. /* also remove the filter node */
  22930. if (this.filterer && remove === true)
  22931. this.filterer.remove();
  22932. /* delete reference to filterer */
  22933. delete this.filterer;
  22934. /* remove filter attribute */
  22935. return this.attr('filter', null)
  22936. }
  22937. });
  22938. // Create SVG.Effect class
  22939. SVG.Effect = SVG.invent({
  22940. create: function(){
  22941. this.constructor.call(this);
  22942. },
  22943. inherit: SVG.Element,
  22944. extend: {
  22945. // Set in attribute
  22946. in: function(effect) {
  22947. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  22948. },
  22949. // Named result
  22950. result: function(result) {
  22951. return result == null? this.attr('result') : this.attr('result',result)
  22952. },
  22953. // Stringification
  22954. toString: function() {
  22955. return this.result()
  22956. }
  22957. }
  22958. });
  22959. // create class for parent effects like merge
  22960. // Inherit from SVG.Parent
  22961. SVG.ParentEffect = SVG.invent({
  22962. create: function(){
  22963. this.constructor.call(this);
  22964. },
  22965. inherit: SVG.Parent,
  22966. extend: {
  22967. // Set in attribute
  22968. in: function(effect) {
  22969. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  22970. },
  22971. // Named result
  22972. result: function(result) {
  22973. return result == null? this.attr('result') : this.attr('result',result)
  22974. },
  22975. // Stringification
  22976. toString: function() {
  22977. return this.result()
  22978. }
  22979. }
  22980. });
  22981. //chaining
  22982. var chainingEffects = {
  22983. // Blend effect
  22984. blend: function(in2, mode) {
  22985. return this.parent() && this.parent().blend(this, in2, mode) //pass this as the first input
  22986. },
  22987. // ColorMatrix effect
  22988. colorMatrix: function(type, values) {
  22989. return this.parent() && this.parent().colorMatrix(type, values).in(this)
  22990. },
  22991. // ConvolveMatrix effect
  22992. convolveMatrix: function(matrix) {
  22993. return this.parent() && this.parent().convolveMatrix(matrix).in(this)
  22994. },
  22995. // ComponentTransfer effect
  22996. componentTransfer: function(components) {
  22997. return this.parent() && this.parent().componentTransfer(components).in(this)
  22998. },
  22999. // Composite effect
  23000. composite: function(in2, operator) {
  23001. return this.parent() && this.parent().composite(this, in2, operator) //pass this as the first input
  23002. },
  23003. // Flood effect
  23004. flood: function(color, opacity) {
  23005. return this.parent() && this.parent().flood(color, opacity) //this effect dont have inputs
  23006. },
  23007. // Offset effect
  23008. offset: function(x, y) {
  23009. return this.parent() && this.parent().offset(x,y).in(this)
  23010. },
  23011. // Image effect
  23012. image: function(src) {
  23013. return this.parent() && this.parent().image(src) //this effect dont have inputs
  23014. },
  23015. // Merge effect
  23016. merge: function() {
  23017. return this.parent() && this.parent().merge.apply(this.parent(),[this].concat(arguments)) //pass this as the first argument
  23018. },
  23019. // Gaussian Blur effect
  23020. gaussianBlur: function(x,y) {
  23021. return this.parent() && this.parent().gaussianBlur(x,y).in(this)
  23022. },
  23023. // Morphology effect
  23024. morphology: function(operator,radius){
  23025. return this.parent() && this.parent().morphology(operator,radius).in(this)
  23026. },
  23027. // DiffuseLighting effect
  23028. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  23029. return this.parent() && this.parent().diffuseLighting(surfaceScale,diffuseConstant,kernelUnitLength).in(this)
  23030. },
  23031. // DisplacementMap effect
  23032. displacementMap: function(in2,scale,xChannelSelector,yChannelSelector){
  23033. return this.parent() && this.parent().displacementMap(this,in2,scale,xChannelSelector,yChannelSelector) //pass this as the first input
  23034. },
  23035. // SpecularLighting effect
  23036. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  23037. return this.parent() && this.parent().specularLighting(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength).in(this)
  23038. },
  23039. // Tile effect
  23040. tile: function(){
  23041. return this.parent() && this.parent().tile().in(this)
  23042. },
  23043. // Turbulence effect
  23044. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  23045. return this.parent() && this.parent().turbulence(baseFrequency,numOctaves,seed,stitchTiles,type).in(this)
  23046. }
  23047. };
  23048. SVG.extend(SVG.Effect,chainingEffects);
  23049. SVG.extend(SVG.ParentEffect,chainingEffects);
  23050. //crea class for child effects, like MergeNode, FuncR and lights
  23051. SVG.ChildEffect = SVG.invent({
  23052. create: function(){
  23053. this.constructor.call(this);
  23054. },
  23055. inherit: SVG.Element,
  23056. extend: {
  23057. in: function(effect){
  23058. this.attr('in',effect);
  23059. }
  23060. //dont include any "result" functions because these types of nodes dont have them
  23061. }
  23062. });
  23063. // Create all different effects
  23064. var effects = {
  23065. blend: function(in1,in2,mode){
  23066. this.attr({
  23067. in: in1,
  23068. in2: in2,
  23069. mode: mode || 'normal'
  23070. });
  23071. },
  23072. colorMatrix: function(type,values){
  23073. if (type == 'matrix')
  23074. values = normaliseMatrix(values);
  23075. this.attr({
  23076. type: type
  23077. , values: typeof values == 'undefined' ? null : values
  23078. });
  23079. },
  23080. convolveMatrix: function(matrix){
  23081. matrix = normaliseMatrix(matrix);
  23082. this.attr({
  23083. order: Math.sqrt(matrix.split(' ').length)
  23084. , kernelMatrix: matrix
  23085. });
  23086. },
  23087. composite: function(in1, in2, operator){
  23088. this.attr({
  23089. in: in1,
  23090. in2: in2,
  23091. operator: operator
  23092. });
  23093. },
  23094. flood: function(color,opacity){
  23095. this.attr('flood-color',color);
  23096. if(opacity != null) this.attr('flood-opacity',opacity);
  23097. },
  23098. offset: function(x,y){
  23099. this.attr({
  23100. dx: x,
  23101. dy: y
  23102. });
  23103. },
  23104. image: function(src){
  23105. this.attr('href', src, SVG.xlink);
  23106. },
  23107. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  23108. this.attr({
  23109. in: in1,
  23110. in2: in2,
  23111. scale: scale,
  23112. xChannelSelector: xChannelSelector,
  23113. yChannelSelector: yChannelSelector
  23114. });
  23115. },
  23116. gaussianBlur: function(x,y){
  23117. if(x != null || y != null)
  23118. this.attr('stdDeviation', listString(Array.prototype.slice.call(arguments)));
  23119. else
  23120. this.attr('stdDeviation', '0 0');
  23121. },
  23122. morphology: function(operator,radius){
  23123. this.attr({
  23124. operator: operator,
  23125. radius: radius
  23126. });
  23127. },
  23128. tile: function(){
  23129. },
  23130. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  23131. this.attr({
  23132. numOctaves: numOctaves,
  23133. seed: seed,
  23134. stitchTiles: stitchTiles,
  23135. baseFrequency: baseFrequency,
  23136. type: type
  23137. });
  23138. }
  23139. };
  23140. // Create all parent effects
  23141. var parentEffects = {
  23142. merge: function(){
  23143. var children;
  23144. //test to see if we have a set
  23145. if(arguments[0] instanceof SVG.Set){
  23146. var that = this;
  23147. arguments[0].each(function(i){
  23148. if(this instanceof SVG.MergeNode)
  23149. that.put(this);
  23150. else if(this instanceof SVG.Effect || this instanceof SVG.ParentEffect)
  23151. that.put(new SVG.MergeNode(this));
  23152. });
  23153. }
  23154. else{
  23155. //if the first argument is an array use it
  23156. if(Array.isArray(arguments[0]))
  23157. children = arguments[0];
  23158. else
  23159. children = arguments;
  23160. for(var i = 0; i < children.length; i++){
  23161. if(children[i] instanceof SVG.MergeNode){
  23162. this.put(children[i]);
  23163. }
  23164. else this.put(new SVG.MergeNode(children[i]));
  23165. }
  23166. }
  23167. },
  23168. componentTransfer: function(compontents){
  23169. /* create rgb set */
  23170. this.rgb = new SVG.Set
  23171. /* create components */
  23172. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  23173. /* create component */
  23174. this[c] = new SVG['Func' + c.toUpperCase()]('identity');
  23175. /* store component in set */
  23176. this.rgb.add(this[c]);
  23177. /* add component node */
  23178. this.node.appendChild(this[c].node);
  23179. }.bind(this)); //lost context in foreach
  23180. /* set components */
  23181. if (compontents) {
  23182. if (compontents.rgb) {
  23183. (['r', 'g', 'b']).forEach(function(c) {
  23184. this[c].attr(compontents.rgb);
  23185. }.bind(this));
  23186. delete compontents.rgb;
  23187. }
  23188. /* set individual components */
  23189. for (var c in compontents)
  23190. this[c].attr(compontents[c]);
  23191. }
  23192. },
  23193. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  23194. this.attr({
  23195. surfaceScale: surfaceScale,
  23196. diffuseConstant: diffuseConstant,
  23197. kernelUnitLength: kernelUnitLength
  23198. });
  23199. },
  23200. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  23201. this.attr({
  23202. surfaceScale: surfaceScale,
  23203. diffuseConstant: diffuseConstant,
  23204. specularExponent: specularExponent,
  23205. kernelUnitLength: kernelUnitLength
  23206. });
  23207. },
  23208. };
  23209. // Create child effects like PointLight and MergeNode
  23210. var childEffects = {
  23211. distantLight: function(azimuth, elevation){
  23212. this.attr({
  23213. azimuth: azimuth,
  23214. elevation: elevation
  23215. });
  23216. },
  23217. pointLight: function(x,y,z){
  23218. this.attr({
  23219. x: x,
  23220. y: y,
  23221. z: z
  23222. });
  23223. },
  23224. spotLight: function(x,y,z,pointsAtX,pointsAtY,pointsAtZ){
  23225. this.attr({
  23226. x: x,
  23227. y: y,
  23228. z: z,
  23229. pointsAtX: pointsAtX,
  23230. pointsAtY: pointsAtY,
  23231. pointsAtZ: pointsAtZ
  23232. });
  23233. },
  23234. mergeNode: function(in1){
  23235. this.attr('in',in1);
  23236. }
  23237. }
  23238. // Create compontent functions
  23239. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  23240. /* create class */
  23241. childEffects['Func' + c.toUpperCase()] = function(type) {
  23242. this.attr('type',type);
  23243. // take diffent arguments based on the type
  23244. switch(type){
  23245. case 'table':
  23246. this.attr('tableValues',arguments[1]);
  23247. break
  23248. case 'linear':
  23249. this.attr('slope',arguments[1]);
  23250. this.attr('intercept',arguments[2]);
  23251. break
  23252. case 'gamma':
  23253. this.attr('amplitude',arguments[1]);
  23254. this.attr('exponent',arguments[2]);
  23255. this.attr('offset',arguments[2]);
  23256. break
  23257. }
  23258. };
  23259. });
  23260. //create effects
  23261. foreach(effects,function(effect,i){
  23262. /* capitalize name */
  23263. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23264. var proto = {};
  23265. /* create class */
  23266. SVG[name + 'Effect'] = SVG.invent({
  23267. create: function() {
  23268. //call super
  23269. this.constructor.call(this, SVG.create('fe' + name));
  23270. //call constructor for this effect
  23271. effect.apply(this,arguments);
  23272. //set the result
  23273. this.result(this.attr('id') + 'Out');
  23274. },
  23275. inherit: SVG.Effect,
  23276. extend: proto
  23277. });
  23278. });
  23279. //create parent effects
  23280. foreach(parentEffects,function(effect,i){
  23281. /* capitalize name */
  23282. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23283. var proto = {};
  23284. /* create class */
  23285. SVG[name + 'Effect'] = SVG.invent({
  23286. create: function() {
  23287. //call super
  23288. this.constructor.call(this, SVG.create('fe' + name));
  23289. //call constructor for this effect
  23290. effect.apply(this,arguments);
  23291. //set the result
  23292. this.result(this.attr('id') + 'Out');
  23293. },
  23294. inherit: SVG.ParentEffect,
  23295. extend: proto
  23296. });
  23297. });
  23298. //create child effects
  23299. foreach(childEffects,function(effect,i){
  23300. /* capitalize name */
  23301. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23302. var proto = {};
  23303. /* create class */
  23304. SVG[name] = SVG.invent({
  23305. create: function() {
  23306. //call super
  23307. this.constructor.call(this, SVG.create('fe' + name));
  23308. //call constructor for this effect
  23309. effect.apply(this,arguments);
  23310. },
  23311. inherit: SVG.ChildEffect,
  23312. extend: proto
  23313. });
  23314. });
  23315. // Effect-specific extensions
  23316. SVG.extend(SVG.MergeEffect,{
  23317. in: function(effect){
  23318. if(effect instanceof SVG.MergeNode)
  23319. this.add(effect,0);
  23320. else
  23321. this.add(new SVG.MergeNode(effect),0);
  23322. return this
  23323. }
  23324. });
  23325. SVG.extend(SVG.CompositeEffect,SVG.BlendEffect,SVG.DisplacementMapEffect,{
  23326. in2: function(effect){
  23327. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in2')+'"]').get(0) || this.attr('in2') : this.attr('in2', effect)
  23328. }
  23329. });
  23330. // Presets
  23331. SVG.filter = {
  23332. sepiatone: [ .343, .669, .119, 0, 0
  23333. , .249, .626, .130, 0, 0
  23334. , .172, .334, .111, 0, 0
  23335. , .000, .000, .000, 1, 0 ]
  23336. };
  23337. // Helpers
  23338. function normaliseMatrix(matrix) {
  23339. /* convert possible array value to string */
  23340. if (Array.isArray(matrix))
  23341. matrix = new SVG.Array(matrix);
  23342. /* ensure there are no leading, tailing or double spaces */
  23343. return matrix.toString().replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' ')
  23344. }
  23345. function listString(list) {
  23346. if (!Array.isArray(list))
  23347. return list
  23348. for (var i = 0, l = list.length, s = []; i < l; i++)
  23349. s.push(list[i]);
  23350. return s.join(' ')
  23351. }
  23352. function foreach(){ //loops through mutiple objects
  23353. var fn = function(){};
  23354. if(typeof arguments[arguments.length-1] == 'function'){
  23355. fn = arguments[arguments.length-1];
  23356. Array.prototype.splice.call(arguments,arguments.length-1,1);
  23357. }
  23358. for(var k in arguments){
  23359. for(var i in arguments[k]){
  23360. fn(arguments[k][i],i,arguments[k]);
  23361. }
  23362. }
  23363. }
  23364. }).call(undefined);
  23365. (function() {
  23366. SVG.extend(SVG.PathArray, {
  23367. morph: function(array) {
  23368. var startArr = this.value
  23369. , destArr = this.parse(array);
  23370. var startOffsetM = 0
  23371. , destOffsetM = 0;
  23372. var startOffsetNextM = false
  23373. , destOffsetNextM = false;
  23374. while(true){
  23375. // stop if there is no M anymore
  23376. if(startOffsetM === false && destOffsetM === false) break
  23377. // find the next M in path array
  23378. startOffsetNextM = findNextM(startArr, startOffsetM === false ? false : startOffsetM+1);
  23379. destOffsetNextM = findNextM( destArr, destOffsetM === false ? false : destOffsetM+1);
  23380. // We have to add one M to the startArray
  23381. if(startOffsetM === false){
  23382. var bbox = new SVG.PathArray(result.start).bbox();
  23383. // when the last block had no bounding box we simply take the first M we got
  23384. if(bbox.height == 0 || bbox.width == 0){
  23385. startOffsetM = startArr.push(startArr[0]) - 1;
  23386. }else{
  23387. // we take the middle of the bbox instead when we got one
  23388. startOffsetM = startArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  23389. }
  23390. }
  23391. // We have to add one M to the destArray
  23392. if( destOffsetM === false){
  23393. var bbox = new SVG.PathArray(result.dest).bbox();
  23394. if(bbox.height == 0 || bbox.width == 0){
  23395. destOffsetM = destArr.push(destArr[0]) - 1;
  23396. }else{
  23397. destOffsetM = destArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  23398. }
  23399. }
  23400. // handle block from M to next M
  23401. var result = handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM);
  23402. // update the arrays to their new values
  23403. startArr = startArr.slice(0, startOffsetM).concat(result.start, startOffsetNextM === false ? [] : startArr.slice(startOffsetNextM));
  23404. destArr = destArr.slice(0, destOffsetM).concat(result.dest , destOffsetNextM === false ? [] : destArr.slice( destOffsetNextM));
  23405. // update offsets
  23406. startOffsetM = startOffsetNextM === false ? false : startOffsetM + result.start.length;
  23407. destOffsetM = destOffsetNextM === false ? false : destOffsetM + result.dest.length;
  23408. }
  23409. // copy back arrays
  23410. this.value = startArr;
  23411. this.destination = new SVG.PathArray();
  23412. this.destination.value = destArr;
  23413. return this
  23414. }
  23415. });
  23416. // sorry for the long declaration
  23417. // slices out one block (from M to M) and syncronize it so the types and length match
  23418. function handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM, undefined$1){
  23419. // slice out the block we need
  23420. var startArrTemp = startArr.slice(startOffsetM, startOffsetNextM || undefined$1)
  23421. , destArrTemp = destArr.slice( destOffsetM, destOffsetNextM || undefined$1);
  23422. var i = 0
  23423. , posStart = {pos:[0,0], start:[0,0]}
  23424. , posDest = {pos:[0,0], start:[0,0]};
  23425. do{
  23426. // convert shorthand types to long form
  23427. startArrTemp[i] = simplyfy.call(posStart, startArrTemp[i]);
  23428. destArrTemp[i] = simplyfy.call(posDest , destArrTemp[i]);
  23429. // check if both shape types match
  23430. // 2 elliptical arc curve commands ('A'), are considered different if the
  23431. // flags (large-arc-flag, sweep-flag) don't match
  23432. if(startArrTemp[i][0] != destArrTemp[i][0] || startArrTemp[i][0] == 'M' ||
  23433. (startArrTemp[i][0] == 'A' &&
  23434. (startArrTemp[i][4] != destArrTemp[i][4] || startArrTemp[i][5] != destArrTemp[i][5])
  23435. )
  23436. ) {
  23437. // if not, convert shapes to beziere
  23438. Array.prototype.splice.apply(startArrTemp, [i, 1].concat(toBeziere.call(posStart, startArrTemp[i])));
  23439. Array.prototype.splice.apply(destArrTemp, [i, 1].concat(toBeziere.call(posDest, destArrTemp[i])));
  23440. } else {
  23441. // only update positions otherwise
  23442. startArrTemp[i] = setPosAndReflection.call(posStart, startArrTemp[i]);
  23443. destArrTemp[i] = setPosAndReflection.call(posDest , destArrTemp[i]);
  23444. }
  23445. // we are at the end at both arrays. stop here
  23446. if(++i == startArrTemp.length && i == destArrTemp.length) break
  23447. // destArray is longer. Add one element
  23448. if(i == startArrTemp.length){
  23449. startArrTemp.push([
  23450. 'C',
  23451. posStart.pos[0],
  23452. posStart.pos[1],
  23453. posStart.pos[0],
  23454. posStart.pos[1],
  23455. posStart.pos[0],
  23456. posStart.pos[1],
  23457. ]);
  23458. }
  23459. // startArr is longer. Add one element
  23460. if(i == destArrTemp.length){
  23461. destArrTemp.push([
  23462. 'C',
  23463. posDest.pos[0],
  23464. posDest.pos[1],
  23465. posDest.pos[0],
  23466. posDest.pos[1],
  23467. posDest.pos[0],
  23468. posDest.pos[1]
  23469. ]);
  23470. }
  23471. }while(true)
  23472. // return the updated block
  23473. return {start:startArrTemp, dest:destArrTemp}
  23474. }
  23475. // converts shorthand types to long form
  23476. function simplyfy(val){
  23477. switch(val[0]){
  23478. case 'z': // shorthand line to start
  23479. case 'Z':
  23480. val[0] = 'L';
  23481. val[1] = this.start[0];
  23482. val[2] = this.start[1];
  23483. break
  23484. case 'H': // shorthand horizontal line
  23485. val[0] = 'L';
  23486. val[2] = this.pos[1];
  23487. break
  23488. case 'V': // shorthand vertical line
  23489. val[0] = 'L';
  23490. val[2] = val[1];
  23491. val[1] = this.pos[0];
  23492. break
  23493. case 'T': // shorthand quadratic beziere
  23494. val[0] = 'Q';
  23495. val[3] = val[1];
  23496. val[4] = val[2];
  23497. val[1] = this.reflection[1];
  23498. val[2] = this.reflection[0];
  23499. break
  23500. case 'S': // shorthand cubic beziere
  23501. val[0] = 'C';
  23502. val[6] = val[4];
  23503. val[5] = val[3];
  23504. val[4] = val[2];
  23505. val[3] = val[1];
  23506. val[2] = this.reflection[1];
  23507. val[1] = this.reflection[0];
  23508. break
  23509. }
  23510. return val
  23511. }
  23512. // updates reflection point and current position
  23513. function setPosAndReflection(val){
  23514. var len = val.length;
  23515. this.pos = [ val[len-2], val[len-1] ];
  23516. if('SCQT'.indexOf(val[0]) != -1)
  23517. this.reflection = [ 2 * this.pos[0] - val[len-4], 2 * this.pos[1] - val[len-3] ];
  23518. return val
  23519. }
  23520. // converts all types to cubic beziere
  23521. function toBeziere(val){
  23522. var retVal = [val];
  23523. switch(val[0]){
  23524. case 'M': // special handling for M
  23525. this.pos = this.start = [val[1], val[2]];
  23526. return retVal
  23527. case 'L':
  23528. val[5] = val[3] = val[1];
  23529. val[6] = val[4] = val[2];
  23530. val[1] = this.pos[0];
  23531. val[2] = this.pos[1];
  23532. break
  23533. case 'Q':
  23534. val[6] = val[4];
  23535. val[5] = val[3];
  23536. val[4] = val[4] * 1/3 + val[2] * 2/3;
  23537. val[3] = val[3] * 1/3 + val[1] * 2/3;
  23538. val[2] = this.pos[1] * 1/3 + val[2] * 2/3;
  23539. val[1] = this.pos[0] * 1/3 + val[1] * 2/3;
  23540. break
  23541. case 'A':
  23542. retVal = arcToBeziere(this.pos, val);
  23543. val = retVal[0];
  23544. break
  23545. }
  23546. val[0] = 'C';
  23547. this.pos = [val[5], val[6]];
  23548. this.reflection = [2 * val[5] - val[3], 2 * val[6] - val[4]];
  23549. return retVal
  23550. }
  23551. // finds the next position of type M
  23552. function findNextM(arr, offset){
  23553. if(offset === false) return false
  23554. for(var i = offset, len = arr.length;i < len;++i){
  23555. if(arr[i][0] == 'M') return i
  23556. }
  23557. return false
  23558. }
  23559. // Convert an arc segment into equivalent cubic Bezier curves
  23560. // Depending on the arc, up to 4 curves might be used to represent it since a
  23561. // curve gives a good approximation for only a quarter of an ellipse
  23562. // The curves are returned as an array of SVG curve commands:
  23563. // [ ['C', x1, y1, x2, y2, x, y] ... ]
  23564. function arcToBeziere(pos, val) {
  23565. // Parameters extraction, handle out-of-range parameters as specified in the SVG spec
  23566. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcOutOfRangeParameters
  23567. var rx = Math.abs(val[1]), ry = Math.abs(val[2]), xAxisRotation = val[3] % 360
  23568. , largeArcFlag = val[4], sweepFlag = val[5], x = val[6], y = val[7]
  23569. , A = new SVG.Point(pos), B = new SVG.Point(x, y)
  23570. , primedCoord, lambda, mat, k, c, cSquare, t, O, OA, OB, tetaStart, tetaEnd
  23571. , deltaTeta, nbSectors, f, arcSegPoints, angle, sinAngle, cosAngle, pt, i, il
  23572. , retVal = [], x1, y1, x2, y2;
  23573. // Ensure radii are non-zero
  23574. if(rx === 0 || ry === 0 || (A.x === B.x && A.y === B.y)) {
  23575. // treat this arc as a straight line segment
  23576. return [['C', A.x, A.y, B.x, B.y, B.x, B.y]]
  23577. }
  23578. // Ensure radii are large enough using the algorithm provided in the SVG spec
  23579. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcCorrectionOutOfRangeRadii
  23580. primedCoord = new SVG.Point((A.x-B.x)/2, (A.y-B.y)/2).transform(new SVG.Matrix().rotate(xAxisRotation));
  23581. lambda = (primedCoord.x * primedCoord.x) / (rx * rx) + (primedCoord.y * primedCoord.y) / (ry * ry);
  23582. if(lambda > 1) {
  23583. lambda = Math.sqrt(lambda);
  23584. rx = lambda*rx;
  23585. ry = lambda*ry;
  23586. }
  23587. // To simplify calculations, we make the arc part of a unit circle (rayon is 1) instead of an ellipse
  23588. mat = new SVG.Matrix().rotate(xAxisRotation).scale(1/rx, 1/ry).rotate(-xAxisRotation);
  23589. A = A.transform(mat);
  23590. B = B.transform(mat);
  23591. // Calculate the horizontal and vertical distance between the initial and final point of the arc
  23592. k = [B.x-A.x, B.y-A.y];
  23593. // Find the length of the chord formed by A and B
  23594. cSquare = k[0]*k[0] + k[1]*k[1];
  23595. c = Math.sqrt(cSquare);
  23596. // Calculate the ratios of the horizontal and vertical distance on the length of the chord
  23597. k[0] /= c;
  23598. k[1] /= c;
  23599. // Calculate the distance between the circle center and the chord midpoint
  23600. // using this formula: t = sqrt(r^2 - c^2 / 4)
  23601. // where t is the distance between the cirle center and the chord midpoint,
  23602. // r is the rayon of the circle and c is the chord length
  23603. // From: http://www.ajdesigner.com/phpcircle/circle_segment_chord_t.php
  23604. // Because of the imprecision of floating point numbers, cSquare might end
  23605. // up being slightly above 4 which would result in a negative radicand
  23606. // To prevent that, a test is made before computing the square root
  23607. t = (cSquare < 4) ? Math.sqrt(1 - cSquare/4) : 0;
  23608. // For most situations, there are actually two different ellipses that
  23609. // satisfy the constraints imposed by the points A and B, the radii rx and ry,
  23610. // and the xAxisRotation
  23611. // When the flags largeArcFlag and sweepFlag are equal, it means that the
  23612. // second ellipse is used as a solution
  23613. // See: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
  23614. if(largeArcFlag === sweepFlag) {
  23615. t *= -1;
  23616. }
  23617. // Calculate the coordinates of the center of the circle from the midpoint of the chord
  23618. // This is done by multiplying the ratios calculated previously by the distance between
  23619. // the circle center and the chord midpoint and using these values to go from the midpoint
  23620. // to the center of the circle
  23621. // The negative of the vertical distance ratio is used to modify the x coordinate while
  23622. // the horizontal distance ratio is used to modify the y coordinate
  23623. // That is because the center of the circle is perpendicular to the chord and perpendicular
  23624. // lines are negative reciprocals
  23625. O = new SVG.Point((B.x+A.x)/2 + t*-k[1], (B.y+A.y)/2 + t*k[0]);
  23626. // Move the center of the circle at the origin
  23627. OA = new SVG.Point(A.x-O.x, A.y-O.y);
  23628. OB = new SVG.Point(B.x-O.x, B.y-O.y);
  23629. // Calculate the start and end angle
  23630. tetaStart = Math.acos(OA.x/Math.sqrt(OA.x*OA.x + OA.y*OA.y));
  23631. if (OA.y < 0) {
  23632. tetaStart *= -1;
  23633. }
  23634. tetaEnd = Math.acos(OB.x/Math.sqrt(OB.x*OB.x + OB.y*OB.y));
  23635. if (OB.y < 0) {
  23636. tetaEnd *= -1;
  23637. }
  23638. // If sweep-flag is '1', then the arc will be drawn in a "positive-angle" direction,
  23639. // make sure that the end angle is above the start angle
  23640. if (sweepFlag && tetaStart > tetaEnd) {
  23641. tetaEnd += 2*Math.PI;
  23642. }
  23643. // If sweep-flag is '0', then the arc will be drawn in a "negative-angle" direction,
  23644. // make sure that the end angle is below the start angle
  23645. if (!sweepFlag && tetaStart < tetaEnd) {
  23646. tetaEnd -= 2*Math.PI;
  23647. }
  23648. // Find the number of Bezier curves that are required to represent the arc
  23649. // A cubic Bezier curve gives a good enough approximation when representing at most a quarter of a circle
  23650. nbSectors = Math.ceil(Math.abs(tetaStart-tetaEnd) * 2/Math.PI);
  23651. // Calculate the coordinates of the points of all the Bezier curves required to represent the arc
  23652. // For an in-depth explanation of this part see: http://pomax.github.io/bezierinfo/#circles_cubic
  23653. arcSegPoints = [];
  23654. angle = tetaStart;
  23655. deltaTeta = (tetaEnd-tetaStart)/nbSectors;
  23656. f = 4*Math.tan(deltaTeta/4)/3;
  23657. for (i = 0; i <= nbSectors; i++) { // The <= is because a Bezier curve have a start and a endpoint
  23658. cosAngle = Math.cos(angle);
  23659. sinAngle = Math.sin(angle);
  23660. pt = new SVG.Point(O.x+cosAngle, O.y+sinAngle);
  23661. 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)];
  23662. angle += deltaTeta;
  23663. }
  23664. // Remove the first control point of the first segment point and remove the second control point of the last segment point
  23665. // These two control points are not used in the approximation of the arc, that is why they are removed
  23666. arcSegPoints[0][0] = arcSegPoints[0][1].clone();
  23667. arcSegPoints[arcSegPoints.length-1][2] = arcSegPoints[arcSegPoints.length-1][1].clone();
  23668. // Revert the transformation that was applied to make the arc part of a unit circle instead of an ellipse
  23669. mat = new SVG.Matrix().rotate(xAxisRotation).scale(rx, ry).rotate(-xAxisRotation);
  23670. for (i = 0, il = arcSegPoints.length; i < il; i++) {
  23671. arcSegPoints[i][0] = arcSegPoints[i][0].transform(mat);
  23672. arcSegPoints[i][1] = arcSegPoints[i][1].transform(mat);
  23673. arcSegPoints[i][2] = arcSegPoints[i][2].transform(mat);
  23674. }
  23675. // Convert the segments points to SVG curve commands
  23676. for (i = 1, il = arcSegPoints.length; i < il; i++) {
  23677. pt = arcSegPoints[i-1][2];
  23678. x1 = pt.x;
  23679. y1 = pt.y;
  23680. pt = arcSegPoints[i][0];
  23681. x2 = pt.x;
  23682. y2 = pt.y;
  23683. pt = arcSegPoints[i][1];
  23684. x = pt.x;
  23685. y = pt.y;
  23686. retVal.push(['C', x1, y1, x2, y2, x, y]);
  23687. }
  23688. return retVal
  23689. }
  23690. }());
  23691. /*! svg.draggable.js - v2.2.2 - 2019-01-08
  23692. * https://github.com/svgdotjs/svg.draggable.js
  23693. * Copyright (c) 2019 Wout Fierens; Licensed MIT */
  23694. (function() {
  23695. // creates handler, saves it
  23696. function DragHandler(el){
  23697. el.remember('_draggable', this);
  23698. this.el = el;
  23699. }
  23700. // Sets new parameter, starts dragging
  23701. DragHandler.prototype.init = function(constraint, val){
  23702. var _this = this;
  23703. this.constraint = constraint;
  23704. this.value = val;
  23705. this.el.on('mousedown.drag', function(e){ _this.start(e); });
  23706. this.el.on('touchstart.drag', function(e){ _this.start(e); });
  23707. };
  23708. // transforms one point from screen to user coords
  23709. DragHandler.prototype.transformPoint = function(event, offset){
  23710. event = event || window.event;
  23711. var touches = event.changedTouches && event.changedTouches[0] || event;
  23712. this.p.x = touches.clientX - (offset || 0);
  23713. this.p.y = touches.clientY;
  23714. return this.p.matrixTransform(this.m)
  23715. };
  23716. // gets elements bounding box with special handling of groups, nested and use
  23717. DragHandler.prototype.getBBox = function(){
  23718. var box = this.el.bbox();
  23719. if(this.el instanceof SVG.Nested) box = this.el.rbox();
  23720. if (this.el instanceof SVG.G || this.el instanceof SVG.Use || this.el instanceof SVG.Nested) {
  23721. box.x = this.el.x();
  23722. box.y = this.el.y();
  23723. }
  23724. return box
  23725. };
  23726. // start dragging
  23727. DragHandler.prototype.start = function(e){
  23728. // check for left button
  23729. if(e.type == 'click'|| e.type == 'mousedown' || e.type == 'mousemove'){
  23730. if((e.which || e.buttons) != 1){
  23731. return
  23732. }
  23733. }
  23734. var _this = this;
  23735. // fire beforedrag event
  23736. this.el.fire('beforedrag', { event: e, handler: this });
  23737. if(this.el.event().defaultPrevented) return;
  23738. // prevent browser drag behavior as soon as possible
  23739. e.preventDefault();
  23740. // prevent propagation to a parent that might also have dragging enabled
  23741. e.stopPropagation();
  23742. // search for parent on the fly to make sure we can call
  23743. // draggable() even when element is not in the dom currently
  23744. this.parent = this.parent || this.el.parent(SVG.Nested) || this.el.parent(SVG.Doc);
  23745. this.p = this.parent.node.createSVGPoint();
  23746. // save current transformation matrix
  23747. this.m = this.el.node.getScreenCTM().inverse();
  23748. var box = this.getBBox();
  23749. var anchorOffset;
  23750. // fix text-anchor in text-element (#37)
  23751. if(this.el instanceof SVG.Text){
  23752. anchorOffset = this.el.node.getComputedTextLength();
  23753. switch(this.el.attr('text-anchor')){
  23754. case 'middle':
  23755. anchorOffset /= 2;
  23756. break
  23757. case 'start':
  23758. anchorOffset = 0;
  23759. break;
  23760. }
  23761. }
  23762. this.startPoints = {
  23763. // We take absolute coordinates since we are just using a delta here
  23764. point: this.transformPoint(e, anchorOffset),
  23765. box: box,
  23766. transform: this.el.transform()
  23767. };
  23768. // add drag and end events to window
  23769. SVG.on(window, 'mousemove.drag', function(e){ _this.drag(e); });
  23770. SVG.on(window, 'touchmove.drag', function(e){ _this.drag(e); });
  23771. SVG.on(window, 'mouseup.drag', function(e){ _this.end(e); });
  23772. SVG.on(window, 'touchend.drag', function(e){ _this.end(e); });
  23773. // fire dragstart event
  23774. this.el.fire('dragstart', {event: e, p: this.startPoints.point, m: this.m, handler: this});
  23775. };
  23776. // while dragging
  23777. DragHandler.prototype.drag = function(e){
  23778. var box = this.getBBox()
  23779. , p = this.transformPoint(e)
  23780. , x = this.startPoints.box.x + p.x - this.startPoints.point.x
  23781. , y = this.startPoints.box.y + p.y - this.startPoints.point.y
  23782. , c = this.constraint
  23783. , gx = p.x - this.startPoints.point.x
  23784. , gy = p.y - this.startPoints.point.y;
  23785. this.el.fire('dragmove', {
  23786. event: e
  23787. , p: p
  23788. , m: this.m
  23789. , handler: this
  23790. });
  23791. if(this.el.event().defaultPrevented) return p
  23792. // move the element to its new position, if possible by constraint
  23793. if (typeof c == 'function') {
  23794. var coord = c.call(this.el, x, y, this.m);
  23795. // bool, just show us if movement is allowed or not
  23796. if (typeof coord == 'boolean') {
  23797. coord = {
  23798. x: coord,
  23799. y: coord
  23800. };
  23801. }
  23802. // if true, we just move. If !false its a number and we move it there
  23803. if (coord.x === true) {
  23804. this.el.x(x);
  23805. } else if (coord.x !== false) {
  23806. this.el.x(coord.x);
  23807. }
  23808. if (coord.y === true) {
  23809. this.el.y(y);
  23810. } else if (coord.y !== false) {
  23811. this.el.y(coord.y);
  23812. }
  23813. } else if (typeof c == 'object') {
  23814. // keep element within constrained box
  23815. if (c.minX != null && x < c.minX) {
  23816. x = c.minX;
  23817. gx = x - this.startPoints.box.x;
  23818. } else if (c.maxX != null && x > c.maxX - box.width) {
  23819. x = c.maxX - box.width;
  23820. gx = x - this.startPoints.box.x;
  23821. } if (c.minY != null && y < c.minY) {
  23822. y = c.minY;
  23823. gy = y - this.startPoints.box.y;
  23824. } else if (c.maxY != null && y > c.maxY - box.height) {
  23825. y = c.maxY - box.height;
  23826. gy = y - this.startPoints.box.y;
  23827. }
  23828. if (c.snapToGrid != null) {
  23829. x = x - (x % c.snapToGrid);
  23830. y = y - (y % c.snapToGrid);
  23831. gx = gx - (gx % c.snapToGrid);
  23832. gy = gy - (gy % c.snapToGrid);
  23833. }
  23834. if(this.el instanceof SVG.G)
  23835. this.el.matrix(this.startPoints.transform).transform({x:gx, y: gy}, true);
  23836. else
  23837. this.el.move(x, y);
  23838. }
  23839. // so we can use it in the end-method, too
  23840. return p
  23841. };
  23842. DragHandler.prototype.end = function(e){
  23843. // final drag
  23844. var p = this.drag(e);
  23845. // fire dragend event
  23846. this.el.fire('dragend', { event: e, p: p, m: this.m, handler: this });
  23847. // unbind events
  23848. SVG.off(window, 'mousemove.drag');
  23849. SVG.off(window, 'touchmove.drag');
  23850. SVG.off(window, 'mouseup.drag');
  23851. SVG.off(window, 'touchend.drag');
  23852. };
  23853. SVG.extend(SVG.Element, {
  23854. // Make element draggable
  23855. // Constraint might be an object (as described in readme.md) or a function in the form "function (x, y)" that gets called before every move.
  23856. // The function can return a boolean or an object of the form {x, y}, to which the element will be moved. "False" skips moving, true moves to raw x, y.
  23857. draggable: function(value, constraint) {
  23858. // Check the parameters and reassign if needed
  23859. if (typeof value == 'function' || typeof value == 'object') {
  23860. constraint = value;
  23861. value = true;
  23862. }
  23863. var dragHandler = this.remember('_draggable') || new DragHandler(this);
  23864. // When no parameter is given, value is true
  23865. value = typeof value === 'undefined' ? true : value;
  23866. if(value) dragHandler.init(constraint || {}, value);
  23867. else {
  23868. this.off('mousedown.drag');
  23869. this.off('touchstart.drag');
  23870. }
  23871. return this
  23872. }
  23873. });
  23874. }).call(undefined);
  23875. (function() {
  23876. function SelectHandler(el) {
  23877. this.el = el;
  23878. el.remember('_selectHandler', this);
  23879. this.pointSelection = {isSelected: false};
  23880. this.rectSelection = {isSelected: false};
  23881. // helper list with position settings of each type of point
  23882. this.pointsList = {
  23883. lt: [ 0, 0 ],
  23884. rt: [ 'width', 0 ],
  23885. rb: [ 'width', 'height' ],
  23886. lb: [ 0, 'height' ],
  23887. t: [ 'width', 0 ],
  23888. r: [ 'width', 'height' ],
  23889. b: [ 'width', 'height' ],
  23890. l: [ 0, 'height' ]
  23891. };
  23892. // helper function to get point coordinates based on settings above and an object (bbox in our case)
  23893. this.pointCoord = function (setting, object, isPointCentered) {
  23894. var coord = typeof setting !== 'string' ? setting : object[setting];
  23895. // Top, bottom, right and left points are placed in the center of element width/height
  23896. return isPointCentered ? coord / 2 : coord
  23897. };
  23898. this.pointCoords = function (point, object) {
  23899. var settings = this.pointsList[point];
  23900. return {
  23901. x: this.pointCoord(settings[0], object, (point === 't' || point === 'b')),
  23902. y: this.pointCoord(settings[1], object, (point === 'r' || point === 'l'))
  23903. }
  23904. };
  23905. }
  23906. SelectHandler.prototype.init = function (value, options) {
  23907. var bbox = this.el.bbox();
  23908. this.options = {};
  23909. // store defaults list of points in order to verify users config
  23910. var points = this.el.selectize.defaults.points;
  23911. // Merging the defaults and the options-object together
  23912. for (var i in this.el.selectize.defaults) {
  23913. this.options[i] = this.el.selectize.defaults[i];
  23914. if (options[i] !== undefined) {
  23915. this.options[i] = options[i];
  23916. }
  23917. }
  23918. // prepare & validate list of points to be added (or excluded)
  23919. var pointsLists = ['points', 'pointsExclude'];
  23920. for (var i in pointsLists) {
  23921. var option = this.options[pointsLists[i]];
  23922. if (typeof option === 'string') {
  23923. if (option.length > 0) {
  23924. // if set as comma separated string list => convert it into an array
  23925. option = option.split(/\s*,\s*/i);
  23926. } else {
  23927. option = [];
  23928. }
  23929. } else if (typeof option === 'boolean' && pointsLists[i] === 'points') {
  23930. // this is not needed, but let's have it for legacy support
  23931. option = option ? points : [];
  23932. }
  23933. this.options[pointsLists[i]] = option;
  23934. }
  23935. // intersect correct all points options with users config (exclude unwanted points)
  23936. // ES5 -> NO arrow functions nor Array.includes()
  23937. this.options.points = [ points, this.options.points ].reduce(
  23938. function (a, b) {
  23939. return a.filter(
  23940. function (c) {
  23941. return b.indexOf(c) > -1;
  23942. }
  23943. )
  23944. }
  23945. );
  23946. // exclude pointsExclude, if wanted
  23947. this.options.points = [ this.options.points, this.options.pointsExclude ].reduce(
  23948. function (a, b) {
  23949. return a.filter(
  23950. function (c) {
  23951. return b.indexOf(c) < 0;
  23952. }
  23953. )
  23954. }
  23955. );
  23956. this.parent = this.el.parent();
  23957. this.nested = (this.nested || this.parent.group());
  23958. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  23959. // When deepSelect is enabled and the element is a line/polyline/polygon, draw only points for moving
  23960. if (this.options.deepSelect && ['line', 'polyline', 'polygon'].indexOf(this.el.type) !== -1) {
  23961. this.selectPoints(value);
  23962. } else {
  23963. this.selectRect(value);
  23964. }
  23965. this.observe();
  23966. this.cleanup();
  23967. };
  23968. SelectHandler.prototype.selectPoints = function (value) {
  23969. this.pointSelection.isSelected = value;
  23970. // When set is already there we dont have to create one
  23971. if (this.pointSelection.set) {
  23972. return this;
  23973. }
  23974. // Create our set of elements
  23975. this.pointSelection.set = this.parent.set();
  23976. // draw the points and mark the element as selected
  23977. this.drawPoints();
  23978. return this;
  23979. };
  23980. // create the point-array which contains the 2 points of a line or simply the points-array of polyline/polygon
  23981. SelectHandler.prototype.getPointArray = function () {
  23982. var bbox = this.el.bbox();
  23983. return this.el.array().valueOf().map(function (el) {
  23984. return [el[0] - bbox.x, el[1] - bbox.y];
  23985. });
  23986. };
  23987. // Draws a points
  23988. SelectHandler.prototype.drawPoints = function () {
  23989. var _this = this, array = this.getPointArray();
  23990. // go through the array of points
  23991. for (var i = 0, len = array.length; i < len; ++i) {
  23992. var curriedEvent = (function (k) {
  23993. return function (ev) {
  23994. ev = ev || window.event;
  23995. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  23996. ev.stopPropagation();
  23997. var x = ev.pageX || ev.touches[0].pageX;
  23998. var y = ev.pageY || ev.touches[0].pageY;
  23999. _this.el.fire('point', {x: x, y: y, i: k, event: ev});
  24000. };
  24001. })(i);
  24002. // add every point to the set
  24003. // add css-classes and a touchstart-event which fires our event for moving points
  24004. var point = this.drawPoint(array[i][0], array[i][1])
  24005. .addClass(this.options.classPoints)
  24006. .addClass(this.options.classPoints + '_point')
  24007. .on('touchstart', curriedEvent)
  24008. .on('mousedown', curriedEvent);
  24009. this.pointSelection.set.add(point);
  24010. }
  24011. };
  24012. // The function to draw single point
  24013. SelectHandler.prototype.drawPoint = function (cx, cy) {
  24014. var pointType = this.options.pointType;
  24015. switch (pointType) {
  24016. case 'circle':
  24017. return this.drawCircle(cx, cy);
  24018. case 'rect':
  24019. return this.drawRect(cx, cy);
  24020. default:
  24021. if (typeof pointType === 'function') {
  24022. return pointType.call(this, cx, cy);
  24023. }
  24024. throw new Error('Unknown ' + pointType + ' point type!');
  24025. }
  24026. };
  24027. // The function to draw the circle point
  24028. SelectHandler.prototype.drawCircle = function (cx, cy) {
  24029. return this.nested.circle(this.options.pointSize)
  24030. .center(cx, cy);
  24031. };
  24032. // The function to draw the rect point
  24033. SelectHandler.prototype.drawRect = function (cx, cy) {
  24034. return this.nested.rect(this.options.pointSize, this.options.pointSize)
  24035. .center(cx, cy);
  24036. };
  24037. // every time a point is moved, we have to update the positions of our point
  24038. SelectHandler.prototype.updatePointSelection = function () {
  24039. var array = this.getPointArray();
  24040. this.pointSelection.set.each(function (i) {
  24041. if (this.cx() === array[i][0] && this.cy() === array[i][1]) {
  24042. return;
  24043. }
  24044. this.center(array[i][0], array[i][1]);
  24045. });
  24046. };
  24047. SelectHandler.prototype.updateRectSelection = function () {
  24048. var _this = this, bbox = this.el.bbox();
  24049. this.rectSelection.set.get(0).attr({
  24050. width: bbox.width,
  24051. height: bbox.height
  24052. });
  24053. // set.get(1) is always in the upper left corner. no need to move it
  24054. if (this.options.points.length) {
  24055. this.options.points.map(function (point, index) {
  24056. var coords = _this.pointCoords(point, bbox);
  24057. _this.rectSelection.set.get(index + 1).center(coords.x, coords.y);
  24058. });
  24059. }
  24060. if (this.options.rotationPoint) {
  24061. var length = this.rectSelection.set.length();
  24062. this.rectSelection.set.get(length - 1).center(bbox.width / 2, 20);
  24063. }
  24064. };
  24065. SelectHandler.prototype.selectRect = function (value) {
  24066. var _this = this, bbox = this.el.bbox();
  24067. this.rectSelection.isSelected = value;
  24068. // when set is already p
  24069. this.rectSelection.set = this.rectSelection.set || this.parent.set();
  24070. // helperFunction to create a mouse-down function which triggers the event specified in `eventName`
  24071. function getMoseDownFunc(eventName) {
  24072. return function (ev) {
  24073. ev = ev || window.event;
  24074. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  24075. ev.stopPropagation();
  24076. var x = ev.pageX || ev.touches[0].pageX;
  24077. var y = ev.pageY || ev.touches[0].pageY;
  24078. _this.el.fire(eventName, {x: x, y: y, event: ev});
  24079. };
  24080. }
  24081. // create the selection-rectangle and add the css-class
  24082. if (!this.rectSelection.set.get(0)) {
  24083. this.rectSelection.set.add(this.nested.rect(bbox.width, bbox.height).addClass(this.options.classRect));
  24084. }
  24085. // Draw Points at the edges, if enabled
  24086. if (this.options.points.length && this.rectSelection.set.length() < 2) {
  24087. var ename ="touchstart", mname = "mousedown";
  24088. this.options.points.map(function (point, index) {
  24089. var coords = _this.pointCoords(point, bbox);
  24090. var pointElement = _this.drawPoint(coords.x, coords.y)
  24091. .attr('class', _this.options.classPoints + '_' + point)
  24092. .on(mname, getMoseDownFunc(point))
  24093. .on(ename, getMoseDownFunc(point));
  24094. _this.rectSelection.set.add(pointElement);
  24095. });
  24096. this.rectSelection.set.each(function () {
  24097. this.addClass(_this.options.classPoints);
  24098. });
  24099. }
  24100. // draw rotationPint, if enabled
  24101. if (this.options.rotationPoint && ((this.options.points && !this.rectSelection.set.get(9)) || (!this.options.points && !this.rectSelection.set.get(1)))) {
  24102. var curriedEvent = function (ev) {
  24103. ev = ev || window.event;
  24104. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  24105. ev.stopPropagation();
  24106. var x = ev.pageX || ev.touches[0].pageX;
  24107. var y = ev.pageY || ev.touches[0].pageY;
  24108. _this.el.fire('rot', {x: x, y: y, event: ev});
  24109. };
  24110. var pointElement = this.drawPoint(bbox.width / 2, 20)
  24111. .attr('class', this.options.classPoints + '_rot')
  24112. .on("touchstart", curriedEvent)
  24113. .on("mousedown", curriedEvent);
  24114. this.rectSelection.set.add(pointElement);
  24115. }
  24116. };
  24117. SelectHandler.prototype.handler = function () {
  24118. var bbox = this.el.bbox();
  24119. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  24120. if (this.rectSelection.isSelected) {
  24121. this.updateRectSelection();
  24122. }
  24123. if (this.pointSelection.isSelected) {
  24124. this.updatePointSelection();
  24125. }
  24126. };
  24127. SelectHandler.prototype.observe = function () {
  24128. var _this = this;
  24129. if (MutationObserver) {
  24130. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  24131. this.observerInst = this.observerInst || new MutationObserver(function () {
  24132. _this.handler();
  24133. });
  24134. this.observerInst.observe(this.el.node, {attributes: true});
  24135. } else {
  24136. try {
  24137. this.observerInst.disconnect();
  24138. delete this.observerInst;
  24139. } catch (e) {
  24140. }
  24141. }
  24142. } else {
  24143. this.el.off('DOMAttrModified.select');
  24144. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  24145. this.el.on('DOMAttrModified.select', function () {
  24146. _this.handler();
  24147. });
  24148. }
  24149. }
  24150. };
  24151. SelectHandler.prototype.cleanup = function () {
  24152. //var _this = this;
  24153. if (!this.rectSelection.isSelected && this.rectSelection.set) {
  24154. // stop watching the element, remove the selection
  24155. this.rectSelection.set.each(function () {
  24156. this.remove();
  24157. });
  24158. this.rectSelection.set.clear();
  24159. delete this.rectSelection.set;
  24160. }
  24161. if (!this.pointSelection.isSelected && this.pointSelection.set) {
  24162. // Remove all points, clear the set, stop watching the element
  24163. this.pointSelection.set.each(function () {
  24164. this.remove();
  24165. });
  24166. this.pointSelection.set.clear();
  24167. delete this.pointSelection.set;
  24168. }
  24169. if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
  24170. this.nested.remove();
  24171. delete this.nested;
  24172. }
  24173. };
  24174. SVG.extend(SVG.Element, {
  24175. // Select element with mouse
  24176. selectize: function (value, options) {
  24177. // Check the parameters and reassign if needed
  24178. if (typeof value === 'object') {
  24179. options = value;
  24180. value = true;
  24181. }
  24182. var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
  24183. selectHandler.init(value === undefined ? true : value, options || {});
  24184. return this;
  24185. }
  24186. });
  24187. SVG.Element.prototype.selectize.defaults = {
  24188. points: ['lt', 'rt', 'rb', 'lb', 't', 'r', 'b', 'l'], // which points to draw, default all
  24189. pointsExclude: [], // easier option if to exclude few than rewrite all
  24190. classRect: 'svg_select_boundingRect', // Css-class added to the rect
  24191. classPoints: 'svg_select_points', // Css-class added to the points
  24192. pointSize: 7, // size of point
  24193. rotationPoint: true, // If true, rotation point is drawn. Needed for rotation!
  24194. deepSelect: false, // If true, moving of single points is possible (only line, polyline, polyon)
  24195. pointType: 'circle' // Point type: circle or rect, default circle
  24196. };
  24197. }());
  24198. (function() {
  24199. (function () {
  24200. function ResizeHandler(el) {
  24201. el.remember('_resizeHandler', this);
  24202. this.el = el;
  24203. this.parameters = {};
  24204. this.lastUpdateCall = null;
  24205. this.p = el.doc().node.createSVGPoint();
  24206. }
  24207. ResizeHandler.prototype.transformPoint = function(x, y, m){
  24208. this.p.x = x - (this.offset.x - window.pageXOffset);
  24209. this.p.y = y - (this.offset.y - window.pageYOffset);
  24210. return this.p.matrixTransform(m || this.m);
  24211. };
  24212. ResizeHandler.prototype._extractPosition = function(event) {
  24213. // Extract a position from a mouse/touch event.
  24214. // Returns { x: .., y: .. }
  24215. return {
  24216. x: event.clientX != null ? event.clientX : event.touches[0].clientX,
  24217. y: event.clientY != null ? event.clientY : event.touches[0].clientY
  24218. }
  24219. };
  24220. ResizeHandler.prototype.init = function (options) {
  24221. var _this = this;
  24222. this.stop();
  24223. if (options === 'stop') {
  24224. return;
  24225. }
  24226. this.options = {};
  24227. // Merge options and defaults
  24228. for (var i in this.el.resize.defaults) {
  24229. this.options[i] = this.el.resize.defaults[i];
  24230. if (typeof options[i] !== 'undefined') {
  24231. this.options[i] = options[i];
  24232. }
  24233. }
  24234. // We listen to all these events which are specifying different edges
  24235. this.el.on('lt.resize', function(e){ _this.resize(e || window.event); }); // Left-Top
  24236. this.el.on('rt.resize', function(e){ _this.resize(e || window.event); }); // Right-Top
  24237. this.el.on('rb.resize', function(e){ _this.resize(e || window.event); }); // Right-Bottom
  24238. this.el.on('lb.resize', function(e){ _this.resize(e || window.event); }); // Left-Bottom
  24239. this.el.on('t.resize', function(e){ _this.resize(e || window.event); }); // Top
  24240. this.el.on('r.resize', function(e){ _this.resize(e || window.event); }); // Right
  24241. this.el.on('b.resize', function(e){ _this.resize(e || window.event); }); // Bottom
  24242. this.el.on('l.resize', function(e){ _this.resize(e || window.event); }); // Left
  24243. this.el.on('rot.resize', function(e){ _this.resize(e || window.event); }); // Rotation
  24244. this.el.on('point.resize', function(e){ _this.resize(e || window.event); }); // Point-Moving
  24245. // This call ensures, that the plugin reacts to a change of snapToGrid immediately
  24246. this.update();
  24247. };
  24248. ResizeHandler.prototype.stop = function(){
  24249. this.el.off('lt.resize');
  24250. this.el.off('rt.resize');
  24251. this.el.off('rb.resize');
  24252. this.el.off('lb.resize');
  24253. this.el.off('t.resize');
  24254. this.el.off('r.resize');
  24255. this.el.off('b.resize');
  24256. this.el.off('l.resize');
  24257. this.el.off('rot.resize');
  24258. this.el.off('point.resize');
  24259. return this;
  24260. };
  24261. ResizeHandler.prototype.resize = function (event) {
  24262. var _this = this;
  24263. this.m = this.el.node.getScreenCTM().inverse();
  24264. this.offset = { x: window.pageXOffset, y: window.pageYOffset };
  24265. var txPt = this._extractPosition(event.detail.event);
  24266. this.parameters = {
  24267. type: this.el.type, // the type of element
  24268. p: this.transformPoint(txPt.x, txPt.y),
  24269. x: event.detail.x, // x-position of the mouse when resizing started
  24270. y: event.detail.y, // y-position of the mouse when resizing started
  24271. box: this.el.bbox(), // The bounding-box of the element
  24272. rotation: this.el.transform().rotation // The current rotation of the element
  24273. };
  24274. // Add font-size parameter if the element type is text
  24275. if (this.el.type === "text") {
  24276. this.parameters.fontSize = this.el.attr()["font-size"];
  24277. }
  24278. // the i-param in the event holds the index of the point which is moved, when using `deepSelect`
  24279. if (event.detail.i !== undefined) {
  24280. // get the point array
  24281. var array = this.el.array().valueOf();
  24282. // Save the index and the point which is moved
  24283. this.parameters.i = event.detail.i;
  24284. this.parameters.pointCoords = [array[event.detail.i][0], array[event.detail.i][1]];
  24285. }
  24286. // Lets check which edge of the bounding-box was clicked and resize the this.el according to this
  24287. switch (event.type) {
  24288. // Left-Top-Edge
  24289. case 'lt':
  24290. // We build a calculating function for every case which gives us the new position of the this.el
  24291. this.calc = function (diffX, diffY) {
  24292. // The procedure is always the same
  24293. // First we snap the edge to the given grid (snapping to 1px grid is normal resizing)
  24294. var snap = this.snapToGrid(diffX, diffY);
  24295. // Now we check if the new height and width still valid (> 0)
  24296. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  24297. // ...if valid, we resize the this.el (which can include moving because the coord-system starts at the left-top and this edge is moving sometimes when resized)
  24298. /*
  24299. * but first check if the element is text box, so we can change the font size instead of
  24300. * the width and height
  24301. */
  24302. if (this.parameters.type === "text") {
  24303. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  24304. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  24305. return;
  24306. }
  24307. snap = this.checkAspectRatio(snap);
  24308. 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]);
  24309. }
  24310. };
  24311. break;
  24312. // Right-Top
  24313. case 'rt':
  24314. // s.a.
  24315. this.calc = function (diffX, diffY) {
  24316. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  24317. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  24318. if (this.parameters.type === "text") {
  24319. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  24320. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  24321. return;
  24322. }
  24323. snap = this.checkAspectRatio(snap, true);
  24324. 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]);
  24325. }
  24326. };
  24327. break;
  24328. // Right-Bottom
  24329. case 'rb':
  24330. // s.a.
  24331. this.calc = function (diffX, diffY) {
  24332. var snap = this.snapToGrid(diffX, diffY, 0);
  24333. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  24334. if (this.parameters.type === "text") {
  24335. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  24336. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  24337. return;
  24338. }
  24339. snap = this.checkAspectRatio(snap);
  24340. this.el.move(this.parameters.box.x, this.parameters.box.y).size(this.parameters.box.width + snap[0], this.parameters.box.height + snap[1]);
  24341. }
  24342. };
  24343. break;
  24344. // Left-Bottom
  24345. case 'lb':
  24346. // s.a.
  24347. this.calc = function (diffX, diffY) {
  24348. var snap = this.snapToGrid(diffX, diffY, 1);
  24349. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  24350. if (this.parameters.type === "text") {
  24351. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  24352. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  24353. return;
  24354. }
  24355. snap = this.checkAspectRatio(snap, true);
  24356. 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]);
  24357. }
  24358. };
  24359. break;
  24360. // Top
  24361. case 't':
  24362. // s.a.
  24363. this.calc = function (diffX, diffY) {
  24364. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  24365. if (this.parameters.box.height - snap[1] > 0) {
  24366. // Disable the font-resizing if it is not from the corner of bounding-box
  24367. if (this.parameters.type === "text") {
  24368. return;
  24369. }
  24370. this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).height(this.parameters.box.height - snap[1]);
  24371. }
  24372. };
  24373. break;
  24374. // Right
  24375. case 'r':
  24376. // s.a.
  24377. this.calc = function (diffX, diffY) {
  24378. var snap = this.snapToGrid(diffX, diffY, 0);
  24379. if (this.parameters.box.width + snap[0] > 0) {
  24380. if (this.parameters.type === "text") {
  24381. return;
  24382. }
  24383. this.el.move(this.parameters.box.x, this.parameters.box.y).width(this.parameters.box.width + snap[0]);
  24384. }
  24385. };
  24386. break;
  24387. // Bottom
  24388. case 'b':
  24389. // s.a.
  24390. this.calc = function (diffX, diffY) {
  24391. var snap = this.snapToGrid(diffX, diffY, 0);
  24392. if (this.parameters.box.height + snap[1] > 0) {
  24393. if (this.parameters.type === "text") {
  24394. return;
  24395. }
  24396. this.el.move(this.parameters.box.x, this.parameters.box.y).height(this.parameters.box.height + snap[1]);
  24397. }
  24398. };
  24399. break;
  24400. // Left
  24401. case 'l':
  24402. // s.a.
  24403. this.calc = function (diffX, diffY) {
  24404. var snap = this.snapToGrid(diffX, diffY, 1);
  24405. if (this.parameters.box.width - snap[0] > 0) {
  24406. if (this.parameters.type === "text") {
  24407. return;
  24408. }
  24409. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).width(this.parameters.box.width - snap[0]);
  24410. }
  24411. };
  24412. break;
  24413. // Rotation
  24414. case 'rot':
  24415. // s.a.
  24416. this.calc = function (diffX, diffY) {
  24417. // yes this is kinda stupid but we need the mouse coords back...
  24418. var current = {x: diffX + this.parameters.p.x, y: diffY + this.parameters.p.y};
  24419. // start minus middle
  24420. 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));
  24421. // end minus middle
  24422. 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));
  24423. var angle = this.parameters.rotation + (pAngle - sAngle) * 180 / Math.PI + this.options.snapToAngle / 2;
  24424. // We have to move the element to the center of the box first and change the rotation afterwards
  24425. // because rotation always works around a rotation-center, which is changed when moving the element
  24426. // We also set the new rotation center to the center of the box.
  24427. 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);
  24428. };
  24429. break;
  24430. // Moving one single Point (needed when an element is deepSelected which means you can move every single point of the object)
  24431. case 'point':
  24432. this.calc = function (diffX, diffY) {
  24433. // Snapping the point to the grid
  24434. var snap = this.snapToGrid(diffX, diffY, this.parameters.pointCoords[0], this.parameters.pointCoords[1]);
  24435. // Get the point array
  24436. var array = this.el.array().valueOf();
  24437. // Changing the moved point in the array
  24438. array[this.parameters.i][0] = this.parameters.pointCoords[0] + snap[0];
  24439. array[this.parameters.i][1] = this.parameters.pointCoords[1] + snap[1];
  24440. // And plot the new this.el
  24441. this.el.plot(array);
  24442. };
  24443. }
  24444. this.el.fire('resizestart', {dx: this.parameters.x, dy: this.parameters.y, event: event});
  24445. // When resizing started, we have to register events for...
  24446. // Touches.
  24447. SVG.on(window, 'touchmove.resize', function(e) {
  24448. _this.update(e || window.event);
  24449. });
  24450. SVG.on(window, 'touchend.resize', function() {
  24451. _this.done();
  24452. });
  24453. // Mouse.
  24454. SVG.on(window, 'mousemove.resize', function (e) {
  24455. _this.update(e || window.event);
  24456. });
  24457. SVG.on(window, 'mouseup.resize', function () {
  24458. _this.done();
  24459. });
  24460. };
  24461. // The update-function redraws the element every time the mouse is moving
  24462. ResizeHandler.prototype.update = function (event) {
  24463. if (!event) {
  24464. if (this.lastUpdateCall) {
  24465. this.calc(this.lastUpdateCall[0], this.lastUpdateCall[1]);
  24466. }
  24467. return;
  24468. }
  24469. // Calculate the difference between the mouseposition at start and now
  24470. var txPt = this._extractPosition(event);
  24471. var p = this.transformPoint(txPt.x, txPt.y);
  24472. var diffX = p.x - this.parameters.p.x,
  24473. diffY = p.y - this.parameters.p.y;
  24474. this.lastUpdateCall = [diffX, diffY];
  24475. // Calculate the new position and height / width of the element
  24476. this.calc(diffX, diffY);
  24477. // Emit an event to say we have changed.
  24478. this.el.fire('resizing', {dx: diffX, dy: diffY, event: event});
  24479. };
  24480. // Is called on mouseup.
  24481. // Removes the update-function from the mousemove event
  24482. ResizeHandler.prototype.done = function () {
  24483. this.lastUpdateCall = null;
  24484. SVG.off(window, 'mousemove.resize');
  24485. SVG.off(window, 'mouseup.resize');
  24486. SVG.off(window, 'touchmove.resize');
  24487. SVG.off(window, 'touchend.resize');
  24488. this.el.fire('resizedone');
  24489. };
  24490. // The flag is used to determine whether the resizing is used with a left-Point (first bit) and top-point (second bit)
  24491. // In this cases the temp-values are calculated differently
  24492. ResizeHandler.prototype.snapToGrid = function (diffX, diffY, flag, pointCoordsY) {
  24493. var temp;
  24494. // If `pointCoordsY` is given, a single Point has to be snapped (deepSelect). That's why we need a different temp-value
  24495. if (typeof pointCoordsY !== 'undefined') {
  24496. // Note that flag = pointCoordsX in this case
  24497. temp = [(flag + diffX) % this.options.snapToGrid, (pointCoordsY + diffY) % this.options.snapToGrid];
  24498. } else {
  24499. // We check if the flag is set and if not we set a default-value (both bits set - which means upper-left-edge)
  24500. flag = flag == null ? 1 | 1 << 1 : flag;
  24501. 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];
  24502. }
  24503. if(diffX < 0) {
  24504. temp[0] -= this.options.snapToGrid;
  24505. }
  24506. if(diffY < 0) {
  24507. temp[1] -= this.options.snapToGrid;
  24508. }
  24509. diffX -= (Math.abs(temp[0]) < this.options.snapToGrid / 2 ?
  24510. temp[0] :
  24511. temp[0] - (diffX < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  24512. diffY -= (Math.abs(temp[1]) < this.options.snapToGrid / 2 ?
  24513. temp[1] :
  24514. temp[1] - (diffY < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  24515. return this.constraintToBox(diffX, diffY, flag, pointCoordsY);
  24516. };
  24517. // keep element within constrained box
  24518. ResizeHandler.prototype.constraintToBox = function (diffX, diffY, flag, pointCoordsY) {
  24519. //return [diffX, diffY]
  24520. var c = this.options.constraint || {};
  24521. var orgX, orgY;
  24522. if (typeof pointCoordsY !== 'undefined') {
  24523. orgX = flag;
  24524. orgY = pointCoordsY;
  24525. } else {
  24526. orgX = this.parameters.box.x + (flag & 1 ? 0 : this.parameters.box.width);
  24527. orgY = this.parameters.box.y + (flag & (1<<1) ? 0 : this.parameters.box.height);
  24528. }
  24529. if (typeof c.minX !== 'undefined' && orgX + diffX < c.minX) {
  24530. diffX = c.minX - orgX;
  24531. }
  24532. if (typeof c.maxX !== 'undefined' && orgX + diffX > c.maxX) {
  24533. diffX = c.maxX - orgX;
  24534. }
  24535. if (typeof c.minY !== 'undefined' && orgY + diffY < c.minY) {
  24536. diffY = c.minY - orgY;
  24537. }
  24538. if (typeof c.maxY !== 'undefined' && orgY + diffY > c.maxY) {
  24539. diffY = c.maxY - orgY;
  24540. }
  24541. return [diffX, diffY];
  24542. };
  24543. ResizeHandler.prototype.checkAspectRatio = function (snap, isReverse) {
  24544. if (!this.options.saveAspectRatio) {
  24545. return snap;
  24546. }
  24547. var updatedSnap = snap.slice();
  24548. var aspectRatio = this.parameters.box.width / this.parameters.box.height;
  24549. var newW = this.parameters.box.width + snap[0];
  24550. var newH = this.parameters.box.height - snap[1];
  24551. var newAspectRatio = newW / newH;
  24552. if (newAspectRatio < aspectRatio) {
  24553. // Height is too big. Adapt it
  24554. updatedSnap[1] = newW / aspectRatio - this.parameters.box.height;
  24555. isReverse && (updatedSnap[1] = -updatedSnap[1]);
  24556. } else if (newAspectRatio > aspectRatio) {
  24557. // Width is too big. Adapt it
  24558. updatedSnap[0] = this.parameters.box.width - newH * aspectRatio;
  24559. isReverse && (updatedSnap[0] = -updatedSnap[0]);
  24560. }
  24561. return updatedSnap;
  24562. };
  24563. SVG.extend(SVG.Element, {
  24564. // Resize element with mouse
  24565. resize: function (options) {
  24566. (this.remember('_resizeHandler') || new ResizeHandler(this)).init(options || {});
  24567. return this;
  24568. }
  24569. });
  24570. SVG.Element.prototype.resize.defaults = {
  24571. snapToAngle: 0.1, // Specifies the speed the rotation is happening when moving the mouse
  24572. snapToGrid: 1, // Snaps to a grid of `snapToGrid` Pixels
  24573. constraint: {}, // keep element within constrained box
  24574. saveAspectRatio: false // Save aspect ratio when resizing using lt, rt, rb or lb points
  24575. };
  24576. }).call(this);
  24577. }());
  24578. function styleInject(css, ref) {
  24579. if ( ref === void 0 ) ref = {};
  24580. var insertAt = ref.insertAt;
  24581. if (!css || typeof document === 'undefined') { return; }
  24582. var head = document.head || document.getElementsByTagName('head')[0];
  24583. var style = document.createElement('style');
  24584. style.type = 'text/css';
  24585. if (insertAt === 'top') {
  24586. if (head.firstChild) {
  24587. head.insertBefore(style, head.firstChild);
  24588. } else {
  24589. head.appendChild(style);
  24590. }
  24591. } else {
  24592. head.appendChild(style);
  24593. }
  24594. if (style.styleSheet) {
  24595. style.styleSheet.cssText = css;
  24596. } else {
  24597. style.appendChild(document.createTextNode(css));
  24598. }
  24599. }
  24600. 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}";
  24601. styleInject(css);
  24602. /**
  24603. * Detect Element Resize
  24604. *
  24605. * https://github.com/sdecima/javascript-detect-element-resize
  24606. * Sebastian Decima
  24607. *
  24608. * version: 0.5.3
  24609. **/
  24610. (function () {
  24611. function resetTriggers(element) {
  24612. var triggers = element.__resizeTriggers__,
  24613. expand = triggers.firstElementChild,
  24614. contract = triggers.lastElementChild,
  24615. expandChild = expand ? expand.firstElementChild : null;
  24616. if (contract) {
  24617. contract.scrollLeft = contract.scrollWidth;
  24618. contract.scrollTop = contract.scrollHeight;
  24619. }
  24620. if (expandChild) {
  24621. expandChild.style.width = expand.offsetWidth + 1 + 'px';
  24622. expandChild.style.height = expand.offsetHeight + 1 + 'px';
  24623. }
  24624. if (expand) {
  24625. expand.scrollLeft = expand.scrollWidth;
  24626. expand.scrollTop = expand.scrollHeight;
  24627. }
  24628. }
  24629. function checkTriggers(element) {
  24630. return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
  24631. }
  24632. function scrollListener(e) {
  24633. var element = this;
  24634. resetTriggers(this);
  24635. if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
  24636. this.__resizeRAF__ = requestFrame(function () {
  24637. if (checkTriggers(element)) {
  24638. element.__resizeLast__.width = element.offsetWidth;
  24639. element.__resizeLast__.height = element.offsetHeight;
  24640. element.__resizeListeners__.forEach(function (fn) {
  24641. fn.call(e);
  24642. });
  24643. }
  24644. });
  24645. }
  24646. var requestFrame = function () {
  24647. var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
  24648. return window.setTimeout(fn, 20);
  24649. };
  24650. return function (fn) {
  24651. return raf(fn);
  24652. };
  24653. }();
  24654. var cancelFrame = function () {
  24655. var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.clearTimeout;
  24656. return function (id) {
  24657. return cancel(id);
  24658. };
  24659. }();
  24660. /* Detect CSS Animations support to detect element display/re-attach */
  24661. var animation = false,
  24662. animationstartevent = 'animationstart',
  24663. domPrefixes = 'Webkit Moz O ms'.split(' '),
  24664. startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' ');
  24665. {
  24666. var elm = document.createElement('fakeelement');
  24667. if (elm.style.animationName !== undefined) {
  24668. animation = true;
  24669. }
  24670. if (animation === false) {
  24671. for (var i = 0; i < domPrefixes.length; i++) {
  24672. if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
  24673. animationstartevent = startEvents[i];
  24674. break;
  24675. }
  24676. }
  24677. }
  24678. }
  24679. var animationName = 'resizeanim';
  24680. window.addResizeListener = function (element, fn) {
  24681. if (!element.__resizeTriggers__) {
  24682. if (getComputedStyle(element).position == 'static') element.style.position = 'relative';
  24683. element.__resizeLast__ = {};
  24684. element.__resizeListeners__ = [];
  24685. (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
  24686. element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
  24687. element.appendChild(element.__resizeTriggers__);
  24688. resetTriggers(element);
  24689. element.addEventListener('scroll', scrollListener, true);
  24690. /* Listen for a css animation to detect element display/re-attach */
  24691. animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
  24692. if (e.animationName == animationName) {
  24693. resetTriggers(element);
  24694. }
  24695. });
  24696. }
  24697. element.__resizeListeners__.push(fn);
  24698. };
  24699. window.removeResizeListener = function (element, fn) {
  24700. if (element) {
  24701. element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
  24702. if (!element.__resizeListeners__.length) {
  24703. element.removeEventListener('scroll', scrollListener);
  24704. if (element.__resizeTriggers__.parentNode) {
  24705. element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
  24706. }
  24707. }
  24708. }
  24709. };
  24710. })();
  24711. window.Apex = {};
  24712. var InitCtxVariables = /*#__PURE__*/function () {
  24713. function InitCtxVariables(ctx) {
  24714. _classCallCheck(this, InitCtxVariables);
  24715. this.ctx = ctx;
  24716. this.w = ctx.w;
  24717. }
  24718. _createClass(InitCtxVariables, [{
  24719. key: "initModules",
  24720. value: function initModules() {
  24721. this.ctx.publicMethods = ['updateOptions', 'updateSeries', 'appendData', 'appendSeries', 'toggleSeries', 'showSeries', 'hideSeries', 'setLocale', 'resetSeries', 'toggleDataPointSelection', 'dataURI', 'addXaxisAnnotation', 'addYaxisAnnotation', 'addPointAnnotation', 'clearAnnotations', 'removeAnnotation', 'paper', 'destroy'];
  24722. this.ctx.eventList = ['click', 'mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
  24723. this.ctx.animations = new Animations(this.ctx);
  24724. this.ctx.axes = new Axes(this.ctx);
  24725. this.ctx.core = new Core(this.ctx.el, this.ctx);
  24726. this.ctx.config = new Config({});
  24727. this.ctx.data = new Data(this.ctx);
  24728. this.ctx.grid = new Grid(this.ctx);
  24729. this.ctx.graphics = new Graphics(this.ctx);
  24730. this.ctx.coreUtils = new CoreUtils(this.ctx);
  24731. this.ctx.crosshairs = new Crosshairs(this.ctx);
  24732. this.ctx.events = new Events(this.ctx);
  24733. this.ctx.exports = new Exports(this.ctx);
  24734. this.ctx.localization = new Localization(this.ctx);
  24735. this.ctx.options = new Options();
  24736. this.ctx.responsive = new Responsive(this.ctx);
  24737. this.ctx.series = new Series(this.ctx);
  24738. this.ctx.theme = new Theme(this.ctx);
  24739. this.ctx.formatters = new Formatters(this.ctx);
  24740. this.ctx.titleSubtitle = new TitleSubtitle(this.ctx);
  24741. this.ctx.legend = new Legend(this.ctx);
  24742. this.ctx.toolbar = new Toolbar(this.ctx);
  24743. this.ctx.dimensions = new Dimensions(this.ctx);
  24744. this.ctx.updateHelpers = new UpdateHelpers(this.ctx);
  24745. this.ctx.zoomPanSelection = new ZoomPanSelection(this.ctx);
  24746. this.ctx.w.globals.tooltip = new Tooltip(this.ctx);
  24747. }
  24748. }]);
  24749. return InitCtxVariables;
  24750. }();
  24751. var Destroy = /*#__PURE__*/function () {
  24752. function Destroy(ctx) {
  24753. _classCallCheck(this, Destroy);
  24754. this.ctx = ctx;
  24755. this.w = ctx.w;
  24756. }
  24757. _createClass(Destroy, [{
  24758. key: "clear",
  24759. value: function clear() {
  24760. if (this.ctx.zoomPanSelection) {
  24761. this.ctx.zoomPanSelection.destroy();
  24762. }
  24763. if (this.ctx.toolbar) {
  24764. this.ctx.toolbar.destroy();
  24765. }
  24766. this.ctx.animations = null;
  24767. this.ctx.axes = null;
  24768. this.ctx.annotations = null;
  24769. this.ctx.core = null;
  24770. this.ctx.data = null;
  24771. this.ctx.grid = null;
  24772. this.ctx.series = null;
  24773. this.ctx.responsive = null;
  24774. this.ctx.theme = null;
  24775. this.ctx.formatters = null;
  24776. this.ctx.titleSubtitle = null;
  24777. this.ctx.legend = null;
  24778. this.ctx.dimensions = null;
  24779. this.ctx.options = null;
  24780. this.ctx.crosshairs = null;
  24781. this.ctx.zoomPanSelection = null;
  24782. this.ctx.updateHelpers = null;
  24783. this.ctx.toolbar = null;
  24784. this.ctx.localization = null;
  24785. this.ctx.w.globals.tooltip = null;
  24786. this.clearDomElements();
  24787. }
  24788. }, {
  24789. key: "killSVG",
  24790. value: function killSVG(draw) {
  24791. draw.each(function (i, children) {
  24792. this.removeClass('*');
  24793. this.off();
  24794. this.stop();
  24795. }, true);
  24796. draw.ungroup();
  24797. draw.clear();
  24798. }
  24799. }, {
  24800. key: "clearDomElements",
  24801. value: function clearDomElements() {
  24802. var _this = this;
  24803. // detach document event
  24804. this.ctx.eventList.forEach(function (event) {
  24805. document.removeEventListener(event, _this.ctx.events.documentEvent);
  24806. });
  24807. var domEls = this.w.globals.dom;
  24808. if (this.ctx.el !== null) {
  24809. // remove all child elements - resetting the whole chart
  24810. while (this.ctx.el.firstChild) {
  24811. this.ctx.el.removeChild(this.ctx.el.firstChild);
  24812. }
  24813. }
  24814. this.killSVG(domEls.Paper);
  24815. domEls.Paper.remove();
  24816. domEls.elWrap = null;
  24817. domEls.elGraphical = null;
  24818. domEls.elAnnotations = null;
  24819. domEls.elLegendWrap = null;
  24820. domEls.baseEl = null;
  24821. domEls.elGridRect = null;
  24822. domEls.elGridRectMask = null;
  24823. domEls.elGridRectMarkerMask = null;
  24824. domEls.elDefs = null;
  24825. }
  24826. }]);
  24827. return Destroy;
  24828. }();
  24829. /**
  24830. *
  24831. * @module ApexCharts
  24832. **/
  24833. var ApexCharts$1 = /*#__PURE__*/function () {
  24834. function ApexCharts(el, opts) {
  24835. _classCallCheck(this, ApexCharts);
  24836. this.opts = opts;
  24837. this.ctx = this; // Pass the user supplied options to the Base Class where these options will be extended with defaults. The returned object from Base Class will become the config object in the entire codebase.
  24838. this.w = new Base(opts).init();
  24839. this.el = el;
  24840. this.w.globals.cuid = Utils.randomId();
  24841. this.w.globals.chartID = this.w.config.chart.id ? this.w.config.chart.id : this.w.globals.cuid;
  24842. var initCtx = new InitCtxVariables(this);
  24843. initCtx.initModules();
  24844. this.create = Utils.bind(this.create, this);
  24845. this.windowResizeHandler = this._windowResize.bind(this);
  24846. }
  24847. /**
  24848. * The primary method user will call to render the chart.
  24849. */
  24850. _createClass(ApexCharts, [{
  24851. key: "render",
  24852. value: function render() {
  24853. var _this = this;
  24854. // main method
  24855. return new Promise(function (resolve, reject) {
  24856. // only draw chart, if element found
  24857. if (_this.el !== null) {
  24858. if (typeof Apex._chartInstances === 'undefined') {
  24859. Apex._chartInstances = [];
  24860. }
  24861. if (_this.w.config.chart.id) {
  24862. Apex._chartInstances.push({
  24863. id: _this.w.globals.chartID,
  24864. group: _this.w.config.chart.group,
  24865. chart: _this
  24866. });
  24867. } // set the locale here
  24868. _this.setLocale(_this.w.config.chart.defaultLocale);
  24869. var beforeMount = _this.w.config.chart.events.beforeMount;
  24870. if (typeof beforeMount === 'function') {
  24871. beforeMount(_this, _this.w);
  24872. }
  24873. _this.events.fireEvent('beforeMount', [_this, _this.w]);
  24874. window.addEventListener('resize', _this.windowResizeHandler);
  24875. window.addResizeListener(_this.el.parentNode, _this._parentResizeCallback.bind(_this));
  24876. var graphData = _this.create(_this.w.config.series, {});
  24877. if (!graphData) return resolve(_this);
  24878. _this.mount(graphData).then(function () {
  24879. if (typeof _this.w.config.chart.events.mounted === 'function') {
  24880. _this.w.config.chart.events.mounted(_this, _this.w);
  24881. }
  24882. _this.events.fireEvent('mounted', [_this, _this.w]);
  24883. resolve(graphData);
  24884. }).catch(function (e) {
  24885. reject(e); // handle error in case no data or element not found
  24886. });
  24887. } else {
  24888. reject(new Error('Element not found'));
  24889. }
  24890. });
  24891. }
  24892. }, {
  24893. key: "create",
  24894. value: function create(ser, opts) {
  24895. var w = this.w;
  24896. var initCtx = new InitCtxVariables(this);
  24897. initCtx.initModules();
  24898. var gl = this.w.globals;
  24899. gl.noData = false;
  24900. gl.animationEnded = false;
  24901. this.responsive.checkResponsiveConfig(opts);
  24902. if (w.config.xaxis.convertedCatToNumeric) {
  24903. var defaults = new Defaults(w.config);
  24904. defaults.convertCatToNumericXaxis(w.config, this.ctx);
  24905. }
  24906. if (this.el === null) {
  24907. gl.animationEnded = true;
  24908. return null;
  24909. }
  24910. this.core.setupElements();
  24911. if (gl.svgWidth === 0) {
  24912. // if the element is hidden, skip drawing
  24913. gl.animationEnded = true;
  24914. return null;
  24915. }
  24916. var combo = CoreUtils.checkComboSeries(ser);
  24917. gl.comboCharts = combo.comboCharts;
  24918. gl.comboBarCount = combo.comboBarCount;
  24919. if (ser.length === 0 || ser.length === 1 && ser[0].data && ser[0].data.length === 0) {
  24920. this.series.handleNoData();
  24921. }
  24922. this.events.setupEventHandlers(); // Handle the data inputted by user and set some of the global variables (for eg, if data is datetime / numeric / category). Don't calculate the range / min / max at this time
  24923. this.data.parseData(ser); // this is a good time to set theme colors first
  24924. this.theme.init(); // as markers accepts array, we need to setup global markers for easier access
  24925. var markers = new Markers(this);
  24926. markers.setGlobalMarkerSize(); // labelFormatters should be called before dimensions as in dimensions we need text labels width
  24927. this.formatters.setLabelFormatters();
  24928. this.titleSubtitle.draw(); // legend is calculated here before coreCalculations because it affects the plottable area
  24929. // if there is some data to show or user collapsed all series, then proceed drawing legend
  24930. if (!gl.noData || gl.collapsedSeries.length === gl.series.length) {
  24931. this.legend.init();
  24932. } // check whether in multiple series, all series share the same X
  24933. this.series.hasAllSeriesEqualX(); // coreCalculations will give the min/max range and yaxis/axis values. It should be called here to set series variable from config to globals
  24934. if (gl.axisCharts) {
  24935. this.core.coreCalculations();
  24936. if (w.config.xaxis.type !== 'category') {
  24937. // as we have minX and maxX values, determine the default DateTimeFormat for time series
  24938. this.formatters.setLabelFormatters();
  24939. }
  24940. } // we need to generate yaxis for heatmap separately as we are not showing numerics there, but seriesNames. There are some tweaks which are required for heatmap to align labels correctly which are done in below function
  24941. // Also we need to do this before calcuting Dimentions plotCoords() method of Dimensions
  24942. this.formatters.heatmapLabelFormatters(); // We got plottable area here, next task would be to calculate axis areas
  24943. this.dimensions.plotCoords();
  24944. var xyRatios = this.core.xySettings();
  24945. this.grid.createGridMask();
  24946. var elGraph = this.core.plotChartType(ser, xyRatios);
  24947. var dataLabels = new DataLabels(this);
  24948. dataLabels.bringForward();
  24949. if (w.config.dataLabels.background.enabled) {
  24950. dataLabels.dataLabelsBackground();
  24951. } // after all the drawing calculations, shift the graphical area (actual charts/bars) excluding legends
  24952. this.core.shiftGraphPosition();
  24953. var dim = {
  24954. plot: {
  24955. left: w.globals.translateX,
  24956. top: w.globals.translateY,
  24957. width: w.globals.gridWidth,
  24958. height: w.globals.gridHeight
  24959. }
  24960. };
  24961. return {
  24962. elGraph: elGraph,
  24963. xyRatios: xyRatios,
  24964. elInner: w.globals.dom.elGraphical,
  24965. dimensions: dim
  24966. };
  24967. }
  24968. }, {
  24969. key: "mount",
  24970. value: function mount() {
  24971. var _this2 = this;
  24972. var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  24973. var me = this;
  24974. var w = me.w;
  24975. return new Promise(function (resolve, reject) {
  24976. // no data to display
  24977. if (me.el === null) {
  24978. return reject(new Error('Not enough data to display or target element not found'));
  24979. } else if (graphData === null || w.globals.allSeriesCollapsed) {
  24980. me.series.handleNoData();
  24981. }
  24982. me.axes.drawAxis(w.config.chart.type, graphData.xyRatios);
  24983. me.grid = new Grid(me);
  24984. var elgrid = me.grid.drawGrid();
  24985. me.annotations = new Annotations(me);
  24986. me.annotations.drawShapeAnnos();
  24987. me.annotations.drawImageAnnos();
  24988. me.annotations.drawTextAnnos();
  24989. if (w.config.grid.position === 'back' && elgrid) {
  24990. w.globals.dom.elGraphical.add(elgrid.el);
  24991. }
  24992. var xAxis = new XAxis(_this2.ctx);
  24993. var yaxis = new YAxis(_this2.ctx);
  24994. if (elgrid !== null) {
  24995. xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth);
  24996. yaxis.setYAxisTextAlignments();
  24997. }
  24998. if (w.config.annotations.position === 'back') {
  24999. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  25000. me.annotations.drawAxesAnnotations();
  25001. }
  25002. if (graphData.elGraph instanceof Array) {
  25003. for (var g = 0; g < graphData.elGraph.length; g++) {
  25004. w.globals.dom.elGraphical.add(graphData.elGraph[g]);
  25005. }
  25006. } else {
  25007. w.globals.dom.elGraphical.add(graphData.elGraph);
  25008. }
  25009. if (w.config.grid.position === 'front' && elgrid) {
  25010. w.globals.dom.elGraphical.add(elgrid.el);
  25011. }
  25012. if (w.config.xaxis.crosshairs.position === 'front') {
  25013. me.crosshairs.drawXCrosshairs();
  25014. }
  25015. if (w.config.yaxis[0].crosshairs.position === 'front') {
  25016. me.crosshairs.drawYCrosshairs();
  25017. }
  25018. if (w.config.annotations.position === 'front') {
  25019. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  25020. me.annotations.drawAxesAnnotations();
  25021. }
  25022. if (!w.globals.noData) {
  25023. // draw tooltips at the end
  25024. if (w.config.tooltip.enabled && !w.globals.noData) {
  25025. me.w.globals.tooltip.drawTooltip(graphData.xyRatios);
  25026. }
  25027. if (w.globals.axisCharts && (w.globals.isXNumeric || w.config.xaxis.convertedCatToNumeric)) {
  25028. if (w.config.chart.zoom.enabled || w.config.chart.selection && w.config.chart.selection.enabled || w.config.chart.pan && w.config.chart.pan.enabled) {
  25029. me.zoomPanSelection.init({
  25030. xyRatios: graphData.xyRatios
  25031. });
  25032. }
  25033. } else {
  25034. var tools = w.config.chart.toolbar.tools;
  25035. var toolsArr = ['zoom', 'zoomin', 'zoomout', 'selection', 'pan', 'reset'];
  25036. toolsArr.forEach(function (t) {
  25037. tools[t] = false;
  25038. });
  25039. }
  25040. if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) {
  25041. me.toolbar.createToolbar();
  25042. }
  25043. }
  25044. if (w.globals.memory.methodsToExec.length > 0) {
  25045. w.globals.memory.methodsToExec.forEach(function (fn) {
  25046. fn.method(fn.params, false, fn.context);
  25047. });
  25048. }
  25049. if (!w.globals.axisCharts && !w.globals.noData) {
  25050. me.core.resizeNonAxisCharts();
  25051. }
  25052. resolve(me);
  25053. });
  25054. }
  25055. /**
  25056. * Destroy the chart instance by removing all elements which also clean up event listeners on those elements.
  25057. */
  25058. }, {
  25059. key: "destroy",
  25060. value: function destroy() {
  25061. window.removeEventListener('resize', this.windowResizeHandler);
  25062. window.removeResizeListener(this.el.parentNode, this._parentResizeCallback.bind(this)); // remove the chart's instance from the global Apex._chartInstances
  25063. var chartID = this.w.config.chart.id;
  25064. if (chartID) {
  25065. Apex._chartInstances.forEach(function (c, i) {
  25066. if (c.id === chartID) {
  25067. Apex._chartInstances.splice(i, 1);
  25068. }
  25069. });
  25070. }
  25071. new Destroy(this.ctx).clear();
  25072. }
  25073. /**
  25074. * Allows users to update Options after the chart has rendered.
  25075. *
  25076. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  25077. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  25078. * @param {boolean} animate - should animate or not on updating Options
  25079. */
  25080. }, {
  25081. key: "updateOptions",
  25082. value: function updateOptions(options) {
  25083. var _this3 = this;
  25084. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  25085. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25086. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  25087. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  25088. var w = this.w;
  25089. if (options.series) {
  25090. this.series.resetSeries(false, true, false);
  25091. if (options.series.length && options.series[0].data) {
  25092. options.series = options.series.map(function (s, i) {
  25093. return _this3.updateHelpers._extendSeries(s, i);
  25094. });
  25095. } // user updated the series via updateOptions() function.
  25096. // Hence, we need to reset axis min/max to avoid zooming issues
  25097. this.updateHelpers.revertDefaultAxisMinMax();
  25098. } // user has set x-axis min/max externally - hence we need to forcefully set the xaxis min/max
  25099. if (options.xaxis) {
  25100. options = this.updateHelpers.forceXAxisUpdate(options);
  25101. }
  25102. if (options.yaxis) {
  25103. options = this.updateHelpers.forceYAxisUpdate(options);
  25104. }
  25105. if (w.globals.collapsedSeriesIndices.length > 0) {
  25106. this.series.clearPreviousPaths();
  25107. }
  25108. /* update theme mode#459 */
  25109. if (options.theme) {
  25110. options = this.theme.updateThemeOptions(options);
  25111. }
  25112. return this.updateHelpers._updateOptions(options, redraw, animate, updateSyncedCharts, overwriteInitialConfig);
  25113. }
  25114. /**
  25115. * Allows users to update Series after the chart has rendered.
  25116. *
  25117. * @param {array} series - New series which will override the existing
  25118. */
  25119. }, {
  25120. key: "updateSeries",
  25121. value: function updateSeries() {
  25122. var newSeries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  25123. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25124. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25125. this.series.resetSeries(false);
  25126. this.updateHelpers.revertDefaultAxisMinMax();
  25127. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  25128. }
  25129. /**
  25130. * Allows users to append a new series after the chart has rendered.
  25131. *
  25132. * @param {array} newSerie - New serie which will be appended to the existing series
  25133. */
  25134. }, {
  25135. key: "appendSeries",
  25136. value: function appendSeries(newSerie) {
  25137. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25138. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25139. var newSeries = this.w.config.series.slice();
  25140. newSeries.push(newSerie);
  25141. this.series.resetSeries(false);
  25142. this.updateHelpers.revertDefaultAxisMinMax();
  25143. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  25144. }
  25145. /**
  25146. * Allows users to append Data to series.
  25147. *
  25148. * @param {array} newData - New data in the same format as series
  25149. */
  25150. }, {
  25151. key: "appendData",
  25152. value: function appendData(newData) {
  25153. var overwriteInitialSeries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25154. var me = this;
  25155. me.w.globals.dataChanged = true;
  25156. me.series.getPreviousPaths();
  25157. var newSeries = me.w.config.series.slice();
  25158. for (var i = 0; i < newSeries.length; i++) {
  25159. if (typeof newData[i] !== 'undefined') {
  25160. for (var j = 0; j < newData[i].data.length; j++) {
  25161. newSeries[i].data.push(newData[i].data[j]);
  25162. }
  25163. }
  25164. }
  25165. me.w.config.series = newSeries;
  25166. if (overwriteInitialSeries) {
  25167. me.w.globals.initialSeries = JSON.parse(JSON.stringify(me.w.config.series));
  25168. }
  25169. return this.update();
  25170. }
  25171. }, {
  25172. key: "update",
  25173. value: function update(options) {
  25174. var _this4 = this;
  25175. return new Promise(function (resolve, reject) {
  25176. new Destroy(_this4.ctx).clear();
  25177. var graphData = _this4.create(_this4.w.config.series, options);
  25178. if (!graphData) return resolve(_this4);
  25179. _this4.mount(graphData).then(function () {
  25180. if (typeof _this4.w.config.chart.events.updated === 'function') {
  25181. _this4.w.config.chart.events.updated(_this4, _this4.w);
  25182. }
  25183. _this4.events.fireEvent('updated', [_this4, _this4.w]);
  25184. _this4.w.globals.isDirty = true;
  25185. resolve(_this4);
  25186. }).catch(function (e) {
  25187. reject(e);
  25188. });
  25189. });
  25190. }
  25191. /**
  25192. * Get all charts in the same "group" (including the instance which is called upon) to sync them when user zooms in/out or pan.
  25193. */
  25194. }, {
  25195. key: "getSyncedCharts",
  25196. value: function getSyncedCharts() {
  25197. var chartGroups = this.getGroupedCharts();
  25198. var allCharts = [this];
  25199. if (chartGroups.length) {
  25200. allCharts = [];
  25201. chartGroups.forEach(function (ch) {
  25202. allCharts.push(ch);
  25203. });
  25204. }
  25205. return allCharts;
  25206. }
  25207. /**
  25208. * Get charts in the same "group" (excluding the instance which is called upon) to perform operations on the other charts of the same group (eg., tooltip hovering)
  25209. */
  25210. }, {
  25211. key: "getGroupedCharts",
  25212. value: function getGroupedCharts() {
  25213. var _this5 = this;
  25214. return Apex._chartInstances.filter(function (ch) {
  25215. if (ch.group) {
  25216. return true;
  25217. }
  25218. }).map(function (ch) {
  25219. return _this5.w.config.chart.group === ch.group ? ch.chart : _this5;
  25220. });
  25221. }
  25222. }, {
  25223. key: "toggleSeries",
  25224. value: function toggleSeries(seriesName) {
  25225. return this.series.toggleSeries(seriesName);
  25226. }
  25227. }, {
  25228. key: "showSeries",
  25229. value: function showSeries(seriesName) {
  25230. this.series.showSeries(seriesName);
  25231. }
  25232. }, {
  25233. key: "hideSeries",
  25234. value: function hideSeries(seriesName) {
  25235. this.series.hideSeries(seriesName);
  25236. }
  25237. }, {
  25238. key: "resetSeries",
  25239. value: function resetSeries() {
  25240. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  25241. this.series.resetSeries(shouldUpdateChart);
  25242. } // Public method to add event listener on chart context
  25243. }, {
  25244. key: "addEventListener",
  25245. value: function addEventListener(name, handler) {
  25246. this.events.addEventListener(name, handler);
  25247. } // Public method to remove event listener on chart context
  25248. }, {
  25249. key: "removeEventListener",
  25250. value: function removeEventListener(name, handler) {
  25251. this.events.removeEventListener(name, handler);
  25252. }
  25253. }, {
  25254. key: "addXaxisAnnotation",
  25255. value: function addXaxisAnnotation(opts) {
  25256. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25257. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25258. var me = this;
  25259. if (context) {
  25260. me = context;
  25261. }
  25262. me.annotations.addXaxisAnnotationExternal(opts, pushToMemory, me);
  25263. }
  25264. }, {
  25265. key: "addYaxisAnnotation",
  25266. value: function addYaxisAnnotation(opts) {
  25267. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25268. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25269. var me = this;
  25270. if (context) {
  25271. me = context;
  25272. }
  25273. me.annotations.addYaxisAnnotationExternal(opts, pushToMemory, me);
  25274. }
  25275. }, {
  25276. key: "addPointAnnotation",
  25277. value: function addPointAnnotation(opts) {
  25278. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25279. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25280. var me = this;
  25281. if (context) {
  25282. me = context;
  25283. }
  25284. me.annotations.addPointAnnotationExternal(opts, pushToMemory, me);
  25285. }
  25286. }, {
  25287. key: "clearAnnotations",
  25288. value: function clearAnnotations() {
  25289. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
  25290. var me = this;
  25291. if (context) {
  25292. me = context;
  25293. }
  25294. me.annotations.clearAnnotations(me);
  25295. }
  25296. }, {
  25297. key: "removeAnnotation",
  25298. value: function removeAnnotation(id) {
  25299. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  25300. var me = this;
  25301. if (context) {
  25302. me = context;
  25303. }
  25304. me.annotations.removeAnnotation(me, id);
  25305. }
  25306. }, {
  25307. key: "getChartArea",
  25308. value: function getChartArea() {
  25309. var el = this.w.globals.dom.baseEl.querySelector('.apexcharts-inner');
  25310. return el;
  25311. }
  25312. }, {
  25313. key: "getSeriesTotalXRange",
  25314. value: function getSeriesTotalXRange(minX, maxX) {
  25315. return this.coreUtils.getSeriesTotalsXRange(minX, maxX);
  25316. }
  25317. }, {
  25318. key: "getHighestValueInSeries",
  25319. value: function getHighestValueInSeries() {
  25320. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  25321. var range = new Range$1(this.ctx);
  25322. return range.getMinYMaxY(seriesIndex).highestY;
  25323. }
  25324. }, {
  25325. key: "getLowestValueInSeries",
  25326. value: function getLowestValueInSeries() {
  25327. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  25328. var range = new Range$1(this.ctx);
  25329. return range.getMinYMaxY(seriesIndex).lowestY;
  25330. }
  25331. }, {
  25332. key: "getSeriesTotal",
  25333. value: function getSeriesTotal() {
  25334. return this.w.globals.seriesTotals;
  25335. }
  25336. }, {
  25337. key: "toggleDataPointSelection",
  25338. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  25339. return this.updateHelpers.toggleDataPointSelection(seriesIndex, dataPointIndex);
  25340. }
  25341. }, {
  25342. key: "setLocale",
  25343. value: function setLocale(localeName) {
  25344. this.localization.setCurrentLocaleValues(localeName);
  25345. }
  25346. }, {
  25347. key: "dataURI",
  25348. value: function dataURI() {
  25349. var exp = new Exports(this.ctx);
  25350. return exp.dataURI();
  25351. }
  25352. }, {
  25353. key: "paper",
  25354. value: function paper() {
  25355. return this.w.globals.dom.Paper;
  25356. }
  25357. }, {
  25358. key: "_parentResizeCallback",
  25359. value: function _parentResizeCallback() {
  25360. if (!this.w.globals.noData && this.w.globals.animationEnded && this.w.config.chart.redrawOnParentResize) {
  25361. this._windowResize();
  25362. }
  25363. }
  25364. /**
  25365. * Handle window resize and re-draw the whole chart.
  25366. */
  25367. }, {
  25368. key: "_windowResize",
  25369. value: function _windowResize() {
  25370. var _this6 = this;
  25371. clearTimeout(this.w.globals.resizeTimer);
  25372. this.w.globals.resizeTimer = window.setTimeout(function () {
  25373. _this6.w.globals.resized = true;
  25374. _this6.w.globals.dataChanged = false; // we need to redraw the whole chart on window resize (with a small delay).
  25375. _this6.ctx.update();
  25376. }, 150);
  25377. }
  25378. }], [{
  25379. key: "getChartByID",
  25380. value: function getChartByID(chartID) {
  25381. var c = Apex._chartInstances.filter(function (ch) {
  25382. return ch.id === chartID;
  25383. })[0];
  25384. return c && c.chart;
  25385. }
  25386. /**
  25387. * Allows the user to provide data attrs in the element and the chart will render automatically when this method is called by searching for the elements containing 'data-apexcharts' attribute
  25388. */
  25389. }, {
  25390. key: "initOnLoad",
  25391. value: function initOnLoad() {
  25392. var els = document.querySelectorAll('[data-apexcharts]');
  25393. for (var i = 0; i < els.length; i++) {
  25394. var el = els[i];
  25395. var options = JSON.parse(els[i].getAttribute('data-options'));
  25396. var apexChart = new ApexCharts(el, options);
  25397. apexChart.render();
  25398. }
  25399. }
  25400. /**
  25401. * This static method allows users to call chart methods without necessarily from the
  25402. * instance of the chart in case user has assigned chartID to the targetted chart.
  25403. * The chartID is used for mapping the instance stored in Apex._chartInstances global variable
  25404. *
  25405. * This is helpful in cases when you don't have reference of the chart instance
  25406. * easily and need to call the method from anywhere.
  25407. * For eg, in React/Vue applications when you have many parent/child components,
  25408. * and need easy reference to other charts for performing dynamic operations
  25409. *
  25410. * @param {string} chartID - The unique identifier which will be used to call methods
  25411. * on that chart instance
  25412. * @param {function} fn - The method name to call
  25413. * @param {object} opts - The parameters which are accepted in the original method will be passed here in the same order.
  25414. */
  25415. }, {
  25416. key: "exec",
  25417. value: function exec(chartID, fn) {
  25418. var chart = this.getChartByID(chartID);
  25419. if (!chart) return; // turn on the global exec flag to indicate this method was called
  25420. chart.w.globals.isExecCalled = true;
  25421. var ret = null;
  25422. if (chart.publicMethods.indexOf(fn) !== -1) {
  25423. for (var _len = arguments.length, opts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  25424. opts[_key - 2] = arguments[_key];
  25425. }
  25426. ret = chart[fn].apply(chart, opts);
  25427. }
  25428. return ret;
  25429. }
  25430. }, {
  25431. key: "merge",
  25432. value: function merge(target, source) {
  25433. return Utils.extend(target, source);
  25434. }
  25435. }]);
  25436. return ApexCharts;
  25437. }();
  25438. return ApexCharts$1;
  25439. })));