apexcharts.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781
  1. /*!
  2. * ApexCharts v3.35.0
  3. * (c) 2018-2022 ApexCharts
  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 = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ApexCharts = factory());
  10. }(this, (function () { 'use strict';
  11. function ownKeys(object, enumerableOnly) {
  12. var keys = Object.keys(object);
  13. if (Object.getOwnPropertySymbols) {
  14. var symbols = Object.getOwnPropertySymbols(object);
  15. if (enumerableOnly) {
  16. symbols = symbols.filter(function (sym) {
  17. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  18. });
  19. }
  20. keys.push.apply(keys, symbols);
  21. }
  22. return keys;
  23. }
  24. function _objectSpread2(target) {
  25. for (var i = 1; i < arguments.length; i++) {
  26. var source = arguments[i] != null ? arguments[i] : {};
  27. if (i % 2) {
  28. ownKeys(Object(source), true).forEach(function (key) {
  29. _defineProperty(target, key, source[key]);
  30. });
  31. } else if (Object.getOwnPropertyDescriptors) {
  32. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  33. } else {
  34. ownKeys(Object(source)).forEach(function (key) {
  35. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  36. });
  37. }
  38. }
  39. return target;
  40. }
  41. function _typeof(obj) {
  42. "@babel/helpers - typeof";
  43. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  44. _typeof = function (obj) {
  45. return typeof obj;
  46. };
  47. } else {
  48. _typeof = function (obj) {
  49. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  50. };
  51. }
  52. return _typeof(obj);
  53. }
  54. function _classCallCheck(instance, Constructor) {
  55. if (!(instance instanceof Constructor)) {
  56. throw new TypeError("Cannot call a class as a function");
  57. }
  58. }
  59. function _defineProperties(target, props) {
  60. for (var i = 0; i < props.length; i++) {
  61. var descriptor = props[i];
  62. descriptor.enumerable = descriptor.enumerable || false;
  63. descriptor.configurable = true;
  64. if ("value" in descriptor) descriptor.writable = true;
  65. Object.defineProperty(target, descriptor.key, descriptor);
  66. }
  67. }
  68. function _createClass(Constructor, protoProps, staticProps) {
  69. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  70. if (staticProps) _defineProperties(Constructor, staticProps);
  71. return Constructor;
  72. }
  73. function _defineProperty(obj, key, value) {
  74. if (key in obj) {
  75. Object.defineProperty(obj, key, {
  76. value: value,
  77. enumerable: true,
  78. configurable: true,
  79. writable: true
  80. });
  81. } else {
  82. obj[key] = value;
  83. }
  84. return obj;
  85. }
  86. function _inherits(subClass, superClass) {
  87. if (typeof superClass !== "function" && superClass !== null) {
  88. throw new TypeError("Super expression must either be null or a function");
  89. }
  90. subClass.prototype = Object.create(superClass && superClass.prototype, {
  91. constructor: {
  92. value: subClass,
  93. writable: true,
  94. configurable: true
  95. }
  96. });
  97. if (superClass) _setPrototypeOf(subClass, superClass);
  98. }
  99. function _getPrototypeOf(o) {
  100. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  101. return o.__proto__ || Object.getPrototypeOf(o);
  102. };
  103. return _getPrototypeOf(o);
  104. }
  105. function _setPrototypeOf(o, p) {
  106. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  107. o.__proto__ = p;
  108. return o;
  109. };
  110. return _setPrototypeOf(o, p);
  111. }
  112. function _isNativeReflectConstruct() {
  113. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  114. if (Reflect.construct.sham) return false;
  115. if (typeof Proxy === "function") return true;
  116. try {
  117. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  118. return true;
  119. } catch (e) {
  120. return false;
  121. }
  122. }
  123. function _assertThisInitialized(self) {
  124. if (self === void 0) {
  125. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  126. }
  127. return self;
  128. }
  129. function _possibleConstructorReturn(self, call) {
  130. if (call && (typeof call === "object" || typeof call === "function")) {
  131. return call;
  132. } else if (call !== void 0) {
  133. throw new TypeError("Derived constructors may only return object or undefined");
  134. }
  135. return _assertThisInitialized(self);
  136. }
  137. function _createSuper(Derived) {
  138. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  139. return function _createSuperInternal() {
  140. var Super = _getPrototypeOf(Derived),
  141. result;
  142. if (hasNativeReflectConstruct) {
  143. var NewTarget = _getPrototypeOf(this).constructor;
  144. result = Reflect.construct(Super, arguments, NewTarget);
  145. } else {
  146. result = Super.apply(this, arguments);
  147. }
  148. return _possibleConstructorReturn(this, result);
  149. };
  150. }
  151. function _slicedToArray(arr, i) {
  152. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  153. }
  154. function _toConsumableArray(arr) {
  155. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  156. }
  157. function _arrayWithoutHoles(arr) {
  158. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  159. }
  160. function _arrayWithHoles(arr) {
  161. if (Array.isArray(arr)) return arr;
  162. }
  163. function _iterableToArray(iter) {
  164. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  165. }
  166. function _iterableToArrayLimit(arr, i) {
  167. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  168. if (_i == null) return;
  169. var _arr = [];
  170. var _n = true;
  171. var _d = false;
  172. var _s, _e;
  173. try {
  174. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  175. _arr.push(_s.value);
  176. if (i && _arr.length === i) break;
  177. }
  178. } catch (err) {
  179. _d = true;
  180. _e = err;
  181. } finally {
  182. try {
  183. if (!_n && _i["return"] != null) _i["return"]();
  184. } finally {
  185. if (_d) throw _e;
  186. }
  187. }
  188. return _arr;
  189. }
  190. function _unsupportedIterableToArray(o, minLen) {
  191. if (!o) return;
  192. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  193. var n = Object.prototype.toString.call(o).slice(8, -1);
  194. if (n === "Object" && o.constructor) n = o.constructor.name;
  195. if (n === "Map" || n === "Set") return Array.from(o);
  196. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  197. }
  198. function _arrayLikeToArray(arr, len) {
  199. if (len == null || len > arr.length) len = arr.length;
  200. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  201. return arr2;
  202. }
  203. function _nonIterableSpread() {
  204. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  205. }
  206. function _nonIterableRest() {
  207. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  208. }
  209. /*
  210. ** Generic functions which are not dependent on ApexCharts
  211. */
  212. var Utils$1 = /*#__PURE__*/function () {
  213. function Utils() {
  214. _classCallCheck(this, Utils);
  215. }
  216. _createClass(Utils, [{
  217. key: "shadeRGBColor",
  218. value: function shadeRGBColor(percent, color) {
  219. var f = color.split(','),
  220. t = percent < 0 ? 0 : 255,
  221. p = percent < 0 ? percent * -1 : percent,
  222. R = parseInt(f[0].slice(4), 10),
  223. G = parseInt(f[1], 10),
  224. B = parseInt(f[2], 10);
  225. return 'rgb(' + (Math.round((t - R) * p) + R) + ',' + (Math.round((t - G) * p) + G) + ',' + (Math.round((t - B) * p) + B) + ')';
  226. }
  227. }, {
  228. key: "shadeHexColor",
  229. value: function shadeHexColor(percent, color) {
  230. var f = parseInt(color.slice(1), 16),
  231. t = percent < 0 ? 0 : 255,
  232. p = percent < 0 ? percent * -1 : percent,
  233. R = f >> 16,
  234. G = f >> 8 & 0x00ff,
  235. B = f & 0x0000ff;
  236. 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);
  237. } // beautiful color shading blending code
  238. // http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
  239. }, {
  240. key: "shadeColor",
  241. value: function shadeColor(p, color) {
  242. if (Utils.isColorHex(color)) {
  243. return this.shadeHexColor(p, color);
  244. } else {
  245. return this.shadeRGBColor(p, color);
  246. }
  247. }
  248. }], [{
  249. key: "bind",
  250. value: function bind(fn, me) {
  251. return function () {
  252. return fn.apply(me, arguments);
  253. };
  254. }
  255. }, {
  256. key: "isObject",
  257. value: function isObject(item) {
  258. return item && _typeof(item) === 'object' && !Array.isArray(item) && item != null;
  259. } // Type checking that works across different window objects
  260. }, {
  261. key: "is",
  262. value: function is(type, val) {
  263. return Object.prototype.toString.call(val) === '[object ' + type + ']';
  264. }
  265. }, {
  266. key: "listToArray",
  267. value: function listToArray(list) {
  268. var i,
  269. array = [];
  270. for (i = 0; i < list.length; i++) {
  271. array[i] = list[i];
  272. }
  273. return array;
  274. } // to extend defaults with user options
  275. // credit: http://stackoverflow.com/questions/27936772/deep-object-merging-in-es6-es7#answer-34749873
  276. }, {
  277. key: "extend",
  278. value: function extend(target, source) {
  279. var _this = this;
  280. if (typeof Object.assign !== 'function') {
  281. (function () {
  282. Object.assign = function (target) {
  283. if (target === undefined || target === null) {
  284. throw new TypeError('Cannot convert undefined or null to object');
  285. }
  286. var output = Object(target);
  287. for (var index = 1; index < arguments.length; index++) {
  288. var _source = arguments[index];
  289. if (_source !== undefined && _source !== null) {
  290. for (var nextKey in _source) {
  291. if (_source.hasOwnProperty(nextKey)) {
  292. output[nextKey] = _source[nextKey];
  293. }
  294. }
  295. }
  296. }
  297. return output;
  298. };
  299. })();
  300. }
  301. var output = Object.assign({}, target);
  302. if (this.isObject(target) && this.isObject(source)) {
  303. Object.keys(source).forEach(function (key) {
  304. if (_this.isObject(source[key])) {
  305. if (!(key in target)) {
  306. Object.assign(output, _defineProperty({}, key, source[key]));
  307. } else {
  308. output[key] = _this.extend(target[key], source[key]);
  309. }
  310. } else {
  311. Object.assign(output, _defineProperty({}, key, source[key]));
  312. }
  313. });
  314. }
  315. return output;
  316. }
  317. }, {
  318. key: "extendArray",
  319. value: function extendArray(arrToExtend, resultArr) {
  320. var extendedArr = [];
  321. arrToExtend.map(function (item) {
  322. extendedArr.push(Utils.extend(resultArr, item));
  323. });
  324. arrToExtend = extendedArr;
  325. return arrToExtend;
  326. } // If month counter exceeds 12, it starts again from 1
  327. }, {
  328. key: "monthMod",
  329. value: function monthMod(month) {
  330. return month % 12;
  331. }
  332. }, {
  333. key: "clone",
  334. value: function clone(source) {
  335. if (Utils.is('Array', source)) {
  336. var cloneResult = [];
  337. for (var i = 0; i < source.length; i++) {
  338. cloneResult[i] = this.clone(source[i]);
  339. }
  340. return cloneResult;
  341. } else if (Utils.is('Null', source)) {
  342. // fixes an issue where null values were converted to {}
  343. return null;
  344. } else if (Utils.is('Date', source)) {
  345. return source;
  346. } else if (_typeof(source) === 'object') {
  347. var _cloneResult = {};
  348. for (var prop in source) {
  349. if (source.hasOwnProperty(prop)) {
  350. _cloneResult[prop] = this.clone(source[prop]);
  351. }
  352. }
  353. return _cloneResult;
  354. } else {
  355. return source;
  356. }
  357. }
  358. }, {
  359. key: "log10",
  360. value: function log10(x) {
  361. return Math.log(x) / Math.LN10;
  362. }
  363. }, {
  364. key: "roundToBase10",
  365. value: function roundToBase10(x) {
  366. return Math.pow(10, Math.floor(Math.log10(x)));
  367. }
  368. }, {
  369. key: "roundToBase",
  370. value: function roundToBase(x, base) {
  371. return Math.pow(base, Math.floor(Math.log(x) / Math.log(base)));
  372. }
  373. }, {
  374. key: "parseNumber",
  375. value: function parseNumber(val) {
  376. if (val === null) return val;
  377. return parseFloat(val);
  378. }
  379. }, {
  380. key: "randomId",
  381. value: function randomId() {
  382. return (Math.random() + 1).toString(36).substring(4);
  383. }
  384. }, {
  385. key: "noExponents",
  386. value: function noExponents(val) {
  387. var data = String(val).split(/[eE]/);
  388. if (data.length === 1) return data[0];
  389. var z = '',
  390. sign = val < 0 ? '-' : '',
  391. str = data[0].replace('.', ''),
  392. mag = Number(data[1]) + 1;
  393. if (mag < 0) {
  394. z = sign + '0.';
  395. while (mag++) {
  396. z += '0';
  397. }
  398. return z + str.replace(/^-/, '');
  399. }
  400. mag -= str.length;
  401. while (mag--) {
  402. z += '0';
  403. }
  404. return str + z;
  405. }
  406. }, {
  407. key: "getDimensions",
  408. value: function getDimensions(el) {
  409. var computedStyle = getComputedStyle(el, null);
  410. var elementHeight = el.clientHeight;
  411. var elementWidth = el.clientWidth;
  412. elementHeight -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
  413. elementWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
  414. return [elementWidth, elementHeight];
  415. }
  416. }, {
  417. key: "getBoundingClientRect",
  418. value: function getBoundingClientRect(element) {
  419. var rect = element.getBoundingClientRect();
  420. return {
  421. top: rect.top,
  422. right: rect.right,
  423. bottom: rect.bottom,
  424. left: rect.left,
  425. width: element.clientWidth,
  426. height: element.clientHeight,
  427. x: rect.left,
  428. y: rect.top
  429. };
  430. }
  431. }, {
  432. key: "getLargestStringFromArr",
  433. value: function getLargestStringFromArr(arr) {
  434. return arr.reduce(function (a, b) {
  435. if (Array.isArray(b)) {
  436. b = b.reduce(function (aa, bb) {
  437. return aa.length > bb.length ? aa : bb;
  438. });
  439. }
  440. return a.length > b.length ? a : b;
  441. }, 0);
  442. } // http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-12342275
  443. }, {
  444. key: "hexToRgba",
  445. value: function hexToRgba() {
  446. var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#999999';
  447. var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
  448. if (hex.substring(0, 1) !== '#') {
  449. hex = '#999999';
  450. }
  451. var h = hex.replace('#', '');
  452. h = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g'));
  453. for (var i = 0; i < h.length; i++) {
  454. h[i] = parseInt(h[i].length === 1 ? h[i] + h[i] : h[i], 16);
  455. }
  456. if (typeof opacity !== 'undefined') h.push(opacity);
  457. return 'rgba(' + h.join(',') + ')';
  458. }
  459. }, {
  460. key: "getOpacityFromRGBA",
  461. value: function getOpacityFromRGBA(rgba) {
  462. return parseFloat(rgba.replace(/^.*,(.+)\)/, '$1'));
  463. }
  464. }, {
  465. key: "rgb2hex",
  466. value: function rgb2hex(rgb) {
  467. rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  468. 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) : '';
  469. }
  470. }, {
  471. key: "isColorHex",
  472. value: function isColorHex(color) {
  473. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)|(^#[0-9A-F]{8}$)/i.test(color);
  474. }
  475. }, {
  476. key: "getPolygonPos",
  477. value: function getPolygonPos(size, dataPointsLen) {
  478. var dotsArray = [];
  479. var angle = Math.PI * 2 / dataPointsLen;
  480. for (var i = 0; i < dataPointsLen; i++) {
  481. var curPos = {};
  482. curPos.x = size * Math.sin(i * angle);
  483. curPos.y = -size * Math.cos(i * angle);
  484. dotsArray.push(curPos);
  485. }
  486. return dotsArray;
  487. }
  488. }, {
  489. key: "polarToCartesian",
  490. value: function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
  491. var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
  492. return {
  493. x: centerX + radius * Math.cos(angleInRadians),
  494. y: centerY + radius * Math.sin(angleInRadians)
  495. };
  496. }
  497. }, {
  498. key: "escapeString",
  499. value: function escapeString(str) {
  500. var escapeWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';
  501. var newStr = str.toString().slice();
  502. newStr = newStr.replace(/[` ~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, escapeWith);
  503. return newStr;
  504. }
  505. }, {
  506. key: "negToZero",
  507. value: function negToZero(val) {
  508. return val < 0 ? 0 : val;
  509. }
  510. }, {
  511. key: "moveIndexInArray",
  512. value: function moveIndexInArray(arr, old_index, new_index) {
  513. if (new_index >= arr.length) {
  514. var k = new_index - arr.length + 1;
  515. while (k--) {
  516. arr.push(undefined);
  517. }
  518. }
  519. arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
  520. return arr;
  521. }
  522. }, {
  523. key: "extractNumber",
  524. value: function extractNumber(s) {
  525. return parseFloat(s.replace(/[^\d.]*/g, ''));
  526. }
  527. }, {
  528. key: "findAncestor",
  529. value: function findAncestor(el, cls) {
  530. while ((el = el.parentElement) && !el.classList.contains(cls)) {
  531. }
  532. return el;
  533. }
  534. }, {
  535. key: "setELstyles",
  536. value: function setELstyles(el, styles) {
  537. for (var key in styles) {
  538. if (styles.hasOwnProperty(key)) {
  539. el.style.key = styles[key];
  540. }
  541. }
  542. }
  543. }, {
  544. key: "isNumber",
  545. value: function isNumber(value) {
  546. return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
  547. }
  548. }, {
  549. key: "isFloat",
  550. value: function isFloat(n) {
  551. return Number(n) === n && n % 1 !== 0;
  552. }
  553. }, {
  554. key: "isSafari",
  555. value: function isSafari() {
  556. return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  557. }
  558. }, {
  559. key: "isFirefox",
  560. value: function isFirefox() {
  561. return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  562. }
  563. }, {
  564. key: "isIE11",
  565. value: function isIE11() {
  566. if (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.appVersion.indexOf('Trident/') > -1) {
  567. return true;
  568. }
  569. }
  570. }, {
  571. key: "isIE",
  572. value: function isIE() {
  573. var ua = window.navigator.userAgent;
  574. var msie = ua.indexOf('MSIE ');
  575. if (msie > 0) {
  576. // IE 10 or older => return version number
  577. return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
  578. }
  579. var trident = ua.indexOf('Trident/');
  580. if (trident > 0) {
  581. // IE 11 => return version number
  582. var rv = ua.indexOf('rv:');
  583. return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
  584. }
  585. var edge = ua.indexOf('Edge/');
  586. if (edge > 0) {
  587. // Edge (IE 12+) => return version number
  588. return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
  589. } // other browser
  590. return false;
  591. }
  592. }]);
  593. return Utils;
  594. }();
  595. /**
  596. * ApexCharts Animation Class.
  597. *
  598. * @module Animations
  599. **/
  600. var Animations = /*#__PURE__*/function () {
  601. function Animations(ctx) {
  602. _classCallCheck(this, Animations);
  603. this.ctx = ctx;
  604. this.w = ctx.w;
  605. this.setEasingFunctions();
  606. }
  607. _createClass(Animations, [{
  608. key: "setEasingFunctions",
  609. value: function setEasingFunctions() {
  610. var easing;
  611. if (this.w.globals.easing) return;
  612. var userDefinedEasing = this.w.config.chart.animations.easing;
  613. switch (userDefinedEasing) {
  614. case 'linear':
  615. {
  616. easing = '-';
  617. break;
  618. }
  619. case 'easein':
  620. {
  621. easing = '<';
  622. break;
  623. }
  624. case 'easeout':
  625. {
  626. easing = '>';
  627. break;
  628. }
  629. case 'easeinout':
  630. {
  631. easing = '<>';
  632. break;
  633. }
  634. case 'swing':
  635. {
  636. easing = function easing(pos) {
  637. var s = 1.70158;
  638. var ret = (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
  639. return ret;
  640. };
  641. break;
  642. }
  643. case 'bounce':
  644. {
  645. easing = function easing(pos) {
  646. var ret = '';
  647. if (pos < 1 / 2.75) {
  648. ret = 7.5625 * pos * pos;
  649. } else if (pos < 2 / 2.75) {
  650. ret = 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75;
  651. } else if (pos < 2.5 / 2.75) {
  652. ret = 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375;
  653. } else {
  654. ret = 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375;
  655. }
  656. return ret;
  657. };
  658. break;
  659. }
  660. case 'elastic':
  661. {
  662. easing = function easing(pos) {
  663. if (pos === !!pos) return pos;
  664. return Math.pow(2, -10 * pos) * Math.sin((pos - 0.075) * (2 * Math.PI) / 0.3) + 1;
  665. };
  666. break;
  667. }
  668. default:
  669. {
  670. easing = '<>';
  671. }
  672. }
  673. this.w.globals.easing = easing;
  674. }
  675. }, {
  676. key: "animateLine",
  677. value: function animateLine(el, from, to, speed) {
  678. el.attr(from).animate(speed).attr(to);
  679. }
  680. /*
  681. ** Animate radius of a circle element
  682. */
  683. }, {
  684. key: "animateMarker",
  685. value: function animateMarker(el, from, to, speed, easing, cb) {
  686. if (!from) from = 0;
  687. el.attr({
  688. r: from,
  689. width: from,
  690. height: from
  691. }).animate(speed, easing).attr({
  692. r: to,
  693. width: to.width,
  694. height: to.height
  695. }).afterAll(function () {
  696. cb();
  697. });
  698. }
  699. /*
  700. ** Animate radius and position of a circle element
  701. */
  702. }, {
  703. key: "animateCircle",
  704. value: function animateCircle(el, from, to, speed, easing) {
  705. el.attr({
  706. r: from.r,
  707. cx: from.cx,
  708. cy: from.cy
  709. }).animate(speed, easing).attr({
  710. r: to.r,
  711. cx: to.cx,
  712. cy: to.cy
  713. });
  714. }
  715. /*
  716. ** Animate rect properties
  717. */
  718. }, {
  719. key: "animateRect",
  720. value: function animateRect(el, from, to, speed, fn) {
  721. el.attr(from).animate(speed).attr(to).afterAll(function () {
  722. return fn();
  723. });
  724. }
  725. }, {
  726. key: "animatePathsGradually",
  727. value: function animatePathsGradually(params) {
  728. var el = params.el,
  729. realIndex = params.realIndex,
  730. j = params.j,
  731. fill = params.fill,
  732. pathFrom = params.pathFrom,
  733. pathTo = params.pathTo,
  734. speed = params.speed,
  735. delay = params.delay;
  736. var me = this;
  737. var w = this.w;
  738. var delayFactor = 0;
  739. if (w.config.chart.animations.animateGradually.enabled) {
  740. delayFactor = w.config.chart.animations.animateGradually.delay;
  741. }
  742. if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged && w.config.chart.type !== 'bar') {
  743. // disabled due to this bug - https://github.com/apexcharts/vue-apexcharts/issues/75
  744. delayFactor = 0;
  745. }
  746. me.morphSVG(el, realIndex, j, w.config.chart.type === 'line' && !w.globals.comboCharts ? 'stroke' : fill, pathFrom, pathTo, speed, delay * delayFactor);
  747. }
  748. }, {
  749. key: "showDelayedElements",
  750. value: function showDelayedElements() {
  751. this.w.globals.delayedElements.forEach(function (d) {
  752. var ele = d.el;
  753. ele.classList.remove('apexcharts-element-hidden');
  754. });
  755. }
  756. }, {
  757. key: "animationCompleted",
  758. value: function animationCompleted(el) {
  759. var w = this.w;
  760. if (w.globals.animationEnded) return;
  761. w.globals.animationEnded = true;
  762. this.showDelayedElements();
  763. if (typeof w.config.chart.events.animationEnd === 'function') {
  764. w.config.chart.events.animationEnd(this.ctx, {
  765. el: el,
  766. w: w
  767. });
  768. }
  769. } // SVG.js animation for morphing one path to another
  770. }, {
  771. key: "morphSVG",
  772. value: function morphSVG(el, realIndex, j, fill, pathFrom, pathTo, speed, delay) {
  773. var _this = this;
  774. var w = this.w;
  775. if (!pathFrom) {
  776. pathFrom = el.attr('pathFrom');
  777. }
  778. if (!pathTo) {
  779. pathTo = el.attr('pathTo');
  780. }
  781. var disableAnimationForCorrupPath = function disableAnimationForCorrupPath(path) {
  782. if (w.config.chart.type === 'radar') {
  783. // radar chart drops the path to bottom and hence a corrup path looks ugly
  784. // therefore, disable animation for such a case
  785. speed = 1;
  786. }
  787. return "M 0 ".concat(w.globals.gridHeight);
  788. };
  789. if (!pathFrom || pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) {
  790. pathFrom = disableAnimationForCorrupPath();
  791. }
  792. if (!pathTo || pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) {
  793. pathTo = disableAnimationForCorrupPath();
  794. }
  795. if (!w.globals.shouldAnimate) {
  796. speed = 1;
  797. }
  798. el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo).afterAll(function () {
  799. // a flag to indicate that the original mount function can return true now as animation finished here
  800. if (Utils$1.isNumber(j)) {
  801. if (j === w.globals.series[w.globals.maxValsInArrayIndex].length - 2 && w.globals.shouldAnimate) {
  802. _this.animationCompleted(el);
  803. }
  804. } else if (fill !== 'none' && w.globals.shouldAnimate) {
  805. if (!w.globals.comboCharts && realIndex === w.globals.series.length - 1 || w.globals.comboCharts) {
  806. _this.animationCompleted(el);
  807. }
  808. }
  809. _this.showDelayedElements();
  810. });
  811. }
  812. }]);
  813. return Animations;
  814. }();
  815. /**
  816. * ApexCharts Filters Class for setting hover/active states on the paths.
  817. *
  818. * @module Formatters
  819. **/
  820. var Filters = /*#__PURE__*/function () {
  821. function Filters(ctx) {
  822. _classCallCheck(this, Filters);
  823. this.ctx = ctx;
  824. this.w = ctx.w;
  825. } // create a re-usable filter which can be appended other filter effects and applied to multiple elements
  826. _createClass(Filters, [{
  827. key: "getDefaultFilter",
  828. value: function getDefaultFilter(el, i) {
  829. var w = this.w;
  830. el.unfilter(true);
  831. var filter = new window.SVG.Filter();
  832. filter.size('120%', '180%', '-5%', '-40%');
  833. if (w.config.states.normal.filter !== 'none') {
  834. this.applyFilter(el, i, w.config.states.normal.filter.type, w.config.states.normal.filter.value);
  835. } else {
  836. if (w.config.chart.dropShadow.enabled) {
  837. this.dropShadow(el, w.config.chart.dropShadow, i);
  838. }
  839. }
  840. }
  841. }, {
  842. key: "addNormalFilter",
  843. value: function addNormalFilter(el, i) {
  844. var w = this.w; // revert shadow if it was there
  845. // but, ignore marker as marker don't have dropshadow yet
  846. if (w.config.chart.dropShadow.enabled && !el.node.classList.contains('apexcharts-marker')) {
  847. this.dropShadow(el, w.config.chart.dropShadow, i);
  848. }
  849. } // appends dropShadow to the filter object which can be chained with other filter effects
  850. }, {
  851. key: "addLightenFilter",
  852. value: function addLightenFilter(el, i, attrs) {
  853. var _this = this;
  854. var w = this.w;
  855. var intensity = attrs.intensity;
  856. el.unfilter(true);
  857. var filter = new window.SVG.Filter();
  858. el.filter(function (add) {
  859. var shadowAttr = w.config.chart.dropShadow;
  860. if (shadowAttr.enabled) {
  861. filter = _this.addShadow(add, i, shadowAttr);
  862. } else {
  863. filter = add;
  864. }
  865. filter.componentTransfer({
  866. rgb: {
  867. type: 'linear',
  868. slope: 1.5,
  869. intercept: intensity
  870. }
  871. });
  872. });
  873. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  874. this._scaleFilterSize(el.filterer.node);
  875. } // appends dropShadow to the filter object which can be chained with other filter effects
  876. }, {
  877. key: "addDarkenFilter",
  878. value: function addDarkenFilter(el, i, attrs) {
  879. var _this2 = this;
  880. var w = this.w;
  881. var intensity = attrs.intensity;
  882. el.unfilter(true);
  883. var filter = new window.SVG.Filter();
  884. el.filter(function (add) {
  885. var shadowAttr = w.config.chart.dropShadow;
  886. if (shadowAttr.enabled) {
  887. filter = _this2.addShadow(add, i, shadowAttr);
  888. } else {
  889. filter = add;
  890. }
  891. filter.componentTransfer({
  892. rgb: {
  893. type: 'linear',
  894. slope: intensity
  895. }
  896. });
  897. });
  898. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  899. this._scaleFilterSize(el.filterer.node);
  900. }
  901. }, {
  902. key: "applyFilter",
  903. value: function applyFilter(el, i, filter) {
  904. var intensity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
  905. switch (filter) {
  906. case 'none':
  907. {
  908. this.addNormalFilter(el, i);
  909. break;
  910. }
  911. case 'lighten':
  912. {
  913. this.addLightenFilter(el, i, {
  914. intensity: intensity
  915. });
  916. break;
  917. }
  918. case 'darken':
  919. {
  920. this.addDarkenFilter(el, i, {
  921. intensity: intensity
  922. });
  923. break;
  924. }
  925. }
  926. } // appends dropShadow to the filter object which can be chained with other filter effects
  927. }, {
  928. key: "addShadow",
  929. value: function addShadow(add, i, attrs) {
  930. var blur = attrs.blur,
  931. top = attrs.top,
  932. left = attrs.left,
  933. color = attrs.color,
  934. opacity = attrs.opacity;
  935. var shadowBlur = add.flood(Array.isArray(color) ? color[i] : color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  936. return add.blend(add.source, shadowBlur);
  937. } // directly adds dropShadow to the element and returns the same element.
  938. // 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
  939. }, {
  940. key: "dropShadow",
  941. value: function dropShadow(el, attrs) {
  942. var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  943. var top = attrs.top,
  944. left = attrs.left,
  945. blur = attrs.blur,
  946. color = attrs.color,
  947. opacity = attrs.opacity,
  948. noUserSpaceOnUse = attrs.noUserSpaceOnUse;
  949. var w = this.w;
  950. el.unfilter(true);
  951. if (Utils$1.isIE() && w.config.chart.type === 'radialBar') {
  952. // in radialbar charts, dropshadow is clipping actual drawing in IE
  953. return el;
  954. }
  955. color = Array.isArray(color) ? color[i] : color;
  956. el.filter(function (add) {
  957. var shadowBlur = null;
  958. if (Utils$1.isSafari() || Utils$1.isFirefox() || Utils$1.isIE()) {
  959. // safari/firefox/IE have some alternative way to use this filter
  960. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur);
  961. } else {
  962. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  963. }
  964. add.blend(add.source, shadowBlur);
  965. });
  966. if (!noUserSpaceOnUse) {
  967. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  968. }
  969. this._scaleFilterSize(el.filterer.node);
  970. return el;
  971. }
  972. }, {
  973. key: "setSelectionFilter",
  974. value: function setSelectionFilter(el, realIndex, dataPointIndex) {
  975. var w = this.w;
  976. if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') {
  977. if (w.globals.selectedDataPoints[realIndex].indexOf(dataPointIndex) > -1) {
  978. el.node.setAttribute('selected', true);
  979. var activeFilter = w.config.states.active.filter;
  980. if (activeFilter !== 'none') {
  981. this.applyFilter(el, realIndex, activeFilter.type, activeFilter.value);
  982. }
  983. }
  984. }
  985. }
  986. }, {
  987. key: "_scaleFilterSize",
  988. value: function _scaleFilterSize(el) {
  989. var setAttributes = function setAttributes(attrs) {
  990. for (var key in attrs) {
  991. if (attrs.hasOwnProperty(key)) {
  992. el.setAttribute(key, attrs[key]);
  993. }
  994. }
  995. };
  996. setAttributes({
  997. width: '200%',
  998. height: '200%',
  999. x: '-50%',
  1000. y: '-50%'
  1001. });
  1002. }
  1003. }]);
  1004. return Filters;
  1005. }();
  1006. /**
  1007. * ApexCharts Graphics Class for all drawing operations.
  1008. *
  1009. * @module Graphics
  1010. **/
  1011. var Graphics = /*#__PURE__*/function () {
  1012. function Graphics(ctx) {
  1013. _classCallCheck(this, Graphics);
  1014. this.ctx = ctx;
  1015. this.w = ctx.w;
  1016. }
  1017. _createClass(Graphics, [{
  1018. key: "drawLine",
  1019. value: function drawLine(x1, y1, x2, y2) {
  1020. var lineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#a8a8a8';
  1021. var dashArray = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  1022. var strokeWidth = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  1023. var strokeLineCap = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'butt';
  1024. var w = this.w;
  1025. var line = w.globals.dom.Paper.line().attr({
  1026. x1: x1,
  1027. y1: y1,
  1028. x2: x2,
  1029. y2: y2,
  1030. stroke: lineColor,
  1031. 'stroke-dasharray': dashArray,
  1032. 'stroke-width': strokeWidth,
  1033. 'stroke-linecap': strokeLineCap
  1034. });
  1035. return line;
  1036. }
  1037. }, {
  1038. key: "drawRect",
  1039. value: function drawRect() {
  1040. var x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1041. var y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1042. var x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  1043. var y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  1044. var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  1045. var color = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '#fefefe';
  1046. var opacity = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1;
  1047. var strokeWidth = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  1048. var strokeColor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  1049. var strokeDashArray = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 0;
  1050. var w = this.w;
  1051. var rect = w.globals.dom.Paper.rect();
  1052. rect.attr({
  1053. x: x1,
  1054. y: y1,
  1055. width: x2 > 0 ? x2 : 0,
  1056. height: y2 > 0 ? y2 : 0,
  1057. rx: radius,
  1058. ry: radius,
  1059. opacity: opacity,
  1060. 'stroke-width': strokeWidth !== null ? strokeWidth : 0,
  1061. stroke: strokeColor !== null ? strokeColor : 'none',
  1062. 'stroke-dasharray': strokeDashArray
  1063. }); // fix apexcharts.js#1410
  1064. rect.node.setAttribute('fill', color);
  1065. return rect;
  1066. }
  1067. }, {
  1068. key: "drawPolygon",
  1069. value: function drawPolygon(polygonString) {
  1070. var stroke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#e1e1e1';
  1071. var strokeWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  1072. var fill = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'none';
  1073. var w = this.w;
  1074. var polygon = w.globals.dom.Paper.polygon(polygonString).attr({
  1075. fill: fill,
  1076. stroke: stroke,
  1077. 'stroke-width': strokeWidth
  1078. });
  1079. return polygon;
  1080. }
  1081. }, {
  1082. key: "drawCircle",
  1083. value: function drawCircle(radius) {
  1084. var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1085. var w = this.w;
  1086. if (radius < 0) radius = 0;
  1087. var c = w.globals.dom.Paper.circle(radius * 2);
  1088. if (attrs !== null) {
  1089. c.attr(attrs);
  1090. }
  1091. return c;
  1092. }
  1093. }, {
  1094. key: "drawPath",
  1095. value: function drawPath(_ref) {
  1096. var _ref$d = _ref.d,
  1097. d = _ref$d === void 0 ? '' : _ref$d,
  1098. _ref$stroke = _ref.stroke,
  1099. stroke = _ref$stroke === void 0 ? '#a8a8a8' : _ref$stroke,
  1100. _ref$strokeWidth = _ref.strokeWidth,
  1101. strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
  1102. fill = _ref.fill,
  1103. _ref$fillOpacity = _ref.fillOpacity,
  1104. fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
  1105. _ref$strokeOpacity = _ref.strokeOpacity,
  1106. strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
  1107. classes = _ref.classes,
  1108. _ref$strokeLinecap = _ref.strokeLinecap,
  1109. strokeLinecap = _ref$strokeLinecap === void 0 ? null : _ref$strokeLinecap,
  1110. _ref$strokeDashArray = _ref.strokeDashArray,
  1111. strokeDashArray = _ref$strokeDashArray === void 0 ? 0 : _ref$strokeDashArray;
  1112. var w = this.w;
  1113. if (strokeLinecap === null) {
  1114. strokeLinecap = w.config.stroke.lineCap;
  1115. }
  1116. if (d.indexOf('undefined') > -1 || d.indexOf('NaN') > -1) {
  1117. d = "M 0 ".concat(w.globals.gridHeight);
  1118. }
  1119. var p = w.globals.dom.Paper.path(d).attr({
  1120. fill: fill,
  1121. 'fill-opacity': fillOpacity,
  1122. stroke: stroke,
  1123. 'stroke-opacity': strokeOpacity,
  1124. 'stroke-linecap': strokeLinecap,
  1125. 'stroke-width': strokeWidth,
  1126. 'stroke-dasharray': strokeDashArray,
  1127. class: classes
  1128. });
  1129. return p;
  1130. }
  1131. }, {
  1132. key: "group",
  1133. value: function group() {
  1134. var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1135. var w = this.w;
  1136. var g = w.globals.dom.Paper.group();
  1137. if (attrs !== null) {
  1138. g.attr(attrs);
  1139. }
  1140. return g;
  1141. }
  1142. }, {
  1143. key: "move",
  1144. value: function move(x, y) {
  1145. var move = ['M', x, y].join(' ');
  1146. return move;
  1147. }
  1148. }, {
  1149. key: "line",
  1150. value: function line(x, y) {
  1151. var hORv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1152. var line = null;
  1153. if (hORv === null) {
  1154. line = ['L', x, y].join(' ');
  1155. } else if (hORv === 'H') {
  1156. line = ['H', x].join(' ');
  1157. } else if (hORv === 'V') {
  1158. line = ['V', y].join(' ');
  1159. }
  1160. return line;
  1161. }
  1162. }, {
  1163. key: "curve",
  1164. value: function curve(x1, y1, x2, y2, x, y) {
  1165. var curve = ['C', x1, y1, x2, y2, x, y].join(' ');
  1166. return curve;
  1167. }
  1168. }, {
  1169. key: "quadraticCurve",
  1170. value: function quadraticCurve(x1, y1, x, y) {
  1171. var curve = ['Q', x1, y1, x, y].join(' ');
  1172. return curve;
  1173. }
  1174. }, {
  1175. key: "arc",
  1176. value: function arc(rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y) {
  1177. var relative = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
  1178. var coord = 'A';
  1179. if (relative) coord = 'a';
  1180. var arc = [coord, rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y].join(' ');
  1181. return arc;
  1182. }
  1183. /**
  1184. * @memberof Graphics
  1185. * @param {object}
  1186. * i = series's index
  1187. * 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
  1188. * pathFrom = existing pathFrom to animateTo
  1189. * pathTo = new Path to which d attr will be animated from pathFrom to pathTo
  1190. * stroke = line Color
  1191. * strokeWidth = width of path Line
  1192. * fill = it can be gradient, single color, pattern or image
  1193. * animationDelay = how much to delay when starting animation (in milliseconds)
  1194. * dataChangeSpeed = for dynamic animations, when data changes
  1195. * className = class attribute to add
  1196. * @return {object} svg.js path object
  1197. **/
  1198. }, {
  1199. key: "renderPaths",
  1200. value: function renderPaths(_ref2) {
  1201. var j = _ref2.j,
  1202. realIndex = _ref2.realIndex,
  1203. pathFrom = _ref2.pathFrom,
  1204. pathTo = _ref2.pathTo,
  1205. stroke = _ref2.stroke,
  1206. strokeWidth = _ref2.strokeWidth,
  1207. strokeLinecap = _ref2.strokeLinecap,
  1208. fill = _ref2.fill,
  1209. animationDelay = _ref2.animationDelay,
  1210. initialSpeed = _ref2.initialSpeed,
  1211. dataChangeSpeed = _ref2.dataChangeSpeed,
  1212. className = _ref2.className,
  1213. _ref2$shouldClipToGri = _ref2.shouldClipToGrid,
  1214. shouldClipToGrid = _ref2$shouldClipToGri === void 0 ? true : _ref2$shouldClipToGri,
  1215. _ref2$bindEventsOnPat = _ref2.bindEventsOnPaths,
  1216. bindEventsOnPaths = _ref2$bindEventsOnPat === void 0 ? true : _ref2$bindEventsOnPat,
  1217. _ref2$drawShadow = _ref2.drawShadow,
  1218. drawShadow = _ref2$drawShadow === void 0 ? true : _ref2$drawShadow;
  1219. var w = this.w;
  1220. var filters = new Filters(this.ctx);
  1221. var anim = new Animations(this.ctx);
  1222. var initialAnim = this.w.config.chart.animations.enabled;
  1223. var dynamicAnim = initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  1224. var d;
  1225. var shouldAnimate = !!(initialAnim && !w.globals.resized || dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate);
  1226. if (shouldAnimate) {
  1227. d = pathFrom;
  1228. } else {
  1229. d = pathTo;
  1230. w.globals.animationEnded = true;
  1231. }
  1232. var strokeDashArrayOpt = w.config.stroke.dashArray;
  1233. var strokeDashArray = 0;
  1234. if (Array.isArray(strokeDashArrayOpt)) {
  1235. strokeDashArray = strokeDashArrayOpt[realIndex];
  1236. } else {
  1237. strokeDashArray = w.config.stroke.dashArray;
  1238. }
  1239. var el = this.drawPath({
  1240. d: d,
  1241. stroke: stroke,
  1242. strokeWidth: strokeWidth,
  1243. fill: fill,
  1244. fillOpacity: 1,
  1245. classes: className,
  1246. strokeLinecap: strokeLinecap,
  1247. strokeDashArray: strokeDashArray
  1248. });
  1249. el.attr('index', realIndex);
  1250. if (shouldClipToGrid) {
  1251. el.attr({
  1252. 'clip-path': "url(#gridRectMask".concat(w.globals.cuid, ")")
  1253. });
  1254. } // const defaultFilter = el.filterer
  1255. if (w.config.states.normal.filter.type !== 'none') {
  1256. filters.getDefaultFilter(el, realIndex);
  1257. } else {
  1258. if (w.config.chart.dropShadow.enabled && drawShadow) {
  1259. if (!w.config.chart.dropShadow.enabledOnSeries || w.config.chart.dropShadow.enabledOnSeries && w.config.chart.dropShadow.enabledOnSeries.indexOf(realIndex) !== -1) {
  1260. var shadow = w.config.chart.dropShadow;
  1261. filters.dropShadow(el, shadow, realIndex);
  1262. }
  1263. }
  1264. }
  1265. if (bindEventsOnPaths) {
  1266. el.node.addEventListener('mouseenter', this.pathMouseEnter.bind(this, el));
  1267. el.node.addEventListener('mouseleave', this.pathMouseLeave.bind(this, el));
  1268. el.node.addEventListener('mousedown', this.pathMouseDown.bind(this, el));
  1269. }
  1270. el.attr({
  1271. pathTo: pathTo,
  1272. pathFrom: pathFrom
  1273. });
  1274. var defaultAnimateOpts = {
  1275. el: el,
  1276. j: j,
  1277. realIndex: realIndex,
  1278. pathFrom: pathFrom,
  1279. pathTo: pathTo,
  1280. fill: fill,
  1281. strokeWidth: strokeWidth,
  1282. delay: animationDelay
  1283. };
  1284. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  1285. anim.animatePathsGradually(_objectSpread2(_objectSpread2({}, defaultAnimateOpts), {}, {
  1286. speed: initialSpeed
  1287. }));
  1288. } else {
  1289. if (w.globals.resized || !w.globals.dataChanged) {
  1290. anim.showDelayedElements();
  1291. }
  1292. }
  1293. if (w.globals.dataChanged && dynamicAnim && shouldAnimate) {
  1294. anim.animatePathsGradually(_objectSpread2(_objectSpread2({}, defaultAnimateOpts), {}, {
  1295. speed: dataChangeSpeed
  1296. }));
  1297. }
  1298. return el;
  1299. }
  1300. }, {
  1301. key: "drawPattern",
  1302. value: function drawPattern(style, width, height) {
  1303. var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8';
  1304. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  1305. var w = this.w;
  1306. var p = w.globals.dom.Paper.pattern(width, height, function (add) {
  1307. if (style === 'horizontalLines') {
  1308. add.line(0, 0, height, 0).stroke({
  1309. color: stroke,
  1310. width: strokeWidth + 1
  1311. });
  1312. } else if (style === 'verticalLines') {
  1313. add.line(0, 0, 0, width).stroke({
  1314. color: stroke,
  1315. width: strokeWidth + 1
  1316. });
  1317. } else if (style === 'slantedLines') {
  1318. add.line(0, 0, width, height).stroke({
  1319. color: stroke,
  1320. width: strokeWidth
  1321. });
  1322. } else if (style === 'squares') {
  1323. add.rect(width, height).fill('none').stroke({
  1324. color: stroke,
  1325. width: strokeWidth
  1326. });
  1327. } else if (style === 'circles') {
  1328. add.circle(width).fill('none').stroke({
  1329. color: stroke,
  1330. width: strokeWidth
  1331. });
  1332. }
  1333. });
  1334. return p;
  1335. }
  1336. }, {
  1337. key: "drawGradient",
  1338. value: function drawGradient(style, gfrom, gto, opacityFrom, opacityTo) {
  1339. var size = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  1340. var stops = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  1341. var colorStops = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  1342. var i = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
  1343. var w = this.w;
  1344. var g;
  1345. if (gfrom.length < 9 && gfrom.indexOf('#') === 0) {
  1346. // if the hex contains alpha and is of 9 digit, skip the opacity
  1347. gfrom = Utils$1.hexToRgba(gfrom, opacityFrom);
  1348. }
  1349. if (gto.length < 9 && gto.indexOf('#') === 0) {
  1350. gto = Utils$1.hexToRgba(gto, opacityTo);
  1351. }
  1352. var stop1 = 0;
  1353. var stop2 = 1;
  1354. var stop3 = 1;
  1355. var stop4 = null;
  1356. if (stops !== null) {
  1357. stop1 = typeof stops[0] !== 'undefined' ? stops[0] / 100 : 0;
  1358. stop2 = typeof stops[1] !== 'undefined' ? stops[1] / 100 : 1;
  1359. stop3 = typeof stops[2] !== 'undefined' ? stops[2] / 100 : 1;
  1360. stop4 = typeof stops[3] !== 'undefined' ? stops[3] / 100 : null;
  1361. }
  1362. var radial = !!(w.config.chart.type === 'donut' || w.config.chart.type === 'pie' || w.config.chart.type === 'polarArea' || w.config.chart.type === 'bubble');
  1363. if (colorStops === null || colorStops.length === 0) {
  1364. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1365. stop.at(stop1, gfrom, opacityFrom);
  1366. stop.at(stop2, gto, opacityTo);
  1367. stop.at(stop3, gto, opacityTo);
  1368. if (stop4 !== null) {
  1369. stop.at(stop4, gfrom, opacityFrom);
  1370. }
  1371. });
  1372. } else {
  1373. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1374. var gradientStops = Array.isArray(colorStops[i]) ? colorStops[i] : colorStops;
  1375. gradientStops.forEach(function (s) {
  1376. stop.at(s.offset / 100, s.color, s.opacity);
  1377. });
  1378. });
  1379. }
  1380. if (!radial) {
  1381. if (style === 'vertical') {
  1382. g.from(0, 0).to(0, 1);
  1383. } else if (style === 'diagonal') {
  1384. g.from(0, 0).to(1, 1);
  1385. } else if (style === 'horizontal') {
  1386. g.from(0, 1).to(1, 1);
  1387. } else if (style === 'diagonal2') {
  1388. g.from(1, 0).to(0, 1);
  1389. }
  1390. } else {
  1391. var offx = w.globals.gridWidth / 2;
  1392. var offy = w.globals.gridHeight / 2;
  1393. if (w.config.chart.type !== 'bubble') {
  1394. g.attr({
  1395. gradientUnits: 'userSpaceOnUse',
  1396. cx: offx,
  1397. cy: offy,
  1398. r: size
  1399. });
  1400. } else {
  1401. g.attr({
  1402. cx: 0.5,
  1403. cy: 0.5,
  1404. r: 0.8,
  1405. fx: 0.2,
  1406. fy: 0.2
  1407. });
  1408. }
  1409. }
  1410. return g;
  1411. }
  1412. }, {
  1413. key: "drawText",
  1414. value: function drawText(_ref3) {
  1415. var x = _ref3.x,
  1416. y = _ref3.y,
  1417. text = _ref3.text,
  1418. textAnchor = _ref3.textAnchor,
  1419. fontSize = _ref3.fontSize,
  1420. fontFamily = _ref3.fontFamily,
  1421. fontWeight = _ref3.fontWeight,
  1422. foreColor = _ref3.foreColor,
  1423. opacity = _ref3.opacity,
  1424. _ref3$cssClass = _ref3.cssClass,
  1425. cssClass = _ref3$cssClass === void 0 ? '' : _ref3$cssClass,
  1426. _ref3$isPlainText = _ref3.isPlainText,
  1427. isPlainText = _ref3$isPlainText === void 0 ? true : _ref3$isPlainText;
  1428. var w = this.w;
  1429. if (typeof text === 'undefined') text = '';
  1430. if (!textAnchor) {
  1431. textAnchor = 'start';
  1432. }
  1433. if (!foreColor || !foreColor.length) {
  1434. foreColor = w.config.chart.foreColor;
  1435. }
  1436. fontFamily = fontFamily || w.config.chart.fontFamily;
  1437. fontWeight = fontWeight || 'regular';
  1438. var elText;
  1439. if (Array.isArray(text)) {
  1440. elText = w.globals.dom.Paper.text(function (add) {
  1441. for (var i = 0; i < text.length; i++) {
  1442. i === 0 ? add.tspan(text[i]) : add.tspan(text[i]).newLine();
  1443. }
  1444. });
  1445. } else {
  1446. elText = isPlainText ? w.globals.dom.Paper.plain(text) : w.globals.dom.Paper.text(function (add) {
  1447. return add.tspan(text);
  1448. });
  1449. }
  1450. elText.attr({
  1451. x: x,
  1452. y: y,
  1453. 'text-anchor': textAnchor,
  1454. 'dominant-baseline': 'auto',
  1455. 'font-size': fontSize,
  1456. 'font-family': fontFamily,
  1457. 'font-weight': fontWeight,
  1458. fill: foreColor,
  1459. class: 'apexcharts-text ' + cssClass
  1460. });
  1461. elText.node.style.fontFamily = fontFamily;
  1462. elText.node.style.opacity = opacity;
  1463. return elText;
  1464. }
  1465. }, {
  1466. key: "drawMarker",
  1467. value: function drawMarker(x, y, opts) {
  1468. x = x || 0;
  1469. var size = opts.pSize || 0;
  1470. var elPoint = null;
  1471. if (opts.shape === 'square' || opts.shape === 'rect') {
  1472. var radius = opts.pRadius === undefined ? size / 2 : opts.pRadius;
  1473. if (y === null || !size) {
  1474. size = 0;
  1475. radius = 0;
  1476. }
  1477. var nSize = size * 1.2 + radius;
  1478. var p = this.drawRect(nSize, nSize, nSize, nSize, radius);
  1479. p.attr({
  1480. x: x - nSize / 2,
  1481. y: y - nSize / 2,
  1482. cx: x,
  1483. cy: y,
  1484. class: opts.class ? opts.class : '',
  1485. fill: opts.pointFillColor,
  1486. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1487. stroke: opts.pointStrokeColor,
  1488. 'stroke-width': opts.pointStrokeWidth ? opts.pointStrokeWidth : 0,
  1489. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1490. });
  1491. elPoint = p;
  1492. } else if (opts.shape === 'circle' || !opts.shape) {
  1493. if (!Utils$1.isNumber(y)) {
  1494. size = 0;
  1495. y = 0;
  1496. } // let nSize = size - opts.pRadius / 2 < 0 ? 0 : size - opts.pRadius / 2
  1497. elPoint = this.drawCircle(size, {
  1498. cx: x,
  1499. cy: y,
  1500. class: opts.class ? opts.class : '',
  1501. stroke: opts.pointStrokeColor,
  1502. fill: opts.pointFillColor,
  1503. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1504. 'stroke-width': opts.pointStrokeWidth ? opts.pointStrokeWidth : 0,
  1505. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1506. });
  1507. }
  1508. return elPoint;
  1509. }
  1510. }, {
  1511. key: "pathMouseEnter",
  1512. value: function pathMouseEnter(path, e) {
  1513. var w = this.w;
  1514. var filters = new Filters(this.ctx);
  1515. var i = parseInt(path.node.getAttribute('index'), 10);
  1516. var j = parseInt(path.node.getAttribute('j'), 10);
  1517. if (typeof w.config.chart.events.dataPointMouseEnter === 'function') {
  1518. w.config.chart.events.dataPointMouseEnter(e, this.ctx, {
  1519. seriesIndex: i,
  1520. dataPointIndex: j,
  1521. w: w
  1522. });
  1523. }
  1524. this.ctx.events.fireEvent('dataPointMouseEnter', [e, this.ctx, {
  1525. seriesIndex: i,
  1526. dataPointIndex: j,
  1527. w: w
  1528. }]);
  1529. if (w.config.states.active.filter.type !== 'none') {
  1530. if (path.node.getAttribute('selected') === 'true') {
  1531. return;
  1532. }
  1533. }
  1534. if (w.config.states.hover.filter.type !== 'none') {
  1535. if (!w.globals.isTouchDevice) {
  1536. var hoverFilter = w.config.states.hover.filter;
  1537. filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value);
  1538. }
  1539. }
  1540. }
  1541. }, {
  1542. key: "pathMouseLeave",
  1543. value: function pathMouseLeave(path, e) {
  1544. var w = this.w;
  1545. var filters = new Filters(this.ctx);
  1546. var i = parseInt(path.node.getAttribute('index'), 10);
  1547. var j = parseInt(path.node.getAttribute('j'), 10);
  1548. if (typeof w.config.chart.events.dataPointMouseLeave === 'function') {
  1549. w.config.chart.events.dataPointMouseLeave(e, this.ctx, {
  1550. seriesIndex: i,
  1551. dataPointIndex: j,
  1552. w: w
  1553. });
  1554. }
  1555. this.ctx.events.fireEvent('dataPointMouseLeave', [e, this.ctx, {
  1556. seriesIndex: i,
  1557. dataPointIndex: j,
  1558. w: w
  1559. }]);
  1560. if (w.config.states.active.filter.type !== 'none') {
  1561. if (path.node.getAttribute('selected') === 'true') {
  1562. return;
  1563. }
  1564. }
  1565. if (w.config.states.hover.filter.type !== 'none') {
  1566. filters.getDefaultFilter(path, i);
  1567. }
  1568. }
  1569. }, {
  1570. key: "pathMouseDown",
  1571. value: function pathMouseDown(path, e) {
  1572. var w = this.w;
  1573. var filters = new Filters(this.ctx);
  1574. var i = parseInt(path.node.getAttribute('index'), 10);
  1575. var j = parseInt(path.node.getAttribute('j'), 10);
  1576. var selected = 'false';
  1577. if (path.node.getAttribute('selected') === 'true') {
  1578. path.node.setAttribute('selected', 'false');
  1579. if (w.globals.selectedDataPoints[i].indexOf(j) > -1) {
  1580. var index = w.globals.selectedDataPoints[i].indexOf(j);
  1581. w.globals.selectedDataPoints[i].splice(index, 1);
  1582. }
  1583. } else {
  1584. if (!w.config.states.active.allowMultipleDataPointsSelection && w.globals.selectedDataPoints.length > 0) {
  1585. w.globals.selectedDataPoints = [];
  1586. var elPaths = w.globals.dom.Paper.select('.apexcharts-series path').members;
  1587. var elCircles = w.globals.dom.Paper.select('.apexcharts-series circle, .apexcharts-series rect').members;
  1588. var deSelect = function deSelect(els) {
  1589. Array.prototype.forEach.call(els, function (el) {
  1590. el.node.setAttribute('selected', 'false');
  1591. filters.getDefaultFilter(el, i);
  1592. });
  1593. };
  1594. deSelect(elPaths);
  1595. deSelect(elCircles);
  1596. }
  1597. path.node.setAttribute('selected', 'true');
  1598. selected = 'true';
  1599. if (typeof w.globals.selectedDataPoints[i] === 'undefined') {
  1600. w.globals.selectedDataPoints[i] = [];
  1601. }
  1602. w.globals.selectedDataPoints[i].push(j);
  1603. }
  1604. if (selected === 'true') {
  1605. var activeFilter = w.config.states.active.filter;
  1606. if (activeFilter !== 'none') {
  1607. filters.applyFilter(path, i, activeFilter.type, activeFilter.value);
  1608. }
  1609. } else {
  1610. if (w.config.states.active.filter.type !== 'none') {
  1611. filters.getDefaultFilter(path, i);
  1612. }
  1613. }
  1614. if (typeof w.config.chart.events.dataPointSelection === 'function') {
  1615. w.config.chart.events.dataPointSelection(e, this.ctx, {
  1616. selectedDataPoints: w.globals.selectedDataPoints,
  1617. seriesIndex: i,
  1618. dataPointIndex: j,
  1619. w: w
  1620. });
  1621. }
  1622. if (e) {
  1623. this.ctx.events.fireEvent('dataPointSelection', [e, this.ctx, {
  1624. selectedDataPoints: w.globals.selectedDataPoints,
  1625. seriesIndex: i,
  1626. dataPointIndex: j,
  1627. w: w
  1628. }]);
  1629. }
  1630. }
  1631. }, {
  1632. key: "rotateAroundCenter",
  1633. value: function rotateAroundCenter(el) {
  1634. var coord = {};
  1635. if (el && typeof el.getBBox === 'function') {
  1636. coord = el.getBBox();
  1637. }
  1638. var x = coord.x + coord.width / 2;
  1639. var y = coord.y + coord.height / 2;
  1640. return {
  1641. x: x,
  1642. y: y
  1643. };
  1644. }
  1645. }, {
  1646. key: "getTextRects",
  1647. value: function getTextRects(text, fontSize, fontFamily, transform) {
  1648. var useBBox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  1649. var w = this.w;
  1650. var virtualText = this.drawText({
  1651. x: -200,
  1652. y: -200,
  1653. text: text,
  1654. textAnchor: 'start',
  1655. fontSize: fontSize,
  1656. fontFamily: fontFamily,
  1657. foreColor: '#fff',
  1658. opacity: 0
  1659. });
  1660. if (transform) {
  1661. virtualText.attr('transform', transform);
  1662. }
  1663. w.globals.dom.Paper.add(virtualText);
  1664. var rect = virtualText.bbox();
  1665. if (!useBBox) {
  1666. rect = virtualText.node.getBoundingClientRect();
  1667. }
  1668. virtualText.remove();
  1669. return {
  1670. width: rect.width,
  1671. height: rect.height
  1672. };
  1673. }
  1674. /**
  1675. * append ... to long text
  1676. * http://stackoverflow.com/questions/9241315/trimming-text-to-a-given-pixel-width-in-svg
  1677. * @memberof Graphics
  1678. **/
  1679. }, {
  1680. key: "placeTextWithEllipsis",
  1681. value: function placeTextWithEllipsis(textObj, textString, width) {
  1682. if (typeof textObj.getComputedTextLength !== 'function') return;
  1683. textObj.textContent = textString;
  1684. if (textString.length > 0) {
  1685. // ellipsis is needed
  1686. if (textObj.getComputedTextLength() >= width / 1.1) {
  1687. for (var x = textString.length - 3; x > 0; x -= 3) {
  1688. if (textObj.getSubStringLength(0, x) <= width / 1.1) {
  1689. textObj.textContent = textString.substring(0, x) + '...';
  1690. return;
  1691. }
  1692. }
  1693. textObj.textContent = '.'; // can't place at all
  1694. }
  1695. }
  1696. }
  1697. }], [{
  1698. key: "setAttrs",
  1699. value: function setAttrs(el, attrs) {
  1700. for (var key in attrs) {
  1701. if (attrs.hasOwnProperty(key)) {
  1702. el.setAttribute(key, attrs[key]);
  1703. }
  1704. }
  1705. }
  1706. }]);
  1707. return Graphics;
  1708. }();
  1709. /*
  1710. ** Util functions which are dependent on ApexCharts instance
  1711. */
  1712. var CoreUtils = /*#__PURE__*/function () {
  1713. function CoreUtils(ctx) {
  1714. _classCallCheck(this, CoreUtils);
  1715. this.ctx = ctx;
  1716. this.w = ctx.w;
  1717. }
  1718. _createClass(CoreUtils, [{
  1719. key: "getStackedSeriesTotals",
  1720. value:
  1721. /**
  1722. * @memberof CoreUtils
  1723. * returns the sum of all individual values in a multiple stacked series
  1724. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  1725. * @return [34,36,48,13]
  1726. **/
  1727. function getStackedSeriesTotals() {
  1728. var w = this.w;
  1729. var total = [];
  1730. if (w.globals.series.length === 0) return total;
  1731. for (var i = 0; i < w.globals.series[w.globals.maxValsInArrayIndex].length; i++) {
  1732. var t = 0;
  1733. for (var j = 0; j < w.globals.series.length; j++) {
  1734. if (typeof w.globals.series[j][i] !== 'undefined') {
  1735. t += w.globals.series[j][i];
  1736. }
  1737. }
  1738. total.push(t);
  1739. }
  1740. w.globals.stackedSeriesTotals = total;
  1741. return total;
  1742. } // get total of the all values inside all series
  1743. }, {
  1744. key: "getSeriesTotalByIndex",
  1745. value: function getSeriesTotalByIndex() {
  1746. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1747. if (index === null) {
  1748. // non-plot chart types - pie / donut / circle
  1749. return this.w.config.series.reduce(function (acc, cur) {
  1750. return acc + cur;
  1751. }, 0);
  1752. } else {
  1753. // axis charts - supporting multiple series
  1754. return this.w.globals.series[index].reduce(function (acc, cur) {
  1755. return acc + cur;
  1756. }, 0);
  1757. }
  1758. }
  1759. }, {
  1760. key: "isSeriesNull",
  1761. value: function isSeriesNull() {
  1762. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1763. var r = [];
  1764. if (index === null) {
  1765. // non-plot chart types - pie / donut / circle
  1766. r = this.w.config.series.filter(function (d) {
  1767. return d !== null;
  1768. });
  1769. } else {
  1770. // axis charts - supporting multiple series
  1771. r = this.w.config.series[index].data.filter(function (d) {
  1772. return d !== null;
  1773. });
  1774. }
  1775. return r.length === 0;
  1776. }
  1777. }, {
  1778. key: "seriesHaveSameValues",
  1779. value: function seriesHaveSameValues(index) {
  1780. return this.w.globals.series[index].every(function (val, i, arr) {
  1781. return val === arr[0];
  1782. });
  1783. }
  1784. }, {
  1785. key: "getCategoryLabels",
  1786. value: function getCategoryLabels(labels) {
  1787. var w = this.w;
  1788. var catLabels = labels.slice();
  1789. if (w.config.xaxis.convertedCatToNumeric) {
  1790. catLabels = labels.map(function (i, li) {
  1791. return w.config.xaxis.labels.formatter(i - w.globals.minX + 1);
  1792. });
  1793. }
  1794. return catLabels;
  1795. } // maxValsInArrayIndex is the index of series[] which has the largest number of items
  1796. }, {
  1797. key: "getLargestSeries",
  1798. value: function getLargestSeries() {
  1799. var w = this.w;
  1800. w.globals.maxValsInArrayIndex = w.globals.series.map(function (a) {
  1801. return a.length;
  1802. }).indexOf(Math.max.apply(Math, w.globals.series.map(function (a) {
  1803. return a.length;
  1804. })));
  1805. }
  1806. }, {
  1807. key: "getLargestMarkerSize",
  1808. value: function getLargestMarkerSize() {
  1809. var w = this.w;
  1810. var size = 0;
  1811. w.globals.markers.size.forEach(function (m) {
  1812. size = Math.max(size, m);
  1813. });
  1814. if (w.config.markers.discrete && w.config.markers.discrete.length) {
  1815. w.config.markers.discrete.forEach(function (m) {
  1816. size = Math.max(size, m.size);
  1817. });
  1818. }
  1819. if (size > 0) {
  1820. size += w.config.markers.hover.sizeOffset + 1;
  1821. }
  1822. w.globals.markers.largestSize = size;
  1823. return size;
  1824. }
  1825. /**
  1826. * @memberof Core
  1827. * returns the sum of all values in a series
  1828. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  1829. * @return [120, 11]
  1830. **/
  1831. }, {
  1832. key: "getSeriesTotals",
  1833. value: function getSeriesTotals() {
  1834. var w = this.w;
  1835. w.globals.seriesTotals = w.globals.series.map(function (ser, index) {
  1836. var total = 0;
  1837. if (Array.isArray(ser)) {
  1838. for (var j = 0; j < ser.length; j++) {
  1839. total += ser[j];
  1840. }
  1841. } else {
  1842. // for pie/donuts/gauges
  1843. total += ser;
  1844. }
  1845. return total;
  1846. });
  1847. }
  1848. }, {
  1849. key: "getSeriesTotalsXRange",
  1850. value: function getSeriesTotalsXRange(minX, maxX) {
  1851. var w = this.w;
  1852. var seriesTotalsXRange = w.globals.series.map(function (ser, index) {
  1853. var total = 0;
  1854. for (var j = 0; j < ser.length; j++) {
  1855. if (w.globals.seriesX[index][j] > minX && w.globals.seriesX[index][j] < maxX) {
  1856. total += ser[j];
  1857. }
  1858. }
  1859. return total;
  1860. });
  1861. return seriesTotalsXRange;
  1862. }
  1863. /**
  1864. * @memberof CoreUtils
  1865. * returns the percentage value of all individual values which can be used in a 100% stacked series
  1866. * Eg. w.globals.series = [[32, 33, 43, 12], [2, 3, 5, 1]]
  1867. * @return [[94.11, 91.66, 89.58, 92.30], [5.88, 8.33, 10.41, 7.7]]
  1868. **/
  1869. }, {
  1870. key: "getPercentSeries",
  1871. value: function getPercentSeries() {
  1872. var w = this.w;
  1873. w.globals.seriesPercent = w.globals.series.map(function (ser, index) {
  1874. var seriesPercent = [];
  1875. if (Array.isArray(ser)) {
  1876. for (var j = 0; j < ser.length; j++) {
  1877. var total = w.globals.stackedSeriesTotals[j];
  1878. var percent = 0;
  1879. if (total) {
  1880. percent = 100 * ser[j] / total;
  1881. }
  1882. seriesPercent.push(percent);
  1883. }
  1884. } else {
  1885. var _total = w.globals.seriesTotals.reduce(function (acc, val) {
  1886. return acc + val;
  1887. }, 0);
  1888. var _percent = 100 * ser / _total;
  1889. seriesPercent.push(_percent);
  1890. }
  1891. return seriesPercent;
  1892. });
  1893. }
  1894. }, {
  1895. key: "getCalculatedRatios",
  1896. value: function getCalculatedRatios() {
  1897. var gl = this.w.globals;
  1898. var yRatio = [];
  1899. var invertedYRatio = 0;
  1900. var xRatio = 0;
  1901. var initialXRatio = 0;
  1902. var invertedXRatio = 0;
  1903. var zRatio = 0;
  1904. var baseLineY = [];
  1905. var baseLineInvertedY = 0.1;
  1906. var baseLineX = 0;
  1907. gl.yRange = [];
  1908. if (gl.isMultipleYAxis) {
  1909. for (var i = 0; i < gl.minYArr.length; i++) {
  1910. gl.yRange.push(Math.abs(gl.minYArr[i] - gl.maxYArr[i]));
  1911. baseLineY.push(0);
  1912. }
  1913. } else {
  1914. gl.yRange.push(Math.abs(gl.minY - gl.maxY));
  1915. }
  1916. gl.xRange = Math.abs(gl.maxX - gl.minX);
  1917. gl.zRange = Math.abs(gl.maxZ - gl.minZ); // multiple y axis
  1918. for (var _i = 0; _i < gl.yRange.length; _i++) {
  1919. yRatio.push(gl.yRange[_i] / gl.gridHeight);
  1920. }
  1921. xRatio = gl.xRange / gl.gridWidth;
  1922. initialXRatio = Math.abs(gl.initialMaxX - gl.initialMinX) / gl.gridWidth;
  1923. invertedYRatio = gl.yRange / gl.gridWidth;
  1924. invertedXRatio = gl.xRange / gl.gridHeight;
  1925. zRatio = gl.zRange / gl.gridHeight * 16;
  1926. if (!zRatio) {
  1927. zRatio = 1;
  1928. }
  1929. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  1930. // Negative numbers present in series
  1931. gl.hasNegs = true;
  1932. }
  1933. if (gl.isMultipleYAxis) {
  1934. baseLineY = []; // baseline variables is the 0 of the yaxis which will be needed when there are negatives
  1935. for (var _i2 = 0; _i2 < yRatio.length; _i2++) {
  1936. baseLineY.push(-gl.minYArr[_i2] / yRatio[_i2]);
  1937. }
  1938. } else {
  1939. baseLineY.push(-gl.minY / yRatio[0]);
  1940. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  1941. baseLineInvertedY = -gl.minY / invertedYRatio; // this is for bar chart
  1942. baseLineX = gl.minX / xRatio;
  1943. }
  1944. }
  1945. return {
  1946. yRatio: yRatio,
  1947. invertedYRatio: invertedYRatio,
  1948. zRatio: zRatio,
  1949. xRatio: xRatio,
  1950. initialXRatio: initialXRatio,
  1951. invertedXRatio: invertedXRatio,
  1952. baseLineInvertedY: baseLineInvertedY,
  1953. baseLineY: baseLineY,
  1954. baseLineX: baseLineX
  1955. };
  1956. }
  1957. }, {
  1958. key: "getLogSeries",
  1959. value: function getLogSeries(series) {
  1960. var _this = this;
  1961. var w = this.w;
  1962. w.globals.seriesLog = series.map(function (s, i) {
  1963. if (w.config.yaxis[i] && w.config.yaxis[i].logarithmic) {
  1964. return s.map(function (d) {
  1965. if (d === null) return null;
  1966. return _this.getLogVal(w.config.yaxis[i].logBase, d, i);
  1967. });
  1968. } else {
  1969. return s;
  1970. }
  1971. });
  1972. return w.globals.invalidLogScale ? series : w.globals.seriesLog;
  1973. }
  1974. }, {
  1975. key: "getBaseLog",
  1976. value: function getBaseLog(base, value) {
  1977. return Math.log(value) / Math.log(base);
  1978. }
  1979. }, {
  1980. key: "getLogVal",
  1981. value: function getLogVal(b, d, yIndex) {
  1982. if (d === 0) {
  1983. return 0;
  1984. }
  1985. var w = this.w;
  1986. var min_log_val = w.globals.minYArr[yIndex] === 0 ? -1 // make sure we dont calculate log of 0
  1987. : this.getBaseLog(b, w.globals.minYArr[yIndex]);
  1988. var max_log_val = w.globals.maxYArr[yIndex] === 0 ? 0 // make sure we dont calculate log of 0
  1989. : this.getBaseLog(b, w.globals.maxYArr[yIndex]);
  1990. var number_of_height_levels = max_log_val - min_log_val;
  1991. if (d < 1) return d / number_of_height_levels;
  1992. var log_height_value = this.getBaseLog(b, d) - min_log_val;
  1993. return log_height_value / number_of_height_levels;
  1994. }
  1995. }, {
  1996. key: "getLogYRatios",
  1997. value: function getLogYRatios(yRatio) {
  1998. var _this2 = this;
  1999. var w = this.w;
  2000. var gl = this.w.globals;
  2001. gl.yLogRatio = yRatio.slice();
  2002. gl.logYRange = gl.yRange.map(function (yRange, i) {
  2003. if (w.config.yaxis[i] && _this2.w.config.yaxis[i].logarithmic) {
  2004. var maxY = -Number.MAX_VALUE;
  2005. var minY = Number.MIN_VALUE;
  2006. var range = 1;
  2007. gl.seriesLog.forEach(function (s, si) {
  2008. s.forEach(function (v) {
  2009. if (w.config.yaxis[si] && w.config.yaxis[si].logarithmic) {
  2010. maxY = Math.max(v, maxY);
  2011. minY = Math.min(v, minY);
  2012. }
  2013. });
  2014. });
  2015. range = Math.pow(gl.yRange[i], Math.abs(minY - maxY) / gl.yRange[i]);
  2016. gl.yLogRatio[i] = range / gl.gridHeight;
  2017. return range;
  2018. }
  2019. });
  2020. return gl.invalidLogScale ? yRatio.slice() : gl.yLogRatio;
  2021. } // Some config objects can be array - and we need to extend them correctly
  2022. }], [{
  2023. key: "checkComboSeries",
  2024. value: function checkComboSeries(series) {
  2025. var comboCharts = false;
  2026. var comboBarCount = 0;
  2027. var comboCount = 0; // if user specified a type in series too, turn on comboCharts flag
  2028. if (series.length && typeof series[0].type !== 'undefined') {
  2029. series.forEach(function (s) {
  2030. if (s.type === 'bar' || s.type === 'column' || s.type === 'candlestick' || s.type === 'boxPlot') {
  2031. comboBarCount++;
  2032. }
  2033. if (typeof s.type !== 'undefined') {
  2034. comboCount++;
  2035. }
  2036. });
  2037. }
  2038. if (comboCount > 0) {
  2039. comboCharts = true;
  2040. }
  2041. return {
  2042. comboBarCount: comboBarCount,
  2043. comboCharts: comboCharts
  2044. };
  2045. }
  2046. }, {
  2047. key: "extendArrayProps",
  2048. value: function extendArrayProps(configInstance, options, w) {
  2049. if (options.yaxis) {
  2050. options = configInstance.extendYAxis(options, w);
  2051. }
  2052. if (options.annotations) {
  2053. if (options.annotations.yaxis) {
  2054. options = configInstance.extendYAxisAnnotations(options);
  2055. }
  2056. if (options.annotations.xaxis) {
  2057. options = configInstance.extendXAxisAnnotations(options);
  2058. }
  2059. if (options.annotations.points) {
  2060. options = configInstance.extendPointAnnotations(options);
  2061. }
  2062. }
  2063. return options;
  2064. }
  2065. }]);
  2066. return CoreUtils;
  2067. }();
  2068. var Helpers$4 = /*#__PURE__*/function () {
  2069. function Helpers(annoCtx) {
  2070. _classCallCheck(this, Helpers);
  2071. this.w = annoCtx.w;
  2072. this.annoCtx = annoCtx;
  2073. }
  2074. _createClass(Helpers, [{
  2075. key: "setOrientations",
  2076. value: function setOrientations(anno) {
  2077. var annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2078. var w = this.w;
  2079. if (anno.label.orientation === 'vertical') {
  2080. var i = annoIndex !== null ? annoIndex : 0;
  2081. var xAnno = w.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(i, "']"));
  2082. if (xAnno !== null) {
  2083. var xAnnoCoord = xAnno.getBoundingClientRect();
  2084. xAnno.setAttribute('x', parseFloat(xAnno.getAttribute('x')) - xAnnoCoord.height + 4);
  2085. if (anno.label.position === 'top') {
  2086. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) + xAnnoCoord.width);
  2087. } else {
  2088. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) - xAnnoCoord.width);
  2089. }
  2090. var annoRotatingCenter = this.annoCtx.graphics.rotateAroundCenter(xAnno);
  2091. var x = annoRotatingCenter.x;
  2092. var y = annoRotatingCenter.y;
  2093. xAnno.setAttribute('transform', "rotate(-90 ".concat(x, " ").concat(y, ")"));
  2094. }
  2095. }
  2096. }
  2097. }, {
  2098. key: "addBackgroundToAnno",
  2099. value: function addBackgroundToAnno(annoEl, anno) {
  2100. var w = this.w;
  2101. if (!annoEl || typeof anno.label.text === 'undefined' || typeof anno.label.text !== 'undefined' && !String(anno.label.text).trim()) return null;
  2102. var elGridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid').getBoundingClientRect();
  2103. var coords = annoEl.getBoundingClientRect();
  2104. var pleft = anno.label.style.padding.left;
  2105. var pright = anno.label.style.padding.right;
  2106. var ptop = anno.label.style.padding.top;
  2107. var pbottom = anno.label.style.padding.bottom;
  2108. if (anno.label.orientation === 'vertical') {
  2109. ptop = anno.label.style.padding.left;
  2110. pbottom = anno.label.style.padding.right;
  2111. pleft = anno.label.style.padding.top;
  2112. pright = anno.label.style.padding.bottom;
  2113. }
  2114. var x1 = coords.left - elGridRect.left - pleft;
  2115. var y1 = coords.top - elGridRect.top - ptop;
  2116. var elRect = this.annoCtx.graphics.drawRect(x1 - w.globals.barPadForNumericAxis, y1, coords.width + pleft + pright, coords.height + ptop + pbottom, anno.label.borderRadius, anno.label.style.background, 1, anno.label.borderWidth, anno.label.borderColor, 0);
  2117. if (anno.id) {
  2118. // don't escapeString for this ID as it causes duplicate rects
  2119. elRect.node.classList.add(anno.id);
  2120. }
  2121. return elRect;
  2122. }
  2123. }, {
  2124. key: "annotationsBackground",
  2125. value: function annotationsBackground() {
  2126. var _this = this;
  2127. var w = this.w;
  2128. var add = function add(anno, i, type) {
  2129. var annoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(i, "']"));
  2130. if (annoLabel) {
  2131. var parent = annoLabel.parentNode;
  2132. var elRect = _this.addBackgroundToAnno(annoLabel, anno);
  2133. if (elRect) {
  2134. parent.insertBefore(elRect.node, annoLabel);
  2135. if (anno.label.mouseEnter) {
  2136. elRect.node.addEventListener('mouseenter', anno.label.mouseEnter.bind(_this, anno));
  2137. }
  2138. if (anno.label.mouseLeave) {
  2139. elRect.node.addEventListener('mouseleave', anno.label.mouseLeave.bind(_this, anno));
  2140. }
  2141. }
  2142. }
  2143. };
  2144. w.config.annotations.xaxis.map(function (anno, i) {
  2145. add(anno, i, 'xaxis');
  2146. });
  2147. w.config.annotations.yaxis.map(function (anno, i) {
  2148. add(anno, i, 'yaxis');
  2149. });
  2150. w.config.annotations.points.map(function (anno, i) {
  2151. add(anno, i, 'point');
  2152. });
  2153. }
  2154. }, {
  2155. key: "getY1Y2",
  2156. value: function getY1Y2(type, anno) {
  2157. var y = type === 'y1' ? anno.y : anno.y2;
  2158. var yP;
  2159. var w = this.w;
  2160. if (this.annoCtx.invertAxis) {
  2161. var catIndex = w.globals.labels.indexOf(y);
  2162. if (w.config.xaxis.convertedCatToNumeric) {
  2163. catIndex = w.globals.categoryLabels.indexOf(y);
  2164. }
  2165. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  2166. if (xLabel) {
  2167. yP = parseFloat(xLabel.getAttribute('y'));
  2168. }
  2169. } else {
  2170. var yPos;
  2171. if (w.config.yaxis[anno.yAxisIndex].logarithmic) {
  2172. var coreUtils = new CoreUtils(this.annoCtx.ctx);
  2173. y = coreUtils.getLogVal(y, anno.yAxisIndex);
  2174. yPos = y / w.globals.yLogRatio[anno.yAxisIndex];
  2175. } else {
  2176. yPos = (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  2177. }
  2178. yP = w.globals.gridHeight - yPos;
  2179. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  2180. yP = yPos;
  2181. }
  2182. }
  2183. return yP;
  2184. }
  2185. }, {
  2186. key: "getX1X2",
  2187. value: function getX1X2(type, anno) {
  2188. var w = this.w;
  2189. var min = this.annoCtx.invertAxis ? w.globals.minY : w.globals.minX;
  2190. var max = this.annoCtx.invertAxis ? w.globals.maxY : w.globals.maxX;
  2191. var range = this.annoCtx.invertAxis ? w.globals.yRange[0] : w.globals.xRange;
  2192. var x1 = (anno.x - min) / (range / w.globals.gridWidth);
  2193. if (this.annoCtx.inversedReversedAxis) {
  2194. x1 = (max - anno.x) / (range / w.globals.gridWidth);
  2195. }
  2196. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.annoCtx.invertAxis && !w.globals.dataFormatXNumeric) {
  2197. x1 = this.getStringX(anno.x);
  2198. }
  2199. var x2 = (anno.x2 - min) / (range / w.globals.gridWidth);
  2200. if (this.annoCtx.inversedReversedAxis) {
  2201. x2 = (max - anno.x2) / (range / w.globals.gridWidth);
  2202. }
  2203. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.annoCtx.invertAxis && !w.globals.dataFormatXNumeric) {
  2204. x2 = this.getStringX(anno.x2);
  2205. }
  2206. return type === 'x1' ? x1 : x2;
  2207. }
  2208. }, {
  2209. key: "getStringX",
  2210. value: function getStringX(x) {
  2211. var w = this.w;
  2212. var rX = x;
  2213. if (w.config.xaxis.convertedCatToNumeric && w.globals.categoryLabels.length) {
  2214. x = w.globals.categoryLabels.indexOf(x) + 1;
  2215. }
  2216. var catIndex = w.globals.labels.indexOf(x);
  2217. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  2218. if (xLabel) {
  2219. rX = parseFloat(xLabel.getAttribute('x'));
  2220. }
  2221. return rX;
  2222. }
  2223. }]);
  2224. return Helpers;
  2225. }();
  2226. var XAnnotations = /*#__PURE__*/function () {
  2227. function XAnnotations(annoCtx) {
  2228. _classCallCheck(this, XAnnotations);
  2229. this.w = annoCtx.w;
  2230. this.annoCtx = annoCtx;
  2231. this.invertAxis = this.annoCtx.invertAxis;
  2232. this.helpers = new Helpers$4(this.annoCtx);
  2233. }
  2234. _createClass(XAnnotations, [{
  2235. key: "addXaxisAnnotation",
  2236. value: function addXaxisAnnotation(anno, parent, index) {
  2237. var w = this.w;
  2238. var x1 = this.helpers.getX1X2('x1', anno);
  2239. var x2;
  2240. var text = anno.label.text;
  2241. var strokeDashArray = anno.strokeDashArray;
  2242. if (!Utils$1.isNumber(x1)) return;
  2243. if (anno.x2 === null || typeof anno.x2 === 'undefined') {
  2244. var line = this.annoCtx.graphics.drawLine(x1 + anno.offsetX, // x1
  2245. 0 + anno.offsetY, // y1
  2246. x1 + anno.offsetX, // x2
  2247. w.globals.gridHeight + anno.offsetY, // y2
  2248. anno.borderColor, // lineColor
  2249. strokeDashArray, //dashArray
  2250. anno.borderWidth);
  2251. parent.appendChild(line.node);
  2252. if (anno.id) {
  2253. line.node.classList.add(anno.id);
  2254. }
  2255. } else {
  2256. x2 = this.helpers.getX1X2('x2', anno);
  2257. if (x2 < x1) {
  2258. var temp = x1;
  2259. x1 = x2;
  2260. x2 = temp;
  2261. }
  2262. var rect = this.annoCtx.graphics.drawRect(x1 + anno.offsetX, // x1
  2263. 0 + anno.offsetY, // y1
  2264. x2 - x1, // x2
  2265. w.globals.gridHeight + anno.offsetY, // y2
  2266. 0, // radius
  2267. anno.fillColor, // color
  2268. anno.opacity, // opacity,
  2269. 1, // strokeWidth
  2270. anno.borderColor, // strokeColor
  2271. strokeDashArray // stokeDashArray
  2272. );
  2273. rect.node.classList.add('apexcharts-annotation-rect');
  2274. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  2275. parent.appendChild(rect.node);
  2276. if (anno.id) {
  2277. rect.node.classList.add(anno.id);
  2278. }
  2279. }
  2280. var textY = anno.label.position === 'top' ? 4 : w.globals.gridHeight;
  2281. var textRects = this.annoCtx.graphics.getTextRects(text, parseFloat(anno.label.style.fontSize));
  2282. var elText = this.annoCtx.graphics.drawText({
  2283. x: x1 + anno.label.offsetX,
  2284. y: textY + anno.label.offsetY - (anno.label.orientation === 'vertical' ? anno.label.position === 'top' ? textRects.width / 2 - 12 : -textRects.width / 2 : 0),
  2285. text: text,
  2286. textAnchor: anno.label.textAnchor,
  2287. fontSize: anno.label.style.fontSize,
  2288. fontFamily: anno.label.style.fontFamily,
  2289. fontWeight: anno.label.style.fontWeight,
  2290. foreColor: anno.label.style.color,
  2291. cssClass: "apexcharts-xaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2292. });
  2293. elText.attr({
  2294. rel: index
  2295. });
  2296. parent.appendChild(elText.node); // after placing the annotations on svg, set any vertically placed annotations
  2297. this.annoCtx.helpers.setOrientations(anno, index);
  2298. }
  2299. }, {
  2300. key: "drawXAxisAnnotations",
  2301. value: function drawXAxisAnnotations() {
  2302. var _this = this;
  2303. var w = this.w;
  2304. var elg = this.annoCtx.graphics.group({
  2305. class: 'apexcharts-xaxis-annotations'
  2306. });
  2307. w.config.annotations.xaxis.map(function (anno, index) {
  2308. _this.addXaxisAnnotation(anno, elg.node, index);
  2309. });
  2310. return elg;
  2311. }
  2312. }]);
  2313. return XAnnotations;
  2314. }();
  2315. var YAnnotations = /*#__PURE__*/function () {
  2316. function YAnnotations(annoCtx) {
  2317. _classCallCheck(this, YAnnotations);
  2318. this.w = annoCtx.w;
  2319. this.annoCtx = annoCtx;
  2320. this.helpers = new Helpers$4(this.annoCtx);
  2321. }
  2322. _createClass(YAnnotations, [{
  2323. key: "addYaxisAnnotation",
  2324. value: function addYaxisAnnotation(anno, parent, index) {
  2325. var w = this.w;
  2326. var strokeDashArray = anno.strokeDashArray;
  2327. var y1 = this.helpers.getY1Y2('y1', anno);
  2328. var y2;
  2329. var text = anno.label.text;
  2330. if (anno.y2 === null || typeof anno.y2 === 'undefined') {
  2331. var line = this.annoCtx.graphics.drawLine(0 + anno.offsetX, // x1
  2332. y1 + anno.offsetY, // y1
  2333. this._getYAxisAnnotationWidth(anno), // x2
  2334. y1 + anno.offsetY, // y2
  2335. anno.borderColor, // lineColor
  2336. strokeDashArray, // dashArray
  2337. anno.borderWidth);
  2338. parent.appendChild(line.node);
  2339. if (anno.id) {
  2340. line.node.classList.add(anno.id);
  2341. }
  2342. } else {
  2343. y2 = this.helpers.getY1Y2('y2', anno);
  2344. if (y2 > y1) {
  2345. var temp = y1;
  2346. y1 = y2;
  2347. y2 = temp;
  2348. }
  2349. var rect = this.annoCtx.graphics.drawRect(0 + anno.offsetX, // x1
  2350. y2 + anno.offsetY, // y1
  2351. this._getYAxisAnnotationWidth(anno), // x2
  2352. y1 - y2, // y2
  2353. 0, // radius
  2354. anno.fillColor, // color
  2355. anno.opacity, // opacity,
  2356. 1, // strokeWidth
  2357. anno.borderColor, // strokeColor
  2358. strokeDashArray // stokeDashArray
  2359. );
  2360. rect.node.classList.add('apexcharts-annotation-rect');
  2361. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  2362. parent.appendChild(rect.node);
  2363. if (anno.id) {
  2364. rect.node.classList.add(anno.id);
  2365. }
  2366. }
  2367. var textX = anno.label.position === 'right' ? w.globals.gridWidth : 0;
  2368. var elText = this.annoCtx.graphics.drawText({
  2369. x: textX + anno.label.offsetX,
  2370. y: (y2 != null ? y2 : y1) + anno.label.offsetY - 3,
  2371. text: text,
  2372. textAnchor: anno.label.textAnchor,
  2373. fontSize: anno.label.style.fontSize,
  2374. fontFamily: anno.label.style.fontFamily,
  2375. fontWeight: anno.label.style.fontWeight,
  2376. foreColor: anno.label.style.color,
  2377. cssClass: "apexcharts-yaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2378. });
  2379. elText.attr({
  2380. rel: index
  2381. });
  2382. parent.appendChild(elText.node);
  2383. }
  2384. }, {
  2385. key: "_getYAxisAnnotationWidth",
  2386. value: function _getYAxisAnnotationWidth(anno) {
  2387. // issue apexcharts.js#2009
  2388. var w = this.w;
  2389. var width = w.globals.gridWidth;
  2390. if (anno.width.indexOf('%') > -1) {
  2391. width = w.globals.gridWidth * parseInt(anno.width, 10) / 100;
  2392. } else {
  2393. width = parseInt(anno.width, 10);
  2394. }
  2395. return width + anno.offsetX;
  2396. }
  2397. }, {
  2398. key: "drawYAxisAnnotations",
  2399. value: function drawYAxisAnnotations() {
  2400. var _this = this;
  2401. var w = this.w;
  2402. var elg = this.annoCtx.graphics.group({
  2403. class: 'apexcharts-yaxis-annotations'
  2404. });
  2405. w.config.annotations.yaxis.map(function (anno, index) {
  2406. _this.addYaxisAnnotation(anno, elg.node, index);
  2407. });
  2408. return elg;
  2409. }
  2410. }]);
  2411. return YAnnotations;
  2412. }();
  2413. var PointAnnotations = /*#__PURE__*/function () {
  2414. function PointAnnotations(annoCtx) {
  2415. _classCallCheck(this, PointAnnotations);
  2416. this.w = annoCtx.w;
  2417. this.annoCtx = annoCtx;
  2418. this.helpers = new Helpers$4(this.annoCtx);
  2419. }
  2420. _createClass(PointAnnotations, [{
  2421. key: "addPointAnnotation",
  2422. value: function addPointAnnotation(anno, parent, index) {
  2423. this.w;
  2424. var x = this.helpers.getX1X2('x1', anno);
  2425. var y = this.helpers.getY1Y2('y1', anno);
  2426. if (!Utils$1.isNumber(x)) return;
  2427. var optsPoints = {
  2428. pSize: anno.marker.size,
  2429. pointStrokeWidth: anno.marker.strokeWidth,
  2430. pointFillColor: anno.marker.fillColor,
  2431. pointStrokeColor: anno.marker.strokeColor,
  2432. shape: anno.marker.shape,
  2433. pRadius: anno.marker.radius,
  2434. class: "apexcharts-point-annotation-marker ".concat(anno.marker.cssClass, " ").concat(anno.id ? anno.id : '')
  2435. };
  2436. var point = this.annoCtx.graphics.drawMarker(x + anno.marker.offsetX, y + anno.marker.offsetY, optsPoints);
  2437. parent.appendChild(point.node);
  2438. var text = anno.label.text ? anno.label.text : '';
  2439. var elText = this.annoCtx.graphics.drawText({
  2440. x: x + anno.label.offsetX,
  2441. y: y + anno.label.offsetY - anno.marker.size - parseFloat(anno.label.style.fontSize) / 1.6,
  2442. text: text,
  2443. textAnchor: anno.label.textAnchor,
  2444. fontSize: anno.label.style.fontSize,
  2445. fontFamily: anno.label.style.fontFamily,
  2446. fontWeight: anno.label.style.fontWeight,
  2447. foreColor: anno.label.style.color,
  2448. cssClass: "apexcharts-point-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2449. });
  2450. elText.attr({
  2451. rel: index
  2452. });
  2453. parent.appendChild(elText.node); // TODO: deprecate this as we will use custom
  2454. if (anno.customSVG.SVG) {
  2455. var g = this.annoCtx.graphics.group({
  2456. class: 'apexcharts-point-annotations-custom-svg ' + anno.customSVG.cssClass
  2457. });
  2458. g.attr({
  2459. transform: "translate(".concat(x + anno.customSVG.offsetX, ", ").concat(y + anno.customSVG.offsetY, ")")
  2460. });
  2461. g.node.innerHTML = anno.customSVG.SVG;
  2462. parent.appendChild(g.node);
  2463. }
  2464. if (anno.image.path) {
  2465. var imgWidth = anno.image.width ? anno.image.width : 20;
  2466. var imgHeight = anno.image.height ? anno.image.height : 20;
  2467. point = this.annoCtx.addImage({
  2468. x: x + anno.image.offsetX - imgWidth / 2,
  2469. y: y + anno.image.offsetY - imgHeight / 2,
  2470. width: imgWidth,
  2471. height: imgHeight,
  2472. path: anno.image.path,
  2473. appendTo: '.apexcharts-point-annotations'
  2474. });
  2475. }
  2476. if (anno.mouseEnter) {
  2477. point.node.addEventListener('mouseenter', anno.mouseEnter.bind(this, anno));
  2478. }
  2479. if (anno.mouseLeave) {
  2480. point.node.addEventListener('mouseleave', anno.mouseLeave.bind(this, anno));
  2481. }
  2482. }
  2483. }, {
  2484. key: "drawPointAnnotations",
  2485. value: function drawPointAnnotations() {
  2486. var _this = this;
  2487. var w = this.w;
  2488. var elg = this.annoCtx.graphics.group({
  2489. class: 'apexcharts-point-annotations'
  2490. });
  2491. w.config.annotations.points.map(function (anno, index) {
  2492. _this.addPointAnnotation(anno, elg.node, index);
  2493. });
  2494. return elg;
  2495. }
  2496. }]);
  2497. return PointAnnotations;
  2498. }();
  2499. const name = "en";
  2500. const options = {
  2501. months: [
  2502. "January",
  2503. "February",
  2504. "March",
  2505. "April",
  2506. "May",
  2507. "June",
  2508. "July",
  2509. "August",
  2510. "September",
  2511. "October",
  2512. "November",
  2513. "December"
  2514. ],
  2515. shortMonths: [
  2516. "Jan",
  2517. "Feb",
  2518. "Mar",
  2519. "Apr",
  2520. "May",
  2521. "Jun",
  2522. "Jul",
  2523. "Aug",
  2524. "Sep",
  2525. "Oct",
  2526. "Nov",
  2527. "Dec"
  2528. ],
  2529. days: [
  2530. "Sunday",
  2531. "Monday",
  2532. "Tuesday",
  2533. "Wednesday",
  2534. "Thursday",
  2535. "Friday",
  2536. "Saturday"
  2537. ],
  2538. shortDays: [
  2539. "Sun",
  2540. "Mon",
  2541. "Tue",
  2542. "Wed",
  2543. "Thu",
  2544. "Fri",
  2545. "Sat"
  2546. ],
  2547. toolbar: {
  2548. exportToSVG: "Download SVG",
  2549. exportToPNG: "Download PNG",
  2550. exportToCSV: "Download CSV",
  2551. menu: "Menu",
  2552. selection: "Selection",
  2553. selectionZoom: "Selection Zoom",
  2554. zoomIn: "Zoom In",
  2555. zoomOut: "Zoom Out",
  2556. pan: "Panning",
  2557. reset: "Reset Zoom"
  2558. }
  2559. };
  2560. var en = {
  2561. name: name,
  2562. options: options
  2563. };
  2564. var Options = /*#__PURE__*/function () {
  2565. function Options() {
  2566. _classCallCheck(this, Options);
  2567. this.yAxis = {
  2568. show: true,
  2569. showAlways: false,
  2570. showForNullSeries: true,
  2571. seriesName: undefined,
  2572. opposite: false,
  2573. reversed: false,
  2574. logarithmic: false,
  2575. logBase: 10,
  2576. tickAmount: undefined,
  2577. forceNiceScale: false,
  2578. max: undefined,
  2579. min: undefined,
  2580. floating: false,
  2581. decimalsInFloat: undefined,
  2582. labels: {
  2583. show: true,
  2584. minWidth: 0,
  2585. maxWidth: 160,
  2586. offsetX: 0,
  2587. offsetY: 0,
  2588. align: undefined,
  2589. rotate: 0,
  2590. padding: 20,
  2591. style: {
  2592. colors: [],
  2593. fontSize: '11px',
  2594. fontWeight: 400,
  2595. fontFamily: undefined,
  2596. cssClass: ''
  2597. },
  2598. formatter: undefined
  2599. },
  2600. axisBorder: {
  2601. show: false,
  2602. color: '#e0e0e0',
  2603. width: 1,
  2604. offsetX: 0,
  2605. offsetY: 0
  2606. },
  2607. axisTicks: {
  2608. show: false,
  2609. color: '#e0e0e0',
  2610. width: 6,
  2611. offsetX: 0,
  2612. offsetY: 0
  2613. },
  2614. title: {
  2615. text: undefined,
  2616. rotate: -90,
  2617. offsetY: 0,
  2618. offsetX: 0,
  2619. style: {
  2620. color: undefined,
  2621. fontSize: '11px',
  2622. fontWeight: 900,
  2623. fontFamily: undefined,
  2624. cssClass: ''
  2625. }
  2626. },
  2627. tooltip: {
  2628. enabled: false,
  2629. offsetX: 0
  2630. },
  2631. crosshairs: {
  2632. show: true,
  2633. position: 'front',
  2634. stroke: {
  2635. color: '#b6b6b6',
  2636. width: 1,
  2637. dashArray: 0
  2638. }
  2639. }
  2640. };
  2641. this.pointAnnotation = {
  2642. id: undefined,
  2643. x: 0,
  2644. y: null,
  2645. yAxisIndex: 0,
  2646. seriesIndex: 0,
  2647. mouseEnter: undefined,
  2648. mouseLeave: undefined,
  2649. marker: {
  2650. size: 4,
  2651. fillColor: '#fff',
  2652. strokeWidth: 2,
  2653. strokeColor: '#333',
  2654. shape: 'circle',
  2655. offsetX: 0,
  2656. offsetY: 0,
  2657. radius: 2,
  2658. cssClass: ''
  2659. },
  2660. label: {
  2661. borderColor: '#c2c2c2',
  2662. borderWidth: 1,
  2663. borderRadius: 2,
  2664. text: undefined,
  2665. textAnchor: 'middle',
  2666. offsetX: 0,
  2667. offsetY: 0,
  2668. mouseEnter: undefined,
  2669. mouseLeave: undefined,
  2670. style: {
  2671. background: '#fff',
  2672. color: undefined,
  2673. fontSize: '11px',
  2674. fontFamily: undefined,
  2675. fontWeight: 400,
  2676. cssClass: '',
  2677. padding: {
  2678. left: 5,
  2679. right: 5,
  2680. top: 2,
  2681. bottom: 2
  2682. }
  2683. }
  2684. },
  2685. customSVG: {
  2686. // this will be deprecated in the next major version as it is going to be replaced with a better alternative below
  2687. SVG: undefined,
  2688. cssClass: undefined,
  2689. offsetX: 0,
  2690. offsetY: 0
  2691. },
  2692. image: {
  2693. path: undefined,
  2694. width: 20,
  2695. height: 20,
  2696. offsetX: 0,
  2697. offsetY: 0
  2698. }
  2699. };
  2700. this.yAxisAnnotation = {
  2701. id: undefined,
  2702. y: 0,
  2703. y2: null,
  2704. strokeDashArray: 1,
  2705. fillColor: '#c2c2c2',
  2706. borderColor: '#c2c2c2',
  2707. borderWidth: 1,
  2708. opacity: 0.3,
  2709. offsetX: 0,
  2710. offsetY: 0,
  2711. width: '100%',
  2712. yAxisIndex: 0,
  2713. label: {
  2714. borderColor: '#c2c2c2',
  2715. borderWidth: 1,
  2716. borderRadius: 2,
  2717. text: undefined,
  2718. textAnchor: 'end',
  2719. position: 'right',
  2720. offsetX: 0,
  2721. offsetY: -3,
  2722. mouseEnter: undefined,
  2723. mouseLeave: undefined,
  2724. style: {
  2725. background: '#fff',
  2726. color: undefined,
  2727. fontSize: '11px',
  2728. fontFamily: undefined,
  2729. fontWeight: 400,
  2730. cssClass: '',
  2731. padding: {
  2732. left: 5,
  2733. right: 5,
  2734. top: 2,
  2735. bottom: 2
  2736. }
  2737. }
  2738. }
  2739. };
  2740. this.xAxisAnnotation = {
  2741. id: undefined,
  2742. x: 0,
  2743. x2: null,
  2744. strokeDashArray: 1,
  2745. fillColor: '#c2c2c2',
  2746. borderColor: '#c2c2c2',
  2747. borderWidth: 1,
  2748. opacity: 0.3,
  2749. offsetX: 0,
  2750. offsetY: 0,
  2751. label: {
  2752. borderColor: '#c2c2c2',
  2753. borderWidth: 1,
  2754. borderRadius: 2,
  2755. text: undefined,
  2756. textAnchor: 'middle',
  2757. orientation: 'vertical',
  2758. position: 'top',
  2759. offsetX: 0,
  2760. offsetY: 0,
  2761. mouseEnter: undefined,
  2762. mouseLeave: undefined,
  2763. style: {
  2764. background: '#fff',
  2765. color: undefined,
  2766. fontSize: '11px',
  2767. fontFamily: undefined,
  2768. fontWeight: 400,
  2769. cssClass: '',
  2770. padding: {
  2771. left: 5,
  2772. right: 5,
  2773. top: 2,
  2774. bottom: 2
  2775. }
  2776. }
  2777. }
  2778. };
  2779. this.text = {
  2780. x: 0,
  2781. y: 0,
  2782. text: '',
  2783. textAnchor: 'start',
  2784. foreColor: undefined,
  2785. fontSize: '13px',
  2786. fontFamily: undefined,
  2787. fontWeight: 400,
  2788. appendTo: '.apexcharts-annotations',
  2789. backgroundColor: 'transparent',
  2790. borderColor: '#c2c2c2',
  2791. borderRadius: 0,
  2792. borderWidth: 0,
  2793. paddingLeft: 4,
  2794. paddingRight: 4,
  2795. paddingTop: 2,
  2796. paddingBottom: 2
  2797. };
  2798. }
  2799. _createClass(Options, [{
  2800. key: "init",
  2801. value: function init() {
  2802. return {
  2803. annotations: {
  2804. position: 'front',
  2805. yaxis: [this.yAxisAnnotation],
  2806. xaxis: [this.xAxisAnnotation],
  2807. points: [this.pointAnnotation],
  2808. texts: [],
  2809. images: [],
  2810. shapes: []
  2811. },
  2812. chart: {
  2813. animations: {
  2814. enabled: true,
  2815. easing: 'easeinout',
  2816. // linear, easeout, easein, easeinout, swing, bounce, elastic
  2817. speed: 800,
  2818. animateGradually: {
  2819. delay: 150,
  2820. enabled: true
  2821. },
  2822. dynamicAnimation: {
  2823. enabled: true,
  2824. speed: 350
  2825. }
  2826. },
  2827. background: 'transparent',
  2828. locales: [en],
  2829. defaultLocale: 'en',
  2830. dropShadow: {
  2831. enabled: false,
  2832. enabledOnSeries: undefined,
  2833. top: 2,
  2834. left: 2,
  2835. blur: 4,
  2836. color: '#000',
  2837. opacity: 0.35
  2838. },
  2839. events: {
  2840. animationEnd: undefined,
  2841. beforeMount: undefined,
  2842. mounted: undefined,
  2843. updated: undefined,
  2844. click: undefined,
  2845. mouseMove: undefined,
  2846. mouseLeave: undefined,
  2847. legendClick: undefined,
  2848. markerClick: undefined,
  2849. selection: undefined,
  2850. dataPointSelection: undefined,
  2851. dataPointMouseEnter: undefined,
  2852. dataPointMouseLeave: undefined,
  2853. beforeZoom: undefined,
  2854. beforeResetZoom: undefined,
  2855. zoomed: undefined,
  2856. scrolled: undefined,
  2857. brushScrolled: undefined
  2858. },
  2859. foreColor: '#373d3f',
  2860. fontFamily: 'Helvetica, Arial, sans-serif',
  2861. height: 'auto',
  2862. parentHeightOffset: 15,
  2863. redrawOnParentResize: true,
  2864. redrawOnWindowResize: true,
  2865. id: undefined,
  2866. group: undefined,
  2867. offsetX: 0,
  2868. offsetY: 0,
  2869. selection: {
  2870. enabled: false,
  2871. type: 'x',
  2872. // selectedPoints: undefined, // default datapoints that should be selected automatically
  2873. fill: {
  2874. color: '#24292e',
  2875. opacity: 0.1
  2876. },
  2877. stroke: {
  2878. width: 1,
  2879. color: '#24292e',
  2880. opacity: 0.4,
  2881. dashArray: 3
  2882. },
  2883. xaxis: {
  2884. min: undefined,
  2885. max: undefined
  2886. },
  2887. yaxis: {
  2888. min: undefined,
  2889. max: undefined
  2890. }
  2891. },
  2892. sparkline: {
  2893. enabled: false
  2894. },
  2895. brush: {
  2896. enabled: false,
  2897. autoScaleYaxis: true,
  2898. target: undefined
  2899. },
  2900. stacked: false,
  2901. stackType: 'normal',
  2902. toolbar: {
  2903. show: true,
  2904. offsetX: 0,
  2905. offsetY: 0,
  2906. tools: {
  2907. download: true,
  2908. selection: true,
  2909. zoom: true,
  2910. zoomin: true,
  2911. zoomout: true,
  2912. pan: true,
  2913. reset: true,
  2914. customIcons: []
  2915. },
  2916. export: {
  2917. csv: {
  2918. filename: undefined,
  2919. columnDelimiter: ',',
  2920. headerCategory: 'category',
  2921. headerValue: 'value',
  2922. dateFormatter: function dateFormatter(timestamp) {
  2923. return new Date(timestamp).toDateString();
  2924. }
  2925. },
  2926. png: {
  2927. filename: undefined
  2928. },
  2929. svg: {
  2930. filename: undefined
  2931. }
  2932. },
  2933. autoSelected: 'zoom' // accepts -> zoom, pan, selection
  2934. },
  2935. type: 'line',
  2936. width: '100%',
  2937. zoom: {
  2938. enabled: true,
  2939. type: 'x',
  2940. autoScaleYaxis: false,
  2941. zoomedArea: {
  2942. fill: {
  2943. color: '#90CAF9',
  2944. opacity: 0.4
  2945. },
  2946. stroke: {
  2947. color: '#0D47A1',
  2948. opacity: 0.4,
  2949. width: 1
  2950. }
  2951. }
  2952. }
  2953. },
  2954. plotOptions: {
  2955. area: {
  2956. fillTo: 'origin'
  2957. },
  2958. bar: {
  2959. horizontal: false,
  2960. columnWidth: '70%',
  2961. // should be in percent 0 - 100
  2962. barHeight: '70%',
  2963. // should be in percent 0 - 100
  2964. distributed: false,
  2965. borderRadius: 0,
  2966. rangeBarOverlap: true,
  2967. rangeBarGroupRows: false,
  2968. colors: {
  2969. ranges: [],
  2970. backgroundBarColors: [],
  2971. backgroundBarOpacity: 1,
  2972. backgroundBarRadius: 0
  2973. },
  2974. dataLabels: {
  2975. position: 'top',
  2976. // top, center, bottom
  2977. maxItems: 100,
  2978. hideOverflowingLabels: true,
  2979. orientation: 'horizontal' // TODO: provide stackedLabels for stacked charts which gives additions of values
  2980. }
  2981. },
  2982. bubble: {
  2983. minBubbleRadius: undefined,
  2984. maxBubbleRadius: undefined
  2985. },
  2986. candlestick: {
  2987. colors: {
  2988. upward: '#00B746',
  2989. downward: '#EF403C'
  2990. },
  2991. wick: {
  2992. useFillColor: true
  2993. }
  2994. },
  2995. boxPlot: {
  2996. colors: {
  2997. upper: '#00E396',
  2998. lower: '#008FFB'
  2999. }
  3000. },
  3001. heatmap: {
  3002. radius: 2,
  3003. enableShades: true,
  3004. shadeIntensity: 0.5,
  3005. reverseNegativeShade: false,
  3006. distributed: false,
  3007. useFillColorAsStroke: false,
  3008. colorScale: {
  3009. inverse: false,
  3010. ranges: [],
  3011. min: undefined,
  3012. max: undefined
  3013. }
  3014. },
  3015. treemap: {
  3016. enableShades: true,
  3017. shadeIntensity: 0.5,
  3018. distributed: false,
  3019. reverseNegativeShade: false,
  3020. useFillColorAsStroke: false,
  3021. colorScale: {
  3022. inverse: false,
  3023. ranges: [],
  3024. min: undefined,
  3025. max: undefined
  3026. }
  3027. },
  3028. radialBar: {
  3029. inverseOrder: false,
  3030. startAngle: 0,
  3031. endAngle: 360,
  3032. offsetX: 0,
  3033. offsetY: 0,
  3034. hollow: {
  3035. margin: 5,
  3036. size: '50%',
  3037. background: 'transparent',
  3038. image: undefined,
  3039. imageWidth: 150,
  3040. imageHeight: 150,
  3041. imageOffsetX: 0,
  3042. imageOffsetY: 0,
  3043. imageClipped: true,
  3044. position: 'front',
  3045. dropShadow: {
  3046. enabled: false,
  3047. top: 0,
  3048. left: 0,
  3049. blur: 3,
  3050. color: '#000',
  3051. opacity: 0.5
  3052. }
  3053. },
  3054. track: {
  3055. show: true,
  3056. startAngle: undefined,
  3057. endAngle: undefined,
  3058. background: '#f2f2f2',
  3059. strokeWidth: '97%',
  3060. opacity: 1,
  3061. margin: 5,
  3062. // margin is in pixels
  3063. dropShadow: {
  3064. enabled: false,
  3065. top: 0,
  3066. left: 0,
  3067. blur: 3,
  3068. color: '#000',
  3069. opacity: 0.5
  3070. }
  3071. },
  3072. dataLabels: {
  3073. show: true,
  3074. name: {
  3075. show: true,
  3076. fontSize: '16px',
  3077. fontFamily: undefined,
  3078. fontWeight: 600,
  3079. color: undefined,
  3080. offsetY: 0,
  3081. formatter: function formatter(val) {
  3082. return val;
  3083. }
  3084. },
  3085. value: {
  3086. show: true,
  3087. fontSize: '14px',
  3088. fontFamily: undefined,
  3089. fontWeight: 400,
  3090. color: undefined,
  3091. offsetY: 16,
  3092. formatter: function formatter(val) {
  3093. return val + '%';
  3094. }
  3095. },
  3096. total: {
  3097. show: false,
  3098. label: 'Total',
  3099. fontSize: '16px',
  3100. fontWeight: 600,
  3101. fontFamily: undefined,
  3102. color: undefined,
  3103. formatter: function formatter(w) {
  3104. return w.globals.seriesTotals.reduce(function (a, b) {
  3105. return a + b;
  3106. }, 0) / w.globals.series.length + '%';
  3107. }
  3108. }
  3109. }
  3110. },
  3111. pie: {
  3112. customScale: 1,
  3113. offsetX: 0,
  3114. offsetY: 0,
  3115. startAngle: 0,
  3116. endAngle: 360,
  3117. expandOnClick: true,
  3118. dataLabels: {
  3119. // These are the percentage values which are displayed on slice
  3120. offset: 0,
  3121. // offset by which labels will move outside
  3122. minAngleToShowLabel: 10
  3123. },
  3124. donut: {
  3125. size: '65%',
  3126. background: 'transparent',
  3127. labels: {
  3128. // These are the inner labels appearing inside donut
  3129. show: false,
  3130. name: {
  3131. show: true,
  3132. fontSize: '16px',
  3133. fontFamily: undefined,
  3134. fontWeight: 600,
  3135. color: undefined,
  3136. offsetY: -10,
  3137. formatter: function formatter(val) {
  3138. return val;
  3139. }
  3140. },
  3141. value: {
  3142. show: true,
  3143. fontSize: '20px',
  3144. fontFamily: undefined,
  3145. fontWeight: 400,
  3146. color: undefined,
  3147. offsetY: 10,
  3148. formatter: function formatter(val) {
  3149. return val;
  3150. }
  3151. },
  3152. total: {
  3153. show: false,
  3154. showAlways: false,
  3155. label: 'Total',
  3156. fontSize: '16px',
  3157. fontWeight: 400,
  3158. fontFamily: undefined,
  3159. color: undefined,
  3160. formatter: function formatter(w) {
  3161. return w.globals.seriesTotals.reduce(function (a, b) {
  3162. return a + b;
  3163. }, 0);
  3164. }
  3165. }
  3166. }
  3167. }
  3168. },
  3169. polarArea: {
  3170. rings: {
  3171. strokeWidth: 1,
  3172. strokeColor: '#e8e8e8'
  3173. },
  3174. spokes: {
  3175. strokeWidth: 1,
  3176. connectorColors: '#e8e8e8'
  3177. }
  3178. },
  3179. radar: {
  3180. size: undefined,
  3181. offsetX: 0,
  3182. offsetY: 0,
  3183. polygons: {
  3184. // strokeColor: '#e8e8e8', // should be deprecated in the minor version i.e 3.2
  3185. strokeWidth: 1,
  3186. strokeColors: '#e8e8e8',
  3187. connectorColors: '#e8e8e8',
  3188. fill: {
  3189. colors: undefined
  3190. }
  3191. }
  3192. }
  3193. },
  3194. colors: undefined,
  3195. dataLabels: {
  3196. enabled: true,
  3197. enabledOnSeries: undefined,
  3198. formatter: function formatter(val) {
  3199. return val !== null ? val : '';
  3200. },
  3201. textAnchor: 'middle',
  3202. distributed: false,
  3203. offsetX: 0,
  3204. offsetY: 0,
  3205. style: {
  3206. fontSize: '12px',
  3207. fontFamily: undefined,
  3208. fontWeight: 600,
  3209. colors: undefined
  3210. },
  3211. background: {
  3212. enabled: true,
  3213. foreColor: '#fff',
  3214. borderRadius: 2,
  3215. padding: 4,
  3216. opacity: 0.9,
  3217. borderWidth: 1,
  3218. borderColor: '#fff',
  3219. dropShadow: {
  3220. enabled: false,
  3221. top: 1,
  3222. left: 1,
  3223. blur: 1,
  3224. color: '#000',
  3225. opacity: 0.45
  3226. }
  3227. },
  3228. dropShadow: {
  3229. enabled: false,
  3230. top: 1,
  3231. left: 1,
  3232. blur: 1,
  3233. color: '#000',
  3234. opacity: 0.45
  3235. }
  3236. },
  3237. fill: {
  3238. type: 'solid',
  3239. colors: undefined,
  3240. // array of colors
  3241. opacity: 0.85,
  3242. gradient: {
  3243. shade: 'dark',
  3244. type: 'horizontal',
  3245. shadeIntensity: 0.5,
  3246. gradientToColors: undefined,
  3247. inverseColors: true,
  3248. opacityFrom: 1,
  3249. opacityTo: 1,
  3250. stops: [0, 50, 100],
  3251. colorStops: []
  3252. },
  3253. image: {
  3254. src: [],
  3255. width: undefined,
  3256. // optional
  3257. height: undefined // optional
  3258. },
  3259. pattern: {
  3260. style: 'squares',
  3261. // String | Array of Strings
  3262. width: 6,
  3263. height: 6,
  3264. strokeWidth: 2
  3265. }
  3266. },
  3267. forecastDataPoints: {
  3268. count: 0,
  3269. fillOpacity: 0.5,
  3270. strokeWidth: undefined,
  3271. dashArray: 4
  3272. },
  3273. grid: {
  3274. show: true,
  3275. borderColor: '#e0e0e0',
  3276. strokeDashArray: 0,
  3277. position: 'back',
  3278. xaxis: {
  3279. lines: {
  3280. show: false
  3281. }
  3282. },
  3283. yaxis: {
  3284. lines: {
  3285. show: true
  3286. }
  3287. },
  3288. row: {
  3289. colors: undefined,
  3290. // takes as array which will be repeated on rows
  3291. opacity: 0.5
  3292. },
  3293. column: {
  3294. colors: undefined,
  3295. // takes an array which will be repeated on columns
  3296. opacity: 0.5
  3297. },
  3298. padding: {
  3299. top: 0,
  3300. right: 10,
  3301. bottom: 0,
  3302. left: 12
  3303. }
  3304. },
  3305. labels: [],
  3306. legend: {
  3307. show: true,
  3308. showForSingleSeries: false,
  3309. showForNullSeries: true,
  3310. showForZeroSeries: true,
  3311. floating: false,
  3312. position: 'bottom',
  3313. // whether to position legends in 1 of 4
  3314. // direction - top, bottom, left, right
  3315. horizontalAlign: 'center',
  3316. // when position top/bottom, you can specify whether to align legends left, right or center
  3317. inverseOrder: false,
  3318. fontSize: '12px',
  3319. fontFamily: undefined,
  3320. fontWeight: 400,
  3321. width: undefined,
  3322. height: undefined,
  3323. formatter: undefined,
  3324. tooltipHoverFormatter: undefined,
  3325. offsetX: -20,
  3326. offsetY: 4,
  3327. customLegendItems: [],
  3328. labels: {
  3329. colors: undefined,
  3330. useSeriesColors: false
  3331. },
  3332. markers: {
  3333. width: 12,
  3334. height: 12,
  3335. strokeWidth: 0,
  3336. fillColors: undefined,
  3337. strokeColor: '#fff',
  3338. radius: 12,
  3339. customHTML: undefined,
  3340. offsetX: 0,
  3341. offsetY: 0,
  3342. onClick: undefined
  3343. },
  3344. itemMargin: {
  3345. horizontal: 5,
  3346. vertical: 2
  3347. },
  3348. onItemClick: {
  3349. toggleDataSeries: true
  3350. },
  3351. onItemHover: {
  3352. highlightDataSeries: true
  3353. }
  3354. },
  3355. markers: {
  3356. discrete: [],
  3357. size: 0,
  3358. colors: undefined,
  3359. //strokeColor: '#fff', // TODO: deprecate in major version 4.0
  3360. strokeColors: '#fff',
  3361. strokeWidth: 2,
  3362. strokeOpacity: 0.9,
  3363. strokeDashArray: 0,
  3364. fillOpacity: 1,
  3365. shape: 'circle',
  3366. width: 8,
  3367. // only applicable when shape is rect/square
  3368. height: 8,
  3369. // only applicable when shape is rect/square
  3370. radius: 2,
  3371. offsetX: 0,
  3372. offsetY: 0,
  3373. onClick: undefined,
  3374. onDblClick: undefined,
  3375. showNullDataPoints: true,
  3376. hover: {
  3377. size: undefined,
  3378. sizeOffset: 3
  3379. }
  3380. },
  3381. noData: {
  3382. text: undefined,
  3383. align: 'center',
  3384. verticalAlign: 'middle',
  3385. offsetX: 0,
  3386. offsetY: 0,
  3387. style: {
  3388. color: undefined,
  3389. fontSize: '14px',
  3390. fontFamily: undefined
  3391. }
  3392. },
  3393. responsive: [],
  3394. // breakpoints should follow ascending order 400, then 700, then 1000
  3395. series: undefined,
  3396. states: {
  3397. normal: {
  3398. filter: {
  3399. type: 'none',
  3400. value: 0
  3401. }
  3402. },
  3403. hover: {
  3404. filter: {
  3405. type: 'lighten',
  3406. value: 0.1
  3407. }
  3408. },
  3409. active: {
  3410. allowMultipleDataPointsSelection: false,
  3411. filter: {
  3412. type: 'darken',
  3413. value: 0.5
  3414. }
  3415. }
  3416. },
  3417. title: {
  3418. text: undefined,
  3419. align: 'left',
  3420. margin: 5,
  3421. offsetX: 0,
  3422. offsetY: 0,
  3423. floating: false,
  3424. style: {
  3425. fontSize: '14px',
  3426. fontWeight: 900,
  3427. fontFamily: undefined,
  3428. color: undefined
  3429. }
  3430. },
  3431. subtitle: {
  3432. text: undefined,
  3433. align: 'left',
  3434. margin: 5,
  3435. offsetX: 0,
  3436. offsetY: 30,
  3437. floating: false,
  3438. style: {
  3439. fontSize: '12px',
  3440. fontWeight: 400,
  3441. fontFamily: undefined,
  3442. color: undefined
  3443. }
  3444. },
  3445. stroke: {
  3446. show: true,
  3447. curve: 'smooth',
  3448. // "smooth" / "straight" / "stepline"
  3449. lineCap: 'butt',
  3450. // round, butt , square
  3451. width: 2,
  3452. colors: undefined,
  3453. // array of colors
  3454. dashArray: 0 // single value or array of values
  3455. },
  3456. tooltip: {
  3457. enabled: true,
  3458. enabledOnSeries: undefined,
  3459. shared: true,
  3460. followCursor: false,
  3461. // when disabled, the tooltip will show on top of the series instead of mouse position
  3462. intersect: false,
  3463. // when enabled, tooltip will only show when user directly hovers over point
  3464. inverseOrder: false,
  3465. custom: undefined,
  3466. fillSeriesColor: false,
  3467. theme: 'light',
  3468. cssClass: '',
  3469. style: {
  3470. fontSize: '12px',
  3471. fontFamily: undefined
  3472. },
  3473. onDatasetHover: {
  3474. highlightDataSeries: false
  3475. },
  3476. x: {
  3477. // x value
  3478. show: true,
  3479. format: 'dd MMM',
  3480. // dd/MM, dd MMM yy, dd MMM yyyy
  3481. formatter: undefined // a custom user supplied formatter function
  3482. },
  3483. y: {
  3484. formatter: undefined,
  3485. title: {
  3486. formatter: function formatter(seriesName) {
  3487. return seriesName ? seriesName + ': ' : '';
  3488. }
  3489. }
  3490. },
  3491. z: {
  3492. formatter: undefined,
  3493. title: 'Size: '
  3494. },
  3495. marker: {
  3496. show: true,
  3497. fillColors: undefined
  3498. },
  3499. items: {
  3500. display: 'flex'
  3501. },
  3502. fixed: {
  3503. enabled: false,
  3504. position: 'topRight',
  3505. // topRight, topLeft, bottomRight, bottomLeft
  3506. offsetX: 0,
  3507. offsetY: 0
  3508. }
  3509. },
  3510. xaxis: {
  3511. type: 'category',
  3512. categories: [],
  3513. convertedCatToNumeric: false,
  3514. // internal property which should not be altered outside
  3515. offsetX: 0,
  3516. offsetY: 0,
  3517. overwriteCategories: undefined,
  3518. labels: {
  3519. show: true,
  3520. rotate: -45,
  3521. rotateAlways: false,
  3522. hideOverlappingLabels: true,
  3523. trim: false,
  3524. minHeight: undefined,
  3525. maxHeight: 120,
  3526. showDuplicates: true,
  3527. style: {
  3528. colors: [],
  3529. fontSize: '12px',
  3530. fontWeight: 400,
  3531. fontFamily: undefined,
  3532. cssClass: ''
  3533. },
  3534. offsetX: 0,
  3535. offsetY: 0,
  3536. format: undefined,
  3537. formatter: undefined,
  3538. // custom formatter function which will override format
  3539. datetimeUTC: true,
  3540. datetimeFormatter: {
  3541. year: 'yyyy',
  3542. month: "MMM 'yy",
  3543. day: 'dd MMM',
  3544. hour: 'HH:mm',
  3545. minute: 'HH:mm:ss',
  3546. second: 'HH:mm:ss'
  3547. },
  3548. group: {
  3549. groups: [],
  3550. style: {
  3551. colors: [],
  3552. fontSize: '12px',
  3553. fontWeight: 400,
  3554. fontFamily: undefined,
  3555. cssClass: ''
  3556. }
  3557. }
  3558. },
  3559. axisBorder: {
  3560. show: true,
  3561. color: '#e0e0e0',
  3562. width: '100%',
  3563. height: 1,
  3564. offsetX: 0,
  3565. offsetY: 0
  3566. },
  3567. axisTicks: {
  3568. show: true,
  3569. color: '#e0e0e0',
  3570. height: 6,
  3571. offsetX: 0,
  3572. offsetY: 0
  3573. },
  3574. tickAmount: undefined,
  3575. tickPlacement: 'on',
  3576. min: undefined,
  3577. max: undefined,
  3578. range: undefined,
  3579. floating: false,
  3580. decimalsInFloat: undefined,
  3581. position: 'bottom',
  3582. title: {
  3583. text: undefined,
  3584. offsetX: 0,
  3585. offsetY: 0,
  3586. style: {
  3587. color: undefined,
  3588. fontSize: '12px',
  3589. fontWeight: 900,
  3590. fontFamily: undefined,
  3591. cssClass: ''
  3592. }
  3593. },
  3594. crosshairs: {
  3595. show: true,
  3596. width: 1,
  3597. // tickWidth/barWidth or an integer
  3598. position: 'back',
  3599. opacity: 0.9,
  3600. stroke: {
  3601. color: '#b6b6b6',
  3602. width: 1,
  3603. dashArray: 3
  3604. },
  3605. fill: {
  3606. type: 'solid',
  3607. // solid, gradient
  3608. color: '#B1B9C4',
  3609. gradient: {
  3610. colorFrom: '#D8E3F0',
  3611. colorTo: '#BED1E6',
  3612. stops: [0, 100],
  3613. opacityFrom: 0.4,
  3614. opacityTo: 0.5
  3615. }
  3616. },
  3617. dropShadow: {
  3618. enabled: false,
  3619. left: 0,
  3620. top: 0,
  3621. blur: 1,
  3622. opacity: 0.4
  3623. }
  3624. },
  3625. tooltip: {
  3626. enabled: true,
  3627. offsetY: 0,
  3628. formatter: undefined,
  3629. style: {
  3630. fontSize: '12px',
  3631. fontFamily: undefined
  3632. }
  3633. }
  3634. },
  3635. yaxis: this.yAxis,
  3636. theme: {
  3637. mode: 'light',
  3638. palette: 'palette1',
  3639. // If defined, it will overwrite globals.colors variable
  3640. monochrome: {
  3641. // monochrome allows you to select just 1 color and fill out the rest with light/dark shade (intensity can be selected)
  3642. enabled: false,
  3643. color: '#008FFB',
  3644. shadeTo: 'light',
  3645. shadeIntensity: 0.65
  3646. }
  3647. }
  3648. };
  3649. }
  3650. }]);
  3651. return Options;
  3652. }();
  3653. /**
  3654. * ApexCharts Annotations Class for drawing lines/rects on both xaxis and yaxis.
  3655. *
  3656. * @module Annotations
  3657. **/
  3658. var Annotations = /*#__PURE__*/function () {
  3659. function Annotations(ctx) {
  3660. _classCallCheck(this, Annotations);
  3661. this.ctx = ctx;
  3662. this.w = ctx.w;
  3663. this.graphics = new Graphics(this.ctx);
  3664. if (this.w.globals.isBarHorizontal) {
  3665. this.invertAxis = true;
  3666. }
  3667. this.helpers = new Helpers$4(this);
  3668. this.xAxisAnnotations = new XAnnotations(this);
  3669. this.yAxisAnnotations = new YAnnotations(this);
  3670. this.pointsAnnotations = new PointAnnotations(this);
  3671. if (this.w.globals.isBarHorizontal && this.w.config.yaxis[0].reversed) {
  3672. this.inversedReversedAxis = true;
  3673. }
  3674. this.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints;
  3675. }
  3676. _createClass(Annotations, [{
  3677. key: "drawAxesAnnotations",
  3678. value: function drawAxesAnnotations() {
  3679. var w = this.w;
  3680. if (w.globals.axisCharts) {
  3681. var yAnnotations = this.yAxisAnnotations.drawYAxisAnnotations();
  3682. var xAnnotations = this.xAxisAnnotations.drawXAxisAnnotations();
  3683. var pointAnnotations = this.pointsAnnotations.drawPointAnnotations();
  3684. var initialAnim = w.config.chart.animations.enabled;
  3685. var annoArray = [yAnnotations, xAnnotations, pointAnnotations];
  3686. var annoElArray = [xAnnotations.node, yAnnotations.node, pointAnnotations.node];
  3687. for (var i = 0; i < 3; i++) {
  3688. w.globals.dom.elGraphical.add(annoArray[i]);
  3689. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  3690. // fixes apexcharts/apexcharts.js#685
  3691. if (w.config.chart.type !== 'scatter' && w.config.chart.type !== 'bubble' && w.globals.dataPoints > 1) {
  3692. annoElArray[i].classList.add('apexcharts-element-hidden');
  3693. }
  3694. }
  3695. w.globals.delayedElements.push({
  3696. el: annoElArray[i],
  3697. index: 0
  3698. });
  3699. } // background sizes needs to be calculated after text is drawn, so calling them last
  3700. this.helpers.annotationsBackground();
  3701. }
  3702. }
  3703. }, {
  3704. key: "drawImageAnnos",
  3705. value: function drawImageAnnos() {
  3706. var _this = this;
  3707. var w = this.w;
  3708. w.config.annotations.images.map(function (s, index) {
  3709. _this.addImage(s, index);
  3710. });
  3711. }
  3712. }, {
  3713. key: "drawTextAnnos",
  3714. value: function drawTextAnnos() {
  3715. var _this2 = this;
  3716. var w = this.w;
  3717. w.config.annotations.texts.map(function (t, index) {
  3718. _this2.addText(t, index);
  3719. });
  3720. }
  3721. }, {
  3722. key: "addXaxisAnnotation",
  3723. value: function addXaxisAnnotation(anno, parent, index) {
  3724. this.xAxisAnnotations.addXaxisAnnotation(anno, parent, index);
  3725. }
  3726. }, {
  3727. key: "addYaxisAnnotation",
  3728. value: function addYaxisAnnotation(anno, parent, index) {
  3729. this.yAxisAnnotations.addYaxisAnnotation(anno, parent, index);
  3730. }
  3731. }, {
  3732. key: "addPointAnnotation",
  3733. value: function addPointAnnotation(anno, parent, index) {
  3734. this.pointsAnnotations.addPointAnnotation(anno, parent, index);
  3735. }
  3736. }, {
  3737. key: "addText",
  3738. value: function addText(params, index) {
  3739. var x = params.x,
  3740. y = params.y,
  3741. text = params.text,
  3742. textAnchor = params.textAnchor,
  3743. foreColor = params.foreColor,
  3744. fontSize = params.fontSize,
  3745. fontFamily = params.fontFamily,
  3746. fontWeight = params.fontWeight,
  3747. cssClass = params.cssClass,
  3748. backgroundColor = params.backgroundColor,
  3749. borderWidth = params.borderWidth,
  3750. strokeDashArray = params.strokeDashArray,
  3751. borderRadius = params.borderRadius,
  3752. borderColor = params.borderColor,
  3753. _params$appendTo = params.appendTo,
  3754. appendTo = _params$appendTo === void 0 ? '.apexcharts-annotations' : _params$appendTo,
  3755. _params$paddingLeft = params.paddingLeft,
  3756. paddingLeft = _params$paddingLeft === void 0 ? 4 : _params$paddingLeft,
  3757. _params$paddingRight = params.paddingRight,
  3758. paddingRight = _params$paddingRight === void 0 ? 4 : _params$paddingRight,
  3759. _params$paddingBottom = params.paddingBottom,
  3760. paddingBottom = _params$paddingBottom === void 0 ? 2 : _params$paddingBottom,
  3761. _params$paddingTop = params.paddingTop,
  3762. paddingTop = _params$paddingTop === void 0 ? 2 : _params$paddingTop;
  3763. var w = this.w;
  3764. var elText = this.graphics.drawText({
  3765. x: x,
  3766. y: y,
  3767. text: text,
  3768. textAnchor: textAnchor || 'start',
  3769. fontSize: fontSize || '12px',
  3770. fontWeight: fontWeight || 'regular',
  3771. fontFamily: fontFamily || w.config.chart.fontFamily,
  3772. foreColor: foreColor || w.config.chart.foreColor,
  3773. cssClass: 'apexcharts-text ' + cssClass ? cssClass : ''
  3774. });
  3775. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3776. if (parent) {
  3777. parent.appendChild(elText.node);
  3778. }
  3779. var textRect = elText.bbox();
  3780. if (text) {
  3781. 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);
  3782. parent.insertBefore(elRect.node, elText.node);
  3783. }
  3784. }
  3785. }, {
  3786. key: "addImage",
  3787. value: function addImage(params, index) {
  3788. var w = this.w;
  3789. var path = params.path,
  3790. _params$x = params.x,
  3791. x = _params$x === void 0 ? 0 : _params$x,
  3792. _params$y = params.y,
  3793. y = _params$y === void 0 ? 0 : _params$y,
  3794. _params$width = params.width,
  3795. width = _params$width === void 0 ? 20 : _params$width,
  3796. _params$height = params.height,
  3797. height = _params$height === void 0 ? 20 : _params$height,
  3798. _params$appendTo2 = params.appendTo,
  3799. appendTo = _params$appendTo2 === void 0 ? '.apexcharts-annotations' : _params$appendTo2;
  3800. var img = w.globals.dom.Paper.image(path);
  3801. img.size(width, height).move(x, y);
  3802. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3803. if (parent) {
  3804. parent.appendChild(img.node);
  3805. }
  3806. return img;
  3807. } // 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
  3808. }, {
  3809. key: "addXaxisAnnotationExternal",
  3810. value: function addXaxisAnnotationExternal(params, pushToMemory, context) {
  3811. this.addAnnotationExternal({
  3812. params: params,
  3813. pushToMemory: pushToMemory,
  3814. context: context,
  3815. type: 'xaxis',
  3816. contextMethod: context.addXaxisAnnotation
  3817. });
  3818. return context;
  3819. }
  3820. }, {
  3821. key: "addYaxisAnnotationExternal",
  3822. value: function addYaxisAnnotationExternal(params, pushToMemory, context) {
  3823. this.addAnnotationExternal({
  3824. params: params,
  3825. pushToMemory: pushToMemory,
  3826. context: context,
  3827. type: 'yaxis',
  3828. contextMethod: context.addYaxisAnnotation
  3829. });
  3830. return context;
  3831. }
  3832. }, {
  3833. key: "addPointAnnotationExternal",
  3834. value: function addPointAnnotationExternal(params, pushToMemory, context) {
  3835. if (typeof this.invertAxis === 'undefined') {
  3836. this.invertAxis = context.w.globals.isBarHorizontal;
  3837. }
  3838. this.addAnnotationExternal({
  3839. params: params,
  3840. pushToMemory: pushToMemory,
  3841. context: context,
  3842. type: 'point',
  3843. contextMethod: context.addPointAnnotation
  3844. });
  3845. return context;
  3846. }
  3847. }, {
  3848. key: "addAnnotationExternal",
  3849. value: function addAnnotationExternal(_ref) {
  3850. var params = _ref.params,
  3851. pushToMemory = _ref.pushToMemory,
  3852. context = _ref.context,
  3853. type = _ref.type,
  3854. contextMethod = _ref.contextMethod;
  3855. var me = context;
  3856. var w = me.w;
  3857. var parent = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations"));
  3858. var index = parent.childNodes.length + 1;
  3859. var options = new Options();
  3860. var axesAnno = Object.assign({}, type === 'xaxis' ? options.xAxisAnnotation : type === 'yaxis' ? options.yAxisAnnotation : options.pointAnnotation);
  3861. var anno = Utils$1.extend(axesAnno, params);
  3862. switch (type) {
  3863. case 'xaxis':
  3864. this.addXaxisAnnotation(anno, parent, index);
  3865. break;
  3866. case 'yaxis':
  3867. this.addYaxisAnnotation(anno, parent, index);
  3868. break;
  3869. case 'point':
  3870. this.addPointAnnotation(anno, parent, index);
  3871. break;
  3872. } // add background
  3873. var axesAnnoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(index, "']"));
  3874. var elRect = this.helpers.addBackgroundToAnno(axesAnnoLabel, anno);
  3875. if (elRect) {
  3876. parent.insertBefore(elRect.node, axesAnnoLabel);
  3877. }
  3878. if (pushToMemory) {
  3879. w.globals.memory.methodsToExec.push({
  3880. context: me,
  3881. id: anno.id ? anno.id : Utils$1.randomId(),
  3882. method: contextMethod,
  3883. label: 'addAnnotation',
  3884. params: params
  3885. });
  3886. }
  3887. return context;
  3888. }
  3889. }, {
  3890. key: "clearAnnotations",
  3891. value: function clearAnnotations(ctx) {
  3892. var w = ctx.w;
  3893. var annos = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations'); // annotations added externally should be cleared out too
  3894. w.globals.memory.methodsToExec.map(function (m, i) {
  3895. if (m.label === 'addText' || m.label === 'addAnnotation') {
  3896. w.globals.memory.methodsToExec.splice(i, 1);
  3897. }
  3898. });
  3899. annos = Utils$1.listToArray(annos); // delete the DOM elements
  3900. Array.prototype.forEach.call(annos, function (a) {
  3901. while (a.firstChild) {
  3902. a.removeChild(a.firstChild);
  3903. }
  3904. });
  3905. }
  3906. }, {
  3907. key: "removeAnnotation",
  3908. value: function removeAnnotation(ctx, id) {
  3909. var w = ctx.w;
  3910. var annos = w.globals.dom.baseEl.querySelectorAll(".".concat(id));
  3911. if (annos) {
  3912. w.globals.memory.methodsToExec.map(function (m, i) {
  3913. if (m.id === id) {
  3914. w.globals.memory.methodsToExec.splice(i, 1);
  3915. }
  3916. });
  3917. Array.prototype.forEach.call(annos, function (a) {
  3918. a.parentElement.removeChild(a);
  3919. });
  3920. }
  3921. }
  3922. }]);
  3923. return Annotations;
  3924. }();
  3925. /**
  3926. * ApexCharts Fill Class for setting fill options of the paths.
  3927. *
  3928. * @module Fill
  3929. **/
  3930. var Fill = /*#__PURE__*/function () {
  3931. function Fill(ctx) {
  3932. _classCallCheck(this, Fill);
  3933. this.ctx = ctx;
  3934. this.w = ctx.w;
  3935. this.opts = null;
  3936. this.seriesIndex = 0;
  3937. }
  3938. _createClass(Fill, [{
  3939. key: "clippedImgArea",
  3940. value: function clippedImgArea(params) {
  3941. var w = this.w;
  3942. var cnf = w.config;
  3943. var svgW = parseInt(w.globals.gridWidth, 10);
  3944. var svgH = parseInt(w.globals.gridHeight, 10);
  3945. var size = svgW > svgH ? svgW : svgH;
  3946. var fillImg = params.image;
  3947. var imgWidth = 0;
  3948. var imgHeight = 0;
  3949. if (typeof params.width === 'undefined' && typeof params.height === 'undefined') {
  3950. if (cnf.fill.image.width !== undefined && cnf.fill.image.height !== undefined) {
  3951. imgWidth = cnf.fill.image.width + 1;
  3952. imgHeight = cnf.fill.image.height;
  3953. } else {
  3954. imgWidth = size + 1;
  3955. imgHeight = size;
  3956. }
  3957. } else {
  3958. imgWidth = params.width;
  3959. imgHeight = params.height;
  3960. }
  3961. var elPattern = document.createElementNS(w.globals.SVGNS, 'pattern');
  3962. Graphics.setAttrs(elPattern, {
  3963. id: params.patternID,
  3964. patternUnits: params.patternUnits ? params.patternUnits : 'userSpaceOnUse',
  3965. width: imgWidth + 'px',
  3966. height: imgHeight + 'px'
  3967. });
  3968. var elImage = document.createElementNS(w.globals.SVGNS, 'image');
  3969. elPattern.appendChild(elImage);
  3970. elImage.setAttributeNS(window.SVG.xlink, 'href', fillImg);
  3971. Graphics.setAttrs(elImage, {
  3972. x: 0,
  3973. y: 0,
  3974. preserveAspectRatio: 'none',
  3975. width: imgWidth + 'px',
  3976. height: imgHeight + 'px'
  3977. });
  3978. elImage.style.opacity = params.opacity;
  3979. w.globals.dom.elDefs.node.appendChild(elPattern);
  3980. }
  3981. }, {
  3982. key: "getSeriesIndex",
  3983. value: function getSeriesIndex(opts) {
  3984. var w = this.w;
  3985. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap' || w.config.chart.type === 'treemap') {
  3986. this.seriesIndex = opts.seriesNumber;
  3987. } else {
  3988. this.seriesIndex = opts.seriesNumber % w.globals.series.length;
  3989. }
  3990. return this.seriesIndex;
  3991. }
  3992. }, {
  3993. key: "fillPath",
  3994. value: function fillPath(opts) {
  3995. var w = this.w;
  3996. this.opts = opts;
  3997. var cnf = this.w.config;
  3998. var pathFill;
  3999. var patternFill, gradientFill;
  4000. this.seriesIndex = this.getSeriesIndex(opts);
  4001. var fillColors = this.getFillColors();
  4002. var fillColor = fillColors[this.seriesIndex]; //override fillcolor if user inputted color with data
  4003. if (w.globals.seriesColors[this.seriesIndex] !== undefined) {
  4004. fillColor = w.globals.seriesColors[this.seriesIndex];
  4005. }
  4006. if (typeof fillColor === 'function') {
  4007. fillColor = fillColor({
  4008. seriesIndex: this.seriesIndex,
  4009. dataPointIndex: opts.dataPointIndex,
  4010. value: opts.value,
  4011. w: w
  4012. });
  4013. }
  4014. var fillType = this.getFillType(this.seriesIndex);
  4015. var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[this.seriesIndex] : cnf.fill.opacity;
  4016. if (opts.color) {
  4017. fillColor = opts.color;
  4018. }
  4019. var defaultColor = fillColor;
  4020. if (fillColor.indexOf('rgb') === -1) {
  4021. if (fillColor.length < 9) {
  4022. // if the hex contains alpha and is of 9 digit, skip the opacity
  4023. defaultColor = Utils$1.hexToRgba(fillColor, fillOpacity);
  4024. }
  4025. } else {
  4026. if (fillColor.indexOf('rgba') > -1) {
  4027. fillOpacity = Utils$1.getOpacityFromRGBA(fillColor);
  4028. }
  4029. }
  4030. if (opts.opacity) fillOpacity = opts.opacity;
  4031. if (fillType === 'pattern') {
  4032. patternFill = this.handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor);
  4033. }
  4034. if (fillType === 'gradient') {
  4035. gradientFill = this.handleGradientFill(fillColor, fillOpacity, this.seriesIndex);
  4036. }
  4037. if (fillType === 'image') {
  4038. var imgSrc = cnf.fill.image.src;
  4039. var patternID = opts.patternID ? opts.patternID : '';
  4040. this.clippedImgArea({
  4041. opacity: fillOpacity,
  4042. image: Array.isArray(imgSrc) ? opts.seriesNumber < imgSrc.length ? imgSrc[opts.seriesNumber] : imgSrc[0] : imgSrc,
  4043. width: opts.width ? opts.width : undefined,
  4044. height: opts.height ? opts.height : undefined,
  4045. patternUnits: opts.patternUnits,
  4046. patternID: "pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID)
  4047. });
  4048. pathFill = "url(#pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID, ")");
  4049. } else if (fillType === 'gradient') {
  4050. pathFill = gradientFill;
  4051. } else if (fillType === 'pattern') {
  4052. pathFill = patternFill;
  4053. } else {
  4054. pathFill = defaultColor;
  4055. } // override pattern/gradient if opts.solid is true
  4056. if (opts.solid) {
  4057. pathFill = defaultColor;
  4058. }
  4059. return pathFill;
  4060. }
  4061. }, {
  4062. key: "getFillType",
  4063. value: function getFillType(seriesIndex) {
  4064. var w = this.w;
  4065. if (Array.isArray(w.config.fill.type)) {
  4066. return w.config.fill.type[seriesIndex];
  4067. } else {
  4068. return w.config.fill.type;
  4069. }
  4070. }
  4071. }, {
  4072. key: "getFillColors",
  4073. value: function getFillColors() {
  4074. var w = this.w;
  4075. var cnf = w.config;
  4076. var opts = this.opts;
  4077. var fillColors = [];
  4078. if (w.globals.comboCharts) {
  4079. if (w.config.series[this.seriesIndex].type === 'line') {
  4080. if (Array.isArray(w.globals.stroke.colors)) {
  4081. fillColors = w.globals.stroke.colors;
  4082. } else {
  4083. fillColors.push(w.globals.stroke.colors);
  4084. }
  4085. } else {
  4086. if (Array.isArray(w.globals.fill.colors)) {
  4087. fillColors = w.globals.fill.colors;
  4088. } else {
  4089. fillColors.push(w.globals.fill.colors);
  4090. }
  4091. }
  4092. } else {
  4093. if (cnf.chart.type === 'line') {
  4094. if (Array.isArray(w.globals.stroke.colors)) {
  4095. fillColors = w.globals.stroke.colors;
  4096. } else {
  4097. fillColors.push(w.globals.stroke.colors);
  4098. }
  4099. } else {
  4100. if (Array.isArray(w.globals.fill.colors)) {
  4101. fillColors = w.globals.fill.colors;
  4102. } else {
  4103. fillColors.push(w.globals.fill.colors);
  4104. }
  4105. }
  4106. } // colors passed in arguments
  4107. if (typeof opts.fillColors !== 'undefined') {
  4108. fillColors = [];
  4109. if (Array.isArray(opts.fillColors)) {
  4110. fillColors = opts.fillColors.slice();
  4111. } else {
  4112. fillColors.push(opts.fillColors);
  4113. }
  4114. }
  4115. return fillColors;
  4116. }
  4117. }, {
  4118. key: "handlePatternFill",
  4119. value: function handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor) {
  4120. var cnf = this.w.config;
  4121. var opts = this.opts;
  4122. var graphics = new Graphics(this.ctx);
  4123. 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;
  4124. var patternLineColor = fillColor;
  4125. if (Array.isArray(cnf.fill.pattern.style)) {
  4126. if (typeof cnf.fill.pattern.style[opts.seriesNumber] !== 'undefined') {
  4127. var pf = graphics.drawPattern(cnf.fill.pattern.style[opts.seriesNumber], cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  4128. patternFill = pf;
  4129. } else {
  4130. patternFill = defaultColor;
  4131. }
  4132. } else {
  4133. patternFill = graphics.drawPattern(cnf.fill.pattern.style, cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  4134. }
  4135. return patternFill;
  4136. }
  4137. }, {
  4138. key: "handleGradientFill",
  4139. value: function handleGradientFill(fillColor, fillOpacity, i) {
  4140. var cnf = this.w.config;
  4141. var opts = this.opts;
  4142. var graphics = new Graphics(this.ctx);
  4143. var utils = new Utils$1();
  4144. var type = cnf.fill.gradient.type;
  4145. var gradientFrom = fillColor;
  4146. var gradientTo;
  4147. var opacityFrom = cnf.fill.gradient.opacityFrom === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityFrom) ? cnf.fill.gradient.opacityFrom[i] : cnf.fill.gradient.opacityFrom;
  4148. if (gradientFrom.indexOf('rgba') > -1) {
  4149. opacityFrom = Utils$1.getOpacityFromRGBA(gradientFrom);
  4150. }
  4151. var opacityTo = cnf.fill.gradient.opacityTo === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityTo) ? cnf.fill.gradient.opacityTo[i] : cnf.fill.gradient.opacityTo;
  4152. if (cnf.fill.gradient.gradientToColors === undefined || cnf.fill.gradient.gradientToColors.length === 0) {
  4153. if (cnf.fill.gradient.shade === 'dark') {
  4154. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity) * -1, fillColor.indexOf('rgb') > -1 ? Utils$1.rgb2hex(fillColor) : fillColor);
  4155. } else {
  4156. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity), fillColor.indexOf('rgb') > -1 ? Utils$1.rgb2hex(fillColor) : fillColor);
  4157. }
  4158. } else {
  4159. if (cnf.fill.gradient.gradientToColors[opts.seriesNumber]) {
  4160. var gToColor = cnf.fill.gradient.gradientToColors[opts.seriesNumber];
  4161. gradientTo = gToColor;
  4162. if (gToColor.indexOf('rgba') > -1) {
  4163. opacityTo = Utils$1.getOpacityFromRGBA(gToColor);
  4164. }
  4165. } else {
  4166. gradientTo = fillColor;
  4167. }
  4168. }
  4169. if (cnf.fill.gradient.inverseColors) {
  4170. var t = gradientFrom;
  4171. gradientFrom = gradientTo;
  4172. gradientTo = t;
  4173. }
  4174. if (gradientFrom.indexOf('rgb') > -1) {
  4175. gradientFrom = Utils$1.rgb2hex(gradientFrom);
  4176. }
  4177. if (gradientTo.indexOf('rgb') > -1) {
  4178. gradientTo = Utils$1.rgb2hex(gradientTo);
  4179. }
  4180. return graphics.drawGradient(type, gradientFrom, gradientTo, opacityFrom, opacityTo, opts.size, cnf.fill.gradient.stops, cnf.fill.gradient.colorStops, i);
  4181. }
  4182. }]);
  4183. return Fill;
  4184. }();
  4185. /**
  4186. * ApexCharts Markers Class for drawing points on y values in axes charts.
  4187. *
  4188. * @module Markers
  4189. **/
  4190. var Markers = /*#__PURE__*/function () {
  4191. function Markers(ctx, opts) {
  4192. _classCallCheck(this, Markers);
  4193. this.ctx = ctx;
  4194. this.w = ctx.w;
  4195. }
  4196. _createClass(Markers, [{
  4197. key: "setGlobalMarkerSize",
  4198. value: function setGlobalMarkerSize() {
  4199. var w = this.w;
  4200. w.globals.markers.size = Array.isArray(w.config.markers.size) ? w.config.markers.size : [w.config.markers.size];
  4201. if (w.globals.markers.size.length > 0) {
  4202. if (w.globals.markers.size.length < w.globals.series.length + 1) {
  4203. for (var i = 0; i <= w.globals.series.length; i++) {
  4204. if (typeof w.globals.markers.size[i] === 'undefined') {
  4205. w.globals.markers.size.push(w.globals.markers.size[0]);
  4206. }
  4207. }
  4208. }
  4209. } else {
  4210. w.globals.markers.size = w.config.series.map(function (s) {
  4211. return w.config.markers.size;
  4212. });
  4213. }
  4214. }
  4215. }, {
  4216. key: "plotChartMarkers",
  4217. value: function plotChartMarkers(pointsPos, seriesIndex, j, pSize) {
  4218. var alwaysDrawMarker = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  4219. var w = this.w;
  4220. var i = seriesIndex;
  4221. var p = pointsPos;
  4222. var elPointsWrap = null;
  4223. var graphics = new Graphics(this.ctx);
  4224. var point;
  4225. var hasDiscreteMarkers = w.config.markers.discrete && w.config.markers.discrete.length;
  4226. if (w.globals.markers.size[seriesIndex] > 0 || alwaysDrawMarker || hasDiscreteMarkers) {
  4227. elPointsWrap = graphics.group({
  4228. class: alwaysDrawMarker || hasDiscreteMarkers ? '' : 'apexcharts-series-markers'
  4229. });
  4230. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  4231. }
  4232. if (Array.isArray(p.x)) {
  4233. for (var q = 0; q < p.x.length; q++) {
  4234. var dataPointIndex = j; // a small hack as we have 2 points for the first val to connect it
  4235. if (j === 1 && q === 0) dataPointIndex = 0;
  4236. if (j === 1 && q === 1) dataPointIndex = 1;
  4237. var PointClasses = 'apexcharts-marker';
  4238. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  4239. PointClasses += ' no-pointer-events';
  4240. }
  4241. var shouldMarkerDraw = Array.isArray(w.config.markers.size) ? w.globals.markers.size[seriesIndex] > 0 : w.config.markers.size > 0;
  4242. if (shouldMarkerDraw || alwaysDrawMarker || hasDiscreteMarkers) {
  4243. if (Utils$1.isNumber(p.y[q])) {
  4244. PointClasses += " w".concat(Utils$1.randomId());
  4245. } else {
  4246. PointClasses = 'apexcharts-nullpoint';
  4247. }
  4248. var opts = this.getMarkerConfig({
  4249. cssClass: PointClasses,
  4250. seriesIndex: seriesIndex,
  4251. dataPointIndex: dataPointIndex
  4252. });
  4253. if (w.config.series[i].data[dataPointIndex]) {
  4254. if (w.config.series[i].data[dataPointIndex].fillColor) {
  4255. opts.pointFillColor = w.config.series[i].data[dataPointIndex].fillColor;
  4256. }
  4257. if (w.config.series[i].data[dataPointIndex].strokeColor) {
  4258. opts.pointStrokeColor = w.config.series[i].data[dataPointIndex].strokeColor;
  4259. }
  4260. }
  4261. if (pSize) {
  4262. opts.pSize = pSize;
  4263. }
  4264. point = graphics.drawMarker(p.x[q], p.y[q], opts);
  4265. point.attr('rel', dataPointIndex);
  4266. point.attr('j', dataPointIndex);
  4267. point.attr('index', seriesIndex);
  4268. point.node.setAttribute('default-marker-size', opts.pSize);
  4269. var filters = new Filters(this.ctx);
  4270. filters.setSelectionFilter(point, seriesIndex, dataPointIndex);
  4271. this.addEvents(point);
  4272. if (elPointsWrap) {
  4273. elPointsWrap.add(point);
  4274. }
  4275. } else {
  4276. // dynamic array creation - multidimensional
  4277. if (typeof w.globals.pointsArray[seriesIndex] === 'undefined') w.globals.pointsArray[seriesIndex] = [];
  4278. w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]);
  4279. }
  4280. }
  4281. }
  4282. return elPointsWrap;
  4283. }
  4284. }, {
  4285. key: "getMarkerConfig",
  4286. value: function getMarkerConfig(_ref) {
  4287. var cssClass = _ref.cssClass,
  4288. seriesIndex = _ref.seriesIndex,
  4289. _ref$dataPointIndex = _ref.dataPointIndex,
  4290. dataPointIndex = _ref$dataPointIndex === void 0 ? null : _ref$dataPointIndex,
  4291. _ref$finishRadius = _ref.finishRadius,
  4292. finishRadius = _ref$finishRadius === void 0 ? null : _ref$finishRadius;
  4293. var w = this.w;
  4294. var pStyle = this.getMarkerStyle(seriesIndex);
  4295. var pSize = w.globals.markers.size[seriesIndex];
  4296. var m = w.config.markers; // discrete markers is an option where user can specify a particular marker with different shape, size and color
  4297. if (dataPointIndex !== null && m.discrete.length) {
  4298. m.discrete.map(function (marker) {
  4299. if (marker.seriesIndex === seriesIndex && marker.dataPointIndex === dataPointIndex) {
  4300. pStyle.pointStrokeColor = marker.strokeColor;
  4301. pStyle.pointFillColor = marker.fillColor;
  4302. pSize = marker.size;
  4303. pStyle.pointShape = marker.shape;
  4304. }
  4305. });
  4306. }
  4307. return {
  4308. pSize: finishRadius === null ? pSize : finishRadius,
  4309. pRadius: m.radius,
  4310. width: Array.isArray(m.width) ? m.width[seriesIndex] : m.width,
  4311. height: Array.isArray(m.height) ? m.height[seriesIndex] : m.height,
  4312. pointStrokeWidth: Array.isArray(m.strokeWidth) ? m.strokeWidth[seriesIndex] : m.strokeWidth,
  4313. pointStrokeColor: pStyle.pointStrokeColor,
  4314. pointFillColor: pStyle.pointFillColor,
  4315. shape: pStyle.pointShape || (Array.isArray(m.shape) ? m.shape[seriesIndex] : m.shape),
  4316. class: cssClass,
  4317. pointStrokeOpacity: Array.isArray(m.strokeOpacity) ? m.strokeOpacity[seriesIndex] : m.strokeOpacity,
  4318. pointStrokeDashArray: Array.isArray(m.strokeDashArray) ? m.strokeDashArray[seriesIndex] : m.strokeDashArray,
  4319. pointFillOpacity: Array.isArray(m.fillOpacity) ? m.fillOpacity[seriesIndex] : m.fillOpacity,
  4320. seriesIndex: seriesIndex
  4321. };
  4322. }
  4323. }, {
  4324. key: "addEvents",
  4325. value: function addEvents(circle) {
  4326. var w = this.w;
  4327. var graphics = new Graphics(this.ctx);
  4328. circle.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this.ctx, circle));
  4329. circle.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this.ctx, circle));
  4330. circle.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this.ctx, circle));
  4331. circle.node.addEventListener('click', w.config.markers.onClick);
  4332. circle.node.addEventListener('dblclick', w.config.markers.onDblClick);
  4333. circle.node.addEventListener('touchstart', graphics.pathMouseDown.bind(this.ctx, circle), {
  4334. passive: true
  4335. });
  4336. }
  4337. }, {
  4338. key: "getMarkerStyle",
  4339. value: function getMarkerStyle(seriesIndex) {
  4340. var w = this.w;
  4341. var colors = w.globals.markers.colors;
  4342. var strokeColors = w.config.markers.strokeColor || w.config.markers.strokeColors;
  4343. var pointStrokeColor = Array.isArray(strokeColors) ? strokeColors[seriesIndex] : strokeColors;
  4344. var pointFillColor = Array.isArray(colors) ? colors[seriesIndex] : colors;
  4345. return {
  4346. pointStrokeColor: pointStrokeColor,
  4347. pointFillColor: pointFillColor
  4348. };
  4349. }
  4350. }]);
  4351. return Markers;
  4352. }();
  4353. /**
  4354. * ApexCharts Scatter Class.
  4355. * This Class also handles bubbles chart as currently there is no major difference in drawing them,
  4356. * @module Scatter
  4357. **/
  4358. var Scatter = /*#__PURE__*/function () {
  4359. function Scatter(ctx) {
  4360. _classCallCheck(this, Scatter);
  4361. this.ctx = ctx;
  4362. this.w = ctx.w;
  4363. this.initialAnim = this.w.config.chart.animations.enabled;
  4364. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  4365. }
  4366. _createClass(Scatter, [{
  4367. key: "draw",
  4368. value: function draw(elSeries, j, opts) {
  4369. var w = this.w;
  4370. var graphics = new Graphics(this.ctx);
  4371. var realIndex = opts.realIndex;
  4372. var pointsPos = opts.pointsPos;
  4373. var zRatio = opts.zRatio;
  4374. var elPointsMain = opts.elParent;
  4375. var elPointsWrap = graphics.group({
  4376. class: "apexcharts-series-markers apexcharts-series-".concat(w.config.chart.type)
  4377. });
  4378. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  4379. if (Array.isArray(pointsPos.x)) {
  4380. for (var q = 0; q < pointsPos.x.length; q++) {
  4381. var dataPointIndex = j + 1;
  4382. var shouldDraw = true; // a small hack as we have 2 points for the first val to connect it
  4383. if (j === 0 && q === 0) dataPointIndex = 0;
  4384. if (j === 0 && q === 1) dataPointIndex = 1;
  4385. var radius = 0;
  4386. var finishRadius = w.globals.markers.size[realIndex];
  4387. if (zRatio !== Infinity) {
  4388. // means we have a bubble
  4389. finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] / zRatio;
  4390. var bubble = w.config.plotOptions.bubble;
  4391. if (bubble.minBubbleRadius && finishRadius < bubble.minBubbleRadius) {
  4392. finishRadius = bubble.minBubbleRadius;
  4393. }
  4394. if (bubble.maxBubbleRadius && finishRadius > bubble.maxBubbleRadius) {
  4395. finishRadius = bubble.maxBubbleRadius;
  4396. }
  4397. }
  4398. if (!w.config.chart.animations.enabled) {
  4399. radius = finishRadius;
  4400. }
  4401. var x = pointsPos.x[q];
  4402. var y = pointsPos.y[q];
  4403. radius = radius || 0;
  4404. if (y === null || typeof w.globals.series[realIndex][dataPointIndex] === 'undefined') {
  4405. shouldDraw = false;
  4406. }
  4407. if (shouldDraw) {
  4408. var point = this.drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j);
  4409. elPointsWrap.add(point);
  4410. }
  4411. elPointsMain.add(elPointsWrap);
  4412. }
  4413. }
  4414. }
  4415. }, {
  4416. key: "drawPoint",
  4417. value: function drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j) {
  4418. var w = this.w;
  4419. var i = realIndex;
  4420. var anim = new Animations(this.ctx);
  4421. var filters = new Filters(this.ctx);
  4422. var fill = new Fill(this.ctx);
  4423. var markers = new Markers(this.ctx);
  4424. var graphics = new Graphics(this.ctx);
  4425. var markerConfig = markers.getMarkerConfig({
  4426. cssClass: 'apexcharts-marker',
  4427. seriesIndex: i,
  4428. dataPointIndex: dataPointIndex,
  4429. finishRadius: w.config.chart.type === 'bubble' || w.globals.comboCharts && w.config.series[realIndex] && w.config.series[realIndex].type === 'bubble' ? finishRadius : null
  4430. });
  4431. finishRadius = markerConfig.pSize;
  4432. var pathFillCircle = fill.fillPath({
  4433. seriesNumber: realIndex,
  4434. dataPointIndex: dataPointIndex,
  4435. color: markerConfig.pointFillColor,
  4436. patternUnits: 'objectBoundingBox',
  4437. value: w.globals.series[realIndex][j]
  4438. });
  4439. var el;
  4440. if (markerConfig.shape === 'circle') {
  4441. el = graphics.drawCircle(radius);
  4442. } else if (markerConfig.shape === 'square' || markerConfig.shape === 'rect') {
  4443. el = graphics.drawRect(0, 0, markerConfig.width - markerConfig.pointStrokeWidth / 2, markerConfig.height - markerConfig.pointStrokeWidth / 2, markerConfig.pRadius);
  4444. }
  4445. if (w.config.series[i].data[dataPointIndex]) {
  4446. if (w.config.series[i].data[dataPointIndex].fillColor) {
  4447. pathFillCircle = w.config.series[i].data[dataPointIndex].fillColor;
  4448. }
  4449. }
  4450. el.attr({
  4451. x: x - markerConfig.width / 2 - markerConfig.pointStrokeWidth / 2,
  4452. y: y - markerConfig.height / 2 - markerConfig.pointStrokeWidth / 2,
  4453. cx: x,
  4454. cy: y,
  4455. fill: pathFillCircle,
  4456. 'fill-opacity': markerConfig.pointFillOpacity,
  4457. stroke: markerConfig.pointStrokeColor,
  4458. r: finishRadius,
  4459. 'stroke-width': markerConfig.pointStrokeWidth,
  4460. 'stroke-dasharray': markerConfig.pointStrokeDashArray,
  4461. 'stroke-opacity': markerConfig.pointStrokeOpacity
  4462. });
  4463. if (w.config.chart.dropShadow.enabled) {
  4464. var dropShadow = w.config.chart.dropShadow;
  4465. filters.dropShadow(el, dropShadow, realIndex);
  4466. }
  4467. if (this.initialAnim && !w.globals.dataChanged && !w.globals.resized) {
  4468. var speed = w.config.chart.animations.speed;
  4469. anim.animateMarker(el, 0, markerConfig.shape === 'circle' ? finishRadius : {
  4470. width: markerConfig.width,
  4471. height: markerConfig.height
  4472. }, speed, w.globals.easing, function () {
  4473. window.setTimeout(function () {
  4474. anim.animationCompleted(el);
  4475. }, 100);
  4476. });
  4477. } else {
  4478. w.globals.animationEnded = true;
  4479. }
  4480. if (w.globals.dataChanged && markerConfig.shape === 'circle') {
  4481. if (this.dynamicAnim) {
  4482. var _speed = w.config.chart.animations.dynamicAnimation.speed;
  4483. var prevX, prevY, prevR;
  4484. var prevPathJ = null;
  4485. prevPathJ = w.globals.previousPaths[realIndex] && w.globals.previousPaths[realIndex][j];
  4486. if (typeof prevPathJ !== 'undefined' && prevPathJ !== null) {
  4487. // series containing less elements will ignore these values and revert to 0
  4488. prevX = prevPathJ.x;
  4489. prevY = prevPathJ.y;
  4490. prevR = typeof prevPathJ.r !== 'undefined' ? prevPathJ.r : finishRadius;
  4491. }
  4492. for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) {
  4493. if (w.globals.collapsedSeries[cs].index === realIndex) {
  4494. _speed = 1;
  4495. finishRadius = 0;
  4496. }
  4497. }
  4498. if (x === 0 && y === 0) finishRadius = 0;
  4499. anim.animateCircle(el, {
  4500. cx: prevX,
  4501. cy: prevY,
  4502. r: prevR
  4503. }, {
  4504. cx: x,
  4505. cy: y,
  4506. r: finishRadius
  4507. }, _speed, w.globals.easing);
  4508. } else {
  4509. el.attr({
  4510. r: finishRadius
  4511. });
  4512. }
  4513. }
  4514. el.attr({
  4515. rel: dataPointIndex,
  4516. j: dataPointIndex,
  4517. index: realIndex,
  4518. 'default-marker-size': finishRadius
  4519. });
  4520. filters.setSelectionFilter(el, realIndex, dataPointIndex);
  4521. markers.addEvents(el);
  4522. el.node.classList.add('apexcharts-marker');
  4523. return el;
  4524. }
  4525. }, {
  4526. key: "centerTextInBubble",
  4527. value: function centerTextInBubble(y) {
  4528. var w = this.w;
  4529. y = y + parseInt(w.config.dataLabels.style.fontSize, 10) / 4;
  4530. return {
  4531. y: y
  4532. };
  4533. }
  4534. }]);
  4535. return Scatter;
  4536. }();
  4537. /**
  4538. * ApexCharts DataLabels Class for drawing dataLabels on Axes based Charts.
  4539. *
  4540. * @module DataLabels
  4541. **/
  4542. var DataLabels = /*#__PURE__*/function () {
  4543. function DataLabels(ctx) {
  4544. _classCallCheck(this, DataLabels);
  4545. this.ctx = ctx;
  4546. this.w = ctx.w;
  4547. } // 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
  4548. // Also, when datalabels exceeds the drawable area and get clipped off, we need to adjust and move some pixels to make them visible again
  4549. _createClass(DataLabels, [{
  4550. key: "dataLabelsCorrection",
  4551. value: function dataLabelsCorrection(x, y, val, i, dataPointIndex, alwaysDrawDataLabel, fontSize) {
  4552. var w = this.w;
  4553. var graphics = new Graphics(this.ctx);
  4554. var drawnextLabel = false; //
  4555. var textRects = graphics.getTextRects(val, fontSize);
  4556. var width = textRects.width;
  4557. var height = textRects.height;
  4558. if (y < 0) y = 0;
  4559. if (y > w.globals.gridHeight + height) y = w.globals.gridHeight + height / 2; // first value in series, so push an empty array
  4560. if (typeof w.globals.dataLabelsRects[i] === 'undefined') w.globals.dataLabelsRects[i] = []; // then start pushing actual rects in that sub-array
  4561. w.globals.dataLabelsRects[i].push({
  4562. x: x,
  4563. y: y,
  4564. width: width,
  4565. height: height
  4566. });
  4567. var len = w.globals.dataLabelsRects[i].length - 2;
  4568. var lastDrawnIndex = typeof w.globals.lastDrawnDataLabelsIndexes[i] !== 'undefined' ? w.globals.lastDrawnDataLabelsIndexes[i][w.globals.lastDrawnDataLabelsIndexes[i].length - 1] : 0;
  4569. if (typeof w.globals.dataLabelsRects[i][len] !== 'undefined') {
  4570. var lastDataLabelRect = w.globals.dataLabelsRects[i][lastDrawnIndex];
  4571. if ( // next label forward and x not intersecting
  4572. x > lastDataLabelRect.x + lastDataLabelRect.width + 2 || y > lastDataLabelRect.y + lastDataLabelRect.height + 2 || x + width < lastDataLabelRect.x // next label is going to be drawn backwards
  4573. ) {
  4574. // the 2 indexes don't override, so OK to draw next label
  4575. drawnextLabel = true;
  4576. }
  4577. }
  4578. if (dataPointIndex === 0 || alwaysDrawDataLabel) {
  4579. drawnextLabel = true;
  4580. }
  4581. return {
  4582. x: x,
  4583. y: y,
  4584. textRects: textRects,
  4585. drawnextLabel: drawnextLabel
  4586. };
  4587. }
  4588. }, {
  4589. key: "drawDataLabel",
  4590. value: function drawDataLabel(pos, i, j) {
  4591. var _this = this;
  4592. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
  4593. // this method handles line, area, bubble, scatter charts as those charts contains markers/points which have pre-defined x/y positions
  4594. // all other charts like radar / bars / heatmaps will define their own drawDataLabel routine
  4595. var w = this.w;
  4596. var graphics = new Graphics(this.ctx);
  4597. var dataLabelsConfig = w.config.dataLabels;
  4598. var x = 0;
  4599. var y = 0;
  4600. var dataPointIndex = j;
  4601. var elDataLabelsWrap = null;
  4602. if (!dataLabelsConfig.enabled || !Array.isArray(pos.x)) {
  4603. return elDataLabelsWrap;
  4604. }
  4605. elDataLabelsWrap = graphics.group({
  4606. class: 'apexcharts-data-labels'
  4607. });
  4608. for (var q = 0; q < pos.x.length; q++) {
  4609. x = pos.x[q] + dataLabelsConfig.offsetX;
  4610. y = pos.y[q] + dataLabelsConfig.offsetY + strokeWidth;
  4611. if (!isNaN(x)) {
  4612. // a small hack as we have 2 points for the first val to connect it
  4613. if (j === 1 && q === 0) dataPointIndex = 0;
  4614. if (j === 1 && q === 1) dataPointIndex = 1;
  4615. var val = w.globals.series[i][dataPointIndex];
  4616. var text = '';
  4617. var getText = function getText(v) {
  4618. return w.config.dataLabels.formatter(v, {
  4619. ctx: _this.ctx,
  4620. seriesIndex: i,
  4621. dataPointIndex: dataPointIndex,
  4622. w: w
  4623. });
  4624. };
  4625. if (w.config.chart.type === 'bubble') {
  4626. val = w.globals.seriesZ[i][dataPointIndex];
  4627. text = getText(val);
  4628. y = pos.y[q];
  4629. var scatter = new Scatter(this.ctx);
  4630. var centerTextInBubbleCoords = scatter.centerTextInBubble(y, i, dataPointIndex);
  4631. y = centerTextInBubbleCoords.y;
  4632. } else {
  4633. if (typeof val !== 'undefined') {
  4634. text = getText(val);
  4635. }
  4636. }
  4637. this.plotDataLabelsText({
  4638. x: x,
  4639. y: y,
  4640. text: text,
  4641. i: i,
  4642. j: dataPointIndex,
  4643. parent: elDataLabelsWrap,
  4644. offsetCorrection: true,
  4645. dataLabelsConfig: w.config.dataLabels
  4646. });
  4647. }
  4648. }
  4649. return elDataLabelsWrap;
  4650. }
  4651. }, {
  4652. key: "plotDataLabelsText",
  4653. value: function plotDataLabelsText(opts) {
  4654. var w = this.w;
  4655. var graphics = new Graphics(this.ctx);
  4656. var x = opts.x,
  4657. y = opts.y,
  4658. i = opts.i,
  4659. j = opts.j,
  4660. text = opts.text,
  4661. textAnchor = opts.textAnchor,
  4662. fontSize = opts.fontSize,
  4663. parent = opts.parent,
  4664. dataLabelsConfig = opts.dataLabelsConfig,
  4665. color = opts.color,
  4666. alwaysDrawDataLabel = opts.alwaysDrawDataLabel,
  4667. offsetCorrection = opts.offsetCorrection;
  4668. if (Array.isArray(w.config.dataLabels.enabledOnSeries)) {
  4669. if (w.config.dataLabels.enabledOnSeries.indexOf(i) < 0) {
  4670. return;
  4671. }
  4672. }
  4673. var correctedLabels = {
  4674. x: x,
  4675. y: y,
  4676. drawnextLabel: true,
  4677. textRects: null
  4678. };
  4679. if (offsetCorrection) {
  4680. correctedLabels = this.dataLabelsCorrection(x, y, text, i, j, alwaysDrawDataLabel, parseInt(dataLabelsConfig.style.fontSize, 10));
  4681. } // when zoomed, we don't need to correct labels offsets,
  4682. // but if normally, labels get cropped, correct them
  4683. if (!w.globals.zoomed) {
  4684. x = correctedLabels.x;
  4685. y = correctedLabels.y;
  4686. }
  4687. if (correctedLabels.textRects) {
  4688. // fixes #2264
  4689. if (x < -10 - correctedLabels.textRects.width || x > w.globals.gridWidth + correctedLabels.textRects.width + 10) {
  4690. // datalabels fall outside drawing area, so draw a blank label
  4691. text = '';
  4692. }
  4693. }
  4694. var dataLabelColor = w.globals.dataLabels.style.colors[i];
  4695. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.dataLabels.distributed) {
  4696. dataLabelColor = w.globals.dataLabels.style.colors[j];
  4697. }
  4698. if (typeof dataLabelColor === 'function') {
  4699. dataLabelColor = dataLabelColor({
  4700. series: w.globals.series,
  4701. seriesIndex: i,
  4702. dataPointIndex: j,
  4703. w: w
  4704. });
  4705. }
  4706. if (color) {
  4707. dataLabelColor = color;
  4708. }
  4709. var offX = dataLabelsConfig.offsetX;
  4710. var offY = dataLabelsConfig.offsetY;
  4711. if (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') {
  4712. // for certain chart types, we handle offsets while calculating datalabels pos
  4713. // why? because bars/column may have negative values and based on that
  4714. // offsets becomes reversed
  4715. offX = 0;
  4716. offY = 0;
  4717. }
  4718. if (correctedLabels.drawnextLabel) {
  4719. var dataLabelText = graphics.drawText({
  4720. width: 100,
  4721. height: parseInt(dataLabelsConfig.style.fontSize, 10),
  4722. x: x + offX,
  4723. y: y + offY,
  4724. foreColor: dataLabelColor,
  4725. textAnchor: textAnchor || dataLabelsConfig.textAnchor,
  4726. text: text,
  4727. fontSize: fontSize || dataLabelsConfig.style.fontSize,
  4728. fontFamily: dataLabelsConfig.style.fontFamily,
  4729. fontWeight: dataLabelsConfig.style.fontWeight || 'normal'
  4730. });
  4731. dataLabelText.attr({
  4732. class: 'apexcharts-datalabel',
  4733. cx: x,
  4734. cy: y
  4735. });
  4736. if (dataLabelsConfig.dropShadow.enabled) {
  4737. var textShadow = dataLabelsConfig.dropShadow;
  4738. var filters = new Filters(this.ctx);
  4739. filters.dropShadow(dataLabelText, textShadow);
  4740. }
  4741. parent.add(dataLabelText);
  4742. if (typeof w.globals.lastDrawnDataLabelsIndexes[i] === 'undefined') {
  4743. w.globals.lastDrawnDataLabelsIndexes[i] = [];
  4744. }
  4745. w.globals.lastDrawnDataLabelsIndexes[i].push(j);
  4746. }
  4747. }
  4748. }, {
  4749. key: "addBackgroundToDataLabel",
  4750. value: function addBackgroundToDataLabel(el, coords) {
  4751. var w = this.w;
  4752. var bCnf = w.config.dataLabels.background;
  4753. var paddingH = bCnf.padding;
  4754. var paddingV = bCnf.padding / 2;
  4755. var width = coords.width;
  4756. var height = coords.height;
  4757. var graphics = new Graphics(this.ctx);
  4758. 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);
  4759. if (bCnf.dropShadow.enabled) {
  4760. var filters = new Filters(this.ctx);
  4761. filters.dropShadow(elRect, bCnf.dropShadow);
  4762. }
  4763. return elRect;
  4764. }
  4765. }, {
  4766. key: "dataLabelsBackground",
  4767. value: function dataLabelsBackground() {
  4768. var w = this.w;
  4769. if (w.config.chart.type === 'bubble') return;
  4770. var elDataLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-datalabels text');
  4771. for (var i = 0; i < elDataLabels.length; i++) {
  4772. var el = elDataLabels[i];
  4773. var coords = el.getBBox();
  4774. var elRect = null;
  4775. if (coords.width && coords.height) {
  4776. elRect = this.addBackgroundToDataLabel(el, coords);
  4777. }
  4778. if (elRect) {
  4779. el.parentNode.insertBefore(elRect.node, el);
  4780. var background = el.getAttribute('fill');
  4781. var shouldAnim = w.config.chart.animations.enabled && !w.globals.resized && !w.globals.dataChanged;
  4782. if (shouldAnim) {
  4783. elRect.animate().attr({
  4784. fill: background
  4785. });
  4786. } else {
  4787. elRect.attr({
  4788. fill: background
  4789. });
  4790. }
  4791. el.setAttribute('fill', w.config.dataLabels.background.foreColor);
  4792. }
  4793. }
  4794. }
  4795. }, {
  4796. key: "bringForward",
  4797. value: function bringForward() {
  4798. var w = this.w;
  4799. var elDataLabelsNodes = w.globals.dom.baseEl.querySelectorAll('.apexcharts-datalabels');
  4800. var elSeries = w.globals.dom.baseEl.querySelector('.apexcharts-plot-series:last-child');
  4801. for (var i = 0; i < elDataLabelsNodes.length; i++) {
  4802. if (elSeries) {
  4803. elSeries.insertBefore(elDataLabelsNodes[i], elSeries.nextSibling);
  4804. }
  4805. }
  4806. }
  4807. }]);
  4808. return DataLabels;
  4809. }();
  4810. var BarDataLabels = /*#__PURE__*/function () {
  4811. function BarDataLabels(barCtx) {
  4812. _classCallCheck(this, BarDataLabels);
  4813. this.w = barCtx.w;
  4814. this.barCtx = barCtx;
  4815. }
  4816. /** handleBarDataLabels is used to calculate the positions for the data-labels
  4817. * It also sets the element's data attr for bars and calls drawCalculatedBarDataLabels()
  4818. * After calculating, it also calls the function to draw data labels
  4819. * @memberof Bar
  4820. * @param {object} {barProps} most of the bar properties used throughout the bar
  4821. * drawing function
  4822. * @return {object} dataLabels node-element which you can append later
  4823. **/
  4824. _createClass(BarDataLabels, [{
  4825. key: "handleBarDataLabels",
  4826. value: function handleBarDataLabels(opts) {
  4827. var x = opts.x,
  4828. y = opts.y,
  4829. y1 = opts.y1,
  4830. y2 = opts.y2,
  4831. i = opts.i,
  4832. j = opts.j,
  4833. realIndex = opts.realIndex,
  4834. series = opts.series,
  4835. barHeight = opts.barHeight,
  4836. barWidth = opts.barWidth,
  4837. barYPosition = opts.barYPosition,
  4838. visibleSeries = opts.visibleSeries,
  4839. renderedPath = opts.renderedPath;
  4840. var w = this.w;
  4841. var graphics = new Graphics(this.barCtx.ctx);
  4842. var strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  4843. var bcx = x + parseFloat(barWidth * visibleSeries);
  4844. var bcy = y + parseFloat(barHeight * visibleSeries);
  4845. if (w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  4846. bcx = x + parseFloat(barWidth * (visibleSeries + 1));
  4847. bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth;
  4848. }
  4849. var dataLabels = null;
  4850. var dataLabelsX = x;
  4851. var dataLabelsY = y;
  4852. var dataLabelsPos = {};
  4853. var dataLabelsConfig = w.config.dataLabels;
  4854. var barDataLabelsConfig = this.barCtx.barOptions.dataLabels;
  4855. if (typeof barYPosition !== 'undefined' && this.barCtx.isRangeBar) {
  4856. bcy = barYPosition;
  4857. dataLabelsY = barYPosition;
  4858. }
  4859. var offX = dataLabelsConfig.offsetX;
  4860. var offY = dataLabelsConfig.offsetY;
  4861. var textRects = {
  4862. width: 0,
  4863. height: 0
  4864. };
  4865. if (w.config.dataLabels.enabled) {
  4866. var yLabel = this.barCtx.series[i][j];
  4867. textRects = graphics.getTextRects(w.globals.yLabelFormatters[0](yLabel), parseFloat(dataLabelsConfig.style.fontSize));
  4868. }
  4869. var params = {
  4870. x: x,
  4871. y: y,
  4872. i: i,
  4873. j: j,
  4874. renderedPath: renderedPath,
  4875. bcx: bcx,
  4876. bcy: bcy,
  4877. barHeight: barHeight,
  4878. barWidth: barWidth,
  4879. textRects: textRects,
  4880. strokeWidth: strokeWidth,
  4881. dataLabelsX: dataLabelsX,
  4882. dataLabelsY: dataLabelsY,
  4883. barDataLabelsConfig: barDataLabelsConfig,
  4884. offX: offX,
  4885. offY: offY
  4886. };
  4887. if (this.barCtx.isHorizontal) {
  4888. dataLabelsPos = this.calculateBarsDataLabelsPosition(params);
  4889. } else {
  4890. dataLabelsPos = this.calculateColumnsDataLabelsPosition(params);
  4891. }
  4892. renderedPath.attr({
  4893. cy: dataLabelsPos.bcy,
  4894. cx: dataLabelsPos.bcx,
  4895. j: j,
  4896. val: series[i][j],
  4897. barHeight: barHeight,
  4898. barWidth: barWidth
  4899. });
  4900. dataLabels = this.drawCalculatedDataLabels({
  4901. x: dataLabelsPos.dataLabelsX,
  4902. y: dataLabelsPos.dataLabelsY,
  4903. val: this.barCtx.isRangeBar ? [y1, y2] : series[i][j],
  4904. i: realIndex,
  4905. j: j,
  4906. barWidth: barWidth,
  4907. barHeight: barHeight,
  4908. textRects: textRects,
  4909. dataLabelsConfig: dataLabelsConfig
  4910. });
  4911. return dataLabels;
  4912. }
  4913. }, {
  4914. key: "calculateColumnsDataLabelsPosition",
  4915. value: function calculateColumnsDataLabelsPosition(opts) {
  4916. var w = this.w;
  4917. var i = opts.i,
  4918. j = opts.j,
  4919. y = opts.y,
  4920. bcx = opts.bcx,
  4921. barWidth = opts.barWidth,
  4922. barHeight = opts.barHeight,
  4923. textRects = opts.textRects,
  4924. dataLabelsY = opts.dataLabelsY,
  4925. barDataLabelsConfig = opts.barDataLabelsConfig,
  4926. strokeWidth = opts.strokeWidth,
  4927. offX = opts.offX,
  4928. offY = opts.offY;
  4929. var dataLabelsX;
  4930. barHeight = Math.abs(barHeight);
  4931. var vertical = w.config.plotOptions.bar.dataLabels.orientation === 'vertical';
  4932. bcx = bcx - strokeWidth / 2;
  4933. var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  4934. if (w.globals.isXNumeric) {
  4935. dataLabelsX = bcx - barWidth / 2 + offX;
  4936. } else {
  4937. dataLabelsX = bcx - dataPointsDividedWidth + barWidth / 2 + offX;
  4938. }
  4939. if (vertical) {
  4940. var offsetDLX = 2;
  4941. dataLabelsX = dataLabelsX + textRects.height / 2 - strokeWidth / 2 - offsetDLX;
  4942. }
  4943. var valIsNegative = this.barCtx.series[i][j] < 0;
  4944. var newY = y;
  4945. if (this.barCtx.isReversed) {
  4946. newY = y - barHeight + (valIsNegative ? barHeight * 2 : 0);
  4947. y = y - barHeight;
  4948. }
  4949. switch (barDataLabelsConfig.position) {
  4950. case 'center':
  4951. if (vertical) {
  4952. if (valIsNegative) {
  4953. dataLabelsY = newY + barHeight / 2 + offY;
  4954. } else {
  4955. dataLabelsY = newY + barHeight / 2 - offY;
  4956. }
  4957. } else {
  4958. if (valIsNegative) {
  4959. dataLabelsY = newY - barHeight / 2 + textRects.height / 2 + offY;
  4960. } else {
  4961. dataLabelsY = newY + barHeight / 2 + textRects.height / 2 - offY;
  4962. }
  4963. }
  4964. break;
  4965. case 'bottom':
  4966. if (vertical) {
  4967. if (valIsNegative) {
  4968. dataLabelsY = newY + barHeight + offY;
  4969. } else {
  4970. dataLabelsY = newY + barHeight - offY;
  4971. }
  4972. } else {
  4973. if (valIsNegative) {
  4974. dataLabelsY = newY - barHeight + textRects.height + strokeWidth + offY;
  4975. } else {
  4976. dataLabelsY = newY + barHeight - textRects.height / 2 + strokeWidth - offY;
  4977. }
  4978. }
  4979. break;
  4980. case 'top':
  4981. if (vertical) {
  4982. if (valIsNegative) {
  4983. dataLabelsY = newY + offY;
  4984. } else {
  4985. dataLabelsY = newY - offY;
  4986. }
  4987. } else {
  4988. if (valIsNegative) {
  4989. dataLabelsY = newY - textRects.height / 2 - offY;
  4990. } else {
  4991. dataLabelsY = newY + textRects.height + offY;
  4992. }
  4993. }
  4994. break;
  4995. }
  4996. if (!w.config.chart.stacked) {
  4997. if (dataLabelsY < 0) {
  4998. dataLabelsY = 0 + strokeWidth;
  4999. } else if (dataLabelsY + textRects.height / 3 > w.globals.gridHeight) {
  5000. dataLabelsY = w.globals.gridHeight - strokeWidth;
  5001. }
  5002. }
  5003. return {
  5004. bcx: bcx,
  5005. bcy: y,
  5006. dataLabelsX: dataLabelsX,
  5007. dataLabelsY: dataLabelsY
  5008. };
  5009. }
  5010. }, {
  5011. key: "calculateBarsDataLabelsPosition",
  5012. value: function calculateBarsDataLabelsPosition(opts) {
  5013. var w = this.w;
  5014. var x = opts.x,
  5015. i = opts.i,
  5016. j = opts.j,
  5017. bcy = opts.bcy,
  5018. barHeight = opts.barHeight,
  5019. barWidth = opts.barWidth,
  5020. textRects = opts.textRects,
  5021. dataLabelsX = opts.dataLabelsX,
  5022. strokeWidth = opts.strokeWidth,
  5023. barDataLabelsConfig = opts.barDataLabelsConfig,
  5024. offX = opts.offX,
  5025. offY = opts.offY;
  5026. var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  5027. barWidth = Math.abs(barWidth);
  5028. var dataLabelsY = bcy - (this.barCtx.isRangeBar ? 0 : dataPointsDividedHeight) + barHeight / 2 + textRects.height / 2 + offY - 3;
  5029. var valIsNegative = this.barCtx.series[i][j] < 0;
  5030. var newX = x;
  5031. if (this.barCtx.isReversed) {
  5032. newX = x + barWidth - (valIsNegative ? barWidth * 2 : 0);
  5033. x = w.globals.gridWidth - barWidth;
  5034. }
  5035. switch (barDataLabelsConfig.position) {
  5036. case 'center':
  5037. if (valIsNegative) {
  5038. dataLabelsX = newX + barWidth / 2 - offX;
  5039. } else {
  5040. dataLabelsX = Math.max(textRects.width / 2, newX - barWidth / 2) + offX;
  5041. }
  5042. break;
  5043. case 'bottom':
  5044. if (valIsNegative) {
  5045. dataLabelsX = newX + barWidth - strokeWidth - Math.round(textRects.width / 2) - offX;
  5046. } else {
  5047. dataLabelsX = newX - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX;
  5048. }
  5049. break;
  5050. case 'top':
  5051. if (valIsNegative) {
  5052. dataLabelsX = newX - strokeWidth + Math.round(textRects.width / 2) - offX;
  5053. } else {
  5054. dataLabelsX = newX - strokeWidth - Math.round(textRects.width / 2) + offX;
  5055. }
  5056. break;
  5057. }
  5058. if (!w.config.chart.stacked) {
  5059. if (dataLabelsX < 0) {
  5060. dataLabelsX = dataLabelsX + textRects.width + strokeWidth;
  5061. } else if (dataLabelsX + textRects.width / 2 > w.globals.gridWidth) {
  5062. dataLabelsX = w.globals.gridWidth - textRects.width - strokeWidth;
  5063. }
  5064. }
  5065. return {
  5066. bcx: x,
  5067. bcy: bcy,
  5068. dataLabelsX: dataLabelsX,
  5069. dataLabelsY: dataLabelsY
  5070. };
  5071. }
  5072. }, {
  5073. key: "drawCalculatedDataLabels",
  5074. value: function drawCalculatedDataLabels(_ref) {
  5075. var x = _ref.x,
  5076. y = _ref.y,
  5077. val = _ref.val,
  5078. i = _ref.i,
  5079. j = _ref.j,
  5080. textRects = _ref.textRects,
  5081. barHeight = _ref.barHeight,
  5082. barWidth = _ref.barWidth,
  5083. dataLabelsConfig = _ref.dataLabelsConfig;
  5084. var w = this.w;
  5085. var rotate = 'rotate(0)';
  5086. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') rotate = "rotate(-90, ".concat(x, ", ").concat(y, ")");
  5087. var dataLabels = new DataLabels(this.barCtx.ctx);
  5088. var graphics = new Graphics(this.barCtx.ctx);
  5089. var formatter = dataLabelsConfig.formatter;
  5090. var elDataLabelsWrap = null;
  5091. var isSeriesNotCollapsed = w.globals.collapsedSeriesIndices.indexOf(i) > -1;
  5092. if (dataLabelsConfig.enabled && !isSeriesNotCollapsed) {
  5093. elDataLabelsWrap = graphics.group({
  5094. class: 'apexcharts-data-labels',
  5095. transform: rotate
  5096. });
  5097. var text = '';
  5098. if (typeof val !== 'undefined') {
  5099. text = formatter(val, {
  5100. seriesIndex: i,
  5101. dataPointIndex: j,
  5102. w: w
  5103. });
  5104. }
  5105. var valIsNegative = w.globals.series[i][j] < 0;
  5106. var position = w.config.plotOptions.bar.dataLabels.position;
  5107. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
  5108. if (position === 'top') {
  5109. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  5110. }
  5111. if (position === 'center') {
  5112. dataLabelsConfig.textAnchor = 'middle';
  5113. }
  5114. if (position === 'bottom') {
  5115. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  5116. }
  5117. }
  5118. if (this.barCtx.isRangeBar && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  5119. // hide the datalabel if it cannot fit into the rect
  5120. var txRect = graphics.getTextRects(text, parseFloat(dataLabelsConfig.style.fontSize));
  5121. if (barWidth < txRect.width) {
  5122. text = '';
  5123. }
  5124. }
  5125. if (w.config.chart.stacked && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  5126. // if there is not enough space to draw the label in the bar/column rect, check hideOverflowingLabels property to prevent overflowing on wrong rect
  5127. // Note: This issue is only seen in stacked charts
  5128. if (this.barCtx.isHorizontal) {
  5129. if (textRects.width / 1.6 > Math.abs(barWidth)) {
  5130. text = '';
  5131. }
  5132. } else {
  5133. if (textRects.height / 1.6 > Math.abs(barHeight)) {
  5134. text = '';
  5135. }
  5136. }
  5137. }
  5138. var modifiedDataLabelsConfig = _objectSpread2({}, dataLabelsConfig);
  5139. if (this.barCtx.isHorizontal) {
  5140. if (val < 0) {
  5141. if (dataLabelsConfig.textAnchor === 'start') {
  5142. modifiedDataLabelsConfig.textAnchor = 'end';
  5143. } else if (dataLabelsConfig.textAnchor === 'end') {
  5144. modifiedDataLabelsConfig.textAnchor = 'start';
  5145. }
  5146. }
  5147. }
  5148. dataLabels.plotDataLabelsText({
  5149. x: x,
  5150. y: y,
  5151. text: text,
  5152. i: i,
  5153. j: j,
  5154. parent: elDataLabelsWrap,
  5155. dataLabelsConfig: modifiedDataLabelsConfig,
  5156. alwaysDrawDataLabel: true,
  5157. offsetCorrection: true
  5158. });
  5159. }
  5160. return elDataLabelsWrap;
  5161. }
  5162. }]);
  5163. return BarDataLabels;
  5164. }();
  5165. /**
  5166. * ApexCharts Series Class for interaction with the Series of the chart.
  5167. *
  5168. * @module Series
  5169. **/
  5170. var Series = /*#__PURE__*/function () {
  5171. function Series(ctx) {
  5172. _classCallCheck(this, Series);
  5173. this.ctx = ctx;
  5174. this.w = ctx.w;
  5175. this.legendInactiveClass = 'legend-mouseover-inactive';
  5176. }
  5177. _createClass(Series, [{
  5178. key: "getAllSeriesEls",
  5179. value: function getAllSeriesEls() {
  5180. return this.w.globals.dom.baseEl.getElementsByClassName("apexcharts-series");
  5181. }
  5182. }, {
  5183. key: "getSeriesByName",
  5184. value: function getSeriesByName(seriesName) {
  5185. return this.w.globals.dom.baseEl.querySelector(".apexcharts-inner .apexcharts-series[seriesName='".concat(Utils$1.escapeString(seriesName), "']"));
  5186. }
  5187. }, {
  5188. key: "isSeriesHidden",
  5189. value: function isSeriesHidden(seriesName) {
  5190. var targetElement = this.getSeriesByName(seriesName);
  5191. var realIndex = parseInt(targetElement.getAttribute('data:realIndex'), 10);
  5192. var isHidden = targetElement.classList.contains('apexcharts-series-collapsed');
  5193. return {
  5194. isHidden: isHidden,
  5195. realIndex: realIndex
  5196. };
  5197. }
  5198. }, {
  5199. key: "addCollapsedClassToSeries",
  5200. value: function addCollapsedClassToSeries(elSeries, index) {
  5201. var w = this.w;
  5202. function iterateOnAllCollapsedSeries(series) {
  5203. for (var cs = 0; cs < series.length; cs++) {
  5204. if (series[cs].index === index) {
  5205. elSeries.node.classList.add('apexcharts-series-collapsed');
  5206. }
  5207. }
  5208. }
  5209. iterateOnAllCollapsedSeries(w.globals.collapsedSeries);
  5210. iterateOnAllCollapsedSeries(w.globals.ancillaryCollapsedSeries);
  5211. }
  5212. }, {
  5213. key: "toggleSeries",
  5214. value: function toggleSeries(seriesName) {
  5215. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5216. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, isSeriesHidden.isHidden);
  5217. return isSeriesHidden.isHidden;
  5218. }
  5219. }, {
  5220. key: "showSeries",
  5221. value: function showSeries(seriesName) {
  5222. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5223. if (isSeriesHidden.isHidden) {
  5224. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, true);
  5225. }
  5226. }
  5227. }, {
  5228. key: "hideSeries",
  5229. value: function hideSeries(seriesName) {
  5230. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5231. if (!isSeriesHidden.isHidden) {
  5232. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, false);
  5233. }
  5234. }
  5235. }, {
  5236. key: "resetSeries",
  5237. value: function resetSeries() {
  5238. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  5239. var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5240. var shouldResetCollapsed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5241. var w = this.w;
  5242. var series = Utils$1.clone(w.globals.initialSeries);
  5243. w.globals.previousPaths = [];
  5244. if (shouldResetCollapsed) {
  5245. w.globals.collapsedSeries = [];
  5246. w.globals.ancillaryCollapsedSeries = [];
  5247. w.globals.collapsedSeriesIndices = [];
  5248. w.globals.ancillaryCollapsedSeriesIndices = [];
  5249. } else {
  5250. series = this.emptyCollapsedSeries(series);
  5251. }
  5252. w.config.series = series;
  5253. if (shouldUpdateChart) {
  5254. if (shouldResetZoom) {
  5255. w.globals.zoomed = false;
  5256. this.ctx.updateHelpers.revertDefaultAxisMinMax();
  5257. }
  5258. this.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  5259. }
  5260. }
  5261. }, {
  5262. key: "emptyCollapsedSeries",
  5263. value: function emptyCollapsedSeries(series) {
  5264. var w = this.w;
  5265. for (var i = 0; i < series.length; i++) {
  5266. if (w.globals.collapsedSeriesIndices.indexOf(i) > -1) {
  5267. series[i].data = [];
  5268. }
  5269. }
  5270. return series;
  5271. }
  5272. }, {
  5273. key: "toggleSeriesOnHover",
  5274. value: function toggleSeriesOnHover(e, targetElement) {
  5275. var w = this.w;
  5276. if (!targetElement) targetElement = e.target;
  5277. var allSeriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");
  5278. if (e.type === 'mousemove') {
  5279. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  5280. var seriesEl = null;
  5281. var dataLabelEl = null;
  5282. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  5283. if (w.globals.axisCharts) {
  5284. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  5285. dataLabelEl = w.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(seriesCnt, "']"));
  5286. } else {
  5287. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  5288. }
  5289. } else {
  5290. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  5291. }
  5292. for (var se = 0; se < allSeriesEls.length; se++) {
  5293. allSeriesEls[se].classList.add(this.legendInactiveClass);
  5294. }
  5295. if (seriesEl !== null) {
  5296. if (!w.globals.axisCharts) {
  5297. seriesEl.parentNode.classList.remove(this.legendInactiveClass);
  5298. }
  5299. seriesEl.classList.remove(this.legendInactiveClass);
  5300. if (dataLabelEl !== null) {
  5301. dataLabelEl.classList.remove(this.legendInactiveClass);
  5302. }
  5303. }
  5304. } else if (e.type === 'mouseout') {
  5305. for (var _se = 0; _se < allSeriesEls.length; _se++) {
  5306. allSeriesEls[_se].classList.remove(this.legendInactiveClass);
  5307. }
  5308. }
  5309. }
  5310. }, {
  5311. key: "highlightRangeInSeries",
  5312. value: function highlightRangeInSeries(e, targetElement) {
  5313. var _this = this;
  5314. var w = this.w;
  5315. var allHeatMapElements = w.globals.dom.baseEl.getElementsByClassName('apexcharts-heatmap-rect');
  5316. var activeInactive = function activeInactive(action) {
  5317. for (var i = 0; i < allHeatMapElements.length; i++) {
  5318. allHeatMapElements[i].classList[action](_this.legendInactiveClass);
  5319. }
  5320. };
  5321. var removeInactiveClassFromHoveredRange = function removeInactiveClassFromHoveredRange(range) {
  5322. for (var i = 0; i < allHeatMapElements.length; i++) {
  5323. var val = parseInt(allHeatMapElements[i].getAttribute('val'), 10);
  5324. if (val >= range.from && val <= range.to) {
  5325. allHeatMapElements[i].classList.remove(_this.legendInactiveClass);
  5326. }
  5327. }
  5328. };
  5329. if (e.type === 'mousemove') {
  5330. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  5331. activeInactive('add');
  5332. var range = w.config.plotOptions.heatmap.colorScale.ranges[seriesCnt];
  5333. removeInactiveClassFromHoveredRange(range);
  5334. } else if (e.type === 'mouseout') {
  5335. activeInactive('remove');
  5336. }
  5337. }
  5338. }, {
  5339. key: "getActiveConfigSeriesIndex",
  5340. value: function getActiveConfigSeriesIndex() {
  5341. var ignoreBars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5342. var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'asc';
  5343. var w = this.w;
  5344. var activeIndex = 0;
  5345. if (w.config.series.length > 1) {
  5346. // active series flag is required to know if user has not deactivated via legend click
  5347. var activeSeriesIndex = w.config.series.map(function (s, index) {
  5348. var hasBars = false;
  5349. if (ignoreBars) {
  5350. hasBars = w.config.series[index].type === 'bar' || w.config.series[index].type === 'column';
  5351. }
  5352. return s.data && s.data.length > 0 && !hasBars ? index : -1;
  5353. });
  5354. for (var a = order === 'asc' ? 0 : activeSeriesIndex.length - 1; order === 'asc' ? a < activeSeriesIndex.length : a >= 0; order === 'asc' ? a++ : a--) {
  5355. if (activeSeriesIndex[a] !== -1) {
  5356. activeIndex = activeSeriesIndex[a];
  5357. break;
  5358. }
  5359. }
  5360. }
  5361. return activeIndex;
  5362. }
  5363. }, {
  5364. key: "getPreviousPaths",
  5365. value: function getPreviousPaths() {
  5366. var w = this.w;
  5367. w.globals.previousPaths = [];
  5368. function pushPaths(seriesEls, i, type) {
  5369. var paths = seriesEls[i].childNodes;
  5370. var dArr = {
  5371. type: type,
  5372. paths: [],
  5373. realIndex: seriesEls[i].getAttribute('data:realIndex')
  5374. };
  5375. for (var j = 0; j < paths.length; j++) {
  5376. if (paths[j].hasAttribute('pathTo')) {
  5377. var d = paths[j].getAttribute('pathTo');
  5378. dArr.paths.push({
  5379. d: d
  5380. });
  5381. }
  5382. }
  5383. w.globals.previousPaths.push(dArr);
  5384. }
  5385. var getPaths = function getPaths(chartType) {
  5386. return w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(chartType, "-series .apexcharts-series"));
  5387. };
  5388. var chartTypes = ['line', 'area', 'bar', 'rangebar', 'candlestick', 'radar'];
  5389. chartTypes.forEach(function (type) {
  5390. var paths = getPaths(type);
  5391. for (var p = 0; p < paths.length; p++) {
  5392. pushPaths(paths, p, type);
  5393. }
  5394. });
  5395. this.handlePrevBubbleScatterPaths('bubble');
  5396. this.handlePrevBubbleScatterPaths('scatter');
  5397. var heatTreeSeries = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(w.config.chart.type, " .apexcharts-series"));
  5398. if (heatTreeSeries.length > 0) {
  5399. var _loop = function _loop(h) {
  5400. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(w.config.chart.type, " .apexcharts-series[data\\:realIndex='").concat(h, "'] rect"));
  5401. var dArr = [];
  5402. var _loop2 = function _loop2(i) {
  5403. var getAttr = function getAttr(x) {
  5404. return seriesEls[i].getAttribute(x);
  5405. };
  5406. var rect = {
  5407. x: parseFloat(getAttr('x')),
  5408. y: parseFloat(getAttr('y')),
  5409. width: parseFloat(getAttr('width')),
  5410. height: parseFloat(getAttr('height'))
  5411. };
  5412. dArr.push({
  5413. rect: rect,
  5414. color: seriesEls[i].getAttribute('color')
  5415. });
  5416. };
  5417. for (var i = 0; i < seriesEls.length; i++) {
  5418. _loop2(i);
  5419. }
  5420. w.globals.previousPaths.push(dArr);
  5421. };
  5422. for (var h = 0; h < heatTreeSeries.length; h++) {
  5423. _loop(h);
  5424. }
  5425. }
  5426. if (!w.globals.axisCharts) {
  5427. // for non-axis charts (i.e., circular charts, pathFrom is not usable. We need whole series)
  5428. w.globals.previousPaths = w.globals.series;
  5429. }
  5430. }
  5431. }, {
  5432. key: "handlePrevBubbleScatterPaths",
  5433. value: function handlePrevBubbleScatterPaths(type) {
  5434. var w = this.w;
  5435. var paths = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series"));
  5436. if (paths.length > 0) {
  5437. for (var s = 0; s < paths.length; s++) {
  5438. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series[data\\:realIndex='").concat(s, "'] circle"));
  5439. var dArr = [];
  5440. for (var i = 0; i < seriesEls.length; i++) {
  5441. dArr.push({
  5442. x: seriesEls[i].getAttribute('cx'),
  5443. y: seriesEls[i].getAttribute('cy'),
  5444. r: seriesEls[i].getAttribute('r')
  5445. });
  5446. }
  5447. w.globals.previousPaths.push(dArr);
  5448. }
  5449. }
  5450. }
  5451. }, {
  5452. key: "clearPreviousPaths",
  5453. value: function clearPreviousPaths() {
  5454. var w = this.w;
  5455. w.globals.previousPaths = [];
  5456. w.globals.allSeriesCollapsed = false;
  5457. }
  5458. }, {
  5459. key: "handleNoData",
  5460. value: function handleNoData() {
  5461. var w = this.w;
  5462. var me = this;
  5463. var noDataOpts = w.config.noData;
  5464. var graphics = new Graphics(me.ctx);
  5465. var x = w.globals.svgWidth / 2;
  5466. var y = w.globals.svgHeight / 2;
  5467. var textAnchor = 'middle';
  5468. w.globals.noData = true;
  5469. w.globals.animationEnded = true;
  5470. if (noDataOpts.align === 'left') {
  5471. x = 10;
  5472. textAnchor = 'start';
  5473. } else if (noDataOpts.align === 'right') {
  5474. x = w.globals.svgWidth - 10;
  5475. textAnchor = 'end';
  5476. }
  5477. if (noDataOpts.verticalAlign === 'top') {
  5478. y = 50;
  5479. } else if (noDataOpts.verticalAlign === 'bottom') {
  5480. y = w.globals.svgHeight - 50;
  5481. }
  5482. x = x + noDataOpts.offsetX;
  5483. y = y + parseInt(noDataOpts.style.fontSize, 10) + 2 + noDataOpts.offsetY;
  5484. if (noDataOpts.text !== undefined && noDataOpts.text !== '') {
  5485. var titleText = graphics.drawText({
  5486. x: x,
  5487. y: y,
  5488. text: noDataOpts.text,
  5489. textAnchor: textAnchor,
  5490. fontSize: noDataOpts.style.fontSize,
  5491. fontFamily: noDataOpts.style.fontFamily,
  5492. foreColor: noDataOpts.style.color,
  5493. opacity: 1,
  5494. class: 'apexcharts-text-nodata'
  5495. });
  5496. w.globals.dom.Paper.add(titleText);
  5497. }
  5498. } // When user clicks on legends, the collapsed series is filled with [0,0,0,...,0]
  5499. // This is because we don't want to alter the series' length as it is used at many places
  5500. }, {
  5501. key: "setNullSeriesToZeroValues",
  5502. value: function setNullSeriesToZeroValues(series) {
  5503. var w = this.w;
  5504. for (var sl = 0; sl < series.length; sl++) {
  5505. if (series[sl].length === 0) {
  5506. for (var j = 0; j < series[w.globals.maxValsInArrayIndex].length; j++) {
  5507. series[sl].push(0);
  5508. }
  5509. }
  5510. }
  5511. return series;
  5512. }
  5513. }, {
  5514. key: "hasAllSeriesEqualX",
  5515. value: function hasAllSeriesEqualX() {
  5516. var equalLen = true;
  5517. var w = this.w;
  5518. var filteredSerX = this.filteredSeriesX();
  5519. for (var i = 0; i < filteredSerX.length - 1; i++) {
  5520. if (filteredSerX[i][0] !== filteredSerX[i + 1][0]) {
  5521. equalLen = false;
  5522. break;
  5523. }
  5524. }
  5525. w.globals.allSeriesHasEqualX = equalLen;
  5526. return equalLen;
  5527. }
  5528. }, {
  5529. key: "filteredSeriesX",
  5530. value: function filteredSeriesX() {
  5531. var w = this.w;
  5532. var filteredSeriesX = w.globals.seriesX.map(function (ser) {
  5533. return ser.length > 0 ? ser : [];
  5534. });
  5535. return filteredSeriesX;
  5536. }
  5537. }]);
  5538. return Series;
  5539. }();
  5540. var Helpers$3 = /*#__PURE__*/function () {
  5541. function Helpers(barCtx) {
  5542. _classCallCheck(this, Helpers);
  5543. this.w = barCtx.w;
  5544. this.barCtx = barCtx;
  5545. }
  5546. _createClass(Helpers, [{
  5547. key: "initVariables",
  5548. value: function initVariables(series) {
  5549. var w = this.w;
  5550. this.barCtx.series = series;
  5551. this.barCtx.totalItems = 0;
  5552. this.barCtx.seriesLen = 0;
  5553. this.barCtx.visibleI = -1; // visible Series
  5554. this.barCtx.visibleItems = 1; // number of visible bars after user zoomed in/out
  5555. for (var sl = 0; sl < series.length; sl++) {
  5556. if (series[sl].length > 0) {
  5557. this.barCtx.seriesLen = this.barCtx.seriesLen + 1;
  5558. this.barCtx.totalItems += series[sl].length;
  5559. }
  5560. if (w.globals.isXNumeric) {
  5561. // get max visible items
  5562. for (var j = 0; j < series[sl].length; j++) {
  5563. if (w.globals.seriesX[sl][j] > w.globals.minX && w.globals.seriesX[sl][j] < w.globals.maxX) {
  5564. this.barCtx.visibleItems++;
  5565. }
  5566. }
  5567. } else {
  5568. this.barCtx.visibleItems = w.globals.dataPoints;
  5569. }
  5570. }
  5571. if (this.barCtx.seriesLen === 0) {
  5572. // A small adjustment when combo charts are used
  5573. this.barCtx.seriesLen = 1;
  5574. }
  5575. this.barCtx.zeroSerieses = [];
  5576. this.barCtx.radiusOnSeriesNumber = series.length - 1; // which series to draw ending shape on
  5577. if (!w.globals.comboCharts) {
  5578. this.checkZeroSeries({
  5579. series: series
  5580. });
  5581. }
  5582. }
  5583. }, {
  5584. key: "initialPositions",
  5585. value: function initialPositions() {
  5586. var w = this.w;
  5587. var x, y, yDivision, xDivision, barHeight, barWidth, zeroH, zeroW;
  5588. var dataPoints = w.globals.dataPoints;
  5589. if (this.barCtx.isRangeBar) {
  5590. // timeline rangebar chart
  5591. dataPoints = w.globals.labels.length;
  5592. }
  5593. var seriesLen = this.barCtx.seriesLen;
  5594. if (w.config.plotOptions.bar.rangeBarGroupRows) {
  5595. seriesLen = 1;
  5596. }
  5597. if (this.barCtx.isHorizontal) {
  5598. // height divided into equal parts
  5599. yDivision = w.globals.gridHeight / dataPoints;
  5600. barHeight = yDivision / seriesLen;
  5601. if (w.globals.isXNumeric) {
  5602. yDivision = w.globals.gridHeight / this.barCtx.totalItems;
  5603. barHeight = yDivision / this.barCtx.seriesLen;
  5604. }
  5605. barHeight = barHeight * parseInt(this.barCtx.barOptions.barHeight, 10) / 100;
  5606. zeroW = this.barCtx.baseLineInvertedY + w.globals.padHorizontal + (this.barCtx.isReversed ? w.globals.gridWidth : 0) - (this.barCtx.isReversed ? this.barCtx.baseLineInvertedY * 2 : 0);
  5607. y = (yDivision - barHeight * this.barCtx.seriesLen) / 2;
  5608. } else {
  5609. // width divided into equal parts
  5610. xDivision = w.globals.gridWidth / this.barCtx.visibleItems;
  5611. if (w.config.xaxis.convertedCatToNumeric) {
  5612. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  5613. }
  5614. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  5615. if (w.globals.isXNumeric) {
  5616. // max barwidth should be equal to minXDiff to avoid overlap
  5617. var xRatio = this.barCtx.xRatio;
  5618. if (w.config.xaxis.convertedCatToNumeric) {
  5619. xRatio = this.barCtx.initialXRatio;
  5620. }
  5621. if (w.globals.minXDiff && w.globals.minXDiff !== 0.5 && w.globals.minXDiff / xRatio > 0) {
  5622. xDivision = w.globals.minXDiff / xRatio;
  5623. }
  5624. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  5625. if (barWidth < 1) {
  5626. barWidth = 1;
  5627. }
  5628. }
  5629. 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);
  5630. x = w.globals.padHorizontal + (xDivision - barWidth * this.barCtx.seriesLen) / 2;
  5631. }
  5632. return {
  5633. x: x,
  5634. y: y,
  5635. yDivision: yDivision,
  5636. xDivision: xDivision,
  5637. barHeight: barHeight,
  5638. barWidth: barWidth,
  5639. zeroH: zeroH,
  5640. zeroW: zeroW
  5641. };
  5642. }
  5643. }, {
  5644. key: "getPathFillColor",
  5645. value: function getPathFillColor(series, i, j, realIndex) {
  5646. var w = this.w;
  5647. var fill = new Fill(this.barCtx.ctx);
  5648. var fillColor = null;
  5649. var seriesNumber = this.barCtx.barOptions.distributed ? j : i;
  5650. if (this.barCtx.barOptions.colors.ranges.length > 0) {
  5651. var colorRange = this.barCtx.barOptions.colors.ranges;
  5652. colorRange.map(function (range) {
  5653. if (series[i][j] >= range.from && series[i][j] <= range.to) {
  5654. fillColor = range.color;
  5655. }
  5656. });
  5657. }
  5658. if (w.config.series[i].data[j] && w.config.series[i].data[j].fillColor) {
  5659. fillColor = w.config.series[i].data[j].fillColor;
  5660. }
  5661. var pathFill = fill.fillPath({
  5662. seriesNumber: this.barCtx.barOptions.distributed ? seriesNumber : realIndex,
  5663. dataPointIndex: j,
  5664. color: fillColor,
  5665. value: series[i][j]
  5666. });
  5667. return pathFill;
  5668. }
  5669. }, {
  5670. key: "getStrokeWidth",
  5671. value: function getStrokeWidth(i, j, realIndex) {
  5672. var strokeWidth = 0;
  5673. var w = this.w;
  5674. if (typeof this.barCtx.series[i][j] === 'undefined' || this.barCtx.series[i][j] === null) {
  5675. this.barCtx.isNullValue = true;
  5676. } else {
  5677. this.barCtx.isNullValue = false;
  5678. }
  5679. if (w.config.stroke.show) {
  5680. if (!this.barCtx.isNullValue) {
  5681. strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  5682. }
  5683. }
  5684. return strokeWidth;
  5685. }
  5686. }, {
  5687. key: "barBackground",
  5688. value: function barBackground(_ref) {
  5689. var j = _ref.j,
  5690. i = _ref.i,
  5691. x1 = _ref.x1,
  5692. x2 = _ref.x2,
  5693. y1 = _ref.y1,
  5694. y2 = _ref.y2,
  5695. elSeries = _ref.elSeries;
  5696. var w = this.w;
  5697. var graphics = new Graphics(this.barCtx.ctx);
  5698. var sr = new Series(this.barCtx.ctx);
  5699. var activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  5700. if (this.barCtx.barOptions.colors.backgroundBarColors.length > 0 && activeSeriesIndex === i) {
  5701. if (j >= this.barCtx.barOptions.colors.backgroundBarColors.length) {
  5702. j %= this.barCtx.barOptions.colors.backgroundBarColors.length;
  5703. }
  5704. var bcolor = this.barCtx.barOptions.colors.backgroundBarColors[j];
  5705. 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);
  5706. elSeries.add(rect);
  5707. rect.node.classList.add('apexcharts-backgroundBar');
  5708. }
  5709. }
  5710. }, {
  5711. key: "getColumnPaths",
  5712. value: function getColumnPaths(_ref2) {
  5713. var barWidth = _ref2.barWidth,
  5714. barXPosition = _ref2.barXPosition,
  5715. yRatio = _ref2.yRatio,
  5716. y1 = _ref2.y1,
  5717. y2 = _ref2.y2,
  5718. strokeWidth = _ref2.strokeWidth,
  5719. series = _ref2.series,
  5720. realIndex = _ref2.realIndex,
  5721. i = _ref2.i,
  5722. j = _ref2.j,
  5723. w = _ref2.w;
  5724. var graphics = new Graphics(this.barCtx.ctx);
  5725. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  5726. if (!strokeWidth) strokeWidth = 0;
  5727. var shapeOpts = {
  5728. barWidth: barWidth,
  5729. strokeWidth: strokeWidth,
  5730. yRatio: yRatio,
  5731. barXPosition: barXPosition,
  5732. y1: y1,
  5733. y2: y2
  5734. };
  5735. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  5736. var x1 = barXPosition;
  5737. var x2 = barXPosition + barWidth;
  5738. var pathTo = graphics.move(x1, y1);
  5739. var pathFrom = graphics.move(x1, y1);
  5740. var sl = graphics.line(x2 - strokeWidth, y1);
  5741. if (w.globals.previousPaths.length > 0) {
  5742. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  5743. }
  5744. pathTo = pathTo + graphics.line(x1, newPath.y2) + newPath.pathWithRadius + graphics.line(x2 - strokeWidth, newPath.y2) + sl + sl + 'z'; // the lines in pathFrom are repeated to equal it to the points of pathTo
  5745. // this is to avoid weird animation (bug in svg.js)
  5746. pathFrom = pathFrom + graphics.line(x1, y1) + sl + sl + sl + sl + sl + graphics.line(x1, y1);
  5747. if (w.config.chart.stacked) {
  5748. this.barCtx.yArrj.push(newPath.y2);
  5749. this.barCtx.yArrjF.push(Math.abs(y1 - newPath.y2));
  5750. this.barCtx.yArrjVal.push(this.barCtx.series[i][j]);
  5751. }
  5752. return {
  5753. pathTo: pathTo,
  5754. pathFrom: pathFrom
  5755. };
  5756. }
  5757. }, {
  5758. key: "getBarpaths",
  5759. value: function getBarpaths(_ref3) {
  5760. var barYPosition = _ref3.barYPosition,
  5761. barHeight = _ref3.barHeight,
  5762. x1 = _ref3.x1,
  5763. x2 = _ref3.x2,
  5764. strokeWidth = _ref3.strokeWidth,
  5765. series = _ref3.series,
  5766. realIndex = _ref3.realIndex,
  5767. i = _ref3.i,
  5768. j = _ref3.j,
  5769. w = _ref3.w;
  5770. var graphics = new Graphics(this.barCtx.ctx);
  5771. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  5772. if (!strokeWidth) strokeWidth = 0;
  5773. var shapeOpts = {
  5774. barHeight: barHeight,
  5775. strokeWidth: strokeWidth,
  5776. barYPosition: barYPosition,
  5777. x2: x2,
  5778. x1: x1
  5779. };
  5780. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  5781. var pathTo = graphics.move(x1, barYPosition);
  5782. var pathFrom = graphics.move(x1, barYPosition);
  5783. if (w.globals.previousPaths.length > 0) {
  5784. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  5785. }
  5786. var y1 = barYPosition;
  5787. var y2 = barYPosition + barHeight;
  5788. var sl = graphics.line(x1, y2 - strokeWidth);
  5789. pathTo = pathTo + graphics.line(newPath.x2, y1) + newPath.pathWithRadius + graphics.line(newPath.x2, y2 - strokeWidth) + sl + sl + 'z';
  5790. pathFrom = pathFrom + graphics.line(x1, y1) + sl + sl + sl + sl + sl + graphics.line(x1, y1);
  5791. if (w.config.chart.stacked) {
  5792. this.barCtx.xArrj.push(newPath.x2);
  5793. this.barCtx.xArrjF.push(Math.abs(x1 - newPath.x2));
  5794. this.barCtx.xArrjVal.push(this.barCtx.series[i][j]);
  5795. }
  5796. return {
  5797. pathTo: pathTo,
  5798. pathFrom: pathFrom
  5799. };
  5800. }
  5801. /** getRoundedBars draws border radius for bars/columns
  5802. * @memberof Bar
  5803. * @param {object} w - chart context
  5804. * @param {object} opts - consists several properties like barHeight/barWidth
  5805. * @param {array} series - global primary series
  5806. * @param {int} i - current iterating series's index
  5807. * @param {int} j - series's j of i
  5808. * @return {object} pathWithRadius - ending shape path string
  5809. * newY/newX - which is calculated from existing x/y based on rounded border
  5810. **/
  5811. }, {
  5812. key: "getRoundedBars",
  5813. value: function getRoundedBars(w, opts, series, i, j) {
  5814. var graphics = new Graphics(this.barCtx.ctx);
  5815. var radius = 0;
  5816. var borderRadius = w.config.plotOptions.bar.borderRadius;
  5817. var borderRadiusIsArray = Array.isArray(borderRadius);
  5818. if (borderRadiusIsArray) {
  5819. var radiusIndex = i > borderRadius.length - 1 ? borderRadius.length - 1 : i;
  5820. radius = borderRadius[radiusIndex];
  5821. } else {
  5822. radius = borderRadius;
  5823. }
  5824. if (w.config.chart.stacked && series.length > 1 && i !== this.barCtx.radiusOnSeriesNumber && !borderRadiusIsArray) {
  5825. radius = 0;
  5826. }
  5827. if (this.barCtx.isHorizontal) {
  5828. var pathWithRadius = '';
  5829. var x2 = opts.x2;
  5830. if (Math.abs(opts.x1 - opts.x2) < radius) {
  5831. radius = Math.abs(opts.x1 - opts.x2);
  5832. }
  5833. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  5834. var inverse = this.barCtx.isReversed ? series[i][j] > 0 : series[i][j] < 0;
  5835. if (inverse) radius = radius * -1;
  5836. x2 = x2 - radius;
  5837. pathWithRadius = graphics.quadraticCurve(x2 + radius, opts.barYPosition, x2 + radius, opts.barYPosition + (!inverse ? radius : radius * -1)) + graphics.line(x2 + radius, opts.barYPosition + opts.barHeight - opts.strokeWidth - (!inverse ? radius : radius * -1)) + graphics.quadraticCurve(x2 + radius, opts.barYPosition + opts.barHeight - opts.strokeWidth, x2, opts.barYPosition + opts.barHeight - opts.strokeWidth);
  5838. }
  5839. return {
  5840. pathWithRadius: pathWithRadius,
  5841. x2: x2
  5842. };
  5843. } else {
  5844. var _pathWithRadius = '';
  5845. var y2 = opts.y2;
  5846. if (Math.abs(opts.y1 - opts.y2) < radius) {
  5847. radius = Math.abs(opts.y1 - opts.y2);
  5848. }
  5849. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  5850. var _inverse = series[i][j] < 0;
  5851. if (_inverse) radius = radius * -1;
  5852. y2 = y2 + radius;
  5853. _pathWithRadius = graphics.quadraticCurve(opts.barXPosition, y2 - radius, opts.barXPosition + (!_inverse ? radius : radius * -1), y2 - radius) + graphics.line(opts.barXPosition + opts.barWidth - opts.strokeWidth - (!_inverse ? radius : radius * -1), y2 - radius) + graphics.quadraticCurve(opts.barXPosition + opts.barWidth - opts.strokeWidth, y2 - radius, opts.barXPosition + opts.barWidth - opts.strokeWidth, y2);
  5854. }
  5855. return {
  5856. pathWithRadius: _pathWithRadius,
  5857. y2: y2
  5858. };
  5859. }
  5860. }
  5861. }, {
  5862. key: "checkZeroSeries",
  5863. value: function checkZeroSeries(_ref4) {
  5864. var series = _ref4.series;
  5865. var w = this.w;
  5866. for (var zs = 0; zs < series.length; zs++) {
  5867. var total = 0;
  5868. for (var zsj = 0; zsj < series[w.globals.maxValsInArrayIndex].length; zsj++) {
  5869. total += series[zs][zsj];
  5870. }
  5871. if (total === 0) {
  5872. this.barCtx.zeroSerieses.push(zs);
  5873. }
  5874. } // After getting all zeroserieses, we need to ensure whether radiusOnSeriesNumber is not in that zeroseries array
  5875. for (var s = series.length - 1; s >= 0; s--) {
  5876. if (this.barCtx.zeroSerieses.indexOf(s) > -1 && s === this.radiusOnSeriesNumber) {
  5877. this.barCtx.radiusOnSeriesNumber -= 1;
  5878. }
  5879. }
  5880. for (var _s = series.length - 1; _s >= 0; _s--) {
  5881. if (w.globals.collapsedSeriesIndices.indexOf(this.barCtx.radiusOnSeriesNumber) > -1) {
  5882. this.barCtx.radiusOnSeriesNumber -= 1;
  5883. }
  5884. }
  5885. }
  5886. }, {
  5887. key: "getXForValue",
  5888. value: function getXForValue(value, zeroW) {
  5889. var zeroPositionForNull = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5890. var xForVal = zeroPositionForNull ? zeroW : null;
  5891. if (typeof value !== 'undefined' && value !== null) {
  5892. xForVal = zeroW + value / this.barCtx.invertedYRatio - (this.barCtx.isReversed ? value / this.barCtx.invertedYRatio : 0) * 2;
  5893. }
  5894. return xForVal;
  5895. }
  5896. }, {
  5897. key: "getYForValue",
  5898. value: function getYForValue(value, zeroH) {
  5899. var zeroPositionForNull = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5900. var yForVal = zeroPositionForNull ? zeroH : null;
  5901. if (typeof value !== 'undefined' && value !== null) {
  5902. yForVal = zeroH - value / this.barCtx.yRatio[this.barCtx.yaxisIndex] + (this.barCtx.isReversed ? value / this.barCtx.yRatio[this.barCtx.yaxisIndex] : 0) * 2;
  5903. }
  5904. return yForVal;
  5905. }
  5906. }, {
  5907. key: "getGoalValues",
  5908. value: function getGoalValues(type, zeroW, zeroH, i, j) {
  5909. var _this = this;
  5910. var w = this.w;
  5911. var goals = [];
  5912. if (w.globals.seriesGoals[i] && w.globals.seriesGoals[i][j] && Array.isArray(w.globals.seriesGoals[i][j])) {
  5913. w.globals.seriesGoals[i][j].forEach(function (goal) {
  5914. var _goals$push;
  5915. goals.push((_goals$push = {}, _defineProperty(_goals$push, type, type === 'x' ? _this.getXForValue(goal.value, zeroW, false) : _this.getYForValue(goal.value, zeroH, false)), _defineProperty(_goals$push, "attrs", goal), _goals$push));
  5916. });
  5917. }
  5918. return goals;
  5919. }
  5920. }, {
  5921. key: "drawGoalLine",
  5922. value: function drawGoalLine(_ref5) {
  5923. var barXPosition = _ref5.barXPosition,
  5924. barYPosition = _ref5.barYPosition,
  5925. goalX = _ref5.goalX,
  5926. goalY = _ref5.goalY,
  5927. barWidth = _ref5.barWidth,
  5928. barHeight = _ref5.barHeight;
  5929. var graphics = new Graphics(this.barCtx.ctx);
  5930. var lineGroup = graphics.group({
  5931. className: 'apexcharts-bar-goals-groups'
  5932. });
  5933. var line = null;
  5934. if (this.barCtx.isHorizontal) {
  5935. if (Array.isArray(goalX)) {
  5936. goalX.forEach(function (goal) {
  5937. var sHeight = typeof goal.attrs.strokeHeight !== 'undefined' ? goal.attrs.strokeHeight : barHeight / 2;
  5938. var y = barYPosition + sHeight + barHeight / 2;
  5939. line = graphics.drawLine(goal.x, y - sHeight * 2, goal.x, y, goal.attrs.strokeColor ? goal.attrs.strokeColor : undefined, goal.attrs.strokeDashArray, goal.attrs.strokeWidth ? goal.attrs.strokeWidth : 2, goal.attrs.strokeLineCap);
  5940. lineGroup.add(line);
  5941. });
  5942. }
  5943. } else {
  5944. if (Array.isArray(goalY)) {
  5945. goalY.forEach(function (goal) {
  5946. var sWidth = typeof goal.attrs.strokeWidth !== 'undefined' ? goal.attrs.strokeWidth : barWidth / 2;
  5947. var x = barXPosition + sWidth + barWidth / 2;
  5948. line = graphics.drawLine(x - sWidth * 2, goal.y, x, goal.y, goal.attrs.strokeColor ? goal.attrs.strokeColor : undefined, goal.attrs.strokeDashArray, goal.attrs.strokeHeight ? goal.attrs.strokeHeight : 2, goal.attrs.strokeLineCap);
  5949. lineGroup.add(line);
  5950. });
  5951. }
  5952. }
  5953. return lineGroup;
  5954. }
  5955. }]);
  5956. return Helpers;
  5957. }();
  5958. /**
  5959. * ApexCharts Bar Class responsible for drawing both Columns and Bars.
  5960. *
  5961. * @module Bar
  5962. **/
  5963. var Bar = /*#__PURE__*/function () {
  5964. function Bar(ctx, xyRatios) {
  5965. _classCallCheck(this, Bar);
  5966. this.ctx = ctx;
  5967. this.w = ctx.w;
  5968. var w = this.w;
  5969. this.barOptions = w.config.plotOptions.bar;
  5970. this.isHorizontal = this.barOptions.horizontal;
  5971. this.strokeWidth = w.config.stroke.width;
  5972. this.isNullValue = false;
  5973. this.isRangeBar = w.globals.seriesRangeBar.length && this.isHorizontal;
  5974. this.xyRatios = xyRatios;
  5975. if (this.xyRatios !== null) {
  5976. this.xRatio = xyRatios.xRatio;
  5977. this.initialXRatio = xyRatios.initialXRatio;
  5978. this.yRatio = xyRatios.yRatio;
  5979. this.invertedXRatio = xyRatios.invertedXRatio;
  5980. this.invertedYRatio = xyRatios.invertedYRatio;
  5981. this.baseLineY = xyRatios.baseLineY;
  5982. this.baseLineInvertedY = xyRatios.baseLineInvertedY;
  5983. }
  5984. this.yaxisIndex = 0;
  5985. this.seriesLen = 0;
  5986. this.barHelpers = new Helpers$3(this);
  5987. }
  5988. /** primary draw method which is called on bar object
  5989. * @memberof Bar
  5990. * @param {array} series - user supplied series values
  5991. * @param {int} seriesIndex - the index by which series will be drawn on the svg
  5992. * @return {node} element which is supplied to parent chart draw method for appending
  5993. **/
  5994. _createClass(Bar, [{
  5995. key: "draw",
  5996. value: function draw(series, seriesIndex) {
  5997. var w = this.w;
  5998. var graphics = new Graphics(this.ctx);
  5999. var coreUtils = new CoreUtils(this.ctx, w);
  6000. series = coreUtils.getLogSeries(series);
  6001. this.series = series;
  6002. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  6003. this.barHelpers.initVariables(series);
  6004. var ret = graphics.group({
  6005. class: 'apexcharts-bar-series apexcharts-plot-series'
  6006. });
  6007. if (w.config.dataLabels.enabled) {
  6008. if (this.totalItems > this.barOptions.dataLabels.maxItems) {
  6009. console.warn('WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.');
  6010. }
  6011. }
  6012. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  6013. var x = void 0,
  6014. y = void 0,
  6015. xDivision = void 0,
  6016. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  6017. yDivision = void 0,
  6018. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  6019. zeroH = void 0,
  6020. // zeroH is the baseline where 0 meets y axis
  6021. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  6022. var yArrj = []; // hold y values of current iterating series
  6023. var xArrj = []; // hold x values of current iterating series
  6024. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  6025. var elSeries = graphics.group({
  6026. class: "apexcharts-series",
  6027. rel: i + 1,
  6028. seriesName: Utils$1.escapeString(w.globals.seriesNames[realIndex]),
  6029. 'data:realIndex': realIndex
  6030. });
  6031. this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
  6032. if (series[i].length > 0) {
  6033. this.visibleI = this.visibleI + 1;
  6034. }
  6035. var barHeight = 0;
  6036. var barWidth = 0;
  6037. if (this.yRatio.length > 1) {
  6038. this.yaxisIndex = realIndex;
  6039. }
  6040. this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
  6041. var initPositions = this.barHelpers.initialPositions();
  6042. y = initPositions.y;
  6043. barHeight = initPositions.barHeight;
  6044. yDivision = initPositions.yDivision;
  6045. zeroW = initPositions.zeroW;
  6046. x = initPositions.x;
  6047. barWidth = initPositions.barWidth;
  6048. xDivision = initPositions.xDivision;
  6049. zeroH = initPositions.zeroH;
  6050. if (!this.horizontal) {
  6051. xArrj.push(x + barWidth / 2);
  6052. } // eldatalabels
  6053. var elDataLabelsWrap = graphics.group({
  6054. class: 'apexcharts-datalabels',
  6055. 'data:realIndex': realIndex
  6056. });
  6057. var elGoalsMarkers = graphics.group({
  6058. class: 'apexcharts-bar-goals-markers',
  6059. style: "pointer-events: none"
  6060. });
  6061. for (var j = 0; j < w.globals.dataPoints; j++) {
  6062. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  6063. var paths = null;
  6064. var pathsParams = {
  6065. indexes: {
  6066. i: i,
  6067. j: j,
  6068. realIndex: realIndex,
  6069. bc: bc
  6070. },
  6071. x: x,
  6072. y: y,
  6073. strokeWidth: strokeWidth,
  6074. elSeries: elSeries
  6075. };
  6076. if (this.isHorizontal) {
  6077. paths = this.drawBarPaths(_objectSpread2(_objectSpread2({}, pathsParams), {}, {
  6078. barHeight: barHeight,
  6079. zeroW: zeroW,
  6080. yDivision: yDivision
  6081. }));
  6082. barWidth = this.series[i][j] / this.invertedYRatio;
  6083. } else {
  6084. paths = this.drawColumnPaths(_objectSpread2(_objectSpread2({}, pathsParams), {}, {
  6085. xDivision: xDivision,
  6086. barWidth: barWidth,
  6087. zeroH: zeroH
  6088. }));
  6089. barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex];
  6090. }
  6091. var barGoalLine = this.barHelpers.drawGoalLine({
  6092. barXPosition: paths.barXPosition,
  6093. barYPosition: paths.barYPosition,
  6094. goalX: paths.goalX,
  6095. goalY: paths.goalY,
  6096. barHeight: barHeight,
  6097. barWidth: barWidth
  6098. });
  6099. if (barGoalLine) {
  6100. elGoalsMarkers.add(barGoalLine);
  6101. }
  6102. y = paths.y;
  6103. x = paths.x; // push current X
  6104. if (j > 0) {
  6105. xArrj.push(x + barWidth / 2);
  6106. }
  6107. yArrj.push(y);
  6108. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  6109. this.renderSeries({
  6110. realIndex: realIndex,
  6111. pathFill: pathFill,
  6112. j: j,
  6113. i: i,
  6114. pathFrom: paths.pathFrom,
  6115. pathTo: paths.pathTo,
  6116. strokeWidth: strokeWidth,
  6117. elSeries: elSeries,
  6118. x: x,
  6119. y: y,
  6120. series: series,
  6121. barHeight: barHeight,
  6122. barWidth: barWidth,
  6123. elDataLabelsWrap: elDataLabelsWrap,
  6124. elGoalsMarkers: elGoalsMarkers,
  6125. visibleSeries: this.visibleI,
  6126. type: 'bar'
  6127. });
  6128. } // push all x val arrays into main xArr
  6129. w.globals.seriesXvalues[realIndex] = xArrj;
  6130. w.globals.seriesYvalues[realIndex] = yArrj;
  6131. ret.add(elSeries);
  6132. }
  6133. return ret;
  6134. }
  6135. }, {
  6136. key: "renderSeries",
  6137. value: function renderSeries(_ref) {
  6138. var realIndex = _ref.realIndex,
  6139. pathFill = _ref.pathFill,
  6140. lineFill = _ref.lineFill,
  6141. j = _ref.j,
  6142. i = _ref.i,
  6143. pathFrom = _ref.pathFrom,
  6144. pathTo = _ref.pathTo,
  6145. strokeWidth = _ref.strokeWidth,
  6146. elSeries = _ref.elSeries,
  6147. x = _ref.x,
  6148. y = _ref.y,
  6149. y1 = _ref.y1,
  6150. y2 = _ref.y2,
  6151. series = _ref.series,
  6152. barHeight = _ref.barHeight,
  6153. barWidth = _ref.barWidth,
  6154. barYPosition = _ref.barYPosition,
  6155. elDataLabelsWrap = _ref.elDataLabelsWrap,
  6156. elGoalsMarkers = _ref.elGoalsMarkers,
  6157. visibleSeries = _ref.visibleSeries,
  6158. type = _ref.type;
  6159. var w = this.w;
  6160. var graphics = new Graphics(this.ctx);
  6161. if (!lineFill) {
  6162. /* fix apexcharts#341 */
  6163. lineFill = this.barOptions.distributed ? w.globals.stroke.colors[j] : w.globals.stroke.colors[realIndex];
  6164. }
  6165. if (w.config.series[i].data[j] && w.config.series[i].data[j].strokeColor) {
  6166. lineFill = w.config.series[i].data[j].strokeColor;
  6167. }
  6168. if (this.isNullValue) {
  6169. pathFill = 'none';
  6170. }
  6171. var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4;
  6172. var renderedPath = graphics.renderPaths({
  6173. i: i,
  6174. j: j,
  6175. realIndex: realIndex,
  6176. pathFrom: pathFrom,
  6177. pathTo: pathTo,
  6178. stroke: lineFill,
  6179. strokeWidth: strokeWidth,
  6180. strokeLineCap: w.config.stroke.lineCap,
  6181. fill: pathFill,
  6182. animationDelay: delay,
  6183. initialSpeed: w.config.chart.animations.speed,
  6184. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  6185. className: "apexcharts-".concat(type, "-area")
  6186. });
  6187. renderedPath.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  6188. var forecast = w.config.forecastDataPoints;
  6189. if (forecast.count > 0) {
  6190. if (j >= w.globals.dataPoints - forecast.count) {
  6191. renderedPath.node.setAttribute('stroke-dasharray', forecast.dashArray);
  6192. renderedPath.node.setAttribute('stroke-width', forecast.strokeWidth);
  6193. renderedPath.node.setAttribute('fill-opacity', forecast.fillOpacity);
  6194. }
  6195. }
  6196. if (typeof y1 !== 'undefined' && typeof y2 !== 'undefined') {
  6197. renderedPath.attr('data-range-y1', y1);
  6198. renderedPath.attr('data-range-y2', y2);
  6199. }
  6200. var filters = new Filters(this.ctx);
  6201. filters.setSelectionFilter(renderedPath, realIndex, j);
  6202. elSeries.add(renderedPath);
  6203. var barDataLabels = new BarDataLabels(this);
  6204. var dataLabels = barDataLabels.handleBarDataLabels({
  6205. x: x,
  6206. y: y,
  6207. y1: y1,
  6208. y2: y2,
  6209. i: i,
  6210. j: j,
  6211. series: series,
  6212. realIndex: realIndex,
  6213. barHeight: barHeight,
  6214. barWidth: barWidth,
  6215. barYPosition: barYPosition,
  6216. renderedPath: renderedPath,
  6217. visibleSeries: visibleSeries
  6218. });
  6219. if (dataLabels !== null) {
  6220. elDataLabelsWrap.add(dataLabels);
  6221. }
  6222. elSeries.add(elDataLabelsWrap);
  6223. if (elGoalsMarkers) {
  6224. elSeries.add(elGoalsMarkers);
  6225. }
  6226. return elSeries;
  6227. }
  6228. }, {
  6229. key: "drawBarPaths",
  6230. value: function drawBarPaths(_ref2) {
  6231. var indexes = _ref2.indexes,
  6232. barHeight = _ref2.barHeight,
  6233. strokeWidth = _ref2.strokeWidth,
  6234. zeroW = _ref2.zeroW,
  6235. x = _ref2.x,
  6236. y = _ref2.y,
  6237. yDivision = _ref2.yDivision,
  6238. elSeries = _ref2.elSeries;
  6239. var w = this.w;
  6240. var i = indexes.i;
  6241. var j = indexes.j;
  6242. if (w.globals.isXNumeric) {
  6243. y = (w.globals.seriesX[i][j] - w.globals.minX) / this.invertedXRatio - barHeight;
  6244. }
  6245. var barYPosition = y + barHeight * this.visibleI;
  6246. x = this.barHelpers.getXForValue(this.series[i][j], zeroW);
  6247. var paths = this.barHelpers.getBarpaths({
  6248. barYPosition: barYPosition,
  6249. barHeight: barHeight,
  6250. x1: zeroW,
  6251. x2: x,
  6252. strokeWidth: strokeWidth,
  6253. series: this.series,
  6254. realIndex: indexes.realIndex,
  6255. i: i,
  6256. j: j,
  6257. w: w
  6258. });
  6259. if (!w.globals.isXNumeric) {
  6260. y = y + yDivision;
  6261. }
  6262. this.barHelpers.barBackground({
  6263. j: j,
  6264. i: i,
  6265. y1: barYPosition - barHeight * this.visibleI,
  6266. y2: barHeight * this.seriesLen,
  6267. elSeries: elSeries
  6268. });
  6269. return {
  6270. pathTo: paths.pathTo,
  6271. pathFrom: paths.pathFrom,
  6272. x: x,
  6273. y: y,
  6274. goalX: this.barHelpers.getGoalValues('x', zeroW, null, i, j),
  6275. barYPosition: barYPosition
  6276. };
  6277. }
  6278. }, {
  6279. key: "drawColumnPaths",
  6280. value: function drawColumnPaths(_ref3) {
  6281. var indexes = _ref3.indexes,
  6282. x = _ref3.x,
  6283. y = _ref3.y,
  6284. xDivision = _ref3.xDivision,
  6285. barWidth = _ref3.barWidth,
  6286. zeroH = _ref3.zeroH,
  6287. strokeWidth = _ref3.strokeWidth,
  6288. elSeries = _ref3.elSeries;
  6289. var w = this.w;
  6290. var realIndex = indexes.realIndex;
  6291. var i = indexes.i;
  6292. var j = indexes.j;
  6293. var bc = indexes.bc;
  6294. if (w.globals.isXNumeric) {
  6295. var sxI = realIndex;
  6296. if (!w.globals.seriesX[realIndex].length) {
  6297. sxI = w.globals.maxValsInArrayIndex;
  6298. }
  6299. x = (w.globals.seriesX[sxI][j] - w.globals.minX) / this.xRatio - barWidth * this.seriesLen / 2;
  6300. }
  6301. var barXPosition = x + barWidth * this.visibleI;
  6302. y = this.barHelpers.getYForValue(this.series[i][j], zeroH);
  6303. var paths = this.barHelpers.getColumnPaths({
  6304. barXPosition: barXPosition,
  6305. barWidth: barWidth,
  6306. y1: zeroH,
  6307. y2: y,
  6308. strokeWidth: strokeWidth,
  6309. series: this.series,
  6310. realIndex: indexes.realIndex,
  6311. i: i,
  6312. j: j,
  6313. w: w
  6314. });
  6315. if (!w.globals.isXNumeric) {
  6316. x = x + xDivision;
  6317. }
  6318. this.barHelpers.barBackground({
  6319. bc: bc,
  6320. j: j,
  6321. i: i,
  6322. x1: barXPosition - strokeWidth / 2 - barWidth * this.visibleI,
  6323. x2: barWidth * this.seriesLen + strokeWidth / 2,
  6324. elSeries: elSeries
  6325. });
  6326. return {
  6327. pathTo: paths.pathTo,
  6328. pathFrom: paths.pathFrom,
  6329. x: x,
  6330. y: y,
  6331. goalY: this.barHelpers.getGoalValues('y', null, zeroH, i, j),
  6332. barXPosition: barXPosition
  6333. };
  6334. }
  6335. /** getPreviousPath is a common function for bars/columns which is used to get previous paths when data changes.
  6336. * @memberof Bar
  6337. * @param {int} realIndex - current iterating i
  6338. * @param {int} j - current iterating series's j index
  6339. * @return {string} pathFrom is the string which will be appended in animations
  6340. **/
  6341. }, {
  6342. key: "getPreviousPath",
  6343. value: function getPreviousPath(realIndex, j) {
  6344. var w = this.w;
  6345. var pathFrom;
  6346. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  6347. var gpp = w.globals.previousPaths[pp];
  6348. if (gpp.paths && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  6349. if (typeof w.globals.previousPaths[pp].paths[j] !== 'undefined') {
  6350. pathFrom = w.globals.previousPaths[pp].paths[j].d;
  6351. }
  6352. }
  6353. }
  6354. return pathFrom;
  6355. }
  6356. }]);
  6357. return Bar;
  6358. }();
  6359. /**
  6360. * DateTime Class to manipulate datetime values.
  6361. *
  6362. * @module DateTime
  6363. **/
  6364. var DateTime = /*#__PURE__*/function () {
  6365. function DateTime(ctx) {
  6366. _classCallCheck(this, DateTime);
  6367. this.ctx = ctx;
  6368. this.w = ctx.w;
  6369. this.months31 = [1, 3, 5, 7, 8, 10, 12];
  6370. this.months30 = [2, 4, 6, 9, 11];
  6371. this.daysCntOfYear = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
  6372. }
  6373. _createClass(DateTime, [{
  6374. key: "isValidDate",
  6375. value: function isValidDate(date) {
  6376. return !isNaN(this.parseDate(date));
  6377. }
  6378. }, {
  6379. key: "getTimeStamp",
  6380. value: function getTimeStamp(dateStr) {
  6381. if (!Date.parse(dateStr)) {
  6382. return dateStr;
  6383. }
  6384. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6385. return !utc ? new Date(dateStr).getTime() : new Date(new Date(dateStr).toISOString().substr(0, 25)).getTime();
  6386. }
  6387. }, {
  6388. key: "getDate",
  6389. value: function getDate(timestamp) {
  6390. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6391. return utc ? new Date(new Date(timestamp).toUTCString()) : new Date(timestamp);
  6392. }
  6393. }, {
  6394. key: "parseDate",
  6395. value: function parseDate(dateStr) {
  6396. var parsed = Date.parse(dateStr);
  6397. if (!isNaN(parsed)) {
  6398. return this.getTimeStamp(dateStr);
  6399. }
  6400. var output = Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' '));
  6401. output = this.getTimeStamp(output);
  6402. return output;
  6403. } // This fixes the difference of x-axis labels between chrome/safari
  6404. // Fixes #1726, #1544, #1485, #1255
  6405. }, {
  6406. key: "parseDateWithTimezone",
  6407. value: function parseDateWithTimezone(dateStr) {
  6408. return Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' '));
  6409. } // http://stackoverflow.com/questions/14638018/current-time-formatting-with-javascript#answer-14638191
  6410. }, {
  6411. key: "formatDate",
  6412. value: function formatDate(date, format) {
  6413. var locale = this.w.globals.locale;
  6414. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6415. var MMMM = ['\x00'].concat(_toConsumableArray(locale.months));
  6416. var MMM = ['\x01'].concat(_toConsumableArray(locale.shortMonths));
  6417. var dddd = ['\x02'].concat(_toConsumableArray(locale.days));
  6418. var ddd = ['\x03'].concat(_toConsumableArray(locale.shortDays));
  6419. function ii(i, len) {
  6420. var s = i + '';
  6421. len = len || 2;
  6422. while (s.length < len) {
  6423. s = '0' + s;
  6424. }
  6425. return s;
  6426. }
  6427. var y = utc ? date.getUTCFullYear() : date.getFullYear();
  6428. format = format.replace(/(^|[^\\])yyyy+/g, '$1' + y);
  6429. format = format.replace(/(^|[^\\])yy/g, '$1' + y.toString().substr(2, 2));
  6430. format = format.replace(/(^|[^\\])y/g, '$1' + y);
  6431. var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
  6432. format = format.replace(/(^|[^\\])MMMM+/g, '$1' + MMMM[0]);
  6433. format = format.replace(/(^|[^\\])MMM/g, '$1' + MMM[0]);
  6434. format = format.replace(/(^|[^\\])MM/g, '$1' + ii(M));
  6435. format = format.replace(/(^|[^\\])M/g, '$1' + M);
  6436. var d = utc ? date.getUTCDate() : date.getDate();
  6437. format = format.replace(/(^|[^\\])dddd+/g, '$1' + dddd[0]);
  6438. format = format.replace(/(^|[^\\])ddd/g, '$1' + ddd[0]);
  6439. format = format.replace(/(^|[^\\])dd/g, '$1' + ii(d));
  6440. format = format.replace(/(^|[^\\])d/g, '$1' + d);
  6441. var H = utc ? date.getUTCHours() : date.getHours();
  6442. format = format.replace(/(^|[^\\])HH+/g, '$1' + ii(H));
  6443. format = format.replace(/(^|[^\\])H/g, '$1' + H);
  6444. var h = H > 12 ? H - 12 : H === 0 ? 12 : H;
  6445. format = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h));
  6446. format = format.replace(/(^|[^\\])h/g, '$1' + h);
  6447. var m = utc ? date.getUTCMinutes() : date.getMinutes();
  6448. format = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m));
  6449. format = format.replace(/(^|[^\\])m/g, '$1' + m);
  6450. var s = utc ? date.getUTCSeconds() : date.getSeconds();
  6451. format = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s));
  6452. format = format.replace(/(^|[^\\])s/g, '$1' + s);
  6453. var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
  6454. format = format.replace(/(^|[^\\])fff+/g, '$1' + ii(f, 3));
  6455. f = Math.round(f / 10);
  6456. format = format.replace(/(^|[^\\])ff/g, '$1' + ii(f));
  6457. f = Math.round(f / 10);
  6458. format = format.replace(/(^|[^\\])f/g, '$1' + f);
  6459. var T = H < 12 ? 'AM' : 'PM';
  6460. format = format.replace(/(^|[^\\])TT+/g, '$1' + T);
  6461. format = format.replace(/(^|[^\\])T/g, '$1' + T.charAt(0));
  6462. var t = T.toLowerCase();
  6463. format = format.replace(/(^|[^\\])tt+/g, '$1' + t);
  6464. format = format.replace(/(^|[^\\])t/g, '$1' + t.charAt(0));
  6465. var tz = -date.getTimezoneOffset();
  6466. var K = utc || !tz ? 'Z' : tz > 0 ? '+' : '-';
  6467. if (!utc) {
  6468. tz = Math.abs(tz);
  6469. var tzHrs = Math.floor(tz / 60);
  6470. var tzMin = tz % 60;
  6471. K += ii(tzHrs) + ':' + ii(tzMin);
  6472. }
  6473. format = format.replace(/(^|[^\\])K/g, '$1' + K);
  6474. var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
  6475. format = format.replace(new RegExp(dddd[0], 'g'), dddd[day]);
  6476. format = format.replace(new RegExp(ddd[0], 'g'), ddd[day]);
  6477. format = format.replace(new RegExp(MMMM[0], 'g'), MMMM[M]);
  6478. format = format.replace(new RegExp(MMM[0], 'g'), MMM[M]);
  6479. format = format.replace(/\\(.)/g, '$1');
  6480. return format;
  6481. }
  6482. }, {
  6483. key: "getTimeUnitsfromTimestamp",
  6484. value: function getTimeUnitsfromTimestamp(minX, maxX, utc) {
  6485. var w = this.w;
  6486. if (w.config.xaxis.min !== undefined) {
  6487. minX = w.config.xaxis.min;
  6488. }
  6489. if (w.config.xaxis.max !== undefined) {
  6490. maxX = w.config.xaxis.max;
  6491. }
  6492. var tsMin = this.getDate(minX);
  6493. var tsMax = this.getDate(maxX);
  6494. var minD = this.formatDate(tsMin, 'yyyy MM dd HH mm ss fff').split(' ');
  6495. var maxD = this.formatDate(tsMax, 'yyyy MM dd HH mm ss fff').split(' ');
  6496. return {
  6497. minMillisecond: parseInt(minD[6], 10),
  6498. maxMillisecond: parseInt(maxD[6], 10),
  6499. minSecond: parseInt(minD[5], 10),
  6500. maxSecond: parseInt(maxD[5], 10),
  6501. minMinute: parseInt(minD[4], 10),
  6502. maxMinute: parseInt(maxD[4], 10),
  6503. minHour: parseInt(minD[3], 10),
  6504. maxHour: parseInt(maxD[3], 10),
  6505. minDate: parseInt(minD[2], 10),
  6506. maxDate: parseInt(maxD[2], 10),
  6507. minMonth: parseInt(minD[1], 10) - 1,
  6508. maxMonth: parseInt(maxD[1], 10) - 1,
  6509. minYear: parseInt(minD[0], 10),
  6510. maxYear: parseInt(maxD[0], 10)
  6511. };
  6512. }
  6513. }, {
  6514. key: "isLeapYear",
  6515. value: function isLeapYear(year) {
  6516. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  6517. }
  6518. }, {
  6519. key: "calculcateLastDaysOfMonth",
  6520. value: function calculcateLastDaysOfMonth(month, year, subtract) {
  6521. var days = this.determineDaysOfMonths(month, year); // whatever days we get, subtract the number of days asked
  6522. return days - subtract;
  6523. }
  6524. }, {
  6525. key: "determineDaysOfYear",
  6526. value: function determineDaysOfYear(year) {
  6527. var days = 365;
  6528. if (this.isLeapYear(year)) {
  6529. days = 366;
  6530. }
  6531. return days;
  6532. }
  6533. }, {
  6534. key: "determineRemainingDaysOfYear",
  6535. value: function determineRemainingDaysOfYear(year, month, date) {
  6536. var dayOfYear = this.daysCntOfYear[month] + date;
  6537. if (month > 1 && this.isLeapYear()) dayOfYear++;
  6538. return dayOfYear;
  6539. }
  6540. }, {
  6541. key: "determineDaysOfMonths",
  6542. value: function determineDaysOfMonths(month, year) {
  6543. var days = 30;
  6544. month = Utils$1.monthMod(month);
  6545. switch (true) {
  6546. case this.months30.indexOf(month) > -1:
  6547. if (month === 2) {
  6548. if (this.isLeapYear(year)) {
  6549. days = 29;
  6550. } else {
  6551. days = 28;
  6552. }
  6553. }
  6554. break;
  6555. case this.months31.indexOf(month) > -1:
  6556. days = 31;
  6557. break;
  6558. default:
  6559. days = 31;
  6560. break;
  6561. }
  6562. return days;
  6563. }
  6564. }]);
  6565. return DateTime;
  6566. }();
  6567. /**
  6568. * ApexCharts RangeBar Class responsible for drawing Range/Timeline Bars.
  6569. *
  6570. * @module RangeBar
  6571. **/
  6572. var RangeBar = /*#__PURE__*/function (_Bar) {
  6573. _inherits(RangeBar, _Bar);
  6574. var _super = _createSuper(RangeBar);
  6575. function RangeBar() {
  6576. _classCallCheck(this, RangeBar);
  6577. return _super.apply(this, arguments);
  6578. }
  6579. _createClass(RangeBar, [{
  6580. key: "draw",
  6581. value: function draw(series, seriesIndex) {
  6582. var w = this.w;
  6583. var graphics = new Graphics(this.ctx);
  6584. this.rangeBarOptions = this.w.config.plotOptions.rangeBar;
  6585. this.series = series;
  6586. this.seriesRangeStart = w.globals.seriesRangeStart;
  6587. this.seriesRangeEnd = w.globals.seriesRangeEnd;
  6588. this.barHelpers.initVariables(series);
  6589. var ret = graphics.group({
  6590. class: 'apexcharts-rangebar-series apexcharts-plot-series'
  6591. });
  6592. for (var i = 0; i < series.length; i++) {
  6593. var x = void 0,
  6594. y = void 0,
  6595. xDivision = void 0,
  6596. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  6597. yDivision = void 0,
  6598. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  6599. zeroH = void 0,
  6600. // zeroH is the baseline where 0 meets y axis
  6601. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  6602. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  6603. var elSeries = graphics.group({
  6604. class: "apexcharts-series",
  6605. seriesName: Utils$1.escapeString(w.globals.seriesNames[realIndex]),
  6606. rel: i + 1,
  6607. 'data:realIndex': realIndex
  6608. });
  6609. this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
  6610. if (series[i].length > 0) {
  6611. this.visibleI = this.visibleI + 1;
  6612. }
  6613. var barHeight = 0;
  6614. var barWidth = 0;
  6615. if (this.yRatio.length > 1) {
  6616. this.yaxisIndex = realIndex;
  6617. }
  6618. var initPositions = this.barHelpers.initialPositions();
  6619. y = initPositions.y;
  6620. zeroW = initPositions.zeroW;
  6621. x = initPositions.x;
  6622. barWidth = initPositions.barWidth;
  6623. xDivision = initPositions.xDivision;
  6624. zeroH = initPositions.zeroH; // eldatalabels
  6625. var elDataLabelsWrap = graphics.group({
  6626. class: 'apexcharts-datalabels',
  6627. 'data:realIndex': realIndex
  6628. });
  6629. var elGoalsMarkers = graphics.group({
  6630. class: 'apexcharts-rangebar-goals-markers',
  6631. style: "pointer-events: none"
  6632. });
  6633. for (var j = 0; j < w.globals.dataPoints; j++) {
  6634. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  6635. var y1 = this.seriesRangeStart[i][j];
  6636. var y2 = this.seriesRangeEnd[i][j];
  6637. var paths = null;
  6638. var barYPosition = null;
  6639. var params = {
  6640. x: x,
  6641. y: y,
  6642. strokeWidth: strokeWidth,
  6643. elSeries: elSeries
  6644. };
  6645. yDivision = initPositions.yDivision;
  6646. barHeight = initPositions.barHeight;
  6647. if (this.isHorizontal) {
  6648. barYPosition = y + barHeight * this.visibleI;
  6649. var seriesLen = this.seriesLen;
  6650. if (w.config.plotOptions.bar.rangeBarGroupRows) {
  6651. seriesLen = 1;
  6652. }
  6653. var srty = (yDivision - barHeight * seriesLen) / 2;
  6654. if (typeof w.config.series[i].data[j] === 'undefined') {
  6655. // no data exists for further indexes, hence we need to get out the innr loop.
  6656. // As we are iterating over total datapoints, there is a possiblity the series might not have data for j index
  6657. break;
  6658. }
  6659. if (w.config.series[i].data[j].x) {
  6660. var positions = this.detectOverlappingBars({
  6661. i: i,
  6662. j: j,
  6663. barYPosition: barYPosition,
  6664. srty: srty,
  6665. barHeight: barHeight,
  6666. yDivision: yDivision,
  6667. initPositions: initPositions
  6668. });
  6669. barHeight = positions.barHeight;
  6670. barYPosition = positions.barYPosition;
  6671. }
  6672. paths = this.drawRangeBarPaths(_objectSpread2({
  6673. indexes: {
  6674. i: i,
  6675. j: j,
  6676. realIndex: realIndex
  6677. },
  6678. barHeight: barHeight,
  6679. barYPosition: barYPosition,
  6680. zeroW: zeroW,
  6681. yDivision: yDivision,
  6682. y1: y1,
  6683. y2: y2
  6684. }, params));
  6685. barWidth = paths.barWidth;
  6686. } else {
  6687. paths = this.drawRangeColumnPaths(_objectSpread2({
  6688. indexes: {
  6689. i: i,
  6690. j: j,
  6691. realIndex: realIndex
  6692. },
  6693. zeroH: zeroH,
  6694. barWidth: barWidth,
  6695. xDivision: xDivision
  6696. }, params));
  6697. barHeight = paths.barHeight;
  6698. }
  6699. var barGoalLine = this.barHelpers.drawGoalLine({
  6700. barXPosition: paths.barXPosition,
  6701. barYPosition: barYPosition,
  6702. goalX: paths.goalX,
  6703. goalY: paths.goalY,
  6704. barHeight: barHeight,
  6705. barWidth: barWidth
  6706. });
  6707. if (barGoalLine) {
  6708. elGoalsMarkers.add(barGoalLine);
  6709. }
  6710. y = paths.y;
  6711. x = paths.x;
  6712. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  6713. var lineFill = w.globals.stroke.colors[realIndex];
  6714. this.renderSeries({
  6715. realIndex: realIndex,
  6716. pathFill: pathFill,
  6717. lineFill: lineFill,
  6718. j: j,
  6719. i: i,
  6720. x: x,
  6721. y: y,
  6722. y1: y1,
  6723. y2: y2,
  6724. pathFrom: paths.pathFrom,
  6725. pathTo: paths.pathTo,
  6726. strokeWidth: strokeWidth,
  6727. elSeries: elSeries,
  6728. series: series,
  6729. barHeight: barHeight,
  6730. barYPosition: barYPosition,
  6731. barWidth: barWidth,
  6732. elDataLabelsWrap: elDataLabelsWrap,
  6733. elGoalsMarkers: elGoalsMarkers,
  6734. visibleSeries: this.visibleI,
  6735. type: 'rangebar'
  6736. });
  6737. }
  6738. ret.add(elSeries);
  6739. }
  6740. return ret;
  6741. }
  6742. }, {
  6743. key: "detectOverlappingBars",
  6744. value: function detectOverlappingBars(_ref) {
  6745. var i = _ref.i,
  6746. j = _ref.j,
  6747. barYPosition = _ref.barYPosition,
  6748. srty = _ref.srty,
  6749. barHeight = _ref.barHeight,
  6750. yDivision = _ref.yDivision,
  6751. initPositions = _ref.initPositions;
  6752. var w = this.w;
  6753. var overlaps = [];
  6754. var rangeName = w.config.series[i].data[j].rangeName;
  6755. var labelX = w.config.series[i].data[j].x;
  6756. var rowIndex = w.globals.labels.indexOf(labelX);
  6757. var overlappedIndex = w.globals.seriesRangeBar[i].findIndex(function (tx) {
  6758. return tx.x === labelX && tx.overlaps.length > 0;
  6759. });
  6760. if (w.config.plotOptions.bar.rangeBarGroupRows) {
  6761. barYPosition = srty + yDivision * rowIndex;
  6762. } else {
  6763. barYPosition = srty + barHeight * this.visibleI + yDivision * rowIndex;
  6764. }
  6765. if (overlappedIndex > -1 && !w.config.plotOptions.bar.rangeBarOverlap) {
  6766. overlaps = w.globals.seriesRangeBar[i][overlappedIndex].overlaps;
  6767. if (overlaps.indexOf(rangeName) > -1) {
  6768. barHeight = initPositions.barHeight / overlaps.length;
  6769. barYPosition = barHeight * this.visibleI + yDivision * (100 - parseInt(this.barOptions.barHeight, 10)) / 100 / 2 + barHeight * (this.visibleI + overlaps.indexOf(rangeName)) + yDivision * rowIndex;
  6770. }
  6771. }
  6772. return {
  6773. barYPosition: barYPosition,
  6774. barHeight: barHeight
  6775. };
  6776. }
  6777. }, {
  6778. key: "drawRangeColumnPaths",
  6779. value: function drawRangeColumnPaths(_ref2) {
  6780. var indexes = _ref2.indexes,
  6781. x = _ref2.x;
  6782. _ref2.strokeWidth;
  6783. var xDivision = _ref2.xDivision,
  6784. barWidth = _ref2.barWidth,
  6785. zeroH = _ref2.zeroH;
  6786. var w = this.w;
  6787. var i = indexes.i;
  6788. var j = indexes.j;
  6789. var yRatio = this.yRatio[this.yaxisIndex];
  6790. var realIndex = indexes.realIndex;
  6791. var range = this.getRangeValue(realIndex, j);
  6792. var y1 = Math.min(range.start, range.end);
  6793. var y2 = Math.max(range.start, range.end);
  6794. if (w.globals.isXNumeric) {
  6795. x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  6796. }
  6797. var barXPosition = x + barWidth * this.visibleI;
  6798. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  6799. y1 = zeroH;
  6800. } else {
  6801. y1 = zeroH - y1 / yRatio;
  6802. y2 = zeroH - y2 / yRatio;
  6803. }
  6804. var barHeight = Math.abs(y2 - y1);
  6805. var paths = this.barHelpers.getColumnPaths({
  6806. barXPosition: barXPosition,
  6807. barWidth: barWidth,
  6808. y1: y1,
  6809. y2: y2,
  6810. strokeWidth: this.strokeWidth,
  6811. series: this.seriesRangeEnd,
  6812. realIndex: indexes.realIndex,
  6813. i: realIndex,
  6814. j: j,
  6815. w: w
  6816. });
  6817. if (!w.globals.isXNumeric) {
  6818. x = x + xDivision;
  6819. }
  6820. return {
  6821. pathTo: paths.pathTo,
  6822. pathFrom: paths.pathFrom,
  6823. barHeight: barHeight,
  6824. x: x,
  6825. y: y2,
  6826. goalY: this.barHelpers.getGoalValues('y', null, zeroH, i, j),
  6827. barXPosition: barXPosition
  6828. };
  6829. }
  6830. }, {
  6831. key: "drawRangeBarPaths",
  6832. value: function drawRangeBarPaths(_ref3) {
  6833. var indexes = _ref3.indexes,
  6834. y = _ref3.y,
  6835. y1 = _ref3.y1,
  6836. y2 = _ref3.y2,
  6837. yDivision = _ref3.yDivision,
  6838. barHeight = _ref3.barHeight,
  6839. barYPosition = _ref3.barYPosition,
  6840. zeroW = _ref3.zeroW;
  6841. var w = this.w;
  6842. var x1 = zeroW + y1 / this.invertedYRatio;
  6843. var x2 = zeroW + y2 / this.invertedYRatio;
  6844. var barWidth = Math.abs(x2 - x1);
  6845. var paths = this.barHelpers.getBarpaths({
  6846. barYPosition: barYPosition,
  6847. barHeight: barHeight,
  6848. x1: x1,
  6849. x2: x2,
  6850. strokeWidth: this.strokeWidth,
  6851. series: this.seriesRangeEnd,
  6852. i: indexes.realIndex,
  6853. realIndex: indexes.realIndex,
  6854. j: indexes.j,
  6855. w: w
  6856. });
  6857. if (!w.globals.isXNumeric) {
  6858. y = y + yDivision;
  6859. }
  6860. return {
  6861. pathTo: paths.pathTo,
  6862. pathFrom: paths.pathFrom,
  6863. barWidth: barWidth,
  6864. x: x2,
  6865. goalX: this.barHelpers.getGoalValues('x', zeroW, null, indexes.realIndex, indexes.j),
  6866. y: y
  6867. };
  6868. }
  6869. }, {
  6870. key: "getRangeValue",
  6871. value: function getRangeValue(i, j) {
  6872. var w = this.w;
  6873. return {
  6874. start: w.globals.seriesRangeStart[i][j],
  6875. end: w.globals.seriesRangeEnd[i][j]
  6876. };
  6877. }
  6878. }, {
  6879. key: "getTooltipValues",
  6880. value: function getTooltipValues(_ref4) {
  6881. var ctx = _ref4.ctx,
  6882. seriesIndex = _ref4.seriesIndex,
  6883. dataPointIndex = _ref4.dataPointIndex,
  6884. y1 = _ref4.y1,
  6885. y2 = _ref4.y2,
  6886. w = _ref4.w;
  6887. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  6888. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  6889. var ylabel = w.globals.labels[dataPointIndex];
  6890. var seriesName = w.config.series[seriesIndex].name ? w.config.series[seriesIndex].name : '';
  6891. var yLbFormatter = w.config.tooltip.y.formatter;
  6892. var yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  6893. var opts = {
  6894. w: w,
  6895. seriesIndex: seriesIndex,
  6896. dataPointIndex: dataPointIndex,
  6897. start: start,
  6898. end: end
  6899. };
  6900. if (typeof yLbTitleFormatter === 'function') {
  6901. seriesName = yLbTitleFormatter(seriesName, opts);
  6902. }
  6903. if (Number.isFinite(y1) && Number.isFinite(y2)) {
  6904. start = y1;
  6905. end = y2;
  6906. if (w.config.series[seriesIndex].data[dataPointIndex].x) {
  6907. ylabel = w.config.series[seriesIndex].data[dataPointIndex].x + ':';
  6908. }
  6909. if (typeof yLbFormatter === 'function') {
  6910. ylabel = yLbFormatter(ylabel, opts);
  6911. }
  6912. }
  6913. var startVal = '';
  6914. var endVal = '';
  6915. var color = w.globals.colors[seriesIndex];
  6916. if (w.config.tooltip.x.formatter === undefined) {
  6917. if (w.config.xaxis.type === 'datetime') {
  6918. var datetimeObj = new DateTime(ctx);
  6919. startVal = datetimeObj.formatDate(datetimeObj.getDate(start), w.config.tooltip.x.format);
  6920. endVal = datetimeObj.formatDate(datetimeObj.getDate(end), w.config.tooltip.x.format);
  6921. } else {
  6922. startVal = start;
  6923. endVal = end;
  6924. }
  6925. } else {
  6926. startVal = w.config.tooltip.x.formatter(start);
  6927. endVal = w.config.tooltip.x.formatter(end);
  6928. }
  6929. return {
  6930. start: start,
  6931. end: end,
  6932. startVal: startVal,
  6933. endVal: endVal,
  6934. ylabel: ylabel,
  6935. color: color,
  6936. seriesName: seriesName
  6937. };
  6938. }
  6939. }, {
  6940. key: "buildCustomTooltipHTML",
  6941. value: function buildCustomTooltipHTML(_ref5) {
  6942. var color = _ref5.color,
  6943. seriesName = _ref5.seriesName,
  6944. ylabel = _ref5.ylabel,
  6945. start = _ref5.start,
  6946. end = _ref5.end;
  6947. 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">' + start + '</span> <span class="separator">-</span> <span class="value end-value">' + end + '</span></div>' + '</div>';
  6948. }
  6949. }]);
  6950. return RangeBar;
  6951. }(Bar);
  6952. /**
  6953. * ApexCharts Default Class for setting default options for all chart types.
  6954. *
  6955. * @module Defaults
  6956. **/
  6957. var Defaults = /*#__PURE__*/function () {
  6958. function Defaults(opts) {
  6959. _classCallCheck(this, Defaults);
  6960. this.opts = opts;
  6961. }
  6962. _createClass(Defaults, [{
  6963. key: "line",
  6964. value: function line() {
  6965. return {
  6966. chart: {
  6967. animations: {
  6968. easing: 'swing'
  6969. }
  6970. },
  6971. dataLabels: {
  6972. enabled: false
  6973. },
  6974. stroke: {
  6975. width: 5,
  6976. curve: 'straight'
  6977. },
  6978. markers: {
  6979. size: 0,
  6980. hover: {
  6981. sizeOffset: 6
  6982. }
  6983. },
  6984. xaxis: {
  6985. crosshairs: {
  6986. width: 1
  6987. }
  6988. }
  6989. };
  6990. }
  6991. }, {
  6992. key: "sparkline",
  6993. value: function sparkline(defaults) {
  6994. this.opts.yaxis[0].show = false;
  6995. this.opts.yaxis[0].title.text = '';
  6996. this.opts.yaxis[0].axisBorder.show = false;
  6997. this.opts.yaxis[0].axisTicks.show = false;
  6998. this.opts.yaxis[0].floating = true;
  6999. var ret = {
  7000. grid: {
  7001. show: false,
  7002. padding: {
  7003. left: 0,
  7004. right: 0,
  7005. top: 0,
  7006. bottom: 0
  7007. }
  7008. },
  7009. legend: {
  7010. show: false
  7011. },
  7012. xaxis: {
  7013. labels: {
  7014. show: false
  7015. },
  7016. tooltip: {
  7017. enabled: false
  7018. },
  7019. axisBorder: {
  7020. show: false
  7021. },
  7022. axisTicks: {
  7023. show: false
  7024. }
  7025. },
  7026. chart: {
  7027. toolbar: {
  7028. show: false
  7029. },
  7030. zoom: {
  7031. enabled: false
  7032. }
  7033. },
  7034. dataLabels: {
  7035. enabled: false
  7036. }
  7037. };
  7038. return Utils$1.extend(defaults, ret);
  7039. }
  7040. }, {
  7041. key: "bar",
  7042. value: function bar() {
  7043. return {
  7044. chart: {
  7045. stacked: false,
  7046. animations: {
  7047. easing: 'swing'
  7048. }
  7049. },
  7050. plotOptions: {
  7051. bar: {
  7052. dataLabels: {
  7053. position: 'center'
  7054. }
  7055. }
  7056. },
  7057. dataLabels: {
  7058. style: {
  7059. colors: ['#fff']
  7060. },
  7061. background: {
  7062. enabled: false
  7063. }
  7064. },
  7065. stroke: {
  7066. width: 0,
  7067. lineCap: 'round'
  7068. },
  7069. fill: {
  7070. opacity: 0.85
  7071. },
  7072. legend: {
  7073. markers: {
  7074. shape: 'square',
  7075. radius: 2,
  7076. size: 8
  7077. }
  7078. },
  7079. tooltip: {
  7080. shared: false,
  7081. intersect: true
  7082. },
  7083. xaxis: {
  7084. tooltip: {
  7085. enabled: false
  7086. },
  7087. tickPlacement: 'between',
  7088. crosshairs: {
  7089. width: 'barWidth',
  7090. position: 'back',
  7091. fill: {
  7092. type: 'gradient'
  7093. },
  7094. dropShadow: {
  7095. enabled: false
  7096. },
  7097. stroke: {
  7098. width: 0
  7099. }
  7100. }
  7101. }
  7102. };
  7103. }
  7104. }, {
  7105. key: "candlestick",
  7106. value: function candlestick() {
  7107. var _this = this;
  7108. return {
  7109. stroke: {
  7110. width: 1,
  7111. colors: ['#333']
  7112. },
  7113. fill: {
  7114. opacity: 1
  7115. },
  7116. dataLabels: {
  7117. enabled: false
  7118. },
  7119. tooltip: {
  7120. shared: true,
  7121. custom: function custom(_ref) {
  7122. var seriesIndex = _ref.seriesIndex,
  7123. dataPointIndex = _ref.dataPointIndex,
  7124. w = _ref.w;
  7125. return _this._getBoxTooltip(w, seriesIndex, dataPointIndex, ['Open', 'High', '', 'Low', 'Close'], 'candlestick');
  7126. }
  7127. },
  7128. states: {
  7129. active: {
  7130. filter: {
  7131. type: 'none'
  7132. }
  7133. }
  7134. },
  7135. xaxis: {
  7136. crosshairs: {
  7137. width: 1
  7138. }
  7139. }
  7140. };
  7141. }
  7142. }, {
  7143. key: "boxPlot",
  7144. value: function boxPlot() {
  7145. var _this2 = this;
  7146. return {
  7147. chart: {
  7148. animations: {
  7149. dynamicAnimation: {
  7150. enabled: false
  7151. }
  7152. }
  7153. },
  7154. stroke: {
  7155. width: 1,
  7156. colors: ['#24292e']
  7157. },
  7158. dataLabels: {
  7159. enabled: false
  7160. },
  7161. tooltip: {
  7162. shared: true,
  7163. custom: function custom(_ref2) {
  7164. var seriesIndex = _ref2.seriesIndex,
  7165. dataPointIndex = _ref2.dataPointIndex,
  7166. w = _ref2.w;
  7167. return _this2._getBoxTooltip(w, seriesIndex, dataPointIndex, ['Minimum', 'Q1', 'Median', 'Q3', 'Maximum'], 'boxPlot');
  7168. }
  7169. },
  7170. markers: {
  7171. size: 5,
  7172. strokeWidth: 1,
  7173. strokeColors: '#111'
  7174. },
  7175. xaxis: {
  7176. crosshairs: {
  7177. width: 1
  7178. }
  7179. }
  7180. };
  7181. }
  7182. }, {
  7183. key: "rangeBar",
  7184. value: function rangeBar() {
  7185. var handleTimelineTooltip = function handleTimelineTooltip(opts) {
  7186. var rangeCtx = new RangeBar(opts.ctx, null);
  7187. var _rangeCtx$getTooltipV = rangeCtx.getTooltipValues(opts),
  7188. color = _rangeCtx$getTooltipV.color,
  7189. seriesName = _rangeCtx$getTooltipV.seriesName,
  7190. ylabel = _rangeCtx$getTooltipV.ylabel,
  7191. startVal = _rangeCtx$getTooltipV.startVal,
  7192. endVal = _rangeCtx$getTooltipV.endVal;
  7193. return rangeCtx.buildCustomTooltipHTML({
  7194. color: color,
  7195. seriesName: seriesName,
  7196. ylabel: ylabel,
  7197. start: startVal,
  7198. end: endVal
  7199. });
  7200. };
  7201. var handleRangeColumnTooltip = function handleRangeColumnTooltip(opts) {
  7202. var rangeCtx = new RangeBar(opts.ctx, null);
  7203. var _rangeCtx$getTooltipV2 = rangeCtx.getTooltipValues(opts),
  7204. color = _rangeCtx$getTooltipV2.color,
  7205. seriesName = _rangeCtx$getTooltipV2.seriesName,
  7206. ylabel = _rangeCtx$getTooltipV2.ylabel,
  7207. start = _rangeCtx$getTooltipV2.start,
  7208. end = _rangeCtx$getTooltipV2.end;
  7209. return rangeCtx.buildCustomTooltipHTML({
  7210. color: color,
  7211. seriesName: seriesName,
  7212. ylabel: ylabel,
  7213. start: start,
  7214. end: end
  7215. });
  7216. };
  7217. return {
  7218. stroke: {
  7219. width: 0,
  7220. lineCap: 'square'
  7221. },
  7222. plotOptions: {
  7223. bar: {
  7224. borderRadius: 0,
  7225. dataLabels: {
  7226. position: 'center'
  7227. }
  7228. }
  7229. },
  7230. dataLabels: {
  7231. enabled: false,
  7232. formatter: function formatter(val, _ref3) {
  7233. _ref3.ctx;
  7234. var seriesIndex = _ref3.seriesIndex,
  7235. dataPointIndex = _ref3.dataPointIndex,
  7236. w = _ref3.w;
  7237. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  7238. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  7239. return end - start;
  7240. },
  7241. background: {
  7242. enabled: false
  7243. },
  7244. style: {
  7245. colors: ['#fff']
  7246. }
  7247. },
  7248. tooltip: {
  7249. shared: false,
  7250. followCursor: true,
  7251. custom: function custom(opts) {
  7252. if (opts.w.config.plotOptions && opts.w.config.plotOptions.bar && opts.w.config.plotOptions.bar.horizontal) {
  7253. return handleTimelineTooltip(opts);
  7254. } else {
  7255. return handleRangeColumnTooltip(opts);
  7256. }
  7257. }
  7258. },
  7259. xaxis: {
  7260. tickPlacement: 'between',
  7261. tooltip: {
  7262. enabled: false
  7263. },
  7264. crosshairs: {
  7265. stroke: {
  7266. width: 0
  7267. }
  7268. }
  7269. }
  7270. };
  7271. }
  7272. }, {
  7273. key: "area",
  7274. value: function area() {
  7275. return {
  7276. stroke: {
  7277. width: 4
  7278. },
  7279. fill: {
  7280. type: 'gradient',
  7281. gradient: {
  7282. inverseColors: false,
  7283. shade: 'light',
  7284. type: 'vertical',
  7285. opacityFrom: 0.65,
  7286. opacityTo: 0.5,
  7287. stops: [0, 100, 100]
  7288. }
  7289. },
  7290. markers: {
  7291. size: 0,
  7292. hover: {
  7293. sizeOffset: 6
  7294. }
  7295. },
  7296. tooltip: {
  7297. followCursor: false
  7298. }
  7299. };
  7300. }
  7301. }, {
  7302. key: "brush",
  7303. value: function brush(defaults) {
  7304. var ret = {
  7305. chart: {
  7306. toolbar: {
  7307. autoSelected: 'selection',
  7308. show: false
  7309. },
  7310. zoom: {
  7311. enabled: false
  7312. }
  7313. },
  7314. dataLabels: {
  7315. enabled: false
  7316. },
  7317. stroke: {
  7318. width: 1
  7319. },
  7320. tooltip: {
  7321. enabled: false
  7322. },
  7323. xaxis: {
  7324. tooltip: {
  7325. enabled: false
  7326. }
  7327. }
  7328. };
  7329. return Utils$1.extend(defaults, ret);
  7330. }
  7331. }, {
  7332. key: "stacked100",
  7333. value: function stacked100(opts) {
  7334. opts.dataLabels = opts.dataLabels || {};
  7335. opts.dataLabels.formatter = opts.dataLabels.formatter || undefined;
  7336. var existingDataLabelFormatter = opts.dataLabels.formatter;
  7337. opts.yaxis.forEach(function (yaxe, index) {
  7338. opts.yaxis[index].min = 0;
  7339. opts.yaxis[index].max = 100;
  7340. });
  7341. var isBar = opts.chart.type === 'bar';
  7342. if (isBar) {
  7343. opts.dataLabels.formatter = existingDataLabelFormatter || function (val) {
  7344. if (typeof val === 'number') {
  7345. return val ? val.toFixed(0) + '%' : val;
  7346. }
  7347. return val;
  7348. };
  7349. }
  7350. return opts;
  7351. } // 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
  7352. }, {
  7353. key: "convertCatToNumeric",
  7354. value: function convertCatToNumeric(opts) {
  7355. opts.xaxis.convertedCatToNumeric = true;
  7356. return opts;
  7357. }
  7358. }, {
  7359. key: "convertCatToNumericXaxis",
  7360. value: function convertCatToNumericXaxis(opts, ctx, cats) {
  7361. opts.xaxis.type = 'numeric';
  7362. opts.xaxis.labels = opts.xaxis.labels || {};
  7363. opts.xaxis.labels.formatter = opts.xaxis.labels.formatter || function (val) {
  7364. return Utils$1.isNumber(val) ? Math.floor(val) : val;
  7365. };
  7366. var defaultFormatter = opts.xaxis.labels.formatter;
  7367. var labels = opts.xaxis.categories && opts.xaxis.categories.length ? opts.xaxis.categories : opts.labels;
  7368. if (cats && cats.length) {
  7369. labels = cats.map(function (c) {
  7370. return Array.isArray(c) ? c : String(c);
  7371. });
  7372. }
  7373. if (labels && labels.length) {
  7374. opts.xaxis.labels.formatter = function (val) {
  7375. return Utils$1.isNumber(val) ? defaultFormatter(labels[Math.floor(val) - 1]) : defaultFormatter(val);
  7376. };
  7377. }
  7378. opts.xaxis.categories = [];
  7379. opts.labels = [];
  7380. opts.xaxis.tickAmount = opts.xaxis.tickAmount || 'dataPoints';
  7381. return opts;
  7382. }
  7383. }, {
  7384. key: "bubble",
  7385. value: function bubble() {
  7386. return {
  7387. dataLabels: {
  7388. style: {
  7389. colors: ['#fff']
  7390. }
  7391. },
  7392. tooltip: {
  7393. shared: false,
  7394. intersect: true
  7395. },
  7396. xaxis: {
  7397. crosshairs: {
  7398. width: 0
  7399. }
  7400. },
  7401. fill: {
  7402. type: 'solid',
  7403. gradient: {
  7404. shade: 'light',
  7405. inverse: true,
  7406. shadeIntensity: 0.55,
  7407. opacityFrom: 0.4,
  7408. opacityTo: 0.8
  7409. }
  7410. }
  7411. };
  7412. }
  7413. }, {
  7414. key: "scatter",
  7415. value: function scatter() {
  7416. return {
  7417. dataLabels: {
  7418. enabled: false
  7419. },
  7420. tooltip: {
  7421. shared: false,
  7422. intersect: true
  7423. },
  7424. markers: {
  7425. size: 6,
  7426. strokeWidth: 1,
  7427. hover: {
  7428. sizeOffset: 2
  7429. }
  7430. }
  7431. };
  7432. }
  7433. }, {
  7434. key: "heatmap",
  7435. value: function heatmap() {
  7436. return {
  7437. chart: {
  7438. stacked: false
  7439. },
  7440. fill: {
  7441. opacity: 1
  7442. },
  7443. dataLabels: {
  7444. style: {
  7445. colors: ['#fff']
  7446. }
  7447. },
  7448. stroke: {
  7449. colors: ['#fff']
  7450. },
  7451. tooltip: {
  7452. followCursor: true,
  7453. marker: {
  7454. show: false
  7455. },
  7456. x: {
  7457. show: false
  7458. }
  7459. },
  7460. legend: {
  7461. position: 'top',
  7462. markers: {
  7463. shape: 'square',
  7464. size: 10,
  7465. offsetY: 2
  7466. }
  7467. },
  7468. grid: {
  7469. padding: {
  7470. right: 20
  7471. }
  7472. }
  7473. };
  7474. }
  7475. }, {
  7476. key: "treemap",
  7477. value: function treemap() {
  7478. return {
  7479. chart: {
  7480. zoom: {
  7481. enabled: false
  7482. }
  7483. },
  7484. dataLabels: {
  7485. style: {
  7486. fontSize: 14,
  7487. fontWeight: 600,
  7488. colors: ['#fff']
  7489. }
  7490. },
  7491. stroke: {
  7492. show: true,
  7493. width: 2,
  7494. colors: ['#fff']
  7495. },
  7496. legend: {
  7497. show: false
  7498. },
  7499. fill: {
  7500. gradient: {
  7501. stops: [0, 100]
  7502. }
  7503. },
  7504. tooltip: {
  7505. followCursor: true,
  7506. x: {
  7507. show: false
  7508. }
  7509. },
  7510. grid: {
  7511. padding: {
  7512. left: 0,
  7513. right: 0
  7514. }
  7515. },
  7516. xaxis: {
  7517. crosshairs: {
  7518. show: false
  7519. },
  7520. tooltip: {
  7521. enabled: false
  7522. }
  7523. }
  7524. };
  7525. }
  7526. }, {
  7527. key: "pie",
  7528. value: function pie() {
  7529. return {
  7530. chart: {
  7531. toolbar: {
  7532. show: false
  7533. }
  7534. },
  7535. plotOptions: {
  7536. pie: {
  7537. donut: {
  7538. labels: {
  7539. show: false
  7540. }
  7541. }
  7542. }
  7543. },
  7544. dataLabels: {
  7545. formatter: function formatter(val) {
  7546. return val.toFixed(1) + '%';
  7547. },
  7548. style: {
  7549. colors: ['#fff']
  7550. },
  7551. background: {
  7552. enabled: false
  7553. },
  7554. dropShadow: {
  7555. enabled: true
  7556. }
  7557. },
  7558. stroke: {
  7559. colors: ['#fff']
  7560. },
  7561. fill: {
  7562. opacity: 1,
  7563. gradient: {
  7564. shade: 'light',
  7565. stops: [0, 100]
  7566. }
  7567. },
  7568. tooltip: {
  7569. theme: 'dark',
  7570. fillSeriesColor: true
  7571. },
  7572. legend: {
  7573. position: 'right'
  7574. }
  7575. };
  7576. }
  7577. }, {
  7578. key: "donut",
  7579. value: function donut() {
  7580. return {
  7581. chart: {
  7582. toolbar: {
  7583. show: false
  7584. }
  7585. },
  7586. dataLabels: {
  7587. formatter: function formatter(val) {
  7588. return val.toFixed(1) + '%';
  7589. },
  7590. style: {
  7591. colors: ['#fff']
  7592. },
  7593. background: {
  7594. enabled: false
  7595. },
  7596. dropShadow: {
  7597. enabled: true
  7598. }
  7599. },
  7600. stroke: {
  7601. colors: ['#fff']
  7602. },
  7603. fill: {
  7604. opacity: 1,
  7605. gradient: {
  7606. shade: 'light',
  7607. shadeIntensity: 0.35,
  7608. stops: [80, 100],
  7609. opacityFrom: 1,
  7610. opacityTo: 1
  7611. }
  7612. },
  7613. tooltip: {
  7614. theme: 'dark',
  7615. fillSeriesColor: true
  7616. },
  7617. legend: {
  7618. position: 'right'
  7619. }
  7620. };
  7621. }
  7622. }, {
  7623. key: "polarArea",
  7624. value: function polarArea() {
  7625. this.opts.yaxis[0].tickAmount = this.opts.yaxis[0].tickAmount ? this.opts.yaxis[0].tickAmount : 6;
  7626. return {
  7627. chart: {
  7628. toolbar: {
  7629. show: false
  7630. }
  7631. },
  7632. dataLabels: {
  7633. formatter: function formatter(val) {
  7634. return val.toFixed(1) + '%';
  7635. },
  7636. enabled: false
  7637. },
  7638. stroke: {
  7639. show: true,
  7640. width: 2
  7641. },
  7642. fill: {
  7643. opacity: 0.7
  7644. },
  7645. tooltip: {
  7646. theme: 'dark',
  7647. fillSeriesColor: true
  7648. },
  7649. legend: {
  7650. position: 'right'
  7651. }
  7652. };
  7653. }
  7654. }, {
  7655. key: "radar",
  7656. value: function radar() {
  7657. this.opts.yaxis[0].labels.offsetY = this.opts.yaxis[0].labels.offsetY ? this.opts.yaxis[0].labels.offsetY : 6;
  7658. return {
  7659. dataLabels: {
  7660. enabled: false,
  7661. style: {
  7662. fontSize: '11px'
  7663. }
  7664. },
  7665. stroke: {
  7666. width: 2
  7667. },
  7668. markers: {
  7669. size: 3,
  7670. strokeWidth: 1,
  7671. strokeOpacity: 1
  7672. },
  7673. fill: {
  7674. opacity: 0.2
  7675. },
  7676. tooltip: {
  7677. shared: false,
  7678. intersect: true,
  7679. followCursor: true
  7680. },
  7681. grid: {
  7682. show: false
  7683. },
  7684. xaxis: {
  7685. labels: {
  7686. formatter: function formatter(val) {
  7687. return val;
  7688. },
  7689. style: {
  7690. colors: ['#a8a8a8'],
  7691. fontSize: '11px'
  7692. }
  7693. },
  7694. tooltip: {
  7695. enabled: false
  7696. },
  7697. crosshairs: {
  7698. show: false
  7699. }
  7700. }
  7701. };
  7702. }
  7703. }, {
  7704. key: "radialBar",
  7705. value: function radialBar() {
  7706. return {
  7707. chart: {
  7708. animations: {
  7709. dynamicAnimation: {
  7710. enabled: true,
  7711. speed: 800
  7712. }
  7713. },
  7714. toolbar: {
  7715. show: false
  7716. }
  7717. },
  7718. fill: {
  7719. gradient: {
  7720. shade: 'dark',
  7721. shadeIntensity: 0.4,
  7722. inverseColors: false,
  7723. type: 'diagonal2',
  7724. opacityFrom: 1,
  7725. opacityTo: 1,
  7726. stops: [70, 98, 100]
  7727. }
  7728. },
  7729. legend: {
  7730. show: false,
  7731. position: 'right'
  7732. },
  7733. tooltip: {
  7734. enabled: false,
  7735. fillSeriesColor: true
  7736. }
  7737. };
  7738. }
  7739. }, {
  7740. key: "_getBoxTooltip",
  7741. value: function _getBoxTooltip(w, seriesIndex, dataPointIndex, labels, chartType) {
  7742. var o = w.globals.seriesCandleO[seriesIndex][dataPointIndex];
  7743. var h = w.globals.seriesCandleH[seriesIndex][dataPointIndex];
  7744. var m = w.globals.seriesCandleM[seriesIndex][dataPointIndex];
  7745. var l = w.globals.seriesCandleL[seriesIndex][dataPointIndex];
  7746. var c = w.globals.seriesCandleC[seriesIndex][dataPointIndex];
  7747. if (w.config.series[seriesIndex].type && w.config.series[seriesIndex].type !== chartType) {
  7748. return "<div class=\"apexcharts-custom-tooltip\">\n ".concat(w.config.series[seriesIndex].name ? w.config.series[seriesIndex].name : 'series-' + (seriesIndex + 1), ": <strong>").concat(w.globals.series[seriesIndex][dataPointIndex], "</strong>\n </div>");
  7749. } else {
  7750. return "<div class=\"apexcharts-tooltip-box apexcharts-tooltip-".concat(w.config.chart.type, "\">") + "<div>".concat(labels[0], ": <span class=\"value\">") + o + '</span></div>' + "<div>".concat(labels[1], ": <span class=\"value\">") + h + '</span></div>' + (m ? "<div>".concat(labels[2], ": <span class=\"value\">") + m + '</span></div>' : '') + "<div>".concat(labels[3], ": <span class=\"value\">") + l + '</span></div>' + "<div>".concat(labels[4], ": <span class=\"value\">") + c + '</span></div>' + '</div>';
  7751. }
  7752. }
  7753. }]);
  7754. return Defaults;
  7755. }();
  7756. /**
  7757. * ApexCharts Config Class for extending user options with pre-defined ApexCharts config.
  7758. *
  7759. * @module Config
  7760. **/
  7761. var Config = /*#__PURE__*/function () {
  7762. function Config(opts) {
  7763. _classCallCheck(this, Config);
  7764. this.opts = opts;
  7765. }
  7766. _createClass(Config, [{
  7767. key: "init",
  7768. value: function init(_ref) {
  7769. var responsiveOverride = _ref.responsiveOverride;
  7770. var opts = this.opts;
  7771. var options = new Options();
  7772. var defaults = new Defaults(opts);
  7773. this.chartType = opts.chart.type;
  7774. if (this.chartType === 'histogram') {
  7775. // technically, a histogram can be drawn by a column chart with no spaces in between
  7776. opts.chart.type = 'bar';
  7777. opts = Utils$1.extend({
  7778. plotOptions: {
  7779. bar: {
  7780. columnWidth: '99.99%'
  7781. }
  7782. }
  7783. }, opts);
  7784. }
  7785. opts = this.extendYAxis(opts);
  7786. opts = this.extendAnnotations(opts);
  7787. var config = options.init();
  7788. var newDefaults = {};
  7789. if (opts && _typeof(opts) === 'object') {
  7790. var chartDefaults = {};
  7791. var chartTypes = ['line', 'area', 'bar', 'candlestick', 'boxPlot', 'rangeBar', 'histogram', 'bubble', 'scatter', 'heatmap', 'treemap', 'pie', 'polarArea', 'donut', 'radar', 'radialBar'];
  7792. if (chartTypes.indexOf(opts.chart.type) !== -1) {
  7793. chartDefaults = defaults[opts.chart.type]();
  7794. } else {
  7795. chartDefaults = defaults.line();
  7796. }
  7797. if (opts.chart.brush && opts.chart.brush.enabled) {
  7798. chartDefaults = defaults.brush(chartDefaults);
  7799. }
  7800. if (opts.chart.stacked && opts.chart.stackType === '100%') {
  7801. opts = defaults.stacked100(opts);
  7802. } // If user has specified a dark theme, make the tooltip dark too
  7803. this.checkForDarkTheme(window.Apex); // check global window Apex options
  7804. this.checkForDarkTheme(opts); // check locally passed options
  7805. opts.xaxis = opts.xaxis || window.Apex.xaxis || {}; // an important boolean needs to be set here
  7806. // otherwise all the charts will have this flag set to true window.Apex.xaxis is set globally
  7807. if (!responsiveOverride) {
  7808. opts.xaxis.convertedCatToNumeric = false;
  7809. }
  7810. opts = this.checkForCatToNumericXAxis(this.chartType, chartDefaults, opts);
  7811. if (opts.chart.sparkline && opts.chart.sparkline.enabled || window.Apex.chart && window.Apex.chart.sparkline && window.Apex.chart.sparkline.enabled) {
  7812. chartDefaults = defaults.sparkline(chartDefaults);
  7813. }
  7814. newDefaults = Utils$1.extend(config, chartDefaults);
  7815. } // config should cascade in this fashion
  7816. // default-config < global-apex-variable-config < user-defined-config
  7817. // get GLOBALLY defined options and merge with the default config
  7818. var mergedWithDefaultConfig = Utils$1.extend(newDefaults, window.Apex); // get the merged config and extend with user defined config
  7819. config = Utils$1.extend(mergedWithDefaultConfig, opts); // some features are not supported. those mismatches should be handled
  7820. config = this.handleUserInputErrors(config);
  7821. return config;
  7822. }
  7823. }, {
  7824. key: "checkForCatToNumericXAxis",
  7825. value: function checkForCatToNumericXAxis(chartType, chartDefaults, opts) {
  7826. var defaults = new Defaults(opts);
  7827. var isBarHorizontal = (chartType === 'bar' || chartType === 'boxPlot') && opts.plotOptions && opts.plotOptions.bar && opts.plotOptions.bar.horizontal;
  7828. var unsupportedZoom = chartType === 'pie' || chartType === 'polarArea' || chartType === 'donut' || chartType === 'radar' || chartType === 'radialBar' || chartType === 'heatmap';
  7829. var notNumericXAxis = opts.xaxis.type !== 'datetime' && opts.xaxis.type !== 'numeric';
  7830. var tickPlacement = opts.xaxis.tickPlacement ? opts.xaxis.tickPlacement : chartDefaults.xaxis && chartDefaults.xaxis.tickPlacement;
  7831. if (!isBarHorizontal && !unsupportedZoom && notNumericXAxis && tickPlacement !== 'between') {
  7832. opts = defaults.convertCatToNumeric(opts);
  7833. }
  7834. return opts;
  7835. }
  7836. }, {
  7837. key: "extendYAxis",
  7838. value: function extendYAxis(opts, w) {
  7839. var options = new Options();
  7840. if (typeof opts.yaxis === 'undefined' || !opts.yaxis || Array.isArray(opts.yaxis) && opts.yaxis.length === 0) {
  7841. opts.yaxis = {};
  7842. } // extend global yaxis config (only if object is provided / not an array)
  7843. if (opts.yaxis.constructor !== Array && window.Apex.yaxis && window.Apex.yaxis.constructor !== Array) {
  7844. opts.yaxis = Utils$1.extend(opts.yaxis, window.Apex.yaxis);
  7845. } // as we can't extend nested object's array with extend, we need to do it first
  7846. // user can provide either an array or object in yaxis config
  7847. if (opts.yaxis.constructor !== Array) {
  7848. // convert the yaxis to array if user supplied object
  7849. opts.yaxis = [Utils$1.extend(options.yAxis, opts.yaxis)];
  7850. } else {
  7851. opts.yaxis = Utils$1.extendArray(opts.yaxis, options.yAxis);
  7852. }
  7853. var isLogY = false;
  7854. opts.yaxis.forEach(function (y) {
  7855. if (y.logarithmic) {
  7856. isLogY = true;
  7857. }
  7858. });
  7859. var series = opts.series;
  7860. if (w && !series) {
  7861. series = w.config.series;
  7862. } // A logarithmic chart works correctly when each series has a corresponding y-axis
  7863. // If this is not the case, we manually create yaxis for multi-series log chart
  7864. if (isLogY && series.length !== opts.yaxis.length && series.length) {
  7865. opts.yaxis = series.map(function (s, i) {
  7866. if (!s.name) {
  7867. series[i].name = "series-".concat(i + 1);
  7868. }
  7869. if (opts.yaxis[i]) {
  7870. opts.yaxis[i].seriesName = series[i].name;
  7871. return opts.yaxis[i];
  7872. } else {
  7873. var newYaxis = Utils$1.extend(options.yAxis, opts.yaxis[0]);
  7874. newYaxis.show = false;
  7875. return newYaxis;
  7876. }
  7877. });
  7878. }
  7879. if (isLogY && series.length > 1 && series.length !== opts.yaxis.length) {
  7880. console.warn('A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both.');
  7881. }
  7882. return opts;
  7883. } // annotations also accepts array, so we need to extend them manually
  7884. }, {
  7885. key: "extendAnnotations",
  7886. value: function extendAnnotations(opts) {
  7887. if (typeof opts.annotations === 'undefined') {
  7888. opts.annotations = {};
  7889. opts.annotations.yaxis = [];
  7890. opts.annotations.xaxis = [];
  7891. opts.annotations.points = [];
  7892. }
  7893. opts = this.extendYAxisAnnotations(opts);
  7894. opts = this.extendXAxisAnnotations(opts);
  7895. opts = this.extendPointAnnotations(opts);
  7896. return opts;
  7897. }
  7898. }, {
  7899. key: "extendYAxisAnnotations",
  7900. value: function extendYAxisAnnotations(opts) {
  7901. var options = new Options();
  7902. opts.annotations.yaxis = Utils$1.extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], options.yAxisAnnotation);
  7903. return opts;
  7904. }
  7905. }, {
  7906. key: "extendXAxisAnnotations",
  7907. value: function extendXAxisAnnotations(opts) {
  7908. var options = new Options();
  7909. opts.annotations.xaxis = Utils$1.extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], options.xAxisAnnotation);
  7910. return opts;
  7911. }
  7912. }, {
  7913. key: "extendPointAnnotations",
  7914. value: function extendPointAnnotations(opts) {
  7915. var options = new Options();
  7916. opts.annotations.points = Utils$1.extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], options.pointAnnotation);
  7917. return opts;
  7918. }
  7919. }, {
  7920. key: "checkForDarkTheme",
  7921. value: function checkForDarkTheme(opts) {
  7922. if (opts.theme && opts.theme.mode === 'dark') {
  7923. if (!opts.tooltip) {
  7924. opts.tooltip = {};
  7925. }
  7926. if (opts.tooltip.theme !== 'light') {
  7927. opts.tooltip.theme = 'dark';
  7928. }
  7929. if (!opts.chart.foreColor) {
  7930. opts.chart.foreColor = '#f6f7f8';
  7931. }
  7932. if (!opts.chart.background) {
  7933. opts.chart.background = '#424242';
  7934. }
  7935. if (!opts.theme.palette) {
  7936. opts.theme.palette = 'palette4';
  7937. }
  7938. }
  7939. }
  7940. }, {
  7941. key: "handleUserInputErrors",
  7942. value: function handleUserInputErrors(opts) {
  7943. var config = opts; // conflicting tooltip option. intersect makes sure to focus on 1 point at a time. Shared cannot be used along with it
  7944. if (config.tooltip.shared && config.tooltip.intersect) {
  7945. throw new Error('tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.');
  7946. }
  7947. if (config.chart.type === 'bar' && config.plotOptions.bar.horizontal) {
  7948. // No multiple yaxis for bars
  7949. if (config.yaxis.length > 1) {
  7950. throw new Error('Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false');
  7951. } // if yaxis is reversed in horizontal bar chart, you should draw the y-axis on right side
  7952. if (config.yaxis[0].reversed) {
  7953. config.yaxis[0].opposite = true;
  7954. }
  7955. config.xaxis.tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  7956. config.yaxis[0].tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  7957. config.chart.zoom.enabled = false; // no zooming for horz bars
  7958. }
  7959. if (config.chart.type === 'bar' || config.chart.type === 'rangeBar') {
  7960. if (config.tooltip.shared) {
  7961. if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) {
  7962. config.xaxis.crosshairs.width = 'tickWidth';
  7963. }
  7964. }
  7965. }
  7966. if (config.chart.type === 'candlestick' || config.chart.type === 'boxPlot') {
  7967. if (config.yaxis[0].reversed) {
  7968. console.warn("Reversed y-axis in ".concat(config.chart.type, " chart is not supported."));
  7969. config.yaxis[0].reversed = false;
  7970. }
  7971. }
  7972. return config;
  7973. }
  7974. }]);
  7975. return Config;
  7976. }();
  7977. var Globals = /*#__PURE__*/function () {
  7978. function Globals() {
  7979. _classCallCheck(this, Globals);
  7980. }
  7981. _createClass(Globals, [{
  7982. key: "initGlobalVars",
  7983. value: function initGlobalVars(gl) {
  7984. gl.series = []; // the MAIN series array (y values)
  7985. gl.seriesCandleO = [];
  7986. gl.seriesCandleH = [];
  7987. gl.seriesCandleM = [];
  7988. gl.seriesCandleL = [];
  7989. gl.seriesCandleC = [];
  7990. gl.seriesRangeStart = [];
  7991. gl.seriesRangeEnd = [];
  7992. gl.seriesRangeBar = [];
  7993. gl.seriesPercent = [];
  7994. gl.seriesGoals = [];
  7995. gl.seriesX = [];
  7996. gl.seriesZ = [];
  7997. gl.seriesNames = [];
  7998. gl.seriesTotals = [];
  7999. gl.seriesLog = [];
  8000. gl.seriesColors = [];
  8001. gl.stackedSeriesTotals = [];
  8002. gl.seriesXvalues = []; // we will need this in tooltip (it's x position)
  8003. // when we will have unequal x values, we will need
  8004. // some way to get x value depending on mouse pointer
  8005. gl.seriesYvalues = []; // we will need this when deciding which series
  8006. // user hovered on
  8007. gl.labels = [];
  8008. gl.hasGroups = false;
  8009. gl.groups = [];
  8010. gl.categoryLabels = [];
  8011. gl.timescaleLabels = [];
  8012. gl.noLabelsProvided = false;
  8013. gl.resizeTimer = null;
  8014. gl.selectionResizeTimer = null;
  8015. gl.delayedElements = [];
  8016. gl.pointsArray = [];
  8017. gl.dataLabelsRects = [];
  8018. gl.isXNumeric = false;
  8019. gl.xaxisLabelsCount = 0;
  8020. gl.skipLastTimelinelabel = false;
  8021. gl.skipFirstTimelinelabel = false;
  8022. gl.isDataXYZ = false;
  8023. gl.isMultiLineX = false;
  8024. gl.isMultipleYAxis = false;
  8025. gl.maxY = -Number.MAX_VALUE;
  8026. gl.minY = Number.MIN_VALUE;
  8027. gl.minYArr = [];
  8028. gl.maxYArr = [];
  8029. gl.maxX = -Number.MAX_VALUE;
  8030. gl.minX = Number.MAX_VALUE;
  8031. gl.initialMaxX = -Number.MAX_VALUE;
  8032. gl.initialMinX = Number.MAX_VALUE;
  8033. gl.maxDate = 0;
  8034. gl.minDate = Number.MAX_VALUE;
  8035. gl.minZ = Number.MAX_VALUE;
  8036. gl.maxZ = -Number.MAX_VALUE;
  8037. gl.minXDiff = Number.MAX_VALUE;
  8038. gl.yAxisScale = [];
  8039. gl.xAxisScale = null;
  8040. gl.xAxisTicksPositions = [];
  8041. gl.yLabelsCoords = [];
  8042. gl.yTitleCoords = [];
  8043. gl.barPadForNumericAxis = 0;
  8044. gl.padHorizontal = 0;
  8045. gl.xRange = 0;
  8046. gl.yRange = [];
  8047. gl.zRange = 0;
  8048. gl.dataPoints = 0;
  8049. gl.xTickAmount = 0;
  8050. }
  8051. }, {
  8052. key: "globalVars",
  8053. value: function globalVars(config) {
  8054. return {
  8055. chartID: null,
  8056. // chart ID - apexcharts-cuid
  8057. cuid: null,
  8058. // chart ID - random numbers excluding "apexcharts" part
  8059. events: {
  8060. beforeMount: [],
  8061. mounted: [],
  8062. updated: [],
  8063. clicked: [],
  8064. selection: [],
  8065. dataPointSelection: [],
  8066. zoomed: [],
  8067. scrolled: []
  8068. },
  8069. colors: [],
  8070. clientX: null,
  8071. clientY: null,
  8072. fill: {
  8073. colors: []
  8074. },
  8075. stroke: {
  8076. colors: []
  8077. },
  8078. dataLabels: {
  8079. style: {
  8080. colors: []
  8081. }
  8082. },
  8083. radarPolygons: {
  8084. fill: {
  8085. colors: []
  8086. }
  8087. },
  8088. markers: {
  8089. colors: [],
  8090. size: config.markers.size,
  8091. largestSize: 0
  8092. },
  8093. animationEnded: false,
  8094. isTouchDevice: 'ontouchstart' in window || navigator.msMaxTouchPoints,
  8095. isDirty: false,
  8096. // chart has been updated after the initial render. This is different than dataChanged property. isDirty means user manually called some method to update
  8097. isExecCalled: false,
  8098. // whether user updated the chart through the exec method
  8099. initialConfig: null,
  8100. // we will store the first config user has set to go back when user finishes interactions like zooming and come out of it
  8101. initialSeries: [],
  8102. lastXAxis: [],
  8103. lastYAxis: [],
  8104. columnSeries: null,
  8105. labels: [],
  8106. // store the text to draw on x axis
  8107. // Don't mutate the labels, many things including tooltips depends on it!
  8108. timescaleLabels: [],
  8109. // store the timescaleLabels Labels in another variable
  8110. noLabelsProvided: false,
  8111. // if user didn't provide any categories/labels or x values, fallback to 1,2,3,4...
  8112. allSeriesCollapsed: false,
  8113. collapsedSeries: [],
  8114. // when user collapses a series, it goes into this array
  8115. collapsedSeriesIndices: [],
  8116. // this stores the index of the collapsedSeries instead of whole object for quick access
  8117. ancillaryCollapsedSeries: [],
  8118. // when user collapses an "alwaysVisible" series, it goes into this array
  8119. ancillaryCollapsedSeriesIndices: [],
  8120. // this stores the index of the ancillaryCollapsedSeries whose y-axis is always visible
  8121. risingSeries: [],
  8122. // when user re-opens a collapsed series, it goes here
  8123. dataFormatXNumeric: false,
  8124. // boolean value to indicate user has passed numeric x values
  8125. capturedSeriesIndex: -1,
  8126. capturedDataPointIndex: -1,
  8127. selectedDataPoints: [],
  8128. goldenPadding: 35,
  8129. // this value is used at a lot of places for spacing purpose
  8130. invalidLogScale: false,
  8131. // if a user enabled log scale but the data provided is not valid to generate a log scale, turn on this flag
  8132. ignoreYAxisIndexes: [],
  8133. // when series are being collapsed in multiple y axes, ignore certain index
  8134. yAxisSameScaleIndices: [],
  8135. maxValsInArrayIndex: 0,
  8136. radialSize: 0,
  8137. selection: undefined,
  8138. zoomEnabled: config.chart.toolbar.autoSelected === 'zoom' && config.chart.toolbar.tools.zoom && config.chart.zoom.enabled,
  8139. panEnabled: config.chart.toolbar.autoSelected === 'pan' && config.chart.toolbar.tools.pan,
  8140. selectionEnabled: config.chart.toolbar.autoSelected === 'selection' && config.chart.toolbar.tools.selection,
  8141. yaxis: null,
  8142. mousedown: false,
  8143. lastClientPosition: {},
  8144. // don't reset this variable this the chart is destroyed. It is used to detect right or left mousemove in panning
  8145. visibleXRange: undefined,
  8146. yValueDecimal: 0,
  8147. // are there floating numbers in the series. If yes, this represent the len of the decimals
  8148. total: 0,
  8149. SVGNS: 'http://www.w3.org/2000/svg',
  8150. // svg namespace
  8151. svgWidth: 0,
  8152. // the whole svg width
  8153. svgHeight: 0,
  8154. // the whole svg height
  8155. noData: false,
  8156. // whether there is any data to display or not
  8157. locale: {},
  8158. // the current locale values will be preserved here for global access
  8159. dom: {},
  8160. // for storing all dom nodes in this particular property
  8161. memory: {
  8162. methodsToExec: []
  8163. },
  8164. shouldAnimate: true,
  8165. skipLastTimelinelabel: false,
  8166. // when last label is cropped, skip drawing it
  8167. skipFirstTimelinelabel: false,
  8168. // when first label is cropped, skip drawing it
  8169. delayedElements: [],
  8170. // element which appear after animation has finished
  8171. axisCharts: true,
  8172. // chart type = line or area or bar
  8173. // (refer them also as plot charts in the code)
  8174. isDataXYZ: false,
  8175. // bool: data was provided in a {[x,y,z]} pattern
  8176. resized: false,
  8177. // bool: user has resized
  8178. resizeTimer: null,
  8179. // timeout function to make a small delay before
  8180. // drawing when user resized
  8181. comboCharts: false,
  8182. // bool: whether it's a combination of line/column
  8183. dataChanged: false,
  8184. // bool: has data changed dynamically
  8185. previousPaths: [],
  8186. // array: when data is changed, it will animate from
  8187. // previous paths
  8188. allSeriesHasEqualX: true,
  8189. pointsArray: [],
  8190. // store the points positions here to draw later on hover
  8191. // format is - [[x,y],[x,y]... [x,y]]
  8192. dataLabelsRects: [],
  8193. // store the positions of datalabels to prevent collision
  8194. lastDrawnDataLabelsIndexes: [],
  8195. hasNullValues: false,
  8196. // bool: whether series contains null values
  8197. easing: null,
  8198. // function: animation effect to apply
  8199. zoomed: false,
  8200. // whether user has zoomed or not
  8201. gridWidth: 0,
  8202. // drawable width of actual graphs (series paths)
  8203. gridHeight: 0,
  8204. // drawable height of actual graphs (series paths)
  8205. rotateXLabels: false,
  8206. defaultLabels: false,
  8207. xLabelFormatter: undefined,
  8208. // formatter for x axis labels
  8209. yLabelFormatters: [],
  8210. xaxisTooltipFormatter: undefined,
  8211. // formatter for x axis tooltip
  8212. ttKeyFormatter: undefined,
  8213. ttVal: undefined,
  8214. ttZFormatter: undefined,
  8215. LINE_HEIGHT_RATIO: 1.618,
  8216. xAxisLabelsHeight: 0,
  8217. xAxisGroupLabelsHeight: 0,
  8218. xAxisLabelsWidth: 0,
  8219. yAxisLabelsWidth: 0,
  8220. scaleX: 1,
  8221. scaleY: 1,
  8222. translateX: 0,
  8223. translateY: 0,
  8224. translateYAxisX: [],
  8225. yAxisWidths: [],
  8226. translateXAxisY: 0,
  8227. translateXAxisX: 0,
  8228. tooltip: null
  8229. };
  8230. }
  8231. }, {
  8232. key: "init",
  8233. value: function init(config) {
  8234. var globals = this.globalVars(config);
  8235. this.initGlobalVars(globals);
  8236. globals.initialConfig = Utils$1.extend({}, config);
  8237. globals.initialSeries = Utils$1.clone(config.series);
  8238. globals.lastXAxis = Utils$1.clone(globals.initialConfig.xaxis);
  8239. globals.lastYAxis = Utils$1.clone(globals.initialConfig.yaxis);
  8240. return globals;
  8241. }
  8242. }]);
  8243. return Globals;
  8244. }();
  8245. /**
  8246. * ApexCharts Base Class for extending user options with pre-defined ApexCharts config.
  8247. *
  8248. * @module Base
  8249. **/
  8250. var Base = /*#__PURE__*/function () {
  8251. function Base(opts) {
  8252. _classCallCheck(this, Base);
  8253. this.opts = opts;
  8254. }
  8255. _createClass(Base, [{
  8256. key: "init",
  8257. value: function init() {
  8258. var config = new Config(this.opts).init({
  8259. responsiveOverride: false
  8260. });
  8261. var globals = new Globals().init(config);
  8262. var w = {
  8263. config: config,
  8264. globals: globals
  8265. };
  8266. return w;
  8267. }
  8268. }]);
  8269. return Base;
  8270. }();
  8271. var Data = /*#__PURE__*/function () {
  8272. function Data(ctx) {
  8273. _classCallCheck(this, Data);
  8274. this.ctx = ctx;
  8275. this.w = ctx.w;
  8276. this.twoDSeries = [];
  8277. this.threeDSeries = [];
  8278. this.twoDSeriesX = [];
  8279. this.seriesGoals = [];
  8280. this.coreUtils = new CoreUtils(this.ctx);
  8281. }
  8282. _createClass(Data, [{
  8283. key: "isMultiFormat",
  8284. value: function isMultiFormat() {
  8285. return this.isFormatXY() || this.isFormat2DArray();
  8286. } // given format is [{x, y}, {x, y}]
  8287. }, {
  8288. key: "isFormatXY",
  8289. value: function isFormatXY() {
  8290. var series = this.w.config.series.slice();
  8291. var sr = new Series(this.ctx);
  8292. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  8293. 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) {
  8294. return true;
  8295. }
  8296. } // given format is [[x, y], [x, y]]
  8297. }, {
  8298. key: "isFormat2DArray",
  8299. value: function isFormat2DArray() {
  8300. var series = this.w.config.series.slice();
  8301. var sr = new Series(this.ctx);
  8302. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  8303. 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) {
  8304. return true;
  8305. }
  8306. }
  8307. }, {
  8308. key: "handleFormat2DArray",
  8309. value: function handleFormat2DArray(ser, i) {
  8310. var cnf = this.w.config;
  8311. var gl = this.w.globals;
  8312. var isBoxPlot = cnf.chart.type === 'boxPlot' || cnf.series[i].type === 'boxPlot';
  8313. for (var j = 0; j < ser[i].data.length; j++) {
  8314. if (typeof ser[i].data[j][1] !== 'undefined') {
  8315. if (Array.isArray(ser[i].data[j][1]) && ser[i].data[j][1].length === 4 && !isBoxPlot) {
  8316. // candlestick nested ohlc format
  8317. this.twoDSeries.push(Utils$1.parseNumber(ser[i].data[j][1][3]));
  8318. } else if (ser[i].data[j].length >= 5) {
  8319. // candlestick non-nested ohlc format
  8320. this.twoDSeries.push(Utils$1.parseNumber(ser[i].data[j][4]));
  8321. } else {
  8322. this.twoDSeries.push(Utils$1.parseNumber(ser[i].data[j][1]));
  8323. }
  8324. gl.dataFormatXNumeric = true;
  8325. }
  8326. if (cnf.xaxis.type === 'datetime') {
  8327. // if timestamps are provided and xaxis type is datetime,
  8328. var ts = new Date(ser[i].data[j][0]);
  8329. ts = new Date(ts).getTime();
  8330. this.twoDSeriesX.push(ts);
  8331. } else {
  8332. this.twoDSeriesX.push(ser[i].data[j][0]);
  8333. }
  8334. }
  8335. for (var _j = 0; _j < ser[i].data.length; _j++) {
  8336. if (typeof ser[i].data[_j][2] !== 'undefined') {
  8337. this.threeDSeries.push(ser[i].data[_j][2]);
  8338. gl.isDataXYZ = true;
  8339. }
  8340. }
  8341. }
  8342. }, {
  8343. key: "handleFormatXY",
  8344. value: function handleFormatXY(ser, i) {
  8345. var cnf = this.w.config;
  8346. var gl = this.w.globals;
  8347. var dt = new DateTime(this.ctx);
  8348. var activeI = i;
  8349. if (gl.collapsedSeriesIndices.indexOf(i) > -1) {
  8350. // fix #368
  8351. activeI = this.activeSeriesIndex;
  8352. } // get series
  8353. for (var j = 0; j < ser[i].data.length; j++) {
  8354. if (typeof ser[i].data[j].y !== 'undefined') {
  8355. if (Array.isArray(ser[i].data[j].y)) {
  8356. this.twoDSeries.push(Utils$1.parseNumber(ser[i].data[j].y[ser[i].data[j].y.length - 1]));
  8357. } else {
  8358. this.twoDSeries.push(Utils$1.parseNumber(ser[i].data[j].y));
  8359. }
  8360. }
  8361. if (typeof ser[i].data[j].goals !== 'undefined' && Array.isArray(ser[i].data[j].goals)) {
  8362. if (typeof this.seriesGoals[i] === 'undefined') {
  8363. this.seriesGoals[i] = [];
  8364. }
  8365. this.seriesGoals[i].push(ser[i].data[j].goals);
  8366. } else {
  8367. if (typeof this.seriesGoals[i] === 'undefined') {
  8368. this.seriesGoals[i] = [];
  8369. }
  8370. this.seriesGoals[i].push(null);
  8371. }
  8372. } // get seriesX
  8373. for (var _j2 = 0; _j2 < ser[activeI].data.length; _j2++) {
  8374. var isXString = typeof ser[activeI].data[_j2].x === 'string';
  8375. var isXArr = Array.isArray(ser[activeI].data[_j2].x);
  8376. var isXDate = !isXArr && !!dt.isValidDate(ser[activeI].data[_j2].x.toString());
  8377. if (isXString || isXDate) {
  8378. // user supplied '01/01/2017' or a date string (a JS date object is not supported)
  8379. if (isXString || cnf.xaxis.convertedCatToNumeric) {
  8380. var isRangeColumn = gl.isBarHorizontal && gl.isRangeData;
  8381. if (cnf.xaxis.type === 'datetime' && !isRangeColumn) {
  8382. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x));
  8383. } else {
  8384. // a category and not a numeric x value
  8385. this.fallbackToCategory = true;
  8386. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  8387. }
  8388. } else {
  8389. if (cnf.xaxis.type === 'datetime') {
  8390. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x.toString()));
  8391. } else {
  8392. gl.dataFormatXNumeric = true;
  8393. gl.isXNumeric = true;
  8394. this.twoDSeriesX.push(parseFloat(ser[activeI].data[_j2].x));
  8395. }
  8396. }
  8397. } else if (isXArr) {
  8398. // a multiline label described in array format
  8399. this.fallbackToCategory = true;
  8400. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  8401. } else {
  8402. // a numeric value in x property
  8403. gl.isXNumeric = true;
  8404. gl.dataFormatXNumeric = true;
  8405. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  8406. }
  8407. }
  8408. if (ser[i].data[0] && typeof ser[i].data[0].z !== 'undefined') {
  8409. for (var t = 0; t < ser[i].data.length; t++) {
  8410. this.threeDSeries.push(ser[i].data[t].z);
  8411. }
  8412. gl.isDataXYZ = true;
  8413. }
  8414. }
  8415. }, {
  8416. key: "handleRangeData",
  8417. value: function handleRangeData(ser, i) {
  8418. var gl = this.w.globals;
  8419. var range = {};
  8420. if (this.isFormat2DArray()) {
  8421. range = this.handleRangeDataFormat('array', ser, i);
  8422. } else if (this.isFormatXY()) {
  8423. range = this.handleRangeDataFormat('xy', ser, i);
  8424. }
  8425. gl.seriesRangeStart.push(range.start);
  8426. gl.seriesRangeEnd.push(range.end);
  8427. gl.seriesRangeBar.push(range.rangeUniques); // check for overlaps to avoid clashes in a timeline chart
  8428. gl.seriesRangeBar.forEach(function (sr, si) {
  8429. if (sr) {
  8430. sr.forEach(function (sarr, sarri) {
  8431. sarr.y.forEach(function (arr, arri) {
  8432. for (var sri = 0; sri < sarr.y.length; sri++) {
  8433. if (arri !== sri) {
  8434. var range1y1 = arr.y1;
  8435. var range1y2 = arr.y2;
  8436. var range2y1 = sarr.y[sri].y1;
  8437. var range2y2 = sarr.y[sri].y2;
  8438. if (range1y1 <= range2y2 && range2y1 <= range1y2) {
  8439. if (sarr.overlaps.indexOf(arr.rangeName) < 0) {
  8440. sarr.overlaps.push(arr.rangeName);
  8441. }
  8442. if (sarr.overlaps.indexOf(sarr.y[sri].rangeName) < 0) {
  8443. sarr.overlaps.push(sarr.y[sri].rangeName);
  8444. }
  8445. }
  8446. }
  8447. }
  8448. });
  8449. });
  8450. }
  8451. });
  8452. return range;
  8453. }
  8454. }, {
  8455. key: "handleCandleStickBoxData",
  8456. value: function handleCandleStickBoxData(ser, i) {
  8457. var gl = this.w.globals;
  8458. var ohlc = {};
  8459. if (this.isFormat2DArray()) {
  8460. ohlc = this.handleCandleStickBoxDataFormat('array', ser, i);
  8461. } else if (this.isFormatXY()) {
  8462. ohlc = this.handleCandleStickBoxDataFormat('xy', ser, i);
  8463. }
  8464. gl.seriesCandleO[i] = ohlc.o;
  8465. gl.seriesCandleH[i] = ohlc.h;
  8466. gl.seriesCandleM[i] = ohlc.m;
  8467. gl.seriesCandleL[i] = ohlc.l;
  8468. gl.seriesCandleC[i] = ohlc.c;
  8469. return ohlc;
  8470. }
  8471. }, {
  8472. key: "handleRangeDataFormat",
  8473. value: function handleRangeDataFormat(format, ser, i) {
  8474. var rangeStart = [];
  8475. var rangeEnd = [];
  8476. var uniqueKeys = ser[i].data.filter(function (thing, index, self) {
  8477. return index === self.findIndex(function (t) {
  8478. return t.x === thing.x;
  8479. });
  8480. }).map(function (r, index) {
  8481. return {
  8482. x: r.x,
  8483. overlaps: [],
  8484. y: []
  8485. };
  8486. });
  8487. var err = 'Please provide [Start, End] values in valid format. Read more https://apexcharts.com/docs/series/#rangecharts';
  8488. var serObj = new Series(this.ctx);
  8489. var activeIndex = serObj.getActiveConfigSeriesIndex();
  8490. if (format === 'array') {
  8491. if (ser[activeIndex].data[0][1].length !== 2) {
  8492. throw new Error(err);
  8493. }
  8494. for (var j = 0; j < ser[i].data.length; j++) {
  8495. rangeStart.push(ser[i].data[j][1][0]);
  8496. rangeEnd.push(ser[i].data[j][1][1]);
  8497. }
  8498. } else if (format === 'xy') {
  8499. if (ser[activeIndex].data[0].y.length !== 2) {
  8500. throw new Error(err);
  8501. }
  8502. var _loop = function _loop(_j3) {
  8503. var id = Utils$1.randomId();
  8504. var x = ser[i].data[_j3].x;
  8505. var y = {
  8506. y1: ser[i].data[_j3].y[0],
  8507. y2: ser[i].data[_j3].y[1],
  8508. rangeName: id
  8509. }; // mutating config object by adding a new property
  8510. // TODO: As this is specifically for timeline rangebar charts, update the docs mentioning the series only supports xy format
  8511. ser[i].data[_j3].rangeName = id;
  8512. var uI = uniqueKeys.findIndex(function (t) {
  8513. return t.x === x;
  8514. });
  8515. uniqueKeys[uI].y.push(y);
  8516. rangeStart.push(y.y1);
  8517. rangeEnd.push(y.y2);
  8518. };
  8519. for (var _j3 = 0; _j3 < ser[i].data.length; _j3++) {
  8520. _loop(_j3);
  8521. }
  8522. }
  8523. return {
  8524. start: rangeStart,
  8525. end: rangeEnd,
  8526. rangeUniques: uniqueKeys
  8527. };
  8528. }
  8529. }, {
  8530. key: "handleCandleStickBoxDataFormat",
  8531. value: function handleCandleStickBoxDataFormat(format, ser, i) {
  8532. var w = this.w;
  8533. var isBoxPlot = w.config.chart.type === 'boxPlot' || w.config.series[i].type === 'boxPlot';
  8534. var serO = [];
  8535. var serH = [];
  8536. var serM = [];
  8537. var serL = [];
  8538. var serC = [];
  8539. if (format === 'array') {
  8540. if (isBoxPlot && ser[i].data[0].length === 6 || !isBoxPlot && ser[i].data[0].length === 5) {
  8541. for (var j = 0; j < ser[i].data.length; j++) {
  8542. serO.push(ser[i].data[j][1]);
  8543. serH.push(ser[i].data[j][2]);
  8544. if (isBoxPlot) {
  8545. serM.push(ser[i].data[j][3]);
  8546. serL.push(ser[i].data[j][4]);
  8547. serC.push(ser[i].data[j][5]);
  8548. } else {
  8549. serL.push(ser[i].data[j][3]);
  8550. serC.push(ser[i].data[j][4]);
  8551. }
  8552. }
  8553. } else {
  8554. for (var _j4 = 0; _j4 < ser[i].data.length; _j4++) {
  8555. if (Array.isArray(ser[i].data[_j4][1])) {
  8556. serO.push(ser[i].data[_j4][1][0]);
  8557. serH.push(ser[i].data[_j4][1][1]);
  8558. if (isBoxPlot) {
  8559. serM.push(ser[i].data[_j4][1][2]);
  8560. serL.push(ser[i].data[_j4][1][3]);
  8561. serC.push(ser[i].data[_j4][1][4]);
  8562. } else {
  8563. serL.push(ser[i].data[_j4][1][2]);
  8564. serC.push(ser[i].data[_j4][1][3]);
  8565. }
  8566. }
  8567. }
  8568. }
  8569. } else if (format === 'xy') {
  8570. for (var _j5 = 0; _j5 < ser[i].data.length; _j5++) {
  8571. if (Array.isArray(ser[i].data[_j5].y)) {
  8572. serO.push(ser[i].data[_j5].y[0]);
  8573. serH.push(ser[i].data[_j5].y[1]);
  8574. if (isBoxPlot) {
  8575. serM.push(ser[i].data[_j5].y[2]);
  8576. serL.push(ser[i].data[_j5].y[3]);
  8577. serC.push(ser[i].data[_j5].y[4]);
  8578. } else {
  8579. serL.push(ser[i].data[_j5].y[2]);
  8580. serC.push(ser[i].data[_j5].y[3]);
  8581. }
  8582. }
  8583. }
  8584. }
  8585. return {
  8586. o: serO,
  8587. h: serH,
  8588. m: serM,
  8589. l: serL,
  8590. c: serC
  8591. };
  8592. }
  8593. }, {
  8594. key: "parseDataAxisCharts",
  8595. value: function parseDataAxisCharts(ser) {
  8596. var _this = this;
  8597. var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.ctx;
  8598. var cnf = this.w.config;
  8599. var gl = this.w.globals;
  8600. var dt = new DateTime(ctx);
  8601. var xlabels = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice();
  8602. gl.isRangeBar = cnf.chart.type === 'rangeBar' && gl.isBarHorizontal;
  8603. gl.hasGroups = cnf.xaxis.type === 'category' && typeof cnf.xaxis.group !== 'undefined' && typeof cnf.xaxis.group.groups !== 'undefined' && cnf.xaxis.group.groups.length > 0;
  8604. if (gl.hasGroups) {
  8605. gl.groups = cnf.xaxis.group.groups;
  8606. }
  8607. var handleDates = function handleDates() {
  8608. for (var j = 0; j < xlabels.length; j++) {
  8609. if (typeof xlabels[j] === 'string') {
  8610. // user provided date strings
  8611. var isDate = dt.isValidDate(xlabels[j]);
  8612. if (isDate) {
  8613. _this.twoDSeriesX.push(dt.parseDate(xlabels[j]));
  8614. } else {
  8615. throw new Error('You have provided invalid Date format. Please provide a valid JavaScript Date');
  8616. }
  8617. } else {
  8618. // user provided timestamps
  8619. _this.twoDSeriesX.push(xlabels[j]);
  8620. }
  8621. }
  8622. };
  8623. for (var i = 0; i < ser.length; i++) {
  8624. this.twoDSeries = [];
  8625. this.twoDSeriesX = [];
  8626. this.threeDSeries = [];
  8627. if (typeof ser[i].data === 'undefined') {
  8628. console.error("It is a possibility that you may have not included 'data' property in series.");
  8629. return;
  8630. }
  8631. if (cnf.chart.type === 'rangeBar' || cnf.chart.type === 'rangeArea' || ser[i].type === 'rangeBar' || ser[i].type === 'rangeArea') {
  8632. gl.isRangeData = true;
  8633. this.handleRangeData(ser, i);
  8634. }
  8635. if (this.isMultiFormat()) {
  8636. if (this.isFormat2DArray()) {
  8637. this.handleFormat2DArray(ser, i);
  8638. } else if (this.isFormatXY()) {
  8639. this.handleFormatXY(ser, i);
  8640. }
  8641. if (cnf.chart.type === 'candlestick' || ser[i].type === 'candlestick' || cnf.chart.type === 'boxPlot' || ser[i].type === 'boxPlot') {
  8642. this.handleCandleStickBoxData(ser, i);
  8643. }
  8644. gl.series.push(this.twoDSeries);
  8645. gl.labels.push(this.twoDSeriesX);
  8646. gl.seriesX.push(this.twoDSeriesX);
  8647. gl.seriesGoals = this.seriesGoals;
  8648. if (i === this.activeSeriesIndex && !this.fallbackToCategory) {
  8649. gl.isXNumeric = true;
  8650. }
  8651. } else {
  8652. if (cnf.xaxis.type === 'datetime') {
  8653. // user didn't supplied [{x,y}] or [[x,y]], but single array in data.
  8654. // Also labels/categories were supplied differently
  8655. gl.isXNumeric = true;
  8656. handleDates();
  8657. gl.seriesX.push(this.twoDSeriesX);
  8658. } else if (cnf.xaxis.type === 'numeric') {
  8659. gl.isXNumeric = true;
  8660. if (xlabels.length > 0) {
  8661. this.twoDSeriesX = xlabels;
  8662. gl.seriesX.push(this.twoDSeriesX);
  8663. }
  8664. }
  8665. gl.labels.push(this.twoDSeriesX);
  8666. var singleArray = ser[i].data.map(function (d) {
  8667. return Utils$1.parseNumber(d);
  8668. });
  8669. gl.series.push(singleArray);
  8670. }
  8671. gl.seriesZ.push(this.threeDSeries);
  8672. if (ser[i].name !== undefined) {
  8673. gl.seriesNames.push(ser[i].name);
  8674. } else {
  8675. gl.seriesNames.push('series-' + parseInt(i + 1, 10));
  8676. } // overrided default color if user inputs color with series data
  8677. if (ser[i].color !== undefined) {
  8678. gl.seriesColors.push(ser[i].color);
  8679. } else {
  8680. gl.seriesColors.push(undefined);
  8681. }
  8682. }
  8683. return this.w;
  8684. }
  8685. }, {
  8686. key: "parseDataNonAxisCharts",
  8687. value: function parseDataNonAxisCharts(ser) {
  8688. var gl = this.w.globals;
  8689. var cnf = this.w.config;
  8690. gl.series = ser.slice();
  8691. gl.seriesNames = cnf.labels.slice();
  8692. for (var i = 0; i < gl.series.length; i++) {
  8693. if (gl.seriesNames[i] === undefined) {
  8694. gl.seriesNames.push('series-' + (i + 1));
  8695. }
  8696. }
  8697. return this.w;
  8698. }
  8699. /** User possibly set string categories in xaxis.categories or labels prop
  8700. * Or didn't set xaxis labels at all - in which case we manually do it.
  8701. * If user passed series data as [[3, 2], [4, 5]] or [{ x: 3, y: 55 }],
  8702. * this shouldn't be called
  8703. * @param {array} ser - the series which user passed to the config
  8704. */
  8705. }, {
  8706. key: "handleExternalLabelsData",
  8707. value: function handleExternalLabelsData(ser) {
  8708. var cnf = this.w.config;
  8709. var gl = this.w.globals;
  8710. if (cnf.xaxis.categories.length > 0) {
  8711. // user provided labels in xaxis.category prop
  8712. gl.labels = cnf.xaxis.categories;
  8713. } else if (cnf.labels.length > 0) {
  8714. // user provided labels in labels props
  8715. gl.labels = cnf.labels.slice();
  8716. } else if (this.fallbackToCategory) {
  8717. // 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
  8718. gl.labels = gl.labels[0];
  8719. if (gl.seriesRangeBar.length) {
  8720. gl.seriesRangeBar.map(function (srt) {
  8721. srt.forEach(function (sr) {
  8722. if (gl.labels.indexOf(sr.x) < 0 && sr.x) {
  8723. gl.labels.push(sr.x);
  8724. }
  8725. });
  8726. });
  8727. gl.labels = gl.labels.filter(function (elem, pos, arr) {
  8728. return arr.indexOf(elem) === pos;
  8729. });
  8730. }
  8731. if (cnf.xaxis.convertedCatToNumeric) {
  8732. var defaults = new Defaults(cnf);
  8733. defaults.convertCatToNumericXaxis(cnf, this.ctx, gl.seriesX[0]);
  8734. this._generateExternalLabels(ser);
  8735. }
  8736. } else {
  8737. this._generateExternalLabels(ser);
  8738. }
  8739. }
  8740. }, {
  8741. key: "_generateExternalLabels",
  8742. value: function _generateExternalLabels(ser) {
  8743. var gl = this.w.globals;
  8744. var cnf = this.w.config; // user didn't provided any labels, fallback to 1-2-3-4-5
  8745. var labelArr = [];
  8746. if (gl.axisCharts) {
  8747. if (gl.series.length > 0) {
  8748. if (this.isFormatXY()) {
  8749. // in case there is a combo chart (boxplot/scatter)
  8750. // and there are duplicated x values, we need to eliminate duplicates
  8751. var seriesDataFiltered = cnf.series.map(function (serie, s) {
  8752. return serie.data.filter(function (v, i, a) {
  8753. return a.findIndex(function (t) {
  8754. return t.x === v.x;
  8755. }) === i;
  8756. });
  8757. });
  8758. var len = seriesDataFiltered.reduce(function (p, c, i, a) {
  8759. return a[p].length > c.length ? p : i;
  8760. }, 0);
  8761. for (var i = 0; i < seriesDataFiltered[len].length; i++) {
  8762. labelArr.push(i + 1);
  8763. }
  8764. } else {
  8765. for (var _i = 0; _i < gl.series[gl.maxValsInArrayIndex].length; _i++) {
  8766. labelArr.push(_i + 1);
  8767. }
  8768. }
  8769. }
  8770. gl.seriesX = []; // create gl.seriesX as it will be used in calculations of x positions
  8771. for (var _i2 = 0; _i2 < ser.length; _i2++) {
  8772. gl.seriesX.push(labelArr);
  8773. } // turn on the isXNumeric flag to allow minX and maxX to function properly
  8774. gl.isXNumeric = true;
  8775. } // no series to pull labels from, put a 0-10 series
  8776. // possibly, user collapsed all series. Hence we can't work with above calc
  8777. if (labelArr.length === 0) {
  8778. labelArr = gl.axisCharts ? [] : gl.series.map(function (gls, glsi) {
  8779. return glsi + 1;
  8780. });
  8781. for (var _i3 = 0; _i3 < ser.length; _i3++) {
  8782. gl.seriesX.push(labelArr);
  8783. }
  8784. } // Finally, pass the labelArr in gl.labels which will be printed on x-axis
  8785. gl.labels = labelArr;
  8786. if (cnf.xaxis.convertedCatToNumeric) {
  8787. gl.categoryLabels = labelArr.map(function (l) {
  8788. return cnf.xaxis.labels.formatter(l);
  8789. });
  8790. } // Turn on this global flag to indicate no labels were provided by user
  8791. gl.noLabelsProvided = true;
  8792. } // Segregate user provided data into appropriate vars
  8793. }, {
  8794. key: "parseData",
  8795. value: function parseData(ser) {
  8796. var w = this.w;
  8797. var cnf = w.config;
  8798. var gl = w.globals;
  8799. this.excludeCollapsedSeriesInYAxis(); // If we detected string in X prop of series, we fallback to category x-axis
  8800. this.fallbackToCategory = false;
  8801. this.ctx.core.resetGlobals();
  8802. this.ctx.core.isMultipleY();
  8803. if (gl.axisCharts) {
  8804. // axisCharts includes line / area / column / scatter
  8805. this.parseDataAxisCharts(ser);
  8806. } else {
  8807. // non-axis charts are pie / donut
  8808. this.parseDataNonAxisCharts(ser);
  8809. }
  8810. this.coreUtils.getLargestSeries(); // set Null values to 0 in all series when user hides/shows some series
  8811. if (cnf.chart.type === 'bar' && cnf.chart.stacked) {
  8812. var series = new Series(this.ctx);
  8813. gl.series = series.setNullSeriesToZeroValues(gl.series);
  8814. }
  8815. this.coreUtils.getSeriesTotals();
  8816. if (gl.axisCharts) {
  8817. this.coreUtils.getStackedSeriesTotals();
  8818. }
  8819. this.coreUtils.getPercentSeries();
  8820. if (!gl.dataFormatXNumeric && (!gl.isXNumeric || cnf.xaxis.type === 'numeric' && cnf.labels.length === 0 && cnf.xaxis.categories.length === 0)) {
  8821. // x-axis labels couldn't be detected; hence try searching every option in config
  8822. this.handleExternalLabelsData(ser);
  8823. } // check for multiline xaxis
  8824. var catLabels = this.coreUtils.getCategoryLabels(gl.labels);
  8825. for (var l = 0; l < catLabels.length; l++) {
  8826. if (Array.isArray(catLabels[l])) {
  8827. gl.isMultiLineX = true;
  8828. break;
  8829. }
  8830. }
  8831. }
  8832. }, {
  8833. key: "excludeCollapsedSeriesInYAxis",
  8834. value: function excludeCollapsedSeriesInYAxis() {
  8835. var _this2 = this;
  8836. var w = this.w;
  8837. w.globals.ignoreYAxisIndexes = w.globals.collapsedSeries.map(function (collapsed, i) {
  8838. // fix issue #1215
  8839. // if stacked, not returning collapsed.index to preserve yaxis
  8840. if (_this2.w.globals.isMultipleYAxis && !w.config.chart.stacked) {
  8841. return collapsed.index;
  8842. }
  8843. });
  8844. }
  8845. }]);
  8846. return Data;
  8847. }();
  8848. /**
  8849. * ApexCharts Formatter Class for setting value formatters for axes as well as tooltips.
  8850. *
  8851. * @module Formatters
  8852. **/
  8853. var Formatters = /*#__PURE__*/function () {
  8854. function Formatters(ctx) {
  8855. _classCallCheck(this, Formatters);
  8856. this.ctx = ctx;
  8857. this.w = ctx.w;
  8858. this.tooltipKeyFormat = 'dd MMM';
  8859. }
  8860. _createClass(Formatters, [{
  8861. key: "xLabelFormat",
  8862. value: function xLabelFormat(fn, val, timestamp, opts) {
  8863. var w = this.w;
  8864. if (w.config.xaxis.type === 'datetime') {
  8865. if (w.config.xaxis.labels.formatter === undefined) {
  8866. // if user has not specified a custom formatter, use the default tooltip.x.format
  8867. if (w.config.tooltip.x.formatter === undefined) {
  8868. var datetimeObj = new DateTime(this.ctx);
  8869. return datetimeObj.formatDate(datetimeObj.getDate(val), w.config.tooltip.x.format);
  8870. }
  8871. }
  8872. }
  8873. return fn(val, timestamp, opts);
  8874. }
  8875. }, {
  8876. key: "defaultGeneralFormatter",
  8877. value: function defaultGeneralFormatter(val) {
  8878. if (Array.isArray(val)) {
  8879. return val.map(function (v) {
  8880. return v;
  8881. });
  8882. } else {
  8883. return val;
  8884. }
  8885. }
  8886. }, {
  8887. key: "defaultYFormatter",
  8888. value: function defaultYFormatter(v, yaxe, i) {
  8889. var w = this.w;
  8890. if (Utils$1.isNumber(v)) {
  8891. if (w.globals.yValueDecimal !== 0) {
  8892. v = v.toFixed(yaxe.decimalsInFloat !== undefined ? yaxe.decimalsInFloat : w.globals.yValueDecimal);
  8893. } else if (w.globals.maxYArr[i] - w.globals.minYArr[i] < 5) {
  8894. v = v.toFixed(1);
  8895. } else {
  8896. v = v.toFixed(0);
  8897. }
  8898. }
  8899. return v;
  8900. }
  8901. }, {
  8902. key: "setLabelFormatters",
  8903. value: function setLabelFormatters() {
  8904. var _this = this;
  8905. var w = this.w;
  8906. w.globals.xaxisTooltipFormatter = function (val) {
  8907. return _this.defaultGeneralFormatter(val);
  8908. };
  8909. w.globals.ttKeyFormatter = function (val) {
  8910. return _this.defaultGeneralFormatter(val);
  8911. };
  8912. w.globals.ttZFormatter = function (val) {
  8913. return val;
  8914. };
  8915. w.globals.legendFormatter = function (val) {
  8916. return _this.defaultGeneralFormatter(val);
  8917. }; // formatter function will always overwrite format property
  8918. if (w.config.xaxis.labels.formatter !== undefined) {
  8919. w.globals.xLabelFormatter = w.config.xaxis.labels.formatter;
  8920. } else {
  8921. w.globals.xLabelFormatter = function (val) {
  8922. if (Utils$1.isNumber(val)) {
  8923. if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric') {
  8924. if (Utils$1.isNumber(w.config.xaxis.decimalsInFloat)) {
  8925. return val.toFixed(w.config.xaxis.decimalsInFloat);
  8926. } else {
  8927. var diff = w.globals.maxX - w.globals.minX;
  8928. if (diff > 0 && diff < 100) {
  8929. return val.toFixed(1);
  8930. }
  8931. return val.toFixed(0);
  8932. }
  8933. }
  8934. if (w.globals.isBarHorizontal) {
  8935. var range = w.globals.maxY - w.globals.minYArr;
  8936. if (range < 4) {
  8937. return val.toFixed(1);
  8938. }
  8939. }
  8940. return val.toFixed(0);
  8941. }
  8942. return val;
  8943. };
  8944. }
  8945. if (typeof w.config.tooltip.x.formatter === 'function') {
  8946. w.globals.ttKeyFormatter = w.config.tooltip.x.formatter;
  8947. } else {
  8948. w.globals.ttKeyFormatter = w.globals.xLabelFormatter;
  8949. }
  8950. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  8951. w.globals.xaxisTooltipFormatter = w.config.xaxis.tooltip.formatter;
  8952. }
  8953. if (Array.isArray(w.config.tooltip.y)) {
  8954. w.globals.ttVal = w.config.tooltip.y;
  8955. } else {
  8956. if (w.config.tooltip.y.formatter !== undefined) {
  8957. w.globals.ttVal = w.config.tooltip.y;
  8958. }
  8959. }
  8960. if (w.config.tooltip.z.formatter !== undefined) {
  8961. w.globals.ttZFormatter = w.config.tooltip.z.formatter;
  8962. } // legend formatter - if user wants to append any global values of series to legend text
  8963. if (w.config.legend.formatter !== undefined) {
  8964. w.globals.legendFormatter = w.config.legend.formatter;
  8965. } // formatter function will always overwrite format property
  8966. w.config.yaxis.forEach(function (yaxe, i) {
  8967. if (yaxe.labels.formatter !== undefined) {
  8968. w.globals.yLabelFormatters[i] = yaxe.labels.formatter;
  8969. } else {
  8970. w.globals.yLabelFormatters[i] = function (val) {
  8971. if (!w.globals.xyCharts) return val;
  8972. if (Array.isArray(val)) {
  8973. return val.map(function (v) {
  8974. return _this.defaultYFormatter(v, yaxe, i);
  8975. });
  8976. } else {
  8977. return _this.defaultYFormatter(val, yaxe, i);
  8978. }
  8979. };
  8980. }
  8981. });
  8982. return w.globals;
  8983. }
  8984. }, {
  8985. key: "heatmapLabelFormatters",
  8986. value: function heatmapLabelFormatters() {
  8987. var w = this.w;
  8988. if (w.config.chart.type === 'heatmap') {
  8989. w.globals.yAxisScale[0].result = w.globals.seriesNames.slice(); // get the longest string from the labels array and also apply label formatter to it
  8990. var longest = w.globals.seriesNames.reduce(function (a, b) {
  8991. return a.length > b.length ? a : b;
  8992. }, 0);
  8993. w.globals.yAxisScale[0].niceMax = longest;
  8994. w.globals.yAxisScale[0].niceMin = longest;
  8995. }
  8996. }
  8997. }]);
  8998. return Formatters;
  8999. }();
  9000. var AxesUtils = /*#__PURE__*/function () {
  9001. function AxesUtils(ctx) {
  9002. _classCallCheck(this, AxesUtils);
  9003. this.ctx = ctx;
  9004. this.w = ctx.w;
  9005. } // Based on the formatter function, get the label text and position
  9006. _createClass(AxesUtils, [{
  9007. key: "getLabel",
  9008. value: function getLabel(labels, timescaleLabels, x, i) {
  9009. var drawnLabels = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
  9010. var fontSize = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '12px';
  9011. var isLeafGroup = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
  9012. var w = this.w;
  9013. var rawLabel = typeof labels[i] === 'undefined' ? '' : labels[i];
  9014. var label = rawLabel;
  9015. var xlbFormatter = w.globals.xLabelFormatter;
  9016. var customFormatter = w.config.xaxis.labels.formatter;
  9017. var isBold = false;
  9018. var xFormat = new Formatters(this.ctx);
  9019. var timestamp = rawLabel;
  9020. if (isLeafGroup) {
  9021. label = xFormat.xLabelFormat(xlbFormatter, rawLabel, timestamp, {
  9022. i: i,
  9023. dateFormatter: new DateTime(this.ctx).formatDate,
  9024. w: w
  9025. });
  9026. if (customFormatter !== undefined) {
  9027. label = customFormatter(rawLabel, labels[i], {
  9028. i: i,
  9029. dateFormatter: new DateTime(this.ctx).formatDate,
  9030. w: w
  9031. });
  9032. }
  9033. }
  9034. var determineHighestUnit = function determineHighestUnit(unit) {
  9035. var highestUnit = null;
  9036. timescaleLabels.forEach(function (t) {
  9037. if (t.unit === 'month') {
  9038. highestUnit = 'year';
  9039. } else if (t.unit === 'day') {
  9040. highestUnit = 'month';
  9041. } else if (t.unit === 'hour') {
  9042. highestUnit = 'day';
  9043. } else if (t.unit === 'minute') {
  9044. highestUnit = 'hour';
  9045. }
  9046. });
  9047. return highestUnit === unit;
  9048. };
  9049. if (timescaleLabels.length > 0) {
  9050. isBold = determineHighestUnit(timescaleLabels[i].unit);
  9051. x = timescaleLabels[i].position;
  9052. label = timescaleLabels[i].value;
  9053. } else {
  9054. if (w.config.xaxis.type === 'datetime' && customFormatter === undefined) {
  9055. label = '';
  9056. }
  9057. }
  9058. if (typeof label === 'undefined') label = '';
  9059. label = Array.isArray(label) ? label : label.toString();
  9060. var graphics = new Graphics(this.ctx);
  9061. var textRect = {};
  9062. if (w.globals.rotateXLabels && isLeafGroup) {
  9063. textRect = graphics.getTextRects(label, parseInt(fontSize, 10), null, "rotate(".concat(w.config.xaxis.labels.rotate, " 0 0)"), false);
  9064. } else {
  9065. textRect = graphics.getTextRects(label, parseInt(fontSize, 10));
  9066. }
  9067. var allowDuplicatesInTimeScale = !w.config.xaxis.labels.showDuplicates && this.ctx.timeScale;
  9068. if (!Array.isArray(label) && (label.indexOf('NaN') === 0 || label.toLowerCase().indexOf('invalid') === 0 || label.toLowerCase().indexOf('infinity') >= 0 || drawnLabels.indexOf(label) >= 0 && allowDuplicatesInTimeScale)) {
  9069. label = '';
  9070. }
  9071. return {
  9072. x: x,
  9073. text: label,
  9074. textRect: textRect,
  9075. isBold: isBold
  9076. };
  9077. }
  9078. }, {
  9079. key: "checkLabelBasedOnTickamount",
  9080. value: function checkLabelBasedOnTickamount(i, label, labelsLen) {
  9081. var w = this.w;
  9082. var ticks = w.config.xaxis.tickAmount;
  9083. if (ticks === 'dataPoints') ticks = Math.round(w.globals.gridWidth / 120);
  9084. if (ticks > labelsLen) return label;
  9085. var tickMultiple = Math.round(labelsLen / (ticks + 1));
  9086. if (i % tickMultiple === 0) {
  9087. return label;
  9088. } else {
  9089. label.text = '';
  9090. }
  9091. return label;
  9092. }
  9093. }, {
  9094. key: "checkForOverflowingLabels",
  9095. value: function checkForOverflowingLabels(i, label, labelsLen, drawnLabels, drawnLabelsRects) {
  9096. var w = this.w;
  9097. if (i === 0) {
  9098. // check if first label is being truncated
  9099. if (w.globals.skipFirstTimelinelabel) {
  9100. label.text = '';
  9101. }
  9102. }
  9103. if (i === labelsLen - 1) {
  9104. // check if last label is being truncated
  9105. if (w.globals.skipLastTimelinelabel) {
  9106. label.text = '';
  9107. }
  9108. }
  9109. if (w.config.xaxis.labels.hideOverlappingLabels && drawnLabels.length > 0) {
  9110. var prev = drawnLabelsRects[drawnLabelsRects.length - 1];
  9111. if (label.x < prev.textRect.width / (w.globals.rotateXLabels ? Math.abs(w.config.xaxis.labels.rotate) / 12 : 1.01) + prev.x) {
  9112. label.text = '';
  9113. }
  9114. }
  9115. return label;
  9116. }
  9117. }, {
  9118. key: "checkForReversedLabels",
  9119. value: function checkForReversedLabels(i, labels) {
  9120. var w = this.w;
  9121. if (w.config.yaxis[i] && w.config.yaxis[i].reversed) {
  9122. labels.reverse();
  9123. }
  9124. return labels;
  9125. }
  9126. }, {
  9127. key: "isYAxisHidden",
  9128. value: function isYAxisHidden(index) {
  9129. var w = this.w;
  9130. var coreUtils = new CoreUtils(this.ctx);
  9131. return !w.config.yaxis[index].show || !w.config.yaxis[index].showForNullSeries && coreUtils.isSeriesNull(index) && w.globals.collapsedSeriesIndices.indexOf(index) === -1;
  9132. } // get the label color for y-axis
  9133. // realIndex is the actual series index, while i is the tick Index
  9134. }, {
  9135. key: "getYAxisForeColor",
  9136. value: function getYAxisForeColor(yColors, realIndex) {
  9137. var w = this.w;
  9138. if (Array.isArray(yColors) && w.globals.yAxisScale[realIndex]) {
  9139. this.ctx.theme.pushExtraColors(yColors, w.globals.yAxisScale[realIndex].result.length, false);
  9140. }
  9141. return yColors;
  9142. }
  9143. }, {
  9144. key: "drawYAxisTicks",
  9145. value: function drawYAxisTicks(x, tickAmount, axisBorder, axisTicks, realIndex, labelsDivider, elYaxis) {
  9146. var w = this.w;
  9147. var graphics = new Graphics(this.ctx); // initial label position = 0;
  9148. var t = w.globals.translateY;
  9149. if (axisTicks.show && tickAmount > 0) {
  9150. if (w.config.yaxis[realIndex].opposite === true) x = x + axisTicks.width;
  9151. for (var i = tickAmount; i >= 0; i--) {
  9152. var tY = t + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY - 1;
  9153. if (w.globals.isBarHorizontal) {
  9154. tY = labelsDivider * i;
  9155. }
  9156. if (w.config.chart.type === 'heatmap') {
  9157. tY = tY + labelsDivider / 2;
  9158. }
  9159. var elTick = graphics.drawLine(x + axisBorder.offsetX - axisTicks.width + axisTicks.offsetX, tY + axisTicks.offsetY, x + axisBorder.offsetX + axisTicks.offsetX, tY + axisTicks.offsetY, axisTicks.color);
  9160. elYaxis.add(elTick);
  9161. t = t + labelsDivider;
  9162. }
  9163. }
  9164. }
  9165. }]);
  9166. return AxesUtils;
  9167. }();
  9168. var Exports = /*#__PURE__*/function () {
  9169. function Exports(ctx) {
  9170. _classCallCheck(this, Exports);
  9171. this.ctx = ctx;
  9172. this.w = ctx.w;
  9173. }
  9174. _createClass(Exports, [{
  9175. key: "scaleSvgNode",
  9176. value: function scaleSvgNode(svg, scale) {
  9177. // get current both width and height of the svg
  9178. var svgWidth = parseFloat(svg.getAttributeNS(null, 'width'));
  9179. var svgHeight = parseFloat(svg.getAttributeNS(null, 'height')); // set new width and height based on the scale
  9180. svg.setAttributeNS(null, 'width', svgWidth * scale);
  9181. svg.setAttributeNS(null, 'height', svgHeight * scale);
  9182. svg.setAttributeNS(null, 'viewBox', '0 0 ' + svgWidth + ' ' + svgHeight);
  9183. }
  9184. }, {
  9185. key: "fixSvgStringForIe11",
  9186. value: function fixSvgStringForIe11(svgData) {
  9187. // IE11 generates broken SVG that we have to fix by using regex
  9188. if (!Utils$1.isIE11()) {
  9189. // not IE11 - noop
  9190. return svgData.replace(/&nbsp;/g, '&#160;');
  9191. } // replace second occurrence of "xmlns" attribute with "xmlns:xlink" with correct url + add xmlns:svgjs
  9192. var nXmlnsSeen = 0;
  9193. var result = svgData.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g, function (match) {
  9194. nXmlnsSeen++;
  9195. return nXmlnsSeen === 2 ? 'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev"' : match;
  9196. }); // remove the invalid empty namespace declarations
  9197. result = result.replace(/xmlns:NS\d+=""/g, ''); // remove these broken namespaces from attributes
  9198. result = result.replace(/NS\d+:(\w+:\w+=")/g, '$1');
  9199. return result;
  9200. }
  9201. }, {
  9202. key: "getSvgString",
  9203. value: function getSvgString(scale) {
  9204. var svgString = this.w.globals.dom.Paper.svg(); // in case the scale is different than 1, the svg needs to be rescaled
  9205. if (scale !== 1) {
  9206. // clone the svg node so it remains intact in the UI
  9207. var svgNode = this.w.globals.dom.Paper.node.cloneNode(true); // scale the image
  9208. this.scaleSvgNode(svgNode, scale); // get the string representation of the svgNode
  9209. svgString = new XMLSerializer().serializeToString(svgNode);
  9210. }
  9211. return this.fixSvgStringForIe11(svgString);
  9212. }
  9213. }, {
  9214. key: "cleanup",
  9215. value: function cleanup() {
  9216. var w = this.w; // hide some elements to avoid printing them on exported svg
  9217. var xcrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-xcrosshairs');
  9218. var ycrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-ycrosshairs');
  9219. var zoomSelectionRects = w.globals.dom.baseEl.querySelectorAll('.apexcharts-zoom-rect, .apexcharts-selection-rect');
  9220. Array.prototype.forEach.call(zoomSelectionRects, function (z) {
  9221. z.setAttribute('width', 0);
  9222. });
  9223. if (xcrosshairs && xcrosshairs[0]) {
  9224. xcrosshairs[0].setAttribute('x', -500);
  9225. xcrosshairs[0].setAttribute('x1', -500);
  9226. xcrosshairs[0].setAttribute('x2', -500);
  9227. }
  9228. if (ycrosshairs && ycrosshairs[0]) {
  9229. ycrosshairs[0].setAttribute('y', -100);
  9230. ycrosshairs[0].setAttribute('y1', -100);
  9231. ycrosshairs[0].setAttribute('y2', -100);
  9232. }
  9233. }
  9234. }, {
  9235. key: "svgUrl",
  9236. value: function svgUrl() {
  9237. this.cleanup();
  9238. var svgData = this.getSvgString();
  9239. var svgBlob = new Blob([svgData], {
  9240. type: 'image/svg+xml;charset=utf-8'
  9241. });
  9242. return URL.createObjectURL(svgBlob);
  9243. }
  9244. }, {
  9245. key: "dataURI",
  9246. value: function dataURI(options) {
  9247. var _this = this;
  9248. return new Promise(function (resolve) {
  9249. var w = _this.w;
  9250. var scale = options ? options.scale || options.width / w.globals.svgWidth : 1;
  9251. _this.cleanup();
  9252. var canvas = document.createElement('canvas');
  9253. canvas.width = w.globals.svgWidth * scale;
  9254. canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10) * scale; // because of resizeNonAxisCharts
  9255. var canvasBg = w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background;
  9256. var ctx = canvas.getContext('2d');
  9257. ctx.fillStyle = canvasBg;
  9258. ctx.fillRect(0, 0, canvas.width * scale, canvas.height * scale);
  9259. var svgData = _this.getSvgString(scale);
  9260. if (window.canvg && Utils$1.isIE11()) {
  9261. // use canvg as a polyfill to workaround ie11 considering a canvas with loaded svg 'unsafe'
  9262. // without ignoreClear we lose our background color; without ignoreDimensions some grid lines become invisible
  9263. var v = window.canvg.Canvg.fromString(ctx, svgData, {
  9264. ignoreClear: true,
  9265. ignoreDimensions: true
  9266. }); // render the svg to canvas
  9267. v.start();
  9268. var blob = canvas.msToBlob(); // dispose - missing this will cause a memory leak
  9269. v.stop();
  9270. resolve({
  9271. blob: blob
  9272. });
  9273. } else {
  9274. var svgUrl = 'data:image/svg+xml,' + encodeURIComponent(svgData);
  9275. var img = new Image();
  9276. img.crossOrigin = 'anonymous';
  9277. img.onload = function () {
  9278. ctx.drawImage(img, 0, 0);
  9279. if (canvas.msToBlob) {
  9280. // IE and Edge can't navigate to data urls, so we return the blob instead
  9281. var _blob = canvas.msToBlob();
  9282. resolve({
  9283. blob: _blob
  9284. });
  9285. } else {
  9286. var imgURI = canvas.toDataURL('image/png');
  9287. resolve({
  9288. imgURI: imgURI
  9289. });
  9290. }
  9291. };
  9292. img.src = svgUrl;
  9293. }
  9294. });
  9295. }
  9296. }, {
  9297. key: "exportToSVG",
  9298. value: function exportToSVG() {
  9299. this.triggerDownload(this.svgUrl(), this.w.config.chart.toolbar.export.svg.filename, '.svg');
  9300. }
  9301. }, {
  9302. key: "exportToPng",
  9303. value: function exportToPng() {
  9304. var _this2 = this;
  9305. this.dataURI().then(function (_ref) {
  9306. var imgURI = _ref.imgURI,
  9307. blob = _ref.blob;
  9308. if (blob) {
  9309. navigator.msSaveOrOpenBlob(blob, _this2.w.globals.chartID + '.png');
  9310. } else {
  9311. _this2.triggerDownload(imgURI, _this2.w.config.chart.toolbar.export.png.filename, '.png');
  9312. }
  9313. });
  9314. }
  9315. }, {
  9316. key: "exportToCSV",
  9317. value: function exportToCSV(_ref2) {
  9318. var _this3 = this;
  9319. var series = _ref2.series,
  9320. columnDelimiter = _ref2.columnDelimiter,
  9321. _ref2$lineDelimiter = _ref2.lineDelimiter,
  9322. lineDelimiter = _ref2$lineDelimiter === void 0 ? '\n' : _ref2$lineDelimiter;
  9323. var w = this.w;
  9324. var columns = [];
  9325. var rows = [];
  9326. var result = '';
  9327. var universalBOM = "\uFEFF";
  9328. var isTimeStamp = function isTimeStamp(num) {
  9329. return w.config.xaxis.type === 'datetime' && String(num).length >= 10;
  9330. };
  9331. var dataFormat = new Data(this.ctx);
  9332. var axesUtils = new AxesUtils(this.ctx);
  9333. var getCat = function getCat(i) {
  9334. var cat = ''; // pie / donut/ radial
  9335. if (!w.globals.axisCharts) {
  9336. cat = w.config.labels[i];
  9337. } else {
  9338. // xy charts
  9339. // non datetime
  9340. if (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) {
  9341. if (w.globals.isBarHorizontal) {
  9342. var lbFormatter = w.globals.yLabelFormatters[0];
  9343. var sr = new Series(_this3.ctx);
  9344. var activeSeries = sr.getActiveConfigSeriesIndex();
  9345. cat = lbFormatter(w.globals.labels[i], {
  9346. seriesIndex: activeSeries,
  9347. dataPointIndex: i,
  9348. w: w
  9349. });
  9350. } else {
  9351. cat = axesUtils.getLabel(w.globals.labels, w.globals.timescaleLabels, 0, i).text;
  9352. }
  9353. } // datetime, but labels specified in categories or labels
  9354. if (w.config.xaxis.type === 'datetime') {
  9355. if (w.config.xaxis.categories.length) {
  9356. cat = w.config.xaxis.categories[i];
  9357. } else if (w.config.labels.length) {
  9358. cat = w.config.labels[i];
  9359. }
  9360. }
  9361. }
  9362. if (Array.isArray(cat)) {
  9363. cat = cat.join(' ');
  9364. }
  9365. return Utils$1.isNumber(cat) ? cat : cat.split(columnDelimiter).join('');
  9366. };
  9367. var handleAxisRowsColumns = function handleAxisRowsColumns(s, sI) {
  9368. if (columns.length && sI === 0) {
  9369. rows.push(columns.join(columnDelimiter));
  9370. }
  9371. if (s.data && s.data.length) {
  9372. for (var i = 0; i < s.data.length; i++) {
  9373. columns = [];
  9374. var cat = getCat(i);
  9375. if (!cat) {
  9376. if (dataFormat.isFormatXY()) {
  9377. cat = series[sI].data[i].x;
  9378. } else if (dataFormat.isFormat2DArray()) {
  9379. cat = series[sI].data[i] ? series[sI].data[i][0] : '';
  9380. }
  9381. }
  9382. if (sI === 0) {
  9383. columns.push(isTimeStamp(cat) ? w.config.chart.toolbar.export.csv.dateFormatter(cat) : Utils$1.isNumber(cat) ? cat : cat.split(columnDelimiter).join(''));
  9384. for (var ci = 0; ci < w.globals.series.length; ci++) {
  9385. columns.push(w.globals.series[ci][i]);
  9386. }
  9387. }
  9388. if (w.config.chart.type === 'candlestick' || s.type && s.type === 'candlestick') {
  9389. columns.pop();
  9390. columns.push(w.globals.seriesCandleO[sI][i]);
  9391. columns.push(w.globals.seriesCandleH[sI][i]);
  9392. columns.push(w.globals.seriesCandleL[sI][i]);
  9393. columns.push(w.globals.seriesCandleC[sI][i]);
  9394. }
  9395. if (w.config.chart.type === 'boxPlot' || s.type && s.type === 'boxPlot') {
  9396. columns.pop();
  9397. columns.push(w.globals.seriesCandleO[sI][i]);
  9398. columns.push(w.globals.seriesCandleH[sI][i]);
  9399. columns.push(w.globals.seriesCandleM[sI][i]);
  9400. columns.push(w.globals.seriesCandleL[sI][i]);
  9401. columns.push(w.globals.seriesCandleC[sI][i]);
  9402. }
  9403. if (w.config.chart.type === 'rangeBar') {
  9404. columns.pop();
  9405. columns.push(w.globals.seriesRangeStart[sI][i]);
  9406. columns.push(w.globals.seriesRangeEnd[sI][i]);
  9407. }
  9408. if (columns.length) {
  9409. rows.push(columns.join(columnDelimiter));
  9410. }
  9411. }
  9412. }
  9413. };
  9414. columns.push(w.config.chart.toolbar.export.csv.headerCategory);
  9415. series.map(function (s, sI) {
  9416. var sname = s.name ? s.name : "series-".concat(sI);
  9417. if (w.globals.axisCharts) {
  9418. columns.push(sname.split(columnDelimiter).join('') ? sname.split(columnDelimiter).join('') : "series-".concat(sI));
  9419. }
  9420. });
  9421. if (!w.globals.axisCharts) {
  9422. columns.push(w.config.chart.toolbar.export.csv.headerValue);
  9423. rows.push(columns.join(columnDelimiter));
  9424. }
  9425. series.map(function (s, sI) {
  9426. if (w.globals.axisCharts) {
  9427. handleAxisRowsColumns(s, sI);
  9428. } else {
  9429. columns = [];
  9430. columns.push(w.globals.labels[sI].split(columnDelimiter).join(''));
  9431. columns.push(w.globals.series[sI]);
  9432. rows.push(columns.join(columnDelimiter));
  9433. }
  9434. });
  9435. result += rows.join(lineDelimiter);
  9436. this.triggerDownload('data:text/csv; charset=utf-8,' + encodeURIComponent(universalBOM + result), w.config.chart.toolbar.export.csv.filename, '.csv');
  9437. }
  9438. }, {
  9439. key: "triggerDownload",
  9440. value: function triggerDownload(href, filename, ext) {
  9441. var downloadLink = document.createElement('a');
  9442. downloadLink.href = href;
  9443. downloadLink.download = (filename ? filename : this.w.globals.chartID) + ext;
  9444. document.body.appendChild(downloadLink);
  9445. downloadLink.click();
  9446. document.body.removeChild(downloadLink);
  9447. }
  9448. }]);
  9449. return Exports;
  9450. }();
  9451. /**
  9452. * ApexCharts XAxis Class for drawing X-Axis.
  9453. *
  9454. * @module XAxis
  9455. **/
  9456. var XAxis = /*#__PURE__*/function () {
  9457. function XAxis(ctx) {
  9458. _classCallCheck(this, XAxis);
  9459. this.ctx = ctx;
  9460. this.w = ctx.w;
  9461. var w = this.w;
  9462. this.axesUtils = new AxesUtils(ctx);
  9463. this.xaxisLabels = w.globals.labels.slice();
  9464. if (w.globals.timescaleLabels.length > 0 && !w.globals.isBarHorizontal) {
  9465. // timeline labels are there and chart is not rangeabr timeline
  9466. this.xaxisLabels = w.globals.timescaleLabels.slice();
  9467. }
  9468. if (w.config.xaxis.overwriteCategories) {
  9469. this.xaxisLabels = w.config.xaxis.overwriteCategories;
  9470. }
  9471. this.drawnLabels = [];
  9472. this.drawnLabelsRects = [];
  9473. if (w.config.xaxis.position === 'top') {
  9474. this.offY = 0;
  9475. } else {
  9476. this.offY = w.globals.gridHeight + 1;
  9477. }
  9478. this.offY = this.offY + w.config.xaxis.axisBorder.offsetY;
  9479. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  9480. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  9481. this.xaxisFontFamily = w.config.xaxis.labels.style.fontFamily;
  9482. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  9483. this.xaxisBorderWidth = w.config.xaxis.axisBorder.width;
  9484. if (this.isCategoryBarHorizontal) {
  9485. this.xaxisBorderWidth = w.config.yaxis[0].axisBorder.width.toString();
  9486. }
  9487. if (this.xaxisBorderWidth.indexOf('%') > -1) {
  9488. this.xaxisBorderWidth = w.globals.gridWidth * parseInt(this.xaxisBorderWidth, 10) / 100;
  9489. } else {
  9490. this.xaxisBorderWidth = parseInt(this.xaxisBorderWidth, 10);
  9491. }
  9492. this.xaxisBorderHeight = w.config.xaxis.axisBorder.height; // For bars, we will only consider single y xais,
  9493. // as we are not providing multiple yaxis for bar charts
  9494. this.yaxis = w.config.yaxis[0];
  9495. }
  9496. _createClass(XAxis, [{
  9497. key: "drawXaxis",
  9498. value: function drawXaxis() {
  9499. var w = this.w;
  9500. var graphics = new Graphics(this.ctx);
  9501. var elXaxis = graphics.group({
  9502. class: 'apexcharts-xaxis',
  9503. transform: "translate(".concat(w.config.xaxis.offsetX, ", ").concat(w.config.xaxis.offsetY, ")")
  9504. });
  9505. var elXaxisTexts = graphics.group({
  9506. class: 'apexcharts-xaxis-texts-g',
  9507. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  9508. });
  9509. elXaxis.add(elXaxisTexts);
  9510. var labels = [];
  9511. for (var i = 0; i < this.xaxisLabels.length; i++) {
  9512. labels.push(this.xaxisLabels[i]);
  9513. }
  9514. this.drawXAxisLabelAndGroup(true, graphics, elXaxisTexts, labels, w.globals.isXNumeric, function (i, colWidth) {
  9515. return colWidth;
  9516. });
  9517. if (w.globals.hasGroups) {
  9518. var labelsGroup = w.globals.groups;
  9519. labels = [];
  9520. for (var _i = 0; _i < labelsGroup.length; _i++) {
  9521. labels.push(labelsGroup[_i].title);
  9522. }
  9523. var overwriteStyles = {};
  9524. if (w.config.xaxis.group.style) {
  9525. overwriteStyles.xaxisFontSize = w.config.xaxis.group.style.fontSize;
  9526. overwriteStyles.xaxisFontFamily = w.config.xaxis.group.style.fontFamily;
  9527. overwriteStyles.xaxisForeColors = w.config.xaxis.group.style.colors;
  9528. overwriteStyles.fontWeight = w.config.xaxis.group.style.fontWeight;
  9529. overwriteStyles.cssClass = w.config.xaxis.group.style.cssClass;
  9530. }
  9531. this.drawXAxisLabelAndGroup(false, graphics, elXaxisTexts, labels, false, function (i, colWidth) {
  9532. return labelsGroup[i].cols * colWidth;
  9533. }, overwriteStyles);
  9534. }
  9535. if (w.config.xaxis.title.text !== undefined) {
  9536. var elXaxisTitle = graphics.group({
  9537. class: 'apexcharts-xaxis-title'
  9538. });
  9539. var elXAxisTitleText = graphics.drawText({
  9540. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  9541. y: this.offY + parseFloat(this.xaxisFontSize) + w.globals.xAxisLabelsHeight + w.config.xaxis.title.offsetY,
  9542. text: w.config.xaxis.title.text,
  9543. textAnchor: 'middle',
  9544. fontSize: w.config.xaxis.title.style.fontSize,
  9545. fontFamily: w.config.xaxis.title.style.fontFamily,
  9546. fontWeight: w.config.xaxis.title.style.fontWeight,
  9547. foreColor: w.config.xaxis.title.style.color,
  9548. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  9549. });
  9550. elXaxisTitle.add(elXAxisTitleText);
  9551. elXaxis.add(elXaxisTitle);
  9552. }
  9553. if (w.config.xaxis.axisBorder.show) {
  9554. var offX = w.globals.barPadForNumericAxis;
  9555. var elHorzLine = graphics.drawLine(w.globals.padHorizontal + w.config.xaxis.axisBorder.offsetX - offX, this.offY, this.xaxisBorderWidth + offX, this.offY, w.config.xaxis.axisBorder.color, 0, this.xaxisBorderHeight);
  9556. elXaxis.add(elHorzLine);
  9557. }
  9558. return elXaxis;
  9559. }
  9560. }, {
  9561. key: "drawXAxisLabelAndGroup",
  9562. value: function drawXAxisLabelAndGroup(isLeafGroup, graphics, elXaxisTexts, labels, isXNumeric, colWidthCb) {
  9563. var _this = this;
  9564. var overwriteStyles = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
  9565. var drawnLabels = [];
  9566. var drawnLabelsRects = [];
  9567. var w = this.w;
  9568. var xaxisFontSize = overwriteStyles.xaxisFontSize || this.xaxisFontSize;
  9569. var xaxisFontFamily = overwriteStyles.xaxisFontFamily || this.xaxisFontFamily;
  9570. var xaxisForeColors = overwriteStyles.xaxisForeColors || this.xaxisForeColors;
  9571. var fontWeight = overwriteStyles.fontWeight || w.config.xaxis.labels.style.fontWeight;
  9572. var cssClass = overwriteStyles.cssClass || w.config.xaxis.labels.style.cssClass;
  9573. var colWidth; // initial x Position (keep adding column width in the loop)
  9574. var xPos = w.globals.padHorizontal;
  9575. var labelsLen = labels.length;
  9576. /**
  9577. * labelsLen can be different (whether you are drawing x-axis labels or x-axis group labels)
  9578. * hence, we introduce dataPoints to be consistent.
  9579. * Also, in datetime/numeric xaxis, dataPoints can be misleading, so we resort to labelsLen for such xaxis type
  9580. */
  9581. var dataPoints = w.config.xaxis.type === 'category' ? w.globals.dataPoints : labelsLen;
  9582. if (isXNumeric) {
  9583. var len = dataPoints > 1 ? dataPoints - 1 : dataPoints;
  9584. colWidth = w.globals.gridWidth / len;
  9585. xPos = xPos + colWidthCb(0, colWidth) / 2 + w.config.xaxis.labels.offsetX;
  9586. } else {
  9587. colWidth = w.globals.gridWidth / dataPoints;
  9588. xPos = xPos + colWidthCb(0, colWidth) + w.config.xaxis.labels.offsetX;
  9589. }
  9590. var _loop = function _loop(i) {
  9591. var x = xPos - colWidthCb(i, colWidth) / 2 + w.config.xaxis.labels.offsetX;
  9592. if (i === 0 && labelsLen === 1 && colWidth / 2 === xPos && dataPoints === 1) {
  9593. // single datapoint
  9594. x = w.globals.gridWidth / 2;
  9595. }
  9596. var label = _this.axesUtils.getLabel(labels, w.globals.timescaleLabels, x, i, drawnLabels, xaxisFontSize, isLeafGroup);
  9597. var offsetYCorrection = 28;
  9598. if (w.globals.rotateXLabels && isLeafGroup) {
  9599. offsetYCorrection = 22;
  9600. }
  9601. if (!isLeafGroup) {
  9602. offsetYCorrection = offsetYCorrection + parseFloat(xaxisFontSize) + (w.globals.xAxisLabelsHeight - w.globals.xAxisGroupLabelsHeight) + (w.globals.rotateXLabels ? 10 : 0);
  9603. }
  9604. var isCategoryTickAmounts = typeof w.config.xaxis.tickAmount !== 'undefined' && w.config.xaxis.tickAmount !== 'dataPoints' && w.config.xaxis.type !== 'datetime';
  9605. if (isCategoryTickAmounts) {
  9606. label = _this.axesUtils.checkLabelBasedOnTickamount(i, label, labelsLen);
  9607. } else {
  9608. label = _this.axesUtils.checkForOverflowingLabels(i, label, labelsLen, drawnLabels, drawnLabelsRects);
  9609. }
  9610. var getCatForeColor = function getCatForeColor() {
  9611. return isLeafGroup && w.config.xaxis.convertedCatToNumeric ? xaxisForeColors[w.globals.minX + i - 1] : xaxisForeColors[i];
  9612. };
  9613. if (isLeafGroup && label.text) {
  9614. w.globals.xaxisLabelsCount++;
  9615. }
  9616. if (w.config.xaxis.labels.show) {
  9617. var elText = graphics.drawText({
  9618. x: label.x,
  9619. y: _this.offY + w.config.xaxis.labels.offsetY + offsetYCorrection - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  9620. text: label.text,
  9621. textAnchor: 'middle',
  9622. fontWeight: label.isBold ? 600 : fontWeight,
  9623. fontSize: xaxisFontSize,
  9624. fontFamily: xaxisFontFamily,
  9625. foreColor: Array.isArray(xaxisForeColors) ? getCatForeColor() : xaxisForeColors,
  9626. isPlainText: false,
  9627. cssClass: (isLeafGroup ? 'apexcharts-xaxis-label ' : 'apexcharts-xaxis-group-label ') + cssClass
  9628. });
  9629. elXaxisTexts.add(elText);
  9630. if (isLeafGroup) {
  9631. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  9632. elTooltipTitle.textContent = Array.isArray(label.text) ? label.text.join(' ') : label.text;
  9633. elText.node.appendChild(elTooltipTitle);
  9634. if (label.text !== '') {
  9635. drawnLabels.push(label.text);
  9636. drawnLabelsRects.push(label);
  9637. }
  9638. }
  9639. }
  9640. if (i < labelsLen - 1) {
  9641. xPos = xPos + colWidthCb(i + 1, colWidth);
  9642. }
  9643. };
  9644. for (var i = 0; i <= labelsLen - 1; i++) {
  9645. _loop(i);
  9646. }
  9647. } // this actually becomes the vertical axis (for bar charts)
  9648. }, {
  9649. key: "drawXaxisInversed",
  9650. value: function drawXaxisInversed(realIndex) {
  9651. var _this2 = this;
  9652. var w = this.w;
  9653. var graphics = new Graphics(this.ctx);
  9654. var translateYAxisX = w.config.yaxis[0].opposite ? w.globals.translateYAxisX[realIndex] : 0;
  9655. var elYaxis = graphics.group({
  9656. class: 'apexcharts-yaxis apexcharts-xaxis-inversed',
  9657. rel: realIndex
  9658. });
  9659. var elYaxisTexts = graphics.group({
  9660. class: 'apexcharts-yaxis-texts-g apexcharts-xaxis-inversed-texts-g',
  9661. transform: 'translate(' + translateYAxisX + ', 0)'
  9662. });
  9663. elYaxis.add(elYaxisTexts);
  9664. var colHeight; // initial x Position (keep adding column width in the loop)
  9665. var yPos;
  9666. var labels = [];
  9667. if (w.config.yaxis[realIndex].show) {
  9668. for (var i = 0; i < this.xaxisLabels.length; i++) {
  9669. labels.push(this.xaxisLabels[i]);
  9670. }
  9671. }
  9672. colHeight = w.globals.gridHeight / labels.length;
  9673. yPos = -(colHeight / 2.2);
  9674. var lbFormatter = w.globals.yLabelFormatters[0];
  9675. var ylabels = w.config.yaxis[0].labels;
  9676. if (ylabels.show) {
  9677. var _loop2 = function _loop2(_i2) {
  9678. var label = typeof labels[_i2] === 'undefined' ? '' : labels[_i2];
  9679. label = lbFormatter(label, {
  9680. seriesIndex: realIndex,
  9681. dataPointIndex: _i2,
  9682. w: w
  9683. });
  9684. var yColors = _this2.axesUtils.getYAxisForeColor(ylabels.style.colors, realIndex);
  9685. var getForeColor = function getForeColor() {
  9686. return Array.isArray(yColors) ? yColors[_i2] : yColors;
  9687. };
  9688. var multiY = 0;
  9689. if (Array.isArray(label)) {
  9690. multiY = label.length / 2 * parseInt(ylabels.style.fontSize, 10);
  9691. }
  9692. var elLabel = graphics.drawText({
  9693. x: ylabels.offsetX - 15,
  9694. y: yPos + colHeight + ylabels.offsetY - multiY,
  9695. text: label,
  9696. textAnchor: _this2.yaxis.opposite ? 'start' : 'end',
  9697. foreColor: getForeColor(),
  9698. fontSize: ylabels.style.fontSize,
  9699. fontFamily: ylabels.style.fontFamily,
  9700. fontWeight: ylabels.style.fontWeight,
  9701. isPlainText: false,
  9702. cssClass: 'apexcharts-yaxis-label ' + ylabels.style.cssClass
  9703. });
  9704. elYaxisTexts.add(elLabel);
  9705. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  9706. elTooltipTitle.textContent = Array.isArray(label) ? label.join(' ') : label;
  9707. elLabel.node.appendChild(elTooltipTitle);
  9708. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  9709. var labelRotatingCenter = graphics.rotateAroundCenter(elLabel.node);
  9710. elLabel.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " 0 ").concat(labelRotatingCenter.y, ")"));
  9711. }
  9712. yPos = yPos + colHeight;
  9713. };
  9714. for (var _i2 = 0; _i2 <= labels.length - 1; _i2++) {
  9715. _loop2(_i2);
  9716. }
  9717. }
  9718. if (w.config.yaxis[0].title.text !== undefined) {
  9719. var elXaxisTitle = graphics.group({
  9720. class: 'apexcharts-yaxis-title apexcharts-xaxis-title-inversed',
  9721. transform: 'translate(' + translateYAxisX + ', 0)'
  9722. });
  9723. var elXAxisTitleText = graphics.drawText({
  9724. x: 0,
  9725. y: w.globals.gridHeight / 2,
  9726. text: w.config.yaxis[0].title.text,
  9727. textAnchor: 'middle',
  9728. foreColor: w.config.yaxis[0].title.style.color,
  9729. fontSize: w.config.yaxis[0].title.style.fontSize,
  9730. fontWeight: w.config.yaxis[0].title.style.fontWeight,
  9731. fontFamily: w.config.yaxis[0].title.style.fontFamily,
  9732. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[0].title.style.cssClass
  9733. });
  9734. elXaxisTitle.add(elXAxisTitleText);
  9735. elYaxis.add(elXaxisTitle);
  9736. }
  9737. var offX = 0;
  9738. if (this.isCategoryBarHorizontal && w.config.yaxis[0].opposite) {
  9739. offX = w.globals.gridWidth;
  9740. }
  9741. var axisBorder = w.config.xaxis.axisBorder;
  9742. if (axisBorder.show) {
  9743. 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);
  9744. elYaxis.add(elVerticalLine);
  9745. }
  9746. if (w.config.yaxis[0].axisTicks.show) {
  9747. this.axesUtils.drawYAxisTicks(offX, labels.length, w.config.yaxis[0].axisBorder, w.config.yaxis[0].axisTicks, 0, colHeight, elYaxis);
  9748. }
  9749. return elYaxis;
  9750. }
  9751. }, {
  9752. key: "drawXaxisTicks",
  9753. value: function drawXaxisTicks(x1, y2, appendToElement) {
  9754. var w = this.w;
  9755. var x2 = x1;
  9756. if (x1 < 0 || x1 - 2 > w.globals.gridWidth) return;
  9757. var y1 = this.offY + w.config.xaxis.axisTicks.offsetY;
  9758. y2 = y2 + y1 + w.config.xaxis.axisTicks.height;
  9759. if (w.config.xaxis.position === 'top') {
  9760. y2 = y1 - w.config.xaxis.axisTicks.height;
  9761. }
  9762. if (w.config.xaxis.axisTicks.show) {
  9763. var graphics = new Graphics(this.ctx);
  9764. 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 passed in param
  9765. appendToElement.add(line);
  9766. line.node.classList.add('apexcharts-xaxis-tick');
  9767. }
  9768. }
  9769. }, {
  9770. key: "getXAxisTicksPositions",
  9771. value: function getXAxisTicksPositions() {
  9772. var w = this.w;
  9773. var xAxisTicksPositions = [];
  9774. var xCount = this.xaxisLabels.length;
  9775. var x1 = w.globals.padHorizontal;
  9776. if (w.globals.timescaleLabels.length > 0) {
  9777. for (var i = 0; i < xCount; i++) {
  9778. x1 = this.xaxisLabels[i].position;
  9779. xAxisTicksPositions.push(x1);
  9780. }
  9781. } else {
  9782. var xCountForCategoryCharts = xCount;
  9783. for (var _i3 = 0; _i3 < xCountForCategoryCharts; _i3++) {
  9784. var x1Count = xCountForCategoryCharts;
  9785. if (w.globals.isXNumeric && w.config.chart.type !== 'bar') {
  9786. x1Count -= 1;
  9787. }
  9788. x1 = x1 + w.globals.gridWidth / x1Count;
  9789. xAxisTicksPositions.push(x1);
  9790. }
  9791. }
  9792. return xAxisTicksPositions;
  9793. } // to rotate x-axis labels or to put ... for longer text in xaxis
  9794. }, {
  9795. key: "xAxisLabelCorrections",
  9796. value: function xAxisLabelCorrections() {
  9797. var w = this.w;
  9798. var graphics = new Graphics(this.ctx);
  9799. var xAxis = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g');
  9800. var xAxisTexts = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-texts-g text:not(.apexcharts-xaxis-group-label)');
  9801. var yAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-inversed text');
  9802. var xAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-inversed-texts-g text tspan');
  9803. if (w.globals.rotateXLabels || w.config.xaxis.labels.rotateAlways) {
  9804. for (var xat = 0; xat < xAxisTexts.length; xat++) {
  9805. var textRotatingCenter = graphics.rotateAroundCenter(xAxisTexts[xat]);
  9806. textRotatingCenter.y = textRotatingCenter.y - 1; // + tickWidth/4;
  9807. textRotatingCenter.x = textRotatingCenter.x + 1;
  9808. xAxisTexts[xat].setAttribute('transform', "rotate(".concat(w.config.xaxis.labels.rotate, " ").concat(textRotatingCenter.x, " ").concat(textRotatingCenter.y, ")"));
  9809. xAxisTexts[xat].setAttribute('text-anchor', "end");
  9810. var offsetHeight = 10;
  9811. xAxis.setAttribute('transform', "translate(0, ".concat(-offsetHeight, ")"));
  9812. var tSpan = xAxisTexts[xat].childNodes;
  9813. if (w.config.xaxis.labels.trim) {
  9814. Array.prototype.forEach.call(tSpan, function (ts) {
  9815. graphics.placeTextWithEllipsis(ts, ts.textContent, w.globals.xAxisLabelsHeight - (w.config.legend.position === 'bottom' ? 20 : 10));
  9816. });
  9817. }
  9818. }
  9819. } else {
  9820. (function () {
  9821. var width = w.globals.gridWidth / (w.globals.labels.length + 1);
  9822. for (var _xat = 0; _xat < xAxisTexts.length; _xat++) {
  9823. var _tSpan = xAxisTexts[_xat].childNodes;
  9824. if (w.config.xaxis.labels.trim && w.config.xaxis.type !== 'datetime') {
  9825. Array.prototype.forEach.call(_tSpan, function (ts) {
  9826. graphics.placeTextWithEllipsis(ts, ts.textContent, width);
  9827. });
  9828. }
  9829. }
  9830. })();
  9831. }
  9832. if (yAxisTextsInversed.length > 0) {
  9833. // truncate rotated y axis in bar chart (x axis)
  9834. var firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox();
  9835. var lastLabelPosX = yAxisTextsInversed[0].getBBox();
  9836. if (firstLabelPosX.x < -20) {
  9837. yAxisTextsInversed[yAxisTextsInversed.length - 1].parentNode.removeChild(yAxisTextsInversed[yAxisTextsInversed.length - 1]);
  9838. }
  9839. if (lastLabelPosX.x + lastLabelPosX.width > w.globals.gridWidth && !w.globals.isBarHorizontal) {
  9840. yAxisTextsInversed[0].parentNode.removeChild(yAxisTextsInversed[0]);
  9841. } // truncate rotated x axis in bar chart (y axis)
  9842. for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) {
  9843. graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 - 20);
  9844. }
  9845. }
  9846. } // renderXAxisBands() {
  9847. // let w = this.w;
  9848. // let plotBand = document.createElementNS(w.globals.SVGNS, 'rect')
  9849. // w.globals.dom.elGraphical.add(plotBand)
  9850. // }
  9851. }]);
  9852. return XAxis;
  9853. }();
  9854. /**
  9855. * ApexCharts Grid Class for drawing Cartesian Grid.
  9856. *
  9857. * @module Grid
  9858. **/
  9859. var Grid = /*#__PURE__*/function () {
  9860. function Grid(ctx) {
  9861. _classCallCheck(this, Grid);
  9862. this.ctx = ctx;
  9863. this.w = ctx.w;
  9864. var w = this.w;
  9865. this.xaxisLabels = w.globals.labels.slice();
  9866. this.axesUtils = new AxesUtils(ctx);
  9867. this.isRangeBar = w.globals.seriesRangeBar.length;
  9868. if (w.globals.timescaleLabels.length > 0) {
  9869. // timescaleLabels labels are there
  9870. this.xaxisLabels = w.globals.timescaleLabels.slice();
  9871. }
  9872. } // 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
  9873. _createClass(Grid, [{
  9874. key: "drawGridArea",
  9875. value: function drawGridArea() {
  9876. var elGrid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9877. var w = this.w;
  9878. var graphics = new Graphics(this.ctx);
  9879. if (elGrid === null) {
  9880. elGrid = graphics.group({
  9881. class: 'apexcharts-grid'
  9882. });
  9883. }
  9884. var elVerticalLine = graphics.drawLine(w.globals.padHorizontal, 1, w.globals.padHorizontal, w.globals.gridHeight, 'transparent');
  9885. var elHorzLine = graphics.drawLine(w.globals.padHorizontal, w.globals.gridHeight, w.globals.gridWidth, w.globals.gridHeight, 'transparent');
  9886. elGrid.add(elHorzLine);
  9887. elGrid.add(elVerticalLine);
  9888. return elGrid;
  9889. }
  9890. }, {
  9891. key: "drawGrid",
  9892. value: function drawGrid() {
  9893. var gl = this.w.globals;
  9894. var elgrid = null;
  9895. if (gl.axisCharts) {
  9896. // grid is drawn after xaxis and yaxis are drawn
  9897. elgrid = this.renderGrid();
  9898. this.drawGridArea(elgrid.el);
  9899. }
  9900. return elgrid;
  9901. } // This mask will clip off overflowing graphics from the drawable area
  9902. }, {
  9903. key: "createGridMask",
  9904. value: function createGridMask() {
  9905. var w = this.w;
  9906. var gl = w.globals;
  9907. var graphics = new Graphics(this.ctx);
  9908. var strokeSize = Array.isArray(w.config.stroke.width) ? 0 : w.config.stroke.width;
  9909. if (Array.isArray(w.config.stroke.width)) {
  9910. var strokeMaxSize = 0;
  9911. w.config.stroke.width.forEach(function (m) {
  9912. strokeMaxSize = Math.max(strokeMaxSize, m);
  9913. });
  9914. strokeSize = strokeMaxSize;
  9915. }
  9916. gl.dom.elGridRectMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9917. gl.dom.elGridRectMask.setAttribute('id', "gridRectMask".concat(gl.cuid));
  9918. gl.dom.elGridRectMarkerMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9919. gl.dom.elGridRectMarkerMask.setAttribute('id', "gridRectMarkerMask".concat(gl.cuid));
  9920. gl.dom.elForecastMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9921. gl.dom.elForecastMask.setAttribute('id', "forecastMask".concat(gl.cuid));
  9922. gl.dom.elNonForecastMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9923. gl.dom.elNonForecastMask.setAttribute('id', "nonForecastMask".concat(gl.cuid)); // let barHalfWidth = 0
  9924. var type = w.config.chart.type;
  9925. var hasBar = type === 'bar' || type === 'rangeBar' || type === 'candlestick' || type === 'boxPlot' || w.globals.comboBarCount > 0;
  9926. var barWidthLeft = 0;
  9927. var barWidthRight = 0;
  9928. if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  9929. barWidthLeft = w.config.grid.padding.left;
  9930. barWidthRight = w.config.grid.padding.right;
  9931. if (gl.barPadForNumericAxis > barWidthLeft) {
  9932. barWidthLeft = gl.barPadForNumericAxis;
  9933. barWidthRight = gl.barPadForNumericAxis;
  9934. }
  9935. }
  9936. gl.dom.elGridRect = graphics.drawRect(-strokeSize / 2 - barWidthLeft - 2, -strokeSize / 2, gl.gridWidth + strokeSize + barWidthRight + barWidthLeft + 4, gl.gridHeight + strokeSize, 0, '#fff');
  9937. var markerSize = w.globals.markers.largestSize + 1;
  9938. gl.dom.elGridRectMarker = graphics.drawRect(-markerSize * 2, -markerSize * 2, gl.gridWidth + markerSize * 4, gl.gridHeight + markerSize * 4, 0, '#fff');
  9939. gl.dom.elGridRectMask.appendChild(gl.dom.elGridRect.node);
  9940. gl.dom.elGridRectMarkerMask.appendChild(gl.dom.elGridRectMarker.node);
  9941. var defs = gl.dom.baseEl.querySelector('defs');
  9942. defs.appendChild(gl.dom.elGridRectMask);
  9943. defs.appendChild(gl.dom.elForecastMask);
  9944. defs.appendChild(gl.dom.elNonForecastMask);
  9945. defs.appendChild(gl.dom.elGridRectMarkerMask);
  9946. }
  9947. }, {
  9948. key: "_drawGridLines",
  9949. value: function _drawGridLines(_ref) {
  9950. var i = _ref.i,
  9951. x1 = _ref.x1,
  9952. y1 = _ref.y1,
  9953. x2 = _ref.x2,
  9954. y2 = _ref.y2,
  9955. xCount = _ref.xCount,
  9956. parent = _ref.parent;
  9957. var w = this.w;
  9958. var shouldDraw = function shouldDraw() {
  9959. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  9960. return false;
  9961. }
  9962. if (i === xCount - 1 && w.globals.skipLastTimelinelabel && !w.config.xaxis.labels.formatter) {
  9963. return false;
  9964. }
  9965. if (w.config.chart.type === 'radar') {
  9966. return false;
  9967. }
  9968. return true;
  9969. };
  9970. if (shouldDraw()) {
  9971. if (w.config.grid.xaxis.lines.show) {
  9972. this._drawGridLine({
  9973. x1: x1,
  9974. y1: y1,
  9975. x2: x2,
  9976. y2: y2,
  9977. parent: parent
  9978. });
  9979. }
  9980. var y_2 = 0;
  9981. if (w.globals.hasGroups && (typeof w.config.xaxis.tickAmount === 'undefined' || w.config.xaxis.tickAmount === 'dataPoints') && w.config.xaxis.tickPlacement === 'between') {
  9982. var groups = w.globals.groups;
  9983. if (groups) {
  9984. var gacc = 0;
  9985. for (var gi = 0; gacc < i && gi < groups.length; gi++) {
  9986. gacc += groups[gi].cols;
  9987. }
  9988. if (gacc === i) {
  9989. y_2 = w.globals.xAxisLabelsHeight * 0.6;
  9990. }
  9991. }
  9992. }
  9993. var xAxis = new XAxis(this.ctx);
  9994. xAxis.drawXaxisTicks(x1, y_2, this.elg);
  9995. }
  9996. }
  9997. }, {
  9998. key: "_drawGridLine",
  9999. value: function _drawGridLine(_ref2) {
  10000. var x1 = _ref2.x1,
  10001. y1 = _ref2.y1,
  10002. x2 = _ref2.x2,
  10003. y2 = _ref2.y2,
  10004. parent = _ref2.parent;
  10005. var w = this.w;
  10006. var isHorzLine = parent.node.classList.contains('apexcharts-gridlines-horizontal');
  10007. var strokeDashArray = w.config.grid.strokeDashArray;
  10008. var offX = w.globals.barPadForNumericAxis;
  10009. var graphics = new Graphics(this);
  10010. var line = graphics.drawLine(x1 - (isHorzLine ? offX : 0), y1, x2 + (isHorzLine ? offX : 0), y2, w.config.grid.borderColor, strokeDashArray);
  10011. line.node.classList.add('apexcharts-gridline');
  10012. parent.add(line);
  10013. }
  10014. }, {
  10015. key: "_drawGridBandRect",
  10016. value: function _drawGridBandRect(_ref3) {
  10017. var c = _ref3.c,
  10018. x1 = _ref3.x1,
  10019. y1 = _ref3.y1,
  10020. x2 = _ref3.x2,
  10021. y2 = _ref3.y2,
  10022. type = _ref3.type;
  10023. var w = this.w;
  10024. var graphics = new Graphics(this.ctx);
  10025. var offX = w.globals.barPadForNumericAxis;
  10026. if (type === 'column' && w.config.xaxis.type === 'datetime') return;
  10027. var color = w.config.grid[type].colors[c];
  10028. var rect = graphics.drawRect(x1 - (type === 'row' ? offX : 0), y1, x2 + (type === 'row' ? offX * 2 : 0), y2, 0, color, w.config.grid[type].opacity);
  10029. this.elg.add(rect);
  10030. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  10031. rect.node.classList.add("apexcharts-grid-".concat(type));
  10032. }
  10033. }, {
  10034. key: "_drawXYLines",
  10035. value: function _drawXYLines(_ref4) {
  10036. var _this = this;
  10037. var xCount = _ref4.xCount,
  10038. tickAmount = _ref4.tickAmount;
  10039. var w = this.w;
  10040. var datetimeLines = function datetimeLines(_ref5) {
  10041. var xC = _ref5.xC,
  10042. x1 = _ref5.x1,
  10043. y1 = _ref5.y1,
  10044. x2 = _ref5.x2,
  10045. y2 = _ref5.y2;
  10046. for (var i = 0; i < xC; i++) {
  10047. x1 = _this.xaxisLabels[i].position;
  10048. x2 = _this.xaxisLabels[i].position;
  10049. _this._drawGridLines({
  10050. i: i,
  10051. x1: x1,
  10052. y1: y1,
  10053. x2: x2,
  10054. y2: y2,
  10055. xCount: xCount,
  10056. parent: _this.elgridLinesV
  10057. });
  10058. }
  10059. };
  10060. var categoryLines = function categoryLines(_ref6) {
  10061. var xC = _ref6.xC,
  10062. x1 = _ref6.x1,
  10063. y1 = _ref6.y1,
  10064. x2 = _ref6.x2,
  10065. y2 = _ref6.y2;
  10066. if (typeof w.config.xaxis.tickAmount !== 'undefined' && w.config.xaxis.tickAmount !== 'dataPoints') {
  10067. // user has specified tickamount in a category x-axis chart
  10068. var visibleLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-text.apexcharts-xaxis-label tspan:not(:empty)');
  10069. visibleLabels.forEach(function (d, i) {
  10070. var textRect = d.getBBox();
  10071. _this._drawGridLines({
  10072. i: i,
  10073. x1: textRect.x + textRect.width / 2,
  10074. y1: y1,
  10075. x2: textRect.x + textRect.width / 2,
  10076. y2: y2,
  10077. xCount: xCount,
  10078. parent: _this.elgridLinesV
  10079. });
  10080. });
  10081. } else {
  10082. for (var i = 0; i < xC + (w.globals.isXNumeric ? 0 : 1); i++) {
  10083. if (i === 0 && xC === 1 && w.globals.dataPoints === 1) {
  10084. // single datapoint
  10085. x1 = w.globals.gridWidth / 2;
  10086. x2 = x1;
  10087. }
  10088. _this._drawGridLines({
  10089. i: i,
  10090. x1: x1,
  10091. y1: y1,
  10092. x2: x2,
  10093. y2: y2,
  10094. xCount: xCount,
  10095. parent: _this.elgridLinesV
  10096. });
  10097. x1 = x1 + w.globals.gridWidth / (w.globals.isXNumeric ? xC - 1 : xC);
  10098. x2 = x1;
  10099. }
  10100. }
  10101. }; // draw vertical lines
  10102. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  10103. var x1 = w.globals.padHorizontal;
  10104. var y1 = 0;
  10105. var x2;
  10106. var y2 = w.globals.gridHeight;
  10107. if (w.globals.timescaleLabels.length) {
  10108. datetimeLines({
  10109. xC: xCount,
  10110. x1: x1,
  10111. y1: y1,
  10112. x2: x2,
  10113. y2: y2
  10114. });
  10115. } else {
  10116. if (w.globals.isXNumeric) {
  10117. xCount = w.globals.xAxisScale.result.length;
  10118. }
  10119. if (w.config.xaxis.convertedCatToNumeric) {
  10120. // in case of a convertedCatToNumeric, some labels might be skipped due to hideOverLapping labels, hence use this var to get the visible ticks
  10121. xCount = w.globals.xaxisLabelsCount;
  10122. }
  10123. categoryLines({
  10124. xC: xCount,
  10125. x1: x1,
  10126. y1: y1,
  10127. x2: x2,
  10128. y2: y2
  10129. });
  10130. }
  10131. } // draw horizontal lines
  10132. if (w.config.grid.yaxis.lines.show) {
  10133. var _x = 0;
  10134. var _y = 0;
  10135. var _y2 = 0;
  10136. var _x2 = w.globals.gridWidth;
  10137. var tA = tickAmount + 1;
  10138. if (this.isRangeBar) {
  10139. tA = w.globals.labels.length;
  10140. }
  10141. for (var i = 0; i < tA + (this.isRangeBar ? 1 : 0); i++) {
  10142. this._drawGridLine({
  10143. x1: _x,
  10144. y1: _y,
  10145. x2: _x2,
  10146. y2: _y2,
  10147. parent: this.elgridLinesH
  10148. });
  10149. _y = _y + w.globals.gridHeight / (this.isRangeBar ? tA : tickAmount);
  10150. _y2 = _y;
  10151. }
  10152. }
  10153. }
  10154. }, {
  10155. key: "_drawInvertedXYLines",
  10156. value: function _drawInvertedXYLines(_ref7) {
  10157. var xCount = _ref7.xCount;
  10158. var w = this.w; // draw vertical lines
  10159. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  10160. var x1 = w.globals.padHorizontal;
  10161. var y1 = 0;
  10162. var x2;
  10163. var y2 = w.globals.gridHeight;
  10164. for (var i = 0; i < xCount + 1; i++) {
  10165. if (w.config.grid.xaxis.lines.show) {
  10166. this._drawGridLine({
  10167. x1: x1,
  10168. y1: y1,
  10169. x2: x2,
  10170. y2: y2,
  10171. parent: this.elgridLinesV
  10172. });
  10173. }
  10174. var xAxis = new XAxis(this.ctx);
  10175. xAxis.drawXaxisTicks(x1, 0, this.elg);
  10176. x1 = x1 + w.globals.gridWidth / xCount + 0.3;
  10177. x2 = x1;
  10178. }
  10179. } // draw horizontal lines
  10180. if (w.config.grid.yaxis.lines.show) {
  10181. var _x3 = 0;
  10182. var _y3 = 0;
  10183. var _y4 = 0;
  10184. var _x4 = w.globals.gridWidth;
  10185. for (var _i = 0; _i < w.globals.dataPoints + 1; _i++) {
  10186. this._drawGridLine({
  10187. x1: _x3,
  10188. y1: _y3,
  10189. x2: _x4,
  10190. y2: _y4,
  10191. parent: this.elgridLinesH
  10192. });
  10193. _y3 = _y3 + w.globals.gridHeight / w.globals.dataPoints;
  10194. _y4 = _y3;
  10195. }
  10196. }
  10197. } // actual grid rendering
  10198. }, {
  10199. key: "renderGrid",
  10200. value: function renderGrid() {
  10201. var w = this.w;
  10202. var graphics = new Graphics(this.ctx);
  10203. this.elg = graphics.group({
  10204. class: 'apexcharts-grid'
  10205. });
  10206. this.elgridLinesH = graphics.group({
  10207. class: 'apexcharts-gridlines-horizontal'
  10208. });
  10209. this.elgridLinesV = graphics.group({
  10210. class: 'apexcharts-gridlines-vertical'
  10211. });
  10212. this.elg.add(this.elgridLinesH);
  10213. this.elg.add(this.elgridLinesV);
  10214. if (!w.config.grid.show) {
  10215. this.elgridLinesV.hide();
  10216. this.elgridLinesH.hide();
  10217. }
  10218. var yTickAmount = w.globals.yAxisScale.length ? w.globals.yAxisScale[0].result.length - 1 : 5;
  10219. for (var i = 0; i < w.globals.series.length; i++) {
  10220. if (typeof w.globals.yAxisScale[i] !== 'undefined') {
  10221. yTickAmount = w.globals.yAxisScale[i].result.length - 1;
  10222. }
  10223. if (yTickAmount > 2) break;
  10224. }
  10225. var xCount;
  10226. if (!w.globals.isBarHorizontal || this.isRangeBar) {
  10227. xCount = this.xaxisLabels.length;
  10228. if (this.isRangeBar) {
  10229. yTickAmount = w.globals.labels.length;
  10230. if (w.config.xaxis.tickAmount && w.config.xaxis.labels.formatter) {
  10231. xCount = w.config.xaxis.tickAmount;
  10232. }
  10233. }
  10234. this._drawXYLines({
  10235. xCount: xCount,
  10236. tickAmount: yTickAmount
  10237. });
  10238. } else {
  10239. xCount = yTickAmount; // for horizontal bar chart, get the xaxis tickamount
  10240. yTickAmount = w.globals.xTickAmount;
  10241. this._drawInvertedXYLines({
  10242. xCount: xCount,
  10243. tickAmount: yTickAmount
  10244. });
  10245. }
  10246. this.drawGridBands(xCount, yTickAmount);
  10247. return {
  10248. el: this.elg,
  10249. xAxisTickWidth: w.globals.gridWidth / xCount
  10250. };
  10251. }
  10252. }, {
  10253. key: "drawGridBands",
  10254. value: function drawGridBands(xCount, tickAmount) {
  10255. var w = this.w; // rows background bands
  10256. if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) {
  10257. var x1 = 0;
  10258. var y1 = 0;
  10259. var y2 = w.globals.gridHeight / tickAmount;
  10260. var x2 = w.globals.gridWidth;
  10261. for (var i = 0, c = 0; i < tickAmount; i++, c++) {
  10262. if (c >= w.config.grid.row.colors.length) {
  10263. c = 0;
  10264. }
  10265. this._drawGridBandRect({
  10266. c: c,
  10267. x1: x1,
  10268. y1: y1,
  10269. x2: x2,
  10270. y2: y2,
  10271. type: 'row'
  10272. });
  10273. y1 = y1 + w.globals.gridHeight / tickAmount;
  10274. }
  10275. } // columns background bands
  10276. if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) {
  10277. var xc = !w.globals.isBarHorizontal && (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) ? xCount - 1 : xCount;
  10278. var _x5 = w.globals.padHorizontal;
  10279. var _y5 = 0;
  10280. var _x6 = w.globals.padHorizontal + w.globals.gridWidth / xc;
  10281. var _y6 = w.globals.gridHeight;
  10282. for (var _i2 = 0, _c = 0; _i2 < xCount; _i2++, _c++) {
  10283. if (_c >= w.config.grid.column.colors.length) {
  10284. _c = 0;
  10285. }
  10286. this._drawGridBandRect({
  10287. c: _c,
  10288. x1: _x5,
  10289. y1: _y5,
  10290. x2: _x6,
  10291. y2: _y6,
  10292. type: 'column'
  10293. });
  10294. _x5 = _x5 + w.globals.gridWidth / xc;
  10295. }
  10296. }
  10297. }
  10298. }]);
  10299. return Grid;
  10300. }();
  10301. var Range$1 = /*#__PURE__*/function () {
  10302. function Range(ctx) {
  10303. _classCallCheck(this, Range);
  10304. this.ctx = ctx;
  10305. this.w = ctx.w;
  10306. } // http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axiss
  10307. // This routine creates the Y axis values for a graph.
  10308. _createClass(Range, [{
  10309. key: "niceScale",
  10310. value: function niceScale(yMin, yMax) {
  10311. var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  10312. var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  10313. var NO_MIN_MAX_PROVIDED = arguments.length > 4 ? arguments[4] : undefined;
  10314. var w = this.w; // Determine Range
  10315. var range = Math.abs(yMax - yMin);
  10316. ticks = this._adjustTicksForSmallRange(ticks, index, range);
  10317. if (ticks === 'dataPoints') {
  10318. ticks = w.globals.dataPoints - 1;
  10319. }
  10320. if (yMin === Number.MIN_VALUE && yMax === 0 || !Utils$1.isNumber(yMin) && !Utils$1.isNumber(yMax) || yMin === Number.MIN_VALUE && yMax === -Number.MAX_VALUE) {
  10321. // when all values are 0
  10322. yMin = 0;
  10323. yMax = ticks;
  10324. var linearScale = this.linearScale(yMin, yMax, ticks);
  10325. return linearScale;
  10326. }
  10327. if (yMin > yMax) {
  10328. // if somehow due to some wrong config, user sent max less than min,
  10329. // adjust the min/max again
  10330. console.warn('axis.min cannot be greater than axis.max');
  10331. yMax = yMin + 0.1;
  10332. } else if (yMin === yMax) {
  10333. // If yMin and yMax are identical, then
  10334. // adjust the yMin and yMax values to actually
  10335. // make a graph. Also avoids division by zero errors.
  10336. yMin = yMin === 0 ? 0 : yMin - 0.5; // some small value
  10337. yMax = yMax === 0 ? 2 : yMax + 0.5; // some small value
  10338. } // Calculate Min amd Max graphical labels and graph
  10339. // increments. The number of ticks defaults to
  10340. // 10 which is the SUGGESTED value. Any tick value
  10341. // entered is used as a suggested value which is
  10342. // adjusted to be a 'pretty' value.
  10343. //
  10344. // Output will be an array of the Y axis values that
  10345. // encompass the Y values.
  10346. var result = [];
  10347. if (range < 1 && NO_MIN_MAX_PROVIDED && (w.config.chart.type === 'candlestick' || w.config.series[index].type === 'candlestick' || w.config.chart.type === 'boxPlot' || w.config.series[index].type === 'boxPlot' || w.globals.isRangeData)) {
  10348. /* fix https://github.com/apexcharts/apexcharts.js/issues/430 */
  10349. yMax = yMax * 1.01;
  10350. }
  10351. var tiks = ticks + 1; // Adjust ticks if needed
  10352. if (tiks < 2) {
  10353. tiks = 2;
  10354. } else if (tiks > 2) {
  10355. tiks -= 2;
  10356. } // Get raw step value
  10357. var tempStep = range / tiks; // Calculate pretty step value
  10358. var mag = Math.floor(Utils$1.log10(tempStep));
  10359. var magPow = Math.pow(10, mag);
  10360. var magMsd = Math.round(tempStep / magPow);
  10361. if (magMsd < 1) {
  10362. magMsd = 1;
  10363. }
  10364. var stepSize = magMsd * magPow; // build Y label array.
  10365. // Lower and upper bounds calculations
  10366. var lb = stepSize * Math.floor(yMin / stepSize);
  10367. var ub = stepSize * Math.ceil(yMax / stepSize); // Build array
  10368. var val = lb;
  10369. if (NO_MIN_MAX_PROVIDED && range > 2) {
  10370. while (1) {
  10371. result.push(val);
  10372. val += stepSize;
  10373. if (val > ub) {
  10374. break;
  10375. }
  10376. }
  10377. return {
  10378. result: result,
  10379. niceMin: result[0],
  10380. niceMax: result[result.length - 1]
  10381. };
  10382. } else {
  10383. result = [];
  10384. var v = yMin;
  10385. result.push(v);
  10386. var valuesDivider = Math.abs(yMax - yMin) / ticks;
  10387. for (var i = 0; i <= ticks; i++) {
  10388. v = v + valuesDivider;
  10389. result.push(v);
  10390. }
  10391. if (result[result.length - 2] >= yMax) {
  10392. result.pop();
  10393. }
  10394. return {
  10395. result: result,
  10396. niceMin: result[0],
  10397. niceMax: result[result.length - 1]
  10398. };
  10399. }
  10400. }
  10401. }, {
  10402. key: "linearScale",
  10403. value: function linearScale(yMin, yMax) {
  10404. var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  10405. var index = arguments.length > 3 ? arguments[3] : undefined;
  10406. var range = Math.abs(yMax - yMin);
  10407. ticks = this._adjustTicksForSmallRange(ticks, index, range);
  10408. if (ticks === 'dataPoints') {
  10409. ticks = this.w.globals.dataPoints - 1;
  10410. }
  10411. var step = range / ticks;
  10412. if (ticks === Number.MAX_VALUE) {
  10413. ticks = 10;
  10414. step = 1;
  10415. }
  10416. var result = [];
  10417. var v = yMin;
  10418. while (ticks >= 0) {
  10419. result.push(v);
  10420. v = v + step;
  10421. ticks -= 1;
  10422. }
  10423. return {
  10424. result: result,
  10425. niceMin: result[0],
  10426. niceMax: result[result.length - 1]
  10427. };
  10428. }
  10429. }, {
  10430. key: "logarithmicScale",
  10431. value: function logarithmicScale(yMin, yMax, base) {
  10432. var logs = [];
  10433. var ticks = Math.ceil(Math.log(yMax) / Math.log(base)) + 1; // Get powers of base up to our max, and then one more
  10434. for (var i = 0; i < ticks; i++) {
  10435. logs.push(Math.pow(base, i));
  10436. }
  10437. if (yMin === 0) {
  10438. logs.unshift(yMin);
  10439. }
  10440. return {
  10441. result: logs,
  10442. niceMin: logs[0],
  10443. niceMax: logs[logs.length - 1]
  10444. };
  10445. }
  10446. }, {
  10447. key: "_adjustTicksForSmallRange",
  10448. value: function _adjustTicksForSmallRange(ticks, index, range) {
  10449. var newTicks = ticks;
  10450. if (typeof index !== 'undefined' && this.w.config.yaxis[index].labels.formatter && this.w.config.yaxis[index].tickAmount === undefined) {
  10451. var formattedVal = this.w.config.yaxis[index].labels.formatter(1);
  10452. if (Utils$1.isNumber(Number(formattedVal)) && !Utils$1.isFloat(formattedVal)) {
  10453. newTicks = Math.ceil(range);
  10454. }
  10455. }
  10456. return newTicks < ticks ? newTicks : ticks;
  10457. }
  10458. }, {
  10459. key: "setYScaleForIndex",
  10460. value: function setYScaleForIndex(index, minY, maxY) {
  10461. var gl = this.w.globals;
  10462. var cnf = this.w.config;
  10463. var y = gl.isBarHorizontal ? cnf.xaxis : cnf.yaxis[index];
  10464. if (typeof gl.yAxisScale[index] === 'undefined') {
  10465. gl.yAxisScale[index] = [];
  10466. }
  10467. var diff = Math.abs(maxY - minY);
  10468. if (y.logarithmic && diff <= 5) {
  10469. gl.invalidLogScale = true;
  10470. }
  10471. if (y.logarithmic && diff > 5) {
  10472. gl.allSeriesCollapsed = false;
  10473. gl.yAxisScale[index] = this.logarithmicScale(minY, maxY, y.logBase);
  10474. } else {
  10475. if (maxY === -Number.MAX_VALUE || !Utils$1.isNumber(maxY)) {
  10476. // no data in the chart. Either all series collapsed or user passed a blank array
  10477. gl.yAxisScale[index] = this.linearScale(0, 5, 5);
  10478. } else {
  10479. // there is some data. Turn off the allSeriesCollapsed flag
  10480. gl.allSeriesCollapsed = false;
  10481. if ((y.min !== undefined || y.max !== undefined) && !y.forceNiceScale) {
  10482. // fix https://github.com/apexcharts/apexcharts.js/issues/492
  10483. gl.yAxisScale[index] = this.linearScale(minY, maxY, y.tickAmount, index);
  10484. } else {
  10485. var noMinMaxProvided = cnf.yaxis[index].max === undefined && cnf.yaxis[index].min === undefined || cnf.yaxis[index].forceNiceScale;
  10486. gl.yAxisScale[index] = this.niceScale(minY, maxY, y.tickAmount ? y.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5, index, // fix https://github.com/apexcharts/apexcharts.js/issues/397
  10487. noMinMaxProvided);
  10488. }
  10489. }
  10490. }
  10491. }
  10492. }, {
  10493. key: "setXScale",
  10494. value: function setXScale(minX, maxX) {
  10495. var w = this.w;
  10496. var gl = w.globals;
  10497. var x = w.config.xaxis;
  10498. var diff = Math.abs(maxX - minX);
  10499. if (maxX === -Number.MAX_VALUE || !Utils$1.isNumber(maxX)) {
  10500. // no data in the chart. Either all series collapsed or user passed a blank array
  10501. gl.xAxisScale = this.linearScale(0, 5, 5);
  10502. } else {
  10503. gl.xAxisScale = this.linearScale(minX, maxX, x.tickAmount ? x.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5, 0);
  10504. }
  10505. return gl.xAxisScale;
  10506. }
  10507. }, {
  10508. key: "setMultipleYScales",
  10509. value: function setMultipleYScales() {
  10510. var _this = this;
  10511. var gl = this.w.globals;
  10512. var cnf = this.w.config;
  10513. var minYArr = gl.minYArr.concat([]);
  10514. var maxYArr = gl.maxYArr.concat([]);
  10515. var scalesIndices = []; // here, we loop through the yaxis array and find the item which has "seriesName" property
  10516. cnf.yaxis.forEach(function (yaxe, i) {
  10517. var index = i;
  10518. cnf.series.forEach(function (s, si) {
  10519. // if seriesName matches and that series is not collapsed, we use that scale
  10520. // fix issue #1215
  10521. // proceed even if si is in gl.collapsedSeriesIndices
  10522. if (s.name === yaxe.seriesName) {
  10523. index = si;
  10524. if (i !== si) {
  10525. scalesIndices.push({
  10526. index: si,
  10527. similarIndex: i,
  10528. alreadyExists: true
  10529. });
  10530. } else {
  10531. scalesIndices.push({
  10532. index: si
  10533. });
  10534. }
  10535. }
  10536. });
  10537. var minY = minYArr[index];
  10538. var maxY = maxYArr[index];
  10539. _this.setYScaleForIndex(i, minY, maxY);
  10540. });
  10541. this.sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices);
  10542. }
  10543. }, {
  10544. key: "sameScaleInMultipleAxes",
  10545. value: function sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) {
  10546. var _this2 = this;
  10547. var cnf = this.w.config;
  10548. 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
  10549. var similarIndices = [];
  10550. scalesIndices.forEach(function (scale) {
  10551. if (scale.alreadyExists) {
  10552. if (typeof similarIndices[scale.index] === 'undefined') {
  10553. similarIndices[scale.index] = [];
  10554. }
  10555. similarIndices[scale.index].push(scale.index);
  10556. similarIndices[scale.index].push(scale.similarIndex);
  10557. }
  10558. });
  10559. function intersect(a, b) {
  10560. return a.filter(function (value) {
  10561. return b.indexOf(value) !== -1;
  10562. });
  10563. }
  10564. gl.yAxisSameScaleIndices = similarIndices;
  10565. similarIndices.forEach(function (si, i) {
  10566. similarIndices.forEach(function (sj, j) {
  10567. if (i !== j) {
  10568. if (intersect(si, sj).length > 0) {
  10569. similarIndices[i] = similarIndices[i].concat(similarIndices[j]);
  10570. }
  10571. }
  10572. });
  10573. }); // then, we remove duplicates from the similarScale array
  10574. var uniqueSimilarIndices = similarIndices.map(function (item) {
  10575. return item.filter(function (i, pos) {
  10576. return item.indexOf(i) === pos;
  10577. });
  10578. }); // sort further to remove whole duplicate arrays later
  10579. var sortedIndices = uniqueSimilarIndices.map(function (s) {
  10580. return s.sort();
  10581. }); // remove undefined items
  10582. similarIndices = similarIndices.filter(function (s) {
  10583. return !!s;
  10584. });
  10585. var indices = sortedIndices.slice();
  10586. var stringIndices = indices.map(function (ind) {
  10587. return JSON.stringify(ind);
  10588. });
  10589. indices = indices.filter(function (ind, p) {
  10590. return stringIndices.indexOf(JSON.stringify(ind)) === p;
  10591. });
  10592. var sameScaleMinYArr = [];
  10593. var sameScaleMaxYArr = [];
  10594. minYArr.forEach(function (minYValue, yi) {
  10595. indices.forEach(function (scale, i) {
  10596. // we compare only the yIndex which exists in the indices array
  10597. if (scale.indexOf(yi) > -1) {
  10598. if (typeof sameScaleMinYArr[i] === 'undefined') {
  10599. sameScaleMinYArr[i] = [];
  10600. sameScaleMaxYArr[i] = [];
  10601. }
  10602. sameScaleMinYArr[i].push({
  10603. key: yi,
  10604. value: minYValue
  10605. });
  10606. sameScaleMaxYArr[i].push({
  10607. key: yi,
  10608. value: maxYArr[yi]
  10609. });
  10610. }
  10611. });
  10612. });
  10613. var sameScaleMin = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, Number.MIN_VALUE);
  10614. var sameScaleMax = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, -Number.MAX_VALUE);
  10615. sameScaleMinYArr.forEach(function (s, i) {
  10616. s.forEach(function (sc, j) {
  10617. sameScaleMin[i] = Math.min(sc.value, sameScaleMin[i]);
  10618. });
  10619. });
  10620. sameScaleMaxYArr.forEach(function (s, i) {
  10621. s.forEach(function (sc, j) {
  10622. sameScaleMax[i] = Math.max(sc.value, sameScaleMax[i]);
  10623. });
  10624. });
  10625. minYArr.forEach(function (min, i) {
  10626. sameScaleMaxYArr.forEach(function (s, si) {
  10627. var minY = sameScaleMin[si];
  10628. var maxY = sameScaleMax[si];
  10629. if (cnf.chart.stacked) {
  10630. // for stacked charts, we need to add the values
  10631. maxY = 0;
  10632. s.forEach(function (ind, k) {
  10633. // fix incorrectly adjust y scale issue #1215
  10634. if (ind.value !== -Number.MAX_VALUE) {
  10635. maxY += ind.value;
  10636. }
  10637. if (minY !== Number.MIN_VALUE) {
  10638. minY += sameScaleMinYArr[si][k].value;
  10639. }
  10640. });
  10641. }
  10642. s.forEach(function (ind, k) {
  10643. if (s[k].key === i) {
  10644. if (cnf.yaxis[i].min !== undefined) {
  10645. if (typeof cnf.yaxis[i].min === 'function') {
  10646. minY = cnf.yaxis[i].min(gl.minY);
  10647. } else {
  10648. minY = cnf.yaxis[i].min;
  10649. }
  10650. }
  10651. if (cnf.yaxis[i].max !== undefined) {
  10652. if (typeof cnf.yaxis[i].max === 'function') {
  10653. maxY = cnf.yaxis[i].max(gl.maxY);
  10654. } else {
  10655. maxY = cnf.yaxis[i].max;
  10656. }
  10657. }
  10658. _this2.setYScaleForIndex(i, minY, maxY);
  10659. }
  10660. });
  10661. });
  10662. });
  10663. } // experimental feature which scales the y-axis to a min/max based on x-axis range
  10664. }, {
  10665. key: "autoScaleY",
  10666. value: function autoScaleY(ctx, yaxis, e) {
  10667. if (!ctx) {
  10668. ctx = this;
  10669. }
  10670. var w = ctx.w;
  10671. if (w.globals.isMultipleYAxis || w.globals.collapsedSeries.length) {
  10672. // The autoScale option for multiple y-axis is turned off as it leads to buggy behavior.
  10673. // Also, when a series is collapsed, it results in incorrect behavior. Hence turned it off for that too - fixes apexcharts.js#795
  10674. console.warn('autoScaleYaxis is not supported in a multi-yaxis chart.');
  10675. return yaxis;
  10676. }
  10677. var seriesX = w.globals.seriesX[0];
  10678. var isStacked = w.config.chart.stacked;
  10679. yaxis.forEach(function (yaxe, yi) {
  10680. var firstXIndex = 0;
  10681. for (var xi = 0; xi < seriesX.length; xi++) {
  10682. if (seriesX[xi] >= e.xaxis.min) {
  10683. firstXIndex = xi;
  10684. break;
  10685. }
  10686. }
  10687. var initialMin = w.globals.minYArr[yi];
  10688. var initialMax = w.globals.maxYArr[yi];
  10689. var min, max;
  10690. var stackedSer = w.globals.stackedSeriesTotals;
  10691. w.globals.series.forEach(function (serie, sI) {
  10692. var firstValue = serie[firstXIndex];
  10693. if (isStacked) {
  10694. firstValue = stackedSer[firstXIndex];
  10695. min = max = firstValue;
  10696. stackedSer.forEach(function (y, yI) {
  10697. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  10698. if (y > max && y !== null) max = y;
  10699. if (serie[yI] < min && serie[yI] !== null) min = serie[yI];
  10700. }
  10701. });
  10702. } else {
  10703. min = max = firstValue;
  10704. serie.forEach(function (y, yI) {
  10705. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  10706. var valMin = y;
  10707. var valMax = y;
  10708. w.globals.series.forEach(function (wS, wSI) {
  10709. if (y !== null) {
  10710. valMin = Math.min(wS[yI], valMin);
  10711. valMax = Math.max(wS[yI], valMax);
  10712. }
  10713. });
  10714. if (valMax > max && valMax !== null) max = valMax;
  10715. if (valMin < min && valMin !== null) min = valMin;
  10716. }
  10717. });
  10718. }
  10719. if (min === undefined && max === undefined) {
  10720. min = initialMin;
  10721. max = initialMax;
  10722. }
  10723. min *= min < 0 ? 1.1 : 0.9;
  10724. max *= max < 0 ? 0.9 : 1.1;
  10725. if (max < 0 && max < initialMax) {
  10726. max = initialMax;
  10727. }
  10728. if (min < 0 && min > initialMin) {
  10729. min = initialMin;
  10730. }
  10731. if (yaxis.length > 1) {
  10732. yaxis[sI].min = yaxe.min === undefined ? min : yaxe.min;
  10733. yaxis[sI].max = yaxe.max === undefined ? max : yaxe.max;
  10734. } else {
  10735. yaxis[0].min = yaxe.min === undefined ? min : yaxe.min;
  10736. yaxis[0].max = yaxe.max === undefined ? max : yaxe.max;
  10737. }
  10738. });
  10739. });
  10740. return yaxis;
  10741. }
  10742. }]);
  10743. return Range;
  10744. }();
  10745. /**
  10746. * Range is used to generates values between min and max.
  10747. *
  10748. * @module Range
  10749. **/
  10750. var Range = /*#__PURE__*/function () {
  10751. function Range(ctx) {
  10752. _classCallCheck(this, Range);
  10753. this.ctx = ctx;
  10754. this.w = ctx.w;
  10755. this.scales = new Range$1(ctx);
  10756. }
  10757. _createClass(Range, [{
  10758. key: "init",
  10759. value: function init() {
  10760. this.setYRange();
  10761. this.setXRange();
  10762. this.setZRange();
  10763. }
  10764. }, {
  10765. key: "getMinYMaxY",
  10766. value: function getMinYMaxY(startingIndex) {
  10767. var lowestY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  10768. var highestY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -Number.MAX_VALUE;
  10769. var len = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  10770. var cnf = this.w.config;
  10771. var gl = this.w.globals;
  10772. var maxY = -Number.MAX_VALUE;
  10773. var minY = Number.MIN_VALUE;
  10774. if (len === null) {
  10775. len = startingIndex + 1;
  10776. }
  10777. var series = gl.series;
  10778. var seriesMin = series;
  10779. var seriesMax = series;
  10780. if (cnf.chart.type === 'candlestick') {
  10781. seriesMin = gl.seriesCandleL;
  10782. seriesMax = gl.seriesCandleH;
  10783. } else if (cnf.chart.type === 'boxPlot') {
  10784. seriesMin = gl.seriesCandleO;
  10785. seriesMax = gl.seriesCandleC;
  10786. } else if (gl.isRangeData) {
  10787. seriesMin = gl.seriesRangeStart;
  10788. seriesMax = gl.seriesRangeEnd;
  10789. }
  10790. for (var i = startingIndex; i < len; i++) {
  10791. gl.dataPoints = Math.max(gl.dataPoints, series[i].length);
  10792. if (gl.categoryLabels.length) {
  10793. gl.dataPoints = gl.categoryLabels.filter(function (label) {
  10794. return typeof label !== 'undefined';
  10795. }).length;
  10796. }
  10797. for (var j = 0; j < gl.series[i].length; j++) {
  10798. var val = series[i][j];
  10799. if (val !== null && Utils$1.isNumber(val)) {
  10800. if (typeof seriesMax[i][j] !== 'undefined') {
  10801. maxY = Math.max(maxY, seriesMax[i][j]);
  10802. lowestY = Math.min(lowestY, seriesMax[i][j]);
  10803. }
  10804. if (typeof seriesMin[i][j] !== 'undefined') {
  10805. lowestY = Math.min(lowestY, seriesMin[i][j]);
  10806. highestY = Math.max(highestY, seriesMin[i][j]);
  10807. }
  10808. if (this.w.config.chart.type === 'candlestick' || this.w.config.chart.type === 'boxPlot') {
  10809. if (typeof gl.seriesCandleC[i][j] !== 'undefined') {
  10810. maxY = Math.max(maxY, gl.seriesCandleO[i][j]);
  10811. maxY = Math.max(maxY, gl.seriesCandleH[i][j]);
  10812. maxY = Math.max(maxY, gl.seriesCandleL[i][j]);
  10813. maxY = Math.max(maxY, gl.seriesCandleC[i][j]);
  10814. if (this.w.config.chart.type === 'boxPlot') {
  10815. maxY = Math.max(maxY, gl.seriesCandleM[i][j]);
  10816. }
  10817. } // there is a combo chart and the specified series in not either candlestick or boxplot, find the max there
  10818. if (cnf.series[i].type && (cnf.series[i].type !== 'candlestick' || cnf.series[i].type !== 'boxPlot')) {
  10819. maxY = Math.max(maxY, gl.series[i][j]);
  10820. lowestY = Math.min(lowestY, gl.series[i][j]);
  10821. }
  10822. highestY = maxY;
  10823. }
  10824. if (gl.seriesGoals[i] && gl.seriesGoals[i][j] && Array.isArray(gl.seriesGoals[i][j])) {
  10825. gl.seriesGoals[i][j].forEach(function (g) {
  10826. if (minY !== Number.MIN_VALUE) {
  10827. minY = Math.min(minY, g.value);
  10828. lowestY = minY;
  10829. }
  10830. maxY = Math.max(maxY, g.value);
  10831. highestY = maxY;
  10832. });
  10833. }
  10834. if (Utils$1.isFloat(val)) {
  10835. val = Utils$1.noExponents(val);
  10836. gl.yValueDecimal = Math.max(gl.yValueDecimal, val.toString().split('.')[1].length);
  10837. }
  10838. if (minY > seriesMin[i][j] && seriesMin[i][j] < 0) {
  10839. minY = seriesMin[i][j];
  10840. }
  10841. } else {
  10842. gl.hasNullValues = true;
  10843. }
  10844. }
  10845. }
  10846. if (cnf.chart.type === 'rangeBar' && gl.seriesRangeStart.length && gl.isBarHorizontal) {
  10847. minY = lowestY;
  10848. }
  10849. if (cnf.chart.type === 'bar') {
  10850. if (minY < 0 && maxY < 0) {
  10851. // all negative values in a bar chart, hence make the max to 0
  10852. maxY = 0;
  10853. }
  10854. if (minY === Number.MIN_VALUE) {
  10855. minY = 0;
  10856. }
  10857. }
  10858. return {
  10859. minY: minY,
  10860. maxY: maxY,
  10861. lowestY: lowestY,
  10862. highestY: highestY
  10863. };
  10864. }
  10865. }, {
  10866. key: "setYRange",
  10867. value: function setYRange() {
  10868. var gl = this.w.globals;
  10869. var cnf = this.w.config;
  10870. gl.maxY = -Number.MAX_VALUE;
  10871. gl.minY = Number.MIN_VALUE;
  10872. var lowestYInAllSeries = Number.MAX_VALUE;
  10873. if (gl.isMultipleYAxis) {
  10874. // we need to get minY and maxY for multiple y axis
  10875. for (var i = 0; i < gl.series.length; i++) {
  10876. var minYMaxYArr = this.getMinYMaxY(i, lowestYInAllSeries, null, i + 1);
  10877. gl.minYArr.push(minYMaxYArr.minY);
  10878. gl.maxYArr.push(minYMaxYArr.maxY);
  10879. lowestYInAllSeries = minYMaxYArr.lowestY;
  10880. }
  10881. } // and then, get the minY and maxY from all series
  10882. var minYMaxY = this.getMinYMaxY(0, lowestYInAllSeries, null, gl.series.length);
  10883. gl.minY = minYMaxY.minY;
  10884. gl.maxY = minYMaxY.maxY;
  10885. lowestYInAllSeries = minYMaxY.lowestY;
  10886. if (cnf.chart.stacked) {
  10887. this._setStackedMinMax();
  10888. } // if the numbers are too big, reduce the range
  10889. // 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/boxPlot
  10890. if (cnf.chart.type === 'line' || cnf.chart.type === 'area' || cnf.chart.type === 'candlestick' || cnf.chart.type === 'boxPlot' || cnf.chart.type === 'rangeBar' && !gl.isBarHorizontal) {
  10891. if (gl.minY === Number.MIN_VALUE && lowestYInAllSeries !== -Number.MAX_VALUE && lowestYInAllSeries !== gl.maxY // single value possibility
  10892. ) {
  10893. var diff = gl.maxY - lowestYInAllSeries;
  10894. if (lowestYInAllSeries >= 0 && lowestYInAllSeries <= 10 || cnf.yaxis[0].min !== undefined || cnf.yaxis[0].max !== undefined) {
  10895. // if minY is already 0/low value, we don't want to go negatives here - so this check is essential.
  10896. diff = 0;
  10897. }
  10898. gl.minY = lowestYInAllSeries - diff * 5 / 100;
  10899. /* fix https://github.com/apexcharts/apexcharts.js/issues/614 */
  10900. /* fix https://github.com/apexcharts/apexcharts.js/issues/968 */
  10901. if (lowestYInAllSeries > 0 && gl.minY < 0) {
  10902. gl.minY = 0;
  10903. }
  10904. /* fix https://github.com/apexcharts/apexcharts.js/issues/426 */
  10905. gl.maxY = gl.maxY + diff * 5 / 100;
  10906. }
  10907. }
  10908. cnf.yaxis.forEach(function (yaxe, index) {
  10909. // override all min/max values by user defined values (y axis)
  10910. if (yaxe.max !== undefined) {
  10911. if (typeof yaxe.max === 'number') {
  10912. gl.maxYArr[index] = yaxe.max;
  10913. } else if (typeof yaxe.max === 'function') {
  10914. // fixes apexcharts.js/issues/2098
  10915. gl.maxYArr[index] = yaxe.max(gl.isMultipleYAxis ? gl.maxYArr[index] : gl.maxY);
  10916. } // gl.maxY is for single y-axis chart, it will be ignored in multi-yaxis
  10917. gl.maxY = gl.maxYArr[index];
  10918. }
  10919. if (yaxe.min !== undefined) {
  10920. if (typeof yaxe.min === 'number') {
  10921. gl.minYArr[index] = yaxe.min;
  10922. } else if (typeof yaxe.min === 'function') {
  10923. // fixes apexcharts.js/issues/2098
  10924. gl.minYArr[index] = yaxe.min(gl.isMultipleYAxis ? gl.minYArr[index] === Number.MIN_VALUE ? 0 : gl.minYArr[index] : gl.minY);
  10925. } // gl.minY is for single y-axis chart, it will be ignored in multi-yaxis
  10926. gl.minY = gl.minYArr[index];
  10927. }
  10928. }); // for horizontal bar charts, we need to check xaxis min/max as user may have specified there
  10929. if (gl.isBarHorizontal) {
  10930. var minmax = ['min', 'max'];
  10931. minmax.forEach(function (m) {
  10932. if (cnf.xaxis[m] !== undefined && typeof cnf.xaxis[m] === 'number') {
  10933. m === 'min' ? gl.minY = cnf.xaxis[m] : gl.maxY = cnf.xaxis[m];
  10934. }
  10935. });
  10936. } // for multi y-axis we need different scales for each
  10937. if (gl.isMultipleYAxis) {
  10938. this.scales.setMultipleYScales();
  10939. gl.minY = lowestYInAllSeries;
  10940. gl.yAxisScale.forEach(function (scale, i) {
  10941. gl.minYArr[i] = scale.niceMin;
  10942. gl.maxYArr[i] = scale.niceMax;
  10943. });
  10944. } else {
  10945. this.scales.setYScaleForIndex(0, gl.minY, gl.maxY);
  10946. gl.minY = gl.yAxisScale[0].niceMin;
  10947. gl.maxY = gl.yAxisScale[0].niceMax;
  10948. gl.minYArr[0] = gl.yAxisScale[0].niceMin;
  10949. gl.maxYArr[0] = gl.yAxisScale[0].niceMax;
  10950. }
  10951. return {
  10952. minY: gl.minY,
  10953. maxY: gl.maxY,
  10954. minYArr: gl.minYArr,
  10955. maxYArr: gl.maxYArr,
  10956. yAxisScale: gl.yAxisScale
  10957. };
  10958. }
  10959. }, {
  10960. key: "setXRange",
  10961. value: function setXRange() {
  10962. var gl = this.w.globals;
  10963. var cnf = this.w.config;
  10964. var isXNumeric = cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'datetime' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided || gl.noLabelsProvided || gl.isXNumeric;
  10965. var getInitialMinXMaxX = function getInitialMinXMaxX() {
  10966. for (var i = 0; i < gl.series.length; i++) {
  10967. if (gl.labels[i]) {
  10968. for (var j = 0; j < gl.labels[i].length; j++) {
  10969. if (gl.labels[i][j] !== null && Utils$1.isNumber(gl.labels[i][j])) {
  10970. gl.maxX = Math.max(gl.maxX, gl.labels[i][j]);
  10971. gl.initialMaxX = Math.max(gl.maxX, gl.labels[i][j]);
  10972. gl.minX = Math.min(gl.minX, gl.labels[i][j]);
  10973. gl.initialMinX = Math.min(gl.minX, gl.labels[i][j]);
  10974. }
  10975. }
  10976. }
  10977. }
  10978. }; // minX maxX starts here
  10979. if (gl.isXNumeric) {
  10980. getInitialMinXMaxX();
  10981. }
  10982. if (gl.noLabelsProvided) {
  10983. if (cnf.xaxis.categories.length === 0) {
  10984. gl.maxX = gl.labels[gl.labels.length - 1];
  10985. gl.initialMaxX = gl.labels[gl.labels.length - 1];
  10986. gl.minX = 1;
  10987. gl.initialMinX = 1;
  10988. }
  10989. }
  10990. if (gl.isXNumeric || gl.noLabelsProvided || gl.dataFormatXNumeric) {
  10991. var ticks;
  10992. if (cnf.xaxis.tickAmount === undefined) {
  10993. ticks = Math.round(gl.svgWidth / 150); // no labels provided and total number of dataPoints is less than 30
  10994. if (cnf.xaxis.type === 'numeric' && gl.dataPoints < 30) {
  10995. ticks = gl.dataPoints - 1;
  10996. } // this check is for when ticks exceeds total datapoints and that would result in duplicate labels
  10997. if (ticks > gl.dataPoints && gl.dataPoints !== 0) {
  10998. ticks = gl.dataPoints - 1;
  10999. }
  11000. } else if (cnf.xaxis.tickAmount === 'dataPoints') {
  11001. if (gl.series.length > 1) {
  11002. ticks = gl.series[gl.maxValsInArrayIndex].length - 1;
  11003. }
  11004. if (gl.isXNumeric) {
  11005. ticks = gl.maxX - gl.minX - 1;
  11006. }
  11007. } else {
  11008. ticks = cnf.xaxis.tickAmount;
  11009. }
  11010. gl.xTickAmount = ticks; // override all min/max values by user defined values (x axis)
  11011. if (cnf.xaxis.max !== undefined && typeof cnf.xaxis.max === 'number') {
  11012. gl.maxX = cnf.xaxis.max;
  11013. }
  11014. if (cnf.xaxis.min !== undefined && typeof cnf.xaxis.min === 'number') {
  11015. gl.minX = cnf.xaxis.min;
  11016. } // if range is provided, adjust the new minX
  11017. if (cnf.xaxis.range !== undefined) {
  11018. gl.minX = gl.maxX - cnf.xaxis.range;
  11019. }
  11020. if (gl.minX !== Number.MAX_VALUE && gl.maxX !== -Number.MAX_VALUE) {
  11021. if (cnf.xaxis.convertedCatToNumeric && !gl.dataFormatXNumeric) {
  11022. var catScale = [];
  11023. for (var i = gl.minX - 1; i < gl.maxX; i++) {
  11024. catScale.push(i + 1);
  11025. }
  11026. gl.xAxisScale = {
  11027. result: catScale,
  11028. niceMin: catScale[0],
  11029. niceMax: catScale[catScale.length - 1]
  11030. };
  11031. } else {
  11032. gl.xAxisScale = this.scales.setXScale(gl.minX, gl.maxX);
  11033. }
  11034. } else {
  11035. gl.xAxisScale = this.scales.linearScale(1, ticks, ticks);
  11036. if (gl.noLabelsProvided && gl.labels.length > 0) {
  11037. gl.xAxisScale = this.scales.linearScale(1, gl.labels.length, ticks - 1); // this is the only place seriesX is again mutated
  11038. gl.seriesX = gl.labels.slice();
  11039. }
  11040. } // we will still store these labels as the count for this will be different (to draw grid and labels placement)
  11041. if (isXNumeric) {
  11042. gl.labels = gl.xAxisScale.result.slice();
  11043. }
  11044. }
  11045. if (gl.isBarHorizontal && gl.labels.length) {
  11046. gl.xTickAmount = gl.labels.length;
  11047. } // single dataPoint
  11048. this._handleSingleDataPoint(); // minimum x difference to calculate bar width in numeric bars
  11049. this._getMinXDiff();
  11050. return {
  11051. minX: gl.minX,
  11052. maxX: gl.maxX
  11053. };
  11054. }
  11055. }, {
  11056. key: "setZRange",
  11057. value: function setZRange() {
  11058. // minZ, maxZ starts here
  11059. var gl = this.w.globals;
  11060. if (!gl.isDataXYZ) return;
  11061. for (var i = 0; i < gl.series.length; i++) {
  11062. if (typeof gl.seriesZ[i] !== 'undefined') {
  11063. for (var j = 0; j < gl.seriesZ[i].length; j++) {
  11064. if (gl.seriesZ[i][j] !== null && Utils$1.isNumber(gl.seriesZ[i][j])) {
  11065. gl.maxZ = Math.max(gl.maxZ, gl.seriesZ[i][j]);
  11066. gl.minZ = Math.min(gl.minZ, gl.seriesZ[i][j]);
  11067. }
  11068. }
  11069. }
  11070. }
  11071. }
  11072. }, {
  11073. key: "_handleSingleDataPoint",
  11074. value: function _handleSingleDataPoint() {
  11075. var gl = this.w.globals;
  11076. var cnf = this.w.config;
  11077. if (gl.minX === gl.maxX) {
  11078. var datetimeObj = new DateTime(this.ctx);
  11079. if (cnf.xaxis.type === 'datetime') {
  11080. var newMinX = datetimeObj.getDate(gl.minX);
  11081. if (cnf.xaxis.labels.datetimeUTC) {
  11082. newMinX.setUTCDate(newMinX.getUTCDate() - 2);
  11083. } else {
  11084. newMinX.setDate(newMinX.getDate() - 2);
  11085. }
  11086. gl.minX = new Date(newMinX).getTime();
  11087. var newMaxX = datetimeObj.getDate(gl.maxX);
  11088. if (cnf.xaxis.labels.datetimeUTC) {
  11089. newMaxX.setUTCDate(newMaxX.getUTCDate() + 2);
  11090. } else {
  11091. newMaxX.setDate(newMaxX.getDate() + 2);
  11092. }
  11093. gl.maxX = new Date(newMaxX).getTime();
  11094. } else if (cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided) {
  11095. gl.minX = gl.minX - 2;
  11096. gl.initialMinX = gl.minX;
  11097. gl.maxX = gl.maxX + 2;
  11098. gl.initialMaxX = gl.maxX;
  11099. }
  11100. }
  11101. }
  11102. }, {
  11103. key: "_getMinXDiff",
  11104. value: function _getMinXDiff() {
  11105. var gl = this.w.globals;
  11106. if (gl.isXNumeric) {
  11107. // get the least x diff if numeric x axis is present
  11108. gl.seriesX.forEach(function (sX, i) {
  11109. if (sX.length === 1) {
  11110. // a small hack to prevent overlapping multiple bars when there is just 1 datapoint in bar series.
  11111. // fix #811
  11112. sX.push(gl.seriesX[gl.maxValsInArrayIndex][gl.seriesX[gl.maxValsInArrayIndex].length - 1]);
  11113. } // fix #983 (clone the array to avoid side effects)
  11114. var seriesX = sX.slice();
  11115. seriesX.sort(function (a, b) {
  11116. return a - b;
  11117. });
  11118. seriesX.forEach(function (s, j) {
  11119. if (j > 0) {
  11120. var xDiff = s - seriesX[j - 1];
  11121. if (xDiff > 0) {
  11122. gl.minXDiff = Math.min(xDiff, gl.minXDiff);
  11123. }
  11124. }
  11125. });
  11126. if (gl.dataPoints === 1 || gl.minXDiff === Number.MAX_VALUE) {
  11127. // fixes apexcharts.js #1221
  11128. gl.minXDiff = 0.5;
  11129. }
  11130. });
  11131. }
  11132. }
  11133. }, {
  11134. key: "_setStackedMinMax",
  11135. value: function _setStackedMinMax() {
  11136. 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
  11137. var stackedPoss = [];
  11138. var stackedNegs = [];
  11139. if (gl.series.length) {
  11140. for (var j = 0; j < gl.series[gl.maxValsInArrayIndex].length; j++) {
  11141. var poss = 0;
  11142. var negs = 0;
  11143. for (var i = 0; i < gl.series.length; i++) {
  11144. if (gl.series[i][j] !== null && Utils$1.isNumber(gl.series[i][j])) {
  11145. // 0.0001 fixes #185 when values are very small
  11146. gl.series[i][j] > 0 ? poss = poss + parseFloat(gl.series[i][j]) + 0.0001 : negs = negs + parseFloat(gl.series[i][j]);
  11147. }
  11148. if (i === gl.series.length - 1) {
  11149. // push all the totals to the array for future use
  11150. stackedPoss.push(poss);
  11151. stackedNegs.push(negs);
  11152. }
  11153. }
  11154. }
  11155. } // get the max/min out of the added parallel values
  11156. for (var z = 0; z < stackedPoss.length; z++) {
  11157. gl.maxY = Math.max(gl.maxY, stackedPoss[z]);
  11158. gl.minY = Math.min(gl.minY, stackedNegs[z]);
  11159. }
  11160. }
  11161. }]);
  11162. return Range;
  11163. }();
  11164. /**
  11165. * ApexCharts YAxis Class for drawing Y-Axis.
  11166. *
  11167. * @module YAxis
  11168. **/
  11169. var YAxis = /*#__PURE__*/function () {
  11170. function YAxis(ctx) {
  11171. _classCallCheck(this, YAxis);
  11172. this.ctx = ctx;
  11173. this.w = ctx.w;
  11174. var w = this.w;
  11175. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  11176. this.axisFontFamily = w.config.xaxis.labels.style.fontFamily;
  11177. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  11178. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  11179. this.xAxisoffX = 0;
  11180. if (w.config.xaxis.position === 'bottom') {
  11181. this.xAxisoffX = w.globals.gridHeight;
  11182. }
  11183. this.drawnLabels = [];
  11184. this.axesUtils = new AxesUtils(ctx);
  11185. }
  11186. _createClass(YAxis, [{
  11187. key: "drawYaxis",
  11188. value: function drawYaxis(realIndex) {
  11189. var _this = this;
  11190. var w = this.w;
  11191. var graphics = new Graphics(this.ctx);
  11192. var yaxisStyle = w.config.yaxis[realIndex].labels.style;
  11193. var yaxisFontSize = yaxisStyle.fontSize;
  11194. var yaxisFontFamily = yaxisStyle.fontFamily;
  11195. var yaxisFontWeight = yaxisStyle.fontWeight;
  11196. var elYaxis = graphics.group({
  11197. class: 'apexcharts-yaxis',
  11198. rel: realIndex,
  11199. transform: 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)'
  11200. });
  11201. if (this.axesUtils.isYAxisHidden(realIndex)) {
  11202. return elYaxis;
  11203. }
  11204. var elYaxisTexts = graphics.group({
  11205. class: 'apexcharts-yaxis-texts-g'
  11206. });
  11207. elYaxis.add(elYaxisTexts);
  11208. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg height/number of ticks
  11209. var labelsDivider = w.globals.gridHeight / tickAmount; // initial label position = 0;
  11210. var l = w.globals.translateY;
  11211. var lbFormatter = w.globals.yLabelFormatters[realIndex];
  11212. var labels = w.globals.yAxisScale[realIndex].result.slice();
  11213. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  11214. var firstLabel = '';
  11215. if (w.config.yaxis[realIndex].labels.show) {
  11216. var _loop = function _loop(i) {
  11217. var val = labels[i];
  11218. val = lbFormatter(val, i, w);
  11219. var xPad = w.config.yaxis[realIndex].labels.padding;
  11220. if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
  11221. xPad = xPad * -1;
  11222. }
  11223. var yColors = _this.axesUtils.getYAxisForeColor(yaxisStyle.colors, realIndex);
  11224. var getForeColor = function getForeColor() {
  11225. return Array.isArray(yColors) ? yColors[i] : yColors;
  11226. };
  11227. var label = graphics.drawText({
  11228. x: xPad,
  11229. y: l + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY + 1,
  11230. text: val,
  11231. textAnchor: w.config.yaxis[realIndex].opposite ? 'start' : 'end',
  11232. fontSize: yaxisFontSize,
  11233. fontFamily: yaxisFontFamily,
  11234. fontWeight: yaxisFontWeight,
  11235. foreColor: getForeColor(),
  11236. isPlainText: false,
  11237. cssClass: 'apexcharts-yaxis-label ' + yaxisStyle.cssClass
  11238. });
  11239. if (i === tickAmount) {
  11240. firstLabel = label;
  11241. }
  11242. elYaxisTexts.add(label);
  11243. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  11244. elTooltipTitle.textContent = Array.isArray(val) ? val.join(' ') : val;
  11245. label.node.appendChild(elTooltipTitle);
  11246. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  11247. var firstabelRotatingCenter = graphics.rotateAroundCenter(firstLabel.node);
  11248. var labelRotatingCenter = graphics.rotateAroundCenter(label.node);
  11249. label.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " ").concat(firstabelRotatingCenter.x, " ").concat(labelRotatingCenter.y, ")"));
  11250. }
  11251. l = l + labelsDivider;
  11252. };
  11253. for (var i = tickAmount; i >= 0; i--) {
  11254. _loop(i);
  11255. }
  11256. }
  11257. if (w.config.yaxis[realIndex].title.text !== undefined) {
  11258. var elYaxisTitle = graphics.group({
  11259. class: 'apexcharts-yaxis-title'
  11260. });
  11261. var _x = 0;
  11262. if (w.config.yaxis[realIndex].opposite) {
  11263. _x = w.globals.translateYAxisX[realIndex];
  11264. }
  11265. var elYAxisTitleText = graphics.drawText({
  11266. x: _x,
  11267. y: w.globals.gridHeight / 2 + w.globals.translateY + w.config.yaxis[realIndex].title.offsetY,
  11268. text: w.config.yaxis[realIndex].title.text,
  11269. textAnchor: 'end',
  11270. foreColor: w.config.yaxis[realIndex].title.style.color,
  11271. fontSize: w.config.yaxis[realIndex].title.style.fontSize,
  11272. fontWeight: w.config.yaxis[realIndex].title.style.fontWeight,
  11273. fontFamily: w.config.yaxis[realIndex].title.style.fontFamily,
  11274. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[realIndex].title.style.cssClass
  11275. });
  11276. elYaxisTitle.add(elYAxisTitleText);
  11277. elYaxis.add(elYaxisTitle);
  11278. }
  11279. var axisBorder = w.config.yaxis[realIndex].axisBorder;
  11280. var x = 31 + axisBorder.offsetX;
  11281. if (w.config.yaxis[realIndex].opposite) {
  11282. x = -31 - axisBorder.offsetX;
  11283. }
  11284. if (axisBorder.show) {
  11285. 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);
  11286. elYaxis.add(elVerticalLine);
  11287. }
  11288. if (w.config.yaxis[realIndex].axisTicks.show) {
  11289. this.axesUtils.drawYAxisTicks(x, tickAmount, axisBorder, w.config.yaxis[realIndex].axisTicks, realIndex, labelsDivider, elYaxis);
  11290. }
  11291. return elYaxis;
  11292. } // This actually becomes horizontal axis (for bar charts)
  11293. }, {
  11294. key: "drawYaxisInversed",
  11295. value: function drawYaxisInversed(realIndex) {
  11296. var w = this.w;
  11297. var graphics = new Graphics(this.ctx);
  11298. var elXaxis = graphics.group({
  11299. class: 'apexcharts-xaxis apexcharts-yaxis-inversed'
  11300. });
  11301. var elXaxisTexts = graphics.group({
  11302. class: 'apexcharts-xaxis-texts-g',
  11303. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  11304. });
  11305. elXaxis.add(elXaxisTexts);
  11306. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg width/number of ticks
  11307. var labelsDivider = w.globals.gridWidth / tickAmount + 0.1; // initial label position;
  11308. var l = labelsDivider + w.config.xaxis.labels.offsetX;
  11309. var lbFormatter = w.globals.xLabelFormatter;
  11310. var labels = w.globals.yAxisScale[realIndex].result.slice();
  11311. var timescaleLabels = w.globals.timescaleLabels;
  11312. if (timescaleLabels.length > 0) {
  11313. this.xaxisLabels = timescaleLabels.slice();
  11314. labels = timescaleLabels.slice();
  11315. tickAmount = labels.length;
  11316. }
  11317. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  11318. var tl = timescaleLabels.length;
  11319. if (w.config.xaxis.labels.show) {
  11320. for (var i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
  11321. var val = labels[i];
  11322. val = lbFormatter(val, i, w);
  11323. var x = w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX);
  11324. if (timescaleLabels.length) {
  11325. var label = this.axesUtils.getLabel(labels, timescaleLabels, x, i, this.drawnLabels, this.xaxisFontSize);
  11326. x = label.x;
  11327. val = label.text;
  11328. this.drawnLabels.push(label.text);
  11329. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  11330. val = '';
  11331. }
  11332. if (i === labels.length - 1 && w.globals.skipLastTimelinelabel) {
  11333. val = '';
  11334. }
  11335. }
  11336. var elTick = graphics.drawText({
  11337. x: x,
  11338. y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30 - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  11339. text: val,
  11340. textAnchor: 'middle',
  11341. foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors,
  11342. fontSize: this.xaxisFontSize,
  11343. fontFamily: this.xaxisFontFamily,
  11344. fontWeight: w.config.xaxis.labels.style.fontWeight,
  11345. isPlainText: false,
  11346. cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
  11347. });
  11348. elXaxisTexts.add(elTick);
  11349. elTick.tspan(val);
  11350. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  11351. elTooltipTitle.textContent = val;
  11352. elTick.node.appendChild(elTooltipTitle);
  11353. l = l + labelsDivider;
  11354. }
  11355. }
  11356. this.inversedYAxisTitleText(elXaxis);
  11357. this.inversedYAxisBorder(elXaxis);
  11358. return elXaxis;
  11359. }
  11360. }, {
  11361. key: "inversedYAxisBorder",
  11362. value: function inversedYAxisBorder(parent) {
  11363. var w = this.w;
  11364. var graphics = new Graphics(this.ctx);
  11365. var axisBorder = w.config.xaxis.axisBorder;
  11366. if (axisBorder.show) {
  11367. var lineCorrection = 0;
  11368. if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
  11369. lineCorrection = lineCorrection - 15;
  11370. }
  11371. var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + axisBorder.offsetX, this.xAxisoffX, w.globals.gridWidth, this.xAxisoffX, axisBorder.color, 0, axisBorder.height);
  11372. parent.add(elHorzLine);
  11373. }
  11374. }
  11375. }, {
  11376. key: "inversedYAxisTitleText",
  11377. value: function inversedYAxisTitleText(parent) {
  11378. var w = this.w;
  11379. var graphics = new Graphics(this.ctx);
  11380. if (w.config.xaxis.title.text !== undefined) {
  11381. var elYaxisTitle = graphics.group({
  11382. class: 'apexcharts-xaxis-title apexcharts-yaxis-title-inversed'
  11383. });
  11384. var elYAxisTitleText = graphics.drawText({
  11385. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  11386. y: this.xAxisoffX + parseFloat(this.xaxisFontSize) + parseFloat(w.config.xaxis.title.style.fontSize) + w.config.xaxis.title.offsetY + 20,
  11387. text: w.config.xaxis.title.text,
  11388. textAnchor: 'middle',
  11389. fontSize: w.config.xaxis.title.style.fontSize,
  11390. fontFamily: w.config.xaxis.title.style.fontFamily,
  11391. fontWeight: w.config.xaxis.title.style.fontWeight,
  11392. foreColor: w.config.xaxis.title.style.color,
  11393. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  11394. });
  11395. elYaxisTitle.add(elYAxisTitleText);
  11396. parent.add(elYaxisTitle);
  11397. }
  11398. }
  11399. }, {
  11400. key: "yAxisTitleRotate",
  11401. value: function yAxisTitleRotate(realIndex, yAxisOpposite) {
  11402. var w = this.w;
  11403. var graphics = new Graphics(this.ctx);
  11404. var yAxisLabelsCoord = {
  11405. width: 0,
  11406. height: 0
  11407. };
  11408. var yAxisTitleCoord = {
  11409. width: 0,
  11410. height: 0
  11411. };
  11412. var elYAxisLabelsWrap = w.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-texts-g"));
  11413. if (elYAxisLabelsWrap !== null) {
  11414. yAxisLabelsCoord = elYAxisLabelsWrap.getBoundingClientRect();
  11415. }
  11416. var yAxisTitle = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-title text"));
  11417. if (yAxisTitle !== null) {
  11418. yAxisTitleCoord = yAxisTitle.getBoundingClientRect();
  11419. }
  11420. if (yAxisTitle !== null) {
  11421. var x = this.xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite);
  11422. yAxisTitle.setAttribute('x', x.xPos - (yAxisOpposite ? 10 : 0));
  11423. }
  11424. if (yAxisTitle !== null) {
  11425. var titleRotatingCenter = graphics.rotateAroundCenter(yAxisTitle);
  11426. yAxisTitle.setAttribute('transform', "rotate(".concat(yAxisOpposite ? w.config.yaxis[realIndex].title.rotate * -1 : w.config.yaxis[realIndex].title.rotate, " ").concat(titleRotatingCenter.x, " ").concat(titleRotatingCenter.y, ")"));
  11427. }
  11428. }
  11429. }, {
  11430. key: "xPaddingForYAxisTitle",
  11431. value: function xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite) {
  11432. var w = this.w;
  11433. var oppositeAxisCount = 0;
  11434. var x = 0;
  11435. var padd = 10;
  11436. if (w.config.yaxis[realIndex].title.text === undefined || realIndex < 0) {
  11437. return {
  11438. xPos: x,
  11439. padd: 0
  11440. };
  11441. }
  11442. if (yAxisOpposite) {
  11443. x = yAxisLabelsCoord.width + w.config.yaxis[realIndex].title.offsetX + yAxisTitleCoord.width / 2 + padd / 2;
  11444. oppositeAxisCount += 1;
  11445. if (oppositeAxisCount === 0) {
  11446. x = x - padd / 2;
  11447. }
  11448. } else {
  11449. x = yAxisLabelsCoord.width * -1 + w.config.yaxis[realIndex].title.offsetX + padd / 2 + yAxisTitleCoord.width / 2;
  11450. if (w.globals.isBarHorizontal) {
  11451. padd = 25;
  11452. x = yAxisLabelsCoord.width * -1 - w.config.yaxis[realIndex].title.offsetX - padd;
  11453. }
  11454. }
  11455. return {
  11456. xPos: x,
  11457. padd: padd
  11458. };
  11459. } // sets the x position of the y-axis by counting the labels width, title width and any offset
  11460. }, {
  11461. key: "setYAxisXPosition",
  11462. value: function setYAxisXPosition(yaxisLabelCoords, yTitleCoords) {
  11463. var w = this.w;
  11464. var xLeft = 0;
  11465. var xRight = 0;
  11466. var leftOffsetX = 18;
  11467. var rightOffsetX = 1;
  11468. if (w.config.yaxis.length > 1) {
  11469. this.multipleYs = true;
  11470. }
  11471. w.config.yaxis.map(function (yaxe, index) {
  11472. var shouldNotDrawAxis = w.globals.ignoreYAxisIndexes.indexOf(index) > -1 || !yaxe.show || yaxe.floating || yaxisLabelCoords[index].width === 0;
  11473. var axisWidth = yaxisLabelCoords[index].width + yTitleCoords[index].width;
  11474. if (!yaxe.opposite) {
  11475. xLeft = w.globals.translateX - leftOffsetX;
  11476. if (!shouldNotDrawAxis) {
  11477. leftOffsetX = leftOffsetX + axisWidth + 20;
  11478. }
  11479. w.globals.translateYAxisX[index] = xLeft + yaxe.labels.offsetX;
  11480. } else {
  11481. if (w.globals.isBarHorizontal) {
  11482. xRight = w.globals.gridWidth + w.globals.translateX - 1;
  11483. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX;
  11484. } else {
  11485. xRight = w.globals.gridWidth + w.globals.translateX + rightOffsetX;
  11486. if (!shouldNotDrawAxis) {
  11487. rightOffsetX = rightOffsetX + axisWidth + 20;
  11488. }
  11489. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX + 20;
  11490. }
  11491. }
  11492. });
  11493. }
  11494. }, {
  11495. key: "setYAxisTextAlignments",
  11496. value: function setYAxisTextAlignments() {
  11497. var w = this.w;
  11498. var yaxis = w.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");
  11499. yaxis = Utils$1.listToArray(yaxis);
  11500. yaxis.forEach(function (y, index) {
  11501. var yaxe = w.config.yaxis[index]; // proceed only if user has specified alignment
  11502. if (yaxe && yaxe.labels.align !== undefined) {
  11503. var yAxisInner = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-texts-g"));
  11504. var yAxisTexts = w.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-label"));
  11505. yAxisTexts = Utils$1.listToArray(yAxisTexts);
  11506. var rect = yAxisInner.getBoundingClientRect();
  11507. if (yaxe.labels.align === 'left') {
  11508. yAxisTexts.forEach(function (label, lI) {
  11509. label.setAttribute('text-anchor', 'start');
  11510. });
  11511. if (!yaxe.opposite) {
  11512. yAxisInner.setAttribute('transform', "translate(-".concat(rect.width, ", 0)"));
  11513. }
  11514. } else if (yaxe.labels.align === 'center') {
  11515. yAxisTexts.forEach(function (label, lI) {
  11516. label.setAttribute('text-anchor', 'middle');
  11517. });
  11518. yAxisInner.setAttribute('transform', "translate(".concat(rect.width / 2 * (!yaxe.opposite ? -1 : 1), ", 0)"));
  11519. } else if (yaxe.labels.align === 'right') {
  11520. yAxisTexts.forEach(function (label, lI) {
  11521. label.setAttribute('text-anchor', 'end');
  11522. });
  11523. if (yaxe.opposite) {
  11524. yAxisInner.setAttribute('transform', "translate(".concat(rect.width, ", 0)"));
  11525. }
  11526. }
  11527. }
  11528. });
  11529. }
  11530. }]);
  11531. return YAxis;
  11532. }();
  11533. var Events = /*#__PURE__*/function () {
  11534. function Events(ctx) {
  11535. _classCallCheck(this, Events);
  11536. this.ctx = ctx;
  11537. this.w = ctx.w;
  11538. this.documentEvent = Utils$1.bind(this.documentEvent, this);
  11539. }
  11540. _createClass(Events, [{
  11541. key: "addEventListener",
  11542. value: function addEventListener(name, handler) {
  11543. var w = this.w;
  11544. if (w.globals.events.hasOwnProperty(name)) {
  11545. w.globals.events[name].push(handler);
  11546. } else {
  11547. w.globals.events[name] = [handler];
  11548. }
  11549. }
  11550. }, {
  11551. key: "removeEventListener",
  11552. value: function removeEventListener(name, handler) {
  11553. var w = this.w;
  11554. if (!w.globals.events.hasOwnProperty(name)) {
  11555. return;
  11556. }
  11557. var index = w.globals.events[name].indexOf(handler);
  11558. if (index !== -1) {
  11559. w.globals.events[name].splice(index, 1);
  11560. }
  11561. }
  11562. }, {
  11563. key: "fireEvent",
  11564. value: function fireEvent(name, args) {
  11565. var w = this.w;
  11566. if (!w.globals.events.hasOwnProperty(name)) {
  11567. return;
  11568. }
  11569. if (!args || !args.length) {
  11570. args = [];
  11571. }
  11572. var evs = w.globals.events[name];
  11573. var l = evs.length;
  11574. for (var i = 0; i < l; i++) {
  11575. evs[i].apply(null, args);
  11576. }
  11577. }
  11578. }, {
  11579. key: "setupEventHandlers",
  11580. value: function setupEventHandlers() {
  11581. var _this = this;
  11582. var w = this.w;
  11583. var me = this.ctx;
  11584. var clickableArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
  11585. this.ctx.eventList.forEach(function (event) {
  11586. clickableArea.addEventListener(event, function (e) {
  11587. var opts = Object.assign({}, w, {
  11588. seriesIndex: w.globals.capturedSeriesIndex,
  11589. dataPointIndex: w.globals.capturedDataPointIndex
  11590. });
  11591. if (e.type === 'mousemove' || e.type === 'touchmove') {
  11592. if (typeof w.config.chart.events.mouseMove === 'function') {
  11593. w.config.chart.events.mouseMove(e, me, opts);
  11594. }
  11595. } else if (e.type === 'mouseleave' || e.type === 'touchleave') {
  11596. if (typeof w.config.chart.events.mouseLeave === 'function') {
  11597. w.config.chart.events.mouseLeave(e, me, opts);
  11598. }
  11599. } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') {
  11600. if (typeof w.config.chart.events.click === 'function') {
  11601. w.config.chart.events.click(e, me, opts);
  11602. }
  11603. me.ctx.events.fireEvent('click', [e, me, opts]);
  11604. }
  11605. }, {
  11606. capture: false,
  11607. passive: true
  11608. });
  11609. });
  11610. this.ctx.eventList.forEach(function (event) {
  11611. w.globals.dom.baseEl.addEventListener(event, _this.documentEvent, {
  11612. passive: true
  11613. });
  11614. });
  11615. this.ctx.core.setupBrushHandler();
  11616. }
  11617. }, {
  11618. key: "documentEvent",
  11619. value: function documentEvent(e) {
  11620. var w = this.w;
  11621. var target = e.target.className;
  11622. if (e.type === 'click') {
  11623. var elMenu = w.globals.dom.baseEl.querySelector('.apexcharts-menu');
  11624. if (elMenu && elMenu.classList.contains('apexcharts-menu-open') && target !== 'apexcharts-menu-icon') {
  11625. elMenu.classList.remove('apexcharts-menu-open');
  11626. }
  11627. }
  11628. w.globals.clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  11629. w.globals.clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  11630. }
  11631. }]);
  11632. return Events;
  11633. }();
  11634. var Localization = /*#__PURE__*/function () {
  11635. function Localization(ctx) {
  11636. _classCallCheck(this, Localization);
  11637. this.ctx = ctx;
  11638. this.w = ctx.w;
  11639. }
  11640. _createClass(Localization, [{
  11641. key: "setCurrentLocaleValues",
  11642. value: function setCurrentLocaleValues(localeName) {
  11643. var locales = this.w.config.chart.locales; // check if user has specified locales in global Apex variable
  11644. // if yes - then extend those with local chart's locale
  11645. if (window.Apex.chart && window.Apex.chart.locales && window.Apex.chart.locales.length > 0) {
  11646. locales = this.w.config.chart.locales.concat(window.Apex.chart.locales);
  11647. } // find the locale from the array of locales which user has set (either by chart.defaultLocale or by calling setLocale() method.)
  11648. var selectedLocale = locales.filter(function (c) {
  11649. return c.name === localeName;
  11650. })[0];
  11651. if (selectedLocale) {
  11652. // create a complete locale object by extending defaults so you don't get undefined errors.
  11653. var ret = Utils$1.extend(en, selectedLocale); // store these locale options in global var for ease access
  11654. this.w.globals.locale = ret.options;
  11655. } else {
  11656. throw new Error('Wrong locale name provided. Please make sure you set the correct locale name in options');
  11657. }
  11658. }
  11659. }]);
  11660. return Localization;
  11661. }();
  11662. var Axes = /*#__PURE__*/function () {
  11663. function Axes(ctx) {
  11664. _classCallCheck(this, Axes);
  11665. this.ctx = ctx;
  11666. this.w = ctx.w;
  11667. }
  11668. _createClass(Axes, [{
  11669. key: "drawAxis",
  11670. value: function drawAxis(type, xyRatios) {
  11671. var gl = this.w.globals;
  11672. var cnf = this.w.config;
  11673. var xAxis = new XAxis(this.ctx);
  11674. var yAxis = new YAxis(this.ctx);
  11675. if (gl.axisCharts && type !== 'radar') {
  11676. var elXaxis, elYaxis;
  11677. if (gl.isBarHorizontal) {
  11678. elYaxis = yAxis.drawYaxisInversed(0);
  11679. elXaxis = xAxis.drawXaxisInversed(0);
  11680. gl.dom.elGraphical.add(elXaxis);
  11681. gl.dom.elGraphical.add(elYaxis);
  11682. } else {
  11683. elXaxis = xAxis.drawXaxis();
  11684. gl.dom.elGraphical.add(elXaxis);
  11685. cnf.yaxis.map(function (yaxe, index) {
  11686. if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
  11687. elYaxis = yAxis.drawYaxis(index);
  11688. gl.dom.Paper.add(elYaxis);
  11689. }
  11690. });
  11691. }
  11692. }
  11693. }
  11694. }]);
  11695. return Axes;
  11696. }();
  11697. var Crosshairs = /*#__PURE__*/function () {
  11698. function Crosshairs(ctx) {
  11699. _classCallCheck(this, Crosshairs);
  11700. this.ctx = ctx;
  11701. this.w = ctx.w;
  11702. }
  11703. _createClass(Crosshairs, [{
  11704. key: "drawXCrosshairs",
  11705. value: function drawXCrosshairs() {
  11706. var w = this.w;
  11707. var graphics = new Graphics(this.ctx);
  11708. var filters = new Filters(this.ctx);
  11709. var crosshairGradient = w.config.xaxis.crosshairs.fill.gradient;
  11710. var crosshairShadow = w.config.xaxis.crosshairs.dropShadow;
  11711. var fillType = w.config.xaxis.crosshairs.fill.type;
  11712. var gradientFrom = crosshairGradient.colorFrom;
  11713. var gradientTo = crosshairGradient.colorTo;
  11714. var opacityFrom = crosshairGradient.opacityFrom;
  11715. var opacityTo = crosshairGradient.opacityTo;
  11716. var stops = crosshairGradient.stops;
  11717. var shadow = 'none';
  11718. var dropShadow = crosshairShadow.enabled;
  11719. var shadowLeft = crosshairShadow.left;
  11720. var shadowTop = crosshairShadow.top;
  11721. var shadowBlur = crosshairShadow.blur;
  11722. var shadowColor = crosshairShadow.color;
  11723. var shadowOpacity = crosshairShadow.opacity;
  11724. var xcrosshairsFill = w.config.xaxis.crosshairs.fill.color;
  11725. if (w.config.xaxis.crosshairs.show) {
  11726. if (fillType === 'gradient') {
  11727. xcrosshairsFill = graphics.drawGradient('vertical', gradientFrom, gradientTo, opacityFrom, opacityTo, null, stops, null);
  11728. }
  11729. var xcrosshairs = graphics.drawRect();
  11730. if (w.config.xaxis.crosshairs.width === 1) {
  11731. // to prevent drawing 2 lines, convert rect to line
  11732. xcrosshairs = graphics.drawLine();
  11733. }
  11734. var gridHeight = w.globals.gridHeight;
  11735. if (!Utils$1.isNumber(gridHeight) || gridHeight < 0) {
  11736. gridHeight = 0;
  11737. }
  11738. var crosshairsWidth = w.config.xaxis.crosshairs.width;
  11739. if (!Utils$1.isNumber(crosshairsWidth) || crosshairsWidth < 0) {
  11740. crosshairsWidth = 0;
  11741. }
  11742. xcrosshairs.attr({
  11743. class: 'apexcharts-xcrosshairs',
  11744. x: 0,
  11745. y: 0,
  11746. y2: gridHeight,
  11747. width: crosshairsWidth,
  11748. height: gridHeight,
  11749. fill: xcrosshairsFill,
  11750. filter: shadow,
  11751. 'fill-opacity': w.config.xaxis.crosshairs.opacity,
  11752. stroke: w.config.xaxis.crosshairs.stroke.color,
  11753. 'stroke-width': w.config.xaxis.crosshairs.stroke.width,
  11754. 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray
  11755. });
  11756. if (dropShadow) {
  11757. xcrosshairs = filters.dropShadow(xcrosshairs, {
  11758. left: shadowLeft,
  11759. top: shadowTop,
  11760. blur: shadowBlur,
  11761. color: shadowColor,
  11762. opacity: shadowOpacity
  11763. });
  11764. }
  11765. w.globals.dom.elGraphical.add(xcrosshairs);
  11766. }
  11767. }
  11768. }, {
  11769. key: "drawYCrosshairs",
  11770. value: function drawYCrosshairs() {
  11771. var w = this.w;
  11772. var graphics = new Graphics(this.ctx);
  11773. var crosshair = w.config.yaxis[0].crosshairs;
  11774. var offX = w.globals.barPadForNumericAxis;
  11775. if (w.config.yaxis[0].crosshairs.show) {
  11776. var ycrosshairs = graphics.drawLine(-offX, 0, w.globals.gridWidth + offX, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width);
  11777. ycrosshairs.attr({
  11778. class: 'apexcharts-ycrosshairs'
  11779. });
  11780. w.globals.dom.elGraphical.add(ycrosshairs);
  11781. } // draw an invisible crosshair to help in positioning the yaxis tooltip
  11782. var ycrosshairsHidden = graphics.drawLine(-offX, 0, w.globals.gridWidth + offX, 0, crosshair.stroke.color, 0, 0);
  11783. ycrosshairsHidden.attr({
  11784. class: 'apexcharts-ycrosshairs-hidden'
  11785. });
  11786. w.globals.dom.elGraphical.add(ycrosshairsHidden);
  11787. }
  11788. }]);
  11789. return Crosshairs;
  11790. }();
  11791. /**
  11792. * ApexCharts Responsive Class to override options for different screen sizes.
  11793. *
  11794. * @module Responsive
  11795. **/
  11796. var Responsive = /*#__PURE__*/function () {
  11797. function Responsive(ctx) {
  11798. _classCallCheck(this, Responsive);
  11799. this.ctx = ctx;
  11800. this.w = ctx.w;
  11801. } // the opts parameter if not null has to be set overriding everything
  11802. // as the opts is set by user externally
  11803. _createClass(Responsive, [{
  11804. key: "checkResponsiveConfig",
  11805. value: function checkResponsiveConfig(opts) {
  11806. var _this = this;
  11807. var w = this.w;
  11808. var cnf = w.config; // check if responsive config exists
  11809. if (cnf.responsive.length === 0) return;
  11810. var res = cnf.responsive.slice();
  11811. res.sort(function (a, b) {
  11812. return a.breakpoint > b.breakpoint ? 1 : b.breakpoint > a.breakpoint ? -1 : 0;
  11813. }).reverse();
  11814. var config = new Config({});
  11815. var iterateResponsiveOptions = function iterateResponsiveOptions() {
  11816. var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11817. var largestBreakpoint = res[0].breakpoint;
  11818. var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
  11819. if (width > largestBreakpoint) {
  11820. var options = CoreUtils.extendArrayProps(config, w.globals.initialConfig, w);
  11821. newOptions = Utils$1.extend(options, newOptions);
  11822. newOptions = Utils$1.extend(w.config, newOptions);
  11823. _this.overrideResponsiveOptions(newOptions);
  11824. } else {
  11825. for (var i = 0; i < res.length; i++) {
  11826. if (width < res[i].breakpoint) {
  11827. newOptions = CoreUtils.extendArrayProps(config, res[i].options, w);
  11828. newOptions = Utils$1.extend(w.config, newOptions);
  11829. _this.overrideResponsiveOptions(newOptions);
  11830. }
  11831. }
  11832. }
  11833. };
  11834. if (opts) {
  11835. var options = CoreUtils.extendArrayProps(config, opts, w);
  11836. options = Utils$1.extend(w.config, options);
  11837. options = Utils$1.extend(options, opts);
  11838. iterateResponsiveOptions(options);
  11839. } else {
  11840. iterateResponsiveOptions({});
  11841. }
  11842. }
  11843. }, {
  11844. key: "overrideResponsiveOptions",
  11845. value: function overrideResponsiveOptions(newOptions) {
  11846. var newConfig = new Config(newOptions).init({
  11847. responsiveOverride: true
  11848. });
  11849. this.w.config = newConfig;
  11850. }
  11851. }]);
  11852. return Responsive;
  11853. }();
  11854. /**
  11855. * ApexCharts Theme Class for setting the colors and palettes.
  11856. *
  11857. * @module Theme
  11858. **/
  11859. var Theme = /*#__PURE__*/function () {
  11860. function Theme(ctx) {
  11861. _classCallCheck(this, Theme);
  11862. this.ctx = ctx;
  11863. this.colors = [];
  11864. this.w = ctx.w;
  11865. var w = this.w;
  11866. this.isColorFn = false;
  11867. this.isHeatmapDistributed = w.config.chart.type === 'treemap' && w.config.plotOptions.treemap.distributed || w.config.chart.type === 'heatmap' && w.config.plotOptions.heatmap.distributed;
  11868. this.isBarDistributed = w.config.plotOptions.bar.distributed && (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar');
  11869. }
  11870. _createClass(Theme, [{
  11871. key: "init",
  11872. value: function init() {
  11873. this.setDefaultColors();
  11874. }
  11875. }, {
  11876. key: "setDefaultColors",
  11877. value: function setDefaultColors() {
  11878. var _this = this;
  11879. var w = this.w;
  11880. var utils = new Utils$1();
  11881. w.globals.dom.elWrap.classList.add("apexcharts-theme-".concat(w.config.theme.mode));
  11882. if (w.config.colors === undefined) {
  11883. w.globals.colors = this.predefined();
  11884. } else {
  11885. w.globals.colors = w.config.colors; // if user provided a function in colors, we need to eval here
  11886. if (Array.isArray(w.config.colors) && w.config.colors.length > 0 && typeof w.config.colors[0] === 'function') {
  11887. w.globals.colors = w.config.series.map(function (s, i) {
  11888. var c = w.config.colors[i];
  11889. if (!c) c = w.config.colors[0];
  11890. if (typeof c === 'function') {
  11891. _this.isColorFn = true;
  11892. return c({
  11893. value: w.globals.axisCharts ? w.globals.series[i][0] ? w.globals.series[i][0] : 0 : w.globals.series[i],
  11894. seriesIndex: i,
  11895. dataPointIndex: i,
  11896. w: w
  11897. });
  11898. }
  11899. return c;
  11900. });
  11901. }
  11902. } // user defined colors in series array
  11903. w.globals.seriesColors.map(function (c, i) {
  11904. if (c) {
  11905. w.globals.colors[i] = c;
  11906. }
  11907. });
  11908. if (w.config.theme.monochrome.enabled) {
  11909. var monoArr = [];
  11910. var glsCnt = w.globals.series.length;
  11911. if (this.isBarDistributed || this.isHeatmapDistributed) {
  11912. glsCnt = w.globals.series[0].length * w.globals.series.length;
  11913. }
  11914. var mainColor = w.config.theme.monochrome.color;
  11915. var part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity);
  11916. var shade = w.config.theme.monochrome.shadeTo;
  11917. var percent = 0;
  11918. for (var gsl = 0; gsl < glsCnt; gsl++) {
  11919. var newColor = void 0;
  11920. if (shade === 'dark') {
  11921. newColor = utils.shadeColor(percent * -1, mainColor);
  11922. percent = percent + part;
  11923. } else {
  11924. newColor = utils.shadeColor(percent, mainColor);
  11925. percent = percent + part;
  11926. }
  11927. monoArr.push(newColor);
  11928. }
  11929. w.globals.colors = monoArr.slice();
  11930. }
  11931. var defaultColors = w.globals.colors.slice(); // if user specified fewer colors than no. of series, push the same colors again
  11932. this.pushExtraColors(w.globals.colors);
  11933. var colorTypes = ['fill', 'stroke'];
  11934. colorTypes.forEach(function (c) {
  11935. if (w.config[c].colors === undefined) {
  11936. w.globals[c].colors = _this.isColorFn ? w.config.colors : defaultColors;
  11937. } else {
  11938. w.globals[c].colors = w.config[c].colors.slice();
  11939. }
  11940. _this.pushExtraColors(w.globals[c].colors);
  11941. });
  11942. if (w.config.dataLabels.style.colors === undefined) {
  11943. w.globals.dataLabels.style.colors = defaultColors;
  11944. } else {
  11945. w.globals.dataLabels.style.colors = w.config.dataLabels.style.colors.slice();
  11946. }
  11947. this.pushExtraColors(w.globals.dataLabels.style.colors, 50);
  11948. if (w.config.plotOptions.radar.polygons.fill.colors === undefined) {
  11949. w.globals.radarPolygons.fill.colors = [w.config.theme.mode === 'dark' ? '#424242' : 'none'];
  11950. } else {
  11951. w.globals.radarPolygons.fill.colors = w.config.plotOptions.radar.polygons.fill.colors.slice();
  11952. }
  11953. this.pushExtraColors(w.globals.radarPolygons.fill.colors, 20); // The point colors
  11954. if (w.config.markers.colors === undefined) {
  11955. w.globals.markers.colors = defaultColors;
  11956. } else {
  11957. w.globals.markers.colors = w.config.markers.colors.slice();
  11958. }
  11959. this.pushExtraColors(w.globals.markers.colors);
  11960. } // When the number of colors provided is less than the number of series, this method
  11961. // will push same colors to the list
  11962. // params:
  11963. // distributed is only valid for distributed column/bar charts
  11964. }, {
  11965. key: "pushExtraColors",
  11966. value: function pushExtraColors(colorSeries, length) {
  11967. var distributed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11968. var w = this.w;
  11969. var len = length || w.globals.series.length;
  11970. if (distributed === null) {
  11971. distributed = this.isBarDistributed || this.isHeatmapDistributed || w.config.chart.type === 'heatmap' && w.config.plotOptions.heatmap.colorScale.inverse;
  11972. }
  11973. if (distributed && w.globals.series.length) {
  11974. len = w.globals.series[w.globals.maxValsInArrayIndex].length * w.globals.series.length;
  11975. }
  11976. if (colorSeries.length < len) {
  11977. var diff = len - colorSeries.length;
  11978. for (var i = 0; i < diff; i++) {
  11979. colorSeries.push(colorSeries[i]);
  11980. }
  11981. }
  11982. }
  11983. }, {
  11984. key: "updateThemeOptions",
  11985. value: function updateThemeOptions(options) {
  11986. options.chart = options.chart || {};
  11987. options.tooltip = options.tooltip || {};
  11988. var mode = options.theme.mode || 'light';
  11989. var palette = options.theme.palette ? options.theme.palette : mode === 'dark' ? 'palette4' : 'palette1';
  11990. var foreColor = options.chart.foreColor ? options.chart.foreColor : mode === 'dark' ? '#f6f7f8' : '#373d3f';
  11991. options.tooltip.theme = mode;
  11992. options.chart.foreColor = foreColor;
  11993. options.theme.palette = palette;
  11994. return options;
  11995. }
  11996. }, {
  11997. key: "predefined",
  11998. value: function predefined() {
  11999. var palette = this.w.config.theme.palette; // D6E3F8, FCEFEF, DCE0D9, A5978B, EDDDD4, D6E3F8, FEF5EF
  12000. switch (palette) {
  12001. case 'palette1':
  12002. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  12003. break;
  12004. case 'palette2':
  12005. this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800'];
  12006. break;
  12007. case 'palette3':
  12008. this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B'];
  12009. break;
  12010. case 'palette4':
  12011. this.colors = ['#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a', '#546E7A'];
  12012. break;
  12013. case 'palette5':
  12014. this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7'];
  12015. break;
  12016. case 'palette6':
  12017. this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D'];
  12018. break;
  12019. case 'palette7':
  12020. this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#E2C044'];
  12021. break;
  12022. case 'palette8':
  12023. this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD'];
  12024. break;
  12025. case 'palette9':
  12026. this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF'];
  12027. break;
  12028. case 'palette10':
  12029. this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2'];
  12030. break;
  12031. default:
  12032. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  12033. break;
  12034. }
  12035. return this.colors;
  12036. }
  12037. }]);
  12038. return Theme;
  12039. }();
  12040. var TitleSubtitle = /*#__PURE__*/function () {
  12041. function TitleSubtitle(ctx) {
  12042. _classCallCheck(this, TitleSubtitle);
  12043. this.ctx = ctx;
  12044. this.w = ctx.w;
  12045. }
  12046. _createClass(TitleSubtitle, [{
  12047. key: "draw",
  12048. value: function draw() {
  12049. this.drawTitleSubtitle('title');
  12050. this.drawTitleSubtitle('subtitle');
  12051. }
  12052. }, {
  12053. key: "drawTitleSubtitle",
  12054. value: function drawTitleSubtitle(type) {
  12055. var w = this.w;
  12056. var tsConfig = type === 'title' ? w.config.title : w.config.subtitle;
  12057. var x = w.globals.svgWidth / 2;
  12058. var y = tsConfig.offsetY;
  12059. var textAnchor = 'middle';
  12060. if (tsConfig.align === 'left') {
  12061. x = 10;
  12062. textAnchor = 'start';
  12063. } else if (tsConfig.align === 'right') {
  12064. x = w.globals.svgWidth - 10;
  12065. textAnchor = 'end';
  12066. }
  12067. x = x + tsConfig.offsetX;
  12068. y = y + parseInt(tsConfig.style.fontSize, 10) + tsConfig.margin / 2;
  12069. if (tsConfig.text !== undefined) {
  12070. var graphics = new Graphics(this.ctx);
  12071. var titleText = graphics.drawText({
  12072. x: x,
  12073. y: y,
  12074. text: tsConfig.text,
  12075. textAnchor: textAnchor,
  12076. fontSize: tsConfig.style.fontSize,
  12077. fontFamily: tsConfig.style.fontFamily,
  12078. fontWeight: tsConfig.style.fontWeight,
  12079. foreColor: tsConfig.style.color,
  12080. opacity: 1
  12081. });
  12082. titleText.node.setAttribute('class', "apexcharts-".concat(type, "-text"));
  12083. w.globals.dom.Paper.add(titleText);
  12084. }
  12085. }
  12086. }]);
  12087. return TitleSubtitle;
  12088. }();
  12089. var Helpers$2 = /*#__PURE__*/function () {
  12090. function Helpers(dCtx) {
  12091. _classCallCheck(this, Helpers);
  12092. this.w = dCtx.w;
  12093. this.dCtx = dCtx;
  12094. }
  12095. /**
  12096. * Get Chart Title/Subtitle Dimensions
  12097. * @memberof Dimensions
  12098. * @return {{width, height}}
  12099. **/
  12100. _createClass(Helpers, [{
  12101. key: "getTitleSubtitleCoords",
  12102. value: function getTitleSubtitleCoords(type) {
  12103. var w = this.w;
  12104. var width = 0;
  12105. var height = 0;
  12106. var floating = type === 'title' ? w.config.title.floating : w.config.subtitle.floating;
  12107. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-text"));
  12108. if (el !== null && !floating) {
  12109. var coord = el.getBoundingClientRect();
  12110. width = coord.width;
  12111. height = w.globals.axisCharts ? coord.height + 5 : coord.height;
  12112. }
  12113. return {
  12114. width: width,
  12115. height: height
  12116. };
  12117. }
  12118. }, {
  12119. key: "getLegendsRect",
  12120. value: function getLegendsRect() {
  12121. var w = this.w;
  12122. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  12123. if (!w.config.legend.height && (w.config.legend.position === 'top' || w.config.legend.position === 'bottom')) {
  12124. // avoid legend to take up all the space
  12125. elLegendWrap.style.maxHeight = w.globals.svgHeight / 2 + 'px';
  12126. }
  12127. var lgRect = Object.assign({}, Utils$1.getBoundingClientRect(elLegendWrap));
  12128. if (elLegendWrap !== null && !w.config.legend.floating && w.config.legend.show) {
  12129. this.dCtx.lgRect = {
  12130. x: lgRect.x,
  12131. y: lgRect.y,
  12132. height: lgRect.height,
  12133. width: lgRect.height === 0 ? 0 : lgRect.width
  12134. };
  12135. } else {
  12136. this.dCtx.lgRect = {
  12137. x: 0,
  12138. y: 0,
  12139. height: 0,
  12140. width: 0
  12141. };
  12142. } // if legend takes up all of the chart space, we need to restrict it.
  12143. if (w.config.legend.position === 'left' || w.config.legend.position === 'right') {
  12144. if (this.dCtx.lgRect.width * 1.5 > w.globals.svgWidth) {
  12145. this.dCtx.lgRect.width = w.globals.svgWidth / 1.5;
  12146. }
  12147. }
  12148. return this.dCtx.lgRect;
  12149. }
  12150. }, {
  12151. key: "getLargestStringFromMultiArr",
  12152. value: function getLargestStringFromMultiArr(val, arr) {
  12153. var w = this.w;
  12154. var valArr = val;
  12155. if (w.globals.isMultiLineX) {
  12156. // if the xaxis labels has multiline texts (array)
  12157. var maxArrs = arr.map(function (xl, idx) {
  12158. return Array.isArray(xl) ? xl.length : 1;
  12159. });
  12160. var maxArrLen = Math.max.apply(Math, _toConsumableArray(maxArrs));
  12161. var maxArrIndex = maxArrs.indexOf(maxArrLen);
  12162. valArr = arr[maxArrIndex];
  12163. }
  12164. return valArr;
  12165. }
  12166. }]);
  12167. return Helpers;
  12168. }();
  12169. var DimXAxis = /*#__PURE__*/function () {
  12170. function DimXAxis(dCtx) {
  12171. _classCallCheck(this, DimXAxis);
  12172. this.w = dCtx.w;
  12173. this.dCtx = dCtx;
  12174. }
  12175. /**
  12176. * Get X Axis Dimensions
  12177. * @memberof Dimensions
  12178. * @return {{width, height}}
  12179. **/
  12180. _createClass(DimXAxis, [{
  12181. key: "getxAxisLabelsCoords",
  12182. value: function getxAxisLabelsCoords() {
  12183. var w = this.w;
  12184. var xaxisLabels = w.globals.labels.slice();
  12185. if (w.config.xaxis.convertedCatToNumeric && xaxisLabels.length === 0) {
  12186. xaxisLabels = w.globals.categoryLabels;
  12187. }
  12188. var rect;
  12189. if (w.globals.timescaleLabels.length > 0) {
  12190. var coords = this.getxAxisTimeScaleLabelsCoords();
  12191. rect = {
  12192. width: coords.width,
  12193. height: coords.height
  12194. };
  12195. w.globals.rotateXLabels = false;
  12196. } else {
  12197. 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
  12198. var xlbFormatter = w.globals.xLabelFormatter; // prevent changing xaxisLabels to avoid issues in multi-yaxes - fix #522
  12199. var val = Utils$1.getLargestStringFromArr(xaxisLabels);
  12200. var valArr = this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, xaxisLabels); // the labels gets changed for bar charts
  12201. if (w.globals.isBarHorizontal) {
  12202. val = w.globals.yAxisScale[0].result.reduce(function (a, b) {
  12203. return a.length > b.length ? a : b;
  12204. }, 0);
  12205. valArr = val;
  12206. }
  12207. var xFormat = new Formatters(this.dCtx.ctx);
  12208. var timestamp = val;
  12209. val = xFormat.xLabelFormat(xlbFormatter, val, timestamp, {
  12210. i: undefined,
  12211. dateFormatter: new DateTime(this.dCtx.ctx).formatDate,
  12212. w: w
  12213. });
  12214. valArr = xFormat.xLabelFormat(xlbFormatter, valArr, timestamp, {
  12215. i: undefined,
  12216. dateFormatter: new DateTime(this.dCtx.ctx).formatDate,
  12217. w: w
  12218. });
  12219. if (w.config.xaxis.convertedCatToNumeric && typeof val === 'undefined' || String(val).trim() === '') {
  12220. val = '1';
  12221. valArr = val;
  12222. }
  12223. var graphics = new Graphics(this.dCtx.ctx);
  12224. var xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  12225. var xArrLabelrect = xLabelrect;
  12226. if (val !== valArr) {
  12227. xArrLabelrect = graphics.getTextRects(valArr, w.config.xaxis.labels.style.fontSize);
  12228. }
  12229. rect = {
  12230. width: xLabelrect.width >= xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width,
  12231. height: xLabelrect.height >= xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height
  12232. };
  12233. 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) {
  12234. if (!w.globals.isBarHorizontal) {
  12235. w.globals.rotateXLabels = true;
  12236. var getRotatedTextRects = function getRotatedTextRects(text) {
  12237. 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);
  12238. };
  12239. xLabelrect = getRotatedTextRects(val);
  12240. if (val !== valArr) {
  12241. xArrLabelrect = getRotatedTextRects(valArr);
  12242. }
  12243. rect.height = (xLabelrect.height > xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height) / 1.5;
  12244. rect.width = xLabelrect.width > xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width;
  12245. }
  12246. } else {
  12247. w.globals.rotateXLabels = false;
  12248. }
  12249. }
  12250. if (!w.config.xaxis.labels.show) {
  12251. rect = {
  12252. width: 0,
  12253. height: 0
  12254. };
  12255. }
  12256. return {
  12257. width: rect.width,
  12258. height: rect.height
  12259. };
  12260. }
  12261. /**
  12262. * Get X Axis Label Group height
  12263. * @memberof Dimensions
  12264. * @return {{width, height}}
  12265. */
  12266. }, {
  12267. key: "getxAxisGroupLabelsCoords",
  12268. value: function getxAxisGroupLabelsCoords() {
  12269. var _w$config$xaxis$group;
  12270. var w = this.w;
  12271. if (!w.globals.hasGroups) {
  12272. return {
  12273. width: 0,
  12274. height: 0
  12275. };
  12276. }
  12277. var fontSize = ((_w$config$xaxis$group = w.config.xaxis.group.style) === null || _w$config$xaxis$group === void 0 ? void 0 : _w$config$xaxis$group.fontSize) || w.config.xaxis.labels.style.fontSize;
  12278. var xaxisLabels = w.globals.groups.map(function (g) {
  12279. return g.title;
  12280. });
  12281. var rect; // prevent changing xaxisLabels to avoid issues in multi-yaxes - fix #522
  12282. var val = Utils$1.getLargestStringFromArr(xaxisLabels);
  12283. var valArr = this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, xaxisLabels);
  12284. var graphics = new Graphics(this.dCtx.ctx);
  12285. var xLabelrect = graphics.getTextRects(val, fontSize);
  12286. var xArrLabelrect = xLabelrect;
  12287. if (val !== valArr) {
  12288. xArrLabelrect = graphics.getTextRects(valArr, fontSize);
  12289. }
  12290. rect = {
  12291. width: xLabelrect.width >= xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width,
  12292. height: xLabelrect.height >= xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height
  12293. };
  12294. if (!w.config.xaxis.labels.show) {
  12295. rect = {
  12296. width: 0,
  12297. height: 0
  12298. };
  12299. }
  12300. return {
  12301. width: rect.width,
  12302. height: rect.height
  12303. };
  12304. }
  12305. /**
  12306. * Get X Axis Title Dimensions
  12307. * @memberof Dimensions
  12308. * @return {{width, height}}
  12309. **/
  12310. }, {
  12311. key: "getxAxisTitleCoords",
  12312. value: function getxAxisTitleCoords() {
  12313. var w = this.w;
  12314. var width = 0;
  12315. var height = 0;
  12316. if (w.config.xaxis.title.text !== undefined) {
  12317. var graphics = new Graphics(this.dCtx.ctx);
  12318. var rect = graphics.getTextRects(w.config.xaxis.title.text, w.config.xaxis.title.style.fontSize);
  12319. width = rect.width;
  12320. height = rect.height;
  12321. }
  12322. return {
  12323. width: width,
  12324. height: height
  12325. };
  12326. }
  12327. }, {
  12328. key: "getxAxisTimeScaleLabelsCoords",
  12329. value: function getxAxisTimeScaleLabelsCoords() {
  12330. var w = this.w;
  12331. var rect;
  12332. this.dCtx.timescaleLabels = w.globals.timescaleLabels.slice();
  12333. var labels = this.dCtx.timescaleLabels.map(function (label) {
  12334. return label.value;
  12335. }); // get the longest string from the labels array and also apply label formatter to it
  12336. var val = labels.reduce(function (a, b) {
  12337. // if undefined, maybe user didn't pass the datetime(x) values
  12338. if (typeof a === 'undefined') {
  12339. console.error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date');
  12340. return 0;
  12341. } else {
  12342. return a.length > b.length ? a : b;
  12343. }
  12344. }, 0);
  12345. var graphics = new Graphics(this.dCtx.ctx);
  12346. rect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  12347. var totalWidthRotated = rect.width * 1.05 * labels.length;
  12348. if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) {
  12349. w.globals.overlappingXLabels = true;
  12350. }
  12351. return rect;
  12352. } // In certain cases, the last labels gets cropped in xaxis.
  12353. // 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
  12354. }, {
  12355. key: "additionalPaddingXLabels",
  12356. value: function additionalPaddingXLabels(xaxisLabelCoords) {
  12357. var _this = this;
  12358. var w = this.w;
  12359. var gl = w.globals;
  12360. var cnf = w.config;
  12361. var xtype = cnf.xaxis.type;
  12362. var lbWidth = xaxisLabelCoords.width;
  12363. gl.skipLastTimelinelabel = false;
  12364. gl.skipFirstTimelinelabel = false;
  12365. var isBarOpposite = w.config.yaxis[0].opposite && w.globals.isBarHorizontal;
  12366. var isCollapsed = function isCollapsed(i) {
  12367. return gl.collapsedSeriesIndices.indexOf(i) !== -1;
  12368. };
  12369. var rightPad = function rightPad(yaxe) {
  12370. if (_this.dCtx.timescaleLabels && _this.dCtx.timescaleLabels.length) {
  12371. // for timeline labels, we take the last label and check if it exceeds gridWidth
  12372. var firstimescaleLabel = _this.dCtx.timescaleLabels[0];
  12373. var lastTimescaleLabel = _this.dCtx.timescaleLabels[_this.dCtx.timescaleLabels.length - 1];
  12374. var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 - _this.dCtx.yAxisWidthRight;
  12375. var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 + _this.dCtx.yAxisWidthLeft;
  12376. var lgRightRectWidth = w.config.legend.position === 'right' && _this.dCtx.lgRect.width > 0 ? _this.dCtx.lgRect.width : 0;
  12377. if (lastLabelPosition > gl.svgWidth - gl.translateX - lgRightRectWidth) {
  12378. gl.skipLastTimelinelabel = true;
  12379. }
  12380. if (firstLabelPosition < -((!yaxe.show || yaxe.floating) && (cnf.chart.type === 'bar' || cnf.chart.type === 'candlestick' || cnf.chart.type === 'rangeBar' || cnf.chart.type === 'boxPlot') ? lbWidth / 1.75 : 10)) {
  12381. gl.skipFirstTimelinelabel = true;
  12382. }
  12383. } else if (xtype === 'datetime') {
  12384. // If user has enabled DateTime, but uses own's formatter
  12385. if (_this.dCtx.gridPad.right < lbWidth && !gl.rotateXLabels) {
  12386. gl.skipLastTimelinelabel = true;
  12387. }
  12388. } else if (xtype !== 'datetime') {
  12389. if (_this.dCtx.gridPad.right < lbWidth / 2 - _this.dCtx.yAxisWidthRight && !gl.rotateXLabels && !w.config.xaxis.labels.trim && (w.config.xaxis.tickPlacement !== 'between' || w.globals.isBarHorizontal)) {
  12390. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  12391. }
  12392. }
  12393. };
  12394. var padYAxe = function padYAxe(yaxe, i) {
  12395. if (isCollapsed(i)) return; // the code below causes issue apexcharts.js#1989
  12396. // after testing with other use-cases, this has no actual value, hence commented
  12397. // if (xtype !== 'datetime') {
  12398. // if (
  12399. // this.dCtx.gridPad.left < lbWidth / 2 - this.dCtx.yAxisWidthLeft &&
  12400. // !gl.rotateXLabels &&
  12401. // !cnf.xaxis.labels.trim
  12402. // ) {
  12403. // this.dCtx.xPadLeft = lbWidth / 2 + 1
  12404. // }
  12405. // }
  12406. rightPad(yaxe);
  12407. };
  12408. cnf.yaxis.forEach(function (yaxe, i) {
  12409. if (isBarOpposite) {
  12410. if (_this.dCtx.gridPad.left < lbWidth) {
  12411. _this.dCtx.xPadLeft = lbWidth / 2 + 1;
  12412. }
  12413. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  12414. } else {
  12415. padYAxe(yaxe, i);
  12416. }
  12417. });
  12418. }
  12419. }]);
  12420. return DimXAxis;
  12421. }();
  12422. var DimYAxis = /*#__PURE__*/function () {
  12423. function DimYAxis(dCtx) {
  12424. _classCallCheck(this, DimYAxis);
  12425. this.w = dCtx.w;
  12426. this.dCtx = dCtx;
  12427. }
  12428. /**
  12429. * Get Y Axis Dimensions
  12430. * @memberof Dimensions
  12431. * @return {{width, height}}
  12432. **/
  12433. _createClass(DimYAxis, [{
  12434. key: "getyAxisLabelsCoords",
  12435. value: function getyAxisLabelsCoords() {
  12436. var _this = this;
  12437. var w = this.w;
  12438. var width = 0;
  12439. var height = 0;
  12440. var ret = [];
  12441. var labelPad = 10;
  12442. var axesUtils = new AxesUtils(this.dCtx.ctx);
  12443. w.config.yaxis.map(function (yaxe, index) {
  12444. var yS = w.globals.yAxisScale[index];
  12445. var yAxisMinWidth = 0;
  12446. if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && yaxe.labels.minWidth !== undefined) yAxisMinWidth = yaxe.labels.minWidth;
  12447. if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && yS.result.length) {
  12448. var lbFormatter = w.globals.yLabelFormatters[index];
  12449. var minV = yS.niceMin === Number.MIN_VALUE ? 0 : yS.niceMin;
  12450. var longestStr = String(minV).length > String(yS.niceMax).length ? minV : yS.niceMax; // the second parameter -1 is the index of tick which user can use in the formatter
  12451. var val = lbFormatter(longestStr, {
  12452. seriesIndex: index,
  12453. dataPointIndex: -1,
  12454. w: w
  12455. });
  12456. 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.
  12457. if (typeof val === 'undefined' || val.length === 0) {
  12458. val = longestStr;
  12459. }
  12460. if (w.globals.isBarHorizontal) {
  12461. labelPad = 0;
  12462. var barYaxisLabels = w.globals.labels.slice(); // get the longest string from the labels array and also apply label formatter to it
  12463. val = Utils$1.getLargestStringFromArr(barYaxisLabels);
  12464. val = lbFormatter(val, {
  12465. seriesIndex: index,
  12466. dataPointIndex: -1,
  12467. w: w
  12468. });
  12469. valArr = _this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, barYaxisLabels);
  12470. }
  12471. var graphics = new Graphics(_this.dCtx.ctx);
  12472. var rotateStr = 'rotate('.concat(yaxe.labels.rotate, ' 0 0)');
  12473. var rect = graphics.getTextRects(val, yaxe.labels.style.fontSize, yaxe.labels.style.fontFamily, rotateStr, false);
  12474. var arrLabelrect = rect;
  12475. if (val !== valArr) {
  12476. arrLabelrect = graphics.getTextRects(valArr, yaxe.labels.style.fontSize, yaxe.labels.style.fontFamily, rotateStr, false);
  12477. }
  12478. ret.push({
  12479. width: (yAxisMinWidth > arrLabelrect.width || yAxisMinWidth > rect.width ? yAxisMinWidth : arrLabelrect.width > rect.width ? arrLabelrect.width : rect.width) + labelPad,
  12480. height: arrLabelrect.height > rect.height ? arrLabelrect.height : rect.height
  12481. });
  12482. } else {
  12483. ret.push({
  12484. width: width,
  12485. height: height
  12486. });
  12487. }
  12488. });
  12489. return ret;
  12490. }
  12491. /**
  12492. * Get Y Axis Dimensions
  12493. * @memberof Dimensions
  12494. * @return {{width, height}}
  12495. **/
  12496. }, {
  12497. key: "getyAxisTitleCoords",
  12498. value: function getyAxisTitleCoords() {
  12499. var _this2 = this;
  12500. var w = this.w;
  12501. var ret = [];
  12502. w.config.yaxis.map(function (yaxe, index) {
  12503. if (yaxe.show && yaxe.title.text !== undefined) {
  12504. var graphics = new Graphics(_this2.dCtx.ctx);
  12505. var rotateStr = 'rotate('.concat(yaxe.title.rotate, ' 0 0)');
  12506. var rect = graphics.getTextRects(yaxe.title.text, yaxe.title.style.fontSize, yaxe.title.style.fontFamily, rotateStr, false);
  12507. ret.push({
  12508. width: rect.width,
  12509. height: rect.height
  12510. });
  12511. } else {
  12512. ret.push({
  12513. width: 0,
  12514. height: 0
  12515. });
  12516. }
  12517. });
  12518. return ret;
  12519. }
  12520. }, {
  12521. key: "getTotalYAxisWidth",
  12522. value: function getTotalYAxisWidth() {
  12523. var w = this.w;
  12524. var yAxisWidth = 0;
  12525. var yAxisWidthLeft = 0;
  12526. var yAxisWidthRight = 0;
  12527. var padding = w.globals.yAxisScale.length > 1 ? 10 : 0;
  12528. var axesUtils = new AxesUtils(this.dCtx.ctx);
  12529. var isHiddenYAxis = function isHiddenYAxis(index) {
  12530. return w.globals.ignoreYAxisIndexes.indexOf(index) > -1;
  12531. };
  12532. var padForLabelTitle = function padForLabelTitle(coord, index) {
  12533. var floating = w.config.yaxis[index].floating;
  12534. var width = 0;
  12535. if (coord.width > 0 && !floating) {
  12536. width = coord.width + padding;
  12537. if (isHiddenYAxis(index)) {
  12538. width = width - coord.width - padding;
  12539. }
  12540. } else {
  12541. width = floating || axesUtils.isYAxisHidden(index) ? 0 : 5;
  12542. }
  12543. w.config.yaxis[index].opposite ? yAxisWidthRight = yAxisWidthRight + width : yAxisWidthLeft = yAxisWidthLeft + width;
  12544. yAxisWidth = yAxisWidth + width;
  12545. };
  12546. w.globals.yLabelsCoords.map(function (yLabelCoord, index) {
  12547. padForLabelTitle(yLabelCoord, index);
  12548. });
  12549. w.globals.yTitleCoords.map(function (yTitleCoord, index) {
  12550. padForLabelTitle(yTitleCoord, index);
  12551. });
  12552. if (w.globals.isBarHorizontal && !w.config.yaxis[0].floating) {
  12553. yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15;
  12554. }
  12555. this.dCtx.yAxisWidthLeft = yAxisWidthLeft;
  12556. this.dCtx.yAxisWidthRight = yAxisWidthRight;
  12557. return yAxisWidth;
  12558. }
  12559. }]);
  12560. return DimYAxis;
  12561. }();
  12562. var DimGrid = /*#__PURE__*/function () {
  12563. function DimGrid(dCtx) {
  12564. _classCallCheck(this, DimGrid);
  12565. this.w = dCtx.w;
  12566. this.dCtx = dCtx;
  12567. }
  12568. _createClass(DimGrid, [{
  12569. key: "gridPadForColumnsInNumericAxis",
  12570. value: function gridPadForColumnsInNumericAxis(gridWidth) {
  12571. var w = this.w;
  12572. if (w.globals.noData || w.globals.allSeriesCollapsed) {
  12573. return 0;
  12574. }
  12575. var hasBar = function hasBar(type) {
  12576. return type === 'bar' || type === 'rangeBar' || type === 'candlestick' || type === 'boxPlot';
  12577. };
  12578. var type = w.config.chart.type;
  12579. var barWidth = 0;
  12580. var seriesLen = hasBar(type) ? w.config.series.length : 1;
  12581. if (w.globals.comboBarCount > 0) {
  12582. seriesLen = w.globals.comboBarCount;
  12583. }
  12584. w.globals.collapsedSeries.forEach(function (c) {
  12585. if (hasBar(c.type)) {
  12586. seriesLen = seriesLen - 1;
  12587. }
  12588. });
  12589. if (w.config.chart.stacked) {
  12590. seriesLen = 1;
  12591. }
  12592. var barsPresent = hasBar(type) || w.globals.comboBarCount > 0;
  12593. if (barsPresent && w.globals.isXNumeric && !w.globals.isBarHorizontal && seriesLen > 0) {
  12594. var xRatio = 0;
  12595. var xRange = Math.abs(w.globals.initialMaxX - w.globals.initialMinX);
  12596. if (xRange <= 3) {
  12597. xRange = w.globals.dataPoints;
  12598. }
  12599. xRatio = xRange / gridWidth;
  12600. var xDivision; // max barwidth should be equal to minXDiff to avoid overlap
  12601. if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
  12602. xDivision = w.globals.minXDiff / xRatio;
  12603. }
  12604. if (xDivision > gridWidth / 2) {
  12605. xDivision = xDivision / 2;
  12606. }
  12607. barWidth = xDivision / seriesLen * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  12608. if (barWidth < 1) {
  12609. barWidth = 1;
  12610. }
  12611. barWidth = barWidth / (seriesLen > 1 ? 1 : 1.5) + 5;
  12612. w.globals.barPadForNumericAxis = barWidth;
  12613. }
  12614. return barWidth;
  12615. }
  12616. }, {
  12617. key: "gridPadFortitleSubtitle",
  12618. value: function gridPadFortitleSubtitle() {
  12619. var _this = this;
  12620. var w = this.w;
  12621. var gl = w.globals;
  12622. var gridShrinkOffset = this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 10;
  12623. var titleSubtitle = ['title', 'subtitle'];
  12624. titleSubtitle.forEach(function (t) {
  12625. if (w.config[t].text !== undefined) {
  12626. gridShrinkOffset += w.config[t].margin;
  12627. } else {
  12628. gridShrinkOffset += _this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 5;
  12629. }
  12630. });
  12631. if (w.config.legend.show && w.config.legend.position === 'bottom' && !w.config.legend.floating && !w.globals.axisCharts) {
  12632. gridShrinkOffset += 10;
  12633. }
  12634. var titleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('title');
  12635. var subtitleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('subtitle');
  12636. gl.gridHeight = gl.gridHeight - titleCoords.height - subtitleCoords.height - gridShrinkOffset;
  12637. gl.translateY = gl.translateY + titleCoords.height + subtitleCoords.height + gridShrinkOffset;
  12638. }
  12639. }, {
  12640. key: "setGridXPosForDualYAxis",
  12641. value: function setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords) {
  12642. var w = this.w;
  12643. var axesUtils = new AxesUtils(this.dCtx.ctx);
  12644. w.config.yaxis.map(function (yaxe, index) {
  12645. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1 && !yaxe.floating && !axesUtils.isYAxisHidden(index)) {
  12646. if (yaxe.opposite) {
  12647. w.globals.translateX = w.globals.translateX - (yaxisLabelCoords[index].width + yTitleCoords[index].width) - parseInt(w.config.yaxis[index].labels.style.fontSize, 10) / 1.2 - 12;
  12648. } // fixes apexcharts.js#1599
  12649. if (w.globals.translateX < 2) {
  12650. w.globals.translateX = 2;
  12651. }
  12652. }
  12653. });
  12654. }
  12655. }]);
  12656. return DimGrid;
  12657. }();
  12658. /**
  12659. * ApexCharts Dimensions Class for calculating rects of all elements that are drawn and will be drawn.
  12660. *
  12661. * @module Dimensions
  12662. **/
  12663. var Dimensions = /*#__PURE__*/function () {
  12664. function Dimensions(ctx) {
  12665. _classCallCheck(this, Dimensions);
  12666. this.ctx = ctx;
  12667. this.w = ctx.w;
  12668. this.lgRect = {};
  12669. this.yAxisWidth = 0;
  12670. this.yAxisWidthLeft = 0;
  12671. this.yAxisWidthRight = 0;
  12672. this.xAxisHeight = 0;
  12673. this.isSparkline = this.w.config.chart.sparkline.enabled;
  12674. this.dimHelpers = new Helpers$2(this);
  12675. this.dimYAxis = new DimYAxis(this);
  12676. this.dimXAxis = new DimXAxis(this);
  12677. this.dimGrid = new DimGrid(this);
  12678. this.lgWidthForSideLegends = 0;
  12679. this.gridPad = this.w.config.grid.padding;
  12680. this.xPadRight = 0;
  12681. this.xPadLeft = 0;
  12682. }
  12683. /**
  12684. * @memberof Dimensions
  12685. * @param {object} w - chart context
  12686. **/
  12687. _createClass(Dimensions, [{
  12688. key: "plotCoords",
  12689. value: function plotCoords() {
  12690. var _this = this;
  12691. var w = this.w;
  12692. var gl = w.globals;
  12693. this.lgRect = this.dimHelpers.getLegendsRect();
  12694. if (this.isSparkline && (w.config.markers.discrete.length > 0 || w.config.markers.size > 0)) {
  12695. Object.entries(this.gridPad).forEach(function (_ref) {
  12696. var _ref2 = _slicedToArray(_ref, 2),
  12697. k = _ref2[0],
  12698. v = _ref2[1];
  12699. _this.gridPad[k] = Math.max(v, _this.w.globals.markers.largestSize / 1.5);
  12700. });
  12701. }
  12702. if (gl.axisCharts) {
  12703. // for line / area / scatter / column
  12704. this.setDimensionsForAxisCharts();
  12705. } else {
  12706. // for pie / donuts / circle
  12707. this.setDimensionsForNonAxisCharts();
  12708. }
  12709. this.dimGrid.gridPadFortitleSubtitle(); // after calculating everything, apply padding set by user
  12710. gl.gridHeight = gl.gridHeight - this.gridPad.top - this.gridPad.bottom;
  12711. gl.gridWidth = gl.gridWidth - this.gridPad.left - this.gridPad.right - this.xPadRight - this.xPadLeft;
  12712. var barWidth = this.dimGrid.gridPadForColumnsInNumericAxis(gl.gridWidth);
  12713. gl.gridWidth = gl.gridWidth - barWidth * 2;
  12714. gl.translateX = gl.translateX + this.gridPad.left + this.xPadLeft + (barWidth > 0 ? barWidth + 4 : 0);
  12715. gl.translateY = gl.translateY + this.gridPad.top;
  12716. }
  12717. }, {
  12718. key: "setDimensionsForAxisCharts",
  12719. value: function setDimensionsForAxisCharts() {
  12720. var _this2 = this;
  12721. var w = this.w;
  12722. var gl = w.globals;
  12723. var yaxisLabelCoords = this.dimYAxis.getyAxisLabelsCoords();
  12724. var yTitleCoords = this.dimYAxis.getyAxisTitleCoords();
  12725. w.globals.yLabelsCoords = [];
  12726. w.globals.yTitleCoords = [];
  12727. w.config.yaxis.map(function (yaxe, index) {
  12728. // store the labels and titles coords in global vars
  12729. w.globals.yLabelsCoords.push({
  12730. width: yaxisLabelCoords[index].width,
  12731. index: index
  12732. });
  12733. w.globals.yTitleCoords.push({
  12734. width: yTitleCoords[index].width,
  12735. index: index
  12736. });
  12737. });
  12738. this.yAxisWidth = this.dimYAxis.getTotalYAxisWidth();
  12739. var xaxisLabelCoords = this.dimXAxis.getxAxisLabelsCoords();
  12740. var xaxisGroupLabelCoords = this.dimXAxis.getxAxisGroupLabelsCoords();
  12741. var xtitleCoords = this.dimXAxis.getxAxisTitleCoords();
  12742. this.conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords, xaxisGroupLabelCoords);
  12743. gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4;
  12744. gl.translateXAxisX = w.globals.rotateXLabels && w.globals.isXNumeric && w.config.xaxis.labels.rotate <= -45 ? -this.xAxisWidth / 4 : 0;
  12745. if (w.globals.isBarHorizontal) {
  12746. gl.rotateXLabels = false;
  12747. gl.translateXAxisY = -1 * (parseInt(w.config.xaxis.labels.style.fontSize, 10) / 1.5);
  12748. }
  12749. gl.translateXAxisY = gl.translateXAxisY + w.config.xaxis.labels.offsetY;
  12750. gl.translateXAxisX = gl.translateXAxisX + w.config.xaxis.labels.offsetX;
  12751. var yAxisWidth = this.yAxisWidth;
  12752. var xAxisHeight = this.xAxisHeight;
  12753. gl.xAxisLabelsHeight = this.xAxisHeight - xtitleCoords.height;
  12754. gl.xAxisGroupLabelsHeight = gl.xAxisLabelsHeight - xaxisLabelCoords.height;
  12755. gl.xAxisLabelsWidth = this.xAxisWidth;
  12756. gl.xAxisHeight = this.xAxisHeight;
  12757. var translateY = 10;
  12758. if (w.config.chart.type === 'radar' || this.isSparkline) {
  12759. yAxisWidth = 0;
  12760. xAxisHeight = gl.goldenPadding;
  12761. }
  12762. if (this.isSparkline) {
  12763. this.lgRect = {
  12764. height: 0,
  12765. width: 0
  12766. };
  12767. }
  12768. if (this.isSparkline || w.config.chart.type === 'treemap') {
  12769. yAxisWidth = 0;
  12770. xAxisHeight = 0;
  12771. translateY = 0;
  12772. }
  12773. if (!this.isSparkline) {
  12774. this.dimXAxis.additionalPaddingXLabels(xaxisLabelCoords);
  12775. }
  12776. var legendTopBottom = function legendTopBottom() {
  12777. gl.translateX = yAxisWidth;
  12778. gl.gridHeight = gl.svgHeight - _this2.lgRect.height - xAxisHeight - (!_this2.isSparkline && w.config.chart.type !== 'treemap' ? w.globals.rotateXLabels ? 10 : 15 : 0);
  12779. gl.gridWidth = gl.svgWidth - yAxisWidth;
  12780. };
  12781. if (w.config.xaxis.position === 'top') translateY = gl.xAxisHeight - w.config.xaxis.axisTicks.height - 5;
  12782. switch (w.config.legend.position) {
  12783. case 'bottom':
  12784. gl.translateY = translateY;
  12785. legendTopBottom();
  12786. break;
  12787. case 'top':
  12788. gl.translateY = this.lgRect.height + translateY;
  12789. legendTopBottom();
  12790. break;
  12791. case 'left':
  12792. gl.translateY = translateY;
  12793. gl.translateX = this.lgRect.width + yAxisWidth;
  12794. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  12795. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth;
  12796. break;
  12797. case 'right':
  12798. gl.translateY = translateY;
  12799. gl.translateX = yAxisWidth;
  12800. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  12801. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth - 5;
  12802. break;
  12803. default:
  12804. throw new Error('Legend position not supported');
  12805. }
  12806. this.dimGrid.setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords); // after drawing everything, set the Y axis positions
  12807. var objyAxis = new YAxis(this.ctx);
  12808. objyAxis.setYAxisXPosition(yaxisLabelCoords, yTitleCoords);
  12809. }
  12810. }, {
  12811. key: "setDimensionsForNonAxisCharts",
  12812. value: function setDimensionsForNonAxisCharts() {
  12813. var w = this.w;
  12814. var gl = w.globals;
  12815. var cnf = w.config;
  12816. var xPad = 0;
  12817. if (w.config.legend.show && !w.config.legend.floating) {
  12818. xPad = 20;
  12819. }
  12820. var type = cnf.chart.type === 'pie' || cnf.chart.type === 'polarArea' || cnf.chart.type === 'donut' ? 'pie' : 'radialBar';
  12821. var offY = cnf.plotOptions[type].offsetY;
  12822. var offX = cnf.plotOptions[type].offsetX;
  12823. if (!cnf.legend.show || cnf.legend.floating) {
  12824. gl.gridHeight = gl.svgHeight - cnf.grid.padding.left + cnf.grid.padding.right;
  12825. gl.gridWidth = gl.gridHeight;
  12826. gl.translateY = offY;
  12827. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12828. return;
  12829. }
  12830. switch (cnf.legend.position) {
  12831. case 'bottom':
  12832. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  12833. gl.gridWidth = gl.svgWidth;
  12834. gl.translateY = offY - 10;
  12835. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12836. break;
  12837. case 'top':
  12838. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  12839. gl.gridWidth = gl.svgWidth;
  12840. gl.translateY = this.lgRect.height + offY + 10;
  12841. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12842. break;
  12843. case 'left':
  12844. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad;
  12845. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  12846. gl.translateY = offY;
  12847. gl.translateX = offX + this.lgRect.width + xPad;
  12848. break;
  12849. case 'right':
  12850. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad - 5;
  12851. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  12852. gl.translateY = offY;
  12853. gl.translateX = offX + 10;
  12854. break;
  12855. default:
  12856. throw new Error('Legend position not supported');
  12857. }
  12858. }
  12859. }, {
  12860. key: "conditionalChecksForAxisCoords",
  12861. value: function conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords, xaxisGroupLabelCoords) {
  12862. var w = this.w;
  12863. var xAxisNum = w.globals.hasGroups ? 2 : 1;
  12864. var baseXAxisHeight = xaxisGroupLabelCoords.height + xaxisLabelCoords.height + xtitleCoords.height;
  12865. var xAxisHeightMultiplicate = w.globals.isMultiLineX ? 1.2 : w.globals.LINE_HEIGHT_RATIO;
  12866. var rotatedXAxisOffset = w.globals.rotateXLabels ? 22 : 10;
  12867. var rotatedXAxisLegendOffset = w.globals.rotateXLabels && w.config.legend.position === 'bottom';
  12868. var additionalOffset = rotatedXAxisLegendOffset ? 10 : 0;
  12869. this.xAxisHeight = baseXAxisHeight * xAxisHeightMultiplicate + xAxisNum * rotatedXAxisOffset + additionalOffset;
  12870. this.xAxisWidth = xaxisLabelCoords.width;
  12871. if (this.xAxisHeight - xtitleCoords.height > w.config.xaxis.labels.maxHeight) {
  12872. this.xAxisHeight = w.config.xaxis.labels.maxHeight;
  12873. }
  12874. if (w.config.xaxis.labels.minHeight && this.xAxisHeight < w.config.xaxis.labels.minHeight) {
  12875. this.xAxisHeight = w.config.xaxis.labels.minHeight;
  12876. }
  12877. if (w.config.xaxis.floating) {
  12878. this.xAxisHeight = 0;
  12879. }
  12880. var minYAxisWidth = 0;
  12881. var maxYAxisWidth = 0;
  12882. w.config.yaxis.forEach(function (y) {
  12883. minYAxisWidth += y.labels.minWidth;
  12884. maxYAxisWidth += y.labels.maxWidth;
  12885. });
  12886. if (this.yAxisWidth < minYAxisWidth) {
  12887. this.yAxisWidth = minYAxisWidth;
  12888. }
  12889. if (this.yAxisWidth > maxYAxisWidth) {
  12890. this.yAxisWidth = maxYAxisWidth;
  12891. }
  12892. }
  12893. }]);
  12894. return Dimensions;
  12895. }();
  12896. var Helpers$1 = /*#__PURE__*/function () {
  12897. function Helpers(lgCtx) {
  12898. _classCallCheck(this, Helpers);
  12899. this.w = lgCtx.w;
  12900. this.lgCtx = lgCtx;
  12901. }
  12902. _createClass(Helpers, [{
  12903. key: "getLegendStyles",
  12904. value: function getLegendStyles() {
  12905. var stylesheet = document.createElement('style');
  12906. stylesheet.setAttribute('type', 'text/css');
  12907. 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.apx-legend-position-bottom, .apexcharts-legend.apx-legend-position-top {\t\n flex-wrap: wrap\t\n }\t\n .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n flex-direction: column;\t\n bottom: 0;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-left, .apexcharts-legend.apx-legend-position-top.apexcharts-align-left, .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n justify-content: flex-start;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-center, .apexcharts-legend.apx-legend-position-top.apexcharts-align-center {\t\n justify-content: center; \t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-right, .apexcharts-legend.apx-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.apx-legend-position-bottom .apexcharts-legend-series, .apexcharts-legend.apx-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 }";
  12908. var rules = document.createTextNode(text);
  12909. stylesheet.appendChild(rules);
  12910. return stylesheet;
  12911. }
  12912. }, {
  12913. key: "getLegendBBox",
  12914. value: function getLegendBBox() {
  12915. var w = this.w;
  12916. var currLegendsWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  12917. var currLegendsWrapRect = currLegendsWrap.getBoundingClientRect();
  12918. var currLegendsWrapWidth = currLegendsWrapRect.width;
  12919. var currLegendsWrapHeight = currLegendsWrapRect.height;
  12920. return {
  12921. clwh: currLegendsWrapHeight,
  12922. clww: currLegendsWrapWidth
  12923. };
  12924. }
  12925. }, {
  12926. key: "appendToForeignObject",
  12927. value: function appendToForeignObject() {
  12928. var gl = this.w.globals;
  12929. gl.dom.elLegendForeign = document.createElementNS(gl.SVGNS, 'foreignObject');
  12930. var elForeign = gl.dom.elLegendForeign;
  12931. elForeign.setAttribute('x', 0);
  12932. elForeign.setAttribute('y', 0);
  12933. elForeign.setAttribute('width', gl.svgWidth);
  12934. elForeign.setAttribute('height', gl.svgHeight);
  12935. gl.dom.elLegendWrap.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
  12936. elForeign.appendChild(gl.dom.elLegendWrap);
  12937. elForeign.appendChild(this.getLegendStyles()); //gl.dom.elGraphical.node.insertAdjacentElement('afterend', elForeign)
  12938. // the above line causes issue #1907
  12939. gl.dom.Paper.node.insertBefore(elForeign, gl.dom.elGraphical.node);
  12940. }
  12941. }, {
  12942. key: "toggleDataSeries",
  12943. value: function toggleDataSeries(seriesCnt, isHidden) {
  12944. var _this = this;
  12945. var w = this.w;
  12946. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  12947. w.globals.resized = true; // we don't want initial animations again
  12948. var seriesEl = null;
  12949. var realIndex = null; // yes, make it null. 1 series will rise at a time
  12950. w.globals.risingSeries = [];
  12951. if (w.globals.axisCharts) {
  12952. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  12953. realIndex = parseInt(seriesEl.getAttribute('data:realIndex'), 10);
  12954. } else {
  12955. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  12956. realIndex = parseInt(seriesEl.getAttribute('rel'), 10) - 1;
  12957. }
  12958. if (isHidden) {
  12959. var seriesToMakeVisible = [{
  12960. cs: w.globals.collapsedSeries,
  12961. csi: w.globals.collapsedSeriesIndices
  12962. }, {
  12963. cs: w.globals.ancillaryCollapsedSeries,
  12964. csi: w.globals.ancillaryCollapsedSeriesIndices
  12965. }];
  12966. seriesToMakeVisible.forEach(function (r) {
  12967. _this.riseCollapsedSeries(r.cs, r.csi, realIndex);
  12968. });
  12969. } else {
  12970. this.hideSeries({
  12971. seriesEl: seriesEl,
  12972. realIndex: realIndex
  12973. });
  12974. }
  12975. } else {
  12976. // for non-axis charts i.e pie / donuts
  12977. var _seriesEl = w.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  12978. var type = w.config.chart.type;
  12979. if (type === 'pie' || type === 'polarArea' || type === 'donut') {
  12980. var dataLabels = w.config.plotOptions.pie.donut.labels;
  12981. var graphics = new Graphics(this.lgCtx.ctx);
  12982. graphics.pathMouseDown(_seriesEl.members[0], null);
  12983. this.lgCtx.ctx.pie.printDataLabelsInner(_seriesEl.members[0].node, dataLabels);
  12984. }
  12985. _seriesEl.fire('click');
  12986. }
  12987. }
  12988. }, {
  12989. key: "hideSeries",
  12990. value: function hideSeries(_ref) {
  12991. var seriesEl = _ref.seriesEl,
  12992. realIndex = _ref.realIndex;
  12993. var w = this.w;
  12994. var series = Utils$1.clone(w.config.series);
  12995. if (w.globals.axisCharts) {
  12996. var shouldNotHideYAxis = false;
  12997. if (w.config.yaxis[realIndex] && w.config.yaxis[realIndex].show && w.config.yaxis[realIndex].showAlways) {
  12998. shouldNotHideYAxis = true;
  12999. if (w.globals.ancillaryCollapsedSeriesIndices.indexOf(realIndex) < 0) {
  13000. w.globals.ancillaryCollapsedSeries.push({
  13001. index: realIndex,
  13002. data: series[realIndex].data.slice(),
  13003. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  13004. });
  13005. w.globals.ancillaryCollapsedSeriesIndices.push(realIndex);
  13006. }
  13007. }
  13008. if (!shouldNotHideYAxis) {
  13009. w.globals.collapsedSeries.push({
  13010. index: realIndex,
  13011. data: series[realIndex].data.slice(),
  13012. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  13013. });
  13014. w.globals.collapsedSeriesIndices.push(realIndex);
  13015. var removeIndexOfRising = w.globals.risingSeries.indexOf(realIndex);
  13016. w.globals.risingSeries.splice(removeIndexOfRising, 1);
  13017. }
  13018. } else {
  13019. w.globals.collapsedSeries.push({
  13020. index: realIndex,
  13021. data: series[realIndex]
  13022. });
  13023. w.globals.collapsedSeriesIndices.push(realIndex);
  13024. }
  13025. var seriesChildren = seriesEl.childNodes;
  13026. for (var sc = 0; sc < seriesChildren.length; sc++) {
  13027. if (seriesChildren[sc].classList.contains('apexcharts-series-markers-wrap')) {
  13028. if (seriesChildren[sc].classList.contains('apexcharts-hide')) {
  13029. seriesChildren[sc].classList.remove('apexcharts-hide');
  13030. } else {
  13031. seriesChildren[sc].classList.add('apexcharts-hide');
  13032. }
  13033. }
  13034. }
  13035. w.globals.allSeriesCollapsed = w.globals.collapsedSeries.length === w.config.series.length;
  13036. series = this._getSeriesBasedOnCollapsedState(series);
  13037. this.lgCtx.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  13038. }
  13039. }, {
  13040. key: "riseCollapsedSeries",
  13041. value: function riseCollapsedSeries(collapsedSeries, seriesIndices, realIndex) {
  13042. var w = this.w;
  13043. var series = Utils$1.clone(w.config.series);
  13044. if (collapsedSeries.length > 0) {
  13045. for (var c = 0; c < collapsedSeries.length; c++) {
  13046. if (collapsedSeries[c].index === realIndex) {
  13047. if (w.globals.axisCharts) {
  13048. series[realIndex].data = collapsedSeries[c].data.slice();
  13049. collapsedSeries.splice(c, 1);
  13050. seriesIndices.splice(c, 1);
  13051. w.globals.risingSeries.push(realIndex);
  13052. } else {
  13053. series[realIndex] = collapsedSeries[c].data;
  13054. collapsedSeries.splice(c, 1);
  13055. seriesIndices.splice(c, 1);
  13056. w.globals.risingSeries.push(realIndex);
  13057. }
  13058. }
  13059. }
  13060. series = this._getSeriesBasedOnCollapsedState(series);
  13061. this.lgCtx.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  13062. }
  13063. }
  13064. }, {
  13065. key: "_getSeriesBasedOnCollapsedState",
  13066. value: function _getSeriesBasedOnCollapsedState(series) {
  13067. var w = this.w;
  13068. if (w.globals.axisCharts) {
  13069. series.forEach(function (s, sI) {
  13070. if (w.globals.collapsedSeriesIndices.indexOf(sI) > -1) {
  13071. series[sI].data = [];
  13072. }
  13073. });
  13074. } else {
  13075. series.forEach(function (s, sI) {
  13076. if (w.globals.collapsedSeriesIndices.indexOf(sI) > -1) {
  13077. series[sI] = 0;
  13078. }
  13079. });
  13080. }
  13081. return series;
  13082. }
  13083. }]);
  13084. return Helpers;
  13085. }();
  13086. /**
  13087. * ApexCharts Legend Class to draw legend.
  13088. *
  13089. * @module Legend
  13090. **/
  13091. var Legend = /*#__PURE__*/function () {
  13092. function Legend(ctx, opts) {
  13093. _classCallCheck(this, Legend);
  13094. this.ctx = ctx;
  13095. this.w = ctx.w;
  13096. this.onLegendClick = this.onLegendClick.bind(this);
  13097. this.onLegendHovered = this.onLegendHovered.bind(this);
  13098. this.isBarsDistributed = this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.distributed && this.w.config.series.length === 1;
  13099. this.legendHelpers = new Helpers$1(this);
  13100. }
  13101. _createClass(Legend, [{
  13102. key: "init",
  13103. value: function init() {
  13104. var w = this.w;
  13105. var gl = w.globals;
  13106. var cnf = w.config;
  13107. var showLegendAlways = cnf.legend.showForSingleSeries && gl.series.length === 1 || this.isBarsDistributed || gl.series.length > 1;
  13108. if ((showLegendAlways || !gl.axisCharts) && cnf.legend.show) {
  13109. while (gl.dom.elLegendWrap.firstChild) {
  13110. gl.dom.elLegendWrap.removeChild(gl.dom.elLegendWrap.firstChild);
  13111. }
  13112. this.drawLegends();
  13113. if (!Utils$1.isIE11()) {
  13114. this.legendHelpers.appendToForeignObject();
  13115. } else {
  13116. // IE11 doesn't supports foreignObject, hence append it to <head>
  13117. document.getElementsByTagName('head')[0].appendChild(this.legendHelpers.getLegendStyles());
  13118. }
  13119. if (cnf.legend.position === 'bottom' || cnf.legend.position === 'top') {
  13120. this.legendAlignHorizontal();
  13121. } else if (cnf.legend.position === 'right' || cnf.legend.position === 'left') {
  13122. this.legendAlignVertical();
  13123. }
  13124. }
  13125. }
  13126. }, {
  13127. key: "drawLegends",
  13128. value: function drawLegends() {
  13129. var me = this;
  13130. var w = this.w;
  13131. var fontFamily = w.config.legend.fontFamily;
  13132. var legendNames = w.globals.seriesNames;
  13133. var fillcolor = w.globals.colors.slice();
  13134. if (w.config.chart.type === 'heatmap') {
  13135. var ranges = w.config.plotOptions.heatmap.colorScale.ranges;
  13136. legendNames = ranges.map(function (colorScale) {
  13137. return colorScale.name ? colorScale.name : colorScale.from + ' - ' + colorScale.to;
  13138. });
  13139. fillcolor = ranges.map(function (color) {
  13140. return color.color;
  13141. });
  13142. } else if (this.isBarsDistributed) {
  13143. legendNames = w.globals.labels.slice();
  13144. }
  13145. if (w.config.legend.customLegendItems.length) {
  13146. legendNames = w.config.legend.customLegendItems;
  13147. }
  13148. var legendFormatter = w.globals.legendFormatter;
  13149. var isLegendInversed = w.config.legend.inverseOrder;
  13150. for (var i = isLegendInversed ? legendNames.length - 1 : 0; isLegendInversed ? i >= 0 : i <= legendNames.length - 1; isLegendInversed ? i-- : i++) {
  13151. var text = legendFormatter(legendNames[i], {
  13152. seriesIndex: i,
  13153. w: w
  13154. });
  13155. var collapsedSeries = false;
  13156. var ancillaryCollapsedSeries = false;
  13157. if (w.globals.collapsedSeries.length > 0) {
  13158. for (var c = 0; c < w.globals.collapsedSeries.length; c++) {
  13159. if (w.globals.collapsedSeries[c].index === i) {
  13160. collapsedSeries = true;
  13161. }
  13162. }
  13163. }
  13164. if (w.globals.ancillaryCollapsedSeriesIndices.length > 0) {
  13165. for (var _c = 0; _c < w.globals.ancillaryCollapsedSeriesIndices.length; _c++) {
  13166. if (w.globals.ancillaryCollapsedSeriesIndices[_c] === i) {
  13167. ancillaryCollapsedSeries = true;
  13168. }
  13169. }
  13170. }
  13171. var elMarker = document.createElement('span');
  13172. elMarker.classList.add('apexcharts-legend-marker');
  13173. var mOffsetX = w.config.legend.markers.offsetX;
  13174. var mOffsetY = w.config.legend.markers.offsetY;
  13175. var mHeight = w.config.legend.markers.height;
  13176. var mWidth = w.config.legend.markers.width;
  13177. var mBorderWidth = w.config.legend.markers.strokeWidth;
  13178. var mBorderColor = w.config.legend.markers.strokeColor;
  13179. var mBorderRadius = w.config.legend.markers.radius; // todo - untested code below
  13180. // if (Array.isArray(w.config.legend.markers.shape)) {
  13181. // } else {
  13182. // if (w.config.legend.markers.shape !== 'circle') {
  13183. // mBorderRadius = 1
  13184. // }
  13185. // }
  13186. var mStyle = elMarker.style;
  13187. mStyle.background = fillcolor[i];
  13188. mStyle.color = fillcolor[i];
  13189. mStyle.setProperty('background', fillcolor[i], 'important'); // override fill color with custom legend.markers.fillColors
  13190. if (w.config.legend.markers.fillColors && w.config.legend.markers.fillColors[i]) {
  13191. mStyle.background = w.config.legend.markers.fillColors[i];
  13192. } // override with data color
  13193. if (w.globals.seriesColors[i] !== undefined) {
  13194. mStyle.background = w.globals.seriesColors[i];
  13195. mStyle.color = w.globals.seriesColors[i];
  13196. }
  13197. mStyle.height = Array.isArray(mHeight) ? parseFloat(mHeight[i]) + 'px' : parseFloat(mHeight) + 'px';
  13198. mStyle.width = Array.isArray(mWidth) ? parseFloat(mWidth[i]) + 'px' : parseFloat(mWidth) + 'px';
  13199. mStyle.left = (Array.isArray(mOffsetX) ? parseFloat(mOffsetX[i]) : parseFloat(mOffsetX)) + 'px';
  13200. mStyle.top = (Array.isArray(mOffsetY) ? parseFloat(mOffsetY[i]) : parseFloat(mOffsetY)) + 'px';
  13201. mStyle.borderWidth = Array.isArray(mBorderWidth) ? mBorderWidth[i] : mBorderWidth;
  13202. mStyle.borderColor = Array.isArray(mBorderColor) ? mBorderColor[i] : mBorderColor;
  13203. mStyle.borderRadius = Array.isArray(mBorderRadius) ? parseFloat(mBorderRadius[i]) + 'px' : parseFloat(mBorderRadius) + 'px';
  13204. if (w.config.legend.markers.customHTML) {
  13205. if (Array.isArray(w.config.legend.markers.customHTML)) {
  13206. if (w.config.legend.markers.customHTML[i]) {
  13207. elMarker.innerHTML = w.config.legend.markers.customHTML[i]();
  13208. }
  13209. } else {
  13210. elMarker.innerHTML = w.config.legend.markers.customHTML();
  13211. }
  13212. }
  13213. Graphics.setAttrs(elMarker, {
  13214. rel: i + 1,
  13215. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  13216. });
  13217. if (collapsedSeries || ancillaryCollapsedSeries) {
  13218. elMarker.classList.add('apexcharts-inactive-legend');
  13219. }
  13220. var elLegend = document.createElement('div');
  13221. var elLegendText = document.createElement('span');
  13222. elLegendText.classList.add('apexcharts-legend-text');
  13223. elLegendText.innerHTML = Array.isArray(text) ? text.join(' ') : text;
  13224. var textColor = w.config.legend.labels.useSeriesColors ? w.globals.colors[i] : w.config.legend.labels.colors;
  13225. if (!textColor) {
  13226. textColor = w.config.chart.foreColor;
  13227. }
  13228. elLegendText.style.color = textColor;
  13229. elLegendText.style.fontSize = parseFloat(w.config.legend.fontSize) + 'px';
  13230. elLegendText.style.fontWeight = w.config.legend.fontWeight;
  13231. elLegendText.style.fontFamily = fontFamily || w.config.chart.fontFamily;
  13232. Graphics.setAttrs(elLegendText, {
  13233. rel: i + 1,
  13234. i: i,
  13235. 'data:default-text': encodeURIComponent(text),
  13236. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  13237. });
  13238. elLegend.appendChild(elMarker);
  13239. elLegend.appendChild(elLegendText);
  13240. var coreUtils = new CoreUtils(this.ctx);
  13241. if (!w.config.legend.showForZeroSeries) {
  13242. var total = coreUtils.getSeriesTotalByIndex(i);
  13243. if (total === 0 && coreUtils.seriesHaveSameValues(i) && !coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  13244. elLegend.classList.add('apexcharts-hidden-zero-series');
  13245. }
  13246. }
  13247. if (!w.config.legend.showForNullSeries) {
  13248. if (coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  13249. elLegend.classList.add('apexcharts-hidden-null-series');
  13250. }
  13251. }
  13252. w.globals.dom.elLegendWrap.appendChild(elLegend);
  13253. w.globals.dom.elLegendWrap.classList.add("apexcharts-align-".concat(w.config.legend.horizontalAlign));
  13254. w.globals.dom.elLegendWrap.classList.add('apx-legend-position-' + w.config.legend.position);
  13255. elLegend.classList.add('apexcharts-legend-series');
  13256. elLegend.style.margin = "".concat(w.config.legend.itemMargin.vertical, "px ").concat(w.config.legend.itemMargin.horizontal, "px");
  13257. w.globals.dom.elLegendWrap.style.width = w.config.legend.width ? w.config.legend.width + 'px' : '';
  13258. w.globals.dom.elLegendWrap.style.height = w.config.legend.height ? w.config.legend.height + 'px' : '';
  13259. Graphics.setAttrs(elLegend, {
  13260. rel: i + 1,
  13261. seriesName: Utils$1.escapeString(legendNames[i]),
  13262. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  13263. });
  13264. if (collapsedSeries || ancillaryCollapsedSeries) {
  13265. elLegend.classList.add('apexcharts-inactive-legend');
  13266. }
  13267. if (!w.config.legend.onItemClick.toggleDataSeries) {
  13268. elLegend.classList.add('apexcharts-no-click');
  13269. }
  13270. }
  13271. w.globals.dom.elWrap.addEventListener('click', me.onLegendClick, true);
  13272. if (w.config.legend.onItemHover.highlightDataSeries && w.config.legend.customLegendItems.length === 0) {
  13273. w.globals.dom.elWrap.addEventListener('mousemove', me.onLegendHovered, true);
  13274. w.globals.dom.elWrap.addEventListener('mouseout', me.onLegendHovered, true);
  13275. }
  13276. }
  13277. }, {
  13278. key: "setLegendWrapXY",
  13279. value: function setLegendWrapXY(offsetX, offsetY) {
  13280. var w = this.w;
  13281. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  13282. var legendRect = elLegendWrap.getBoundingClientRect();
  13283. var x = 0;
  13284. var y = 0;
  13285. if (w.config.legend.position === 'bottom') {
  13286. y = y + (w.globals.svgHeight - legendRect.height / 2);
  13287. } else if (w.config.legend.position === 'top') {
  13288. var dim = new Dimensions(this.ctx);
  13289. var titleH = dim.dimHelpers.getTitleSubtitleCoords('title').height;
  13290. var subtitleH = dim.dimHelpers.getTitleSubtitleCoords('subtitle').height;
  13291. y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0);
  13292. }
  13293. elLegendWrap.style.position = 'absolute';
  13294. x = x + offsetX + w.config.legend.offsetX;
  13295. y = y + offsetY + w.config.legend.offsetY;
  13296. elLegendWrap.style.left = x + 'px';
  13297. elLegendWrap.style.top = y + 'px';
  13298. if (w.config.legend.position === 'bottom') {
  13299. elLegendWrap.style.top = 'auto';
  13300. elLegendWrap.style.bottom = 5 - w.config.legend.offsetY + 'px';
  13301. } else if (w.config.legend.position === 'right') {
  13302. elLegendWrap.style.left = 'auto';
  13303. elLegendWrap.style.right = 25 + w.config.legend.offsetX + 'px';
  13304. }
  13305. var fixedHeigthWidth = ['width', 'height'];
  13306. fixedHeigthWidth.forEach(function (hw) {
  13307. if (elLegendWrap.style[hw]) {
  13308. elLegendWrap.style[hw] = parseInt(w.config.legend[hw], 10) + 'px';
  13309. }
  13310. });
  13311. }
  13312. }, {
  13313. key: "legendAlignHorizontal",
  13314. value: function legendAlignHorizontal() {
  13315. var w = this.w;
  13316. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  13317. elLegendWrap.style.right = 0;
  13318. var lRect = this.legendHelpers.getLegendBBox();
  13319. var dimensions = new Dimensions(this.ctx);
  13320. var titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title');
  13321. var subtitleRect = dimensions.dimHelpers.getTitleSubtitleCoords('subtitle');
  13322. var offsetX = 20;
  13323. var offsetY = 0; // the whole legend box is set to bottom
  13324. if (w.config.legend.position === 'bottom') {
  13325. offsetY = -lRect.clwh / 1.8;
  13326. } else if (w.config.legend.position === 'top') {
  13327. offsetY = titleRect.height + subtitleRect.height + w.config.title.margin + w.config.subtitle.margin - 10;
  13328. }
  13329. this.setLegendWrapXY(offsetX, offsetY);
  13330. }
  13331. }, {
  13332. key: "legendAlignVertical",
  13333. value: function legendAlignVertical() {
  13334. var w = this.w;
  13335. var lRect = this.legendHelpers.getLegendBBox();
  13336. var offsetY = 20;
  13337. var offsetX = 0;
  13338. if (w.config.legend.position === 'left') {
  13339. offsetX = 20;
  13340. }
  13341. if (w.config.legend.position === 'right') {
  13342. offsetX = w.globals.svgWidth - lRect.clww - 10;
  13343. }
  13344. this.setLegendWrapXY(offsetX, offsetY);
  13345. }
  13346. }, {
  13347. key: "onLegendHovered",
  13348. value: function onLegendHovered(e) {
  13349. var w = this.w;
  13350. var hoverOverLegend = e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker');
  13351. if (w.config.chart.type !== 'heatmap' && !this.isBarsDistributed) {
  13352. if (!e.target.classList.contains('apexcharts-inactive-legend') && hoverOverLegend) {
  13353. var series = new Series(this.ctx);
  13354. series.toggleSeriesOnHover(e, e.target);
  13355. }
  13356. } else {
  13357. // for heatmap handling
  13358. if (hoverOverLegend) {
  13359. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  13360. this.ctx.events.fireEvent('legendHover', [this.ctx, seriesCnt, this.w]);
  13361. var _series = new Series(this.ctx);
  13362. _series.highlightRangeInSeries(e, e.target);
  13363. }
  13364. }
  13365. }
  13366. }, {
  13367. key: "onLegendClick",
  13368. value: function onLegendClick(e) {
  13369. var w = this.w;
  13370. if (w.config.legend.customLegendItems.length) return;
  13371. if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker')) {
  13372. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  13373. var isHidden = e.target.getAttribute('data:collapsed') === 'true';
  13374. var legendClick = this.w.config.chart.events.legendClick;
  13375. if (typeof legendClick === 'function') {
  13376. legendClick(this.ctx, seriesCnt, this.w);
  13377. }
  13378. this.ctx.events.fireEvent('legendClick', [this.ctx, seriesCnt, this.w]);
  13379. var markerClick = this.w.config.legend.markers.onClick;
  13380. if (typeof markerClick === 'function' && e.target.classList.contains('apexcharts-legend-marker')) {
  13381. markerClick(this.ctx, seriesCnt, this.w);
  13382. this.ctx.events.fireEvent('legendMarkerClick', [this.ctx, seriesCnt, this.w]);
  13383. } // for now - just prevent click on heatmap legend - and allow hover only
  13384. var clickAllowed = w.config.chart.type !== 'treemap' && w.config.chart.type !== 'heatmap' && !this.isBarsDistributed;
  13385. if (clickAllowed && w.config.legend.onItemClick.toggleDataSeries) {
  13386. this.legendHelpers.toggleDataSeries(seriesCnt, isHidden);
  13387. }
  13388. }
  13389. }
  13390. }]);
  13391. return Legend;
  13392. }();
  13393. 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>";
  13394. 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>";
  13395. 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>";
  13396. 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";
  13397. 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";
  13398. 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>";
  13399. 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>";
  13400. /**
  13401. * ApexCharts Toolbar Class for creating toolbar in axis based charts.
  13402. *
  13403. * @module Toolbar
  13404. **/
  13405. var Toolbar = /*#__PURE__*/function () {
  13406. function Toolbar(ctx) {
  13407. _classCallCheck(this, Toolbar);
  13408. this.ctx = ctx;
  13409. this.w = ctx.w;
  13410. var w = this.w;
  13411. this.ev = this.w.config.chart.events;
  13412. this.selectedClass = 'apexcharts-selected';
  13413. this.localeValues = this.w.globals.locale.toolbar;
  13414. this.minX = w.globals.minX;
  13415. this.maxX = w.globals.maxX;
  13416. }
  13417. _createClass(Toolbar, [{
  13418. key: "createToolbar",
  13419. value: function createToolbar() {
  13420. var _this = this;
  13421. var w = this.w;
  13422. var createDiv = function createDiv() {
  13423. return document.createElement('div');
  13424. };
  13425. var elToolbarWrap = createDiv();
  13426. elToolbarWrap.setAttribute('class', 'apexcharts-toolbar');
  13427. elToolbarWrap.style.top = w.config.chart.toolbar.offsetY + 'px';
  13428. elToolbarWrap.style.right = -w.config.chart.toolbar.offsetX + 3 + 'px';
  13429. w.globals.dom.elWrap.appendChild(elToolbarWrap);
  13430. this.elZoom = createDiv();
  13431. this.elZoomIn = createDiv();
  13432. this.elZoomOut = createDiv();
  13433. this.elPan = createDiv();
  13434. this.elSelection = createDiv();
  13435. this.elZoomReset = createDiv();
  13436. this.elMenuIcon = createDiv();
  13437. this.elMenu = createDiv();
  13438. this.elCustomIcons = [];
  13439. this.t = w.config.chart.toolbar.tools;
  13440. if (Array.isArray(this.t.customIcons)) {
  13441. for (var i = 0; i < this.t.customIcons.length; i++) {
  13442. this.elCustomIcons.push(createDiv());
  13443. }
  13444. }
  13445. var toolbarControls = [];
  13446. var appendZoomControl = function appendZoomControl(type, el, ico) {
  13447. var tool = type.toLowerCase();
  13448. if (_this.t[tool] && w.config.chart.zoom.enabled) {
  13449. toolbarControls.push({
  13450. el: el,
  13451. icon: typeof _this.t[tool] === 'string' ? _this.t[tool] : ico,
  13452. title: _this.localeValues[type],
  13453. class: "apexcharts-".concat(tool, "-icon")
  13454. });
  13455. }
  13456. };
  13457. appendZoomControl('zoomIn', this.elZoomIn, icoZoomIn);
  13458. appendZoomControl('zoomOut', this.elZoomOut, icoZoomOut);
  13459. var zoomSelectionCtrls = function zoomSelectionCtrls(z) {
  13460. if (_this.t[z] && w.config.chart[z].enabled) {
  13461. toolbarControls.push({
  13462. el: z === 'zoom' ? _this.elZoom : _this.elSelection,
  13463. icon: typeof _this.t[z] === 'string' ? _this.t[z] : z === 'zoom' ? icoZoom : icoSelect,
  13464. title: _this.localeValues[z === 'zoom' ? 'selectionZoom' : 'selection'],
  13465. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : "apexcharts-".concat(z, "-icon")
  13466. });
  13467. }
  13468. };
  13469. zoomSelectionCtrls('zoom');
  13470. zoomSelectionCtrls('selection');
  13471. if (this.t.pan && w.config.chart.zoom.enabled) {
  13472. toolbarControls.push({
  13473. el: this.elPan,
  13474. icon: typeof this.t.pan === 'string' ? this.t.pan : icoPan,
  13475. title: this.localeValues.pan,
  13476. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : 'apexcharts-pan-icon'
  13477. });
  13478. }
  13479. appendZoomControl('reset', this.elZoomReset, icoReset);
  13480. if (this.t.download) {
  13481. toolbarControls.push({
  13482. el: this.elMenuIcon,
  13483. icon: typeof this.t.download === 'string' ? this.t.download : icoMenu,
  13484. title: this.localeValues.menu,
  13485. class: 'apexcharts-menu-icon'
  13486. });
  13487. }
  13488. for (var _i = 0; _i < this.elCustomIcons.length; _i++) {
  13489. toolbarControls.push({
  13490. el: this.elCustomIcons[_i],
  13491. icon: this.t.customIcons[_i].icon,
  13492. title: this.t.customIcons[_i].title,
  13493. index: this.t.customIcons[_i].index,
  13494. class: 'apexcharts-toolbar-custom-icon ' + this.t.customIcons[_i].class
  13495. });
  13496. }
  13497. toolbarControls.forEach(function (t, index) {
  13498. if (t.index) {
  13499. Utils$1.moveIndexInArray(toolbarControls, index, t.index);
  13500. }
  13501. });
  13502. for (var _i2 = 0; _i2 < toolbarControls.length; _i2++) {
  13503. Graphics.setAttrs(toolbarControls[_i2].el, {
  13504. class: toolbarControls[_i2].class,
  13505. title: toolbarControls[_i2].title
  13506. });
  13507. toolbarControls[_i2].el.innerHTML = toolbarControls[_i2].icon;
  13508. elToolbarWrap.appendChild(toolbarControls[_i2].el);
  13509. }
  13510. this._createHamburgerMenu(elToolbarWrap);
  13511. if (w.globals.zoomEnabled) {
  13512. this.elZoom.classList.add(this.selectedClass);
  13513. } else if (w.globals.panEnabled) {
  13514. this.elPan.classList.add(this.selectedClass);
  13515. } else if (w.globals.selectionEnabled) {
  13516. this.elSelection.classList.add(this.selectedClass);
  13517. }
  13518. this.addToolbarEventListeners();
  13519. }
  13520. }, {
  13521. key: "_createHamburgerMenu",
  13522. value: function _createHamburgerMenu(parent) {
  13523. this.elMenuItems = [];
  13524. parent.appendChild(this.elMenu);
  13525. Graphics.setAttrs(this.elMenu, {
  13526. class: 'apexcharts-menu'
  13527. });
  13528. var menuItems = [{
  13529. name: 'exportSVG',
  13530. title: this.localeValues.exportToSVG
  13531. }, {
  13532. name: 'exportPNG',
  13533. title: this.localeValues.exportToPNG
  13534. }, {
  13535. name: 'exportCSV',
  13536. title: this.localeValues.exportToCSV
  13537. }];
  13538. if (!this.w.globals.allSeriesHasEqualX) {
  13539. // if it is a multi series, and all series have variable x values, export CSV won't work
  13540. menuItems.splice(2, 1);
  13541. }
  13542. for (var i = 0; i < menuItems.length; i++) {
  13543. this.elMenuItems.push(document.createElement('div'));
  13544. this.elMenuItems[i].innerHTML = menuItems[i].title;
  13545. Graphics.setAttrs(this.elMenuItems[i], {
  13546. class: "apexcharts-menu-item ".concat(menuItems[i].name),
  13547. title: menuItems[i].title
  13548. });
  13549. this.elMenu.appendChild(this.elMenuItems[i]);
  13550. }
  13551. }
  13552. }, {
  13553. key: "addToolbarEventListeners",
  13554. value: function addToolbarEventListeners() {
  13555. var _this2 = this;
  13556. this.elZoomReset.addEventListener('click', this.handleZoomReset.bind(this));
  13557. this.elSelection.addEventListener('click', this.toggleZoomSelection.bind(this, 'selection'));
  13558. this.elZoom.addEventListener('click', this.toggleZoomSelection.bind(this, 'zoom'));
  13559. this.elZoomIn.addEventListener('click', this.handleZoomIn.bind(this));
  13560. this.elZoomOut.addEventListener('click', this.handleZoomOut.bind(this));
  13561. this.elPan.addEventListener('click', this.togglePanning.bind(this));
  13562. this.elMenuIcon.addEventListener('click', this.toggleMenu.bind(this));
  13563. this.elMenuItems.forEach(function (m) {
  13564. if (m.classList.contains('exportSVG')) {
  13565. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'svg'));
  13566. } else if (m.classList.contains('exportPNG')) {
  13567. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'png'));
  13568. } else if (m.classList.contains('exportCSV')) {
  13569. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'csv'));
  13570. }
  13571. });
  13572. for (var i = 0; i < this.t.customIcons.length; i++) {
  13573. this.elCustomIcons[i].addEventListener('click', this.t.customIcons[i].click.bind(this, this.ctx, this.ctx.w));
  13574. }
  13575. }
  13576. }, {
  13577. key: "toggleZoomSelection",
  13578. value: function toggleZoomSelection(type) {
  13579. var charts = this.ctx.getSyncedCharts();
  13580. charts.forEach(function (ch) {
  13581. ch.ctx.toolbar.toggleOtherControls();
  13582. var el = type === 'selection' ? ch.ctx.toolbar.elSelection : ch.ctx.toolbar.elZoom;
  13583. var enabledType = type === 'selection' ? 'selectionEnabled' : 'zoomEnabled';
  13584. ch.w.globals[enabledType] = !ch.w.globals[enabledType];
  13585. if (!el.classList.contains(ch.ctx.toolbar.selectedClass)) {
  13586. el.classList.add(ch.ctx.toolbar.selectedClass);
  13587. } else {
  13588. el.classList.remove(ch.ctx.toolbar.selectedClass);
  13589. }
  13590. });
  13591. }
  13592. }, {
  13593. key: "getToolbarIconsReference",
  13594. value: function getToolbarIconsReference() {
  13595. var w = this.w;
  13596. if (!this.elZoom) {
  13597. this.elZoom = w.globals.dom.baseEl.querySelector('.apexcharts-zoom-icon');
  13598. }
  13599. if (!this.elPan) {
  13600. this.elPan = w.globals.dom.baseEl.querySelector('.apexcharts-pan-icon');
  13601. }
  13602. if (!this.elSelection) {
  13603. this.elSelection = w.globals.dom.baseEl.querySelector('.apexcharts-selection-icon');
  13604. }
  13605. }
  13606. }, {
  13607. key: "enableZoomPanFromToolbar",
  13608. value: function enableZoomPanFromToolbar(type) {
  13609. this.toggleOtherControls();
  13610. type === 'pan' ? this.w.globals.panEnabled = true : this.w.globals.zoomEnabled = true;
  13611. var el = type === 'pan' ? this.elPan : this.elZoom;
  13612. var el2 = type === 'pan' ? this.elZoom : this.elPan;
  13613. if (el) {
  13614. el.classList.add(this.selectedClass);
  13615. }
  13616. if (el2) {
  13617. el2.classList.remove(this.selectedClass);
  13618. }
  13619. }
  13620. }, {
  13621. key: "togglePanning",
  13622. value: function togglePanning() {
  13623. var charts = this.ctx.getSyncedCharts();
  13624. charts.forEach(function (ch) {
  13625. ch.ctx.toolbar.toggleOtherControls();
  13626. ch.w.globals.panEnabled = !ch.w.globals.panEnabled;
  13627. if (!ch.ctx.toolbar.elPan.classList.contains(ch.ctx.toolbar.selectedClass)) {
  13628. ch.ctx.toolbar.elPan.classList.add(ch.ctx.toolbar.selectedClass);
  13629. } else {
  13630. ch.ctx.toolbar.elPan.classList.remove(ch.ctx.toolbar.selectedClass);
  13631. }
  13632. });
  13633. }
  13634. }, {
  13635. key: "toggleOtherControls",
  13636. value: function toggleOtherControls() {
  13637. var _this3 = this;
  13638. var w = this.w;
  13639. w.globals.panEnabled = false;
  13640. w.globals.zoomEnabled = false;
  13641. w.globals.selectionEnabled = false;
  13642. this.getToolbarIconsReference();
  13643. var toggleEls = [this.elPan, this.elSelection, this.elZoom];
  13644. toggleEls.forEach(function (el) {
  13645. if (el) {
  13646. el.classList.remove(_this3.selectedClass);
  13647. }
  13648. });
  13649. }
  13650. }, {
  13651. key: "handleZoomIn",
  13652. value: function handleZoomIn() {
  13653. var w = this.w;
  13654. if (w.globals.isRangeBar) {
  13655. this.minX = w.globals.minY;
  13656. this.maxX = w.globals.maxY;
  13657. }
  13658. var centerX = (this.minX + this.maxX) / 2;
  13659. var newMinX = (this.minX + centerX) / 2;
  13660. var newMaxX = (this.maxX + centerX) / 2;
  13661. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  13662. if (!w.globals.disableZoomIn) {
  13663. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  13664. }
  13665. }
  13666. }, {
  13667. key: "handleZoomOut",
  13668. value: function handleZoomOut() {
  13669. var w = this.w;
  13670. if (w.globals.isRangeBar) {
  13671. this.minX = w.globals.minY;
  13672. this.maxX = w.globals.maxY;
  13673. } // avoid zooming out beyond 1000 which may result in NaN values being printed on x-axis
  13674. if (w.config.xaxis.type === 'datetime' && new Date(this.minX).getUTCFullYear() < 1000) {
  13675. return;
  13676. }
  13677. var centerX = (this.minX + this.maxX) / 2;
  13678. var newMinX = this.minX - (centerX - this.minX);
  13679. var newMaxX = this.maxX - (centerX - this.maxX);
  13680. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  13681. if (!w.globals.disableZoomOut) {
  13682. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  13683. }
  13684. }
  13685. }, {
  13686. key: "_getNewMinXMaxX",
  13687. value: function _getNewMinXMaxX(newMinX, newMaxX) {
  13688. var shouldFloor = this.w.config.xaxis.convertedCatToNumeric;
  13689. return {
  13690. minX: shouldFloor ? Math.floor(newMinX) : newMinX,
  13691. maxX: shouldFloor ? Math.floor(newMaxX) : newMaxX
  13692. };
  13693. }
  13694. }, {
  13695. key: "zoomUpdateOptions",
  13696. value: function zoomUpdateOptions(newMinX, newMaxX) {
  13697. var w = this.w;
  13698. if (newMinX === undefined && newMaxX === undefined) {
  13699. this.handleZoomReset();
  13700. return;
  13701. }
  13702. if (w.config.xaxis.convertedCatToNumeric) {
  13703. // in category charts, avoid zooming out beyond min and max
  13704. if (newMinX < 1) {
  13705. newMinX = 1;
  13706. newMaxX = w.globals.dataPoints;
  13707. }
  13708. if (newMaxX - newMinX < 2) {
  13709. return;
  13710. }
  13711. }
  13712. var xaxis = {
  13713. min: newMinX,
  13714. max: newMaxX
  13715. };
  13716. var beforeZoomRange = this.getBeforeZoomRange(xaxis);
  13717. if (beforeZoomRange) {
  13718. xaxis = beforeZoomRange.xaxis;
  13719. }
  13720. var options = {
  13721. xaxis: xaxis
  13722. };
  13723. var yaxis = Utils$1.clone(w.globals.initialConfig.yaxis);
  13724. if (w.config.chart.zoom.autoScaleYaxis) {
  13725. var scale = new Range$1(this.ctx);
  13726. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  13727. xaxis: xaxis
  13728. });
  13729. }
  13730. if (!w.config.chart.group) {
  13731. // if chart in a group, prevent yaxis update here
  13732. // fix issue #650
  13733. options.yaxis = yaxis;
  13734. }
  13735. this.w.globals.zoomed = true;
  13736. this.ctx.updateHelpers._updateOptions(options, false, this.w.config.chart.animations.dynamicAnimation.enabled);
  13737. this.zoomCallback(xaxis, yaxis);
  13738. }
  13739. }, {
  13740. key: "zoomCallback",
  13741. value: function zoomCallback(xaxis, yaxis) {
  13742. if (typeof this.ev.zoomed === 'function') {
  13743. this.ev.zoomed(this.ctx, {
  13744. xaxis: xaxis,
  13745. yaxis: yaxis
  13746. });
  13747. }
  13748. }
  13749. }, {
  13750. key: "getBeforeZoomRange",
  13751. value: function getBeforeZoomRange(xaxis, yaxis) {
  13752. var newRange = null;
  13753. if (typeof this.ev.beforeZoom === 'function') {
  13754. newRange = this.ev.beforeZoom(this, {
  13755. xaxis: xaxis,
  13756. yaxis: yaxis
  13757. });
  13758. }
  13759. return newRange;
  13760. }
  13761. }, {
  13762. key: "toggleMenu",
  13763. value: function toggleMenu() {
  13764. var _this4 = this;
  13765. window.setTimeout(function () {
  13766. if (_this4.elMenu.classList.contains('apexcharts-menu-open')) {
  13767. _this4.elMenu.classList.remove('apexcharts-menu-open');
  13768. } else {
  13769. _this4.elMenu.classList.add('apexcharts-menu-open');
  13770. }
  13771. }, 0);
  13772. }
  13773. }, {
  13774. key: "handleDownload",
  13775. value: function handleDownload(type) {
  13776. var w = this.w;
  13777. var exprt = new Exports(this.ctx);
  13778. switch (type) {
  13779. case 'svg':
  13780. exprt.exportToSVG(this.ctx);
  13781. break;
  13782. case 'png':
  13783. exprt.exportToPng(this.ctx);
  13784. break;
  13785. case 'csv':
  13786. exprt.exportToCSV({
  13787. series: w.config.series,
  13788. columnDelimiter: w.config.chart.toolbar.export.csv.columnDelimiter
  13789. });
  13790. break;
  13791. }
  13792. }
  13793. }, {
  13794. key: "handleZoomReset",
  13795. value: function handleZoomReset(e) {
  13796. var charts = this.ctx.getSyncedCharts();
  13797. charts.forEach(function (ch) {
  13798. var w = ch.w; // forget lastXAxis min/max as reset button isn't resetting the x-axis completely if zoomX is called before
  13799. w.globals.lastXAxis.min = undefined;
  13800. w.globals.lastXAxis.max = undefined;
  13801. ch.updateHelpers.revertDefaultAxisMinMax();
  13802. if (typeof w.config.chart.events.beforeResetZoom === 'function') {
  13803. // here, user get an option to control xaxis and yaxis when resetZoom is called
  13804. // at this point, whatever is returned from w.config.chart.events.beforeResetZoom
  13805. // is set as the new xaxis/yaxis min/max
  13806. var resetZoomRange = w.config.chart.events.beforeResetZoom(ch, w);
  13807. if (resetZoomRange) {
  13808. ch.updateHelpers.revertDefaultAxisMinMax(resetZoomRange);
  13809. }
  13810. }
  13811. if (typeof w.config.chart.events.zoomed === 'function') {
  13812. ch.ctx.toolbar.zoomCallback({
  13813. min: w.config.xaxis.min,
  13814. max: w.config.xaxis.max
  13815. });
  13816. }
  13817. w.globals.zoomed = false; // if user has some series collapsed before hitting zoom reset button,
  13818. // those series should stay collapsed
  13819. var series = ch.ctx.series.emptyCollapsedSeries(Utils$1.clone(w.globals.initialSeries));
  13820. ch.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  13821. });
  13822. }
  13823. }, {
  13824. key: "destroy",
  13825. value: function destroy() {
  13826. this.elZoom = null;
  13827. this.elZoomIn = null;
  13828. this.elZoomOut = null;
  13829. this.elPan = null;
  13830. this.elSelection = null;
  13831. this.elZoomReset = null;
  13832. this.elMenuIcon = null;
  13833. }
  13834. }]);
  13835. return Toolbar;
  13836. }();
  13837. /**
  13838. * ApexCharts Zoom Class for handling zooming and panning on axes based charts.
  13839. *
  13840. * @module ZoomPanSelection
  13841. **/
  13842. var ZoomPanSelection = /*#__PURE__*/function (_Toolbar) {
  13843. _inherits(ZoomPanSelection, _Toolbar);
  13844. var _super = _createSuper(ZoomPanSelection);
  13845. function ZoomPanSelection(ctx) {
  13846. var _this;
  13847. _classCallCheck(this, ZoomPanSelection);
  13848. _this = _super.call(this, ctx);
  13849. _this.ctx = ctx;
  13850. _this.w = ctx.w;
  13851. _this.dragged = false;
  13852. _this.graphics = new Graphics(_this.ctx);
  13853. _this.eventList = ['mousedown', 'mouseleave', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
  13854. _this.clientX = 0;
  13855. _this.clientY = 0;
  13856. _this.startX = 0;
  13857. _this.endX = 0;
  13858. _this.dragX = 0;
  13859. _this.startY = 0;
  13860. _this.endY = 0;
  13861. _this.dragY = 0;
  13862. _this.moveDirection = 'none';
  13863. return _this;
  13864. }
  13865. _createClass(ZoomPanSelection, [{
  13866. key: "init",
  13867. value: function init(_ref) {
  13868. var _this2 = this;
  13869. var xyRatios = _ref.xyRatios;
  13870. var w = this.w;
  13871. var me = this;
  13872. this.xyRatios = xyRatios;
  13873. this.zoomRect = this.graphics.drawRect(0, 0, 0, 0);
  13874. this.selectionRect = this.graphics.drawRect(0, 0, 0, 0);
  13875. this.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  13876. this.zoomRect.node.classList.add('apexcharts-zoom-rect');
  13877. this.selectionRect.node.classList.add('apexcharts-selection-rect');
  13878. w.globals.dom.elGraphical.add(this.zoomRect);
  13879. w.globals.dom.elGraphical.add(this.selectionRect);
  13880. if (w.config.chart.selection.type === 'x') {
  13881. this.slDraggableRect = this.selectionRect.draggable({
  13882. minX: 0,
  13883. minY: 0,
  13884. maxX: w.globals.gridWidth,
  13885. maxY: w.globals.gridHeight
  13886. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13887. } else if (w.config.chart.selection.type === 'y') {
  13888. this.slDraggableRect = this.selectionRect.draggable({
  13889. minX: 0,
  13890. maxX: w.globals.gridWidth
  13891. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13892. } else {
  13893. this.slDraggableRect = this.selectionRect.draggable().on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13894. }
  13895. this.preselectedSelection();
  13896. this.hoverArea = w.globals.dom.baseEl.querySelector("".concat(w.globals.chartClass, " .apexcharts-svg"));
  13897. this.hoverArea.classList.add('apexcharts-zoomable');
  13898. this.eventList.forEach(function (event) {
  13899. _this2.hoverArea.addEventListener(event, me.svgMouseEvents.bind(me, xyRatios), {
  13900. capture: false,
  13901. passive: true
  13902. });
  13903. });
  13904. } // remove the event listeners which were previously added on hover area
  13905. }, {
  13906. key: "destroy",
  13907. value: function destroy() {
  13908. if (this.slDraggableRect) {
  13909. this.slDraggableRect.draggable(false);
  13910. this.slDraggableRect.off();
  13911. this.selectionRect.off();
  13912. }
  13913. this.selectionRect = null;
  13914. this.zoomRect = null;
  13915. this.gridRect = null;
  13916. }
  13917. }, {
  13918. key: "svgMouseEvents",
  13919. value: function svgMouseEvents(xyRatios, e) {
  13920. var w = this.w;
  13921. var me = this;
  13922. var toolbar = this.ctx.toolbar;
  13923. var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type;
  13924. var autoSelected = w.config.chart.toolbar.autoSelected;
  13925. if (e.shiftKey) {
  13926. this.shiftWasPressed = true;
  13927. toolbar.enableZoomPanFromToolbar(autoSelected === 'pan' ? 'zoom' : 'pan');
  13928. } else {
  13929. if (this.shiftWasPressed) {
  13930. toolbar.enableZoomPanFromToolbar(autoSelected);
  13931. this.shiftWasPressed = false;
  13932. }
  13933. }
  13934. if (!e.target) return;
  13935. var tc = e.target.classList;
  13936. var pc;
  13937. if (e.target.parentNode && e.target.parentNode !== null) {
  13938. pc = e.target.parentNode.classList;
  13939. }
  13940. var falsePositives = tc.contains('apexcharts-selection-rect') || tc.contains('apexcharts-legend-marker') || tc.contains('apexcharts-legend-text') || pc && pc.contains('apexcharts-toolbar');
  13941. if (falsePositives) return;
  13942. me.clientX = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientX : e.type === 'touchend' ? e.changedTouches[0].clientX : e.clientX;
  13943. me.clientY = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientY : e.type === 'touchend' ? e.changedTouches[0].clientY : e.clientY;
  13944. if (e.type === 'mousedown' && e.which === 1) {
  13945. var gridRectDim = me.gridRect.getBoundingClientRect();
  13946. me.startX = me.clientX - gridRectDim.left;
  13947. me.startY = me.clientY - gridRectDim.top;
  13948. me.dragged = false;
  13949. me.w.globals.mousedown = true;
  13950. }
  13951. if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') {
  13952. me.dragged = true;
  13953. if (w.globals.panEnabled) {
  13954. w.globals.selection = null;
  13955. if (me.w.globals.mousedown) {
  13956. me.panDragging({
  13957. context: me,
  13958. zoomtype: zoomtype,
  13959. xyRatios: xyRatios
  13960. });
  13961. }
  13962. } else {
  13963. if (me.w.globals.mousedown && w.globals.zoomEnabled || me.w.globals.mousedown && w.globals.selectionEnabled) {
  13964. me.selection = me.selectionDrawing({
  13965. context: me,
  13966. zoomtype: zoomtype
  13967. });
  13968. }
  13969. }
  13970. }
  13971. if (e.type === 'mouseup' || e.type === 'touchend' || e.type === 'mouseleave') {
  13972. // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup
  13973. var _gridRectDim = me.gridRect.getBoundingClientRect();
  13974. if (me.w.globals.mousedown) {
  13975. // user released the drag, now do all the calculations
  13976. me.endX = me.clientX - _gridRectDim.left;
  13977. me.endY = me.clientY - _gridRectDim.top;
  13978. me.dragX = Math.abs(me.endX - me.startX);
  13979. me.dragY = Math.abs(me.endY - me.startY);
  13980. if (w.globals.zoomEnabled || w.globals.selectionEnabled) {
  13981. me.selectionDrawn({
  13982. context: me,
  13983. zoomtype: zoomtype
  13984. });
  13985. }
  13986. if (w.globals.panEnabled && w.config.xaxis.convertedCatToNumeric) {
  13987. me.delayedPanScrolled();
  13988. }
  13989. }
  13990. if (w.globals.zoomEnabled) {
  13991. me.hideSelectionRect(this.selectionRect);
  13992. }
  13993. me.dragged = false;
  13994. me.w.globals.mousedown = false;
  13995. }
  13996. this.makeSelectionRectDraggable();
  13997. }
  13998. }, {
  13999. key: "makeSelectionRectDraggable",
  14000. value: function makeSelectionRectDraggable() {
  14001. var w = this.w;
  14002. if (!this.selectionRect) return;
  14003. var rectDim = this.selectionRect.node.getBoundingClientRect();
  14004. if (rectDim.width > 0 && rectDim.height > 0) {
  14005. this.slDraggableRect.selectize({
  14006. points: 'l, r',
  14007. pointSize: 8,
  14008. pointType: 'rect'
  14009. }).resize({
  14010. constraint: {
  14011. minX: 0,
  14012. minY: 0,
  14013. maxX: w.globals.gridWidth,
  14014. maxY: w.globals.gridHeight
  14015. }
  14016. }).on('resizing', this.selectionDragging.bind(this, 'resizing'));
  14017. }
  14018. }
  14019. }, {
  14020. key: "preselectedSelection",
  14021. value: function preselectedSelection() {
  14022. var w = this.w;
  14023. var xyRatios = this.xyRatios;
  14024. if (!w.globals.zoomEnabled) {
  14025. if (typeof w.globals.selection !== 'undefined' && w.globals.selection !== null) {
  14026. this.drawSelectionRect(w.globals.selection);
  14027. } else {
  14028. if (w.config.chart.selection.xaxis.min !== undefined && w.config.chart.selection.xaxis.max !== undefined) {
  14029. var x = (w.config.chart.selection.xaxis.min - w.globals.minX) / xyRatios.xRatio;
  14030. var width = w.globals.gridWidth - (w.globals.maxX - w.config.chart.selection.xaxis.max) / xyRatios.xRatio - x;
  14031. var selectionRect = {
  14032. x: x,
  14033. y: 0,
  14034. width: width,
  14035. height: w.globals.gridHeight,
  14036. translateX: 0,
  14037. translateY: 0,
  14038. selectionEnabled: true
  14039. };
  14040. this.drawSelectionRect(selectionRect);
  14041. this.makeSelectionRectDraggable();
  14042. if (typeof w.config.chart.events.selection === 'function') {
  14043. w.config.chart.events.selection(this.ctx, {
  14044. xaxis: {
  14045. min: w.config.chart.selection.xaxis.min,
  14046. max: w.config.chart.selection.xaxis.max
  14047. },
  14048. yaxis: {}
  14049. });
  14050. }
  14051. }
  14052. }
  14053. }
  14054. }
  14055. }, {
  14056. key: "drawSelectionRect",
  14057. value: function drawSelectionRect(_ref2) {
  14058. var x = _ref2.x,
  14059. y = _ref2.y,
  14060. width = _ref2.width,
  14061. height = _ref2.height,
  14062. _ref2$translateX = _ref2.translateX,
  14063. translateX = _ref2$translateX === void 0 ? 0 : _ref2$translateX,
  14064. _ref2$translateY = _ref2.translateY,
  14065. translateY = _ref2$translateY === void 0 ? 0 : _ref2$translateY;
  14066. var w = this.w;
  14067. var zoomRect = this.zoomRect;
  14068. var selectionRect = this.selectionRect;
  14069. if (this.dragged || w.globals.selection !== null) {
  14070. var scalingAttrs = {
  14071. transform: 'translate(' + translateX + ', ' + translateY + ')'
  14072. }; // change styles based on zoom or selection
  14073. // zoom is Enabled and user has dragged, so draw blue rect
  14074. if (w.globals.zoomEnabled && this.dragged) {
  14075. if (width < 0) width = 1; // fixes apexcharts.js#1168
  14076. zoomRect.attr({
  14077. x: x,
  14078. y: y,
  14079. width: width,
  14080. height: height,
  14081. fill: w.config.chart.zoom.zoomedArea.fill.color,
  14082. 'fill-opacity': w.config.chart.zoom.zoomedArea.fill.opacity,
  14083. stroke: w.config.chart.zoom.zoomedArea.stroke.color,
  14084. 'stroke-width': w.config.chart.zoom.zoomedArea.stroke.width,
  14085. 'stroke-opacity': w.config.chart.zoom.zoomedArea.stroke.opacity
  14086. });
  14087. Graphics.setAttrs(zoomRect.node, scalingAttrs);
  14088. } // selection is enabled
  14089. if (w.globals.selectionEnabled) {
  14090. selectionRect.attr({
  14091. x: x,
  14092. y: y,
  14093. width: width > 0 ? width : 0,
  14094. height: height > 0 ? height : 0,
  14095. fill: w.config.chart.selection.fill.color,
  14096. 'fill-opacity': w.config.chart.selection.fill.opacity,
  14097. stroke: w.config.chart.selection.stroke.color,
  14098. 'stroke-width': w.config.chart.selection.stroke.width,
  14099. 'stroke-dasharray': w.config.chart.selection.stroke.dashArray,
  14100. 'stroke-opacity': w.config.chart.selection.stroke.opacity
  14101. });
  14102. Graphics.setAttrs(selectionRect.node, scalingAttrs);
  14103. }
  14104. }
  14105. }
  14106. }, {
  14107. key: "hideSelectionRect",
  14108. value: function hideSelectionRect(rect) {
  14109. if (rect) {
  14110. rect.attr({
  14111. x: 0,
  14112. y: 0,
  14113. width: 0,
  14114. height: 0
  14115. });
  14116. }
  14117. }
  14118. }, {
  14119. key: "selectionDrawing",
  14120. value: function selectionDrawing(_ref3) {
  14121. var context = _ref3.context,
  14122. zoomtype = _ref3.zoomtype;
  14123. var w = this.w;
  14124. var me = context;
  14125. var gridRectDim = this.gridRect.getBoundingClientRect();
  14126. var startX = me.startX - 1;
  14127. var startY = me.startY;
  14128. var inversedX = false;
  14129. var inversedY = false;
  14130. var selectionWidth = me.clientX - gridRectDim.left - startX;
  14131. var selectionHeight = me.clientY - gridRectDim.top - startY;
  14132. var selectionRect = {};
  14133. if (Math.abs(selectionWidth + startX) > w.globals.gridWidth) {
  14134. // user dragged the mouse outside drawing area to the right
  14135. selectionWidth = w.globals.gridWidth - startX;
  14136. } else if (me.clientX - gridRectDim.left < 0) {
  14137. // user dragged the mouse outside drawing area to the left
  14138. selectionWidth = startX;
  14139. } // inverse selection X
  14140. if (startX > me.clientX - gridRectDim.left) {
  14141. inversedX = true;
  14142. selectionWidth = Math.abs(selectionWidth);
  14143. } // inverse selection Y
  14144. if (startY > me.clientY - gridRectDim.top) {
  14145. inversedY = true;
  14146. selectionHeight = Math.abs(selectionHeight);
  14147. }
  14148. if (zoomtype === 'x') {
  14149. selectionRect = {
  14150. x: inversedX ? startX - selectionWidth : startX,
  14151. y: 0,
  14152. width: selectionWidth,
  14153. height: w.globals.gridHeight
  14154. };
  14155. } else if (zoomtype === 'y') {
  14156. selectionRect = {
  14157. x: 0,
  14158. y: inversedY ? startY - selectionHeight : startY,
  14159. width: w.globals.gridWidth,
  14160. height: selectionHeight
  14161. };
  14162. } else {
  14163. selectionRect = {
  14164. x: inversedX ? startX - selectionWidth : startX,
  14165. y: inversedY ? startY - selectionHeight : startY,
  14166. width: selectionWidth,
  14167. height: selectionHeight
  14168. };
  14169. }
  14170. me.drawSelectionRect(selectionRect);
  14171. me.selectionDragging('resizing');
  14172. return selectionRect;
  14173. }
  14174. }, {
  14175. key: "selectionDragging",
  14176. value: function selectionDragging(type, e) {
  14177. var _this3 = this;
  14178. var w = this.w;
  14179. var xyRatios = this.xyRatios;
  14180. var selRect = this.selectionRect;
  14181. var timerInterval = 0;
  14182. if (type === 'resizing') {
  14183. timerInterval = 30;
  14184. } // update selection when selection rect is dragged
  14185. var getSelAttr = function getSelAttr(attr) {
  14186. return parseFloat(selRect.node.getAttribute(attr));
  14187. };
  14188. var draggedProps = {
  14189. x: getSelAttr('x'),
  14190. y: getSelAttr('y'),
  14191. width: getSelAttr('width'),
  14192. height: getSelAttr('height')
  14193. };
  14194. w.globals.selection = draggedProps; // update selection ends
  14195. if (typeof w.config.chart.events.selection === 'function' && w.globals.selectionEnabled) {
  14196. // a small debouncer is required when resizing to avoid freezing the chart
  14197. clearTimeout(this.w.globals.selectionResizeTimer);
  14198. this.w.globals.selectionResizeTimer = window.setTimeout(function () {
  14199. var gridRectDim = _this3.gridRect.getBoundingClientRect();
  14200. var selectionRect = selRect.node.getBoundingClientRect();
  14201. var minX = w.globals.xAxisScale.niceMin + (selectionRect.left - gridRectDim.left) * xyRatios.xRatio;
  14202. var maxX = w.globals.xAxisScale.niceMin + (selectionRect.right - gridRectDim.left) * xyRatios.xRatio;
  14203. var minY = w.globals.yAxisScale[0].niceMin + (gridRectDim.bottom - selectionRect.bottom) * xyRatios.yRatio[0];
  14204. var maxY = w.globals.yAxisScale[0].niceMax - (selectionRect.top - gridRectDim.top) * xyRatios.yRatio[0];
  14205. var xyAxis = {
  14206. xaxis: {
  14207. min: minX,
  14208. max: maxX
  14209. },
  14210. yaxis: {
  14211. min: minY,
  14212. max: maxY
  14213. }
  14214. };
  14215. w.config.chart.events.selection(_this3.ctx, xyAxis);
  14216. if (w.config.chart.brush.enabled && w.config.chart.events.brushScrolled !== undefined) {
  14217. w.config.chart.events.brushScrolled(_this3.ctx, xyAxis);
  14218. }
  14219. }, timerInterval);
  14220. }
  14221. }
  14222. }, {
  14223. key: "selectionDrawn",
  14224. value: function selectionDrawn(_ref4) {
  14225. var context = _ref4.context,
  14226. zoomtype = _ref4.zoomtype;
  14227. var w = this.w;
  14228. var me = context;
  14229. var xyRatios = this.xyRatios;
  14230. var toolbar = this.ctx.toolbar;
  14231. if (me.startX > me.endX) {
  14232. var tempX = me.startX;
  14233. me.startX = me.endX;
  14234. me.endX = tempX;
  14235. }
  14236. if (me.startY > me.endY) {
  14237. var tempY = me.startY;
  14238. me.startY = me.endY;
  14239. me.endY = tempY;
  14240. }
  14241. var xLowestValue = undefined;
  14242. var xHighestValue = undefined;
  14243. if (!w.globals.isRangeBar) {
  14244. xLowestValue = w.globals.xAxisScale.niceMin + me.startX * xyRatios.xRatio;
  14245. xHighestValue = w.globals.xAxisScale.niceMin + me.endX * xyRatios.xRatio;
  14246. } else {
  14247. xLowestValue = w.globals.yAxisScale[0].niceMin + me.startX * xyRatios.invertedYRatio;
  14248. xHighestValue = w.globals.yAxisScale[0].niceMin + me.endX * xyRatios.invertedYRatio;
  14249. } // TODO: we will consider the 1st y axis values here for getting highest and lowest y
  14250. var yHighestValue = [];
  14251. var yLowestValue = [];
  14252. w.config.yaxis.forEach(function (yaxe, index) {
  14253. yHighestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.startY);
  14254. yLowestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.endY);
  14255. });
  14256. if (me.dragged && (me.dragX > 10 || me.dragY > 10) && xLowestValue !== xHighestValue) {
  14257. if (w.globals.zoomEnabled) {
  14258. var yaxis = Utils$1.clone(w.globals.initialConfig.yaxis);
  14259. var xaxis = Utils$1.clone(w.globals.initialConfig.xaxis);
  14260. w.globals.zoomed = true;
  14261. if (w.config.xaxis.convertedCatToNumeric) {
  14262. xLowestValue = Math.floor(xLowestValue);
  14263. xHighestValue = Math.floor(xHighestValue);
  14264. if (xLowestValue < 1) {
  14265. xLowestValue = 1;
  14266. xHighestValue = w.globals.dataPoints;
  14267. }
  14268. if (xHighestValue - xLowestValue < 2) {
  14269. xHighestValue = xLowestValue + 1;
  14270. }
  14271. }
  14272. if (zoomtype === 'xy' || zoomtype === 'x') {
  14273. xaxis = {
  14274. min: xLowestValue,
  14275. max: xHighestValue
  14276. };
  14277. }
  14278. if (zoomtype === 'xy' || zoomtype === 'y') {
  14279. yaxis.forEach(function (yaxe, index) {
  14280. yaxis[index].min = yLowestValue[index];
  14281. yaxis[index].max = yHighestValue[index];
  14282. });
  14283. }
  14284. if (w.config.chart.zoom.autoScaleYaxis) {
  14285. var scale = new Range$1(me.ctx);
  14286. yaxis = scale.autoScaleY(me.ctx, yaxis, {
  14287. xaxis: xaxis
  14288. });
  14289. }
  14290. if (toolbar) {
  14291. var beforeZoomRange = toolbar.getBeforeZoomRange(xaxis, yaxis);
  14292. if (beforeZoomRange) {
  14293. xaxis = beforeZoomRange.xaxis ? beforeZoomRange.xaxis : xaxis;
  14294. yaxis = beforeZoomRange.yaxis ? beforeZoomRange.yaxis : yaxis;
  14295. }
  14296. }
  14297. var options = {
  14298. xaxis: xaxis
  14299. };
  14300. if (!w.config.chart.group) {
  14301. // if chart in a group, prevent yaxis update here
  14302. // fix issue #650
  14303. options.yaxis = yaxis;
  14304. }
  14305. me.ctx.updateHelpers._updateOptions(options, false, me.w.config.chart.animations.dynamicAnimation.enabled);
  14306. if (typeof w.config.chart.events.zoomed === 'function') {
  14307. toolbar.zoomCallback(xaxis, yaxis);
  14308. }
  14309. } else if (w.globals.selectionEnabled) {
  14310. var _yaxis = null;
  14311. var _xaxis = null;
  14312. _xaxis = {
  14313. min: xLowestValue,
  14314. max: xHighestValue
  14315. };
  14316. if (zoomtype === 'xy' || zoomtype === 'y') {
  14317. _yaxis = Utils$1.clone(w.config.yaxis);
  14318. _yaxis.forEach(function (yaxe, index) {
  14319. _yaxis[index].min = yLowestValue[index];
  14320. _yaxis[index].max = yHighestValue[index];
  14321. });
  14322. }
  14323. w.globals.selection = me.selection;
  14324. if (typeof w.config.chart.events.selection === 'function') {
  14325. w.config.chart.events.selection(me.ctx, {
  14326. xaxis: _xaxis,
  14327. yaxis: _yaxis
  14328. });
  14329. }
  14330. }
  14331. }
  14332. }
  14333. }, {
  14334. key: "panDragging",
  14335. value: function panDragging(_ref5) {
  14336. var context = _ref5.context;
  14337. var w = this.w;
  14338. var me = context; // check to make sure there is data to compare against
  14339. if (typeof w.globals.lastClientPosition.x !== 'undefined') {
  14340. // get the change from last position to this position
  14341. var deltaX = w.globals.lastClientPosition.x - me.clientX;
  14342. 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
  14343. if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) {
  14344. this.moveDirection = 'left';
  14345. } else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) {
  14346. this.moveDirection = 'right';
  14347. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
  14348. this.moveDirection = 'up';
  14349. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) {
  14350. this.moveDirection = 'down';
  14351. }
  14352. } // set the new last position to the current for next time (to get the position of drag)
  14353. w.globals.lastClientPosition = {
  14354. x: me.clientX,
  14355. y: me.clientY
  14356. };
  14357. var xLowestValue = w.globals.isRangeBar ? w.globals.minY : w.globals.minX;
  14358. var xHighestValue = w.globals.isRangeBar ? w.globals.maxY : w.globals.maxX; // on a category, we don't pan continuosly as it causes bugs
  14359. if (!w.config.xaxis.convertedCatToNumeric) {
  14360. me.panScrolled(xLowestValue, xHighestValue);
  14361. }
  14362. }
  14363. }, {
  14364. key: "delayedPanScrolled",
  14365. value: function delayedPanScrolled() {
  14366. var w = this.w;
  14367. var newMinX = w.globals.minX;
  14368. var newMaxX = w.globals.maxX;
  14369. var centerX = (w.globals.maxX - w.globals.minX) / 2;
  14370. if (this.moveDirection === 'left') {
  14371. newMinX = w.globals.minX + centerX;
  14372. newMaxX = w.globals.maxX + centerX;
  14373. } else if (this.moveDirection === 'right') {
  14374. newMinX = w.globals.minX - centerX;
  14375. newMaxX = w.globals.maxX - centerX;
  14376. }
  14377. newMinX = Math.floor(newMinX);
  14378. newMaxX = Math.floor(newMaxX);
  14379. this.updateScrolledChart({
  14380. xaxis: {
  14381. min: newMinX,
  14382. max: newMaxX
  14383. }
  14384. }, newMinX, newMaxX);
  14385. }
  14386. }, {
  14387. key: "panScrolled",
  14388. value: function panScrolled(xLowestValue, xHighestValue) {
  14389. var w = this.w;
  14390. var xyRatios = this.xyRatios;
  14391. var yaxis = Utils$1.clone(w.globals.initialConfig.yaxis);
  14392. var xRatio = xyRatios.xRatio;
  14393. var minX = w.globals.minX;
  14394. var maxX = w.globals.maxX;
  14395. if (w.globals.isRangeBar) {
  14396. xRatio = xyRatios.invertedYRatio;
  14397. minX = w.globals.minY;
  14398. maxX = w.globals.maxY;
  14399. }
  14400. if (this.moveDirection === 'left') {
  14401. xLowestValue = minX + w.globals.gridWidth / 15 * xRatio;
  14402. xHighestValue = maxX + w.globals.gridWidth / 15 * xRatio;
  14403. } else if (this.moveDirection === 'right') {
  14404. xLowestValue = minX - w.globals.gridWidth / 15 * xRatio;
  14405. xHighestValue = maxX - w.globals.gridWidth / 15 * xRatio;
  14406. }
  14407. if (!w.globals.isRangeBar) {
  14408. if (xLowestValue < w.globals.initialMinX || xHighestValue > w.globals.initialMaxX) {
  14409. xLowestValue = minX;
  14410. xHighestValue = maxX;
  14411. }
  14412. }
  14413. var xaxis = {
  14414. min: xLowestValue,
  14415. max: xHighestValue
  14416. };
  14417. if (w.config.chart.zoom.autoScaleYaxis) {
  14418. var scale = new Range$1(this.ctx);
  14419. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  14420. xaxis: xaxis
  14421. });
  14422. }
  14423. var options = {
  14424. xaxis: {
  14425. min: xLowestValue,
  14426. max: xHighestValue
  14427. }
  14428. };
  14429. if (!w.config.chart.group) {
  14430. // if chart in a group, prevent yaxis update here
  14431. // fix issue #650
  14432. options.yaxis = yaxis;
  14433. }
  14434. this.updateScrolledChart(options, xLowestValue, xHighestValue);
  14435. }
  14436. }, {
  14437. key: "updateScrolledChart",
  14438. value: function updateScrolledChart(options, xLowestValue, xHighestValue) {
  14439. var w = this.w;
  14440. this.ctx.updateHelpers._updateOptions(options, false, false);
  14441. if (typeof w.config.chart.events.scrolled === 'function') {
  14442. w.config.chart.events.scrolled(this.ctx, {
  14443. xaxis: {
  14444. min: xLowestValue,
  14445. max: xHighestValue
  14446. }
  14447. });
  14448. }
  14449. }
  14450. }]);
  14451. return ZoomPanSelection;
  14452. }(Toolbar);
  14453. /**
  14454. * ApexCharts Tooltip.Utils Class to support Tooltip functionality.
  14455. *
  14456. * @module Tooltip.Utils
  14457. **/
  14458. var Utils = /*#__PURE__*/function () {
  14459. function Utils(tooltipContext) {
  14460. _classCallCheck(this, Utils);
  14461. this.w = tooltipContext.w;
  14462. this.ttCtx = tooltipContext;
  14463. this.ctx = tooltipContext.ctx;
  14464. }
  14465. /**
  14466. ** When hovering over series, you need to capture which series is being hovered on.
  14467. ** This function will return both capturedseries index as well as inner index of that series
  14468. * @memberof Utils
  14469. * @param {object}
  14470. * - hoverArea = the rect on which user hovers
  14471. * - elGrid = dimensions of the hover rect (it can be different than hoverarea)
  14472. */
  14473. _createClass(Utils, [{
  14474. key: "getNearestValues",
  14475. value: function getNearestValues(_ref) {
  14476. var hoverArea = _ref.hoverArea,
  14477. elGrid = _ref.elGrid,
  14478. clientX = _ref.clientX,
  14479. clientY = _ref.clientY;
  14480. var w = this.w;
  14481. var seriesBound = elGrid.getBoundingClientRect();
  14482. var hoverWidth = seriesBound.width;
  14483. var hoverHeight = seriesBound.height;
  14484. var xDivisor = hoverWidth / (w.globals.dataPoints - 1);
  14485. var yDivisor = hoverHeight / w.globals.dataPoints;
  14486. var hasBars = this.hasBars();
  14487. if ((w.globals.comboCharts || hasBars) && !w.config.xaxis.convertedCatToNumeric) {
  14488. xDivisor = hoverWidth / w.globals.dataPoints;
  14489. }
  14490. var hoverX = clientX - seriesBound.left - w.globals.barPadForNumericAxis;
  14491. var hoverY = clientY - seriesBound.top;
  14492. var notInRect = hoverX < 0 || hoverY < 0 || hoverX > hoverWidth || hoverY > hoverHeight;
  14493. if (notInRect) {
  14494. hoverArea.classList.remove('hovering-zoom');
  14495. hoverArea.classList.remove('hovering-pan');
  14496. } else {
  14497. if (w.globals.zoomEnabled) {
  14498. hoverArea.classList.remove('hovering-pan');
  14499. hoverArea.classList.add('hovering-zoom');
  14500. } else if (w.globals.panEnabled) {
  14501. hoverArea.classList.remove('hovering-zoom');
  14502. hoverArea.classList.add('hovering-pan');
  14503. }
  14504. }
  14505. var j = Math.round(hoverX / xDivisor);
  14506. var jHorz = Math.floor(hoverY / yDivisor);
  14507. if (hasBars && !w.config.xaxis.convertedCatToNumeric) {
  14508. j = Math.ceil(hoverX / xDivisor);
  14509. j = j - 1;
  14510. }
  14511. var capturedSeries = null;
  14512. var closest = null;
  14513. var seriesXValArr = [];
  14514. var seriesYValArr = []; //add extra values to show markers for the first points. Included both axes to avoid incorrect positioning of the marker
  14515. w.globals.seriesXvalues.forEach(function (value) {
  14516. seriesXValArr.push([value[0] + 0.000001].concat(value));
  14517. });
  14518. w.globals.seriesYvalues.forEach(function (value) {
  14519. seriesYValArr.push([value[0] + 0.000001].concat(value));
  14520. });
  14521. seriesXValArr = seriesXValArr.map(function (seriesXVal) {
  14522. return seriesXVal.filter(function (s) {
  14523. return Utils$1.isNumber(s);
  14524. });
  14525. });
  14526. seriesYValArr = seriesYValArr.map(function (seriesYVal) {
  14527. return seriesYVal.filter(function (s) {
  14528. return Utils$1.isNumber(s);
  14529. });
  14530. }); // 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
  14531. if (w.globals.isXNumeric) {
  14532. // Change origin of cursor position so that we can compute the relative nearest point to the cursor on our chart
  14533. // we only need to scale because all points are relative to the bounds.left and bounds.top => origin is virtually (0, 0)
  14534. var chartGridEl = this.ttCtx.getElGrid();
  14535. var chartGridElBoundingRect = chartGridEl.getBoundingClientRect();
  14536. var transformedHoverX = hoverX * (chartGridElBoundingRect.width / hoverWidth);
  14537. var transformedHoverY = hoverY * (chartGridElBoundingRect.height / hoverHeight);
  14538. closest = this.closestInMultiArray(transformedHoverX, transformedHoverY, seriesXValArr, seriesYValArr);
  14539. capturedSeries = closest.index;
  14540. j = closest.j;
  14541. if (capturedSeries !== null) {
  14542. // initial push, it should be a little smaller than the 1st val
  14543. seriesXValArr = w.globals.seriesXvalues[capturedSeries];
  14544. closest = this.closestInArray(transformedHoverX, seriesXValArr);
  14545. j = closest.index;
  14546. }
  14547. }
  14548. w.globals.capturedSeriesIndex = capturedSeries === null ? -1 : capturedSeries;
  14549. if (!j || j < 1) j = 0;
  14550. if (w.globals.isBarHorizontal) {
  14551. w.globals.capturedDataPointIndex = jHorz;
  14552. } else {
  14553. w.globals.capturedDataPointIndex = j;
  14554. }
  14555. return {
  14556. capturedSeries: capturedSeries,
  14557. j: w.globals.isBarHorizontal ? jHorz : j,
  14558. hoverX: hoverX,
  14559. hoverY: hoverY
  14560. };
  14561. }
  14562. }, {
  14563. key: "closestInMultiArray",
  14564. value: function closestInMultiArray(hoverX, hoverY, Xarrays, Yarrays) {
  14565. var w = this.w;
  14566. var activeIndex = 0;
  14567. var currIndex = null;
  14568. var j = -1;
  14569. if (w.globals.series.length > 1) {
  14570. activeIndex = this.getFirstActiveXArray(Xarrays);
  14571. } else {
  14572. currIndex = 0;
  14573. }
  14574. var currX = Xarrays[activeIndex][0];
  14575. var diffX = Math.abs(hoverX - currX); // find nearest point on x-axis
  14576. Xarrays.forEach(function (arrX) {
  14577. arrX.forEach(function (x, iX) {
  14578. var newDiff = Math.abs(hoverX - x);
  14579. if (newDiff < diffX) {
  14580. diffX = newDiff;
  14581. j = iX;
  14582. }
  14583. });
  14584. });
  14585. if (j !== -1) {
  14586. // find nearest graph on y-axis relevanted to nearest point on x-axis
  14587. var currY = Yarrays[activeIndex][j];
  14588. var diffY = Math.abs(hoverY - currY);
  14589. currIndex = activeIndex;
  14590. Yarrays.forEach(function (arrY, iAY) {
  14591. var newDiff = Math.abs(hoverY - arrY[j]);
  14592. if (newDiff < diffY) {
  14593. diffY = newDiff;
  14594. currIndex = iAY;
  14595. }
  14596. });
  14597. }
  14598. return {
  14599. index: currIndex,
  14600. j: j
  14601. };
  14602. }
  14603. }, {
  14604. key: "getFirstActiveXArray",
  14605. value: function getFirstActiveXArray(Xarrays) {
  14606. var w = this.w;
  14607. var activeIndex = 0;
  14608. var firstActiveSeriesIndex = Xarrays.map(function (xarr, index) {
  14609. return xarr.length > 0 ? index : -1;
  14610. });
  14611. for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
  14612. if (firstActiveSeriesIndex[a] !== -1 && w.globals.collapsedSeriesIndices.indexOf(a) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(a) === -1) {
  14613. activeIndex = firstActiveSeriesIndex[a];
  14614. break;
  14615. }
  14616. }
  14617. return activeIndex;
  14618. }
  14619. }, {
  14620. key: "closestInArray",
  14621. value: function closestInArray(val, arr) {
  14622. var curr = arr[0];
  14623. var currIndex = null;
  14624. var diff = Math.abs(val - curr);
  14625. for (var i = 0; i < arr.length; i++) {
  14626. var newdiff = Math.abs(val - arr[i]);
  14627. if (newdiff < diff) {
  14628. diff = newdiff;
  14629. currIndex = i;
  14630. }
  14631. }
  14632. return {
  14633. index: currIndex
  14634. };
  14635. }
  14636. /**
  14637. * When there are multiple series, it is possible to have different x values for each series.
  14638. * But it may be possible in those multiple series, that there is same x value for 2 or more
  14639. * series.
  14640. * @memberof Utils
  14641. * @param {int}
  14642. * - j = is the inner index of series -> (series[i][j])
  14643. * @return {bool}
  14644. */
  14645. }, {
  14646. key: "isXoverlap",
  14647. value: function isXoverlap(j) {
  14648. var w = this.w;
  14649. var xSameForAllSeriesJArr = [];
  14650. var seriesX = w.globals.seriesX.filter(function (s) {
  14651. return typeof s[0] !== 'undefined';
  14652. });
  14653. if (seriesX.length > 0) {
  14654. for (var i = 0; i < seriesX.length - 1; i++) {
  14655. if (typeof seriesX[i][j] !== 'undefined' && typeof seriesX[i + 1][j] !== 'undefined') {
  14656. if (seriesX[i][j] !== seriesX[i + 1][j]) {
  14657. xSameForAllSeriesJArr.push('unEqual');
  14658. }
  14659. }
  14660. }
  14661. }
  14662. if (xSameForAllSeriesJArr.length === 0) {
  14663. return true;
  14664. }
  14665. return false;
  14666. }
  14667. }, {
  14668. key: "isInitialSeriesSameLen",
  14669. value: function isInitialSeriesSameLen() {
  14670. var sameLen = true;
  14671. var initialSeries = this.w.globals.initialSeries;
  14672. for (var i = 0; i < initialSeries.length - 1; i++) {
  14673. if (initialSeries[i].data.length !== initialSeries[i + 1].data.length) {
  14674. sameLen = false;
  14675. break;
  14676. }
  14677. }
  14678. return sameLen;
  14679. }
  14680. }, {
  14681. key: "getBarsHeight",
  14682. value: function getBarsHeight(allbars) {
  14683. var bars = _toConsumableArray(allbars);
  14684. var totalHeight = bars.reduce(function (acc, bar) {
  14685. return acc + bar.getBBox().height;
  14686. }, 0);
  14687. return totalHeight;
  14688. }
  14689. }, {
  14690. key: "getElMarkers",
  14691. value: function getElMarkers() {
  14692. return this.w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers');
  14693. }
  14694. }, {
  14695. key: "getAllMarkers",
  14696. value: function getAllMarkers() {
  14697. // first get all marker parents. This parent class contains series-index
  14698. // which helps to sort the markers as they are dynamic
  14699. var markersWraps = this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers-wrap');
  14700. markersWraps = _toConsumableArray(markersWraps);
  14701. markersWraps.sort(function (a, b) {
  14702. return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
  14703. });
  14704. var markers = [];
  14705. markersWraps.forEach(function (m) {
  14706. markers.push(m.querySelector('.apexcharts-marker'));
  14707. });
  14708. return markers;
  14709. }
  14710. }, {
  14711. key: "hasMarkers",
  14712. value: function hasMarkers() {
  14713. var markers = this.getElMarkers();
  14714. return markers.length > 0;
  14715. }
  14716. }, {
  14717. key: "getElBars",
  14718. value: function getElBars() {
  14719. return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-boxPlot-series, .apexcharts-rangebar-series');
  14720. }
  14721. }, {
  14722. key: "hasBars",
  14723. value: function hasBars() {
  14724. var bars = this.getElBars();
  14725. return bars.length > 0;
  14726. }
  14727. }, {
  14728. key: "getHoverMarkerSize",
  14729. value: function getHoverMarkerSize(index) {
  14730. var w = this.w;
  14731. var hoverSize = w.config.markers.hover.size;
  14732. if (hoverSize === undefined) {
  14733. hoverSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  14734. }
  14735. return hoverSize;
  14736. }
  14737. }, {
  14738. key: "toggleAllTooltipSeriesGroups",
  14739. value: function toggleAllTooltipSeriesGroups(state) {
  14740. var w = this.w;
  14741. var ttCtx = this.ttCtx;
  14742. if (ttCtx.allTooltipSeriesGroups.length === 0) {
  14743. ttCtx.allTooltipSeriesGroups = w.globals.dom.baseEl.querySelectorAll('.apexcharts-tooltip-series-group');
  14744. }
  14745. var allTooltipSeriesGroups = ttCtx.allTooltipSeriesGroups;
  14746. for (var i = 0; i < allTooltipSeriesGroups.length; i++) {
  14747. if (state === 'enable') {
  14748. allTooltipSeriesGroups[i].classList.add('apexcharts-active');
  14749. allTooltipSeriesGroups[i].style.display = w.config.tooltip.items.display;
  14750. } else {
  14751. allTooltipSeriesGroups[i].classList.remove('apexcharts-active');
  14752. allTooltipSeriesGroups[i].style.display = 'none';
  14753. }
  14754. }
  14755. }
  14756. }]);
  14757. return Utils;
  14758. }();
  14759. /**
  14760. * ApexCharts Tooltip.Labels Class to draw texts on the tooltip.
  14761. * This file deals with printing actual text on the tooltip.
  14762. *
  14763. * @module Tooltip.Labels
  14764. **/
  14765. var Labels = /*#__PURE__*/function () {
  14766. function Labels(tooltipContext) {
  14767. _classCallCheck(this, Labels);
  14768. this.w = tooltipContext.w;
  14769. this.ctx = tooltipContext.ctx;
  14770. this.ttCtx = tooltipContext;
  14771. this.tooltipUtil = new Utils(tooltipContext);
  14772. }
  14773. _createClass(Labels, [{
  14774. key: "drawSeriesTexts",
  14775. value: function drawSeriesTexts(_ref) {
  14776. var _ref$shared = _ref.shared,
  14777. shared = _ref$shared === void 0 ? true : _ref$shared,
  14778. ttItems = _ref.ttItems,
  14779. _ref$i = _ref.i,
  14780. i = _ref$i === void 0 ? 0 : _ref$i,
  14781. _ref$j = _ref.j,
  14782. j = _ref$j === void 0 ? null : _ref$j,
  14783. y1 = _ref.y1,
  14784. y2 = _ref.y2,
  14785. e = _ref.e;
  14786. var w = this.w;
  14787. if (w.config.tooltip.custom !== undefined) {
  14788. this.handleCustomTooltip({
  14789. i: i,
  14790. j: j,
  14791. y1: y1,
  14792. y2: y2,
  14793. w: w
  14794. });
  14795. } else {
  14796. this.toggleActiveInactiveSeries(shared);
  14797. }
  14798. var values = this.getValuesToPrint({
  14799. i: i,
  14800. j: j
  14801. });
  14802. this.printLabels({
  14803. i: i,
  14804. j: j,
  14805. values: values,
  14806. ttItems: ttItems,
  14807. shared: shared,
  14808. e: e
  14809. }); // Re-calculate tooltip dimensions now that we have drawn the text
  14810. var tooltipEl = this.ttCtx.getElTooltip();
  14811. this.ttCtx.tooltipRect.ttWidth = tooltipEl.getBoundingClientRect().width;
  14812. this.ttCtx.tooltipRect.ttHeight = tooltipEl.getBoundingClientRect().height;
  14813. }
  14814. }, {
  14815. key: "printLabels",
  14816. value: function printLabels(_ref2) {
  14817. var _this = this;
  14818. var i = _ref2.i,
  14819. j = _ref2.j,
  14820. values = _ref2.values,
  14821. ttItems = _ref2.ttItems,
  14822. shared = _ref2.shared,
  14823. e = _ref2.e;
  14824. var w = this.w;
  14825. var val;
  14826. var goalVals = [];
  14827. var hasGoalValues = function hasGoalValues(gi) {
  14828. return w.globals.seriesGoals[gi] && w.globals.seriesGoals[gi][j] && Array.isArray(w.globals.seriesGoals[gi][j]);
  14829. };
  14830. var xVal = values.xVal,
  14831. zVal = values.zVal,
  14832. xAxisTTVal = values.xAxisTTVal;
  14833. var seriesName = '';
  14834. var pColor = w.globals.colors[i]; // The pColor here is for the markers inside tooltip
  14835. if (j !== null && w.config.plotOptions.bar.distributed) {
  14836. pColor = w.globals.colors[j];
  14837. }
  14838. var _loop = function _loop(t, inverset) {
  14839. var f = _this.getFormatters(i);
  14840. seriesName = _this.getSeriesName({
  14841. fn: f.yLbTitleFormatter,
  14842. index: i,
  14843. seriesIndex: i,
  14844. j: j
  14845. });
  14846. if (w.config.chart.type === 'treemap') {
  14847. seriesName = f.yLbTitleFormatter(String(w.config.series[i].data[j].x), {
  14848. series: w.globals.series,
  14849. seriesIndex: i,
  14850. dataPointIndex: j,
  14851. w: w
  14852. });
  14853. }
  14854. var tIndex = w.config.tooltip.inverseOrder ? inverset : t;
  14855. if (w.globals.axisCharts) {
  14856. var getValBySeriesIndex = function getValBySeriesIndex(index) {
  14857. return f.yLbFormatter(w.globals.series[index][j], {
  14858. series: w.globals.series,
  14859. seriesIndex: index,
  14860. dataPointIndex: j,
  14861. w: w
  14862. });
  14863. };
  14864. if (shared) {
  14865. f = _this.getFormatters(tIndex);
  14866. seriesName = _this.getSeriesName({
  14867. fn: f.yLbTitleFormatter,
  14868. index: tIndex,
  14869. seriesIndex: i,
  14870. j: j
  14871. });
  14872. pColor = w.globals.colors[tIndex];
  14873. val = getValBySeriesIndex(tIndex);
  14874. if (hasGoalValues(tIndex)) {
  14875. goalVals = w.globals.seriesGoals[tIndex][j].map(function (goal) {
  14876. return {
  14877. attrs: goal,
  14878. val: f.yLbFormatter(goal.value, {
  14879. seriesIndex: tIndex,
  14880. dataPointIndex: j,
  14881. w: w
  14882. })
  14883. };
  14884. });
  14885. }
  14886. } else {
  14887. var _e$target;
  14888. // get a color from a hover area (if it's a line pattern then get from a first line)
  14889. var targetFill = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.getAttribute('fill');
  14890. if (targetFill) {
  14891. pColor = targetFill.indexOf("url") !== -1 ? document.querySelector(targetFill.substr(4).slice(0, -1)).childNodes[0].getAttribute("stroke") : targetFill;
  14892. }
  14893. val = getValBySeriesIndex(i);
  14894. if (hasGoalValues(i) && Array.isArray(w.globals.seriesGoals[i][j])) {
  14895. goalVals = w.globals.seriesGoals[i][j].map(function (goal) {
  14896. return {
  14897. attrs: goal,
  14898. val: f.yLbFormatter(goal.value, {
  14899. seriesIndex: i,
  14900. dataPointIndex: j,
  14901. w: w
  14902. })
  14903. };
  14904. });
  14905. }
  14906. }
  14907. } // for pie / donuts
  14908. if (j === null) {
  14909. val = f.yLbFormatter(w.globals.series[i], _objectSpread2(_objectSpread2({}, w), {}, {
  14910. seriesIndex: i,
  14911. dataPointIndex: i
  14912. }));
  14913. }
  14914. _this.DOMHandling({
  14915. i: i,
  14916. t: tIndex,
  14917. j: j,
  14918. ttItems: ttItems,
  14919. values: {
  14920. val: val,
  14921. goalVals: goalVals,
  14922. xVal: xVal,
  14923. xAxisTTVal: xAxisTTVal,
  14924. zVal: zVal
  14925. },
  14926. seriesName: seriesName,
  14927. shared: shared,
  14928. pColor: pColor
  14929. });
  14930. };
  14931. for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) {
  14932. _loop(t, inverset);
  14933. }
  14934. }
  14935. }, {
  14936. key: "getFormatters",
  14937. value: function getFormatters(i) {
  14938. var w = this.w;
  14939. var yLbFormatter = w.globals.yLabelFormatters[i];
  14940. var yLbTitleFormatter;
  14941. if (w.globals.ttVal !== undefined) {
  14942. if (Array.isArray(w.globals.ttVal)) {
  14943. yLbFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].formatter;
  14944. yLbTitleFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].title && w.globals.ttVal[i].title.formatter;
  14945. } else {
  14946. yLbFormatter = w.globals.ttVal.formatter;
  14947. if (typeof w.globals.ttVal.title.formatter === 'function') {
  14948. yLbTitleFormatter = w.globals.ttVal.title.formatter;
  14949. }
  14950. }
  14951. } else {
  14952. yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  14953. }
  14954. if (typeof yLbFormatter !== 'function') {
  14955. if (w.globals.yLabelFormatters[0]) {
  14956. yLbFormatter = w.globals.yLabelFormatters[0];
  14957. } else {
  14958. yLbFormatter = function yLbFormatter(label) {
  14959. return label;
  14960. };
  14961. }
  14962. }
  14963. if (typeof yLbTitleFormatter !== 'function') {
  14964. yLbTitleFormatter = function yLbTitleFormatter(label) {
  14965. return label;
  14966. };
  14967. }
  14968. return {
  14969. yLbFormatter: yLbFormatter,
  14970. yLbTitleFormatter: yLbTitleFormatter
  14971. };
  14972. }
  14973. }, {
  14974. key: "getSeriesName",
  14975. value: function getSeriesName(_ref3) {
  14976. var fn = _ref3.fn,
  14977. index = _ref3.index,
  14978. seriesIndex = _ref3.seriesIndex,
  14979. j = _ref3.j;
  14980. var w = this.w;
  14981. return fn(String(w.globals.seriesNames[index]), {
  14982. series: w.globals.series,
  14983. seriesIndex: seriesIndex,
  14984. dataPointIndex: j,
  14985. w: w
  14986. });
  14987. }
  14988. }, {
  14989. key: "DOMHandling",
  14990. value: function DOMHandling(_ref4) {
  14991. _ref4.i;
  14992. var t = _ref4.t,
  14993. j = _ref4.j,
  14994. ttItems = _ref4.ttItems,
  14995. values = _ref4.values,
  14996. seriesName = _ref4.seriesName,
  14997. shared = _ref4.shared,
  14998. pColor = _ref4.pColor;
  14999. var w = this.w;
  15000. var ttCtx = this.ttCtx;
  15001. var val = values.val,
  15002. goalVals = values.goalVals,
  15003. xVal = values.xVal,
  15004. xAxisTTVal = values.xAxisTTVal,
  15005. zVal = values.zVal;
  15006. var ttItemsChildren = null;
  15007. ttItemsChildren = ttItems[t].children;
  15008. if (w.config.tooltip.fillSeriesColor) {
  15009. ttItems[t].style.backgroundColor = pColor;
  15010. ttItemsChildren[0].style.display = 'none';
  15011. }
  15012. if (ttCtx.showTooltipTitle) {
  15013. if (ttCtx.tooltipTitle === null) {
  15014. // get it once if null, and store it in class property
  15015. ttCtx.tooltipTitle = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-title');
  15016. }
  15017. ttCtx.tooltipTitle.innerHTML = xVal;
  15018. } // if xaxis tooltip is constructed, we need to replace the innerHTML
  15019. if (ttCtx.isXAxisTooltipEnabled) {
  15020. ttCtx.xaxisTooltipText.innerHTML = xAxisTTVal !== '' ? xAxisTTVal : xVal;
  15021. }
  15022. var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-y-label');
  15023. if (ttYLabel) {
  15024. ttYLabel.innerHTML = seriesName ? seriesName : '';
  15025. }
  15026. var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-y-value');
  15027. if (ttYVal) {
  15028. ttYVal.innerHTML = typeof val !== 'undefined' ? val : '';
  15029. }
  15030. if (ttItemsChildren[0] && ttItemsChildren[0].classList.contains('apexcharts-tooltip-marker')) {
  15031. if (w.config.tooltip.marker.fillColors && Array.isArray(w.config.tooltip.marker.fillColors)) {
  15032. pColor = w.config.tooltip.marker.fillColors[t];
  15033. }
  15034. ttItemsChildren[0].style.backgroundColor = pColor;
  15035. }
  15036. if (!w.config.tooltip.marker.show) {
  15037. ttItemsChildren[0].style.display = 'none';
  15038. }
  15039. var ttGLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-goals-label');
  15040. var ttGVal = ttItems[t].querySelector('.apexcharts-tooltip-text-goals-value');
  15041. if (goalVals.length && w.globals.seriesGoals[t]) {
  15042. var createGoalsHtml = function createGoalsHtml() {
  15043. var gLabels = '<div >';
  15044. var gVals = '<div>';
  15045. goalVals.forEach(function (goal, gi) {
  15046. gLabels += " <div style=\"display: flex\"><span class=\"apexcharts-tooltip-marker\" style=\"background-color: ".concat(goal.attrs.strokeColor, "; height: 3px; border-radius: 0; top: 5px;\"></span> ").concat(goal.attrs.name, "</div>");
  15047. gVals += "<div>".concat(goal.val, "</div>");
  15048. });
  15049. ttGLabel.innerHTML = gLabels + "</div>";
  15050. ttGVal.innerHTML = gVals + "</div>";
  15051. };
  15052. if (shared) {
  15053. if (w.globals.seriesGoals[t][j] && Array.isArray(w.globals.seriesGoals[t][j])) {
  15054. createGoalsHtml();
  15055. } else {
  15056. ttGLabel.innerHTML = '';
  15057. ttGVal.innerHTML = '';
  15058. }
  15059. } else {
  15060. createGoalsHtml();
  15061. }
  15062. } else {
  15063. ttGLabel.innerHTML = '';
  15064. ttGVal.innerHTML = '';
  15065. }
  15066. if (zVal !== null) {
  15067. var ttZLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-z-label');
  15068. ttZLabel.innerHTML = w.config.tooltip.z.title;
  15069. var ttZVal = ttItems[t].querySelector('.apexcharts-tooltip-text-z-value');
  15070. ttZVal.innerHTML = typeof zVal !== 'undefined' ? zVal : '';
  15071. }
  15072. if (shared && ttItemsChildren[0]) {
  15073. // hide when no Val or series collapsed
  15074. if (typeof val === 'undefined' || val === null || w.globals.ancillaryCollapsedSeriesIndices.indexOf(t) > -1 || w.globals.collapsedSeriesIndices.indexOf(t) > -1) {
  15075. ttItemsChildren[0].parentNode.style.display = 'none';
  15076. } else {
  15077. ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display;
  15078. } // TODO: issue #1240 needs to be looked at again. commenting it because this also hides single series values with 0 in it (shared tooltip)
  15079. // if (w.globals.stackedSeriesTotals[j] === 0) {
  15080. // // shared tooltip and all values are null, so we need to hide the x value too
  15081. // let allYZeroForJ = false
  15082. // for (let si = 1; si < w.globals.seriesYvalues.length; si++) {
  15083. // if (
  15084. // w.globals.seriesYvalues[si][j] ===
  15085. // w.globals.seriesYvalues[si - 1][j]
  15086. // ) {
  15087. // allYZeroForJ = true
  15088. // }
  15089. // }
  15090. // if (allYZeroForJ) {
  15091. // ttCtx.tooltipTitle.style.display = 'none'
  15092. // } else {
  15093. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  15094. // }
  15095. // } else {
  15096. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  15097. // }
  15098. }
  15099. }
  15100. }, {
  15101. key: "toggleActiveInactiveSeries",
  15102. value: function toggleActiveInactiveSeries(shared) {
  15103. var w = this.w;
  15104. if (shared) {
  15105. // make all tooltips active
  15106. this.tooltipUtil.toggleAllTooltipSeriesGroups('enable');
  15107. } else {
  15108. // disable all tooltip text groups
  15109. this.tooltipUtil.toggleAllTooltipSeriesGroups('disable'); // enable the first tooltip text group
  15110. var firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-series-group');
  15111. if (firstTooltipSeriesGroup) {
  15112. firstTooltipSeriesGroup.classList.add('apexcharts-active');
  15113. firstTooltipSeriesGroup.style.display = w.config.tooltip.items.display;
  15114. }
  15115. }
  15116. }
  15117. }, {
  15118. key: "getValuesToPrint",
  15119. value: function getValuesToPrint(_ref5) {
  15120. var i = _ref5.i,
  15121. j = _ref5.j;
  15122. var w = this.w;
  15123. var filteredSeriesX = this.ctx.series.filteredSeriesX();
  15124. var xVal = '';
  15125. var xAxisTTVal = '';
  15126. var zVal = null;
  15127. var val = null;
  15128. var customFormatterOpts = {
  15129. series: w.globals.series,
  15130. seriesIndex: i,
  15131. dataPointIndex: j,
  15132. w: w
  15133. };
  15134. var zFormatter = w.globals.ttZFormatter;
  15135. if (j === null) {
  15136. val = w.globals.series[i];
  15137. } else {
  15138. if (w.globals.isXNumeric && w.config.chart.type !== 'treemap') {
  15139. xVal = filteredSeriesX[i][j];
  15140. if (filteredSeriesX[i].length === 0) {
  15141. // a series (possibly the first one) might be collapsed, so get the next active index
  15142. var firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(filteredSeriesX);
  15143. xVal = filteredSeriesX[firstActiveSeriesIndex][j];
  15144. }
  15145. } else {
  15146. xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : '';
  15147. }
  15148. }
  15149. var bufferXVal = xVal;
  15150. if (w.globals.isXNumeric && w.config.xaxis.type === 'datetime') {
  15151. var xFormat = new Formatters(this.ctx);
  15152. xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal, bufferXVal, {
  15153. i: undefined,
  15154. dateFormatter: new DateTime(this.ctx).formatDate,
  15155. w: this.w
  15156. });
  15157. } else {
  15158. if (w.globals.isBarHorizontal) {
  15159. xVal = w.globals.yLabelFormatters[0](bufferXVal, customFormatterOpts);
  15160. } else {
  15161. xVal = w.globals.xLabelFormatter(bufferXVal, customFormatterOpts);
  15162. }
  15163. } // override default x-axis formatter with tooltip formatter
  15164. if (w.config.tooltip.x.formatter !== undefined) {
  15165. xVal = w.globals.ttKeyFormatter(bufferXVal, customFormatterOpts);
  15166. }
  15167. if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[i].length > 0) {
  15168. zVal = zFormatter(w.globals.seriesZ[i][j], w);
  15169. }
  15170. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  15171. xAxisTTVal = w.globals.xaxisTooltipFormatter(bufferXVal, customFormatterOpts);
  15172. } else {
  15173. xAxisTTVal = xVal;
  15174. }
  15175. return {
  15176. val: Array.isArray(val) ? val.join(' ') : val,
  15177. xVal: Array.isArray(xVal) ? xVal.join(' ') : xVal,
  15178. xAxisTTVal: Array.isArray(xAxisTTVal) ? xAxisTTVal.join(' ') : xAxisTTVal,
  15179. zVal: zVal
  15180. };
  15181. }
  15182. }, {
  15183. key: "handleCustomTooltip",
  15184. value: function handleCustomTooltip(_ref6) {
  15185. var i = _ref6.i,
  15186. j = _ref6.j,
  15187. y1 = _ref6.y1,
  15188. y2 = _ref6.y2,
  15189. w = _ref6.w;
  15190. var tooltipEl = this.ttCtx.getElTooltip();
  15191. var fn = w.config.tooltip.custom;
  15192. if (Array.isArray(fn) && fn[i]) {
  15193. fn = fn[i];
  15194. } // override everything with a custom html tooltip and replace it
  15195. tooltipEl.innerHTML = fn({
  15196. ctx: this.ctx,
  15197. series: w.globals.series,
  15198. seriesIndex: i,
  15199. dataPointIndex: j,
  15200. y1: y1,
  15201. y2: y2,
  15202. w: w
  15203. });
  15204. }
  15205. }]);
  15206. return Labels;
  15207. }();
  15208. /**
  15209. * ApexCharts Tooltip.Position Class to move the tooltip based on x and y position.
  15210. *
  15211. * @module Tooltip.Position
  15212. **/
  15213. var Position = /*#__PURE__*/function () {
  15214. function Position(tooltipContext) {
  15215. _classCallCheck(this, Position);
  15216. this.ttCtx = tooltipContext;
  15217. this.ctx = tooltipContext.ctx;
  15218. this.w = tooltipContext.w;
  15219. }
  15220. /**
  15221. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  15222. * Along with this, this function also calls the xaxisMove function
  15223. * @memberof Position
  15224. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  15225. */
  15226. _createClass(Position, [{
  15227. key: "moveXCrosshairs",
  15228. value: function moveXCrosshairs(cx) {
  15229. var j = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  15230. var ttCtx = this.ttCtx;
  15231. var w = this.w;
  15232. var xcrosshairs = ttCtx.getElXCrosshairs();
  15233. var x = cx - ttCtx.xcrosshairsWidth / 2;
  15234. var tickAmount = w.globals.labels.slice().length;
  15235. if (j !== null) {
  15236. x = w.globals.gridWidth / tickAmount * j;
  15237. }
  15238. if (xcrosshairs !== null && !w.globals.isBarHorizontal) {
  15239. xcrosshairs.setAttribute('x', x);
  15240. xcrosshairs.setAttribute('x1', x);
  15241. xcrosshairs.setAttribute('x2', x);
  15242. xcrosshairs.setAttribute('y2', w.globals.gridHeight);
  15243. xcrosshairs.classList.add('apexcharts-active');
  15244. }
  15245. if (x < 0) {
  15246. x = 0;
  15247. }
  15248. if (x > w.globals.gridWidth) {
  15249. x = w.globals.gridWidth;
  15250. }
  15251. if (ttCtx.isXAxisTooltipEnabled) {
  15252. var tx = x;
  15253. if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') {
  15254. tx = x + ttCtx.xcrosshairsWidth / 2;
  15255. }
  15256. this.moveXAxisTooltip(tx);
  15257. }
  15258. }
  15259. /**
  15260. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  15261. * Along with this, this function also calls the xaxisMove function
  15262. * @memberof Position
  15263. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  15264. */
  15265. }, {
  15266. key: "moveYCrosshairs",
  15267. value: function moveYCrosshairs(cy) {
  15268. var ttCtx = this.ttCtx;
  15269. if (ttCtx.ycrosshairs !== null) {
  15270. Graphics.setAttrs(ttCtx.ycrosshairs, {
  15271. y1: cy,
  15272. y2: cy
  15273. });
  15274. }
  15275. if (ttCtx.ycrosshairsHidden !== null) {
  15276. Graphics.setAttrs(ttCtx.ycrosshairsHidden, {
  15277. y1: cy,
  15278. y2: cy
  15279. });
  15280. }
  15281. }
  15282. /**
  15283. ** AxisTooltip is the small rectangle which appears on x axis with x value, when user moves
  15284. * @memberof Position
  15285. * @param {int} - cx = point's x position, wherever point's x is, you need to move
  15286. */
  15287. }, {
  15288. key: "moveXAxisTooltip",
  15289. value: function moveXAxisTooltip(cx) {
  15290. var w = this.w;
  15291. var ttCtx = this.ttCtx;
  15292. if (ttCtx.xaxisTooltip !== null && ttCtx.xcrosshairsWidth !== 0) {
  15293. ttCtx.xaxisTooltip.classList.add('apexcharts-active');
  15294. var cy = ttCtx.xaxisOffY + w.config.xaxis.tooltip.offsetY + w.globals.translateY + 1 + w.config.xaxis.offsetY;
  15295. var xaxisTTText = ttCtx.xaxisTooltip.getBoundingClientRect();
  15296. var xaxisTTTextWidth = xaxisTTText.width;
  15297. cx = cx - xaxisTTTextWidth / 2;
  15298. if (!isNaN(cx)) {
  15299. cx = cx + w.globals.translateX;
  15300. var textRect = 0;
  15301. var graphics = new Graphics(this.ctx);
  15302. textRect = graphics.getTextRects(ttCtx.xaxisTooltipText.innerHTML);
  15303. ttCtx.xaxisTooltipText.style.minWidth = textRect.width + 'px';
  15304. ttCtx.xaxisTooltip.style.left = cx + 'px';
  15305. ttCtx.xaxisTooltip.style.top = cy + 'px';
  15306. }
  15307. }
  15308. }
  15309. }, {
  15310. key: "moveYAxisTooltip",
  15311. value: function moveYAxisTooltip(index) {
  15312. var w = this.w;
  15313. var ttCtx = this.ttCtx;
  15314. if (ttCtx.yaxisTTEls === null) {
  15315. ttCtx.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  15316. }
  15317. var ycrosshairsHiddenRectY1 = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1'), 10);
  15318. var cy = w.globals.translateY + ycrosshairsHiddenRectY1;
  15319. var yAxisTTRect = ttCtx.yaxisTTEls[index].getBoundingClientRect();
  15320. var yAxisTTHeight = yAxisTTRect.height;
  15321. var cx = w.globals.translateYAxisX[index] - 2;
  15322. if (w.config.yaxis[index].opposite) {
  15323. cx = cx - 26;
  15324. }
  15325. cy = cy - yAxisTTHeight / 2;
  15326. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1) {
  15327. ttCtx.yaxisTTEls[index].classList.add('apexcharts-active');
  15328. ttCtx.yaxisTTEls[index].style.top = cy + 'px';
  15329. ttCtx.yaxisTTEls[index].style.left = cx + w.config.yaxis[index].tooltip.offsetX + 'px';
  15330. } else {
  15331. ttCtx.yaxisTTEls[index].classList.remove('apexcharts-active');
  15332. }
  15333. }
  15334. /**
  15335. ** moves the whole tooltip by changing x, y attrs
  15336. * @memberof Position
  15337. * @param {int} - cx = point's x position, wherever point's x is, you need to move tooltip
  15338. * @param {int} - cy = point's y position, wherever point's y is, you need to move tooltip
  15339. * @param {int} - r = point's radius
  15340. */
  15341. }, {
  15342. key: "moveTooltip",
  15343. value: function moveTooltip(cx, cy) {
  15344. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  15345. var w = this.w;
  15346. var ttCtx = this.ttCtx;
  15347. var tooltipEl = ttCtx.getElTooltip();
  15348. var tooltipRect = ttCtx.tooltipRect;
  15349. var pointR = r !== null ? parseFloat(r) : 1;
  15350. var x = parseFloat(cx) + pointR + 5;
  15351. var y = parseFloat(cy) + pointR / 2; // - tooltipRect.ttHeight / 2
  15352. if (x > w.globals.gridWidth / 2) {
  15353. x = x - tooltipRect.ttWidth - pointR - 10;
  15354. }
  15355. if (x > w.globals.gridWidth - tooltipRect.ttWidth - 10) {
  15356. x = w.globals.gridWidth - tooltipRect.ttWidth;
  15357. }
  15358. if (x < -20) {
  15359. x = -20;
  15360. }
  15361. if (w.config.tooltip.followCursor) {
  15362. var elGrid = ttCtx.getElGrid();
  15363. var seriesBound = elGrid.getBoundingClientRect();
  15364. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top - tooltipRect.ttHeight / 2;
  15365. } else {
  15366. if (!w.globals.isBarHorizontal) {
  15367. if (tooltipRect.ttHeight / 2 + y > w.globals.gridHeight) {
  15368. y = w.globals.gridHeight - tooltipRect.ttHeight + w.globals.translateY;
  15369. }
  15370. if (y < 0) {
  15371. y = 0;
  15372. }
  15373. }
  15374. }
  15375. if (!isNaN(x)) {
  15376. x = x + w.globals.translateX;
  15377. tooltipEl.style.left = x + 'px';
  15378. tooltipEl.style.top = y + 'px';
  15379. }
  15380. }
  15381. }, {
  15382. key: "moveMarkers",
  15383. value: function moveMarkers(i, j) {
  15384. var w = this.w;
  15385. var ttCtx = this.ttCtx;
  15386. if (w.globals.markers.size[i] > 0) {
  15387. var allPoints = w.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(i, "'] .apexcharts-marker"));
  15388. for (var p = 0; p < allPoints.length; p++) {
  15389. if (parseInt(allPoints[p].getAttribute('rel'), 10) === j) {
  15390. ttCtx.marker.resetPointsSize();
  15391. ttCtx.marker.enlargeCurrentPoint(j, allPoints[p]);
  15392. }
  15393. }
  15394. } else {
  15395. ttCtx.marker.resetPointsSize();
  15396. this.moveDynamicPointOnHover(j, i);
  15397. }
  15398. } // This function is used when you need to show markers/points only on hover -
  15399. // DIFFERENT X VALUES in multiple series
  15400. }, {
  15401. key: "moveDynamicPointOnHover",
  15402. value: function moveDynamicPointOnHover(j, capturedSeries) {
  15403. var w = this.w;
  15404. var ttCtx = this.ttCtx;
  15405. var cx = 0;
  15406. var cy = 0;
  15407. var pointsArr = w.globals.pointsArray;
  15408. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(capturedSeries);
  15409. var serType = w.config.series[capturedSeries].type;
  15410. if (serType && (serType === 'column' || serType === 'candlestick' || serType === 'boxPlot')) {
  15411. // fix error mentioned in #811
  15412. return;
  15413. }
  15414. cx = pointsArr[capturedSeries][j][0];
  15415. cy = pointsArr[capturedSeries][j][1] ? pointsArr[capturedSeries][j][1] : 0;
  15416. var point = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(capturedSeries, "'] .apexcharts-series-markers circle"));
  15417. if (point && cy < w.globals.gridHeight && cy > 0) {
  15418. point.setAttribute('r', hoverSize);
  15419. point.setAttribute('cx', cx);
  15420. point.setAttribute('cy', cy);
  15421. } // point.style.opacity = w.config.markers.hover.opacity
  15422. this.moveXCrosshairs(cx);
  15423. if (!ttCtx.fixedTooltip) {
  15424. this.moveTooltip(cx, cy, hoverSize);
  15425. }
  15426. } // This function is used when you need to show markers/points only on hover -
  15427. // SAME X VALUES in multiple series
  15428. }, {
  15429. key: "moveDynamicPointsOnHover",
  15430. value: function moveDynamicPointsOnHover(j) {
  15431. var ttCtx = this.ttCtx;
  15432. var w = ttCtx.w;
  15433. var cx = 0;
  15434. var cy = 0;
  15435. var activeSeries = 0;
  15436. var pointsArr = w.globals.pointsArray;
  15437. var series = new Series(this.ctx);
  15438. activeSeries = series.getActiveConfigSeriesIndex(true);
  15439. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(activeSeries);
  15440. if (pointsArr[activeSeries]) {
  15441. cx = pointsArr[activeSeries][j][0];
  15442. cy = pointsArr[activeSeries][j][1];
  15443. }
  15444. var points = ttCtx.tooltipUtil.getAllMarkers();
  15445. if (points !== null) {
  15446. for (var p = 0; p < w.globals.series.length; p++) {
  15447. var pointArr = pointsArr[p];
  15448. if (w.globals.comboCharts) {
  15449. // 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
  15450. if (typeof pointArr === 'undefined') {
  15451. // nodelist to array
  15452. points.splice(p, 0, null);
  15453. }
  15454. }
  15455. if (pointArr && pointArr.length) {
  15456. var pcy = pointsArr[p][j][1];
  15457. points[p].setAttribute('cx', cx);
  15458. if (pcy !== null && !isNaN(pcy) && pcy < w.globals.gridHeight + hoverSize && pcy + hoverSize > 0) {
  15459. points[p] && points[p].setAttribute('r', hoverSize);
  15460. points[p] && points[p].setAttribute('cy', pcy);
  15461. } else {
  15462. points[p] && points[p].setAttribute('r', 0);
  15463. }
  15464. }
  15465. }
  15466. }
  15467. this.moveXCrosshairs(cx);
  15468. if (!ttCtx.fixedTooltip) {
  15469. var tcy = cy || w.globals.gridHeight;
  15470. this.moveTooltip(cx, tcy, hoverSize);
  15471. }
  15472. }
  15473. }, {
  15474. key: "moveStickyTooltipOverBars",
  15475. value: function moveStickyTooltipOverBars(j) {
  15476. var w = this.w;
  15477. var ttCtx = this.ttCtx;
  15478. var barLen = w.globals.columnSeries ? w.globals.columnSeries.length : w.globals.series.length;
  15479. var i = barLen >= 2 && barLen % 2 === 0 ? Math.floor(barLen / 2) : Math.floor(barLen / 2) + 1;
  15480. if (w.globals.isBarHorizontal) {
  15481. var series = new Series(this.ctx);
  15482. i = series.getActiveConfigSeriesIndex(false, 'desc') + 1;
  15483. }
  15484. 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-boxPlot-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "'], .apexcharts-rangebar-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "']"));
  15485. var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0;
  15486. var bcy = jBar ? parseFloat(jBar.getAttribute('cy')) : 0;
  15487. var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0;
  15488. var bh = jBar ? parseFloat(jBar.getAttribute('barHeight')) : 0;
  15489. var elGrid = ttCtx.getElGrid();
  15490. var seriesBound = elGrid.getBoundingClientRect();
  15491. var isBoxOrCandle = jBar.classList.contains('apexcharts-candlestick-area') || jBar.classList.contains('apexcharts-boxPlot-area');
  15492. if (w.globals.isXNumeric) {
  15493. if (jBar && !isBoxOrCandle) {
  15494. bcx = bcx - (barLen % 2 !== 0 ? bw / 2 : 0);
  15495. }
  15496. if (jBar && // fixes apexcharts.js#2354
  15497. isBoxOrCandle && w.globals.comboCharts) {
  15498. bcx = bcx - bw / 2;
  15499. }
  15500. } else {
  15501. if (!w.globals.isBarHorizontal) {
  15502. bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2;
  15503. if (isNaN(bcx)) {
  15504. bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2;
  15505. }
  15506. }
  15507. }
  15508. if (!w.globals.isBarHorizontal) {
  15509. if (w.config.tooltip.followCursor) {
  15510. bcy = ttCtx.e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2;
  15511. } else {
  15512. if (bcy + ttCtx.tooltipRect.ttHeight + 15 > w.globals.gridHeight) {
  15513. bcy = w.globals.gridHeight;
  15514. }
  15515. }
  15516. } else {
  15517. if (bcy > w.globals.gridHeight / 2) {
  15518. bcy = bcy - ttCtx.tooltipRect.ttHeight;
  15519. }
  15520. bcy = bcy + w.config.grid.padding.top + bh / 3;
  15521. if (bcy + bh > w.globals.gridHeight) {
  15522. bcy = w.globals.gridHeight - bh;
  15523. }
  15524. }
  15525. if (bcy < -10) {
  15526. bcy = -10;
  15527. }
  15528. if (!w.globals.isBarHorizontal) {
  15529. this.moveXCrosshairs(bcx);
  15530. }
  15531. if (!ttCtx.fixedTooltip) {
  15532. var tcy = bcy || w.globals.gridHeight;
  15533. this.moveTooltip(bcx, tcy);
  15534. }
  15535. }
  15536. }]);
  15537. return Position;
  15538. }();
  15539. /**
  15540. * ApexCharts Tooltip.Marker Class to draw texts on the tooltip.
  15541. * This file deals with the markers that appear near tooltip in line/area charts.
  15542. * These markers helps the user to associate the data-points and the values
  15543. * that are shown in the tooltip
  15544. *
  15545. * @module Tooltip.Marker
  15546. **/
  15547. var Marker = /*#__PURE__*/function () {
  15548. function Marker(tooltipContext) {
  15549. _classCallCheck(this, Marker);
  15550. this.w = tooltipContext.w;
  15551. this.ttCtx = tooltipContext;
  15552. this.ctx = tooltipContext.ctx;
  15553. this.tooltipPosition = new Position(tooltipContext);
  15554. }
  15555. _createClass(Marker, [{
  15556. key: "drawDynamicPoints",
  15557. value: function drawDynamicPoints() {
  15558. var w = this.w;
  15559. var graphics = new Graphics(this.ctx);
  15560. var marker = new Markers(this.ctx);
  15561. var elsSeries = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  15562. elsSeries = _toConsumableArray(elsSeries);
  15563. if (w.config.chart.stacked) {
  15564. elsSeries.sort(function (a, b) {
  15565. return parseFloat(a.getAttribute('data:realIndex')) - parseFloat(b.getAttribute('data:realIndex'));
  15566. });
  15567. }
  15568. for (var i = 0; i < elsSeries.length; i++) {
  15569. var pointsMain = elsSeries[i].querySelector(".apexcharts-series-markers-wrap");
  15570. if (pointsMain !== null) {
  15571. // it can be null as we have tooltips in donut/bar charts
  15572. var point = void 0;
  15573. var PointClasses = "apexcharts-marker w".concat((Math.random() + 1).toString(36).substring(4));
  15574. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  15575. PointClasses += ' no-pointer-events';
  15576. }
  15577. var elPointOptions = marker.getMarkerConfig({
  15578. cssClass: PointClasses,
  15579. seriesIndex: Number(pointsMain.getAttribute('data:realIndex')) // fixes apexcharts/apexcharts.js #1427
  15580. });
  15581. point = graphics.drawMarker(0, 0, elPointOptions);
  15582. point.node.setAttribute('default-marker-size', 0);
  15583. var elPointsG = document.createElementNS(w.globals.SVGNS, 'g');
  15584. elPointsG.classList.add('apexcharts-series-markers');
  15585. elPointsG.appendChild(point.node);
  15586. pointsMain.appendChild(elPointsG);
  15587. }
  15588. }
  15589. }
  15590. }, {
  15591. key: "enlargeCurrentPoint",
  15592. value: function enlargeCurrentPoint(rel, point) {
  15593. var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  15594. var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  15595. var w = this.w;
  15596. if (w.config.chart.type !== 'bubble') {
  15597. this.newPointSize(rel, point);
  15598. }
  15599. var cx = point.getAttribute('cx');
  15600. var cy = point.getAttribute('cy');
  15601. if (x !== null && y !== null) {
  15602. cx = x;
  15603. cy = y;
  15604. }
  15605. this.tooltipPosition.moveXCrosshairs(cx);
  15606. if (!this.fixedTooltip) {
  15607. if (w.config.chart.type === 'radar') {
  15608. var elGrid = this.ttCtx.getElGrid();
  15609. var seriesBound = elGrid.getBoundingClientRect();
  15610. cx = this.ttCtx.e.clientX - seriesBound.left;
  15611. }
  15612. this.tooltipPosition.moveTooltip(cx, cy, w.config.markers.hover.size);
  15613. }
  15614. }
  15615. }, {
  15616. key: "enlargePoints",
  15617. value: function enlargePoints(j) {
  15618. var w = this.w;
  15619. var me = this;
  15620. var ttCtx = this.ttCtx;
  15621. var col = j;
  15622. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  15623. var newSize = w.config.markers.hover.size;
  15624. for (var p = 0; p < points.length; p++) {
  15625. var rel = points[p].getAttribute('rel');
  15626. var index = points[p].getAttribute('index');
  15627. if (newSize === undefined) {
  15628. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  15629. }
  15630. if (col === parseInt(rel, 10)) {
  15631. me.newPointSize(col, points[p]);
  15632. var cx = points[p].getAttribute('cx');
  15633. var cy = points[p].getAttribute('cy');
  15634. me.tooltipPosition.moveXCrosshairs(cx);
  15635. if (!ttCtx.fixedTooltip) {
  15636. me.tooltipPosition.moveTooltip(cx, cy, newSize);
  15637. }
  15638. } else {
  15639. me.oldPointSize(points[p]);
  15640. }
  15641. }
  15642. }
  15643. }, {
  15644. key: "newPointSize",
  15645. value: function newPointSize(rel, point) {
  15646. var w = this.w;
  15647. var newSize = w.config.markers.hover.size;
  15648. var elPoint = rel === 0 ? point.parentNode.firstChild : point.parentNode.lastChild;
  15649. if (elPoint.getAttribute('default-marker-size') !== '0') {
  15650. var index = parseInt(elPoint.getAttribute('index'), 10);
  15651. if (newSize === undefined) {
  15652. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  15653. }
  15654. if (newSize < 0) newSize = 0;
  15655. elPoint.setAttribute('r', newSize);
  15656. }
  15657. }
  15658. }, {
  15659. key: "oldPointSize",
  15660. value: function oldPointSize(point) {
  15661. var size = parseFloat(point.getAttribute('default-marker-size'));
  15662. point.setAttribute('r', size);
  15663. }
  15664. }, {
  15665. key: "resetPointsSize",
  15666. value: function resetPointsSize() {
  15667. var w = this.w;
  15668. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  15669. for (var p = 0; p < points.length; p++) {
  15670. var size = parseFloat(points[p].getAttribute('default-marker-size'));
  15671. if (Utils$1.isNumber(size) && size >= 0) {
  15672. points[p].setAttribute('r', size);
  15673. } else {
  15674. points[p].setAttribute('r', 0);
  15675. }
  15676. }
  15677. }
  15678. }]);
  15679. return Marker;
  15680. }();
  15681. /**
  15682. * ApexCharts Tooltip.Intersect Class.
  15683. * This file deals with functions related to intersecting tooltips
  15684. * (tooltips that appear when user hovers directly over a data-point whether)
  15685. *
  15686. * @module Tooltip.Intersect
  15687. **/
  15688. var Intersect = /*#__PURE__*/function () {
  15689. function Intersect(tooltipContext) {
  15690. _classCallCheck(this, Intersect);
  15691. this.w = tooltipContext.w;
  15692. this.ttCtx = tooltipContext;
  15693. } // a helper function to get an element's attribute value
  15694. _createClass(Intersect, [{
  15695. key: "getAttr",
  15696. value: function getAttr(e, attr) {
  15697. return parseFloat(e.target.getAttribute(attr));
  15698. } // handle tooltip for heatmaps and treemaps
  15699. }, {
  15700. key: "handleHeatTreeTooltip",
  15701. value: function handleHeatTreeTooltip(_ref) {
  15702. var e = _ref.e,
  15703. opt = _ref.opt,
  15704. x = _ref.x,
  15705. y = _ref.y,
  15706. type = _ref.type;
  15707. var ttCtx = this.ttCtx;
  15708. var w = this.w;
  15709. if (e.target.classList.contains("apexcharts-".concat(type, "-rect"))) {
  15710. var i = this.getAttr(e, 'i');
  15711. var j = this.getAttr(e, 'j');
  15712. var cx = this.getAttr(e, 'cx');
  15713. var cy = this.getAttr(e, 'cy');
  15714. var width = this.getAttr(e, 'width');
  15715. var height = this.getAttr(e, 'height');
  15716. ttCtx.tooltipLabels.drawSeriesTexts({
  15717. ttItems: opt.ttItems,
  15718. i: i,
  15719. j: j,
  15720. shared: false,
  15721. e: e
  15722. });
  15723. w.globals.capturedSeriesIndex = i;
  15724. w.globals.capturedDataPointIndex = j;
  15725. x = cx + ttCtx.tooltipRect.ttWidth / 2 + width;
  15726. y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2;
  15727. ttCtx.tooltipPosition.moveXCrosshairs(cx + width / 2);
  15728. if (x > w.globals.gridWidth / 2) {
  15729. x = cx - ttCtx.tooltipRect.ttWidth / 2 + width;
  15730. }
  15731. if (ttCtx.w.config.tooltip.followCursor) {
  15732. var seriesBound = w.globals.dom.elWrap.getBoundingClientRect();
  15733. x = w.globals.clientX - seriesBound.left - (x > w.globals.gridWidth / 2 ? ttCtx.tooltipRect.ttWidth : 0);
  15734. y = w.globals.clientY - seriesBound.top - (y > w.globals.gridHeight / 2 ? ttCtx.tooltipRect.ttHeight : 0);
  15735. }
  15736. }
  15737. return {
  15738. x: x,
  15739. y: y
  15740. };
  15741. }
  15742. /**
  15743. * handle tooltips for line/area/scatter charts where tooltip.intersect is true
  15744. * when user hovers over the marker directly, this function is executed
  15745. */
  15746. }, {
  15747. key: "handleMarkerTooltip",
  15748. value: function handleMarkerTooltip(_ref2) {
  15749. var e = _ref2.e,
  15750. opt = _ref2.opt,
  15751. x = _ref2.x,
  15752. y = _ref2.y;
  15753. var w = this.w;
  15754. var ttCtx = this.ttCtx;
  15755. var i;
  15756. var j;
  15757. if (e.target.classList.contains('apexcharts-marker')) {
  15758. var cx = parseInt(opt.paths.getAttribute('cx'), 10);
  15759. var cy = parseInt(opt.paths.getAttribute('cy'), 10);
  15760. var val = parseFloat(opt.paths.getAttribute('val'));
  15761. j = parseInt(opt.paths.getAttribute('rel'), 10);
  15762. i = parseInt(opt.paths.parentNode.parentNode.parentNode.getAttribute('rel'), 10) - 1;
  15763. if (ttCtx.intersect) {
  15764. var el = Utils$1.findAncestor(opt.paths, 'apexcharts-series');
  15765. if (el) {
  15766. i = parseInt(el.getAttribute('data:realIndex'), 10);
  15767. }
  15768. }
  15769. ttCtx.tooltipLabels.drawSeriesTexts({
  15770. ttItems: opt.ttItems,
  15771. i: i,
  15772. j: j,
  15773. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared,
  15774. e: e
  15775. });
  15776. if (e.type === 'mouseup') {
  15777. ttCtx.markerClick(e, i, j);
  15778. }
  15779. w.globals.capturedSeriesIndex = i;
  15780. w.globals.capturedDataPointIndex = j;
  15781. x = cx;
  15782. y = cy + w.globals.translateY - ttCtx.tooltipRect.ttHeight * 1.4;
  15783. if (ttCtx.w.config.tooltip.followCursor) {
  15784. var elGrid = ttCtx.getElGrid();
  15785. var seriesBound = elGrid.getBoundingClientRect();
  15786. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top;
  15787. }
  15788. if (val < 0) {
  15789. y = cy;
  15790. }
  15791. ttCtx.marker.enlargeCurrentPoint(j, opt.paths, x, y);
  15792. }
  15793. return {
  15794. x: x,
  15795. y: y
  15796. };
  15797. }
  15798. /**
  15799. * handle tooltips for bar/column charts
  15800. */
  15801. }, {
  15802. key: "handleBarTooltip",
  15803. value: function handleBarTooltip(_ref3) {
  15804. var e = _ref3.e,
  15805. opt = _ref3.opt;
  15806. var w = this.w;
  15807. var ttCtx = this.ttCtx;
  15808. var tooltipEl = ttCtx.getElTooltip();
  15809. var bx = 0;
  15810. var x = 0;
  15811. var y = 0;
  15812. var i = 0;
  15813. var strokeWidth;
  15814. var barXY = this.getBarTooltipXY({
  15815. e: e,
  15816. opt: opt
  15817. });
  15818. i = barXY.i;
  15819. var barHeight = barXY.barHeight;
  15820. var j = barXY.j;
  15821. w.globals.capturedSeriesIndex = i;
  15822. w.globals.capturedDataPointIndex = j;
  15823. if (w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars() || !w.config.tooltip.shared) {
  15824. x = barXY.x;
  15825. y = barXY.y;
  15826. strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[i] : w.config.stroke.width;
  15827. bx = x;
  15828. } else {
  15829. if (!w.globals.comboCharts && !w.config.tooltip.shared) {
  15830. // todo: re-check this condition as it's always 0
  15831. bx = bx / 2;
  15832. }
  15833. } // y is NaN, make it touch the bottom of grid area
  15834. if (isNaN(y)) {
  15835. y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight;
  15836. } else if (y < 0) {
  15837. y = 0;
  15838. }
  15839. var seriesIndex = parseInt(opt.paths.parentNode.getAttribute('data:realIndex'), 10);
  15840. var isReversed = w.globals.isMultipleYAxis ? w.config.yaxis[seriesIndex] && w.config.yaxis[seriesIndex].reversed : w.config.yaxis[0].reversed;
  15841. if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth && !isReversed) {
  15842. x = x - ttCtx.tooltipRect.ttWidth;
  15843. } else if (x < 0) {
  15844. x = 0;
  15845. }
  15846. if (ttCtx.w.config.tooltip.followCursor) {
  15847. var elGrid = ttCtx.getElGrid();
  15848. var seriesBound = elGrid.getBoundingClientRect();
  15849. y = ttCtx.e.clientY - seriesBound.top;
  15850. } // if tooltip is still null, querySelector
  15851. if (ttCtx.tooltip === null) {
  15852. ttCtx.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  15853. }
  15854. if (!w.config.tooltip.shared) {
  15855. if (w.globals.comboBarCount > 0) {
  15856. ttCtx.tooltipPosition.moveXCrosshairs(bx + strokeWidth / 2);
  15857. } else {
  15858. ttCtx.tooltipPosition.moveXCrosshairs(bx);
  15859. }
  15860. } // move tooltip here
  15861. if (!ttCtx.fixedTooltip && (!w.config.tooltip.shared || w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  15862. if (isReversed) {
  15863. x = x - ttCtx.tooltipRect.ttWidth;
  15864. if (x < 0) {
  15865. x = 0;
  15866. }
  15867. }
  15868. if (isReversed && !(w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  15869. y = y + barHeight - (w.globals.series[i][j] < 0 ? barHeight : 0) * 2;
  15870. }
  15871. if (ttCtx.tooltipRect.ttHeight + y > w.globals.gridHeight) {
  15872. y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight + w.globals.translateY;
  15873. } else {
  15874. y = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2;
  15875. if (y < 0) {
  15876. y = 0;
  15877. }
  15878. }
  15879. tooltipEl.style.left = x + w.globals.translateX + 'px';
  15880. tooltipEl.style.top = y + 'px';
  15881. }
  15882. }
  15883. }, {
  15884. key: "getBarTooltipXY",
  15885. value: function getBarTooltipXY(_ref4) {
  15886. var e = _ref4.e,
  15887. opt = _ref4.opt;
  15888. var w = this.w;
  15889. var j = null;
  15890. var ttCtx = this.ttCtx;
  15891. var i = 0;
  15892. var x = 0;
  15893. var y = 0;
  15894. var barWidth = 0;
  15895. var barHeight = 0;
  15896. var cl = e.target.classList;
  15897. if (cl.contains('apexcharts-bar-area') || cl.contains('apexcharts-candlestick-area') || cl.contains('apexcharts-boxPlot-area') || cl.contains('apexcharts-rangebar-area')) {
  15898. var bar = e.target;
  15899. var barRect = bar.getBoundingClientRect();
  15900. var seriesBound = opt.elGrid.getBoundingClientRect();
  15901. var bh = barRect.height;
  15902. barHeight = barRect.height;
  15903. var bw = barRect.width;
  15904. var cx = parseInt(bar.getAttribute('cx'), 10);
  15905. var cy = parseInt(bar.getAttribute('cy'), 10);
  15906. barWidth = parseFloat(bar.getAttribute('barWidth'));
  15907. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  15908. j = parseInt(bar.getAttribute('j'), 10);
  15909. i = parseInt(bar.parentNode.getAttribute('rel'), 10) - 1;
  15910. var y1 = bar.getAttribute('data-range-y1');
  15911. var y2 = bar.getAttribute('data-range-y2');
  15912. if (w.globals.comboCharts) {
  15913. i = parseInt(bar.parentNode.getAttribute('data:realIndex'), 10);
  15914. } // if (w.config.tooltip.shared) {
  15915. // this check not needed at the moment
  15916. // const yDivisor = w.globals.gridHeight / (w.globals.series.length)
  15917. // const hoverY = ttCtx.clientY - ttCtx.seriesBound.top
  15918. // j = Math.ceil(hoverY / yDivisor)
  15919. // }
  15920. ttCtx.tooltipLabels.drawSeriesTexts({
  15921. ttItems: opt.ttItems,
  15922. i: i,
  15923. j: j,
  15924. y1: y1 ? parseInt(y1, 10) : null,
  15925. y2: y2 ? parseInt(y2, 10) : null,
  15926. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared,
  15927. e: e
  15928. });
  15929. if (w.config.tooltip.followCursor) {
  15930. if (w.globals.isBarHorizontal) {
  15931. x = clientX - seriesBound.left + 15;
  15932. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  15933. } else {
  15934. if (w.globals.isXNumeric) {
  15935. x = cx - bw / 2;
  15936. } else {
  15937. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  15938. }
  15939. y = e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2 - 15;
  15940. }
  15941. } else {
  15942. if (w.globals.isBarHorizontal) {
  15943. x = cx;
  15944. if (x < ttCtx.xyRatios.baseLineInvertedY) {
  15945. x = cx - ttCtx.tooltipRect.ttWidth;
  15946. }
  15947. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  15948. } else {
  15949. // if columns
  15950. if (w.globals.isXNumeric) {
  15951. x = cx - bw / 2;
  15952. } else {
  15953. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  15954. }
  15955. y = cy; // - ttCtx.tooltipRect.ttHeight / 2 + 10
  15956. }
  15957. }
  15958. }
  15959. return {
  15960. x: x,
  15961. y: y,
  15962. barHeight: barHeight,
  15963. barWidth: barWidth,
  15964. i: i,
  15965. j: j
  15966. };
  15967. }
  15968. }]);
  15969. return Intersect;
  15970. }();
  15971. /**
  15972. * ApexCharts Tooltip.AxesTooltip Class.
  15973. * This file deals with the x-axis and y-axis tooltips.
  15974. *
  15975. * @module Tooltip.AxesTooltip
  15976. **/
  15977. var AxesTooltip = /*#__PURE__*/function () {
  15978. function AxesTooltip(tooltipContext) {
  15979. _classCallCheck(this, AxesTooltip);
  15980. this.w = tooltipContext.w;
  15981. this.ttCtx = tooltipContext;
  15982. }
  15983. /**
  15984. * This method adds the secondary tooltip which appears below x axis
  15985. * @memberof Tooltip
  15986. **/
  15987. _createClass(AxesTooltip, [{
  15988. key: "drawXaxisTooltip",
  15989. value: function drawXaxisTooltip() {
  15990. var w = this.w;
  15991. var ttCtx = this.ttCtx;
  15992. var isBottom = w.config.xaxis.position === 'bottom';
  15993. ttCtx.xaxisOffY = isBottom ? w.globals.gridHeight + 1 : -w.globals.xAxisHeight - w.config.xaxis.axisTicks.height + 3;
  15994. var tooltipCssClass = isBottom ? 'apexcharts-xaxistooltip apexcharts-xaxistooltip-bottom' : 'apexcharts-xaxistooltip apexcharts-xaxistooltip-top';
  15995. var renderTo = w.globals.dom.elWrap;
  15996. if (ttCtx.isXAxisTooltipEnabled) {
  15997. var xaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-xaxistooltip');
  15998. if (xaxisTooltip === null) {
  15999. ttCtx.xaxisTooltip = document.createElement('div');
  16000. ttCtx.xaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  16001. renderTo.appendChild(ttCtx.xaxisTooltip);
  16002. ttCtx.xaxisTooltipText = document.createElement('div');
  16003. ttCtx.xaxisTooltipText.classList.add('apexcharts-xaxistooltip-text');
  16004. ttCtx.xaxisTooltipText.style.fontFamily = w.config.xaxis.tooltip.style.fontFamily || w.config.chart.fontFamily;
  16005. ttCtx.xaxisTooltipText.style.fontSize = w.config.xaxis.tooltip.style.fontSize;
  16006. ttCtx.xaxisTooltip.appendChild(ttCtx.xaxisTooltipText);
  16007. }
  16008. }
  16009. }
  16010. /**
  16011. * This method adds the secondary tooltip which appears below x axis
  16012. * @memberof Tooltip
  16013. **/
  16014. }, {
  16015. key: "drawYaxisTooltip",
  16016. value: function drawYaxisTooltip() {
  16017. var w = this.w;
  16018. var ttCtx = this.ttCtx;
  16019. var _loop = function _loop(i) {
  16020. var isRight = w.config.yaxis[i].opposite || w.config.yaxis[i].crosshairs.opposite;
  16021. ttCtx.yaxisOffX = isRight ? w.globals.gridWidth + 1 : 1;
  16022. var tooltipCssClass = isRight ? "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-right") : "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-left");
  16023. w.globals.yAxisSameScaleIndices.map(function (samescales, ssi) {
  16024. samescales.map(function (s, si) {
  16025. if (si === i) {
  16026. tooltipCssClass += w.config.yaxis[si].show ? " " : " apexcharts-yaxistooltip-hidden";
  16027. }
  16028. });
  16029. });
  16030. var renderTo = w.globals.dom.elWrap;
  16031. var yaxisTooltip = w.globals.dom.baseEl.querySelector(".apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i));
  16032. if (yaxisTooltip === null) {
  16033. ttCtx.yaxisTooltip = document.createElement('div');
  16034. ttCtx.yaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  16035. renderTo.appendChild(ttCtx.yaxisTooltip);
  16036. if (i === 0) ttCtx.yaxisTooltipText = [];
  16037. ttCtx.yaxisTooltipText[i] = document.createElement('div');
  16038. ttCtx.yaxisTooltipText[i].classList.add('apexcharts-yaxistooltip-text');
  16039. ttCtx.yaxisTooltip.appendChild(ttCtx.yaxisTooltipText[i]);
  16040. }
  16041. };
  16042. for (var i = 0; i < w.config.yaxis.length; i++) {
  16043. _loop(i);
  16044. }
  16045. }
  16046. /**
  16047. * @memberof Tooltip
  16048. **/
  16049. }, {
  16050. key: "setXCrosshairWidth",
  16051. value: function setXCrosshairWidth() {
  16052. var w = this.w;
  16053. var ttCtx = this.ttCtx; // set xcrosshairs width
  16054. var xcrosshairs = ttCtx.getElXCrosshairs();
  16055. ttCtx.xcrosshairsWidth = parseInt(w.config.xaxis.crosshairs.width, 10);
  16056. if (!w.globals.comboCharts) {
  16057. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  16058. var count = w.globals.labels.length;
  16059. ttCtx.xcrosshairsWidth = w.globals.gridWidth / count;
  16060. } else if (w.config.xaxis.crosshairs.width === 'barWidth') {
  16061. var bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  16062. if (bar !== null) {
  16063. var barWidth = parseFloat(bar.getAttribute('barWidth'));
  16064. ttCtx.xcrosshairsWidth = barWidth;
  16065. } else {
  16066. ttCtx.xcrosshairsWidth = 1;
  16067. }
  16068. }
  16069. } else {
  16070. var _bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  16071. if (_bar !== null && w.config.xaxis.crosshairs.width === 'barWidth') {
  16072. var _barWidth = parseFloat(_bar.getAttribute('barWidth'));
  16073. ttCtx.xcrosshairsWidth = _barWidth;
  16074. } else {
  16075. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  16076. var _count = w.globals.labels.length;
  16077. ttCtx.xcrosshairsWidth = w.globals.gridWidth / _count;
  16078. }
  16079. }
  16080. }
  16081. if (w.globals.isBarHorizontal) {
  16082. ttCtx.xcrosshairsWidth = 0;
  16083. }
  16084. if (xcrosshairs !== null && ttCtx.xcrosshairsWidth > 0) {
  16085. xcrosshairs.setAttribute('width', ttCtx.xcrosshairsWidth);
  16086. }
  16087. }
  16088. }, {
  16089. key: "handleYCrosshair",
  16090. value: function handleYCrosshair() {
  16091. var w = this.w;
  16092. var ttCtx = this.ttCtx; // set ycrosshairs height
  16093. ttCtx.ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs');
  16094. ttCtx.ycrosshairsHidden = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs-hidden');
  16095. }
  16096. }, {
  16097. key: "drawYaxisTooltipText",
  16098. value: function drawYaxisTooltipText(index, clientY, xyRatios) {
  16099. var ttCtx = this.ttCtx;
  16100. var w = this.w;
  16101. var lbFormatter = w.globals.yLabelFormatters[index];
  16102. if (ttCtx.yaxisTooltips[index]) {
  16103. var elGrid = ttCtx.getElGrid();
  16104. var seriesBound = elGrid.getBoundingClientRect();
  16105. var hoverY = (clientY - seriesBound.top) * xyRatios.yRatio[index];
  16106. var height = w.globals.maxYArr[index] - w.globals.minYArr[index];
  16107. var val = w.globals.minYArr[index] + (height - hoverY);
  16108. ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top);
  16109. ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val);
  16110. ttCtx.tooltipPosition.moveYAxisTooltip(index);
  16111. }
  16112. }
  16113. }]);
  16114. return AxesTooltip;
  16115. }();
  16116. /**
  16117. * ApexCharts Core Tooltip Class to handle the tooltip generation.
  16118. *
  16119. * @module Tooltip
  16120. **/
  16121. var Tooltip = /*#__PURE__*/function () {
  16122. function Tooltip(ctx) {
  16123. _classCallCheck(this, Tooltip);
  16124. this.ctx = ctx;
  16125. this.w = ctx.w;
  16126. var w = this.w;
  16127. this.tConfig = w.config.tooltip;
  16128. this.tooltipUtil = new Utils(this);
  16129. this.tooltipLabels = new Labels(this);
  16130. this.tooltipPosition = new Position(this);
  16131. this.marker = new Marker(this);
  16132. this.intersect = new Intersect(this);
  16133. this.axesTooltip = new AxesTooltip(this);
  16134. this.showOnIntersect = this.tConfig.intersect;
  16135. this.showTooltipTitle = this.tConfig.x.show;
  16136. this.fixedTooltip = this.tConfig.fixed.enabled;
  16137. this.xaxisTooltip = null;
  16138. this.yaxisTTEls = null;
  16139. this.isBarShared = !w.globals.isBarHorizontal && this.tConfig.shared;
  16140. this.lastHoverTime = Date.now();
  16141. }
  16142. _createClass(Tooltip, [{
  16143. key: "getElTooltip",
  16144. value: function getElTooltip(ctx) {
  16145. if (!ctx) ctx = this;
  16146. if (!ctx.w.globals.dom.baseEl) return null;
  16147. return ctx.w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  16148. }
  16149. }, {
  16150. key: "getElXCrosshairs",
  16151. value: function getElXCrosshairs() {
  16152. return this.w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs');
  16153. }
  16154. }, {
  16155. key: "getElGrid",
  16156. value: function getElGrid() {
  16157. return this.w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  16158. }
  16159. }, {
  16160. key: "drawTooltip",
  16161. value: function drawTooltip(xyRatios) {
  16162. var w = this.w;
  16163. this.xyRatios = xyRatios;
  16164. this.isXAxisTooltipEnabled = w.config.xaxis.tooltip.enabled && w.globals.axisCharts;
  16165. this.yaxisTooltips = w.config.yaxis.map(function (y, i) {
  16166. return y.show && y.tooltip.enabled && w.globals.axisCharts ? true : false;
  16167. });
  16168. this.allTooltipSeriesGroups = [];
  16169. if (!w.globals.axisCharts) {
  16170. this.showTooltipTitle = false;
  16171. }
  16172. var tooltipEl = document.createElement('div');
  16173. tooltipEl.classList.add('apexcharts-tooltip');
  16174. if (w.config.tooltip.cssClass) {
  16175. tooltipEl.classList.add(w.config.tooltip.cssClass);
  16176. }
  16177. tooltipEl.classList.add("apexcharts-theme-".concat(this.tConfig.theme));
  16178. w.globals.dom.elWrap.appendChild(tooltipEl);
  16179. if (w.globals.axisCharts) {
  16180. this.axesTooltip.drawXaxisTooltip();
  16181. this.axesTooltip.drawYaxisTooltip();
  16182. this.axesTooltip.setXCrosshairWidth();
  16183. this.axesTooltip.handleYCrosshair();
  16184. var xAxis = new XAxis(this.ctx);
  16185. this.xAxisTicksPositions = xAxis.getXAxisTicksPositions();
  16186. } // we forcefully set intersect true for these conditions
  16187. if ((w.globals.comboCharts || this.tConfig.intersect || w.config.chart.type === 'rangeBar') && !this.tConfig.shared) {
  16188. this.showOnIntersect = true;
  16189. }
  16190. if (w.config.markers.size === 0 || w.globals.markers.largestSize === 0) {
  16191. // when user don't want to show points all the time, but only on when hovering on series
  16192. this.marker.drawDynamicPoints(this);
  16193. } // no visible series, exit
  16194. if (w.globals.collapsedSeries.length === w.globals.series.length) return;
  16195. this.dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  16196. this.dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  16197. if (this.showTooltipTitle) {
  16198. this.tooltipTitle = document.createElement('div');
  16199. this.tooltipTitle.classList.add('apexcharts-tooltip-title');
  16200. this.tooltipTitle.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  16201. this.tooltipTitle.style.fontSize = this.tConfig.style.fontSize;
  16202. tooltipEl.appendChild(this.tooltipTitle);
  16203. }
  16204. var ttItemsCnt = w.globals.series.length; // whether shared or not, default is shared
  16205. if ((w.globals.xyCharts || w.globals.comboCharts) && this.tConfig.shared) {
  16206. if (!this.showOnIntersect) {
  16207. ttItemsCnt = w.globals.series.length;
  16208. } else {
  16209. ttItemsCnt = 1;
  16210. }
  16211. }
  16212. this.legendLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-text');
  16213. this.ttItems = this.createTTElements(ttItemsCnt);
  16214. this.addSVGEvents();
  16215. }
  16216. }, {
  16217. key: "createTTElements",
  16218. value: function createTTElements(ttItemsCnt) {
  16219. var _this = this;
  16220. var w = this.w;
  16221. var ttItems = [];
  16222. var tooltipEl = this.getElTooltip();
  16223. var _loop = function _loop(i) {
  16224. var gTxt = document.createElement('div');
  16225. gTxt.classList.add('apexcharts-tooltip-series-group');
  16226. gTxt.style.order = w.config.tooltip.inverseOrder ? ttItemsCnt - i : i + 1;
  16227. if (_this.tConfig.shared && _this.tConfig.enabledOnSeries && Array.isArray(_this.tConfig.enabledOnSeries)) {
  16228. if (_this.tConfig.enabledOnSeries.indexOf(i) < 0) {
  16229. gTxt.classList.add('apexcharts-tooltip-series-group-hidden');
  16230. }
  16231. }
  16232. var point = document.createElement('span');
  16233. point.classList.add('apexcharts-tooltip-marker');
  16234. point.style.backgroundColor = w.globals.colors[i];
  16235. gTxt.appendChild(point);
  16236. var gYZ = document.createElement('div');
  16237. gYZ.classList.add('apexcharts-tooltip-text');
  16238. gYZ.style.fontFamily = _this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  16239. gYZ.style.fontSize = _this.tConfig.style.fontSize;
  16240. ['y', 'goals', 'z'].forEach(function (g) {
  16241. var gValText = document.createElement('div');
  16242. gValText.classList.add("apexcharts-tooltip-".concat(g, "-group"));
  16243. var txtLabel = document.createElement('span');
  16244. txtLabel.classList.add("apexcharts-tooltip-text-".concat(g, "-label"));
  16245. gValText.appendChild(txtLabel);
  16246. var txtValue = document.createElement('span');
  16247. txtValue.classList.add("apexcharts-tooltip-text-".concat(g, "-value"));
  16248. gValText.appendChild(txtValue);
  16249. gYZ.appendChild(gValText);
  16250. });
  16251. gTxt.appendChild(gYZ);
  16252. tooltipEl.appendChild(gTxt);
  16253. ttItems.push(gTxt);
  16254. };
  16255. for (var i = 0; i < ttItemsCnt; i++) {
  16256. _loop(i);
  16257. }
  16258. return ttItems;
  16259. }
  16260. }, {
  16261. key: "addSVGEvents",
  16262. value: function addSVGEvents() {
  16263. var w = this.w;
  16264. var type = w.config.chart.type;
  16265. var tooltipEl = this.getElTooltip();
  16266. var commonBar = !!(type === 'bar' || type === 'candlestick' || type === 'boxPlot' || type === 'rangeBar');
  16267. var chartWithmarkers = type === 'area' || type === 'line' || type === 'scatter' || type === 'bubble' || type === 'radar';
  16268. var hoverArea = w.globals.dom.Paper.node;
  16269. var elGrid = this.getElGrid();
  16270. if (elGrid) {
  16271. this.seriesBound = elGrid.getBoundingClientRect();
  16272. }
  16273. var tooltipY = [];
  16274. var tooltipX = [];
  16275. var seriesHoverParams = {
  16276. hoverArea: hoverArea,
  16277. elGrid: elGrid,
  16278. tooltipEl: tooltipEl,
  16279. tooltipY: tooltipY,
  16280. tooltipX: tooltipX,
  16281. ttItems: this.ttItems
  16282. };
  16283. var points;
  16284. if (w.globals.axisCharts) {
  16285. if (chartWithmarkers) {
  16286. points = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series[data\\:longestSeries='true'] .apexcharts-marker");
  16287. } else if (commonBar) {
  16288. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area, .apexcharts-series .apexcharts-candlestick-area, .apexcharts-series .apexcharts-boxPlot-area, .apexcharts-series .apexcharts-rangebar-area');
  16289. } else if (type === 'heatmap' || type === 'treemap') {
  16290. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap, .apexcharts-series .apexcharts-treemap');
  16291. }
  16292. if (points && points.length) {
  16293. for (var p = 0; p < points.length; p++) {
  16294. tooltipY.push(points[p].getAttribute('cy'));
  16295. tooltipX.push(points[p].getAttribute('cx'));
  16296. }
  16297. }
  16298. }
  16299. var validSharedChartTypes = w.globals.xyCharts && !this.showOnIntersect || w.globals.comboCharts && !this.showOnIntersect || commonBar && this.tooltipUtil.hasBars() && this.tConfig.shared;
  16300. if (validSharedChartTypes) {
  16301. this.addPathsEventListeners([hoverArea], seriesHoverParams);
  16302. } else if (commonBar && !w.globals.comboCharts || chartWithmarkers && this.showOnIntersect) {
  16303. this.addDatapointEventsListeners(seriesHoverParams);
  16304. } else if (!w.globals.axisCharts || type === 'heatmap' || type === 'treemap') {
  16305. var seriesAll = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  16306. this.addPathsEventListeners(seriesAll, seriesHoverParams);
  16307. }
  16308. if (this.showOnIntersect) {
  16309. var lineAreaPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-marker, .apexcharts-area-series .apexcharts-marker');
  16310. if (lineAreaPoints.length > 0) {
  16311. // if we find any lineSeries, addEventListeners for them
  16312. this.addPathsEventListeners(lineAreaPoints, seriesHoverParams);
  16313. } // combo charts may have bars, so add event listeners here too
  16314. if (this.tooltipUtil.hasBars() && !this.tConfig.shared) {
  16315. this.addDatapointEventsListeners(seriesHoverParams);
  16316. }
  16317. }
  16318. }
  16319. }, {
  16320. key: "drawFixedTooltipRect",
  16321. value: function drawFixedTooltipRect() {
  16322. var w = this.w;
  16323. var tooltipEl = this.getElTooltip();
  16324. var tooltipRect = tooltipEl.getBoundingClientRect();
  16325. var ttWidth = tooltipRect.width + 10;
  16326. var ttHeight = tooltipRect.height + 10;
  16327. var x = this.tConfig.fixed.offsetX;
  16328. var y = this.tConfig.fixed.offsetY;
  16329. var fixed = this.tConfig.fixed.position.toLowerCase();
  16330. if (fixed.indexOf('right') > -1) {
  16331. x = x + w.globals.svgWidth - ttWidth + 10;
  16332. }
  16333. if (fixed.indexOf('bottom') > -1) {
  16334. y = y + w.globals.svgHeight - ttHeight - 10;
  16335. }
  16336. tooltipEl.style.left = x + 'px';
  16337. tooltipEl.style.top = y + 'px';
  16338. return {
  16339. x: x,
  16340. y: y,
  16341. ttWidth: ttWidth,
  16342. ttHeight: ttHeight
  16343. };
  16344. }
  16345. }, {
  16346. key: "addDatapointEventsListeners",
  16347. value: function addDatapointEventsListeners(seriesHoverParams) {
  16348. var w = this.w;
  16349. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-boxPlot-area, .apexcharts-rangebar-area');
  16350. this.addPathsEventListeners(points, seriesHoverParams);
  16351. }
  16352. }, {
  16353. key: "addPathsEventListeners",
  16354. value: function addPathsEventListeners(paths, opts) {
  16355. var self = this;
  16356. var _loop2 = function _loop2(p) {
  16357. var extendedOpts = {
  16358. paths: paths[p],
  16359. tooltipEl: opts.tooltipEl,
  16360. tooltipY: opts.tooltipY,
  16361. tooltipX: opts.tooltipX,
  16362. elGrid: opts.elGrid,
  16363. hoverArea: opts.hoverArea,
  16364. ttItems: opts.ttItems
  16365. };
  16366. var events = ['mousemove', 'mouseup', 'touchmove', 'mouseout', 'touchend'];
  16367. events.map(function (ev) {
  16368. return paths[p].addEventListener(ev, self.onSeriesHover.bind(self, extendedOpts), {
  16369. capture: false,
  16370. passive: true
  16371. });
  16372. });
  16373. };
  16374. for (var p = 0; p < paths.length; p++) {
  16375. _loop2(p);
  16376. }
  16377. }
  16378. /*
  16379. ** Check to see if the tooltips should be updated based on a mouse / touch event
  16380. */
  16381. }, {
  16382. key: "onSeriesHover",
  16383. value: function onSeriesHover(opt, e) {
  16384. var _this2 = this;
  16385. // If a user is moving their mouse quickly, don't bother updating the tooltip every single frame
  16386. var targetDelay = 100;
  16387. var timeSinceLastUpdate = Date.now() - this.lastHoverTime;
  16388. if (timeSinceLastUpdate >= targetDelay) {
  16389. // The tooltip was last updated over 100ms ago - redraw it even if the user is still moving their
  16390. // mouse so they get some feedback that their moves are being registered
  16391. this.seriesHover(opt, e);
  16392. } else {
  16393. // The tooltip was last updated less than 100ms ago
  16394. // Cancel any other delayed draw, so we don't show stale data
  16395. clearTimeout(this.seriesHoverTimeout); // Schedule the next draw so that it happens about 100ms after the last update
  16396. this.seriesHoverTimeout = setTimeout(function () {
  16397. _this2.seriesHover(opt, e);
  16398. }, targetDelay - timeSinceLastUpdate);
  16399. }
  16400. }
  16401. /*
  16402. ** The actual series hover function
  16403. */
  16404. }, {
  16405. key: "seriesHover",
  16406. value: function seriesHover(opt, e) {
  16407. var _this3 = this;
  16408. this.lastHoverTime = Date.now();
  16409. var chartGroups = [];
  16410. var w = this.w; // if user has more than one charts in group, we need to sync
  16411. if (w.config.chart.group) {
  16412. chartGroups = this.ctx.getGroupedCharts();
  16413. }
  16414. if (w.globals.axisCharts && (w.globals.minX === -Infinity && w.globals.maxX === Infinity || w.globals.dataPoints === 0)) {
  16415. return;
  16416. }
  16417. if (chartGroups.length) {
  16418. chartGroups.forEach(function (ch) {
  16419. var tooltipEl = _this3.getElTooltip(ch);
  16420. var newOpts = {
  16421. paths: opt.paths,
  16422. tooltipEl: tooltipEl,
  16423. tooltipY: opt.tooltipY,
  16424. tooltipX: opt.tooltipX,
  16425. elGrid: opt.elGrid,
  16426. hoverArea: opt.hoverArea,
  16427. ttItems: ch.w.globals.tooltip.ttItems
  16428. }; // all the charts should have the same minX and maxX (same xaxis) for multiple tooltips to work correctly
  16429. if (ch.w.globals.minX === _this3.w.globals.minX && ch.w.globals.maxX === _this3.w.globals.maxX) {
  16430. ch.w.globals.tooltip.seriesHoverByContext({
  16431. chartCtx: ch,
  16432. ttCtx: ch.w.globals.tooltip,
  16433. opt: newOpts,
  16434. e: e
  16435. });
  16436. }
  16437. });
  16438. } else {
  16439. this.seriesHoverByContext({
  16440. chartCtx: this.ctx,
  16441. ttCtx: this.w.globals.tooltip,
  16442. opt: opt,
  16443. e: e
  16444. });
  16445. }
  16446. }
  16447. }, {
  16448. key: "seriesHoverByContext",
  16449. value: function seriesHoverByContext(_ref) {
  16450. var chartCtx = _ref.chartCtx,
  16451. ttCtx = _ref.ttCtx,
  16452. opt = _ref.opt,
  16453. e = _ref.e;
  16454. var w = chartCtx.w;
  16455. var tooltipEl = this.getElTooltip();
  16456. if (!tooltipEl) return; // tooltipRect is calculated on every mousemove, because the text is dynamic
  16457. ttCtx.tooltipRect = {
  16458. x: 0,
  16459. y: 0,
  16460. ttWidth: tooltipEl.getBoundingClientRect().width,
  16461. ttHeight: tooltipEl.getBoundingClientRect().height
  16462. };
  16463. ttCtx.e = e; // highlight the current hovered bars
  16464. if (ttCtx.tooltipUtil.hasBars() && !w.globals.comboCharts && !ttCtx.isBarShared) {
  16465. if (this.tConfig.onDatasetHover.highlightDataSeries) {
  16466. var series = new Series(chartCtx);
  16467. series.toggleSeriesOnHover(e, e.target.parentNode);
  16468. }
  16469. }
  16470. if (ttCtx.fixedTooltip) {
  16471. ttCtx.drawFixedTooltipRect();
  16472. }
  16473. if (w.globals.axisCharts) {
  16474. ttCtx.axisChartsTooltips({
  16475. e: e,
  16476. opt: opt,
  16477. tooltipRect: ttCtx.tooltipRect
  16478. });
  16479. } else {
  16480. // non-plot charts i.e pie/donut/circle
  16481. ttCtx.nonAxisChartsTooltips({
  16482. e: e,
  16483. opt: opt,
  16484. tooltipRect: ttCtx.tooltipRect
  16485. });
  16486. }
  16487. } // tooltip handling for line/area/bar/columns/scatter
  16488. }, {
  16489. key: "axisChartsTooltips",
  16490. value: function axisChartsTooltips(_ref2) {
  16491. var e = _ref2.e,
  16492. opt = _ref2.opt;
  16493. var w = this.w;
  16494. var x, y;
  16495. var seriesBound = opt.elGrid.getBoundingClientRect();
  16496. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  16497. var clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  16498. this.clientY = clientY;
  16499. this.clientX = clientX;
  16500. w.globals.capturedSeriesIndex = -1;
  16501. w.globals.capturedDataPointIndex = -1;
  16502. if (clientY < seriesBound.top || clientY > seriesBound.top + seriesBound.height) {
  16503. this.handleMouseOut(opt);
  16504. return;
  16505. }
  16506. if (Array.isArray(this.tConfig.enabledOnSeries) && !w.config.tooltip.shared) {
  16507. var index = parseInt(opt.paths.getAttribute('index'), 10);
  16508. if (this.tConfig.enabledOnSeries.indexOf(index) < 0) {
  16509. this.handleMouseOut(opt);
  16510. return;
  16511. }
  16512. }
  16513. var tooltipEl = this.getElTooltip();
  16514. var xcrosshairs = this.getElXCrosshairs();
  16515. 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();
  16516. if (e.type === 'mousemove' || e.type === 'touchmove' || e.type === 'mouseup') {
  16517. // there is no series to hover over
  16518. if (w.globals.collapsedSeries.length + w.globals.ancillaryCollapsedSeries.length === w.globals.series.length) {
  16519. return;
  16520. }
  16521. if (xcrosshairs !== null) {
  16522. xcrosshairs.classList.add('apexcharts-active');
  16523. }
  16524. var hasYAxisTooltip = this.yaxisTooltips.filter(function (b) {
  16525. return b === true;
  16526. });
  16527. if (this.ycrosshairs !== null && hasYAxisTooltip.length) {
  16528. this.ycrosshairs.classList.add('apexcharts-active');
  16529. }
  16530. if (isStickyTooltip && !this.showOnIntersect) {
  16531. this.handleStickyTooltip(e, clientX, clientY, opt);
  16532. } else {
  16533. if (w.config.chart.type === 'heatmap' || w.config.chart.type === 'treemap') {
  16534. var markerXY = this.intersect.handleHeatTreeTooltip({
  16535. e: e,
  16536. opt: opt,
  16537. x: x,
  16538. y: y,
  16539. type: w.config.chart.type
  16540. });
  16541. x = markerXY.x;
  16542. y = markerXY.y;
  16543. tooltipEl.style.left = x + 'px';
  16544. tooltipEl.style.top = y + 'px';
  16545. } else {
  16546. if (this.tooltipUtil.hasBars()) {
  16547. this.intersect.handleBarTooltip({
  16548. e: e,
  16549. opt: opt
  16550. });
  16551. }
  16552. if (this.tooltipUtil.hasMarkers()) {
  16553. // intersect - line/area/scatter/bubble
  16554. this.intersect.handleMarkerTooltip({
  16555. e: e,
  16556. opt: opt,
  16557. x: x,
  16558. y: y
  16559. });
  16560. }
  16561. }
  16562. }
  16563. if (this.yaxisTooltips.length) {
  16564. for (var yt = 0; yt < w.config.yaxis.length; yt++) {
  16565. this.axesTooltip.drawYaxisTooltipText(yt, clientY, this.xyRatios);
  16566. }
  16567. }
  16568. opt.tooltipEl.classList.add('apexcharts-active');
  16569. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  16570. this.handleMouseOut(opt);
  16571. }
  16572. } // tooltip handling for pie/donuts
  16573. }, {
  16574. key: "nonAxisChartsTooltips",
  16575. value: function nonAxisChartsTooltips(_ref3) {
  16576. var e = _ref3.e,
  16577. opt = _ref3.opt,
  16578. tooltipRect = _ref3.tooltipRect;
  16579. var w = this.w;
  16580. var rel = opt.paths.getAttribute('rel');
  16581. var tooltipEl = this.getElTooltip();
  16582. var seriesBound = w.globals.dom.elWrap.getBoundingClientRect();
  16583. if (e.type === 'mousemove' || e.type === 'touchmove') {
  16584. tooltipEl.classList.add('apexcharts-active');
  16585. this.tooltipLabels.drawSeriesTexts({
  16586. ttItems: opt.ttItems,
  16587. i: parseInt(rel, 10) - 1,
  16588. shared: false
  16589. });
  16590. var x = w.globals.clientX - seriesBound.left - tooltipRect.ttWidth / 2;
  16591. var y = w.globals.clientY - seriesBound.top - tooltipRect.ttHeight - 10;
  16592. tooltipEl.style.left = x + 'px';
  16593. tooltipEl.style.top = y + 'px';
  16594. if (w.config.legend.tooltipHoverFormatter) {
  16595. var legendFormatter = w.config.legend.tooltipHoverFormatter;
  16596. var i = rel - 1;
  16597. var legendName = this.legendLabels[i].getAttribute('data:default-text');
  16598. var text = legendFormatter(legendName, {
  16599. seriesIndex: i,
  16600. dataPointIndex: i,
  16601. w: w
  16602. });
  16603. this.legendLabels[i].innerHTML = text;
  16604. }
  16605. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  16606. tooltipEl.classList.remove('apexcharts-active');
  16607. if (w.config.legend.tooltipHoverFormatter) {
  16608. this.legendLabels.forEach(function (l) {
  16609. var defaultText = l.getAttribute('data:default-text');
  16610. l.innerHTML = decodeURIComponent(defaultText);
  16611. });
  16612. }
  16613. }
  16614. }
  16615. }, {
  16616. key: "handleStickyTooltip",
  16617. value: function handleStickyTooltip(e, clientX, clientY, opt) {
  16618. var w = this.w;
  16619. var capj = this.tooltipUtil.getNearestValues({
  16620. context: this,
  16621. hoverArea: opt.hoverArea,
  16622. elGrid: opt.elGrid,
  16623. clientX: clientX,
  16624. clientY: clientY
  16625. });
  16626. var j = capj.j;
  16627. var capturedSeries = capj.capturedSeries;
  16628. var bounds = opt.elGrid.getBoundingClientRect();
  16629. if (capj.hoverX < 0 || capj.hoverX > bounds.width) {
  16630. this.handleMouseOut(opt);
  16631. return;
  16632. }
  16633. if (capturedSeries !== null) {
  16634. this.handleStickyCapturedSeries(e, capturedSeries, opt, j);
  16635. } else {
  16636. // couldn't capture any series. check if shared X is same,
  16637. // if yes, draw a grouped tooltip
  16638. if (this.tooltipUtil.isXoverlap(j) || w.globals.isBarHorizontal) {
  16639. this.create(e, this, 0, j, opt.ttItems);
  16640. }
  16641. }
  16642. }
  16643. }, {
  16644. key: "handleStickyCapturedSeries",
  16645. value: function handleStickyCapturedSeries(e, capturedSeries, opt, j) {
  16646. var w = this.w;
  16647. if (!this.tConfig.shared) {
  16648. var ignoreNull = w.globals.series[capturedSeries][j] === null;
  16649. if (ignoreNull) {
  16650. this.handleMouseOut(opt);
  16651. return;
  16652. }
  16653. }
  16654. if (typeof w.globals.series[capturedSeries][j] !== 'undefined') {
  16655. if (this.tConfig.shared && this.tooltipUtil.isXoverlap(j) && this.tooltipUtil.isInitialSeriesSameLen()) {
  16656. this.create(e, this, capturedSeries, j, opt.ttItems);
  16657. } else {
  16658. this.create(e, this, capturedSeries, j, opt.ttItems, false);
  16659. }
  16660. } else {
  16661. if (this.tooltipUtil.isXoverlap(j)) {
  16662. this.create(e, this, 0, j, opt.ttItems);
  16663. }
  16664. }
  16665. }
  16666. }, {
  16667. key: "deactivateHoverFilter",
  16668. value: function deactivateHoverFilter() {
  16669. var w = this.w;
  16670. var graphics = new Graphics(this.ctx);
  16671. var allPaths = w.globals.dom.Paper.select(".apexcharts-bar-area");
  16672. for (var b = 0; b < allPaths.length; b++) {
  16673. graphics.pathMouseLeave(allPaths[b]);
  16674. }
  16675. }
  16676. }, {
  16677. key: "handleMouseOut",
  16678. value: function handleMouseOut(opt) {
  16679. var w = this.w;
  16680. var xcrosshairs = this.getElXCrosshairs();
  16681. opt.tooltipEl.classList.remove('apexcharts-active');
  16682. this.deactivateHoverFilter();
  16683. if (w.config.chart.type !== 'bubble') {
  16684. this.marker.resetPointsSize();
  16685. }
  16686. if (xcrosshairs !== null) {
  16687. xcrosshairs.classList.remove('apexcharts-active');
  16688. }
  16689. if (this.ycrosshairs !== null) {
  16690. this.ycrosshairs.classList.remove('apexcharts-active');
  16691. }
  16692. if (this.isXAxisTooltipEnabled) {
  16693. this.xaxisTooltip.classList.remove('apexcharts-active');
  16694. }
  16695. if (this.yaxisTooltips.length) {
  16696. if (this.yaxisTTEls === null) {
  16697. this.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  16698. }
  16699. for (var i = 0; i < this.yaxisTTEls.length; i++) {
  16700. this.yaxisTTEls[i].classList.remove('apexcharts-active');
  16701. }
  16702. }
  16703. if (w.config.legend.tooltipHoverFormatter) {
  16704. this.legendLabels.forEach(function (l) {
  16705. var defaultText = l.getAttribute('data:default-text');
  16706. l.innerHTML = decodeURIComponent(defaultText);
  16707. });
  16708. }
  16709. }
  16710. }, {
  16711. key: "markerClick",
  16712. value: function markerClick(e, seriesIndex, dataPointIndex) {
  16713. var w = this.w;
  16714. if (typeof w.config.chart.events.markerClick === 'function') {
  16715. w.config.chart.events.markerClick(e, this.ctx, {
  16716. seriesIndex: seriesIndex,
  16717. dataPointIndex: dataPointIndex,
  16718. w: w
  16719. });
  16720. }
  16721. this.ctx.events.fireEvent('markerClick', [e, this.ctx, {
  16722. seriesIndex: seriesIndex,
  16723. dataPointIndex: dataPointIndex,
  16724. w: w
  16725. }]);
  16726. }
  16727. }, {
  16728. key: "create",
  16729. value: function create(e, context, capturedSeries, j, ttItems) {
  16730. var shared = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  16731. var w = this.w;
  16732. var ttCtx = context;
  16733. if (e.type === 'mouseup') {
  16734. this.markerClick(e, capturedSeries, j);
  16735. }
  16736. if (shared === null) shared = this.tConfig.shared;
  16737. var hasMarkers = this.tooltipUtil.hasMarkers();
  16738. var bars = this.tooltipUtil.getElBars();
  16739. if (w.config.legend.tooltipHoverFormatter) {
  16740. var legendFormatter = w.config.legend.tooltipHoverFormatter;
  16741. var els = Array.from(this.legendLabels); // reset all legend values first
  16742. els.forEach(function (l) {
  16743. var legendName = l.getAttribute('data:default-text');
  16744. l.innerHTML = decodeURIComponent(legendName);
  16745. }); // for irregular time series
  16746. for (var i = 0; i < els.length; i++) {
  16747. var l = els[i];
  16748. var lsIndex = parseInt(l.getAttribute('i'), 10);
  16749. var legendName = decodeURIComponent(l.getAttribute('data:default-text'));
  16750. var text = legendFormatter(legendName, {
  16751. seriesIndex: shared ? lsIndex : capturedSeries,
  16752. dataPointIndex: j,
  16753. w: w
  16754. });
  16755. if (!shared) {
  16756. l.innerHTML = lsIndex === capturedSeries ? text : legendName;
  16757. if (capturedSeries === lsIndex) {
  16758. break;
  16759. }
  16760. } else {
  16761. l.innerHTML = w.globals.collapsedSeriesIndices.indexOf(lsIndex) < 0 ? text : legendName;
  16762. }
  16763. }
  16764. }
  16765. if (shared) {
  16766. ttCtx.tooltipLabels.drawSeriesTexts({
  16767. ttItems: ttItems,
  16768. i: capturedSeries,
  16769. j: j,
  16770. shared: this.showOnIntersect ? false : this.tConfig.shared
  16771. });
  16772. if (hasMarkers) {
  16773. if (w.globals.markers.largestSize > 0) {
  16774. ttCtx.marker.enlargePoints(j);
  16775. } else {
  16776. ttCtx.tooltipPosition.moveDynamicPointsOnHover(j);
  16777. }
  16778. }
  16779. if (this.tooltipUtil.hasBars()) {
  16780. this.barSeriesHeight = this.tooltipUtil.getBarsHeight(bars);
  16781. if (this.barSeriesHeight > 0) {
  16782. // hover state, activate snap filter
  16783. var graphics = new Graphics(this.ctx);
  16784. var paths = w.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(j, "']")); // de-activate first
  16785. this.deactivateHoverFilter();
  16786. this.tooltipPosition.moveStickyTooltipOverBars(j);
  16787. for (var b = 0; b < paths.length; b++) {
  16788. graphics.pathMouseEnter(paths[b]);
  16789. }
  16790. }
  16791. }
  16792. } else {
  16793. ttCtx.tooltipLabels.drawSeriesTexts({
  16794. shared: false,
  16795. ttItems: ttItems,
  16796. i: capturedSeries,
  16797. j: j
  16798. });
  16799. if (this.tooltipUtil.hasBars()) {
  16800. ttCtx.tooltipPosition.moveStickyTooltipOverBars(j);
  16801. }
  16802. if (hasMarkers) {
  16803. ttCtx.tooltipPosition.moveMarkers(capturedSeries, j);
  16804. }
  16805. }
  16806. }
  16807. }]);
  16808. return Tooltip;
  16809. }();
  16810. /**
  16811. * ApexCharts BarStacked Class responsible for drawing both Stacked Columns and Bars.
  16812. *
  16813. * @module BarStacked
  16814. * The whole calculation for stacked bar/column is different from normal bar/column,
  16815. * hence it makes sense to derive a new class for it extending most of the props of Parent Bar
  16816. **/
  16817. var BarStacked = /*#__PURE__*/function (_Bar) {
  16818. _inherits(BarStacked, _Bar);
  16819. var _super = _createSuper(BarStacked);
  16820. function BarStacked() {
  16821. _classCallCheck(this, BarStacked);
  16822. return _super.apply(this, arguments);
  16823. }
  16824. _createClass(BarStacked, [{
  16825. key: "draw",
  16826. value: function draw(series, seriesIndex) {
  16827. var _this = this;
  16828. var w = this.w;
  16829. this.graphics = new Graphics(this.ctx);
  16830. this.bar = new Bar(this.ctx, this.xyRatios);
  16831. var coreUtils = new CoreUtils(this.ctx, w);
  16832. series = coreUtils.getLogSeries(series);
  16833. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  16834. this.barHelpers.initVariables(series);
  16835. if (w.config.chart.stackType === '100%') {
  16836. series = w.globals.seriesPercent.slice();
  16837. }
  16838. this.series = series;
  16839. this.totalItems = 0;
  16840. this.prevY = []; // y position on chart
  16841. this.prevX = []; // x position on chart
  16842. this.prevYF = []; // y position including shapes on chart
  16843. this.prevXF = []; // x position including shapes on chart
  16844. this.prevYVal = []; // y values (series[i][j]) in columns
  16845. this.prevXVal = []; // x values (series[i][j]) in bars
  16846. this.xArrj = []; // xj indicates x position on graph in bars
  16847. this.xArrjF = []; // xjF indicates bar's x position + roundedShape's positions in bars
  16848. this.xArrjVal = []; // x val means the actual series's y values in horizontal/bars
  16849. this.yArrj = []; // yj indicates y position on graph in columns
  16850. this.yArrjF = []; // yjF indicates bar's y position + roundedShape's positions in columns
  16851. this.yArrjVal = []; // y val means the actual series's y values in columns
  16852. for (var sl = 0; sl < series.length; sl++) {
  16853. if (series[sl].length > 0) {
  16854. this.totalItems += series[sl].length;
  16855. }
  16856. }
  16857. var ret = this.graphics.group({
  16858. class: 'apexcharts-bar-series apexcharts-plot-series'
  16859. });
  16860. var x = 0;
  16861. var y = 0;
  16862. var _loop = function _loop(i, bc) {
  16863. var xDivision = void 0; // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  16864. var yDivision = void 0; // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  16865. var zeroH = void 0; // zeroH is the baseline where 0 meets y axis
  16866. var zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  16867. var xArrValues = [];
  16868. var yArrValues = [];
  16869. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  16870. if (_this.yRatio.length > 1) {
  16871. _this.yaxisIndex = realIndex;
  16872. }
  16873. _this.isReversed = w.config.yaxis[_this.yaxisIndex] && w.config.yaxis[_this.yaxisIndex].reversed; // el to which series will be drawn
  16874. var elSeries = _this.graphics.group({
  16875. class: "apexcharts-series",
  16876. seriesName: Utils$1.escapeString(w.globals.seriesNames[realIndex]),
  16877. rel: i + 1,
  16878. 'data:realIndex': realIndex
  16879. });
  16880. _this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex); // eldatalabels
  16881. var elDataLabelsWrap = _this.graphics.group({
  16882. class: 'apexcharts-datalabels',
  16883. 'data:realIndex': realIndex
  16884. });
  16885. var barHeight = 0;
  16886. var barWidth = 0;
  16887. var initPositions = _this.initialPositions(x, y, xDivision, yDivision, zeroH, zeroW);
  16888. y = initPositions.y;
  16889. barHeight = initPositions.barHeight;
  16890. yDivision = initPositions.yDivision;
  16891. zeroW = initPositions.zeroW;
  16892. x = initPositions.x;
  16893. barWidth = initPositions.barWidth;
  16894. xDivision = initPositions.xDivision;
  16895. zeroH = initPositions.zeroH;
  16896. _this.yArrj = [];
  16897. _this.yArrjF = [];
  16898. _this.yArrjVal = [];
  16899. _this.xArrj = [];
  16900. _this.xArrjF = [];
  16901. _this.xArrjVal = []; // if (!this.horizontal) {
  16902. // this.xArrj.push(x + barWidth / 2)
  16903. // }
  16904. // fix issue #1215;
  16905. // where all stack bar disappear after collapsing the first series
  16906. // sol: if only 1 arr in this.prevY(this.prevY.length === 1) and all are NaN
  16907. if (_this.prevY.length === 1 && _this.prevY[0].every(function (val) {
  16908. return isNaN(val);
  16909. })) {
  16910. // make this.prevY[0] all zeroH
  16911. _this.prevY[0] = _this.prevY[0].map(function (val) {
  16912. return zeroH;
  16913. }); // make this.prevYF[0] all 0
  16914. _this.prevYF[0] = _this.prevYF[0].map(function (val) {
  16915. return 0;
  16916. });
  16917. }
  16918. for (var j = 0; j < w.globals.dataPoints; j++) {
  16919. var strokeWidth = _this.barHelpers.getStrokeWidth(i, j, realIndex);
  16920. var commonPathOpts = {
  16921. indexes: {
  16922. i: i,
  16923. j: j,
  16924. realIndex: realIndex,
  16925. bc: bc
  16926. },
  16927. strokeWidth: strokeWidth,
  16928. x: x,
  16929. y: y,
  16930. elSeries: elSeries
  16931. };
  16932. var paths = null;
  16933. if (_this.isHorizontal) {
  16934. paths = _this.drawStackedBarPaths(_objectSpread2(_objectSpread2({}, commonPathOpts), {}, {
  16935. zeroW: zeroW,
  16936. barHeight: barHeight,
  16937. yDivision: yDivision
  16938. }));
  16939. barWidth = _this.series[i][j] / _this.invertedYRatio;
  16940. } else {
  16941. paths = _this.drawStackedColumnPaths(_objectSpread2(_objectSpread2({}, commonPathOpts), {}, {
  16942. xDivision: xDivision,
  16943. barWidth: barWidth,
  16944. zeroH: zeroH
  16945. }));
  16946. barHeight = _this.series[i][j] / _this.yRatio[_this.yaxisIndex];
  16947. }
  16948. y = paths.y;
  16949. x = paths.x;
  16950. xArrValues.push(x);
  16951. yArrValues.push(y);
  16952. var pathFill = _this.barHelpers.getPathFillColor(series, i, j, realIndex);
  16953. elSeries = _this.renderSeries({
  16954. realIndex: realIndex,
  16955. pathFill: pathFill,
  16956. j: j,
  16957. i: i,
  16958. pathFrom: paths.pathFrom,
  16959. pathTo: paths.pathTo,
  16960. strokeWidth: strokeWidth,
  16961. elSeries: elSeries,
  16962. x: x,
  16963. y: y,
  16964. series: series,
  16965. barHeight: barHeight,
  16966. barWidth: barWidth,
  16967. elDataLabelsWrap: elDataLabelsWrap,
  16968. type: 'bar',
  16969. visibleSeries: 0
  16970. });
  16971. } // push all x val arrays into main xArr
  16972. w.globals.seriesXvalues[realIndex] = xArrValues;
  16973. w.globals.seriesYvalues[realIndex] = yArrValues; // push all current y values array to main PrevY Array
  16974. _this.prevY.push(_this.yArrj);
  16975. _this.prevYF.push(_this.yArrjF);
  16976. _this.prevYVal.push(_this.yArrjVal);
  16977. _this.prevX.push(_this.xArrj);
  16978. _this.prevXF.push(_this.xArrjF);
  16979. _this.prevXVal.push(_this.xArrjVal);
  16980. ret.add(elSeries);
  16981. };
  16982. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  16983. _loop(i, bc);
  16984. }
  16985. return ret;
  16986. }
  16987. }, {
  16988. key: "initialPositions",
  16989. value: function initialPositions(x, y, xDivision, yDivision, zeroH, zeroW) {
  16990. var w = this.w;
  16991. var barHeight, barWidth;
  16992. if (this.isHorizontal) {
  16993. // height divided into equal parts
  16994. yDivision = w.globals.gridHeight / w.globals.dataPoints;
  16995. barHeight = yDivision;
  16996. barHeight = barHeight * parseInt(w.config.plotOptions.bar.barHeight, 10) / 100;
  16997. 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
  16998. y = (yDivision - barHeight) / 2;
  16999. } else {
  17000. // width divided into equal parts
  17001. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  17002. barWidth = xDivision;
  17003. if (w.globals.isXNumeric && w.globals.dataPoints > 1) {
  17004. // the check (w.globals.dataPoints > 1) fixes apexcharts.js #1617
  17005. xDivision = w.globals.minXDiff / this.xRatio;
  17006. barWidth = xDivision * parseInt(this.barOptions.columnWidth, 10) / 100;
  17007. } else {
  17008. barWidth = barWidth * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  17009. }
  17010. 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
  17011. x = w.globals.padHorizontal + (xDivision - barWidth) / 2;
  17012. }
  17013. return {
  17014. x: x,
  17015. y: y,
  17016. yDivision: yDivision,
  17017. xDivision: xDivision,
  17018. barHeight: barHeight,
  17019. barWidth: barWidth,
  17020. zeroH: zeroH,
  17021. zeroW: zeroW
  17022. };
  17023. }
  17024. }, {
  17025. key: "drawStackedBarPaths",
  17026. value: function drawStackedBarPaths(_ref) {
  17027. var indexes = _ref.indexes,
  17028. barHeight = _ref.barHeight,
  17029. strokeWidth = _ref.strokeWidth,
  17030. zeroW = _ref.zeroW,
  17031. x = _ref.x,
  17032. y = _ref.y,
  17033. yDivision = _ref.yDivision,
  17034. elSeries = _ref.elSeries;
  17035. var w = this.w;
  17036. var barYPosition = y;
  17037. var barXPosition;
  17038. var i = indexes.i;
  17039. var j = indexes.j;
  17040. var prevBarW = 0;
  17041. for (var k = 0; k < this.prevXF.length; k++) {
  17042. prevBarW = prevBarW + this.prevXF[k][j];
  17043. }
  17044. if (i > 0) {
  17045. var bXP = zeroW;
  17046. if (this.prevXVal[i - 1][j] < 0) {
  17047. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] + prevBarW - (this.isReversed ? prevBarW : 0) * 2 : this.prevX[i - 1][j];
  17048. } else if (this.prevXVal[i - 1][j] >= 0) {
  17049. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] : this.prevX[i - 1][j] - prevBarW + (this.isReversed ? prevBarW : 0) * 2;
  17050. }
  17051. barXPosition = bXP;
  17052. } else {
  17053. // the first series will not have prevX values
  17054. barXPosition = zeroW;
  17055. }
  17056. if (this.series[i][j] === null) {
  17057. x = barXPosition;
  17058. } else {
  17059. x = barXPosition + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
  17060. }
  17061. var paths = this.barHelpers.getBarpaths({
  17062. barYPosition: barYPosition,
  17063. barHeight: barHeight,
  17064. x1: barXPosition,
  17065. x2: x,
  17066. strokeWidth: strokeWidth,
  17067. series: this.series,
  17068. realIndex: indexes.realIndex,
  17069. i: i,
  17070. j: j,
  17071. w: w
  17072. });
  17073. this.barHelpers.barBackground({
  17074. j: j,
  17075. i: i,
  17076. y1: barYPosition,
  17077. y2: barHeight,
  17078. elSeries: elSeries
  17079. });
  17080. y = y + yDivision;
  17081. return {
  17082. pathTo: paths.pathTo,
  17083. pathFrom: paths.pathFrom,
  17084. x: x,
  17085. y: y
  17086. };
  17087. }
  17088. }, {
  17089. key: "drawStackedColumnPaths",
  17090. value: function drawStackedColumnPaths(_ref2) {
  17091. var indexes = _ref2.indexes,
  17092. x = _ref2.x,
  17093. y = _ref2.y,
  17094. xDivision = _ref2.xDivision,
  17095. barWidth = _ref2.barWidth,
  17096. zeroH = _ref2.zeroH;
  17097. _ref2.strokeWidth;
  17098. var elSeries = _ref2.elSeries;
  17099. var w = this.w;
  17100. var i = indexes.i;
  17101. var j = indexes.j;
  17102. var bc = indexes.bc;
  17103. if (w.globals.isXNumeric) {
  17104. var seriesVal = w.globals.seriesX[i][j];
  17105. if (!seriesVal) seriesVal = 0;
  17106. x = (seriesVal - w.globals.minX) / this.xRatio - barWidth / 2;
  17107. }
  17108. var barXPosition = x;
  17109. var barYPosition;
  17110. var prevBarH = 0;
  17111. for (var k = 0; k < this.prevYF.length; k++) {
  17112. // fix issue #1215
  17113. // in case where this.prevYF[k][j] is NaN, use 0 instead
  17114. prevBarH = prevBarH + (!isNaN(this.prevYF[k][j]) ? this.prevYF[k][j] : 0);
  17115. }
  17116. if (i > 0 && !w.globals.isXNumeric || i > 0 && w.globals.isXNumeric && w.globals.seriesX[i - 1][j] === w.globals.seriesX[i][j]) {
  17117. var bYP;
  17118. var prevYValue;
  17119. var p = Math.min(this.yRatio.length + 1, i + 1);
  17120. if (this.prevY[i - 1] !== undefined) {
  17121. for (var ii = 1; ii < p; ii++) {
  17122. if (!isNaN(this.prevY[i - ii][j])) {
  17123. // find the previous available value to give prevYValue
  17124. prevYValue = this.prevY[i - ii][j]; // if found it, break the loop
  17125. break;
  17126. }
  17127. }
  17128. }
  17129. for (var _ii = 1; _ii < p; _ii++) {
  17130. // find the previous available value(non-NaN) to give bYP
  17131. if (this.prevYVal[i - _ii][j] < 0) {
  17132. bYP = this.series[i][j] >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue; // found it? break the loop
  17133. break;
  17134. } else if (this.prevYVal[i - _ii][j] >= 0) {
  17135. bYP = this.series[i][j] >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2; // found it? break the loop
  17136. break;
  17137. }
  17138. }
  17139. if (typeof bYP === 'undefined') bYP = w.globals.gridHeight; // if this.prevYF[0] is all 0 resulted from line #486
  17140. // AND every arr starting from the second only contains NaN
  17141. if (this.prevYF[0].every(function (val) {
  17142. return val === 0;
  17143. }) && this.prevYF.slice(1, i).every(function (arr) {
  17144. return arr.every(function (val) {
  17145. return isNaN(val);
  17146. });
  17147. })) {
  17148. // Use the same calc way as line #485
  17149. barYPosition = w.globals.gridHeight - zeroH;
  17150. } else {
  17151. // Nothing special
  17152. barYPosition = bYP;
  17153. }
  17154. } else {
  17155. // 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
  17156. barYPosition = w.globals.gridHeight - zeroH;
  17157. }
  17158. y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
  17159. var paths = this.barHelpers.getColumnPaths({
  17160. barXPosition: barXPosition,
  17161. barWidth: barWidth,
  17162. y1: barYPosition,
  17163. y2: y,
  17164. yRatio: this.yRatio[this.yaxisIndex],
  17165. strokeWidth: this.strokeWidth,
  17166. series: this.series,
  17167. realIndex: indexes.realIndex,
  17168. i: i,
  17169. j: j,
  17170. w: w
  17171. });
  17172. this.barHelpers.barBackground({
  17173. bc: bc,
  17174. j: j,
  17175. i: i,
  17176. x1: barXPosition,
  17177. x2: barWidth,
  17178. elSeries: elSeries
  17179. });
  17180. x = x + xDivision;
  17181. return {
  17182. pathTo: paths.pathTo,
  17183. pathFrom: paths.pathFrom,
  17184. x: w.globals.isXNumeric ? x - xDivision : x,
  17185. y: y
  17186. };
  17187. }
  17188. }]);
  17189. return BarStacked;
  17190. }(Bar);
  17191. /**
  17192. * ApexCharts BoxCandleStick Class responsible for drawing both Stacked Columns and Bars.
  17193. *
  17194. * @module BoxCandleStick
  17195. **/
  17196. var BoxCandleStick = /*#__PURE__*/function (_Bar) {
  17197. _inherits(BoxCandleStick, _Bar);
  17198. var _super = _createSuper(BoxCandleStick);
  17199. function BoxCandleStick() {
  17200. _classCallCheck(this, BoxCandleStick);
  17201. return _super.apply(this, arguments);
  17202. }
  17203. _createClass(BoxCandleStick, [{
  17204. key: "draw",
  17205. value: function draw(series, seriesIndex) {
  17206. var _this = this;
  17207. var w = this.w;
  17208. var graphics = new Graphics(this.ctx);
  17209. var fill = new Fill(this.ctx);
  17210. this.candlestickOptions = this.w.config.plotOptions.candlestick;
  17211. this.boxOptions = this.w.config.plotOptions.boxPlot;
  17212. this.isHorizontal = w.config.plotOptions.bar.horizontal;
  17213. var coreUtils = new CoreUtils(this.ctx, w);
  17214. series = coreUtils.getLogSeries(series);
  17215. this.series = series;
  17216. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  17217. this.barHelpers.initVariables(series);
  17218. var ret = graphics.group({
  17219. class: "apexcharts-".concat(w.config.chart.type, "-series apexcharts-plot-series")
  17220. });
  17221. var _loop = function _loop(i) {
  17222. _this.isBoxPlot = w.config.chart.type === 'boxPlot' || w.config.series[i].type === 'boxPlot';
  17223. var x = void 0,
  17224. y = void 0,
  17225. xDivision = void 0,
  17226. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  17227. yDivision = void 0,
  17228. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  17229. zeroH = void 0,
  17230. // zeroH is the baseline where 0 meets y axis
  17231. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  17232. var yArrj = []; // hold y values of current iterating series
  17233. var xArrj = []; // hold x values of current iterating series
  17234. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  17235. var elSeries = graphics.group({
  17236. class: "apexcharts-series",
  17237. seriesName: Utils$1.escapeString(w.globals.seriesNames[realIndex]),
  17238. rel: i + 1,
  17239. 'data:realIndex': realIndex
  17240. });
  17241. _this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
  17242. if (series[i].length > 0) {
  17243. _this.visibleI = _this.visibleI + 1;
  17244. }
  17245. var barHeight = 0;
  17246. var barWidth = 0;
  17247. if (_this.yRatio.length > 1) {
  17248. _this.yaxisIndex = realIndex;
  17249. }
  17250. var initPositions = _this.barHelpers.initialPositions();
  17251. y = initPositions.y;
  17252. barHeight = initPositions.barHeight;
  17253. yDivision = initPositions.yDivision;
  17254. zeroW = initPositions.zeroW;
  17255. x = initPositions.x;
  17256. barWidth = initPositions.barWidth;
  17257. xDivision = initPositions.xDivision;
  17258. zeroH = initPositions.zeroH;
  17259. xArrj.push(x + barWidth / 2); // eldatalabels
  17260. var elDataLabelsWrap = graphics.group({
  17261. class: 'apexcharts-datalabels',
  17262. 'data:realIndex': realIndex
  17263. });
  17264. var _loop2 = function _loop2(j) {
  17265. var strokeWidth = _this.barHelpers.getStrokeWidth(i, j, realIndex);
  17266. var paths = null;
  17267. var pathsParams = {
  17268. indexes: {
  17269. i: i,
  17270. j: j,
  17271. realIndex: realIndex
  17272. },
  17273. x: x,
  17274. y: y,
  17275. strokeWidth: strokeWidth,
  17276. elSeries: elSeries
  17277. };
  17278. if (_this.isHorizontal) {
  17279. paths = _this.drawHorizontalBoxPaths(_objectSpread2(_objectSpread2({}, pathsParams), {}, {
  17280. yDivision: yDivision,
  17281. barHeight: barHeight,
  17282. zeroW: zeroW
  17283. }));
  17284. } else {
  17285. paths = _this.drawVerticalBoxPaths(_objectSpread2(_objectSpread2({}, pathsParams), {}, {
  17286. xDivision: xDivision,
  17287. barWidth: barWidth,
  17288. zeroH: zeroH
  17289. }));
  17290. }
  17291. y = paths.y;
  17292. x = paths.x; // push current X
  17293. if (j > 0) {
  17294. xArrj.push(x + barWidth / 2);
  17295. }
  17296. yArrj.push(y);
  17297. paths.pathTo.forEach(function (pathTo, pi) {
  17298. var lineFill = !_this.isBoxPlot && _this.candlestickOptions.wick.useFillColor ? paths.color[pi] : w.globals.stroke.colors[i];
  17299. var pathFill = fill.fillPath({
  17300. seriesNumber: realIndex,
  17301. dataPointIndex: j,
  17302. color: paths.color[pi],
  17303. value: series[i][j]
  17304. });
  17305. _this.renderSeries({
  17306. realIndex: realIndex,
  17307. pathFill: pathFill,
  17308. lineFill: lineFill,
  17309. j: j,
  17310. i: i,
  17311. pathFrom: paths.pathFrom,
  17312. pathTo: pathTo,
  17313. strokeWidth: strokeWidth,
  17314. elSeries: elSeries,
  17315. x: x,
  17316. y: y,
  17317. series: series,
  17318. barHeight: barHeight,
  17319. barWidth: barWidth,
  17320. elDataLabelsWrap: elDataLabelsWrap,
  17321. visibleSeries: _this.visibleI,
  17322. type: w.config.chart.type
  17323. });
  17324. });
  17325. };
  17326. for (var j = 0; j < w.globals.dataPoints; j++) {
  17327. _loop2(j);
  17328. } // push all x val arrays into main xArr
  17329. w.globals.seriesXvalues[realIndex] = xArrj;
  17330. w.globals.seriesYvalues[realIndex] = yArrj;
  17331. ret.add(elSeries);
  17332. };
  17333. for (var i = 0; i < series.length; i++) {
  17334. _loop(i);
  17335. }
  17336. return ret;
  17337. }
  17338. }, {
  17339. key: "drawVerticalBoxPaths",
  17340. value: function drawVerticalBoxPaths(_ref) {
  17341. var indexes = _ref.indexes,
  17342. x = _ref.x;
  17343. _ref.y;
  17344. var xDivision = _ref.xDivision,
  17345. barWidth = _ref.barWidth,
  17346. zeroH = _ref.zeroH,
  17347. strokeWidth = _ref.strokeWidth;
  17348. var w = this.w;
  17349. var graphics = new Graphics(this.ctx);
  17350. var i = indexes.i;
  17351. var j = indexes.j;
  17352. var isPositive = true;
  17353. var colorPos = w.config.plotOptions.candlestick.colors.upward;
  17354. var colorNeg = w.config.plotOptions.candlestick.colors.downward;
  17355. var color = '';
  17356. if (this.isBoxPlot) {
  17357. color = [this.boxOptions.colors.lower, this.boxOptions.colors.upper];
  17358. }
  17359. var yRatio = this.yRatio[this.yaxisIndex];
  17360. var realIndex = indexes.realIndex;
  17361. var ohlc = this.getOHLCValue(realIndex, j);
  17362. var l1 = zeroH;
  17363. var l2 = zeroH;
  17364. if (ohlc.o > ohlc.c) {
  17365. isPositive = false;
  17366. }
  17367. var y1 = Math.min(ohlc.o, ohlc.c);
  17368. var y2 = Math.max(ohlc.o, ohlc.c);
  17369. var m = ohlc.m;
  17370. if (w.globals.isXNumeric) {
  17371. x = (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  17372. }
  17373. var barXPosition = x + barWidth * this.visibleI;
  17374. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  17375. y1 = zeroH;
  17376. y2 = zeroH;
  17377. } else {
  17378. y1 = zeroH - y1 / yRatio;
  17379. y2 = zeroH - y2 / yRatio;
  17380. l1 = zeroH - ohlc.h / yRatio;
  17381. l2 = zeroH - ohlc.l / yRatio;
  17382. m = zeroH - ohlc.m / yRatio;
  17383. }
  17384. var pathTo = graphics.move(barXPosition, zeroH);
  17385. var pathFrom = graphics.move(barXPosition + barWidth / 2, y1);
  17386. if (w.globals.previousPaths.length > 0) {
  17387. pathFrom = this.getPreviousPath(realIndex, j, true);
  17388. }
  17389. if (this.isBoxPlot) {
  17390. pathTo = [graphics.move(barXPosition, y1) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition + barWidth / 2, l1) + graphics.line(barXPosition + barWidth / 4, l1) + graphics.line(barXPosition + barWidth - barWidth / 4, l1) + graphics.line(barXPosition + barWidth / 2, l1) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition + barWidth, y1) + graphics.line(barXPosition + barWidth, m) + graphics.line(barXPosition, m) + graphics.line(barXPosition, y1 + strokeWidth / 2), graphics.move(barXPosition, m) + graphics.line(barXPosition + barWidth, m) + graphics.line(barXPosition + barWidth, y2) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition + barWidth / 2, l2) + graphics.line(barXPosition + barWidth - barWidth / 4, l2) + graphics.line(barXPosition + barWidth / 4, l2) + graphics.line(barXPosition + barWidth / 2, l2) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition, y2) + graphics.line(barXPosition, m) + 'z'];
  17391. } else {
  17392. // candlestick
  17393. 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)];
  17394. }
  17395. pathFrom = pathFrom + graphics.move(barXPosition, y1);
  17396. if (!w.globals.isXNumeric) {
  17397. x = x + xDivision;
  17398. }
  17399. return {
  17400. pathTo: pathTo,
  17401. pathFrom: pathFrom,
  17402. x: x,
  17403. y: y2,
  17404. barXPosition: barXPosition,
  17405. color: this.isBoxPlot ? color : isPositive ? [colorPos] : [colorNeg]
  17406. };
  17407. }
  17408. }, {
  17409. key: "drawHorizontalBoxPaths",
  17410. value: function drawHorizontalBoxPaths(_ref2) {
  17411. var indexes = _ref2.indexes;
  17412. _ref2.x;
  17413. var y = _ref2.y,
  17414. yDivision = _ref2.yDivision,
  17415. barHeight = _ref2.barHeight,
  17416. zeroW = _ref2.zeroW,
  17417. strokeWidth = _ref2.strokeWidth;
  17418. var w = this.w;
  17419. var graphics = new Graphics(this.ctx);
  17420. var i = indexes.i;
  17421. var j = indexes.j;
  17422. var color = this.boxOptions.colors.lower;
  17423. if (this.isBoxPlot) {
  17424. color = [this.boxOptions.colors.lower, this.boxOptions.colors.upper];
  17425. }
  17426. var yRatio = this.invertedYRatio;
  17427. var realIndex = indexes.realIndex;
  17428. var ohlc = this.getOHLCValue(realIndex, j);
  17429. var l1 = zeroW;
  17430. var l2 = zeroW;
  17431. var x1 = Math.min(ohlc.o, ohlc.c);
  17432. var x2 = Math.max(ohlc.o, ohlc.c);
  17433. var m = ohlc.m;
  17434. if (w.globals.isXNumeric) {
  17435. y = (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.invertedXRatio - barHeight / 2;
  17436. }
  17437. var barYPosition = y + barHeight * this.visibleI;
  17438. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  17439. x1 = zeroW;
  17440. x2 = zeroW;
  17441. } else {
  17442. x1 = zeroW + x1 / yRatio;
  17443. x2 = zeroW + x2 / yRatio;
  17444. l1 = zeroW + ohlc.h / yRatio;
  17445. l2 = zeroW + ohlc.l / yRatio;
  17446. m = zeroW + ohlc.m / yRatio;
  17447. }
  17448. var pathTo = graphics.move(zeroW, barYPosition);
  17449. var pathFrom = graphics.move(x1, barYPosition + barHeight / 2);
  17450. if (w.globals.previousPaths.length > 0) {
  17451. pathFrom = this.getPreviousPath(realIndex, j, true);
  17452. }
  17453. pathTo = [graphics.move(x1, barYPosition) + graphics.line(x1, barYPosition + barHeight / 2) + graphics.line(l1, barYPosition + barHeight / 2) + graphics.line(l1, barYPosition + barHeight / 2 - barHeight / 4) + graphics.line(l1, barYPosition + barHeight / 2 + barHeight / 4) + graphics.line(l1, barYPosition + barHeight / 2) + graphics.line(x1, barYPosition + barHeight / 2) + graphics.line(x1, barYPosition + barHeight) + graphics.line(m, barYPosition + barHeight) + graphics.line(m, barYPosition) + graphics.line(x1 + strokeWidth / 2, barYPosition), graphics.move(m, barYPosition) + graphics.line(m, barYPosition + barHeight) + graphics.line(x2, barYPosition + barHeight) + graphics.line(x2, barYPosition + barHeight / 2) + graphics.line(l2, barYPosition + barHeight / 2) + graphics.line(l2, barYPosition + barHeight - barHeight / 4) + graphics.line(l2, barYPosition + barHeight / 4) + graphics.line(l2, barYPosition + barHeight / 2) + graphics.line(x2, barYPosition + barHeight / 2) + graphics.line(x2, barYPosition) + graphics.line(m, barYPosition) + 'z'];
  17454. pathFrom = pathFrom + graphics.move(x1, barYPosition);
  17455. if (!w.globals.isXNumeric) {
  17456. y = y + yDivision;
  17457. }
  17458. return {
  17459. pathTo: pathTo,
  17460. pathFrom: pathFrom,
  17461. x: x2,
  17462. y: y,
  17463. barYPosition: barYPosition,
  17464. color: color
  17465. };
  17466. }
  17467. }, {
  17468. key: "getOHLCValue",
  17469. value: function getOHLCValue(i, j) {
  17470. var w = this.w;
  17471. return {
  17472. o: this.isBoxPlot ? w.globals.seriesCandleH[i][j] : w.globals.seriesCandleO[i][j],
  17473. h: this.isBoxPlot ? w.globals.seriesCandleO[i][j] : w.globals.seriesCandleH[i][j],
  17474. m: w.globals.seriesCandleM[i][j],
  17475. l: this.isBoxPlot ? w.globals.seriesCandleC[i][j] : w.globals.seriesCandleL[i][j],
  17476. c: this.isBoxPlot ? w.globals.seriesCandleL[i][j] : w.globals.seriesCandleC[i][j]
  17477. };
  17478. }
  17479. }]);
  17480. return BoxCandleStick;
  17481. }(Bar);
  17482. var TreemapHelpers = /*#__PURE__*/function () {
  17483. function TreemapHelpers(ctx) {
  17484. _classCallCheck(this, TreemapHelpers);
  17485. this.ctx = ctx;
  17486. this.w = ctx.w;
  17487. }
  17488. _createClass(TreemapHelpers, [{
  17489. key: "checkColorRange",
  17490. value: function checkColorRange() {
  17491. var w = this.w;
  17492. var negRange = false;
  17493. var chartOpts = w.config.plotOptions[w.config.chart.type];
  17494. if (chartOpts.colorScale.ranges.length > 0) {
  17495. chartOpts.colorScale.ranges.map(function (range, index) {
  17496. if (range.from <= 0) {
  17497. negRange = true;
  17498. }
  17499. });
  17500. }
  17501. return negRange;
  17502. }
  17503. }, {
  17504. key: "getShadeColor",
  17505. value: function getShadeColor(chartType, i, j, negRange) {
  17506. var w = this.w;
  17507. var colorShadePercent = 1;
  17508. var shadeIntensity = w.config.plotOptions[chartType].shadeIntensity;
  17509. var colorProps = this.determineColor(chartType, i, j);
  17510. if (w.globals.hasNegs || negRange) {
  17511. if (w.config.plotOptions[chartType].reverseNegativeShade) {
  17512. if (colorProps.percent < 0) {
  17513. colorShadePercent = colorProps.percent / 100 * (shadeIntensity * 1.25);
  17514. } else {
  17515. colorShadePercent = (1 - colorProps.percent / 100) * (shadeIntensity * 1.25);
  17516. }
  17517. } else {
  17518. if (colorProps.percent <= 0) {
  17519. colorShadePercent = 1 - (1 + colorProps.percent / 100) * shadeIntensity;
  17520. } else {
  17521. colorShadePercent = (1 - colorProps.percent / 100) * shadeIntensity;
  17522. }
  17523. }
  17524. } else {
  17525. colorShadePercent = 1 - colorProps.percent / 100;
  17526. if (chartType === 'treemap') {
  17527. colorShadePercent = (1 - colorProps.percent / 100) * (shadeIntensity * 1.25);
  17528. }
  17529. }
  17530. var color = colorProps.color;
  17531. var utils = new Utils$1();
  17532. if (w.config.plotOptions[chartType].enableShades) {
  17533. if (this.w.config.theme.mode === 'dark') {
  17534. color = Utils$1.hexToRgba(utils.shadeColor(colorShadePercent * -1, colorProps.color), w.config.fill.opacity);
  17535. } else {
  17536. color = Utils$1.hexToRgba(utils.shadeColor(colorShadePercent, colorProps.color), w.config.fill.opacity);
  17537. }
  17538. }
  17539. return {
  17540. color: color,
  17541. colorProps: colorProps
  17542. };
  17543. }
  17544. }, {
  17545. key: "determineColor",
  17546. value: function determineColor(chartType, i, j) {
  17547. var w = this.w;
  17548. var val = w.globals.series[i][j];
  17549. var chartOpts = w.config.plotOptions[chartType];
  17550. var seriesNumber = chartOpts.colorScale.inverse ? j : i;
  17551. if (chartOpts.distributed && w.config.chart.type === 'treemap') {
  17552. seriesNumber = j;
  17553. }
  17554. var color = w.globals.colors[seriesNumber];
  17555. var foreColor = null;
  17556. var min = Math.min.apply(Math, _toConsumableArray(w.globals.series[i]));
  17557. var max = Math.max.apply(Math, _toConsumableArray(w.globals.series[i]));
  17558. if (!chartOpts.distributed && chartType === 'heatmap') {
  17559. min = w.globals.minY;
  17560. max = w.globals.maxY;
  17561. }
  17562. if (typeof chartOpts.colorScale.min !== 'undefined') {
  17563. min = chartOpts.colorScale.min < w.globals.minY ? chartOpts.colorScale.min : w.globals.minY;
  17564. max = chartOpts.colorScale.max > w.globals.maxY ? chartOpts.colorScale.max : w.globals.maxY;
  17565. }
  17566. var total = Math.abs(max) + Math.abs(min);
  17567. var percent = 100 * val / (total === 0 ? total - 0.000001 : total);
  17568. if (chartOpts.colorScale.ranges.length > 0) {
  17569. var colorRange = chartOpts.colorScale.ranges;
  17570. colorRange.map(function (range, index) {
  17571. if (val >= range.from && val <= range.to) {
  17572. color = range.color;
  17573. foreColor = range.foreColor ? range.foreColor : null;
  17574. min = range.from;
  17575. max = range.to;
  17576. var rTotal = Math.abs(max) + Math.abs(min);
  17577. percent = 100 * val / (rTotal === 0 ? rTotal - 0.000001 : rTotal);
  17578. }
  17579. });
  17580. }
  17581. return {
  17582. color: color,
  17583. foreColor: foreColor,
  17584. percent: percent
  17585. };
  17586. }
  17587. }, {
  17588. key: "calculateDataLabels",
  17589. value: function calculateDataLabels(_ref) {
  17590. var text = _ref.text,
  17591. x = _ref.x,
  17592. y = _ref.y,
  17593. i = _ref.i,
  17594. j = _ref.j,
  17595. colorProps = _ref.colorProps,
  17596. fontSize = _ref.fontSize;
  17597. var w = this.w;
  17598. var dataLabelsConfig = w.config.dataLabels;
  17599. var graphics = new Graphics(this.ctx);
  17600. var dataLabels = new DataLabels(this.ctx);
  17601. var elDataLabelsWrap = null;
  17602. if (dataLabelsConfig.enabled) {
  17603. elDataLabelsWrap = graphics.group({
  17604. class: 'apexcharts-data-labels'
  17605. });
  17606. var offX = dataLabelsConfig.offsetX;
  17607. var offY = dataLabelsConfig.offsetY;
  17608. var dataLabelsX = x + offX;
  17609. var dataLabelsY = y + parseFloat(dataLabelsConfig.style.fontSize) / 3 + offY;
  17610. dataLabels.plotDataLabelsText({
  17611. x: dataLabelsX,
  17612. y: dataLabelsY,
  17613. text: text,
  17614. i: i,
  17615. j: j,
  17616. color: colorProps.foreColor,
  17617. parent: elDataLabelsWrap,
  17618. fontSize: fontSize,
  17619. dataLabelsConfig: dataLabelsConfig
  17620. });
  17621. }
  17622. return elDataLabelsWrap;
  17623. }
  17624. }, {
  17625. key: "addListeners",
  17626. value: function addListeners(elRect) {
  17627. var graphics = new Graphics(this.ctx);
  17628. elRect.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elRect));
  17629. elRect.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elRect));
  17630. elRect.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elRect));
  17631. }
  17632. }]);
  17633. return TreemapHelpers;
  17634. }();
  17635. /**
  17636. * ApexCharts HeatMap Class.
  17637. * @module HeatMap
  17638. **/
  17639. var HeatMap = /*#__PURE__*/function () {
  17640. function HeatMap(ctx, xyRatios) {
  17641. _classCallCheck(this, HeatMap);
  17642. this.ctx = ctx;
  17643. this.w = ctx.w;
  17644. this.xRatio = xyRatios.xRatio;
  17645. this.yRatio = xyRatios.yRatio;
  17646. this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation;
  17647. this.helpers = new TreemapHelpers(ctx);
  17648. this.rectRadius = this.w.config.plotOptions.heatmap.radius;
  17649. this.strokeWidth = this.w.config.stroke.show ? this.w.config.stroke.width : 0;
  17650. }
  17651. _createClass(HeatMap, [{
  17652. key: "draw",
  17653. value: function draw(series) {
  17654. var w = this.w;
  17655. var graphics = new Graphics(this.ctx);
  17656. var ret = graphics.group({
  17657. class: 'apexcharts-heatmap'
  17658. });
  17659. ret.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")")); // width divided into equal parts
  17660. var xDivision = w.globals.gridWidth / w.globals.dataPoints;
  17661. var yDivision = w.globals.gridHeight / w.globals.series.length;
  17662. var y1 = 0;
  17663. var rev = false;
  17664. this.negRange = this.helpers.checkColorRange();
  17665. var heatSeries = series.slice();
  17666. if (w.config.yaxis[0].reversed) {
  17667. rev = true;
  17668. heatSeries.reverse();
  17669. }
  17670. for (var i = rev ? 0 : heatSeries.length - 1; rev ? i < heatSeries.length : i >= 0; rev ? i++ : i--) {
  17671. // el to which series will be drawn
  17672. var elSeries = graphics.group({
  17673. class: "apexcharts-series apexcharts-heatmap-series",
  17674. seriesName: Utils$1.escapeString(w.globals.seriesNames[i]),
  17675. rel: i + 1,
  17676. 'data:realIndex': i
  17677. });
  17678. this.ctx.series.addCollapsedClassToSeries(elSeries, i);
  17679. if (w.config.chart.dropShadow.enabled) {
  17680. var shadow = w.config.chart.dropShadow;
  17681. var filters = new Filters(this.ctx);
  17682. filters.dropShadow(elSeries, shadow, i);
  17683. }
  17684. var x1 = 0;
  17685. var shadeIntensity = w.config.plotOptions.heatmap.shadeIntensity;
  17686. for (var j = 0; j < heatSeries[i].length; j++) {
  17687. var heatColor = this.helpers.getShadeColor(w.config.chart.type, i, j, this.negRange);
  17688. var color = heatColor.color;
  17689. var heatColorProps = heatColor.colorProps;
  17690. if (w.config.fill.type === 'image') {
  17691. var fill = new Fill(this.ctx);
  17692. color = fill.fillPath({
  17693. seriesNumber: i,
  17694. dataPointIndex: j,
  17695. opacity: w.globals.hasNegs ? heatColorProps.percent < 0 ? 1 - (1 + heatColorProps.percent / 100) : shadeIntensity + heatColorProps.percent / 100 : heatColorProps.percent / 100,
  17696. patternID: Utils$1.randomId(),
  17697. width: w.config.fill.image.width ? w.config.fill.image.width : xDivision,
  17698. height: w.config.fill.image.height ? w.config.fill.image.height : yDivision
  17699. });
  17700. }
  17701. var radius = this.rectRadius;
  17702. var rect = graphics.drawRect(x1, y1, xDivision, yDivision, radius);
  17703. rect.attr({
  17704. cx: x1,
  17705. cy: y1
  17706. });
  17707. rect.node.classList.add('apexcharts-heatmap-rect');
  17708. elSeries.add(rect);
  17709. rect.attr({
  17710. fill: color,
  17711. i: i,
  17712. index: i,
  17713. j: j,
  17714. val: heatSeries[i][j],
  17715. 'stroke-width': this.strokeWidth,
  17716. stroke: w.config.plotOptions.heatmap.useFillColorAsStroke ? color : w.globals.stroke.colors[0],
  17717. color: color
  17718. });
  17719. this.helpers.addListeners(rect);
  17720. if (w.config.chart.animations.enabled && !w.globals.dataChanged) {
  17721. var speed = 1;
  17722. if (!w.globals.resized) {
  17723. speed = w.config.chart.animations.speed;
  17724. }
  17725. this.animateHeatMap(rect, x1, y1, xDivision, yDivision, speed);
  17726. }
  17727. if (w.globals.dataChanged) {
  17728. var _speed = 1;
  17729. if (this.dynamicAnim.enabled && w.globals.shouldAnimate) {
  17730. _speed = this.dynamicAnim.speed;
  17731. var colorFrom = w.globals.previousPaths[i] && w.globals.previousPaths[i][j] && w.globals.previousPaths[i][j].color;
  17732. if (!colorFrom) colorFrom = 'rgba(255, 255, 255, 0)';
  17733. this.animateHeatColor(rect, Utils$1.isColorHex(colorFrom) ? colorFrom : Utils$1.rgb2hex(colorFrom), Utils$1.isColorHex(color) ? color : Utils$1.rgb2hex(color), _speed);
  17734. }
  17735. }
  17736. var formatter = w.config.dataLabels.formatter;
  17737. var formattedText = formatter(w.globals.series[i][j], {
  17738. value: w.globals.series[i][j],
  17739. seriesIndex: i,
  17740. dataPointIndex: j,
  17741. w: w
  17742. });
  17743. var dataLabels = this.helpers.calculateDataLabels({
  17744. text: formattedText,
  17745. x: x1 + xDivision / 2,
  17746. y: y1 + yDivision / 2,
  17747. i: i,
  17748. j: j,
  17749. colorProps: heatColorProps,
  17750. series: heatSeries
  17751. });
  17752. if (dataLabels !== null) {
  17753. elSeries.add(dataLabels);
  17754. }
  17755. x1 = x1 + xDivision;
  17756. }
  17757. y1 = y1 + yDivision;
  17758. ret.add(elSeries);
  17759. } // adjust yaxis labels for heatmap
  17760. var yAxisScale = w.globals.yAxisScale[0].result.slice();
  17761. if (w.config.yaxis[0].reversed) {
  17762. yAxisScale.unshift('');
  17763. } else {
  17764. yAxisScale.push('');
  17765. }
  17766. w.globals.yAxisScale[0].result = yAxisScale;
  17767. var divisor = w.globals.gridHeight / w.globals.series.length;
  17768. w.config.yaxis[0].labels.offsetY = -(divisor / 2);
  17769. return ret;
  17770. }
  17771. }, {
  17772. key: "animateHeatMap",
  17773. value: function animateHeatMap(el, x, y, width, height, speed) {
  17774. var animations = new Animations(this.ctx);
  17775. animations.animateRect(el, {
  17776. x: x + width / 2,
  17777. y: y + height / 2,
  17778. width: 0,
  17779. height: 0
  17780. }, {
  17781. x: x,
  17782. y: y,
  17783. width: width,
  17784. height: height
  17785. }, speed, function () {
  17786. animations.animationCompleted(el);
  17787. });
  17788. }
  17789. }, {
  17790. key: "animateHeatColor",
  17791. value: function animateHeatColor(el, colorFrom, colorTo, speed) {
  17792. el.attr({
  17793. fill: colorFrom
  17794. }).animate(speed).attr({
  17795. fill: colorTo
  17796. });
  17797. }
  17798. }]);
  17799. return HeatMap;
  17800. }();
  17801. var CircularChartsHelpers = /*#__PURE__*/function () {
  17802. function CircularChartsHelpers(ctx) {
  17803. _classCallCheck(this, CircularChartsHelpers);
  17804. this.ctx = ctx;
  17805. this.w = ctx.w;
  17806. }
  17807. _createClass(CircularChartsHelpers, [{
  17808. key: "drawYAxisTexts",
  17809. value: function drawYAxisTexts(x, y, i, text) {
  17810. var w = this.w;
  17811. var yaxisConfig = w.config.yaxis[0];
  17812. var formatter = w.globals.yLabelFormatters[0];
  17813. var graphics = new Graphics(this.ctx);
  17814. var yaxisLabel = graphics.drawText({
  17815. x: x + yaxisConfig.labels.offsetX,
  17816. y: y + yaxisConfig.labels.offsetY,
  17817. text: formatter(text, i),
  17818. textAnchor: 'middle',
  17819. fontSize: yaxisConfig.labels.style.fontSize,
  17820. fontFamily: yaxisConfig.labels.style.fontFamily,
  17821. foreColor: Array.isArray(yaxisConfig.labels.style.colors) ? yaxisConfig.labels.style.colors[i] : yaxisConfig.labels.style.colors
  17822. });
  17823. return yaxisLabel;
  17824. }
  17825. }]);
  17826. return CircularChartsHelpers;
  17827. }();
  17828. /**
  17829. * ApexCharts Pie Class for drawing Pie / Donut Charts.
  17830. * @module Pie
  17831. **/
  17832. var Pie = /*#__PURE__*/function () {
  17833. function Pie(ctx) {
  17834. _classCallCheck(this, Pie);
  17835. this.ctx = ctx;
  17836. this.w = ctx.w;
  17837. var w = this.w;
  17838. this.chartType = this.w.config.chart.type;
  17839. this.initialAnim = this.w.config.chart.animations.enabled;
  17840. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  17841. this.animBeginArr = [0];
  17842. this.animDur = 0;
  17843. this.donutDataLabels = this.w.config.plotOptions.pie.donut.labels;
  17844. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  17845. this.defaultSize = Math.min(w.globals.gridWidth, w.globals.gridHeight);
  17846. this.centerY = this.defaultSize / 2;
  17847. this.centerX = w.globals.gridWidth / 2;
  17848. if (w.config.chart.type === 'radialBar') {
  17849. this.fullAngle = 360;
  17850. } else {
  17851. this.fullAngle = Math.abs(w.config.plotOptions.pie.endAngle - w.config.plotOptions.pie.startAngle);
  17852. }
  17853. this.initialAngle = w.config.plotOptions.pie.startAngle % this.fullAngle;
  17854. w.globals.radialSize = this.defaultSize / 2.05 - w.config.stroke.width - (!w.config.chart.sparkline.enabled ? w.config.chart.dropShadow.blur : 0);
  17855. this.donutSize = w.globals.radialSize * parseInt(w.config.plotOptions.pie.donut.size, 10) / 100;
  17856. this.maxY = 0;
  17857. this.sliceLabels = [];
  17858. this.sliceSizes = [];
  17859. this.prevSectorAngleArr = []; // for dynamic animations
  17860. }
  17861. _createClass(Pie, [{
  17862. key: "draw",
  17863. value: function draw(series) {
  17864. var _this = this;
  17865. var self = this;
  17866. var w = this.w;
  17867. var graphics = new Graphics(this.ctx);
  17868. this.ret = graphics.group({
  17869. class: 'apexcharts-pie'
  17870. });
  17871. if (w.globals.noData) return this.ret;
  17872. var total = 0;
  17873. for (var k = 0; k < series.length; k++) {
  17874. // CALCULATE THE TOTAL
  17875. total += Utils$1.negToZero(series[k]);
  17876. }
  17877. var sectorAngleArr = []; // el to which series will be drawn
  17878. var elSeries = graphics.group(); // prevent division by zero error if there is no data
  17879. if (total === 0) {
  17880. total = 0.00001;
  17881. }
  17882. series.forEach(function (m) {
  17883. _this.maxY = Math.max(_this.maxY, m);
  17884. }); // override maxY if user provided in config
  17885. if (w.config.yaxis[0].max) {
  17886. this.maxY = w.config.yaxis[0].max;
  17887. }
  17888. if (w.config.grid.position === 'back' && this.chartType === 'polarArea') {
  17889. this.drawPolarElements(this.ret);
  17890. }
  17891. for (var i = 0; i < series.length; i++) {
  17892. // CALCULATE THE ANGLES
  17893. var angle = this.fullAngle * Utils$1.negToZero(series[i]) / total;
  17894. sectorAngleArr.push(angle);
  17895. if (this.chartType === 'polarArea') {
  17896. sectorAngleArr[i] = this.fullAngle / series.length;
  17897. this.sliceSizes.push(w.globals.radialSize * series[i] / this.maxY);
  17898. } else {
  17899. this.sliceSizes.push(w.globals.radialSize);
  17900. }
  17901. }
  17902. if (w.globals.dataChanged) {
  17903. var prevTotal = 0;
  17904. for (var _k = 0; _k < w.globals.previousPaths.length; _k++) {
  17905. // CALCULATE THE PREV TOTAL
  17906. prevTotal += Utils$1.negToZero(w.globals.previousPaths[_k]);
  17907. }
  17908. var previousAngle;
  17909. for (var _i = 0; _i < w.globals.previousPaths.length; _i++) {
  17910. // CALCULATE THE PREVIOUS ANGLES
  17911. previousAngle = this.fullAngle * Utils$1.negToZero(w.globals.previousPaths[_i]) / prevTotal;
  17912. this.prevSectorAngleArr.push(previousAngle);
  17913. }
  17914. } // on small chart size after few count of resizes browser window donutSize can be negative
  17915. if (this.donutSize < 0) {
  17916. this.donutSize = 0;
  17917. }
  17918. var scaleSize = w.config.plotOptions.pie.customScale;
  17919. var halfW = w.globals.gridWidth / 2;
  17920. var halfH = w.globals.gridHeight / 2;
  17921. var translateX = halfW - w.globals.gridWidth / 2 * scaleSize;
  17922. var translateY = halfH - w.globals.gridHeight / 2 * scaleSize;
  17923. if (this.chartType === 'donut') {
  17924. // draw the inner circle and add some text to it
  17925. var circle = graphics.drawCircle(this.donutSize);
  17926. circle.attr({
  17927. cx: this.centerX,
  17928. cy: this.centerY,
  17929. fill: w.config.plotOptions.pie.donut.background ? w.config.plotOptions.pie.donut.background : 'transparent'
  17930. });
  17931. elSeries.add(circle);
  17932. }
  17933. var elG = self.drawArcs(sectorAngleArr, series); // add slice dataLabels at the end
  17934. this.sliceLabels.forEach(function (s) {
  17935. elG.add(s);
  17936. });
  17937. elSeries.attr({
  17938. transform: "translate(".concat(translateX, ", ").concat(translateY, ") scale(").concat(scaleSize, ")")
  17939. });
  17940. elSeries.add(elG);
  17941. this.ret.add(elSeries);
  17942. if (this.donutDataLabels.show) {
  17943. var dataLabels = this.renderInnerDataLabels(this.donutDataLabels, {
  17944. hollowSize: this.donutSize,
  17945. centerX: this.centerX,
  17946. centerY: this.centerY,
  17947. opacity: this.donutDataLabels.show,
  17948. translateX: translateX,
  17949. translateY: translateY
  17950. });
  17951. this.ret.add(dataLabels);
  17952. }
  17953. if (w.config.grid.position === 'front' && this.chartType === 'polarArea') {
  17954. this.drawPolarElements(this.ret);
  17955. }
  17956. return this.ret;
  17957. } // core function for drawing pie arcs
  17958. }, {
  17959. key: "drawArcs",
  17960. value: function drawArcs(sectorAngleArr, series) {
  17961. var w = this.w;
  17962. var filters = new Filters(this.ctx);
  17963. var graphics = new Graphics(this.ctx);
  17964. var fill = new Fill(this.ctx);
  17965. var g = graphics.group({
  17966. class: 'apexcharts-slices'
  17967. });
  17968. var startAngle = this.initialAngle;
  17969. var prevStartAngle = this.initialAngle;
  17970. var endAngle = this.initialAngle;
  17971. var prevEndAngle = this.initialAngle;
  17972. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  17973. for (var i = 0; i < sectorAngleArr.length; i++) {
  17974. var elPieArc = graphics.group({
  17975. class: "apexcharts-series apexcharts-pie-series",
  17976. seriesName: Utils$1.escapeString(w.globals.seriesNames[i]),
  17977. rel: i + 1,
  17978. 'data:realIndex': i
  17979. });
  17980. g.add(elPieArc);
  17981. startAngle = endAngle;
  17982. prevStartAngle = prevEndAngle;
  17983. endAngle = startAngle + sectorAngleArr[i];
  17984. prevEndAngle = prevStartAngle + this.prevSectorAngleArr[i];
  17985. var angle = endAngle < startAngle ? this.fullAngle + endAngle - startAngle : endAngle - startAngle;
  17986. var pathFill = fill.fillPath({
  17987. seriesNumber: i,
  17988. size: this.sliceSizes[i],
  17989. value: series[i]
  17990. }); // additionally, pass size for gradient drawing in the fillPath function
  17991. var path = this.getChangedPath(prevStartAngle, prevEndAngle);
  17992. var elPath = graphics.drawPath({
  17993. d: path,
  17994. stroke: Array.isArray(this.lineColorArr) ? this.lineColorArr[i] : this.lineColorArr,
  17995. strokeWidth: 0,
  17996. fill: pathFill,
  17997. fillOpacity: w.config.fill.opacity,
  17998. classes: "apexcharts-pie-area apexcharts-".concat(this.chartType.toLowerCase(), "-slice-").concat(i)
  17999. });
  18000. elPath.attr({
  18001. index: 0,
  18002. j: i
  18003. });
  18004. filters.setSelectionFilter(elPath, 0, i);
  18005. if (w.config.chart.dropShadow.enabled) {
  18006. var shadow = w.config.chart.dropShadow;
  18007. filters.dropShadow(elPath, shadow, i);
  18008. }
  18009. this.addListeners(elPath, this.donutDataLabels);
  18010. Graphics.setAttrs(elPath.node, {
  18011. 'data:angle': angle,
  18012. 'data:startAngle': startAngle,
  18013. 'data:strokeWidth': this.strokeWidth,
  18014. 'data:value': series[i]
  18015. });
  18016. var labelPosition = {
  18017. x: 0,
  18018. y: 0
  18019. };
  18020. if (this.chartType === 'pie' || this.chartType === 'polarArea') {
  18021. labelPosition = Utils$1.polarToCartesian(this.centerX, this.centerY, w.globals.radialSize / 1.25 + w.config.plotOptions.pie.dataLabels.offset, (startAngle + angle / 2) % this.fullAngle);
  18022. } else if (this.chartType === 'donut') {
  18023. labelPosition = Utils$1.polarToCartesian(this.centerX, this.centerY, (w.globals.radialSize + this.donutSize) / 2 + w.config.plotOptions.pie.dataLabels.offset, (startAngle + angle / 2) % this.fullAngle);
  18024. }
  18025. elPieArc.add(elPath); // Animation code starts
  18026. var dur = 0;
  18027. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  18028. dur = angle / this.fullAngle * w.config.chart.animations.speed;
  18029. if (dur === 0) dur = 1;
  18030. this.animDur = dur + this.animDur;
  18031. this.animBeginArr.push(this.animDur);
  18032. } else {
  18033. this.animBeginArr.push(0);
  18034. }
  18035. if (this.dynamicAnim && w.globals.dataChanged) {
  18036. this.animatePaths(elPath, {
  18037. size: this.sliceSizes[i],
  18038. endAngle: endAngle,
  18039. startAngle: startAngle,
  18040. prevStartAngle: prevStartAngle,
  18041. prevEndAngle: prevEndAngle,
  18042. animateStartingPos: true,
  18043. i: i,
  18044. animBeginArr: this.animBeginArr,
  18045. shouldSetPrevPaths: true,
  18046. dur: w.config.chart.animations.dynamicAnimation.speed
  18047. });
  18048. } else {
  18049. this.animatePaths(elPath, {
  18050. size: this.sliceSizes[i],
  18051. endAngle: endAngle,
  18052. startAngle: startAngle,
  18053. i: i,
  18054. totalItems: sectorAngleArr.length - 1,
  18055. animBeginArr: this.animBeginArr,
  18056. dur: dur
  18057. });
  18058. } // animation code ends
  18059. if (w.config.plotOptions.pie.expandOnClick && this.chartType !== 'polarArea') {
  18060. elPath.click(this.pieClicked.bind(this, i));
  18061. }
  18062. if (typeof w.globals.selectedDataPoints[0] !== 'undefined' && w.globals.selectedDataPoints[0].indexOf(i) > -1) {
  18063. this.pieClicked(i);
  18064. }
  18065. if (w.config.dataLabels.enabled) {
  18066. var xPos = labelPosition.x;
  18067. var yPos = labelPosition.y;
  18068. var text = 100 * angle / this.fullAngle + '%';
  18069. if (angle !== 0 && w.config.plotOptions.pie.dataLabels.minAngleToShowLabel < sectorAngleArr[i]) {
  18070. var formatter = w.config.dataLabels.formatter;
  18071. if (formatter !== undefined) {
  18072. text = formatter(w.globals.seriesPercent[i][0], {
  18073. seriesIndex: i,
  18074. w: w
  18075. });
  18076. }
  18077. var foreColor = w.globals.dataLabels.style.colors[i];
  18078. var elPieLabelWrap = graphics.group({
  18079. class: "apexcharts-datalabels"
  18080. });
  18081. var elPieLabel = graphics.drawText({
  18082. x: xPos,
  18083. y: yPos,
  18084. text: text,
  18085. textAnchor: 'middle',
  18086. fontSize: w.config.dataLabels.style.fontSize,
  18087. fontFamily: w.config.dataLabels.style.fontFamily,
  18088. fontWeight: w.config.dataLabels.style.fontWeight,
  18089. foreColor: foreColor
  18090. });
  18091. elPieLabelWrap.add(elPieLabel);
  18092. if (w.config.dataLabels.dropShadow.enabled) {
  18093. var textShadow = w.config.dataLabels.dropShadow;
  18094. filters.dropShadow(elPieLabel, textShadow);
  18095. }
  18096. elPieLabel.node.classList.add('apexcharts-pie-label');
  18097. if (w.config.chart.animations.animate && w.globals.resized === false) {
  18098. elPieLabel.node.classList.add('apexcharts-pie-label-delay');
  18099. elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + 's';
  18100. }
  18101. this.sliceLabels.push(elPieLabelWrap);
  18102. }
  18103. }
  18104. }
  18105. return g;
  18106. }
  18107. }, {
  18108. key: "addListeners",
  18109. value: function addListeners(elPath, dataLabels) {
  18110. var graphics = new Graphics(this.ctx); // append filters on mouseenter and mouseleave
  18111. elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath));
  18112. elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elPath));
  18113. elPath.node.addEventListener('mouseleave', this.revertDataLabelsInner.bind(this, elPath.node, dataLabels));
  18114. elPath.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elPath));
  18115. if (!this.donutDataLabels.total.showAlways) {
  18116. elPath.node.addEventListener('mouseenter', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  18117. elPath.node.addEventListener('mousedown', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  18118. }
  18119. } // This function can be used for other circle charts too
  18120. }, {
  18121. key: "animatePaths",
  18122. value: function animatePaths(el, opts) {
  18123. var w = this.w;
  18124. var me = this;
  18125. var angle = opts.endAngle < opts.startAngle ? this.fullAngle + opts.endAngle - opts.startAngle : opts.endAngle - opts.startAngle;
  18126. var prevAngle = angle;
  18127. var fromStartAngle = opts.startAngle;
  18128. var toStartAngle = opts.startAngle;
  18129. if (opts.prevStartAngle !== undefined && opts.prevEndAngle !== undefined) {
  18130. fromStartAngle = opts.prevEndAngle;
  18131. prevAngle = opts.prevEndAngle < opts.prevStartAngle ? this.fullAngle + opts.prevEndAngle - opts.prevStartAngle : opts.prevEndAngle - opts.prevStartAngle;
  18132. }
  18133. if (opts.i === w.config.series.length - 1) {
  18134. // some adjustments for the last overlapping paths
  18135. if (angle + toStartAngle > this.fullAngle) {
  18136. opts.endAngle = opts.endAngle - (angle + toStartAngle);
  18137. } else if (angle + toStartAngle < this.fullAngle) {
  18138. opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle));
  18139. }
  18140. }
  18141. if (angle === this.fullAngle) angle = this.fullAngle - 0.01;
  18142. me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts);
  18143. }
  18144. }, {
  18145. key: "animateArc",
  18146. value: function animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts) {
  18147. var me = this;
  18148. var w = this.w;
  18149. var animations = new Animations(this.ctx);
  18150. var size = opts.size;
  18151. var path;
  18152. if (isNaN(fromStartAngle) || isNaN(prevAngle)) {
  18153. fromStartAngle = toStartAngle;
  18154. prevAngle = angle;
  18155. opts.dur = 0;
  18156. }
  18157. var currAngle = angle;
  18158. var startAngle = toStartAngle;
  18159. var fromAngle = fromStartAngle < toStartAngle ? this.fullAngle + fromStartAngle - toStartAngle : fromStartAngle - toStartAngle;
  18160. if (w.globals.dataChanged && opts.shouldSetPrevPaths) {
  18161. // to avoid flicker when updating, set prev path first and then animate from there
  18162. if (opts.prevEndAngle) {
  18163. path = me.getPiePath({
  18164. me: me,
  18165. startAngle: opts.prevStartAngle,
  18166. angle: opts.prevEndAngle < opts.prevStartAngle ? this.fullAngle + opts.prevEndAngle - opts.prevStartAngle : opts.prevEndAngle - opts.prevStartAngle,
  18167. size: size
  18168. });
  18169. el.attr({
  18170. d: path
  18171. });
  18172. }
  18173. }
  18174. if (opts.dur !== 0) {
  18175. el.animate(opts.dur, w.globals.easing, opts.animBeginArr[opts.i]).afterAll(function () {
  18176. if (me.chartType === 'pie' || me.chartType === 'donut' || me.chartType === 'polarArea') {
  18177. this.animate(w.config.chart.animations.dynamicAnimation.speed).attr({
  18178. 'stroke-width': me.strokeWidth
  18179. });
  18180. }
  18181. if (opts.i === w.config.series.length - 1) {
  18182. animations.animationCompleted(el);
  18183. }
  18184. }).during(function (pos) {
  18185. currAngle = fromAngle + (angle - fromAngle) * pos;
  18186. if (opts.animateStartingPos) {
  18187. currAngle = prevAngle + (angle - prevAngle) * pos;
  18188. startAngle = fromStartAngle - prevAngle + (toStartAngle - (fromStartAngle - prevAngle)) * pos;
  18189. }
  18190. path = me.getPiePath({
  18191. me: me,
  18192. startAngle: startAngle,
  18193. angle: currAngle,
  18194. size: size
  18195. });
  18196. el.node.setAttribute('data:pathOrig', path);
  18197. el.attr({
  18198. d: path
  18199. });
  18200. });
  18201. } else {
  18202. path = me.getPiePath({
  18203. me: me,
  18204. startAngle: startAngle,
  18205. angle: angle,
  18206. size: size
  18207. });
  18208. if (!opts.isTrack) {
  18209. w.globals.animationEnded = true;
  18210. }
  18211. el.node.setAttribute('data:pathOrig', path);
  18212. el.attr({
  18213. d: path,
  18214. 'stroke-width': me.strokeWidth
  18215. });
  18216. }
  18217. }
  18218. }, {
  18219. key: "pieClicked",
  18220. value: function pieClicked(i) {
  18221. var w = this.w;
  18222. var me = this;
  18223. var path;
  18224. var size = me.sliceSizes[i] + (w.config.plotOptions.pie.expandOnClick ? 4 : 0);
  18225. var elPath = w.globals.dom.Paper.select(".apexcharts-".concat(me.chartType.toLowerCase(), "-slice-").concat(i)).members[0];
  18226. if (elPath.attr('data:pieClicked') === 'true') {
  18227. elPath.attr({
  18228. 'data:pieClicked': 'false'
  18229. });
  18230. this.revertDataLabelsInner(elPath.node, this.donutDataLabels);
  18231. var origPath = elPath.attr('data:pathOrig');
  18232. elPath.attr({
  18233. d: origPath
  18234. });
  18235. return;
  18236. } else {
  18237. // reset all elems
  18238. var allEls = w.globals.dom.baseEl.getElementsByClassName('apexcharts-pie-area');
  18239. Array.prototype.forEach.call(allEls, function (pieSlice) {
  18240. pieSlice.setAttribute('data:pieClicked', 'false');
  18241. var origPath = pieSlice.getAttribute('data:pathOrig');
  18242. pieSlice.setAttribute('d', origPath);
  18243. });
  18244. elPath.attr('data:pieClicked', 'true');
  18245. }
  18246. var startAngle = parseInt(elPath.attr('data:startAngle'), 10);
  18247. var angle = parseInt(elPath.attr('data:angle'), 10);
  18248. path = me.getPiePath({
  18249. me: me,
  18250. startAngle: startAngle,
  18251. angle: angle,
  18252. size: size
  18253. });
  18254. if (angle === 360) return;
  18255. elPath.plot(path);
  18256. }
  18257. }, {
  18258. key: "getChangedPath",
  18259. value: function getChangedPath(prevStartAngle, prevEndAngle) {
  18260. var path = '';
  18261. if (this.dynamicAnim && this.w.globals.dataChanged) {
  18262. path = this.getPiePath({
  18263. me: this,
  18264. startAngle: prevStartAngle,
  18265. angle: prevEndAngle - prevStartAngle,
  18266. size: this.size
  18267. });
  18268. }
  18269. return path;
  18270. }
  18271. }, {
  18272. key: "getPiePath",
  18273. value: function getPiePath(_ref) {
  18274. var me = _ref.me,
  18275. startAngle = _ref.startAngle,
  18276. angle = _ref.angle,
  18277. size = _ref.size;
  18278. var path;
  18279. var startDeg = startAngle;
  18280. var startRadians = Math.PI * (startDeg - 90) / 180;
  18281. var endDeg = angle + startAngle; // prevent overlap
  18282. if (Math.ceil(endDeg) >= this.fullAngle + this.w.config.plotOptions.pie.startAngle % this.fullAngle) {
  18283. endDeg = this.fullAngle + this.w.config.plotOptions.pie.startAngle % this.fullAngle - 0.01;
  18284. }
  18285. if (Math.ceil(endDeg) > this.fullAngle) endDeg -= this.fullAngle;
  18286. var endRadians = Math.PI * (endDeg - 90) / 180;
  18287. var x1 = me.centerX + size * Math.cos(startRadians);
  18288. var y1 = me.centerY + size * Math.sin(startRadians);
  18289. var x2 = me.centerX + size * Math.cos(endRadians);
  18290. var y2 = me.centerY + size * Math.sin(endRadians);
  18291. var startInner = Utils$1.polarToCartesian(me.centerX, me.centerY, me.donutSize, endDeg);
  18292. var endInner = Utils$1.polarToCartesian(me.centerX, me.centerY, me.donutSize, startDeg);
  18293. var largeArc = angle > 180 ? 1 : 0;
  18294. var pathBeginning = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2];
  18295. if (me.chartType === 'donut') {
  18296. 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(' ');
  18297. } else if (me.chartType === 'pie' || me.chartType === 'polarArea') {
  18298. path = [].concat(pathBeginning, ['L', me.centerX, me.centerY, 'L', x1, y1]).join(' ');
  18299. } else {
  18300. path = [].concat(pathBeginning).join(' ');
  18301. }
  18302. return path;
  18303. }
  18304. }, {
  18305. key: "drawPolarElements",
  18306. value: function drawPolarElements(parent) {
  18307. var w = this.w;
  18308. var scale = new Range$1(this.ctx);
  18309. var graphics = new Graphics(this.ctx);
  18310. var helpers = new CircularChartsHelpers(this.ctx);
  18311. var gCircles = graphics.group();
  18312. var gYAxis = graphics.group();
  18313. var yScale = scale.niceScale(0, Math.ceil(this.maxY), w.config.yaxis[0].tickAmount, 0, true);
  18314. var yTexts = yScale.result.reverse();
  18315. var len = yScale.result.length;
  18316. this.maxY = yScale.niceMax;
  18317. var circleSize = w.globals.radialSize;
  18318. var diff = circleSize / (len - 1);
  18319. for (var i = 0; i < len - 1; i++) {
  18320. var circle = graphics.drawCircle(circleSize);
  18321. circle.attr({
  18322. cx: this.centerX,
  18323. cy: this.centerY,
  18324. fill: 'none',
  18325. 'stroke-width': w.config.plotOptions.polarArea.rings.strokeWidth,
  18326. stroke: w.config.plotOptions.polarArea.rings.strokeColor
  18327. });
  18328. if (w.config.yaxis[0].show) {
  18329. var yLabel = helpers.drawYAxisTexts(this.centerX, this.centerY - circleSize + parseInt(w.config.yaxis[0].labels.style.fontSize, 10) / 2, i, yTexts[i]);
  18330. gYAxis.add(yLabel);
  18331. }
  18332. gCircles.add(circle);
  18333. circleSize = circleSize - diff;
  18334. }
  18335. this.drawSpokes(parent);
  18336. parent.add(gCircles);
  18337. parent.add(gYAxis);
  18338. }
  18339. }, {
  18340. key: "renderInnerDataLabels",
  18341. value: function renderInnerDataLabels(dataLabelsConfig, opts) {
  18342. var w = this.w;
  18343. var graphics = new Graphics(this.ctx);
  18344. var g = graphics.group({
  18345. class: 'apexcharts-datalabels-group',
  18346. transform: "translate(".concat(opts.translateX ? opts.translateX : 0, ", ").concat(opts.translateY ? opts.translateY : 0, ") scale(").concat(w.config.plotOptions.pie.customScale, ")")
  18347. });
  18348. var showTotal = dataLabelsConfig.total.show;
  18349. g.node.style.opacity = opts.opacity;
  18350. var x = opts.centerX;
  18351. var y = opts.centerY;
  18352. var labelColor, valueColor;
  18353. if (dataLabelsConfig.name.color === undefined) {
  18354. labelColor = w.globals.colors[0];
  18355. } else {
  18356. labelColor = dataLabelsConfig.name.color;
  18357. }
  18358. var labelFontSize = dataLabelsConfig.name.fontSize;
  18359. var labelFontFamily = dataLabelsConfig.name.fontFamily;
  18360. var labelFontWeight = dataLabelsConfig.name.fontWeight;
  18361. if (dataLabelsConfig.value.color === undefined) {
  18362. valueColor = w.config.chart.foreColor;
  18363. } else {
  18364. valueColor = dataLabelsConfig.value.color;
  18365. }
  18366. var lbFormatter = dataLabelsConfig.value.formatter;
  18367. var val = '';
  18368. var name = '';
  18369. if (showTotal) {
  18370. labelColor = dataLabelsConfig.total.color;
  18371. labelFontSize = dataLabelsConfig.total.fontSize;
  18372. labelFontFamily = dataLabelsConfig.total.fontFamily;
  18373. labelFontWeight = dataLabelsConfig.total.fontWeight;
  18374. name = dataLabelsConfig.total.label;
  18375. val = dataLabelsConfig.total.formatter(w);
  18376. } else {
  18377. if (w.globals.series.length === 1) {
  18378. val = lbFormatter(w.globals.series[0], w);
  18379. name = w.globals.seriesNames[0];
  18380. }
  18381. }
  18382. if (name) {
  18383. name = dataLabelsConfig.name.formatter(name, dataLabelsConfig.total.show, w);
  18384. }
  18385. if (dataLabelsConfig.name.show) {
  18386. var elLabel = graphics.drawText({
  18387. x: x,
  18388. y: y + parseFloat(dataLabelsConfig.name.offsetY),
  18389. text: name,
  18390. textAnchor: 'middle',
  18391. foreColor: labelColor,
  18392. fontSize: labelFontSize,
  18393. fontWeight: labelFontWeight,
  18394. fontFamily: labelFontFamily
  18395. });
  18396. elLabel.node.classList.add('apexcharts-datalabel-label');
  18397. g.add(elLabel);
  18398. }
  18399. if (dataLabelsConfig.value.show) {
  18400. var valOffset = dataLabelsConfig.name.show ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
  18401. var elValue = graphics.drawText({
  18402. x: x,
  18403. y: y + valOffset,
  18404. text: val,
  18405. textAnchor: 'middle',
  18406. foreColor: valueColor,
  18407. fontWeight: dataLabelsConfig.value.fontWeight,
  18408. fontSize: dataLabelsConfig.value.fontSize,
  18409. fontFamily: dataLabelsConfig.value.fontFamily
  18410. });
  18411. elValue.node.classList.add('apexcharts-datalabel-value');
  18412. g.add(elValue);
  18413. } // for a multi-series circle chart, we need to show total value instead of first series labels
  18414. return g;
  18415. }
  18416. /**
  18417. *
  18418. * @param {string} name - The name of the series
  18419. * @param {string} val - The value of that series
  18420. * @param {object} el - Optional el (indicates which series was hovered/clicked). If this param is not present, means we need to show total
  18421. */
  18422. }, {
  18423. key: "printInnerLabels",
  18424. value: function printInnerLabels(labelsConfig, name, val, el) {
  18425. var w = this.w;
  18426. var labelColor;
  18427. if (el) {
  18428. if (labelsConfig.name.color === undefined) {
  18429. labelColor = w.globals.colors[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  18430. } else {
  18431. labelColor = labelsConfig.name.color;
  18432. }
  18433. } else {
  18434. if (w.globals.series.length > 1 && labelsConfig.total.show) {
  18435. labelColor = labelsConfig.total.color;
  18436. }
  18437. }
  18438. var elLabel = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-label');
  18439. var elValue = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-value');
  18440. var lbFormatter = labelsConfig.value.formatter;
  18441. val = lbFormatter(val, w); // we need to show Total Val - so get the formatter of it
  18442. if (!el && typeof labelsConfig.total.formatter === 'function') {
  18443. val = labelsConfig.total.formatter(w);
  18444. }
  18445. var isTotal = name === labelsConfig.total.label;
  18446. name = labelsConfig.name.formatter(name, isTotal, w);
  18447. if (elLabel !== null) {
  18448. elLabel.textContent = name;
  18449. }
  18450. if (elValue !== null) {
  18451. elValue.textContent = val;
  18452. }
  18453. if (elLabel !== null) {
  18454. elLabel.style.fill = labelColor;
  18455. }
  18456. }
  18457. }, {
  18458. key: "printDataLabelsInner",
  18459. value: function printDataLabelsInner(el, dataLabelsConfig) {
  18460. var w = this.w;
  18461. var val = el.getAttribute('data:value');
  18462. var name = w.globals.seriesNames[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  18463. if (w.globals.series.length > 1) {
  18464. this.printInnerLabels(dataLabelsConfig, name, val, el);
  18465. }
  18466. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  18467. if (dataLabelsGroup !== null) {
  18468. dataLabelsGroup.style.opacity = 1;
  18469. }
  18470. }
  18471. }, {
  18472. key: "drawSpokes",
  18473. value: function drawSpokes(parent) {
  18474. var _this2 = this;
  18475. var w = this.w;
  18476. var graphics = new Graphics(this.ctx);
  18477. var spokeConfig = w.config.plotOptions.polarArea.spokes;
  18478. if (spokeConfig.strokeWidth === 0) return;
  18479. var spokes = [];
  18480. var angleDivision = 360 / w.globals.series.length;
  18481. for (var i = 0; i < w.globals.series.length; i++) {
  18482. spokes.push(Utils$1.polarToCartesian(this.centerX, this.centerY, w.globals.radialSize, w.config.plotOptions.pie.startAngle + angleDivision * i));
  18483. }
  18484. spokes.forEach(function (p, i) {
  18485. var line = graphics.drawLine(p.x, p.y, _this2.centerX, _this2.centerY, Array.isArray(spokeConfig.connectorColors) ? spokeConfig.connectorColors[i] : spokeConfig.connectorColors);
  18486. parent.add(line);
  18487. });
  18488. }
  18489. }, {
  18490. key: "revertDataLabelsInner",
  18491. value: function revertDataLabelsInner(elem, dataLabelsConfig, event) {
  18492. var _this3 = this;
  18493. var w = this.w;
  18494. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  18495. var sliceOut = false;
  18496. var slices = w.globals.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
  18497. var selectSlice = function selectSlice(_ref2) {
  18498. var makeSliceOut = _ref2.makeSliceOut,
  18499. printLabel = _ref2.printLabel;
  18500. Array.prototype.forEach.call(slices, function (s) {
  18501. if (s.getAttribute('data:pieClicked') === 'true') {
  18502. if (makeSliceOut) {
  18503. sliceOut = true;
  18504. }
  18505. if (printLabel) {
  18506. _this3.printDataLabelsInner(s, dataLabelsConfig);
  18507. }
  18508. }
  18509. });
  18510. };
  18511. selectSlice({
  18512. makeSliceOut: true,
  18513. printLabel: false
  18514. });
  18515. if (dataLabelsConfig.total.show && w.globals.series.length > 1) {
  18516. if (sliceOut && !dataLabelsConfig.total.showAlways) {
  18517. selectSlice({
  18518. makeSliceOut: false,
  18519. printLabel: true
  18520. });
  18521. } else {
  18522. this.printInnerLabels(dataLabelsConfig, dataLabelsConfig.total.label, dataLabelsConfig.total.formatter(w));
  18523. }
  18524. } else {
  18525. selectSlice({
  18526. makeSliceOut: false,
  18527. printLabel: true
  18528. });
  18529. if (!sliceOut) {
  18530. if (w.globals.selectedDataPoints.length && w.globals.series.length > 1) {
  18531. if (w.globals.selectedDataPoints[0].length > 0) {
  18532. var index = w.globals.selectedDataPoints[0];
  18533. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(this.chartType.toLowerCase(), "-slice-").concat(index));
  18534. this.printDataLabelsInner(el, dataLabelsConfig);
  18535. } else if (dataLabelsGroup && w.globals.selectedDataPoints.length && w.globals.selectedDataPoints[0].length === 0) {
  18536. dataLabelsGroup.style.opacity = 0;
  18537. }
  18538. } else {
  18539. if (dataLabelsGroup && w.globals.series.length > 1) {
  18540. dataLabelsGroup.style.opacity = 0;
  18541. }
  18542. }
  18543. }
  18544. }
  18545. }
  18546. }]);
  18547. return Pie;
  18548. }();
  18549. /**
  18550. * ApexCharts Radar Class for Spider/Radar Charts.
  18551. * @module Radar
  18552. **/
  18553. var Radar = /*#__PURE__*/function () {
  18554. function Radar(ctx) {
  18555. _classCallCheck(this, Radar);
  18556. this.ctx = ctx;
  18557. this.w = ctx.w;
  18558. this.chartType = this.w.config.chart.type;
  18559. this.initialAnim = this.w.config.chart.animations.enabled;
  18560. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  18561. this.animDur = 0;
  18562. var w = this.w;
  18563. this.graphics = new Graphics(this.ctx);
  18564. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  18565. this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight + w.globals.goldenPadding * 1.5 : w.globals.gridWidth;
  18566. this.isLog = w.config.yaxis[0].logarithmic;
  18567. this.coreUtils = new CoreUtils(this.ctx);
  18568. this.maxValue = this.isLog ? this.coreUtils.getLogVal(w.globals.maxY, 0) : w.globals.maxY;
  18569. this.minValue = this.isLog ? this.coreUtils.getLogVal(this.w.globals.minY, 0) : w.globals.minY;
  18570. this.polygons = w.config.plotOptions.radar.polygons;
  18571. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  18572. this.size = this.defaultSize / 2.1 - this.strokeWidth - w.config.chart.dropShadow.blur;
  18573. if (w.config.xaxis.labels.show) {
  18574. this.size = this.size - w.globals.xAxisLabelsWidth / 1.75;
  18575. }
  18576. if (w.config.plotOptions.radar.size !== undefined) {
  18577. this.size = w.config.plotOptions.radar.size;
  18578. }
  18579. this.dataRadiusOfPercent = [];
  18580. this.dataRadius = [];
  18581. this.angleArr = [];
  18582. this.yaxisLabelsTextsPos = [];
  18583. }
  18584. _createClass(Radar, [{
  18585. key: "draw",
  18586. value: function draw(series) {
  18587. var _this = this;
  18588. var w = this.w;
  18589. var fill = new Fill(this.ctx);
  18590. var allSeries = [];
  18591. var dataLabels = new DataLabels(this.ctx);
  18592. if (series.length) {
  18593. this.dataPointsLen = series[w.globals.maxValsInArrayIndex].length;
  18594. }
  18595. this.disAngle = Math.PI * 2 / this.dataPointsLen;
  18596. var halfW = w.globals.gridWidth / 2;
  18597. var halfH = w.globals.gridHeight / 2;
  18598. var translateX = halfW + w.config.plotOptions.radar.offsetX;
  18599. var translateY = halfH + w.config.plotOptions.radar.offsetY;
  18600. var ret = this.graphics.group({
  18601. class: 'apexcharts-radar-series apexcharts-plot-series',
  18602. transform: "translate(".concat(translateX || 0, ", ").concat(translateY || 0, ")")
  18603. });
  18604. var dataPointsPos = [];
  18605. var elPointsMain = null;
  18606. var elDataPointsMain = null;
  18607. this.yaxisLabels = this.graphics.group({
  18608. class: 'apexcharts-yaxis'
  18609. });
  18610. series.forEach(function (s, i) {
  18611. var longestSeries = s.length === w.globals.dataPoints; // el to which series will be drawn
  18612. var elSeries = _this.graphics.group().attr({
  18613. class: "apexcharts-series",
  18614. 'data:longestSeries': longestSeries,
  18615. seriesName: Utils$1.escapeString(w.globals.seriesNames[i]),
  18616. rel: i + 1,
  18617. 'data:realIndex': i
  18618. });
  18619. _this.dataRadiusOfPercent[i] = [];
  18620. _this.dataRadius[i] = [];
  18621. _this.angleArr[i] = [];
  18622. s.forEach(function (dv, j) {
  18623. var range = Math.abs(_this.maxValue - _this.minValue);
  18624. dv = dv + Math.abs(_this.minValue);
  18625. if (_this.isLog) {
  18626. dv = _this.coreUtils.getLogVal(dv, 0);
  18627. }
  18628. _this.dataRadiusOfPercent[i][j] = dv / range;
  18629. _this.dataRadius[i][j] = _this.dataRadiusOfPercent[i][j] * _this.size;
  18630. _this.angleArr[i][j] = j * _this.disAngle;
  18631. });
  18632. dataPointsPos = _this.getDataPointsPos(_this.dataRadius[i], _this.angleArr[i]);
  18633. var paths = _this.createPaths(dataPointsPos, {
  18634. x: 0,
  18635. y: 0
  18636. }); // points
  18637. elPointsMain = _this.graphics.group({
  18638. class: 'apexcharts-series-markers-wrap apexcharts-element-hidden'
  18639. }); // datapoints
  18640. elDataPointsMain = _this.graphics.group({
  18641. class: "apexcharts-datalabels",
  18642. 'data:realIndex': i
  18643. });
  18644. w.globals.delayedElements.push({
  18645. el: elPointsMain.node,
  18646. index: i
  18647. });
  18648. var defaultRenderedPathOptions = {
  18649. i: i,
  18650. realIndex: i,
  18651. animationDelay: i,
  18652. initialSpeed: w.config.chart.animations.speed,
  18653. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  18654. className: "apexcharts-radar",
  18655. shouldClipToGrid: false,
  18656. bindEventsOnPaths: false,
  18657. stroke: w.globals.stroke.colors[i],
  18658. strokeLineCap: w.config.stroke.lineCap
  18659. };
  18660. var pathFrom = null;
  18661. if (w.globals.previousPaths.length > 0) {
  18662. pathFrom = _this.getPreviousPath(i);
  18663. }
  18664. for (var p = 0; p < paths.linePathsTo.length; p++) {
  18665. var renderedLinePath = _this.graphics.renderPaths(_objectSpread2(_objectSpread2({}, defaultRenderedPathOptions), {}, {
  18666. pathFrom: pathFrom === null ? paths.linePathsFrom[p] : pathFrom,
  18667. pathTo: paths.linePathsTo[p],
  18668. strokeWidth: Array.isArray(_this.strokeWidth) ? _this.strokeWidth[i] : _this.strokeWidth,
  18669. fill: 'none',
  18670. drawShadow: false
  18671. }));
  18672. elSeries.add(renderedLinePath);
  18673. var pathFill = fill.fillPath({
  18674. seriesNumber: i
  18675. });
  18676. var renderedAreaPath = _this.graphics.renderPaths(_objectSpread2(_objectSpread2({}, defaultRenderedPathOptions), {}, {
  18677. pathFrom: pathFrom === null ? paths.areaPathsFrom[p] : pathFrom,
  18678. pathTo: paths.areaPathsTo[p],
  18679. strokeWidth: 0,
  18680. fill: pathFill,
  18681. drawShadow: false
  18682. }));
  18683. if (w.config.chart.dropShadow.enabled) {
  18684. var filters = new Filters(_this.ctx);
  18685. var shadow = w.config.chart.dropShadow;
  18686. filters.dropShadow(renderedAreaPath, Object.assign({}, shadow, {
  18687. noUserSpaceOnUse: true
  18688. }), i);
  18689. }
  18690. elSeries.add(renderedAreaPath);
  18691. }
  18692. s.forEach(function (sj, j) {
  18693. var markers = new Markers(_this.ctx);
  18694. var opts = markers.getMarkerConfig({
  18695. cssClass: 'apexcharts-marker',
  18696. seriesIndex: i,
  18697. dataPointIndex: j
  18698. });
  18699. var point = _this.graphics.drawMarker(dataPointsPos[j].x, dataPointsPos[j].y, opts);
  18700. point.attr('rel', j);
  18701. point.attr('j', j);
  18702. point.attr('index', i);
  18703. point.node.setAttribute('default-marker-size', opts.pSize);
  18704. var elPointsWrap = _this.graphics.group({
  18705. class: 'apexcharts-series-markers'
  18706. });
  18707. if (elPointsWrap) {
  18708. elPointsWrap.add(point);
  18709. }
  18710. elPointsMain.add(elPointsWrap);
  18711. elSeries.add(elPointsMain);
  18712. var dataLabelsConfig = w.config.dataLabels;
  18713. if (dataLabelsConfig.enabled) {
  18714. var text = dataLabelsConfig.formatter(w.globals.series[i][j], {
  18715. seriesIndex: i,
  18716. dataPointIndex: j,
  18717. w: w
  18718. });
  18719. dataLabels.plotDataLabelsText({
  18720. x: dataPointsPos[j].x,
  18721. y: dataPointsPos[j].y,
  18722. text: text,
  18723. textAnchor: 'middle',
  18724. i: i,
  18725. j: i,
  18726. parent: elDataPointsMain,
  18727. offsetCorrection: false,
  18728. dataLabelsConfig: _objectSpread2({}, dataLabelsConfig)
  18729. });
  18730. }
  18731. elSeries.add(elDataPointsMain);
  18732. });
  18733. allSeries.push(elSeries);
  18734. });
  18735. this.drawPolygons({
  18736. parent: ret
  18737. });
  18738. if (w.config.xaxis.labels.show) {
  18739. var xaxisTexts = this.drawXAxisTexts();
  18740. ret.add(xaxisTexts);
  18741. }
  18742. allSeries.forEach(function (elS) {
  18743. ret.add(elS);
  18744. });
  18745. ret.add(this.yaxisLabels);
  18746. return ret;
  18747. }
  18748. }, {
  18749. key: "drawPolygons",
  18750. value: function drawPolygons(opts) {
  18751. var _this2 = this;
  18752. var w = this.w;
  18753. var parent = opts.parent;
  18754. var helpers = new CircularChartsHelpers(this.ctx);
  18755. var yaxisTexts = w.globals.yAxisScale[0].result.reverse();
  18756. var layers = yaxisTexts.length;
  18757. var radiusSizes = [];
  18758. var layerDis = this.size / (layers - 1);
  18759. for (var i = 0; i < layers; i++) {
  18760. radiusSizes[i] = layerDis * i;
  18761. }
  18762. radiusSizes.reverse();
  18763. var polygonStrings = [];
  18764. var lines = [];
  18765. radiusSizes.forEach(function (radiusSize, r) {
  18766. var polygon = Utils$1.getPolygonPos(radiusSize, _this2.dataPointsLen);
  18767. var string = '';
  18768. polygon.forEach(function (p, i) {
  18769. if (r === 0) {
  18770. var line = _this2.graphics.drawLine(p.x, p.y, 0, 0, Array.isArray(_this2.polygons.connectorColors) ? _this2.polygons.connectorColors[i] : _this2.polygons.connectorColors);
  18771. lines.push(line);
  18772. }
  18773. if (i === 0) {
  18774. _this2.yaxisLabelsTextsPos.push({
  18775. x: p.x,
  18776. y: p.y
  18777. });
  18778. }
  18779. string += p.x + ',' + p.y + ' ';
  18780. });
  18781. polygonStrings.push(string);
  18782. });
  18783. polygonStrings.forEach(function (p, i) {
  18784. var strokeColors = _this2.polygons.strokeColors;
  18785. var strokeWidth = _this2.polygons.strokeWidth;
  18786. var polygon = _this2.graphics.drawPolygon(p, Array.isArray(strokeColors) ? strokeColors[i] : strokeColors, Array.isArray(strokeWidth) ? strokeWidth[i] : strokeWidth, w.globals.radarPolygons.fill.colors[i]);
  18787. parent.add(polygon);
  18788. });
  18789. lines.forEach(function (l) {
  18790. parent.add(l);
  18791. });
  18792. if (w.config.yaxis[0].show) {
  18793. this.yaxisLabelsTextsPos.forEach(function (p, i) {
  18794. var yText = helpers.drawYAxisTexts(p.x, p.y, i, yaxisTexts[i]);
  18795. _this2.yaxisLabels.add(yText);
  18796. });
  18797. }
  18798. }
  18799. }, {
  18800. key: "drawXAxisTexts",
  18801. value: function drawXAxisTexts() {
  18802. var _this3 = this;
  18803. var w = this.w;
  18804. var xaxisLabelsConfig = w.config.xaxis.labels;
  18805. var elXAxisWrap = this.graphics.group({
  18806. class: 'apexcharts-xaxis'
  18807. });
  18808. var polygonPos = Utils$1.getPolygonPos(this.size, this.dataPointsLen);
  18809. w.globals.labels.forEach(function (label, i) {
  18810. var formatter = w.config.xaxis.labels.formatter;
  18811. var dataLabels = new DataLabels(_this3.ctx);
  18812. if (polygonPos[i]) {
  18813. var textPos = _this3.getTextPos(polygonPos[i], _this3.size);
  18814. var text = formatter(label, {
  18815. seriesIndex: -1,
  18816. dataPointIndex: i,
  18817. w: w
  18818. });
  18819. dataLabels.plotDataLabelsText({
  18820. x: textPos.newX,
  18821. y: textPos.newY,
  18822. text: text,
  18823. textAnchor: textPos.textAnchor,
  18824. i: i,
  18825. j: i,
  18826. parent: elXAxisWrap,
  18827. color: Array.isArray(xaxisLabelsConfig.style.colors) && xaxisLabelsConfig.style.colors[i] ? xaxisLabelsConfig.style.colors[i] : '#a8a8a8',
  18828. dataLabelsConfig: _objectSpread2({
  18829. textAnchor: textPos.textAnchor,
  18830. dropShadow: {
  18831. enabled: false
  18832. }
  18833. }, xaxisLabelsConfig),
  18834. offsetCorrection: false
  18835. });
  18836. }
  18837. });
  18838. return elXAxisWrap;
  18839. }
  18840. }, {
  18841. key: "createPaths",
  18842. value: function createPaths(pos, origin) {
  18843. var _this4 = this;
  18844. var linePathsTo = [];
  18845. var linePathsFrom = [];
  18846. var areaPathsTo = [];
  18847. var areaPathsFrom = [];
  18848. if (pos.length) {
  18849. linePathsFrom = [this.graphics.move(origin.x, origin.y)];
  18850. areaPathsFrom = [this.graphics.move(origin.x, origin.y)];
  18851. var linePathTo = this.graphics.move(pos[0].x, pos[0].y);
  18852. var areaPathTo = this.graphics.move(pos[0].x, pos[0].y);
  18853. pos.forEach(function (p, i) {
  18854. linePathTo += _this4.graphics.line(p.x, p.y);
  18855. areaPathTo += _this4.graphics.line(p.x, p.y);
  18856. if (i === pos.length - 1) {
  18857. linePathTo += 'Z';
  18858. areaPathTo += 'Z';
  18859. }
  18860. });
  18861. linePathsTo.push(linePathTo);
  18862. areaPathsTo.push(areaPathTo);
  18863. }
  18864. return {
  18865. linePathsFrom: linePathsFrom,
  18866. linePathsTo: linePathsTo,
  18867. areaPathsFrom: areaPathsFrom,
  18868. areaPathsTo: areaPathsTo
  18869. };
  18870. }
  18871. }, {
  18872. key: "getTextPos",
  18873. value: function getTextPos(pos, polygonSize) {
  18874. var limit = 10;
  18875. var textAnchor = 'middle';
  18876. var newX = pos.x;
  18877. var newY = pos.y;
  18878. if (Math.abs(pos.x) >= limit) {
  18879. if (pos.x > 0) {
  18880. textAnchor = 'start';
  18881. newX += 10;
  18882. } else if (pos.x < 0) {
  18883. textAnchor = 'end';
  18884. newX -= 10;
  18885. }
  18886. } else {
  18887. textAnchor = 'middle';
  18888. }
  18889. if (Math.abs(pos.y) >= polygonSize - limit) {
  18890. if (pos.y < 0) {
  18891. newY -= 10;
  18892. } else if (pos.y > 0) {
  18893. newY += 10;
  18894. }
  18895. }
  18896. return {
  18897. textAnchor: textAnchor,
  18898. newX: newX,
  18899. newY: newY
  18900. };
  18901. }
  18902. }, {
  18903. key: "getPreviousPath",
  18904. value: function getPreviousPath(realIndex) {
  18905. var w = this.w;
  18906. var pathFrom = null;
  18907. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  18908. var gpp = w.globals.previousPaths[pp];
  18909. if (gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  18910. if (typeof w.globals.previousPaths[pp].paths[0] !== 'undefined') {
  18911. pathFrom = w.globals.previousPaths[pp].paths[0].d;
  18912. }
  18913. }
  18914. }
  18915. return pathFrom;
  18916. }
  18917. }, {
  18918. key: "getDataPointsPos",
  18919. value: function getDataPointsPos(dataRadiusArr, angleArr) {
  18920. var dataPointsLen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.dataPointsLen;
  18921. dataRadiusArr = dataRadiusArr || [];
  18922. angleArr = angleArr || [];
  18923. var dataPointsPosArray = [];
  18924. for (var j = 0; j < dataPointsLen; j++) {
  18925. var curPointPos = {};
  18926. curPointPos.x = dataRadiusArr[j] * Math.sin(angleArr[j]);
  18927. curPointPos.y = -dataRadiusArr[j] * Math.cos(angleArr[j]);
  18928. dataPointsPosArray.push(curPointPos);
  18929. }
  18930. return dataPointsPosArray;
  18931. }
  18932. }]);
  18933. return Radar;
  18934. }();
  18935. /**
  18936. * ApexCharts Radial Class for drawing Circle / Semi Circle Charts.
  18937. * @module Radial
  18938. **/
  18939. var Radial = /*#__PURE__*/function (_Pie) {
  18940. _inherits(Radial, _Pie);
  18941. var _super = _createSuper(Radial);
  18942. function Radial(ctx) {
  18943. var _this;
  18944. _classCallCheck(this, Radial);
  18945. _this = _super.call(this, ctx);
  18946. _this.ctx = ctx;
  18947. _this.w = ctx.w;
  18948. _this.animBeginArr = [0];
  18949. _this.animDur = 0;
  18950. var w = _this.w;
  18951. _this.startAngle = w.config.plotOptions.radialBar.startAngle;
  18952. _this.endAngle = w.config.plotOptions.radialBar.endAngle;
  18953. _this.totalAngle = Math.abs(w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle);
  18954. _this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle;
  18955. _this.trackEndAngle = w.config.plotOptions.radialBar.track.endAngle;
  18956. _this.donutDataLabels = _this.w.config.plotOptions.radialBar.dataLabels;
  18957. _this.radialDataLabels = _this.donutDataLabels; // make a copy for easy reference
  18958. if (!_this.trackStartAngle) _this.trackStartAngle = _this.startAngle;
  18959. if (!_this.trackEndAngle) _this.trackEndAngle = _this.endAngle;
  18960. if (_this.endAngle === 360) _this.endAngle = 359.99;
  18961. _this.margin = parseInt(w.config.plotOptions.radialBar.track.margin, 10);
  18962. return _this;
  18963. }
  18964. _createClass(Radial, [{
  18965. key: "draw",
  18966. value: function draw(series) {
  18967. var w = this.w;
  18968. var graphics = new Graphics(this.ctx);
  18969. var ret = graphics.group({
  18970. class: 'apexcharts-radialbar'
  18971. });
  18972. if (w.globals.noData) return ret;
  18973. var elSeries = graphics.group();
  18974. var centerY = this.defaultSize / 2;
  18975. var centerX = w.globals.gridWidth / 2;
  18976. var size = this.defaultSize / 2.05;
  18977. if (!w.config.chart.sparkline.enabled) {
  18978. size = size - w.config.stroke.width - w.config.chart.dropShadow.blur;
  18979. }
  18980. var colorArr = w.globals.fill.colors;
  18981. if (w.config.plotOptions.radialBar.track.show) {
  18982. var elTracks = this.drawTracks({
  18983. size: size,
  18984. centerX: centerX,
  18985. centerY: centerY,
  18986. colorArr: colorArr,
  18987. series: series
  18988. });
  18989. elSeries.add(elTracks);
  18990. }
  18991. var elG = this.drawArcs({
  18992. size: size,
  18993. centerX: centerX,
  18994. centerY: centerY,
  18995. colorArr: colorArr,
  18996. series: series
  18997. });
  18998. var totalAngle = 360;
  18999. if (w.config.plotOptions.radialBar.startAngle < 0) {
  19000. totalAngle = this.totalAngle;
  19001. }
  19002. var angleRatio = (360 - totalAngle) / 360;
  19003. w.globals.radialSize = size - size * angleRatio;
  19004. if (this.radialDataLabels.value.show) {
  19005. var offset = Math.max(this.radialDataLabels.value.offsetY, this.radialDataLabels.name.offsetY);
  19006. w.globals.radialSize += offset * angleRatio;
  19007. }
  19008. elSeries.add(elG.g);
  19009. if (w.config.plotOptions.radialBar.hollow.position === 'front') {
  19010. elG.g.add(elG.elHollow);
  19011. if (elG.dataLabels) {
  19012. elG.g.add(elG.dataLabels);
  19013. }
  19014. }
  19015. ret.add(elSeries);
  19016. return ret;
  19017. }
  19018. }, {
  19019. key: "drawTracks",
  19020. value: function drawTracks(opts) {
  19021. var w = this.w;
  19022. var graphics = new Graphics(this.ctx);
  19023. var g = graphics.group({
  19024. class: 'apexcharts-tracks'
  19025. });
  19026. var filters = new Filters(this.ctx);
  19027. var fill = new Fill(this.ctx);
  19028. var strokeWidth = this.getStrokeWidth(opts);
  19029. opts.size = opts.size - strokeWidth / 2;
  19030. for (var i = 0; i < opts.series.length; i++) {
  19031. var elRadialBarTrack = graphics.group({
  19032. class: 'apexcharts-radialbar-track apexcharts-track'
  19033. });
  19034. g.add(elRadialBarTrack);
  19035. elRadialBarTrack.attr({
  19036. rel: i + 1
  19037. });
  19038. opts.size = opts.size - strokeWidth - this.margin;
  19039. var trackConfig = w.config.plotOptions.radialBar.track;
  19040. var pathFill = fill.fillPath({
  19041. seriesNumber: 0,
  19042. size: opts.size,
  19043. fillColors: Array.isArray(trackConfig.background) ? trackConfig.background[i] : trackConfig.background,
  19044. solid: true
  19045. });
  19046. var startAngle = this.trackStartAngle;
  19047. var endAngle = this.trackEndAngle;
  19048. if (Math.abs(endAngle) + Math.abs(startAngle) >= 360) endAngle = 360 - Math.abs(this.startAngle) - 0.1;
  19049. var elPath = graphics.drawPath({
  19050. d: '',
  19051. stroke: pathFill,
  19052. strokeWidth: strokeWidth * parseInt(trackConfig.strokeWidth, 10) / 100,
  19053. fill: 'none',
  19054. strokeOpacity: trackConfig.opacity,
  19055. classes: 'apexcharts-radialbar-area'
  19056. });
  19057. if (trackConfig.dropShadow.enabled) {
  19058. var shadow = trackConfig.dropShadow;
  19059. filters.dropShadow(elPath, shadow);
  19060. }
  19061. elRadialBarTrack.add(elPath);
  19062. elPath.attr('id', 'apexcharts-radialbarTrack-' + i);
  19063. this.animatePaths(elPath, {
  19064. centerX: opts.centerX,
  19065. centerY: opts.centerY,
  19066. endAngle: endAngle,
  19067. startAngle: startAngle,
  19068. size: opts.size,
  19069. i: i,
  19070. totalItems: 2,
  19071. animBeginArr: 0,
  19072. dur: 0,
  19073. isTrack: true,
  19074. easing: w.globals.easing
  19075. });
  19076. }
  19077. return g;
  19078. }
  19079. }, {
  19080. key: "drawArcs",
  19081. value: function drawArcs(opts) {
  19082. var w = this.w; // size, donutSize, centerX, centerY, colorArr, lineColorArr, sectorAngleArr, series
  19083. var graphics = new Graphics(this.ctx);
  19084. var fill = new Fill(this.ctx);
  19085. var filters = new Filters(this.ctx);
  19086. var g = graphics.group();
  19087. var strokeWidth = this.getStrokeWidth(opts);
  19088. opts.size = opts.size - strokeWidth / 2;
  19089. var hollowFillID = w.config.plotOptions.radialBar.hollow.background;
  19090. var hollowSize = opts.size - strokeWidth * opts.series.length - this.margin * opts.series.length - strokeWidth * parseInt(w.config.plotOptions.radialBar.track.strokeWidth, 10) / 100 / 2;
  19091. var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin;
  19092. if (w.config.plotOptions.radialBar.hollow.image !== undefined) {
  19093. hollowFillID = this.drawHollowImage(opts, g, hollowSize, hollowFillID);
  19094. }
  19095. var elHollow = this.drawHollow({
  19096. size: hollowRadius,
  19097. centerX: opts.centerX,
  19098. centerY: opts.centerY,
  19099. fill: hollowFillID ? hollowFillID : 'transparent'
  19100. });
  19101. if (w.config.plotOptions.radialBar.hollow.dropShadow.enabled) {
  19102. var shadow = w.config.plotOptions.radialBar.hollow.dropShadow;
  19103. filters.dropShadow(elHollow, shadow);
  19104. }
  19105. var shown = 1;
  19106. if (!this.radialDataLabels.total.show && w.globals.series.length > 1) {
  19107. shown = 0;
  19108. }
  19109. var dataLabels = null;
  19110. if (this.radialDataLabels.show) {
  19111. dataLabels = this.renderInnerDataLabels(this.radialDataLabels, {
  19112. hollowSize: hollowSize,
  19113. centerX: opts.centerX,
  19114. centerY: opts.centerY,
  19115. opacity: shown
  19116. });
  19117. }
  19118. if (w.config.plotOptions.radialBar.hollow.position === 'back') {
  19119. g.add(elHollow);
  19120. if (dataLabels) {
  19121. g.add(dataLabels);
  19122. }
  19123. }
  19124. var reverseLoop = false;
  19125. if (w.config.plotOptions.radialBar.inverseOrder) {
  19126. reverseLoop = true;
  19127. }
  19128. for (var i = reverseLoop ? opts.series.length - 1 : 0; reverseLoop ? i >= 0 : i < opts.series.length; reverseLoop ? i-- : i++) {
  19129. var elRadialBarArc = graphics.group({
  19130. class: "apexcharts-series apexcharts-radial-series",
  19131. seriesName: Utils$1.escapeString(w.globals.seriesNames[i])
  19132. });
  19133. g.add(elRadialBarArc);
  19134. elRadialBarArc.attr({
  19135. rel: i + 1,
  19136. 'data:realIndex': i
  19137. });
  19138. this.ctx.series.addCollapsedClassToSeries(elRadialBarArc, i);
  19139. opts.size = opts.size - strokeWidth - this.margin;
  19140. var pathFill = fill.fillPath({
  19141. seriesNumber: i,
  19142. size: opts.size,
  19143. value: opts.series[i]
  19144. });
  19145. var startAngle = this.startAngle;
  19146. var prevStartAngle = void 0; // if data exceeds 100, make it 100
  19147. var dataValue = Utils$1.negToZero(opts.series[i] > 100 ? 100 : opts.series[i]) / 100;
  19148. var endAngle = Math.round(this.totalAngle * dataValue) + this.startAngle;
  19149. var prevEndAngle = void 0;
  19150. if (w.globals.dataChanged) {
  19151. prevStartAngle = this.startAngle;
  19152. prevEndAngle = Math.round(this.totalAngle * Utils$1.negToZero(w.globals.previousPaths[i]) / 100) + prevStartAngle;
  19153. }
  19154. var currFullAngle = Math.abs(endAngle) + Math.abs(startAngle);
  19155. if (currFullAngle >= 360) {
  19156. endAngle = endAngle - 0.01;
  19157. }
  19158. var prevFullAngle = Math.abs(prevEndAngle) + Math.abs(prevStartAngle);
  19159. if (prevFullAngle >= 360) {
  19160. prevEndAngle = prevEndAngle - 0.01;
  19161. }
  19162. var angle = endAngle - startAngle;
  19163. var dashArray = Array.isArray(w.config.stroke.dashArray) ? w.config.stroke.dashArray[i] : w.config.stroke.dashArray;
  19164. var elPath = graphics.drawPath({
  19165. d: '',
  19166. stroke: pathFill,
  19167. strokeWidth: strokeWidth,
  19168. fill: 'none',
  19169. fillOpacity: w.config.fill.opacity,
  19170. classes: 'apexcharts-radialbar-area apexcharts-radialbar-slice-' + i,
  19171. strokeDashArray: dashArray
  19172. });
  19173. Graphics.setAttrs(elPath.node, {
  19174. 'data:angle': angle,
  19175. 'data:value': opts.series[i]
  19176. });
  19177. if (w.config.chart.dropShadow.enabled) {
  19178. var _shadow = w.config.chart.dropShadow;
  19179. filters.dropShadow(elPath, _shadow, i);
  19180. }
  19181. filters.setSelectionFilter(elPath, 0, i);
  19182. this.addListeners(elPath, this.radialDataLabels);
  19183. elRadialBarArc.add(elPath);
  19184. elPath.attr({
  19185. index: 0,
  19186. j: i
  19187. });
  19188. var dur = 0;
  19189. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  19190. dur = w.config.chart.animations.speed;
  19191. }
  19192. if (w.globals.dataChanged) {
  19193. dur = w.config.chart.animations.dynamicAnimation.speed;
  19194. }
  19195. this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
  19196. this.animBeginArr.push(this.animDur);
  19197. this.animatePaths(elPath, {
  19198. centerX: opts.centerX,
  19199. centerY: opts.centerY,
  19200. endAngle: endAngle,
  19201. startAngle: startAngle,
  19202. prevEndAngle: prevEndAngle,
  19203. prevStartAngle: prevStartAngle,
  19204. size: opts.size,
  19205. i: i,
  19206. totalItems: 2,
  19207. animBeginArr: this.animBeginArr,
  19208. dur: dur,
  19209. shouldSetPrevPaths: true,
  19210. easing: w.globals.easing
  19211. });
  19212. }
  19213. return {
  19214. g: g,
  19215. elHollow: elHollow,
  19216. dataLabels: dataLabels
  19217. };
  19218. }
  19219. }, {
  19220. key: "drawHollow",
  19221. value: function drawHollow(opts) {
  19222. var graphics = new Graphics(this.ctx);
  19223. var circle = graphics.drawCircle(opts.size * 2);
  19224. circle.attr({
  19225. class: 'apexcharts-radialbar-hollow',
  19226. cx: opts.centerX,
  19227. cy: opts.centerY,
  19228. r: opts.size,
  19229. fill: opts.fill
  19230. });
  19231. return circle;
  19232. }
  19233. }, {
  19234. key: "drawHollowImage",
  19235. value: function drawHollowImage(opts, g, hollowSize, hollowFillID) {
  19236. var w = this.w;
  19237. var fill = new Fill(this.ctx);
  19238. var randID = Utils$1.randomId();
  19239. var hollowFillImg = w.config.plotOptions.radialBar.hollow.image;
  19240. if (w.config.plotOptions.radialBar.hollow.imageClipped) {
  19241. fill.clippedImgArea({
  19242. width: hollowSize,
  19243. height: hollowSize,
  19244. image: hollowFillImg,
  19245. patternID: "pattern".concat(w.globals.cuid).concat(randID)
  19246. });
  19247. hollowFillID = "url(#pattern".concat(w.globals.cuid).concat(randID, ")");
  19248. } else {
  19249. var imgWidth = w.config.plotOptions.radialBar.hollow.imageWidth;
  19250. var imgHeight = w.config.plotOptions.radialBar.hollow.imageHeight;
  19251. if (imgWidth === undefined && imgHeight === undefined) {
  19252. var image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  19253. this.move(opts.centerX - loader.width / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - loader.height / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  19254. });
  19255. g.add(image);
  19256. } else {
  19257. var _image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  19258. this.move(opts.centerX - imgWidth / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - imgHeight / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  19259. this.size(imgWidth, imgHeight);
  19260. });
  19261. g.add(_image);
  19262. }
  19263. }
  19264. return hollowFillID;
  19265. }
  19266. }, {
  19267. key: "getStrokeWidth",
  19268. value: function getStrokeWidth(opts) {
  19269. var w = this.w;
  19270. return opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size, 10)) / 100 / (opts.series.length + 1) - this.margin;
  19271. }
  19272. }]);
  19273. return Radial;
  19274. }(Pie);
  19275. var Helpers = /*#__PURE__*/function () {
  19276. function Helpers(lineCtx) {
  19277. _classCallCheck(this, Helpers);
  19278. this.w = lineCtx.w;
  19279. this.lineCtx = lineCtx;
  19280. }
  19281. _createClass(Helpers, [{
  19282. key: "sameValueSeriesFix",
  19283. value: function sameValueSeriesFix(i, series) {
  19284. var w = this.w;
  19285. if (w.config.chart.type === 'line' && (w.config.fill.type === 'gradient' || w.config.fill.type[i] === 'gradient')) {
  19286. var coreUtils = new CoreUtils(this.lineCtx.ctx, w); // a small adjustment to allow gradient line to draw correctly for all same values
  19287. /* #fix https://github.com/apexcharts/apexcharts.js/issues/358 */
  19288. if (coreUtils.seriesHaveSameValues(i)) {
  19289. var gSeries = series[i].slice();
  19290. gSeries[gSeries.length - 1] = gSeries[gSeries.length - 1] + 0.000001;
  19291. series[i] = gSeries;
  19292. }
  19293. }
  19294. return series;
  19295. }
  19296. }, {
  19297. key: "calculatePoints",
  19298. value: function calculatePoints(_ref) {
  19299. var series = _ref.series,
  19300. realIndex = _ref.realIndex,
  19301. x = _ref.x,
  19302. y = _ref.y,
  19303. i = _ref.i,
  19304. j = _ref.j,
  19305. prevY = _ref.prevY;
  19306. var w = this.w;
  19307. var ptX = [];
  19308. var ptY = [];
  19309. if (j === 0) {
  19310. var xPT1st = this.lineCtx.categoryAxisCorrection + w.config.markers.offsetX; // the first point for line series
  19311. // we need to check whether it's not a time series, because a time series may
  19312. // start from the middle of the x axis
  19313. if (w.globals.isXNumeric) {
  19314. xPT1st = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.lineCtx.xRatio + w.config.markers.offsetX;
  19315. } // push 2 points for the first data values
  19316. ptX.push(xPT1st);
  19317. ptY.push(Utils$1.isNumber(series[i][0]) ? prevY + w.config.markers.offsetY : null);
  19318. ptX.push(x + w.config.markers.offsetX);
  19319. ptY.push(Utils$1.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  19320. } else {
  19321. ptX.push(x + w.config.markers.offsetX);
  19322. ptY.push(Utils$1.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  19323. }
  19324. var pointsPos = {
  19325. x: ptX,
  19326. y: ptY
  19327. };
  19328. return pointsPos;
  19329. }
  19330. }, {
  19331. key: "checkPreviousPaths",
  19332. value: function checkPreviousPaths(_ref2) {
  19333. var pathFromLine = _ref2.pathFromLine,
  19334. pathFromArea = _ref2.pathFromArea,
  19335. realIndex = _ref2.realIndex;
  19336. var w = this.w;
  19337. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  19338. var gpp = w.globals.previousPaths[pp];
  19339. if ((gpp.type === 'line' || gpp.type === 'area') && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  19340. if (gpp.type === 'line') {
  19341. this.lineCtx.appendPathFrom = false;
  19342. pathFromLine = w.globals.previousPaths[pp].paths[0].d;
  19343. } else if (gpp.type === 'area') {
  19344. this.lineCtx.appendPathFrom = false;
  19345. pathFromArea = w.globals.previousPaths[pp].paths[0].d;
  19346. if (w.config.stroke.show && w.globals.previousPaths[pp].paths[1]) {
  19347. pathFromLine = w.globals.previousPaths[pp].paths[1].d;
  19348. }
  19349. }
  19350. }
  19351. }
  19352. return {
  19353. pathFromLine: pathFromLine,
  19354. pathFromArea: pathFromArea
  19355. };
  19356. }
  19357. }, {
  19358. key: "determineFirstPrevY",
  19359. value: function determineFirstPrevY(_ref3) {
  19360. var i = _ref3.i,
  19361. series = _ref3.series,
  19362. prevY = _ref3.prevY,
  19363. lineYPosition = _ref3.lineYPosition;
  19364. var w = this.w;
  19365. if (typeof series[i][0] !== 'undefined') {
  19366. if (w.config.chart.stacked) {
  19367. if (i > 0) {
  19368. // 1st y value of previous series
  19369. lineYPosition = this.lineCtx.prevSeriesY[i - 1][0];
  19370. } else {
  19371. // the first series will not have prevY values
  19372. lineYPosition = this.lineCtx.zeroY;
  19373. }
  19374. } else {
  19375. lineYPosition = this.lineCtx.zeroY;
  19376. }
  19377. 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;
  19378. } else {
  19379. // the first value in the current series is null
  19380. if (w.config.chart.stacked && i > 0 && typeof series[i][0] === 'undefined') {
  19381. // check for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses)
  19382. for (var s = i - 1; s >= 0; s--) {
  19383. // for loop to get to 1st previous value until we get it
  19384. if (series[s][0] !== null && typeof series[s][0] !== 'undefined') {
  19385. lineYPosition = this.lineCtx.prevSeriesY[s][0];
  19386. prevY = lineYPosition;
  19387. break;
  19388. }
  19389. }
  19390. }
  19391. }
  19392. return {
  19393. prevY: prevY,
  19394. lineYPosition: lineYPosition
  19395. };
  19396. }
  19397. }]);
  19398. return Helpers;
  19399. }();
  19400. /**
  19401. * ApexCharts Line Class responsible for drawing Line / Area Charts.
  19402. * This class is also responsible for generating values for Bubble/Scatter charts, so need to rename it to Axis Charts to avoid confusions
  19403. * @module Line
  19404. **/
  19405. var Line = /*#__PURE__*/function () {
  19406. function Line(ctx, xyRatios, isPointsChart) {
  19407. _classCallCheck(this, Line);
  19408. this.ctx = ctx;
  19409. this.w = ctx.w;
  19410. this.xyRatios = xyRatios;
  19411. this.pointsChart = !(this.w.config.chart.type !== 'bubble' && this.w.config.chart.type !== 'scatter') || isPointsChart;
  19412. this.scatter = new Scatter(this.ctx);
  19413. this.noNegatives = this.w.globals.minX === Number.MAX_VALUE;
  19414. this.lineHelpers = new Helpers(this);
  19415. this.markers = new Markers(this.ctx);
  19416. this.prevSeriesY = [];
  19417. this.categoryAxisCorrection = 0;
  19418. this.yaxisIndex = 0;
  19419. }
  19420. _createClass(Line, [{
  19421. key: "draw",
  19422. value: function draw(series, ptype, seriesIndex) {
  19423. var w = this.w;
  19424. var graphics = new Graphics(this.ctx);
  19425. var type = w.globals.comboCharts ? ptype : w.config.chart.type;
  19426. var ret = graphics.group({
  19427. class: "apexcharts-".concat(type, "-series apexcharts-plot-series")
  19428. });
  19429. var coreUtils = new CoreUtils(this.ctx, w);
  19430. this.yRatio = this.xyRatios.yRatio;
  19431. this.zRatio = this.xyRatios.zRatio;
  19432. this.xRatio = this.xyRatios.xRatio;
  19433. this.baseLineY = this.xyRatios.baseLineY;
  19434. series = coreUtils.getLogSeries(series);
  19435. this.yRatio = coreUtils.getLogYRatios(this.yRatio); // push all series in an array, so we can draw in reverse order (for stacked charts)
  19436. var allSeries = [];
  19437. for (var i = 0; i < series.length; i++) {
  19438. series = this.lineHelpers.sameValueSeriesFix(i, series);
  19439. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  19440. this._initSerieVariables(series, i, realIndex);
  19441. var yArrj = []; // hold y values of current iterating series
  19442. var xArrj = []; // hold x values of current iterating series
  19443. var x = w.globals.padHorizontal + this.categoryAxisCorrection;
  19444. var y = 1;
  19445. var linePaths = [];
  19446. var areaPaths = [];
  19447. this.ctx.series.addCollapsedClassToSeries(this.elSeries, realIndex);
  19448. if (w.globals.isXNumeric && w.globals.seriesX.length > 0) {
  19449. x = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.xRatio;
  19450. }
  19451. xArrj.push(x);
  19452. var pX = x;
  19453. var pY = void 0;
  19454. var prevX = pX;
  19455. var prevY = this.zeroY;
  19456. var lineYPosition = 0; // the first value in the current series is not null or undefined
  19457. var firstPrevY = this.lineHelpers.determineFirstPrevY({
  19458. i: i,
  19459. series: series,
  19460. prevY: prevY,
  19461. lineYPosition: lineYPosition
  19462. });
  19463. prevY = firstPrevY.prevY;
  19464. yArrj.push(prevY);
  19465. pY = prevY;
  19466. var pathsFrom = this._calculatePathsFrom({
  19467. series: series,
  19468. i: i,
  19469. realIndex: realIndex,
  19470. prevX: prevX,
  19471. prevY: prevY
  19472. });
  19473. var paths = this._iterateOverDataPoints({
  19474. series: series,
  19475. realIndex: realIndex,
  19476. i: i,
  19477. x: x,
  19478. y: y,
  19479. pX: pX,
  19480. pY: pY,
  19481. pathsFrom: pathsFrom,
  19482. linePaths: linePaths,
  19483. areaPaths: areaPaths,
  19484. seriesIndex: seriesIndex,
  19485. lineYPosition: lineYPosition,
  19486. xArrj: xArrj,
  19487. yArrj: yArrj
  19488. });
  19489. this._handlePaths({
  19490. type: type,
  19491. realIndex: realIndex,
  19492. i: i,
  19493. paths: paths
  19494. });
  19495. this.elSeries.add(this.elPointsMain);
  19496. this.elSeries.add(this.elDataLabelsWrap);
  19497. allSeries.push(this.elSeries);
  19498. }
  19499. if (w.config.chart.stacked) {
  19500. for (var s = allSeries.length; s > 0; s--) {
  19501. ret.add(allSeries[s - 1]);
  19502. }
  19503. } else {
  19504. for (var _s = 0; _s < allSeries.length; _s++) {
  19505. ret.add(allSeries[_s]);
  19506. }
  19507. }
  19508. return ret;
  19509. }
  19510. }, {
  19511. key: "_initSerieVariables",
  19512. value: function _initSerieVariables(series, i, realIndex) {
  19513. var w = this.w;
  19514. var graphics = new Graphics(this.ctx); // width divided into equal parts
  19515. this.xDivision = w.globals.gridWidth / (w.globals.dataPoints - (w.config.xaxis.tickPlacement === 'on' ? 1 : 0));
  19516. this.strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width;
  19517. if (this.yRatio.length > 1) {
  19518. this.yaxisIndex = realIndex;
  19519. }
  19520. 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
  19521. this.zeroY = w.globals.gridHeight - this.baseLineY[this.yaxisIndex] - (this.isReversed ? w.globals.gridHeight : 0) + (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0);
  19522. this.areaBottomY = this.zeroY;
  19523. if (this.zeroY > w.globals.gridHeight || w.config.plotOptions.area.fillTo === 'end') {
  19524. this.areaBottomY = w.globals.gridHeight;
  19525. }
  19526. this.categoryAxisCorrection = this.xDivision / 2; // el to which series will be drawn
  19527. this.elSeries = graphics.group({
  19528. class: "apexcharts-series",
  19529. seriesName: Utils$1.escapeString(w.globals.seriesNames[realIndex])
  19530. }); // points
  19531. this.elPointsMain = graphics.group({
  19532. class: 'apexcharts-series-markers-wrap',
  19533. 'data:realIndex': realIndex
  19534. }); // eldatalabels
  19535. this.elDataLabelsWrap = graphics.group({
  19536. class: 'apexcharts-datalabels',
  19537. 'data:realIndex': realIndex
  19538. });
  19539. var longestSeries = series[i].length === w.globals.dataPoints;
  19540. this.elSeries.attr({
  19541. 'data:longestSeries': longestSeries,
  19542. rel: i + 1,
  19543. 'data:realIndex': realIndex
  19544. });
  19545. this.appendPathFrom = true;
  19546. }
  19547. }, {
  19548. key: "_calculatePathsFrom",
  19549. value: function _calculatePathsFrom(_ref) {
  19550. var series = _ref.series,
  19551. i = _ref.i,
  19552. realIndex = _ref.realIndex,
  19553. prevX = _ref.prevX,
  19554. prevY = _ref.prevY;
  19555. var w = this.w;
  19556. var graphics = new Graphics(this.ctx);
  19557. var linePath, areaPath, pathFromLine, pathFromArea;
  19558. if (series[i][0] === null) {
  19559. // when the first value itself is null, we need to move the pointer to a location where a null value is not found
  19560. for (var s = 0; s < series[i].length; s++) {
  19561. if (series[i][s] !== null) {
  19562. prevX = this.xDivision * s;
  19563. prevY = this.zeroY - series[i][s] / this.yRatio[this.yaxisIndex];
  19564. linePath = graphics.move(prevX, prevY);
  19565. areaPath = graphics.move(prevX, this.areaBottomY);
  19566. break;
  19567. }
  19568. }
  19569. } else {
  19570. linePath = graphics.move(prevX, prevY);
  19571. areaPath = graphics.move(prevX, this.areaBottomY) + graphics.line(prevX, prevY);
  19572. }
  19573. pathFromLine = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  19574. pathFromArea = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  19575. if (w.globals.previousPaths.length > 0) {
  19576. var pathFrom = this.lineHelpers.checkPreviousPaths({
  19577. pathFromLine: pathFromLine,
  19578. pathFromArea: pathFromArea,
  19579. realIndex: realIndex
  19580. });
  19581. pathFromLine = pathFrom.pathFromLine;
  19582. pathFromArea = pathFrom.pathFromArea;
  19583. }
  19584. return {
  19585. prevX: prevX,
  19586. prevY: prevY,
  19587. linePath: linePath,
  19588. areaPath: areaPath,
  19589. pathFromLine: pathFromLine,
  19590. pathFromArea: pathFromArea
  19591. };
  19592. }
  19593. }, {
  19594. key: "_handlePaths",
  19595. value: function _handlePaths(_ref2) {
  19596. var type = _ref2.type,
  19597. realIndex = _ref2.realIndex,
  19598. i = _ref2.i,
  19599. paths = _ref2.paths;
  19600. var w = this.w;
  19601. var graphics = new Graphics(this.ctx);
  19602. var fill = new Fill(this.ctx); // push all current y values array to main PrevY Array
  19603. this.prevSeriesY.push(paths.yArrj); // push all x val arrays into main xArr
  19604. w.globals.seriesXvalues[realIndex] = paths.xArrj;
  19605. w.globals.seriesYvalues[realIndex] = paths.yArrj;
  19606. var forecast = w.config.forecastDataPoints;
  19607. if (forecast.count > 0) {
  19608. var forecastCutoff = w.globals.seriesXvalues[realIndex][w.globals.seriesXvalues[realIndex].length - forecast.count - 1];
  19609. var elForecastMask = graphics.drawRect(forecastCutoff, 0, w.globals.gridWidth, w.globals.gridHeight, 0);
  19610. w.globals.dom.elForecastMask.appendChild(elForecastMask.node);
  19611. var elNonForecastMask = graphics.drawRect(0, 0, forecastCutoff, w.globals.gridHeight, 0);
  19612. w.globals.dom.elNonForecastMask.appendChild(elNonForecastMask.node);
  19613. } // these elements will be shown after area path animation completes
  19614. if (!this.pointsChart) {
  19615. w.globals.delayedElements.push({
  19616. el: this.elPointsMain.node,
  19617. index: realIndex
  19618. });
  19619. }
  19620. var defaultRenderedPathOptions = {
  19621. i: i,
  19622. realIndex: realIndex,
  19623. animationDelay: i,
  19624. initialSpeed: w.config.chart.animations.speed,
  19625. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  19626. className: "apexcharts-".concat(type)
  19627. };
  19628. if (type === 'area') {
  19629. var pathFill = fill.fillPath({
  19630. seriesNumber: realIndex
  19631. });
  19632. for (var p = 0; p < paths.areaPaths.length; p++) {
  19633. var renderedPath = graphics.renderPaths(_objectSpread2(_objectSpread2({}, defaultRenderedPathOptions), {}, {
  19634. pathFrom: paths.pathFromArea,
  19635. pathTo: paths.areaPaths[p],
  19636. stroke: 'none',
  19637. strokeWidth: 0,
  19638. strokeLineCap: null,
  19639. fill: pathFill
  19640. }));
  19641. this.elSeries.add(renderedPath);
  19642. }
  19643. }
  19644. if (w.config.stroke.show && !this.pointsChart) {
  19645. var lineFill = null;
  19646. if (type === 'line') {
  19647. // fillable lines only for lineChart
  19648. lineFill = fill.fillPath({
  19649. seriesNumber: realIndex,
  19650. i: i
  19651. });
  19652. } else {
  19653. lineFill = w.globals.stroke.colors[realIndex];
  19654. }
  19655. for (var _p = 0; _p < paths.linePaths.length; _p++) {
  19656. var linePathCommonOpts = _objectSpread2(_objectSpread2({}, defaultRenderedPathOptions), {}, {
  19657. pathFrom: paths.pathFromLine,
  19658. pathTo: paths.linePaths[_p],
  19659. stroke: lineFill,
  19660. strokeWidth: this.strokeWidth,
  19661. strokeLineCap: w.config.stroke.lineCap,
  19662. fill: 'none'
  19663. });
  19664. var _renderedPath = graphics.renderPaths(linePathCommonOpts);
  19665. this.elSeries.add(_renderedPath);
  19666. if (forecast.count > 0) {
  19667. var renderedForecastPath = graphics.renderPaths(linePathCommonOpts);
  19668. renderedForecastPath.node.setAttribute('stroke-dasharray', forecast.dashArray);
  19669. if (forecast.strokeWidth) {
  19670. renderedForecastPath.node.setAttribute('stroke-width', forecast.strokeWidth);
  19671. }
  19672. this.elSeries.add(renderedForecastPath);
  19673. renderedForecastPath.attr('clip-path', "url(#forecastMask".concat(w.globals.cuid, ")"));
  19674. _renderedPath.attr('clip-path', "url(#nonForecastMask".concat(w.globals.cuid, ")"));
  19675. }
  19676. }
  19677. }
  19678. }
  19679. }, {
  19680. key: "_iterateOverDataPoints",
  19681. value: function _iterateOverDataPoints(_ref3) {
  19682. var series = _ref3.series,
  19683. realIndex = _ref3.realIndex,
  19684. i = _ref3.i,
  19685. x = _ref3.x,
  19686. y = _ref3.y,
  19687. pX = _ref3.pX,
  19688. pY = _ref3.pY,
  19689. pathsFrom = _ref3.pathsFrom,
  19690. linePaths = _ref3.linePaths,
  19691. areaPaths = _ref3.areaPaths,
  19692. seriesIndex = _ref3.seriesIndex,
  19693. lineYPosition = _ref3.lineYPosition,
  19694. xArrj = _ref3.xArrj,
  19695. yArrj = _ref3.yArrj;
  19696. var w = this.w;
  19697. var graphics = new Graphics(this.ctx);
  19698. var yRatio = this.yRatio;
  19699. var prevY = pathsFrom.prevY,
  19700. linePath = pathsFrom.linePath,
  19701. areaPath = pathsFrom.areaPath,
  19702. pathFromLine = pathsFrom.pathFromLine,
  19703. pathFromArea = pathsFrom.pathFromArea;
  19704. var minY = Utils$1.isNumber(w.globals.minYArr[realIndex]) ? w.globals.minYArr[realIndex] : w.globals.minY;
  19705. var iterations = w.globals.dataPoints > 1 ? w.globals.dataPoints - 1 : w.globals.dataPoints;
  19706. for (var j = 0; j < iterations; j++) {
  19707. var isNull = typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null;
  19708. if (w.globals.isXNumeric) {
  19709. var sX = w.globals.seriesX[realIndex][j + 1];
  19710. if (typeof w.globals.seriesX[realIndex][j + 1] === 'undefined') {
  19711. /* fix #374 */
  19712. sX = w.globals.seriesX[realIndex][iterations - 1];
  19713. }
  19714. x = (sX - w.globals.minX) / this.xRatio;
  19715. } else {
  19716. x = x + this.xDivision;
  19717. }
  19718. if (w.config.chart.stacked) {
  19719. if (i > 0 && w.globals.collapsedSeries.length < w.config.series.length - 1) {
  19720. // 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
  19721. var prevIndex = function prevIndex(pi) {
  19722. var pii = pi;
  19723. for (var cpi = 0; cpi < w.globals.series.length; cpi++) {
  19724. if (w.globals.collapsedSeriesIndices.indexOf(pi) > -1) {
  19725. pii--;
  19726. break;
  19727. }
  19728. }
  19729. return pii >= 0 ? pii : 0;
  19730. };
  19731. lineYPosition = this.prevSeriesY[prevIndex(i - 1)][j + 1];
  19732. } else {
  19733. // the first series will not have prevY values
  19734. lineYPosition = this.zeroY;
  19735. }
  19736. } else {
  19737. lineYPosition = this.zeroY;
  19738. }
  19739. if (isNull) {
  19740. y = lineYPosition - minY / yRatio[this.yaxisIndex] + (this.isReversed ? minY / yRatio[this.yaxisIndex] : 0) * 2;
  19741. } else {
  19742. y = lineYPosition - series[i][j + 1] / yRatio[this.yaxisIndex] + (this.isReversed ? series[i][j + 1] / yRatio[this.yaxisIndex] : 0) * 2;
  19743. } // push current X
  19744. xArrj.push(x); // push current Y that will be used as next series's bottom position
  19745. yArrj.push(y);
  19746. var pointsPos = this.lineHelpers.calculatePoints({
  19747. series: series,
  19748. x: x,
  19749. y: y,
  19750. realIndex: realIndex,
  19751. i: i,
  19752. j: j,
  19753. prevY: prevY
  19754. });
  19755. var calculatedPaths = this._createPaths({
  19756. series: series,
  19757. i: i,
  19758. realIndex: realIndex,
  19759. j: j,
  19760. x: x,
  19761. y: y,
  19762. pX: pX,
  19763. pY: pY,
  19764. linePath: linePath,
  19765. areaPath: areaPath,
  19766. linePaths: linePaths,
  19767. areaPaths: areaPaths,
  19768. seriesIndex: seriesIndex
  19769. });
  19770. areaPaths = calculatedPaths.areaPaths;
  19771. linePaths = calculatedPaths.linePaths;
  19772. pX = calculatedPaths.pX;
  19773. pY = calculatedPaths.pY;
  19774. areaPath = calculatedPaths.areaPath;
  19775. linePath = calculatedPaths.linePath;
  19776. if (this.appendPathFrom) {
  19777. pathFromLine = pathFromLine + graphics.line(x, this.zeroY);
  19778. pathFromArea = pathFromArea + graphics.line(x, this.zeroY);
  19779. }
  19780. this.handleNullDataPoints(series, pointsPos, i, j, realIndex);
  19781. this._handleMarkersAndLabels({
  19782. pointsPos: pointsPos,
  19783. series: series,
  19784. x: x,
  19785. y: y,
  19786. prevY: prevY,
  19787. i: i,
  19788. j: j,
  19789. realIndex: realIndex
  19790. });
  19791. }
  19792. return {
  19793. yArrj: yArrj,
  19794. xArrj: xArrj,
  19795. pathFromArea: pathFromArea,
  19796. areaPaths: areaPaths,
  19797. pathFromLine: pathFromLine,
  19798. linePaths: linePaths
  19799. };
  19800. }
  19801. }, {
  19802. key: "_handleMarkersAndLabels",
  19803. value: function _handleMarkersAndLabels(_ref4) {
  19804. var pointsPos = _ref4.pointsPos;
  19805. _ref4.series;
  19806. _ref4.x;
  19807. _ref4.y;
  19808. _ref4.prevY;
  19809. var i = _ref4.i,
  19810. j = _ref4.j,
  19811. realIndex = _ref4.realIndex;
  19812. var w = this.w;
  19813. var dataLabels = new DataLabels(this.ctx);
  19814. if (!this.pointsChart) {
  19815. if (w.globals.series[i].length > 1) {
  19816. this.elPointsMain.node.classList.add('apexcharts-element-hidden');
  19817. }
  19818. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1);
  19819. if (elPointsWrap !== null) {
  19820. this.elPointsMain.add(elPointsWrap);
  19821. }
  19822. } else {
  19823. // scatter / bubble chart points creation
  19824. this.scatter.draw(this.elSeries, j, {
  19825. realIndex: realIndex,
  19826. pointsPos: pointsPos,
  19827. zRatio: this.zRatio,
  19828. elParent: this.elPointsMain
  19829. });
  19830. }
  19831. var drawnLabels = dataLabels.drawDataLabel(pointsPos, realIndex, j + 1, null);
  19832. if (drawnLabels !== null) {
  19833. this.elDataLabelsWrap.add(drawnLabels);
  19834. }
  19835. }
  19836. }, {
  19837. key: "_createPaths",
  19838. value: function _createPaths(_ref5) {
  19839. var series = _ref5.series,
  19840. i = _ref5.i,
  19841. realIndex = _ref5.realIndex,
  19842. j = _ref5.j,
  19843. x = _ref5.x,
  19844. y = _ref5.y,
  19845. pX = _ref5.pX,
  19846. pY = _ref5.pY,
  19847. linePath = _ref5.linePath,
  19848. areaPath = _ref5.areaPath,
  19849. linePaths = _ref5.linePaths,
  19850. areaPaths = _ref5.areaPaths,
  19851. seriesIndex = _ref5.seriesIndex;
  19852. var w = this.w;
  19853. var graphics = new Graphics(this.ctx);
  19854. var curve = w.config.stroke.curve;
  19855. var areaBottomY = this.areaBottomY;
  19856. if (Array.isArray(w.config.stroke.curve)) {
  19857. if (Array.isArray(seriesIndex)) {
  19858. curve = w.config.stroke.curve[seriesIndex[i]];
  19859. } else {
  19860. curve = w.config.stroke.curve[i];
  19861. }
  19862. } // logic of smooth curve derived from chartist
  19863. // CREDITS: https://gionkunz.github.io/chartist-js/
  19864. if (curve === 'smooth') {
  19865. var length = (x - pX) * 0.35;
  19866. if (w.globals.hasNullValues) {
  19867. if (series[i][j] !== null) {
  19868. if (series[i][j + 1] !== null) {
  19869. linePath = graphics.move(pX, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y);
  19870. 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';
  19871. } else {
  19872. linePath = graphics.move(pX, pY);
  19873. areaPath = graphics.move(pX, pY) + 'z';
  19874. }
  19875. }
  19876. linePaths.push(linePath);
  19877. areaPaths.push(areaPath);
  19878. } else {
  19879. linePath = linePath + graphics.curve(pX + length, pY, x - length, y, x, y);
  19880. areaPath = areaPath + graphics.curve(pX + length, pY, x - length, y, x, y);
  19881. }
  19882. pX = x;
  19883. pY = y;
  19884. if (j === series[i].length - 2) {
  19885. // last loop, close path
  19886. areaPath = areaPath + graphics.curve(pX, pY, x, y, x, areaBottomY) + graphics.move(x, y) + 'z';
  19887. if (!w.globals.hasNullValues) {
  19888. linePaths.push(linePath);
  19889. areaPaths.push(areaPath);
  19890. }
  19891. }
  19892. } else {
  19893. if (series[i][j + 1] === null) {
  19894. linePath = linePath + graphics.move(x, y);
  19895. var numericOrCatX = w.globals.isXNumeric ? (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio : x - this.xDivision;
  19896. areaPath = areaPath + graphics.line(numericOrCatX, areaBottomY) + graphics.move(x, y) + 'z';
  19897. }
  19898. if (series[i][j] === null) {
  19899. linePath = linePath + graphics.move(x, y);
  19900. areaPath = areaPath + graphics.move(x, areaBottomY);
  19901. }
  19902. if (curve === 'stepline') {
  19903. linePath = linePath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  19904. areaPath = areaPath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  19905. } else if (curve === 'straight') {
  19906. linePath = linePath + graphics.line(x, y);
  19907. areaPath = areaPath + graphics.line(x, y);
  19908. }
  19909. if (j === series[i].length - 2) {
  19910. // last loop, close path
  19911. areaPath = areaPath + graphics.line(x, areaBottomY) + graphics.move(x, y) + 'z';
  19912. linePaths.push(linePath);
  19913. areaPaths.push(areaPath);
  19914. }
  19915. }
  19916. return {
  19917. linePaths: linePaths,
  19918. areaPaths: areaPaths,
  19919. pX: pX,
  19920. pY: pY,
  19921. linePath: linePath,
  19922. areaPath: areaPath
  19923. };
  19924. }
  19925. }, {
  19926. key: "handleNullDataPoints",
  19927. value: function handleNullDataPoints(series, pointsPos, i, j, realIndex) {
  19928. var w = this.w;
  19929. if (series[i][j] === null && w.config.markers.showNullDataPoints || series[i].length === 1) {
  19930. // fixes apexcharts.js#1282, #1252
  19931. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1, this.strokeWidth - w.config.markers.strokeWidth / 2, true);
  19932. if (elPointsWrap !== null) {
  19933. this.elPointsMain.add(elPointsWrap);
  19934. }
  19935. }
  19936. }
  19937. }]);
  19938. return Line;
  19939. }();
  19940. /*
  19941. * treemap-squarify.js - open source implementation of squarified treemaps
  19942. *
  19943. * Treemap Squared 0.5 - Treemap Charting library
  19944. *
  19945. * https://github.com/imranghory/treemap-squared/
  19946. *
  19947. * Copyright (c) 2012 Imran Ghory (imranghory@gmail.com)
  19948. * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
  19949. *
  19950. *
  19951. * Implementation of the squarify treemap algorithm described in:
  19952. *
  19953. * Bruls, Mark; Huizing, Kees; van Wijk, Jarke J. (2000), "Squarified treemaps"
  19954. * in de Leeuw, W.; van Liere, R., Data Visualization 2000:
  19955. * Proc. Joint Eurographics and IEEE TCVG Symp. on Visualization, Springer-Verlag, pp. 33–42.
  19956. *
  19957. * Paper is available online at: http://www.win.tue.nl/~vanwijk/stm.pdf
  19958. *
  19959. * The code in this file is completeley decoupled from the drawing code so it should be trivial
  19960. * to port it to any other vector drawing library. Given an array of datapoints this library returns
  19961. * an array of cartesian coordinates that represent the rectangles that make up the treemap.
  19962. *
  19963. * The library also supports multidimensional data (nested treemaps) and performs normalization on the data.
  19964. *
  19965. * See the README file for more details.
  19966. */
  19967. window.TreemapSquared = {};
  19968. (function () {
  19969. window.TreemapSquared.generate = function () {
  19970. function Container(xoffset, yoffset, width, height) {
  19971. this.xoffset = xoffset; // offset from the the top left hand corner
  19972. this.yoffset = yoffset; // ditto
  19973. this.height = height;
  19974. this.width = width;
  19975. this.shortestEdge = function () {
  19976. return Math.min(this.height, this.width);
  19977. }; // getCoordinates - for a row of boxes which we've placed
  19978. // return an array of their cartesian coordinates
  19979. this.getCoordinates = function (row) {
  19980. var coordinates = [];
  19981. var subxoffset = this.xoffset,
  19982. subyoffset = this.yoffset; //our offset within the container
  19983. var areawidth = sumArray(row) / this.height;
  19984. var areaheight = sumArray(row) / this.width;
  19985. var i;
  19986. if (this.width >= this.height) {
  19987. for (i = 0; i < row.length; i++) {
  19988. coordinates.push([subxoffset, subyoffset, subxoffset + areawidth, subyoffset + row[i] / areawidth]);
  19989. subyoffset = subyoffset + row[i] / areawidth;
  19990. }
  19991. } else {
  19992. for (i = 0; i < row.length; i++) {
  19993. coordinates.push([subxoffset, subyoffset, subxoffset + row[i] / areaheight, subyoffset + areaheight]);
  19994. subxoffset = subxoffset + row[i] / areaheight;
  19995. }
  19996. }
  19997. return coordinates;
  19998. }; // cutArea - once we've placed some boxes into an row we then need to identify the remaining area,
  19999. // this function takes the area of the boxes we've placed and calculates the location and
  20000. // dimensions of the remaining space and returns a container box defined by the remaining area
  20001. this.cutArea = function (area) {
  20002. var newcontainer;
  20003. if (this.width >= this.height) {
  20004. var areawidth = area / this.height;
  20005. var newwidth = this.width - areawidth;
  20006. newcontainer = new Container(this.xoffset + areawidth, this.yoffset, newwidth, this.height);
  20007. } else {
  20008. var areaheight = area / this.width;
  20009. var newheight = this.height - areaheight;
  20010. newcontainer = new Container(this.xoffset, this.yoffset + areaheight, this.width, newheight);
  20011. }
  20012. return newcontainer;
  20013. };
  20014. } // normalize - the Bruls algorithm assumes we're passing in areas that nicely fit into our
  20015. // container box, this method takes our raw data and normalizes the data values into
  20016. // area values so that this assumption is valid.
  20017. function normalize(data, area) {
  20018. var normalizeddata = [];
  20019. var sum = sumArray(data);
  20020. var multiplier = area / sum;
  20021. var i;
  20022. for (i = 0; i < data.length; i++) {
  20023. normalizeddata[i] = data[i] * multiplier;
  20024. }
  20025. return normalizeddata;
  20026. } // treemapMultidimensional - takes multidimensional data (aka [[23,11],[11,32]] - nested array)
  20027. // and recursively calls itself using treemapSingledimensional
  20028. // to create a patchwork of treemaps and merge them
  20029. function treemapMultidimensional(data, width, height, xoffset, yoffset) {
  20030. xoffset = typeof xoffset === 'undefined' ? 0 : xoffset;
  20031. yoffset = typeof yoffset === 'undefined' ? 0 : yoffset;
  20032. var mergeddata = [];
  20033. var mergedtreemap;
  20034. var results = [];
  20035. var i;
  20036. if (isArray(data[0])) {
  20037. // if we've got more dimensions of depth
  20038. for (i = 0; i < data.length; i++) {
  20039. mergeddata[i] = sumMultidimensionalArray(data[i]);
  20040. }
  20041. mergedtreemap = treemapSingledimensional(mergeddata, width, height, xoffset, yoffset);
  20042. for (i = 0; i < data.length; i++) {
  20043. results.push(treemapMultidimensional(data[i], mergedtreemap[i][2] - mergedtreemap[i][0], mergedtreemap[i][3] - mergedtreemap[i][1], mergedtreemap[i][0], mergedtreemap[i][1]));
  20044. }
  20045. } else {
  20046. results = treemapSingledimensional(data, width, height, xoffset, yoffset);
  20047. }
  20048. return results;
  20049. } // treemapSingledimensional - simple wrapper around squarify
  20050. function treemapSingledimensional(data, width, height, xoffset, yoffset) {
  20051. xoffset = typeof xoffset === 'undefined' ? 0 : xoffset;
  20052. yoffset = typeof yoffset === 'undefined' ? 0 : yoffset;
  20053. var rawtreemap = squarify(normalize(data, width * height), [], new Container(xoffset, yoffset, width, height), []);
  20054. return flattenTreemap(rawtreemap);
  20055. } // flattenTreemap - squarify implementation returns an array of arrays of coordinates
  20056. // because we have a new array everytime we switch to building a new row
  20057. // this converts it into an array of coordinates.
  20058. function flattenTreemap(rawtreemap) {
  20059. var flattreemap = [];
  20060. var i, j;
  20061. for (i = 0; i < rawtreemap.length; i++) {
  20062. for (j = 0; j < rawtreemap[i].length; j++) {
  20063. flattreemap.push(rawtreemap[i][j]);
  20064. }
  20065. }
  20066. return flattreemap;
  20067. } // squarify - as per the Bruls paper
  20068. // plus coordinates stack and containers so we get
  20069. // usable data out of it
  20070. function squarify(data, currentrow, container, stack) {
  20071. var length;
  20072. var nextdatapoint;
  20073. var newcontainer;
  20074. if (data.length === 0) {
  20075. stack.push(container.getCoordinates(currentrow));
  20076. return;
  20077. }
  20078. length = container.shortestEdge();
  20079. nextdatapoint = data[0];
  20080. if (improvesRatio(currentrow, nextdatapoint, length)) {
  20081. currentrow.push(nextdatapoint);
  20082. squarify(data.slice(1), currentrow, container, stack);
  20083. } else {
  20084. newcontainer = container.cutArea(sumArray(currentrow), stack);
  20085. stack.push(container.getCoordinates(currentrow));
  20086. squarify(data, [], newcontainer, stack);
  20087. }
  20088. return stack;
  20089. } // improveRatio - implements the worse calculation and comparision as given in Bruls
  20090. // (note the error in the original paper; fixed here)
  20091. function improvesRatio(currentrow, nextnode, length) {
  20092. var newrow;
  20093. if (currentrow.length === 0) {
  20094. return true;
  20095. }
  20096. newrow = currentrow.slice();
  20097. newrow.push(nextnode);
  20098. var currentratio = calculateRatio(currentrow, length);
  20099. var newratio = calculateRatio(newrow, length); // the pseudocode in the Bruls paper has the direction of the comparison
  20100. // wrong, this is the correct one.
  20101. return currentratio >= newratio;
  20102. } // calculateRatio - calculates the maximum width to height ratio of the
  20103. // boxes in this row
  20104. function calculateRatio(row, length) {
  20105. var min = Math.min.apply(Math, row);
  20106. var max = Math.max.apply(Math, row);
  20107. var sum = sumArray(row);
  20108. return Math.max(Math.pow(length, 2) * max / Math.pow(sum, 2), Math.pow(sum, 2) / (Math.pow(length, 2) * min));
  20109. } // isArray - checks if arr is an array
  20110. function isArray(arr) {
  20111. return arr && arr.constructor === Array;
  20112. } // sumArray - sums a single dimensional array
  20113. function sumArray(arr) {
  20114. var sum = 0;
  20115. var i;
  20116. for (i = 0; i < arr.length; i++) {
  20117. sum += arr[i];
  20118. }
  20119. return sum;
  20120. } // sumMultidimensionalArray - sums the values in a nested array (aka [[0,1],[[2,3]]])
  20121. function sumMultidimensionalArray(arr) {
  20122. var i,
  20123. total = 0;
  20124. if (isArray(arr[0])) {
  20125. for (i = 0; i < arr.length; i++) {
  20126. total += sumMultidimensionalArray(arr[i]);
  20127. }
  20128. } else {
  20129. total = sumArray(arr);
  20130. }
  20131. return total;
  20132. }
  20133. return treemapMultidimensional;
  20134. }();
  20135. })();
  20136. /**
  20137. * ApexCharts TreemapChart Class.
  20138. * @module TreemapChart
  20139. **/
  20140. var TreemapChart = /*#__PURE__*/function () {
  20141. function TreemapChart(ctx, xyRatios) {
  20142. _classCallCheck(this, TreemapChart);
  20143. this.ctx = ctx;
  20144. this.w = ctx.w;
  20145. this.strokeWidth = this.w.config.stroke.width;
  20146. this.helpers = new TreemapHelpers(ctx);
  20147. this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation;
  20148. this.labels = [];
  20149. }
  20150. _createClass(TreemapChart, [{
  20151. key: "draw",
  20152. value: function draw(series) {
  20153. var _this = this;
  20154. var w = this.w;
  20155. var graphics = new Graphics(this.ctx);
  20156. var fill = new Fill(this.ctx);
  20157. var ret = graphics.group({
  20158. class: 'apexcharts-treemap'
  20159. });
  20160. if (w.globals.noData) return ret;
  20161. var ser = [];
  20162. series.forEach(function (s) {
  20163. var d = s.map(function (v) {
  20164. return Math.abs(v);
  20165. });
  20166. ser.push(d);
  20167. });
  20168. this.negRange = this.helpers.checkColorRange();
  20169. w.config.series.forEach(function (s, i) {
  20170. s.data.forEach(function (l) {
  20171. if (!Array.isArray(_this.labels[i])) _this.labels[i] = [];
  20172. _this.labels[i].push(l.x);
  20173. });
  20174. });
  20175. var nodes = window.TreemapSquared.generate(ser, w.globals.gridWidth, w.globals.gridHeight);
  20176. nodes.forEach(function (node, i) {
  20177. var elSeries = graphics.group({
  20178. class: "apexcharts-series apexcharts-treemap-series",
  20179. seriesName: Utils$1.escapeString(w.globals.seriesNames[i]),
  20180. rel: i + 1,
  20181. 'data:realIndex': i
  20182. });
  20183. if (w.config.chart.dropShadow.enabled) {
  20184. var shadow = w.config.chart.dropShadow;
  20185. var filters = new Filters(_this.ctx);
  20186. filters.dropShadow(ret, shadow, i);
  20187. }
  20188. var elDataLabelWrap = graphics.group({
  20189. class: 'apexcharts-data-labels'
  20190. });
  20191. node.forEach(function (r, j) {
  20192. var x1 = r[0];
  20193. var y1 = r[1];
  20194. var x2 = r[2];
  20195. var y2 = r[3];
  20196. var elRect = graphics.drawRect(x1, y1, x2 - x1, y2 - y1, 0, '#fff', 1, _this.strokeWidth, w.config.plotOptions.treemap.useFillColorAsStroke ? color : w.globals.stroke.colors[i]);
  20197. elRect.attr({
  20198. cx: x1,
  20199. cy: y1,
  20200. index: i,
  20201. i: i,
  20202. j: j,
  20203. width: x2 - x1,
  20204. height: y2 - y1
  20205. });
  20206. var colorProps = _this.helpers.getShadeColor(w.config.chart.type, i, j, _this.negRange);
  20207. var color = colorProps.color;
  20208. if (typeof w.config.series[i].data[j] !== 'undefined' && w.config.series[i].data[j].fillColor) {
  20209. color = w.config.series[i].data[j].fillColor;
  20210. }
  20211. var pathFill = fill.fillPath({
  20212. color: color,
  20213. seriesNumber: i,
  20214. dataPointIndex: j
  20215. });
  20216. elRect.node.classList.add('apexcharts-treemap-rect');
  20217. elRect.attr({
  20218. fill: pathFill
  20219. });
  20220. _this.helpers.addListeners(elRect);
  20221. var fromRect = {
  20222. x: x1 + (x2 - x1) / 2,
  20223. y: y1 + (y2 - y1) / 2,
  20224. width: 0,
  20225. height: 0
  20226. };
  20227. var toRect = {
  20228. x: x1,
  20229. y: y1,
  20230. width: x2 - x1,
  20231. height: y2 - y1
  20232. };
  20233. if (w.config.chart.animations.enabled && !w.globals.dataChanged) {
  20234. var speed = 1;
  20235. if (!w.globals.resized) {
  20236. speed = w.config.chart.animations.speed;
  20237. }
  20238. _this.animateTreemap(elRect, fromRect, toRect, speed);
  20239. }
  20240. if (w.globals.dataChanged) {
  20241. var _speed = 1;
  20242. if (_this.dynamicAnim.enabled && w.globals.shouldAnimate) {
  20243. _speed = _this.dynamicAnim.speed;
  20244. if (w.globals.previousPaths[i] && w.globals.previousPaths[i][j] && w.globals.previousPaths[i][j].rect) {
  20245. fromRect = w.globals.previousPaths[i][j].rect;
  20246. }
  20247. _this.animateTreemap(elRect, fromRect, toRect, _speed);
  20248. }
  20249. }
  20250. var fontSize = _this.getFontSize(r);
  20251. var formattedText = w.config.dataLabels.formatter(_this.labels[i][j], {
  20252. value: w.globals.series[i][j],
  20253. seriesIndex: i,
  20254. dataPointIndex: j,
  20255. w: w
  20256. });
  20257. var dataLabels = _this.helpers.calculateDataLabels({
  20258. text: formattedText,
  20259. x: (x1 + x2) / 2,
  20260. y: (y1 + y2) / 2 + _this.strokeWidth / 2 + fontSize / 3,
  20261. i: i,
  20262. j: j,
  20263. colorProps: colorProps,
  20264. fontSize: fontSize,
  20265. series: series
  20266. });
  20267. if (w.config.dataLabels.enabled && dataLabels) {
  20268. _this.rotateToFitLabel(dataLabels, formattedText, x1, y1, x2, y2);
  20269. }
  20270. elSeries.add(elRect);
  20271. if (dataLabels !== null) {
  20272. elSeries.add(dataLabels);
  20273. }
  20274. });
  20275. elSeries.add(elDataLabelWrap);
  20276. ret.add(elSeries);
  20277. });
  20278. return ret;
  20279. } // This calculates a font-size based upon
  20280. // average label length and the size of the box the label is
  20281. // going into. The maximum font size is set in chart config.
  20282. }, {
  20283. key: "getFontSize",
  20284. value: function getFontSize(coordinates) {
  20285. var w = this.w; // total length of labels (i.e [["Italy"],["Spain", "Greece"]] -> 16)
  20286. function totalLabelLength(arr) {
  20287. var i,
  20288. total = 0;
  20289. if (Array.isArray(arr[0])) {
  20290. for (i = 0; i < arr.length; i++) {
  20291. total += totalLabelLength(arr[i]);
  20292. }
  20293. } else {
  20294. for (i = 0; i < arr.length; i++) {
  20295. total += arr[i].length;
  20296. }
  20297. }
  20298. return total;
  20299. } // count of labels (i.e [["Italy"],["Spain", "Greece"]] -> 3)
  20300. function countLabels(arr) {
  20301. var i,
  20302. total = 0;
  20303. if (Array.isArray(arr[0])) {
  20304. for (i = 0; i < arr.length; i++) {
  20305. total += countLabels(arr[i]);
  20306. }
  20307. } else {
  20308. for (i = 0; i < arr.length; i++) {
  20309. total += 1;
  20310. }
  20311. }
  20312. return total;
  20313. }
  20314. var averagelabelsize = totalLabelLength(this.labels) / countLabels(this.labels);
  20315. function fontSize(width, height) {
  20316. // the font size should be proportional to the size of the box (and the value)
  20317. // otherwise you can end up creating a visual distortion where two boxes of identical
  20318. // size have different sized labels, and thus make it look as if the two boxes
  20319. // represent different sizes
  20320. var area = width * height;
  20321. var arearoot = Math.pow(area, 0.5);
  20322. return Math.min(arearoot / averagelabelsize, parseInt(w.config.dataLabels.style.fontSize, 10));
  20323. }
  20324. return fontSize(coordinates[2] - coordinates[0], coordinates[3] - coordinates[1]);
  20325. }
  20326. }, {
  20327. key: "rotateToFitLabel",
  20328. value: function rotateToFitLabel(elText, text, x1, y1, x2, y2) {
  20329. var graphics = new Graphics(this.ctx);
  20330. var textRect = graphics.getTextRects(text); //if the label fits better sideways then rotate it
  20331. if (textRect.width + 5 > x2 - x1 && textRect.width <= y2 - y1) {
  20332. var labelRotatingCenter = graphics.rotateAroundCenter(elText.node);
  20333. elText.node.setAttribute('transform', "rotate(-90 ".concat(labelRotatingCenter.x, " ").concat(labelRotatingCenter.y, ")"));
  20334. }
  20335. }
  20336. }, {
  20337. key: "animateTreemap",
  20338. value: function animateTreemap(el, fromRect, toRect, speed) {
  20339. var animations = new Animations(this.ctx);
  20340. animations.animateRect(el, {
  20341. x: fromRect.x,
  20342. y: fromRect.y,
  20343. width: fromRect.width,
  20344. height: fromRect.height
  20345. }, {
  20346. x: toRect.x,
  20347. y: toRect.y,
  20348. width: toRect.width,
  20349. height: toRect.height
  20350. }, speed, function () {
  20351. animations.animationCompleted(el);
  20352. });
  20353. }
  20354. }]);
  20355. return TreemapChart;
  20356. }();
  20357. var MINUTES_IN_DAY = 24 * 60;
  20358. var SECONDS_IN_DAY = MINUTES_IN_DAY * 60;
  20359. var MIN_ZOOM_DAYS = 10 / SECONDS_IN_DAY;
  20360. /**
  20361. * ApexCharts TimeScale Class for generating time ticks for x-axis.
  20362. *
  20363. * @module TimeScale
  20364. **/
  20365. var TimeScale = /*#__PURE__*/function () {
  20366. function TimeScale(ctx) {
  20367. _classCallCheck(this, TimeScale);
  20368. this.ctx = ctx;
  20369. this.w = ctx.w;
  20370. this.timeScaleArray = [];
  20371. this.utc = this.w.config.xaxis.labels.datetimeUTC;
  20372. }
  20373. _createClass(TimeScale, [{
  20374. key: "calculateTimeScaleTicks",
  20375. value: function calculateTimeScaleTicks(minX, maxX) {
  20376. var _this = this;
  20377. var w = this.w; // null check when no series to show
  20378. if (w.globals.allSeriesCollapsed) {
  20379. w.globals.labels = [];
  20380. w.globals.timescaleLabels = [];
  20381. return [];
  20382. }
  20383. var dt = new DateTime(this.ctx);
  20384. var daysDiff = (maxX - minX) / (1000 * SECONDS_IN_DAY);
  20385. this.determineInterval(daysDiff);
  20386. w.globals.disableZoomIn = false;
  20387. w.globals.disableZoomOut = false;
  20388. if (daysDiff < MIN_ZOOM_DAYS) {
  20389. w.globals.disableZoomIn = true;
  20390. } else if (daysDiff > 50000) {
  20391. w.globals.disableZoomOut = true;
  20392. }
  20393. var timeIntervals = dt.getTimeUnitsfromTimestamp(minX, maxX, this.utc);
  20394. var daysWidthOnXAxis = w.globals.gridWidth / daysDiff;
  20395. var hoursWidthOnXAxis = daysWidthOnXAxis / 24;
  20396. var minutesWidthOnXAxis = hoursWidthOnXAxis / 60;
  20397. var secondsWidthOnXAxis = minutesWidthOnXAxis / 60;
  20398. var numberOfHours = Math.floor(daysDiff * 24);
  20399. var numberOfMinutes = Math.floor(daysDiff * MINUTES_IN_DAY);
  20400. var numberOfSeconds = Math.floor(daysDiff * SECONDS_IN_DAY);
  20401. var numberOfDays = Math.floor(daysDiff);
  20402. var numberOfMonths = Math.floor(daysDiff / 30);
  20403. var numberOfYears = Math.floor(daysDiff / 365);
  20404. var firstVal = {
  20405. minMillisecond: timeIntervals.minMillisecond,
  20406. minSecond: timeIntervals.minSecond,
  20407. minMinute: timeIntervals.minMinute,
  20408. minHour: timeIntervals.minHour,
  20409. minDate: timeIntervals.minDate,
  20410. minMonth: timeIntervals.minMonth,
  20411. minYear: timeIntervals.minYear
  20412. };
  20413. var currentMillisecond = firstVal.minMillisecond;
  20414. var currentSecond = firstVal.minSecond;
  20415. var currentMinute = firstVal.minMinute;
  20416. var currentHour = firstVal.minHour;
  20417. var currentMonthDate = firstVal.minDate;
  20418. var currentDate = firstVal.minDate;
  20419. var currentMonth = firstVal.minMonth;
  20420. var currentYear = firstVal.minYear;
  20421. var params = {
  20422. firstVal: firstVal,
  20423. currentMillisecond: currentMillisecond,
  20424. currentSecond: currentSecond,
  20425. currentMinute: currentMinute,
  20426. currentHour: currentHour,
  20427. currentMonthDate: currentMonthDate,
  20428. currentDate: currentDate,
  20429. currentMonth: currentMonth,
  20430. currentYear: currentYear,
  20431. daysWidthOnXAxis: daysWidthOnXAxis,
  20432. hoursWidthOnXAxis: hoursWidthOnXAxis,
  20433. minutesWidthOnXAxis: minutesWidthOnXAxis,
  20434. secondsWidthOnXAxis: secondsWidthOnXAxis,
  20435. numberOfSeconds: numberOfSeconds,
  20436. numberOfMinutes: numberOfMinutes,
  20437. numberOfHours: numberOfHours,
  20438. numberOfDays: numberOfDays,
  20439. numberOfMonths: numberOfMonths,
  20440. numberOfYears: numberOfYears
  20441. };
  20442. switch (this.tickInterval) {
  20443. case 'years':
  20444. {
  20445. this.generateYearScale(params);
  20446. break;
  20447. }
  20448. case 'months':
  20449. case 'half_year':
  20450. {
  20451. this.generateMonthScale(params);
  20452. break;
  20453. }
  20454. case 'months_days':
  20455. case 'months_fortnight':
  20456. case 'days':
  20457. case 'week_days':
  20458. {
  20459. this.generateDayScale(params);
  20460. break;
  20461. }
  20462. case 'hours':
  20463. {
  20464. this.generateHourScale(params);
  20465. break;
  20466. }
  20467. case 'minutes_fives':
  20468. case 'minutes':
  20469. this.generateMinuteScale(params);
  20470. break;
  20471. case 'seconds_tens':
  20472. case 'seconds_fives':
  20473. case 'seconds':
  20474. this.generateSecondScale(params);
  20475. break;
  20476. } // first, we will adjust the month values index
  20477. // as in the upper function, it is starting from 0
  20478. // we will start them from 1
  20479. var adjustedMonthInTimeScaleArray = this.timeScaleArray.map(function (ts) {
  20480. var defaultReturn = {
  20481. position: ts.position,
  20482. unit: ts.unit,
  20483. year: ts.year,
  20484. day: ts.day ? ts.day : 1,
  20485. hour: ts.hour ? ts.hour : 0,
  20486. month: ts.month + 1
  20487. };
  20488. if (ts.unit === 'month') {
  20489. return _objectSpread2(_objectSpread2({}, defaultReturn), {}, {
  20490. day: 1,
  20491. value: ts.value + 1
  20492. });
  20493. } else if (ts.unit === 'day' || ts.unit === 'hour') {
  20494. return _objectSpread2(_objectSpread2({}, defaultReturn), {}, {
  20495. value: ts.value
  20496. });
  20497. } else if (ts.unit === 'minute') {
  20498. return _objectSpread2(_objectSpread2({}, defaultReturn), {}, {
  20499. value: ts.value,
  20500. minute: ts.value
  20501. });
  20502. } else if (ts.unit === 'second') {
  20503. return _objectSpread2(_objectSpread2({}, defaultReturn), {}, {
  20504. value: ts.value,
  20505. minute: ts.minute,
  20506. second: ts.second
  20507. });
  20508. }
  20509. return ts;
  20510. });
  20511. var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts) {
  20512. var modulo = 1;
  20513. var ticks = Math.ceil(w.globals.gridWidth / 120);
  20514. var value = ts.value;
  20515. if (w.config.xaxis.tickAmount !== undefined) {
  20516. ticks = w.config.xaxis.tickAmount;
  20517. }
  20518. if (adjustedMonthInTimeScaleArray.length > ticks) {
  20519. modulo = Math.floor(adjustedMonthInTimeScaleArray.length / ticks);
  20520. }
  20521. var shouldNotSkipUnit = false; // there is a big change in unit i.e days to months
  20522. var shouldNotPrint = false; // should skip these values
  20523. switch (_this.tickInterval) {
  20524. case 'years':
  20525. // make years label denser
  20526. if (ts.unit === 'year') {
  20527. shouldNotSkipUnit = true;
  20528. }
  20529. break;
  20530. case 'half_year':
  20531. modulo = 7;
  20532. if (ts.unit === 'year') {
  20533. shouldNotSkipUnit = true;
  20534. }
  20535. break;
  20536. case 'months':
  20537. modulo = 1;
  20538. if (ts.unit === 'year') {
  20539. shouldNotSkipUnit = true;
  20540. }
  20541. break;
  20542. case 'months_fortnight':
  20543. modulo = 15;
  20544. if (ts.unit === 'year' || ts.unit === 'month') {
  20545. shouldNotSkipUnit = true;
  20546. }
  20547. if (value === 30) {
  20548. shouldNotPrint = true;
  20549. }
  20550. break;
  20551. case 'months_days':
  20552. modulo = 10;
  20553. if (ts.unit === 'month') {
  20554. shouldNotSkipUnit = true;
  20555. }
  20556. if (value === 30) {
  20557. shouldNotPrint = true;
  20558. }
  20559. break;
  20560. case 'week_days':
  20561. modulo = 8;
  20562. if (ts.unit === 'month') {
  20563. shouldNotSkipUnit = true;
  20564. }
  20565. break;
  20566. case 'days':
  20567. modulo = 1;
  20568. if (ts.unit === 'month') {
  20569. shouldNotSkipUnit = true;
  20570. }
  20571. break;
  20572. case 'hours':
  20573. if (ts.unit === 'day') {
  20574. shouldNotSkipUnit = true;
  20575. }
  20576. break;
  20577. case 'minutes_fives':
  20578. if (value % 5 !== 0) {
  20579. shouldNotPrint = true;
  20580. }
  20581. break;
  20582. case 'seconds_tens':
  20583. if (value % 10 !== 0) {
  20584. shouldNotPrint = true;
  20585. }
  20586. break;
  20587. case 'seconds_fives':
  20588. if (value % 5 !== 0) {
  20589. shouldNotPrint = true;
  20590. }
  20591. break;
  20592. }
  20593. if (_this.tickInterval === 'hours' || _this.tickInterval === 'minutes_fives' || _this.tickInterval === 'seconds_tens' || _this.tickInterval === 'seconds_fives') {
  20594. if (!shouldNotPrint) {
  20595. return true;
  20596. }
  20597. } else {
  20598. if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) {
  20599. return true;
  20600. }
  20601. }
  20602. });
  20603. return filteredTimeScale;
  20604. }
  20605. }, {
  20606. key: "recalcDimensionsBasedOnFormat",
  20607. value: function recalcDimensionsBasedOnFormat(filteredTimeScale, inverted) {
  20608. var w = this.w;
  20609. var reformattedTimescaleArray = this.formatDates(filteredTimeScale);
  20610. var removedOverlappingTS = this.removeOverlappingTS(reformattedTimescaleArray);
  20611. 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
  20612. // 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
  20613. // Dependency on Dimensions(), need to refactor correctly
  20614. // TODO - find an alternate way to avoid calling this Heavy method twice
  20615. var dimensions = new Dimensions(this.ctx);
  20616. dimensions.plotCoords();
  20617. }
  20618. }, {
  20619. key: "determineInterval",
  20620. value: function determineInterval(daysDiff) {
  20621. var yearsDiff = daysDiff / 365;
  20622. var hoursDiff = daysDiff * 24;
  20623. var minutesDiff = hoursDiff * 60;
  20624. var secondsDiff = minutesDiff * 60;
  20625. switch (true) {
  20626. case yearsDiff > 5:
  20627. this.tickInterval = 'years';
  20628. break;
  20629. case daysDiff > 800:
  20630. this.tickInterval = 'half_year';
  20631. break;
  20632. case daysDiff > 180:
  20633. this.tickInterval = 'months';
  20634. break;
  20635. case daysDiff > 90:
  20636. this.tickInterval = 'months_fortnight';
  20637. break;
  20638. case daysDiff > 60:
  20639. this.tickInterval = 'months_days';
  20640. break;
  20641. case daysDiff > 30:
  20642. this.tickInterval = 'week_days';
  20643. break;
  20644. case daysDiff > 2:
  20645. this.tickInterval = 'days';
  20646. break;
  20647. case hoursDiff > 2.4:
  20648. this.tickInterval = 'hours';
  20649. break;
  20650. case minutesDiff > 15:
  20651. this.tickInterval = 'minutes_fives';
  20652. break;
  20653. case minutesDiff > 5:
  20654. this.tickInterval = 'minutes';
  20655. break;
  20656. case minutesDiff > 1:
  20657. this.tickInterval = 'seconds_tens';
  20658. break;
  20659. case secondsDiff > 20:
  20660. this.tickInterval = 'seconds_fives';
  20661. break;
  20662. default:
  20663. this.tickInterval = 'seconds';
  20664. break;
  20665. }
  20666. }
  20667. }, {
  20668. key: "generateYearScale",
  20669. value: function generateYearScale(_ref) {
  20670. var firstVal = _ref.firstVal,
  20671. currentMonth = _ref.currentMonth,
  20672. currentYear = _ref.currentYear,
  20673. daysWidthOnXAxis = _ref.daysWidthOnXAxis,
  20674. numberOfYears = _ref.numberOfYears;
  20675. var firstTickValue = firstVal.minYear;
  20676. var firstTickPosition = 0;
  20677. var dt = new DateTime(this.ctx);
  20678. var unit = 'year';
  20679. if (firstVal.minDate > 1 || firstVal.minMonth > 0) {
  20680. var remainingDays = dt.determineRemainingDaysOfYear(firstVal.minYear, firstVal.minMonth, firstVal.minDate); // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  20681. var remainingDaysOfFirstYear = dt.determineDaysOfYear(firstVal.minYear) - remainingDays + 1; // calculate the first tick position
  20682. firstTickPosition = remainingDaysOfFirstYear * daysWidthOnXAxis;
  20683. firstTickValue = firstVal.minYear + 1; // push the first tick in the array
  20684. this.timeScaleArray.push({
  20685. position: firstTickPosition,
  20686. value: firstTickValue,
  20687. unit: unit,
  20688. year: firstTickValue,
  20689. month: Utils$1.monthMod(currentMonth + 1)
  20690. });
  20691. } else if (firstVal.minDate === 1 && firstVal.minMonth === 0) {
  20692. // push the first tick in the array
  20693. this.timeScaleArray.push({
  20694. position: firstTickPosition,
  20695. value: firstTickValue,
  20696. unit: unit,
  20697. year: currentYear,
  20698. month: Utils$1.monthMod(currentMonth + 1)
  20699. });
  20700. }
  20701. var year = firstTickValue;
  20702. var pos = firstTickPosition; // keep drawing rest of the ticks
  20703. for (var i = 0; i < numberOfYears; i++) {
  20704. year++;
  20705. pos = dt.determineDaysOfYear(year - 1) * daysWidthOnXAxis + pos;
  20706. this.timeScaleArray.push({
  20707. position: pos,
  20708. value: year,
  20709. unit: unit,
  20710. year: year,
  20711. month: 1
  20712. });
  20713. }
  20714. }
  20715. }, {
  20716. key: "generateMonthScale",
  20717. value: function generateMonthScale(_ref2) {
  20718. var firstVal = _ref2.firstVal,
  20719. currentMonthDate = _ref2.currentMonthDate,
  20720. currentMonth = _ref2.currentMonth,
  20721. currentYear = _ref2.currentYear,
  20722. daysWidthOnXAxis = _ref2.daysWidthOnXAxis,
  20723. numberOfMonths = _ref2.numberOfMonths;
  20724. var firstTickValue = currentMonth;
  20725. var firstTickPosition = 0;
  20726. var dt = new DateTime(this.ctx);
  20727. var unit = 'month';
  20728. var yrCounter = 0;
  20729. if (firstVal.minDate > 1) {
  20730. // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  20731. var remainingDaysOfFirstMonth = dt.determineDaysOfMonths(currentMonth + 1, firstVal.minYear) - currentMonthDate + 1; // calculate the first tick position
  20732. firstTickPosition = remainingDaysOfFirstMonth * daysWidthOnXAxis;
  20733. firstTickValue = Utils$1.monthMod(currentMonth + 1);
  20734. var year = currentYear + yrCounter;
  20735. var _month = Utils$1.monthMod(firstTickValue);
  20736. var value = firstTickValue; // it's Jan, so update the year
  20737. if (firstTickValue === 0) {
  20738. unit = 'year';
  20739. value = year;
  20740. _month = 1;
  20741. yrCounter += 1;
  20742. year = year + yrCounter;
  20743. } // push the first tick in the array
  20744. this.timeScaleArray.push({
  20745. position: firstTickPosition,
  20746. value: value,
  20747. unit: unit,
  20748. year: year,
  20749. month: _month
  20750. });
  20751. } else {
  20752. // push the first tick in the array
  20753. this.timeScaleArray.push({
  20754. position: firstTickPosition,
  20755. value: firstTickValue,
  20756. unit: unit,
  20757. year: currentYear,
  20758. month: Utils$1.monthMod(currentMonth)
  20759. });
  20760. }
  20761. var month = firstTickValue + 1;
  20762. var pos = firstTickPosition; // keep drawing rest of the ticks
  20763. for (var i = 0, j = 1; i < numberOfMonths; i++, j++) {
  20764. month = Utils$1.monthMod(month);
  20765. if (month === 0) {
  20766. unit = 'year';
  20767. yrCounter += 1;
  20768. } else {
  20769. unit = 'month';
  20770. }
  20771. var _year = this._getYear(currentYear, month, yrCounter);
  20772. pos = dt.determineDaysOfMonths(month, _year) * daysWidthOnXAxis + pos;
  20773. var monthVal = month === 0 ? _year : month;
  20774. this.timeScaleArray.push({
  20775. position: pos,
  20776. value: monthVal,
  20777. unit: unit,
  20778. year: _year,
  20779. month: month === 0 ? 1 : month
  20780. });
  20781. month++;
  20782. }
  20783. }
  20784. }, {
  20785. key: "generateDayScale",
  20786. value: function generateDayScale(_ref3) {
  20787. var firstVal = _ref3.firstVal,
  20788. currentMonth = _ref3.currentMonth,
  20789. currentYear = _ref3.currentYear,
  20790. hoursWidthOnXAxis = _ref3.hoursWidthOnXAxis,
  20791. numberOfDays = _ref3.numberOfDays;
  20792. var dt = new DateTime(this.ctx);
  20793. var unit = 'day';
  20794. var firstTickValue = firstVal.minDate + 1;
  20795. var date = firstTickValue;
  20796. var changeMonth = function changeMonth(dateVal, month, year) {
  20797. var monthdays = dt.determineDaysOfMonths(month + 1, year);
  20798. if (dateVal > monthdays) {
  20799. month = month + 1;
  20800. date = 1;
  20801. unit = 'month';
  20802. val = month;
  20803. return month;
  20804. }
  20805. return month;
  20806. };
  20807. var remainingHours = 24 - firstVal.minHour;
  20808. var yrCounter = 0; // calculate the first tick position
  20809. var firstTickPosition = remainingHours * hoursWidthOnXAxis;
  20810. var val = firstTickValue;
  20811. var month = changeMonth(date, currentMonth, currentYear);
  20812. if (firstVal.minHour === 0 && firstVal.minDate === 1) {
  20813. // the first value is the first day of month
  20814. firstTickPosition = 0;
  20815. val = Utils$1.monthMod(firstVal.minMonth);
  20816. unit = 'month';
  20817. date = firstVal.minDate;
  20818. numberOfDays++;
  20819. } else if (firstVal.minDate !== 1 && firstVal.minHour === 0 && firstVal.minMinute === 0) {
  20820. // fixes apexcharts/apexcharts.js/issues/1730
  20821. firstTickPosition = 0;
  20822. firstTickValue = firstVal.minDate;
  20823. date = firstTickValue;
  20824. val = firstTickValue; // in case it's the last date of month, we need to check it
  20825. month = changeMonth(date, currentMonth, currentYear);
  20826. } // push the first tick in the array
  20827. this.timeScaleArray.push({
  20828. position: firstTickPosition,
  20829. value: val,
  20830. unit: unit,
  20831. year: this._getYear(currentYear, month, yrCounter),
  20832. month: Utils$1.monthMod(month),
  20833. day: date
  20834. });
  20835. var pos = firstTickPosition; // keep drawing rest of the ticks
  20836. for (var i = 0; i < numberOfDays; i++) {
  20837. date += 1;
  20838. unit = 'day';
  20839. month = changeMonth(date, month, this._getYear(currentYear, month, yrCounter));
  20840. var year = this._getYear(currentYear, month, yrCounter);
  20841. pos = 24 * hoursWidthOnXAxis + pos;
  20842. var value = date === 1 ? Utils$1.monthMod(month) : date;
  20843. this.timeScaleArray.push({
  20844. position: pos,
  20845. value: value,
  20846. unit: unit,
  20847. year: year,
  20848. month: Utils$1.monthMod(month),
  20849. day: value
  20850. });
  20851. }
  20852. }
  20853. }, {
  20854. key: "generateHourScale",
  20855. value: function generateHourScale(_ref4) {
  20856. var firstVal = _ref4.firstVal,
  20857. currentDate = _ref4.currentDate,
  20858. currentMonth = _ref4.currentMonth,
  20859. currentYear = _ref4.currentYear,
  20860. minutesWidthOnXAxis = _ref4.minutesWidthOnXAxis,
  20861. numberOfHours = _ref4.numberOfHours;
  20862. var dt = new DateTime(this.ctx);
  20863. var yrCounter = 0;
  20864. var unit = 'hour';
  20865. var changeDate = function changeDate(dateVal, month) {
  20866. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  20867. if (dateVal > monthdays) {
  20868. date = 1;
  20869. month = month + 1;
  20870. }
  20871. return {
  20872. month: month,
  20873. date: date
  20874. };
  20875. };
  20876. var changeMonth = function changeMonth(dateVal, month) {
  20877. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  20878. if (dateVal > monthdays) {
  20879. month = month + 1;
  20880. return month;
  20881. }
  20882. return month;
  20883. }; // factor in minSeconds as well
  20884. var remainingMins = 60 - (firstVal.minMinute + firstVal.minSecond / 60.0);
  20885. var firstTickPosition = remainingMins * minutesWidthOnXAxis;
  20886. var firstTickValue = firstVal.minHour + 1;
  20887. var hour = firstTickValue + 1;
  20888. if (remainingMins === 60) {
  20889. firstTickPosition = 0;
  20890. firstTickValue = firstVal.minHour;
  20891. hour = firstTickValue + 1;
  20892. }
  20893. var date = currentDate;
  20894. var month = changeMonth(date, currentMonth); // push the first tick in the array
  20895. this.timeScaleArray.push({
  20896. position: firstTickPosition,
  20897. value: firstTickValue,
  20898. unit: unit,
  20899. day: date,
  20900. hour: hour,
  20901. year: currentYear,
  20902. month: Utils$1.monthMod(month)
  20903. });
  20904. var pos = firstTickPosition; // keep drawing rest of the ticks
  20905. for (var i = 0; i < numberOfHours; i++) {
  20906. unit = 'hour';
  20907. if (hour >= 24) {
  20908. hour = 0;
  20909. date += 1;
  20910. unit = 'day';
  20911. var checkNextMonth = changeDate(date, month);
  20912. month = checkNextMonth.month;
  20913. month = changeMonth(date, month);
  20914. }
  20915. var year = this._getYear(currentYear, month, yrCounter);
  20916. pos = hour === 0 && i === 0 ? remainingMins * minutesWidthOnXAxis : 60 * minutesWidthOnXAxis + pos;
  20917. var val = hour === 0 ? date : hour;
  20918. this.timeScaleArray.push({
  20919. position: pos,
  20920. value: val,
  20921. unit: unit,
  20922. hour: hour,
  20923. day: date,
  20924. year: year,
  20925. month: Utils$1.monthMod(month)
  20926. });
  20927. hour++;
  20928. }
  20929. }
  20930. }, {
  20931. key: "generateMinuteScale",
  20932. value: function generateMinuteScale(_ref5) {
  20933. var currentMillisecond = _ref5.currentMillisecond,
  20934. currentSecond = _ref5.currentSecond,
  20935. currentMinute = _ref5.currentMinute,
  20936. currentHour = _ref5.currentHour,
  20937. currentDate = _ref5.currentDate,
  20938. currentMonth = _ref5.currentMonth,
  20939. currentYear = _ref5.currentYear,
  20940. minutesWidthOnXAxis = _ref5.minutesWidthOnXAxis,
  20941. secondsWidthOnXAxis = _ref5.secondsWidthOnXAxis,
  20942. numberOfMinutes = _ref5.numberOfMinutes;
  20943. var yrCounter = 0;
  20944. var unit = 'minute';
  20945. var remainingSecs = 60 - currentSecond;
  20946. var firstTickPosition = (remainingSecs - currentMillisecond / 1000) * secondsWidthOnXAxis;
  20947. var minute = currentMinute + 1;
  20948. var date = currentDate;
  20949. var month = currentMonth;
  20950. var year = currentYear;
  20951. var hour = currentHour;
  20952. var pos = firstTickPosition;
  20953. for (var i = 0; i < numberOfMinutes; i++) {
  20954. if (minute >= 60) {
  20955. minute = 0;
  20956. hour += 1;
  20957. if (hour === 24) {
  20958. hour = 0;
  20959. }
  20960. }
  20961. this.timeScaleArray.push({
  20962. position: pos,
  20963. value: minute,
  20964. unit: unit,
  20965. hour: hour,
  20966. minute: minute,
  20967. day: date,
  20968. year: this._getYear(year, month, yrCounter),
  20969. month: Utils$1.monthMod(month)
  20970. });
  20971. pos += minutesWidthOnXAxis;
  20972. minute++;
  20973. }
  20974. }
  20975. }, {
  20976. key: "generateSecondScale",
  20977. value: function generateSecondScale(_ref6) {
  20978. var currentMillisecond = _ref6.currentMillisecond,
  20979. currentSecond = _ref6.currentSecond,
  20980. currentMinute = _ref6.currentMinute,
  20981. currentHour = _ref6.currentHour,
  20982. currentDate = _ref6.currentDate,
  20983. currentMonth = _ref6.currentMonth,
  20984. currentYear = _ref6.currentYear,
  20985. secondsWidthOnXAxis = _ref6.secondsWidthOnXAxis,
  20986. numberOfSeconds = _ref6.numberOfSeconds;
  20987. var yrCounter = 0;
  20988. var unit = 'second';
  20989. var remainingMillisecs = 1000 - currentMillisecond;
  20990. var firstTickPosition = remainingMillisecs / 1000 * secondsWidthOnXAxis;
  20991. var second = currentSecond + 1;
  20992. var minute = currentMinute;
  20993. var date = currentDate;
  20994. var month = currentMonth;
  20995. var year = currentYear;
  20996. var hour = currentHour;
  20997. var pos = firstTickPosition;
  20998. for (var i = 0; i < numberOfSeconds; i++) {
  20999. if (second >= 60) {
  21000. minute++;
  21001. second = 0;
  21002. if (minute >= 60) {
  21003. hour++;
  21004. minute = 0;
  21005. if (hour === 24) {
  21006. hour = 0;
  21007. }
  21008. }
  21009. }
  21010. this.timeScaleArray.push({
  21011. position: pos,
  21012. value: second,
  21013. unit: unit,
  21014. hour: hour,
  21015. minute: minute,
  21016. second: second,
  21017. day: date,
  21018. year: this._getYear(year, month, yrCounter),
  21019. month: Utils$1.monthMod(month)
  21020. });
  21021. pos += secondsWidthOnXAxis;
  21022. second++;
  21023. }
  21024. }
  21025. }, {
  21026. key: "createRawDateString",
  21027. value: function createRawDateString(ts, value) {
  21028. var raw = ts.year;
  21029. if (ts.month === 0) {
  21030. // invalid month, correct it
  21031. ts.month = 1;
  21032. }
  21033. raw += '-' + ('0' + ts.month.toString()).slice(-2); // unit is day
  21034. if (ts.unit === 'day') {
  21035. raw += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01';
  21036. } else {
  21037. raw += '-' + ('0' + (ts.day ? ts.day : '1')).slice(-2);
  21038. } // unit is hour
  21039. if (ts.unit === 'hour') {
  21040. raw += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) : 'T00';
  21041. } else {
  21042. raw += 'T' + ('0' + (ts.hour ? ts.hour : '0')).slice(-2);
  21043. }
  21044. if (ts.unit === 'minute') {
  21045. raw += ':' + ('0' + value).slice(-2);
  21046. } else {
  21047. raw += ':' + (ts.minute ? ('0' + ts.minute).slice(-2) : '00');
  21048. }
  21049. if (ts.unit === 'second') {
  21050. raw += ':' + ('0' + value).slice(-2);
  21051. } else {
  21052. raw += ':00';
  21053. }
  21054. if (this.utc) {
  21055. raw += '.000Z';
  21056. }
  21057. return raw;
  21058. }
  21059. }, {
  21060. key: "formatDates",
  21061. value: function formatDates(filteredTimeScale) {
  21062. var _this2 = this;
  21063. var w = this.w;
  21064. var reformattedTimescaleArray = filteredTimeScale.map(function (ts) {
  21065. var value = ts.value.toString();
  21066. var dt = new DateTime(_this2.ctx);
  21067. var raw = _this2.createRawDateString(ts, value);
  21068. var dateToFormat = dt.getDate(dt.parseDate(raw));
  21069. if (!_this2.utc) {
  21070. // Fixes #1726, #1544, #1485, #1255
  21071. dateToFormat = dt.getDate(dt.parseDateWithTimezone(raw));
  21072. }
  21073. if (w.config.xaxis.labels.format === undefined) {
  21074. var customFormat = 'dd MMM';
  21075. var dtFormatter = w.config.xaxis.labels.datetimeFormatter;
  21076. if (ts.unit === 'year') customFormat = dtFormatter.year;
  21077. if (ts.unit === 'month') customFormat = dtFormatter.month;
  21078. if (ts.unit === 'day') customFormat = dtFormatter.day;
  21079. if (ts.unit === 'hour') customFormat = dtFormatter.hour;
  21080. if (ts.unit === 'minute') customFormat = dtFormatter.minute;
  21081. if (ts.unit === 'second') customFormat = dtFormatter.second;
  21082. value = dt.formatDate(dateToFormat, customFormat);
  21083. } else {
  21084. value = dt.formatDate(dateToFormat, w.config.xaxis.labels.format);
  21085. }
  21086. return {
  21087. dateString: raw,
  21088. position: ts.position,
  21089. value: value,
  21090. unit: ts.unit,
  21091. year: ts.year,
  21092. month: ts.month
  21093. };
  21094. });
  21095. return reformattedTimescaleArray;
  21096. }
  21097. }, {
  21098. key: "removeOverlappingTS",
  21099. value: function removeOverlappingTS(arr) {
  21100. var _this3 = this;
  21101. var graphics = new Graphics(this.ctx);
  21102. var equalLabelLengthFlag = false; // These labels got same length?
  21103. var constantLabelWidth; // If true, what is the constant length to use
  21104. if (arr.length > 0 && // check arr length
  21105. arr[0].value && // check arr[0] contains value
  21106. arr.every(function (lb) {
  21107. return lb.value.length === arr[0].value.length;
  21108. }) // check every arr label value is the same as the first one
  21109. ) {
  21110. equalLabelLengthFlag = true; // These labels got same length
  21111. constantLabelWidth = graphics.getTextRects(arr[0].value).width; // The constant label width to use
  21112. }
  21113. var lastDrawnIndex = 0;
  21114. var filteredArray = arr.map(function (item, index) {
  21115. if (index > 0 && _this3.w.config.xaxis.labels.hideOverlappingLabels) {
  21116. var prevLabelWidth = !equalLabelLengthFlag // if vary in label length
  21117. ? graphics.getTextRects(arr[lastDrawnIndex].value).width // get individual length
  21118. : constantLabelWidth; // else: use constant length
  21119. var prevPos = arr[lastDrawnIndex].position;
  21120. var pos = item.position;
  21121. if (pos > prevPos + prevLabelWidth + 10) {
  21122. lastDrawnIndex = index;
  21123. return item;
  21124. } else {
  21125. return null;
  21126. }
  21127. } else {
  21128. return item;
  21129. }
  21130. });
  21131. filteredArray = filteredArray.filter(function (f) {
  21132. return f !== null;
  21133. });
  21134. return filteredArray;
  21135. }
  21136. }, {
  21137. key: "_getYear",
  21138. value: function _getYear(currentYear, month, yrCounter) {
  21139. return currentYear + Math.floor(month / 12) + yrCounter;
  21140. }
  21141. }]);
  21142. return TimeScale;
  21143. }();
  21144. /**
  21145. * ApexCharts Core Class responsible for major calculations and creating elements.
  21146. *
  21147. * @module Core
  21148. **/
  21149. var Core = /*#__PURE__*/function () {
  21150. function Core(el, ctx) {
  21151. _classCallCheck(this, Core);
  21152. this.ctx = ctx;
  21153. this.w = ctx.w;
  21154. this.el = el;
  21155. } // get data and store into appropriate vars
  21156. _createClass(Core, [{
  21157. key: "setupElements",
  21158. value: function setupElements() {
  21159. var gl = this.w.globals;
  21160. var cnf = this.w.config; // const graphics = new Graphics(this.ctx)
  21161. var ct = cnf.chart.type;
  21162. var axisChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'boxPlot', 'scatter', 'bubble', 'radar', 'heatmap', 'treemap'];
  21163. var xyChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'boxPlot', 'scatter', 'bubble'];
  21164. gl.axisCharts = axisChartsArrTypes.indexOf(ct) > -1;
  21165. gl.xyCharts = xyChartsArrTypes.indexOf(ct) > -1;
  21166. gl.isBarHorizontal = (cnf.chart.type === 'bar' || cnf.chart.type === 'rangeBar' || cnf.chart.type === 'boxPlot') && cnf.plotOptions.bar.horizontal;
  21167. gl.chartClass = '.apexcharts' + gl.chartID;
  21168. gl.dom.baseEl = this.el;
  21169. gl.dom.elWrap = document.createElement('div');
  21170. Graphics.setAttrs(gl.dom.elWrap, {
  21171. id: gl.chartClass.substring(1),
  21172. class: 'apexcharts-canvas ' + gl.chartClass.substring(1)
  21173. });
  21174. this.el.appendChild(gl.dom.elWrap);
  21175. gl.dom.Paper = new window.SVG.Doc(gl.dom.elWrap);
  21176. gl.dom.Paper.attr({
  21177. class: 'apexcharts-svg',
  21178. 'xmlns:data': 'ApexChartsNS',
  21179. transform: "translate(".concat(cnf.chart.offsetX, ", ").concat(cnf.chart.offsetY, ")")
  21180. });
  21181. gl.dom.Paper.node.style.background = cnf.chart.background;
  21182. this.setSVGDimensions();
  21183. gl.dom.elGraphical = gl.dom.Paper.group().attr({
  21184. class: 'apexcharts-inner apexcharts-graphical'
  21185. });
  21186. gl.dom.elAnnotations = gl.dom.Paper.group().attr({
  21187. class: 'apexcharts-annotations'
  21188. });
  21189. gl.dom.elDefs = gl.dom.Paper.defs();
  21190. gl.dom.elLegendWrap = document.createElement('div');
  21191. gl.dom.elLegendWrap.classList.add('apexcharts-legend');
  21192. gl.dom.elWrap.appendChild(gl.dom.elLegendWrap);
  21193. gl.dom.Paper.add(gl.dom.elGraphical);
  21194. gl.dom.elGraphical.add(gl.dom.elDefs);
  21195. }
  21196. }, {
  21197. key: "plotChartType",
  21198. value: function plotChartType(ser, xyRatios) {
  21199. var w = this.w;
  21200. var cnf = w.config;
  21201. var gl = w.globals;
  21202. var lineSeries = {
  21203. series: [],
  21204. i: []
  21205. };
  21206. var areaSeries = {
  21207. series: [],
  21208. i: []
  21209. };
  21210. var scatterSeries = {
  21211. series: [],
  21212. i: []
  21213. };
  21214. var bubbleSeries = {
  21215. series: [],
  21216. i: []
  21217. };
  21218. var columnSeries = {
  21219. series: [],
  21220. i: []
  21221. };
  21222. var candlestickSeries = {
  21223. series: [],
  21224. i: []
  21225. };
  21226. var boxplotSeries = {
  21227. series: [],
  21228. i: []
  21229. };
  21230. gl.series.map(function (series, st) {
  21231. var comboCount = 0; // if user has specified a particular type for particular series
  21232. if (typeof ser[st].type !== 'undefined') {
  21233. if (ser[st].type === 'column' || ser[st].type === 'bar') {
  21234. if (gl.series.length > 1 && cnf.plotOptions.bar.horizontal) {
  21235. // horizontal bars not supported in mixed charts, hence show a warning
  21236. console.warn('Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`');
  21237. }
  21238. columnSeries.series.push(series);
  21239. columnSeries.i.push(st);
  21240. comboCount++;
  21241. w.globals.columnSeries = columnSeries.series;
  21242. } else if (ser[st].type === 'area') {
  21243. areaSeries.series.push(series);
  21244. areaSeries.i.push(st);
  21245. comboCount++;
  21246. } else if (ser[st].type === 'line') {
  21247. lineSeries.series.push(series);
  21248. lineSeries.i.push(st);
  21249. comboCount++;
  21250. } else if (ser[st].type === 'scatter') {
  21251. scatterSeries.series.push(series);
  21252. scatterSeries.i.push(st);
  21253. } else if (ser[st].type === 'bubble') {
  21254. bubbleSeries.series.push(series);
  21255. bubbleSeries.i.push(st);
  21256. comboCount++;
  21257. } else if (ser[st].type === 'candlestick') {
  21258. candlestickSeries.series.push(series);
  21259. candlestickSeries.i.push(st);
  21260. comboCount++;
  21261. } else if (ser[st].type === 'boxPlot') {
  21262. boxplotSeries.series.push(series);
  21263. boxplotSeries.i.push(st);
  21264. comboCount++;
  21265. } else {
  21266. // user has specified type, but it is not valid (other than line/area/column)
  21267. console.warn('You have specified an unrecognized chart type. Available types for this property are line/area/column/bar/scatter/bubble');
  21268. }
  21269. if (comboCount > 1) {
  21270. gl.comboCharts = true;
  21271. }
  21272. } else {
  21273. lineSeries.series.push(series);
  21274. lineSeries.i.push(st);
  21275. }
  21276. });
  21277. var line = new Line(this.ctx, xyRatios);
  21278. var boxCandlestick = new BoxCandleStick(this.ctx, xyRatios);
  21279. this.ctx.pie = new Pie(this.ctx);
  21280. var radialBar = new Radial(this.ctx);
  21281. this.ctx.rangeBar = new RangeBar(this.ctx, xyRatios);
  21282. var radar = new Radar(this.ctx);
  21283. var elGraph = [];
  21284. if (gl.comboCharts) {
  21285. if (areaSeries.series.length > 0) {
  21286. elGraph.push(line.draw(areaSeries.series, 'area', areaSeries.i));
  21287. }
  21288. if (columnSeries.series.length > 0) {
  21289. if (w.config.chart.stacked) {
  21290. var barStacked = new BarStacked(this.ctx, xyRatios);
  21291. elGraph.push(barStacked.draw(columnSeries.series, columnSeries.i));
  21292. } else {
  21293. this.ctx.bar = new Bar(this.ctx, xyRatios);
  21294. elGraph.push(this.ctx.bar.draw(columnSeries.series, columnSeries.i));
  21295. }
  21296. }
  21297. if (lineSeries.series.length > 0) {
  21298. elGraph.push(line.draw(lineSeries.series, 'line', lineSeries.i));
  21299. }
  21300. if (candlestickSeries.series.length > 0) {
  21301. elGraph.push(boxCandlestick.draw(candlestickSeries.series, candlestickSeries.i));
  21302. }
  21303. if (boxplotSeries.series.length > 0) {
  21304. elGraph.push(boxCandlestick.draw(boxplotSeries.series, boxplotSeries.i));
  21305. }
  21306. if (scatterSeries.series.length > 0) {
  21307. var scatterLine = new Line(this.ctx, xyRatios, true);
  21308. elGraph.push(scatterLine.draw(scatterSeries.series, 'scatter', scatterSeries.i));
  21309. }
  21310. if (bubbleSeries.series.length > 0) {
  21311. var bubbleLine = new Line(this.ctx, xyRatios, true);
  21312. elGraph.push(bubbleLine.draw(bubbleSeries.series, 'bubble', bubbleSeries.i));
  21313. }
  21314. } else {
  21315. switch (cnf.chart.type) {
  21316. case 'line':
  21317. elGraph = line.draw(gl.series, 'line');
  21318. break;
  21319. case 'area':
  21320. elGraph = line.draw(gl.series, 'area');
  21321. break;
  21322. case 'bar':
  21323. if (cnf.chart.stacked) {
  21324. var _barStacked = new BarStacked(this.ctx, xyRatios);
  21325. elGraph = _barStacked.draw(gl.series);
  21326. } else {
  21327. this.ctx.bar = new Bar(this.ctx, xyRatios);
  21328. elGraph = this.ctx.bar.draw(gl.series);
  21329. }
  21330. break;
  21331. case 'candlestick':
  21332. var candleStick = new BoxCandleStick(this.ctx, xyRatios);
  21333. elGraph = candleStick.draw(gl.series);
  21334. break;
  21335. case 'boxPlot':
  21336. var boxPlot = new BoxCandleStick(this.ctx, xyRatios);
  21337. elGraph = boxPlot.draw(gl.series);
  21338. break;
  21339. case 'rangeBar':
  21340. elGraph = this.ctx.rangeBar.draw(gl.series);
  21341. break;
  21342. case 'heatmap':
  21343. var heatmap = new HeatMap(this.ctx, xyRatios);
  21344. elGraph = heatmap.draw(gl.series);
  21345. break;
  21346. case 'treemap':
  21347. var treemap = new TreemapChart(this.ctx, xyRatios);
  21348. elGraph = treemap.draw(gl.series);
  21349. break;
  21350. case 'pie':
  21351. case 'donut':
  21352. case 'polarArea':
  21353. elGraph = this.ctx.pie.draw(gl.series);
  21354. break;
  21355. case 'radialBar':
  21356. elGraph = radialBar.draw(gl.series);
  21357. break;
  21358. case 'radar':
  21359. elGraph = radar.draw(gl.series);
  21360. break;
  21361. default:
  21362. elGraph = line.draw(gl.series);
  21363. }
  21364. }
  21365. return elGraph;
  21366. }
  21367. }, {
  21368. key: "setSVGDimensions",
  21369. value: function setSVGDimensions() {
  21370. var gl = this.w.globals;
  21371. var cnf = this.w.config;
  21372. gl.svgWidth = cnf.chart.width;
  21373. gl.svgHeight = cnf.chart.height;
  21374. var elDim = Utils$1.getDimensions(this.el);
  21375. var widthUnit = cnf.chart.width.toString().split(/[0-9]+/g).pop();
  21376. if (widthUnit === '%') {
  21377. if (Utils$1.isNumber(elDim[0])) {
  21378. if (elDim[0].width === 0) {
  21379. elDim = Utils$1.getDimensions(this.el.parentNode);
  21380. }
  21381. gl.svgWidth = elDim[0] * parseInt(cnf.chart.width, 10) / 100;
  21382. }
  21383. } else if (widthUnit === 'px' || widthUnit === '') {
  21384. gl.svgWidth = parseInt(cnf.chart.width, 10);
  21385. }
  21386. var heightUnit = cnf.chart.height.toString().split(/[0-9]+/g).pop();
  21387. if (gl.svgHeight !== 'auto' && gl.svgHeight !== '') {
  21388. if (heightUnit === '%') {
  21389. var elParentDim = Utils$1.getDimensions(this.el.parentNode);
  21390. gl.svgHeight = elParentDim[1] * parseInt(cnf.chart.height, 10) / 100;
  21391. } else {
  21392. gl.svgHeight = parseInt(cnf.chart.height, 10);
  21393. }
  21394. } else {
  21395. if (gl.axisCharts) {
  21396. gl.svgHeight = gl.svgWidth / 1.61;
  21397. } else {
  21398. gl.svgHeight = gl.svgWidth / 1.2;
  21399. }
  21400. }
  21401. if (gl.svgWidth < 0) gl.svgWidth = 0;
  21402. if (gl.svgHeight < 0) gl.svgHeight = 0;
  21403. Graphics.setAttrs(gl.dom.Paper.node, {
  21404. width: gl.svgWidth,
  21405. height: gl.svgHeight
  21406. });
  21407. if (heightUnit !== '%') {
  21408. // fixes https://github.com/apexcharts/apexcharts.js/issues/2059
  21409. var offsetY = cnf.chart.sparkline.enabled ? 0 : gl.axisCharts ? cnf.chart.parentHeightOffset : 0;
  21410. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = gl.svgHeight + offsetY + 'px';
  21411. }
  21412. gl.dom.elWrap.style.width = gl.svgWidth + 'px';
  21413. gl.dom.elWrap.style.height = gl.svgHeight + 'px';
  21414. }
  21415. }, {
  21416. key: "shiftGraphPosition",
  21417. value: function shiftGraphPosition() {
  21418. var gl = this.w.globals;
  21419. var tY = gl.translateY;
  21420. var tX = gl.translateX;
  21421. var scalingAttrs = {
  21422. transform: 'translate(' + tX + ', ' + tY + ')'
  21423. };
  21424. Graphics.setAttrs(gl.dom.elGraphical.node, scalingAttrs);
  21425. } // To prevent extra spacings in the bottom of the chart, we need to recalculate the height for pie/donut/radialbar charts
  21426. }, {
  21427. key: "resizeNonAxisCharts",
  21428. value: function resizeNonAxisCharts() {
  21429. var w = this.w;
  21430. var gl = w.globals;
  21431. var legendHeight = 0;
  21432. var offY = w.config.chart.sparkline.enabled ? 1 : 15;
  21433. offY = offY + w.config.grid.padding.bottom;
  21434. if ((w.config.legend.position === 'top' || w.config.legend.position === 'bottom') && w.config.legend.show && !w.config.legend.floating) {
  21435. legendHeight = new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10;
  21436. }
  21437. var el = w.globals.dom.baseEl.querySelector('.apexcharts-radialbar, .apexcharts-pie');
  21438. var chartInnerDimensions = w.globals.radialSize * 2.05;
  21439. if (el && !w.config.chart.sparkline.enabled && w.config.plotOptions.radialBar.startAngle !== 0) {
  21440. var elRadialRect = Utils$1.getBoundingClientRect(el);
  21441. chartInnerDimensions = elRadialRect.bottom;
  21442. var maxHeight = elRadialRect.bottom - elRadialRect.top;
  21443. chartInnerDimensions = Math.max(w.globals.radialSize * 2.05, maxHeight);
  21444. }
  21445. var newHeight = chartInnerDimensions + gl.translateY + legendHeight + offY;
  21446. if (gl.dom.elLegendForeign) {
  21447. gl.dom.elLegendForeign.setAttribute('height', newHeight);
  21448. }
  21449. gl.dom.elWrap.style.height = newHeight + 'px';
  21450. Graphics.setAttrs(gl.dom.Paper.node, {
  21451. height: newHeight
  21452. });
  21453. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = newHeight + 'px';
  21454. }
  21455. /*
  21456. ** All the calculations for setting range in charts will be done here
  21457. */
  21458. }, {
  21459. key: "coreCalculations",
  21460. value: function coreCalculations() {
  21461. var range = new Range(this.ctx);
  21462. range.init();
  21463. }
  21464. }, {
  21465. key: "resetGlobals",
  21466. value: function resetGlobals() {
  21467. var _this = this;
  21468. var resetxyValues = function resetxyValues() {
  21469. return _this.w.config.series.map(function (s) {
  21470. return [];
  21471. });
  21472. };
  21473. var globalObj = new Globals();
  21474. var gl = this.w.globals;
  21475. globalObj.initGlobalVars(gl);
  21476. gl.seriesXvalues = resetxyValues();
  21477. gl.seriesYvalues = resetxyValues();
  21478. }
  21479. }, {
  21480. key: "isMultipleY",
  21481. value: function isMultipleY() {
  21482. // user has supplied an array in yaxis property. So, turn on multipleYAxis flag
  21483. if (this.w.config.yaxis.constructor === Array && this.w.config.yaxis.length > 1) {
  21484. this.w.globals.isMultipleYAxis = true;
  21485. return true;
  21486. }
  21487. }
  21488. }, {
  21489. key: "xySettings",
  21490. value: function xySettings() {
  21491. var xyRatios = null;
  21492. var w = this.w;
  21493. if (w.globals.axisCharts) {
  21494. if (w.config.xaxis.crosshairs.position === 'back') {
  21495. var crosshairs = new Crosshairs(this.ctx);
  21496. crosshairs.drawXCrosshairs();
  21497. }
  21498. if (w.config.yaxis[0].crosshairs.position === 'back') {
  21499. var _crosshairs = new Crosshairs(this.ctx);
  21500. _crosshairs.drawYCrosshairs();
  21501. }
  21502. if (w.config.xaxis.type === 'datetime' && w.config.xaxis.labels.formatter === undefined) {
  21503. this.ctx.timeScale = new TimeScale(this.ctx);
  21504. var formattedTimeScale = [];
  21505. if (isFinite(w.globals.minX) && isFinite(w.globals.maxX) && !w.globals.isBarHorizontal) {
  21506. formattedTimeScale = this.ctx.timeScale.calculateTimeScaleTicks(w.globals.minX, w.globals.maxX);
  21507. } else if (w.globals.isBarHorizontal) {
  21508. formattedTimeScale = this.ctx.timeScale.calculateTimeScaleTicks(w.globals.minY, w.globals.maxY);
  21509. }
  21510. this.ctx.timeScale.recalcDimensionsBasedOnFormat(formattedTimeScale);
  21511. }
  21512. var coreUtils = new CoreUtils(this.ctx);
  21513. xyRatios = coreUtils.getCalculatedRatios();
  21514. }
  21515. return xyRatios;
  21516. }
  21517. }, {
  21518. key: "updateSourceChart",
  21519. value: function updateSourceChart(targetChart) {
  21520. this.ctx.w.globals.selection = undefined;
  21521. this.ctx.updateHelpers._updateOptions({
  21522. chart: {
  21523. selection: {
  21524. xaxis: {
  21525. min: targetChart.w.globals.minX,
  21526. max: targetChart.w.globals.maxX
  21527. }
  21528. }
  21529. }
  21530. }, false, false);
  21531. }
  21532. }, {
  21533. key: "setupBrushHandler",
  21534. value: function setupBrushHandler() {
  21535. var _this2 = this;
  21536. var w = this.w; // only for brush charts
  21537. if (!w.config.chart.brush.enabled) {
  21538. return;
  21539. } // if user has not defined a custom function for selection - we handle the brush chart
  21540. // otherwise we leave it to the user to define the functionality for selection
  21541. if (typeof w.config.chart.events.selection !== 'function') {
  21542. var targets = w.config.chart.brush.targets || [w.config.chart.brush.target]; // retro compatibility with single target option
  21543. targets.forEach(function (target) {
  21544. var targetChart = ApexCharts.getChartByID(target);
  21545. targetChart.w.globals.brushSource = _this2.ctx;
  21546. if (typeof targetChart.w.config.chart.events.zoomed !== 'function') {
  21547. targetChart.w.config.chart.events.zoomed = function () {
  21548. _this2.updateSourceChart(targetChart);
  21549. };
  21550. }
  21551. if (typeof targetChart.w.config.chart.events.scrolled !== 'function') {
  21552. targetChart.w.config.chart.events.scrolled = function () {
  21553. _this2.updateSourceChart(targetChart);
  21554. };
  21555. }
  21556. });
  21557. w.config.chart.events.selection = function (chart, e) {
  21558. targets.forEach(function (target) {
  21559. var targetChart = ApexCharts.getChartByID(target);
  21560. var yaxis = Utils$1.clone(w.config.yaxis);
  21561. if (w.config.chart.brush.autoScaleYaxis && targetChart.w.globals.series.length === 1) {
  21562. var scale = new Range$1(targetChart);
  21563. yaxis = scale.autoScaleY(targetChart, yaxis, e);
  21564. }
  21565. var multipleYaxis = targetChart.w.config.yaxis.reduce(function (acc, curr, index) {
  21566. return [].concat(_toConsumableArray(acc), [_objectSpread2(_objectSpread2({}, targetChart.w.config.yaxis[index]), {}, {
  21567. min: yaxis[0].min,
  21568. max: yaxis[0].max
  21569. })]);
  21570. }, []);
  21571. targetChart.ctx.updateHelpers._updateOptions({
  21572. xaxis: {
  21573. min: e.xaxis.min,
  21574. max: e.xaxis.max
  21575. },
  21576. yaxis: multipleYaxis
  21577. }, false, false, false, false);
  21578. });
  21579. };
  21580. }
  21581. }
  21582. }]);
  21583. return Core;
  21584. }();
  21585. var UpdateHelpers = /*#__PURE__*/function () {
  21586. function UpdateHelpers(ctx) {
  21587. _classCallCheck(this, UpdateHelpers);
  21588. this.ctx = ctx;
  21589. this.w = ctx.w;
  21590. }
  21591. /**
  21592. * private method to update Options.
  21593. *
  21594. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  21595. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  21596. * @param {boolean} animate - should animate or not on updating Options
  21597. * @param {boolean} overwriteInitialConfig - should update the initial config or not
  21598. */
  21599. _createClass(UpdateHelpers, [{
  21600. key: "_updateOptions",
  21601. value: function _updateOptions(options) {
  21602. var _this = this;
  21603. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  21604. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  21605. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  21606. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  21607. return new Promise(function (resolve) {
  21608. var charts = [_this.ctx];
  21609. if (updateSyncedCharts) {
  21610. charts = _this.ctx.getSyncedCharts();
  21611. }
  21612. if (_this.ctx.w.globals.isExecCalled) {
  21613. // If the user called exec method, we don't want to get grouped charts as user specifically provided a chartID to update
  21614. charts = [_this.ctx];
  21615. _this.ctx.w.globals.isExecCalled = false;
  21616. }
  21617. charts.forEach(function (ch, chartIndex) {
  21618. var w = ch.w;
  21619. w.globals.shouldAnimate = animate;
  21620. if (!redraw) {
  21621. w.globals.resized = true;
  21622. w.globals.dataChanged = true;
  21623. if (animate) {
  21624. ch.series.getPreviousPaths();
  21625. }
  21626. }
  21627. if (options && _typeof(options) === 'object') {
  21628. ch.config = new Config(options);
  21629. options = CoreUtils.extendArrayProps(ch.config, options, w); // fixes #914, #623
  21630. if (ch.w.globals.chartID !== _this.ctx.w.globals.chartID) {
  21631. // don't overwrite series of synchronized charts
  21632. delete options.series;
  21633. }
  21634. w.config = Utils$1.extend(w.config, options);
  21635. if (overwriteInitialConfig) {
  21636. // we need to forget the lastXAxis and lastYAxis as 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.
  21637. w.globals.lastXAxis = options.xaxis ? Utils$1.clone(options.xaxis) : [];
  21638. w.globals.lastYAxis = options.yaxis ? Utils$1.clone(options.yaxis) : []; // After forgetting lastAxes, we need to restore the new config in initialConfig/initialSeries
  21639. w.globals.initialConfig = Utils$1.extend({}, w.config);
  21640. w.globals.initialSeries = Utils$1.clone(w.config.series);
  21641. if (options.series) {
  21642. // Replace the collapsed series data
  21643. for (var i = 0; i < w.globals.collapsedSeriesIndices.length; i++) {
  21644. var series = w.config.series[w.globals.collapsedSeriesIndices[i]];
  21645. w.globals.collapsedSeries[i].data = w.globals.axisCharts ? series.data.slice() : series;
  21646. }
  21647. for (var _i = 0; _i < w.globals.ancillaryCollapsedSeriesIndices.length; _i++) {
  21648. var _series = w.config.series[w.globals.ancillaryCollapsedSeriesIndices[_i]];
  21649. w.globals.ancillaryCollapsedSeries[_i].data = w.globals.axisCharts ? _series.data.slice() : _series;
  21650. } // Ensure that auto-generated axes are scaled to the visible data
  21651. ch.series.emptyCollapsedSeries(w.config.series);
  21652. }
  21653. }
  21654. }
  21655. return ch.update(options).then(function () {
  21656. if (chartIndex === charts.length - 1) {
  21657. resolve(ch);
  21658. }
  21659. });
  21660. });
  21661. });
  21662. }
  21663. /**
  21664. * Private method to update Series.
  21665. *
  21666. * @param {array} series - New series which will override the existing
  21667. */
  21668. }, {
  21669. key: "_updateSeries",
  21670. value: function _updateSeries(newSeries, animate) {
  21671. var _this2 = this;
  21672. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  21673. return new Promise(function (resolve) {
  21674. var w = _this2.w;
  21675. w.globals.shouldAnimate = animate;
  21676. w.globals.dataChanged = true;
  21677. if (animate) {
  21678. _this2.ctx.series.getPreviousPaths();
  21679. }
  21680. var existingSeries; // axis charts
  21681. if (w.globals.axisCharts) {
  21682. existingSeries = newSeries.map(function (s, i) {
  21683. return _this2._extendSeries(s, i);
  21684. });
  21685. if (existingSeries.length === 0) {
  21686. existingSeries = [{
  21687. data: []
  21688. }];
  21689. }
  21690. w.config.series = existingSeries;
  21691. } else {
  21692. // non-axis chart (pie/radialbar)
  21693. w.config.series = newSeries.slice();
  21694. }
  21695. if (overwriteInitialSeries) {
  21696. w.globals.initialSeries = Utils$1.clone(w.config.series);
  21697. }
  21698. return _this2.ctx.update().then(function () {
  21699. resolve(_this2.ctx);
  21700. });
  21701. });
  21702. }
  21703. }, {
  21704. key: "_extendSeries",
  21705. value: function _extendSeries(s, i) {
  21706. var w = this.w;
  21707. var ser = w.config.series[i];
  21708. return _objectSpread2(_objectSpread2({}, w.config.series[i]), {}, {
  21709. name: s.name ? s.name : ser && ser.name,
  21710. color: s.color ? s.color : ser && ser.color,
  21711. type: s.type ? s.type : ser && ser.type,
  21712. data: s.data ? s.data : ser && ser.data
  21713. });
  21714. }
  21715. }, {
  21716. key: "toggleDataPointSelection",
  21717. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  21718. var w = this.w;
  21719. var elPath = null;
  21720. var parent = ".apexcharts-series[data\\:realIndex='".concat(seriesIndex, "']");
  21721. if (w.globals.axisCharts) {
  21722. 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];
  21723. } else {
  21724. // dataPointIndex will be undefined here, hence using seriesIndex
  21725. if (typeof dataPointIndex === 'undefined') {
  21726. elPath = w.globals.dom.Paper.select("".concat(parent, " path[j='").concat(seriesIndex, "']")).members[0];
  21727. if (w.config.chart.type === 'pie' || w.config.chart.type === 'polarArea' || w.config.chart.type === 'donut') {
  21728. this.ctx.pie.pieClicked(seriesIndex);
  21729. }
  21730. }
  21731. }
  21732. if (elPath) {
  21733. var graphics = new Graphics(this.ctx);
  21734. graphics.pathMouseDown(elPath, null);
  21735. } else {
  21736. console.warn('toggleDataPointSelection: Element not found');
  21737. return null;
  21738. }
  21739. return elPath.node ? elPath.node : null;
  21740. }
  21741. }, {
  21742. key: "forceXAxisUpdate",
  21743. value: function forceXAxisUpdate(options) {
  21744. var w = this.w;
  21745. var minmax = ['min', 'max'];
  21746. minmax.forEach(function (a) {
  21747. if (typeof options.xaxis[a] !== 'undefined') {
  21748. w.config.xaxis[a] = options.xaxis[a];
  21749. w.globals.lastXAxis[a] = options.xaxis[a];
  21750. }
  21751. });
  21752. if (options.xaxis.categories && options.xaxis.categories.length) {
  21753. w.config.xaxis.categories = options.xaxis.categories;
  21754. }
  21755. if (w.config.xaxis.convertedCatToNumeric) {
  21756. var defaults = new Defaults(options);
  21757. options = defaults.convertCatToNumericXaxis(options, this.ctx);
  21758. }
  21759. return options;
  21760. }
  21761. }, {
  21762. key: "forceYAxisUpdate",
  21763. value: function forceYAxisUpdate(options) {
  21764. var w = this.w;
  21765. if (w.config.chart.stacked && w.config.chart.stackType === '100%') {
  21766. if (Array.isArray(options.yaxis)) {
  21767. options.yaxis.forEach(function (yaxe, index) {
  21768. options.yaxis[index].min = 0;
  21769. options.yaxis[index].max = 100;
  21770. });
  21771. } else {
  21772. options.yaxis.min = 0;
  21773. options.yaxis.max = 100;
  21774. }
  21775. }
  21776. return options;
  21777. }
  21778. /**
  21779. * This function reverts the yaxis and xaxis min/max values to what it was when the chart was defined.
  21780. * 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
  21781. * Also, this should never be called internally on zoom/pan - the reset should only happen when user calls the updateSeries() function externally
  21782. * The function also accepts an object {xaxis, yaxis} which when present is set as the new xaxis/yaxis
  21783. */
  21784. }, {
  21785. key: "revertDefaultAxisMinMax",
  21786. value: function revertDefaultAxisMinMax(opts) {
  21787. var _this3 = this;
  21788. var w = this.w;
  21789. var xaxis = w.globals.lastXAxis;
  21790. var yaxis = w.globals.lastYAxis;
  21791. if (opts && opts.xaxis) {
  21792. xaxis = opts.xaxis;
  21793. }
  21794. if (opts && opts.yaxis) {
  21795. yaxis = opts.yaxis;
  21796. }
  21797. w.config.xaxis.min = xaxis.min;
  21798. w.config.xaxis.max = xaxis.max;
  21799. var getLastYAxis = function getLastYAxis(index) {
  21800. if (typeof yaxis[index] !== 'undefined') {
  21801. w.config.yaxis[index].min = yaxis[index].min;
  21802. w.config.yaxis[index].max = yaxis[index].max;
  21803. }
  21804. };
  21805. w.config.yaxis.map(function (yaxe, index) {
  21806. if (w.globals.zoomed) {
  21807. // user has zoomed, check the last yaxis
  21808. getLastYAxis(index);
  21809. } else {
  21810. // user hasn't zoomed, check the last yaxis first
  21811. if (typeof yaxis[index] !== 'undefined') {
  21812. getLastYAxis(index);
  21813. } else {
  21814. // if last y-axis don't exist, check the original yaxis
  21815. if (typeof _this3.ctx.opts.yaxis[index] !== 'undefined') {
  21816. yaxe.min = _this3.ctx.opts.yaxis[index].min;
  21817. yaxe.max = _this3.ctx.opts.yaxis[index].max;
  21818. }
  21819. }
  21820. }
  21821. });
  21822. }
  21823. }]);
  21824. return UpdateHelpers;
  21825. }();
  21826. (function (root, factory) {
  21827. /* istanbul ignore next */
  21828. if (typeof define === 'function' && define.amd) {
  21829. define(function () {
  21830. return factory(root, root.document);
  21831. });
  21832. /* below check fixes #412 */
  21833. } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
  21834. module.exports = root.document ? factory(root, root.document) : function (w) {
  21835. return factory(w, w.document);
  21836. };
  21837. } else {
  21838. root.SVG = factory(root, root.document);
  21839. }
  21840. })(typeof window !== 'undefined' ? window : undefined, function (window, document) {
  21841. // Find global reference - uses 'this' by default when available,
  21842. // falls back to 'window' otherwise (for bundlers like Webpack)
  21843. var globalRef = typeof this !== 'undefined' ? this : window; // The main wrapping element
  21844. var SVG = globalRef.SVG = function (element) {
  21845. if (SVG.supported) {
  21846. element = new SVG.Doc(element);
  21847. if (!SVG.parser.draw) {
  21848. SVG.prepare();
  21849. }
  21850. return element;
  21851. }
  21852. }; // Default namespaces
  21853. SVG.ns = 'http://www.w3.org/2000/svg';
  21854. SVG.xmlns = 'http://www.w3.org/2000/xmlns/';
  21855. SVG.xlink = 'http://www.w3.org/1999/xlink';
  21856. SVG.svgjs = 'http://svgjs.dev'; // Svg support test
  21857. SVG.supported = function () {
  21858. return true; // !!document.createElementNS &&
  21859. // !! document.createElementNS(SVG.ns,'svg').createSVGRect
  21860. }(); // Don't bother to continue if SVG is not supported
  21861. if (!SVG.supported) return false; // Element id sequence
  21862. SVG.did = 1000; // Get next named element id
  21863. SVG.eid = function (name) {
  21864. return 'Svgjs' + capitalize(name) + SVG.did++;
  21865. }; // Method for element creation
  21866. SVG.create = function (name) {
  21867. // create element
  21868. var element = document.createElementNS(this.ns, name); // apply unique id
  21869. element.setAttribute('id', this.eid(name));
  21870. return element;
  21871. }; // Method for extending objects
  21872. SVG.extend = function () {
  21873. var modules, methods; // Get list of modules
  21874. modules = [].slice.call(arguments); // Get object with extensions
  21875. methods = modules.pop();
  21876. for (var i = modules.length - 1; i >= 0; i--) {
  21877. if (modules[i]) {
  21878. for (var key in methods) {
  21879. modules[i].prototype[key] = methods[key];
  21880. }
  21881. }
  21882. } // Make sure SVG.Set inherits any newly added methods
  21883. if (SVG.Set && SVG.Set.inherit) {
  21884. SVG.Set.inherit();
  21885. }
  21886. }; // Invent new element
  21887. SVG.invent = function (config) {
  21888. // Create element initializer
  21889. var initializer = typeof config.create === 'function' ? config.create : function () {
  21890. this.constructor.call(this, SVG.create(config.create));
  21891. }; // Inherit prototype
  21892. if (config.inherit) {
  21893. initializer.prototype = new config.inherit();
  21894. } // Extend with methods
  21895. if (config.extend) {
  21896. SVG.extend(initializer, config.extend);
  21897. } // Attach construct method to parent
  21898. if (config.construct) {
  21899. SVG.extend(config.parent || SVG.Container, config.construct);
  21900. }
  21901. return initializer;
  21902. }; // Adopt existing svg elements
  21903. SVG.adopt = function (node) {
  21904. // check for presence of node
  21905. if (!node) return null; // make sure a node isn't already adopted
  21906. if (node.instance) return node.instance; // initialize variables
  21907. var element; // adopt with element-specific settings
  21908. if (node.nodeName == 'svg') {
  21909. element = node.parentNode instanceof window.SVGElement ? new SVG.Nested() : new SVG.Doc();
  21910. } else if (node.nodeName == 'linearGradient') {
  21911. element = new SVG.Gradient('linear');
  21912. } else if (node.nodeName == 'radialGradient') {
  21913. element = new SVG.Gradient('radial');
  21914. } else if (SVG[capitalize(node.nodeName)]) {
  21915. element = new SVG[capitalize(node.nodeName)]();
  21916. } else {
  21917. element = new SVG.Element(node);
  21918. } // ensure references
  21919. element.type = node.nodeName;
  21920. element.node = node;
  21921. node.instance = element; // SVG.Class specific preparations
  21922. if (element instanceof SVG.Doc) {
  21923. element.namespace().defs();
  21924. } // pull svgjs data from the dom (getAttributeNS doesn't work in html5)
  21925. element.setData(JSON.parse(node.getAttribute('svgjs:data')) || {});
  21926. return element;
  21927. }; // Initialize parsing element
  21928. SVG.prepare = function () {
  21929. // Select document body and create invisible svg element
  21930. var body = document.getElementsByTagName('body')[0],
  21931. draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0); // Create parser object
  21932. SVG.parser = {
  21933. body: body || document.documentElement,
  21934. draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node,
  21935. poly: draw.polyline().node,
  21936. path: draw.path().node,
  21937. native: SVG.create('svg')
  21938. };
  21939. };
  21940. SVG.parser = {
  21941. native: SVG.create('svg')
  21942. };
  21943. document.addEventListener('DOMContentLoaded', function () {
  21944. if (!SVG.parser.draw) {
  21945. SVG.prepare();
  21946. }
  21947. }, false); // Storage for regular expressions
  21948. SVG.regex = {
  21949. // Parse unit value
  21950. numberAndUnit: /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,
  21951. // Parse hex value
  21952. hex: /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
  21953. // Parse rgb value
  21954. rgb: /rgb\((\d+),(\d+),(\d+)\)/,
  21955. // Parse reference id
  21956. reference: /#([a-z0-9\-_]+)/i,
  21957. // splits a transformation chain
  21958. transforms: /\)\s*,?\s*/,
  21959. // Whitespace
  21960. whitespace: /\s/g,
  21961. // Test hex value
  21962. isHex: /^#[a-f0-9]{3,6}$/i,
  21963. // Test rgb value
  21964. isRgb: /^rgb\(/,
  21965. // Test css declaration
  21966. isCss: /[^:]+:[^;]+;?/,
  21967. // Test for blank string
  21968. isBlank: /^(\s+)?$/,
  21969. // Test for numeric string
  21970. isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  21971. // Test for percent value
  21972. isPercent: /^-?[\d\.]+%$/,
  21973. // Test for image url
  21974. isImage: /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,
  21975. // split at whitespace and comma
  21976. delimiter: /[\s,]+/,
  21977. // The following regex are used to parse the d attribute of a path
  21978. // Matches all hyphens which are not after an exponent
  21979. hyphen: /([^e])\-/gi,
  21980. // Replaces and tests for all path letters
  21981. pathLetters: /[MLHVCSQTAZ]/gi,
  21982. // yes we need this one, too
  21983. isPathLetter: /[MLHVCSQTAZ]/i,
  21984. // matches 0.154.23.45
  21985. numbersWithDots: /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,
  21986. // matches .
  21987. dots: /\./g
  21988. };
  21989. SVG.utils = {
  21990. // Map function
  21991. map: function map(array, block) {
  21992. var il = array.length,
  21993. result = [];
  21994. for (var i = 0; i < il; i++) {
  21995. result.push(block(array[i]));
  21996. }
  21997. return result;
  21998. },
  21999. // Filter function
  22000. filter: function filter(array, block) {
  22001. var il = array.length,
  22002. result = [];
  22003. for (var i = 0; i < il; i++) {
  22004. if (block(array[i])) {
  22005. result.push(array[i]);
  22006. }
  22007. }
  22008. return result;
  22009. },
  22010. filterSVGElements: function filterSVGElements(nodes) {
  22011. return this.filter(nodes, function (el) {
  22012. return el instanceof window.SVGElement;
  22013. });
  22014. }
  22015. };
  22016. SVG.defaults = {
  22017. // Default attribute values
  22018. attrs: {
  22019. // fill and stroke
  22020. 'fill-opacity': 1,
  22021. 'stroke-opacity': 1,
  22022. 'stroke-width': 0,
  22023. 'stroke-linejoin': 'miter',
  22024. 'stroke-linecap': 'butt',
  22025. fill: '#000000',
  22026. stroke: '#000000',
  22027. opacity: 1,
  22028. // position
  22029. x: 0,
  22030. y: 0,
  22031. cx: 0,
  22032. cy: 0,
  22033. // size
  22034. width: 0,
  22035. height: 0,
  22036. // radius
  22037. r: 0,
  22038. rx: 0,
  22039. ry: 0,
  22040. // gradient
  22041. offset: 0,
  22042. 'stop-opacity': 1,
  22043. 'stop-color': '#000000',
  22044. // text
  22045. 'font-size': 16,
  22046. 'font-family': 'Helvetica, Arial, sans-serif',
  22047. 'text-anchor': 'start'
  22048. }
  22049. }; // Module for color convertions
  22050. SVG.Color = function (color) {
  22051. var match; // initialize defaults
  22052. this.r = 0;
  22053. this.g = 0;
  22054. this.b = 0;
  22055. if (!color) return; // parse color
  22056. if (typeof color === 'string') {
  22057. if (SVG.regex.isRgb.test(color)) {
  22058. // get rgb values
  22059. match = SVG.regex.rgb.exec(color.replace(SVG.regex.whitespace, '')); // parse numeric values
  22060. this.r = parseInt(match[1]);
  22061. this.g = parseInt(match[2]);
  22062. this.b = parseInt(match[3]);
  22063. } else if (SVG.regex.isHex.test(color)) {
  22064. // get hex values
  22065. match = SVG.regex.hex.exec(fullHex(color)); // parse numeric values
  22066. this.r = parseInt(match[1], 16);
  22067. this.g = parseInt(match[2], 16);
  22068. this.b = parseInt(match[3], 16);
  22069. }
  22070. } else if (_typeof(color) === 'object') {
  22071. this.r = color.r;
  22072. this.g = color.g;
  22073. this.b = color.b;
  22074. }
  22075. };
  22076. SVG.extend(SVG.Color, {
  22077. // Default to hex conversion
  22078. toString: function toString() {
  22079. return this.toHex();
  22080. },
  22081. // Build hex value
  22082. toHex: function toHex() {
  22083. return '#' + compToHex(this.r) + compToHex(this.g) + compToHex(this.b);
  22084. },
  22085. // Build rgb value
  22086. toRgb: function toRgb() {
  22087. return 'rgb(' + [this.r, this.g, this.b].join() + ')';
  22088. },
  22089. // Calculate true brightness
  22090. brightness: function brightness() {
  22091. return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11;
  22092. },
  22093. // Make color morphable
  22094. morph: function morph(color) {
  22095. this.destination = new SVG.Color(color);
  22096. return this;
  22097. },
  22098. // Get morphed color at given position
  22099. at: function at(pos) {
  22100. // make sure a destination is defined
  22101. if (!this.destination) return this; // normalise pos
  22102. pos = pos < 0 ? 0 : pos > 1 ? 1 : pos; // generate morphed color
  22103. return new SVG.Color({
  22104. r: ~~(this.r + (this.destination.r - this.r) * pos),
  22105. g: ~~(this.g + (this.destination.g - this.g) * pos),
  22106. b: ~~(this.b + (this.destination.b - this.b) * pos)
  22107. });
  22108. }
  22109. }); // Testers
  22110. // Test if given value is a color string
  22111. SVG.Color.test = function (color) {
  22112. color += '';
  22113. return SVG.regex.isHex.test(color) || SVG.regex.isRgb.test(color);
  22114. }; // Test if given value is a rgb object
  22115. SVG.Color.isRgb = function (color) {
  22116. return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number';
  22117. }; // Test if given value is a color
  22118. SVG.Color.isColor = function (color) {
  22119. return SVG.Color.isRgb(color) || SVG.Color.test(color);
  22120. }; // Module for array conversion
  22121. SVG.Array = function (array, fallback) {
  22122. array = (array || []).valueOf(); // if array is empty and fallback is provided, use fallback
  22123. if (array.length == 0 && fallback) {
  22124. array = fallback.valueOf();
  22125. } // parse array
  22126. this.value = this.parse(array);
  22127. };
  22128. SVG.extend(SVG.Array, {
  22129. // Convert array to string
  22130. toString: function toString() {
  22131. return this.value.join(' ');
  22132. },
  22133. // Real value
  22134. valueOf: function valueOf() {
  22135. return this.value;
  22136. },
  22137. // Parse whitespace separated string
  22138. parse: function parse(array) {
  22139. array = array.valueOf(); // if already is an array, no need to parse it
  22140. if (Array.isArray(array)) return array;
  22141. return this.split(array);
  22142. }
  22143. }); // Poly points array
  22144. SVG.PointArray = function (array, fallback) {
  22145. SVG.Array.call(this, array, fallback || [[0, 0]]);
  22146. }; // Inherit from SVG.Array
  22147. SVG.PointArray.prototype = new SVG.Array();
  22148. SVG.PointArray.prototype.constructor = SVG.PointArray;
  22149. var pathHandlers = {
  22150. M: function M(c, p, p0) {
  22151. p.x = p0.x = c[0];
  22152. p.y = p0.y = c[1];
  22153. return ['M', p.x, p.y];
  22154. },
  22155. L: function L(c, p) {
  22156. p.x = c[0];
  22157. p.y = c[1];
  22158. return ['L', c[0], c[1]];
  22159. },
  22160. H: function H(c, p) {
  22161. p.x = c[0];
  22162. return ['H', c[0]];
  22163. },
  22164. V: function V(c, p) {
  22165. p.y = c[0];
  22166. return ['V', c[0]];
  22167. },
  22168. C: function C(c, p) {
  22169. p.x = c[4];
  22170. p.y = c[5];
  22171. return ['C', c[0], c[1], c[2], c[3], c[4], c[5]];
  22172. },
  22173. Q: function Q(c, p) {
  22174. p.x = c[2];
  22175. p.y = c[3];
  22176. return ['Q', c[0], c[1], c[2], c[3]];
  22177. },
  22178. Z: function Z(c, p, p0) {
  22179. p.x = p0.x;
  22180. p.y = p0.y;
  22181. return ['Z'];
  22182. }
  22183. };
  22184. var mlhvqtcsa = 'mlhvqtcsaz'.split('');
  22185. for (var i = 0, il = mlhvqtcsa.length; i < il; ++i) {
  22186. pathHandlers[mlhvqtcsa[i]] = function (i) {
  22187. return function (c, p, p0) {
  22188. if (i == 'H') c[0] = c[0] + p.x;else if (i == 'V') c[0] = c[0] + p.y;else if (i == 'A') {
  22189. c[5] = c[5] + p.x, c[6] = c[6] + p.y;
  22190. } else {
  22191. for (var j = 0, jl = c.length; j < jl; ++j) {
  22192. c[j] = c[j] + (j % 2 ? p.y : p.x);
  22193. }
  22194. }
  22195. if (pathHandlers && typeof pathHandlers[i] === 'function') {
  22196. // this check fixes jest unit tests
  22197. return pathHandlers[i](c, p, p0);
  22198. }
  22199. };
  22200. }(mlhvqtcsa[i].toUpperCase());
  22201. } // Path points array
  22202. SVG.PathArray = function (array, fallback) {
  22203. SVG.Array.call(this, array, fallback || [['M', 0, 0]]);
  22204. }; // Inherit from SVG.Array
  22205. SVG.PathArray.prototype = new SVG.Array();
  22206. SVG.PathArray.prototype.constructor = SVG.PathArray;
  22207. SVG.extend(SVG.PathArray, {
  22208. // Convert array to string
  22209. toString: function toString() {
  22210. return arrayToString(this.value);
  22211. },
  22212. // Move path string
  22213. move: function move(x, y) {
  22214. // get bounding box of current situation
  22215. var box = this.bbox(); // get relative offset
  22216. x -= box.x;
  22217. y -= box.y;
  22218. return this;
  22219. },
  22220. // Get morphed path array at given position
  22221. at: function at(pos) {
  22222. // make sure a destination is defined
  22223. if (!this.destination) return this;
  22224. var sourceArray = this.value,
  22225. destinationArray = this.destination.value,
  22226. array = [],
  22227. pathArray = new SVG.PathArray(),
  22228. il,
  22229. jl; // Animate has specified in the SVG spec
  22230. // See: https://www.w3.org/TR/SVG11/paths.html#PathElement
  22231. for (var i = 0, il = sourceArray.length; i < il; i++) {
  22232. array[i] = [sourceArray[i][0]];
  22233. for (var j = 1, jl = sourceArray[i].length; j < jl; j++) {
  22234. array[i][j] = sourceArray[i][j] + (destinationArray[i][j] - sourceArray[i][j]) * pos;
  22235. } // For the two flags of the elliptical arc command, the SVG spec say:
  22236. // Flags and booleans are interpolated as fractions between zero and one, with any non-zero value considered to be a value of one/true
  22237. // Elliptical arc command as an array followed by corresponding indexes:
  22238. // ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
  22239. // 0 1 2 3 4 5 6 7
  22240. if (array[i][0] === 'A') {
  22241. array[i][4] = +(array[i][4] != 0);
  22242. array[i][5] = +(array[i][5] != 0);
  22243. }
  22244. } // Directly modify the value of a path array, this is done this way for performance
  22245. pathArray.value = array;
  22246. return pathArray;
  22247. },
  22248. // Absolutize and parse path to array
  22249. parse: function parse(array) {
  22250. // if it's already a patharray, no need to parse it
  22251. if (array instanceof SVG.PathArray) return array.valueOf(); // prepare for parsing
  22252. var s,
  22253. arr,
  22254. paramCnt = {
  22255. 'M': 2,
  22256. 'L': 2,
  22257. 'H': 1,
  22258. 'V': 1,
  22259. 'C': 6,
  22260. 'S': 4,
  22261. 'Q': 4,
  22262. 'T': 2,
  22263. 'A': 7,
  22264. 'Z': 0
  22265. };
  22266. if (typeof array === 'string') {
  22267. array = array.replace(SVG.regex.numbersWithDots, pathRegReplace) // convert 45.123.123 to 45.123 .123
  22268. .replace(SVG.regex.pathLetters, ' $& ') // put some room between letters and numbers
  22269. .replace(SVG.regex.hyphen, '$1 -') // add space before hyphen
  22270. .trim() // trim
  22271. .split(SVG.regex.delimiter); // split into array
  22272. } else {
  22273. array = array.reduce(function (prev, curr) {
  22274. return [].concat.call(prev, curr);
  22275. }, []);
  22276. } // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...]
  22277. var arr = [],
  22278. p = new SVG.Point(),
  22279. p0 = new SVG.Point(),
  22280. index = 0,
  22281. len = array.length;
  22282. do {
  22283. // Test if we have a path letter
  22284. if (SVG.regex.isPathLetter.test(array[index])) {
  22285. s = array[index];
  22286. ++index; // If last letter was a move command and we got no new, it defaults to [L]ine
  22287. } else if (s == 'M') {
  22288. s = 'L';
  22289. } else if (s == 'm') {
  22290. s = 'l';
  22291. }
  22292. arr.push(pathHandlers[s].call(null, array.slice(index, index = index + paramCnt[s.toUpperCase()]).map(parseFloat), p, p0));
  22293. } while (len > index);
  22294. return arr;
  22295. },
  22296. // Get bounding box of path
  22297. bbox: function bbox() {
  22298. if (!SVG.parser.draw) {
  22299. SVG.prepare();
  22300. }
  22301. SVG.parser.path.setAttribute('d', this.toString());
  22302. return SVG.parser.path.getBBox();
  22303. }
  22304. }); // Module for unit convertions
  22305. SVG.Number = SVG.invent({
  22306. // Initialize
  22307. create: function create(value, unit) {
  22308. // initialize defaults
  22309. this.value = 0;
  22310. this.unit = unit || ''; // parse value
  22311. if (typeof value === 'number') {
  22312. // ensure a valid numeric value
  22313. this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -3.4e+38 : +3.4e+38 : value;
  22314. } else if (typeof value === 'string') {
  22315. unit = value.match(SVG.regex.numberAndUnit);
  22316. if (unit) {
  22317. // make value numeric
  22318. this.value = parseFloat(unit[1]); // normalize
  22319. if (unit[5] == '%') {
  22320. this.value /= 100;
  22321. } else if (unit[5] == 's') {
  22322. this.value *= 1000;
  22323. } // store unit
  22324. this.unit = unit[5];
  22325. }
  22326. } else {
  22327. if (value instanceof SVG.Number) {
  22328. this.value = value.valueOf();
  22329. this.unit = value.unit;
  22330. }
  22331. }
  22332. },
  22333. // Add methods
  22334. extend: {
  22335. // Stringalize
  22336. toString: function toString() {
  22337. return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.unit == 's' ? this.value / 1e3 : this.value) + this.unit;
  22338. },
  22339. toJSON: function toJSON() {
  22340. return this.toString();
  22341. },
  22342. // Convert to primitive
  22343. valueOf: function valueOf() {
  22344. return this.value;
  22345. },
  22346. // Add number
  22347. plus: function plus(number) {
  22348. number = new SVG.Number(number);
  22349. return new SVG.Number(this + number, this.unit || number.unit);
  22350. },
  22351. // Subtract number
  22352. minus: function minus(number) {
  22353. number = new SVG.Number(number);
  22354. return new SVG.Number(this - number, this.unit || number.unit);
  22355. },
  22356. // Multiply number
  22357. times: function times(number) {
  22358. number = new SVG.Number(number);
  22359. return new SVG.Number(this * number, this.unit || number.unit);
  22360. },
  22361. // Divide number
  22362. divide: function divide(number) {
  22363. number = new SVG.Number(number);
  22364. return new SVG.Number(this / number, this.unit || number.unit);
  22365. },
  22366. // Convert to different unit
  22367. to: function to(unit) {
  22368. var number = new SVG.Number(this);
  22369. if (typeof unit === 'string') {
  22370. number.unit = unit;
  22371. }
  22372. return number;
  22373. },
  22374. // Make number morphable
  22375. morph: function morph(number) {
  22376. this.destination = new SVG.Number(number);
  22377. if (number.relative) {
  22378. this.destination.value += this.value;
  22379. }
  22380. return this;
  22381. },
  22382. // Get morphed number at given position
  22383. at: function at(pos) {
  22384. // Make sure a destination is defined
  22385. if (!this.destination) return this; // Generate new morphed number
  22386. return new SVG.Number(this.destination).minus(this).times(pos).plus(this);
  22387. }
  22388. }
  22389. });
  22390. SVG.Element = SVG.invent({
  22391. // Initialize node
  22392. create: function create(node) {
  22393. // make stroke value accessible dynamically
  22394. this._stroke = SVG.defaults.attrs.stroke;
  22395. this._event = null; // initialize data object
  22396. this.dom = {}; // create circular reference
  22397. if (this.node = node) {
  22398. this.type = node.nodeName;
  22399. this.node.instance = this; // store current attribute value
  22400. this._stroke = node.getAttribute('stroke') || this._stroke;
  22401. }
  22402. },
  22403. // Add class methods
  22404. extend: {
  22405. // Move over x-axis
  22406. x: function x(_x) {
  22407. return this.attr('x', _x);
  22408. },
  22409. // Move over y-axis
  22410. y: function y(_y) {
  22411. return this.attr('y', _y);
  22412. },
  22413. // Move by center over x-axis
  22414. cx: function cx(x) {
  22415. return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2);
  22416. },
  22417. // Move by center over y-axis
  22418. cy: function cy(y) {
  22419. return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2);
  22420. },
  22421. // Move element to given x and y values
  22422. move: function move(x, y) {
  22423. return this.x(x).y(y);
  22424. },
  22425. // Move element by its center
  22426. center: function center(x, y) {
  22427. return this.cx(x).cy(y);
  22428. },
  22429. // Set width of element
  22430. width: function width(_width) {
  22431. return this.attr('width', _width);
  22432. },
  22433. // Set height of element
  22434. height: function height(_height) {
  22435. return this.attr('height', _height);
  22436. },
  22437. // Set element size to given width and height
  22438. size: function size(width, height) {
  22439. var p = proportionalSize(this, width, height);
  22440. return this.width(new SVG.Number(p.width)).height(new SVG.Number(p.height));
  22441. },
  22442. // Clone element
  22443. clone: function clone(parent) {
  22444. // write dom data to the dom so the clone can pickup the data
  22445. this.writeDataToDom(); // clone element and assign new id
  22446. var clone = assignNewId(this.node.cloneNode(true)); // insert the clone in the given parent or after myself
  22447. if (parent) parent.add(clone);else this.after(clone);
  22448. return clone;
  22449. },
  22450. // Remove element
  22451. remove: function remove() {
  22452. if (this.parent()) {
  22453. this.parent().removeElement(this);
  22454. }
  22455. return this;
  22456. },
  22457. // Replace element
  22458. replace: function replace(element) {
  22459. this.after(element).remove();
  22460. return element;
  22461. },
  22462. // Add element to given container and return self
  22463. addTo: function addTo(parent) {
  22464. return parent.put(this);
  22465. },
  22466. // Add element to given container and return container
  22467. putIn: function putIn(parent) {
  22468. return parent.add(this);
  22469. },
  22470. // Get / set id
  22471. id: function id(_id) {
  22472. return this.attr('id', _id);
  22473. },
  22474. // Show element
  22475. show: function show() {
  22476. return this.style('display', '');
  22477. },
  22478. // Hide element
  22479. hide: function hide() {
  22480. return this.style('display', 'none');
  22481. },
  22482. // Is element visible?
  22483. visible: function visible() {
  22484. return this.style('display') != 'none';
  22485. },
  22486. // Return id on string conversion
  22487. toString: function toString() {
  22488. return this.attr('id');
  22489. },
  22490. // Return array of classes on the node
  22491. classes: function classes() {
  22492. var attr = this.attr('class');
  22493. return attr == null ? [] : attr.trim().split(SVG.regex.delimiter);
  22494. },
  22495. // Return true if class exists on the node, false otherwise
  22496. hasClass: function hasClass(name) {
  22497. return this.classes().indexOf(name) != -1;
  22498. },
  22499. // Add class to the node
  22500. addClass: function addClass(name) {
  22501. if (!this.hasClass(name)) {
  22502. var array = this.classes();
  22503. array.push(name);
  22504. this.attr('class', array.join(' '));
  22505. }
  22506. return this;
  22507. },
  22508. // Remove class from the node
  22509. removeClass: function removeClass(name) {
  22510. if (this.hasClass(name)) {
  22511. this.attr('class', this.classes().filter(function (c) {
  22512. return c != name;
  22513. }).join(' '));
  22514. }
  22515. return this;
  22516. },
  22517. // Toggle the presence of a class on the node
  22518. toggleClass: function toggleClass(name) {
  22519. return this.hasClass(name) ? this.removeClass(name) : this.addClass(name);
  22520. },
  22521. // Get referenced element form attribute value
  22522. reference: function reference(attr) {
  22523. return SVG.get(this.attr(attr));
  22524. },
  22525. // Returns the parent element instance
  22526. parent: function parent(type) {
  22527. var parent = this; // check for parent
  22528. if (!parent.node.parentNode) return null; // get parent element
  22529. parent = SVG.adopt(parent.node.parentNode);
  22530. if (!type) return parent; // loop trough ancestors if type is given
  22531. while (parent && parent.node instanceof window.SVGElement) {
  22532. if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent;
  22533. if (!parent.node.parentNode || parent.node.parentNode.nodeName == '#document') return null; // #759, #720
  22534. parent = SVG.adopt(parent.node.parentNode);
  22535. }
  22536. },
  22537. // Get parent document
  22538. doc: function doc() {
  22539. return this instanceof SVG.Doc ? this : this.parent(SVG.Doc);
  22540. },
  22541. // return array of all ancestors of given type up to the root svg
  22542. parents: function parents(type) {
  22543. var parents = [],
  22544. parent = this;
  22545. do {
  22546. parent = parent.parent(type);
  22547. if (!parent || !parent.node) break;
  22548. parents.push(parent);
  22549. } while (parent.parent);
  22550. return parents;
  22551. },
  22552. // matches the element vs a css selector
  22553. matches: function matches(selector) {
  22554. return _matches(this.node, selector);
  22555. },
  22556. // Returns the svg node to call native svg methods on it
  22557. native: function native() {
  22558. return this.node;
  22559. },
  22560. // Import raw svg
  22561. svg: function svg(_svg) {
  22562. // create temporary holder
  22563. var well = document.createElement('svg'); // act as a setter if svg is given
  22564. if (_svg && this instanceof SVG.Parent) {
  22565. // dump raw svg
  22566. well.innerHTML = '<svg>' + _svg.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2></$1>') + '</svg>'; // transplant nodes
  22567. for (var i = 0, il = well.firstChild.childNodes.length; i < il; i++) {
  22568. this.node.appendChild(well.firstChild.firstChild);
  22569. } // otherwise act as a getter
  22570. } else {
  22571. // create a wrapping svg element in case of partial content
  22572. well.appendChild(_svg = document.createElement('svg')); // write svgjs data to the dom
  22573. this.writeDataToDom(); // insert a copy of this node
  22574. _svg.appendChild(this.node.cloneNode(true)); // return target element
  22575. return well.innerHTML.replace(/^<svg>/, '').replace(/<\/svg>$/, '');
  22576. }
  22577. return this;
  22578. },
  22579. // write svgjs data to the dom
  22580. writeDataToDom: function writeDataToDom() {
  22581. // dump variables recursively
  22582. if (this.each || this.lines) {
  22583. var fn = this.each ? this : this.lines();
  22584. fn.each(function () {
  22585. this.writeDataToDom();
  22586. });
  22587. } // remove previously set data
  22588. this.node.removeAttribute('svgjs:data');
  22589. if (Object.keys(this.dom).length) {
  22590. this.node.setAttribute('svgjs:data', JSON.stringify(this.dom));
  22591. } // see #428
  22592. return this;
  22593. },
  22594. // set given data to the elements data property
  22595. setData: function setData(o) {
  22596. this.dom = o;
  22597. return this;
  22598. },
  22599. is: function is(obj) {
  22600. return _is(this, obj);
  22601. }
  22602. }
  22603. });
  22604. SVG.easing = {
  22605. '-': function _(pos) {
  22606. return pos;
  22607. },
  22608. '<>': function _(pos) {
  22609. return -Math.cos(pos * Math.PI) / 2 + 0.5;
  22610. },
  22611. '>': function _(pos) {
  22612. return Math.sin(pos * Math.PI / 2);
  22613. },
  22614. '<': function _(pos) {
  22615. return -Math.cos(pos * Math.PI / 2) + 1;
  22616. }
  22617. };
  22618. SVG.morph = function (pos) {
  22619. return function (from, to) {
  22620. return new SVG.MorphObj(from, to).at(pos);
  22621. };
  22622. };
  22623. SVG.Situation = SVG.invent({
  22624. create: function create(o) {
  22625. this.init = false;
  22626. this.reversed = false;
  22627. this.reversing = false;
  22628. this.duration = new SVG.Number(o.duration).valueOf();
  22629. this.delay = new SVG.Number(o.delay).valueOf();
  22630. this.start = +new Date() + this.delay;
  22631. this.finish = this.start + this.duration;
  22632. this.ease = o.ease; // this.loop is incremented from 0 to this.loops
  22633. // it is also incremented when in an infinite loop (when this.loops is true)
  22634. this.loop = 0;
  22635. this.loops = false;
  22636. this.animations = {// functionToCall: [list of morphable objects]
  22637. // e.g. move: [SVG.Number, SVG.Number]
  22638. };
  22639. this.attrs = {// holds all attributes which are not represented from a function svg.js provides
  22640. // e.g. someAttr: SVG.Number
  22641. };
  22642. this.styles = {// holds all styles which should be animated
  22643. // e.g. fill-color: SVG.Color
  22644. };
  22645. this.transforms = [// holds all transformations as transformation objects
  22646. // e.g. [SVG.Rotate, SVG.Translate, SVG.Matrix]
  22647. ];
  22648. this.once = {// functions to fire at a specific position
  22649. // e.g. "0.5": function foo(){}
  22650. };
  22651. }
  22652. });
  22653. SVG.FX = SVG.invent({
  22654. create: function create(element) {
  22655. this._target = element;
  22656. this.situations = [];
  22657. this.active = false;
  22658. this.situation = null;
  22659. this.paused = false;
  22660. this.lastPos = 0;
  22661. this.pos = 0; // The absolute position of an animation is its position in the context of its complete duration (including delay and loops)
  22662. // When performing a delay, absPos is below 0 and when performing a loop, its value is above 1
  22663. this.absPos = 0;
  22664. this._speed = 1;
  22665. },
  22666. extend: {
  22667. /**
  22668. * sets or returns the target of this animation
  22669. * @param o object || number In case of Object it holds all parameters. In case of number its the duration of the animation
  22670. * @param ease function || string Function which should be used for easing or easing keyword
  22671. * @param delay Number indicating the delay before the animation starts
  22672. * @return target || this
  22673. */
  22674. animate: function animate(o, ease, delay) {
  22675. if (_typeof(o) === 'object') {
  22676. ease = o.ease;
  22677. delay = o.delay;
  22678. o = o.duration;
  22679. }
  22680. var situation = new SVG.Situation({
  22681. duration: o || 1000,
  22682. delay: delay || 0,
  22683. ease: SVG.easing[ease || '-'] || ease
  22684. });
  22685. this.queue(situation);
  22686. return this;
  22687. },
  22688. /**
  22689. * sets a delay before the next element of the queue is called
  22690. * @param delay Duration of delay in milliseconds
  22691. * @return this.target()
  22692. */
  22693. /**
  22694. * sets or returns the target of this animation
  22695. * @param null || target SVG.Element which should be set as new target
  22696. * @return target || this
  22697. */
  22698. target: function target(_target) {
  22699. if (_target && _target instanceof SVG.Element) {
  22700. this._target = _target;
  22701. return this;
  22702. }
  22703. return this._target;
  22704. },
  22705. // returns the absolute position at a given time
  22706. timeToAbsPos: function timeToAbsPos(timestamp) {
  22707. return (timestamp - this.situation.start) / (this.situation.duration / this._speed);
  22708. },
  22709. // returns the timestamp from a given absolute positon
  22710. absPosToTime: function absPosToTime(absPos) {
  22711. return this.situation.duration / this._speed * absPos + this.situation.start;
  22712. },
  22713. // starts the animationloop
  22714. startAnimFrame: function startAnimFrame() {
  22715. this.stopAnimFrame();
  22716. this.animationFrame = window.requestAnimationFrame(function () {
  22717. this.step();
  22718. }.bind(this));
  22719. },
  22720. // cancels the animationframe
  22721. stopAnimFrame: function stopAnimFrame() {
  22722. window.cancelAnimationFrame(this.animationFrame);
  22723. },
  22724. // kicks off the animation - only does something when the queue is currently not active and at least one situation is set
  22725. start: function start() {
  22726. // dont start if already started
  22727. if (!this.active && this.situation) {
  22728. this.active = true;
  22729. this.startCurrent();
  22730. }
  22731. return this;
  22732. },
  22733. // start the current situation
  22734. startCurrent: function startCurrent() {
  22735. this.situation.start = +new Date() + this.situation.delay / this._speed;
  22736. this.situation.finish = this.situation.start + this.situation.duration / this._speed;
  22737. return this.initAnimations().step();
  22738. },
  22739. /**
  22740. * adds a function / Situation to the animation queue
  22741. * @param fn function / situation to add
  22742. * @return this
  22743. */
  22744. queue: function queue(fn) {
  22745. if (typeof fn === 'function' || fn instanceof SVG.Situation) {
  22746. this.situations.push(fn);
  22747. }
  22748. if (!this.situation) this.situation = this.situations.shift();
  22749. return this;
  22750. },
  22751. /**
  22752. * pulls next element from the queue and execute it
  22753. * @return this
  22754. */
  22755. dequeue: function dequeue() {
  22756. // stop current animation
  22757. this.stop(); // get next animation from queue
  22758. this.situation = this.situations.shift();
  22759. if (this.situation) {
  22760. if (this.situation instanceof SVG.Situation) {
  22761. this.start();
  22762. } else {
  22763. // If it is not a SVG.Situation, then it is a function, we execute it
  22764. this.situation.call(this);
  22765. }
  22766. }
  22767. return this;
  22768. },
  22769. // updates all animations to the current state of the element
  22770. // this is important when one property could be changed from another property
  22771. initAnimations: function initAnimations() {
  22772. var source;
  22773. var s = this.situation;
  22774. if (s.init) return this;
  22775. for (var i in s.animations) {
  22776. source = this.target()[i]();
  22777. if (!Array.isArray(source)) {
  22778. source = [source];
  22779. }
  22780. if (!Array.isArray(s.animations[i])) {
  22781. s.animations[i] = [s.animations[i]];
  22782. } // if(s.animations[i].length > source.length) {
  22783. // source.concat = source.concat(s.animations[i].slice(source.length, s.animations[i].length))
  22784. // }
  22785. for (var j = source.length; j--;) {
  22786. // The condition is because some methods return a normal number instead
  22787. // of a SVG.Number
  22788. if (s.animations[i][j] instanceof SVG.Number) {
  22789. source[j] = new SVG.Number(source[j]);
  22790. }
  22791. s.animations[i][j] = source[j].morph(s.animations[i][j]);
  22792. }
  22793. }
  22794. for (var i in s.attrs) {
  22795. s.attrs[i] = new SVG.MorphObj(this.target().attr(i), s.attrs[i]);
  22796. }
  22797. for (var i in s.styles) {
  22798. s.styles[i] = new SVG.MorphObj(this.target().style(i), s.styles[i]);
  22799. }
  22800. s.initialTransformation = this.target().matrixify();
  22801. s.init = true;
  22802. return this;
  22803. },
  22804. clearQueue: function clearQueue() {
  22805. this.situations = [];
  22806. return this;
  22807. },
  22808. clearCurrent: function clearCurrent() {
  22809. this.situation = null;
  22810. return this;
  22811. },
  22812. /** stops the animation immediately
  22813. * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately.
  22814. * @param clearQueue A Boolean indicating whether to remove queued animation as well.
  22815. * @return this
  22816. */
  22817. stop: function stop(jumpToEnd, clearQueue) {
  22818. var active = this.active;
  22819. this.active = false;
  22820. if (clearQueue) {
  22821. this.clearQueue();
  22822. }
  22823. if (jumpToEnd && this.situation) {
  22824. // initialize the situation if it was not
  22825. !active && this.startCurrent();
  22826. this.atEnd();
  22827. }
  22828. this.stopAnimFrame();
  22829. return this.clearCurrent();
  22830. },
  22831. after: function after(fn) {
  22832. var c = this.last(),
  22833. wrapper = function wrapper(e) {
  22834. if (e.detail.situation == c) {
  22835. fn.call(this, c);
  22836. this.off('finished.fx', wrapper); // prevent memory leak
  22837. }
  22838. };
  22839. this.target().on('finished.fx', wrapper);
  22840. return this._callStart();
  22841. },
  22842. // adds a callback which is called whenever one animation step is performed
  22843. during: function during(fn) {
  22844. var c = this.last(),
  22845. wrapper = function wrapper(e) {
  22846. if (e.detail.situation == c) {
  22847. fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, c);
  22848. }
  22849. }; // see above
  22850. this.target().off('during.fx', wrapper).on('during.fx', wrapper);
  22851. this.after(function () {
  22852. this.off('during.fx', wrapper);
  22853. });
  22854. return this._callStart();
  22855. },
  22856. // calls after ALL animations in the queue are finished
  22857. afterAll: function afterAll(fn) {
  22858. var wrapper = function wrapper(e) {
  22859. fn.call(this);
  22860. this.off('allfinished.fx', wrapper);
  22861. }; // see above
  22862. this.target().off('allfinished.fx', wrapper).on('allfinished.fx', wrapper);
  22863. return this._callStart();
  22864. },
  22865. last: function last() {
  22866. return this.situations.length ? this.situations[this.situations.length - 1] : this.situation;
  22867. },
  22868. // adds one property to the animations
  22869. add: function add(method, args, type) {
  22870. this.last()[type || 'animations'][method] = args;
  22871. return this._callStart();
  22872. },
  22873. /** perform one step of the animation
  22874. * @param ignoreTime Boolean indicating whether to ignore time and use position directly or recalculate position based on time
  22875. * @return this
  22876. */
  22877. step: function step(ignoreTime) {
  22878. // convert current time to an absolute position
  22879. if (!ignoreTime) this.absPos = this.timeToAbsPos(+new Date()); // This part convert an absolute position to a position
  22880. if (this.situation.loops !== false) {
  22881. var absPos, absPosInt, lastLoop; // If the absolute position is below 0, we just treat it as if it was 0
  22882. absPos = Math.max(this.absPos, 0);
  22883. absPosInt = Math.floor(absPos);
  22884. if (this.situation.loops === true || absPosInt < this.situation.loops) {
  22885. this.pos = absPos - absPosInt;
  22886. lastLoop = this.situation.loop;
  22887. this.situation.loop = absPosInt;
  22888. } else {
  22889. this.absPos = this.situation.loops;
  22890. this.pos = 1; // The -1 here is because we don't want to toggle reversed when all the loops have been completed
  22891. lastLoop = this.situation.loop - 1;
  22892. this.situation.loop = this.situation.loops;
  22893. }
  22894. if (this.situation.reversing) {
  22895. // Toggle reversed if an odd number of loops as occured since the last call of step
  22896. this.situation.reversed = this.situation.reversed != Boolean((this.situation.loop - lastLoop) % 2);
  22897. }
  22898. } else {
  22899. // If there are no loop, the absolute position must not be above 1
  22900. this.absPos = Math.min(this.absPos, 1);
  22901. this.pos = this.absPos;
  22902. } // while the absolute position can be below 0, the position must not be below 0
  22903. if (this.pos < 0) this.pos = 0;
  22904. if (this.situation.reversed) this.pos = 1 - this.pos; // apply easing
  22905. var eased = this.situation.ease(this.pos); // call once-callbacks
  22906. for (var i in this.situation.once) {
  22907. if (i > this.lastPos && i <= eased) {
  22908. this.situation.once[i].call(this.target(), this.pos, eased);
  22909. delete this.situation.once[i];
  22910. }
  22911. } // fire during callback with position, eased position and current situation as parameter
  22912. if (this.active) this.target().fire('during', {
  22913. pos: this.pos,
  22914. eased: eased,
  22915. fx: this,
  22916. situation: this.situation
  22917. }); // the user may call stop or finish in the during callback
  22918. // so make sure that we still have a valid situation
  22919. if (!this.situation) {
  22920. return this;
  22921. } // apply the actual animation to every property
  22922. this.eachAt(); // do final code when situation is finished
  22923. if (this.pos == 1 && !this.situation.reversed || this.situation.reversed && this.pos == 0) {
  22924. // stop animation callback
  22925. this.stopAnimFrame(); // fire finished callback with current situation as parameter
  22926. this.target().fire('finished', {
  22927. fx: this,
  22928. situation: this.situation
  22929. });
  22930. if (!this.situations.length) {
  22931. this.target().fire('allfinished'); // Recheck the length since the user may call animate in the afterAll callback
  22932. if (!this.situations.length) {
  22933. this.target().off('.fx'); // there shouldnt be any binding left, but to make sure...
  22934. this.active = false;
  22935. }
  22936. } // start next animation
  22937. if (this.active) this.dequeue();else this.clearCurrent();
  22938. } else if (!this.paused && this.active) {
  22939. // we continue animating when we are not at the end
  22940. this.startAnimFrame();
  22941. } // save last eased position for once callback triggering
  22942. this.lastPos = eased;
  22943. return this;
  22944. },
  22945. // calculates the step for every property and calls block with it
  22946. eachAt: function eachAt() {
  22947. var len,
  22948. at,
  22949. self = this,
  22950. target = this.target(),
  22951. s = this.situation; // apply animations which can be called trough a method
  22952. for (var i in s.animations) {
  22953. at = [].concat(s.animations[i]).map(function (el) {
  22954. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  22955. });
  22956. target[i].apply(target, at);
  22957. } // apply animation which has to be applied with attr()
  22958. for (var i in s.attrs) {
  22959. at = [i].concat(s.attrs[i]).map(function (el) {
  22960. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  22961. });
  22962. target.attr.apply(target, at);
  22963. } // apply animation which has to be applied with style()
  22964. for (var i in s.styles) {
  22965. at = [i].concat(s.styles[i]).map(function (el) {
  22966. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  22967. });
  22968. target.style.apply(target, at);
  22969. } // animate initialTransformation which has to be chained
  22970. if (s.transforms.length) {
  22971. // get initial initialTransformation
  22972. at = s.initialTransformation;
  22973. for (var i = 0, len = s.transforms.length; i < len; i++) {
  22974. // get next transformation in chain
  22975. var a = s.transforms[i]; // multiply matrix directly
  22976. if (a instanceof SVG.Matrix) {
  22977. if (a.relative) {
  22978. at = at.multiply(new SVG.Matrix().morph(a).at(s.ease(this.pos)));
  22979. } else {
  22980. at = at.morph(a).at(s.ease(this.pos));
  22981. }
  22982. continue;
  22983. } // when transformation is absolute we have to reset the needed transformation first
  22984. if (!a.relative) {
  22985. a.undo(at.extract());
  22986. } // and reapply it after
  22987. at = at.multiply(a.at(s.ease(this.pos)));
  22988. } // set new matrix on element
  22989. target.matrix(at);
  22990. }
  22991. return this;
  22992. },
  22993. // adds an once-callback which is called at a specific position and never again
  22994. once: function once(pos, fn, isEased) {
  22995. var c = this.last();
  22996. if (!isEased) pos = c.ease(pos);
  22997. c.once[pos] = fn;
  22998. return this;
  22999. },
  23000. _callStart: function _callStart() {
  23001. setTimeout(function () {
  23002. this.start();
  23003. }.bind(this), 0);
  23004. return this;
  23005. }
  23006. },
  23007. parent: SVG.Element,
  23008. // Add method to parent elements
  23009. construct: {
  23010. // Get fx module or create a new one, then animate with given duration and ease
  23011. animate: function animate(o, ease, delay) {
  23012. return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay);
  23013. },
  23014. delay: function delay(_delay) {
  23015. return (this.fx || (this.fx = new SVG.FX(this))).delay(_delay);
  23016. },
  23017. stop: function stop(jumpToEnd, clearQueue) {
  23018. if (this.fx) {
  23019. this.fx.stop(jumpToEnd, clearQueue);
  23020. }
  23021. return this;
  23022. },
  23023. finish: function finish() {
  23024. if (this.fx) {
  23025. this.fx.finish();
  23026. }
  23027. return this;
  23028. }
  23029. }
  23030. }); // MorphObj is used whenever no morphable object is given
  23031. SVG.MorphObj = SVG.invent({
  23032. create: function create(from, to) {
  23033. // prepare color for morphing
  23034. if (SVG.Color.isColor(to)) return new SVG.Color(from).morph(to); // check if we have a list of values
  23035. if (SVG.regex.delimiter.test(from)) {
  23036. // prepare path for morphing
  23037. if (SVG.regex.pathLetters.test(from)) return new SVG.PathArray(from).morph(to); // prepare value list for morphing
  23038. else return new SVG.Array(from).morph(to);
  23039. } // prepare number for morphing
  23040. if (SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to); // prepare for plain morphing
  23041. this.value = from;
  23042. this.destination = to;
  23043. },
  23044. extend: {
  23045. at: function at(pos, real) {
  23046. return real < 1 ? this.value : this.destination;
  23047. },
  23048. valueOf: function valueOf() {
  23049. return this.value;
  23050. }
  23051. }
  23052. });
  23053. SVG.extend(SVG.FX, {
  23054. // Add animatable attributes
  23055. attr: function attr(a, v, relative) {
  23056. // apply attributes individually
  23057. if (_typeof(a) === 'object') {
  23058. for (var key in a) {
  23059. this.attr(key, a[key]);
  23060. }
  23061. } else {
  23062. this.add(a, v, 'attrs');
  23063. }
  23064. return this;
  23065. },
  23066. // Add animatable plot
  23067. plot: function plot(a, b, c, d) {
  23068. // Lines can be plotted with 4 arguments
  23069. if (arguments.length == 4) {
  23070. return this.plot([a, b, c, d]);
  23071. }
  23072. return this.add('plot', new (this.target().morphArray)(a));
  23073. }
  23074. });
  23075. SVG.Box = SVG.invent({
  23076. create: function create(x, y, width, height) {
  23077. if (_typeof(x) === 'object' && !(x instanceof SVG.Element)) {
  23078. // chromes getBoundingClientRect has no x and y property
  23079. return SVG.Box.call(this, x.left != null ? x.left : x.x, x.top != null ? x.top : x.y, x.width, x.height);
  23080. } else if (arguments.length == 4) {
  23081. this.x = x;
  23082. this.y = y;
  23083. this.width = width;
  23084. this.height = height;
  23085. } // add center, right, bottom...
  23086. fullBox(this);
  23087. }
  23088. });
  23089. SVG.BBox = SVG.invent({
  23090. // Initialize
  23091. create: function create(element) {
  23092. SVG.Box.apply(this, [].slice.call(arguments)); // get values if element is given
  23093. if (element instanceof SVG.Element) {
  23094. var box; // yes this is ugly, but Firefox can be a pain when it comes to elements that are not yet rendered
  23095. try {
  23096. if (!document.documentElement.contains) {
  23097. // This is IE - it does not support contains() for top-level SVGs
  23098. var topParent = element.node;
  23099. while (topParent.parentNode) {
  23100. topParent = topParent.parentNode;
  23101. }
  23102. if (topParent != document) throw new Error('Element not in the dom');
  23103. } else {// the element is NOT in the dom, throw error
  23104. // disabling the check below which fixes issue #76
  23105. // if (!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
  23106. } // find native bbox
  23107. box = element.node.getBBox();
  23108. } catch (e) {
  23109. if (element instanceof SVG.Shape) {
  23110. if (!SVG.parser.draw) {
  23111. // fixes apexcharts/vue-apexcharts #14
  23112. SVG.prepare();
  23113. }
  23114. var clone = element.clone(SVG.parser.draw.instance).show();
  23115. if (clone && clone.node && typeof clone.node.getBBox === 'function') {
  23116. // this check fixes jest unit tests
  23117. box = clone.node.getBBox();
  23118. }
  23119. if (clone && typeof clone.remove === 'function') {
  23120. clone.remove();
  23121. }
  23122. } else {
  23123. box = {
  23124. x: element.node.clientLeft,
  23125. y: element.node.clientTop,
  23126. width: element.node.clientWidth,
  23127. height: element.node.clientHeight
  23128. };
  23129. }
  23130. }
  23131. SVG.Box.call(this, box);
  23132. }
  23133. },
  23134. // Define ancestor
  23135. inherit: SVG.Box,
  23136. // Define Parent
  23137. parent: SVG.Element,
  23138. // Constructor
  23139. construct: {
  23140. // Get bounding box
  23141. bbox: function bbox() {
  23142. return new SVG.BBox(this);
  23143. }
  23144. }
  23145. });
  23146. SVG.BBox.prototype.constructor = SVG.BBox;
  23147. SVG.Matrix = SVG.invent({
  23148. // Initialize
  23149. create: function create(source) {
  23150. var base = arrayToMatrix([1, 0, 0, 1, 0, 0]); // ensure source as object
  23151. source = source === null ? base : 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) : source && _typeof(source) === 'object' ? source : base; // merge source
  23152. for (var i = abcdef.length - 1; i >= 0; --i) {
  23153. this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]];
  23154. }
  23155. },
  23156. // Add methods
  23157. extend: {
  23158. // Extract individual transformations
  23159. extract: function extract() {
  23160. // find delta transform points
  23161. var px = deltaTransformPoint(this, 0, 1);
  23162. deltaTransformPoint(this, 1, 0);
  23163. var skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90;
  23164. return {
  23165. // translation
  23166. x: this.e,
  23167. y: this.f,
  23168. 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),
  23169. 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),
  23170. // rotation
  23171. rotation: skewX,
  23172. a: this.a,
  23173. b: this.b,
  23174. c: this.c,
  23175. d: this.d,
  23176. e: this.e,
  23177. f: this.f,
  23178. matrix: new SVG.Matrix(this)
  23179. };
  23180. },
  23181. // Clone matrix
  23182. clone: function clone() {
  23183. return new SVG.Matrix(this);
  23184. },
  23185. // Morph one matrix into another
  23186. morph: function morph(matrix) {
  23187. // store new destination
  23188. this.destination = new SVG.Matrix(matrix);
  23189. return this;
  23190. },
  23191. // Multiplies by given matrix
  23192. multiply: function multiply(matrix) {
  23193. return new SVG.Matrix(this.native().multiply(parseMatrix(matrix).native()));
  23194. },
  23195. // Inverses matrix
  23196. inverse: function inverse() {
  23197. return new SVG.Matrix(this.native().inverse());
  23198. },
  23199. // Translate matrix
  23200. translate: function translate(x, y) {
  23201. return new SVG.Matrix(this.native().translate(x || 0, y || 0));
  23202. },
  23203. // Convert to native SVGMatrix
  23204. native: function native() {
  23205. // create new matrix
  23206. var matrix = SVG.parser.native.createSVGMatrix(); // update with current values
  23207. for (var i = abcdef.length - 1; i >= 0; i--) {
  23208. matrix[abcdef[i]] = this[abcdef[i]];
  23209. }
  23210. return matrix;
  23211. },
  23212. // Convert matrix to string
  23213. toString: function toString() {
  23214. // Construct the matrix directly, avoid values that are too small
  23215. return 'matrix(' + float32String(this.a) + ',' + float32String(this.b) + ',' + float32String(this.c) + ',' + float32String(this.d) + ',' + float32String(this.e) + ',' + float32String(this.f) + ')';
  23216. }
  23217. },
  23218. // Define parent
  23219. parent: SVG.Element,
  23220. // Add parent method
  23221. construct: {
  23222. // Get current matrix
  23223. ctm: function ctm() {
  23224. return new SVG.Matrix(this.node.getCTM());
  23225. },
  23226. // Get current screen matrix
  23227. screenCTM: function screenCTM() {
  23228. /* https://bugzilla.mozilla.org/show_bug.cgi?id=1344537
  23229. This is needed because FF does not return the transformation matrix
  23230. for the inner coordinate system when getScreenCTM() is called on nested svgs.
  23231. However all other Browsers do that */
  23232. if (this instanceof SVG.Nested) {
  23233. var rect = this.rect(1, 1);
  23234. var m = rect.node.getScreenCTM();
  23235. rect.remove();
  23236. return new SVG.Matrix(m);
  23237. }
  23238. return new SVG.Matrix(this.node.getScreenCTM());
  23239. }
  23240. }
  23241. });
  23242. SVG.Point = SVG.invent({
  23243. // Initialize
  23244. create: function create(x, y) {
  23245. var source,
  23246. base = {
  23247. x: 0,
  23248. y: 0
  23249. }; // ensure source as object
  23250. source = Array.isArray(x) ? {
  23251. x: x[0],
  23252. y: x[1]
  23253. } : _typeof(x) === 'object' ? {
  23254. x: x.x,
  23255. y: x.y
  23256. } : x != null ? {
  23257. x: x,
  23258. y: y != null ? y : x
  23259. } : base; // If y has no value, then x is used has its value
  23260. // merge source
  23261. this.x = source.x;
  23262. this.y = source.y;
  23263. },
  23264. // Add methods
  23265. extend: {
  23266. // Clone point
  23267. clone: function clone() {
  23268. return new SVG.Point(this);
  23269. },
  23270. // Morph one point into another
  23271. morph: function morph(x, y) {
  23272. // store new destination
  23273. this.destination = new SVG.Point(x, y);
  23274. return this;
  23275. }
  23276. }
  23277. });
  23278. SVG.extend(SVG.Element, {
  23279. // Get point
  23280. point: function point(x, y) {
  23281. return new SVG.Point(x, y).transform(this.screenCTM().inverse());
  23282. }
  23283. });
  23284. SVG.extend(SVG.Element, {
  23285. // Set svg element attribute
  23286. attr: function attr(a, v, n) {
  23287. // act as full getter
  23288. if (a == null) {
  23289. // get an object of attributes
  23290. a = {};
  23291. v = this.node.attributes;
  23292. for (var n = v.length - 1; n >= 0; n--) {
  23293. a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue;
  23294. }
  23295. return a;
  23296. } else if (_typeof(a) === 'object') {
  23297. // apply every attribute individually if an object is passed
  23298. for (var v_ in a) {
  23299. this.attr(v_, a[v_]);
  23300. }
  23301. } else if (v === null) {
  23302. // remove value
  23303. this.node.removeAttribute(a);
  23304. } else if (v == null) {
  23305. // act as a getter if the first and only argument is not an object
  23306. v = this.node.getAttribute(a);
  23307. return v == null ? SVG.defaults.attrs[a] : SVG.regex.isNumber.test(v) ? parseFloat(v) : v;
  23308. } else {
  23309. // BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0
  23310. if (a == 'stroke-width') {
  23311. this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null);
  23312. } else if (a == 'stroke') {
  23313. this._stroke = v;
  23314. } // convert image fill and stroke to patterns
  23315. if (a == 'fill' || a == 'stroke') {
  23316. if (SVG.regex.isImage.test(v)) {
  23317. v = this.doc().defs().image(v, 0, 0);
  23318. }
  23319. if (v instanceof SVG.Image) {
  23320. v = this.doc().defs().pattern(0, 0, function () {
  23321. this.add(v);
  23322. });
  23323. }
  23324. } // ensure correct numeric values (also accepts NaN and Infinity)
  23325. if (typeof v === 'number') {
  23326. v = new SVG.Number(v);
  23327. } // ensure full hex color
  23328. else if (SVG.Color.isColor(v)) {
  23329. v = new SVG.Color(v);
  23330. } // parse array values
  23331. else if (Array.isArray(v)) {
  23332. v = new SVG.Array(v);
  23333. } // if the passed attribute is leading...
  23334. if (a == 'leading') {
  23335. // ... call the leading method instead
  23336. if (this.leading) {
  23337. this.leading(v);
  23338. }
  23339. } else {
  23340. // set given attribute on node
  23341. typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString());
  23342. } // rebuild if required
  23343. if (this.rebuild && (a == 'font-size' || a == 'x')) {
  23344. this.rebuild(a, v);
  23345. }
  23346. }
  23347. return this;
  23348. }
  23349. });
  23350. SVG.extend(SVG.Element, {
  23351. // Add transformations
  23352. transform: function transform(o, relative) {
  23353. // get target in case of the fx module, otherwise reference this
  23354. var target = this,
  23355. matrix;
  23356. // act as a getter
  23357. if (_typeof(o) !== 'object') {
  23358. // get current matrix
  23359. matrix = new SVG.Matrix(target).extract();
  23360. return typeof o === 'string' ? matrix[o] : matrix;
  23361. } // get current matrix
  23362. matrix = new SVG.Matrix(target); // ensure relative flag
  23363. relative = !!relative || !!o.relative; // act on matrix
  23364. if (o.a != null) {
  23365. matrix = relative // relative
  23366. ? matrix.multiply(new SVG.Matrix(o)) // absolute
  23367. : new SVG.Matrix(o);
  23368. }
  23369. return this.attr('transform', matrix);
  23370. }
  23371. });
  23372. SVG.extend(SVG.Element, {
  23373. // Reset all transformations
  23374. untransform: function untransform() {
  23375. return this.attr('transform', null);
  23376. },
  23377. // merge the whole transformation chain into one matrix and returns it
  23378. matrixify: function matrixify() {
  23379. var matrix = (this.attr('transform') || '').split(SVG.regex.transforms).slice(0, -1).map(function (str) {
  23380. // generate key => value pairs
  23381. var kv = str.trim().split('(');
  23382. return [kv[0], kv[1].split(SVG.regex.delimiter).map(function (str) {
  23383. return parseFloat(str);
  23384. })];
  23385. }) // merge every transformation into one matrix
  23386. .reduce(function (matrix, transform) {
  23387. if (transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]));
  23388. return matrix[transform[0]].apply(matrix, transform[1]);
  23389. }, new SVG.Matrix());
  23390. return matrix;
  23391. },
  23392. // add an element to another parent without changing the visual representation on the screen
  23393. toParent: function toParent(parent) {
  23394. if (this == parent) return this;
  23395. var ctm = this.screenCTM();
  23396. var pCtm = parent.screenCTM().inverse();
  23397. this.addTo(parent).untransform().transform(pCtm.multiply(ctm));
  23398. return this;
  23399. },
  23400. // same as above with parent equals root-svg
  23401. toDoc: function toDoc() {
  23402. return this.toParent(this.doc());
  23403. }
  23404. });
  23405. SVG.Transformation = SVG.invent({
  23406. create: function create(source, inversed) {
  23407. if (arguments.length > 1 && typeof inversed !== 'boolean') {
  23408. return this.constructor.call(this, [].slice.call(arguments));
  23409. }
  23410. if (Array.isArray(source)) {
  23411. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  23412. this[this.arguments[i]] = source[i];
  23413. }
  23414. } else if (source && _typeof(source) === 'object') {
  23415. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  23416. this[this.arguments[i]] = source[this.arguments[i]];
  23417. }
  23418. }
  23419. this.inversed = false;
  23420. if (inversed === true) {
  23421. this.inversed = true;
  23422. }
  23423. }
  23424. });
  23425. SVG.Translate = SVG.invent({
  23426. parent: SVG.Matrix,
  23427. inherit: SVG.Transformation,
  23428. create: function create(source, inversed) {
  23429. this.constructor.apply(this, [].slice.call(arguments));
  23430. },
  23431. extend: {
  23432. arguments: ['transformedX', 'transformedY'],
  23433. method: 'translate'
  23434. }
  23435. });
  23436. SVG.extend(SVG.Element, {
  23437. // Dynamic style generator
  23438. style: function style(s, v) {
  23439. if (arguments.length == 0) {
  23440. // get full style
  23441. return this.node.style.cssText || '';
  23442. } else if (arguments.length < 2) {
  23443. // apply every style individually if an object is passed
  23444. if (_typeof(s) === 'object') {
  23445. for (var v_ in s) {
  23446. this.style(v_, s[v_]);
  23447. }
  23448. } else if (SVG.regex.isCss.test(s)) {
  23449. // parse css string
  23450. s = s.split(/\s*;\s*/) // filter out suffix ; and stuff like ;;
  23451. .filter(function (e) {
  23452. return !!e;
  23453. }).map(function (e) {
  23454. return e.split(/\s*:\s*/);
  23455. }); // apply every definition individually
  23456. while (v = s.pop()) {
  23457. this.style(v[0], v[1]);
  23458. }
  23459. } else {
  23460. // act as a getter if the first and only argument is not an object
  23461. return this.node.style[camelCase(s)];
  23462. }
  23463. } else {
  23464. this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v;
  23465. }
  23466. return this;
  23467. }
  23468. });
  23469. SVG.Parent = SVG.invent({
  23470. // Initialize node
  23471. create: function create(element) {
  23472. this.constructor.call(this, element);
  23473. },
  23474. // Inherit from
  23475. inherit: SVG.Element,
  23476. // Add class methods
  23477. extend: {
  23478. // Returns all child elements
  23479. children: function children() {
  23480. return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function (node) {
  23481. return SVG.adopt(node);
  23482. });
  23483. },
  23484. // Add given element at a position
  23485. add: function add(element, i) {
  23486. if (i == null) {
  23487. this.node.appendChild(element.node);
  23488. } else if (element.node != this.node.childNodes[i]) {
  23489. this.node.insertBefore(element.node, this.node.childNodes[i]);
  23490. }
  23491. return this;
  23492. },
  23493. // Basically does the same as `add()` but returns the added element instead
  23494. put: function put(element, i) {
  23495. this.add(element, i);
  23496. return element;
  23497. },
  23498. // Checks if the given element is a child
  23499. has: function has(element) {
  23500. return this.index(element) >= 0;
  23501. },
  23502. // Gets index of given element
  23503. index: function index(element) {
  23504. return [].slice.call(this.node.childNodes).indexOf(element.node);
  23505. },
  23506. // Get a element at the given index
  23507. get: function get(i) {
  23508. return SVG.adopt(this.node.childNodes[i]);
  23509. },
  23510. // Get first child
  23511. first: function first() {
  23512. return this.get(0);
  23513. },
  23514. // Get the last child
  23515. last: function last() {
  23516. return this.get(this.node.childNodes.length - 1);
  23517. },
  23518. // Iterates over all children and invokes a given block
  23519. each: function each(block, deep) {
  23520. var il,
  23521. children = this.children();
  23522. for (var i = 0, il = children.length; i < il; i++) {
  23523. if (children[i] instanceof SVG.Element) {
  23524. block.apply(children[i], [i, children]);
  23525. }
  23526. if (deep && children[i] instanceof SVG.Container) {
  23527. children[i].each(block, deep);
  23528. }
  23529. }
  23530. return this;
  23531. },
  23532. // Remove a given child
  23533. removeElement: function removeElement(element) {
  23534. this.node.removeChild(element.node);
  23535. return this;
  23536. },
  23537. // Remove all elements in this container
  23538. clear: function clear() {
  23539. // remove children
  23540. while (this.node.hasChildNodes()) {
  23541. this.node.removeChild(this.node.lastChild);
  23542. } // remove defs reference
  23543. delete this._defs;
  23544. return this;
  23545. },
  23546. // Get defs
  23547. defs: function defs() {
  23548. return this.doc().defs();
  23549. }
  23550. }
  23551. });
  23552. SVG.extend(SVG.Parent, {
  23553. ungroup: function ungroup(parent, depth) {
  23554. if (depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this;
  23555. parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent));
  23556. depth = depth || Infinity;
  23557. this.each(function () {
  23558. if (this instanceof SVG.Defs) return this;
  23559. if (this instanceof SVG.Parent) return this.ungroup(parent, depth - 1);
  23560. return this.toParent(parent);
  23561. });
  23562. this.node.firstChild || this.remove();
  23563. return this;
  23564. },
  23565. flatten: function flatten(parent, depth) {
  23566. return this.ungroup(parent, depth);
  23567. }
  23568. });
  23569. SVG.Container = SVG.invent({
  23570. // Initialize node
  23571. create: function create(element) {
  23572. this.constructor.call(this, element);
  23573. },
  23574. // Inherit from
  23575. inherit: SVG.Parent
  23576. });
  23577. SVG.ViewBox = SVG.invent({
  23578. // Define parent
  23579. parent: SVG.Container,
  23580. // Add parent method
  23581. construct: {}
  23582. }) // Add events to elements
  23583. ;
  23584. ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove', // , 'mouseenter' -> not supported by IE
  23585. // , 'mouseleave' -> not supported by IE
  23586. 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].forEach(function (event) {
  23587. // add event to SVG.Element
  23588. SVG.Element.prototype[event] = function (f) {
  23589. // bind event to element rather than element node
  23590. SVG.on(this.node, event, f);
  23591. return this;
  23592. };
  23593. }); // Initialize listeners stack
  23594. SVG.listeners = [];
  23595. SVG.handlerMap = [];
  23596. SVG.listenerId = 0; // Add event binder in the SVG namespace
  23597. SVG.on = function (node, event, listener, binding, options) {
  23598. // create listener, get object-index
  23599. var l = listener.bind(binding || node.instance || node),
  23600. index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1,
  23601. ev = event.split('.')[0],
  23602. ns = event.split('.')[1] || '*'; // ensure valid object
  23603. SVG.listeners[index] = SVG.listeners[index] || {};
  23604. SVG.listeners[index][ev] = SVG.listeners[index][ev] || {};
  23605. SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {};
  23606. if (!listener._svgjsListenerId) {
  23607. listener._svgjsListenerId = ++SVG.listenerId;
  23608. } // reference listener
  23609. SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l; // add listener
  23610. node.addEventListener(ev, l, options || {
  23611. passive: true
  23612. });
  23613. }; // Add event unbinder in the SVG namespace
  23614. SVG.off = function (node, event, listener) {
  23615. var index = SVG.handlerMap.indexOf(node),
  23616. ev = event && event.split('.')[0],
  23617. ns = event && event.split('.')[1],
  23618. namespace = '';
  23619. if (index == -1) return;
  23620. if (listener) {
  23621. if (typeof listener === 'function') listener = listener._svgjsListenerId;
  23622. if (!listener) return; // remove listener reference
  23623. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) {
  23624. // remove listener
  23625. node.removeEventListener(ev, SVG.listeners[index][ev][ns || '*'][listener], false);
  23626. delete SVG.listeners[index][ev][ns || '*'][listener];
  23627. }
  23628. } else if (ns && ev) {
  23629. // remove all listeners for a namespaced event
  23630. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns]) {
  23631. for (var listener_ in SVG.listeners[index][ev][ns]) {
  23632. SVG.off(node, [ev, ns].join('.'), listener_);
  23633. }
  23634. delete SVG.listeners[index][ev][ns];
  23635. }
  23636. } else if (ns) {
  23637. // remove all listeners for a specific namespace
  23638. for (var event_ in SVG.listeners[index]) {
  23639. for (var namespace in SVG.listeners[index][event_]) {
  23640. if (ns === namespace) {
  23641. SVG.off(node, [event_, ns].join('.'));
  23642. }
  23643. }
  23644. }
  23645. } else if (ev) {
  23646. // remove all listeners for the event
  23647. if (SVG.listeners[index][ev]) {
  23648. for (var namespace in SVG.listeners[index][ev]) {
  23649. SVG.off(node, [ev, namespace].join('.'));
  23650. }
  23651. delete SVG.listeners[index][ev];
  23652. }
  23653. } else {
  23654. // remove all listeners on a given node
  23655. for (var event_ in SVG.listeners[index]) {
  23656. SVG.off(node, event_);
  23657. }
  23658. delete SVG.listeners[index];
  23659. delete SVG.handlerMap[index];
  23660. }
  23661. }; //
  23662. SVG.extend(SVG.Element, {
  23663. // Bind given event to listener
  23664. on: function on(event, listener, binding, options) {
  23665. SVG.on(this.node, event, listener, binding, options);
  23666. return this;
  23667. },
  23668. // Unbind event from listener
  23669. off: function off(event, listener) {
  23670. SVG.off(this.node, event, listener);
  23671. return this;
  23672. },
  23673. // Fire given event
  23674. fire: function fire(event, data) {
  23675. // Dispatch event
  23676. if (event instanceof window.Event) {
  23677. this.node.dispatchEvent(event);
  23678. } else {
  23679. this.node.dispatchEvent(event = new SVG.CustomEvent(event, {
  23680. detail: data,
  23681. cancelable: true
  23682. }));
  23683. }
  23684. this._event = event;
  23685. return this;
  23686. },
  23687. event: function event() {
  23688. return this._event;
  23689. }
  23690. });
  23691. SVG.Defs = SVG.invent({
  23692. // Initialize node
  23693. create: 'defs',
  23694. // Inherit from
  23695. inherit: SVG.Container
  23696. });
  23697. SVG.G = SVG.invent({
  23698. // Initialize node
  23699. create: 'g',
  23700. // Inherit from
  23701. inherit: SVG.Container,
  23702. // Add class methods
  23703. extend: {
  23704. // Move over x-axis
  23705. x: function x(_x2) {
  23706. return _x2 == null ? this.transform('x') : this.transform({
  23707. x: _x2 - this.x()
  23708. }, true);
  23709. }
  23710. },
  23711. // Add parent method
  23712. construct: {
  23713. // Create a group element
  23714. group: function group() {
  23715. return this.put(new SVG.G());
  23716. }
  23717. }
  23718. });
  23719. SVG.Doc = SVG.invent({
  23720. // Initialize node
  23721. create: function create(element) {
  23722. if (element) {
  23723. // ensure the presence of a dom element
  23724. element = typeof element === 'string' ? document.getElementById(element) : element; // If the target is an svg element, use that element as the main wrapper.
  23725. // This allows svg.js to work with svg documents as well.
  23726. if (element.nodeName == 'svg') {
  23727. this.constructor.call(this, element);
  23728. } else {
  23729. this.constructor.call(this, SVG.create('svg'));
  23730. element.appendChild(this.node);
  23731. this.size('100%', '100%');
  23732. } // set svg element attributes and ensure defs node
  23733. this.namespace().defs();
  23734. }
  23735. },
  23736. // Inherit from
  23737. inherit: SVG.Container,
  23738. // Add class methods
  23739. extend: {
  23740. // Add namespaces
  23741. namespace: function namespace() {
  23742. return this.attr({
  23743. xmlns: SVG.ns,
  23744. version: '1.1'
  23745. }).attr('xmlns:xlink', SVG.xlink, SVG.xmlns).attr('xmlns:svgjs', SVG.svgjs, SVG.xmlns);
  23746. },
  23747. // Creates and returns defs element
  23748. defs: function defs() {
  23749. if (!this._defs) {
  23750. var defs; // Find or create a defs element in this instance
  23751. if (defs = this.node.getElementsByTagName('defs')[0]) {
  23752. this._defs = SVG.adopt(defs);
  23753. } else {
  23754. this._defs = new SVG.Defs();
  23755. } // Make sure the defs node is at the end of the stack
  23756. this.node.appendChild(this._defs.node);
  23757. }
  23758. return this._defs;
  23759. },
  23760. // custom parent method
  23761. parent: function parent() {
  23762. if (!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null;
  23763. return this.node.parentNode;
  23764. },
  23765. // Removes the doc from the DOM
  23766. remove: function remove() {
  23767. if (this.parent()) {
  23768. this.parent().removeChild(this.node);
  23769. }
  23770. return this;
  23771. },
  23772. clear: function clear() {
  23773. // remove children
  23774. while (this.node.hasChildNodes()) {
  23775. this.node.removeChild(this.node.lastChild);
  23776. } // remove defs reference
  23777. delete this._defs; // add back parser
  23778. if (SVG.parser.draw && !SVG.parser.draw.parentNode) {
  23779. this.node.appendChild(SVG.parser.draw);
  23780. }
  23781. return this;
  23782. },
  23783. clone: function clone(parent) {
  23784. // write dom data to the dom so the clone can pickup the data
  23785. this.writeDataToDom(); // get reference to node
  23786. var node = this.node; // clone element and assign new id
  23787. var clone = assignNewId(node.cloneNode(true)); // insert the clone in the given parent or after myself
  23788. if (parent) {
  23789. (parent.node || parent).appendChild(clone.node);
  23790. } else {
  23791. node.parentNode.insertBefore(clone.node, node.nextSibling);
  23792. }
  23793. return clone;
  23794. }
  23795. }
  23796. }); // ### This module adds backward / forward functionality to elements.
  23797. //
  23798. SVG.extend(SVG.Element, {// Get all siblings, including myself
  23799. });
  23800. SVG.Gradient = SVG.invent({
  23801. // Initialize node
  23802. create: function create(type) {
  23803. this.constructor.call(this, SVG.create(type + 'Gradient')); // store type
  23804. this.type = type;
  23805. },
  23806. // Inherit from
  23807. inherit: SVG.Container,
  23808. // Add class methods
  23809. extend: {
  23810. // Add a color stop
  23811. at: function at(offset, color, opacity) {
  23812. return this.put(new SVG.Stop()).update(offset, color, opacity);
  23813. },
  23814. // Update gradient
  23815. update: function update(block) {
  23816. // remove all stops
  23817. this.clear(); // invoke passed block
  23818. if (typeof block === 'function') {
  23819. block.call(this, this);
  23820. }
  23821. return this;
  23822. },
  23823. // Return the fill id
  23824. fill: function fill() {
  23825. return 'url(#' + this.id() + ')';
  23826. },
  23827. // Alias string convertion to fill
  23828. toString: function toString() {
  23829. return this.fill();
  23830. },
  23831. // custom attr to handle transform
  23832. attr: function attr(a, b, c) {
  23833. if (a == 'transform') a = 'gradientTransform';
  23834. return SVG.Container.prototype.attr.call(this, a, b, c);
  23835. }
  23836. },
  23837. // Add parent method
  23838. construct: {
  23839. // Create gradient element in defs
  23840. gradient: function gradient(type, block) {
  23841. return this.defs().gradient(type, block);
  23842. }
  23843. }
  23844. }); // Add animatable methods to both gradient and fx module
  23845. SVG.extend(SVG.Gradient, SVG.FX, {
  23846. // From position
  23847. from: function from(x, y) {
  23848. return (this._target || this).type == 'radial' ? this.attr({
  23849. fx: new SVG.Number(x),
  23850. fy: new SVG.Number(y)
  23851. }) : this.attr({
  23852. x1: new SVG.Number(x),
  23853. y1: new SVG.Number(y)
  23854. });
  23855. },
  23856. // To position
  23857. to: function to(x, y) {
  23858. return (this._target || this).type == 'radial' ? this.attr({
  23859. cx: new SVG.Number(x),
  23860. cy: new SVG.Number(y)
  23861. }) : this.attr({
  23862. x2: new SVG.Number(x),
  23863. y2: new SVG.Number(y)
  23864. });
  23865. }
  23866. }); // Base gradient generation
  23867. SVG.extend(SVG.Defs, {
  23868. // define gradient
  23869. gradient: function gradient(type, block) {
  23870. return this.put(new SVG.Gradient(type)).update(block);
  23871. }
  23872. });
  23873. SVG.Stop = SVG.invent({
  23874. // Initialize node
  23875. create: 'stop',
  23876. // Inherit from
  23877. inherit: SVG.Element,
  23878. // Add class methods
  23879. extend: {
  23880. // add color stops
  23881. update: function update(o) {
  23882. if (typeof o === 'number' || o instanceof SVG.Number) {
  23883. o = {
  23884. offset: arguments[0],
  23885. color: arguments[1],
  23886. opacity: arguments[2]
  23887. };
  23888. } // set attributes
  23889. if (o.opacity != null) this.attr('stop-opacity', o.opacity);
  23890. if (o.color != null) this.attr('stop-color', o.color);
  23891. if (o.offset != null) this.attr('offset', new SVG.Number(o.offset));
  23892. return this;
  23893. }
  23894. }
  23895. });
  23896. SVG.Pattern = SVG.invent({
  23897. // Initialize node
  23898. create: 'pattern',
  23899. // Inherit from
  23900. inherit: SVG.Container,
  23901. // Add class methods
  23902. extend: {
  23903. // Return the fill id
  23904. fill: function fill() {
  23905. return 'url(#' + this.id() + ')';
  23906. },
  23907. // Update pattern by rebuilding
  23908. update: function update(block) {
  23909. // remove content
  23910. this.clear(); // invoke passed block
  23911. if (typeof block === 'function') {
  23912. block.call(this, this);
  23913. }
  23914. return this;
  23915. },
  23916. // Alias string convertion to fill
  23917. toString: function toString() {
  23918. return this.fill();
  23919. },
  23920. // custom attr to handle transform
  23921. attr: function attr(a, b, c) {
  23922. if (a == 'transform') a = 'patternTransform';
  23923. return SVG.Container.prototype.attr.call(this, a, b, c);
  23924. }
  23925. },
  23926. // Add parent method
  23927. construct: {
  23928. // Create pattern element in defs
  23929. pattern: function pattern(width, height, block) {
  23930. return this.defs().pattern(width, height, block);
  23931. }
  23932. }
  23933. });
  23934. SVG.extend(SVG.Defs, {
  23935. // Define gradient
  23936. pattern: function pattern(width, height, block) {
  23937. return this.put(new SVG.Pattern()).update(block).attr({
  23938. x: 0,
  23939. y: 0,
  23940. width: width,
  23941. height: height,
  23942. patternUnits: 'userSpaceOnUse'
  23943. });
  23944. }
  23945. });
  23946. SVG.Shape = SVG.invent({
  23947. // Initialize node
  23948. create: function create(element) {
  23949. this.constructor.call(this, element);
  23950. },
  23951. // Inherit from
  23952. inherit: SVG.Element
  23953. });
  23954. SVG.Symbol = SVG.invent({
  23955. // Initialize node
  23956. create: 'symbol',
  23957. // Inherit from
  23958. inherit: SVG.Container,
  23959. construct: {
  23960. // create symbol
  23961. symbol: function symbol() {
  23962. return this.put(new SVG.Symbol());
  23963. }
  23964. }
  23965. });
  23966. SVG.Use = SVG.invent({
  23967. // Initialize node
  23968. create: 'use',
  23969. // Inherit from
  23970. inherit: SVG.Shape,
  23971. // Add class methods
  23972. extend: {
  23973. // Use element as a reference
  23974. element: function element(_element, file) {
  23975. // Set lined element
  23976. return this.attr('href', (file || '') + '#' + _element, SVG.xlink);
  23977. }
  23978. },
  23979. // Add parent method
  23980. construct: {
  23981. // Create a use element
  23982. use: function use(element, file) {
  23983. return this.put(new SVG.Use()).element(element, file);
  23984. }
  23985. }
  23986. });
  23987. SVG.Rect = SVG.invent({
  23988. // Initialize node
  23989. create: 'rect',
  23990. // Inherit from
  23991. inherit: SVG.Shape,
  23992. // Add parent method
  23993. construct: {
  23994. // Create a rect element
  23995. rect: function rect(width, height) {
  23996. return this.put(new SVG.Rect()).size(width, height);
  23997. }
  23998. }
  23999. });
  24000. SVG.Circle = SVG.invent({
  24001. // Initialize node
  24002. create: 'circle',
  24003. // Inherit from
  24004. inherit: SVG.Shape,
  24005. // Add parent method
  24006. construct: {
  24007. // Create circle element, based on ellipse
  24008. circle: function circle(size) {
  24009. return this.put(new SVG.Circle()).rx(new SVG.Number(size).divide(2)).move(0, 0);
  24010. }
  24011. }
  24012. });
  24013. SVG.extend(SVG.Circle, SVG.FX, {
  24014. // Radius x value
  24015. rx: function rx(_rx) {
  24016. return this.attr('r', _rx);
  24017. },
  24018. // Alias radius x value
  24019. ry: function ry(_ry) {
  24020. return this.rx(_ry);
  24021. }
  24022. });
  24023. SVG.Ellipse = SVG.invent({
  24024. // Initialize node
  24025. create: 'ellipse',
  24026. // Inherit from
  24027. inherit: SVG.Shape,
  24028. // Add parent method
  24029. construct: {
  24030. // Create an ellipse
  24031. ellipse: function ellipse(width, height) {
  24032. return this.put(new SVG.Ellipse()).size(width, height).move(0, 0);
  24033. }
  24034. }
  24035. });
  24036. SVG.extend(SVG.Ellipse, SVG.Rect, SVG.FX, {
  24037. // Radius x value
  24038. rx: function rx(_rx2) {
  24039. return this.attr('rx', _rx2);
  24040. },
  24041. // Radius y value
  24042. ry: function ry(_ry2) {
  24043. return this.attr('ry', _ry2);
  24044. }
  24045. }); // Add common method
  24046. SVG.extend(SVG.Circle, SVG.Ellipse, {
  24047. // Move over x-axis
  24048. x: function x(_x3) {
  24049. return _x3 == null ? this.cx() - this.rx() : this.cx(_x3 + this.rx());
  24050. },
  24051. // Move over y-axis
  24052. y: function y(_y2) {
  24053. return _y2 == null ? this.cy() - this.ry() : this.cy(_y2 + this.ry());
  24054. },
  24055. // Move by center over x-axis
  24056. cx: function cx(x) {
  24057. return x == null ? this.attr('cx') : this.attr('cx', x);
  24058. },
  24059. // Move by center over y-axis
  24060. cy: function cy(y) {
  24061. return y == null ? this.attr('cy') : this.attr('cy', y);
  24062. },
  24063. // Set width of element
  24064. width: function width(_width2) {
  24065. return _width2 == null ? this.rx() * 2 : this.rx(new SVG.Number(_width2).divide(2));
  24066. },
  24067. // Set height of element
  24068. height: function height(_height2) {
  24069. return _height2 == null ? this.ry() * 2 : this.ry(new SVG.Number(_height2).divide(2));
  24070. },
  24071. // Custom size function
  24072. size: function size(width, height) {
  24073. var p = proportionalSize(this, width, height);
  24074. return this.rx(new SVG.Number(p.width).divide(2)).ry(new SVG.Number(p.height).divide(2));
  24075. }
  24076. });
  24077. SVG.Line = SVG.invent({
  24078. // Initialize node
  24079. create: 'line',
  24080. // Inherit from
  24081. inherit: SVG.Shape,
  24082. // Add class methods
  24083. extend: {
  24084. // Get array
  24085. array: function array() {
  24086. return new SVG.PointArray([[this.attr('x1'), this.attr('y1')], [this.attr('x2'), this.attr('y2')]]);
  24087. },
  24088. // Overwrite native plot() method
  24089. plot: function plot(x1, y1, x2, y2) {
  24090. if (x1 == null) {
  24091. return this.array();
  24092. } else if (typeof y1 !== 'undefined') {
  24093. x1 = {
  24094. x1: x1,
  24095. y1: y1,
  24096. x2: x2,
  24097. y2: y2
  24098. };
  24099. } else {
  24100. x1 = new SVG.PointArray(x1).toLine();
  24101. }
  24102. return this.attr(x1);
  24103. },
  24104. // Move by left top corner
  24105. move: function move(x, y) {
  24106. return this.attr(this.array().move(x, y).toLine());
  24107. },
  24108. // Set element size to given width and height
  24109. size: function size(width, height) {
  24110. var p = proportionalSize(this, width, height);
  24111. return this.attr(this.array().size(p.width, p.height).toLine());
  24112. }
  24113. },
  24114. // Add parent method
  24115. construct: {
  24116. // Create a line element
  24117. line: function line(x1, y1, x2, y2) {
  24118. // make sure plot is called as a setter
  24119. // x1 is not necessarily a number, it can also be an array, a string and a SVG.PointArray
  24120. return SVG.Line.prototype.plot.apply(this.put(new SVG.Line()), x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]);
  24121. }
  24122. }
  24123. });
  24124. SVG.Polyline = SVG.invent({
  24125. // Initialize node
  24126. create: 'polyline',
  24127. // Inherit from
  24128. inherit: SVG.Shape,
  24129. // Add parent method
  24130. construct: {
  24131. // Create a wrapped polyline element
  24132. polyline: function polyline(p) {
  24133. // make sure plot is called as a setter
  24134. return this.put(new SVG.Polyline()).plot(p || new SVG.PointArray());
  24135. }
  24136. }
  24137. });
  24138. SVG.Polygon = SVG.invent({
  24139. // Initialize node
  24140. create: 'polygon',
  24141. // Inherit from
  24142. inherit: SVG.Shape,
  24143. // Add parent method
  24144. construct: {
  24145. // Create a wrapped polygon element
  24146. polygon: function polygon(p) {
  24147. // make sure plot is called as a setter
  24148. return this.put(new SVG.Polygon()).plot(p || new SVG.PointArray());
  24149. }
  24150. }
  24151. }); // Add polygon-specific functions
  24152. SVG.extend(SVG.Polyline, SVG.Polygon, {
  24153. // Get array
  24154. array: function array() {
  24155. return this._array || (this._array = new SVG.PointArray(this.attr('points')));
  24156. },
  24157. // Plot new path
  24158. plot: function plot(p) {
  24159. return p == null ? this.array() : this.clear().attr('points', typeof p === 'string' ? p : this._array = new SVG.PointArray(p));
  24160. },
  24161. // Clear array cache
  24162. clear: function clear() {
  24163. delete this._array;
  24164. return this;
  24165. },
  24166. // Move by left top corner
  24167. move: function move(x, y) {
  24168. return this.attr('points', this.array().move(x, y));
  24169. },
  24170. // Set element size to given width and height
  24171. size: function size(width, height) {
  24172. var p = proportionalSize(this, width, height);
  24173. return this.attr('points', this.array().size(p.width, p.height));
  24174. }
  24175. }); // unify all point to point elements
  24176. SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, {
  24177. // Define morphable array
  24178. morphArray: SVG.PointArray,
  24179. // Move by left top corner over x-axis
  24180. x: function x(_x4) {
  24181. return _x4 == null ? this.bbox().x : this.move(_x4, this.bbox().y);
  24182. },
  24183. // Move by left top corner over y-axis
  24184. y: function y(_y3) {
  24185. return _y3 == null ? this.bbox().y : this.move(this.bbox().x, _y3);
  24186. },
  24187. // Set width of element
  24188. width: function width(_width3) {
  24189. var b = this.bbox();
  24190. return _width3 == null ? b.width : this.size(_width3, b.height);
  24191. },
  24192. // Set height of element
  24193. height: function height(_height3) {
  24194. var b = this.bbox();
  24195. return _height3 == null ? b.height : this.size(b.width, _height3);
  24196. }
  24197. });
  24198. SVG.Path = SVG.invent({
  24199. // Initialize node
  24200. create: 'path',
  24201. // Inherit from
  24202. inherit: SVG.Shape,
  24203. // Add class methods
  24204. extend: {
  24205. // Define morphable array
  24206. morphArray: SVG.PathArray,
  24207. // Get array
  24208. array: function array() {
  24209. return this._array || (this._array = new SVG.PathArray(this.attr('d')));
  24210. },
  24211. // Plot new path
  24212. plot: function plot(d) {
  24213. return d == null ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : this._array = new SVG.PathArray(d));
  24214. },
  24215. // Clear array cache
  24216. clear: function clear() {
  24217. delete this._array;
  24218. return this;
  24219. }
  24220. },
  24221. // Add parent method
  24222. construct: {
  24223. // Create a wrapped path element
  24224. path: function path(d) {
  24225. // make sure plot is called as a setter
  24226. return this.put(new SVG.Path()).plot(d || new SVG.PathArray());
  24227. }
  24228. }
  24229. });
  24230. SVG.Image = SVG.invent({
  24231. // Initialize node
  24232. create: 'image',
  24233. // Inherit from
  24234. inherit: SVG.Shape,
  24235. // Add class methods
  24236. extend: {
  24237. // (re)load image
  24238. load: function load(url) {
  24239. if (!url) return this;
  24240. var self = this,
  24241. img = new window.Image(); // preload image
  24242. SVG.on(img, 'load', function () {
  24243. SVG.off(img);
  24244. var p = self.parent(SVG.Pattern);
  24245. if (p === null) return; // ensure image size
  24246. if (self.width() == 0 && self.height() == 0) {
  24247. self.size(img.width, img.height);
  24248. } // ensure pattern size if not set
  24249. if (p && p.width() == 0 && p.height() == 0) {
  24250. p.size(self.width(), self.height());
  24251. } // callback
  24252. if (typeof self._loaded === 'function') {
  24253. self._loaded.call(self, {
  24254. width: img.width,
  24255. height: img.height,
  24256. ratio: img.width / img.height,
  24257. url: url
  24258. });
  24259. }
  24260. });
  24261. SVG.on(img, 'error', function (e) {
  24262. SVG.off(img);
  24263. if (typeof self._error === 'function') {
  24264. self._error.call(self, e);
  24265. }
  24266. });
  24267. return this.attr('href', img.src = this.src = url, SVG.xlink);
  24268. },
  24269. // Add loaded callback
  24270. loaded: function loaded(_loaded) {
  24271. this._loaded = _loaded;
  24272. return this;
  24273. },
  24274. error: function error(_error) {
  24275. this._error = _error;
  24276. return this;
  24277. }
  24278. },
  24279. // Add parent method
  24280. construct: {
  24281. // create image element, load image and set its size
  24282. image: function image(source, width, height) {
  24283. return this.put(new SVG.Image()).load(source).size(width || 0, height || width || 0);
  24284. }
  24285. }
  24286. });
  24287. SVG.Text = SVG.invent({
  24288. // Initialize node
  24289. create: function create() {
  24290. this.constructor.call(this, SVG.create('text'));
  24291. this.dom.leading = new SVG.Number(1.3); // store leading value for rebuilding
  24292. this._rebuild = true; // enable automatic updating of dy values
  24293. this._build = false; // disable build mode for adding multiple lines
  24294. // set default font
  24295. this.attr('font-family', SVG.defaults.attrs['font-family']);
  24296. },
  24297. // Inherit from
  24298. inherit: SVG.Shape,
  24299. // Add class methods
  24300. extend: {
  24301. // Move over x-axis
  24302. x: function x(_x5) {
  24303. // act as getter
  24304. if (_x5 == null) {
  24305. return this.attr('x');
  24306. }
  24307. return this.attr('x', _x5);
  24308. },
  24309. // Set the text content
  24310. text: function text(_text) {
  24311. // act as getter
  24312. if (typeof _text === 'undefined') {
  24313. var _text = '';
  24314. var children = this.node.childNodes;
  24315. for (var i = 0, len = children.length; i < len; ++i) {
  24316. // add newline if its not the first child and newLined is set to true
  24317. if (i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true) {
  24318. _text += '\n';
  24319. } // add content of this node
  24320. _text += children[i].textContent;
  24321. }
  24322. return _text;
  24323. } // remove existing content
  24324. this.clear().build(true);
  24325. if (typeof _text === 'function') {
  24326. // call block
  24327. _text.call(this, this);
  24328. } else {
  24329. // store text and make sure text is not blank
  24330. _text = _text.split('\n'); // build new lines
  24331. for (var i = 0, il = _text.length; i < il; i++) {
  24332. this.tspan(_text[i]).newLine();
  24333. }
  24334. } // disable build mode and rebuild lines
  24335. return this.build(false).rebuild();
  24336. },
  24337. // Set font size
  24338. size: function size(_size) {
  24339. return this.attr('font-size', _size).rebuild();
  24340. },
  24341. // Set / get leading
  24342. leading: function leading(value) {
  24343. // act as getter
  24344. if (value == null) {
  24345. return this.dom.leading;
  24346. } // act as setter
  24347. this.dom.leading = new SVG.Number(value);
  24348. return this.rebuild();
  24349. },
  24350. // Get all the first level lines
  24351. lines: function lines() {
  24352. var node = (this.textPath && this.textPath() || this).node; // filter tspans and map them to SVG.js instances
  24353. var lines = SVG.utils.map(SVG.utils.filterSVGElements(node.childNodes), function (el) {
  24354. return SVG.adopt(el);
  24355. }); // return an instance of SVG.set
  24356. return new SVG.Set(lines);
  24357. },
  24358. // Rebuild appearance type
  24359. rebuild: function rebuild(_rebuild) {
  24360. // store new rebuild flag if given
  24361. if (typeof _rebuild === 'boolean') {
  24362. this._rebuild = _rebuild;
  24363. } // define position of all lines
  24364. if (this._rebuild) {
  24365. var self = this,
  24366. blankLineOffset = 0,
  24367. dy = this.dom.leading * new SVG.Number(this.attr('font-size'));
  24368. this.lines().each(function () {
  24369. if (this.dom.newLined) {
  24370. if (!self.textPath()) {
  24371. this.attr('x', self.attr('x'));
  24372. }
  24373. if (this.text() == '\n') {
  24374. blankLineOffset += dy;
  24375. } else {
  24376. this.attr('dy', dy + blankLineOffset);
  24377. blankLineOffset = 0;
  24378. }
  24379. }
  24380. });
  24381. this.fire('rebuild');
  24382. }
  24383. return this;
  24384. },
  24385. // Enable / disable build mode
  24386. build: function build(_build) {
  24387. this._build = !!_build;
  24388. return this;
  24389. },
  24390. // overwrite method from parent to set data properly
  24391. setData: function setData(o) {
  24392. this.dom = o;
  24393. this.dom.leading = new SVG.Number(o.leading || 1.3);
  24394. return this;
  24395. }
  24396. },
  24397. // Add parent method
  24398. construct: {
  24399. // Create text element
  24400. text: function text(_text2) {
  24401. return this.put(new SVG.Text()).text(_text2);
  24402. },
  24403. // Create plain text element
  24404. plain: function plain(text) {
  24405. return this.put(new SVG.Text()).plain(text);
  24406. }
  24407. }
  24408. });
  24409. SVG.Tspan = SVG.invent({
  24410. // Initialize node
  24411. create: 'tspan',
  24412. // Inherit from
  24413. inherit: SVG.Shape,
  24414. // Add class methods
  24415. extend: {
  24416. // Set text content
  24417. text: function text(_text3) {
  24418. if (_text3 == null) return this.node.textContent + (this.dom.newLined ? '\n' : '');
  24419. typeof _text3 === 'function' ? _text3.call(this, this) : this.plain(_text3);
  24420. return this;
  24421. },
  24422. // Shortcut dx
  24423. dx: function dx(_dx) {
  24424. return this.attr('dx', _dx);
  24425. },
  24426. // Shortcut dy
  24427. dy: function dy(_dy) {
  24428. return this.attr('dy', _dy);
  24429. },
  24430. // Create new line
  24431. newLine: function newLine() {
  24432. // fetch text parent
  24433. var t = this.parent(SVG.Text); // mark new line
  24434. this.dom.newLined = true; // apply new hy¡n
  24435. return this.dy(t.dom.leading * t.attr('font-size')).attr('x', t.x());
  24436. }
  24437. }
  24438. });
  24439. SVG.extend(SVG.Text, SVG.Tspan, {
  24440. // Create plain text node
  24441. plain: function plain(text) {
  24442. // clear if build mode is disabled
  24443. if (this._build === false) {
  24444. this.clear();
  24445. } // create text node
  24446. this.node.appendChild(document.createTextNode(text));
  24447. return this;
  24448. },
  24449. // Create a tspan
  24450. tspan: function tspan(text) {
  24451. var node = (this.textPath && this.textPath() || this).node,
  24452. tspan = new SVG.Tspan(); // clear if build mode is disabled
  24453. if (this._build === false) {
  24454. this.clear();
  24455. } // add new tspan
  24456. node.appendChild(tspan.node);
  24457. return tspan.text(text);
  24458. },
  24459. // Clear all lines
  24460. clear: function clear() {
  24461. var node = (this.textPath && this.textPath() || this).node; // remove existing child nodes
  24462. while (node.hasChildNodes()) {
  24463. node.removeChild(node.lastChild);
  24464. }
  24465. return this;
  24466. },
  24467. // Get length of text element
  24468. length: function length() {
  24469. return this.node.getComputedTextLength();
  24470. }
  24471. });
  24472. SVG.TextPath = SVG.invent({
  24473. // Initialize node
  24474. create: 'textPath',
  24475. // Inherit from
  24476. inherit: SVG.Parent,
  24477. // Define parent class
  24478. parent: SVG.Text,
  24479. // Add parent method
  24480. construct: {
  24481. morphArray: SVG.PathArray,
  24482. // return the array of the path track element
  24483. array: function array() {
  24484. var track = this.track();
  24485. return track ? track.array() : null;
  24486. },
  24487. // Plot path if any
  24488. plot: function plot(d) {
  24489. var track = this.track(),
  24490. pathArray = null;
  24491. if (track) {
  24492. pathArray = track.plot(d);
  24493. }
  24494. return d == null ? pathArray : this;
  24495. },
  24496. // Get the path track element
  24497. track: function track() {
  24498. var path = this.textPath();
  24499. if (path) {
  24500. return path.reference('href');
  24501. }
  24502. },
  24503. // Get the textPath child
  24504. textPath: function textPath() {
  24505. if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') {
  24506. return SVG.adopt(this.node.firstChild);
  24507. }
  24508. }
  24509. }
  24510. });
  24511. SVG.Nested = SVG.invent({
  24512. // Initialize node
  24513. create: function create() {
  24514. this.constructor.call(this, SVG.create('svg'));
  24515. this.style('overflow', 'visible');
  24516. },
  24517. // Inherit from
  24518. inherit: SVG.Container,
  24519. // Add parent method
  24520. construct: {
  24521. // Create nested svg document
  24522. nested: function nested() {
  24523. return this.put(new SVG.Nested());
  24524. }
  24525. }
  24526. }); // Define list of available attributes for stroke and fill
  24527. var sugar = {
  24528. stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
  24529. fill: ['color', 'opacity', 'rule'],
  24530. prefix: function prefix(t, a) {
  24531. return a == 'color' ? t : t + '-' + a;
  24532. }
  24533. } // Add sugar for fill and stroke
  24534. ;
  24535. ['fill', 'stroke'].forEach(function (m) {
  24536. var extension = {};
  24537. extension[m] = function (o) {
  24538. if (typeof o === 'undefined') {
  24539. return this;
  24540. }
  24541. if (typeof o === 'string' || SVG.Color.isRgb(o) || o && typeof o.fill === 'function') {
  24542. this.attr(m, o);
  24543. } else // set all attributes from sugar.fill and sugar.stroke list
  24544. {
  24545. for (var i = sugar[m].length - 1; i >= 0; i--) {
  24546. if (o[sugar[m][i]] != null) {
  24547. this.attr(sugar.prefix(m, sugar[m][i]), o[sugar[m][i]]);
  24548. }
  24549. }
  24550. }
  24551. return this;
  24552. };
  24553. SVG.extend(SVG.Element, SVG.FX, extension);
  24554. });
  24555. SVG.extend(SVG.Element, SVG.FX, {
  24556. // Map translate to transform
  24557. translate: function translate(x, y) {
  24558. return this.transform({
  24559. x: x,
  24560. y: y
  24561. });
  24562. },
  24563. // Map matrix to transform
  24564. matrix: function matrix(m) {
  24565. return this.attr('transform', new SVG.Matrix(arguments.length == 6 ? [].slice.call(arguments) : m));
  24566. },
  24567. // Opacity
  24568. opacity: function opacity(value) {
  24569. return this.attr('opacity', value);
  24570. },
  24571. // Relative move over x axis
  24572. dx: function dx(x) {
  24573. return this.x(new SVG.Number(x).plus(this instanceof SVG.FX ? 0 : this.x()), true);
  24574. },
  24575. // Relative move over y axis
  24576. dy: function dy(y) {
  24577. return this.y(new SVG.Number(y).plus(this instanceof SVG.FX ? 0 : this.y()), true);
  24578. }
  24579. });
  24580. SVG.extend(SVG.Path, {
  24581. // Get path length
  24582. length: function length() {
  24583. return this.node.getTotalLength();
  24584. },
  24585. // Get point at length
  24586. pointAt: function pointAt(length) {
  24587. return this.node.getPointAtLength(length);
  24588. }
  24589. });
  24590. SVG.Set = SVG.invent({
  24591. // Initialize
  24592. create: function create(members) {
  24593. // Set initial state
  24594. Array.isArray(members) ? this.members = members : this.clear();
  24595. },
  24596. // Add class methods
  24597. extend: {
  24598. // Add element to set
  24599. add: function add() {
  24600. var il,
  24601. elements = [].slice.call(arguments);
  24602. for (var i = 0, il = elements.length; i < il; i++) {
  24603. this.members.push(elements[i]);
  24604. }
  24605. return this;
  24606. },
  24607. // Remove element from set
  24608. remove: function remove(element) {
  24609. var i = this.index(element); // remove given child
  24610. if (i > -1) {
  24611. this.members.splice(i, 1);
  24612. }
  24613. return this;
  24614. },
  24615. // Iterate over all members
  24616. each: function each(block) {
  24617. for (var i = 0, il = this.members.length; i < il; i++) {
  24618. block.apply(this.members[i], [i, this.members]);
  24619. }
  24620. return this;
  24621. },
  24622. // Restore to defaults
  24623. clear: function clear() {
  24624. // initialize store
  24625. this.members = [];
  24626. return this;
  24627. },
  24628. // Get the length of a set
  24629. length: function length() {
  24630. return this.members.length;
  24631. },
  24632. // Checks if a given element is present in set
  24633. has: function has(element) {
  24634. return this.index(element) >= 0;
  24635. },
  24636. // retuns index of given element in set
  24637. index: function index(element) {
  24638. return this.members.indexOf(element);
  24639. },
  24640. // Get member at given index
  24641. get: function get(i) {
  24642. return this.members[i];
  24643. },
  24644. // Get first member
  24645. first: function first() {
  24646. return this.get(0);
  24647. },
  24648. // Get last member
  24649. last: function last() {
  24650. return this.get(this.members.length - 1);
  24651. },
  24652. // Default value
  24653. valueOf: function valueOf() {
  24654. return this.members;
  24655. }
  24656. },
  24657. // Add parent method
  24658. construct: {
  24659. // Create a new set
  24660. set: function set(members) {
  24661. return new SVG.Set(members);
  24662. }
  24663. }
  24664. });
  24665. SVG.FX.Set = SVG.invent({
  24666. // Initialize node
  24667. create: function create(set) {
  24668. // store reference to set
  24669. this.set = set;
  24670. }
  24671. }); // Alias methods
  24672. SVG.Set.inherit = function () {
  24673. var methods = []; // gather shape methods
  24674. for (var m in SVG.Shape.prototype) {
  24675. if (typeof SVG.Shape.prototype[m] === 'function' && typeof SVG.Set.prototype[m] !== 'function') {
  24676. methods.push(m);
  24677. }
  24678. } // apply shape aliasses
  24679. methods.forEach(function (method) {
  24680. SVG.Set.prototype[method] = function () {
  24681. for (var i = 0, il = this.members.length; i < il; i++) {
  24682. if (this.members[i] && typeof this.members[i][method] === 'function') {
  24683. this.members[i][method].apply(this.members[i], arguments);
  24684. }
  24685. }
  24686. return method == 'animate' ? this.fx || (this.fx = new SVG.FX.Set(this)) : this;
  24687. };
  24688. }); // clear methods for the next round
  24689. methods = []; // gather fx methods
  24690. for (var m in SVG.FX.prototype) {
  24691. if (typeof SVG.FX.prototype[m] === 'function' && typeof SVG.FX.Set.prototype[m] !== 'function') {
  24692. methods.push(m);
  24693. }
  24694. } // apply fx aliasses
  24695. methods.forEach(function (method) {
  24696. SVG.FX.Set.prototype[method] = function () {
  24697. for (var i = 0, il = this.set.members.length; i < il; i++) {
  24698. this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments);
  24699. }
  24700. return this;
  24701. };
  24702. });
  24703. };
  24704. SVG.extend(SVG.Element, {});
  24705. SVG.extend(SVG.Element, {
  24706. // Remember arbitrary data
  24707. remember: function remember(k, v) {
  24708. // remember every item in an object individually
  24709. if (_typeof(arguments[0]) === 'object') {
  24710. for (var v_ in k) {
  24711. this.remember(v_, k[v_]);
  24712. }
  24713. } // retrieve memory
  24714. else if (arguments.length == 1) {
  24715. return this.memory()[k];
  24716. } // store memory
  24717. else {
  24718. this.memory()[k] = v;
  24719. }
  24720. return this;
  24721. },
  24722. // Erase a given memory
  24723. forget: function forget() {
  24724. if (arguments.length == 0) {
  24725. this._memory = {};
  24726. } else {
  24727. for (var i = arguments.length - 1; i >= 0; i--) {
  24728. delete this.memory()[arguments[i]];
  24729. }
  24730. }
  24731. return this;
  24732. },
  24733. // Initialize or return local memory object
  24734. memory: function memory() {
  24735. return this._memory || (this._memory = {});
  24736. }
  24737. }); // Method for getting an element by id
  24738. SVG.get = function (id) {
  24739. var node = document.getElementById(idFromReference(id) || id);
  24740. return SVG.adopt(node);
  24741. }; // Select elements by query string
  24742. SVG.select = function (query, parent) {
  24743. return new SVG.Set(SVG.utils.map((parent || document).querySelectorAll(query), function (node) {
  24744. return SVG.adopt(node);
  24745. }));
  24746. };
  24747. SVG.extend(SVG.Parent, {
  24748. // Scoped select method
  24749. select: function select(query) {
  24750. return SVG.select(query, this.node);
  24751. }
  24752. });
  24753. function pathRegReplace(a, b, c, d) {
  24754. return c + d.replace(SVG.regex.dots, ' .');
  24755. } // creates deep clone of array
  24756. function _is(el, obj) {
  24757. return el instanceof obj;
  24758. } // tests if a given selector matches an element
  24759. function _matches(el, selector) {
  24760. return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
  24761. } // Convert dash-separated-string to camelCase
  24762. function camelCase(s) {
  24763. return s.toLowerCase().replace(/-(.)/g, function (m, g) {
  24764. return g.toUpperCase();
  24765. });
  24766. } // Capitalize first letter of a string
  24767. function capitalize(s) {
  24768. return s.charAt(0).toUpperCase() + s.slice(1);
  24769. } // Ensure to six-based hex
  24770. function fullHex(hex) {
  24771. 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;
  24772. } // Component to hex value
  24773. function compToHex(comp) {
  24774. var hex = comp.toString(16);
  24775. return hex.length == 1 ? '0' + hex : hex;
  24776. } // Calculate proportional width and height values when necessary
  24777. function proportionalSize(element, width, height) {
  24778. if (width == null || height == null) {
  24779. var box = element.bbox();
  24780. if (width == null) {
  24781. width = box.width / box.height * height;
  24782. } else if (height == null) {
  24783. height = box.height / box.width * width;
  24784. }
  24785. }
  24786. return {
  24787. width: width,
  24788. height: height
  24789. };
  24790. } // Delta transform point
  24791. function deltaTransformPoint(matrix, x, y) {
  24792. return {
  24793. x: x * matrix.a + y * matrix.c + 0,
  24794. y: x * matrix.b + y * matrix.d + 0
  24795. };
  24796. } // Map matrix array to object
  24797. function arrayToMatrix(a) {
  24798. return {
  24799. a: a[0],
  24800. b: a[1],
  24801. c: a[2],
  24802. d: a[3],
  24803. e: a[4],
  24804. f: a[5]
  24805. };
  24806. } // Parse matrix if required
  24807. function parseMatrix(matrix) {
  24808. if (!(matrix instanceof SVG.Matrix)) {
  24809. matrix = new SVG.Matrix(matrix);
  24810. }
  24811. return matrix;
  24812. } // Add centre point to transform object
  24813. function arrayToString(a) {
  24814. for (var i = 0, il = a.length, s = ''; i < il; i++) {
  24815. s += a[i][0];
  24816. if (a[i][1] != null) {
  24817. s += a[i][1];
  24818. if (a[i][2] != null) {
  24819. s += ' ';
  24820. s += a[i][2];
  24821. if (a[i][3] != null) {
  24822. s += ' ';
  24823. s += a[i][3];
  24824. s += ' ';
  24825. s += a[i][4];
  24826. if (a[i][5] != null) {
  24827. s += ' ';
  24828. s += a[i][5];
  24829. s += ' ';
  24830. s += a[i][6];
  24831. if (a[i][7] != null) {
  24832. s += ' ';
  24833. s += a[i][7];
  24834. }
  24835. }
  24836. }
  24837. }
  24838. }
  24839. }
  24840. return s + ' ';
  24841. } // Deep new id assignment
  24842. function assignNewId(node) {
  24843. // do the same for SVG child nodes as well
  24844. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  24845. if (node.childNodes[i] instanceof window.SVGElement) {
  24846. assignNewId(node.childNodes[i]);
  24847. }
  24848. }
  24849. return SVG.adopt(node).id(SVG.eid(node.nodeName));
  24850. } // Add more bounding box properties
  24851. function fullBox(b) {
  24852. if (b.x == null) {
  24853. b.x = 0;
  24854. b.y = 0;
  24855. b.width = 0;
  24856. b.height = 0;
  24857. }
  24858. b.w = b.width;
  24859. b.h = b.height;
  24860. b.x2 = b.x + b.width;
  24861. b.y2 = b.y + b.height;
  24862. b.cx = b.x + b.width / 2;
  24863. b.cy = b.y + b.height / 2;
  24864. return b;
  24865. } // Get id from reference string
  24866. function idFromReference(url) {
  24867. var m = (url || '').toString().match(SVG.regex.reference);
  24868. if (m) return m[1];
  24869. } // If values like 1e-88 are passed, this is not a valid 32 bit float,
  24870. // but in those cases, we are so close to 0 that 0 works well!
  24871. function float32String(v) {
  24872. return Math.abs(v) > 1e-37 ? v : 0;
  24873. } // Create matrix array for looping
  24874. var abcdef = 'abcdef'.split(''); // Add CustomEvent to IE9 and IE10
  24875. if (typeof window.CustomEvent !== 'function') {
  24876. // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
  24877. var CustomEventPoly = function CustomEventPoly(event, options) {
  24878. options = options || {
  24879. bubbles: false,
  24880. cancelable: false,
  24881. detail: undefined
  24882. };
  24883. var e = document.createEvent('CustomEvent');
  24884. e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail);
  24885. return e;
  24886. };
  24887. CustomEventPoly.prototype = window.Event.prototype;
  24888. SVG.CustomEvent = CustomEventPoly;
  24889. } else {
  24890. SVG.CustomEvent = window.CustomEvent;
  24891. }
  24892. return SVG;
  24893. });
  24894. /*! svg.filter.js - v2.0.2 - 2016-02-24
  24895. * https://github.com/wout/svg.filter.js
  24896. * Copyright (c) 2016 Wout Fierens; Licensed MIT */
  24897. (function() {
  24898. // Main filter class
  24899. SVG.Filter = SVG.invent({
  24900. create: 'filter',
  24901. inherit: SVG.Parent,
  24902. extend: {
  24903. // Static strings
  24904. source: 'SourceGraphic',
  24905. sourceAlpha: 'SourceAlpha',
  24906. background: 'BackgroundImage',
  24907. backgroundAlpha: 'BackgroundAlpha',
  24908. fill: 'FillPaint',
  24909. stroke: 'StrokePaint',
  24910. autoSetIn: true,
  24911. // Custom put method for leaner code
  24912. put: function(element, i) {
  24913. this.add(element, i);
  24914. if(!element.attr('in') && this.autoSetIn){
  24915. element.attr('in',this.source);
  24916. }
  24917. if(!element.attr('result')){
  24918. element.attr('result',element);
  24919. }
  24920. return element
  24921. },
  24922. // Blend effect
  24923. blend: function(in1, in2, mode) {
  24924. return this.put(new SVG.BlendEffect(in1, in2, mode))
  24925. },
  24926. // ColorMatrix effect
  24927. colorMatrix: function(type, values) {
  24928. return this.put(new SVG.ColorMatrixEffect(type, values))
  24929. },
  24930. // ConvolveMatrix effect
  24931. convolveMatrix: function(matrix) {
  24932. return this.put(new SVG.ConvolveMatrixEffect(matrix))
  24933. },
  24934. // ComponentTransfer effect
  24935. componentTransfer: function(components) {
  24936. return this.put(new SVG.ComponentTransferEffect(components))
  24937. },
  24938. // Composite effect
  24939. composite: function(in1, in2, operator) {
  24940. return this.put(new SVG.CompositeEffect(in1, in2, operator))
  24941. },
  24942. // Flood effect
  24943. flood: function(color, opacity) {
  24944. return this.put(new SVG.FloodEffect(color, opacity))
  24945. },
  24946. // Offset effect
  24947. offset: function(x, y) {
  24948. return this.put(new SVG.OffsetEffect(x,y))
  24949. },
  24950. // Image effect
  24951. image: function(src) {
  24952. return this.put(new SVG.ImageEffect(src))
  24953. },
  24954. // Merge effect
  24955. merge: function() {
  24956. //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
  24957. var args = [undefined];
  24958. for(var i in arguments) args.push(arguments[i]);
  24959. return this.put(new (SVG.MergeEffect.bind.apply(SVG.MergeEffect,args)))
  24960. },
  24961. // Gaussian Blur effect
  24962. gaussianBlur: function(x,y) {
  24963. return this.put(new SVG.GaussianBlurEffect(x,y))
  24964. },
  24965. // Morphology effect
  24966. morphology: function(operator,radius){
  24967. return this.put(new SVG.MorphologyEffect(operator,radius))
  24968. },
  24969. // DiffuseLighting effect
  24970. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  24971. return this.put(new SVG.DiffuseLightingEffect(surfaceScale,diffuseConstant,kernelUnitLength))
  24972. },
  24973. // DisplacementMap effect
  24974. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  24975. return this.put(new SVG.DisplacementMapEffect(in1,in2,scale,xChannelSelector,yChannelSelector))
  24976. },
  24977. // SpecularLighting effect
  24978. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  24979. return this.put(new SVG.SpecularLightingEffect(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength))
  24980. },
  24981. // Tile effect
  24982. tile: function(){
  24983. return this.put(new SVG.TileEffect());
  24984. },
  24985. // Turbulence effect
  24986. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  24987. return this.put(new SVG.TurbulenceEffect(baseFrequency,numOctaves,seed,stitchTiles,type))
  24988. },
  24989. // Default string value
  24990. toString: function() {
  24991. return 'url(#' + this.attr('id') + ')'
  24992. }
  24993. }
  24994. });
  24995. //add .filter function
  24996. SVG.extend(SVG.Defs, {
  24997. // Define filter
  24998. filter: function(block) {
  24999. var filter = this.put(new SVG.Filter);
  25000. /* invoke passed block */
  25001. if (typeof block === 'function')
  25002. block.call(filter, filter);
  25003. return filter
  25004. }
  25005. });
  25006. SVG.extend(SVG.Container, {
  25007. // Define filter on defs
  25008. filter: function(block) {
  25009. return this.defs().filter(block)
  25010. }
  25011. });
  25012. SVG.extend(SVG.Element, SVG.G, SVG.Nested, {
  25013. // Create filter element in defs and store reference
  25014. filter: function(block) {
  25015. this.filterer = block instanceof SVG.Element ?
  25016. block : this.doc().filter(block);
  25017. if(this.doc() && this.filterer.doc() !== this.doc()){
  25018. this.doc().defs().add(this.filterer);
  25019. }
  25020. this.attr('filter', this.filterer);
  25021. return this.filterer
  25022. },
  25023. // Remove filter
  25024. unfilter: function(remove) {
  25025. /* also remove the filter node */
  25026. if (this.filterer && remove === true)
  25027. this.filterer.remove();
  25028. /* delete reference to filterer */
  25029. delete this.filterer;
  25030. /* remove filter attribute */
  25031. return this.attr('filter', null)
  25032. }
  25033. });
  25034. // Create SVG.Effect class
  25035. SVG.Effect = SVG.invent({
  25036. create: function(){
  25037. this.constructor.call(this);
  25038. },
  25039. inherit: SVG.Element,
  25040. extend: {
  25041. // Set in attribute
  25042. in: function(effect) {
  25043. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  25044. },
  25045. // Named result
  25046. result: function(result) {
  25047. return result == null? this.attr('result') : this.attr('result',result)
  25048. },
  25049. // Stringification
  25050. toString: function() {
  25051. return this.result()
  25052. }
  25053. }
  25054. });
  25055. // create class for parent effects like merge
  25056. // Inherit from SVG.Parent
  25057. SVG.ParentEffect = SVG.invent({
  25058. create: function(){
  25059. this.constructor.call(this);
  25060. },
  25061. inherit: SVG.Parent,
  25062. extend: {
  25063. // Set in attribute
  25064. in: function(effect) {
  25065. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  25066. },
  25067. // Named result
  25068. result: function(result) {
  25069. return result == null? this.attr('result') : this.attr('result',result)
  25070. },
  25071. // Stringification
  25072. toString: function() {
  25073. return this.result()
  25074. }
  25075. }
  25076. });
  25077. //chaining
  25078. var chainingEffects = {
  25079. // Blend effect
  25080. blend: function(in2, mode) {
  25081. return this.parent() && this.parent().blend(this, in2, mode) //pass this as the first input
  25082. },
  25083. // ColorMatrix effect
  25084. colorMatrix: function(type, values) {
  25085. return this.parent() && this.parent().colorMatrix(type, values).in(this)
  25086. },
  25087. // ConvolveMatrix effect
  25088. convolveMatrix: function(matrix) {
  25089. return this.parent() && this.parent().convolveMatrix(matrix).in(this)
  25090. },
  25091. // ComponentTransfer effect
  25092. componentTransfer: function(components) {
  25093. return this.parent() && this.parent().componentTransfer(components).in(this)
  25094. },
  25095. // Composite effect
  25096. composite: function(in2, operator) {
  25097. return this.parent() && this.parent().composite(this, in2, operator) //pass this as the first input
  25098. },
  25099. // Flood effect
  25100. flood: function(color, opacity) {
  25101. return this.parent() && this.parent().flood(color, opacity) //this effect dont have inputs
  25102. },
  25103. // Offset effect
  25104. offset: function(x, y) {
  25105. return this.parent() && this.parent().offset(x,y).in(this)
  25106. },
  25107. // Image effect
  25108. image: function(src) {
  25109. return this.parent() && this.parent().image(src) //this effect dont have inputs
  25110. },
  25111. // Merge effect
  25112. merge: function() {
  25113. return this.parent() && this.parent().merge.apply(this.parent(),[this].concat(arguments)) //pass this as the first argument
  25114. },
  25115. // Gaussian Blur effect
  25116. gaussianBlur: function(x,y) {
  25117. return this.parent() && this.parent().gaussianBlur(x,y).in(this)
  25118. },
  25119. // Morphology effect
  25120. morphology: function(operator,radius){
  25121. return this.parent() && this.parent().morphology(operator,radius).in(this)
  25122. },
  25123. // DiffuseLighting effect
  25124. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  25125. return this.parent() && this.parent().diffuseLighting(surfaceScale,diffuseConstant,kernelUnitLength).in(this)
  25126. },
  25127. // DisplacementMap effect
  25128. displacementMap: function(in2,scale,xChannelSelector,yChannelSelector){
  25129. return this.parent() && this.parent().displacementMap(this,in2,scale,xChannelSelector,yChannelSelector) //pass this as the first input
  25130. },
  25131. // SpecularLighting effect
  25132. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  25133. return this.parent() && this.parent().specularLighting(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength).in(this)
  25134. },
  25135. // Tile effect
  25136. tile: function(){
  25137. return this.parent() && this.parent().tile().in(this)
  25138. },
  25139. // Turbulence effect
  25140. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  25141. return this.parent() && this.parent().turbulence(baseFrequency,numOctaves,seed,stitchTiles,type).in(this)
  25142. }
  25143. };
  25144. SVG.extend(SVG.Effect,chainingEffects);
  25145. SVG.extend(SVG.ParentEffect,chainingEffects);
  25146. //crea class for child effects, like MergeNode, FuncR and lights
  25147. SVG.ChildEffect = SVG.invent({
  25148. create: function(){
  25149. this.constructor.call(this);
  25150. },
  25151. inherit: SVG.Element,
  25152. extend: {
  25153. in: function(effect){
  25154. this.attr('in',effect);
  25155. }
  25156. //dont include any "result" functions because these types of nodes dont have them
  25157. }
  25158. });
  25159. // Create all different effects
  25160. var effects = {
  25161. blend: function(in1,in2,mode){
  25162. this.attr({
  25163. in: in1,
  25164. in2: in2,
  25165. mode: mode || 'normal'
  25166. });
  25167. },
  25168. colorMatrix: function(type,values){
  25169. if (type == 'matrix')
  25170. values = normaliseMatrix(values);
  25171. this.attr({
  25172. type: type
  25173. , values: typeof values == 'undefined' ? null : values
  25174. });
  25175. },
  25176. convolveMatrix: function(matrix){
  25177. matrix = normaliseMatrix(matrix);
  25178. this.attr({
  25179. order: Math.sqrt(matrix.split(' ').length)
  25180. , kernelMatrix: matrix
  25181. });
  25182. },
  25183. composite: function(in1, in2, operator){
  25184. this.attr({
  25185. in: in1,
  25186. in2: in2,
  25187. operator: operator
  25188. });
  25189. },
  25190. flood: function(color,opacity){
  25191. this.attr('flood-color',color);
  25192. if(opacity != null) this.attr('flood-opacity',opacity);
  25193. },
  25194. offset: function(x,y){
  25195. this.attr({
  25196. dx: x,
  25197. dy: y
  25198. });
  25199. },
  25200. image: function(src){
  25201. this.attr('href', src, SVG.xlink);
  25202. },
  25203. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  25204. this.attr({
  25205. in: in1,
  25206. in2: in2,
  25207. scale: scale,
  25208. xChannelSelector: xChannelSelector,
  25209. yChannelSelector: yChannelSelector
  25210. });
  25211. },
  25212. gaussianBlur: function(x,y){
  25213. if(x != null || y != null)
  25214. this.attr('stdDeviation', listString(Array.prototype.slice.call(arguments)));
  25215. else
  25216. this.attr('stdDeviation', '0 0');
  25217. },
  25218. morphology: function(operator,radius){
  25219. this.attr({
  25220. operator: operator,
  25221. radius: radius
  25222. });
  25223. },
  25224. tile: function(){
  25225. },
  25226. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  25227. this.attr({
  25228. numOctaves: numOctaves,
  25229. seed: seed,
  25230. stitchTiles: stitchTiles,
  25231. baseFrequency: baseFrequency,
  25232. type: type
  25233. });
  25234. }
  25235. };
  25236. // Create all parent effects
  25237. var parentEffects = {
  25238. merge: function(){
  25239. var children;
  25240. //test to see if we have a set
  25241. if(arguments[0] instanceof SVG.Set){
  25242. var that = this;
  25243. arguments[0].each(function(i){
  25244. if(this instanceof SVG.MergeNode)
  25245. that.put(this);
  25246. else if(this instanceof SVG.Effect || this instanceof SVG.ParentEffect)
  25247. that.put(new SVG.MergeNode(this));
  25248. });
  25249. }
  25250. else {
  25251. //if the first argument is an array use it
  25252. if(Array.isArray(arguments[0]))
  25253. children = arguments[0];
  25254. else
  25255. children = arguments;
  25256. for(var i = 0; i < children.length; i++){
  25257. if(children[i] instanceof SVG.MergeNode){
  25258. this.put(children[i]);
  25259. }
  25260. else this.put(new SVG.MergeNode(children[i]));
  25261. }
  25262. }
  25263. },
  25264. componentTransfer: function(compontents){
  25265. /* create rgb set */
  25266. this.rgb = new SVG.Set
  25267. /* create components */
  25268. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  25269. /* create component */
  25270. this[c] = new SVG['Func' + c.toUpperCase()]('identity');
  25271. /* store component in set */
  25272. this.rgb.add(this[c]);
  25273. /* add component node */
  25274. this.node.appendChild(this[c].node);
  25275. }.bind(this)); //lost context in foreach
  25276. /* set components */
  25277. if (compontents) {
  25278. if (compontents.rgb) {
  25279. (['r', 'g', 'b']).forEach(function(c) {
  25280. this[c].attr(compontents.rgb);
  25281. }.bind(this));
  25282. delete compontents.rgb;
  25283. }
  25284. /* set individual components */
  25285. for (var c in compontents)
  25286. this[c].attr(compontents[c]);
  25287. }
  25288. },
  25289. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  25290. this.attr({
  25291. surfaceScale: surfaceScale,
  25292. diffuseConstant: diffuseConstant,
  25293. kernelUnitLength: kernelUnitLength
  25294. });
  25295. },
  25296. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  25297. this.attr({
  25298. surfaceScale: surfaceScale,
  25299. diffuseConstant: diffuseConstant,
  25300. specularExponent: specularExponent,
  25301. kernelUnitLength: kernelUnitLength
  25302. });
  25303. },
  25304. };
  25305. // Create child effects like PointLight and MergeNode
  25306. var childEffects = {
  25307. distantLight: function(azimuth, elevation){
  25308. this.attr({
  25309. azimuth: azimuth,
  25310. elevation: elevation
  25311. });
  25312. },
  25313. pointLight: function(x,y,z){
  25314. this.attr({
  25315. x: x,
  25316. y: y,
  25317. z: z
  25318. });
  25319. },
  25320. spotLight: function(x,y,z,pointsAtX,pointsAtY,pointsAtZ){
  25321. this.attr({
  25322. x: x,
  25323. y: y,
  25324. z: z,
  25325. pointsAtX: pointsAtX,
  25326. pointsAtY: pointsAtY,
  25327. pointsAtZ: pointsAtZ
  25328. });
  25329. },
  25330. mergeNode: function(in1){
  25331. this.attr('in',in1);
  25332. }
  25333. }
  25334. // Create compontent functions
  25335. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  25336. /* create class */
  25337. childEffects['Func' + c.toUpperCase()] = function(type) {
  25338. this.attr('type',type);
  25339. // take diffent arguments based on the type
  25340. switch(type){
  25341. case 'table':
  25342. this.attr('tableValues',arguments[1]);
  25343. break
  25344. case 'linear':
  25345. this.attr('slope',arguments[1]);
  25346. this.attr('intercept',arguments[2]);
  25347. break
  25348. case 'gamma':
  25349. this.attr('amplitude',arguments[1]);
  25350. this.attr('exponent',arguments[2]);
  25351. this.attr('offset',arguments[2]);
  25352. break
  25353. }
  25354. };
  25355. });
  25356. //create effects
  25357. foreach(effects,function(effect,i){
  25358. /* capitalize name */
  25359. var name = i.charAt(0).toUpperCase() + i.slice(1);
  25360. var proto = {};
  25361. /* create class */
  25362. SVG[name + 'Effect'] = SVG.invent({
  25363. create: function() {
  25364. //call super
  25365. this.constructor.call(this, SVG.create('fe' + name));
  25366. //call constructor for this effect
  25367. effect.apply(this,arguments);
  25368. //set the result
  25369. this.result(this.attr('id') + 'Out');
  25370. },
  25371. inherit: SVG.Effect,
  25372. extend: proto
  25373. });
  25374. });
  25375. //create parent effects
  25376. foreach(parentEffects,function(effect,i){
  25377. /* capitalize name */
  25378. var name = i.charAt(0).toUpperCase() + i.slice(1);
  25379. var proto = {};
  25380. /* create class */
  25381. SVG[name + 'Effect'] = SVG.invent({
  25382. create: function() {
  25383. //call super
  25384. this.constructor.call(this, SVG.create('fe' + name));
  25385. //call constructor for this effect
  25386. effect.apply(this,arguments);
  25387. //set the result
  25388. this.result(this.attr('id') + 'Out');
  25389. },
  25390. inherit: SVG.ParentEffect,
  25391. extend: proto
  25392. });
  25393. });
  25394. //create child effects
  25395. foreach(childEffects,function(effect,i){
  25396. /* capitalize name */
  25397. var name = i.charAt(0).toUpperCase() + i.slice(1);
  25398. var proto = {};
  25399. /* create class */
  25400. SVG[name] = SVG.invent({
  25401. create: function() {
  25402. //call super
  25403. this.constructor.call(this, SVG.create('fe' + name));
  25404. //call constructor for this effect
  25405. effect.apply(this,arguments);
  25406. },
  25407. inherit: SVG.ChildEffect,
  25408. extend: proto
  25409. });
  25410. });
  25411. // Effect-specific extensions
  25412. SVG.extend(SVG.MergeEffect,{
  25413. in: function(effect){
  25414. if(effect instanceof SVG.MergeNode)
  25415. this.add(effect,0);
  25416. else
  25417. this.add(new SVG.MergeNode(effect),0);
  25418. return this
  25419. }
  25420. });
  25421. SVG.extend(SVG.CompositeEffect,SVG.BlendEffect,SVG.DisplacementMapEffect,{
  25422. in2: function(effect){
  25423. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in2')+'"]').get(0) || this.attr('in2') : this.attr('in2', effect)
  25424. }
  25425. });
  25426. // Presets
  25427. SVG.filter = {
  25428. sepiatone: [ .343, .669, .119, 0, 0
  25429. , .249, .626, .130, 0, 0
  25430. , .172, .334, .111, 0, 0
  25431. , .000, .000, .000, 1, 0 ]
  25432. };
  25433. // Helpers
  25434. function normaliseMatrix(matrix) {
  25435. /* convert possible array value to string */
  25436. if (Array.isArray(matrix))
  25437. matrix = new SVG.Array(matrix);
  25438. /* ensure there are no leading, tailing or double spaces */
  25439. return matrix.toString().replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' ')
  25440. }
  25441. function listString(list) {
  25442. if (!Array.isArray(list))
  25443. return list
  25444. for (var i = 0, l = list.length, s = []; i < l; i++)
  25445. s.push(list[i]);
  25446. return s.join(' ')
  25447. }
  25448. function foreach(){ //loops through mutiple objects
  25449. var fn = function(){};
  25450. if(typeof arguments[arguments.length-1] == 'function'){
  25451. fn = arguments[arguments.length-1];
  25452. Array.prototype.splice.call(arguments,arguments.length-1,1);
  25453. }
  25454. for(var k in arguments){
  25455. for(var i in arguments[k]){
  25456. fn(arguments[k][i],i,arguments[k]);
  25457. }
  25458. }
  25459. }
  25460. }).call(undefined);
  25461. (function() {
  25462. SVG.extend(SVG.PathArray, {
  25463. morph: function(array) {
  25464. var startArr = this.value
  25465. , destArr = this.parse(array);
  25466. var startOffsetM = 0
  25467. , destOffsetM = 0;
  25468. var startOffsetNextM = false
  25469. , destOffsetNextM = false;
  25470. while(true){
  25471. // stop if there is no M anymore
  25472. if(startOffsetM === false && destOffsetM === false) break
  25473. // find the next M in path array
  25474. startOffsetNextM = findNextM(startArr, startOffsetM === false ? false : startOffsetM+1);
  25475. destOffsetNextM = findNextM( destArr, destOffsetM === false ? false : destOffsetM+1);
  25476. // We have to add one M to the startArray
  25477. if(startOffsetM === false){
  25478. var bbox = new SVG.PathArray(result.start).bbox();
  25479. // when the last block had no bounding box we simply take the first M we got
  25480. if(bbox.height == 0 || bbox.width == 0){
  25481. startOffsetM = startArr.push(startArr[0]) - 1;
  25482. }else {
  25483. // we take the middle of the bbox instead when we got one
  25484. startOffsetM = startArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  25485. }
  25486. }
  25487. // We have to add one M to the destArray
  25488. if( destOffsetM === false){
  25489. var bbox = new SVG.PathArray(result.dest).bbox();
  25490. if(bbox.height == 0 || bbox.width == 0){
  25491. destOffsetM = destArr.push(destArr[0]) - 1;
  25492. }else {
  25493. destOffsetM = destArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  25494. }
  25495. }
  25496. // handle block from M to next M
  25497. var result = handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM);
  25498. // update the arrays to their new values
  25499. startArr = startArr.slice(0, startOffsetM).concat(result.start, startOffsetNextM === false ? [] : startArr.slice(startOffsetNextM));
  25500. destArr = destArr.slice(0, destOffsetM).concat(result.dest , destOffsetNextM === false ? [] : destArr.slice( destOffsetNextM));
  25501. // update offsets
  25502. startOffsetM = startOffsetNextM === false ? false : startOffsetM + result.start.length;
  25503. destOffsetM = destOffsetNextM === false ? false : destOffsetM + result.dest.length;
  25504. }
  25505. // copy back arrays
  25506. this.value = startArr;
  25507. this.destination = new SVG.PathArray();
  25508. this.destination.value = destArr;
  25509. return this
  25510. }
  25511. });
  25512. // sorry for the long declaration
  25513. // slices out one block (from M to M) and syncronize it so the types and length match
  25514. function handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM, undefined$1){
  25515. // slice out the block we need
  25516. var startArrTemp = startArr.slice(startOffsetM, startOffsetNextM || undefined$1)
  25517. , destArrTemp = destArr.slice( destOffsetM, destOffsetNextM || undefined$1);
  25518. var i = 0
  25519. , posStart = {pos:[0,0], start:[0,0]}
  25520. , posDest = {pos:[0,0], start:[0,0]};
  25521. do{
  25522. // convert shorthand types to long form
  25523. startArrTemp[i] = simplyfy.call(posStart, startArrTemp[i]);
  25524. destArrTemp[i] = simplyfy.call(posDest , destArrTemp[i]);
  25525. // check if both shape types match
  25526. // 2 elliptical arc curve commands ('A'), are considered different if the
  25527. // flags (large-arc-flag, sweep-flag) don't match
  25528. if(startArrTemp[i][0] != destArrTemp[i][0] || startArrTemp[i][0] == 'M' ||
  25529. (startArrTemp[i][0] == 'A' &&
  25530. (startArrTemp[i][4] != destArrTemp[i][4] || startArrTemp[i][5] != destArrTemp[i][5])
  25531. )
  25532. ) {
  25533. // if not, convert shapes to beziere
  25534. Array.prototype.splice.apply(startArrTemp, [i, 1].concat(toBeziere.call(posStart, startArrTemp[i])));
  25535. Array.prototype.splice.apply(destArrTemp, [i, 1].concat(toBeziere.call(posDest, destArrTemp[i])));
  25536. } else {
  25537. // only update positions otherwise
  25538. startArrTemp[i] = setPosAndReflection.call(posStart, startArrTemp[i]);
  25539. destArrTemp[i] = setPosAndReflection.call(posDest , destArrTemp[i]);
  25540. }
  25541. // we are at the end at both arrays. stop here
  25542. if(++i == startArrTemp.length && i == destArrTemp.length) break
  25543. // destArray is longer. Add one element
  25544. if(i == startArrTemp.length){
  25545. startArrTemp.push([
  25546. 'C',
  25547. posStart.pos[0],
  25548. posStart.pos[1],
  25549. posStart.pos[0],
  25550. posStart.pos[1],
  25551. posStart.pos[0],
  25552. posStart.pos[1],
  25553. ]);
  25554. }
  25555. // startArr is longer. Add one element
  25556. if(i == destArrTemp.length){
  25557. destArrTemp.push([
  25558. 'C',
  25559. posDest.pos[0],
  25560. posDest.pos[1],
  25561. posDest.pos[0],
  25562. posDest.pos[1],
  25563. posDest.pos[0],
  25564. posDest.pos[1]
  25565. ]);
  25566. }
  25567. }while(true)
  25568. // return the updated block
  25569. return {start:startArrTemp, dest:destArrTemp}
  25570. }
  25571. // converts shorthand types to long form
  25572. function simplyfy(val){
  25573. switch(val[0]){
  25574. case 'z': // shorthand line to start
  25575. case 'Z':
  25576. val[0] = 'L';
  25577. val[1] = this.start[0];
  25578. val[2] = this.start[1];
  25579. break
  25580. case 'H': // shorthand horizontal line
  25581. val[0] = 'L';
  25582. val[2] = this.pos[1];
  25583. break
  25584. case 'V': // shorthand vertical line
  25585. val[0] = 'L';
  25586. val[2] = val[1];
  25587. val[1] = this.pos[0];
  25588. break
  25589. case 'T': // shorthand quadratic beziere
  25590. val[0] = 'Q';
  25591. val[3] = val[1];
  25592. val[4] = val[2];
  25593. val[1] = this.reflection[1];
  25594. val[2] = this.reflection[0];
  25595. break
  25596. case 'S': // shorthand cubic beziere
  25597. val[0] = 'C';
  25598. val[6] = val[4];
  25599. val[5] = val[3];
  25600. val[4] = val[2];
  25601. val[3] = val[1];
  25602. val[2] = this.reflection[1];
  25603. val[1] = this.reflection[0];
  25604. break
  25605. }
  25606. return val
  25607. }
  25608. // updates reflection point and current position
  25609. function setPosAndReflection(val){
  25610. var len = val.length;
  25611. this.pos = [ val[len-2], val[len-1] ];
  25612. if('SCQT'.indexOf(val[0]) != -1)
  25613. this.reflection = [ 2 * this.pos[0] - val[len-4], 2 * this.pos[1] - val[len-3] ];
  25614. return val
  25615. }
  25616. // converts all types to cubic beziere
  25617. function toBeziere(val){
  25618. var retVal = [val];
  25619. switch(val[0]){
  25620. case 'M': // special handling for M
  25621. this.pos = this.start = [val[1], val[2]];
  25622. return retVal
  25623. case 'L':
  25624. val[5] = val[3] = val[1];
  25625. val[6] = val[4] = val[2];
  25626. val[1] = this.pos[0];
  25627. val[2] = this.pos[1];
  25628. break
  25629. case 'Q':
  25630. val[6] = val[4];
  25631. val[5] = val[3];
  25632. val[4] = val[4] * 1/3 + val[2] * 2/3;
  25633. val[3] = val[3] * 1/3 + val[1] * 2/3;
  25634. val[2] = this.pos[1] * 1/3 + val[2] * 2/3;
  25635. val[1] = this.pos[0] * 1/3 + val[1] * 2/3;
  25636. break
  25637. case 'A':
  25638. retVal = arcToBeziere(this.pos, val);
  25639. val = retVal[0];
  25640. break
  25641. }
  25642. val[0] = 'C';
  25643. this.pos = [val[5], val[6]];
  25644. this.reflection = [2 * val[5] - val[3], 2 * val[6] - val[4]];
  25645. return retVal
  25646. }
  25647. // finds the next position of type M
  25648. function findNextM(arr, offset){
  25649. if(offset === false) return false
  25650. for(var i = offset, len = arr.length;i < len;++i){
  25651. if(arr[i][0] == 'M') return i
  25652. }
  25653. return false
  25654. }
  25655. // Convert an arc segment into equivalent cubic Bezier curves
  25656. // Depending on the arc, up to 4 curves might be used to represent it since a
  25657. // curve gives a good approximation for only a quarter of an ellipse
  25658. // The curves are returned as an array of SVG curve commands:
  25659. // [ ['C', x1, y1, x2, y2, x, y] ... ]
  25660. function arcToBeziere(pos, val) {
  25661. // Parameters extraction, handle out-of-range parameters as specified in the SVG spec
  25662. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcOutOfRangeParameters
  25663. var rx = Math.abs(val[1]), ry = Math.abs(val[2]), xAxisRotation = val[3] % 360
  25664. , largeArcFlag = val[4], sweepFlag = val[5], x = val[6], y = val[7]
  25665. , A = new SVG.Point(pos), B = new SVG.Point(x, y)
  25666. , primedCoord, lambda, mat, k, c, cSquare, t, O, OA, OB, tetaStart, tetaEnd
  25667. , deltaTeta, nbSectors, f, arcSegPoints, angle, sinAngle, cosAngle, pt, i, il
  25668. , retVal = [], x1, y1, x2, y2;
  25669. // Ensure radii are non-zero
  25670. if(rx === 0 || ry === 0 || (A.x === B.x && A.y === B.y)) {
  25671. // treat this arc as a straight line segment
  25672. return [['C', A.x, A.y, B.x, B.y, B.x, B.y]]
  25673. }
  25674. // Ensure radii are large enough using the algorithm provided in the SVG spec
  25675. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcCorrectionOutOfRangeRadii
  25676. primedCoord = new SVG.Point((A.x-B.x)/2, (A.y-B.y)/2).transform(new SVG.Matrix().rotate(xAxisRotation));
  25677. lambda = (primedCoord.x * primedCoord.x) / (rx * rx) + (primedCoord.y * primedCoord.y) / (ry * ry);
  25678. if(lambda > 1) {
  25679. lambda = Math.sqrt(lambda);
  25680. rx = lambda*rx;
  25681. ry = lambda*ry;
  25682. }
  25683. // To simplify calculations, we make the arc part of a unit circle (rayon is 1) instead of an ellipse
  25684. mat = new SVG.Matrix().rotate(xAxisRotation).scale(1/rx, 1/ry).rotate(-xAxisRotation);
  25685. A = A.transform(mat);
  25686. B = B.transform(mat);
  25687. // Calculate the horizontal and vertical distance between the initial and final point of the arc
  25688. k = [B.x-A.x, B.y-A.y];
  25689. // Find the length of the chord formed by A and B
  25690. cSquare = k[0]*k[0] + k[1]*k[1];
  25691. c = Math.sqrt(cSquare);
  25692. // Calculate the ratios of the horizontal and vertical distance on the length of the chord
  25693. k[0] /= c;
  25694. k[1] /= c;
  25695. // Calculate the distance between the circle center and the chord midpoint
  25696. // using this formula: t = sqrt(r^2 - c^2 / 4)
  25697. // where t is the distance between the cirle center and the chord midpoint,
  25698. // r is the rayon of the circle and c is the chord length
  25699. // From: http://www.ajdesigner.com/phpcircle/circle_segment_chord_t.php
  25700. // Because of the imprecision of floating point numbers, cSquare might end
  25701. // up being slightly above 4 which would result in a negative radicand
  25702. // To prevent that, a test is made before computing the square root
  25703. t = (cSquare < 4) ? Math.sqrt(1 - cSquare/4) : 0;
  25704. // For most situations, there are actually two different ellipses that
  25705. // satisfy the constraints imposed by the points A and B, the radii rx and ry,
  25706. // and the xAxisRotation
  25707. // When the flags largeArcFlag and sweepFlag are equal, it means that the
  25708. // second ellipse is used as a solution
  25709. // See: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
  25710. if(largeArcFlag === sweepFlag) {
  25711. t *= -1;
  25712. }
  25713. // Calculate the coordinates of the center of the circle from the midpoint of the chord
  25714. // This is done by multiplying the ratios calculated previously by the distance between
  25715. // the circle center and the chord midpoint and using these values to go from the midpoint
  25716. // to the center of the circle
  25717. // The negative of the vertical distance ratio is used to modify the x coordinate while
  25718. // the horizontal distance ratio is used to modify the y coordinate
  25719. // That is because the center of the circle is perpendicular to the chord and perpendicular
  25720. // lines are negative reciprocals
  25721. O = new SVG.Point((B.x+A.x)/2 + t*-k[1], (B.y+A.y)/2 + t*k[0]);
  25722. // Move the center of the circle at the origin
  25723. OA = new SVG.Point(A.x-O.x, A.y-O.y);
  25724. OB = new SVG.Point(B.x-O.x, B.y-O.y);
  25725. // Calculate the start and end angle
  25726. tetaStart = Math.acos(OA.x/Math.sqrt(OA.x*OA.x + OA.y*OA.y));
  25727. if (OA.y < 0) {
  25728. tetaStart *= -1;
  25729. }
  25730. tetaEnd = Math.acos(OB.x/Math.sqrt(OB.x*OB.x + OB.y*OB.y));
  25731. if (OB.y < 0) {
  25732. tetaEnd *= -1;
  25733. }
  25734. // If sweep-flag is '1', then the arc will be drawn in a "positive-angle" direction,
  25735. // make sure that the end angle is above the start angle
  25736. if (sweepFlag && tetaStart > tetaEnd) {
  25737. tetaEnd += 2*Math.PI;
  25738. }
  25739. // If sweep-flag is '0', then the arc will be drawn in a "negative-angle" direction,
  25740. // make sure that the end angle is below the start angle
  25741. if (!sweepFlag && tetaStart < tetaEnd) {
  25742. tetaEnd -= 2*Math.PI;
  25743. }
  25744. // Find the number of Bezier curves that are required to represent the arc
  25745. // A cubic Bezier curve gives a good enough approximation when representing at most a quarter of a circle
  25746. nbSectors = Math.ceil(Math.abs(tetaStart-tetaEnd) * 2/Math.PI);
  25747. // Calculate the coordinates of the points of all the Bezier curves required to represent the arc
  25748. // For an in-depth explanation of this part see: http://pomax.github.io/bezierinfo/#circles_cubic
  25749. arcSegPoints = [];
  25750. angle = tetaStart;
  25751. deltaTeta = (tetaEnd-tetaStart)/nbSectors;
  25752. f = 4*Math.tan(deltaTeta/4)/3;
  25753. for (i = 0; i <= nbSectors; i++) { // The <= is because a Bezier curve have a start and a endpoint
  25754. cosAngle = Math.cos(angle);
  25755. sinAngle = Math.sin(angle);
  25756. pt = new SVG.Point(O.x+cosAngle, O.y+sinAngle);
  25757. 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)];
  25758. angle += deltaTeta;
  25759. }
  25760. // Remove the first control point of the first segment point and remove the second control point of the last segment point
  25761. // These two control points are not used in the approximation of the arc, that is why they are removed
  25762. arcSegPoints[0][0] = arcSegPoints[0][1].clone();
  25763. arcSegPoints[arcSegPoints.length-1][2] = arcSegPoints[arcSegPoints.length-1][1].clone();
  25764. // Revert the transformation that was applied to make the arc part of a unit circle instead of an ellipse
  25765. mat = new SVG.Matrix().rotate(xAxisRotation).scale(rx, ry).rotate(-xAxisRotation);
  25766. for (i = 0, il = arcSegPoints.length; i < il; i++) {
  25767. arcSegPoints[i][0] = arcSegPoints[i][0].transform(mat);
  25768. arcSegPoints[i][1] = arcSegPoints[i][1].transform(mat);
  25769. arcSegPoints[i][2] = arcSegPoints[i][2].transform(mat);
  25770. }
  25771. // Convert the segments points to SVG curve commands
  25772. for (i = 1, il = arcSegPoints.length; i < il; i++) {
  25773. pt = arcSegPoints[i-1][2];
  25774. x1 = pt.x;
  25775. y1 = pt.y;
  25776. pt = arcSegPoints[i][0];
  25777. x2 = pt.x;
  25778. y2 = pt.y;
  25779. pt = arcSegPoints[i][1];
  25780. x = pt.x;
  25781. y = pt.y;
  25782. retVal.push(['C', x1, y1, x2, y2, x, y]);
  25783. }
  25784. return retVal
  25785. }
  25786. }());
  25787. /*! svg.draggable.js - v2.2.2 - 2019-01-08
  25788. * https://github.com/svgdotjs/svg.draggable.js
  25789. * Copyright (c) 2019 Wout Fierens; Licensed MIT */
  25790. (function() {
  25791. // creates handler, saves it
  25792. function DragHandler(el){
  25793. el.remember('_draggable', this);
  25794. this.el = el;
  25795. }
  25796. // Sets new parameter, starts dragging
  25797. DragHandler.prototype.init = function(constraint, val){
  25798. var _this = this;
  25799. this.constraint = constraint;
  25800. this.value = val;
  25801. this.el.on('mousedown.drag', function(e){ _this.start(e); });
  25802. this.el.on('touchstart.drag', function(e){ _this.start(e); });
  25803. };
  25804. // transforms one point from screen to user coords
  25805. DragHandler.prototype.transformPoint = function(event, offset){
  25806. event = event || window.event;
  25807. var touches = event.changedTouches && event.changedTouches[0] || event;
  25808. this.p.x = touches.clientX - (offset || 0);
  25809. this.p.y = touches.clientY;
  25810. return this.p.matrixTransform(this.m)
  25811. };
  25812. // gets elements bounding box with special handling of groups, nested and use
  25813. DragHandler.prototype.getBBox = function(){
  25814. var box = this.el.bbox();
  25815. if(this.el instanceof SVG.Nested) box = this.el.rbox();
  25816. if (this.el instanceof SVG.G || this.el instanceof SVG.Use || this.el instanceof SVG.Nested) {
  25817. box.x = this.el.x();
  25818. box.y = this.el.y();
  25819. }
  25820. return box
  25821. };
  25822. // start dragging
  25823. DragHandler.prototype.start = function(e){
  25824. // check for left button
  25825. if(e.type == 'click'|| e.type == 'mousedown' || e.type == 'mousemove'){
  25826. if((e.which || e.buttons) != 1){
  25827. return
  25828. }
  25829. }
  25830. var _this = this;
  25831. // fire beforedrag event
  25832. this.el.fire('beforedrag', { event: e, handler: this });
  25833. if(this.el.event().defaultPrevented) return;
  25834. // prevent browser drag behavior as soon as possible
  25835. e.preventDefault();
  25836. // prevent propagation to a parent that might also have dragging enabled
  25837. e.stopPropagation();
  25838. // search for parent on the fly to make sure we can call
  25839. // draggable() even when element is not in the dom currently
  25840. this.parent = this.parent || this.el.parent(SVG.Nested) || this.el.parent(SVG.Doc);
  25841. this.p = this.parent.node.createSVGPoint();
  25842. // save current transformation matrix
  25843. this.m = this.el.node.getScreenCTM().inverse();
  25844. var box = this.getBBox();
  25845. var anchorOffset;
  25846. // fix text-anchor in text-element (#37)
  25847. if(this.el instanceof SVG.Text){
  25848. anchorOffset = this.el.node.getComputedTextLength();
  25849. switch(this.el.attr('text-anchor')){
  25850. case 'middle':
  25851. anchorOffset /= 2;
  25852. break
  25853. case 'start':
  25854. anchorOffset = 0;
  25855. break;
  25856. }
  25857. }
  25858. this.startPoints = {
  25859. // We take absolute coordinates since we are just using a delta here
  25860. point: this.transformPoint(e, anchorOffset),
  25861. box: box,
  25862. transform: this.el.transform()
  25863. };
  25864. // add drag and end events to window
  25865. SVG.on(window, 'mousemove.drag', function(e){ _this.drag(e); });
  25866. SVG.on(window, 'touchmove.drag', function(e){ _this.drag(e); });
  25867. SVG.on(window, 'mouseup.drag', function(e){ _this.end(e); });
  25868. SVG.on(window, 'touchend.drag', function(e){ _this.end(e); });
  25869. // fire dragstart event
  25870. this.el.fire('dragstart', {event: e, p: this.startPoints.point, m: this.m, handler: this});
  25871. };
  25872. // while dragging
  25873. DragHandler.prototype.drag = function(e){
  25874. var box = this.getBBox()
  25875. , p = this.transformPoint(e)
  25876. , x = this.startPoints.box.x + p.x - this.startPoints.point.x
  25877. , y = this.startPoints.box.y + p.y - this.startPoints.point.y
  25878. , c = this.constraint
  25879. , gx = p.x - this.startPoints.point.x
  25880. , gy = p.y - this.startPoints.point.y;
  25881. this.el.fire('dragmove', {
  25882. event: e
  25883. , p: p
  25884. , m: this.m
  25885. , handler: this
  25886. });
  25887. if(this.el.event().defaultPrevented) return p
  25888. // move the element to its new position, if possible by constraint
  25889. if (typeof c == 'function') {
  25890. var coord = c.call(this.el, x, y, this.m);
  25891. // bool, just show us if movement is allowed or not
  25892. if (typeof coord == 'boolean') {
  25893. coord = {
  25894. x: coord,
  25895. y: coord
  25896. };
  25897. }
  25898. // if true, we just move. If !false its a number and we move it there
  25899. if (coord.x === true) {
  25900. this.el.x(x);
  25901. } else if (coord.x !== false) {
  25902. this.el.x(coord.x);
  25903. }
  25904. if (coord.y === true) {
  25905. this.el.y(y);
  25906. } else if (coord.y !== false) {
  25907. this.el.y(coord.y);
  25908. }
  25909. } else if (typeof c == 'object') {
  25910. // keep element within constrained box
  25911. if (c.minX != null && x < c.minX) {
  25912. x = c.minX;
  25913. gx = x - this.startPoints.box.x;
  25914. } else if (c.maxX != null && x > c.maxX - box.width) {
  25915. x = c.maxX - box.width;
  25916. gx = x - this.startPoints.box.x;
  25917. } if (c.minY != null && y < c.minY) {
  25918. y = c.minY;
  25919. gy = y - this.startPoints.box.y;
  25920. } else if (c.maxY != null && y > c.maxY - box.height) {
  25921. y = c.maxY - box.height;
  25922. gy = y - this.startPoints.box.y;
  25923. }
  25924. if (c.snapToGrid != null) {
  25925. x = x - (x % c.snapToGrid);
  25926. y = y - (y % c.snapToGrid);
  25927. gx = gx - (gx % c.snapToGrid);
  25928. gy = gy - (gy % c.snapToGrid);
  25929. }
  25930. if(this.el instanceof SVG.G)
  25931. this.el.matrix(this.startPoints.transform).transform({x:gx, y: gy}, true);
  25932. else
  25933. this.el.move(x, y);
  25934. }
  25935. // so we can use it in the end-method, too
  25936. return p
  25937. };
  25938. DragHandler.prototype.end = function(e){
  25939. // final drag
  25940. var p = this.drag(e);
  25941. // fire dragend event
  25942. this.el.fire('dragend', { event: e, p: p, m: this.m, handler: this });
  25943. // unbind events
  25944. SVG.off(window, 'mousemove.drag');
  25945. SVG.off(window, 'touchmove.drag');
  25946. SVG.off(window, 'mouseup.drag');
  25947. SVG.off(window, 'touchend.drag');
  25948. };
  25949. SVG.extend(SVG.Element, {
  25950. // Make element draggable
  25951. // 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.
  25952. // 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.
  25953. draggable: function(value, constraint) {
  25954. // Check the parameters and reassign if needed
  25955. if (typeof value == 'function' || typeof value == 'object') {
  25956. constraint = value;
  25957. value = true;
  25958. }
  25959. var dragHandler = this.remember('_draggable') || new DragHandler(this);
  25960. // When no parameter is given, value is true
  25961. value = typeof value === 'undefined' ? true : value;
  25962. if(value) dragHandler.init(constraint || {}, value);
  25963. else {
  25964. this.off('mousedown.drag');
  25965. this.off('touchstart.drag');
  25966. }
  25967. return this
  25968. }
  25969. });
  25970. }).call(undefined);
  25971. (function() {
  25972. function SelectHandler(el) {
  25973. this.el = el;
  25974. el.remember('_selectHandler', this);
  25975. this.pointSelection = {isSelected: false};
  25976. this.rectSelection = {isSelected: false};
  25977. // helper list with position settings of each type of point
  25978. this.pointsList = {
  25979. lt: [ 0, 0 ],
  25980. rt: [ 'width', 0 ],
  25981. rb: [ 'width', 'height' ],
  25982. lb: [ 0, 'height' ],
  25983. t: [ 'width', 0 ],
  25984. r: [ 'width', 'height' ],
  25985. b: [ 'width', 'height' ],
  25986. l: [ 0, 'height' ]
  25987. };
  25988. // helper function to get point coordinates based on settings above and an object (bbox in our case)
  25989. this.pointCoord = function (setting, object, isPointCentered) {
  25990. var coord = typeof setting !== 'string' ? setting : object[setting];
  25991. // Top, bottom, right and left points are placed in the center of element width/height
  25992. return isPointCentered ? coord / 2 : coord
  25993. };
  25994. this.pointCoords = function (point, object) {
  25995. var settings = this.pointsList[point];
  25996. return {
  25997. x: this.pointCoord(settings[0], object, (point === 't' || point === 'b')),
  25998. y: this.pointCoord(settings[1], object, (point === 'r' || point === 'l'))
  25999. }
  26000. };
  26001. }
  26002. SelectHandler.prototype.init = function (value, options) {
  26003. var bbox = this.el.bbox();
  26004. this.options = {};
  26005. // store defaults list of points in order to verify users config
  26006. var points = this.el.selectize.defaults.points;
  26007. // Merging the defaults and the options-object together
  26008. for (var i in this.el.selectize.defaults) {
  26009. this.options[i] = this.el.selectize.defaults[i];
  26010. if (options[i] !== undefined) {
  26011. this.options[i] = options[i];
  26012. }
  26013. }
  26014. // prepare & validate list of points to be added (or excluded)
  26015. var pointsLists = ['points', 'pointsExclude'];
  26016. for (var i in pointsLists) {
  26017. var option = this.options[pointsLists[i]];
  26018. if (typeof option === 'string') {
  26019. if (option.length > 0) {
  26020. // if set as comma separated string list => convert it into an array
  26021. option = option.split(/\s*,\s*/i);
  26022. } else {
  26023. option = [];
  26024. }
  26025. } else if (typeof option === 'boolean' && pointsLists[i] === 'points') {
  26026. // this is not needed, but let's have it for legacy support
  26027. option = option ? points : [];
  26028. }
  26029. this.options[pointsLists[i]] = option;
  26030. }
  26031. // intersect correct all points options with users config (exclude unwanted points)
  26032. // ES5 -> NO arrow functions nor Array.includes()
  26033. this.options.points = [ points, this.options.points ].reduce(
  26034. function (a, b) {
  26035. return a.filter(
  26036. function (c) {
  26037. return b.indexOf(c) > -1;
  26038. }
  26039. )
  26040. }
  26041. );
  26042. // exclude pointsExclude, if wanted
  26043. this.options.points = [ this.options.points, this.options.pointsExclude ].reduce(
  26044. function (a, b) {
  26045. return a.filter(
  26046. function (c) {
  26047. return b.indexOf(c) < 0;
  26048. }
  26049. )
  26050. }
  26051. );
  26052. this.parent = this.el.parent();
  26053. this.nested = (this.nested || this.parent.group());
  26054. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  26055. // When deepSelect is enabled and the element is a line/polyline/polygon, draw only points for moving
  26056. if (this.options.deepSelect && ['line', 'polyline', 'polygon'].indexOf(this.el.type) !== -1) {
  26057. this.selectPoints(value);
  26058. } else {
  26059. this.selectRect(value);
  26060. }
  26061. this.observe();
  26062. this.cleanup();
  26063. };
  26064. SelectHandler.prototype.selectPoints = function (value) {
  26065. this.pointSelection.isSelected = value;
  26066. // When set is already there we dont have to create one
  26067. if (this.pointSelection.set) {
  26068. return this;
  26069. }
  26070. // Create our set of elements
  26071. this.pointSelection.set = this.parent.set();
  26072. // draw the points and mark the element as selected
  26073. this.drawPoints();
  26074. return this;
  26075. };
  26076. // create the point-array which contains the 2 points of a line or simply the points-array of polyline/polygon
  26077. SelectHandler.prototype.getPointArray = function () {
  26078. var bbox = this.el.bbox();
  26079. return this.el.array().valueOf().map(function (el) {
  26080. return [el[0] - bbox.x, el[1] - bbox.y];
  26081. });
  26082. };
  26083. // Draws a points
  26084. SelectHandler.prototype.drawPoints = function () {
  26085. var _this = this, array = this.getPointArray();
  26086. // go through the array of points
  26087. for (var i = 0, len = array.length; i < len; ++i) {
  26088. var curriedEvent = (function (k) {
  26089. return function (ev) {
  26090. ev = ev || window.event;
  26091. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  26092. ev.stopPropagation();
  26093. var x = ev.pageX || ev.touches[0].pageX;
  26094. var y = ev.pageY || ev.touches[0].pageY;
  26095. _this.el.fire('point', {x: x, y: y, i: k, event: ev});
  26096. };
  26097. })(i);
  26098. // add every point to the set
  26099. // add css-classes and a touchstart-event which fires our event for moving points
  26100. var point = this.drawPoint(array[i][0], array[i][1])
  26101. .addClass(this.options.classPoints)
  26102. .addClass(this.options.classPoints + '_point')
  26103. .on('touchstart', curriedEvent)
  26104. .on('mousedown', curriedEvent);
  26105. this.pointSelection.set.add(point);
  26106. }
  26107. };
  26108. // The function to draw single point
  26109. SelectHandler.prototype.drawPoint = function (cx, cy) {
  26110. var pointType = this.options.pointType;
  26111. switch (pointType) {
  26112. case 'circle':
  26113. return this.drawCircle(cx, cy);
  26114. case 'rect':
  26115. return this.drawRect(cx, cy);
  26116. default:
  26117. if (typeof pointType === 'function') {
  26118. return pointType.call(this, cx, cy);
  26119. }
  26120. throw new Error('Unknown ' + pointType + ' point type!');
  26121. }
  26122. };
  26123. // The function to draw the circle point
  26124. SelectHandler.prototype.drawCircle = function (cx, cy) {
  26125. return this.nested.circle(this.options.pointSize)
  26126. .center(cx, cy);
  26127. };
  26128. // The function to draw the rect point
  26129. SelectHandler.prototype.drawRect = function (cx, cy) {
  26130. return this.nested.rect(this.options.pointSize, this.options.pointSize)
  26131. .center(cx, cy);
  26132. };
  26133. // every time a point is moved, we have to update the positions of our point
  26134. SelectHandler.prototype.updatePointSelection = function () {
  26135. var array = this.getPointArray();
  26136. this.pointSelection.set.each(function (i) {
  26137. if (this.cx() === array[i][0] && this.cy() === array[i][1]) {
  26138. return;
  26139. }
  26140. this.center(array[i][0], array[i][1]);
  26141. });
  26142. };
  26143. SelectHandler.prototype.updateRectSelection = function () {
  26144. var _this = this, bbox = this.el.bbox();
  26145. this.rectSelection.set.get(0).attr({
  26146. width: bbox.width,
  26147. height: bbox.height
  26148. });
  26149. // set.get(1) is always in the upper left corner. no need to move it
  26150. if (this.options.points.length) {
  26151. this.options.points.map(function (point, index) {
  26152. var coords = _this.pointCoords(point, bbox);
  26153. _this.rectSelection.set.get(index + 1).center(coords.x, coords.y);
  26154. });
  26155. }
  26156. if (this.options.rotationPoint) {
  26157. var length = this.rectSelection.set.length();
  26158. this.rectSelection.set.get(length - 1).center(bbox.width / 2, 20);
  26159. }
  26160. };
  26161. SelectHandler.prototype.selectRect = function (value) {
  26162. var _this = this, bbox = this.el.bbox();
  26163. this.rectSelection.isSelected = value;
  26164. // when set is already p
  26165. this.rectSelection.set = this.rectSelection.set || this.parent.set();
  26166. // helperFunction to create a mouse-down function which triggers the event specified in `eventName`
  26167. function getMoseDownFunc(eventName) {
  26168. return function (ev) {
  26169. ev = ev || window.event;
  26170. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  26171. ev.stopPropagation();
  26172. var x = ev.pageX || ev.touches[0].pageX;
  26173. var y = ev.pageY || ev.touches[0].pageY;
  26174. _this.el.fire(eventName, {x: x, y: y, event: ev});
  26175. };
  26176. }
  26177. // create the selection-rectangle and add the css-class
  26178. if (!this.rectSelection.set.get(0)) {
  26179. this.rectSelection.set.add(this.nested.rect(bbox.width, bbox.height).addClass(this.options.classRect));
  26180. }
  26181. // Draw Points at the edges, if enabled
  26182. if (this.options.points.length && this.rectSelection.set.length() < 2) {
  26183. var ename ="touchstart", mname = "mousedown";
  26184. this.options.points.map(function (point, index) {
  26185. var coords = _this.pointCoords(point, bbox);
  26186. var pointElement = _this.drawPoint(coords.x, coords.y)
  26187. .attr('class', _this.options.classPoints + '_' + point)
  26188. .on(mname, getMoseDownFunc(point))
  26189. .on(ename, getMoseDownFunc(point));
  26190. _this.rectSelection.set.add(pointElement);
  26191. });
  26192. this.rectSelection.set.each(function () {
  26193. this.addClass(_this.options.classPoints);
  26194. });
  26195. }
  26196. // draw rotationPint, if enabled
  26197. if (this.options.rotationPoint && ((this.options.points && !this.rectSelection.set.get(9)) || (!this.options.points && !this.rectSelection.set.get(1)))) {
  26198. var curriedEvent = function (ev) {
  26199. ev = ev || window.event;
  26200. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  26201. ev.stopPropagation();
  26202. var x = ev.pageX || ev.touches[0].pageX;
  26203. var y = ev.pageY || ev.touches[0].pageY;
  26204. _this.el.fire('rot', {x: x, y: y, event: ev});
  26205. };
  26206. var pointElement = this.drawPoint(bbox.width / 2, 20)
  26207. .attr('class', this.options.classPoints + '_rot')
  26208. .on("touchstart", curriedEvent)
  26209. .on("mousedown", curriedEvent);
  26210. this.rectSelection.set.add(pointElement);
  26211. }
  26212. };
  26213. SelectHandler.prototype.handler = function () {
  26214. var bbox = this.el.bbox();
  26215. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  26216. if (this.rectSelection.isSelected) {
  26217. this.updateRectSelection();
  26218. }
  26219. if (this.pointSelection.isSelected) {
  26220. this.updatePointSelection();
  26221. }
  26222. };
  26223. SelectHandler.prototype.observe = function () {
  26224. var _this = this;
  26225. if (MutationObserver) {
  26226. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  26227. this.observerInst = this.observerInst || new MutationObserver(function () {
  26228. _this.handler();
  26229. });
  26230. this.observerInst.observe(this.el.node, {attributes: true});
  26231. } else {
  26232. try {
  26233. this.observerInst.disconnect();
  26234. delete this.observerInst;
  26235. } catch (e) {
  26236. }
  26237. }
  26238. } else {
  26239. this.el.off('DOMAttrModified.select');
  26240. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  26241. this.el.on('DOMAttrModified.select', function () {
  26242. _this.handler();
  26243. });
  26244. }
  26245. }
  26246. };
  26247. SelectHandler.prototype.cleanup = function () {
  26248. //var _this = this;
  26249. if (!this.rectSelection.isSelected && this.rectSelection.set) {
  26250. // stop watching the element, remove the selection
  26251. this.rectSelection.set.each(function () {
  26252. this.remove();
  26253. });
  26254. this.rectSelection.set.clear();
  26255. delete this.rectSelection.set;
  26256. }
  26257. if (!this.pointSelection.isSelected && this.pointSelection.set) {
  26258. // Remove all points, clear the set, stop watching the element
  26259. this.pointSelection.set.each(function () {
  26260. this.remove();
  26261. });
  26262. this.pointSelection.set.clear();
  26263. delete this.pointSelection.set;
  26264. }
  26265. if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
  26266. this.nested.remove();
  26267. delete this.nested;
  26268. }
  26269. };
  26270. SVG.extend(SVG.Element, {
  26271. // Select element with mouse
  26272. selectize: function (value, options) {
  26273. // Check the parameters and reassign if needed
  26274. if (typeof value === 'object') {
  26275. options = value;
  26276. value = true;
  26277. }
  26278. var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
  26279. selectHandler.init(value === undefined ? true : value, options || {});
  26280. return this;
  26281. }
  26282. });
  26283. SVG.Element.prototype.selectize.defaults = {
  26284. points: ['lt', 'rt', 'rb', 'lb', 't', 'r', 'b', 'l'], // which points to draw, default all
  26285. pointsExclude: [], // easier option if to exclude few than rewrite all
  26286. classRect: 'svg_select_boundingRect', // Css-class added to the rect
  26287. classPoints: 'svg_select_points', // Css-class added to the points
  26288. pointSize: 7, // size of point
  26289. rotationPoint: true, // If true, rotation point is drawn. Needed for rotation!
  26290. deepSelect: false, // If true, moving of single points is possible (only line, polyline, polyon)
  26291. pointType: 'circle' // Point type: circle or rect, default circle
  26292. };
  26293. }());
  26294. (function() {
  26295. (function () {
  26296. function ResizeHandler(el) {
  26297. el.remember('_resizeHandler', this);
  26298. this.el = el;
  26299. this.parameters = {};
  26300. this.lastUpdateCall = null;
  26301. this.p = el.doc().node.createSVGPoint();
  26302. }
  26303. ResizeHandler.prototype.transformPoint = function(x, y, m){
  26304. this.p.x = x - (this.offset.x - window.pageXOffset);
  26305. this.p.y = y - (this.offset.y - window.pageYOffset);
  26306. return this.p.matrixTransform(m || this.m);
  26307. };
  26308. ResizeHandler.prototype._extractPosition = function(event) {
  26309. // Extract a position from a mouse/touch event.
  26310. // Returns { x: .., y: .. }
  26311. return {
  26312. x: event.clientX != null ? event.clientX : event.touches[0].clientX,
  26313. y: event.clientY != null ? event.clientY : event.touches[0].clientY
  26314. }
  26315. };
  26316. ResizeHandler.prototype.init = function (options) {
  26317. var _this = this;
  26318. this.stop();
  26319. if (options === 'stop') {
  26320. return;
  26321. }
  26322. this.options = {};
  26323. // Merge options and defaults
  26324. for (var i in this.el.resize.defaults) {
  26325. this.options[i] = this.el.resize.defaults[i];
  26326. if (typeof options[i] !== 'undefined') {
  26327. this.options[i] = options[i];
  26328. }
  26329. }
  26330. // We listen to all these events which are specifying different edges
  26331. this.el.on('lt.resize', function(e){ _this.resize(e || window.event); }); // Left-Top
  26332. this.el.on('rt.resize', function(e){ _this.resize(e || window.event); }); // Right-Top
  26333. this.el.on('rb.resize', function(e){ _this.resize(e || window.event); }); // Right-Bottom
  26334. this.el.on('lb.resize', function(e){ _this.resize(e || window.event); }); // Left-Bottom
  26335. this.el.on('t.resize', function(e){ _this.resize(e || window.event); }); // Top
  26336. this.el.on('r.resize', function(e){ _this.resize(e || window.event); }); // Right
  26337. this.el.on('b.resize', function(e){ _this.resize(e || window.event); }); // Bottom
  26338. this.el.on('l.resize', function(e){ _this.resize(e || window.event); }); // Left
  26339. this.el.on('rot.resize', function(e){ _this.resize(e || window.event); }); // Rotation
  26340. this.el.on('point.resize', function(e){ _this.resize(e || window.event); }); // Point-Moving
  26341. // This call ensures, that the plugin reacts to a change of snapToGrid immediately
  26342. this.update();
  26343. };
  26344. ResizeHandler.prototype.stop = function(){
  26345. this.el.off('lt.resize');
  26346. this.el.off('rt.resize');
  26347. this.el.off('rb.resize');
  26348. this.el.off('lb.resize');
  26349. this.el.off('t.resize');
  26350. this.el.off('r.resize');
  26351. this.el.off('b.resize');
  26352. this.el.off('l.resize');
  26353. this.el.off('rot.resize');
  26354. this.el.off('point.resize');
  26355. return this;
  26356. };
  26357. ResizeHandler.prototype.resize = function (event) {
  26358. var _this = this;
  26359. this.m = this.el.node.getScreenCTM().inverse();
  26360. this.offset = { x: window.pageXOffset, y: window.pageYOffset };
  26361. var txPt = this._extractPosition(event.detail.event);
  26362. this.parameters = {
  26363. type: this.el.type, // the type of element
  26364. p: this.transformPoint(txPt.x, txPt.y),
  26365. x: event.detail.x, // x-position of the mouse when resizing started
  26366. y: event.detail.y, // y-position of the mouse when resizing started
  26367. box: this.el.bbox(), // The bounding-box of the element
  26368. rotation: this.el.transform().rotation // The current rotation of the element
  26369. };
  26370. // Add font-size parameter if the element type is text
  26371. if (this.el.type === "text") {
  26372. this.parameters.fontSize = this.el.attr()["font-size"];
  26373. }
  26374. // the i-param in the event holds the index of the point which is moved, when using `deepSelect`
  26375. if (event.detail.i !== undefined) {
  26376. // get the point array
  26377. var array = this.el.array().valueOf();
  26378. // Save the index and the point which is moved
  26379. this.parameters.i = event.detail.i;
  26380. this.parameters.pointCoords = [array[event.detail.i][0], array[event.detail.i][1]];
  26381. }
  26382. // Lets check which edge of the bounding-box was clicked and resize the this.el according to this
  26383. switch (event.type) {
  26384. // Left-Top-Edge
  26385. case 'lt':
  26386. // We build a calculating function for every case which gives us the new position of the this.el
  26387. this.calc = function (diffX, diffY) {
  26388. // The procedure is always the same
  26389. // First we snap the edge to the given grid (snapping to 1px grid is normal resizing)
  26390. var snap = this.snapToGrid(diffX, diffY);
  26391. // Now we check if the new height and width still valid (> 0)
  26392. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  26393. // ...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)
  26394. /*
  26395. * but first check if the element is text box, so we can change the font size instead of
  26396. * the width and height
  26397. */
  26398. if (this.parameters.type === "text") {
  26399. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  26400. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  26401. return;
  26402. }
  26403. snap = this.checkAspectRatio(snap);
  26404. 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]);
  26405. }
  26406. };
  26407. break;
  26408. // Right-Top
  26409. case 'rt':
  26410. // s.a.
  26411. this.calc = function (diffX, diffY) {
  26412. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  26413. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  26414. if (this.parameters.type === "text") {
  26415. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  26416. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  26417. return;
  26418. }
  26419. snap = this.checkAspectRatio(snap, true);
  26420. 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]);
  26421. }
  26422. };
  26423. break;
  26424. // Right-Bottom
  26425. case 'rb':
  26426. // s.a.
  26427. this.calc = function (diffX, diffY) {
  26428. var snap = this.snapToGrid(diffX, diffY, 0);
  26429. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  26430. if (this.parameters.type === "text") {
  26431. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  26432. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  26433. return;
  26434. }
  26435. snap = this.checkAspectRatio(snap);
  26436. this.el.move(this.parameters.box.x, this.parameters.box.y).size(this.parameters.box.width + snap[0], this.parameters.box.height + snap[1]);
  26437. }
  26438. };
  26439. break;
  26440. // Left-Bottom
  26441. case 'lb':
  26442. // s.a.
  26443. this.calc = function (diffX, diffY) {
  26444. var snap = this.snapToGrid(diffX, diffY, 1);
  26445. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  26446. if (this.parameters.type === "text") {
  26447. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  26448. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  26449. return;
  26450. }
  26451. snap = this.checkAspectRatio(snap, true);
  26452. 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]);
  26453. }
  26454. };
  26455. break;
  26456. // Top
  26457. case 't':
  26458. // s.a.
  26459. this.calc = function (diffX, diffY) {
  26460. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  26461. if (this.parameters.box.height - snap[1] > 0) {
  26462. // Disable the font-resizing if it is not from the corner of bounding-box
  26463. if (this.parameters.type === "text") {
  26464. return;
  26465. }
  26466. this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).height(this.parameters.box.height - snap[1]);
  26467. }
  26468. };
  26469. break;
  26470. // Right
  26471. case 'r':
  26472. // s.a.
  26473. this.calc = function (diffX, diffY) {
  26474. var snap = this.snapToGrid(diffX, diffY, 0);
  26475. if (this.parameters.box.width + snap[0] > 0) {
  26476. if (this.parameters.type === "text") {
  26477. return;
  26478. }
  26479. this.el.move(this.parameters.box.x, this.parameters.box.y).width(this.parameters.box.width + snap[0]);
  26480. }
  26481. };
  26482. break;
  26483. // Bottom
  26484. case 'b':
  26485. // s.a.
  26486. this.calc = function (diffX, diffY) {
  26487. var snap = this.snapToGrid(diffX, diffY, 0);
  26488. if (this.parameters.box.height + snap[1] > 0) {
  26489. if (this.parameters.type === "text") {
  26490. return;
  26491. }
  26492. this.el.move(this.parameters.box.x, this.parameters.box.y).height(this.parameters.box.height + snap[1]);
  26493. }
  26494. };
  26495. break;
  26496. // Left
  26497. case 'l':
  26498. // s.a.
  26499. this.calc = function (diffX, diffY) {
  26500. var snap = this.snapToGrid(diffX, diffY, 1);
  26501. if (this.parameters.box.width - snap[0] > 0) {
  26502. if (this.parameters.type === "text") {
  26503. return;
  26504. }
  26505. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).width(this.parameters.box.width - snap[0]);
  26506. }
  26507. };
  26508. break;
  26509. // Rotation
  26510. case 'rot':
  26511. // s.a.
  26512. this.calc = function (diffX, diffY) {
  26513. // yes this is kinda stupid but we need the mouse coords back...
  26514. var current = {x: diffX + this.parameters.p.x, y: diffY + this.parameters.p.y};
  26515. // start minus middle
  26516. 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));
  26517. // end minus middle
  26518. 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));
  26519. var angle = this.parameters.rotation + (pAngle - sAngle) * 180 / Math.PI + this.options.snapToAngle / 2;
  26520. // We have to move the element to the center of the box first and change the rotation afterwards
  26521. // because rotation always works around a rotation-center, which is changed when moving the element
  26522. // We also set the new rotation center to the center of the box.
  26523. 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);
  26524. };
  26525. break;
  26526. // Moving one single Point (needed when an element is deepSelected which means you can move every single point of the object)
  26527. case 'point':
  26528. this.calc = function (diffX, diffY) {
  26529. // Snapping the point to the grid
  26530. var snap = this.snapToGrid(diffX, diffY, this.parameters.pointCoords[0], this.parameters.pointCoords[1]);
  26531. // Get the point array
  26532. var array = this.el.array().valueOf();
  26533. // Changing the moved point in the array
  26534. array[this.parameters.i][0] = this.parameters.pointCoords[0] + snap[0];
  26535. array[this.parameters.i][1] = this.parameters.pointCoords[1] + snap[1];
  26536. // And plot the new this.el
  26537. this.el.plot(array);
  26538. };
  26539. }
  26540. this.el.fire('resizestart', {dx: this.parameters.x, dy: this.parameters.y, event: event});
  26541. // When resizing started, we have to register events for...
  26542. // Touches.
  26543. SVG.on(window, 'touchmove.resize', function(e) {
  26544. _this.update(e || window.event);
  26545. });
  26546. SVG.on(window, 'touchend.resize', function() {
  26547. _this.done();
  26548. });
  26549. // Mouse.
  26550. SVG.on(window, 'mousemove.resize', function (e) {
  26551. _this.update(e || window.event);
  26552. });
  26553. SVG.on(window, 'mouseup.resize', function () {
  26554. _this.done();
  26555. });
  26556. };
  26557. // The update-function redraws the element every time the mouse is moving
  26558. ResizeHandler.prototype.update = function (event) {
  26559. if (!event) {
  26560. if (this.lastUpdateCall) {
  26561. this.calc(this.lastUpdateCall[0], this.lastUpdateCall[1]);
  26562. }
  26563. return;
  26564. }
  26565. // Calculate the difference between the mouseposition at start and now
  26566. var txPt = this._extractPosition(event);
  26567. var p = this.transformPoint(txPt.x, txPt.y);
  26568. var diffX = p.x - this.parameters.p.x,
  26569. diffY = p.y - this.parameters.p.y;
  26570. this.lastUpdateCall = [diffX, diffY];
  26571. // Calculate the new position and height / width of the element
  26572. this.calc(diffX, diffY);
  26573. // Emit an event to say we have changed.
  26574. this.el.fire('resizing', {dx: diffX, dy: diffY, event: event});
  26575. };
  26576. // Is called on mouseup.
  26577. // Removes the update-function from the mousemove event
  26578. ResizeHandler.prototype.done = function () {
  26579. this.lastUpdateCall = null;
  26580. SVG.off(window, 'mousemove.resize');
  26581. SVG.off(window, 'mouseup.resize');
  26582. SVG.off(window, 'touchmove.resize');
  26583. SVG.off(window, 'touchend.resize');
  26584. this.el.fire('resizedone');
  26585. };
  26586. // The flag is used to determine whether the resizing is used with a left-Point (first bit) and top-point (second bit)
  26587. // In this cases the temp-values are calculated differently
  26588. ResizeHandler.prototype.snapToGrid = function (diffX, diffY, flag, pointCoordsY) {
  26589. var temp;
  26590. // If `pointCoordsY` is given, a single Point has to be snapped (deepSelect). That's why we need a different temp-value
  26591. if (typeof pointCoordsY !== 'undefined') {
  26592. // Note that flag = pointCoordsX in this case
  26593. temp = [(flag + diffX) % this.options.snapToGrid, (pointCoordsY + diffY) % this.options.snapToGrid];
  26594. } else {
  26595. // We check if the flag is set and if not we set a default-value (both bits set - which means upper-left-edge)
  26596. flag = flag == null ? 1 | 1 << 1 : flag;
  26597. 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];
  26598. }
  26599. if(diffX < 0) {
  26600. temp[0] -= this.options.snapToGrid;
  26601. }
  26602. if(diffY < 0) {
  26603. temp[1] -= this.options.snapToGrid;
  26604. }
  26605. diffX -= (Math.abs(temp[0]) < this.options.snapToGrid / 2 ?
  26606. temp[0] :
  26607. temp[0] - (diffX < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  26608. diffY -= (Math.abs(temp[1]) < this.options.snapToGrid / 2 ?
  26609. temp[1] :
  26610. temp[1] - (diffY < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  26611. return this.constraintToBox(diffX, diffY, flag, pointCoordsY);
  26612. };
  26613. // keep element within constrained box
  26614. ResizeHandler.prototype.constraintToBox = function (diffX, diffY, flag, pointCoordsY) {
  26615. //return [diffX, diffY]
  26616. var c = this.options.constraint || {};
  26617. var orgX, orgY;
  26618. if (typeof pointCoordsY !== 'undefined') {
  26619. orgX = flag;
  26620. orgY = pointCoordsY;
  26621. } else {
  26622. orgX = this.parameters.box.x + (flag & 1 ? 0 : this.parameters.box.width);
  26623. orgY = this.parameters.box.y + (flag & (1<<1) ? 0 : this.parameters.box.height);
  26624. }
  26625. if (typeof c.minX !== 'undefined' && orgX + diffX < c.minX) {
  26626. diffX = c.minX - orgX;
  26627. }
  26628. if (typeof c.maxX !== 'undefined' && orgX + diffX > c.maxX) {
  26629. diffX = c.maxX - orgX;
  26630. }
  26631. if (typeof c.minY !== 'undefined' && orgY + diffY < c.minY) {
  26632. diffY = c.minY - orgY;
  26633. }
  26634. if (typeof c.maxY !== 'undefined' && orgY + diffY > c.maxY) {
  26635. diffY = c.maxY - orgY;
  26636. }
  26637. return [diffX, diffY];
  26638. };
  26639. ResizeHandler.prototype.checkAspectRatio = function (snap, isReverse) {
  26640. if (!this.options.saveAspectRatio) {
  26641. return snap;
  26642. }
  26643. var updatedSnap = snap.slice();
  26644. var aspectRatio = this.parameters.box.width / this.parameters.box.height;
  26645. var newW = this.parameters.box.width + snap[0];
  26646. var newH = this.parameters.box.height - snap[1];
  26647. var newAspectRatio = newW / newH;
  26648. if (newAspectRatio < aspectRatio) {
  26649. // Height is too big. Adapt it
  26650. updatedSnap[1] = newW / aspectRatio - this.parameters.box.height;
  26651. isReverse && (updatedSnap[1] = -updatedSnap[1]);
  26652. } else if (newAspectRatio > aspectRatio) {
  26653. // Width is too big. Adapt it
  26654. updatedSnap[0] = this.parameters.box.width - newH * aspectRatio;
  26655. isReverse && (updatedSnap[0] = -updatedSnap[0]);
  26656. }
  26657. return updatedSnap;
  26658. };
  26659. SVG.extend(SVG.Element, {
  26660. // Resize element with mouse
  26661. resize: function (options) {
  26662. (this.remember('_resizeHandler') || new ResizeHandler(this)).init(options || {});
  26663. return this;
  26664. }
  26665. });
  26666. SVG.Element.prototype.resize.defaults = {
  26667. snapToAngle: 0.1, // Specifies the speed the rotation is happening when moving the mouse
  26668. snapToGrid: 1, // Snaps to a grid of `snapToGrid` Pixels
  26669. constraint: {}, // keep element within constrained box
  26670. saveAspectRatio: false // Save aspect ratio when resizing using lt, rt, rb or lb points
  26671. };
  26672. }).call(this);
  26673. }());
  26674. if (typeof window.Apex === 'undefined') {
  26675. window.Apex = {};
  26676. }
  26677. var InitCtxVariables = /*#__PURE__*/function () {
  26678. function InitCtxVariables(ctx) {
  26679. _classCallCheck(this, InitCtxVariables);
  26680. this.ctx = ctx;
  26681. this.w = ctx.w;
  26682. }
  26683. _createClass(InitCtxVariables, [{
  26684. key: "initModules",
  26685. value: function initModules() {
  26686. this.ctx.publicMethods = ['updateOptions', 'updateSeries', 'appendData', 'appendSeries', 'toggleSeries', 'showSeries', 'hideSeries', 'setLocale', 'resetSeries', 'zoomX', 'toggleDataPointSelection', 'dataURI', 'addXaxisAnnotation', 'addYaxisAnnotation', 'addPointAnnotation', 'clearAnnotations', 'removeAnnotation', 'paper', 'destroy'];
  26687. this.ctx.eventList = ['click', 'mousedown', 'mousemove', 'mouseleave', 'touchstart', 'touchmove', 'touchleave', 'mouseup', 'touchend'];
  26688. this.ctx.animations = new Animations(this.ctx);
  26689. this.ctx.axes = new Axes(this.ctx);
  26690. this.ctx.core = new Core(this.ctx.el, this.ctx);
  26691. this.ctx.config = new Config({});
  26692. this.ctx.data = new Data(this.ctx);
  26693. this.ctx.grid = new Grid(this.ctx);
  26694. this.ctx.graphics = new Graphics(this.ctx);
  26695. this.ctx.coreUtils = new CoreUtils(this.ctx);
  26696. this.ctx.crosshairs = new Crosshairs(this.ctx);
  26697. this.ctx.events = new Events(this.ctx);
  26698. this.ctx.exports = new Exports(this.ctx);
  26699. this.ctx.localization = new Localization(this.ctx);
  26700. this.ctx.options = new Options();
  26701. this.ctx.responsive = new Responsive(this.ctx);
  26702. this.ctx.series = new Series(this.ctx);
  26703. this.ctx.theme = new Theme(this.ctx);
  26704. this.ctx.formatters = new Formatters(this.ctx);
  26705. this.ctx.titleSubtitle = new TitleSubtitle(this.ctx);
  26706. this.ctx.legend = new Legend(this.ctx);
  26707. this.ctx.toolbar = new Toolbar(this.ctx);
  26708. this.ctx.dimensions = new Dimensions(this.ctx);
  26709. this.ctx.updateHelpers = new UpdateHelpers(this.ctx);
  26710. this.ctx.zoomPanSelection = new ZoomPanSelection(this.ctx);
  26711. this.ctx.w.globals.tooltip = new Tooltip(this.ctx);
  26712. }
  26713. }]);
  26714. return InitCtxVariables;
  26715. }();
  26716. var Destroy = /*#__PURE__*/function () {
  26717. function Destroy(ctx) {
  26718. _classCallCheck(this, Destroy);
  26719. this.ctx = ctx;
  26720. this.w = ctx.w;
  26721. }
  26722. _createClass(Destroy, [{
  26723. key: "clear",
  26724. value: function clear(_ref) {
  26725. var isUpdating = _ref.isUpdating;
  26726. if (this.ctx.zoomPanSelection) {
  26727. this.ctx.zoomPanSelection.destroy();
  26728. }
  26729. if (this.ctx.toolbar) {
  26730. this.ctx.toolbar.destroy();
  26731. }
  26732. this.ctx.animations = null;
  26733. this.ctx.axes = null;
  26734. this.ctx.annotations = null;
  26735. this.ctx.core = null;
  26736. this.ctx.data = null;
  26737. this.ctx.grid = null;
  26738. this.ctx.series = null;
  26739. this.ctx.responsive = null;
  26740. this.ctx.theme = null;
  26741. this.ctx.formatters = null;
  26742. this.ctx.titleSubtitle = null;
  26743. this.ctx.legend = null;
  26744. this.ctx.dimensions = null;
  26745. this.ctx.options = null;
  26746. this.ctx.crosshairs = null;
  26747. this.ctx.zoomPanSelection = null;
  26748. this.ctx.updateHelpers = null;
  26749. this.ctx.toolbar = null;
  26750. this.ctx.localization = null;
  26751. this.ctx.w.globals.tooltip = null;
  26752. this.clearDomElements({
  26753. isUpdating: isUpdating
  26754. });
  26755. }
  26756. }, {
  26757. key: "killSVG",
  26758. value: function killSVG(draw) {
  26759. draw.each(function (i, children) {
  26760. this.removeClass('*');
  26761. this.off();
  26762. this.stop();
  26763. }, true);
  26764. draw.ungroup();
  26765. draw.clear();
  26766. }
  26767. }, {
  26768. key: "clearDomElements",
  26769. value: function clearDomElements(_ref2) {
  26770. var _this = this;
  26771. var isUpdating = _ref2.isUpdating;
  26772. var elSVG = this.w.globals.dom.Paper.node; // fixes apexcharts.js#1654 & vue-apexcharts#256
  26773. if (elSVG.parentNode && elSVG.parentNode.parentNode && !isUpdating) {
  26774. elSVG.parentNode.parentNode.style.minHeight = 'unset';
  26775. } // detach root event
  26776. var baseEl = this.w.globals.dom.baseEl;
  26777. if (baseEl) {
  26778. // see https://github.com/apexcharts/vue-apexcharts/issues/275
  26779. this.ctx.eventList.forEach(function (event) {
  26780. baseEl.removeEventListener(event, _this.ctx.events.documentEvent);
  26781. });
  26782. }
  26783. var domEls = this.w.globals.dom;
  26784. if (this.ctx.el !== null) {
  26785. // remove all child elements - resetting the whole chart
  26786. while (this.ctx.el.firstChild) {
  26787. this.ctx.el.removeChild(this.ctx.el.firstChild);
  26788. }
  26789. }
  26790. this.killSVG(domEls.Paper);
  26791. domEls.Paper.remove();
  26792. domEls.elWrap = null;
  26793. domEls.elGraphical = null;
  26794. domEls.elAnnotations = null;
  26795. domEls.elLegendWrap = null;
  26796. domEls.baseEl = null;
  26797. domEls.elGridRect = null;
  26798. domEls.elGridRectMask = null;
  26799. domEls.elGridRectMarkerMask = null;
  26800. domEls.elForecastMask = null;
  26801. domEls.elNonForecastMask = null;
  26802. domEls.elDefs = null;
  26803. }
  26804. }]);
  26805. return Destroy;
  26806. }();
  26807. // Helpers to react to element resizes, regardless of what caused them
  26808. // TODO Currently this creates a new ResizeObserver every time we want to observe an element for resizes
  26809. // Ideally, we should be able to use a single observer for all elements
  26810. var ros = new WeakMap(); // Map callbacks to ResizeObserver instances for easy removal
  26811. function addResizeListener(el, fn) {
  26812. var called = false;
  26813. var elRect = el.getBoundingClientRect();
  26814. if (el.style.display === 'none' || elRect.width === 0) {
  26815. // if elRect.width=0, the chart is not rendered at all
  26816. // (it has either display none or hidden in a different tab)
  26817. // fixes https://github.com/apexcharts/apexcharts.js/issues/2825
  26818. // fixes https://github.com/apexcharts/apexcharts.js/issues/2991
  26819. // fixes https://github.com/apexcharts/apexcharts.js/issues/2992
  26820. called = true;
  26821. }
  26822. var ro = new ResizeObserver(function (r) {
  26823. // ROs fire immediately after being created,
  26824. // per spec: https://drafts.csswg.org/resize-observer/#ref-for-element%E2%91%A3
  26825. // we don't want that so we just discard the first run
  26826. if (called) {
  26827. fn.call(el, r);
  26828. }
  26829. called = true;
  26830. });
  26831. if (el.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  26832. // Document fragment, observe children instead (needed for Shadow DOM, see #1332)
  26833. Array.from(el.children).forEach(function (c) {
  26834. return ro.observe(c);
  26835. });
  26836. } else {
  26837. ro.observe(el);
  26838. }
  26839. ros.set(fn, ro);
  26840. }
  26841. function removeResizeListener(el, fn) {
  26842. var ro = ros.get(fn);
  26843. if (ro) {
  26844. ro.disconnect();
  26845. ros.delete(fn);
  26846. }
  26847. }
  26848. var css_248z = ".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\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 display: flex;\n flex-direction: column;\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-y-value,\n.apexcharts-tooltip-text-goals-value,\n.apexcharts-tooltip-text-z-value {\n display: inline-block;\n font-weight: 600;\n margin-left: 5px;\n}\n\n.apexcharts-tooltip-title:empty,\n.apexcharts-tooltip-text-y-label:empty,\n.apexcharts-tooltip-text-y-value:empty,\n.apexcharts-tooltip-text-goals-label:empty,\n.apexcharts-tooltip-text-goals-value:empty,\n.apexcharts-tooltip-text-z-value:empty {\n display: none;\n}\n\n.apexcharts-tooltip-text-y-value,\n.apexcharts-tooltip-text-goals-value,\n.apexcharts-tooltip-text-z-value {\n font-weight: 600;\n}\n\n.apexcharts-tooltip-text-goals-label, \n.apexcharts-tooltip-text-goals-value {\n padding: 6px 0 5px;\n}\n\n.apexcharts-tooltip-goals-group, \n.apexcharts-tooltip-text-goals-label, \n.apexcharts-tooltip-text-goals-value {\n display: flex;\n}\n.apexcharts-tooltip-text-goals-label:not(:empty),\n.apexcharts-tooltip-text-goals-value:not(:empty) {\n margin-top: -6px;\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-box, .apexcharts-custom-tooltip {\n padding: 4px 8px;\n}\n\n.apexcharts-tooltip-boxPlot {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.apexcharts-tooltip-box>div {\n margin: 4px 0;\n}\n\n.apexcharts-tooltip-box 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-svg.apexcharts-zoomable.hovering-zoom {\n cursor: crosshair\n}\n\n.apexcharts-svg.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}";
  26849. /**
  26850. *
  26851. * @module ApexCharts
  26852. **/
  26853. var ApexCharts$1 = /*#__PURE__*/function () {
  26854. function ApexCharts(el, opts) {
  26855. _classCallCheck(this, ApexCharts);
  26856. this.opts = opts;
  26857. 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.
  26858. this.w = new Base(opts).init();
  26859. this.el = el;
  26860. this.w.globals.cuid = Utils$1.randomId();
  26861. this.w.globals.chartID = this.w.config.chart.id ? Utils$1.escapeString(this.w.config.chart.id) : this.w.globals.cuid;
  26862. var initCtx = new InitCtxVariables(this);
  26863. initCtx.initModules();
  26864. this.create = Utils$1.bind(this.create, this);
  26865. this.windowResizeHandler = this._windowResizeHandler.bind(this);
  26866. this.parentResizeHandler = this._parentResizeCallback.bind(this);
  26867. }
  26868. /**
  26869. * The primary method user will call to render the chart.
  26870. */
  26871. _createClass(ApexCharts, [{
  26872. key: "render",
  26873. value: function render() {
  26874. var _this = this;
  26875. // main method
  26876. return new Promise(function (resolve, reject) {
  26877. // only draw chart, if element found
  26878. if (_this.el !== null) {
  26879. if (typeof Apex._chartInstances === 'undefined') {
  26880. Apex._chartInstances = [];
  26881. }
  26882. if (_this.w.config.chart.id) {
  26883. Apex._chartInstances.push({
  26884. id: _this.w.globals.chartID,
  26885. group: _this.w.config.chart.group,
  26886. chart: _this
  26887. });
  26888. } // set the locale here
  26889. _this.setLocale(_this.w.config.chart.defaultLocale);
  26890. var beforeMount = _this.w.config.chart.events.beforeMount;
  26891. if (typeof beforeMount === 'function') {
  26892. beforeMount(_this, _this.w);
  26893. }
  26894. _this.events.fireEvent('beforeMount', [_this, _this.w]);
  26895. window.addEventListener('resize', _this.windowResizeHandler);
  26896. addResizeListener(_this.el.parentNode, _this.parentResizeHandler); // Add CSS if not already added
  26897. if (!_this.css) {
  26898. var rootNode = _this.el.getRootNode && _this.el.getRootNode();
  26899. var inShadowRoot = Utils$1.is('ShadowRoot', rootNode);
  26900. var doc = _this.el.ownerDocument;
  26901. var globalCSS = doc.getElementById('apexcharts-css');
  26902. if (inShadowRoot || !globalCSS) {
  26903. _this.css = document.createElement('style');
  26904. _this.css.id = 'apexcharts-css';
  26905. _this.css.textContent = css_248z;
  26906. if (inShadowRoot) {
  26907. // We are in Shadow DOM, add to shadow root
  26908. rootNode.prepend(_this.css);
  26909. } else {
  26910. // Add to <head> of element's document
  26911. doc.head.appendChild(_this.css);
  26912. }
  26913. }
  26914. }
  26915. var graphData = _this.create(_this.w.config.series, {});
  26916. if (!graphData) return resolve(_this);
  26917. _this.mount(graphData).then(function () {
  26918. if (typeof _this.w.config.chart.events.mounted === 'function') {
  26919. _this.w.config.chart.events.mounted(_this, _this.w);
  26920. }
  26921. _this.events.fireEvent('mounted', [_this, _this.w]);
  26922. resolve(graphData);
  26923. }).catch(function (e) {
  26924. reject(e); // handle error in case no data or element not found
  26925. });
  26926. } else {
  26927. reject(new Error('Element not found'));
  26928. }
  26929. });
  26930. }
  26931. }, {
  26932. key: "create",
  26933. value: function create(ser, opts) {
  26934. var w = this.w;
  26935. var initCtx = new InitCtxVariables(this);
  26936. initCtx.initModules();
  26937. var gl = this.w.globals;
  26938. gl.noData = false;
  26939. gl.animationEnded = false;
  26940. this.responsive.checkResponsiveConfig(opts);
  26941. if (w.config.xaxis.convertedCatToNumeric) {
  26942. var defaults = new Defaults(w.config);
  26943. defaults.convertCatToNumericXaxis(w.config, this.ctx);
  26944. }
  26945. if (this.el === null) {
  26946. gl.animationEnded = true;
  26947. return null;
  26948. }
  26949. this.core.setupElements();
  26950. if (w.config.chart.type === 'treemap') {
  26951. w.config.grid.show = false;
  26952. w.config.yaxis[0].show = false;
  26953. }
  26954. if (gl.svgWidth === 0) {
  26955. // if the element is hidden, skip drawing
  26956. gl.animationEnded = true;
  26957. return null;
  26958. }
  26959. var combo = CoreUtils.checkComboSeries(ser);
  26960. gl.comboCharts = combo.comboCharts;
  26961. gl.comboBarCount = combo.comboBarCount;
  26962. var allSeriesAreEmpty = ser.every(function (s) {
  26963. return s.data && s.data.length === 0;
  26964. });
  26965. if (ser.length === 0 || allSeriesAreEmpty) {
  26966. this.series.handleNoData();
  26967. }
  26968. 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
  26969. this.data.parseData(ser); // this is a good time to set theme colors first
  26970. this.theme.init(); // as markers accepts array, we need to setup global markers for easier access
  26971. var markers = new Markers(this);
  26972. markers.setGlobalMarkerSize(); // labelFormatters should be called before dimensions as in dimensions we need text labels width
  26973. this.formatters.setLabelFormatters();
  26974. this.titleSubtitle.draw(); // legend is calculated here before coreCalculations because it affects the plottable area
  26975. // if there is some data to show or user collapsed all series, then proceed drawing legend
  26976. if (!gl.noData || gl.collapsedSeries.length === gl.series.length || w.config.legend.showForSingleSeries) {
  26977. this.legend.init();
  26978. } // check whether in multiple series, all series share the same X
  26979. 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
  26980. if (gl.axisCharts) {
  26981. this.core.coreCalculations();
  26982. if (w.config.xaxis.type !== 'category') {
  26983. // as we have minX and maxX values, determine the default DateTimeFormat for time series
  26984. this.formatters.setLabelFormatters();
  26985. }
  26986. this.ctx.toolbar.minX = w.globals.minX;
  26987. this.ctx.toolbar.maxX = w.globals.maxX;
  26988. } // 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
  26989. // Also we need to do this before calculating Dimensions plotCoords() method of Dimensions
  26990. this.formatters.heatmapLabelFormatters(); // get the largest marker size which will be needed in dimensions calc
  26991. var coreUtils = new CoreUtils(this);
  26992. coreUtils.getLargestMarkerSize(); // We got plottable area here, next task would be to calculate axis areas
  26993. this.dimensions.plotCoords();
  26994. var xyRatios = this.core.xySettings();
  26995. this.grid.createGridMask();
  26996. var elGraph = this.core.plotChartType(ser, xyRatios);
  26997. var dataLabels = new DataLabels(this);
  26998. dataLabels.bringForward();
  26999. if (w.config.dataLabels.background.enabled) {
  27000. dataLabels.dataLabelsBackground();
  27001. } // after all the drawing calculations, shift the graphical area (actual charts/bars) excluding legends
  27002. this.core.shiftGraphPosition();
  27003. var dim = {
  27004. plot: {
  27005. left: w.globals.translateX,
  27006. top: w.globals.translateY,
  27007. width: w.globals.gridWidth,
  27008. height: w.globals.gridHeight
  27009. }
  27010. };
  27011. return {
  27012. elGraph: elGraph,
  27013. xyRatios: xyRatios,
  27014. elInner: w.globals.dom.elGraphical,
  27015. dimensions: dim
  27016. };
  27017. }
  27018. }, {
  27019. key: "mount",
  27020. value: function mount() {
  27021. var _this2 = this;
  27022. var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  27023. var me = this;
  27024. var w = me.w;
  27025. return new Promise(function (resolve, reject) {
  27026. // no data to display
  27027. if (me.el === null) {
  27028. return reject(new Error('Not enough data to display or target element not found'));
  27029. } else if (graphData === null || w.globals.allSeriesCollapsed) {
  27030. me.series.handleNoData();
  27031. }
  27032. if (w.config.chart.type !== 'treemap') {
  27033. me.axes.drawAxis(w.config.chart.type, graphData.xyRatios);
  27034. }
  27035. me.grid = new Grid(me);
  27036. var elgrid = me.grid.drawGrid();
  27037. me.annotations = new Annotations(me);
  27038. me.annotations.drawImageAnnos();
  27039. me.annotations.drawTextAnnos();
  27040. if (w.config.grid.position === 'back' && elgrid) {
  27041. w.globals.dom.elGraphical.add(elgrid.el);
  27042. }
  27043. var xAxis = new XAxis(_this2.ctx);
  27044. var yaxis = new YAxis(_this2.ctx);
  27045. if (elgrid !== null) {
  27046. xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth);
  27047. yaxis.setYAxisTextAlignments();
  27048. w.config.yaxis.map(function (yaxe, index) {
  27049. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1) {
  27050. yaxis.yAxisTitleRotate(index, yaxe.opposite);
  27051. }
  27052. });
  27053. }
  27054. if (w.config.annotations.position === 'back') {
  27055. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  27056. me.annotations.drawAxesAnnotations();
  27057. }
  27058. if (Array.isArray(graphData.elGraph)) {
  27059. for (var g = 0; g < graphData.elGraph.length; g++) {
  27060. w.globals.dom.elGraphical.add(graphData.elGraph[g]);
  27061. }
  27062. } else {
  27063. w.globals.dom.elGraphical.add(graphData.elGraph);
  27064. }
  27065. if (w.config.grid.position === 'front' && elgrid) {
  27066. w.globals.dom.elGraphical.add(elgrid.el);
  27067. }
  27068. if (w.config.xaxis.crosshairs.position === 'front') {
  27069. me.crosshairs.drawXCrosshairs();
  27070. }
  27071. if (w.config.yaxis[0].crosshairs.position === 'front') {
  27072. me.crosshairs.drawYCrosshairs();
  27073. }
  27074. if (w.config.annotations.position === 'front') {
  27075. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  27076. me.annotations.drawAxesAnnotations();
  27077. }
  27078. if (!w.globals.noData) {
  27079. // draw tooltips at the end
  27080. if (w.config.tooltip.enabled && !w.globals.noData) {
  27081. me.w.globals.tooltip.drawTooltip(graphData.xyRatios);
  27082. }
  27083. if (w.globals.axisCharts && (w.globals.isXNumeric || w.config.xaxis.convertedCatToNumeric || w.globals.isRangeBar)) {
  27084. if (w.config.chart.zoom.enabled || w.config.chart.selection && w.config.chart.selection.enabled || w.config.chart.pan && w.config.chart.pan.enabled) {
  27085. me.zoomPanSelection.init({
  27086. xyRatios: graphData.xyRatios
  27087. });
  27088. }
  27089. } else {
  27090. var tools = w.config.chart.toolbar.tools;
  27091. var toolsArr = ['zoom', 'zoomin', 'zoomout', 'selection', 'pan', 'reset'];
  27092. toolsArr.forEach(function (t) {
  27093. tools[t] = false;
  27094. });
  27095. }
  27096. if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) {
  27097. me.toolbar.createToolbar();
  27098. }
  27099. }
  27100. if (w.globals.memory.methodsToExec.length > 0) {
  27101. w.globals.memory.methodsToExec.forEach(function (fn) {
  27102. fn.method(fn.params, false, fn.context);
  27103. });
  27104. }
  27105. if (!w.globals.axisCharts && !w.globals.noData) {
  27106. me.core.resizeNonAxisCharts();
  27107. }
  27108. resolve(me);
  27109. });
  27110. }
  27111. /**
  27112. * Destroy the chart instance by removing all elements which also clean up event listeners on those elements.
  27113. */
  27114. }, {
  27115. key: "destroy",
  27116. value: function destroy() {
  27117. window.removeEventListener('resize', this.windowResizeHandler);
  27118. removeResizeListener(this.el.parentNode, this.parentResizeHandler); // remove the chart's instance from the global Apex._chartInstances
  27119. var chartID = this.w.config.chart.id;
  27120. if (chartID) {
  27121. Apex._chartInstances.forEach(function (c, i) {
  27122. if (c.id === Utils$1.escapeString(chartID)) {
  27123. Apex._chartInstances.splice(i, 1);
  27124. }
  27125. });
  27126. }
  27127. new Destroy(this.ctx).clear({
  27128. isUpdating: false
  27129. });
  27130. }
  27131. /**
  27132. * Allows users to update Options after the chart has rendered.
  27133. *
  27134. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  27135. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  27136. * @param {boolean} animate - should animate or not on updating Options
  27137. */
  27138. }, {
  27139. key: "updateOptions",
  27140. value: function updateOptions(options) {
  27141. var _this3 = this;
  27142. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  27143. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  27144. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  27145. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  27146. var w = this.w; // when called externally, clear some global variables
  27147. // fixes apexcharts.js#1488
  27148. w.globals.selection = undefined;
  27149. if (options.series) {
  27150. this.series.resetSeries(false, true, false);
  27151. if (options.series.length && options.series[0].data) {
  27152. options.series = options.series.map(function (s, i) {
  27153. return _this3.updateHelpers._extendSeries(s, i);
  27154. });
  27155. } // user updated the series via updateOptions() function.
  27156. // Hence, we need to reset axis min/max to avoid zooming issues
  27157. this.updateHelpers.revertDefaultAxisMinMax();
  27158. } // user has set x-axis min/max externally - hence we need to forcefully set the xaxis min/max
  27159. if (options.xaxis) {
  27160. options = this.updateHelpers.forceXAxisUpdate(options);
  27161. }
  27162. if (options.yaxis) {
  27163. options = this.updateHelpers.forceYAxisUpdate(options);
  27164. }
  27165. if (w.globals.collapsedSeriesIndices.length > 0) {
  27166. this.series.clearPreviousPaths();
  27167. }
  27168. /* update theme mode#459 */
  27169. if (options.theme) {
  27170. options = this.theme.updateThemeOptions(options);
  27171. }
  27172. return this.updateHelpers._updateOptions(options, redraw, animate, updateSyncedCharts, overwriteInitialConfig);
  27173. }
  27174. /**
  27175. * Allows users to update Series after the chart has rendered.
  27176. *
  27177. * @param {array} series - New series which will override the existing
  27178. */
  27179. }, {
  27180. key: "updateSeries",
  27181. value: function updateSeries() {
  27182. var newSeries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  27183. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27184. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  27185. this.series.resetSeries(false);
  27186. this.updateHelpers.revertDefaultAxisMinMax();
  27187. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  27188. }
  27189. /**
  27190. * Allows users to append a new series after the chart has rendered.
  27191. *
  27192. * @param {array} newSerie - New serie which will be appended to the existing series
  27193. */
  27194. }, {
  27195. key: "appendSeries",
  27196. value: function appendSeries(newSerie) {
  27197. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27198. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  27199. var newSeries = this.w.config.series.slice();
  27200. newSeries.push(newSerie);
  27201. this.series.resetSeries(false);
  27202. this.updateHelpers.revertDefaultAxisMinMax();
  27203. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  27204. }
  27205. /**
  27206. * Allows users to append Data to series.
  27207. *
  27208. * @param {array} newData - New data in the same format as series
  27209. */
  27210. }, {
  27211. key: "appendData",
  27212. value: function appendData(newData) {
  27213. var overwriteInitialSeries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27214. var me = this;
  27215. me.w.globals.dataChanged = true;
  27216. me.series.getPreviousPaths();
  27217. var newSeries = me.w.config.series.slice();
  27218. for (var i = 0; i < newSeries.length; i++) {
  27219. if (newData[i] !== null && typeof newData[i] !== 'undefined') {
  27220. for (var j = 0; j < newData[i].data.length; j++) {
  27221. newSeries[i].data.push(newData[i].data[j]);
  27222. }
  27223. }
  27224. }
  27225. me.w.config.series = newSeries;
  27226. if (overwriteInitialSeries) {
  27227. me.w.globals.initialSeries = Utils$1.clone(me.w.config.series);
  27228. }
  27229. return this.update();
  27230. }
  27231. }, {
  27232. key: "update",
  27233. value: function update(options) {
  27234. var _this4 = this;
  27235. return new Promise(function (resolve, reject) {
  27236. new Destroy(_this4.ctx).clear({
  27237. isUpdating: true
  27238. });
  27239. var graphData = _this4.create(_this4.w.config.series, options);
  27240. if (!graphData) return resolve(_this4);
  27241. _this4.mount(graphData).then(function () {
  27242. if (typeof _this4.w.config.chart.events.updated === 'function') {
  27243. _this4.w.config.chart.events.updated(_this4, _this4.w);
  27244. }
  27245. _this4.events.fireEvent('updated', [_this4, _this4.w]);
  27246. _this4.w.globals.isDirty = true;
  27247. resolve(_this4);
  27248. }).catch(function (e) {
  27249. reject(e);
  27250. });
  27251. });
  27252. }
  27253. /**
  27254. * Get all charts in the same "group" (including the instance which is called upon) to sync them when user zooms in/out or pan.
  27255. */
  27256. }, {
  27257. key: "getSyncedCharts",
  27258. value: function getSyncedCharts() {
  27259. var chartGroups = this.getGroupedCharts();
  27260. var allCharts = [this];
  27261. if (chartGroups.length) {
  27262. allCharts = [];
  27263. chartGroups.forEach(function (ch) {
  27264. allCharts.push(ch);
  27265. });
  27266. }
  27267. return allCharts;
  27268. }
  27269. /**
  27270. * 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)
  27271. */
  27272. }, {
  27273. key: "getGroupedCharts",
  27274. value: function getGroupedCharts() {
  27275. var _this5 = this;
  27276. return Apex._chartInstances.filter(function (ch) {
  27277. if (ch.group) {
  27278. return true;
  27279. }
  27280. }).map(function (ch) {
  27281. return _this5.w.config.chart.group === ch.group ? ch.chart : _this5;
  27282. });
  27283. }
  27284. }, {
  27285. key: "toggleSeries",
  27286. value: function toggleSeries(seriesName) {
  27287. return this.series.toggleSeries(seriesName);
  27288. }
  27289. }, {
  27290. key: "highlightSeriesOnLegendHover",
  27291. value: function highlightSeriesOnLegendHover(e, targetElement) {
  27292. return this.series.toggleSeriesOnHover(e, targetElement);
  27293. }
  27294. }, {
  27295. key: "showSeries",
  27296. value: function showSeries(seriesName) {
  27297. this.series.showSeries(seriesName);
  27298. }
  27299. }, {
  27300. key: "hideSeries",
  27301. value: function hideSeries(seriesName) {
  27302. this.series.hideSeries(seriesName);
  27303. }
  27304. }, {
  27305. key: "resetSeries",
  27306. value: function resetSeries() {
  27307. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  27308. var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27309. this.series.resetSeries(shouldUpdateChart, shouldResetZoom);
  27310. } // Public method to add event listener on chart context
  27311. }, {
  27312. key: "addEventListener",
  27313. value: function addEventListener(name, handler) {
  27314. this.events.addEventListener(name, handler);
  27315. } // Public method to remove event listener on chart context
  27316. }, {
  27317. key: "removeEventListener",
  27318. value: function removeEventListener(name, handler) {
  27319. this.events.removeEventListener(name, handler);
  27320. }
  27321. }, {
  27322. key: "addXaxisAnnotation",
  27323. value: function addXaxisAnnotation(opts) {
  27324. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27325. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  27326. var me = this;
  27327. if (context) {
  27328. me = context;
  27329. }
  27330. me.annotations.addXaxisAnnotationExternal(opts, pushToMemory, me);
  27331. }
  27332. }, {
  27333. key: "addYaxisAnnotation",
  27334. value: function addYaxisAnnotation(opts) {
  27335. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27336. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  27337. var me = this;
  27338. if (context) {
  27339. me = context;
  27340. }
  27341. me.annotations.addYaxisAnnotationExternal(opts, pushToMemory, me);
  27342. }
  27343. }, {
  27344. key: "addPointAnnotation",
  27345. value: function addPointAnnotation(opts) {
  27346. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  27347. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  27348. var me = this;
  27349. if (context) {
  27350. me = context;
  27351. }
  27352. me.annotations.addPointAnnotationExternal(opts, pushToMemory, me);
  27353. }
  27354. }, {
  27355. key: "clearAnnotations",
  27356. value: function clearAnnotations() {
  27357. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
  27358. var me = this;
  27359. if (context) {
  27360. me = context;
  27361. }
  27362. me.annotations.clearAnnotations(me);
  27363. }
  27364. }, {
  27365. key: "removeAnnotation",
  27366. value: function removeAnnotation(id) {
  27367. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  27368. var me = this;
  27369. if (context) {
  27370. me = context;
  27371. }
  27372. me.annotations.removeAnnotation(me, id);
  27373. }
  27374. }, {
  27375. key: "getChartArea",
  27376. value: function getChartArea() {
  27377. var el = this.w.globals.dom.baseEl.querySelector('.apexcharts-inner');
  27378. return el;
  27379. }
  27380. }, {
  27381. key: "getSeriesTotalXRange",
  27382. value: function getSeriesTotalXRange(minX, maxX) {
  27383. return this.coreUtils.getSeriesTotalsXRange(minX, maxX);
  27384. }
  27385. }, {
  27386. key: "getHighestValueInSeries",
  27387. value: function getHighestValueInSeries() {
  27388. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  27389. var range = new Range(this.ctx);
  27390. return range.getMinYMaxY(seriesIndex).highestY;
  27391. }
  27392. }, {
  27393. key: "getLowestValueInSeries",
  27394. value: function getLowestValueInSeries() {
  27395. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  27396. var range = new Range(this.ctx);
  27397. return range.getMinYMaxY(seriesIndex).lowestY;
  27398. }
  27399. }, {
  27400. key: "getSeriesTotal",
  27401. value: function getSeriesTotal() {
  27402. return this.w.globals.seriesTotals;
  27403. }
  27404. }, {
  27405. key: "toggleDataPointSelection",
  27406. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  27407. return this.updateHelpers.toggleDataPointSelection(seriesIndex, dataPointIndex);
  27408. }
  27409. }, {
  27410. key: "zoomX",
  27411. value: function zoomX(min, max) {
  27412. this.ctx.toolbar.zoomUpdateOptions(min, max);
  27413. }
  27414. }, {
  27415. key: "setLocale",
  27416. value: function setLocale(localeName) {
  27417. this.localization.setCurrentLocaleValues(localeName);
  27418. }
  27419. }, {
  27420. key: "dataURI",
  27421. value: function dataURI(options) {
  27422. var exp = new Exports(this.ctx);
  27423. return exp.dataURI(options);
  27424. }
  27425. }, {
  27426. key: "paper",
  27427. value: function paper() {
  27428. return this.w.globals.dom.Paper;
  27429. }
  27430. }, {
  27431. key: "_parentResizeCallback",
  27432. value: function _parentResizeCallback() {
  27433. if (this.w.globals.animationEnded && this.w.config.chart.redrawOnParentResize) {
  27434. this._windowResize();
  27435. }
  27436. }
  27437. /**
  27438. * Handle window resize and re-draw the whole chart.
  27439. */
  27440. }, {
  27441. key: "_windowResize",
  27442. value: function _windowResize() {
  27443. var _this6 = this;
  27444. clearTimeout(this.w.globals.resizeTimer);
  27445. this.w.globals.resizeTimer = window.setTimeout(function () {
  27446. _this6.w.globals.resized = true;
  27447. _this6.w.globals.dataChanged = false; // we need to redraw the whole chart on window resize (with a small delay).
  27448. _this6.ctx.update();
  27449. }, 150);
  27450. }
  27451. }, {
  27452. key: "_windowResizeHandler",
  27453. value: function _windowResizeHandler() {
  27454. var redraw = this.w.config.chart.redrawOnWindowResize;
  27455. if (typeof redraw === 'function') {
  27456. redraw = redraw();
  27457. }
  27458. redraw && this._windowResize();
  27459. }
  27460. }], [{
  27461. key: "getChartByID",
  27462. value: function getChartByID(id) {
  27463. var chartId = Utils$1.escapeString(id);
  27464. var c = Apex._chartInstances.filter(function (ch) {
  27465. return ch.id === chartId;
  27466. })[0];
  27467. return c && c.chart;
  27468. }
  27469. /**
  27470. * 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
  27471. */
  27472. }, {
  27473. key: "initOnLoad",
  27474. value: function initOnLoad() {
  27475. var els = document.querySelectorAll('[data-apexcharts]');
  27476. for (var i = 0; i < els.length; i++) {
  27477. var el = els[i];
  27478. var options = JSON.parse(els[i].getAttribute('data-options'));
  27479. var apexChart = new ApexCharts(el, options);
  27480. apexChart.render();
  27481. }
  27482. }
  27483. /**
  27484. * This static method allows users to call chart methods without necessarily from the
  27485. * instance of the chart in case user has assigned chartID to the targeted chart.
  27486. * The chartID is used for mapping the instance stored in Apex._chartInstances global variable
  27487. *
  27488. * This is helpful in cases when you don't have reference of the chart instance
  27489. * easily and need to call the method from anywhere.
  27490. * For eg, in React/Vue applications when you have many parent/child components,
  27491. * and need easy reference to other charts for performing dynamic operations
  27492. *
  27493. * @param {string} chartID - The unique identifier which will be used to call methods
  27494. * on that chart instance
  27495. * @param {function} fn - The method name to call
  27496. * @param {object} opts - The parameters which are accepted in the original method will be passed here in the same order.
  27497. */
  27498. }, {
  27499. key: "exec",
  27500. value: function exec(chartID, fn) {
  27501. var chart = this.getChartByID(chartID);
  27502. if (!chart) return; // turn on the global exec flag to indicate this method was called
  27503. chart.w.globals.isExecCalled = true;
  27504. var ret = null;
  27505. if (chart.publicMethods.indexOf(fn) !== -1) {
  27506. for (var _len = arguments.length, opts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  27507. opts[_key - 2] = arguments[_key];
  27508. }
  27509. ret = chart[fn].apply(chart, opts);
  27510. }
  27511. return ret;
  27512. }
  27513. }, {
  27514. key: "merge",
  27515. value: function merge(target, source) {
  27516. return Utils$1.extend(target, source);
  27517. }
  27518. }]);
  27519. return ApexCharts;
  27520. }();
  27521. return ApexCharts$1;
  27522. })));