apexcharts.js 1003 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605
  1. /*!
  2. * ApexCharts v3.19.0
  3. * (c) 2018-2020 Juned Chhipa
  4. * Released under the MIT License.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global = global || self, global.ApexCharts = factory());
  10. }(this, (function () { 'use strict';
  11. function _typeof(obj) {
  12. "@babel/helpers - typeof";
  13. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  14. _typeof = function (obj) {
  15. return typeof obj;
  16. };
  17. } else {
  18. _typeof = function (obj) {
  19. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  20. };
  21. }
  22. return _typeof(obj);
  23. }
  24. function _classCallCheck(instance, Constructor) {
  25. if (!(instance instanceof Constructor)) {
  26. throw new TypeError("Cannot call a class as a function");
  27. }
  28. }
  29. function _defineProperties(target, props) {
  30. for (var i = 0; i < props.length; i++) {
  31. var descriptor = props[i];
  32. descriptor.enumerable = descriptor.enumerable || false;
  33. descriptor.configurable = true;
  34. if ("value" in descriptor) descriptor.writable = true;
  35. Object.defineProperty(target, descriptor.key, descriptor);
  36. }
  37. }
  38. function _createClass(Constructor, protoProps, staticProps) {
  39. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  40. if (staticProps) _defineProperties(Constructor, staticProps);
  41. return Constructor;
  42. }
  43. function _defineProperty(obj, key, value) {
  44. if (key in obj) {
  45. Object.defineProperty(obj, key, {
  46. value: value,
  47. enumerable: true,
  48. configurable: true,
  49. writable: true
  50. });
  51. } else {
  52. obj[key] = value;
  53. }
  54. return obj;
  55. }
  56. function ownKeys(object, enumerableOnly) {
  57. var keys = Object.keys(object);
  58. if (Object.getOwnPropertySymbols) {
  59. var symbols = Object.getOwnPropertySymbols(object);
  60. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  61. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  62. });
  63. keys.push.apply(keys, symbols);
  64. }
  65. return keys;
  66. }
  67. function _objectSpread2(target) {
  68. for (var i = 1; i < arguments.length; i++) {
  69. var source = arguments[i] != null ? arguments[i] : {};
  70. if (i % 2) {
  71. ownKeys(Object(source), true).forEach(function (key) {
  72. _defineProperty(target, key, source[key]);
  73. });
  74. } else if (Object.getOwnPropertyDescriptors) {
  75. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  76. } else {
  77. ownKeys(Object(source)).forEach(function (key) {
  78. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  79. });
  80. }
  81. }
  82. return target;
  83. }
  84. function _inherits(subClass, superClass) {
  85. if (typeof superClass !== "function" && superClass !== null) {
  86. throw new TypeError("Super expression must either be null or a function");
  87. }
  88. subClass.prototype = Object.create(superClass && superClass.prototype, {
  89. constructor: {
  90. value: subClass,
  91. writable: true,
  92. configurable: true
  93. }
  94. });
  95. if (superClass) _setPrototypeOf(subClass, superClass);
  96. }
  97. function _getPrototypeOf(o) {
  98. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  99. return o.__proto__ || Object.getPrototypeOf(o);
  100. };
  101. return _getPrototypeOf(o);
  102. }
  103. function _setPrototypeOf(o, p) {
  104. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  105. o.__proto__ = p;
  106. return o;
  107. };
  108. return _setPrototypeOf(o, p);
  109. }
  110. function _assertThisInitialized(self) {
  111. if (self === void 0) {
  112. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  113. }
  114. return self;
  115. }
  116. function _possibleConstructorReturn(self, call) {
  117. if (call && (typeof call === "object" || typeof call === "function")) {
  118. return call;
  119. }
  120. return _assertThisInitialized(self);
  121. }
  122. function _toConsumableArray(arr) {
  123. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  124. }
  125. function _arrayWithoutHoles(arr) {
  126. if (Array.isArray(arr)) {
  127. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  128. return arr2;
  129. }
  130. }
  131. function _iterableToArray(iter) {
  132. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  133. }
  134. function _nonIterableSpread() {
  135. throw new TypeError("Invalid attempt to spread non-iterable instance");
  136. }
  137. /*
  138. ** Generic functions which are not dependent on ApexCharts
  139. */
  140. var Utils = /*#__PURE__*/function () {
  141. function Utils() {
  142. _classCallCheck(this, Utils);
  143. }
  144. _createClass(Utils, [{
  145. key: "shadeRGBColor",
  146. value: function shadeRGBColor(percent, color) {
  147. var f = color.split(','),
  148. t = percent < 0 ? 0 : 255,
  149. p = percent < 0 ? percent * -1 : percent,
  150. R = parseInt(f[0].slice(4), 10),
  151. G = parseInt(f[1], 10),
  152. B = parseInt(f[2], 10);
  153. return 'rgb(' + (Math.round((t - R) * p) + R) + ',' + (Math.round((t - G) * p) + G) + ',' + (Math.round((t - B) * p) + B) + ')';
  154. }
  155. }, {
  156. key: "shadeHexColor",
  157. value: function shadeHexColor(percent, color) {
  158. var f = parseInt(color.slice(1), 16),
  159. t = percent < 0 ? 0 : 255,
  160. p = percent < 0 ? percent * -1 : percent,
  161. R = f >> 16,
  162. G = f >> 8 & 0x00ff,
  163. B = f & 0x0000ff;
  164. return '#' + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
  165. } // beautiful color shading blending code
  166. // http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
  167. }, {
  168. key: "shadeColor",
  169. value: function shadeColor(p, color) {
  170. if (Utils.isColorHex(color)) {
  171. return this.shadeHexColor(p, color);
  172. } else {
  173. return this.shadeRGBColor(p, color);
  174. }
  175. }
  176. }], [{
  177. key: "bind",
  178. value: function bind(fn, me) {
  179. return function () {
  180. return fn.apply(me, arguments);
  181. };
  182. }
  183. }, {
  184. key: "isObject",
  185. value: function isObject(item) {
  186. return item && _typeof(item) === 'object' && !Array.isArray(item) && item != null;
  187. }
  188. }, {
  189. key: "listToArray",
  190. value: function listToArray(list) {
  191. var i,
  192. array = [];
  193. for (i = 0; i < list.length; i++) {
  194. array[i] = list[i];
  195. }
  196. return array;
  197. } // to extend defaults with user options
  198. // credit: http://stackoverflow.com/questions/27936772/deep-object-merging-in-es6-es7#answer-34749873
  199. }, {
  200. key: "extend",
  201. value: function extend(target, source) {
  202. var _this = this;
  203. if (typeof Object.assign !== 'function') {
  204. (function () {
  205. Object.assign = function (target) {
  206. if (target === undefined || target === null) {
  207. throw new TypeError('Cannot convert undefined or null to object');
  208. }
  209. var output = Object(target);
  210. for (var index = 1; index < arguments.length; index++) {
  211. var _source = arguments[index];
  212. if (_source !== undefined && _source !== null) {
  213. for (var nextKey in _source) {
  214. if (_source.hasOwnProperty(nextKey)) {
  215. output[nextKey] = _source[nextKey];
  216. }
  217. }
  218. }
  219. }
  220. return output;
  221. };
  222. })();
  223. }
  224. var output = Object.assign({}, target);
  225. if (this.isObject(target) && this.isObject(source)) {
  226. Object.keys(source).forEach(function (key) {
  227. if (_this.isObject(source[key])) {
  228. if (!(key in target)) {
  229. Object.assign(output, _defineProperty({}, key, source[key]));
  230. } else {
  231. output[key] = _this.extend(target[key], source[key]);
  232. }
  233. } else {
  234. Object.assign(output, _defineProperty({}, key, source[key]));
  235. }
  236. });
  237. }
  238. return output;
  239. }
  240. }, {
  241. key: "extendArray",
  242. value: function extendArray(arrToExtend, resultArr) {
  243. var extendedArr = [];
  244. arrToExtend.map(function (item) {
  245. extendedArr.push(Utils.extend(resultArr, item));
  246. });
  247. arrToExtend = extendedArr;
  248. return arrToExtend;
  249. } // If month counter exceeds 12, it starts again from 1
  250. }, {
  251. key: "monthMod",
  252. value: function monthMod(month) {
  253. return month % 12;
  254. }
  255. }, {
  256. key: "clone",
  257. value: function clone(source) {
  258. if (Object.prototype.toString.call(source) === '[object Array]') {
  259. var cloneResult = [];
  260. for (var i = 0; i < source.length; i++) {
  261. cloneResult[i] = this.clone(source[i]);
  262. }
  263. return cloneResult;
  264. } else if (_typeof(source) === 'object') {
  265. var _cloneResult = {};
  266. for (var prop in source) {
  267. if (source.hasOwnProperty(prop)) {
  268. _cloneResult[prop] = this.clone(source[prop]);
  269. }
  270. }
  271. return _cloneResult;
  272. } else {
  273. return source;
  274. }
  275. }
  276. }, {
  277. key: "log10",
  278. value: function log10(x) {
  279. return Math.log(x) / Math.LN10;
  280. }
  281. }, {
  282. key: "roundToBase10",
  283. value: function roundToBase10(x) {
  284. return Math.pow(10, Math.floor(Math.log10(x)));
  285. }
  286. }, {
  287. key: "roundToBase",
  288. value: function roundToBase(x, base) {
  289. return Math.pow(base, Math.floor(Math.log(x) / Math.log(base)));
  290. }
  291. }, {
  292. key: "parseNumber",
  293. value: function parseNumber(val) {
  294. if (val === null) return val;
  295. return parseFloat(val);
  296. }
  297. }, {
  298. key: "randomId",
  299. value: function randomId() {
  300. return (Math.random() + 1).toString(36).substring(4);
  301. }
  302. }, {
  303. key: "noExponents",
  304. value: function noExponents(val) {
  305. var data = String(val).split(/[eE]/);
  306. if (data.length === 1) return data[0];
  307. var z = '',
  308. sign = val < 0 ? '-' : '',
  309. str = data[0].replace('.', ''),
  310. mag = Number(data[1]) + 1;
  311. if (mag < 0) {
  312. z = sign + '0.';
  313. while (mag++) {
  314. z += '0';
  315. }
  316. return z + str.replace(/^-/, '');
  317. }
  318. mag -= str.length;
  319. while (mag--) {
  320. z += '0';
  321. }
  322. return str + z;
  323. }
  324. }, {
  325. key: "getDimensions",
  326. value: function getDimensions(el) {
  327. var computedStyle = getComputedStyle(el);
  328. var ret = [];
  329. var elementHeight = el.clientHeight;
  330. var elementWidth = el.clientWidth;
  331. elementHeight -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
  332. elementWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight);
  333. ret.push(elementWidth);
  334. ret.push(elementHeight);
  335. return ret;
  336. }
  337. }, {
  338. key: "getBoundingClientRect",
  339. value: function getBoundingClientRect(element) {
  340. var rect = element.getBoundingClientRect();
  341. return {
  342. top: rect.top,
  343. right: rect.right,
  344. bottom: rect.bottom,
  345. left: rect.left,
  346. width: element.clientWidth,
  347. height: element.clientHeight,
  348. x: rect.left,
  349. y: rect.top
  350. };
  351. }
  352. }, {
  353. key: "getLargestStringFromArr",
  354. value: function getLargestStringFromArr(arr) {
  355. return arr.reduce(function (a, b) {
  356. if (Array.isArray(b)) {
  357. b = b.reduce(function (aa, bb) {
  358. return aa.length > bb.length ? aa : bb;
  359. });
  360. }
  361. return a.length > b.length ? a : b;
  362. }, 0);
  363. } // http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-12342275
  364. }, {
  365. key: "hexToRgba",
  366. value: function hexToRgba() {
  367. var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#999999';
  368. var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
  369. if (hex.substring(0, 1) !== '#') {
  370. hex = '#999999';
  371. }
  372. var h = hex.replace('#', '');
  373. h = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g'));
  374. for (var i = 0; i < h.length; i++) {
  375. h[i] = parseInt(h[i].length === 1 ? h[i] + h[i] : h[i], 16);
  376. }
  377. if (typeof opacity !== 'undefined') h.push(opacity);
  378. return 'rgba(' + h.join(',') + ')';
  379. }
  380. }, {
  381. key: "getOpacityFromRGBA",
  382. value: function getOpacityFromRGBA(rgba) {
  383. return parseFloat(rgba.replace(/^.*,(.+)\)/, '$1'));
  384. }
  385. }, {
  386. key: "rgb2hex",
  387. value: function rgb2hex(rgb) {
  388. rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  389. return rgb && rgb.length === 4 ? '#' + ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
  390. }
  391. }, {
  392. key: "isColorHex",
  393. value: function isColorHex(color) {
  394. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)|(^#[0-9A-F]{8}$)/i.test(color);
  395. }
  396. }, {
  397. key: "polarToCartesian",
  398. value: function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
  399. var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
  400. return {
  401. x: centerX + radius * Math.cos(angleInRadians),
  402. y: centerY + radius * Math.sin(angleInRadians)
  403. };
  404. }
  405. }, {
  406. key: "escapeString",
  407. value: function escapeString(str) {
  408. var escapeWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';
  409. var newStr = str.toString().slice();
  410. newStr = newStr.replace(/[` ~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, escapeWith);
  411. return newStr;
  412. }
  413. }, {
  414. key: "negToZero",
  415. value: function negToZero(val) {
  416. return val < 0 ? 0 : val;
  417. }
  418. }, {
  419. key: "moveIndexInArray",
  420. value: function moveIndexInArray(arr, old_index, new_index) {
  421. if (new_index >= arr.length) {
  422. var k = new_index - arr.length + 1;
  423. while (k--) {
  424. arr.push(undefined);
  425. }
  426. }
  427. arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
  428. return arr;
  429. }
  430. }, {
  431. key: "extractNumber",
  432. value: function extractNumber(s) {
  433. return parseFloat(s.replace(/[^\d.]*/g, ''));
  434. }
  435. }, {
  436. key: "findAncestor",
  437. value: function findAncestor(el, cls) {
  438. while ((el = el.parentElement) && !el.classList.contains(cls)) {
  439. }
  440. return el;
  441. }
  442. }, {
  443. key: "setELstyles",
  444. value: function setELstyles(el, styles) {
  445. for (var key in styles) {
  446. if (styles.hasOwnProperty(key)) {
  447. el.style.key = styles[key];
  448. }
  449. }
  450. }
  451. }, {
  452. key: "isNumber",
  453. value: function isNumber(value) {
  454. return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
  455. }
  456. }, {
  457. key: "isFloat",
  458. value: function isFloat(n) {
  459. return Number(n) === n && n % 1 !== 0;
  460. }
  461. }, {
  462. key: "isSafari",
  463. value: function isSafari() {
  464. return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  465. }
  466. }, {
  467. key: "isFirefox",
  468. value: function isFirefox() {
  469. return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  470. }
  471. }, {
  472. key: "isIE11",
  473. value: function isIE11() {
  474. if (window.navigator.userAgent.indexOf('MSIE') !== -1 || window.navigator.appVersion.indexOf('Trident/') > -1) {
  475. return true;
  476. }
  477. }
  478. }, {
  479. key: "isIE",
  480. value: function isIE() {
  481. var ua = window.navigator.userAgent;
  482. var msie = ua.indexOf('MSIE ');
  483. if (msie > 0) {
  484. // IE 10 or older => return version number
  485. return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
  486. }
  487. var trident = ua.indexOf('Trident/');
  488. if (trident > 0) {
  489. // IE 11 => return version number
  490. var rv = ua.indexOf('rv:');
  491. return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
  492. }
  493. var edge = ua.indexOf('Edge/');
  494. if (edge > 0) {
  495. // Edge (IE 12+) => return version number
  496. return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
  497. } // other browser
  498. return false;
  499. }
  500. }]);
  501. return Utils;
  502. }();
  503. /**
  504. * ApexCharts Filters Class for setting hover/active states on the paths.
  505. *
  506. * @module Formatters
  507. **/
  508. var Filters = /*#__PURE__*/function () {
  509. function Filters(ctx) {
  510. _classCallCheck(this, Filters);
  511. this.ctx = ctx;
  512. this.w = ctx.w;
  513. } // create a re-usable filter which can be appended other filter effects and applied to multiple elements
  514. _createClass(Filters, [{
  515. key: "getDefaultFilter",
  516. value: function getDefaultFilter(el, i) {
  517. var w = this.w;
  518. el.unfilter(true);
  519. var filter = new window.SVG.Filter();
  520. filter.size('120%', '180%', '-5%', '-40%');
  521. if (w.config.states.normal.filter !== 'none') {
  522. this.applyFilter(el, i, w.config.states.normal.filter.type, w.config.states.normal.filter.value);
  523. } else {
  524. if (w.config.chart.dropShadow.enabled) {
  525. this.dropShadow(el, w.config.chart.dropShadow, i);
  526. }
  527. }
  528. }
  529. }, {
  530. key: "addNormalFilter",
  531. value: function addNormalFilter(el, i) {
  532. var w = this.w; // revert shadow if it was there
  533. // but, ignore marker as marker don't have dropshadow yet
  534. if (w.config.chart.dropShadow.enabled && !el.node.classList.contains('apexcharts-marker')) {
  535. this.dropShadow(el, w.config.chart.dropShadow, i);
  536. }
  537. } // appends dropShadow to the filter object which can be chained with other filter effects
  538. }, {
  539. key: "addLightenFilter",
  540. value: function addLightenFilter(el, i, attrs) {
  541. var _this = this;
  542. var w = this.w;
  543. var intensity = attrs.intensity;
  544. if (Utils.isFirefox()) {
  545. return;
  546. }
  547. el.unfilter(true);
  548. var filter = new window.SVG.Filter();
  549. el.filter(function (add) {
  550. var shadowAttr = w.config.chart.dropShadow;
  551. if (shadowAttr.enabled) {
  552. filter = _this.addShadow(add, i, shadowAttr);
  553. } else {
  554. filter = add;
  555. }
  556. filter.componentTransfer({
  557. rgb: {
  558. type: 'linear',
  559. slope: 1.5,
  560. intercept: intensity
  561. }
  562. });
  563. });
  564. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  565. this._scaleFilterSize(el.filterer.node);
  566. } // appends dropShadow to the filter object which can be chained with other filter effects
  567. }, {
  568. key: "addDarkenFilter",
  569. value: function addDarkenFilter(el, i, attrs) {
  570. var _this2 = this;
  571. var w = this.w;
  572. var intensity = attrs.intensity;
  573. if (Utils.isFirefox()) {
  574. return;
  575. }
  576. el.unfilter(true);
  577. var filter = new window.SVG.Filter();
  578. el.filter(function (add) {
  579. var shadowAttr = w.config.chart.dropShadow;
  580. if (shadowAttr.enabled) {
  581. filter = _this2.addShadow(add, i, shadowAttr);
  582. } else {
  583. filter = add;
  584. }
  585. filter.componentTransfer({
  586. rgb: {
  587. type: 'linear',
  588. slope: intensity
  589. }
  590. });
  591. });
  592. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  593. this._scaleFilterSize(el.filterer.node);
  594. }
  595. }, {
  596. key: "applyFilter",
  597. value: function applyFilter(el, i, filter) {
  598. var intensity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
  599. switch (filter) {
  600. case 'none':
  601. {
  602. this.addNormalFilter(el, i);
  603. break;
  604. }
  605. case 'lighten':
  606. {
  607. this.addLightenFilter(el, i, {
  608. intensity: intensity
  609. });
  610. break;
  611. }
  612. case 'darken':
  613. {
  614. this.addDarkenFilter(el, i, {
  615. intensity: intensity
  616. });
  617. break;
  618. }
  619. }
  620. } // appends dropShadow to the filter object which can be chained with other filter effects
  621. }, {
  622. key: "addShadow",
  623. value: function addShadow(add, i, attrs) {
  624. var blur = attrs.blur,
  625. top = attrs.top,
  626. left = attrs.left,
  627. color = attrs.color,
  628. opacity = attrs.opacity;
  629. var shadowBlur = add.flood(Array.isArray(color) ? color[i] : color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  630. return add.blend(add.source, shadowBlur);
  631. } // directly adds dropShadow to the element and returns the same element.
  632. // the only way it is different from the addShadow() function is that addShadow is chainable to other filters, while this function discards all filters and add dropShadow
  633. }, {
  634. key: "dropShadow",
  635. value: function dropShadow(el, attrs) {
  636. var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  637. var top = attrs.top,
  638. left = attrs.left,
  639. blur = attrs.blur,
  640. color = attrs.color,
  641. opacity = attrs.opacity,
  642. noUserSpaceOnUse = attrs.noUserSpaceOnUse;
  643. var w = this.w;
  644. el.unfilter(true);
  645. if (Utils.isIE() && w.config.chart.type === 'radialBar') {
  646. // in radialbar charts, dropshadow is clipping actual drawing in IE
  647. return el;
  648. }
  649. color = Array.isArray(color) ? color[i] : color;
  650. el.filter(function (add) {
  651. var shadowBlur = null;
  652. if (Utils.isSafari() || Utils.isFirefox() || Utils.isIE()) {
  653. // safari/firefox has some alternative way to use this filter
  654. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur);
  655. } else {
  656. shadowBlur = add.flood(color, opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source);
  657. }
  658. add.blend(add.source, shadowBlur);
  659. });
  660. if (!noUserSpaceOnUse) {
  661. el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse');
  662. }
  663. this._scaleFilterSize(el.filterer.node);
  664. return el;
  665. }
  666. }, {
  667. key: "setSelectionFilter",
  668. value: function setSelectionFilter(el, realIndex, dataPointIndex) {
  669. var w = this.w;
  670. if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') {
  671. if (w.globals.selectedDataPoints[realIndex].indexOf(dataPointIndex) > -1) {
  672. el.node.setAttribute('selected', true);
  673. var activeFilter = w.config.states.active.filter;
  674. if (activeFilter !== 'none') {
  675. this.applyFilter(el, realIndex, activeFilter.type, activeFilter.value);
  676. }
  677. }
  678. }
  679. }
  680. }, {
  681. key: "_scaleFilterSize",
  682. value: function _scaleFilterSize(el) {
  683. var setAttributes = function setAttributes(attrs) {
  684. for (var key in attrs) {
  685. if (attrs.hasOwnProperty(key)) {
  686. el.setAttribute(key, attrs[key]);
  687. }
  688. }
  689. };
  690. setAttributes({
  691. width: '200%',
  692. height: '200%',
  693. x: '-50%',
  694. y: '-50%'
  695. });
  696. }
  697. }]);
  698. return Filters;
  699. }();
  700. /**
  701. * ApexCharts Animation Class.
  702. *
  703. * @module Animations
  704. **/
  705. var Animations = /*#__PURE__*/function () {
  706. function Animations(ctx) {
  707. _classCallCheck(this, Animations);
  708. this.ctx = ctx;
  709. this.w = ctx.w;
  710. this.setEasingFunctions();
  711. }
  712. _createClass(Animations, [{
  713. key: "setEasingFunctions",
  714. value: function setEasingFunctions() {
  715. var easing;
  716. if (this.w.globals.easing) return;
  717. var userDefinedEasing = this.w.config.chart.animations.easing;
  718. switch (userDefinedEasing) {
  719. case 'linear':
  720. {
  721. easing = '-';
  722. break;
  723. }
  724. case 'easein':
  725. {
  726. easing = '<';
  727. break;
  728. }
  729. case 'easeout':
  730. {
  731. easing = '>';
  732. break;
  733. }
  734. case 'easeinout':
  735. {
  736. easing = '<>';
  737. break;
  738. }
  739. case 'swing':
  740. {
  741. easing = function easing(pos) {
  742. var s = 1.70158;
  743. var ret = (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
  744. return ret;
  745. };
  746. break;
  747. }
  748. case 'bounce':
  749. {
  750. easing = function easing(pos) {
  751. var ret = '';
  752. if (pos < 1 / 2.75) {
  753. ret = 7.5625 * pos * pos;
  754. } else if (pos < 2 / 2.75) {
  755. ret = 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75;
  756. } else if (pos < 2.5 / 2.75) {
  757. ret = 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375;
  758. } else {
  759. ret = 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375;
  760. }
  761. return ret;
  762. };
  763. break;
  764. }
  765. case 'elastic':
  766. {
  767. easing = function easing(pos) {
  768. if (pos === !!pos) return pos;
  769. return Math.pow(2, -10 * pos) * Math.sin((pos - 0.075) * (2 * Math.PI) / 0.3) + 1;
  770. };
  771. break;
  772. }
  773. default:
  774. {
  775. easing = '<>';
  776. }
  777. }
  778. this.w.globals.easing = easing;
  779. }
  780. }, {
  781. key: "animateLine",
  782. value: function animateLine(el, from, to, speed) {
  783. el.attr(from).animate(speed).attr(to);
  784. }
  785. /*
  786. ** Animate radius of a circle element
  787. */
  788. }, {
  789. key: "animateCircleRadius",
  790. value: function animateCircleRadius(el, from, to, speed, easing, cb) {
  791. if (!from) from = 0;
  792. el.attr({
  793. r: from
  794. }).animate(speed, easing).attr({
  795. r: to
  796. }).afterAll(function () {
  797. cb();
  798. });
  799. }
  800. /*
  801. ** Animate radius and position of a circle element
  802. */
  803. }, {
  804. key: "animateCircle",
  805. value: function animateCircle(el, from, to, speed, easing) {
  806. el.attr({
  807. r: from.r,
  808. cx: from.cx,
  809. cy: from.cy
  810. }).animate(speed, easing).attr({
  811. r: to.r,
  812. cx: to.cx,
  813. cy: to.cy
  814. });
  815. }
  816. /*
  817. ** Animate rect properties
  818. */
  819. }, {
  820. key: "animateRect",
  821. value: function animateRect(el, from, to, speed, fn) {
  822. el.attr(from).animate(speed).attr(to).afterAll(function () {
  823. return fn();
  824. });
  825. }
  826. }, {
  827. key: "animatePathsGradually",
  828. value: function animatePathsGradually(params) {
  829. var el = params.el,
  830. realIndex = params.realIndex,
  831. j = params.j,
  832. fill = params.fill,
  833. pathFrom = params.pathFrom,
  834. pathTo = params.pathTo,
  835. speed = params.speed,
  836. delay = params.delay;
  837. var me = this;
  838. var w = this.w;
  839. var delayFactor = 0;
  840. if (w.config.chart.animations.animateGradually.enabled) {
  841. delayFactor = w.config.chart.animations.animateGradually.delay;
  842. }
  843. if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged && w.config.chart.type !== 'bar') {
  844. // disabled due to this bug - https://github.com/apexcharts/vue-apexcharts/issues/75
  845. delayFactor = 0;
  846. }
  847. me.morphSVG(el, realIndex, j, w.config.chart.type === 'line' && !w.globals.comboCharts ? 'stroke' : fill, pathFrom, pathTo, speed, delay * delayFactor);
  848. }
  849. }, {
  850. key: "showDelayedElements",
  851. value: function showDelayedElements() {
  852. this.w.globals.delayedElements.forEach(function (d) {
  853. var ele = d.el;
  854. ele.classList.remove('apexcharts-element-hidden');
  855. });
  856. }
  857. }, {
  858. key: "animationCompleted",
  859. value: function animationCompleted(el) {
  860. var w = this.w;
  861. if (w.globals.animationEnded) return;
  862. w.globals.animationEnded = true;
  863. this.showDelayedElements();
  864. if (typeof w.config.chart.events.animationEnd === 'function') {
  865. w.config.chart.events.animationEnd(this.ctx, {
  866. el: el,
  867. w: w
  868. });
  869. }
  870. } // SVG.js animation for morphing one path to another
  871. }, {
  872. key: "morphSVG",
  873. value: function morphSVG(el, realIndex, j, fill, pathFrom, pathTo, speed, delay) {
  874. var _this = this;
  875. var w = this.w;
  876. if (!pathFrom) {
  877. pathFrom = el.attr('pathFrom');
  878. }
  879. if (!pathTo) {
  880. pathTo = el.attr('pathTo');
  881. }
  882. var disableAnimationForCorrupPath = function disableAnimationForCorrupPath(path) {
  883. if (w.config.chart.type === 'radar') {
  884. // radar chart drops the path to bottom and hence a corrup path looks ugly
  885. // therefore, disable animation for such a case
  886. speed = 1;
  887. }
  888. return "M 0 ".concat(w.globals.gridHeight);
  889. };
  890. if (!pathFrom || pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) {
  891. pathFrom = disableAnimationForCorrupPath();
  892. }
  893. if (pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) {
  894. pathTo = disableAnimationForCorrupPath();
  895. }
  896. if (!w.globals.shouldAnimate) {
  897. speed = 1;
  898. }
  899. el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo).afterAll(function () {
  900. // a flag to indicate that the original mount function can return true now as animation finished here
  901. if (Utils.isNumber(j)) {
  902. if (j === w.globals.series[w.globals.maxValsInArrayIndex].length - 2 && w.globals.shouldAnimate) {
  903. _this.animationCompleted(el);
  904. }
  905. } else if (fill !== 'none' && w.globals.shouldAnimate) {
  906. if (!w.globals.comboCharts && realIndex === w.globals.series.length - 1 || w.globals.comboCharts) {
  907. _this.animationCompleted(el);
  908. }
  909. }
  910. _this.showDelayedElements();
  911. });
  912. }
  913. }]);
  914. return Animations;
  915. }();
  916. /**
  917. * ApexCharts Graphics Class for all drawing operations.
  918. *
  919. * @module Graphics
  920. **/
  921. var Graphics = /*#__PURE__*/function () {
  922. function Graphics(ctx) {
  923. _classCallCheck(this, Graphics);
  924. this.ctx = ctx;
  925. this.w = ctx.w;
  926. }
  927. _createClass(Graphics, [{
  928. key: "drawLine",
  929. value: function drawLine(x1, y1, x2, y2) {
  930. var lineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#a8a8a8';
  931. var dashArray = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  932. var strokeWidth = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  933. var w = this.w;
  934. var line = w.globals.dom.Paper.line().attr({
  935. x1: x1,
  936. y1: y1,
  937. x2: x2,
  938. y2: y2,
  939. stroke: lineColor,
  940. 'stroke-dasharray': dashArray,
  941. 'stroke-width': strokeWidth
  942. });
  943. return line;
  944. }
  945. }, {
  946. key: "drawRect",
  947. value: function drawRect() {
  948. var x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  949. var y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  950. var x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  951. var y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  952. var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  953. var color = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '#fefefe';
  954. var opacity = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1;
  955. var strokeWidth = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  956. var strokeColor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  957. var strokeDashArray = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 0;
  958. var w = this.w;
  959. var rect = w.globals.dom.Paper.rect();
  960. rect.attr({
  961. x: x1,
  962. y: y1,
  963. width: x2 > 0 ? x2 : 0,
  964. height: y2 > 0 ? y2 : 0,
  965. rx: radius,
  966. ry: radius,
  967. opacity: opacity,
  968. 'stroke-width': strokeWidth !== null ? strokeWidth : 0,
  969. stroke: strokeColor !== null ? strokeColor : 'none',
  970. 'stroke-dasharray': strokeDashArray
  971. }); // fix apexcharts.js#1410
  972. rect.node.setAttribute('fill', color);
  973. return rect;
  974. }
  975. }, {
  976. key: "drawPolygon",
  977. value: function drawPolygon(polygonString) {
  978. var stroke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#e1e1e1';
  979. var strokeWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  980. var fill = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'none';
  981. var w = this.w;
  982. var polygon = w.globals.dom.Paper.polygon(polygonString).attr({
  983. fill: fill,
  984. stroke: stroke,
  985. 'stroke-width': strokeWidth
  986. });
  987. return polygon;
  988. }
  989. }, {
  990. key: "drawCircle",
  991. value: function drawCircle(radius) {
  992. var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  993. var w = this.w;
  994. var c = w.globals.dom.Paper.circle(radius * 2);
  995. if (attrs !== null) {
  996. c.attr(attrs);
  997. }
  998. return c;
  999. }
  1000. }, {
  1001. key: "drawPath",
  1002. value: function drawPath(_ref) {
  1003. var _ref$d = _ref.d,
  1004. d = _ref$d === void 0 ? '' : _ref$d,
  1005. _ref$stroke = _ref.stroke,
  1006. stroke = _ref$stroke === void 0 ? '#a8a8a8' : _ref$stroke,
  1007. _ref$strokeWidth = _ref.strokeWidth,
  1008. strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
  1009. fill = _ref.fill,
  1010. _ref$fillOpacity = _ref.fillOpacity,
  1011. fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
  1012. _ref$strokeOpacity = _ref.strokeOpacity,
  1013. strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
  1014. classes = _ref.classes,
  1015. _ref$strokeLinecap = _ref.strokeLinecap,
  1016. strokeLinecap = _ref$strokeLinecap === void 0 ? null : _ref$strokeLinecap,
  1017. _ref$strokeDashArray = _ref.strokeDashArray,
  1018. strokeDashArray = _ref$strokeDashArray === void 0 ? 0 : _ref$strokeDashArray;
  1019. var w = this.w;
  1020. if (strokeLinecap === null) {
  1021. strokeLinecap = w.config.stroke.lineCap;
  1022. }
  1023. if (d.indexOf('undefined') > -1 || d.indexOf('NaN') > -1) {
  1024. d = "M 0 ".concat(w.globals.gridHeight);
  1025. }
  1026. var p = w.globals.dom.Paper.path(d).attr({
  1027. fill: fill,
  1028. 'fill-opacity': fillOpacity,
  1029. stroke: stroke,
  1030. 'stroke-opacity': strokeOpacity,
  1031. 'stroke-linecap': strokeLinecap,
  1032. 'stroke-width': strokeWidth,
  1033. 'stroke-dasharray': strokeDashArray,
  1034. class: classes
  1035. });
  1036. return p;
  1037. }
  1038. }, {
  1039. key: "group",
  1040. value: function group() {
  1041. var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1042. var w = this.w;
  1043. var g = w.globals.dom.Paper.group();
  1044. if (attrs !== null) {
  1045. g.attr(attrs);
  1046. }
  1047. return g;
  1048. }
  1049. }, {
  1050. key: "move",
  1051. value: function move(x, y) {
  1052. var move = ['M', x, y].join(' ');
  1053. return move;
  1054. }
  1055. }, {
  1056. key: "line",
  1057. value: function line(x, y) {
  1058. var hORv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1059. var line = null;
  1060. if (hORv === null) {
  1061. line = ['L', x, y].join(' ');
  1062. } else if (hORv === 'H') {
  1063. line = ['H', x].join(' ');
  1064. } else if (hORv === 'V') {
  1065. line = ['V', y].join(' ');
  1066. }
  1067. return line;
  1068. }
  1069. }, {
  1070. key: "curve",
  1071. value: function curve(x1, y1, x2, y2, x, y) {
  1072. var curve = ['C', x1, y1, x2, y2, x, y].join(' ');
  1073. return curve;
  1074. }
  1075. }, {
  1076. key: "quadraticCurve",
  1077. value: function quadraticCurve(x1, y1, x, y) {
  1078. var curve = ['Q', x1, y1, x, y].join(' ');
  1079. return curve;
  1080. }
  1081. }, {
  1082. key: "arc",
  1083. value: function arc(rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y) {
  1084. var relative = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
  1085. var coord = 'A';
  1086. if (relative) coord = 'a';
  1087. var arc = [coord, rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y].join(' ');
  1088. return arc;
  1089. }
  1090. /**
  1091. * @memberof Graphics
  1092. * @param {object}
  1093. * i = series's index
  1094. * 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
  1095. * pathFrom = existing pathFrom to animateTo
  1096. * pathTo = new Path to which d attr will be animated from pathFrom to pathTo
  1097. * stroke = line Color
  1098. * strokeWidth = width of path Line
  1099. * fill = it can be gradient, single color, pattern or image
  1100. * animationDelay = how much to delay when starting animation (in milliseconds)
  1101. * dataChangeSpeed = for dynamic animations, when data changes
  1102. * className = class attribute to add
  1103. * @return {object} svg.js path object
  1104. **/
  1105. }, {
  1106. key: "renderPaths",
  1107. value: function renderPaths(_ref2) {
  1108. var j = _ref2.j,
  1109. realIndex = _ref2.realIndex,
  1110. pathFrom = _ref2.pathFrom,
  1111. pathTo = _ref2.pathTo,
  1112. stroke = _ref2.stroke,
  1113. strokeWidth = _ref2.strokeWidth,
  1114. strokeLinecap = _ref2.strokeLinecap,
  1115. fill = _ref2.fill,
  1116. animationDelay = _ref2.animationDelay,
  1117. initialSpeed = _ref2.initialSpeed,
  1118. dataChangeSpeed = _ref2.dataChangeSpeed,
  1119. className = _ref2.className,
  1120. _ref2$shouldClipToGri = _ref2.shouldClipToGrid,
  1121. shouldClipToGrid = _ref2$shouldClipToGri === void 0 ? true : _ref2$shouldClipToGri,
  1122. _ref2$bindEventsOnPat = _ref2.bindEventsOnPaths,
  1123. bindEventsOnPaths = _ref2$bindEventsOnPat === void 0 ? true : _ref2$bindEventsOnPat,
  1124. _ref2$drawShadow = _ref2.drawShadow,
  1125. drawShadow = _ref2$drawShadow === void 0 ? true : _ref2$drawShadow;
  1126. var w = this.w;
  1127. var filters = new Filters(this.ctx);
  1128. var anim = new Animations(this.ctx);
  1129. var initialAnim = this.w.config.chart.animations.enabled;
  1130. var dynamicAnim = initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  1131. var d;
  1132. var shouldAnimate = !!(initialAnim && !w.globals.resized || dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate);
  1133. if (shouldAnimate) {
  1134. d = pathFrom;
  1135. } else {
  1136. d = pathTo;
  1137. w.globals.animationEnded = true;
  1138. }
  1139. var strokeDashArrayOpt = w.config.stroke.dashArray;
  1140. var strokeDashArray = 0;
  1141. if (Array.isArray(strokeDashArrayOpt)) {
  1142. strokeDashArray = strokeDashArrayOpt[realIndex];
  1143. } else {
  1144. strokeDashArray = w.config.stroke.dashArray;
  1145. }
  1146. var el = this.drawPath({
  1147. d: d,
  1148. stroke: stroke,
  1149. strokeWidth: strokeWidth,
  1150. fill: fill,
  1151. fillOpacity: 1,
  1152. classes: className,
  1153. strokeLinecap: strokeLinecap,
  1154. strokeDashArray: strokeDashArray
  1155. });
  1156. el.attr('index', realIndex);
  1157. if (shouldClipToGrid) {
  1158. el.attr({
  1159. 'clip-path': "url(#gridRectMask".concat(w.globals.cuid, ")")
  1160. });
  1161. } // const defaultFilter = el.filterer
  1162. if (w.config.states.normal.filter.type !== 'none') {
  1163. filters.getDefaultFilter(el, realIndex);
  1164. } else {
  1165. if (w.config.chart.dropShadow.enabled && drawShadow) {
  1166. if (!w.config.chart.dropShadow.enabledOnSeries || w.config.chart.dropShadow.enabledOnSeries && w.config.chart.dropShadow.enabledOnSeries.indexOf(realIndex) !== -1) {
  1167. var shadow = w.config.chart.dropShadow;
  1168. filters.dropShadow(el, shadow, realIndex);
  1169. }
  1170. }
  1171. }
  1172. if (bindEventsOnPaths) {
  1173. el.node.addEventListener('mouseenter', this.pathMouseEnter.bind(this, el));
  1174. el.node.addEventListener('mouseleave', this.pathMouseLeave.bind(this, el));
  1175. el.node.addEventListener('mousedown', this.pathMouseDown.bind(this, el));
  1176. }
  1177. el.attr({
  1178. pathTo: pathTo,
  1179. pathFrom: pathFrom
  1180. });
  1181. var defaultAnimateOpts = {
  1182. el: el,
  1183. j: j,
  1184. realIndex: realIndex,
  1185. pathFrom: pathFrom,
  1186. pathTo: pathTo,
  1187. fill: fill,
  1188. strokeWidth: strokeWidth,
  1189. delay: animationDelay
  1190. };
  1191. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  1192. anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
  1193. speed: initialSpeed
  1194. }));
  1195. } else {
  1196. if (w.globals.resized || !w.globals.dataChanged) {
  1197. anim.showDelayedElements();
  1198. }
  1199. }
  1200. if (w.globals.dataChanged && dynamicAnim && shouldAnimate) {
  1201. anim.animatePathsGradually(_objectSpread2({}, defaultAnimateOpts, {
  1202. speed: dataChangeSpeed
  1203. }));
  1204. }
  1205. return el;
  1206. }
  1207. }, {
  1208. key: "drawPattern",
  1209. value: function drawPattern(style, width, height) {
  1210. var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8';
  1211. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  1212. var w = this.w;
  1213. var p = w.globals.dom.Paper.pattern(width, height, function (add) {
  1214. if (style === 'horizontalLines') {
  1215. add.line(0, 0, height, 0).stroke({
  1216. color: stroke,
  1217. width: strokeWidth + 1
  1218. });
  1219. } else if (style === 'verticalLines') {
  1220. add.line(0, 0, 0, width).stroke({
  1221. color: stroke,
  1222. width: strokeWidth + 1
  1223. });
  1224. } else if (style === 'slantedLines') {
  1225. add.line(0, 0, width, height).stroke({
  1226. color: stroke,
  1227. width: strokeWidth
  1228. });
  1229. } else if (style === 'squares') {
  1230. add.rect(width, height).fill('none').stroke({
  1231. color: stroke,
  1232. width: strokeWidth
  1233. });
  1234. } else if (style === 'circles') {
  1235. add.circle(width).fill('none').stroke({
  1236. color: stroke,
  1237. width: strokeWidth
  1238. });
  1239. }
  1240. });
  1241. return p;
  1242. }
  1243. }, {
  1244. key: "drawGradient",
  1245. value: function drawGradient(style, gfrom, gto, opacityFrom, opacityTo) {
  1246. var size = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  1247. var stops = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  1248. var colorStops = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  1249. var i = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
  1250. var w = this.w;
  1251. var g;
  1252. if (gfrom.length < 9 && gfrom.indexOf('#') === 0) {
  1253. // if the hex contains alpha and is of 9 digit, skip the opacity
  1254. gfrom = Utils.hexToRgba(gfrom, opacityFrom);
  1255. }
  1256. if (gto.length < 9 && gto.indexOf('#') === 0) {
  1257. gto = Utils.hexToRgba(gto, opacityTo);
  1258. }
  1259. var stop1 = 0;
  1260. var stop2 = 1;
  1261. var stop3 = 1;
  1262. var stop4 = null;
  1263. if (stops !== null) {
  1264. stop1 = typeof stops[0] !== 'undefined' ? stops[0] / 100 : 0;
  1265. stop2 = typeof stops[1] !== 'undefined' ? stops[1] / 100 : 1;
  1266. stop3 = typeof stops[2] !== 'undefined' ? stops[2] / 100 : 1;
  1267. stop4 = typeof stops[3] !== 'undefined' ? stops[3] / 100 : null;
  1268. }
  1269. var radial = !!(w.config.chart.type === 'donut' || w.config.chart.type === 'pie' || w.config.chart.type === 'polarArea' || w.config.chart.type === 'bubble');
  1270. if (colorStops === null || colorStops.length === 0) {
  1271. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1272. stop.at(stop1, gfrom, opacityFrom);
  1273. stop.at(stop2, gto, opacityTo);
  1274. stop.at(stop3, gto, opacityTo);
  1275. if (stop4 !== null) {
  1276. stop.at(stop4, gfrom, opacityFrom);
  1277. }
  1278. });
  1279. } else {
  1280. g = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) {
  1281. var gradientStops = Array.isArray(colorStops[i]) ? colorStops[i] : colorStops;
  1282. gradientStops.forEach(function (s) {
  1283. stop.at(s.offset / 100, s.color, s.opacity);
  1284. });
  1285. });
  1286. }
  1287. if (!radial) {
  1288. if (style === 'vertical') {
  1289. g.from(0, 0).to(0, 1);
  1290. } else if (style === 'diagonal') {
  1291. g.from(0, 0).to(1, 1);
  1292. } else if (style === 'horizontal') {
  1293. g.from(0, 1).to(1, 1);
  1294. } else if (style === 'diagonal2') {
  1295. g.from(1, 0).to(0, 1);
  1296. }
  1297. } else {
  1298. var offx = w.globals.gridWidth / 2;
  1299. var offy = w.globals.gridHeight / 2;
  1300. if (w.config.chart.type !== 'bubble') {
  1301. g.attr({
  1302. gradientUnits: 'userSpaceOnUse',
  1303. cx: offx,
  1304. cy: offy,
  1305. r: size
  1306. });
  1307. } else {
  1308. g.attr({
  1309. cx: 0.5,
  1310. cy: 0.5,
  1311. r: 0.8,
  1312. fx: 0.2,
  1313. fy: 0.2
  1314. });
  1315. }
  1316. }
  1317. return g;
  1318. }
  1319. }, {
  1320. key: "drawText",
  1321. value: function drawText(_ref3) {
  1322. var x = _ref3.x,
  1323. y = _ref3.y,
  1324. text = _ref3.text,
  1325. textAnchor = _ref3.textAnchor,
  1326. fontSize = _ref3.fontSize,
  1327. fontFamily = _ref3.fontFamily,
  1328. fontWeight = _ref3.fontWeight,
  1329. foreColor = _ref3.foreColor,
  1330. opacity = _ref3.opacity,
  1331. _ref3$cssClass = _ref3.cssClass,
  1332. cssClass = _ref3$cssClass === void 0 ? '' : _ref3$cssClass,
  1333. _ref3$isPlainText = _ref3.isPlainText,
  1334. isPlainText = _ref3$isPlainText === void 0 ? true : _ref3$isPlainText;
  1335. var w = this.w;
  1336. if (typeof text === 'undefined') text = '';
  1337. if (!textAnchor) {
  1338. textAnchor = 'start';
  1339. }
  1340. if (!foreColor || !foreColor.length) {
  1341. foreColor = w.config.chart.foreColor;
  1342. }
  1343. fontFamily = fontFamily || w.config.chart.fontFamily;
  1344. fontWeight = fontWeight || 'regular';
  1345. var elText;
  1346. if (Array.isArray(text)) {
  1347. elText = w.globals.dom.Paper.text(function (add) {
  1348. for (var i = 0; i < text.length; i++) {
  1349. i === 0 ? add.tspan(text[i]) : add.tspan(text[i]).newLine();
  1350. }
  1351. });
  1352. } else {
  1353. elText = isPlainText ? w.globals.dom.Paper.plain(text) : w.globals.dom.Paper.text(function (add) {
  1354. return add.tspan(text);
  1355. });
  1356. }
  1357. elText.attr({
  1358. x: x,
  1359. y: y,
  1360. 'text-anchor': textAnchor,
  1361. 'dominant-baseline': 'auto',
  1362. 'font-size': fontSize,
  1363. 'font-family': fontFamily,
  1364. 'font-weight': fontWeight,
  1365. fill: foreColor,
  1366. class: 'apexcharts-text ' + cssClass
  1367. });
  1368. elText.node.style.fontFamily = fontFamily;
  1369. elText.node.style.opacity = opacity;
  1370. return elText;
  1371. }
  1372. }, {
  1373. key: "drawMarker",
  1374. value: function drawMarker(x, y, opts) {
  1375. x = x || 0;
  1376. var size = opts.pSize || 0;
  1377. var elPoint = null;
  1378. if (opts.shape === 'square') {
  1379. var radius = opts.pRadius === undefined ? size / 2 : opts.pRadius;
  1380. if (y === null || !size) {
  1381. size = 0;
  1382. radius = 0;
  1383. }
  1384. var nSize = size * 1.2 + radius;
  1385. var p = this.drawRect(nSize, nSize, nSize, nSize, radius);
  1386. p.attr({
  1387. x: x - nSize / 2,
  1388. y: y - nSize / 2,
  1389. cx: x,
  1390. cy: y,
  1391. class: opts.class ? opts.class : '',
  1392. fill: opts.pointFillColor,
  1393. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1394. stroke: opts.pointStrokeColor,
  1395. 'stroke-width': opts.pWidth ? opts.pWidth : 0,
  1396. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1397. });
  1398. elPoint = p;
  1399. } else if (opts.shape === 'circle' || !opts.shape) {
  1400. if (!Utils.isNumber(y)) {
  1401. size = 0;
  1402. y = 0;
  1403. } // let nSize = size - opts.pRadius / 2 < 0 ? 0 : size - opts.pRadius / 2
  1404. elPoint = this.drawCircle(size, {
  1405. cx: x,
  1406. cy: y,
  1407. class: opts.class ? opts.class : '',
  1408. stroke: opts.pointStrokeColor,
  1409. fill: opts.pointFillColor,
  1410. 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1,
  1411. 'stroke-width': opts.pWidth ? opts.pWidth : 0,
  1412. 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1
  1413. });
  1414. }
  1415. return elPoint;
  1416. }
  1417. }, {
  1418. key: "pathMouseEnter",
  1419. value: function pathMouseEnter(path, e) {
  1420. var w = this.w;
  1421. var filters = new Filters(this.ctx);
  1422. var i = parseInt(path.node.getAttribute('index'), 10);
  1423. var j = parseInt(path.node.getAttribute('j'), 10);
  1424. if (typeof w.config.chart.events.dataPointMouseEnter === 'function') {
  1425. w.config.chart.events.dataPointMouseEnter(e, this.ctx, {
  1426. seriesIndex: i,
  1427. dataPointIndex: j,
  1428. w: w
  1429. });
  1430. }
  1431. this.ctx.events.fireEvent('dataPointMouseEnter', [e, this.ctx, {
  1432. seriesIndex: i,
  1433. dataPointIndex: j,
  1434. w: w
  1435. }]);
  1436. if (w.config.states.active.filter.type !== 'none') {
  1437. if (path.node.getAttribute('selected') === 'true') {
  1438. return;
  1439. }
  1440. }
  1441. if (w.config.states.hover.filter.type !== 'none') {
  1442. if (w.config.states.active.filter.type !== 'none' && !w.globals.isTouchDevice) {
  1443. var hoverFilter = w.config.states.hover.filter;
  1444. filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value);
  1445. }
  1446. }
  1447. }
  1448. }, {
  1449. key: "pathMouseLeave",
  1450. value: function pathMouseLeave(path, e) {
  1451. var w = this.w;
  1452. var filters = new Filters(this.ctx);
  1453. var i = parseInt(path.node.getAttribute('index'), 10);
  1454. var j = parseInt(path.node.getAttribute('j'), 10);
  1455. if (typeof w.config.chart.events.dataPointMouseLeave === 'function') {
  1456. w.config.chart.events.dataPointMouseLeave(e, this.ctx, {
  1457. seriesIndex: i,
  1458. dataPointIndex: j,
  1459. w: w
  1460. });
  1461. }
  1462. this.ctx.events.fireEvent('dataPointMouseLeave', [e, this.ctx, {
  1463. seriesIndex: i,
  1464. dataPointIndex: j,
  1465. w: w
  1466. }]);
  1467. if (w.config.states.active.filter.type !== 'none') {
  1468. if (path.node.getAttribute('selected') === 'true') {
  1469. return;
  1470. }
  1471. }
  1472. if (w.config.states.hover.filter.type !== 'none') {
  1473. filters.getDefaultFilter(path, i);
  1474. }
  1475. }
  1476. }, {
  1477. key: "pathMouseDown",
  1478. value: function pathMouseDown(path, e) {
  1479. var w = this.w;
  1480. var filters = new Filters(this.ctx);
  1481. var i = parseInt(path.node.getAttribute('index'), 10);
  1482. var j = parseInt(path.node.getAttribute('j'), 10);
  1483. var selected = 'false';
  1484. if (path.node.getAttribute('selected') === 'true') {
  1485. path.node.setAttribute('selected', 'false');
  1486. if (w.globals.selectedDataPoints[i].indexOf(j) > -1) {
  1487. var index = w.globals.selectedDataPoints[i].indexOf(j);
  1488. w.globals.selectedDataPoints[i].splice(index, 1);
  1489. }
  1490. } else {
  1491. if (!w.config.states.active.allowMultipleDataPointsSelection && w.globals.selectedDataPoints.length > 0) {
  1492. w.globals.selectedDataPoints = [];
  1493. var elPaths = w.globals.dom.Paper.select('.apexcharts-series path').members;
  1494. var elCircles = w.globals.dom.Paper.select('.apexcharts-series circle, .apexcharts-series rect').members;
  1495. var deSelect = function deSelect(els) {
  1496. Array.prototype.forEach.call(els, function (el) {
  1497. el.node.setAttribute('selected', 'false');
  1498. filters.getDefaultFilter(el, i);
  1499. });
  1500. };
  1501. deSelect(elPaths);
  1502. deSelect(elCircles);
  1503. }
  1504. path.node.setAttribute('selected', 'true');
  1505. selected = 'true';
  1506. if (typeof w.globals.selectedDataPoints[i] === 'undefined') {
  1507. w.globals.selectedDataPoints[i] = [];
  1508. }
  1509. w.globals.selectedDataPoints[i].push(j);
  1510. }
  1511. if (selected === 'true') {
  1512. var activeFilter = w.config.states.active.filter;
  1513. if (activeFilter !== 'none') {
  1514. filters.applyFilter(path, i, activeFilter.type, activeFilter.value);
  1515. }
  1516. } else {
  1517. if (w.config.states.active.filter.type !== 'none') {
  1518. filters.getDefaultFilter(path, i);
  1519. }
  1520. }
  1521. if (typeof w.config.chart.events.dataPointSelection === 'function') {
  1522. w.config.chart.events.dataPointSelection(e, this.ctx, {
  1523. selectedDataPoints: w.globals.selectedDataPoints,
  1524. seriesIndex: i,
  1525. dataPointIndex: j,
  1526. w: w
  1527. });
  1528. }
  1529. if (e) {
  1530. this.ctx.events.fireEvent('dataPointSelection', [e, this.ctx, {
  1531. selectedDataPoints: w.globals.selectedDataPoints,
  1532. seriesIndex: i,
  1533. dataPointIndex: j,
  1534. w: w
  1535. }]);
  1536. }
  1537. }
  1538. }, {
  1539. key: "rotateAroundCenter",
  1540. value: function rotateAroundCenter(el) {
  1541. var coord = el.getBBox();
  1542. var x = coord.x + coord.width / 2;
  1543. var y = coord.y + coord.height / 2;
  1544. return {
  1545. x: x,
  1546. y: y
  1547. };
  1548. }
  1549. }, {
  1550. key: "getTextRects",
  1551. value: function getTextRects(text, fontSize, fontFamily, transform) {
  1552. var useBBox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  1553. var w = this.w;
  1554. var virtualText = this.drawText({
  1555. x: -200,
  1556. y: -200,
  1557. text: text,
  1558. textAnchor: 'start',
  1559. fontSize: fontSize,
  1560. fontFamily: fontFamily,
  1561. foreColor: '#fff',
  1562. opacity: 0
  1563. });
  1564. if (transform) {
  1565. virtualText.attr('transform', transform);
  1566. }
  1567. w.globals.dom.Paper.add(virtualText);
  1568. var rect = virtualText.bbox();
  1569. if (!useBBox) {
  1570. rect = virtualText.node.getBoundingClientRect();
  1571. }
  1572. virtualText.remove();
  1573. return {
  1574. width: rect.width,
  1575. height: rect.height
  1576. };
  1577. }
  1578. /**
  1579. * append ... to long text
  1580. * http://stackoverflow.com/questions/9241315/trimming-text-to-a-given-pixel-width-in-svg
  1581. * @memberof Graphics
  1582. **/
  1583. }, {
  1584. key: "placeTextWithEllipsis",
  1585. value: function placeTextWithEllipsis(textObj, textString, width) {
  1586. if (typeof textObj.getComputedTextLength !== 'function') return;
  1587. textObj.textContent = textString;
  1588. if (textString.length > 0) {
  1589. // ellipsis is needed
  1590. if (textObj.getComputedTextLength() >= width / 0.8) {
  1591. for (var x = textString.length - 3; x > 0; x -= 3) {
  1592. if (textObj.getSubStringLength(0, x) <= width / 0.8) {
  1593. textObj.textContent = textString.substring(0, x) + '...';
  1594. return;
  1595. }
  1596. }
  1597. textObj.textContent = '.'; // can't place at all
  1598. }
  1599. }
  1600. }
  1601. }], [{
  1602. key: "setAttrs",
  1603. value: function setAttrs(el, attrs) {
  1604. for (var key in attrs) {
  1605. if (attrs.hasOwnProperty(key)) {
  1606. el.setAttribute(key, attrs[key]);
  1607. }
  1608. }
  1609. }
  1610. }]);
  1611. return Graphics;
  1612. }();
  1613. var Helpers = /*#__PURE__*/function () {
  1614. function Helpers(annoCtx) {
  1615. _classCallCheck(this, Helpers);
  1616. this.w = annoCtx.w;
  1617. this.annoCtx = annoCtx;
  1618. }
  1619. _createClass(Helpers, [{
  1620. key: "setOrientations",
  1621. value: function setOrientations(anno) {
  1622. var annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1623. var w = this.w;
  1624. if (anno.label.orientation === 'vertical') {
  1625. var i = annoIndex !== null ? annoIndex : 0;
  1626. var xAnno = w.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(i, "']"));
  1627. if (xAnno !== null) {
  1628. var xAnnoCoord = xAnno.getBoundingClientRect();
  1629. xAnno.setAttribute('x', parseFloat(xAnno.getAttribute('x')) - xAnnoCoord.height + 4);
  1630. if (anno.label.position === 'top') {
  1631. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) + xAnnoCoord.width);
  1632. } else {
  1633. xAnno.setAttribute('y', parseFloat(xAnno.getAttribute('y')) - xAnnoCoord.width);
  1634. }
  1635. var annoRotatingCenter = this.annoCtx.graphics.rotateAroundCenter(xAnno);
  1636. var x = annoRotatingCenter.x;
  1637. var y = annoRotatingCenter.y;
  1638. xAnno.setAttribute('transform', "rotate(-90 ".concat(x, " ").concat(y, ")"));
  1639. }
  1640. }
  1641. }
  1642. }, {
  1643. key: "addBackgroundToAnno",
  1644. value: function addBackgroundToAnno(annoEl, anno) {
  1645. var w = this.w;
  1646. if (!anno.label.text || anno.label.text && !anno.label.text.trim()) return null;
  1647. var elGridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid').getBoundingClientRect();
  1648. var coords = annoEl.getBoundingClientRect();
  1649. var pleft = anno.label.style.padding.left;
  1650. var pright = anno.label.style.padding.right;
  1651. var ptop = anno.label.style.padding.top;
  1652. var pbottom = anno.label.style.padding.bottom;
  1653. if (anno.label.orientation === 'vertical') {
  1654. ptop = anno.label.style.padding.left;
  1655. pbottom = anno.label.style.padding.right;
  1656. pleft = anno.label.style.padding.top;
  1657. pright = anno.label.style.padding.bottom;
  1658. }
  1659. var x1 = coords.left - elGridRect.left - pleft;
  1660. var y1 = coords.top - elGridRect.top - ptop;
  1661. 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);
  1662. if (anno.id) {
  1663. elRect.node.classList.add(anno.id);
  1664. }
  1665. return elRect;
  1666. }
  1667. }, {
  1668. key: "annotationsBackground",
  1669. value: function annotationsBackground() {
  1670. var _this = this;
  1671. var w = this.w;
  1672. var add = function add(anno, i, type) {
  1673. var annoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(i, "']"));
  1674. if (annoLabel) {
  1675. var parent = annoLabel.parentNode;
  1676. var elRect = _this.addBackgroundToAnno(annoLabel, anno);
  1677. if (elRect) {
  1678. parent.insertBefore(elRect.node, annoLabel);
  1679. }
  1680. }
  1681. };
  1682. w.config.annotations.xaxis.map(function (anno, i) {
  1683. add(anno, i, 'xaxis');
  1684. });
  1685. w.config.annotations.yaxis.map(function (anno, i) {
  1686. add(anno, i, 'yaxis');
  1687. });
  1688. w.config.annotations.points.map(function (anno, i) {
  1689. add(anno, i, 'point');
  1690. });
  1691. }
  1692. }, {
  1693. key: "makeAnnotationDraggable",
  1694. value: function makeAnnotationDraggable(el, annoType, index) {
  1695. var w = this.w;
  1696. var anno = w.config.annotations[annoType][index]; // in the draggable annotations, we will mutate the original config
  1697. // object and store the values directly there
  1698. el.draggable().on('dragend', function (de) {
  1699. var x = de.target.getAttribute('x');
  1700. var y = de.target.getAttribute('y');
  1701. var cx = de.target.getAttribute('cx');
  1702. var cy = de.target.getAttribute('cy');
  1703. anno.x = x;
  1704. anno.y = y;
  1705. if (cx && cy) {
  1706. anno.x = cx;
  1707. anno.y = cy;
  1708. }
  1709. });
  1710. el.node.addEventListener('mousedown', function (e) {
  1711. e.stopPropagation();
  1712. el.selectize({
  1713. pointSize: 8,
  1714. rotationPoint: false,
  1715. pointType: 'rect'
  1716. });
  1717. el.resize().on('resizedone', function (re) {
  1718. var width = re.target.getAttribute('width');
  1719. var height = re.target.getAttribute('height');
  1720. var r = re.target.getAttribute('r');
  1721. anno.width = width;
  1722. anno.height = height;
  1723. if (r) {
  1724. anno.radius = r;
  1725. }
  1726. });
  1727. });
  1728. }
  1729. }, {
  1730. key: "getStringX",
  1731. value: function getStringX(x) {
  1732. var w = this.w;
  1733. var rX = x;
  1734. if (w.config.xaxis.convertedCatToNumeric && w.globals.categoryLabels.length) {
  1735. x = w.globals.categoryLabels.indexOf(x) + 1;
  1736. }
  1737. var catIndex = w.globals.labels.indexOf(x);
  1738. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  1739. if (xLabel) {
  1740. rX = parseFloat(xLabel.getAttribute('x'));
  1741. }
  1742. return rX;
  1743. }
  1744. }]);
  1745. return Helpers;
  1746. }();
  1747. var XAnnotations = /*#__PURE__*/function () {
  1748. function XAnnotations(annoCtx) {
  1749. _classCallCheck(this, XAnnotations);
  1750. this.w = annoCtx.w;
  1751. this.annoCtx = annoCtx;
  1752. this.invertAxis = this.annoCtx.invertAxis;
  1753. }
  1754. _createClass(XAnnotations, [{
  1755. key: "addXaxisAnnotation",
  1756. value: function addXaxisAnnotation(anno, parent, index) {
  1757. var w = this.w;
  1758. var min = this.invertAxis ? w.globals.minY : w.globals.minX;
  1759. var max = this.invertAxis ? w.globals.maxY : w.globals.maxX;
  1760. var range = this.invertAxis ? w.globals.yRange[0] : w.globals.xRange;
  1761. var x1 = (anno.x - min) / (range / w.globals.gridWidth);
  1762. if (this.annoCtx.inversedReversedAxis) {
  1763. x1 = (max - anno.x) / (range / w.globals.gridWidth);
  1764. }
  1765. var text = anno.label.text;
  1766. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
  1767. x1 = this.annoCtx.helpers.getStringX(anno.x);
  1768. }
  1769. var strokeDashArray = anno.strokeDashArray;
  1770. if (!Utils.isNumber(x1)) return;
  1771. if (anno.x2 === null || typeof anno.x2 === 'undefined') {
  1772. var line = this.annoCtx.graphics.drawLine(x1 + anno.offsetX, // x1
  1773. 0 + anno.offsetY, // y1
  1774. x1 + anno.offsetX, // x2
  1775. w.globals.gridHeight + anno.offsetY, // y2
  1776. anno.borderColor, // lineColor
  1777. strokeDashArray, //dashArray
  1778. anno.borderWidth);
  1779. parent.appendChild(line.node);
  1780. if (anno.id) {
  1781. line.node.classList.add(anno.id);
  1782. }
  1783. } else {
  1784. var x2 = (anno.x2 - min) / (range / w.globals.gridWidth);
  1785. if (this.annoCtx.inversedReversedAxis) {
  1786. x2 = (max - anno.x2) / (range / w.globals.gridWidth);
  1787. }
  1788. if ((w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) && !this.invertAxis && !w.globals.dataFormatXNumeric) {
  1789. x2 = this.annoCtx.helpers.getStringX(anno.x2);
  1790. }
  1791. if (x2 < x1) {
  1792. var temp = x1;
  1793. x1 = x2;
  1794. x2 = temp;
  1795. }
  1796. var rect = this.annoCtx.graphics.drawRect(x1 + anno.offsetX, // x1
  1797. 0 + anno.offsetY, // y1
  1798. x2 - x1, // x2
  1799. w.globals.gridHeight + anno.offsetY, // y2
  1800. 0, // radius
  1801. anno.fillColor, // color
  1802. anno.opacity, // opacity,
  1803. 1, // strokeWidth
  1804. anno.borderColor, // strokeColor
  1805. strokeDashArray // stokeDashArray
  1806. );
  1807. rect.node.classList.add('apexcharts-annotation-rect');
  1808. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  1809. parent.appendChild(rect.node);
  1810. if (anno.id) {
  1811. rect.node.classList.add(anno.id);
  1812. }
  1813. }
  1814. var textY = anno.label.position === 'top' ? 4 : w.globals.gridHeight;
  1815. var textRects = this.annoCtx.graphics.getTextRects(text, parseFloat(anno.label.style.fontSize));
  1816. var elText = this.annoCtx.graphics.drawText({
  1817. x: x1 + anno.label.offsetX,
  1818. y: textY + anno.label.offsetY - (anno.label.orientation === 'vertical' ? anno.label.position === 'top' ? textRects.width / 2 - 12 : -textRects.width / 2 : 0),
  1819. text: text,
  1820. textAnchor: anno.label.textAnchor,
  1821. fontSize: anno.label.style.fontSize,
  1822. fontFamily: anno.label.style.fontFamily,
  1823. fontWeight: anno.label.style.fontWeight,
  1824. foreColor: anno.label.style.color,
  1825. cssClass: "apexcharts-xaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  1826. });
  1827. elText.attr({
  1828. rel: index
  1829. });
  1830. parent.appendChild(elText.node); // after placing the annotations on svg, set any vertically placed annotations
  1831. this.annoCtx.helpers.setOrientations(anno, index);
  1832. }
  1833. }, {
  1834. key: "drawXAxisAnnotations",
  1835. value: function drawXAxisAnnotations() {
  1836. var _this = this;
  1837. var w = this.w;
  1838. var elg = this.annoCtx.graphics.group({
  1839. class: 'apexcharts-xaxis-annotations'
  1840. });
  1841. w.config.annotations.xaxis.map(function (anno, index) {
  1842. _this.addXaxisAnnotation(anno, elg.node, index);
  1843. });
  1844. return elg;
  1845. }
  1846. }]);
  1847. return XAnnotations;
  1848. }();
  1849. /*
  1850. ** Util functions which are dependent on ApexCharts instance
  1851. */
  1852. var CoreUtils = /*#__PURE__*/function () {
  1853. function CoreUtils(ctx) {
  1854. _classCallCheck(this, CoreUtils);
  1855. this.ctx = ctx;
  1856. this.w = ctx.w;
  1857. }
  1858. _createClass(CoreUtils, [{
  1859. key: "getStackedSeriesTotals",
  1860. /**
  1861. * @memberof CoreUtils
  1862. * returns the sum of all individual values in a multiple stacked series
  1863. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  1864. * @return [34,36,48,13]
  1865. **/
  1866. value: function getStackedSeriesTotals() {
  1867. var w = this.w;
  1868. var total = [];
  1869. if (w.globals.series.length === 0) return total;
  1870. for (var i = 0; i < w.globals.series[w.globals.maxValsInArrayIndex].length; i++) {
  1871. var t = 0;
  1872. for (var j = 0; j < w.globals.series.length; j++) {
  1873. if (typeof w.globals.series[j][i] !== 'undefined') {
  1874. t += w.globals.series[j][i];
  1875. }
  1876. }
  1877. total.push(t);
  1878. }
  1879. w.globals.stackedSeriesTotals = total;
  1880. return total;
  1881. } // get total of the all values inside all series
  1882. }, {
  1883. key: "getSeriesTotalByIndex",
  1884. value: function getSeriesTotalByIndex() {
  1885. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1886. if (index === null) {
  1887. // non-plot chart types - pie / donut / circle
  1888. return this.w.config.series.reduce(function (acc, cur) {
  1889. return acc + cur;
  1890. }, 0);
  1891. } else {
  1892. // axis charts - supporting multiple series
  1893. return this.w.globals.series[index].reduce(function (acc, cur) {
  1894. return acc + cur;
  1895. }, 0);
  1896. }
  1897. }
  1898. }, {
  1899. key: "isSeriesNull",
  1900. value: function isSeriesNull() {
  1901. var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1902. var r = [];
  1903. if (index === null) {
  1904. // non-plot chart types - pie / donut / circle
  1905. r = this.w.config.series.filter(function (d) {
  1906. return d !== null;
  1907. });
  1908. } else {
  1909. // axis charts - supporting multiple series
  1910. r = this.w.config.series[index].data.filter(function (d) {
  1911. return d !== null;
  1912. });
  1913. }
  1914. return r.length === 0;
  1915. }
  1916. }, {
  1917. key: "seriesHaveSameValues",
  1918. value: function seriesHaveSameValues(index) {
  1919. return this.w.globals.series[index].every(function (val, i, arr) {
  1920. return val === arr[0];
  1921. });
  1922. }
  1923. }, {
  1924. key: "getCategoryLabels",
  1925. value: function getCategoryLabels(labels) {
  1926. var w = this.w;
  1927. var catLabels = labels.slice();
  1928. if (w.config.xaxis.convertedCatToNumeric) {
  1929. catLabels = labels.map(function (i) {
  1930. return w.config.xaxis.labels.formatter(i - w.globals.minX + 1);
  1931. });
  1932. }
  1933. return catLabels;
  1934. } // maxValsInArrayIndex is the index of series[] which has the largest number of items
  1935. }, {
  1936. key: "getLargestSeries",
  1937. value: function getLargestSeries() {
  1938. var w = this.w;
  1939. w.globals.maxValsInArrayIndex = w.globals.series.map(function (a) {
  1940. return a.length;
  1941. }).indexOf(Math.max.apply(Math, w.globals.series.map(function (a) {
  1942. return a.length;
  1943. })));
  1944. }
  1945. }, {
  1946. key: "getLargestMarkerSize",
  1947. value: function getLargestMarkerSize() {
  1948. var w = this.w;
  1949. var size = 0;
  1950. w.globals.markers.size.forEach(function (m) {
  1951. size = Math.max(size, m);
  1952. });
  1953. w.globals.markers.largestSize = size;
  1954. return size;
  1955. }
  1956. /**
  1957. * @memberof Core
  1958. * returns the sum of all values in a series
  1959. * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]]
  1960. * @return [120, 11]
  1961. **/
  1962. }, {
  1963. key: "getSeriesTotals",
  1964. value: function getSeriesTotals() {
  1965. var w = this.w;
  1966. w.globals.seriesTotals = w.globals.series.map(function (ser, index) {
  1967. var total = 0;
  1968. if (Array.isArray(ser)) {
  1969. for (var j = 0; j < ser.length; j++) {
  1970. total += ser[j];
  1971. }
  1972. } else {
  1973. // for pie/donuts/gauges
  1974. total += ser;
  1975. }
  1976. return total;
  1977. });
  1978. }
  1979. }, {
  1980. key: "getSeriesTotalsXRange",
  1981. value: function getSeriesTotalsXRange(minX, maxX) {
  1982. var w = this.w;
  1983. var seriesTotalsXRange = w.globals.series.map(function (ser, index) {
  1984. var total = 0;
  1985. for (var j = 0; j < ser.length; j++) {
  1986. if (w.globals.seriesX[index][j] > minX && w.globals.seriesX[index][j] < maxX) {
  1987. total += ser[j];
  1988. }
  1989. }
  1990. return total;
  1991. });
  1992. return seriesTotalsXRange;
  1993. }
  1994. /**
  1995. * @memberof CoreUtils
  1996. * returns the percentage value of all individual values which can be used in a 100% stacked series
  1997. * Eg. w.globals.series = [[32, 33, 43, 12], [2, 3, 5, 1]]
  1998. * @return [[94.11, 91.66, 89.58, 92.30], [5.88, 8.33, 10.41, 7.7]]
  1999. **/
  2000. }, {
  2001. key: "getPercentSeries",
  2002. value: function getPercentSeries() {
  2003. var w = this.w;
  2004. w.globals.seriesPercent = w.globals.series.map(function (ser, index) {
  2005. var seriesPercent = [];
  2006. if (Array.isArray(ser)) {
  2007. for (var j = 0; j < ser.length; j++) {
  2008. var total = w.globals.stackedSeriesTotals[j];
  2009. var percent = 0;
  2010. if (total) {
  2011. percent = 100 * ser[j] / total;
  2012. }
  2013. seriesPercent.push(percent);
  2014. }
  2015. } else {
  2016. var _total = w.globals.seriesTotals.reduce(function (acc, val) {
  2017. return acc + val;
  2018. }, 0);
  2019. var _percent = 100 * ser / _total;
  2020. seriesPercent.push(_percent);
  2021. }
  2022. return seriesPercent;
  2023. });
  2024. }
  2025. }, {
  2026. key: "getCalculatedRatios",
  2027. value: function getCalculatedRatios() {
  2028. var gl = this.w.globals;
  2029. var yRatio = [];
  2030. var invertedYRatio = 0;
  2031. var xRatio = 0;
  2032. var initialXRatio = 0;
  2033. var invertedXRatio = 0;
  2034. var zRatio = 0;
  2035. var baseLineY = [];
  2036. var baseLineInvertedY = 0.1;
  2037. var baseLineX = 0;
  2038. gl.yRange = [];
  2039. if (gl.isMultipleYAxis) {
  2040. for (var i = 0; i < gl.minYArr.length; i++) {
  2041. gl.yRange.push(Math.abs(gl.minYArr[i] - gl.maxYArr[i]));
  2042. baseLineY.push(0);
  2043. }
  2044. } else {
  2045. gl.yRange.push(Math.abs(gl.minY - gl.maxY));
  2046. }
  2047. gl.xRange = Math.abs(gl.maxX - gl.minX);
  2048. gl.zRange = Math.abs(gl.maxZ - gl.minZ); // multiple y axis
  2049. for (var _i = 0; _i < gl.yRange.length; _i++) {
  2050. yRatio.push(gl.yRange[_i] / gl.gridHeight);
  2051. }
  2052. xRatio = gl.xRange / gl.gridWidth;
  2053. initialXRatio = Math.abs(gl.initialMaxX - gl.initialMinX) / gl.gridWidth;
  2054. invertedYRatio = gl.yRange / gl.gridWidth;
  2055. invertedXRatio = gl.xRange / gl.gridHeight;
  2056. zRatio = gl.zRange / gl.gridHeight * 16;
  2057. if (!zRatio) {
  2058. zRatio = 1;
  2059. }
  2060. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  2061. // Negative numbers present in series
  2062. gl.hasNegs = true;
  2063. }
  2064. if (gl.isMultipleYAxis) {
  2065. baseLineY = []; // baseline variables is the 0 of the yaxis which will be needed when there are negatives
  2066. for (var _i2 = 0; _i2 < yRatio.length; _i2++) {
  2067. baseLineY.push(-gl.minYArr[_i2] / yRatio[_i2]);
  2068. }
  2069. } else {
  2070. baseLineY.push(-gl.minY / yRatio[0]);
  2071. if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) {
  2072. baseLineInvertedY = -gl.minY / invertedYRatio; // this is for bar chart
  2073. baseLineX = gl.minX / xRatio;
  2074. }
  2075. }
  2076. return {
  2077. yRatio: yRatio,
  2078. invertedYRatio: invertedYRatio,
  2079. zRatio: zRatio,
  2080. xRatio: xRatio,
  2081. initialXRatio: initialXRatio,
  2082. invertedXRatio: invertedXRatio,
  2083. baseLineInvertedY: baseLineInvertedY,
  2084. baseLineY: baseLineY,
  2085. baseLineX: baseLineX
  2086. };
  2087. }
  2088. }, {
  2089. key: "getLogSeries",
  2090. value: function getLogSeries(series) {
  2091. var _this = this;
  2092. var w = this.w;
  2093. w.globals.seriesLog = series.map(function (s, i) {
  2094. if (w.config.yaxis[i] && w.config.yaxis[i].logarithmic) {
  2095. return s.map(function (d) {
  2096. if (d === null) return null;
  2097. return _this.getLogVal(d, i);
  2098. });
  2099. } else {
  2100. return s;
  2101. }
  2102. });
  2103. return w.globals.invalidLogScale ? series : w.globals.seriesLog;
  2104. }
  2105. }, {
  2106. key: "getLogVal",
  2107. value: function getLogVal(d, yIndex) {
  2108. var w = this.w;
  2109. return (Math.log(d) - Math.log(w.globals.minYArr[yIndex])) / (Math.log(w.globals.maxYArr[yIndex]) - Math.log(w.globals.minYArr[yIndex]));
  2110. }
  2111. }, {
  2112. key: "getLogYRatios",
  2113. value: function getLogYRatios(yRatio) {
  2114. var _this2 = this;
  2115. var w = this.w;
  2116. var gl = this.w.globals;
  2117. gl.yLogRatio = yRatio.slice();
  2118. gl.logYRange = gl.yRange.map(function (yRange, i) {
  2119. if (w.config.yaxis[i] && _this2.w.config.yaxis[i].logarithmic) {
  2120. var maxY = -Number.MAX_VALUE;
  2121. var minY = Number.MIN_VALUE;
  2122. var range = 1;
  2123. gl.seriesLog.forEach(function (s, si) {
  2124. s.forEach(function (v) {
  2125. if (w.config.yaxis[si] && w.config.yaxis[si].logarithmic) {
  2126. maxY = Math.max(v, maxY);
  2127. minY = Math.min(v, minY);
  2128. }
  2129. });
  2130. });
  2131. range = Math.pow(gl.yRange[i], Math.abs(minY - maxY) / gl.yRange[i]);
  2132. gl.yLogRatio[i] = range / gl.gridHeight;
  2133. return range;
  2134. }
  2135. });
  2136. return gl.invalidLogScale ? yRatio.slice() : gl.yLogRatio;
  2137. } // Some config objects can be array - and we need to extend them correctly
  2138. }], [{
  2139. key: "checkComboSeries",
  2140. value: function checkComboSeries(series) {
  2141. var comboCharts = false;
  2142. var comboBarCount = 0; // if user specified a type in series too, turn on comboCharts flag
  2143. if (series.length && typeof series[0].type !== 'undefined') {
  2144. comboCharts = true;
  2145. series.forEach(function (s) {
  2146. if (s.type === 'bar' || s.type === 'column' || s.type === 'candlestick') {
  2147. comboBarCount++;
  2148. }
  2149. });
  2150. }
  2151. return {
  2152. comboBarCount: comboBarCount,
  2153. comboCharts: comboCharts
  2154. };
  2155. }
  2156. }, {
  2157. key: "extendArrayProps",
  2158. value: function extendArrayProps(configInstance, options, w) {
  2159. if (options.yaxis) {
  2160. options = configInstance.extendYAxis(options, w);
  2161. }
  2162. if (options.annotations) {
  2163. if (options.annotations.yaxis) {
  2164. options = configInstance.extendYAxisAnnotations(options);
  2165. }
  2166. if (options.annotations.xaxis) {
  2167. options = configInstance.extendXAxisAnnotations(options);
  2168. }
  2169. if (options.annotations.points) {
  2170. options = configInstance.extendPointAnnotations(options);
  2171. }
  2172. }
  2173. return options;
  2174. }
  2175. }]);
  2176. return CoreUtils;
  2177. }();
  2178. var YAnnotations = /*#__PURE__*/function () {
  2179. function YAnnotations(annoCtx) {
  2180. _classCallCheck(this, YAnnotations);
  2181. this.w = annoCtx.w;
  2182. this.annoCtx = annoCtx;
  2183. }
  2184. _createClass(YAnnotations, [{
  2185. key: "addYaxisAnnotation",
  2186. value: function addYaxisAnnotation(anno, parent, index) {
  2187. var w = this.w;
  2188. var strokeDashArray = anno.strokeDashArray;
  2189. var y1 = this._getY1Y2('y1', anno);
  2190. var y2;
  2191. var text = anno.label.text;
  2192. if (anno.y2 === null || typeof anno.y2 === 'undefined') {
  2193. var line = this.annoCtx.graphics.drawLine(0 + anno.offsetX, // x1
  2194. y1 + anno.offsetY, // y1
  2195. w.globals.gridWidth + anno.offsetX, // x2
  2196. y1 + anno.offsetY, // y2
  2197. anno.borderColor, // lineColor
  2198. strokeDashArray, // dashArray
  2199. anno.borderWidth);
  2200. parent.appendChild(line.node);
  2201. if (anno.id) {
  2202. line.node.classList.add(anno.id);
  2203. }
  2204. } else {
  2205. y2 = this._getY1Y2('y2', anno);
  2206. if (y2 > y1) {
  2207. var temp = y1;
  2208. y1 = y2;
  2209. y2 = temp;
  2210. }
  2211. var rect = this.annoCtx.graphics.drawRect(0 + anno.offsetX, // x1
  2212. y2 + anno.offsetY, // y1
  2213. w.globals.gridWidth + anno.offsetX, // x2
  2214. y1 - y2, // y2
  2215. 0, // radius
  2216. anno.fillColor, // color
  2217. anno.opacity, // opacity,
  2218. 1, // strokeWidth
  2219. anno.borderColor, // strokeColor
  2220. strokeDashArray // stokeDashArray
  2221. );
  2222. rect.node.classList.add('apexcharts-annotation-rect');
  2223. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  2224. parent.appendChild(rect.node);
  2225. if (anno.id) {
  2226. rect.node.classList.add(anno.id);
  2227. }
  2228. }
  2229. var textX = anno.label.position === 'right' ? w.globals.gridWidth : 0;
  2230. var elText = this.annoCtx.graphics.drawText({
  2231. x: textX + anno.label.offsetX,
  2232. y: (y2 || y1) + anno.label.offsetY - 3,
  2233. text: text,
  2234. textAnchor: anno.label.textAnchor,
  2235. fontSize: anno.label.style.fontSize,
  2236. fontFamily: anno.label.style.fontFamily,
  2237. fontWeight: anno.label.style.fontWeight,
  2238. foreColor: anno.label.style.color,
  2239. cssClass: "apexcharts-yaxis-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2240. });
  2241. elText.attr({
  2242. rel: index
  2243. });
  2244. parent.appendChild(elText.node);
  2245. }
  2246. }, {
  2247. key: "_getY1Y2",
  2248. value: function _getY1Y2(type, anno) {
  2249. var y = type === 'y1' ? anno.y : anno.y2;
  2250. var yP;
  2251. var w = this.w;
  2252. if (this.annoCtx.invertAxis) {
  2253. var catIndex = w.globals.labels.indexOf(y);
  2254. if (w.config.xaxis.convertedCatToNumeric) {
  2255. catIndex = w.globals.categoryLabels.indexOf(y);
  2256. }
  2257. var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-texts-g text:nth-child(' + (catIndex + 1) + ')');
  2258. if (xLabel) {
  2259. yP = parseFloat(xLabel.getAttribute('y'));
  2260. }
  2261. } else {
  2262. var yPos;
  2263. if (w.config.yaxis[anno.yAxisIndex].logarithmic) {
  2264. var coreUtils = new CoreUtils(this.annoCtx.ctx);
  2265. y = coreUtils.getLogVal(y, anno.yAxisIndex);
  2266. yPos = y / w.globals.yLogRatio[anno.yAxisIndex];
  2267. } else {
  2268. yPos = (y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  2269. }
  2270. yP = w.globals.gridHeight - yPos;
  2271. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  2272. yP = yPos;
  2273. }
  2274. }
  2275. return yP;
  2276. }
  2277. }, {
  2278. key: "drawYAxisAnnotations",
  2279. value: function drawYAxisAnnotations() {
  2280. var _this = this;
  2281. var w = this.w;
  2282. var elg = this.annoCtx.graphics.group({
  2283. class: 'apexcharts-yaxis-annotations'
  2284. });
  2285. w.config.annotations.yaxis.map(function (anno, index) {
  2286. _this.addYaxisAnnotation(anno, elg.node, index);
  2287. });
  2288. return elg;
  2289. }
  2290. }]);
  2291. return YAnnotations;
  2292. }();
  2293. var PointAnnotations = /*#__PURE__*/function () {
  2294. function PointAnnotations(annoCtx) {
  2295. _classCallCheck(this, PointAnnotations);
  2296. this.w = annoCtx.w;
  2297. this.annoCtx = annoCtx;
  2298. }
  2299. _createClass(PointAnnotations, [{
  2300. key: "addPointAnnotation",
  2301. value: function addPointAnnotation(anno, parent, index) {
  2302. var w = this.w;
  2303. var x = 0;
  2304. var y = 0;
  2305. var pointY = 0;
  2306. if (this.annoCtx.invertAxis) {
  2307. console.warn('Point annotation is not supported in horizontal bar charts.');
  2308. }
  2309. var annoY = parseFloat(anno.y);
  2310. if (typeof anno.x === 'string') {
  2311. var catIndex = w.globals.labels.indexOf(anno.x);
  2312. if (w.config.xaxis.convertedCatToNumeric) {
  2313. catIndex = w.globals.categoryLabels.indexOf(anno.x);
  2314. }
  2315. x = this.annoCtx.helpers.getStringX(anno.x);
  2316. if (anno.y === null) {
  2317. annoY = w.globals.series[anno.seriesIndex][catIndex];
  2318. }
  2319. } else {
  2320. x = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth);
  2321. }
  2322. var yPos;
  2323. if (w.config.yaxis[anno.yAxisIndex].logarithmic) {
  2324. var coreUtils = new CoreUtils(this.annoCtx.ctx);
  2325. annoY = coreUtils.getLogVal(annoY, anno.yAxisIndex);
  2326. yPos = annoY / w.globals.yLogRatio[anno.yAxisIndex];
  2327. } else {
  2328. yPos = (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight);
  2329. }
  2330. y = w.globals.gridHeight - yPos - parseFloat(anno.label.style.fontSize) - anno.marker.size;
  2331. pointY = w.globals.gridHeight - yPos;
  2332. if (w.config.yaxis[anno.yAxisIndex] && w.config.yaxis[anno.yAxisIndex].reversed) {
  2333. y = yPos + parseFloat(anno.label.style.fontSize) + anno.marker.size;
  2334. pointY = yPos;
  2335. }
  2336. if (!Utils.isNumber(x)) return;
  2337. var optsPoints = {
  2338. pSize: anno.marker.size,
  2339. pWidth: anno.marker.strokeWidth,
  2340. pointFillColor: anno.marker.fillColor,
  2341. pointStrokeColor: anno.marker.strokeColor,
  2342. shape: anno.marker.shape,
  2343. pRadius: anno.marker.radius,
  2344. class: "apexcharts-point-annotation-marker ".concat(anno.marker.cssClass, " ").concat(anno.id ? anno.id : '')
  2345. };
  2346. var point = this.annoCtx.graphics.drawMarker(x + anno.marker.offsetX, pointY + anno.marker.offsetY, optsPoints);
  2347. parent.appendChild(point.node);
  2348. var text = anno.label.text ? anno.label.text : '';
  2349. var elText = this.annoCtx.graphics.drawText({
  2350. x: x + anno.label.offsetX,
  2351. y: y + anno.label.offsetY,
  2352. text: text,
  2353. textAnchor: anno.label.textAnchor,
  2354. fontSize: anno.label.style.fontSize,
  2355. fontFamily: anno.label.style.fontFamily,
  2356. fontWeight: anno.label.style.fontWeight,
  2357. foreColor: anno.label.style.color,
  2358. cssClass: "apexcharts-point-annotation-label ".concat(anno.label.style.cssClass, " ").concat(anno.id ? anno.id : '')
  2359. });
  2360. elText.attr({
  2361. rel: index
  2362. });
  2363. parent.appendChild(elText.node); // TODO: deprecate this as we will use custom
  2364. if (anno.customSVG.SVG) {
  2365. var g = this.annoCtx.graphics.group({
  2366. class: 'apexcharts-point-annotations-custom-svg ' + anno.customSVG.cssClass
  2367. });
  2368. g.attr({
  2369. transform: "translate(".concat(x + anno.customSVG.offsetX, ", ").concat(y + anno.customSVG.offsetY, ")")
  2370. });
  2371. g.node.innerHTML = anno.customSVG.SVG;
  2372. parent.appendChild(g.node);
  2373. }
  2374. if (anno.image.path) {
  2375. var imgWidth = anno.image.width ? anno.image.width : 20;
  2376. var imgHeight = anno.image.height ? anno.image.height : 20;
  2377. this.annoCtx.addImage({
  2378. x: x + anno.image.offsetX - imgWidth / 2,
  2379. y: y + anno.image.offsetY - imgHeight / 2,
  2380. width: imgWidth,
  2381. height: imgHeight,
  2382. path: anno.image.path,
  2383. appendTo: '.apexcharts-point-annotations'
  2384. });
  2385. }
  2386. }
  2387. }, {
  2388. key: "drawPointAnnotations",
  2389. value: function drawPointAnnotations() {
  2390. var _this = this;
  2391. var w = this.w;
  2392. var elg = this.annoCtx.graphics.group({
  2393. class: 'apexcharts-point-annotations'
  2394. });
  2395. w.config.annotations.points.map(function (anno, index) {
  2396. _this.addPointAnnotation(anno, elg.node, index);
  2397. });
  2398. return elg;
  2399. }
  2400. }]);
  2401. return PointAnnotations;
  2402. }();
  2403. const name = "en";
  2404. const options = {
  2405. months: [
  2406. "January",
  2407. "February",
  2408. "March",
  2409. "April",
  2410. "May",
  2411. "June",
  2412. "July",
  2413. "August",
  2414. "September",
  2415. "October",
  2416. "November",
  2417. "December"
  2418. ],
  2419. shortMonths: [
  2420. "Jan",
  2421. "Feb",
  2422. "Mar",
  2423. "Apr",
  2424. "May",
  2425. "Jun",
  2426. "Jul",
  2427. "Aug",
  2428. "Sep",
  2429. "Oct",
  2430. "Nov",
  2431. "Dec"
  2432. ],
  2433. days: [
  2434. "Sunday",
  2435. "Monday",
  2436. "Tuesday",
  2437. "Wednesday",
  2438. "Thursday",
  2439. "Friday",
  2440. "Saturday"
  2441. ],
  2442. shortDays: [
  2443. "Sun",
  2444. "Mon",
  2445. "Tue",
  2446. "Wed",
  2447. "Thu",
  2448. "Fri",
  2449. "Sat"
  2450. ],
  2451. toolbar: {
  2452. exportToSVG: "Download SVG",
  2453. exportToPNG: "Download PNG",
  2454. exportToCSV: "Download CSV",
  2455. menu: "Menu",
  2456. selection: "Selection",
  2457. selectionZoom: "Selection Zoom",
  2458. zoomIn: "Zoom In",
  2459. zoomOut: "Zoom Out",
  2460. pan: "Panning",
  2461. reset: "Reset Zoom"
  2462. }
  2463. };
  2464. var en = {
  2465. name: name,
  2466. options: options
  2467. };
  2468. var Options = /*#__PURE__*/function () {
  2469. function Options() {
  2470. _classCallCheck(this, Options);
  2471. this.yAxis = {
  2472. show: true,
  2473. showAlways: false,
  2474. showForNullSeries: true,
  2475. seriesName: undefined,
  2476. opposite: false,
  2477. reversed: false,
  2478. logarithmic: false,
  2479. tickAmount: undefined,
  2480. forceNiceScale: false,
  2481. max: undefined,
  2482. min: undefined,
  2483. floating: false,
  2484. decimalsInFloat: undefined,
  2485. labels: {
  2486. show: true,
  2487. minWidth: 0,
  2488. maxWidth: 160,
  2489. offsetX: 0,
  2490. offsetY: 0,
  2491. align: undefined,
  2492. rotate: 0,
  2493. padding: 20,
  2494. style: {
  2495. colors: [],
  2496. fontSize: '11px',
  2497. fontWeight: 400,
  2498. fontFamily: undefined,
  2499. cssClass: ''
  2500. },
  2501. formatter: undefined
  2502. },
  2503. axisBorder: {
  2504. show: false,
  2505. color: '#e0e0e0',
  2506. width: 1,
  2507. offsetX: 0,
  2508. offsetY: 0
  2509. },
  2510. axisTicks: {
  2511. show: false,
  2512. color: '#e0e0e0',
  2513. width: 6,
  2514. offsetX: 0,
  2515. offsetY: 0
  2516. },
  2517. title: {
  2518. text: undefined,
  2519. rotate: 90,
  2520. offsetY: 0,
  2521. offsetX: 0,
  2522. style: {
  2523. color: undefined,
  2524. fontSize: '11px',
  2525. fontWeight: 900,
  2526. fontFamily: undefined,
  2527. cssClass: ''
  2528. }
  2529. },
  2530. tooltip: {
  2531. enabled: false,
  2532. offsetX: 0
  2533. },
  2534. crosshairs: {
  2535. show: true,
  2536. position: 'front',
  2537. stroke: {
  2538. color: '#b6b6b6',
  2539. width: 1,
  2540. dashArray: 0
  2541. }
  2542. }
  2543. };
  2544. this.pointAnnotation = {
  2545. x: 0,
  2546. y: null,
  2547. yAxisIndex: 0,
  2548. seriesIndex: 0,
  2549. marker: {
  2550. size: 4,
  2551. fillColor: '#fff',
  2552. strokeWidth: 2,
  2553. strokeColor: '#333',
  2554. shape: 'circle',
  2555. offsetX: 0,
  2556. offsetY: 0,
  2557. radius: 2,
  2558. cssClass: ''
  2559. },
  2560. label: {
  2561. borderColor: '#c2c2c2',
  2562. borderWidth: 1,
  2563. borderRadius: 2,
  2564. text: undefined,
  2565. textAnchor: 'middle',
  2566. offsetX: 0,
  2567. offsetY: 0,
  2568. style: {
  2569. background: '#fff',
  2570. color: undefined,
  2571. fontSize: '11px',
  2572. fontFamily: undefined,
  2573. fontWeight: 400,
  2574. cssClass: '',
  2575. padding: {
  2576. left: 5,
  2577. right: 5,
  2578. top: 2,
  2579. bottom: 2
  2580. }
  2581. }
  2582. },
  2583. customSVG: {
  2584. // this will be deprecated in the next major version as it is going to be replaced with a better alternative below
  2585. SVG: undefined,
  2586. cssClass: undefined,
  2587. offsetX: 0,
  2588. offsetY: 0
  2589. },
  2590. image: {
  2591. path: undefined,
  2592. width: 20,
  2593. height: 20,
  2594. offsetX: 0,
  2595. offsetY: 0
  2596. }
  2597. };
  2598. this.yAxisAnnotation = {
  2599. y: 0,
  2600. y2: null,
  2601. strokeDashArray: 1,
  2602. fillColor: '#c2c2c2',
  2603. borderColor: '#c2c2c2',
  2604. borderWidth: 1,
  2605. opacity: 0.3,
  2606. offsetX: 0,
  2607. offsetY: 0,
  2608. yAxisIndex: 0,
  2609. label: {
  2610. borderColor: '#c2c2c2',
  2611. borderWidth: 1,
  2612. borderRadius: 2,
  2613. text: undefined,
  2614. textAnchor: 'end',
  2615. position: 'right',
  2616. offsetX: 0,
  2617. offsetY: -3,
  2618. style: {
  2619. background: '#fff',
  2620. color: undefined,
  2621. fontSize: '11px',
  2622. fontFamily: undefined,
  2623. fontWeight: 400,
  2624. cssClass: '',
  2625. padding: {
  2626. left: 5,
  2627. right: 5,
  2628. top: 2,
  2629. bottom: 2
  2630. }
  2631. }
  2632. }
  2633. };
  2634. this.xAxisAnnotation = {
  2635. x: 0,
  2636. x2: null,
  2637. strokeDashArray: 1,
  2638. fillColor: '#c2c2c2',
  2639. borderColor: '#c2c2c2',
  2640. borderWidth: 1,
  2641. opacity: 0.3,
  2642. offsetX: 0,
  2643. offsetY: 0,
  2644. label: {
  2645. borderColor: '#c2c2c2',
  2646. borderWidth: 1,
  2647. borderRadius: 2,
  2648. text: undefined,
  2649. textAnchor: 'middle',
  2650. orientation: 'vertical',
  2651. position: 'top',
  2652. offsetX: 0,
  2653. offsetY: 0,
  2654. style: {
  2655. background: '#fff',
  2656. color: undefined,
  2657. fontSize: '11px',
  2658. fontFamily: undefined,
  2659. fontWeight: 400,
  2660. cssClass: '',
  2661. padding: {
  2662. left: 5,
  2663. right: 5,
  2664. top: 2,
  2665. bottom: 2
  2666. }
  2667. }
  2668. }
  2669. };
  2670. this.text = {
  2671. x: 0,
  2672. y: 0,
  2673. text: '',
  2674. textAnchor: 'start',
  2675. foreColor: undefined,
  2676. fontSize: '13px',
  2677. fontFamily: undefined,
  2678. fontWeight: 400,
  2679. appendTo: '.apexcharts-annotations',
  2680. backgroundColor: 'transparent',
  2681. borderColor: '#c2c2c2',
  2682. borderRadius: 0,
  2683. borderWidth: 0,
  2684. paddingLeft: 4,
  2685. paddingRight: 4,
  2686. paddingTop: 2,
  2687. paddingBottom: 2
  2688. };
  2689. this.shape = {
  2690. x: 0,
  2691. y: 0,
  2692. type: 'rect',
  2693. width: '100%',
  2694. // accepts percentage as well as fixed numbers
  2695. height: 50,
  2696. appendTo: '.apexcharts-annotations',
  2697. backgroundColor: '#fff',
  2698. opacity: 1,
  2699. borderWidth: 0,
  2700. borderRadius: 4,
  2701. borderColor: '#c2c2c2'
  2702. };
  2703. }
  2704. _createClass(Options, [{
  2705. key: "init",
  2706. value: function init() {
  2707. return {
  2708. annotations: {
  2709. position: 'front',
  2710. yaxis: [this.yAxisAnnotation],
  2711. xaxis: [this.xAxisAnnotation],
  2712. points: [this.pointAnnotation],
  2713. texts: [],
  2714. images: [],
  2715. shapes: []
  2716. },
  2717. chart: {
  2718. animations: {
  2719. enabled: true,
  2720. easing: 'easeinout',
  2721. // linear, easeout, easein, easeinout, swing, bounce, elastic
  2722. speed: 800,
  2723. animateGradually: {
  2724. delay: 150,
  2725. enabled: true
  2726. },
  2727. dynamicAnimation: {
  2728. enabled: true,
  2729. speed: 350
  2730. }
  2731. },
  2732. background: 'transparent',
  2733. locales: [en],
  2734. defaultLocale: 'en',
  2735. dropShadow: {
  2736. enabled: false,
  2737. enabledOnSeries: undefined,
  2738. top: 2,
  2739. left: 2,
  2740. blur: 4,
  2741. color: '#000',
  2742. opacity: 0.35
  2743. },
  2744. events: {
  2745. animationEnd: undefined,
  2746. beforeMount: undefined,
  2747. mounted: undefined,
  2748. updated: undefined,
  2749. click: undefined,
  2750. mouseMove: undefined,
  2751. legendClick: undefined,
  2752. markerClick: undefined,
  2753. selection: undefined,
  2754. dataPointSelection: undefined,
  2755. dataPointMouseEnter: undefined,
  2756. dataPointMouseLeave: undefined,
  2757. beforeZoom: undefined,
  2758. zoomed: undefined,
  2759. scrolled: undefined
  2760. },
  2761. foreColor: '#373d3f',
  2762. fontFamily: 'Helvetica, Arial, sans-serif',
  2763. height: 'auto',
  2764. parentHeightOffset: 15,
  2765. redrawOnParentResize: true,
  2766. id: undefined,
  2767. group: undefined,
  2768. offsetX: 0,
  2769. offsetY: 0,
  2770. selection: {
  2771. enabled: false,
  2772. type: 'x',
  2773. // selectedPoints: undefined, // default datapoints that should be selected automatically
  2774. fill: {
  2775. color: '#24292e',
  2776. opacity: 0.1
  2777. },
  2778. stroke: {
  2779. width: 1,
  2780. color: '#24292e',
  2781. opacity: 0.4,
  2782. dashArray: 3
  2783. },
  2784. xaxis: {
  2785. min: undefined,
  2786. max: undefined
  2787. },
  2788. yaxis: {
  2789. min: undefined,
  2790. max: undefined
  2791. }
  2792. },
  2793. sparkline: {
  2794. enabled: false
  2795. },
  2796. brush: {
  2797. enabled: false,
  2798. autoScaleYaxis: true,
  2799. target: undefined
  2800. },
  2801. stacked: false,
  2802. stackType: 'normal',
  2803. toolbar: {
  2804. show: true,
  2805. offsetX: 0,
  2806. offsetY: 0,
  2807. tools: {
  2808. download: true,
  2809. selection: true,
  2810. zoom: true,
  2811. zoomin: true,
  2812. zoomout: true,
  2813. pan: true,
  2814. reset: true,
  2815. customIcons: []
  2816. },
  2817. autoSelected: 'zoom' // accepts -> zoom, pan, selection
  2818. },
  2819. type: 'line',
  2820. width: '100%',
  2821. zoom: {
  2822. enabled: true,
  2823. type: 'x',
  2824. autoScaleYaxis: false,
  2825. zoomedArea: {
  2826. fill: {
  2827. color: '#90CAF9',
  2828. opacity: 0.4
  2829. },
  2830. stroke: {
  2831. color: '#0D47A1',
  2832. opacity: 0.4,
  2833. width: 1
  2834. }
  2835. }
  2836. }
  2837. },
  2838. plotOptions: {
  2839. bar: {
  2840. horizontal: false,
  2841. columnWidth: '70%',
  2842. // should be in percent 0 - 100
  2843. barHeight: '70%',
  2844. // should be in percent 0 - 100
  2845. distributed: false,
  2846. startingShape: 'flat',
  2847. endingShape: 'flat',
  2848. rangeBarOverlap: true,
  2849. colors: {
  2850. ranges: [],
  2851. backgroundBarColors: [],
  2852. backgroundBarOpacity: 1,
  2853. backgroundBarRadius: 0
  2854. },
  2855. dataLabels: {
  2856. position: 'top',
  2857. // top, center, bottom
  2858. maxItems: 100,
  2859. hideOverflowingLabels: true,
  2860. orientation: 'horizontal' // TODO: provide stackedLabels for stacked charts which gives additions of values
  2861. }
  2862. },
  2863. bubble: {
  2864. minBubbleRadius: undefined,
  2865. maxBubbleRadius: undefined
  2866. },
  2867. candlestick: {
  2868. colors: {
  2869. upward: '#00B746',
  2870. downward: '#EF403C'
  2871. },
  2872. wick: {
  2873. useFillColor: true
  2874. }
  2875. },
  2876. heatmap: {
  2877. radius: 2,
  2878. enableShades: true,
  2879. shadeIntensity: 0.5,
  2880. reverseNegativeShade: false,
  2881. distributed: false,
  2882. useFillColorAsStroke: false,
  2883. colorScale: {
  2884. inverse: false,
  2885. ranges: [],
  2886. min: undefined,
  2887. max: undefined
  2888. }
  2889. },
  2890. radialBar: {
  2891. inverseOrder: false,
  2892. startAngle: 0,
  2893. endAngle: 360,
  2894. offsetX: 0,
  2895. offsetY: 0,
  2896. hollow: {
  2897. margin: 5,
  2898. size: '50%',
  2899. background: 'transparent',
  2900. image: undefined,
  2901. imageWidth: 150,
  2902. imageHeight: 150,
  2903. imageOffsetX: 0,
  2904. imageOffsetY: 0,
  2905. imageClipped: true,
  2906. position: 'front',
  2907. dropShadow: {
  2908. enabled: false,
  2909. top: 0,
  2910. left: 0,
  2911. blur: 3,
  2912. color: '#000',
  2913. opacity: 0.5
  2914. }
  2915. },
  2916. track: {
  2917. show: true,
  2918. startAngle: undefined,
  2919. endAngle: undefined,
  2920. background: '#f2f2f2',
  2921. strokeWidth: '97%',
  2922. opacity: 1,
  2923. margin: 5,
  2924. // margin is in pixels
  2925. dropShadow: {
  2926. enabled: false,
  2927. top: 0,
  2928. left: 0,
  2929. blur: 3,
  2930. color: '#000',
  2931. opacity: 0.5
  2932. }
  2933. },
  2934. dataLabels: {
  2935. show: true,
  2936. name: {
  2937. show: true,
  2938. fontSize: '16px',
  2939. fontFamily: undefined,
  2940. fontWeight: 600,
  2941. color: undefined,
  2942. offsetY: 0,
  2943. formatter: function formatter(val) {
  2944. return val;
  2945. }
  2946. },
  2947. value: {
  2948. show: true,
  2949. fontSize: '14px',
  2950. fontFamily: undefined,
  2951. fontWeight: 400,
  2952. color: undefined,
  2953. offsetY: 16,
  2954. formatter: function formatter(val) {
  2955. return val + '%';
  2956. }
  2957. },
  2958. total: {
  2959. show: false,
  2960. label: 'Total',
  2961. fontSize: '16px',
  2962. fontWeight: 600,
  2963. fontFamily: undefined,
  2964. color: undefined,
  2965. formatter: function formatter(w) {
  2966. return w.globals.seriesTotals.reduce(function (a, b) {
  2967. return a + b;
  2968. }, 0) / w.globals.series.length + '%';
  2969. }
  2970. }
  2971. }
  2972. },
  2973. pie: {
  2974. customScale: 1,
  2975. offsetX: 0,
  2976. offsetY: 0,
  2977. expandOnClick: true,
  2978. dataLabels: {
  2979. // These are the percentage values which are displayed on slice
  2980. offset: 0,
  2981. // offset by which labels will move outside
  2982. minAngleToShowLabel: 10
  2983. },
  2984. donut: {
  2985. size: '65%',
  2986. background: 'transparent',
  2987. labels: {
  2988. // These are the inner labels appearing inside donut
  2989. show: false,
  2990. name: {
  2991. show: true,
  2992. fontSize: '16px',
  2993. fontFamily: undefined,
  2994. fontWeight: 600,
  2995. color: undefined,
  2996. offsetY: -10,
  2997. formatter: function formatter(val) {
  2998. return val;
  2999. }
  3000. },
  3001. value: {
  3002. show: true,
  3003. fontSize: '20px',
  3004. fontFamily: undefined,
  3005. fontWeight: 400,
  3006. color: undefined,
  3007. offsetY: 10,
  3008. formatter: function formatter(val) {
  3009. return val;
  3010. }
  3011. },
  3012. total: {
  3013. show: false,
  3014. showAlways: false,
  3015. label: 'Total',
  3016. fontSize: '16px',
  3017. fontWeight: 400,
  3018. fontFamily: undefined,
  3019. color: undefined,
  3020. formatter: function formatter(w) {
  3021. return w.globals.seriesTotals.reduce(function (a, b) {
  3022. return a + b;
  3023. }, 0);
  3024. }
  3025. }
  3026. }
  3027. }
  3028. },
  3029. polarArea: {
  3030. rings: {
  3031. strokeWidth: 1,
  3032. strokeColor: '#e8e8e8'
  3033. }
  3034. },
  3035. radar: {
  3036. size: undefined,
  3037. offsetX: 0,
  3038. offsetY: 0,
  3039. polygons: {
  3040. // strokeColor: '#e8e8e8', // should be deprecated in the minor version i.e 3.2
  3041. strokeWidth: 1,
  3042. strokeColors: '#e8e8e8',
  3043. connectorColors: '#e8e8e8',
  3044. fill: {
  3045. colors: undefined
  3046. }
  3047. }
  3048. }
  3049. },
  3050. colors: undefined,
  3051. dataLabels: {
  3052. enabled: true,
  3053. enabledOnSeries: undefined,
  3054. formatter: function formatter(val) {
  3055. return val !== null ? val : '';
  3056. },
  3057. textAnchor: 'middle',
  3058. distributed: false,
  3059. offsetX: 0,
  3060. offsetY: 0,
  3061. style: {
  3062. fontSize: '12px',
  3063. fontFamily: undefined,
  3064. fontWeight: 600,
  3065. colors: undefined
  3066. },
  3067. background: {
  3068. enabled: true,
  3069. foreColor: '#fff',
  3070. borderRadius: 2,
  3071. padding: 4,
  3072. opacity: 0.9,
  3073. borderWidth: 1,
  3074. borderColor: '#fff',
  3075. dropShadow: {
  3076. enabled: false,
  3077. top: 1,
  3078. left: 1,
  3079. blur: 1,
  3080. color: '#000',
  3081. opacity: 0.45
  3082. }
  3083. },
  3084. dropShadow: {
  3085. enabled: false,
  3086. top: 1,
  3087. left: 1,
  3088. blur: 1,
  3089. color: '#000',
  3090. opacity: 0.45
  3091. }
  3092. },
  3093. fill: {
  3094. type: 'solid',
  3095. colors: undefined,
  3096. // array of colors
  3097. opacity: 0.85,
  3098. gradient: {
  3099. shade: 'dark',
  3100. type: 'horizontal',
  3101. shadeIntensity: 0.5,
  3102. gradientToColors: undefined,
  3103. inverseColors: true,
  3104. opacityFrom: 1,
  3105. opacityTo: 1,
  3106. stops: [0, 50, 100],
  3107. colorStops: []
  3108. },
  3109. image: {
  3110. src: [],
  3111. width: undefined,
  3112. // optional
  3113. height: undefined // optional
  3114. },
  3115. pattern: {
  3116. style: 'squares',
  3117. // String | Array of Strings
  3118. width: 6,
  3119. height: 6,
  3120. strokeWidth: 2
  3121. }
  3122. },
  3123. grid: {
  3124. show: true,
  3125. borderColor: '#e0e0e0',
  3126. strokeDashArray: 0,
  3127. position: 'back',
  3128. xaxis: {
  3129. lines: {
  3130. show: false
  3131. }
  3132. },
  3133. yaxis: {
  3134. lines: {
  3135. show: true
  3136. }
  3137. },
  3138. row: {
  3139. colors: undefined,
  3140. // takes as array which will be repeated on rows
  3141. opacity: 0.5
  3142. },
  3143. column: {
  3144. colors: undefined,
  3145. // takes an array which will be repeated on columns
  3146. opacity: 0.5
  3147. },
  3148. padding: {
  3149. top: 0,
  3150. right: 10,
  3151. bottom: 0,
  3152. left: 12
  3153. }
  3154. },
  3155. labels: [],
  3156. legend: {
  3157. show: true,
  3158. showForSingleSeries: false,
  3159. showForNullSeries: true,
  3160. showForZeroSeries: true,
  3161. floating: false,
  3162. position: 'bottom',
  3163. // whether to position legends in 1 of 4
  3164. // direction - top, bottom, left, right
  3165. horizontalAlign: 'center',
  3166. // when position top/bottom, you can specify whether to align legends left, right or center
  3167. inverseOrder: false,
  3168. fontSize: '12px',
  3169. fontFamily: undefined,
  3170. fontWeight: 400,
  3171. width: undefined,
  3172. height: undefined,
  3173. formatter: undefined,
  3174. tooltipHoverFormatter: undefined,
  3175. offsetX: -20,
  3176. offsetY: 0,
  3177. labels: {
  3178. colors: undefined,
  3179. useSeriesColors: false
  3180. },
  3181. markers: {
  3182. width: 12,
  3183. height: 12,
  3184. strokeWidth: 0,
  3185. fillColors: undefined,
  3186. strokeColor: '#fff',
  3187. radius: 12,
  3188. customHTML: undefined,
  3189. offsetX: 0,
  3190. offsetY: 0,
  3191. onClick: undefined
  3192. },
  3193. itemMargin: {
  3194. horizontal: 5,
  3195. vertical: 0
  3196. },
  3197. onItemClick: {
  3198. toggleDataSeries: true
  3199. },
  3200. onItemHover: {
  3201. highlightDataSeries: true
  3202. }
  3203. },
  3204. markers: {
  3205. discrete: [],
  3206. size: 0,
  3207. colors: undefined,
  3208. //strokeColor: '#fff', // TODO: deprecate in major version 4.0
  3209. strokeColors: '#fff',
  3210. strokeWidth: 2,
  3211. strokeOpacity: 0.9,
  3212. strokeDashArray: 0,
  3213. fillOpacity: 1,
  3214. shape: 'circle',
  3215. radius: 2,
  3216. offsetX: 0,
  3217. offsetY: 0,
  3218. onClick: undefined,
  3219. onDblClick: undefined,
  3220. showNullDataPoints: true,
  3221. hover: {
  3222. size: undefined,
  3223. sizeOffset: 3
  3224. }
  3225. },
  3226. noData: {
  3227. text: undefined,
  3228. align: 'center',
  3229. verticalAlign: 'middle',
  3230. offsetX: 0,
  3231. offsetY: 0,
  3232. style: {
  3233. color: undefined,
  3234. fontSize: '14px',
  3235. fontFamily: undefined
  3236. }
  3237. },
  3238. responsive: [],
  3239. // breakpoints should follow ascending order 400, then 700, then 1000
  3240. series: undefined,
  3241. states: {
  3242. normal: {
  3243. filter: {
  3244. type: 'none',
  3245. value: 0
  3246. }
  3247. },
  3248. hover: {
  3249. filter: {
  3250. type: 'lighten',
  3251. value: 0.15
  3252. }
  3253. },
  3254. active: {
  3255. allowMultipleDataPointsSelection: false,
  3256. filter: {
  3257. type: 'darken',
  3258. value: 0.65
  3259. }
  3260. }
  3261. },
  3262. title: {
  3263. text: undefined,
  3264. align: 'left',
  3265. margin: 5,
  3266. offsetX: 0,
  3267. offsetY: 0,
  3268. floating: false,
  3269. style: {
  3270. fontSize: '14px',
  3271. fontWeight: 900,
  3272. fontFamily: undefined,
  3273. color: undefined
  3274. }
  3275. },
  3276. subtitle: {
  3277. text: undefined,
  3278. align: 'left',
  3279. margin: 5,
  3280. offsetX: 0,
  3281. offsetY: 30,
  3282. floating: false,
  3283. style: {
  3284. fontSize: '12px',
  3285. fontWeight: 400,
  3286. fontFamily: undefined,
  3287. color: undefined
  3288. }
  3289. },
  3290. stroke: {
  3291. show: true,
  3292. curve: 'smooth',
  3293. // "smooth" / "straight" / "stepline"
  3294. lineCap: 'butt',
  3295. // round, butt , square
  3296. width: 2,
  3297. colors: undefined,
  3298. // array of colors
  3299. dashArray: 0 // single value or array of values
  3300. },
  3301. tooltip: {
  3302. enabled: true,
  3303. enabledOnSeries: undefined,
  3304. shared: true,
  3305. followCursor: false,
  3306. // when disabled, the tooltip will show on top of the series instead of mouse position
  3307. intersect: false,
  3308. // when enabled, tooltip will only show when user directly hovers over point
  3309. inverseOrder: false,
  3310. custom: undefined,
  3311. fillSeriesColor: false,
  3312. theme: 'light',
  3313. style: {
  3314. fontSize: '12px',
  3315. fontFamily: undefined
  3316. },
  3317. onDatasetHover: {
  3318. highlightDataSeries: false
  3319. },
  3320. x: {
  3321. // x value
  3322. show: true,
  3323. format: 'dd MMM',
  3324. // dd/MM, dd MMM yy, dd MMM yyyy
  3325. formatter: undefined // a custom user supplied formatter function
  3326. },
  3327. y: {
  3328. formatter: undefined,
  3329. title: {
  3330. formatter: function formatter(seriesName) {
  3331. return seriesName;
  3332. }
  3333. }
  3334. },
  3335. z: {
  3336. formatter: undefined,
  3337. title: 'Size: '
  3338. },
  3339. marker: {
  3340. show: true,
  3341. fillColors: undefined
  3342. },
  3343. items: {
  3344. display: 'flex'
  3345. },
  3346. fixed: {
  3347. enabled: false,
  3348. position: 'topRight',
  3349. // topRight, topLeft, bottomRight, bottomLeft
  3350. offsetX: 0,
  3351. offsetY: 0
  3352. }
  3353. },
  3354. xaxis: {
  3355. type: 'category',
  3356. categories: [],
  3357. convertedCatToNumeric: false,
  3358. // internal property which should not be altered outside
  3359. sorted: false,
  3360. offsetX: 0,
  3361. offsetY: 0,
  3362. labels: {
  3363. show: true,
  3364. rotate: -45,
  3365. rotateAlways: false,
  3366. hideOverlappingLabels: true,
  3367. trim: false,
  3368. minHeight: undefined,
  3369. maxHeight: 120,
  3370. showDuplicates: true,
  3371. style: {
  3372. colors: [],
  3373. fontSize: '12px',
  3374. fontWeight: 400,
  3375. fontFamily: undefined,
  3376. cssClass: ''
  3377. },
  3378. offsetX: 0,
  3379. offsetY: 0,
  3380. format: undefined,
  3381. formatter: undefined,
  3382. // custom formatter function which will override format
  3383. datetimeUTC: true,
  3384. datetimeFormatter: {
  3385. year: 'yyyy',
  3386. month: "MMM 'yy",
  3387. day: 'dd MMM',
  3388. hour: 'HH:mm',
  3389. minute: 'HH:mm:ss'
  3390. }
  3391. },
  3392. axisBorder: {
  3393. show: true,
  3394. color: '#e0e0e0',
  3395. width: '100%',
  3396. height: 1,
  3397. offsetX: 0,
  3398. offsetY: 0
  3399. },
  3400. axisTicks: {
  3401. show: true,
  3402. color: '#e0e0e0',
  3403. height: 6,
  3404. offsetX: 0,
  3405. offsetY: 0
  3406. },
  3407. tickAmount: undefined,
  3408. tickPlacement: 'on',
  3409. min: undefined,
  3410. max: undefined,
  3411. range: undefined,
  3412. floating: false,
  3413. position: 'bottom',
  3414. title: {
  3415. text: undefined,
  3416. offsetX: 0,
  3417. offsetY: 0,
  3418. style: {
  3419. color: undefined,
  3420. fontSize: '12px',
  3421. fontWeight: 900,
  3422. fontFamily: undefined,
  3423. cssClass: ''
  3424. }
  3425. },
  3426. crosshairs: {
  3427. show: true,
  3428. width: 1,
  3429. // tickWidth/barWidth or an integer
  3430. position: 'back',
  3431. opacity: 0.9,
  3432. stroke: {
  3433. color: '#b6b6b6',
  3434. width: 1,
  3435. dashArray: 3
  3436. },
  3437. fill: {
  3438. type: 'solid',
  3439. // solid, gradient
  3440. color: '#B1B9C4',
  3441. gradient: {
  3442. colorFrom: '#D8E3F0',
  3443. colorTo: '#BED1E6',
  3444. stops: [0, 100],
  3445. opacityFrom: 0.4,
  3446. opacityTo: 0.5
  3447. }
  3448. },
  3449. dropShadow: {
  3450. enabled: false,
  3451. left: 0,
  3452. top: 0,
  3453. blur: 1,
  3454. opacity: 0.4
  3455. }
  3456. },
  3457. tooltip: {
  3458. enabled: true,
  3459. offsetY: 0,
  3460. formatter: undefined,
  3461. style: {
  3462. fontSize: '12px',
  3463. fontFamily: undefined
  3464. }
  3465. }
  3466. },
  3467. yaxis: this.yAxis,
  3468. theme: {
  3469. mode: 'light',
  3470. palette: 'palette1',
  3471. // If defined, it will overwrite globals.colors variable
  3472. monochrome: {
  3473. // monochrome allows you to select just 1 color and fill out the rest with light/dark shade (intensity can be selected)
  3474. enabled: false,
  3475. color: '#008FFB',
  3476. shadeTo: 'light',
  3477. shadeIntensity: 0.65
  3478. }
  3479. }
  3480. };
  3481. }
  3482. }]);
  3483. return Options;
  3484. }();
  3485. /**
  3486. * ApexCharts Annotations Class for drawing lines/rects on both xaxis and yaxis.
  3487. *
  3488. * @module Annotations
  3489. **/
  3490. var Annotations = /*#__PURE__*/function () {
  3491. function Annotations(ctx) {
  3492. _classCallCheck(this, Annotations);
  3493. this.ctx = ctx;
  3494. this.w = ctx.w;
  3495. this.graphics = new Graphics(this.ctx);
  3496. if (this.w.globals.isBarHorizontal) {
  3497. this.invertAxis = true;
  3498. }
  3499. this.helpers = new Helpers(this);
  3500. this.xAxisAnnotations = new XAnnotations(this);
  3501. this.yAxisAnnotations = new YAnnotations(this);
  3502. this.pointsAnnotations = new PointAnnotations(this);
  3503. if (this.w.globals.isBarHorizontal && this.w.config.yaxis[0].reversed) {
  3504. this.inversedReversedAxis = true;
  3505. }
  3506. this.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints;
  3507. }
  3508. _createClass(Annotations, [{
  3509. key: "drawAxesAnnotations",
  3510. value: function drawAxesAnnotations() {
  3511. var w = this.w;
  3512. if (w.globals.axisCharts) {
  3513. var yAnnotations = this.yAxisAnnotations.drawYAxisAnnotations();
  3514. var xAnnotations = this.xAxisAnnotations.drawXAxisAnnotations();
  3515. var pointAnnotations = this.pointsAnnotations.drawPointAnnotations();
  3516. var initialAnim = w.config.chart.animations.enabled;
  3517. var annoArray = [yAnnotations, xAnnotations, pointAnnotations];
  3518. var annoElArray = [xAnnotations.node, yAnnotations.node, pointAnnotations.node];
  3519. for (var i = 0; i < 3; i++) {
  3520. w.globals.dom.elGraphical.add(annoArray[i]);
  3521. if (initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  3522. // fixes apexcharts/apexcharts.js#685
  3523. if (w.config.chart.type !== 'scatter' && w.config.chart.type !== 'bubble' && w.globals.dataPoints > 1) {
  3524. annoElArray[i].classList.add('apexcharts-element-hidden');
  3525. }
  3526. }
  3527. w.globals.delayedElements.push({
  3528. el: annoElArray[i],
  3529. index: 0
  3530. });
  3531. } // background sizes needs to be calculated after text is drawn, so calling them last
  3532. this.helpers.annotationsBackground();
  3533. }
  3534. }
  3535. }, {
  3536. key: "drawShapeAnnos",
  3537. value: function drawShapeAnnos() {
  3538. var _this = this;
  3539. var w = this.w;
  3540. w.config.annotations.shapes.map(function (s, index) {
  3541. _this.addShape(s, index);
  3542. });
  3543. }
  3544. }, {
  3545. key: "drawImageAnnos",
  3546. value: function drawImageAnnos() {
  3547. var _this2 = this;
  3548. var w = this.w;
  3549. w.config.annotations.images.map(function (s, index) {
  3550. _this2.addImage(s, index);
  3551. });
  3552. }
  3553. }, {
  3554. key: "drawTextAnnos",
  3555. value: function drawTextAnnos() {
  3556. var _this3 = this;
  3557. var w = this.w;
  3558. w.config.annotations.texts.map(function (t, index) {
  3559. _this3.addText(t, index);
  3560. });
  3561. }
  3562. }, {
  3563. key: "addXaxisAnnotation",
  3564. value: function addXaxisAnnotation(anno, parent, index) {
  3565. this.xAxisAnnotations.addXaxisAnnotation(anno, parent, index);
  3566. }
  3567. }, {
  3568. key: "addYaxisAnnotation",
  3569. value: function addYaxisAnnotation(anno, parent, index) {
  3570. this.yAxisAnnotations.addYaxisAnnotation(anno, parent, index);
  3571. }
  3572. }, {
  3573. key: "addPointAnnotation",
  3574. value: function addPointAnnotation(anno, parent, index) {
  3575. this.pointsAnnotations.addPointAnnotation(anno, parent, index);
  3576. }
  3577. }, {
  3578. key: "addText",
  3579. value: function addText(params, index) {
  3580. var x = params.x,
  3581. y = params.y,
  3582. text = params.text,
  3583. textAnchor = params.textAnchor,
  3584. foreColor = params.foreColor,
  3585. fontSize = params.fontSize,
  3586. fontFamily = params.fontFamily,
  3587. fontWeight = params.fontWeight,
  3588. cssClass = params.cssClass,
  3589. backgroundColor = params.backgroundColor,
  3590. borderWidth = params.borderWidth,
  3591. strokeDashArray = params.strokeDashArray,
  3592. borderRadius = params.borderRadius,
  3593. borderColor = params.borderColor,
  3594. _params$appendTo = params.appendTo,
  3595. appendTo = _params$appendTo === void 0 ? '.apexcharts-annotations' : _params$appendTo,
  3596. _params$paddingLeft = params.paddingLeft,
  3597. paddingLeft = _params$paddingLeft === void 0 ? 4 : _params$paddingLeft,
  3598. _params$paddingRight = params.paddingRight,
  3599. paddingRight = _params$paddingRight === void 0 ? 4 : _params$paddingRight,
  3600. _params$paddingBottom = params.paddingBottom,
  3601. paddingBottom = _params$paddingBottom === void 0 ? 2 : _params$paddingBottom,
  3602. _params$paddingTop = params.paddingTop,
  3603. paddingTop = _params$paddingTop === void 0 ? 2 : _params$paddingTop;
  3604. var w = this.w;
  3605. var elText = this.graphics.drawText({
  3606. x: x,
  3607. y: y,
  3608. text: text,
  3609. textAnchor: textAnchor || 'start',
  3610. fontSize: fontSize || '12px',
  3611. fontWeight: fontWeight || 'regular',
  3612. fontFamily: fontFamily || w.config.chart.fontFamily,
  3613. foreColor: foreColor || w.config.chart.foreColor,
  3614. cssClass: 'apexcharts-text ' + cssClass ? cssClass : ''
  3615. });
  3616. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3617. if (parent) {
  3618. parent.appendChild(elText.node);
  3619. }
  3620. var textRect = elText.bbox();
  3621. if (params.draggable) {
  3622. this.helpers.makeAnnotationDraggable(elText, 'texts', index);
  3623. }
  3624. if (text) {
  3625. 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);
  3626. parent.insertBefore(elRect.node, elText.node);
  3627. }
  3628. }
  3629. }, {
  3630. key: "addShape",
  3631. value: function addShape(params, index) {
  3632. var opts = {
  3633. type: params.type,
  3634. x: params.x || 0,
  3635. y: params.y || 0,
  3636. width: params.width || '100%',
  3637. height: params.height || 50,
  3638. circleRadius: params.radius || 25,
  3639. backgroundColor: params.backgroundColor || '#fff',
  3640. opacity: params.opacity || 1,
  3641. borderWidth: params.borderWidth || 0,
  3642. borderRadius: params.borderRadius || 4,
  3643. borderColor: params.borderColor || '#c2c2c2',
  3644. appendTo: params.appendTo || '.apexcharts-annotations'
  3645. };
  3646. var w = this.w;
  3647. if (String(opts.width).indexOf('%') > -1) {
  3648. opts.width = parseInt(opts.width, 10) * parseInt(w.globals.svgWidth, 10) / 100;
  3649. }
  3650. var elShape = null;
  3651. if (opts.type === 'circle') {
  3652. elShape = this.graphics.drawCircle(opts.circleRadius, {
  3653. fill: opts.backgroundColor,
  3654. stroke: opts.borderColor,
  3655. 'stroke-width': opts.borderWidth,
  3656. opacity: opts.opacity,
  3657. cx: opts.x,
  3658. cy: opts.y
  3659. });
  3660. } else {
  3661. elShape = this.graphics.drawRect(opts.x, opts.y, opts.width, opts.height, opts.borderRadius, opts.backgroundColor, opts.opacity, opts.borderWidth, opts.borderColor);
  3662. }
  3663. var parent = w.globals.dom.baseEl.querySelector(opts.appendTo);
  3664. if (parent) {
  3665. parent.appendChild(elShape.node);
  3666. }
  3667. if (params.draggable) {
  3668. this.helpers.makeAnnotationDraggable(elShape, 'shapes', index);
  3669. elShape.node.classList.add('apexcharts-resizable-element');
  3670. }
  3671. }
  3672. }, {
  3673. key: "addImage",
  3674. value: function addImage(params, index) {
  3675. var w = this.w;
  3676. var path = params.path,
  3677. _params$x = params.x,
  3678. x = _params$x === void 0 ? 0 : _params$x,
  3679. _params$y = params.y,
  3680. y = _params$y === void 0 ? 0 : _params$y,
  3681. _params$width = params.width,
  3682. width = _params$width === void 0 ? 20 : _params$width,
  3683. _params$height = params.height,
  3684. height = _params$height === void 0 ? 20 : _params$height,
  3685. _params$appendTo2 = params.appendTo,
  3686. appendTo = _params$appendTo2 === void 0 ? '.apexcharts-annotations' : _params$appendTo2;
  3687. var img = w.globals.dom.Paper.image(path);
  3688. img.size(width, height).move(x, y);
  3689. var parent = w.globals.dom.baseEl.querySelector(appendTo);
  3690. if (parent) {
  3691. parent.appendChild(img.node);
  3692. }
  3693. if (params.draggable) {
  3694. this.helpers.makeAnnotationDraggable(img, 'images', index);
  3695. img.node.classList.add('apexcharts-resizable-element');
  3696. }
  3697. } // 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
  3698. }, {
  3699. key: "addXaxisAnnotationExternal",
  3700. value: function addXaxisAnnotationExternal(params, pushToMemory, context) {
  3701. this.addAnnotationExternal({
  3702. params: params,
  3703. pushToMemory: pushToMemory,
  3704. context: context,
  3705. type: 'xaxis',
  3706. contextMethod: context.addXaxisAnnotation
  3707. });
  3708. return context;
  3709. }
  3710. }, {
  3711. key: "addYaxisAnnotationExternal",
  3712. value: function addYaxisAnnotationExternal(params, pushToMemory, context) {
  3713. this.addAnnotationExternal({
  3714. params: params,
  3715. pushToMemory: pushToMemory,
  3716. context: context,
  3717. type: 'yaxis',
  3718. contextMethod: context.addYaxisAnnotation
  3719. });
  3720. return context;
  3721. }
  3722. }, {
  3723. key: "addPointAnnotationExternal",
  3724. value: function addPointAnnotationExternal(params, pushToMemory, context) {
  3725. if (typeof this.invertAxis === 'undefined') {
  3726. this.invertAxis = context.w.globals.isBarHorizontal;
  3727. }
  3728. this.addAnnotationExternal({
  3729. params: params,
  3730. pushToMemory: pushToMemory,
  3731. context: context,
  3732. type: 'point',
  3733. contextMethod: context.addPointAnnotation
  3734. });
  3735. return context;
  3736. }
  3737. }, {
  3738. key: "addAnnotationExternal",
  3739. value: function addAnnotationExternal(_ref) {
  3740. var params = _ref.params,
  3741. pushToMemory = _ref.pushToMemory,
  3742. context = _ref.context,
  3743. type = _ref.type,
  3744. contextMethod = _ref.contextMethod;
  3745. var me = context;
  3746. var w = me.w;
  3747. var parent = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations"));
  3748. var index = parent.childNodes.length + 1;
  3749. var options = new Options();
  3750. var axesAnno = Object.assign({}, type === 'xaxis' ? options.xAxisAnnotation : type === 'yaxis' ? options.yAxisAnnotation : options.pointAnnotation);
  3751. var anno = Utils.extend(axesAnno, params);
  3752. switch (type) {
  3753. case 'xaxis':
  3754. this.addXaxisAnnotation(anno, parent, index);
  3755. break;
  3756. case 'yaxis':
  3757. this.addYaxisAnnotation(anno, parent, index);
  3758. break;
  3759. case 'point':
  3760. this.addPointAnnotation(anno, parent, index);
  3761. break;
  3762. } // add background
  3763. var axesAnnoLabel = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-annotations .apexcharts-").concat(type, "-annotation-label[rel='").concat(index, "']"));
  3764. var elRect = this.helpers.addBackgroundToAnno(axesAnnoLabel, anno);
  3765. if (elRect) {
  3766. parent.insertBefore(elRect.node, axesAnnoLabel);
  3767. }
  3768. if (pushToMemory) {
  3769. w.globals.memory.methodsToExec.push({
  3770. context: me,
  3771. id: anno.id ? anno.id : Utils.randomId(),
  3772. method: contextMethod,
  3773. label: 'addAnnotation',
  3774. params: params
  3775. });
  3776. }
  3777. return context;
  3778. }
  3779. }, {
  3780. key: "clearAnnotations",
  3781. value: function clearAnnotations(ctx) {
  3782. var w = ctx.w;
  3783. var annos = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations'); // annotations added externally should be cleared out too
  3784. w.globals.memory.methodsToExec.map(function (m, i) {
  3785. if (m.label === 'addText' || m.label === 'addAnnotation') {
  3786. w.globals.memory.methodsToExec.splice(i, 1);
  3787. }
  3788. });
  3789. annos = Utils.listToArray(annos); // delete the DOM elements
  3790. Array.prototype.forEach.call(annos, function (a) {
  3791. while (a.firstChild) {
  3792. a.removeChild(a.firstChild);
  3793. }
  3794. });
  3795. }
  3796. }, {
  3797. key: "removeAnnotation",
  3798. value: function removeAnnotation(ctx, id) {
  3799. var w = ctx.w;
  3800. var annos = w.globals.dom.baseEl.querySelectorAll(".".concat(id));
  3801. if (annos) {
  3802. w.globals.memory.methodsToExec.map(function (m, i) {
  3803. if (m.id === id) {
  3804. w.globals.memory.methodsToExec.splice(i, 1);
  3805. }
  3806. });
  3807. Array.prototype.forEach.call(annos, function (a) {
  3808. a.parentElement.removeChild(a);
  3809. });
  3810. }
  3811. }
  3812. }]);
  3813. return Annotations;
  3814. }();
  3815. /**
  3816. * ApexCharts Fill Class for setting fill options of the paths.
  3817. *
  3818. * @module Fill
  3819. **/
  3820. var Fill = /*#__PURE__*/function () {
  3821. function Fill(ctx) {
  3822. _classCallCheck(this, Fill);
  3823. this.ctx = ctx;
  3824. this.w = ctx.w;
  3825. this.opts = null;
  3826. this.seriesIndex = 0;
  3827. }
  3828. _createClass(Fill, [{
  3829. key: "clippedImgArea",
  3830. value: function clippedImgArea(params) {
  3831. var w = this.w;
  3832. var cnf = w.config;
  3833. var svgW = parseInt(w.globals.gridWidth, 10);
  3834. var svgH = parseInt(w.globals.gridHeight, 10);
  3835. var size = svgW > svgH ? svgW : svgH;
  3836. var fillImg = params.image;
  3837. var imgWidth = 0;
  3838. var imgHeight = 0;
  3839. if (typeof params.width === 'undefined' && typeof params.height === 'undefined') {
  3840. if (cnf.fill.image.width !== undefined && cnf.fill.image.height !== undefined) {
  3841. imgWidth = cnf.fill.image.width + 1;
  3842. imgHeight = cnf.fill.image.height;
  3843. } else {
  3844. imgWidth = size + 1;
  3845. imgHeight = size;
  3846. }
  3847. } else {
  3848. imgWidth = params.width;
  3849. imgHeight = params.height;
  3850. }
  3851. var elPattern = document.createElementNS(w.globals.SVGNS, 'pattern');
  3852. Graphics.setAttrs(elPattern, {
  3853. id: params.patternID,
  3854. patternUnits: params.patternUnits ? params.patternUnits : 'userSpaceOnUse',
  3855. width: imgWidth + 'px',
  3856. height: imgHeight + 'px'
  3857. });
  3858. var elImage = document.createElementNS(w.globals.SVGNS, 'image');
  3859. elPattern.appendChild(elImage);
  3860. elImage.setAttributeNS(window.SVG.xlink, 'href', fillImg);
  3861. Graphics.setAttrs(elImage, {
  3862. x: 0,
  3863. y: 0,
  3864. preserveAspectRatio: 'none',
  3865. width: imgWidth + 'px',
  3866. height: imgHeight + 'px'
  3867. });
  3868. elImage.style.opacity = params.opacity;
  3869. w.globals.dom.elDefs.node.appendChild(elPattern);
  3870. }
  3871. }, {
  3872. key: "getSeriesIndex",
  3873. value: function getSeriesIndex(opts) {
  3874. var w = this.w;
  3875. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap') {
  3876. this.seriesIndex = opts.seriesNumber;
  3877. } else {
  3878. this.seriesIndex = opts.seriesNumber % w.globals.series.length;
  3879. }
  3880. return this.seriesIndex;
  3881. }
  3882. }, {
  3883. key: "fillPath",
  3884. value: function fillPath(opts) {
  3885. var w = this.w;
  3886. this.opts = opts;
  3887. var cnf = this.w.config;
  3888. var pathFill;
  3889. var patternFill, gradientFill;
  3890. this.seriesIndex = this.getSeriesIndex(opts);
  3891. var fillColors = this.getFillColors();
  3892. var fillColor = fillColors[this.seriesIndex];
  3893. if (typeof fillColor === 'function') {
  3894. fillColor = fillColor({
  3895. seriesIndex: this.seriesIndex,
  3896. dataPointIndex: opts.dataPointIndex,
  3897. value: opts.value,
  3898. w: w
  3899. });
  3900. }
  3901. var fillType = this.getFillType(this.seriesIndex);
  3902. var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[this.seriesIndex] : cnf.fill.opacity;
  3903. var defaultColor = fillColor;
  3904. if (opts.color) {
  3905. fillColor = opts.color;
  3906. }
  3907. if (fillColor.indexOf('rgb') === -1) {
  3908. if (fillColor.length < 9) {
  3909. // if the hex contains alpha and is of 9 digit, skip the opacity
  3910. defaultColor = Utils.hexToRgba(fillColor, fillOpacity);
  3911. }
  3912. } else {
  3913. if (fillColor.indexOf('rgba') > -1) {
  3914. fillOpacity = Utils.getOpacityFromRGBA(fillColor);
  3915. }
  3916. }
  3917. if (opts.opacity) fillOpacity = opts.opacity;
  3918. if (fillType === 'pattern') {
  3919. patternFill = this.handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor);
  3920. }
  3921. if (fillType === 'gradient') {
  3922. gradientFill = this.handleGradientFill(fillColor, fillOpacity, this.seriesIndex);
  3923. }
  3924. if (fillType === 'image') {
  3925. var imgSrc = cnf.fill.image.src;
  3926. var patternID = opts.patternID ? opts.patternID : '';
  3927. this.clippedImgArea({
  3928. opacity: fillOpacity,
  3929. image: Array.isArray(imgSrc) ? opts.seriesNumber < imgSrc.length ? imgSrc[opts.seriesNumber] : imgSrc[0] : imgSrc,
  3930. width: opts.width ? opts.width : undefined,
  3931. height: opts.height ? opts.height : undefined,
  3932. patternUnits: opts.patternUnits,
  3933. patternID: "pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID)
  3934. });
  3935. pathFill = "url(#pattern".concat(w.globals.cuid).concat(opts.seriesNumber + 1).concat(patternID, ")");
  3936. } else if (fillType === 'gradient') {
  3937. pathFill = gradientFill;
  3938. } else if (fillType === 'pattern') {
  3939. pathFill = patternFill;
  3940. } else {
  3941. pathFill = defaultColor;
  3942. } // override pattern/gradient if opts.solid is true
  3943. if (opts.solid) {
  3944. pathFill = defaultColor;
  3945. }
  3946. return pathFill;
  3947. }
  3948. }, {
  3949. key: "getFillType",
  3950. value: function getFillType(seriesIndex) {
  3951. var w = this.w;
  3952. if (Array.isArray(w.config.fill.type)) {
  3953. return w.config.fill.type[seriesIndex];
  3954. } else {
  3955. return w.config.fill.type;
  3956. }
  3957. }
  3958. }, {
  3959. key: "getFillColors",
  3960. value: function getFillColors() {
  3961. var w = this.w;
  3962. var cnf = w.config;
  3963. var opts = this.opts;
  3964. var fillColors = [];
  3965. if (w.globals.comboCharts) {
  3966. if (w.config.series[this.seriesIndex].type === 'line') {
  3967. if (w.globals.stroke.colors instanceof Array) {
  3968. fillColors = w.globals.stroke.colors;
  3969. } else {
  3970. fillColors.push(w.globals.stroke.colors);
  3971. }
  3972. } else {
  3973. if (w.globals.fill.colors instanceof Array) {
  3974. fillColors = w.globals.fill.colors;
  3975. } else {
  3976. fillColors.push(w.globals.fill.colors);
  3977. }
  3978. }
  3979. } else {
  3980. if (cnf.chart.type === 'line') {
  3981. if (w.globals.stroke.colors instanceof Array) {
  3982. fillColors = w.globals.stroke.colors;
  3983. } else {
  3984. fillColors.push(w.globals.stroke.colors);
  3985. }
  3986. } else {
  3987. if (w.globals.fill.colors instanceof Array) {
  3988. fillColors = w.globals.fill.colors;
  3989. } else {
  3990. fillColors.push(w.globals.fill.colors);
  3991. }
  3992. }
  3993. } // colors passed in arguments
  3994. if (typeof opts.fillColors !== 'undefined') {
  3995. fillColors = [];
  3996. if (opts.fillColors instanceof Array) {
  3997. fillColors = opts.fillColors.slice();
  3998. } else {
  3999. fillColors.push(opts.fillColors);
  4000. }
  4001. }
  4002. return fillColors;
  4003. }
  4004. }, {
  4005. key: "handlePatternFill",
  4006. value: function handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor) {
  4007. var cnf = this.w.config;
  4008. var opts = this.opts;
  4009. var graphics = new Graphics(this.ctx);
  4010. 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;
  4011. var patternLineColor = fillColor;
  4012. if (cnf.fill.pattern.style instanceof Array) {
  4013. if (typeof cnf.fill.pattern.style[opts.seriesNumber] !== 'undefined') {
  4014. var pf = graphics.drawPattern(cnf.fill.pattern.style[opts.seriesNumber], cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  4015. patternFill = pf;
  4016. } else {
  4017. patternFill = defaultColor;
  4018. }
  4019. } else {
  4020. patternFill = graphics.drawPattern(cnf.fill.pattern.style, cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity);
  4021. }
  4022. return patternFill;
  4023. }
  4024. }, {
  4025. key: "handleGradientFill",
  4026. value: function handleGradientFill(fillColor, fillOpacity, i) {
  4027. var cnf = this.w.config;
  4028. var opts = this.opts;
  4029. var graphics = new Graphics(this.ctx);
  4030. var utils = new Utils();
  4031. var type = cnf.fill.gradient.type;
  4032. var gradientFrom = fillColor;
  4033. var gradientTo;
  4034. var opacityFrom = cnf.fill.gradient.opacityFrom === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityFrom) ? cnf.fill.gradient.opacityFrom[i] : cnf.fill.gradient.opacityFrom;
  4035. if (gradientFrom.indexOf('rgba') > -1) {
  4036. opacityFrom = Utils.getOpacityFromRGBA(gradientFrom);
  4037. }
  4038. var opacityTo = cnf.fill.gradient.opacityTo === undefined ? fillOpacity : Array.isArray(cnf.fill.gradient.opacityTo) ? cnf.fill.gradient.opacityTo[i] : cnf.fill.gradient.opacityTo;
  4039. if (cnf.fill.gradient.gradientToColors === undefined || cnf.fill.gradient.gradientToColors.length === 0) {
  4040. if (cnf.fill.gradient.shade === 'dark') {
  4041. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity) * -1, fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
  4042. } else {
  4043. gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity), fillColor.indexOf('rgb') > -1 ? Utils.rgb2hex(fillColor) : fillColor);
  4044. }
  4045. } else {
  4046. var gToColor = cnf.fill.gradient.gradientToColors[opts.seriesNumber];
  4047. gradientTo = gToColor;
  4048. if (gToColor.indexOf('rgba') > -1) {
  4049. opacityTo = Utils.getOpacityFromRGBA(gToColor);
  4050. }
  4051. }
  4052. if (cnf.fill.gradient.inverseColors) {
  4053. var t = gradientFrom;
  4054. gradientFrom = gradientTo;
  4055. gradientTo = t;
  4056. }
  4057. if (gradientFrom.indexOf('rgb') > -1) {
  4058. gradientFrom = Utils.rgb2hex(gradientFrom);
  4059. }
  4060. if (gradientTo.indexOf('rgb') > -1) {
  4061. gradientTo = Utils.rgb2hex(gradientTo);
  4062. }
  4063. return graphics.drawGradient(type, gradientFrom, gradientTo, opacityFrom, opacityTo, opts.size, cnf.fill.gradient.stops, cnf.fill.gradient.colorStops, i);
  4064. }
  4065. }]);
  4066. return Fill;
  4067. }();
  4068. /**
  4069. * ApexCharts Markers Class for drawing points on y values in axes charts.
  4070. *
  4071. * @module Markers
  4072. **/
  4073. var Markers = /*#__PURE__*/function () {
  4074. function Markers(ctx, opts) {
  4075. _classCallCheck(this, Markers);
  4076. this.ctx = ctx;
  4077. this.w = ctx.w;
  4078. }
  4079. _createClass(Markers, [{
  4080. key: "setGlobalMarkerSize",
  4081. value: function setGlobalMarkerSize() {
  4082. var w = this.w;
  4083. w.globals.markers.size = Array.isArray(w.config.markers.size) ? w.config.markers.size : [w.config.markers.size];
  4084. if (w.globals.markers.size.length > 0) {
  4085. if (w.globals.markers.size.length < w.globals.series.length + 1) {
  4086. for (var i = 0; i <= w.globals.series.length; i++) {
  4087. if (typeof w.globals.markers.size[i] === 'undefined') {
  4088. w.globals.markers.size.push(w.globals.markers.size[0]);
  4089. }
  4090. }
  4091. }
  4092. } else {
  4093. w.globals.markers.size = w.config.series.map(function (s) {
  4094. return w.config.markers.size;
  4095. });
  4096. }
  4097. }
  4098. }, {
  4099. key: "plotChartMarkers",
  4100. value: function plotChartMarkers(pointsPos, seriesIndex, j, pSize) {
  4101. var alwaysDrawMarker = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  4102. var w = this.w;
  4103. var i = seriesIndex;
  4104. var p = pointsPos;
  4105. var elPointsWrap = null;
  4106. var graphics = new Graphics(this.ctx);
  4107. var point;
  4108. if (w.globals.markers.size[seriesIndex] > 0 || alwaysDrawMarker) {
  4109. elPointsWrap = graphics.group({
  4110. class: alwaysDrawMarker ? '' : 'apexcharts-series-markers'
  4111. });
  4112. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  4113. }
  4114. if (p.x instanceof Array) {
  4115. for (var q = 0; q < p.x.length; q++) {
  4116. var dataPointIndex = j; // a small hack as we have 2 points for the first val to connect it
  4117. if (j === 1 && q === 0) dataPointIndex = 0;
  4118. if (j === 1 && q === 1) dataPointIndex = 1;
  4119. var PointClasses = 'apexcharts-marker';
  4120. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  4121. PointClasses += ' no-pointer-events';
  4122. }
  4123. var shouldMarkerDraw = Array.isArray(w.config.markers.size) ? w.globals.markers.size[seriesIndex] > 0 : w.config.markers.size > 0;
  4124. if (shouldMarkerDraw || alwaysDrawMarker) {
  4125. if (Utils.isNumber(p.y[q])) {
  4126. PointClasses += " w".concat(Utils.randomId());
  4127. } else {
  4128. PointClasses = 'apexcharts-nullpoint';
  4129. }
  4130. var opts = this.getMarkerConfig(PointClasses, seriesIndex, dataPointIndex);
  4131. if (w.config.series[i].data[j]) {
  4132. if (w.config.series[i].data[j].fillColor) {
  4133. opts.pointFillColor = w.config.series[i].data[j].fillColor;
  4134. }
  4135. if (w.config.series[i].data[j].strokeColor) {
  4136. opts.pointStrokeColor = w.config.series[i].data[j].strokeColor;
  4137. }
  4138. }
  4139. if (pSize) {
  4140. opts.pSize = pSize;
  4141. }
  4142. point = graphics.drawMarker(p.x[q], p.y[q], opts);
  4143. point.attr('rel', dataPointIndex);
  4144. point.attr('j', dataPointIndex);
  4145. point.attr('index', seriesIndex);
  4146. point.node.setAttribute('default-marker-size', opts.pSize);
  4147. var filters = new Filters(this.ctx);
  4148. filters.setSelectionFilter(point, seriesIndex, dataPointIndex);
  4149. this.addEvents(point);
  4150. if (elPointsWrap) {
  4151. elPointsWrap.add(point);
  4152. }
  4153. } else {
  4154. // dynamic array creation - multidimensional
  4155. if (typeof w.globals.pointsArray[seriesIndex] === 'undefined') w.globals.pointsArray[seriesIndex] = [];
  4156. w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]);
  4157. }
  4158. }
  4159. }
  4160. return elPointsWrap;
  4161. }
  4162. }, {
  4163. key: "getMarkerConfig",
  4164. value: function getMarkerConfig(cssClass, seriesIndex) {
  4165. var dataPointIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4166. var w = this.w;
  4167. var pStyle = this.getMarkerStyle(seriesIndex);
  4168. var pSize = w.globals.markers.size[seriesIndex];
  4169. var m = w.config.markers; // discrete markers is an option where user can specify a particular marker with different size and color
  4170. if (dataPointIndex !== null && m.discrete.length) {
  4171. m.discrete.map(function (marker) {
  4172. if (marker.seriesIndex === seriesIndex && marker.dataPointIndex === dataPointIndex) {
  4173. pStyle.pointStrokeColor = marker.strokeColor;
  4174. pStyle.pointFillColor = marker.fillColor;
  4175. pSize = marker.size;
  4176. }
  4177. });
  4178. }
  4179. return {
  4180. pSize: pSize,
  4181. pRadius: m.radius,
  4182. pWidth: m.strokeWidth instanceof Array ? m.strokeWidth[seriesIndex] : m.strokeWidth,
  4183. pointStrokeColor: pStyle.pointStrokeColor,
  4184. pointFillColor: pStyle.pointFillColor,
  4185. shape: m.shape instanceof Array ? m.shape[seriesIndex] : m.shape,
  4186. class: cssClass,
  4187. pointStrokeOpacity: m.strokeOpacity instanceof Array ? m.strokeOpacity[seriesIndex] : m.strokeOpacity,
  4188. pointStrokeDashArray: m.strokeDashArray instanceof Array ? m.strokeDashArray[seriesIndex] : m.strokeDashArray,
  4189. pointFillOpacity: m.fillOpacity instanceof Array ? m.fillOpacity[seriesIndex] : m.fillOpacity,
  4190. seriesIndex: seriesIndex
  4191. };
  4192. }
  4193. }, {
  4194. key: "addEvents",
  4195. value: function addEvents(circle) {
  4196. var w = this.w;
  4197. var graphics = new Graphics(this.ctx);
  4198. circle.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this.ctx, circle));
  4199. circle.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this.ctx, circle));
  4200. circle.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this.ctx, circle));
  4201. circle.node.addEventListener('click', w.config.markers.onClick);
  4202. circle.node.addEventListener('dblclick', w.config.markers.onDblClick);
  4203. circle.node.addEventListener('touchstart', graphics.pathMouseDown.bind(this.ctx, circle), {
  4204. passive: true
  4205. });
  4206. }
  4207. }, {
  4208. key: "getMarkerStyle",
  4209. value: function getMarkerStyle(seriesIndex) {
  4210. var w = this.w;
  4211. var colors = w.globals.markers.colors;
  4212. var strokeColors = w.config.markers.strokeColor || w.config.markers.strokeColors;
  4213. var pointStrokeColor = strokeColors instanceof Array ? strokeColors[seriesIndex] : strokeColors;
  4214. var pointFillColor = colors instanceof Array ? colors[seriesIndex] : colors;
  4215. return {
  4216. pointStrokeColor: pointStrokeColor,
  4217. pointFillColor: pointFillColor
  4218. };
  4219. }
  4220. }]);
  4221. return Markers;
  4222. }();
  4223. /**
  4224. * ApexCharts Scatter Class.
  4225. * This Class also handles bubbles chart as currently there is no major difference in drawing them,
  4226. * @module Scatter
  4227. **/
  4228. var Scatter = /*#__PURE__*/function () {
  4229. function Scatter(ctx) {
  4230. _classCallCheck(this, Scatter);
  4231. this.ctx = ctx;
  4232. this.w = ctx.w;
  4233. this.initialAnim = this.w.config.chart.animations.enabled;
  4234. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  4235. }
  4236. _createClass(Scatter, [{
  4237. key: "draw",
  4238. value: function draw(elSeries, j, opts) {
  4239. var w = this.w;
  4240. var graphics = new Graphics(this.ctx);
  4241. var realIndex = opts.realIndex;
  4242. var pointsPos = opts.pointsPos;
  4243. var zRatio = opts.zRatio;
  4244. var elPointsMain = opts.elParent;
  4245. var elPointsWrap = graphics.group({
  4246. class: "apexcharts-series-markers apexcharts-series-".concat(w.config.chart.type)
  4247. });
  4248. elPointsWrap.attr('clip-path', "url(#gridRectMarkerMask".concat(w.globals.cuid, ")"));
  4249. if (pointsPos.x instanceof Array) {
  4250. for (var q = 0; q < pointsPos.x.length; q++) {
  4251. var dataPointIndex = j + 1;
  4252. var shouldDraw = true; // a small hack as we have 2 points for the first val to connect it
  4253. if (j === 0 && q === 0) dataPointIndex = 0;
  4254. if (j === 0 && q === 1) dataPointIndex = 1;
  4255. var radius = 0;
  4256. var finishRadius = w.globals.markers.size[realIndex];
  4257. if (zRatio !== Infinity) {
  4258. // means we have a bubble
  4259. finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] / zRatio;
  4260. var bubble = w.config.plotOptions.bubble;
  4261. if (bubble.minBubbleRadius && finishRadius < bubble.minBubbleRadius) {
  4262. finishRadius = bubble.minBubbleRadius;
  4263. }
  4264. if (bubble.maxBubbleRadius && finishRadius > bubble.maxBubbleRadius) {
  4265. finishRadius = bubble.maxBubbleRadius;
  4266. }
  4267. }
  4268. if (!w.config.chart.animations.enabled) {
  4269. radius = finishRadius;
  4270. }
  4271. var x = pointsPos.x[q];
  4272. var y = pointsPos.y[q];
  4273. radius = radius || 0;
  4274. if (y === null || typeof w.globals.series[realIndex][dataPointIndex] === 'undefined') {
  4275. shouldDraw = false;
  4276. }
  4277. if (shouldDraw) {
  4278. var circle = this.drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j);
  4279. elPointsWrap.add(circle);
  4280. }
  4281. elPointsMain.add(elPointsWrap);
  4282. }
  4283. }
  4284. }
  4285. }, {
  4286. key: "drawPoint",
  4287. value: function drawPoint(x, y, radius, finishRadius, realIndex, dataPointIndex, j) {
  4288. var w = this.w;
  4289. var i = realIndex;
  4290. var anim = new Animations(this.ctx);
  4291. var filters = new Filters(this.ctx);
  4292. var fill = new Fill(this.ctx);
  4293. var markers = new Markers(this.ctx);
  4294. var graphics = new Graphics(this.ctx);
  4295. var markerConfig = markers.getMarkerConfig('apexcharts-marker', i);
  4296. var pathFillCircle = fill.fillPath({
  4297. seriesNumber: realIndex,
  4298. dataPointIndex: dataPointIndex,
  4299. patternUnits: 'objectBoundingBox',
  4300. value: w.globals.series[realIndex][j]
  4301. });
  4302. var circle = graphics.drawCircle(radius);
  4303. if (w.config.series[i].data[dataPointIndex]) {
  4304. if (w.config.series[i].data[dataPointIndex].fillColor) {
  4305. pathFillCircle = w.config.series[i].data[dataPointIndex].fillColor;
  4306. }
  4307. }
  4308. circle.attr({
  4309. cx: x,
  4310. cy: y,
  4311. fill: pathFillCircle,
  4312. stroke: markerConfig.pointStrokeColor,
  4313. 'stroke-width': markerConfig.pWidth,
  4314. 'stroke-dasharray': markerConfig.pointStrokeDashArray,
  4315. 'stroke-opacity': markerConfig.pointStrokeOpacity
  4316. });
  4317. if (w.config.chart.dropShadow.enabled) {
  4318. var dropShadow = w.config.chart.dropShadow;
  4319. filters.dropShadow(circle, dropShadow, realIndex);
  4320. }
  4321. if (this.initialAnim && !w.globals.dataChanged) {
  4322. var speed = 1;
  4323. if (!w.globals.resized) {
  4324. speed = w.config.chart.animations.speed;
  4325. }
  4326. anim.animateCircleRadius(circle, 0, finishRadius, speed, w.globals.easing, function () {
  4327. window.setTimeout(function () {
  4328. anim.animationCompleted(circle);
  4329. }, 100);
  4330. });
  4331. }
  4332. if (w.globals.dataChanged) {
  4333. if (this.dynamicAnim) {
  4334. var _speed = w.config.chart.animations.dynamicAnimation.speed;
  4335. var prevX, prevY, prevR;
  4336. var prevPathJ = null;
  4337. prevPathJ = w.globals.previousPaths[realIndex] && w.globals.previousPaths[realIndex][j];
  4338. if (typeof prevPathJ !== 'undefined' && prevPathJ !== null) {
  4339. // series containing less elements will ignore these values and revert to 0
  4340. prevX = prevPathJ.x;
  4341. prevY = prevPathJ.y;
  4342. prevR = typeof prevPathJ.r !== 'undefined' ? prevPathJ.r : finishRadius;
  4343. }
  4344. for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) {
  4345. if (w.globals.collapsedSeries[cs].index === realIndex) {
  4346. _speed = 1;
  4347. finishRadius = 0;
  4348. }
  4349. }
  4350. if (x === 0 && y === 0) finishRadius = 0;
  4351. anim.animateCircle(circle, {
  4352. cx: prevX,
  4353. cy: prevY,
  4354. r: prevR
  4355. }, {
  4356. cx: x,
  4357. cy: y,
  4358. r: finishRadius
  4359. }, _speed, w.globals.easing);
  4360. } else {
  4361. circle.attr({
  4362. r: finishRadius
  4363. });
  4364. }
  4365. }
  4366. circle.attr({
  4367. rel: dataPointIndex,
  4368. j: dataPointIndex,
  4369. index: realIndex,
  4370. 'default-marker-size': finishRadius
  4371. });
  4372. filters.setSelectionFilter(circle, realIndex, dataPointIndex);
  4373. markers.addEvents(circle);
  4374. circle.node.classList.add('apexcharts-marker');
  4375. return circle;
  4376. }
  4377. }, {
  4378. key: "centerTextInBubble",
  4379. value: function centerTextInBubble(y) {
  4380. var w = this.w;
  4381. y = y + parseInt(w.config.dataLabels.style.fontSize, 10) / 4;
  4382. return {
  4383. y: y
  4384. };
  4385. }
  4386. }]);
  4387. return Scatter;
  4388. }();
  4389. /**
  4390. * ApexCharts DataLabels Class for drawing dataLabels on Axes based Charts.
  4391. *
  4392. * @module DataLabels
  4393. **/
  4394. var DataLabels = /*#__PURE__*/function () {
  4395. function DataLabels(ctx) {
  4396. _classCallCheck(this, DataLabels);
  4397. this.ctx = ctx;
  4398. this.w = ctx.w;
  4399. } // 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
  4400. // Also, when datalabels exceeds the drawable area and get clipped off, we need to adjust and move some pixels to make them visible again
  4401. _createClass(DataLabels, [{
  4402. key: "dataLabelsCorrection",
  4403. value: function dataLabelsCorrection(x, y, val, i, dataPointIndex, alwaysDrawDataLabel, fontSize) {
  4404. var w = this.w;
  4405. var graphics = new Graphics(this.ctx);
  4406. var drawnextLabel = false; //
  4407. var textRects = graphics.getTextRects(val, fontSize);
  4408. var width = textRects.width;
  4409. var height = textRects.height; // first value in series, so push an empty array
  4410. if (typeof w.globals.dataLabelsRects[i] === 'undefined') w.globals.dataLabelsRects[i] = []; // then start pushing actual rects in that sub-array
  4411. w.globals.dataLabelsRects[i].push({
  4412. x: x,
  4413. y: y,
  4414. width: width,
  4415. height: height
  4416. });
  4417. var len = w.globals.dataLabelsRects[i].length - 2;
  4418. var lastDrawnIndex = typeof w.globals.lastDrawnDataLabelsIndexes[i] !== 'undefined' ? w.globals.lastDrawnDataLabelsIndexes[i][w.globals.lastDrawnDataLabelsIndexes[i].length - 1] : 0;
  4419. if (typeof w.globals.dataLabelsRects[i][len] !== 'undefined') {
  4420. var lastDataLabelRect = w.globals.dataLabelsRects[i][lastDrawnIndex];
  4421. if ( // next label forward and x not intersecting
  4422. x > lastDataLabelRect.x + lastDataLabelRect.width + 2 || y > lastDataLabelRect.y + lastDataLabelRect.height + 2 || x + width < lastDataLabelRect.x // next label is going to be drawn backwards
  4423. ) {
  4424. // the 2 indexes don't override, so OK to draw next label
  4425. drawnextLabel = true;
  4426. }
  4427. }
  4428. if (dataPointIndex === 0 || alwaysDrawDataLabel) {
  4429. drawnextLabel = true;
  4430. }
  4431. return {
  4432. x: x,
  4433. y: y,
  4434. textRects: textRects,
  4435. drawnextLabel: drawnextLabel
  4436. };
  4437. }
  4438. }, {
  4439. key: "drawDataLabel",
  4440. value: function drawDataLabel(pos, i, j) {
  4441. var _this = this;
  4442. var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
  4443. // this method handles line, area, bubble, scatter charts as those charts contains markers/points which have pre-defined x/y positions
  4444. // all other charts like radar / bars / heatmaps will define their own drawDataLabel routine
  4445. var w = this.w;
  4446. var graphics = new Graphics(this.ctx);
  4447. var dataLabelsConfig = w.config.dataLabels;
  4448. var x = 0;
  4449. var y = 0;
  4450. var dataPointIndex = j;
  4451. var elDataLabelsWrap = null;
  4452. if (!dataLabelsConfig.enabled || pos.x instanceof Array !== true) {
  4453. return elDataLabelsWrap;
  4454. }
  4455. elDataLabelsWrap = graphics.group({
  4456. class: 'apexcharts-data-labels'
  4457. });
  4458. for (var q = 0; q < pos.x.length; q++) {
  4459. x = pos.x[q] + dataLabelsConfig.offsetX;
  4460. y = pos.y[q] + dataLabelsConfig.offsetY + strokeWidth;
  4461. if (!isNaN(x)) {
  4462. // a small hack as we have 2 points for the first val to connect it
  4463. if (j === 1 && q === 0) dataPointIndex = 0;
  4464. if (j === 1 && q === 1) dataPointIndex = 1;
  4465. var val = w.globals.series[i][dataPointIndex];
  4466. var text = '';
  4467. var getText = function getText(v) {
  4468. return w.config.dataLabels.formatter(v, {
  4469. ctx: _this.ctx,
  4470. seriesIndex: i,
  4471. dataPointIndex: dataPointIndex,
  4472. w: w
  4473. });
  4474. };
  4475. if (w.config.chart.type === 'bubble') {
  4476. val = w.globals.seriesZ[i][dataPointIndex];
  4477. text = getText(val);
  4478. y = pos.y[q];
  4479. var scatter = new Scatter(this.ctx);
  4480. var centerTextInBubbleCoords = scatter.centerTextInBubble(y, i, dataPointIndex);
  4481. y = centerTextInBubbleCoords.y;
  4482. } else {
  4483. if (typeof val !== 'undefined') {
  4484. text = getText(val);
  4485. }
  4486. }
  4487. this.plotDataLabelsText({
  4488. x: x,
  4489. y: y,
  4490. text: text,
  4491. i: i,
  4492. j: dataPointIndex,
  4493. parent: elDataLabelsWrap,
  4494. offsetCorrection: true,
  4495. dataLabelsConfig: w.config.dataLabels
  4496. });
  4497. }
  4498. }
  4499. return elDataLabelsWrap;
  4500. }
  4501. }, {
  4502. key: "plotDataLabelsText",
  4503. value: function plotDataLabelsText(opts) {
  4504. var w = this.w;
  4505. var graphics = new Graphics(this.ctx);
  4506. var x = opts.x,
  4507. y = opts.y,
  4508. i = opts.i,
  4509. j = opts.j,
  4510. text = opts.text,
  4511. textAnchor = opts.textAnchor,
  4512. parent = opts.parent,
  4513. dataLabelsConfig = opts.dataLabelsConfig,
  4514. color = opts.color,
  4515. alwaysDrawDataLabel = opts.alwaysDrawDataLabel,
  4516. offsetCorrection = opts.offsetCorrection;
  4517. if (Array.isArray(w.config.dataLabels.enabledOnSeries)) {
  4518. if (w.config.dataLabels.enabledOnSeries.indexOf(i) < 0) {
  4519. return;
  4520. }
  4521. }
  4522. var correctedLabels = {
  4523. x: x,
  4524. y: y,
  4525. drawnextLabel: true
  4526. };
  4527. if (offsetCorrection) {
  4528. correctedLabels = this.dataLabelsCorrection(x, y, text, i, j, alwaysDrawDataLabel, parseInt(dataLabelsConfig.style.fontSize, 10));
  4529. } // when zoomed, we don't need to correct labels offsets,
  4530. // but if normally, labels get cropped, correct them
  4531. if (!w.globals.zoomed) {
  4532. x = correctedLabels.x;
  4533. y = correctedLabels.y;
  4534. }
  4535. if (correctedLabels.textRects) {
  4536. if (x + correctedLabels.textRects.width < -20 || x > w.globals.gridWidth + 20) {
  4537. // datalabels fall outside drawing area, so draw a blank label
  4538. text = '';
  4539. }
  4540. }
  4541. var dataLabelColor = w.globals.dataLabels.style.colors[i];
  4542. if ((w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && w.config.plotOptions.bar.distributed || w.config.dataLabels.distributed) {
  4543. dataLabelColor = w.globals.dataLabels.style.colors[j];
  4544. }
  4545. if (color) {
  4546. dataLabelColor = color;
  4547. }
  4548. var offX = dataLabelsConfig.offsetX;
  4549. var offY = dataLabelsConfig.offsetY;
  4550. if (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') {
  4551. // for certain chart types, we handle offsets while calculating datalabels pos
  4552. // why? because bars/column may have negative values and based on that
  4553. // offsets becomes reversed
  4554. offX = 0;
  4555. offY = 0;
  4556. }
  4557. if (correctedLabels.drawnextLabel) {
  4558. var dataLabelText = graphics.drawText({
  4559. width: 100,
  4560. height: parseInt(dataLabelsConfig.style.fontSize, 10),
  4561. x: x + offX,
  4562. y: y + offY,
  4563. foreColor: dataLabelColor,
  4564. textAnchor: textAnchor || dataLabelsConfig.textAnchor,
  4565. text: text,
  4566. fontSize: dataLabelsConfig.style.fontSize,
  4567. fontFamily: dataLabelsConfig.style.fontFamily,
  4568. fontWeight: dataLabelsConfig.style.fontWeight || 'normal'
  4569. });
  4570. dataLabelText.attr({
  4571. class: 'apexcharts-datalabel',
  4572. cx: x,
  4573. cy: y
  4574. });
  4575. if (dataLabelsConfig.dropShadow.enabled) {
  4576. var textShadow = dataLabelsConfig.dropShadow;
  4577. var filters = new Filters(this.ctx);
  4578. filters.dropShadow(dataLabelText, textShadow);
  4579. }
  4580. parent.add(dataLabelText);
  4581. if (typeof w.globals.lastDrawnDataLabelsIndexes[i] === 'undefined') {
  4582. w.globals.lastDrawnDataLabelsIndexes[i] = [];
  4583. }
  4584. w.globals.lastDrawnDataLabelsIndexes[i].push(j);
  4585. }
  4586. }
  4587. }, {
  4588. key: "addBackgroundToDataLabel",
  4589. value: function addBackgroundToDataLabel(el, coords) {
  4590. var w = this.w;
  4591. var bCnf = w.config.dataLabels.background;
  4592. var paddingH = bCnf.padding;
  4593. var paddingV = bCnf.padding / 2;
  4594. var width = coords.width;
  4595. var height = coords.height;
  4596. var graphics = new Graphics(this.ctx);
  4597. 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);
  4598. if (bCnf.dropShadow.enabled) {
  4599. var filters = new Filters(this.ctx);
  4600. filters.dropShadow(elRect, bCnf.dropShadow);
  4601. }
  4602. return elRect;
  4603. }
  4604. }, {
  4605. key: "dataLabelsBackground",
  4606. value: function dataLabelsBackground() {
  4607. var w = this.w;
  4608. if (w.config.chart.type === 'bubble') return;
  4609. var elDataLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-datalabels text');
  4610. for (var i = 0; i < elDataLabels.length; i++) {
  4611. var el = elDataLabels[i];
  4612. var coords = el.getBBox();
  4613. var elRect = null;
  4614. if (coords.width && coords.height) {
  4615. elRect = this.addBackgroundToDataLabel(el, coords);
  4616. }
  4617. if (elRect) {
  4618. el.parentNode.insertBefore(elRect.node, el);
  4619. var background = el.getAttribute('fill');
  4620. var shouldAnim = w.config.chart.animations.enabled && !w.globals.resized && !w.globals.dataChanged;
  4621. if (shouldAnim) {
  4622. elRect.animate().attr({
  4623. fill: background
  4624. });
  4625. } else {
  4626. elRect.attr({
  4627. fill: background
  4628. });
  4629. }
  4630. el.setAttribute('fill', w.config.dataLabels.background.foreColor);
  4631. }
  4632. }
  4633. }
  4634. }, {
  4635. key: "bringForward",
  4636. value: function bringForward() {
  4637. var w = this.w;
  4638. var elDataLabelsNodes = w.globals.dom.baseEl.getElementsByClassName('apexcharts-datalabels');
  4639. var elSeries = w.globals.dom.baseEl.querySelector('.apexcharts-plot-series:last-child');
  4640. for (var i = 0; i < elDataLabelsNodes.length; i++) {
  4641. if (elSeries) {
  4642. elSeries.insertBefore(elDataLabelsNodes[i], elSeries.nextSibling);
  4643. }
  4644. }
  4645. }
  4646. }]);
  4647. return DataLabels;
  4648. }();
  4649. var BarDataLabels = /*#__PURE__*/function () {
  4650. function BarDataLabels(barCtx) {
  4651. _classCallCheck(this, BarDataLabels);
  4652. this.w = barCtx.w;
  4653. this.barCtx = barCtx;
  4654. }
  4655. /** handleBarDataLabels is used to calculate the positions for the data-labels
  4656. * It also sets the element's data attr for bars and calls drawCalculatedBarDataLabels()
  4657. * After calculating, it also calls the function to draw data labels
  4658. * @memberof Bar
  4659. * @param {object} {barProps} most of the bar properties used throughout the bar
  4660. * drawing function
  4661. * @return {object} dataLabels node-element which you can append later
  4662. **/
  4663. _createClass(BarDataLabels, [{
  4664. key: "handleBarDataLabels",
  4665. value: function handleBarDataLabels(opts) {
  4666. var x = opts.x,
  4667. y = opts.y,
  4668. y1 = opts.y1,
  4669. y2 = opts.y2,
  4670. i = opts.i,
  4671. j = opts.j,
  4672. realIndex = opts.realIndex,
  4673. series = opts.series,
  4674. barHeight = opts.barHeight,
  4675. barWidth = opts.barWidth,
  4676. barYPosition = opts.barYPosition,
  4677. visibleSeries = opts.visibleSeries,
  4678. renderedPath = opts.renderedPath;
  4679. var w = this.w;
  4680. var graphics = new Graphics(this.barCtx.ctx);
  4681. var strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  4682. var bcx = x + parseFloat(barWidth * visibleSeries);
  4683. var bcy = y + parseFloat(barHeight * visibleSeries);
  4684. if (w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  4685. bcx = x + parseFloat(barWidth * (visibleSeries + 1));
  4686. bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth;
  4687. }
  4688. var dataLabels = null;
  4689. var dataLabelsX = x;
  4690. var dataLabelsY = y;
  4691. var dataLabelsPos = {};
  4692. var dataLabelsConfig = w.config.dataLabels;
  4693. var barDataLabelsConfig = this.barCtx.barOptions.dataLabels;
  4694. if (typeof barYPosition !== 'undefined' && this.barCtx.isTimelineBar) {
  4695. bcy = barYPosition;
  4696. dataLabelsY = barYPosition;
  4697. }
  4698. var offX = dataLabelsConfig.offsetX;
  4699. var offY = dataLabelsConfig.offsetY;
  4700. var textRects = {
  4701. width: 0,
  4702. height: 0
  4703. };
  4704. if (w.config.dataLabels.enabled) {
  4705. var longestStr = String(w.globals.minY).length > String(w.globals.maxY).length ? w.globals.minY : w.globals.maxY;
  4706. textRects = graphics.getTextRects(w.globals.yLabelFormatters[0](longestStr), parseFloat(dataLabelsConfig.style.fontSize));
  4707. }
  4708. var params = {
  4709. x: x,
  4710. y: y,
  4711. i: i,
  4712. j: j,
  4713. renderedPath: renderedPath,
  4714. bcx: bcx,
  4715. bcy: bcy,
  4716. barHeight: barHeight,
  4717. barWidth: barWidth,
  4718. textRects: textRects,
  4719. strokeWidth: strokeWidth,
  4720. dataLabelsX: dataLabelsX,
  4721. dataLabelsY: dataLabelsY,
  4722. barDataLabelsConfig: barDataLabelsConfig,
  4723. offX: offX,
  4724. offY: offY
  4725. };
  4726. if (this.barCtx.isHorizontal) {
  4727. dataLabelsPos = this.calculateBarsDataLabelsPosition(params);
  4728. } else {
  4729. dataLabelsPos = this.calculateColumnsDataLabelsPosition(params);
  4730. }
  4731. renderedPath.attr({
  4732. cy: dataLabelsPos.bcy,
  4733. cx: dataLabelsPos.bcx,
  4734. j: j,
  4735. val: series[i][j],
  4736. barHeight: barHeight,
  4737. barWidth: barWidth
  4738. });
  4739. dataLabels = this.drawCalculatedDataLabels({
  4740. x: dataLabelsPos.dataLabelsX,
  4741. y: dataLabelsPos.dataLabelsY,
  4742. val: this.barCtx.isTimelineBar ? [y1, y2] : series[i][j],
  4743. i: realIndex,
  4744. j: j,
  4745. barWidth: barWidth,
  4746. barHeight: barHeight,
  4747. textRects: textRects,
  4748. dataLabelsConfig: dataLabelsConfig
  4749. });
  4750. return dataLabels;
  4751. }
  4752. }, {
  4753. key: "calculateColumnsDataLabelsPosition",
  4754. value: function calculateColumnsDataLabelsPosition(opts) {
  4755. var w = this.w;
  4756. var i = opts.i,
  4757. j = opts.j,
  4758. y = opts.y,
  4759. bcx = opts.bcx,
  4760. barWidth = opts.barWidth,
  4761. barHeight = opts.barHeight,
  4762. textRects = opts.textRects,
  4763. dataLabelsY = opts.dataLabelsY,
  4764. barDataLabelsConfig = opts.barDataLabelsConfig,
  4765. strokeWidth = opts.strokeWidth,
  4766. offX = opts.offX,
  4767. offY = opts.offY;
  4768. var dataLabelsX;
  4769. barHeight = Math.abs(barHeight);
  4770. var vertical = w.config.plotOptions.bar.dataLabels.orientation === 'vertical';
  4771. bcx = bcx - strokeWidth / 2;
  4772. var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  4773. if (w.globals.isXNumeric) {
  4774. dataLabelsX = bcx - barWidth / 2 + offX;
  4775. } else {
  4776. dataLabelsX = bcx - dataPointsDividedWidth + barWidth / 2 + offX;
  4777. }
  4778. if (vertical) {
  4779. var offsetDLX = 2;
  4780. dataLabelsX = dataLabelsX + textRects.height / 2 - strokeWidth / 2 - offsetDLX;
  4781. }
  4782. var valIsNegative = this.barCtx.series[i][j] < 0;
  4783. var newY = y;
  4784. if (this.barCtx.isReversed) {
  4785. newY = y - barHeight + (valIsNegative ? barHeight * 2 : 0);
  4786. y = y - barHeight;
  4787. }
  4788. switch (barDataLabelsConfig.position) {
  4789. case 'center':
  4790. if (vertical) {
  4791. if (valIsNegative) {
  4792. dataLabelsY = newY + barHeight / 2 + offY;
  4793. } else {
  4794. dataLabelsY = newY + barHeight / 2 - offY;
  4795. }
  4796. } else {
  4797. if (valIsNegative) {
  4798. dataLabelsY = newY - barHeight / 2 + textRects.height / 2 + offY;
  4799. } else {
  4800. dataLabelsY = newY + barHeight / 2 + textRects.height / 2 - offY;
  4801. }
  4802. }
  4803. break;
  4804. case 'bottom':
  4805. if (vertical) {
  4806. if (valIsNegative) {
  4807. dataLabelsY = newY + barHeight + offY;
  4808. } else {
  4809. dataLabelsY = newY + barHeight - offY;
  4810. }
  4811. } else {
  4812. if (valIsNegative) {
  4813. dataLabelsY = newY - barHeight + textRects.height + strokeWidth + offY;
  4814. } else {
  4815. dataLabelsY = newY + barHeight - textRects.height / 2 + strokeWidth - offY;
  4816. }
  4817. }
  4818. break;
  4819. case 'top':
  4820. if (vertical) {
  4821. if (valIsNegative) {
  4822. dataLabelsY = newY + offY;
  4823. } else {
  4824. dataLabelsY = newY - offY;
  4825. }
  4826. } else {
  4827. if (valIsNegative) {
  4828. dataLabelsY = newY - textRects.height / 2 - offY;
  4829. } else {
  4830. dataLabelsY = newY + textRects.height + offY;
  4831. }
  4832. }
  4833. break;
  4834. }
  4835. if (!w.config.chart.stacked) {
  4836. if (dataLabelsY < 0) {
  4837. dataLabelsY = 0 + strokeWidth;
  4838. } else if (dataLabelsY + textRects.height / 3 > w.globals.gridHeight) {
  4839. dataLabelsY = w.globals.gridHeight - strokeWidth;
  4840. }
  4841. }
  4842. return {
  4843. bcx: bcx,
  4844. bcy: y,
  4845. dataLabelsX: dataLabelsX,
  4846. dataLabelsY: dataLabelsY
  4847. };
  4848. }
  4849. }, {
  4850. key: "calculateBarsDataLabelsPosition",
  4851. value: function calculateBarsDataLabelsPosition(opts) {
  4852. var w = this.w;
  4853. var x = opts.x,
  4854. i = opts.i,
  4855. j = opts.j,
  4856. bcy = opts.bcy,
  4857. barHeight = opts.barHeight,
  4858. barWidth = opts.barWidth,
  4859. textRects = opts.textRects,
  4860. dataLabelsX = opts.dataLabelsX,
  4861. strokeWidth = opts.strokeWidth,
  4862. barDataLabelsConfig = opts.barDataLabelsConfig,
  4863. offX = opts.offX,
  4864. offY = opts.offY;
  4865. var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  4866. barWidth = Math.abs(barWidth);
  4867. var dataLabelsY = bcy - (this.barCtx.isTimelineBar ? 0 : dataPointsDividedHeight) + barHeight / 2 + textRects.height / 2 + offY - 3;
  4868. var valIsNegative = this.barCtx.series[i][j] < 0;
  4869. var newX = x;
  4870. if (this.barCtx.isReversed) {
  4871. newX = x + barWidth - (valIsNegative ? barWidth * 2 : 0);
  4872. x = w.globals.gridWidth - barWidth;
  4873. }
  4874. switch (barDataLabelsConfig.position) {
  4875. case 'center':
  4876. if (valIsNegative) {
  4877. dataLabelsX = newX + barWidth / 2 - offX;
  4878. } else {
  4879. dataLabelsX = newX - barWidth / 2 + offX;
  4880. }
  4881. break;
  4882. case 'bottom':
  4883. if (valIsNegative) {
  4884. dataLabelsX = newX + barWidth - strokeWidth - Math.round(textRects.width / 2) - offX;
  4885. } else {
  4886. dataLabelsX = newX - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX;
  4887. }
  4888. break;
  4889. case 'top':
  4890. if (valIsNegative) {
  4891. dataLabelsX = newX - strokeWidth + Math.round(textRects.width / 2) - offX;
  4892. } else {
  4893. dataLabelsX = newX - strokeWidth - Math.round(textRects.width / 2) + offX;
  4894. }
  4895. break;
  4896. }
  4897. if (!w.config.chart.stacked) {
  4898. if (dataLabelsX < 0) {
  4899. dataLabelsX = dataLabelsX + textRects.width + strokeWidth;
  4900. } else if (dataLabelsX + textRects.width / 2 > w.globals.gridWidth) {
  4901. dataLabelsX = w.globals.gridWidth - textRects.width - strokeWidth;
  4902. }
  4903. }
  4904. return {
  4905. bcx: x,
  4906. bcy: bcy,
  4907. dataLabelsX: dataLabelsX,
  4908. dataLabelsY: dataLabelsY
  4909. };
  4910. }
  4911. }, {
  4912. key: "drawCalculatedDataLabels",
  4913. value: function drawCalculatedDataLabels(_ref) {
  4914. var x = _ref.x,
  4915. y = _ref.y,
  4916. val = _ref.val,
  4917. i = _ref.i,
  4918. j = _ref.j,
  4919. textRects = _ref.textRects,
  4920. barHeight = _ref.barHeight,
  4921. barWidth = _ref.barWidth,
  4922. dataLabelsConfig = _ref.dataLabelsConfig;
  4923. var w = this.w;
  4924. var rotate = 'rotate(0)';
  4925. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') rotate = "rotate(-90, ".concat(x, ", ").concat(y, ")");
  4926. var dataLabels = new DataLabels(this.barCtx.ctx);
  4927. var graphics = new Graphics(this.barCtx.ctx);
  4928. var formatter = dataLabelsConfig.formatter;
  4929. var elDataLabelsWrap = null;
  4930. var isSeriesNotCollapsed = w.globals.collapsedSeriesIndices.indexOf(i) > -1;
  4931. if (dataLabelsConfig.enabled && !isSeriesNotCollapsed) {
  4932. elDataLabelsWrap = graphics.group({
  4933. class: 'apexcharts-data-labels',
  4934. transform: rotate
  4935. });
  4936. var text = '';
  4937. if (typeof val !== 'undefined') {
  4938. text = formatter(val, {
  4939. seriesIndex: i,
  4940. dataPointIndex: j,
  4941. w: w
  4942. });
  4943. }
  4944. if (val === 0 && w.config.chart.stacked) {
  4945. // in a stacked bar/column chart, 0 value should be neglected as it will overlap on the next element
  4946. text = '';
  4947. }
  4948. var valIsNegative = w.globals.series[i][j] <= 0;
  4949. var position = w.config.plotOptions.bar.dataLabels.position;
  4950. if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
  4951. if (position === 'top') {
  4952. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  4953. }
  4954. if (position === 'center') {
  4955. dataLabelsConfig.textAnchor = 'middle';
  4956. }
  4957. if (position === 'bottom') {
  4958. if (valIsNegative) dataLabelsConfig.textAnchor = 'end';else dataLabelsConfig.textAnchor = 'start';
  4959. }
  4960. }
  4961. if (this.barCtx.isTimelineBar && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  4962. // hide the datalabel if it cannot fit into the rect
  4963. var txRect = graphics.getTextRects(text, parseFloat(dataLabelsConfig.style.fontSize));
  4964. if (barWidth < txRect.width) {
  4965. text = '';
  4966. }
  4967. }
  4968. if (w.config.chart.stacked && this.barCtx.barOptions.dataLabels.hideOverflowingLabels) {
  4969. // if there is not enough space to draw the label in the bar/column rect, check hideOverflowingLabels property to prevent overflowing on wrong rect
  4970. // Note: This issue is only seen in stacked charts
  4971. if (this.barCtx.isHorizontal) {
  4972. barWidth = Math.abs(w.globals.series[i][j]) / this.barCtx.invertedYRatio[this.barCtx.yaxisIndex]; // FIXED: Don't always hide the stacked negative side label
  4973. // A negative value will result in a negative bar width
  4974. // Only hide the text when the width is smaller (a higher negative number) than the negative bar width.
  4975. if (barWidth > 0 && textRects.width / 1.6 > barWidth || barWidth < 0 && textRects.width / 1.6 < barWidth) {
  4976. text = '';
  4977. }
  4978. } else {
  4979. barHeight = Math.abs(w.globals.series[i][j]) / this.barCtx.yRatio[this.barCtx.yaxisIndex];
  4980. if (textRects.height / 1.6 > barHeight) {
  4981. text = '';
  4982. }
  4983. }
  4984. }
  4985. var modifiedDataLabelsConfig = _objectSpread2({}, dataLabelsConfig);
  4986. if (this.barCtx.isHorizontal) {
  4987. if (val < 0) {
  4988. if (dataLabelsConfig.textAnchor === 'start') {
  4989. modifiedDataLabelsConfig.textAnchor = 'end';
  4990. } else if (dataLabelsConfig.textAnchor === 'end') {
  4991. modifiedDataLabelsConfig.textAnchor = 'start';
  4992. }
  4993. }
  4994. }
  4995. dataLabels.plotDataLabelsText({
  4996. x: x,
  4997. y: y,
  4998. text: text,
  4999. i: i,
  5000. j: j,
  5001. parent: elDataLabelsWrap,
  5002. dataLabelsConfig: modifiedDataLabelsConfig,
  5003. alwaysDrawDataLabel: true,
  5004. offsetCorrection: true
  5005. });
  5006. }
  5007. return elDataLabelsWrap;
  5008. }
  5009. }]);
  5010. return BarDataLabels;
  5011. }();
  5012. /**
  5013. * ApexCharts Series Class for interation with the Series of the chart.
  5014. *
  5015. * @module Series
  5016. **/
  5017. var Series = /*#__PURE__*/function () {
  5018. function Series(ctx) {
  5019. _classCallCheck(this, Series);
  5020. this.ctx = ctx;
  5021. this.w = ctx.w;
  5022. this.legendInactiveClass = 'legend-mouseover-inactive';
  5023. }
  5024. _createClass(Series, [{
  5025. key: "getAllSeriesEls",
  5026. value: function getAllSeriesEls() {
  5027. return this.w.globals.dom.baseEl.getElementsByClassName("apexcharts-series");
  5028. }
  5029. }, {
  5030. key: "getSeriesByName",
  5031. value: function getSeriesByName(seriesName) {
  5032. return this.w.globals.dom.baseEl.querySelector("[seriesName='".concat(Utils.escapeString(seriesName), "']"));
  5033. }
  5034. }, {
  5035. key: "isSeriesHidden",
  5036. value: function isSeriesHidden(seriesName) {
  5037. var targetElement = this.getSeriesByName(seriesName);
  5038. var realIndex = parseInt(targetElement.getAttribute('data:realIndex'), 10);
  5039. var isHidden = targetElement.classList.contains('apexcharts-series-collapsed');
  5040. return {
  5041. isHidden: isHidden,
  5042. realIndex: realIndex
  5043. };
  5044. }
  5045. }, {
  5046. key: "addCollapsedClassToSeries",
  5047. value: function addCollapsedClassToSeries(elSeries, index) {
  5048. var w = this.w;
  5049. function iterateOnAllCollapsedSeries(series) {
  5050. for (var cs = 0; cs < series.length; cs++) {
  5051. if (series[cs].index === index) {
  5052. elSeries.node.classList.add('apexcharts-series-collapsed');
  5053. }
  5054. }
  5055. }
  5056. iterateOnAllCollapsedSeries(w.globals.collapsedSeries);
  5057. iterateOnAllCollapsedSeries(w.globals.ancillaryCollapsedSeries);
  5058. }
  5059. }, {
  5060. key: "toggleSeries",
  5061. value: function toggleSeries(seriesName) {
  5062. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5063. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, isSeriesHidden.isHidden);
  5064. return isSeriesHidden.isHidden;
  5065. }
  5066. }, {
  5067. key: "showSeries",
  5068. value: function showSeries(seriesName) {
  5069. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5070. if (isSeriesHidden.isHidden) {
  5071. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, true);
  5072. }
  5073. }
  5074. }, {
  5075. key: "hideSeries",
  5076. value: function hideSeries(seriesName) {
  5077. var isSeriesHidden = this.isSeriesHidden(seriesName);
  5078. if (!isSeriesHidden.isHidden) {
  5079. this.ctx.legend.legendHelpers.toggleDataSeries(isSeriesHidden.realIndex, false);
  5080. }
  5081. }
  5082. }, {
  5083. key: "resetSeries",
  5084. value: function resetSeries() {
  5085. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  5086. var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5087. var shouldResetCollapsed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  5088. var w = this.w;
  5089. var series = Utils.clone(w.globals.initialSeries);
  5090. w.globals.previousPaths = [];
  5091. if (shouldResetCollapsed) {
  5092. w.globals.collapsedSeries = [];
  5093. w.globals.ancillaryCollapsedSeries = [];
  5094. w.globals.collapsedSeriesIndices = [];
  5095. w.globals.ancillaryCollapsedSeriesIndices = [];
  5096. } else {
  5097. series = this.emptyCollapsedSeries(series);
  5098. }
  5099. w.config.series = series;
  5100. if (shouldUpdateChart) {
  5101. if (shouldResetZoom) {
  5102. w.globals.zoomed = false;
  5103. this.ctx.updateHelpers.revertDefaultAxisMinMax();
  5104. }
  5105. this.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  5106. }
  5107. }
  5108. }, {
  5109. key: "emptyCollapsedSeries",
  5110. value: function emptyCollapsedSeries(series) {
  5111. var w = this.w;
  5112. for (var i = 0; i < series.length; i++) {
  5113. if (w.globals.collapsedSeriesIndices.indexOf(i) > -1) {
  5114. series[i].data = [];
  5115. }
  5116. }
  5117. return series;
  5118. }
  5119. }, {
  5120. key: "toggleSeriesOnHover",
  5121. value: function toggleSeriesOnHover(e, targetElement) {
  5122. var w = this.w;
  5123. var allSeriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");
  5124. if (e.type === 'mousemove') {
  5125. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  5126. var seriesEl = null;
  5127. var dataLabelEl = null;
  5128. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  5129. if (w.globals.axisCharts) {
  5130. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  5131. dataLabelEl = w.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(seriesCnt, "']"));
  5132. } else {
  5133. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  5134. }
  5135. } else {
  5136. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  5137. }
  5138. for (var se = 0; se < allSeriesEls.length; se++) {
  5139. allSeriesEls[se].classList.add(this.legendInactiveClass);
  5140. }
  5141. if (seriesEl !== null) {
  5142. if (!w.globals.axisCharts) {
  5143. seriesEl.parentNode.classList.remove(this.legendInactiveClass);
  5144. }
  5145. seriesEl.classList.remove(this.legendInactiveClass);
  5146. if (dataLabelEl !== null) {
  5147. dataLabelEl.classList.remove(this.legendInactiveClass);
  5148. }
  5149. }
  5150. } else if (e.type === 'mouseout') {
  5151. for (var _se = 0; _se < allSeriesEls.length; _se++) {
  5152. allSeriesEls[_se].classList.remove(this.legendInactiveClass);
  5153. }
  5154. }
  5155. }
  5156. }, {
  5157. key: "highlightRangeInSeries",
  5158. value: function highlightRangeInSeries(e, targetElement) {
  5159. var _this = this;
  5160. var w = this.w;
  5161. var allHeatMapElements = w.globals.dom.baseEl.getElementsByClassName('apexcharts-heatmap-rect');
  5162. var activeInactive = function activeInactive(action) {
  5163. for (var i = 0; i < allHeatMapElements.length; i++) {
  5164. allHeatMapElements[i].classList[action](_this.legendInactiveClass);
  5165. }
  5166. };
  5167. var removeInactiveClassFromHoveredRange = function removeInactiveClassFromHoveredRange(range) {
  5168. for (var i = 0; i < allHeatMapElements.length; i++) {
  5169. var val = parseInt(allHeatMapElements[i].getAttribute('val'), 10);
  5170. if (val >= range.from && val <= range.to) {
  5171. allHeatMapElements[i].classList.remove(_this.legendInactiveClass);
  5172. }
  5173. }
  5174. };
  5175. if (e.type === 'mousemove') {
  5176. var seriesCnt = parseInt(targetElement.getAttribute('rel'), 10) - 1;
  5177. activeInactive('add');
  5178. var range = w.config.plotOptions.heatmap.colorScale.ranges[seriesCnt];
  5179. removeInactiveClassFromHoveredRange(range);
  5180. } else if (e.type === 'mouseout') {
  5181. activeInactive('remove');
  5182. }
  5183. }
  5184. }, {
  5185. key: "getActiveConfigSeriesIndex",
  5186. value: function getActiveConfigSeriesIndex() {
  5187. var ignoreBars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5188. var w = this.w;
  5189. var activeIndex = 0;
  5190. if (w.config.series.length > 1) {
  5191. // active series flag is required to know if user has not deactivated via legend click
  5192. var firstActiveSeriesIndex = w.config.series.map(function (series, index) {
  5193. var hasBars = false;
  5194. if (ignoreBars) {
  5195. hasBars = w.config.series[index].type === 'bar' || w.config.series[index].type === 'column';
  5196. }
  5197. return series.data && series.data.length > 0 && !hasBars ? index : -1;
  5198. });
  5199. for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
  5200. if (firstActiveSeriesIndex[a] !== -1) {
  5201. activeIndex = firstActiveSeriesIndex[a];
  5202. break;
  5203. }
  5204. }
  5205. }
  5206. return activeIndex;
  5207. }
  5208. }, {
  5209. key: "getPreviousPaths",
  5210. value: function getPreviousPaths() {
  5211. var w = this.w;
  5212. w.globals.previousPaths = [];
  5213. function pushPaths(seriesEls, i, type) {
  5214. var paths = seriesEls[i].childNodes;
  5215. var dArr = {
  5216. type: type,
  5217. paths: [],
  5218. realIndex: seriesEls[i].getAttribute('data:realIndex')
  5219. };
  5220. for (var j = 0; j < paths.length; j++) {
  5221. if (paths[j].hasAttribute('pathTo')) {
  5222. var d = paths[j].getAttribute('pathTo');
  5223. dArr.paths.push({
  5224. d: d
  5225. });
  5226. }
  5227. }
  5228. w.globals.previousPaths.push(dArr);
  5229. }
  5230. var getPaths = function getPaths(chartType) {
  5231. return w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(chartType, "-series .apexcharts-series"));
  5232. };
  5233. var chartTypes = ['line', 'area', 'bar', 'candlestick', 'radar'];
  5234. chartTypes.forEach(function (type) {
  5235. var paths = getPaths(type);
  5236. for (var p = 0; p < paths.length; p++) {
  5237. pushPaths(paths, p, type);
  5238. }
  5239. });
  5240. this.handlePrevBubbleScatterPaths('bubble');
  5241. this.handlePrevBubbleScatterPaths('scatter');
  5242. var heatmapColors = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap .apexcharts-series');
  5243. if (heatmapColors.length > 0) {
  5244. for (var h = 0; h < heatmapColors.length; h++) {
  5245. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-heatmap .apexcharts-series[data\\:realIndex='".concat(h, "'] rect"));
  5246. var dArr = [];
  5247. for (var i = 0; i < seriesEls.length; i++) {
  5248. dArr.push({
  5249. color: seriesEls[i].getAttribute('color')
  5250. });
  5251. }
  5252. w.globals.previousPaths.push(dArr);
  5253. }
  5254. }
  5255. if (!w.globals.axisCharts) {
  5256. // for non-axis charts (i.e., circular charts, pathFrom is not usable. We need whole series)
  5257. w.globals.previousPaths = w.globals.series;
  5258. }
  5259. }
  5260. }, {
  5261. key: "handlePrevBubbleScatterPaths",
  5262. value: function handlePrevBubbleScatterPaths(type) {
  5263. var w = this.w;
  5264. var paths = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series"));
  5265. if (paths.length > 0) {
  5266. for (var s = 0; s < paths.length; s++) {
  5267. var seriesEls = w.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(type, "-series .apexcharts-series[data\\:realIndex='").concat(s, "'] circle"));
  5268. var dArr = [];
  5269. for (var i = 0; i < seriesEls.length; i++) {
  5270. dArr.push({
  5271. x: seriesEls[i].getAttribute('cx'),
  5272. y: seriesEls[i].getAttribute('cy'),
  5273. r: seriesEls[i].getAttribute('r')
  5274. });
  5275. }
  5276. w.globals.previousPaths.push(dArr);
  5277. }
  5278. }
  5279. }
  5280. }, {
  5281. key: "clearPreviousPaths",
  5282. value: function clearPreviousPaths() {
  5283. var w = this.w;
  5284. w.globals.previousPaths = [];
  5285. w.globals.allSeriesCollapsed = false;
  5286. }
  5287. }, {
  5288. key: "handleNoData",
  5289. value: function handleNoData() {
  5290. var w = this.w;
  5291. var me = this;
  5292. var noDataOpts = w.config.noData;
  5293. var graphics = new Graphics(me.ctx);
  5294. var x = w.globals.svgWidth / 2;
  5295. var y = w.globals.svgHeight / 2;
  5296. var textAnchor = 'middle';
  5297. w.globals.noData = true;
  5298. w.globals.animationEnded = true;
  5299. if (noDataOpts.align === 'left') {
  5300. x = 10;
  5301. textAnchor = 'start';
  5302. } else if (noDataOpts.align === 'right') {
  5303. x = w.globals.svgWidth - 10;
  5304. textAnchor = 'end';
  5305. }
  5306. if (noDataOpts.verticalAlign === 'top') {
  5307. y = 50;
  5308. } else if (noDataOpts.verticalAlign === 'bottom') {
  5309. y = w.globals.svgHeight - 50;
  5310. }
  5311. x = x + noDataOpts.offsetX;
  5312. y = y + parseInt(noDataOpts.style.fontSize, 10) + 2 + noDataOpts.offsetY;
  5313. if (noDataOpts.text !== undefined && noDataOpts.text !== '') {
  5314. var titleText = graphics.drawText({
  5315. x: x,
  5316. y: y,
  5317. text: noDataOpts.text,
  5318. textAnchor: textAnchor,
  5319. fontSize: noDataOpts.style.fontSize,
  5320. fontFamily: noDataOpts.style.fontFamily,
  5321. foreColor: noDataOpts.style.color,
  5322. opacity: 1,
  5323. class: 'apexcharts-text-nodata'
  5324. });
  5325. w.globals.dom.Paper.add(titleText);
  5326. }
  5327. } // When user clicks on legends, the collapsed series is filled with [0,0,0,...,0]
  5328. // This is because we don't want to alter the series' length as it is used at many places
  5329. }, {
  5330. key: "setNullSeriesToZeroValues",
  5331. value: function setNullSeriesToZeroValues(series) {
  5332. var w = this.w;
  5333. for (var sl = 0; sl < series.length; sl++) {
  5334. if (series[sl].length === 0) {
  5335. for (var j = 0; j < series[w.globals.maxValsInArrayIndex].length; j++) {
  5336. series[sl].push(0);
  5337. }
  5338. }
  5339. }
  5340. return series;
  5341. }
  5342. }, {
  5343. key: "hasAllSeriesEqualX",
  5344. value: function hasAllSeriesEqualX() {
  5345. var equalLen = true;
  5346. var w = this.w;
  5347. var filteredSerX = this.filteredSeriesX();
  5348. for (var i = 0; i < filteredSerX.length - 1; i++) {
  5349. if (filteredSerX[i][0] !== filteredSerX[i + 1][0]) {
  5350. equalLen = false;
  5351. break;
  5352. }
  5353. }
  5354. w.globals.allSeriesHasEqualX = equalLen;
  5355. return equalLen;
  5356. }
  5357. }, {
  5358. key: "filteredSeriesX",
  5359. value: function filteredSeriesX() {
  5360. var w = this.w;
  5361. var filteredSeriesX = w.globals.seriesX.map(function (ser) {
  5362. return ser.length > 0 ? ser : [];
  5363. });
  5364. return filteredSeriesX;
  5365. }
  5366. }]);
  5367. return Series;
  5368. }();
  5369. var Helpers$1 = /*#__PURE__*/function () {
  5370. function Helpers(barCtx) {
  5371. _classCallCheck(this, Helpers);
  5372. this.w = barCtx.w;
  5373. this.barCtx = barCtx;
  5374. }
  5375. _createClass(Helpers, [{
  5376. key: "initVariables",
  5377. value: function initVariables(series) {
  5378. var w = this.w;
  5379. this.barCtx.series = series;
  5380. this.barCtx.totalItems = 0;
  5381. this.barCtx.seriesLen = 0;
  5382. this.barCtx.visibleI = -1; // visible Series
  5383. this.barCtx.visibleItems = 1; // number of visible bars after user zoomed in/out
  5384. for (var sl = 0; sl < series.length; sl++) {
  5385. if (series[sl].length > 0) {
  5386. this.barCtx.seriesLen = this.barCtx.seriesLen + 1;
  5387. this.barCtx.totalItems += series[sl].length;
  5388. }
  5389. if (w.globals.isXNumeric) {
  5390. // get max visible items
  5391. for (var j = 0; j < series[sl].length; j++) {
  5392. if (w.globals.seriesX[sl][j] > w.globals.minX && w.globals.seriesX[sl][j] < w.globals.maxX) {
  5393. this.barCtx.visibleItems++;
  5394. }
  5395. }
  5396. } else {
  5397. this.barCtx.visibleItems = w.globals.dataPoints;
  5398. }
  5399. }
  5400. if (this.barCtx.seriesLen === 0) {
  5401. // A small adjustment when combo charts are used
  5402. this.barCtx.seriesLen = 1;
  5403. }
  5404. }
  5405. }, {
  5406. key: "initialPositions",
  5407. value: function initialPositions() {
  5408. var w = this.w;
  5409. var x, y, yDivision, xDivision, barHeight, barWidth, zeroH, zeroW;
  5410. var dataPoints = w.globals.dataPoints;
  5411. if (this.barCtx.isTimelineBar) {
  5412. // timeline rangebar chart
  5413. dataPoints = w.globals.labels.length;
  5414. }
  5415. if (this.barCtx.isHorizontal) {
  5416. // height divided into equal parts
  5417. yDivision = w.globals.gridHeight / dataPoints;
  5418. barHeight = yDivision / this.barCtx.seriesLen;
  5419. if (w.globals.isXNumeric) {
  5420. yDivision = w.globals.gridHeight / this.barCtx.totalItems;
  5421. barHeight = yDivision / this.barCtx.seriesLen;
  5422. }
  5423. barHeight = barHeight * parseInt(this.barCtx.barOptions.barHeight, 10) / 100;
  5424. zeroW = this.barCtx.baseLineInvertedY + w.globals.padHorizontal + (this.barCtx.isReversed ? w.globals.gridWidth : 0) - (this.barCtx.isReversed ? this.barCtx.baseLineInvertedY * 2 : 0);
  5425. y = (yDivision - barHeight * this.barCtx.seriesLen) / 2;
  5426. } else {
  5427. // width divided into equal parts
  5428. xDivision = w.globals.gridWidth / this.barCtx.visibleItems;
  5429. if (w.config.xaxis.convertedCatToNumeric) {
  5430. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  5431. }
  5432. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  5433. if (w.globals.isXNumeric) {
  5434. // max barwidth should be equal to minXDiff to avoid overlap
  5435. var xRatio = this.barCtx.xRatio;
  5436. if (w.config.xaxis.convertedCatToNumeric) {
  5437. xRatio = this.barCtx.initialXRatio;
  5438. }
  5439. if (w.globals.minXDiff && w.globals.minXDiff !== 0.5 && w.globals.minXDiff / xRatio > 0) {
  5440. xDivision = w.globals.minXDiff / xRatio;
  5441. }
  5442. barWidth = xDivision / this.barCtx.seriesLen * parseInt(this.barCtx.barOptions.columnWidth, 10) / 100;
  5443. if (barWidth < 1) {
  5444. barWidth = 1;
  5445. }
  5446. }
  5447. 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);
  5448. x = w.globals.padHorizontal + (xDivision - barWidth * this.barCtx.seriesLen) / 2;
  5449. }
  5450. return {
  5451. x: x,
  5452. y: y,
  5453. yDivision: yDivision,
  5454. xDivision: xDivision,
  5455. barHeight: barHeight,
  5456. barWidth: barWidth,
  5457. zeroH: zeroH,
  5458. zeroW: zeroW
  5459. };
  5460. }
  5461. }, {
  5462. key: "getPathFillColor",
  5463. value: function getPathFillColor(series, i, j, realIndex) {
  5464. var w = this.w;
  5465. var fill = new Fill(this.barCtx.ctx);
  5466. var fillColor = null;
  5467. var seriesNumber = this.barCtx.barOptions.distributed ? j : i;
  5468. if (this.barCtx.barOptions.colors.ranges.length > 0) {
  5469. var colorRange = this.barCtx.barOptions.colors.ranges;
  5470. colorRange.map(function (range) {
  5471. if (series[i][j] >= range.from && series[i][j] <= range.to) {
  5472. fillColor = range.color;
  5473. }
  5474. });
  5475. }
  5476. if (w.config.series[i].data[j] && w.config.series[i].data[j].fillColor) {
  5477. fillColor = w.config.series[i].data[j].fillColor;
  5478. }
  5479. var pathFill = fill.fillPath({
  5480. seriesNumber: this.barCtx.barOptions.distributed ? seriesNumber : realIndex,
  5481. dataPointIndex: j,
  5482. color: fillColor,
  5483. value: series[i][j]
  5484. });
  5485. return pathFill;
  5486. }
  5487. }, {
  5488. key: "getStrokeWidth",
  5489. value: function getStrokeWidth(i, j, realIndex) {
  5490. var strokeWidth = 0;
  5491. var w = this.w;
  5492. if (typeof this.barCtx.series[i][j] === 'undefined' || this.barCtx.series[i][j] === null) {
  5493. this.barCtx.isNullValue = true;
  5494. } else {
  5495. this.barCtx.isNullValue = false;
  5496. }
  5497. if (w.config.stroke.show) {
  5498. if (!this.barCtx.isNullValue) {
  5499. strokeWidth = Array.isArray(this.barCtx.strokeWidth) ? this.barCtx.strokeWidth[realIndex] : this.barCtx.strokeWidth;
  5500. }
  5501. }
  5502. return strokeWidth;
  5503. }
  5504. }, {
  5505. key: "barBackground",
  5506. value: function barBackground(_ref) {
  5507. var bc = _ref.bc,
  5508. i = _ref.i,
  5509. x1 = _ref.x1,
  5510. x2 = _ref.x2,
  5511. y1 = _ref.y1,
  5512. y2 = _ref.y2,
  5513. elSeries = _ref.elSeries;
  5514. var w = this.w;
  5515. var graphics = new Graphics(this.barCtx.ctx);
  5516. var sr = new Series(this.barCtx.ctx);
  5517. var activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  5518. if (this.barCtx.barOptions.colors.backgroundBarColors.length > 0 && activeSeriesIndex === i) {
  5519. if (bc >= this.barCtx.barOptions.colors.backgroundBarColors.length) {
  5520. bc = 0;
  5521. }
  5522. var bcolor = this.barCtx.barOptions.colors.backgroundBarColors[bc];
  5523. 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);
  5524. elSeries.add(rect);
  5525. rect.node.classList.add('apexcharts-backgroundBar');
  5526. }
  5527. }
  5528. }, {
  5529. key: "getColumnPaths",
  5530. value: function getColumnPaths(_ref2) {
  5531. var barWidth = _ref2.barWidth,
  5532. barXPosition = _ref2.barXPosition,
  5533. yRatio = _ref2.yRatio,
  5534. y1 = _ref2.y1,
  5535. y2 = _ref2.y2,
  5536. strokeWidth = _ref2.strokeWidth,
  5537. series = _ref2.series,
  5538. realIndex = _ref2.realIndex,
  5539. i = _ref2.i,
  5540. j = _ref2.j,
  5541. w = _ref2.w;
  5542. var graphics = new Graphics(this.barCtx.ctx);
  5543. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  5544. if (!strokeWidth) strokeWidth = 0;
  5545. var shapeOpts = {
  5546. barWidth: barWidth,
  5547. strokeWidth: strokeWidth,
  5548. yRatio: yRatio,
  5549. barXPosition: barXPosition,
  5550. y1: y1,
  5551. y2: y2
  5552. };
  5553. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  5554. var x1 = barXPosition;
  5555. var x2 = barXPosition + barWidth;
  5556. var pathTo = graphics.move(x1, newPath.y1);
  5557. var pathFrom = graphics.move(x1, newPath.y1);
  5558. if (w.globals.previousPaths.length > 0) {
  5559. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  5560. }
  5561. pathTo = pathTo + graphics.line(x1, newPath.y2) + newPath.endingPath + graphics.line(x2 - strokeWidth, newPath.y2) + graphics.line(x2 - strokeWidth, newPath.y1) + newPath.startingPath + 'z';
  5562. pathFrom = pathFrom + graphics.line(x1, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x2 - strokeWidth, y1) + graphics.line(x1, y1);
  5563. return {
  5564. pathTo: pathTo,
  5565. pathFrom: pathFrom
  5566. };
  5567. }
  5568. }, {
  5569. key: "getBarpaths",
  5570. value: function getBarpaths(_ref3) {
  5571. var barYPosition = _ref3.barYPosition,
  5572. barHeight = _ref3.barHeight,
  5573. x1 = _ref3.x1,
  5574. x2 = _ref3.x2,
  5575. strokeWidth = _ref3.strokeWidth,
  5576. series = _ref3.series,
  5577. realIndex = _ref3.realIndex,
  5578. i = _ref3.i,
  5579. j = _ref3.j,
  5580. w = _ref3.w;
  5581. var graphics = new Graphics(this.barCtx.ctx);
  5582. strokeWidth = Array.isArray(strokeWidth) ? strokeWidth[realIndex] : strokeWidth;
  5583. if (!strokeWidth) strokeWidth = 0;
  5584. var shapeOpts = {
  5585. barHeight: barHeight,
  5586. strokeWidth: strokeWidth,
  5587. barYPosition: barYPosition,
  5588. x2: x2,
  5589. x1: x1
  5590. };
  5591. var newPath = this.getRoundedBars(w, shapeOpts, series, i, j);
  5592. var pathTo = graphics.move(newPath.x1, barYPosition);
  5593. var pathFrom = graphics.move(newPath.x1, barYPosition);
  5594. if (w.globals.previousPaths.length > 0) {
  5595. pathFrom = this.barCtx.getPreviousPath(realIndex, j, false);
  5596. }
  5597. var y1 = barYPosition;
  5598. var y2 = barYPosition + barHeight;
  5599. pathTo = pathTo + graphics.line(newPath.x2, y1) + newPath.endingPath + graphics.line(newPath.x2, y2 - strokeWidth) + graphics.line(newPath.x1, y2 - strokeWidth) + newPath.startingPath + 'z';
  5600. pathFrom = pathFrom + graphics.line(x1, y1) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y2 - strokeWidth) + graphics.line(x1, y1);
  5601. return {
  5602. pathTo: pathTo,
  5603. pathFrom: pathFrom
  5604. };
  5605. }
  5606. /** getRoundedBars draws border radius for bars/columns
  5607. * @memberof Bar
  5608. * @param {object} w - chart context
  5609. * @param {object} opts - consists several properties like barHeight/barWidth
  5610. * @param {array} series - global primary series
  5611. * @param {int} i - current iterating series's index
  5612. * @param {int} j - series's j of i
  5613. * @return {object} endingPath - ending shape path string
  5614. * startingPath - starting shape path string
  5615. * newY/newX - which is calculated from existing x/y based on rounded border
  5616. **/
  5617. }, {
  5618. key: "getRoundedBars",
  5619. value: function getRoundedBars(w, opts, series, i, j) {
  5620. var graphics = new Graphics(this.barCtx.ctx);
  5621. var strokeWidth = Array.isArray(opts.strokeWidth) ? opts.strokeWidth[i] : opts.strokeWidth;
  5622. if (!strokeWidth) strokeWidth = 0;
  5623. if (this.barCtx.isHorizontal) {
  5624. var endingShape = null;
  5625. var startingShape = '';
  5626. var x2 = opts.x2;
  5627. var x1 = opts.x1;
  5628. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  5629. var inverse = series[i][j] < 0;
  5630. var eX = opts.barHeight / 2 - strokeWidth;
  5631. if (inverse) eX = -opts.barHeight / 2 - strokeWidth;
  5632. if (eX > Math.abs(x2 - x1)) {
  5633. eX = Math.abs(x2 - x1);
  5634. }
  5635. if (this.barCtx.barOptions.endingShape === 'rounded') {
  5636. x2 = opts.x2 - eX / 2;
  5637. }
  5638. if (this.barCtx.barOptions.startingShape === 'rounded') {
  5639. x1 = opts.x1 + eX / 2;
  5640. }
  5641. switch (this.barCtx.barOptions.endingShape) {
  5642. case 'flat':
  5643. endingShape = graphics.line(x2, opts.barYPosition + opts.barHeight - strokeWidth);
  5644. break;
  5645. case 'rounded':
  5646. endingShape = graphics.quadraticCurve(x2 + eX, opts.barYPosition + (opts.barHeight - strokeWidth) / 2, x2, opts.barYPosition + opts.barHeight - strokeWidth);
  5647. break;
  5648. }
  5649. switch (this.barCtx.barOptions.startingShape) {
  5650. case 'flat':
  5651. startingShape = graphics.line(x1, opts.barYPosition + opts.barHeight - strokeWidth);
  5652. break;
  5653. case 'rounded':
  5654. startingShape = graphics.quadraticCurve(x1 - eX, opts.barYPosition + opts.barHeight / 2, x1, opts.barYPosition);
  5655. break;
  5656. }
  5657. }
  5658. return {
  5659. endingPath: endingShape,
  5660. startingPath: startingShape,
  5661. x2: x2,
  5662. x1: x1
  5663. };
  5664. } else {
  5665. var _endingShape = null;
  5666. var _startingShape = '';
  5667. var y2 = opts.y2;
  5668. var y1 = opts.y1;
  5669. if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) {
  5670. var _inverse = series[i][j] < 0;
  5671. var eY = opts.barWidth / 2 - strokeWidth;
  5672. if (_inverse) eY = -opts.barWidth / 2 - strokeWidth;
  5673. if (eY > Math.abs(y2 - y1)) {
  5674. eY = Math.abs(y2 - y1);
  5675. }
  5676. if (this.barCtx.barOptions.endingShape === 'rounded') {
  5677. // the shape exceeds the chart height, hence reduce y
  5678. y2 = y2 + eY / 2;
  5679. }
  5680. if (this.barCtx.barOptions.startingShape === 'rounded') {
  5681. y1 = y1 - eY / 2;
  5682. }
  5683. switch (this.barCtx.barOptions.endingShape) {
  5684. case 'flat':
  5685. _endingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y2);
  5686. break;
  5687. case 'rounded':
  5688. _endingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y2 - eY, opts.barXPosition + opts.barWidth - strokeWidth, y2);
  5689. break;
  5690. }
  5691. switch (this.barCtx.barOptions.startingShape) {
  5692. case 'flat':
  5693. _startingShape = graphics.line(opts.barXPosition + opts.barWidth - strokeWidth, y1);
  5694. break;
  5695. case 'rounded':
  5696. _startingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - strokeWidth) / 2, y1 + eY, opts.barXPosition, y1);
  5697. break;
  5698. }
  5699. }
  5700. return {
  5701. endingPath: _endingShape,
  5702. startingPath: _startingShape,
  5703. y2: y2,
  5704. y1: y1
  5705. };
  5706. }
  5707. }
  5708. }]);
  5709. return Helpers;
  5710. }();
  5711. /**
  5712. * ApexCharts Bar Class responsible for drawing both Columns and Bars.
  5713. *
  5714. * @module Bar
  5715. **/
  5716. var Bar = /*#__PURE__*/function () {
  5717. function Bar(ctx, xyRatios) {
  5718. _classCallCheck(this, Bar);
  5719. this.ctx = ctx;
  5720. this.w = ctx.w;
  5721. var w = this.w;
  5722. this.barOptions = w.config.plotOptions.bar;
  5723. this.isHorizontal = this.barOptions.horizontal;
  5724. this.strokeWidth = w.config.stroke.width;
  5725. this.isNullValue = false;
  5726. this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
  5727. this.xyRatios = xyRatios;
  5728. if (this.xyRatios !== null) {
  5729. this.xRatio = xyRatios.xRatio;
  5730. this.initialXRatio = xyRatios.initialXRatio;
  5731. this.yRatio = xyRatios.yRatio;
  5732. this.invertedXRatio = xyRatios.invertedXRatio;
  5733. this.invertedYRatio = xyRatios.invertedYRatio;
  5734. this.baseLineY = xyRatios.baseLineY;
  5735. this.baseLineInvertedY = xyRatios.baseLineInvertedY;
  5736. }
  5737. this.yaxisIndex = 0;
  5738. this.seriesLen = 0;
  5739. this.barHelpers = new Helpers$1(this);
  5740. }
  5741. /** primary draw method which is called on bar object
  5742. * @memberof Bar
  5743. * @param {array} series - user supplied series values
  5744. * @param {int} seriesIndex - the index by which series will be drawn on the svg
  5745. * @return {node} element which is supplied to parent chart draw method for appending
  5746. **/
  5747. _createClass(Bar, [{
  5748. key: "draw",
  5749. value: function draw(series, seriesIndex) {
  5750. var w = this.w;
  5751. var graphics = new Graphics(this.ctx);
  5752. var coreUtils = new CoreUtils(this.ctx, w);
  5753. series = coreUtils.getLogSeries(series);
  5754. this.series = series;
  5755. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  5756. this.barHelpers.initVariables(series);
  5757. var ret = graphics.group({
  5758. class: 'apexcharts-bar-series apexcharts-plot-series'
  5759. });
  5760. if (w.config.dataLabels.enabled) {
  5761. if (this.totalItems > this.barOptions.dataLabels.maxItems) {
  5762. console.warn('WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.');
  5763. }
  5764. }
  5765. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  5766. var x = void 0,
  5767. y = void 0,
  5768. xDivision = void 0,
  5769. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  5770. yDivision = void 0,
  5771. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  5772. zeroH = void 0,
  5773. // zeroH is the baseline where 0 meets y axis
  5774. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  5775. var yArrj = []; // hold y values of current iterating series
  5776. var xArrj = []; // hold x values of current iterating series
  5777. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  5778. var elSeries = graphics.group({
  5779. class: "apexcharts-series",
  5780. rel: i + 1,
  5781. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  5782. 'data:realIndex': realIndex
  5783. });
  5784. this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex);
  5785. if (series[i].length > 0) {
  5786. this.visibleI = this.visibleI + 1;
  5787. }
  5788. var barHeight = 0;
  5789. var barWidth = 0;
  5790. if (this.yRatio.length > 1) {
  5791. this.yaxisIndex = realIndex;
  5792. }
  5793. this.isReversed = w.config.yaxis[this.yaxisIndex] && w.config.yaxis[this.yaxisIndex].reversed;
  5794. var initPositions = this.barHelpers.initialPositions();
  5795. y = initPositions.y;
  5796. barHeight = initPositions.barHeight;
  5797. yDivision = initPositions.yDivision;
  5798. zeroW = initPositions.zeroW;
  5799. x = initPositions.x;
  5800. barWidth = initPositions.barWidth;
  5801. xDivision = initPositions.xDivision;
  5802. zeroH = initPositions.zeroH;
  5803. if (!this.horizontal) {
  5804. xArrj.push(x + barWidth / 2);
  5805. } // eldatalabels
  5806. var elDataLabelsWrap = graphics.group({
  5807. class: 'apexcharts-datalabels',
  5808. 'data:realIndex': realIndex
  5809. });
  5810. for (var j = 0; j < w.globals.dataPoints; j++) {
  5811. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  5812. var paths = null;
  5813. var pathsParams = {
  5814. indexes: {
  5815. i: i,
  5816. j: j,
  5817. realIndex: realIndex,
  5818. bc: bc
  5819. },
  5820. x: x,
  5821. y: y,
  5822. strokeWidth: strokeWidth,
  5823. elSeries: elSeries
  5824. };
  5825. if (this.isHorizontal) {
  5826. paths = this.drawBarPaths(_objectSpread2({}, pathsParams, {
  5827. barHeight: barHeight,
  5828. zeroW: zeroW,
  5829. yDivision: yDivision
  5830. }));
  5831. barWidth = this.series[i][j] / this.invertedYRatio;
  5832. } else {
  5833. paths = this.drawColumnPaths(_objectSpread2({}, pathsParams, {
  5834. xDivision: xDivision,
  5835. barWidth: barWidth,
  5836. zeroH: zeroH
  5837. }));
  5838. barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex];
  5839. }
  5840. y = paths.y;
  5841. x = paths.x; // push current X
  5842. if (j > 0) {
  5843. xArrj.push(x + barWidth / 2);
  5844. }
  5845. yArrj.push(y);
  5846. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  5847. this.renderSeries({
  5848. realIndex: realIndex,
  5849. pathFill: pathFill,
  5850. j: j,
  5851. i: i,
  5852. pathFrom: paths.pathFrom,
  5853. pathTo: paths.pathTo,
  5854. strokeWidth: strokeWidth,
  5855. elSeries: elSeries,
  5856. x: x,
  5857. y: y,
  5858. series: series,
  5859. barHeight: barHeight,
  5860. barWidth: barWidth,
  5861. elDataLabelsWrap: elDataLabelsWrap,
  5862. visibleSeries: this.visibleI,
  5863. type: 'bar'
  5864. });
  5865. } // push all x val arrays into main xArr
  5866. w.globals.seriesXvalues[realIndex] = xArrj;
  5867. w.globals.seriesYvalues[realIndex] = yArrj;
  5868. ret.add(elSeries);
  5869. }
  5870. return ret;
  5871. }
  5872. }, {
  5873. key: "renderSeries",
  5874. value: function renderSeries(_ref) {
  5875. var realIndex = _ref.realIndex,
  5876. pathFill = _ref.pathFill,
  5877. lineFill = _ref.lineFill,
  5878. j = _ref.j,
  5879. i = _ref.i,
  5880. pathFrom = _ref.pathFrom,
  5881. pathTo = _ref.pathTo,
  5882. strokeWidth = _ref.strokeWidth,
  5883. elSeries = _ref.elSeries,
  5884. x = _ref.x,
  5885. y = _ref.y,
  5886. y1 = _ref.y1,
  5887. y2 = _ref.y2,
  5888. series = _ref.series,
  5889. barHeight = _ref.barHeight,
  5890. barWidth = _ref.barWidth,
  5891. barYPosition = _ref.barYPosition,
  5892. elDataLabelsWrap = _ref.elDataLabelsWrap,
  5893. visibleSeries = _ref.visibleSeries,
  5894. type = _ref.type;
  5895. var w = this.w;
  5896. var graphics = new Graphics(this.ctx);
  5897. if (!lineFill) {
  5898. /* fix apexcharts#341 */
  5899. lineFill = this.barOptions.distributed ? w.globals.stroke.colors[j] : w.globals.stroke.colors[realIndex];
  5900. }
  5901. if (w.config.series[i].data[j] && w.config.series[i].data[j].strokeColor) {
  5902. lineFill = w.config.series[i].data[j].strokeColor;
  5903. }
  5904. if (this.isNullValue) {
  5905. pathFill = 'none';
  5906. }
  5907. var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4;
  5908. var renderedPath = graphics.renderPaths({
  5909. i: i,
  5910. j: j,
  5911. realIndex: realIndex,
  5912. pathFrom: pathFrom,
  5913. pathTo: pathTo,
  5914. stroke: lineFill,
  5915. strokeWidth: strokeWidth,
  5916. strokeLineCap: w.config.stroke.lineCap,
  5917. fill: pathFill,
  5918. animationDelay: delay,
  5919. initialSpeed: w.config.chart.animations.speed,
  5920. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  5921. className: "apexcharts-".concat(type, "-area")
  5922. });
  5923. renderedPath.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  5924. if (typeof y1 !== 'undefined' && typeof y2 !== 'undefined') {
  5925. renderedPath.attr('data-range-y1', y1);
  5926. renderedPath.attr('data-range-y2', y2);
  5927. }
  5928. var filters = new Filters(this.ctx);
  5929. filters.setSelectionFilter(renderedPath, realIndex, j);
  5930. elSeries.add(renderedPath);
  5931. var barDataLabels = new BarDataLabels(this);
  5932. var dataLabels = barDataLabels.handleBarDataLabels({
  5933. x: x,
  5934. y: y,
  5935. y1: y1,
  5936. y2: y2,
  5937. i: i,
  5938. j: j,
  5939. series: series,
  5940. realIndex: realIndex,
  5941. barHeight: barHeight,
  5942. barWidth: barWidth,
  5943. barYPosition: barYPosition,
  5944. renderedPath: renderedPath,
  5945. visibleSeries: visibleSeries
  5946. });
  5947. if (dataLabels !== null) {
  5948. elDataLabelsWrap.add(dataLabels);
  5949. }
  5950. elSeries.add(elDataLabelsWrap);
  5951. return elSeries;
  5952. }
  5953. }, {
  5954. key: "drawBarPaths",
  5955. value: function drawBarPaths(_ref2) {
  5956. var indexes = _ref2.indexes,
  5957. barHeight = _ref2.barHeight,
  5958. strokeWidth = _ref2.strokeWidth,
  5959. zeroW = _ref2.zeroW,
  5960. x = _ref2.x,
  5961. y = _ref2.y,
  5962. yDivision = _ref2.yDivision,
  5963. elSeries = _ref2.elSeries;
  5964. var w = this.w;
  5965. var i = indexes.i;
  5966. var j = indexes.j;
  5967. var bc = indexes.bc;
  5968. if (w.globals.isXNumeric) {
  5969. y = (w.globals.seriesX[i][j] - w.globals.minX) / this.invertedXRatio - barHeight;
  5970. }
  5971. var barYPosition = y + barHeight * this.visibleI;
  5972. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  5973. x = zeroW;
  5974. } else {
  5975. x = zeroW + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
  5976. }
  5977. var paths = this.barHelpers.getBarpaths({
  5978. barYPosition: barYPosition,
  5979. barHeight: barHeight,
  5980. x1: zeroW,
  5981. x2: x,
  5982. strokeWidth: strokeWidth,
  5983. series: this.series,
  5984. realIndex: indexes.realIndex,
  5985. i: i,
  5986. j: j,
  5987. w: w
  5988. });
  5989. if (!w.globals.isXNumeric) {
  5990. y = y + yDivision;
  5991. }
  5992. this.barHelpers.barBackground({
  5993. bc: bc,
  5994. i: i,
  5995. y1: barYPosition - barHeight * this.visibleI,
  5996. y2: barHeight * this.seriesLen,
  5997. elSeries: elSeries
  5998. });
  5999. return {
  6000. pathTo: paths.pathTo,
  6001. pathFrom: paths.pathFrom,
  6002. x: x,
  6003. y: y,
  6004. barYPosition: barYPosition
  6005. };
  6006. }
  6007. }, {
  6008. key: "drawColumnPaths",
  6009. value: function drawColumnPaths(_ref3) {
  6010. var indexes = _ref3.indexes,
  6011. x = _ref3.x,
  6012. y = _ref3.y,
  6013. xDivision = _ref3.xDivision,
  6014. barWidth = _ref3.barWidth,
  6015. zeroH = _ref3.zeroH,
  6016. strokeWidth = _ref3.strokeWidth,
  6017. elSeries = _ref3.elSeries;
  6018. var w = this.w;
  6019. var i = indexes.i;
  6020. var j = indexes.j;
  6021. var bc = indexes.bc;
  6022. if (w.globals.isXNumeric) {
  6023. var sxI = i;
  6024. if (!w.globals.seriesX[i].length) {
  6025. sxI = w.globals.maxValsInArrayIndex;
  6026. }
  6027. x = (w.globals.seriesX[sxI][j] - w.globals.minX) / this.xRatio - barWidth * this.seriesLen / 2;
  6028. }
  6029. var barXPosition = x + barWidth * this.visibleI;
  6030. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  6031. y = zeroH;
  6032. } else {
  6033. y = zeroH - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
  6034. }
  6035. var paths = this.barHelpers.getColumnPaths({
  6036. barXPosition: barXPosition,
  6037. barWidth: barWidth,
  6038. y1: zeroH,
  6039. y2: y,
  6040. strokeWidth: strokeWidth,
  6041. series: this.series,
  6042. realIndex: indexes.realIndex,
  6043. i: i,
  6044. j: j,
  6045. w: w
  6046. });
  6047. if (!w.globals.isXNumeric) {
  6048. x = x + xDivision;
  6049. }
  6050. this.barHelpers.barBackground({
  6051. bc: bc,
  6052. i: i,
  6053. x1: barXPosition - strokeWidth / 2 - barWidth * this.visibleI,
  6054. x2: barWidth * this.seriesLen + strokeWidth / 2,
  6055. elSeries: elSeries
  6056. });
  6057. return {
  6058. pathTo: paths.pathTo,
  6059. pathFrom: paths.pathFrom,
  6060. x: x,
  6061. y: y,
  6062. barXPosition: barXPosition
  6063. };
  6064. }
  6065. /** getPreviousPath is a common function for bars/columns which is used to get previous paths when data changes.
  6066. * @memberof Bar
  6067. * @param {int} realIndex - current iterating i
  6068. * @param {int} j - current iterating series's j index
  6069. * @return {string} pathFrom is the string which will be appended in animations
  6070. **/
  6071. }, {
  6072. key: "getPreviousPath",
  6073. value: function getPreviousPath(realIndex, j) {
  6074. var w = this.w;
  6075. var pathFrom;
  6076. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  6077. var gpp = w.globals.previousPaths[pp];
  6078. if (gpp.paths && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  6079. if (typeof w.globals.previousPaths[pp].paths[j] !== 'undefined') {
  6080. pathFrom = w.globals.previousPaths[pp].paths[j].d;
  6081. }
  6082. }
  6083. }
  6084. return pathFrom;
  6085. }
  6086. }]);
  6087. return Bar;
  6088. }();
  6089. /**
  6090. * DateTime Class to manipulate datetime values.
  6091. *
  6092. * @module DateTime
  6093. **/
  6094. var DateTime = /*#__PURE__*/function () {
  6095. function DateTime(ctx) {
  6096. _classCallCheck(this, DateTime);
  6097. this.ctx = ctx;
  6098. this.w = ctx.w;
  6099. this.months31 = [1, 3, 5, 7, 8, 10, 12];
  6100. this.months30 = [2, 4, 6, 9, 11];
  6101. this.daysCntOfYear = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
  6102. }
  6103. _createClass(DateTime, [{
  6104. key: "isValidDate",
  6105. value: function isValidDate(date) {
  6106. return !isNaN(this.parseDate(date));
  6107. }
  6108. }, {
  6109. key: "getTimeStamp",
  6110. value: function getTimeStamp(dateStr) {
  6111. if (!Date.parse(dateStr)) {
  6112. return dateStr;
  6113. }
  6114. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6115. return !utc ? new Date(dateStr).getTime() : new Date(new Date(dateStr).toISOString().substr(0, 25)).getTime();
  6116. }
  6117. }, {
  6118. key: "getDate",
  6119. value: function getDate(timestamp) {
  6120. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6121. return utc ? new Date(new Date(timestamp).toUTCString()) : new Date(timestamp);
  6122. }
  6123. }, {
  6124. key: "parseDate",
  6125. value: function parseDate(dateStr) {
  6126. var parsed = Date.parse(dateStr);
  6127. if (!isNaN(parsed)) {
  6128. return this.getTimeStamp(dateStr);
  6129. }
  6130. var output = Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' '));
  6131. output = this.getTimeStamp(output);
  6132. return output;
  6133. } // http://stackoverflow.com/questions/14638018/current-time-formatting-with-javascript#answer-14638191
  6134. }, {
  6135. key: "formatDate",
  6136. value: function formatDate(date, format) {
  6137. var locale = this.w.globals.locale;
  6138. var utc = this.w.config.xaxis.labels.datetimeUTC;
  6139. var MMMM = ['\x00'].concat(_toConsumableArray(locale.months));
  6140. var MMM = ['\x01'].concat(_toConsumableArray(locale.shortMonths));
  6141. var dddd = ['\x02'].concat(_toConsumableArray(locale.days));
  6142. var ddd = ['\x03'].concat(_toConsumableArray(locale.shortDays));
  6143. function ii(i, len) {
  6144. var s = i + '';
  6145. len = len || 2;
  6146. while (s.length < len) {
  6147. s = '0' + s;
  6148. }
  6149. return s;
  6150. }
  6151. var y = utc ? date.getUTCFullYear() : date.getFullYear();
  6152. format = format.replace(/(^|[^\\])yyyy+/g, '$1' + y);
  6153. format = format.replace(/(^|[^\\])yy/g, '$1' + y.toString().substr(2, 2));
  6154. format = format.replace(/(^|[^\\])y/g, '$1' + y);
  6155. var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1;
  6156. format = format.replace(/(^|[^\\])MMMM+/g, '$1' + MMMM[0]);
  6157. format = format.replace(/(^|[^\\])MMM/g, '$1' + MMM[0]);
  6158. format = format.replace(/(^|[^\\])MM/g, '$1' + ii(M));
  6159. format = format.replace(/(^|[^\\])M/g, '$1' + M);
  6160. var d = utc ? date.getUTCDate() : date.getDate();
  6161. format = format.replace(/(^|[^\\])dddd+/g, '$1' + dddd[0]);
  6162. format = format.replace(/(^|[^\\])ddd/g, '$1' + ddd[0]);
  6163. format = format.replace(/(^|[^\\])dd/g, '$1' + ii(d));
  6164. format = format.replace(/(^|[^\\])d/g, '$1' + d);
  6165. var H = utc ? date.getUTCHours() : date.getHours();
  6166. format = format.replace(/(^|[^\\])HH+/g, '$1' + ii(H));
  6167. format = format.replace(/(^|[^\\])H/g, '$1' + H);
  6168. var h = H > 12 ? H - 12 : H === 0 ? 12 : H;
  6169. format = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h));
  6170. format = format.replace(/(^|[^\\])h/g, '$1' + h);
  6171. var m = utc ? date.getUTCMinutes() : date.getMinutes();
  6172. format = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m));
  6173. format = format.replace(/(^|[^\\])m/g, '$1' + m);
  6174. var s = utc ? date.getUTCSeconds() : date.getSeconds();
  6175. format = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s));
  6176. format = format.replace(/(^|[^\\])s/g, '$1' + s);
  6177. var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
  6178. format = format.replace(/(^|[^\\])fff+/g, '$1' + ii(f, 3));
  6179. f = Math.round(f / 10);
  6180. format = format.replace(/(^|[^\\])ff/g, '$1' + ii(f));
  6181. f = Math.round(f / 10);
  6182. format = format.replace(/(^|[^\\])f/g, '$1' + f);
  6183. var T = H < 12 ? 'AM' : 'PM';
  6184. format = format.replace(/(^|[^\\])TT+/g, '$1' + T);
  6185. format = format.replace(/(^|[^\\])T/g, '$1' + T.charAt(0));
  6186. var t = T.toLowerCase();
  6187. format = format.replace(/(^|[^\\])tt+/g, '$1' + t);
  6188. format = format.replace(/(^|[^\\])t/g, '$1' + t.charAt(0));
  6189. var tz = -date.getTimezoneOffset();
  6190. var K = utc || !tz ? 'Z' : tz > 0 ? '+' : '-';
  6191. if (!utc) {
  6192. tz = Math.abs(tz);
  6193. var tzHrs = Math.floor(tz / 60);
  6194. var tzMin = tz % 60;
  6195. K += ii(tzHrs) + ':' + ii(tzMin);
  6196. }
  6197. format = format.replace(/(^|[^\\])K/g, '$1' + K);
  6198. var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
  6199. format = format.replace(new RegExp(dddd[0], 'g'), dddd[day]);
  6200. format = format.replace(new RegExp(ddd[0], 'g'), ddd[day]);
  6201. format = format.replace(new RegExp(MMMM[0], 'g'), MMMM[M]);
  6202. format = format.replace(new RegExp(MMM[0], 'g'), MMM[M]);
  6203. format = format.replace(/\\(.)/g, '$1');
  6204. return format;
  6205. }
  6206. }, {
  6207. key: "getTimeUnitsfromTimestamp",
  6208. value: function getTimeUnitsfromTimestamp(minX, maxX, utc) {
  6209. var w = this.w;
  6210. if (w.config.xaxis.min !== undefined) {
  6211. minX = w.config.xaxis.min;
  6212. }
  6213. if (w.config.xaxis.max !== undefined) {
  6214. maxX = w.config.xaxis.max;
  6215. }
  6216. var tsMin = this.getDate(minX);
  6217. var tsMax = this.getDate(maxX);
  6218. var minD = this.formatDate(tsMin, 'yyyy MM dd HH mm').split(' ');
  6219. var maxD = this.formatDate(tsMax, 'yyyy MM dd HH mm').split(' ');
  6220. return {
  6221. minMinute: parseInt(minD[4], 10),
  6222. maxMinute: parseInt(maxD[4], 10),
  6223. minHour: parseInt(minD[3], 10),
  6224. maxHour: parseInt(maxD[3], 10),
  6225. minDate: parseInt(minD[2], 10),
  6226. maxDate: parseInt(maxD[2], 10),
  6227. minMonth: parseInt(minD[1], 10) - 1,
  6228. maxMonth: parseInt(maxD[1], 10) - 1,
  6229. minYear: parseInt(minD[0], 10),
  6230. maxYear: parseInt(maxD[0], 10)
  6231. };
  6232. }
  6233. }, {
  6234. key: "isLeapYear",
  6235. value: function isLeapYear(year) {
  6236. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  6237. }
  6238. }, {
  6239. key: "calculcateLastDaysOfMonth",
  6240. value: function calculcateLastDaysOfMonth(month, year, subtract) {
  6241. var days = this.determineDaysOfMonths(month, year); // whatever days we get, subtract the number of days asked
  6242. return days - subtract;
  6243. }
  6244. }, {
  6245. key: "determineDaysOfYear",
  6246. value: function determineDaysOfYear(year) {
  6247. var days = 365;
  6248. if (this.isLeapYear(year)) {
  6249. days = 366;
  6250. }
  6251. return days;
  6252. }
  6253. }, {
  6254. key: "determineRemainingDaysOfYear",
  6255. value: function determineRemainingDaysOfYear(year, month, date) {
  6256. var dayOfYear = this.daysCntOfYear[month] + date;
  6257. if (month > 1 && this.isLeapYear()) dayOfYear++;
  6258. return dayOfYear;
  6259. }
  6260. }, {
  6261. key: "determineDaysOfMonths",
  6262. value: function determineDaysOfMonths(month, year) {
  6263. var days = 30;
  6264. month = Utils.monthMod(month);
  6265. switch (true) {
  6266. case this.months30.indexOf(month) > -1:
  6267. if (month === 2) {
  6268. if (this.isLeapYear(year)) {
  6269. days = 29;
  6270. } else {
  6271. days = 28;
  6272. }
  6273. }
  6274. break;
  6275. case this.months31.indexOf(month) > -1:
  6276. days = 31;
  6277. break;
  6278. default:
  6279. days = 31;
  6280. break;
  6281. }
  6282. return days;
  6283. }
  6284. }]);
  6285. return DateTime;
  6286. }();
  6287. /**
  6288. * ApexCharts RangeBar Class responsible for drawing Range/Timeline Bars.
  6289. *
  6290. * @module RangeBar
  6291. **/
  6292. var RangeBar = /*#__PURE__*/function (_Bar) {
  6293. _inherits(RangeBar, _Bar);
  6294. function RangeBar() {
  6295. _classCallCheck(this, RangeBar);
  6296. return _possibleConstructorReturn(this, _getPrototypeOf(RangeBar).apply(this, arguments));
  6297. }
  6298. _createClass(RangeBar, [{
  6299. key: "draw",
  6300. value: function draw(series, seriesIndex) {
  6301. var w = this.w;
  6302. var graphics = new Graphics(this.ctx);
  6303. this.rangeBarOptions = this.w.config.plotOptions.rangeBar;
  6304. this.series = series;
  6305. this.seriesRangeStart = w.globals.seriesRangeStart;
  6306. this.seriesRangeEnd = w.globals.seriesRangeEnd;
  6307. this.barHelpers.initVariables(series);
  6308. var ret = graphics.group({
  6309. class: 'apexcharts-rangebar-series apexcharts-plot-series'
  6310. });
  6311. for (var i = 0; i < series.length; i++) {
  6312. var x = void 0,
  6313. y = void 0,
  6314. xDivision = void 0,
  6315. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  6316. yDivision = void 0,
  6317. // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  6318. zeroH = void 0,
  6319. // zeroH is the baseline where 0 meets y axis
  6320. zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  6321. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  6322. var elSeries = graphics.group({
  6323. class: "apexcharts-series",
  6324. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  6325. rel: i + 1,
  6326. 'data:realIndex': realIndex
  6327. });
  6328. if (series[i].length > 0) {
  6329. this.visibleI = this.visibleI + 1;
  6330. }
  6331. var barHeight = 0;
  6332. var barWidth = 0;
  6333. if (this.yRatio.length > 1) {
  6334. this.yaxisIndex = realIndex;
  6335. }
  6336. var initPositions = this.barHelpers.initialPositions();
  6337. y = initPositions.y;
  6338. zeroW = initPositions.zeroW;
  6339. x = initPositions.x;
  6340. barWidth = initPositions.barWidth;
  6341. xDivision = initPositions.xDivision;
  6342. zeroH = initPositions.zeroH; // eldatalabels
  6343. var elDataLabelsWrap = graphics.group({
  6344. class: 'apexcharts-datalabels',
  6345. 'data:realIndex': realIndex
  6346. });
  6347. for (var j = 0; j < w.globals.dataPoints; j++) {
  6348. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  6349. var y1 = this.seriesRangeStart[i][j];
  6350. var y2 = this.seriesRangeEnd[i][j];
  6351. var paths = null;
  6352. var barYPosition = null;
  6353. var params = {
  6354. x: x,
  6355. y: y,
  6356. strokeWidth: strokeWidth,
  6357. elSeries: elSeries
  6358. };
  6359. yDivision = initPositions.yDivision;
  6360. barHeight = initPositions.barHeight;
  6361. if (this.isHorizontal) {
  6362. barYPosition = y + barHeight * this.visibleI;
  6363. var srty = (yDivision - barHeight * this.seriesLen) / 2;
  6364. if (typeof w.config.series[i].data[j] === 'undefined') {
  6365. // no data exists for further indexes, hence we need to get out the innr loop.
  6366. // As we are iterating over total datapoints, there is a possiblity the series might not have data for j index
  6367. break;
  6368. }
  6369. if (this.isTimelineBar && w.config.series[i].data[j].x) {
  6370. var positions = this.detectOverlappingBars({
  6371. i: i,
  6372. j: j,
  6373. barYPosition: barYPosition,
  6374. srty: srty,
  6375. barHeight: barHeight,
  6376. yDivision: yDivision,
  6377. initPositions: initPositions
  6378. });
  6379. barHeight = positions.barHeight;
  6380. barYPosition = positions.barYPosition;
  6381. }
  6382. paths = this.drawRangeBarPaths(_objectSpread2({
  6383. indexes: {
  6384. i: i,
  6385. j: j,
  6386. realIndex: realIndex
  6387. },
  6388. barHeight: barHeight,
  6389. barYPosition: barYPosition,
  6390. zeroW: zeroW,
  6391. yDivision: yDivision,
  6392. y1: y1,
  6393. y2: y2
  6394. }, params));
  6395. barWidth = paths.barWidth;
  6396. } else {
  6397. paths = this.drawRangeColumnPaths(_objectSpread2({
  6398. indexes: {
  6399. i: i,
  6400. j: j,
  6401. realIndex: realIndex
  6402. },
  6403. zeroH: zeroH,
  6404. barWidth: barWidth,
  6405. xDivision: xDivision
  6406. }, params));
  6407. barHeight = paths.barHeight;
  6408. }
  6409. y = paths.y;
  6410. x = paths.x;
  6411. var pathFill = this.barHelpers.getPathFillColor(series, i, j, realIndex);
  6412. var lineFill = w.globals.stroke.colors[realIndex];
  6413. this.renderSeries({
  6414. realIndex: realIndex,
  6415. pathFill: pathFill,
  6416. lineFill: lineFill,
  6417. j: j,
  6418. i: i,
  6419. x: x,
  6420. y: y,
  6421. y1: y1,
  6422. y2: y2,
  6423. pathFrom: paths.pathFrom,
  6424. pathTo: paths.pathTo,
  6425. strokeWidth: strokeWidth,
  6426. elSeries: elSeries,
  6427. series: series,
  6428. barHeight: barHeight,
  6429. barYPosition: barYPosition,
  6430. barWidth: barWidth,
  6431. elDataLabelsWrap: elDataLabelsWrap,
  6432. visibleSeries: this.visibleI,
  6433. type: 'rangebar'
  6434. });
  6435. }
  6436. ret.add(elSeries);
  6437. }
  6438. return ret;
  6439. }
  6440. }, {
  6441. key: "detectOverlappingBars",
  6442. value: function detectOverlappingBars(_ref) {
  6443. var i = _ref.i,
  6444. j = _ref.j,
  6445. barYPosition = _ref.barYPosition,
  6446. srty = _ref.srty,
  6447. barHeight = _ref.barHeight,
  6448. yDivision = _ref.yDivision,
  6449. initPositions = _ref.initPositions;
  6450. var w = this.w;
  6451. var overlaps = [];
  6452. var rangeName = w.config.series[i].data[j].rangeName;
  6453. var labelX = w.config.series[i].data[j].x;
  6454. var rowIndex = w.globals.labels.indexOf(labelX);
  6455. var overlappedIndex = w.globals.seriesRangeBarTimeline[i].findIndex(function (tx) {
  6456. return tx.x === labelX && tx.overlaps.length > 0;
  6457. });
  6458. barYPosition = srty + barHeight * this.visibleI + yDivision * rowIndex;
  6459. if (overlappedIndex > -1 && !w.config.plotOptions.bar.rangeBarOverlap) {
  6460. overlaps = w.globals.seriesRangeBarTimeline[i][overlappedIndex].overlaps;
  6461. if (overlaps.indexOf(rangeName) > -1) {
  6462. barHeight = initPositions.barHeight / overlaps.length;
  6463. barYPosition = barHeight * this.visibleI + yDivision * (100 - parseInt(this.barOptions.barHeight, 10)) / 100 / 2 + barHeight * (this.visibleI + overlaps.indexOf(rangeName)) + yDivision * rowIndex;
  6464. }
  6465. }
  6466. return {
  6467. barYPosition: barYPosition,
  6468. barHeight: barHeight
  6469. };
  6470. }
  6471. }, {
  6472. key: "drawRangeColumnPaths",
  6473. value: function drawRangeColumnPaths(_ref2) {
  6474. var indexes = _ref2.indexes,
  6475. x = _ref2.x,
  6476. strokeWidth = _ref2.strokeWidth,
  6477. xDivision = _ref2.xDivision,
  6478. barWidth = _ref2.barWidth,
  6479. zeroH = _ref2.zeroH;
  6480. var w = this.w;
  6481. var i = indexes.i;
  6482. var j = indexes.j;
  6483. var yRatio = this.yRatio[this.yaxisIndex];
  6484. var realIndex = indexes.realIndex;
  6485. var range = this.getRangeValue(realIndex, j);
  6486. var y1 = Math.min(range.start, range.end);
  6487. var y2 = Math.max(range.start, range.end);
  6488. if (w.globals.isXNumeric) {
  6489. x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  6490. }
  6491. var barXPosition = x + barWidth * this.visibleI;
  6492. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  6493. y1 = zeroH;
  6494. } else {
  6495. y1 = zeroH - y1 / yRatio;
  6496. y2 = zeroH - y2 / yRatio;
  6497. }
  6498. var barHeight = Math.abs(y2 - y1);
  6499. var paths = this.barHelpers.getColumnPaths({
  6500. barXPosition: barXPosition,
  6501. barWidth: barWidth,
  6502. y1: y1,
  6503. y2: y2,
  6504. strokeWidth: this.strokeWidth,
  6505. series: this.seriesRangeEnd,
  6506. i: realIndex,
  6507. j: j,
  6508. w: w
  6509. });
  6510. if (!w.globals.isXNumeric) {
  6511. x = x + xDivision;
  6512. }
  6513. return {
  6514. pathTo: paths.pathTo,
  6515. pathFrom: paths.pathFrom,
  6516. barHeight: barHeight,
  6517. x: x,
  6518. y: y2,
  6519. barXPosition: barXPosition
  6520. };
  6521. }
  6522. }, {
  6523. key: "drawRangeBarPaths",
  6524. value: function drawRangeBarPaths(_ref3) {
  6525. var indexes = _ref3.indexes,
  6526. y = _ref3.y,
  6527. y1 = _ref3.y1,
  6528. y2 = _ref3.y2,
  6529. yDivision = _ref3.yDivision,
  6530. barHeight = _ref3.barHeight,
  6531. barYPosition = _ref3.barYPosition,
  6532. zeroW = _ref3.zeroW;
  6533. var w = this.w;
  6534. var x1 = zeroW + y1 / this.invertedYRatio;
  6535. var x2 = zeroW + y2 / this.invertedYRatio;
  6536. var barWidth = Math.abs(x2 - x1);
  6537. var paths = this.barHelpers.getBarpaths({
  6538. barYPosition: barYPosition,
  6539. barHeight: barHeight,
  6540. x1: x1,
  6541. x2: x2,
  6542. strokeWidth: this.strokeWidth,
  6543. series: this.seriesRangeEnd,
  6544. i: indexes.realIndex,
  6545. j: indexes.j,
  6546. w: w
  6547. });
  6548. if (!w.globals.isXNumeric) {
  6549. y = y + yDivision;
  6550. }
  6551. return {
  6552. pathTo: paths.pathTo,
  6553. pathFrom: paths.pathFrom,
  6554. barWidth: barWidth,
  6555. x: x2,
  6556. y: y
  6557. };
  6558. }
  6559. }, {
  6560. key: "getRangeValue",
  6561. value: function getRangeValue(i, j) {
  6562. var w = this.w;
  6563. return {
  6564. start: w.globals.seriesRangeStart[i][j],
  6565. end: w.globals.seriesRangeEnd[i][j]
  6566. };
  6567. }
  6568. }, {
  6569. key: "getTooltipValues",
  6570. value: function getTooltipValues(_ref4) {
  6571. var ctx = _ref4.ctx,
  6572. seriesIndex = _ref4.seriesIndex,
  6573. dataPointIndex = _ref4.dataPointIndex,
  6574. y1 = _ref4.y1,
  6575. y2 = _ref4.y2,
  6576. w = _ref4.w;
  6577. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  6578. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  6579. var ylabel = w.globals.labels[dataPointIndex];
  6580. var seriesName = w.config.series[seriesIndex].name;
  6581. var yLbFormatter = w.config.tooltip.y.formatter;
  6582. var yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  6583. var opts = {
  6584. w: w,
  6585. seriesIndex: seriesIndex,
  6586. dataPointIndex: dataPointIndex
  6587. };
  6588. if (typeof yLbTitleFormatter === 'function') {
  6589. seriesName = yLbTitleFormatter(seriesName, opts);
  6590. }
  6591. if (y1 && y2) {
  6592. start = y1;
  6593. end = y2;
  6594. if (w.config.series[seriesIndex].data[dataPointIndex].x) {
  6595. ylabel = w.config.series[seriesIndex].data[dataPointIndex].x + ':';
  6596. }
  6597. if (typeof yLbFormatter === 'function') {
  6598. ylabel = yLbFormatter(ylabel, opts);
  6599. }
  6600. }
  6601. var startVal = '';
  6602. var endVal = '';
  6603. var color = w.globals.colors[seriesIndex];
  6604. if (w.config.tooltip.x.formatter === undefined) {
  6605. if (w.config.xaxis.type === 'datetime') {
  6606. var datetimeObj = new DateTime(ctx);
  6607. startVal = datetimeObj.formatDate(datetimeObj.getDate(start), w.config.tooltip.x.format);
  6608. endVal = datetimeObj.formatDate(datetimeObj.getDate(end), w.config.tooltip.x.format);
  6609. } else {
  6610. startVal = start;
  6611. endVal = end;
  6612. }
  6613. } else {
  6614. startVal = w.config.tooltip.x.formatter(start);
  6615. endVal = w.config.tooltip.x.formatter(end);
  6616. }
  6617. return {
  6618. start: start,
  6619. end: end,
  6620. startVal: startVal,
  6621. endVal: endVal,
  6622. ylabel: ylabel,
  6623. color: color,
  6624. seriesName: seriesName
  6625. };
  6626. }
  6627. }, {
  6628. key: "buildCustomTooltipHTML",
  6629. value: function buildCustomTooltipHTML(_ref5) {
  6630. var color = _ref5.color,
  6631. seriesName = _ref5.seriesName,
  6632. ylabel = _ref5.ylabel,
  6633. start = _ref5.start,
  6634. end = _ref5.end;
  6635. 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>';
  6636. }
  6637. }]);
  6638. return RangeBar;
  6639. }(Bar);
  6640. /**
  6641. * ApexCharts Default Class for setting default options for all chart types.
  6642. *
  6643. * @module Defaults
  6644. **/
  6645. var Defaults = /*#__PURE__*/function () {
  6646. function Defaults(opts) {
  6647. _classCallCheck(this, Defaults);
  6648. this.opts = opts;
  6649. }
  6650. _createClass(Defaults, [{
  6651. key: "line",
  6652. value: function line() {
  6653. return {
  6654. chart: {
  6655. animations: {
  6656. easing: 'swing'
  6657. }
  6658. },
  6659. dataLabels: {
  6660. enabled: false
  6661. },
  6662. stroke: {
  6663. width: 5,
  6664. curve: 'straight'
  6665. },
  6666. markers: {
  6667. size: 0,
  6668. hover: {
  6669. sizeOffset: 6
  6670. }
  6671. },
  6672. xaxis: {
  6673. crosshairs: {
  6674. width: 1
  6675. }
  6676. }
  6677. };
  6678. }
  6679. }, {
  6680. key: "sparkline",
  6681. value: function sparkline(defaults) {
  6682. this.opts.yaxis[0].show = false;
  6683. this.opts.yaxis[0].title.text = '';
  6684. this.opts.yaxis[0].axisBorder.show = false;
  6685. this.opts.yaxis[0].axisTicks.show = false;
  6686. this.opts.yaxis[0].floating = true;
  6687. var ret = {
  6688. grid: {
  6689. show: false,
  6690. padding: {
  6691. left: 0,
  6692. right: 0,
  6693. top: 0,
  6694. bottom: 0
  6695. }
  6696. },
  6697. legend: {
  6698. show: false
  6699. },
  6700. xaxis: {
  6701. labels: {
  6702. show: false
  6703. },
  6704. tooltip: {
  6705. enabled: false
  6706. },
  6707. axisBorder: {
  6708. show: false
  6709. },
  6710. axisTicks: {
  6711. show: false
  6712. }
  6713. },
  6714. chart: {
  6715. toolbar: {
  6716. show: false
  6717. },
  6718. zoom: {
  6719. enabled: false
  6720. }
  6721. },
  6722. dataLabels: {
  6723. enabled: false
  6724. }
  6725. };
  6726. return Utils.extend(defaults, ret);
  6727. }
  6728. }, {
  6729. key: "bar",
  6730. value: function bar() {
  6731. return {
  6732. chart: {
  6733. stacked: false,
  6734. animations: {
  6735. easing: 'swing'
  6736. }
  6737. },
  6738. plotOptions: {
  6739. bar: {
  6740. dataLabels: {
  6741. position: 'center'
  6742. }
  6743. }
  6744. },
  6745. dataLabels: {
  6746. style: {
  6747. colors: ['#fff']
  6748. },
  6749. background: {
  6750. enabled: false
  6751. }
  6752. },
  6753. stroke: {
  6754. width: 0,
  6755. lineCap: 'square'
  6756. },
  6757. fill: {
  6758. opacity: 0.85
  6759. },
  6760. legend: {
  6761. markers: {
  6762. shape: 'square',
  6763. radius: 2,
  6764. size: 8
  6765. }
  6766. },
  6767. tooltip: {
  6768. shared: false
  6769. },
  6770. xaxis: {
  6771. tooltip: {
  6772. enabled: false
  6773. },
  6774. tickPlacement: 'between',
  6775. crosshairs: {
  6776. width: 'barWidth',
  6777. position: 'back',
  6778. fill: {
  6779. type: 'gradient'
  6780. },
  6781. dropShadow: {
  6782. enabled: false
  6783. },
  6784. stroke: {
  6785. width: 0
  6786. }
  6787. }
  6788. }
  6789. };
  6790. }
  6791. }, {
  6792. key: "candlestick",
  6793. value: function candlestick() {
  6794. return {
  6795. stroke: {
  6796. width: 1,
  6797. colors: ['#333']
  6798. },
  6799. fill: {
  6800. opacity: 1
  6801. },
  6802. dataLabels: {
  6803. enabled: false
  6804. },
  6805. tooltip: {
  6806. shared: true,
  6807. custom: function custom(_ref) {
  6808. var seriesIndex = _ref.seriesIndex,
  6809. dataPointIndex = _ref.dataPointIndex,
  6810. w = _ref.w;
  6811. var o = w.globals.seriesCandleO[seriesIndex][dataPointIndex];
  6812. var h = w.globals.seriesCandleH[seriesIndex][dataPointIndex];
  6813. var l = w.globals.seriesCandleL[seriesIndex][dataPointIndex];
  6814. var c = w.globals.seriesCandleC[seriesIndex][dataPointIndex];
  6815. return '<div class="apexcharts-tooltip-candlestick">' + '<div>Open: <span class="value">' + o + '</span></div>' + '<div>High: <span class="value">' + h + '</span></div>' + '<div>Low: <span class="value">' + l + '</span></div>' + '<div>Close: <span class="value">' + c + '</span></div>' + '</div>';
  6816. }
  6817. },
  6818. states: {
  6819. active: {
  6820. filter: {
  6821. type: 'none'
  6822. }
  6823. }
  6824. },
  6825. xaxis: {
  6826. crosshairs: {
  6827. width: 1
  6828. }
  6829. }
  6830. };
  6831. }
  6832. }, {
  6833. key: "rangeBar",
  6834. value: function rangeBar() {
  6835. var handleTimelineTooltip = function handleTimelineTooltip(opts) {
  6836. var rangeCtx = new RangeBar(opts.ctx, null);
  6837. var _rangeCtx$getTooltipV = rangeCtx.getTooltipValues(opts),
  6838. color = _rangeCtx$getTooltipV.color,
  6839. seriesName = _rangeCtx$getTooltipV.seriesName,
  6840. ylabel = _rangeCtx$getTooltipV.ylabel,
  6841. startVal = _rangeCtx$getTooltipV.startVal,
  6842. endVal = _rangeCtx$getTooltipV.endVal;
  6843. return rangeCtx.buildCustomTooltipHTML({
  6844. color: color,
  6845. seriesName: seriesName,
  6846. ylabel: ylabel,
  6847. start: startVal,
  6848. end: endVal
  6849. });
  6850. };
  6851. var handleRangeColumnTooltip = function handleRangeColumnTooltip(opts) {
  6852. var rangeCtx = new RangeBar(opts.ctx, null);
  6853. var _rangeCtx$getTooltipV2 = rangeCtx.getTooltipValues(opts),
  6854. color = _rangeCtx$getTooltipV2.color,
  6855. seriesName = _rangeCtx$getTooltipV2.seriesName,
  6856. ylabel = _rangeCtx$getTooltipV2.ylabel,
  6857. start = _rangeCtx$getTooltipV2.start,
  6858. end = _rangeCtx$getTooltipV2.end;
  6859. return rangeCtx.buildCustomTooltipHTML({
  6860. color: color,
  6861. seriesName: seriesName,
  6862. ylabel: ylabel,
  6863. start: start,
  6864. end: end
  6865. });
  6866. };
  6867. return {
  6868. stroke: {
  6869. width: 0,
  6870. lineCap: 'square'
  6871. },
  6872. plotOptions: {
  6873. bar: {
  6874. dataLabels: {
  6875. position: 'center'
  6876. }
  6877. }
  6878. },
  6879. dataLabels: {
  6880. enabled: false,
  6881. formatter: function formatter(val, _ref2) {
  6882. var ctx = _ref2.ctx,
  6883. seriesIndex = _ref2.seriesIndex,
  6884. dataPointIndex = _ref2.dataPointIndex,
  6885. w = _ref2.w;
  6886. var start = w.globals.seriesRangeStart[seriesIndex][dataPointIndex];
  6887. var end = w.globals.seriesRangeEnd[seriesIndex][dataPointIndex];
  6888. return end - start;
  6889. },
  6890. background: {
  6891. enabled: false
  6892. },
  6893. style: {
  6894. colors: ['#fff']
  6895. }
  6896. },
  6897. tooltip: {
  6898. shared: false,
  6899. followCursor: true,
  6900. custom: function custom(opts) {
  6901. if (opts.w.config.plotOptions && opts.w.config.plotOptions.bar && opts.w.config.plotOptions.bar.horizontal) {
  6902. return handleTimelineTooltip(opts);
  6903. } else {
  6904. return handleRangeColumnTooltip(opts);
  6905. }
  6906. }
  6907. },
  6908. xaxis: {
  6909. tickPlacement: 'between',
  6910. tooltip: {
  6911. enabled: false
  6912. },
  6913. crosshairs: {
  6914. stroke: {
  6915. width: 0
  6916. }
  6917. }
  6918. }
  6919. };
  6920. }
  6921. }, {
  6922. key: "area",
  6923. value: function area() {
  6924. return {
  6925. stroke: {
  6926. width: 4
  6927. },
  6928. fill: {
  6929. type: 'gradient',
  6930. gradient: {
  6931. inverseColors: false,
  6932. shade: 'light',
  6933. type: 'vertical',
  6934. opacityFrom: 0.65,
  6935. opacityTo: 0.5,
  6936. stops: [0, 100, 100]
  6937. }
  6938. },
  6939. markers: {
  6940. size: 0,
  6941. hover: {
  6942. sizeOffset: 6
  6943. }
  6944. },
  6945. tooltip: {
  6946. followCursor: false
  6947. }
  6948. };
  6949. }
  6950. }, {
  6951. key: "brush",
  6952. value: function brush(defaults) {
  6953. var ret = {
  6954. chart: {
  6955. toolbar: {
  6956. autoSelected: 'selection',
  6957. show: false
  6958. },
  6959. zoom: {
  6960. enabled: false
  6961. }
  6962. },
  6963. dataLabels: {
  6964. enabled: false
  6965. },
  6966. stroke: {
  6967. width: 1
  6968. },
  6969. tooltip: {
  6970. enabled: false
  6971. },
  6972. xaxis: {
  6973. tooltip: {
  6974. enabled: false
  6975. }
  6976. }
  6977. };
  6978. return Utils.extend(defaults, ret);
  6979. }
  6980. }, {
  6981. key: "stacked100",
  6982. value: function stacked100(opts) {
  6983. opts.dataLabels = opts.dataLabels || {};
  6984. opts.dataLabels.formatter = opts.dataLabels.formatter || undefined;
  6985. var existingDataLabelFormatter = opts.dataLabels.formatter;
  6986. opts.yaxis.forEach(function (yaxe, index) {
  6987. opts.yaxis[index].min = 0;
  6988. opts.yaxis[index].max = 100;
  6989. });
  6990. var isBar = opts.chart.type === 'bar';
  6991. if (isBar) {
  6992. opts.dataLabels.formatter = existingDataLabelFormatter || function (val) {
  6993. if (typeof val === 'number') {
  6994. return val ? val.toFixed(0) + '%' : val;
  6995. }
  6996. return val;
  6997. };
  6998. }
  6999. return opts;
  7000. } // 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
  7001. }, {
  7002. key: "convertCatToNumeric",
  7003. value: function convertCatToNumeric(opts) {
  7004. opts.xaxis.convertedCatToNumeric = true;
  7005. return opts;
  7006. }
  7007. }, {
  7008. key: "convertCatToNumericXaxis",
  7009. value: function convertCatToNumericXaxis(opts, ctx, cats) {
  7010. opts.xaxis.type = 'numeric';
  7011. opts.xaxis.labels = opts.xaxis.labels || {};
  7012. opts.xaxis.labels.formatter = opts.xaxis.labels.formatter || function (val) {
  7013. return Utils.isNumber(val) ? Math.floor(val) : val;
  7014. };
  7015. var defaultFormatter = opts.xaxis.labels.formatter;
  7016. var labels = opts.xaxis.categories && opts.xaxis.categories.length ? opts.xaxis.categories : opts.labels;
  7017. if (cats && cats.length) {
  7018. labels = cats.map(function (c) {
  7019. return c.toString();
  7020. });
  7021. }
  7022. if (labels && labels.length) {
  7023. opts.xaxis.labels.formatter = function (val) {
  7024. return Utils.isNumber(val) ? defaultFormatter(labels[Math.floor(val) - 1]) : defaultFormatter(val);
  7025. };
  7026. }
  7027. opts.xaxis.categories = [];
  7028. opts.labels = [];
  7029. opts.xaxis.tickAmount = opts.xaxis.tickAmount || 'dataPoints';
  7030. return opts;
  7031. }
  7032. }, {
  7033. key: "bubble",
  7034. value: function bubble() {
  7035. return {
  7036. dataLabels: {
  7037. style: {
  7038. colors: ['#fff']
  7039. }
  7040. },
  7041. tooltip: {
  7042. shared: false,
  7043. intersect: true
  7044. },
  7045. xaxis: {
  7046. crosshairs: {
  7047. width: 0
  7048. }
  7049. },
  7050. fill: {
  7051. type: 'solid',
  7052. gradient: {
  7053. shade: 'light',
  7054. inverse: true,
  7055. shadeIntensity: 0.55,
  7056. opacityFrom: 0.4,
  7057. opacityTo: 0.8
  7058. }
  7059. }
  7060. };
  7061. }
  7062. }, {
  7063. key: "scatter",
  7064. value: function scatter() {
  7065. return {
  7066. dataLabels: {
  7067. enabled: false
  7068. },
  7069. tooltip: {
  7070. shared: false,
  7071. intersect: true
  7072. },
  7073. markers: {
  7074. size: 6,
  7075. strokeWidth: 1,
  7076. hover: {
  7077. sizeOffset: 2
  7078. }
  7079. }
  7080. };
  7081. }
  7082. }, {
  7083. key: "heatmap",
  7084. value: function heatmap() {
  7085. return {
  7086. chart: {
  7087. stacked: false
  7088. },
  7089. fill: {
  7090. opacity: 1
  7091. },
  7092. dataLabels: {
  7093. style: {
  7094. colors: ['#fff']
  7095. }
  7096. },
  7097. stroke: {
  7098. colors: ['#fff']
  7099. },
  7100. tooltip: {
  7101. followCursor: true,
  7102. marker: {
  7103. show: false
  7104. },
  7105. x: {
  7106. show: false
  7107. }
  7108. },
  7109. legend: {
  7110. position: 'top',
  7111. markers: {
  7112. shape: 'square',
  7113. size: 10,
  7114. offsetY: 2
  7115. }
  7116. },
  7117. grid: {
  7118. padding: {
  7119. right: 20
  7120. }
  7121. }
  7122. };
  7123. }
  7124. }, {
  7125. key: "pie",
  7126. value: function pie() {
  7127. return {
  7128. chart: {
  7129. toolbar: {
  7130. show: false
  7131. }
  7132. },
  7133. plotOptions: {
  7134. pie: {
  7135. donut: {
  7136. labels: {
  7137. show: false
  7138. }
  7139. }
  7140. }
  7141. },
  7142. dataLabels: {
  7143. formatter: function formatter(val) {
  7144. return val.toFixed(1) + '%';
  7145. },
  7146. style: {
  7147. colors: ['#fff']
  7148. },
  7149. dropShadow: {
  7150. enabled: true
  7151. }
  7152. },
  7153. stroke: {
  7154. colors: ['#fff']
  7155. },
  7156. fill: {
  7157. opacity: 1,
  7158. gradient: {
  7159. shade: 'light',
  7160. stops: [0, 100]
  7161. }
  7162. },
  7163. tooltip: {
  7164. theme: 'dark',
  7165. fillSeriesColor: true
  7166. },
  7167. legend: {
  7168. position: 'right'
  7169. }
  7170. };
  7171. }
  7172. }, {
  7173. key: "donut",
  7174. value: function donut() {
  7175. return {
  7176. chart: {
  7177. toolbar: {
  7178. show: false
  7179. }
  7180. },
  7181. dataLabels: {
  7182. formatter: function formatter(val) {
  7183. return val.toFixed(1) + '%';
  7184. },
  7185. style: {
  7186. colors: ['#fff']
  7187. },
  7188. dropShadow: {
  7189. enabled: true
  7190. }
  7191. },
  7192. stroke: {
  7193. colors: ['#fff']
  7194. },
  7195. fill: {
  7196. opacity: 1,
  7197. gradient: {
  7198. shade: 'light',
  7199. shadeIntensity: 0.35,
  7200. stops: [80, 100],
  7201. opacityFrom: 1,
  7202. opacityTo: 1
  7203. }
  7204. },
  7205. tooltip: {
  7206. theme: 'dark',
  7207. fillSeriesColor: true
  7208. },
  7209. legend: {
  7210. position: 'right'
  7211. }
  7212. };
  7213. }
  7214. }, {
  7215. key: "polarArea",
  7216. value: function polarArea() {
  7217. this.opts.yaxis[0].tickAmount = this.opts.yaxis[0].tickAmount ? this.opts.yaxis[0].tickAmount : 6;
  7218. return {
  7219. chart: {
  7220. toolbar: {
  7221. show: false
  7222. }
  7223. },
  7224. dataLabels: {
  7225. formatter: function formatter(val) {
  7226. return val.toFixed(1) + '%';
  7227. },
  7228. enabled: false
  7229. },
  7230. stroke: {
  7231. show: true,
  7232. width: 2
  7233. },
  7234. fill: {
  7235. opacity: 0.7
  7236. },
  7237. tooltip: {
  7238. theme: 'dark',
  7239. fillSeriesColor: true
  7240. },
  7241. legend: {
  7242. position: 'right'
  7243. }
  7244. };
  7245. }
  7246. }, {
  7247. key: "radar",
  7248. value: function radar() {
  7249. this.opts.yaxis[0].labels.offsetY = this.opts.yaxis[0].labels.offsetY ? this.opts.yaxis[0].labels.offsetY : 6;
  7250. return {
  7251. dataLabels: {
  7252. enabled: false,
  7253. style: {
  7254. fontSize: '11px'
  7255. }
  7256. },
  7257. stroke: {
  7258. width: 2
  7259. },
  7260. markers: {
  7261. size: 3,
  7262. strokeWidth: 1,
  7263. strokeOpacity: 1
  7264. },
  7265. fill: {
  7266. opacity: 0.2
  7267. },
  7268. tooltip: {
  7269. shared: false,
  7270. intersect: true,
  7271. followCursor: true
  7272. },
  7273. grid: {
  7274. show: false
  7275. },
  7276. xaxis: {
  7277. labels: {
  7278. formatter: function formatter(val) {
  7279. return val;
  7280. },
  7281. style: {
  7282. colors: ['#a8a8a8'],
  7283. fontSize: '11px'
  7284. }
  7285. },
  7286. tooltip: {
  7287. enabled: false
  7288. },
  7289. crosshairs: {
  7290. show: false
  7291. }
  7292. }
  7293. };
  7294. }
  7295. }, {
  7296. key: "radialBar",
  7297. value: function radialBar() {
  7298. return {
  7299. chart: {
  7300. animations: {
  7301. dynamicAnimation: {
  7302. enabled: true,
  7303. speed: 800
  7304. }
  7305. },
  7306. toolbar: {
  7307. show: false
  7308. }
  7309. },
  7310. fill: {
  7311. gradient: {
  7312. shade: 'dark',
  7313. shadeIntensity: 0.4,
  7314. inverseColors: false,
  7315. type: 'diagonal2',
  7316. opacityFrom: 1,
  7317. opacityTo: 1,
  7318. stops: [70, 98, 100]
  7319. }
  7320. },
  7321. legend: {
  7322. show: false,
  7323. position: 'right'
  7324. },
  7325. tooltip: {
  7326. enabled: false,
  7327. fillSeriesColor: true
  7328. }
  7329. };
  7330. }
  7331. }]);
  7332. return Defaults;
  7333. }();
  7334. /**
  7335. * ApexCharts Config Class for extending user options with pre-defined ApexCharts config.
  7336. *
  7337. * @module Config
  7338. **/
  7339. var Config = /*#__PURE__*/function () {
  7340. function Config(opts) {
  7341. _classCallCheck(this, Config);
  7342. this.opts = opts;
  7343. }
  7344. _createClass(Config, [{
  7345. key: "init",
  7346. value: function init(_ref) {
  7347. var responsiveOverride = _ref.responsiveOverride;
  7348. var opts = this.opts;
  7349. var options = new Options();
  7350. var defaults = new Defaults(opts);
  7351. this.chartType = opts.chart.type;
  7352. if (this.chartType === 'histogram') {
  7353. // technically, a histogram can be drawn by a column chart with no spaces in between
  7354. opts.chart.type = 'bar';
  7355. opts = Utils.extend({
  7356. plotOptions: {
  7357. bar: {
  7358. columnWidth: '99.99%'
  7359. }
  7360. }
  7361. }, opts);
  7362. }
  7363. opts = this.extendYAxis(opts);
  7364. opts = this.extendAnnotations(opts);
  7365. var config = options.init();
  7366. var newDefaults = {};
  7367. if (opts && _typeof(opts) === 'object') {
  7368. var chartDefaults = {};
  7369. var chartTypes = ['line', 'area', 'bar', 'candlestick', 'rangeBar', 'histogram', 'bubble', 'scatter', 'heatmap', 'pie', 'polarArea', 'donut', 'radar', 'radialBar'];
  7370. if (chartTypes.indexOf(opts.chart.type) !== -1) {
  7371. chartDefaults = defaults[opts.chart.type]();
  7372. } else {
  7373. chartDefaults = defaults.line();
  7374. }
  7375. if (opts.chart.brush && opts.chart.brush.enabled) {
  7376. chartDefaults = defaults.brush(chartDefaults);
  7377. }
  7378. if (opts.chart.stacked && opts.chart.stackType === '100%') {
  7379. opts = defaults.stacked100(opts);
  7380. } // If user has specified a dark theme, make the tooltip dark too
  7381. this.checkForDarkTheme(window.Apex); // check global window Apex options
  7382. this.checkForDarkTheme(opts); // check locally passed options
  7383. opts.xaxis = opts.xaxis || window.Apex.xaxis || {}; // an important boolean needs to be set here
  7384. // otherwise all the charts will have this flag set to true window.Apex.xaxis is set globally
  7385. if (!responsiveOverride) {
  7386. opts.xaxis.convertedCatToNumeric = false;
  7387. }
  7388. opts = this.checkForCatToNumericXAxis(this.chartType, chartDefaults, opts);
  7389. if (opts.chart.sparkline && opts.chart.sparkline.enabled || window.Apex.chart && window.Apex.chart.sparkline && window.Apex.chart.sparkline.enabled) {
  7390. chartDefaults = defaults.sparkline(chartDefaults);
  7391. }
  7392. newDefaults = Utils.extend(config, chartDefaults);
  7393. } // config should cascade in this fashion
  7394. // default-config < global-apex-variable-config < user-defined-config
  7395. // get GLOBALLY defined options and merge with the default config
  7396. var mergedWithDefaultConfig = Utils.extend(newDefaults, window.Apex); // get the merged config and extend with user defined config
  7397. config = Utils.extend(mergedWithDefaultConfig, opts); // some features are not supported. those mismatches should be handled
  7398. config = this.handleUserInputErrors(config);
  7399. return config;
  7400. }
  7401. }, {
  7402. key: "checkForCatToNumericXAxis",
  7403. value: function checkForCatToNumericXAxis(chartType, chartDefaults, opts) {
  7404. var defaults = new Defaults(opts);
  7405. var isBarHorizontal = chartType === 'bar' && opts.plotOptions && opts.plotOptions.bar && opts.plotOptions.bar.horizontal;
  7406. var unsupportedZoom = chartType === 'pie' || chartType === 'polarArea' || chartType === 'donut' || chartType === 'radar' || chartType === 'radialBar' || chartType === 'heatmap';
  7407. var notNumericXAxis = opts.xaxis.type !== 'datetime' && opts.xaxis.type !== 'numeric';
  7408. var tickPlacement = opts.xaxis.tickPlacement ? opts.xaxis.tickPlacement : chartDefaults.xaxis && chartDefaults.xaxis.tickPlacement;
  7409. if (!isBarHorizontal && !unsupportedZoom && notNumericXAxis && tickPlacement !== 'between') {
  7410. opts = defaults.convertCatToNumeric(opts);
  7411. }
  7412. return opts;
  7413. }
  7414. }, {
  7415. key: "extendYAxis",
  7416. value: function extendYAxis(opts, w) {
  7417. var options = new Options();
  7418. if (typeof opts.yaxis === 'undefined' || !opts.yaxis || Array.isArray(opts.yaxis) && opts.yaxis.length === 0) {
  7419. opts.yaxis = {};
  7420. } // extend global yaxis config (only if object is provided / not an array)
  7421. if (opts.yaxis.constructor !== Array && window.Apex.yaxis && window.Apex.yaxis.constructor !== Array) {
  7422. opts.yaxis = Utils.extend(opts.yaxis, window.Apex.yaxis);
  7423. } // as we can't extend nested object's array with extend, we need to do it first
  7424. // user can provide either an array or object in yaxis config
  7425. if (opts.yaxis.constructor !== Array) {
  7426. // convert the yaxis to array if user supplied object
  7427. opts.yaxis = [Utils.extend(options.yAxis, opts.yaxis)];
  7428. } else {
  7429. opts.yaxis = Utils.extendArray(opts.yaxis, options.yAxis);
  7430. }
  7431. var isLogY = false;
  7432. opts.yaxis.forEach(function (y) {
  7433. if (y.logarithmic) {
  7434. isLogY = true;
  7435. }
  7436. });
  7437. var series = opts.series;
  7438. if (w && !series) {
  7439. series = w.config.series;
  7440. } // A logarithmic chart works correctly when each series has a corresponding y-axis
  7441. // If this is not the case, we manually create yaxis for multi-series log chart
  7442. if (isLogY && series.length !== opts.yaxis.length && series.length) {
  7443. opts.yaxis = series.map(function (s, i) {
  7444. if (!s.name) {
  7445. series[i].name = "series-".concat(i + 1);
  7446. }
  7447. if (opts.yaxis[i]) {
  7448. opts.yaxis[i].seriesName = series[i].name;
  7449. return opts.yaxis[i];
  7450. } else {
  7451. var newYaxis = Utils.extend(options.yAxis, opts.yaxis[0]);
  7452. newYaxis.show = false;
  7453. return newYaxis;
  7454. }
  7455. });
  7456. }
  7457. if (isLogY && series.length > 1 && series.length !== opts.yaxis.length) {
  7458. console.warn('A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both.');
  7459. }
  7460. return opts;
  7461. } // annotations also accepts array, so we need to extend them manually
  7462. }, {
  7463. key: "extendAnnotations",
  7464. value: function extendAnnotations(opts) {
  7465. if (typeof opts.annotations === 'undefined') {
  7466. opts.annotations = {};
  7467. opts.annotations.yaxis = [];
  7468. opts.annotations.xaxis = [];
  7469. opts.annotations.points = [];
  7470. }
  7471. opts = this.extendYAxisAnnotations(opts);
  7472. opts = this.extendXAxisAnnotations(opts);
  7473. opts = this.extendPointAnnotations(opts);
  7474. return opts;
  7475. }
  7476. }, {
  7477. key: "extendYAxisAnnotations",
  7478. value: function extendYAxisAnnotations(opts) {
  7479. var options = new Options();
  7480. opts.annotations.yaxis = Utils.extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], options.yAxisAnnotation);
  7481. return opts;
  7482. }
  7483. }, {
  7484. key: "extendXAxisAnnotations",
  7485. value: function extendXAxisAnnotations(opts) {
  7486. var options = new Options();
  7487. opts.annotations.xaxis = Utils.extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], options.xAxisAnnotation);
  7488. return opts;
  7489. }
  7490. }, {
  7491. key: "extendPointAnnotations",
  7492. value: function extendPointAnnotations(opts) {
  7493. var options = new Options();
  7494. opts.annotations.points = Utils.extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], options.pointAnnotation);
  7495. return opts;
  7496. }
  7497. }, {
  7498. key: "checkForDarkTheme",
  7499. value: function checkForDarkTheme(opts) {
  7500. if (opts.theme && opts.theme.mode === 'dark') {
  7501. if (!opts.tooltip) {
  7502. opts.tooltip = {};
  7503. }
  7504. if (opts.tooltip.theme !== 'light') {
  7505. opts.tooltip.theme = 'dark';
  7506. }
  7507. if (!opts.chart.foreColor) {
  7508. opts.chart.foreColor = '#f6f7f8';
  7509. }
  7510. if (!opts.theme.palette) {
  7511. opts.theme.palette = 'palette4';
  7512. }
  7513. }
  7514. }
  7515. }, {
  7516. key: "handleUserInputErrors",
  7517. value: function handleUserInputErrors(opts) {
  7518. var config = opts; // conflicting tooltip option. intersect makes sure to focus on 1 point at a time. Shared cannot be used along with it
  7519. if (config.tooltip.shared && config.tooltip.intersect) {
  7520. throw new Error('tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.');
  7521. }
  7522. if ((config.chart.type === 'bar' || config.chart.type === 'rangeBar') && config.plotOptions.bar.horizontal) {
  7523. // No multiple yaxis for bars
  7524. if (config.yaxis.length > 1) {
  7525. throw new Error('Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false');
  7526. } // if yaxis is reversed in horizontal bar chart, you should draw the y-axis on right side
  7527. if (config.yaxis[0].reversed) {
  7528. config.yaxis[0].opposite = true;
  7529. }
  7530. config.xaxis.tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  7531. config.yaxis[0].tooltip.enabled = false; // no xaxis tooltip for horizontal bar
  7532. config.chart.zoom.enabled = false; // no zooming for horz bars
  7533. }
  7534. if (config.chart.type === 'bar' || config.chart.type === 'rangeBar') {
  7535. if (config.tooltip.shared) {
  7536. if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) {
  7537. console.warn('crosshairs.width = "barWidth" is only supported in single series, not in a multi-series barChart.');
  7538. config.xaxis.crosshairs.width = 'tickWidth';
  7539. }
  7540. if (config.plotOptions.bar.horizontal) {
  7541. config.states.hover.type = 'none';
  7542. config.tooltip.shared = false;
  7543. }
  7544. if (!config.tooltip.followCursor) {
  7545. console.warn('followCursor option in shared columns cannot be turned off. Please set %ctooltip.followCursor: true', 'color: blue;');
  7546. config.tooltip.followCursor = true;
  7547. }
  7548. }
  7549. }
  7550. if (config.chart.type === 'candlestick') {
  7551. if (config.yaxis[0].reversed) {
  7552. console.warn('Reversed y-axis in candlestick chart is not supported.');
  7553. config.yaxis[0].reversed = false;
  7554. }
  7555. }
  7556. if (config.chart.group && config.yaxis[0].labels.minWidth === 0) {
  7557. console.warn('It looks like you have multiple charts in synchronization. You must provide yaxis.labels.minWidth which must be EQUAL for all grouped charts to prevent incorrect behaviour.');
  7558. } // if user supplied array for stroke width, it will only be applicable to line/area charts, for any other charts, revert back to Number
  7559. if (Array.isArray(config.stroke.width)) {
  7560. if (config.chart.type !== 'line' && config.chart.type !== 'area') {
  7561. console.warn('stroke.width option accepts array only for line and area charts. Reverted back to Number');
  7562. config.stroke.width = config.stroke.width[0];
  7563. }
  7564. }
  7565. return config;
  7566. }
  7567. }]);
  7568. return Config;
  7569. }();
  7570. var Globals = /*#__PURE__*/function () {
  7571. function Globals() {
  7572. _classCallCheck(this, Globals);
  7573. }
  7574. _createClass(Globals, [{
  7575. key: "initGlobalVars",
  7576. value: function initGlobalVars(gl) {
  7577. gl.series = []; // the MAIN series array (y values)
  7578. gl.seriesCandleO = [];
  7579. gl.seriesCandleH = [];
  7580. gl.seriesCandleL = [];
  7581. gl.seriesCandleC = [];
  7582. gl.seriesRangeStart = [];
  7583. gl.seriesRangeEnd = [];
  7584. gl.seriesRangeBarTimeline = [];
  7585. gl.seriesPercent = [];
  7586. gl.seriesX = [];
  7587. gl.seriesZ = [];
  7588. gl.seriesNames = [];
  7589. gl.seriesTotals = [];
  7590. gl.seriesLog = [];
  7591. gl.stackedSeriesTotals = [];
  7592. gl.seriesXvalues = []; // we will need this in tooltip (it's x position)
  7593. // when we will have unequal x values, we will need
  7594. // some way to get x value depending on mouse pointer
  7595. gl.seriesYvalues = []; // we will need this when deciding which series
  7596. // user hovered on
  7597. gl.labels = [];
  7598. gl.categoryLabels = [];
  7599. gl.timescaleLabels = [];
  7600. gl.noLabelsProvided = false;
  7601. gl.resizeTimer = null;
  7602. gl.selectionResizeTimer = null;
  7603. gl.delayedElements = [];
  7604. gl.pointsArray = [];
  7605. gl.dataLabelsRects = [];
  7606. gl.isXNumeric = false;
  7607. gl.xaxisLabelsCount = 0;
  7608. gl.skipLastTimelinelabel = false;
  7609. gl.skipFirstTimelinelabel = false;
  7610. gl.x2SpaceAvailable = 0;
  7611. gl.isDataXYZ = false;
  7612. gl.isMultiLineX = false;
  7613. gl.isMultipleYAxis = false;
  7614. gl.maxY = -Number.MAX_VALUE;
  7615. gl.minY = Number.MIN_VALUE;
  7616. gl.minYArr = [];
  7617. gl.maxYArr = [];
  7618. gl.maxX = -Number.MAX_VALUE;
  7619. gl.minX = Number.MAX_VALUE;
  7620. gl.initialMaxX = -Number.MAX_VALUE;
  7621. gl.initialMinX = Number.MAX_VALUE;
  7622. gl.maxDate = 0;
  7623. gl.minDate = Number.MAX_VALUE;
  7624. gl.minZ = Number.MAX_VALUE;
  7625. gl.maxZ = -Number.MAX_VALUE;
  7626. gl.minXDiff = Number.MAX_VALUE;
  7627. gl.yAxisScale = [];
  7628. gl.xAxisScale = null;
  7629. gl.xAxisTicksPositions = [];
  7630. gl.yLabelsCoords = [];
  7631. gl.yTitleCoords = [];
  7632. gl.barPadForNumericAxis = 0;
  7633. gl.padHorizontal = 0;
  7634. gl.xRange = 0;
  7635. gl.yRange = [];
  7636. gl.zRange = 0;
  7637. gl.dataPoints = 0;
  7638. gl.xTickAmount = 0;
  7639. }
  7640. }, {
  7641. key: "globalVars",
  7642. value: function globalVars(config) {
  7643. return {
  7644. chartID: null,
  7645. // chart ID - apexcharts-cuid
  7646. cuid: null,
  7647. // chart ID - random numbers excluding "apexcharts" part
  7648. events: {
  7649. beforeMount: [],
  7650. mounted: [],
  7651. updated: [],
  7652. clicked: [],
  7653. selection: [],
  7654. dataPointSelection: [],
  7655. zoomed: [],
  7656. scrolled: []
  7657. },
  7658. colors: [],
  7659. clientX: null,
  7660. clientY: null,
  7661. fill: {
  7662. colors: []
  7663. },
  7664. stroke: {
  7665. colors: []
  7666. },
  7667. dataLabels: {
  7668. style: {
  7669. colors: []
  7670. }
  7671. },
  7672. radarPolygons: {
  7673. fill: {
  7674. colors: []
  7675. }
  7676. },
  7677. markers: {
  7678. colors: [],
  7679. size: config.markers.size,
  7680. largestSize: 0
  7681. },
  7682. animationEnded: false,
  7683. isTouchDevice: 'ontouchstart' in window || navigator.msMaxTouchPoints,
  7684. isDirty: false,
  7685. // chart has been updated after the initial render. This is different than dataChanged property. isDirty means user manually called some method to update
  7686. isExecCalled: false,
  7687. // whether user updated the chart through the exec method
  7688. initialConfig: null,
  7689. // we will store the first config user has set to go back when user finishes interactions like zooming and come out of it
  7690. initialSeries: [],
  7691. lastXAxis: [],
  7692. lastYAxis: [],
  7693. columnSeries: null,
  7694. labels: [],
  7695. // store the text to draw on x axis
  7696. // Don't mutate the labels, many things including tooltips depends on it!
  7697. timescaleLabels: [],
  7698. // store the timescaleLabels Labels in another variable
  7699. noLabelsProvided: false,
  7700. // if user didn't provide any categories/labels or x values, fallback to 1,2,3,4...
  7701. allSeriesCollapsed: false,
  7702. collapsedSeries: [],
  7703. // when user collapses a series, it goes into this array
  7704. collapsedSeriesIndices: [],
  7705. // this stores the index of the collapsedSeries instead of whole object for quick access
  7706. ancillaryCollapsedSeries: [],
  7707. // when user collapses an "alwaysVisible" series, it goes into this array
  7708. ancillaryCollapsedSeriesIndices: [],
  7709. // this stores the index of the ancillaryCollapsedSeries whose y-axis is always visible
  7710. risingSeries: [],
  7711. // when user re-opens a collapsed series, it goes here
  7712. dataFormatXNumeric: false,
  7713. // boolean value to indicate user has passed numeric x values
  7714. capturedSeriesIndex: -1,
  7715. capturedDataPointIndex: -1,
  7716. selectedDataPoints: [],
  7717. goldenPadding: 35,
  7718. // this value is used at a lot of places for spacing purpose
  7719. invalidLogScale: false,
  7720. // if a user enabled log scale but the data provided is not valid to generate a log scale, turn on this flag
  7721. ignoreYAxisIndexes: [],
  7722. // when series are being collapsed in multiple y axes, ignore certain index
  7723. yAxisSameScaleIndices: [],
  7724. maxValsInArrayIndex: 0,
  7725. radialSize: 0,
  7726. zoomEnabled: config.chart.toolbar.autoSelected === 'zoom' && config.chart.toolbar.tools.zoom && config.chart.zoom.enabled,
  7727. panEnabled: config.chart.toolbar.autoSelected === 'pan' && config.chart.toolbar.tools.pan,
  7728. selectionEnabled: config.chart.toolbar.autoSelected === 'selection' && config.chart.toolbar.tools.selection,
  7729. yaxis: null,
  7730. mousedown: false,
  7731. lastClientPosition: {},
  7732. // don't reset this variable this the chart is destroyed. It is used to detect right or left mousemove in panning
  7733. visibleXRange: undefined,
  7734. yValueDecimal: 0,
  7735. // are there floating numbers in the series. If yes, this represent the len of the decimals
  7736. total: 0,
  7737. SVGNS: 'http://www.w3.org/2000/svg',
  7738. // svg namespace
  7739. svgWidth: 0,
  7740. // the whole svg width
  7741. svgHeight: 0,
  7742. // the whole svg height
  7743. noData: false,
  7744. // whether there is any data to display or not
  7745. locale: {},
  7746. // the current locale values will be preserved here for global access
  7747. dom: {},
  7748. // for storing all dom nodes in this particular property
  7749. memory: {
  7750. methodsToExec: []
  7751. },
  7752. shouldAnimate: true,
  7753. skipLastTimelinelabel: false,
  7754. // when last label is cropped, skip drawing it
  7755. skipFirstTimelinelabel: false,
  7756. // when first label is cropped, skip drawing it
  7757. delayedElements: [],
  7758. // element which appear after animation has finished
  7759. axisCharts: true,
  7760. // chart type = line or area or bar
  7761. // (refer them also as plot charts in the code)
  7762. isDataXYZ: false,
  7763. // bool: data was provided in a {[x,y,z]} pattern
  7764. resized: false,
  7765. // bool: user has resized
  7766. resizeTimer: null,
  7767. // timeout function to make a small delay before
  7768. // drawing when user resized
  7769. comboCharts: false,
  7770. // bool: whether it's a combination of line/column
  7771. dataChanged: false,
  7772. // bool: has data changed dynamically
  7773. previousPaths: [],
  7774. // array: when data is changed, it will animate from
  7775. // previous paths
  7776. allSeriesHasEqualX: true,
  7777. pointsArray: [],
  7778. // store the points positions here to draw later on hover
  7779. // format is - [[x,y],[x,y]... [x,y]]
  7780. dataLabelsRects: [],
  7781. // store the positions of datalabels to prevent collision
  7782. lastDrawnDataLabelsIndexes: [],
  7783. x2SpaceAvailable: 0,
  7784. // space available on the right side after grid area
  7785. hasNullValues: false,
  7786. // bool: whether series contains null values
  7787. easing: null,
  7788. // function: animation effect to apply
  7789. zoomed: false,
  7790. // whether user has zoomed or not
  7791. gridWidth: 0,
  7792. // drawable width of actual graphs (series paths)
  7793. gridHeight: 0,
  7794. // drawable height of actual graphs (series paths)
  7795. rotateXLabels: false,
  7796. defaultLabels: false,
  7797. xLabelFormatter: undefined,
  7798. // formatter for x axis labels
  7799. yLabelFormatters: [],
  7800. xaxisTooltipFormatter: undefined,
  7801. // formatter for x axis tooltip
  7802. ttKeyFormatter: undefined,
  7803. ttVal: undefined,
  7804. ttZFormatter: undefined,
  7805. LINE_HEIGHT_RATIO: 1.618,
  7806. xAxisLabelsHeight: 0,
  7807. yAxisLabelsWidth: 0,
  7808. scaleX: 1,
  7809. scaleY: 1,
  7810. translateX: 0,
  7811. translateY: 0,
  7812. translateYAxisX: [],
  7813. yAxisWidths: [],
  7814. translateXAxisY: 0,
  7815. translateXAxisX: 0,
  7816. tooltip: null
  7817. };
  7818. }
  7819. }, {
  7820. key: "init",
  7821. value: function init(config) {
  7822. var globals = this.globalVars(config);
  7823. this.initGlobalVars(globals);
  7824. globals.initialConfig = Utils.extend({}, config);
  7825. globals.initialSeries = Utils.clone(config.series);
  7826. globals.lastXAxis = JSON.parse(JSON.stringify(globals.initialConfig.xaxis));
  7827. globals.lastYAxis = JSON.parse(JSON.stringify(globals.initialConfig.yaxis));
  7828. return globals;
  7829. }
  7830. }]);
  7831. return Globals;
  7832. }();
  7833. /**
  7834. * ApexCharts Base Class for extending user options with pre-defined ApexCharts config.
  7835. *
  7836. * @module Base
  7837. **/
  7838. var Base = /*#__PURE__*/function () {
  7839. function Base(opts) {
  7840. _classCallCheck(this, Base);
  7841. this.opts = opts;
  7842. }
  7843. _createClass(Base, [{
  7844. key: "init",
  7845. value: function init() {
  7846. var config = new Config(this.opts).init({
  7847. responsiveOverride: false
  7848. });
  7849. var globals = new Globals().init(config);
  7850. var w = {
  7851. config: config,
  7852. globals: globals
  7853. };
  7854. return w;
  7855. }
  7856. }]);
  7857. return Base;
  7858. }();
  7859. var Data = /*#__PURE__*/function () {
  7860. function Data(ctx) {
  7861. _classCallCheck(this, Data);
  7862. this.ctx = ctx;
  7863. this.w = ctx.w;
  7864. this.twoDSeries = [];
  7865. this.threeDSeries = [];
  7866. this.twoDSeriesX = [];
  7867. this.coreUtils = new CoreUtils(this.ctx);
  7868. }
  7869. _createClass(Data, [{
  7870. key: "isMultiFormat",
  7871. value: function isMultiFormat() {
  7872. return this.isFormatXY() || this.isFormat2DArray();
  7873. } // given format is [{x, y}, {x, y}]
  7874. }, {
  7875. key: "isFormatXY",
  7876. value: function isFormatXY() {
  7877. var series = this.w.config.series.slice();
  7878. var sr = new Series(this.ctx);
  7879. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  7880. 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) {
  7881. return true;
  7882. }
  7883. } // given format is [[x, y], [x, y]]
  7884. }, {
  7885. key: "isFormat2DArray",
  7886. value: function isFormat2DArray() {
  7887. var series = this.w.config.series.slice();
  7888. var sr = new Series(this.ctx);
  7889. this.activeSeriesIndex = sr.getActiveConfigSeriesIndex();
  7890. 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) {
  7891. return true;
  7892. }
  7893. }
  7894. }, {
  7895. key: "handleFormat2DArray",
  7896. value: function handleFormat2DArray(ser, i) {
  7897. var cnf = this.w.config;
  7898. var gl = this.w.globals;
  7899. if (cnf.xaxis.sorted) {
  7900. if (cnf.xaxis.type === 'datetime') {
  7901. ser[i].data.sort(function (a, b) {
  7902. return new Date(a[0]).getTime() - new Date(b[0]).getTime();
  7903. });
  7904. } else if (cnf.xaxis.type === 'numeric') {
  7905. ser[i].data.sort(function (a, b) {
  7906. return a[0] - b[0];
  7907. });
  7908. }
  7909. }
  7910. for (var j = 0; j < ser[i].data.length; j++) {
  7911. if (typeof ser[i].data[j][1] !== 'undefined') {
  7912. if (Array.isArray(ser[i].data[j][1]) && ser[i].data[j][1].length === 4) {
  7913. // candlestick nested ohlc format
  7914. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1][3]));
  7915. } else if (ser[i].data[j].length === 5) {
  7916. // candlestick non-nested ohlc format
  7917. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][4]));
  7918. } else {
  7919. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j][1]));
  7920. }
  7921. gl.dataFormatXNumeric = true;
  7922. }
  7923. if (cnf.xaxis.type === 'datetime') {
  7924. // if timestamps are provided and xaxis type is datettime,
  7925. var ts = new Date(ser[i].data[j][0]);
  7926. ts = new Date(ts).getTime();
  7927. this.twoDSeriesX.push(ts);
  7928. } else {
  7929. this.twoDSeriesX.push(ser[i].data[j][0]);
  7930. }
  7931. }
  7932. for (var _j = 0; _j < ser[i].data.length; _j++) {
  7933. if (typeof ser[i].data[_j][2] !== 'undefined') {
  7934. this.threeDSeries.push(ser[i].data[_j][2]);
  7935. gl.isDataXYZ = true;
  7936. }
  7937. }
  7938. }
  7939. }, {
  7940. key: "handleFormatXY",
  7941. value: function handleFormatXY(ser, i) {
  7942. var cnf = this.w.config;
  7943. var gl = this.w.globals;
  7944. var dt = new DateTime(this.ctx);
  7945. var activeI = i;
  7946. if (gl.collapsedSeriesIndices.indexOf(i) > -1) {
  7947. // fix #368
  7948. activeI = this.activeSeriesIndex;
  7949. }
  7950. if (cnf.xaxis.sorted) {
  7951. if (cnf.xaxis.type === 'datetime') {
  7952. ser[i].data.sort(function (a, b) {
  7953. return new Date(a.x).getTime() - new Date(b.x).getTime();
  7954. });
  7955. } else if (cnf.xaxis.type === 'numeric') {
  7956. ser[i].data.sort(function (a, b) {
  7957. return a.x - b.x;
  7958. });
  7959. }
  7960. } // get series
  7961. for (var j = 0; j < ser[i].data.length; j++) {
  7962. if (typeof ser[i].data[j].y !== 'undefined') {
  7963. if (Array.isArray(ser[i].data[j].y)) {
  7964. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y[ser[i].data[j].y.length - 1]));
  7965. } else {
  7966. this.twoDSeries.push(Utils.parseNumber(ser[i].data[j].y));
  7967. }
  7968. }
  7969. } // get seriesX
  7970. for (var _j2 = 0; _j2 < ser[activeI].data.length; _j2++) {
  7971. var isXString = typeof ser[activeI].data[_j2].x === 'string';
  7972. var isXArr = Array.isArray(ser[activeI].data[_j2].x);
  7973. var isXDate = !isXArr && !!dt.isValidDate(ser[activeI].data[_j2].x.toString());
  7974. if (isXString || isXDate) {
  7975. // user supplied '01/01/2017' or a date string (a JS date object is not supported)
  7976. if (isXString || cnf.xaxis.convertedCatToNumeric) {
  7977. var isRangeColumn = gl.isBarHorizontal && gl.isRangeData;
  7978. if (cnf.xaxis.type === 'datetime' && !isRangeColumn) {
  7979. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x));
  7980. } else {
  7981. // a category and not a numeric x value
  7982. this.fallbackToCategory = true;
  7983. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  7984. }
  7985. } else {
  7986. if (cnf.xaxis.type === 'datetime') {
  7987. this.twoDSeriesX.push(dt.parseDate(ser[activeI].data[_j2].x.toString()));
  7988. } else {
  7989. gl.dataFormatXNumeric = true;
  7990. gl.isXNumeric = true;
  7991. this.twoDSeriesX.push(parseFloat(ser[activeI].data[_j2].x));
  7992. }
  7993. }
  7994. } else if (isXArr) {
  7995. // a multiline label described in array format
  7996. this.fallbackToCategory = true;
  7997. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  7998. } else {
  7999. // a numeric value in x property
  8000. gl.isXNumeric = true;
  8001. gl.dataFormatXNumeric = true;
  8002. this.twoDSeriesX.push(ser[activeI].data[_j2].x);
  8003. }
  8004. }
  8005. if (ser[i].data[0] && typeof ser[i].data[0].z !== 'undefined') {
  8006. for (var t = 0; t < ser[i].data.length; t++) {
  8007. this.threeDSeries.push(ser[i].data[t].z);
  8008. }
  8009. gl.isDataXYZ = true;
  8010. }
  8011. }
  8012. }, {
  8013. key: "handleRangeData",
  8014. value: function handleRangeData(ser, i) {
  8015. var cnf = this.w.config;
  8016. var gl = this.w.globals;
  8017. var range = {};
  8018. if (this.isFormat2DArray()) {
  8019. range = this.handleRangeDataFormat('array', ser, i);
  8020. } else if (this.isFormatXY()) {
  8021. range = this.handleRangeDataFormat('xy', ser, i);
  8022. }
  8023. gl.seriesRangeStart.push(range.start);
  8024. gl.seriesRangeEnd.push(range.end);
  8025. if (cnf.xaxis.type === 'datetime') {
  8026. gl.seriesRangeBarTimeline.push(range.rangeUniques);
  8027. } // check for overlaps to avoid clashes in a timeline chart
  8028. gl.seriesRangeBarTimeline.forEach(function (sr, si) {
  8029. if (sr) {
  8030. sr.forEach(function (sarr, sarri) {
  8031. sarr.y.forEach(function (arr, arri) {
  8032. for (var sri = 0; sri < sarr.y.length; sri++) {
  8033. if (arri !== sri) {
  8034. var range1y1 = arr.y1;
  8035. var range1y2 = arr.y2;
  8036. var range2y1 = sarr.y[sri].y1;
  8037. var range2y2 = sarr.y[sri].y2;
  8038. if (range1y1 <= range2y2 && range2y1 <= range1y2) {
  8039. if (sarr.overlaps.indexOf(arr.rangeName) < 0) {
  8040. sarr.overlaps.push(arr.rangeName);
  8041. }
  8042. if (sarr.overlaps.indexOf(sarr.y[sri].rangeName) < 0) {
  8043. sarr.overlaps.push(sarr.y[sri].rangeName);
  8044. }
  8045. }
  8046. }
  8047. }
  8048. });
  8049. });
  8050. }
  8051. });
  8052. return range;
  8053. }
  8054. }, {
  8055. key: "handleCandleStickData",
  8056. value: function handleCandleStickData(ser, i) {
  8057. var gl = this.w.globals;
  8058. var ohlc = {};
  8059. if (this.isFormat2DArray()) {
  8060. ohlc = this.handleCandleStickDataFormat('array', ser, i);
  8061. } else if (this.isFormatXY()) {
  8062. ohlc = this.handleCandleStickDataFormat('xy', ser, i);
  8063. }
  8064. gl.seriesCandleO[i] = ohlc.o;
  8065. gl.seriesCandleH[i] = ohlc.h;
  8066. gl.seriesCandleL[i] = ohlc.l;
  8067. gl.seriesCandleC[i] = ohlc.c;
  8068. return ohlc;
  8069. }
  8070. }, {
  8071. key: "handleRangeDataFormat",
  8072. value: function handleRangeDataFormat(format, ser, i) {
  8073. var rangeStart = [];
  8074. var rangeEnd = [];
  8075. var uniqueKeys = ser[i].data.filter(function (thing, index, self) {
  8076. return index === self.findIndex(function (t) {
  8077. return t.x === thing.x;
  8078. });
  8079. }).map(function (r, index) {
  8080. return {
  8081. x: r.x,
  8082. overlaps: [],
  8083. y: []
  8084. };
  8085. });
  8086. var err = 'Please provide [Start, End] values in valid format. Read more https://apexcharts.com/docs/series/#rangecharts';
  8087. var serObj = new Series(this.ctx);
  8088. var activeIndex = serObj.getActiveConfigSeriesIndex();
  8089. if (format === 'array') {
  8090. if (ser[activeIndex].data[0][1].length !== 2) {
  8091. throw new Error(err);
  8092. }
  8093. for (var j = 0; j < ser[i].data.length; j++) {
  8094. rangeStart.push(ser[i].data[j][1][0]);
  8095. rangeEnd.push(ser[i].data[j][1][1]);
  8096. }
  8097. } else if (format === 'xy') {
  8098. if (ser[activeIndex].data[0].y.length !== 2) {
  8099. throw new Error(err);
  8100. }
  8101. var _loop = function _loop(_j3) {
  8102. var id = Utils.randomId();
  8103. var x = ser[i].data[_j3].x;
  8104. var y = {
  8105. y1: ser[i].data[_j3].y[0],
  8106. y2: ser[i].data[_j3].y[1],
  8107. rangeName: id
  8108. }; // mutating config object by adding a new property
  8109. // TODO: As this is specifically for timeline rangebar charts, update the docs mentioning the series only supports xy format
  8110. ser[i].data[_j3].rangeName = id;
  8111. var uI = uniqueKeys.findIndex(function (t) {
  8112. return t.x === x;
  8113. });
  8114. uniqueKeys[uI].y.push(y);
  8115. rangeStart.push(y.y1);
  8116. rangeEnd.push(y.y2);
  8117. };
  8118. for (var _j3 = 0; _j3 < ser[i].data.length; _j3++) {
  8119. _loop(_j3);
  8120. }
  8121. }
  8122. return {
  8123. start: rangeStart,
  8124. end: rangeEnd,
  8125. rangeUniques: uniqueKeys
  8126. };
  8127. }
  8128. }, {
  8129. key: "handleCandleStickDataFormat",
  8130. value: function handleCandleStickDataFormat(format, ser, i) {
  8131. var serO = [];
  8132. var serH = [];
  8133. var serL = [];
  8134. var serC = [];
  8135. var err = 'Please provide [Open, High, Low and Close] values in valid format. Read more https://apexcharts.com/docs/series/#candlestick';
  8136. if (format === 'array') {
  8137. if (!Array.isArray(ser[i].data[0][1]) && ser[i].data[0].length !== 5 || Array.isArray(ser[i].data[0][1]) && ser[i].data[0][1].length !== 4) {
  8138. throw new Error(err);
  8139. }
  8140. if (ser[i].data[0].length === 5) {
  8141. for (var j = 0; j < ser[i].data.length; j++) {
  8142. serO.push(ser[i].data[j][1]);
  8143. serH.push(ser[i].data[j][2]);
  8144. serL.push(ser[i].data[j][3]);
  8145. serC.push(ser[i].data[j][4]);
  8146. }
  8147. } else {
  8148. for (var _j4 = 0; _j4 < ser[i].data.length; _j4++) {
  8149. serO.push(ser[i].data[_j4][1][0]);
  8150. serH.push(ser[i].data[_j4][1][1]);
  8151. serL.push(ser[i].data[_j4][1][2]);
  8152. serC.push(ser[i].data[_j4][1][3]);
  8153. }
  8154. }
  8155. } else if (format === 'xy') {
  8156. if (ser[i].data[0].y.length !== 4) {
  8157. throw new Error(err);
  8158. }
  8159. for (var _j5 = 0; _j5 < ser[i].data.length; _j5++) {
  8160. serO.push(ser[i].data[_j5].y[0]);
  8161. serH.push(ser[i].data[_j5].y[1]);
  8162. serL.push(ser[i].data[_j5].y[2]);
  8163. serC.push(ser[i].data[_j5].y[3]);
  8164. }
  8165. }
  8166. return {
  8167. o: serO,
  8168. h: serH,
  8169. l: serL,
  8170. c: serC
  8171. };
  8172. }
  8173. }, {
  8174. key: "parseDataAxisCharts",
  8175. value: function parseDataAxisCharts(ser) {
  8176. var _this = this;
  8177. var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.ctx;
  8178. var cnf = this.w.config;
  8179. var gl = this.w.globals;
  8180. var dt = new DateTime(ctx);
  8181. var xlabels = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice();
  8182. var handleDates = function handleDates() {
  8183. for (var j = 0; j < xlabels.length; j++) {
  8184. if (typeof xlabels[j] === 'string') {
  8185. // user provided date strings
  8186. var isDate = dt.isValidDate(xlabels[j]);
  8187. if (isDate) {
  8188. _this.twoDSeriesX.push(dt.parseDate(xlabels[j]));
  8189. } else {
  8190. throw new Error('You have provided invalid Date format. Please provide a valid JavaScript Date');
  8191. }
  8192. } else {
  8193. // user provided timestamps
  8194. if (String(xlabels[j]).length !== 13) {
  8195. throw new Error('Please provide a valid JavaScript timestamp');
  8196. } else {
  8197. _this.twoDSeriesX.push(xlabels[j]);
  8198. }
  8199. }
  8200. }
  8201. };
  8202. for (var i = 0; i < ser.length; i++) {
  8203. this.twoDSeries = [];
  8204. this.twoDSeriesX = [];
  8205. this.threeDSeries = [];
  8206. if (typeof ser[i].data === 'undefined') {
  8207. console.error("It is a possibility that you may have not included 'data' property in series.");
  8208. return;
  8209. }
  8210. if (cnf.chart.type === 'rangeBar' || cnf.chart.type === 'rangeArea' || ser[i].type === 'rangeBar' || ser[i].type === 'rangeArea') {
  8211. gl.isRangeData = true;
  8212. this.handleRangeData(ser, i);
  8213. }
  8214. if (this.isMultiFormat()) {
  8215. if (this.isFormat2DArray()) {
  8216. this.handleFormat2DArray(ser, i);
  8217. } else if (this.isFormatXY()) {
  8218. this.handleFormatXY(ser, i);
  8219. }
  8220. if (cnf.chart.type === 'candlestick' || ser[i].type === 'candlestick') {
  8221. this.handleCandleStickData(ser, i);
  8222. }
  8223. gl.series.push(this.twoDSeries);
  8224. gl.labels.push(this.twoDSeriesX);
  8225. gl.seriesX.push(this.twoDSeriesX);
  8226. if (i === this.activeSeriesIndex && !this.fallbackToCategory) {
  8227. gl.isXNumeric = true;
  8228. }
  8229. } else {
  8230. if (cnf.xaxis.type === 'datetime') {
  8231. // user didn't supplied [{x,y}] or [[x,y]], but single array in data.
  8232. // Also labels/categories were supplied differently
  8233. gl.isXNumeric = true;
  8234. handleDates();
  8235. gl.seriesX.push(this.twoDSeriesX);
  8236. } else if (cnf.xaxis.type === 'numeric') {
  8237. gl.isXNumeric = true;
  8238. if (xlabels.length > 0) {
  8239. this.twoDSeriesX = xlabels;
  8240. gl.seriesX.push(this.twoDSeriesX);
  8241. }
  8242. }
  8243. gl.labels.push(this.twoDSeriesX);
  8244. var singleArray = ser[i].data.map(function (d) {
  8245. return Utils.parseNumber(d);
  8246. });
  8247. gl.series.push(singleArray);
  8248. }
  8249. gl.seriesZ.push(this.threeDSeries);
  8250. if (ser[i].name !== undefined) {
  8251. gl.seriesNames.push(ser[i].name);
  8252. } else {
  8253. gl.seriesNames.push('series-' + parseInt(i + 1, 10));
  8254. }
  8255. }
  8256. return this.w;
  8257. }
  8258. }, {
  8259. key: "parseDataNonAxisCharts",
  8260. value: function parseDataNonAxisCharts(ser) {
  8261. var gl = this.w.globals;
  8262. var cnf = this.w.config;
  8263. gl.series = ser.slice();
  8264. gl.seriesNames = cnf.labels.slice();
  8265. for (var i = 0; i < gl.series.length; i++) {
  8266. if (gl.seriesNames[i] === undefined) {
  8267. gl.seriesNames.push('series-' + (i + 1));
  8268. }
  8269. }
  8270. return this.w;
  8271. }
  8272. /** User possibly set string categories in xaxis.categories or labels prop
  8273. * Or didn't set xaxis labels at all - in which case we manually do it.
  8274. * If user passed series data as [[3, 2], [4, 5]] or [{ x: 3, y: 55 }],
  8275. * this shouldn't be called
  8276. * @param {array} ser - the series which user passed to the config
  8277. */
  8278. }, {
  8279. key: "handleExternalLabelsData",
  8280. value: function handleExternalLabelsData(ser) {
  8281. var cnf = this.w.config;
  8282. var gl = this.w.globals;
  8283. if (cnf.xaxis.categories.length > 0) {
  8284. // user provided labels in xaxis.category prop
  8285. gl.labels = cnf.xaxis.categories;
  8286. } else if (cnf.labels.length > 0) {
  8287. // user provided labels in labels props
  8288. gl.labels = cnf.labels.slice();
  8289. } else if (this.fallbackToCategory) {
  8290. // 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
  8291. gl.labels = gl.labels[0];
  8292. if (gl.seriesRangeBarTimeline.length) {
  8293. gl.seriesRangeBarTimeline.map(function (srt) {
  8294. srt.forEach(function (sr) {
  8295. if (gl.labels.indexOf(sr.x) < 0 && sr.x) {
  8296. gl.labels.push(sr.x);
  8297. }
  8298. });
  8299. });
  8300. gl.labels = gl.labels.filter(function (elem, pos, arr) {
  8301. return arr.indexOf(elem) === pos;
  8302. });
  8303. }
  8304. if (cnf.xaxis.convertedCatToNumeric) {
  8305. var defaults = new Defaults(cnf);
  8306. defaults.convertCatToNumericXaxis(cnf, this.ctx, gl.seriesX[0]);
  8307. this._generateExternalLabels(ser);
  8308. }
  8309. } else {
  8310. this._generateExternalLabels(ser);
  8311. }
  8312. }
  8313. }, {
  8314. key: "_generateExternalLabels",
  8315. value: function _generateExternalLabels(ser) {
  8316. var gl = this.w.globals;
  8317. var cnf = this.w.config; // user didn't provided any labels, fallback to 1-2-3-4-5
  8318. var labelArr = [];
  8319. if (gl.axisCharts) {
  8320. if (gl.series.length > 0) {
  8321. for (var i = 0; i < gl.series[gl.maxValsInArrayIndex].length; i++) {
  8322. labelArr.push(i + 1);
  8323. }
  8324. }
  8325. gl.seriesX = []; // create gl.seriesX as it will be used in calculations of x positions
  8326. for (var _i = 0; _i < ser.length; _i++) {
  8327. gl.seriesX.push(labelArr);
  8328. } // turn on the isXNumeric flag to allow minX and maxX to function properly
  8329. gl.isXNumeric = true;
  8330. } // no series to pull labels from, put a 0-10 series
  8331. // possibly, user collapsed all series. Hence we can't work with above calc
  8332. if (labelArr.length === 0) {
  8333. labelArr = gl.axisCharts ? [] : gl.series.map(function (gls, glsi) {
  8334. return glsi + 1;
  8335. });
  8336. for (var _i2 = 0; _i2 < ser.length; _i2++) {
  8337. gl.seriesX.push(labelArr);
  8338. }
  8339. } // Finally, pass the labelArr in gl.labels which will be printed on x-axis
  8340. gl.labels = labelArr;
  8341. if (cnf.xaxis.convertedCatToNumeric) {
  8342. gl.categoryLabels = labelArr.map(function (l) {
  8343. return cnf.xaxis.labels.formatter(l);
  8344. });
  8345. } // Turn on this global flag to indicate no labels were provided by user
  8346. gl.noLabelsProvided = true;
  8347. } // Segregate user provided data into appropriate vars
  8348. }, {
  8349. key: "parseData",
  8350. value: function parseData(ser) {
  8351. var w = this.w;
  8352. var cnf = w.config;
  8353. var gl = w.globals;
  8354. this.excludeCollapsedSeriesInYAxis(); // If we detected string in X prop of series, we fallback to category x-axis
  8355. this.fallbackToCategory = false;
  8356. this.ctx.core.resetGlobals();
  8357. this.ctx.core.isMultipleY();
  8358. if (gl.axisCharts) {
  8359. // axisCharts includes line / area / column / scatter
  8360. this.parseDataAxisCharts(ser);
  8361. } else {
  8362. // non-axis charts are pie / donut
  8363. this.parseDataNonAxisCharts(ser);
  8364. }
  8365. this.coreUtils.getLargestSeries(); // set Null values to 0 in all series when user hides/shows some series
  8366. if (cnf.chart.type === 'bar' && cnf.chart.stacked) {
  8367. var series = new Series(this.ctx);
  8368. gl.series = series.setNullSeriesToZeroValues(gl.series);
  8369. }
  8370. this.coreUtils.getSeriesTotals();
  8371. if (gl.axisCharts) {
  8372. this.coreUtils.getStackedSeriesTotals();
  8373. }
  8374. this.coreUtils.getPercentSeries();
  8375. if (!gl.dataFormatXNumeric && (!gl.isXNumeric || cnf.xaxis.type === 'numeric' && cnf.labels.length === 0 && cnf.xaxis.categories.length === 0)) {
  8376. // x-axis labels couldn't be detected; hence try searching every option in config
  8377. this.handleExternalLabelsData(ser);
  8378. } // check for multiline xaxis
  8379. var catLabels = this.coreUtils.getCategoryLabels(gl.labels);
  8380. for (var l = 0; l < catLabels.length; l++) {
  8381. if (Array.isArray(catLabels[l])) {
  8382. gl.isMultiLineX = true;
  8383. break;
  8384. }
  8385. }
  8386. }
  8387. }, {
  8388. key: "excludeCollapsedSeriesInYAxis",
  8389. value: function excludeCollapsedSeriesInYAxis() {
  8390. var _this2 = this;
  8391. var w = this.w;
  8392. w.globals.ignoreYAxisIndexes = w.globals.collapsedSeries.map(function (collapsed, i) {
  8393. // fix issue #1215
  8394. // if stacked, not returning collapsed.index to preserve yaxis
  8395. if (_this2.w.globals.isMultipleYAxis && !w.config.chart.stacked) {
  8396. return collapsed.index;
  8397. }
  8398. });
  8399. }
  8400. }]);
  8401. return Data;
  8402. }();
  8403. /**
  8404. * ApexCharts Formatter Class for setting value formatters for axes as well as tooltips.
  8405. *
  8406. * @module Formatters
  8407. **/
  8408. var Formatters = /*#__PURE__*/function () {
  8409. function Formatters(ctx) {
  8410. _classCallCheck(this, Formatters);
  8411. this.ctx = ctx;
  8412. this.w = ctx.w;
  8413. this.tooltipKeyFormat = 'dd MMM';
  8414. }
  8415. _createClass(Formatters, [{
  8416. key: "xLabelFormat",
  8417. value: function xLabelFormat(fn, val, timestamp) {
  8418. var w = this.w;
  8419. if (w.config.xaxis.type === 'datetime') {
  8420. if (w.config.xaxis.labels.formatter === undefined) {
  8421. // if user has not specified a custom formatter, use the default tooltip.x.format
  8422. if (w.config.tooltip.x.formatter === undefined) {
  8423. var datetimeObj = new DateTime(this.ctx);
  8424. return datetimeObj.formatDate(datetimeObj.getDate(val), w.config.tooltip.x.format);
  8425. }
  8426. }
  8427. }
  8428. return fn(val, timestamp);
  8429. }
  8430. }, {
  8431. key: "defaultGeneralFormatter",
  8432. value: function defaultGeneralFormatter(val) {
  8433. if (Array.isArray(val)) {
  8434. return val.map(function (v) {
  8435. return v;
  8436. });
  8437. } else {
  8438. return val;
  8439. }
  8440. }
  8441. }, {
  8442. key: "defaultYFormatter",
  8443. value: function defaultYFormatter(v, yaxe, i) {
  8444. var w = this.w;
  8445. if (Utils.isNumber(v)) {
  8446. if (w.globals.yValueDecimal !== 0) {
  8447. v = v.toFixed(yaxe.decimalsInFloat !== undefined ? yaxe.decimalsInFloat : w.globals.yValueDecimal);
  8448. } else if (w.globals.maxYArr[i] - w.globals.minYArr[i] < 10) {
  8449. v = v.toFixed(1);
  8450. } else {
  8451. v = v.toFixed(0);
  8452. }
  8453. }
  8454. return v;
  8455. }
  8456. }, {
  8457. key: "setLabelFormatters",
  8458. value: function setLabelFormatters() {
  8459. var _this = this;
  8460. var w = this.w;
  8461. w.globals.xLabelFormatter = function (val) {
  8462. return _this.defaultGeneralFormatter(val);
  8463. };
  8464. w.globals.xaxisTooltipFormatter = function (val) {
  8465. return _this.defaultGeneralFormatter(val);
  8466. };
  8467. w.globals.ttKeyFormatter = function (val) {
  8468. return _this.defaultGeneralFormatter(val);
  8469. };
  8470. w.globals.ttZFormatter = function (val) {
  8471. return val;
  8472. };
  8473. w.globals.legendFormatter = function (val) {
  8474. return _this.defaultGeneralFormatter(val);
  8475. }; // formatter function will always overwrite format property
  8476. if (w.config.xaxis.labels.formatter !== undefined) {
  8477. w.globals.xLabelFormatter = w.config.xaxis.labels.formatter;
  8478. } else {
  8479. w.globals.xLabelFormatter = function (val) {
  8480. if (Utils.isNumber(val)) {
  8481. // numeric xaxis may have smaller range, so defaulting to 1 decimal
  8482. if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric' && w.globals.dataPoints < 50) {
  8483. return val.toFixed(1);
  8484. }
  8485. if (w.globals.isBarHorizontal) {
  8486. var range = w.globals.maxY - w.globals.minYArr;
  8487. if (range < 4) {
  8488. return val.toFixed(1);
  8489. }
  8490. }
  8491. return val.toFixed(0);
  8492. }
  8493. return val;
  8494. };
  8495. }
  8496. if (typeof w.config.tooltip.x.formatter === 'function') {
  8497. w.globals.ttKeyFormatter = w.config.tooltip.x.formatter;
  8498. } else {
  8499. w.globals.ttKeyFormatter = w.globals.xLabelFormatter;
  8500. }
  8501. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  8502. w.globals.xaxisTooltipFormatter = w.config.xaxis.tooltip.formatter;
  8503. }
  8504. if (Array.isArray(w.config.tooltip.y)) {
  8505. w.globals.ttVal = w.config.tooltip.y;
  8506. } else {
  8507. if (w.config.tooltip.y.formatter !== undefined) {
  8508. w.globals.ttVal = w.config.tooltip.y;
  8509. }
  8510. }
  8511. if (w.config.tooltip.z.formatter !== undefined) {
  8512. w.globals.ttZFormatter = w.config.tooltip.z.formatter;
  8513. } // legend formatter - if user wants to append any global values of series to legend text
  8514. if (w.config.legend.formatter !== undefined) {
  8515. w.globals.legendFormatter = w.config.legend.formatter;
  8516. } // formatter function will always overwrite format property
  8517. w.config.yaxis.forEach(function (yaxe, i) {
  8518. if (yaxe.labels.formatter !== undefined) {
  8519. w.globals.yLabelFormatters[i] = yaxe.labels.formatter;
  8520. } else {
  8521. w.globals.yLabelFormatters[i] = function (val) {
  8522. if (!w.globals.xyCharts) return val;
  8523. if (Array.isArray(val)) {
  8524. return val.map(function (v) {
  8525. return _this.defaultYFormatter(v, yaxe, i);
  8526. });
  8527. } else {
  8528. return _this.defaultYFormatter(val, yaxe, i);
  8529. }
  8530. };
  8531. }
  8532. });
  8533. return w.globals;
  8534. }
  8535. }, {
  8536. key: "heatmapLabelFormatters",
  8537. value: function heatmapLabelFormatters() {
  8538. var w = this.w;
  8539. if (w.config.chart.type === 'heatmap') {
  8540. w.globals.yAxisScale[0].result = w.globals.seriesNames.slice(); // get the longest string from the labels array and also apply label formatter to it
  8541. var longest = w.globals.seriesNames.reduce(function (a, b) {
  8542. return a.length > b.length ? a : b;
  8543. }, 0);
  8544. w.globals.yAxisScale[0].niceMax = longest;
  8545. w.globals.yAxisScale[0].niceMin = longest;
  8546. }
  8547. }
  8548. }]);
  8549. return Formatters;
  8550. }();
  8551. var AxesUtils = /*#__PURE__*/function () {
  8552. function AxesUtils(ctx) {
  8553. _classCallCheck(this, AxesUtils);
  8554. this.ctx = ctx;
  8555. this.w = ctx.w;
  8556. } // Based on the formatter function, get the label text and position
  8557. _createClass(AxesUtils, [{
  8558. key: "getLabel",
  8559. value: function getLabel(labels, timescaleLabels, x, i) {
  8560. var drawnLabels = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
  8561. var fontSize = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '12px';
  8562. var w = this.w;
  8563. var rawLabel = typeof labels[i] === 'undefined' ? '' : labels[i];
  8564. var label = rawLabel;
  8565. var xlbFormatter = w.globals.xLabelFormatter;
  8566. var customFormatter = w.config.xaxis.labels.formatter;
  8567. var isBold = false;
  8568. var xFormat = new Formatters(this.ctx);
  8569. var timestamp = rawLabel;
  8570. label = xFormat.xLabelFormat(xlbFormatter, rawLabel, timestamp);
  8571. if (customFormatter !== undefined) {
  8572. label = customFormatter(rawLabel, labels[i], i);
  8573. }
  8574. var determineHighestUnit = function determineHighestUnit(unit) {
  8575. var highestUnit = null;
  8576. timescaleLabels.forEach(function (t) {
  8577. if (t.unit === 'month') {
  8578. highestUnit = 'year';
  8579. } else if (t.unit === 'day') {
  8580. highestUnit = 'month';
  8581. } else if (t.unit === 'hour') {
  8582. highestUnit = 'day';
  8583. } else if (t.unit === 'minute') {
  8584. highestUnit = 'hour';
  8585. }
  8586. });
  8587. return highestUnit === unit;
  8588. };
  8589. if (timescaleLabels.length > 0) {
  8590. isBold = determineHighestUnit(timescaleLabels[i].unit);
  8591. x = timescaleLabels[i].position;
  8592. label = timescaleLabels[i].value;
  8593. } else {
  8594. if (w.config.xaxis.type === 'datetime' && customFormatter === undefined) {
  8595. label = '';
  8596. }
  8597. }
  8598. if (typeof label === 'undefined') label = '';
  8599. label = Array.isArray(label) ? label : label.toString();
  8600. var graphics = new Graphics(this.ctx);
  8601. var textRect = {};
  8602. if (w.globals.rotateXLabels) {
  8603. textRect = graphics.getTextRects(label, parseInt(fontSize, 10), null, "rotate(".concat(w.config.xaxis.labels.rotate, " 0 0)"), false);
  8604. } else {
  8605. textRect = graphics.getTextRects(label, parseInt(fontSize, 10));
  8606. }
  8607. if (!Array.isArray(label) && (label.indexOf('NaN') === 0 || label.toLowerCase().indexOf('invalid') === 0 || label.toLowerCase().indexOf('infinity') >= 0 || drawnLabels.indexOf(label) >= 0 && !w.config.xaxis.labels.showDuplicates)) {
  8608. label = '';
  8609. }
  8610. return {
  8611. x: x,
  8612. text: label,
  8613. textRect: textRect,
  8614. isBold: isBold
  8615. };
  8616. }
  8617. }, {
  8618. key: "checkForOverflowingLabels",
  8619. value: function checkForOverflowingLabels(i, label, labelsLen, drawnLabels, drawnLabelsRects) {
  8620. var w = this.w;
  8621. if (i === 0) {
  8622. // check if first label is being truncated
  8623. if (w.globals.skipFirstTimelinelabel) {
  8624. label.text = '';
  8625. }
  8626. }
  8627. if (i === labelsLen - 1) {
  8628. // check if last label is being truncated
  8629. if (w.globals.skipLastTimelinelabel) {
  8630. label.text = '';
  8631. }
  8632. }
  8633. if (w.config.xaxis.labels.hideOverlappingLabels && drawnLabels.length > 0) {
  8634. var prev = drawnLabelsRects[drawnLabelsRects.length - 1];
  8635. if (label.x < prev.textRect.width / (w.globals.rotateXLabels ? Math.abs(w.config.xaxis.labels.rotate) / 12 : 1.01) + prev.x) {
  8636. label.text = '';
  8637. }
  8638. }
  8639. return label;
  8640. }
  8641. }, {
  8642. key: "checkForReversedLabels",
  8643. value: function checkForReversedLabels(i, labels) {
  8644. var w = this.w;
  8645. if (w.config.yaxis[i] && w.config.yaxis[i].reversed) {
  8646. labels.reverse();
  8647. }
  8648. return labels;
  8649. }
  8650. }, {
  8651. key: "isYAxisHidden",
  8652. value: function isYAxisHidden(index) {
  8653. var w = this.w;
  8654. var coreUtils = new CoreUtils(this.ctx);
  8655. return !w.config.yaxis[index].show || !w.config.yaxis[index].showForNullSeries && coreUtils.isSeriesNull(index) && w.globals.collapsedSeriesIndices.indexOf(index) === -1;
  8656. }
  8657. }, {
  8658. key: "drawYAxisTicks",
  8659. value: function drawYAxisTicks(x, tickAmount, axisBorder, axisTicks, realIndex, labelsDivider, elYaxis) {
  8660. var w = this.w;
  8661. var graphics = new Graphics(this.ctx); // initial label position = 0;
  8662. var t = w.globals.translateY;
  8663. if (axisTicks.show && tickAmount > 0) {
  8664. if (w.config.yaxis[realIndex].opposite === true) x = x + axisTicks.width;
  8665. for (var i = tickAmount; i >= 0; i--) {
  8666. var tY = t + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY - 1;
  8667. if (w.globals.isBarHorizontal) {
  8668. tY = labelsDivider * i;
  8669. }
  8670. if (w.config.chart.type === 'heatmap') {
  8671. tY = tY + labelsDivider / 2;
  8672. }
  8673. var elTick = graphics.drawLine(x + axisBorder.offsetX - axisTicks.width + axisTicks.offsetX, tY + axisTicks.offsetY, x + axisBorder.offsetX + axisTicks.offsetX, tY + axisTicks.offsetY, axisTicks.color);
  8674. elYaxis.add(elTick);
  8675. t = t + labelsDivider;
  8676. }
  8677. }
  8678. }
  8679. }]);
  8680. return AxesUtils;
  8681. }();
  8682. var Exports = /*#__PURE__*/function () {
  8683. function Exports(ctx) {
  8684. _classCallCheck(this, Exports);
  8685. this.ctx = ctx;
  8686. this.w = ctx.w;
  8687. }
  8688. _createClass(Exports, [{
  8689. key: "fixSvgStringForIe11",
  8690. value: function fixSvgStringForIe11(svgData) {
  8691. // IE11 generates broken SVG that we have to fix by using regex
  8692. if (!Utils.isIE11()) {
  8693. // not IE11 - noop
  8694. return svgData;
  8695. } // replace second occurence of "xmlns" attribute with "xmlns:xlink" with correct url + add xmlns:svgjs
  8696. var nXmlnsSeen = 0;
  8697. var result = svgData.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g, function (match) {
  8698. nXmlnsSeen++;
  8699. return nXmlnsSeen === 2 ? 'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs"' : match;
  8700. }); // remove the invalid empty namespace declarations
  8701. result = result.replace(/xmlns:NS\d+=""/g, ''); // remove these broken namespaces from attributes
  8702. result = result.replace(/NS\d+:(\w+:\w+=")/g, '$1');
  8703. return result;
  8704. }
  8705. }, {
  8706. key: "getSvgString",
  8707. value: function getSvgString() {
  8708. var svgString = this.w.globals.dom.Paper.svg();
  8709. return this.fixSvgStringForIe11(svgString);
  8710. }
  8711. }, {
  8712. key: "cleanup",
  8713. value: function cleanup() {
  8714. var w = this.w; // hide some elements to avoid printing them on exported svg
  8715. var xcrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-xcrosshairs');
  8716. var ycrosshairs = w.globals.dom.baseEl.getElementsByClassName('apexcharts-ycrosshairs');
  8717. var zoomSelectionRects = w.globals.dom.baseEl.querySelectorAll('.apexcharts-zoom-rect, .apexcharts-selection-rect');
  8718. Array.prototype.forEach.call(zoomSelectionRects, function (z) {
  8719. z.setAttribute('width', 0);
  8720. });
  8721. if (xcrosshairs && xcrosshairs[0]) {
  8722. xcrosshairs[0].setAttribute('x', -500);
  8723. xcrosshairs[0].setAttribute('x1', -500);
  8724. xcrosshairs[0].setAttribute('x2', -500);
  8725. }
  8726. if (ycrosshairs && ycrosshairs[0]) {
  8727. ycrosshairs[0].setAttribute('y', -100);
  8728. ycrosshairs[0].setAttribute('y1', -100);
  8729. ycrosshairs[0].setAttribute('y2', -100);
  8730. }
  8731. }
  8732. }, {
  8733. key: "svgUrl",
  8734. value: function svgUrl() {
  8735. this.cleanup();
  8736. var svgData = this.getSvgString();
  8737. var svgBlob = new Blob([svgData], {
  8738. type: 'image/svg+xml;charset=utf-8'
  8739. });
  8740. return URL.createObjectURL(svgBlob);
  8741. }
  8742. }, {
  8743. key: "dataURI",
  8744. value: function dataURI() {
  8745. var _this = this;
  8746. return new Promise(function (resolve) {
  8747. var w = _this.w;
  8748. _this.cleanup();
  8749. var canvas = document.createElement('canvas');
  8750. canvas.width = w.globals.svgWidth;
  8751. canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10); // because of resizeNonAxisCharts
  8752. var canvasBg = w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background;
  8753. var ctx = canvas.getContext('2d');
  8754. ctx.fillStyle = canvasBg;
  8755. ctx.fillRect(0, 0, canvas.width, canvas.height);
  8756. var svgData = _this.getSvgString();
  8757. if (window.canvg && Utils.isIE11()) {
  8758. // use canvg as a polyfill to workaround ie11 considering a canvas with loaded svg 'unsafe'
  8759. // without ignoreClear we lose our background color; without ignoreDimensions some grid lines become invisible
  8760. var v = window.canvg.Canvg.fromString(ctx, svgData, {
  8761. ignoreClear: true,
  8762. ignoreDimensions: true
  8763. }); // render the svg to canvas
  8764. v.start();
  8765. var blob = canvas.msToBlob(); // dispose - missing this will cause a memory leak
  8766. v.stop();
  8767. resolve({
  8768. blob: blob
  8769. });
  8770. } else {
  8771. var svgUrl = 'data:image/svg+xml,' + encodeURIComponent(svgData);
  8772. var img = new Image();
  8773. img.crossOrigin = 'anonymous';
  8774. img.onload = function () {
  8775. ctx.drawImage(img, 0, 0);
  8776. if (canvas.msToBlob) {
  8777. // IE and Edge can't navigate to data urls, so we return the blob instead
  8778. var _blob = canvas.msToBlob();
  8779. resolve({
  8780. blob: _blob
  8781. });
  8782. } else {
  8783. var imgURI = canvas.toDataURL('image/png');
  8784. resolve({
  8785. imgURI: imgURI
  8786. });
  8787. }
  8788. };
  8789. img.src = svgUrl;
  8790. }
  8791. });
  8792. }
  8793. }, {
  8794. key: "exportToSVG",
  8795. value: function exportToSVG() {
  8796. this.triggerDownload(this.svgUrl(), '.svg');
  8797. }
  8798. }, {
  8799. key: "exportToPng",
  8800. value: function exportToPng() {
  8801. var _this2 = this;
  8802. this.dataURI().then(function (_ref) {
  8803. var imgURI = _ref.imgURI,
  8804. blob = _ref.blob;
  8805. if (blob) {
  8806. navigator.msSaveOrOpenBlob(blob, _this2.w.globals.chartID + '.png');
  8807. } else {
  8808. _this2.triggerDownload(imgURI, '.png');
  8809. }
  8810. });
  8811. }
  8812. }, {
  8813. key: "exportToCSV",
  8814. value: function exportToCSV(_ref2) {
  8815. var _this3 = this;
  8816. var series = _ref2.series,
  8817. _ref2$columnDelimiter = _ref2.columnDelimiter,
  8818. columnDelimiter = _ref2$columnDelimiter === void 0 ? ',' : _ref2$columnDelimiter,
  8819. _ref2$lineDelimiter = _ref2.lineDelimiter,
  8820. lineDelimiter = _ref2$lineDelimiter === void 0 ? '\n' : _ref2$lineDelimiter;
  8821. var w = this.w;
  8822. var columns = [];
  8823. var rows = [];
  8824. var result = 'data:text/csv;charset=utf-8,';
  8825. var dataFormat = new Data(this.ctx);
  8826. var axesUtils = new AxesUtils(this.ctx);
  8827. var getCat = function getCat(i) {
  8828. var cat = ''; // pie / donut/ radial
  8829. if (!w.globals.axisCharts) {
  8830. cat = w.config.labels[i];
  8831. } else {
  8832. // xy charts
  8833. // non datetime
  8834. if (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) {
  8835. if (w.globals.isBarHorizontal) {
  8836. var lbFormatter = w.globals.yLabelFormatters[0];
  8837. var sr = new Series(_this3.ctx);
  8838. var activeSeries = sr.getActiveConfigSeriesIndex();
  8839. cat = lbFormatter(w.globals.labels[i], {
  8840. seriesIndex: activeSeries,
  8841. dataPointIndex: i,
  8842. w: w
  8843. });
  8844. } else {
  8845. cat = axesUtils.getLabel(w.globals.labels, w.globals.timescaleLabels, 0, i).text;
  8846. }
  8847. } // datetime, but labels specified in categories or labels
  8848. if (w.config.xaxis.type === 'datetime') {
  8849. if (w.config.xaxis.categories.length) {
  8850. cat = w.config.xaxis.categories[i];
  8851. } else if (w.config.labels.length) {
  8852. cat = w.config.labels[i];
  8853. }
  8854. }
  8855. }
  8856. return cat;
  8857. };
  8858. var handleAxisRowsColumns = function handleAxisRowsColumns(s, sI) {
  8859. if (columns.length && sI === 0) {
  8860. rows.push(columns.join(columnDelimiter));
  8861. }
  8862. if (s.data && s.data.length) {
  8863. for (var i = 0; i < s.data.length; i++) {
  8864. columns = [];
  8865. var cat = getCat(i);
  8866. if (!cat) {
  8867. if (dataFormat.isFormatXY()) {
  8868. cat = series[sI].data[i].x;
  8869. } else if (dataFormat.isFormat2DArray()) {
  8870. cat = series[sI].data[i] ? series[sI].data[i][0] : '';
  8871. }
  8872. }
  8873. if (sI === 0) {
  8874. columns.push(cat);
  8875. for (var ci = 0; ci < w.globals.series.length; ci++) {
  8876. columns.push(w.globals.series[ci][i]);
  8877. }
  8878. }
  8879. if (w.config.chart.type === 'candlestick' || s.type && s.type === 'candlestick') {
  8880. columns.pop();
  8881. columns.push(w.globals.seriesCandleO[sI][i]);
  8882. columns.push(w.globals.seriesCandleH[sI][i]);
  8883. columns.push(w.globals.seriesCandleL[sI][i]);
  8884. columns.push(w.globals.seriesCandleC[sI][i]);
  8885. }
  8886. if (w.config.chart.type === 'rangeBar') {
  8887. columns.pop();
  8888. columns.push(w.globals.seriesRangeStart[sI][i]);
  8889. columns.push(w.globals.seriesRangeEnd[sI][i]);
  8890. }
  8891. if (columns.length) {
  8892. rows.push(columns.join(columnDelimiter));
  8893. }
  8894. }
  8895. }
  8896. };
  8897. columns.push('category');
  8898. series.map(function (s, sI) {
  8899. if (w.globals.axisCharts) {
  8900. columns.push(s.name ? s.name : "series-".concat(sI));
  8901. }
  8902. });
  8903. if (!w.globals.axisCharts) {
  8904. columns.push('value');
  8905. rows.push(columns.join(columnDelimiter));
  8906. }
  8907. series.map(function (s, sI) {
  8908. if (w.globals.axisCharts) {
  8909. handleAxisRowsColumns(s, sI);
  8910. } else {
  8911. columns = [];
  8912. columns.push(w.globals.labels[sI]);
  8913. columns.push(w.globals.series[sI]);
  8914. rows.push(columns.join(columnDelimiter));
  8915. }
  8916. });
  8917. result += rows.join(lineDelimiter);
  8918. this.triggerDownload(encodeURI(result), '.csv');
  8919. }
  8920. }, {
  8921. key: "triggerDownload",
  8922. value: function triggerDownload(href, ext) {
  8923. var downloadLink = document.createElement('a');
  8924. downloadLink.href = href;
  8925. downloadLink.download = this.w.globals.chartID + ext;
  8926. document.body.appendChild(downloadLink);
  8927. downloadLink.click();
  8928. document.body.removeChild(downloadLink);
  8929. }
  8930. }]);
  8931. return Exports;
  8932. }();
  8933. /**
  8934. * ApexCharts XAxis Class for drawing X-Axis.
  8935. *
  8936. * @module XAxis
  8937. **/
  8938. var XAxis = /*#__PURE__*/function () {
  8939. function XAxis(ctx) {
  8940. _classCallCheck(this, XAxis);
  8941. this.ctx = ctx;
  8942. this.w = ctx.w;
  8943. var w = this.w;
  8944. this.axesUtils = new AxesUtils(ctx);
  8945. this.xaxisLabels = w.globals.labels.slice();
  8946. if (w.globals.timescaleLabels.length > 0 && !w.globals.isBarHorizontal) {
  8947. // timeline labels are there and chart is not rangeabr timeline
  8948. this.xaxisLabels = w.globals.timescaleLabels.slice();
  8949. }
  8950. this.drawnLabels = [];
  8951. this.drawnLabelsRects = [];
  8952. if (w.config.xaxis.position === 'top') {
  8953. this.offY = 0;
  8954. } else {
  8955. this.offY = w.globals.gridHeight + 1;
  8956. }
  8957. this.offY = this.offY + w.config.xaxis.axisBorder.offsetY;
  8958. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  8959. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  8960. this.xaxisFontFamily = w.config.xaxis.labels.style.fontFamily;
  8961. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  8962. this.xaxisBorderWidth = w.config.xaxis.axisBorder.width;
  8963. if (this.isCategoryBarHorizontal) {
  8964. this.xaxisBorderWidth = w.config.yaxis[0].axisBorder.width.toString();
  8965. }
  8966. if (this.xaxisBorderWidth.indexOf('%') > -1) {
  8967. this.xaxisBorderWidth = w.globals.gridWidth * parseInt(this.xaxisBorderWidth, 10) / 100;
  8968. } else {
  8969. this.xaxisBorderWidth = parseInt(this.xaxisBorderWidth, 10);
  8970. }
  8971. this.xaxisBorderHeight = w.config.xaxis.axisBorder.height; // For bars, we will only consider single y xais,
  8972. // as we are not providing multiple yaxis for bar charts
  8973. this.yaxis = w.config.yaxis[0];
  8974. }
  8975. _createClass(XAxis, [{
  8976. key: "drawXaxis",
  8977. value: function drawXaxis() {
  8978. var _this = this;
  8979. var w = this.w;
  8980. var graphics = new Graphics(this.ctx);
  8981. var elXaxis = graphics.group({
  8982. class: 'apexcharts-xaxis',
  8983. transform: "translate(".concat(w.config.xaxis.offsetX, ", ").concat(w.config.xaxis.offsetY, ")")
  8984. });
  8985. var elXaxisTexts = graphics.group({
  8986. class: 'apexcharts-xaxis-texts-g',
  8987. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  8988. });
  8989. elXaxis.add(elXaxisTexts);
  8990. var colWidth; // initial x Position (keep adding column width in the loop)
  8991. var xPos = w.globals.padHorizontal;
  8992. var labels = [];
  8993. for (var i = 0; i < this.xaxisLabels.length; i++) {
  8994. labels.push(this.xaxisLabels[i]);
  8995. }
  8996. var labelsLen = labels.length;
  8997. if (w.globals.isXNumeric) {
  8998. var len = labelsLen > 1 ? labelsLen - 1 : labelsLen;
  8999. colWidth = w.globals.gridWidth / len;
  9000. xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX;
  9001. } else {
  9002. colWidth = w.globals.gridWidth / labels.length;
  9003. xPos = xPos + colWidth + w.config.xaxis.labels.offsetX;
  9004. }
  9005. if (w.config.xaxis.labels.show) {
  9006. var _loop = function _loop(_i) {
  9007. var x = xPos - colWidth / 2 + w.config.xaxis.labels.offsetX;
  9008. if (_i === 0 && labelsLen === 1 && colWidth / 2 === xPos && w.globals.dataPoints === 1) {
  9009. // single datapoint
  9010. x = w.globals.gridWidth / 2;
  9011. }
  9012. var label = _this.axesUtils.getLabel(labels, w.globals.timescaleLabels, x, _i, _this.drawnLabels, _this.xaxisFontSize);
  9013. var offsetYCorrection = 28;
  9014. if (w.globals.rotateXLabels) {
  9015. offsetYCorrection = 22;
  9016. }
  9017. label = _this.axesUtils.checkForOverflowingLabels(_i, label, labelsLen, _this.drawnLabels, _this.drawnLabelsRects);
  9018. var getCatForeColor = function getCatForeColor() {
  9019. return w.config.xaxis.convertedCatToNumeric ? _this.xaxisForeColors[w.globals.minX + _i - 1] : _this.xaxisForeColors[_i];
  9020. };
  9021. if (label.text) {
  9022. w.globals.xaxisLabelsCount++;
  9023. }
  9024. var elText = graphics.drawText({
  9025. x: label.x,
  9026. y: _this.offY + w.config.xaxis.labels.offsetY + offsetYCorrection - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  9027. text: label.text,
  9028. textAnchor: 'middle',
  9029. fontWeight: label.isBold ? 600 : w.config.xaxis.labels.style.fontWeight,
  9030. fontSize: _this.xaxisFontSize,
  9031. fontFamily: _this.xaxisFontFamily,
  9032. foreColor: Array.isArray(_this.xaxisForeColors) ? getCatForeColor() : _this.xaxisForeColors,
  9033. isPlainText: false,
  9034. cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
  9035. });
  9036. elXaxisTexts.add(elText);
  9037. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  9038. elTooltipTitle.textContent = label.text;
  9039. elText.node.appendChild(elTooltipTitle);
  9040. if (label.text !== '') {
  9041. _this.drawnLabels.push(label.text);
  9042. _this.drawnLabelsRects.push(label);
  9043. }
  9044. xPos = xPos + colWidth;
  9045. };
  9046. for (var _i = 0; _i <= labelsLen - 1; _i++) {
  9047. _loop(_i);
  9048. }
  9049. }
  9050. if (w.config.xaxis.title.text !== undefined) {
  9051. var elXaxisTitle = graphics.group({
  9052. class: 'apexcharts-xaxis-title'
  9053. });
  9054. var elXAxisTitleText = graphics.drawText({
  9055. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  9056. y: this.offY - parseFloat(this.xaxisFontSize) + w.globals.xAxisLabelsHeight + w.config.xaxis.title.offsetY,
  9057. text: w.config.xaxis.title.text,
  9058. textAnchor: 'middle',
  9059. fontSize: w.config.xaxis.title.style.fontSize,
  9060. fontFamily: w.config.xaxis.title.style.fontFamily,
  9061. fontWeight: w.config.xaxis.title.style.fontWeight,
  9062. foreColor: w.config.xaxis.title.style.color,
  9063. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  9064. });
  9065. elXaxisTitle.add(elXAxisTitleText);
  9066. elXaxis.add(elXaxisTitle);
  9067. }
  9068. if (w.config.xaxis.axisBorder.show) {
  9069. var offX = w.globals.barPadForNumericAxis;
  9070. 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);
  9071. elXaxis.add(elHorzLine);
  9072. }
  9073. return elXaxis;
  9074. } // this actually becomes the vertical axis (for bar charts)
  9075. }, {
  9076. key: "drawXaxisInversed",
  9077. value: function drawXaxisInversed(realIndex) {
  9078. var w = this.w;
  9079. var graphics = new Graphics(this.ctx);
  9080. var translateYAxisX = w.config.yaxis[0].opposite ? w.globals.translateYAxisX[realIndex] : 0;
  9081. var elYaxis = graphics.group({
  9082. class: 'apexcharts-yaxis apexcharts-xaxis-inversed',
  9083. rel: realIndex
  9084. });
  9085. var elYaxisTexts = graphics.group({
  9086. class: 'apexcharts-yaxis-texts-g apexcharts-xaxis-inversed-texts-g',
  9087. transform: 'translate(' + translateYAxisX + ', 0)'
  9088. });
  9089. elYaxis.add(elYaxisTexts);
  9090. var colHeight; // initial x Position (keep adding column width in the loop)
  9091. var yPos;
  9092. var labels = [];
  9093. if (w.config.yaxis[realIndex].show) {
  9094. for (var i = 0; i < this.xaxisLabels.length; i++) {
  9095. labels.push(this.xaxisLabels[i]);
  9096. }
  9097. }
  9098. colHeight = w.globals.gridHeight / labels.length;
  9099. yPos = -(colHeight / 2.2);
  9100. var lbFormatter = w.globals.yLabelFormatters[0];
  9101. var ylabels = w.config.yaxis[0].labels;
  9102. if (ylabels.show) {
  9103. for (var _i2 = 0; _i2 <= labels.length - 1; _i2++) {
  9104. var label = typeof labels[_i2] === 'undefined' ? '' : labels[_i2];
  9105. label = lbFormatter(label, {
  9106. seriesIndex: realIndex,
  9107. dataPointIndex: _i2,
  9108. w: w
  9109. });
  9110. var multiY = 0;
  9111. if (Array.isArray(label)) {
  9112. multiY = label.length / 2 * parseInt(ylabels.style.fontSize, 10);
  9113. }
  9114. var elLabel = graphics.drawText({
  9115. x: ylabels.offsetX - 15,
  9116. y: yPos + colHeight + ylabels.offsetY - multiY,
  9117. text: label,
  9118. textAnchor: this.yaxis.opposite ? 'start' : 'end',
  9119. foreColor: Array.isArray(ylabels.style.colors) ? ylabels.style.colors[_i2] : ylabels.style.colors,
  9120. fontSize: ylabels.style.fontSize,
  9121. fontFamily: ylabels.style.fontFamily,
  9122. fontWeight: ylabels.style.fontWeight,
  9123. isPlainText: false,
  9124. cssClass: 'apexcharts-yaxis-label ' + ylabels.style.cssClass
  9125. });
  9126. elYaxisTexts.add(elLabel);
  9127. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  9128. elTooltipTitle.textContent = label.text;
  9129. elLabel.node.appendChild(elTooltipTitle);
  9130. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  9131. var labelRotatingCenter = graphics.rotateAroundCenter(elLabel.node);
  9132. elLabel.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " 0 ").concat(labelRotatingCenter.y, ")"));
  9133. }
  9134. yPos = yPos + colHeight;
  9135. }
  9136. }
  9137. if (w.config.yaxis[0].title.text !== undefined) {
  9138. var elXaxisTitle = graphics.group({
  9139. class: 'apexcharts-yaxis-title apexcharts-xaxis-title-inversed',
  9140. transform: 'translate(' + translateYAxisX + ', 0)'
  9141. });
  9142. var elXAxisTitleText = graphics.drawText({
  9143. x: 0,
  9144. y: w.globals.gridHeight / 2,
  9145. text: w.config.yaxis[0].title.text,
  9146. textAnchor: 'middle',
  9147. foreColor: w.config.yaxis[0].title.style.color,
  9148. fontSize: w.config.yaxis[0].title.style.fontSize,
  9149. fontWeight: w.config.yaxis[0].title.style.fontWeight,
  9150. fontFamily: w.config.yaxis[0].title.style.fontFamily,
  9151. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[0].title.style.cssClass
  9152. });
  9153. elXaxisTitle.add(elXAxisTitleText);
  9154. elYaxis.add(elXaxisTitle);
  9155. }
  9156. var offX = 0;
  9157. if (this.isCategoryBarHorizontal && w.config.yaxis[0].opposite) {
  9158. offX = w.globals.gridWidth;
  9159. }
  9160. var axisBorder = w.config.xaxis.axisBorder;
  9161. if (axisBorder.show) {
  9162. 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);
  9163. elYaxis.add(elVerticalLine);
  9164. }
  9165. if (w.config.yaxis[0].axisTicks.show) {
  9166. this.axesUtils.drawYAxisTicks(offX, labels.length, w.config.yaxis[0].axisBorder, w.config.yaxis[0].axisTicks, 0, colHeight, elYaxis);
  9167. }
  9168. return elYaxis;
  9169. }
  9170. }, {
  9171. key: "drawXaxisTicks",
  9172. value: function drawXaxisTicks(x1, appendToElement) {
  9173. var w = this.w;
  9174. var x2 = x1;
  9175. if (x1 < 0 || x1 - 2 > w.globals.gridWidth) return;
  9176. var y1 = this.offY + w.config.xaxis.axisTicks.offsetY;
  9177. var y2 = y1 + w.config.xaxis.axisTicks.height;
  9178. if (w.config.xaxis.position === 'top') {
  9179. y2 = y1 - w.config.xaxis.axisTicks.height;
  9180. }
  9181. if (w.config.xaxis.axisTicks.show) {
  9182. var graphics = new Graphics(this.ctx);
  9183. var line = graphics.drawLine(x1 + w.config.xaxis.axisTicks.offsetX, y1 + w.config.xaxis.offsetY, x2 + w.config.xaxis.axisTicks.offsetX, y2 + w.config.xaxis.offsetY, w.config.xaxis.axisTicks.color); // we are not returning anything, but appending directly to the element pased in param
  9184. appendToElement.add(line);
  9185. line.node.classList.add('apexcharts-xaxis-tick');
  9186. }
  9187. }
  9188. }, {
  9189. key: "getXAxisTicksPositions",
  9190. value: function getXAxisTicksPositions() {
  9191. var w = this.w;
  9192. var xAxisTicksPositions = [];
  9193. var xCount = this.xaxisLabels.length;
  9194. var x1 = w.globals.padHorizontal;
  9195. if (w.globals.timescaleLabels.length > 0) {
  9196. for (var i = 0; i < xCount; i++) {
  9197. x1 = this.xaxisLabels[i].position;
  9198. xAxisTicksPositions.push(x1);
  9199. }
  9200. } else {
  9201. var xCountForCategoryCharts = xCount;
  9202. for (var _i3 = 0; _i3 < xCountForCategoryCharts; _i3++) {
  9203. var x1Count = xCountForCategoryCharts;
  9204. if (w.globals.isXNumeric && w.config.chart.type !== 'bar') {
  9205. x1Count -= 1;
  9206. }
  9207. x1 = x1 + w.globals.gridWidth / x1Count;
  9208. xAxisTicksPositions.push(x1);
  9209. }
  9210. }
  9211. return xAxisTicksPositions;
  9212. } // to rotate x-axis labels or to put ... for longer text in xaxis
  9213. }, {
  9214. key: "xAxisLabelCorrections",
  9215. value: function xAxisLabelCorrections() {
  9216. var w = this.w;
  9217. var graphics = new Graphics(this.ctx);
  9218. var xAxis = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g');
  9219. var xAxisTexts = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-texts-g text');
  9220. var yAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-inversed text');
  9221. var xAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-inversed-texts-g text tspan');
  9222. if (w.globals.rotateXLabels || w.config.xaxis.labels.rotateAlways) {
  9223. for (var xat = 0; xat < xAxisTexts.length; xat++) {
  9224. var textRotatingCenter = graphics.rotateAroundCenter(xAxisTexts[xat]);
  9225. textRotatingCenter.y = textRotatingCenter.y - 1; // + tickWidth/4;
  9226. textRotatingCenter.x = textRotatingCenter.x + 1;
  9227. xAxisTexts[xat].setAttribute('transform', "rotate(".concat(w.config.xaxis.labels.rotate, " ").concat(textRotatingCenter.x, " ").concat(textRotatingCenter.y, ")"));
  9228. xAxisTexts[xat].setAttribute('text-anchor', "end");
  9229. var offsetHeight = 10;
  9230. xAxis.setAttribute('transform', "translate(0, ".concat(-offsetHeight, ")"));
  9231. var tSpan = xAxisTexts[xat].childNodes;
  9232. if (w.config.xaxis.labels.trim) {
  9233. Array.prototype.forEach.call(tSpan, function (ts) {
  9234. graphics.placeTextWithEllipsis(ts, ts.textContent, w.config.xaxis.labels.maxHeight - (w.config.legend.position === 'bottom' ? 20 : 10));
  9235. });
  9236. }
  9237. }
  9238. } else {
  9239. (function () {
  9240. var width = w.globals.gridWidth / (w.globals.labels.length + 1);
  9241. for (var _xat = 0; _xat < xAxisTexts.length; _xat++) {
  9242. var _tSpan = xAxisTexts[_xat].childNodes;
  9243. if (w.config.xaxis.labels.trim && w.config.xaxis.type !== 'datetime') {
  9244. Array.prototype.forEach.call(_tSpan, function (ts) {
  9245. graphics.placeTextWithEllipsis(ts, ts.textContent, width);
  9246. });
  9247. }
  9248. }
  9249. })();
  9250. }
  9251. if (yAxisTextsInversed.length > 0) {
  9252. // truncate rotated y axis in bar chart (x axis)
  9253. var firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox();
  9254. var lastLabelPosX = yAxisTextsInversed[0].getBBox();
  9255. if (firstLabelPosX.x < -20) {
  9256. yAxisTextsInversed[yAxisTextsInversed.length - 1].parentNode.removeChild(yAxisTextsInversed[yAxisTextsInversed.length - 1]);
  9257. }
  9258. if (lastLabelPosX.x + lastLabelPosX.width > w.globals.gridWidth && !w.globals.isBarHorizontal) {
  9259. yAxisTextsInversed[0].parentNode.removeChild(yAxisTextsInversed[0]);
  9260. } // truncate rotated x axis in bar chart (y axis)
  9261. for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) {
  9262. graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 - 20);
  9263. }
  9264. }
  9265. } // renderXAxisBands() {
  9266. // let w = this.w;
  9267. // let plotBand = document.createElementNS(w.globals.SVGNS, 'rect')
  9268. // w.globals.dom.elGraphical.add(plotBand)
  9269. // }
  9270. }]);
  9271. return XAxis;
  9272. }();
  9273. /**
  9274. * ApexCharts Grid Class for drawing Cartesian Grid.
  9275. *
  9276. * @module Grid
  9277. **/
  9278. var Grid = /*#__PURE__*/function () {
  9279. function Grid(ctx) {
  9280. _classCallCheck(this, Grid);
  9281. this.ctx = ctx;
  9282. this.w = ctx.w;
  9283. var w = this.w;
  9284. this.xaxisLabels = w.globals.labels.slice();
  9285. this.axesUtils = new AxesUtils(ctx);
  9286. this.isTimelineBar = w.config.xaxis.type === 'datetime' && w.globals.seriesRangeBarTimeline.length;
  9287. if (w.globals.timescaleLabels.length > 0) {
  9288. // timescaleLabels labels are there
  9289. this.xaxisLabels = w.globals.timescaleLabels.slice();
  9290. }
  9291. } // 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
  9292. _createClass(Grid, [{
  9293. key: "drawGridArea",
  9294. value: function drawGridArea() {
  9295. var elGrid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9296. var w = this.w;
  9297. var graphics = new Graphics(this.ctx);
  9298. if (elGrid === null) {
  9299. elGrid = graphics.group({
  9300. class: 'apexcharts-grid'
  9301. });
  9302. }
  9303. var elVerticalLine = graphics.drawLine(w.globals.padHorizontal, 1, w.globals.padHorizontal, w.globals.gridHeight, 'transparent');
  9304. var elHorzLine = graphics.drawLine(w.globals.padHorizontal, w.globals.gridHeight, w.globals.gridWidth, w.globals.gridHeight, 'transparent');
  9305. elGrid.add(elHorzLine);
  9306. elGrid.add(elVerticalLine);
  9307. return elGrid;
  9308. }
  9309. }, {
  9310. key: "drawGrid",
  9311. value: function drawGrid() {
  9312. var gl = this.w.globals;
  9313. var elgrid = null;
  9314. if (gl.axisCharts) {
  9315. // grid is drawn after xaxis and yaxis are drawn
  9316. elgrid = this.renderGrid();
  9317. this.drawGridArea(elgrid.el);
  9318. }
  9319. return elgrid;
  9320. } // This mask will clip off overflowing graphics from the drawable area
  9321. }, {
  9322. key: "createGridMask",
  9323. value: function createGridMask() {
  9324. var w = this.w;
  9325. var gl = w.globals;
  9326. var graphics = new Graphics(this.ctx);
  9327. var strokeSize = Array.isArray(w.config.stroke.width) ? 0 : w.config.stroke.width;
  9328. if (Array.isArray(w.config.stroke.width)) {
  9329. var strokeMaxSize = 0;
  9330. w.config.stroke.width.forEach(function (m) {
  9331. strokeMaxSize = Math.max(strokeMaxSize, m);
  9332. });
  9333. strokeSize = strokeMaxSize;
  9334. }
  9335. gl.dom.elGridRectMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9336. gl.dom.elGridRectMask.setAttribute('id', "gridRectMask".concat(gl.cuid));
  9337. gl.dom.elGridRectMarkerMask = document.createElementNS(gl.SVGNS, 'clipPath');
  9338. gl.dom.elGridRectMarkerMask.setAttribute('id', "gridRectMarkerMask".concat(gl.cuid)); // let barHalfWidth = 0
  9339. var type = w.config.chart.type;
  9340. var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
  9341. var barWidthLeft = 0;
  9342. var barWidthRight = 0;
  9343. if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal) {
  9344. barWidthLeft = w.config.grid.padding.left;
  9345. barWidthRight = w.config.grid.padding.right;
  9346. if (gl.barPadForNumericAxis > barWidthLeft) {
  9347. barWidthLeft = gl.barPadForNumericAxis;
  9348. barWidthRight = gl.barPadForNumericAxis;
  9349. }
  9350. }
  9351. gl.dom.elGridRect = graphics.drawRect(-strokeSize / 2 - barWidthLeft - 2, -strokeSize / 2, gl.gridWidth + strokeSize + barWidthRight + barWidthLeft + 4, gl.gridHeight + strokeSize, 0, '#fff');
  9352. var coreUtils = new CoreUtils(this);
  9353. coreUtils.getLargestMarkerSize();
  9354. var markerSize = w.globals.markers.largestSize + 1;
  9355. gl.dom.elGridRectMarker = graphics.drawRect(-markerSize * 2, -markerSize * 2, gl.gridWidth + markerSize * 4, gl.gridHeight + markerSize * 4, 0, '#fff');
  9356. gl.dom.elGridRectMask.appendChild(gl.dom.elGridRect.node);
  9357. gl.dom.elGridRectMarkerMask.appendChild(gl.dom.elGridRectMarker.node);
  9358. var defs = gl.dom.baseEl.querySelector('defs');
  9359. defs.appendChild(gl.dom.elGridRectMask);
  9360. defs.appendChild(gl.dom.elGridRectMarkerMask);
  9361. }
  9362. }, {
  9363. key: "_drawGridLines",
  9364. value: function _drawGridLines(_ref) {
  9365. var i = _ref.i,
  9366. x1 = _ref.x1,
  9367. y1 = _ref.y1,
  9368. x2 = _ref.x2,
  9369. y2 = _ref.y2,
  9370. xCount = _ref.xCount,
  9371. parent = _ref.parent;
  9372. var w = this.w;
  9373. var shouldDraw = function shouldDraw() {
  9374. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  9375. return false;
  9376. }
  9377. if (i === xCount - 1 && w.globals.skipLastTimelinelabel) {
  9378. return false;
  9379. }
  9380. if (w.config.chart.type === 'radar') {
  9381. return false;
  9382. }
  9383. return true;
  9384. };
  9385. if (shouldDraw()) {
  9386. if (w.config.grid.xaxis.lines.show) {
  9387. this._drawGridLine({
  9388. x1: x1,
  9389. y1: y1,
  9390. x2: x2,
  9391. y2: y2,
  9392. parent: parent
  9393. });
  9394. }
  9395. var xAxis = new XAxis(this.ctx);
  9396. xAxis.drawXaxisTicks(x1, this.elg);
  9397. }
  9398. }
  9399. }, {
  9400. key: "_drawGridLine",
  9401. value: function _drawGridLine(_ref2) {
  9402. var x1 = _ref2.x1,
  9403. y1 = _ref2.y1,
  9404. x2 = _ref2.x2,
  9405. y2 = _ref2.y2,
  9406. parent = _ref2.parent;
  9407. var w = this.w;
  9408. var isHorzLine = parent.node.classList.contains('apexcharts-gridlines-horizontal');
  9409. var strokeDashArray = w.config.grid.strokeDashArray;
  9410. var offX = w.globals.barPadForNumericAxis;
  9411. var graphics = new Graphics(this);
  9412. var line = graphics.drawLine(x1 - (isHorzLine ? offX : 0), y1, x2 + (isHorzLine ? offX : 0), y2, w.config.grid.borderColor, strokeDashArray);
  9413. line.node.classList.add('apexcharts-gridline');
  9414. parent.add(line);
  9415. }
  9416. }, {
  9417. key: "_drawGridBandRect",
  9418. value: function _drawGridBandRect(_ref3) {
  9419. var c = _ref3.c,
  9420. x1 = _ref3.x1,
  9421. y1 = _ref3.y1,
  9422. x2 = _ref3.x2,
  9423. y2 = _ref3.y2,
  9424. type = _ref3.type;
  9425. var w = this.w;
  9426. var graphics = new Graphics(this.ctx);
  9427. var offX = w.globals.barPadForNumericAxis;
  9428. if (type === 'column' && w.config.xaxis.type === 'datetime') return;
  9429. var color = w.config.grid[type].colors[c];
  9430. var rect = graphics.drawRect(x1 - (type === 'row' ? offX : 0), y1, x2 + (type === 'row' ? offX * 2 : 0), y2, 0, color, w.config.grid[type].opacity);
  9431. this.elg.add(rect);
  9432. rect.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")"));
  9433. rect.node.classList.add("apexcharts-grid-".concat(type));
  9434. }
  9435. }, {
  9436. key: "_drawXYLines",
  9437. value: function _drawXYLines(_ref4) {
  9438. var _this = this;
  9439. var xCount = _ref4.xCount,
  9440. tickAmount = _ref4.tickAmount;
  9441. var w = this.w;
  9442. var datetimeLines = function datetimeLines(_ref5) {
  9443. var xC = _ref5.xC,
  9444. x1 = _ref5.x1,
  9445. y1 = _ref5.y1,
  9446. x2 = _ref5.x2,
  9447. y2 = _ref5.y2;
  9448. for (var i = 0; i < xC; i++) {
  9449. x1 = _this.xaxisLabels[i].position;
  9450. x2 = _this.xaxisLabels[i].position;
  9451. _this._drawGridLines({
  9452. i: i,
  9453. x1: x1,
  9454. y1: y1,
  9455. x2: x2,
  9456. y2: y2,
  9457. xCount: xCount,
  9458. parent: _this.elgridLinesV
  9459. });
  9460. }
  9461. };
  9462. var categoryLines = function categoryLines(_ref6) {
  9463. var xC = _ref6.xC,
  9464. x1 = _ref6.x1,
  9465. y1 = _ref6.y1,
  9466. x2 = _ref6.x2,
  9467. y2 = _ref6.y2;
  9468. for (var i = 0; i < xC + (w.globals.isXNumeric ? 0 : 1); i++) {
  9469. if (i === 0 && xC === 1 && w.globals.dataPoints === 1) {
  9470. // single datapoint
  9471. x1 = w.globals.gridWidth / 2;
  9472. x2 = x1;
  9473. }
  9474. _this._drawGridLines({
  9475. i: i,
  9476. x1: x1,
  9477. y1: y1,
  9478. x2: x2,
  9479. y2: y2,
  9480. xCount: xCount,
  9481. parent: _this.elgridLinesV
  9482. });
  9483. x1 = x1 + w.globals.gridWidth / (w.globals.isXNumeric ? xC - 1 : xC);
  9484. x2 = x1;
  9485. }
  9486. }; // draw vertical lines
  9487. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  9488. var x1 = w.globals.padHorizontal;
  9489. var y1 = 0;
  9490. var x2;
  9491. var y2 = w.globals.gridHeight;
  9492. if (w.globals.timescaleLabels.length) {
  9493. datetimeLines({
  9494. xC: xCount,
  9495. x1: x1,
  9496. y1: y1,
  9497. x2: x2,
  9498. y2: y2
  9499. });
  9500. } else {
  9501. if (w.globals.isXNumeric) {
  9502. xCount = w.globals.xAxisScale.result.length;
  9503. }
  9504. if (w.config.xaxis.convertedCatToNumeric) {
  9505. // in case of a convertedCatToNumeric, some labels might be skipped due to hideOverLapping labels, hence use this var to get the visible ticks
  9506. xCount = w.globals.xaxisLabelsCount;
  9507. }
  9508. categoryLines({
  9509. xC: xCount,
  9510. x1: x1,
  9511. y1: y1,
  9512. x2: x2,
  9513. y2: y2
  9514. });
  9515. }
  9516. } // draw horizontal lines
  9517. if (w.config.grid.yaxis.lines.show) {
  9518. var _x = 0;
  9519. var _y = 0;
  9520. var _y2 = 0;
  9521. var _x2 = w.globals.gridWidth;
  9522. var tA = tickAmount + 1;
  9523. if (this.isTimelineBar) {
  9524. tA = w.globals.labels.length;
  9525. }
  9526. for (var i = 0; i < tA + (this.isTimelineBar ? 1 : 0); i++) {
  9527. this._drawGridLine({
  9528. x1: _x,
  9529. y1: _y,
  9530. x2: _x2,
  9531. y2: _y2,
  9532. parent: this.elgridLinesH
  9533. });
  9534. _y = _y + w.globals.gridHeight / (this.isTimelineBar ? tA : tickAmount);
  9535. _y2 = _y;
  9536. }
  9537. }
  9538. }
  9539. }, {
  9540. key: "_drawInvertedXYLines",
  9541. value: function _drawInvertedXYLines(_ref7) {
  9542. var xCount = _ref7.xCount;
  9543. var w = this.w; // draw vertical lines
  9544. if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) {
  9545. var x1 = w.globals.padHorizontal;
  9546. var y1 = 0;
  9547. var x2;
  9548. var y2 = w.globals.gridHeight;
  9549. for (var i = 0; i < xCount + 1; i++) {
  9550. if (w.config.grid.xaxis.lines.show) {
  9551. this._drawGridLine({
  9552. x1: x1,
  9553. y1: y1,
  9554. x2: x2,
  9555. y2: y2,
  9556. parent: this.elgridLinesV
  9557. });
  9558. }
  9559. var xAxis = new XAxis(this.ctx);
  9560. xAxis.drawXaxisTicks(x1, this.elg);
  9561. x1 = x1 + w.globals.gridWidth / xCount + 0.3;
  9562. x2 = x1;
  9563. }
  9564. } // draw horizontal lines
  9565. if (w.config.grid.yaxis.lines.show) {
  9566. var _x3 = 0;
  9567. var _y3 = 0;
  9568. var _y4 = 0;
  9569. var _x4 = w.globals.gridWidth;
  9570. for (var _i = 0; _i < w.globals.dataPoints + 1; _i++) {
  9571. this._drawGridLine({
  9572. x1: _x3,
  9573. y1: _y3,
  9574. x2: _x4,
  9575. y2: _y4,
  9576. parent: this.elgridLinesH
  9577. });
  9578. _y3 = _y3 + w.globals.gridHeight / w.globals.dataPoints;
  9579. _y4 = _y3;
  9580. }
  9581. }
  9582. } // actual grid rendering
  9583. }, {
  9584. key: "renderGrid",
  9585. value: function renderGrid() {
  9586. var w = this.w;
  9587. var graphics = new Graphics(this.ctx);
  9588. this.elg = graphics.group({
  9589. class: 'apexcharts-grid'
  9590. });
  9591. this.elgridLinesH = graphics.group({
  9592. class: 'apexcharts-gridlines-horizontal'
  9593. });
  9594. this.elgridLinesV = graphics.group({
  9595. class: 'apexcharts-gridlines-vertical'
  9596. });
  9597. this.elg.add(this.elgridLinesH);
  9598. this.elg.add(this.elgridLinesV);
  9599. if (!w.config.grid.show) {
  9600. this.elgridLinesV.hide();
  9601. this.elgridLinesH.hide();
  9602. }
  9603. var yTickAmount = w.globals.yAxisScale.length ? w.globals.yAxisScale[0].result.length - 1 : 5;
  9604. for (var i = 0; i < w.globals.series.length; i++) {
  9605. if (typeof w.globals.yAxisScale[i] !== 'undefined') {
  9606. yTickAmount = w.globals.yAxisScale[i].result.length - 1;
  9607. }
  9608. if (yTickAmount > 2) break;
  9609. }
  9610. var xCount;
  9611. if (!w.globals.isBarHorizontal || this.isTimelineBar) {
  9612. xCount = this.xaxisLabels.length;
  9613. if (this.isTimelineBar) {
  9614. yTickAmount = w.globals.labels.length;
  9615. }
  9616. this._drawXYLines({
  9617. xCount: xCount,
  9618. tickAmount: yTickAmount
  9619. });
  9620. } else {
  9621. xCount = yTickAmount; // for horizontal bar chart, get the xaxis tickamount
  9622. yTickAmount = w.globals.xTickAmount;
  9623. this._drawInvertedXYLines({
  9624. xCount: xCount,
  9625. tickAmount: yTickAmount
  9626. });
  9627. }
  9628. this.drawGridBands(xCount, yTickAmount);
  9629. return {
  9630. el: this.elg,
  9631. xAxisTickWidth: w.globals.gridWidth / xCount
  9632. };
  9633. }
  9634. }, {
  9635. key: "drawGridBands",
  9636. value: function drawGridBands(xCount, tickAmount) {
  9637. var w = this.w; // rows background bands
  9638. if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) {
  9639. var x1 = 0;
  9640. var y1 = 0;
  9641. var y2 = w.globals.gridHeight / tickAmount;
  9642. var x2 = w.globals.gridWidth;
  9643. for (var i = 0, c = 0; i < tickAmount; i++, c++) {
  9644. if (c >= w.config.grid.row.colors.length) {
  9645. c = 0;
  9646. }
  9647. this._drawGridBandRect({
  9648. c: c,
  9649. x1: x1,
  9650. y1: y1,
  9651. x2: x2,
  9652. y2: y2,
  9653. type: 'row'
  9654. });
  9655. y1 = y1 + w.globals.gridHeight / tickAmount;
  9656. }
  9657. } // columns background bands
  9658. if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) {
  9659. var xc = !w.globals.isBarHorizontal && (w.config.xaxis.type === 'category' || w.config.xaxis.convertedCatToNumeric) ? xCount - 1 : xCount;
  9660. var _x5 = w.globals.padHorizontal;
  9661. var _y5 = 0;
  9662. var _x6 = w.globals.padHorizontal + w.globals.gridWidth / xc;
  9663. var _y6 = w.globals.gridHeight;
  9664. for (var _i2 = 0, _c = 0; _i2 < xCount; _i2++, _c++) {
  9665. if (_c >= w.config.grid.column.colors.length) {
  9666. _c = 0;
  9667. }
  9668. this._drawGridBandRect({
  9669. c: _c,
  9670. x1: _x5,
  9671. y1: _y5,
  9672. x2: _x6,
  9673. y2: _y6,
  9674. type: 'column'
  9675. });
  9676. _x5 = _x5 + w.globals.gridWidth / xc;
  9677. }
  9678. }
  9679. }
  9680. }]);
  9681. return Grid;
  9682. }();
  9683. var Range = /*#__PURE__*/function () {
  9684. function Range(ctx) {
  9685. _classCallCheck(this, Range);
  9686. this.ctx = ctx;
  9687. this.w = ctx.w;
  9688. } // http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axiss
  9689. // This routine creates the Y axis values for a graph.
  9690. _createClass(Range, [{
  9691. key: "niceScale",
  9692. value: function niceScale(yMin, yMax) {
  9693. var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  9694. var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  9695. var NO_MIN_MAX_PROVIDED = arguments.length > 4 ? arguments[4] : undefined;
  9696. var w = this.w;
  9697. if (ticks === 'dataPoints') {
  9698. ticks = w.globals.dataPoints - 1;
  9699. }
  9700. if (yMin === Number.MIN_VALUE && yMax === 0 || !Utils.isNumber(yMin) && !Utils.isNumber(yMax) || yMin === Number.MIN_VALUE && yMax === -Number.MAX_VALUE) {
  9701. // when all values are 0
  9702. yMin = 0;
  9703. yMax = ticks;
  9704. var linearScale = this.linearScale(yMin, yMax, ticks);
  9705. return linearScale;
  9706. }
  9707. if (yMin > yMax) {
  9708. // if somehow due to some wrong config, user sent max less than min,
  9709. // adjust the min/max again
  9710. console.warn('axis.min cannot be greater than axis.max');
  9711. yMax = yMin + 0.1;
  9712. } else if (yMin === yMax) {
  9713. // If yMin and yMax are identical, then
  9714. // adjust the yMin and yMax values to actually
  9715. // make a graph. Also avoids division by zero errors.
  9716. yMin = yMin === 0 ? 0 : yMin - 0.5; // some small value
  9717. yMax = yMax === 0 ? 2 : yMax + 0.5; // some small value
  9718. } // Calculate Min amd Max graphical labels and graph
  9719. // increments. The number of ticks defaults to
  9720. // 10 which is the SUGGESTED value. Any tick value
  9721. // entered is used as a suggested value which is
  9722. // adjusted to be a 'pretty' value.
  9723. //
  9724. // Output will be an array of the Y axis values that
  9725. // encompass the Y values.
  9726. var result = []; // Determine Range
  9727. var range = Math.abs(yMax - yMin);
  9728. if (range < 1 && NO_MIN_MAX_PROVIDED && (w.config.chart.type === 'candlestick' || w.config.series[index].type === 'candlestick' || w.globals.isRangeData)) {
  9729. /* fix https://github.com/apexcharts/apexcharts.js/issues/430 */
  9730. yMax = yMax * 1.01;
  9731. }
  9732. var tiks = ticks + 1; // Adjust ticks if needed
  9733. if (tiks < 2) {
  9734. tiks = 2;
  9735. } else if (tiks > 2) {
  9736. tiks -= 2;
  9737. } // Get raw step value
  9738. var tempStep = range / tiks; // Calculate pretty step value
  9739. var mag = Math.floor(Utils.log10(tempStep));
  9740. var magPow = Math.pow(10, mag);
  9741. var magMsd = Math.round(tempStep / magPow);
  9742. if (magMsd < 1) {
  9743. magMsd = 1;
  9744. }
  9745. var stepSize = magMsd * magPow; // build Y label array.
  9746. // Lower and upper bounds calculations
  9747. var lb = stepSize * Math.floor(yMin / stepSize);
  9748. var ub = stepSize * Math.ceil(yMax / stepSize); // Build array
  9749. var val = lb;
  9750. if (NO_MIN_MAX_PROVIDED && range > 2) {
  9751. while (1) {
  9752. result.push(val);
  9753. val += stepSize;
  9754. if (val > ub) {
  9755. break;
  9756. }
  9757. }
  9758. return {
  9759. result: result,
  9760. niceMin: result[0],
  9761. niceMax: result[result.length - 1]
  9762. };
  9763. } else {
  9764. result = [];
  9765. var v = yMin;
  9766. result.push(v);
  9767. var valuesDivider = Math.abs(yMax - yMin) / ticks;
  9768. for (var i = 0; i <= ticks; i++) {
  9769. v = v + valuesDivider;
  9770. result.push(v);
  9771. }
  9772. if (result[result.length - 2] >= yMax) {
  9773. result.pop();
  9774. }
  9775. return {
  9776. result: result,
  9777. niceMin: result[0],
  9778. niceMax: result[result.length - 1]
  9779. };
  9780. }
  9781. }
  9782. }, {
  9783. key: "linearScale",
  9784. value: function linearScale(yMin, yMax) {
  9785. var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  9786. var range = Math.abs(yMax - yMin);
  9787. var step = range / ticks;
  9788. if (ticks === Number.MAX_VALUE) {
  9789. ticks = 10;
  9790. step = 1;
  9791. }
  9792. var result = [];
  9793. var v = yMin;
  9794. while (ticks >= 0) {
  9795. result.push(v);
  9796. v = v + step;
  9797. ticks -= 1;
  9798. }
  9799. return {
  9800. result: result,
  9801. niceMin: result[0],
  9802. niceMax: result[result.length - 1]
  9803. };
  9804. }
  9805. }, {
  9806. key: "logarithmicScale",
  9807. value: function logarithmicScale(index, yMin, yMax, ticks) {
  9808. if (yMin < 0 || yMin === Number.MIN_VALUE) yMin = 0.01;
  9809. var base = 10;
  9810. var min = Math.log(yMin) / Math.log(base);
  9811. var max = Math.log(yMax) / Math.log(base);
  9812. var range = Math.abs(yMax - yMin);
  9813. var step = range / ticks;
  9814. var result = [];
  9815. var v = yMin;
  9816. while (ticks >= 0) {
  9817. result.push(v);
  9818. v = v + step;
  9819. ticks -= 1;
  9820. }
  9821. var logs = result.map(function (niceNumber, i) {
  9822. if (niceNumber <= 0) {
  9823. niceNumber = 0.01;
  9824. } // calculate adjustment factor
  9825. var scale = (max - min) / (yMax - yMin);
  9826. var logVal = Math.pow(base, min + scale * (niceNumber - min));
  9827. return Math.round(logVal / Utils.roundToBase(logVal, base)) * Utils.roundToBase(logVal, base);
  9828. }); // Math.floor may have rounded the value to 0, revert back to 1
  9829. if (logs[0] === 0) logs[0] = 1;
  9830. return {
  9831. result: logs,
  9832. niceMin: logs[0],
  9833. niceMax: logs[logs.length - 1]
  9834. };
  9835. }
  9836. }, {
  9837. key: "setYScaleForIndex",
  9838. value: function setYScaleForIndex(index, minY, maxY) {
  9839. var gl = this.w.globals;
  9840. var cnf = this.w.config;
  9841. var y = gl.isBarHorizontal ? cnf.xaxis : cnf.yaxis[index];
  9842. if (typeof gl.yAxisScale[index] === 'undefined') {
  9843. gl.yAxisScale[index] = [];
  9844. }
  9845. var diff = Math.abs(maxY - minY);
  9846. if (y.logarithmic && diff <= 5) {
  9847. gl.invalidLogScale = true;
  9848. }
  9849. if (y.logarithmic && diff > 5) {
  9850. gl.allSeriesCollapsed = false;
  9851. gl.yAxisScale[index] = this.logarithmicScale(index, minY, maxY, y.tickAmount ? y.tickAmount : Math.floor(Math.log10(maxY)));
  9852. } else {
  9853. if (maxY === -Number.MAX_VALUE || !Utils.isNumber(maxY)) {
  9854. // no data in the chart. Either all series collapsed or user passed a blank array
  9855. gl.yAxisScale[index] = this.linearScale(0, 5, 5);
  9856. } else {
  9857. // there is some data. Turn off the allSeriesCollapsed flag
  9858. gl.allSeriesCollapsed = false;
  9859. if ((y.min !== undefined || y.max !== undefined) && !y.forceNiceScale) {
  9860. // fix https://github.com/apexcharts/apexcharts.js/issues/492
  9861. gl.yAxisScale[index] = this.linearScale(minY, maxY, y.tickAmount);
  9862. } else {
  9863. var noMinMaxProvided = cnf.yaxis[index].max === undefined && cnf.yaxis[index].min === undefined || cnf.yaxis[index].forceNiceScale;
  9864. 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
  9865. noMinMaxProvided);
  9866. }
  9867. }
  9868. }
  9869. }
  9870. }, {
  9871. key: "setXScale",
  9872. value: function setXScale(minX, maxX) {
  9873. var w = this.w;
  9874. var gl = w.globals;
  9875. var x = w.config.xaxis;
  9876. var diff = Math.abs(maxX - minX);
  9877. if (maxX === -Number.MAX_VALUE || !Utils.isNumber(maxX)) {
  9878. // no data in the chart. Either all series collapsed or user passed a blank array
  9879. gl.xAxisScale = this.linearScale(0, 5, 5);
  9880. } else {
  9881. gl.xAxisScale = this.niceScale(minX, maxX, x.tickAmount ? x.tickAmount : diff < 5 && diff > 1 ? diff + 1 : 5, 0);
  9882. }
  9883. return gl.xAxisScale;
  9884. }
  9885. }, {
  9886. key: "setMultipleYScales",
  9887. value: function setMultipleYScales() {
  9888. var _this = this;
  9889. var gl = this.w.globals;
  9890. var cnf = this.w.config;
  9891. var minYArr = gl.minYArr.concat([]);
  9892. var maxYArr = gl.maxYArr.concat([]);
  9893. var scalesIndices = []; // here, we loop through the yaxis array and find the item which has "seriesName" property
  9894. cnf.yaxis.forEach(function (yaxe, i) {
  9895. var index = i;
  9896. cnf.series.forEach(function (s, si) {
  9897. // if seriesName matches and that series is not collapsed, we use that scale
  9898. // fix issue #1215
  9899. // proceed even if si is in gl.collapsedSeriesIndices
  9900. if (s.name === yaxe.seriesName) {
  9901. index = si;
  9902. if (i !== si) {
  9903. scalesIndices.push({
  9904. index: si,
  9905. similarIndex: i,
  9906. alreadyExists: true
  9907. });
  9908. } else {
  9909. scalesIndices.push({
  9910. index: si
  9911. });
  9912. }
  9913. }
  9914. });
  9915. var minY = minYArr[index];
  9916. var maxY = maxYArr[index];
  9917. _this.setYScaleForIndex(i, minY, maxY);
  9918. });
  9919. this.sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices);
  9920. }
  9921. }, {
  9922. key: "sameScaleInMultipleAxes",
  9923. value: function sameScaleInMultipleAxes(minYArr, maxYArr, scalesIndices) {
  9924. var _this2 = this;
  9925. var cnf = this.w.config;
  9926. 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
  9927. var similarIndices = [];
  9928. scalesIndices.forEach(function (scale) {
  9929. if (scale.alreadyExists) {
  9930. if (typeof similarIndices[scale.index] === 'undefined') {
  9931. similarIndices[scale.index] = [];
  9932. }
  9933. similarIndices[scale.index].push(scale.index);
  9934. similarIndices[scale.index].push(scale.similarIndex);
  9935. }
  9936. });
  9937. function intersect(a, b) {
  9938. return a.filter(function (value) {
  9939. return b.indexOf(value) !== -1;
  9940. });
  9941. }
  9942. gl.yAxisSameScaleIndices = similarIndices;
  9943. similarIndices.forEach(function (si, i) {
  9944. similarIndices.forEach(function (sj, j) {
  9945. if (i !== j) {
  9946. if (intersect(si, sj).length > 0) {
  9947. similarIndices[i] = similarIndices[i].concat(similarIndices[j]);
  9948. }
  9949. }
  9950. });
  9951. }); // then, we remove duplicates from the similarScale array
  9952. var uniqueSimilarIndices = similarIndices.map(function (item) {
  9953. return item.filter(function (i, pos) {
  9954. return item.indexOf(i) === pos;
  9955. });
  9956. }); // sort further to remove whole duplicate arrays later
  9957. var sortedIndices = uniqueSimilarIndices.map(function (s) {
  9958. return s.sort();
  9959. }); // remove undefined items
  9960. similarIndices = similarIndices.filter(function (s) {
  9961. return !!s;
  9962. });
  9963. var indices = sortedIndices.slice();
  9964. var stringIndices = indices.map(function (ind) {
  9965. return JSON.stringify(ind);
  9966. });
  9967. indices = indices.filter(function (ind, p) {
  9968. return stringIndices.indexOf(JSON.stringify(ind)) === p;
  9969. });
  9970. var sameScaleMinYArr = [];
  9971. var sameScaleMaxYArr = [];
  9972. minYArr.forEach(function (minYValue, yi) {
  9973. indices.forEach(function (scale, i) {
  9974. // we compare only the yIndex which exists in the indices array
  9975. if (scale.indexOf(yi) > -1) {
  9976. if (typeof sameScaleMinYArr[i] === 'undefined') {
  9977. sameScaleMinYArr[i] = [];
  9978. sameScaleMaxYArr[i] = [];
  9979. }
  9980. sameScaleMinYArr[i].push({
  9981. key: yi,
  9982. value: minYValue
  9983. });
  9984. sameScaleMaxYArr[i].push({
  9985. key: yi,
  9986. value: maxYArr[yi]
  9987. });
  9988. }
  9989. });
  9990. });
  9991. var sameScaleMin = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, Number.MIN_VALUE);
  9992. var sameScaleMax = Array.apply(null, Array(indices.length)).map(Number.prototype.valueOf, -Number.MAX_VALUE);
  9993. sameScaleMinYArr.forEach(function (s, i) {
  9994. s.forEach(function (sc, j) {
  9995. sameScaleMin[i] = Math.min(sc.value, sameScaleMin[i]);
  9996. });
  9997. });
  9998. sameScaleMaxYArr.forEach(function (s, i) {
  9999. s.forEach(function (sc, j) {
  10000. sameScaleMax[i] = Math.max(sc.value, sameScaleMax[i]);
  10001. });
  10002. });
  10003. minYArr.forEach(function (min, i) {
  10004. sameScaleMaxYArr.forEach(function (s, si) {
  10005. var minY = sameScaleMin[si];
  10006. var maxY = sameScaleMax[si];
  10007. if (cnf.chart.stacked) {
  10008. // for stacked charts, we need to add the values
  10009. maxY = 0;
  10010. s.forEach(function (ind, k) {
  10011. // fix incorrectly adjust y scale issue #1215
  10012. if (ind.value !== -Number.MAX_VALUE) {
  10013. maxY += ind.value;
  10014. }
  10015. if (minY !== Number.MIN_VALUE) {
  10016. minY += sameScaleMinYArr[si][k].value;
  10017. }
  10018. });
  10019. }
  10020. s.forEach(function (ind, k) {
  10021. if (s[k].key === i) {
  10022. if (cnf.yaxis[i].min !== undefined) {
  10023. if (typeof cnf.yaxis[i].min === 'function') {
  10024. minY = cnf.yaxis[i].min(gl.minY);
  10025. } else {
  10026. minY = cnf.yaxis[i].min;
  10027. }
  10028. }
  10029. if (cnf.yaxis[i].max !== undefined) {
  10030. if (typeof cnf.yaxis[i].max === 'function') {
  10031. maxY = cnf.yaxis[i].max(gl.maxY);
  10032. } else {
  10033. maxY = cnf.yaxis[i].max;
  10034. }
  10035. }
  10036. _this2.setYScaleForIndex(i, minY, maxY);
  10037. }
  10038. });
  10039. });
  10040. });
  10041. } // experimental feature which scales the y-axis to a min/max based on x-axis range
  10042. }, {
  10043. key: "autoScaleY",
  10044. value: function autoScaleY(ctx, yaxis, e) {
  10045. if (!ctx) {
  10046. ctx = this;
  10047. }
  10048. var w = ctx.w;
  10049. if (w.globals.isMultipleYAxis || w.globals.collapsedSeries.length) {
  10050. // The autoScale option for multiple y-axis is turned off as it leads to buggy behavior.
  10051. // Also, when a series is collapsed, it results in incorrect behavior. Hence turned it off for that too - fixes apexcharts.js#795
  10052. console.warn('autoScaleYaxis is not supported in a multi-yaxis chart.');
  10053. return yaxis;
  10054. }
  10055. var seriesX = w.globals.seriesX[0];
  10056. var isStacked = w.config.chart.stacked;
  10057. yaxis.forEach(function (yaxe, yi) {
  10058. var firstXIndex = 0;
  10059. for (var xi = 0; xi < seriesX.length; xi++) {
  10060. if (seriesX[xi] >= e.xaxis.min) {
  10061. firstXIndex = xi;
  10062. break;
  10063. }
  10064. }
  10065. var initialMin = w.globals.minYArr[yi];
  10066. var initialMax = w.globals.maxYArr[yi];
  10067. var min, max;
  10068. var stackedSer = w.globals.stackedSeriesTotals;
  10069. w.globals.series.forEach(function (serie, sI) {
  10070. var firstValue = serie[firstXIndex];
  10071. if (isStacked) {
  10072. firstValue = stackedSer[firstXIndex];
  10073. min = max = firstValue;
  10074. stackedSer.forEach(function (y, yI) {
  10075. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  10076. if (y > max && y !== null) max = y;
  10077. if (serie[yI] < min && serie[yI] !== null) min = serie[yI];
  10078. }
  10079. });
  10080. } else {
  10081. min = max = firstValue;
  10082. serie.forEach(function (y, yI) {
  10083. if (seriesX[yI] <= e.xaxis.max && seriesX[yI] >= e.xaxis.min) {
  10084. var valMin = y;
  10085. var valMax = y;
  10086. w.globals.series.forEach(function (wS, wSI) {
  10087. if (y !== null) {
  10088. valMin = Math.min(wS[yI], valMin);
  10089. valMax = Math.max(wS[yI], valMax);
  10090. }
  10091. });
  10092. if (valMax > max && valMax !== null) max = valMax;
  10093. if (valMin < min && valMin !== null) min = valMin;
  10094. }
  10095. });
  10096. }
  10097. if (min === undefined && max === undefined) {
  10098. min = initialMin;
  10099. max = initialMax;
  10100. }
  10101. min *= min < 0 ? 1.1 : 0.9;
  10102. max *= max < 0 ? 0.9 : 1.1;
  10103. if (max < 0 && max < initialMax) {
  10104. max = initialMax;
  10105. }
  10106. if (min < 0 && min > initialMin) {
  10107. min = initialMin;
  10108. }
  10109. if (yaxis.length > 1) {
  10110. yaxis[sI].min = yaxe.min === undefined ? min : yaxe.min;
  10111. yaxis[sI].max = yaxe.max === undefined ? max : yaxe.max;
  10112. } else {
  10113. yaxis[0].min = yaxe.min === undefined ? min : yaxe.min;
  10114. yaxis[0].max = yaxe.max === undefined ? max : yaxe.max;
  10115. }
  10116. });
  10117. });
  10118. return yaxis;
  10119. }
  10120. }]);
  10121. return Range;
  10122. }();
  10123. /**
  10124. * Range is used to generates values between min and max.
  10125. *
  10126. * @module Range
  10127. **/
  10128. var Range$1 = /*#__PURE__*/function () {
  10129. function Range$1(ctx) {
  10130. _classCallCheck(this, Range$1);
  10131. this.ctx = ctx;
  10132. this.w = ctx.w;
  10133. this.scales = new Range(ctx);
  10134. }
  10135. _createClass(Range$1, [{
  10136. key: "init",
  10137. value: function init() {
  10138. this.setYRange();
  10139. this.setXRange();
  10140. this.setZRange();
  10141. }
  10142. }, {
  10143. key: "getMinYMaxY",
  10144. value: function getMinYMaxY(startingIndex) {
  10145. var lowestY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_VALUE;
  10146. var highestY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -Number.MAX_VALUE;
  10147. var len = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  10148. var cnf = this.w.config;
  10149. var gl = this.w.globals;
  10150. var maxY = -Number.MAX_VALUE;
  10151. var minY = Number.MIN_VALUE;
  10152. if (len === null) {
  10153. len = startingIndex + 1;
  10154. }
  10155. var series = gl.series;
  10156. var seriesMin = series;
  10157. var seriesMax = series;
  10158. if (cnf.chart.type === 'candlestick') {
  10159. seriesMin = gl.seriesCandleL;
  10160. seriesMax = gl.seriesCandleH;
  10161. } else if (gl.isRangeData) {
  10162. seriesMin = gl.seriesRangeStart;
  10163. seriesMax = gl.seriesRangeEnd;
  10164. }
  10165. for (var i = startingIndex; i < len; i++) {
  10166. gl.dataPoints = Math.max(gl.dataPoints, series[i].length);
  10167. for (var j = 0; j < gl.series[i].length; j++) {
  10168. var val = series[i][j];
  10169. if (val !== null && Utils.isNumber(val)) {
  10170. maxY = Math.max(maxY, seriesMax[i][j]);
  10171. lowestY = Math.min(lowestY, seriesMin[i][j]);
  10172. highestY = Math.max(highestY, seriesMin[i][j]);
  10173. if (this.w.config.chart.type === 'candlestick') {
  10174. maxY = Math.max(maxY, gl.seriesCandleO[i][j]);
  10175. maxY = Math.max(maxY, gl.seriesCandleH[i][j]);
  10176. maxY = Math.max(maxY, gl.seriesCandleL[i][j]);
  10177. maxY = Math.max(maxY, gl.seriesCandleC[i][j]);
  10178. highestY = maxY;
  10179. }
  10180. if (Utils.isFloat(val)) {
  10181. val = Utils.noExponents(val);
  10182. gl.yValueDecimal = Math.max(gl.yValueDecimal, val.toString().split('.')[1].length);
  10183. }
  10184. if (minY > seriesMin[i][j] && seriesMin[i][j] < 0) {
  10185. minY = seriesMin[i][j];
  10186. }
  10187. } else {
  10188. gl.hasNullValues = true;
  10189. }
  10190. }
  10191. }
  10192. if (cnf.chart.type === 'rangeBar' && gl.seriesRangeStart.length && gl.isBarHorizontal && cnf.xaxis.type === 'datetime') {
  10193. minY = lowestY;
  10194. }
  10195. if (cnf.chart.type === 'bar') {
  10196. if (minY < 0 && maxY < 0) {
  10197. // all negative values in a bar chart, hence make the max to 0
  10198. maxY = 0;
  10199. }
  10200. if (minY === Number.MIN_VALUE) {
  10201. minY = 0;
  10202. }
  10203. }
  10204. return {
  10205. minY: minY,
  10206. maxY: maxY,
  10207. lowestY: lowestY,
  10208. highestY: highestY
  10209. };
  10210. }
  10211. }, {
  10212. key: "setYRange",
  10213. value: function setYRange() {
  10214. var gl = this.w.globals;
  10215. var cnf = this.w.config;
  10216. gl.maxY = -Number.MAX_VALUE;
  10217. gl.minY = Number.MIN_VALUE;
  10218. var lowestYInAllSeries = Number.MAX_VALUE;
  10219. if (gl.isMultipleYAxis) {
  10220. // we need to get minY and maxY for multiple y axis
  10221. for (var i = 0; i < gl.series.length; i++) {
  10222. var minYMaxYArr = this.getMinYMaxY(i, lowestYInAllSeries, null, i + 1);
  10223. gl.minYArr.push(minYMaxYArr.minY);
  10224. gl.maxYArr.push(minYMaxYArr.maxY);
  10225. lowestYInAllSeries = minYMaxYArr.lowestY;
  10226. }
  10227. } // and then, get the minY and maxY from all series
  10228. var minYMaxY = this.getMinYMaxY(0, lowestYInAllSeries, null, gl.series.length);
  10229. gl.minY = minYMaxY.minY;
  10230. gl.maxY = minYMaxY.maxY;
  10231. lowestYInAllSeries = minYMaxY.lowestY;
  10232. if (cnf.chart.stacked) {
  10233. this._setStackedMinMax();
  10234. } // if the numbers are too big, reduce the range
  10235. // 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
  10236. if (cnf.chart.type === 'line' || cnf.chart.type === 'area' || cnf.chart.type === 'candlestick' || cnf.chart.type === 'rangeBar' && !gl.isBarHorizontal) {
  10237. if (gl.minY === Number.MIN_VALUE && lowestYInAllSeries !== -Number.MAX_VALUE && lowestYInAllSeries !== gl.maxY // single value possibility
  10238. ) {
  10239. var diff = gl.maxY - lowestYInAllSeries;
  10240. if (lowestYInAllSeries >= 0 && lowestYInAllSeries <= 10) {
  10241. // if minY is already 0/low value, we don't want to go negatives here - so this check is essential.
  10242. diff = 0;
  10243. }
  10244. gl.minY = lowestYInAllSeries - diff * 5 / 100;
  10245. /* fix https://github.com/apexcharts/apexcharts.js/issues/614 */
  10246. /* fix https://github.com/apexcharts/apexcharts.js/issues/968 */
  10247. if (lowestYInAllSeries > 0 && gl.minY < 0) {
  10248. gl.minY = 0;
  10249. }
  10250. /* fix https://github.com/apexcharts/apexcharts.js/issues/426 */
  10251. gl.maxY = gl.maxY + diff * 5 / 100;
  10252. }
  10253. }
  10254. cnf.yaxis.forEach(function (yaxe, index) {
  10255. // override all min/max values by user defined values (y axis)
  10256. if (yaxe.max !== undefined) {
  10257. if (typeof yaxe.max === 'number') {
  10258. gl.maxYArr[index] = yaxe.max;
  10259. } else if (typeof yaxe.max === 'function') {
  10260. gl.maxYArr[index] = yaxe.max(gl.maxY);
  10261. } // gl.maxY is for single y-axis chart, it will be ignored in multi-yaxis
  10262. gl.maxY = gl.maxYArr[index];
  10263. }
  10264. if (yaxe.min !== undefined) {
  10265. if (typeof yaxe.min === 'number') {
  10266. gl.minYArr[index] = yaxe.min;
  10267. } else if (typeof yaxe.min === 'function') {
  10268. gl.minYArr[index] = yaxe.min(gl.minY);
  10269. } // gl.minY is for single y-axis chart, it will be ignored in multi-yaxis
  10270. gl.minY = gl.minYArr[index];
  10271. }
  10272. }); // for horizontal bar charts, we need to check xaxis min/max as user may have specified there
  10273. if (gl.isBarHorizontal) {
  10274. var minmax = ['min', 'max'];
  10275. minmax.forEach(function (m) {
  10276. if (cnf.xaxis[m] !== undefined && typeof cnf.xaxis[m] === 'number') {
  10277. m === 'min' ? gl.minY = cnf.xaxis[m] : gl.maxY = cnf.xaxis[m];
  10278. }
  10279. });
  10280. } // for multi y-axis we need different scales for each
  10281. if (gl.isMultipleYAxis) {
  10282. this.scales.setMultipleYScales();
  10283. gl.minY = lowestYInAllSeries;
  10284. gl.yAxisScale.forEach(function (scale, i) {
  10285. gl.minYArr[i] = scale.niceMin;
  10286. gl.maxYArr[i] = scale.niceMax;
  10287. });
  10288. } else {
  10289. this.scales.setYScaleForIndex(0, gl.minY, gl.maxY);
  10290. gl.minY = gl.yAxisScale[0].niceMin;
  10291. gl.maxY = gl.yAxisScale[0].niceMax;
  10292. gl.minYArr[0] = gl.yAxisScale[0].niceMin;
  10293. gl.maxYArr[0] = gl.yAxisScale[0].niceMax;
  10294. }
  10295. return {
  10296. minY: gl.minY,
  10297. maxY: gl.maxY,
  10298. minYArr: gl.minYArr,
  10299. maxYArr: gl.maxYArr
  10300. };
  10301. }
  10302. }, {
  10303. key: "setXRange",
  10304. value: function setXRange() {
  10305. var gl = this.w.globals;
  10306. var cnf = this.w.config;
  10307. var isXNumeric = cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'datetime' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided || gl.noLabelsProvided || gl.isXNumeric;
  10308. var getInitialMinXMaxX = function getInitialMinXMaxX() {
  10309. for (var i = 0; i < gl.series.length; i++) {
  10310. if (gl.labels[i]) {
  10311. for (var j = 0; j < gl.labels[i].length; j++) {
  10312. if (gl.labels[i][j] !== null && Utils.isNumber(gl.labels[i][j])) {
  10313. gl.maxX = Math.max(gl.maxX, gl.labels[i][j]);
  10314. gl.initialMaxX = Math.max(gl.maxX, gl.labels[i][j]);
  10315. gl.minX = Math.min(gl.minX, gl.labels[i][j]);
  10316. gl.initialMinX = Math.min(gl.minX, gl.labels[i][j]);
  10317. }
  10318. }
  10319. }
  10320. }
  10321. }; // minX maxX starts here
  10322. if (gl.isXNumeric) {
  10323. getInitialMinXMaxX();
  10324. }
  10325. if (gl.noLabelsProvided) {
  10326. if (cnf.xaxis.categories.length === 0) {
  10327. gl.maxX = gl.labels[gl.labels.length - 1];
  10328. gl.initialMaxX = gl.labels[gl.labels.length - 1];
  10329. gl.minX = 1;
  10330. gl.initialMinX = 1;
  10331. }
  10332. }
  10333. if (gl.isXNumeric || gl.noLabelsProvided || gl.dataFormatXNumeric) {
  10334. var ticks;
  10335. if (cnf.xaxis.tickAmount === undefined) {
  10336. ticks = Math.round(gl.svgWidth / 150); // no labels provided and total number of dataPoints is less than 30
  10337. if (cnf.xaxis.type === 'numeric' && gl.dataPoints < 30) {
  10338. ticks = gl.dataPoints - 1;
  10339. } // this check is for when ticks exceeds total datapoints and that would result in duplicate labels
  10340. if (ticks > gl.dataPoints && gl.dataPoints !== 0) {
  10341. ticks = gl.dataPoints - 1;
  10342. }
  10343. } else if (cnf.xaxis.tickAmount === 'dataPoints') {
  10344. if (gl.series.length > 1) {
  10345. ticks = gl.series[gl.maxValsInArrayIndex].length - 1;
  10346. }
  10347. if (gl.isXNumeric) {
  10348. ticks = gl.maxX - gl.minX - 1;
  10349. }
  10350. } else {
  10351. ticks = cnf.xaxis.tickAmount;
  10352. }
  10353. gl.xTickAmount = ticks; // override all min/max values by user defined values (x axis)
  10354. if (cnf.xaxis.max !== undefined && typeof cnf.xaxis.max === 'number') {
  10355. gl.maxX = cnf.xaxis.max;
  10356. }
  10357. if (cnf.xaxis.min !== undefined && typeof cnf.xaxis.min === 'number') {
  10358. gl.minX = cnf.xaxis.min;
  10359. } // if range is provided, adjust the new minX
  10360. if (cnf.xaxis.range !== undefined) {
  10361. gl.minX = gl.maxX - cnf.xaxis.range;
  10362. }
  10363. if (gl.minX !== Number.MAX_VALUE && gl.maxX !== -Number.MAX_VALUE) {
  10364. if (cnf.xaxis.convertedCatToNumeric && !gl.dataFormatXNumeric) {
  10365. var catScale = [];
  10366. for (var i = gl.minX - 1; i < gl.maxX; i++) {
  10367. catScale.push(i + 1);
  10368. }
  10369. gl.xAxisScale = {
  10370. result: catScale,
  10371. niceMin: catScale[0],
  10372. niceMax: catScale[catScale.length - 1]
  10373. };
  10374. } else {
  10375. gl.xAxisScale = this.scales.setXScale(gl.minX, gl.maxX);
  10376. }
  10377. } else {
  10378. gl.xAxisScale = this.scales.linearScale(1, ticks, ticks);
  10379. if (gl.noLabelsProvided && gl.labels.length > 0) {
  10380. gl.xAxisScale = this.scales.linearScale(1, gl.labels.length, ticks - 1); // this is the only place seriesX is again mutated
  10381. gl.seriesX = gl.labels.slice();
  10382. }
  10383. } // we will still store these labels as the count for this will be different (to draw grid and labels placement)
  10384. if (isXNumeric) {
  10385. gl.labels = gl.xAxisScale.result.slice();
  10386. }
  10387. }
  10388. if (gl.isBarHorizontal && gl.labels.length) {
  10389. gl.xTickAmount = gl.labels.length;
  10390. } // single dataPoint
  10391. this._handleSingleDataPoint(); // minimum x difference to calculate bar width in numeric bars
  10392. this._getMinXDiff();
  10393. return {
  10394. minX: gl.minX,
  10395. maxX: gl.maxX
  10396. };
  10397. }
  10398. }, {
  10399. key: "setZRange",
  10400. value: function setZRange() {
  10401. // minZ, maxZ starts here
  10402. var gl = this.w.globals;
  10403. if (!gl.isDataXYZ) return;
  10404. for (var i = 0; i < gl.series.length; i++) {
  10405. if (typeof gl.seriesZ[i] !== 'undefined') {
  10406. for (var j = 0; j < gl.seriesZ[i].length; j++) {
  10407. if (gl.seriesZ[i][j] !== null && Utils.isNumber(gl.seriesZ[i][j])) {
  10408. gl.maxZ = Math.max(gl.maxZ, gl.seriesZ[i][j]);
  10409. gl.minZ = Math.min(gl.minZ, gl.seriesZ[i][j]);
  10410. }
  10411. }
  10412. }
  10413. }
  10414. }
  10415. }, {
  10416. key: "_handleSingleDataPoint",
  10417. value: function _handleSingleDataPoint() {
  10418. var gl = this.w.globals;
  10419. var cnf = this.w.config;
  10420. if (gl.minX === gl.maxX) {
  10421. var datetimeObj = new DateTime(this.ctx);
  10422. if (cnf.xaxis.type === 'datetime') {
  10423. var newMinX = datetimeObj.getDate(gl.minX);
  10424. newMinX.setUTCDate(newMinX.getDate() - 2);
  10425. gl.minX = new Date(newMinX).getTime();
  10426. var newMaxX = datetimeObj.getDate(gl.maxX);
  10427. newMaxX.setUTCDate(newMaxX.getDate() + 2);
  10428. gl.maxX = new Date(newMaxX).getTime();
  10429. } else if (cnf.xaxis.type === 'numeric' || cnf.xaxis.type === 'category' && !gl.noLabelsProvided) {
  10430. gl.minX = gl.minX - 2;
  10431. gl.initialMinX = gl.minX;
  10432. gl.maxX = gl.maxX + 2;
  10433. gl.initialMaxX = gl.maxX;
  10434. }
  10435. }
  10436. }
  10437. }, {
  10438. key: "_getMinXDiff",
  10439. value: function _getMinXDiff() {
  10440. var gl = this.w.globals;
  10441. if (gl.isXNumeric) {
  10442. // get the least x diff if numeric x axis is present
  10443. gl.seriesX.forEach(function (sX, i) {
  10444. if (sX.length === 1) {
  10445. // a small hack to prevent overlapping multiple bars when there is just 1 datapoint in bar series.
  10446. // fix #811
  10447. sX.push(gl.seriesX[gl.maxValsInArrayIndex][gl.seriesX[gl.maxValsInArrayIndex].length - 1]);
  10448. } // fix #983 (clone the array to avoid side effects)
  10449. var seriesX = sX.slice();
  10450. seriesX.sort(function (a, b) {
  10451. return a - b;
  10452. });
  10453. seriesX.forEach(function (s, j) {
  10454. if (j > 0) {
  10455. var xDiff = s - gl.seriesX[i][j - 1];
  10456. if (xDiff > 0) {
  10457. gl.minXDiff = Math.min(xDiff, gl.minXDiff);
  10458. }
  10459. }
  10460. });
  10461. if (gl.dataPoints === 1 && gl.minXDiff === Number.MAX_VALUE) {
  10462. gl.minXDiff = 0.5;
  10463. }
  10464. });
  10465. }
  10466. }
  10467. }, {
  10468. key: "_setStackedMinMax",
  10469. value: function _setStackedMinMax() {
  10470. 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
  10471. var stackedPoss = [];
  10472. var stackedNegs = [];
  10473. if (gl.series.length) {
  10474. for (var j = 0; j < gl.series[gl.maxValsInArrayIndex].length; j++) {
  10475. var poss = 0;
  10476. var negs = 0;
  10477. for (var i = 0; i < gl.series.length; i++) {
  10478. if (gl.series[i][j] !== null && Utils.isNumber(gl.series[i][j])) {
  10479. // 0.0001 fixes #185 when values are very small
  10480. gl.series[i][j] > 0 ? poss = poss + parseFloat(gl.series[i][j]) + 0.0001 : negs = negs + parseFloat(gl.series[i][j]);
  10481. }
  10482. if (i === gl.series.length - 1) {
  10483. // push all the totals to the array for future use
  10484. stackedPoss.push(poss);
  10485. stackedNegs.push(negs);
  10486. }
  10487. }
  10488. }
  10489. } // get the max/min out of the added parallel values
  10490. for (var z = 0; z < stackedPoss.length; z++) {
  10491. gl.maxY = Math.max(gl.maxY, stackedPoss[z]);
  10492. gl.minY = Math.min(gl.minY, stackedNegs[z]);
  10493. }
  10494. }
  10495. }]);
  10496. return Range$1;
  10497. }();
  10498. /**
  10499. * ApexCharts YAxis Class for drawing Y-Axis.
  10500. *
  10501. * @module YAxis
  10502. **/
  10503. var YAxis = /*#__PURE__*/function () {
  10504. function YAxis(ctx) {
  10505. _classCallCheck(this, YAxis);
  10506. this.ctx = ctx;
  10507. this.w = ctx.w;
  10508. var w = this.w;
  10509. this.xaxisFontSize = w.config.xaxis.labels.style.fontSize;
  10510. this.axisFontFamily = w.config.xaxis.labels.style.fontFamily;
  10511. this.xaxisForeColors = w.config.xaxis.labels.style.colors;
  10512. this.isCategoryBarHorizontal = w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal;
  10513. this.xAxisoffX = 0;
  10514. if (w.config.xaxis.position === 'bottom') {
  10515. this.xAxisoffX = w.globals.gridHeight;
  10516. }
  10517. this.drawnLabels = [];
  10518. this.axesUtils = new AxesUtils(ctx);
  10519. }
  10520. _createClass(YAxis, [{
  10521. key: "drawYaxis",
  10522. value: function drawYaxis(realIndex) {
  10523. var w = this.w;
  10524. var graphics = new Graphics(this.ctx);
  10525. var yaxisStyle = w.config.yaxis[realIndex].labels.style;
  10526. var yaxisFontSize = yaxisStyle.fontSize;
  10527. var yaxisFontFamily = yaxisStyle.fontFamily;
  10528. var yaxisFontWeight = yaxisStyle.fontWeight;
  10529. var elYaxis = graphics.group({
  10530. class: 'apexcharts-yaxis',
  10531. rel: realIndex,
  10532. transform: 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)'
  10533. });
  10534. if (this.axesUtils.isYAxisHidden(realIndex)) {
  10535. return elYaxis;
  10536. }
  10537. var elYaxisTexts = graphics.group({
  10538. class: 'apexcharts-yaxis-texts-g'
  10539. });
  10540. elYaxis.add(elYaxisTexts);
  10541. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg height/number of ticks
  10542. var labelsDivider = w.globals.gridHeight / tickAmount; // initial label position = 0;
  10543. var l = w.globals.translateY;
  10544. var lbFormatter = w.globals.yLabelFormatters[realIndex];
  10545. var labels = w.globals.yAxisScale[realIndex].result.slice();
  10546. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  10547. var firstLabel = '';
  10548. if (w.config.yaxis[realIndex].labels.show) {
  10549. var _loop = function _loop(i) {
  10550. var val = labels[i];
  10551. val = lbFormatter(val, i);
  10552. var xPad = w.config.yaxis[realIndex].labels.padding;
  10553. if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
  10554. xPad = xPad * -1;
  10555. }
  10556. var getForeColor = function getForeColor() {
  10557. return Array.isArray(yaxisStyle.colors) ? yaxisStyle.colors[i] : yaxisStyle.colors;
  10558. };
  10559. var label = graphics.drawText({
  10560. x: xPad,
  10561. y: l + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY + 1,
  10562. text: val,
  10563. textAnchor: w.config.yaxis[realIndex].opposite ? 'start' : 'end',
  10564. fontSize: yaxisFontSize,
  10565. fontFamily: yaxisFontFamily,
  10566. fontWeight: yaxisFontWeight,
  10567. foreColor: getForeColor(),
  10568. isPlainText: false,
  10569. cssClass: 'apexcharts-yaxis-label ' + yaxisStyle.cssClass
  10570. });
  10571. if (i === tickAmount) {
  10572. firstLabel = label;
  10573. }
  10574. elYaxisTexts.add(label);
  10575. if (w.config.yaxis[realIndex].labels.rotate !== 0) {
  10576. var firstabelRotatingCenter = graphics.rotateAroundCenter(firstLabel.node);
  10577. var labelRotatingCenter = graphics.rotateAroundCenter(label.node);
  10578. label.node.setAttribute('transform', "rotate(".concat(w.config.yaxis[realIndex].labels.rotate, " ").concat(firstabelRotatingCenter.x, " ").concat(labelRotatingCenter.y, ")"));
  10579. }
  10580. l = l + labelsDivider;
  10581. };
  10582. for (var i = tickAmount; i >= 0; i--) {
  10583. _loop(i);
  10584. }
  10585. }
  10586. if (w.config.yaxis[realIndex].title.text !== undefined) {
  10587. var elYaxisTitle = graphics.group({
  10588. class: 'apexcharts-yaxis-title'
  10589. });
  10590. var _x = 0;
  10591. if (w.config.yaxis[realIndex].opposite) {
  10592. _x = w.globals.translateYAxisX[realIndex];
  10593. }
  10594. var elYAxisTitleText = graphics.drawText({
  10595. x: _x,
  10596. y: w.globals.gridHeight / 2 + w.globals.translateY + w.config.yaxis[realIndex].title.offsetY,
  10597. text: w.config.yaxis[realIndex].title.text,
  10598. textAnchor: 'end',
  10599. foreColor: w.config.yaxis[realIndex].title.style.color,
  10600. fontSize: w.config.yaxis[realIndex].title.style.fontSize,
  10601. fontWeight: w.config.yaxis[realIndex].title.style.fontWeight,
  10602. fontFamily: w.config.yaxis[realIndex].title.style.fontFamily,
  10603. cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[realIndex].title.style.cssClass
  10604. });
  10605. elYaxisTitle.add(elYAxisTitleText);
  10606. elYaxis.add(elYaxisTitle);
  10607. }
  10608. var axisBorder = w.config.yaxis[realIndex].axisBorder;
  10609. var x = 31 + axisBorder.offsetX;
  10610. if (w.config.yaxis[realIndex].opposite) {
  10611. x = -31 - axisBorder.offsetX;
  10612. }
  10613. if (axisBorder.show) {
  10614. 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);
  10615. elYaxis.add(elVerticalLine);
  10616. }
  10617. if (w.config.yaxis[realIndex].axisTicks.show) {
  10618. this.axesUtils.drawYAxisTicks(x, tickAmount, axisBorder, w.config.yaxis[realIndex].axisTicks, realIndex, labelsDivider, elYaxis);
  10619. }
  10620. return elYaxis;
  10621. } // This actually becomes horizonal axis (for bar charts)
  10622. }, {
  10623. key: "drawYaxisInversed",
  10624. value: function drawYaxisInversed(realIndex) {
  10625. var w = this.w;
  10626. var graphics = new Graphics(this.ctx);
  10627. var elXaxis = graphics.group({
  10628. class: 'apexcharts-xaxis apexcharts-yaxis-inversed'
  10629. });
  10630. var elXaxisTexts = graphics.group({
  10631. class: 'apexcharts-xaxis-texts-g',
  10632. transform: "translate(".concat(w.globals.translateXAxisX, ", ").concat(w.globals.translateXAxisY, ")")
  10633. });
  10634. elXaxis.add(elXaxisTexts);
  10635. var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg width/number of ticks
  10636. var labelsDivider = w.globals.gridWidth / tickAmount + 0.1; // initial label position;
  10637. var l = labelsDivider + w.config.xaxis.labels.offsetX;
  10638. var lbFormatter = w.globals.xLabelFormatter;
  10639. var labels = w.globals.yAxisScale[realIndex].result.slice();
  10640. var timescaleLabels = w.globals.timescaleLabels;
  10641. if (timescaleLabels.length > 0) {
  10642. this.xaxisLabels = timescaleLabels.slice();
  10643. labels = timescaleLabels.slice();
  10644. tickAmount = labels.length;
  10645. }
  10646. labels = this.axesUtils.checkForReversedLabels(realIndex, labels);
  10647. var tl = timescaleLabels.length;
  10648. if (w.config.xaxis.labels.show) {
  10649. for (var i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
  10650. var val = labels[i];
  10651. val = lbFormatter(val, i);
  10652. var x = w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX);
  10653. if (timescaleLabels.length) {
  10654. var label = this.axesUtils.getLabel(labels, timescaleLabels, x, i, this.drawnLabels, this.xaxisFontSize);
  10655. x = label.x;
  10656. val = label.text;
  10657. this.drawnLabels.push(label.text);
  10658. if (i === 0 && w.globals.skipFirstTimelinelabel) {
  10659. val = '';
  10660. }
  10661. if (i === labels.length - 1 && w.globals.skipLastTimelinelabel) {
  10662. val = '';
  10663. }
  10664. }
  10665. var elTick = graphics.drawText({
  10666. x: x,
  10667. y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30 - (w.config.xaxis.position === 'top' ? w.globals.xAxisHeight + w.config.xaxis.axisTicks.height - 2 : 0),
  10668. text: val,
  10669. textAnchor: 'middle',
  10670. foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors,
  10671. fontSize: this.xaxisFontSize,
  10672. fontFamily: this.xaxisFontFamily,
  10673. fontWeight: w.config.xaxis.labels.style.fontWeight,
  10674. isPlainText: false,
  10675. cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
  10676. });
  10677. elXaxisTexts.add(elTick);
  10678. elTick.tspan(val);
  10679. var elTooltipTitle = document.createElementNS(w.globals.SVGNS, 'title');
  10680. elTooltipTitle.textContent = val;
  10681. elTick.node.appendChild(elTooltipTitle);
  10682. l = l + labelsDivider;
  10683. }
  10684. }
  10685. this.inversedYAxisTitleText(elXaxis);
  10686. this.inversedYAxisBorder(elXaxis);
  10687. return elXaxis;
  10688. }
  10689. }, {
  10690. key: "inversedYAxisBorder",
  10691. value: function inversedYAxisBorder(parent) {
  10692. var w = this.w;
  10693. var graphics = new Graphics(this.ctx);
  10694. var axisBorder = w.config.xaxis.axisBorder;
  10695. if (axisBorder.show) {
  10696. var lineCorrection = 0;
  10697. if (w.config.chart.type === 'bar' && w.globals.isXNumeric) {
  10698. lineCorrection = lineCorrection - 15;
  10699. }
  10700. var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + axisBorder.offsetX, this.xAxisoffX, w.globals.gridWidth, this.xAxisoffX, axisBorder.color, 0, axisBorder.height);
  10701. parent.add(elHorzLine);
  10702. }
  10703. }
  10704. }, {
  10705. key: "inversedYAxisTitleText",
  10706. value: function inversedYAxisTitleText(parent) {
  10707. var w = this.w;
  10708. var graphics = new Graphics(this.ctx);
  10709. if (w.config.xaxis.title.text !== undefined) {
  10710. var elYaxisTitle = graphics.group({
  10711. class: 'apexcharts-xaxis-title apexcharts-yaxis-title-inversed'
  10712. });
  10713. var elYAxisTitleText = graphics.drawText({
  10714. x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX,
  10715. y: this.xAxisoffX + parseFloat(this.xaxisFontSize) + parseFloat(w.config.xaxis.title.style.fontSize) + w.config.xaxis.title.offsetY + 20,
  10716. text: w.config.xaxis.title.text,
  10717. textAnchor: 'middle',
  10718. fontSize: w.config.xaxis.title.style.fontSize,
  10719. fontFamily: w.config.xaxis.title.style.fontFamily,
  10720. fontWeight: w.config.xaxis.title.style.fontWeight,
  10721. cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass
  10722. });
  10723. elYaxisTitle.add(elYAxisTitleText);
  10724. parent.add(elYaxisTitle);
  10725. }
  10726. }
  10727. }, {
  10728. key: "yAxisTitleRotate",
  10729. value: function yAxisTitleRotate(realIndex, yAxisOpposite) {
  10730. var w = this.w;
  10731. var graphics = new Graphics(this.ctx);
  10732. var yAxisLabelsCoord = {
  10733. width: 0,
  10734. height: 0
  10735. };
  10736. var yAxisTitleCoord = {
  10737. width: 0,
  10738. height: 0
  10739. };
  10740. var elYAxisLabelsWrap = w.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-texts-g"));
  10741. if (elYAxisLabelsWrap !== null) {
  10742. yAxisLabelsCoord = elYAxisLabelsWrap.getBoundingClientRect();
  10743. }
  10744. var yAxisTitle = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(realIndex, "'] .apexcharts-yaxis-title text"));
  10745. if (yAxisTitle !== null) {
  10746. yAxisTitleCoord = yAxisTitle.getBoundingClientRect();
  10747. }
  10748. if (yAxisTitle !== null) {
  10749. var x = this.xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite);
  10750. yAxisTitle.setAttribute('x', x.xPos - (yAxisOpposite ? 10 : 0));
  10751. }
  10752. if (yAxisTitle !== null) {
  10753. var titleRotatingCenter = graphics.rotateAroundCenter(yAxisTitle);
  10754. yAxisTitle.setAttribute('transform', "rotate(".concat(yAxisOpposite ? '' : '-').concat(w.config.yaxis[realIndex].title.rotate, " ").concat(titleRotatingCenter.x, " ").concat(titleRotatingCenter.y, ")"));
  10755. }
  10756. }
  10757. }, {
  10758. key: "xPaddingForYAxisTitle",
  10759. value: function xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite) {
  10760. var w = this.w;
  10761. var oppositeAxisCount = 0;
  10762. var x = 0;
  10763. var padd = 10;
  10764. if (w.config.yaxis[realIndex].title.text === undefined || realIndex < 0) {
  10765. return {
  10766. xPos: x,
  10767. padd: 0
  10768. };
  10769. }
  10770. if (yAxisOpposite) {
  10771. x = yAxisLabelsCoord.width + w.config.yaxis[realIndex].title.offsetX + yAxisTitleCoord.width / 2 + padd / 2;
  10772. oppositeAxisCount += 1;
  10773. if (oppositeAxisCount === 0) {
  10774. x = x - padd / 2;
  10775. }
  10776. } else {
  10777. x = yAxisLabelsCoord.width * -1 + w.config.yaxis[realIndex].title.offsetX + padd / 2 + yAxisTitleCoord.width / 2;
  10778. if (w.globals.isBarHorizontal) {
  10779. padd = 25;
  10780. x = yAxisLabelsCoord.width * -1 - w.config.yaxis[realIndex].title.offsetX - padd;
  10781. }
  10782. }
  10783. return {
  10784. xPos: x,
  10785. padd: padd
  10786. };
  10787. } // sets the x position of the y-axis by counting the labels width, title width and any offset
  10788. }, {
  10789. key: "setYAxisXPosition",
  10790. value: function setYAxisXPosition(yaxisLabelCoords, yTitleCoords) {
  10791. var w = this.w;
  10792. var xLeft = 0;
  10793. var xRight = 0;
  10794. var leftOffsetX = 18;
  10795. var rightOffsetX = 1;
  10796. if (w.config.yaxis.length > 1) {
  10797. this.multipleYs = true;
  10798. }
  10799. w.config.yaxis.map(function (yaxe, index) {
  10800. var shouldNotDrawAxis = w.globals.ignoreYAxisIndexes.indexOf(index) > -1 || !yaxe.show || yaxe.floating || yaxisLabelCoords[index].width === 0;
  10801. var axisWidth = yaxisLabelCoords[index].width + yTitleCoords[index].width;
  10802. if (!yaxe.opposite) {
  10803. xLeft = w.globals.translateX - leftOffsetX;
  10804. if (!shouldNotDrawAxis) {
  10805. leftOffsetX = leftOffsetX + axisWidth + 20;
  10806. }
  10807. w.globals.translateYAxisX[index] = xLeft + yaxe.labels.offsetX;
  10808. } else {
  10809. if (w.globals.isBarHorizontal) {
  10810. xRight = w.globals.gridWidth + w.globals.translateX - 1;
  10811. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX;
  10812. } else {
  10813. xRight = w.globals.gridWidth + w.globals.translateX + rightOffsetX;
  10814. if (!shouldNotDrawAxis) {
  10815. rightOffsetX = rightOffsetX + axisWidth + 20;
  10816. }
  10817. w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX + 20;
  10818. }
  10819. }
  10820. });
  10821. }
  10822. }, {
  10823. key: "setYAxisTextAlignments",
  10824. value: function setYAxisTextAlignments() {
  10825. var w = this.w;
  10826. var yaxis = w.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");
  10827. yaxis = Utils.listToArray(yaxis);
  10828. yaxis.forEach(function (y, index) {
  10829. var yaxe = w.config.yaxis[index]; // proceed only if user has specified alignment
  10830. if (yaxe.labels.align !== undefined) {
  10831. var yAxisInner = w.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-texts-g"));
  10832. var yAxisTexts = w.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(index, "'] .apexcharts-yaxis-label"));
  10833. yAxisTexts = Utils.listToArray(yAxisTexts);
  10834. var rect = yAxisInner.getBoundingClientRect();
  10835. if (yaxe.labels.align === 'left') {
  10836. yAxisTexts.forEach(function (label, lI) {
  10837. label.setAttribute('text-anchor', 'start');
  10838. });
  10839. if (!yaxe.opposite) {
  10840. yAxisInner.setAttribute('transform', "translate(-".concat(rect.width, ", 0)"));
  10841. }
  10842. } else if (yaxe.labels.align === 'center') {
  10843. yAxisTexts.forEach(function (label, lI) {
  10844. label.setAttribute('text-anchor', 'middle');
  10845. });
  10846. yAxisInner.setAttribute('transform', "translate(".concat(rect.width / 2 * (!yaxe.opposite ? -1 : 1), ", 0)"));
  10847. } else if (yaxe.labels.align === 'right') {
  10848. yAxisTexts.forEach(function (label, lI) {
  10849. label.setAttribute('text-anchor', 'end');
  10850. });
  10851. if (yaxe.opposite) {
  10852. yAxisInner.setAttribute('transform', "translate(".concat(rect.width, ", 0)"));
  10853. }
  10854. }
  10855. }
  10856. });
  10857. }
  10858. }]);
  10859. return YAxis;
  10860. }();
  10861. var Events = /*#__PURE__*/function () {
  10862. function Events(ctx) {
  10863. _classCallCheck(this, Events);
  10864. this.ctx = ctx;
  10865. this.w = ctx.w;
  10866. this.documentEvent = Utils.bind(this.documentEvent, this);
  10867. }
  10868. _createClass(Events, [{
  10869. key: "addEventListener",
  10870. value: function addEventListener(name, handler) {
  10871. var w = this.w;
  10872. if (w.globals.events.hasOwnProperty(name)) {
  10873. w.globals.events[name].push(handler);
  10874. } else {
  10875. w.globals.events[name] = [handler];
  10876. }
  10877. }
  10878. }, {
  10879. key: "removeEventListener",
  10880. value: function removeEventListener(name, handler) {
  10881. var w = this.w;
  10882. if (!w.globals.events.hasOwnProperty(name)) {
  10883. return;
  10884. }
  10885. var index = w.globals.events[name].indexOf(handler);
  10886. if (index !== -1) {
  10887. w.globals.events[name].splice(index, 1);
  10888. }
  10889. }
  10890. }, {
  10891. key: "fireEvent",
  10892. value: function fireEvent(name, args) {
  10893. var w = this.w;
  10894. if (!w.globals.events.hasOwnProperty(name)) {
  10895. return;
  10896. }
  10897. if (!args || !args.length) {
  10898. args = [];
  10899. }
  10900. var evs = w.globals.events[name];
  10901. var l = evs.length;
  10902. for (var i = 0; i < l; i++) {
  10903. evs[i].apply(null, args);
  10904. }
  10905. }
  10906. }, {
  10907. key: "setupEventHandlers",
  10908. value: function setupEventHandlers() {
  10909. var _this = this;
  10910. var w = this.w;
  10911. var me = this.ctx;
  10912. var clickableArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
  10913. this.ctx.eventList.forEach(function (event) {
  10914. clickableArea.addEventListener(event, function (e) {
  10915. var opts = Object.assign({}, w, {
  10916. seriesIndex: w.globals.capturedSeriesIndex,
  10917. dataPointIndex: w.globals.capturedDataPointIndex
  10918. });
  10919. if (e.type === 'mousemove' || e.type === 'touchmove') {
  10920. if (typeof w.config.chart.events.mouseMove === 'function') {
  10921. w.config.chart.events.mouseMove(e, me, opts);
  10922. }
  10923. } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') {
  10924. if (typeof w.config.chart.events.click === 'function') {
  10925. w.config.chart.events.click(e, me, opts);
  10926. }
  10927. me.ctx.events.fireEvent('click', [e, me, opts]);
  10928. }
  10929. }, {
  10930. capture: false,
  10931. passive: true
  10932. });
  10933. });
  10934. this.ctx.eventList.forEach(function (event) {
  10935. document.addEventListener(event, _this.documentEvent);
  10936. });
  10937. this.ctx.core.setupBrushHandler();
  10938. }
  10939. }, {
  10940. key: "documentEvent",
  10941. value: function documentEvent(e) {
  10942. var w = this.w;
  10943. var target = e.target.className;
  10944. if (e.type === 'click') {
  10945. var elMenu = w.globals.dom.baseEl.querySelector('.apexcharts-menu');
  10946. if (elMenu && elMenu.classList.contains('apexcharts-menu-open') && target !== 'apexcharts-menu-icon') {
  10947. elMenu.classList.remove('apexcharts-menu-open');
  10948. }
  10949. }
  10950. if (e.type === 'mousedown') {
  10951. var elAnnos = w.globals.dom.Paper.select('.apexcharts-resizable-element').members;
  10952. Array.prototype.forEach.call(elAnnos, function (el) {
  10953. // any shape annotations that might have selected by user for resizing, should be deselected
  10954. if (!e.target.classList.contains('apexcharts-resizable-element') && !e.target.classList.contains('svg_select_points')) {
  10955. el.selectize(false);
  10956. }
  10957. });
  10958. }
  10959. w.globals.clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  10960. w.globals.clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  10961. }
  10962. }]);
  10963. return Events;
  10964. }();
  10965. var Localization = /*#__PURE__*/function () {
  10966. function Localization(ctx) {
  10967. _classCallCheck(this, Localization);
  10968. this.ctx = ctx;
  10969. this.w = ctx.w;
  10970. }
  10971. _createClass(Localization, [{
  10972. key: "setCurrentLocaleValues",
  10973. value: function setCurrentLocaleValues(localeName) {
  10974. var locales = this.w.config.chart.locales; // check if user has specified locales in global Apex variable
  10975. // if yes - then extend those with local chart's locale
  10976. if (window.Apex.chart && window.Apex.chart.locales && window.Apex.chart.locales.length > 0) {
  10977. locales = this.w.config.chart.locales.concat(window.Apex.chart.locales);
  10978. } // find the locale from the array of locales which user has set (either by chart.defaultLocale or by calling setLocale() method.)
  10979. var selectedLocale = locales.filter(function (c) {
  10980. return c.name === localeName;
  10981. })[0];
  10982. if (selectedLocale) {
  10983. // create a complete locale object by extending defaults so you don't get undefined errors.
  10984. var ret = Utils.extend(en, selectedLocale); // store these locale options in global var for ease access
  10985. this.w.globals.locale = ret.options;
  10986. } else {
  10987. throw new Error('Wrong locale name provided. Please make sure you set the correct locale name in options');
  10988. }
  10989. }
  10990. }]);
  10991. return Localization;
  10992. }();
  10993. var Axes = /*#__PURE__*/function () {
  10994. function Axes(ctx) {
  10995. _classCallCheck(this, Axes);
  10996. this.ctx = ctx;
  10997. this.w = ctx.w;
  10998. }
  10999. _createClass(Axes, [{
  11000. key: "drawAxis",
  11001. value: function drawAxis(type, xyRatios) {
  11002. var gl = this.w.globals;
  11003. var cnf = this.w.config;
  11004. var xAxis = new XAxis(this.ctx);
  11005. var yAxis = new YAxis(this.ctx);
  11006. if (gl.axisCharts && type !== 'radar') {
  11007. var elXaxis, elYaxis;
  11008. if (gl.isBarHorizontal) {
  11009. elYaxis = yAxis.drawYaxisInversed(0);
  11010. elXaxis = xAxis.drawXaxisInversed(0);
  11011. gl.dom.elGraphical.add(elXaxis);
  11012. gl.dom.elGraphical.add(elYaxis);
  11013. } else {
  11014. elXaxis = xAxis.drawXaxis();
  11015. gl.dom.elGraphical.add(elXaxis);
  11016. cnf.yaxis.map(function (yaxe, index) {
  11017. if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
  11018. elYaxis = yAxis.drawYaxis(index);
  11019. gl.dom.Paper.add(elYaxis);
  11020. }
  11021. });
  11022. }
  11023. }
  11024. cnf.yaxis.map(function (yaxe, index) {
  11025. if (gl.ignoreYAxisIndexes.indexOf(index) === -1) {
  11026. yAxis.yAxisTitleRotate(index, yaxe.opposite);
  11027. }
  11028. });
  11029. }
  11030. }]);
  11031. return Axes;
  11032. }();
  11033. var Crosshairs = /*#__PURE__*/function () {
  11034. function Crosshairs(ctx) {
  11035. _classCallCheck(this, Crosshairs);
  11036. this.ctx = ctx;
  11037. this.w = ctx.w;
  11038. }
  11039. _createClass(Crosshairs, [{
  11040. key: "drawXCrosshairs",
  11041. value: function drawXCrosshairs() {
  11042. var w = this.w;
  11043. var graphics = new Graphics(this.ctx);
  11044. var filters = new Filters(this.ctx);
  11045. var crosshairGradient = w.config.xaxis.crosshairs.fill.gradient;
  11046. var crosshairShadow = w.config.xaxis.crosshairs.dropShadow;
  11047. var fillType = w.config.xaxis.crosshairs.fill.type;
  11048. var gradientFrom = crosshairGradient.colorFrom;
  11049. var gradientTo = crosshairGradient.colorTo;
  11050. var opacityFrom = crosshairGradient.opacityFrom;
  11051. var opacityTo = crosshairGradient.opacityTo;
  11052. var stops = crosshairGradient.stops;
  11053. var shadow = 'none';
  11054. var dropShadow = crosshairShadow.enabled;
  11055. var shadowLeft = crosshairShadow.left;
  11056. var shadowTop = crosshairShadow.top;
  11057. var shadowBlur = crosshairShadow.blur;
  11058. var shadowColor = crosshairShadow.color;
  11059. var shadowOpacity = crosshairShadow.opacity;
  11060. var xcrosshairsFill = w.config.xaxis.crosshairs.fill.color;
  11061. if (w.config.xaxis.crosshairs.show) {
  11062. if (fillType === 'gradient') {
  11063. xcrosshairsFill = graphics.drawGradient('vertical', gradientFrom, gradientTo, opacityFrom, opacityTo, null, stops, null);
  11064. }
  11065. var xcrosshairs = graphics.drawRect();
  11066. if (w.config.xaxis.crosshairs.width === 1) {
  11067. // to prevent drawing 2 lines, convert rect to line
  11068. xcrosshairs = graphics.drawLine();
  11069. }
  11070. xcrosshairs.attr({
  11071. class: 'apexcharts-xcrosshairs',
  11072. x: 0,
  11073. y: 0,
  11074. y2: w.globals.gridHeight,
  11075. width: Utils.isNumber(w.config.xaxis.crosshairs.width) ? w.config.xaxis.crosshairs.width : 0,
  11076. height: w.globals.gridHeight,
  11077. fill: xcrosshairsFill,
  11078. filter: shadow,
  11079. 'fill-opacity': w.config.xaxis.crosshairs.opacity,
  11080. stroke: w.config.xaxis.crosshairs.stroke.color,
  11081. 'stroke-width': w.config.xaxis.crosshairs.stroke.width,
  11082. 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray
  11083. });
  11084. if (dropShadow) {
  11085. xcrosshairs = filters.dropShadow(xcrosshairs, {
  11086. left: shadowLeft,
  11087. top: shadowTop,
  11088. blur: shadowBlur,
  11089. color: shadowColor,
  11090. opacity: shadowOpacity
  11091. });
  11092. }
  11093. w.globals.dom.elGraphical.add(xcrosshairs);
  11094. }
  11095. }
  11096. }, {
  11097. key: "drawYCrosshairs",
  11098. value: function drawYCrosshairs() {
  11099. var w = this.w;
  11100. var graphics = new Graphics(this.ctx);
  11101. var crosshair = w.config.yaxis[0].crosshairs;
  11102. var offX = w.globals.barPadForNumericAxis;
  11103. if (w.config.yaxis[0].crosshairs.show) {
  11104. var ycrosshairs = graphics.drawLine(-offX, 0, w.globals.gridWidth + offX, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width);
  11105. ycrosshairs.attr({
  11106. class: 'apexcharts-ycrosshairs'
  11107. });
  11108. w.globals.dom.elGraphical.add(ycrosshairs);
  11109. } // draw an invisible crosshair to help in positioning the yaxis tooltip
  11110. var ycrosshairsHidden = graphics.drawLine(-offX, 0, w.globals.gridWidth + offX, 0, crosshair.stroke.color, 0, 0);
  11111. ycrosshairsHidden.attr({
  11112. class: 'apexcharts-ycrosshairs-hidden'
  11113. });
  11114. w.globals.dom.elGraphical.add(ycrosshairsHidden);
  11115. }
  11116. }]);
  11117. return Crosshairs;
  11118. }();
  11119. /**
  11120. * ApexCharts Responsive Class to override options for different screen sizes.
  11121. *
  11122. * @module Responsive
  11123. **/
  11124. var Responsive = /*#__PURE__*/function () {
  11125. function Responsive(ctx) {
  11126. _classCallCheck(this, Responsive);
  11127. this.ctx = ctx;
  11128. this.w = ctx.w;
  11129. } // the opts parameter if not null has to be set overriding everything
  11130. // as the opts is set by user externally
  11131. _createClass(Responsive, [{
  11132. key: "checkResponsiveConfig",
  11133. value: function checkResponsiveConfig(opts) {
  11134. var _this = this;
  11135. var w = this.w;
  11136. var cnf = w.config; // check if responsive config exists
  11137. if (cnf.responsive.length === 0) return;
  11138. var res = cnf.responsive.slice();
  11139. res.sort(function (a, b) {
  11140. return a.breakpoint > b.breakpoint ? 1 : b.breakpoint > a.breakpoint ? -1 : 0;
  11141. }).reverse();
  11142. var config = new Config({});
  11143. var iterateResponsiveOptions = function iterateResponsiveOptions() {
  11144. var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11145. var largestBreakpoint = res[0].breakpoint;
  11146. var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
  11147. if (width > largestBreakpoint) {
  11148. var options = CoreUtils.extendArrayProps(config, w.globals.initialConfig, w);
  11149. newOptions = Utils.extend(options, newOptions);
  11150. newOptions = Utils.extend(w.config, newOptions);
  11151. _this.overrideResponsiveOptions(newOptions);
  11152. } else {
  11153. for (var i = 0; i < res.length; i++) {
  11154. if (width < res[i].breakpoint) {
  11155. newOptions = CoreUtils.extendArrayProps(config, res[i].options, w);
  11156. newOptions = Utils.extend(w.config, newOptions);
  11157. _this.overrideResponsiveOptions(newOptions);
  11158. }
  11159. }
  11160. }
  11161. };
  11162. if (opts) {
  11163. var options = CoreUtils.extendArrayProps(config, opts, w);
  11164. options = Utils.extend(w.config, options);
  11165. options = Utils.extend(options, opts);
  11166. iterateResponsiveOptions(options);
  11167. } else {
  11168. iterateResponsiveOptions({});
  11169. }
  11170. }
  11171. }, {
  11172. key: "overrideResponsiveOptions",
  11173. value: function overrideResponsiveOptions(newOptions) {
  11174. var newConfig = new Config(newOptions).init({
  11175. responsiveOverride: true
  11176. });
  11177. this.w.config = newConfig;
  11178. }
  11179. }]);
  11180. return Responsive;
  11181. }();
  11182. /**
  11183. * ApexCharts Theme Class for setting the colors and palettes.
  11184. *
  11185. * @module Theme
  11186. **/
  11187. var Theme = /*#__PURE__*/function () {
  11188. function Theme(ctx) {
  11189. _classCallCheck(this, Theme);
  11190. this.ctx = ctx;
  11191. this.colors = [];
  11192. this.w = ctx.w;
  11193. var w = this.w;
  11194. this.isColorFn = false;
  11195. this.isBarDistributed = w.config.plotOptions.bar.distributed && (w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar');
  11196. }
  11197. _createClass(Theme, [{
  11198. key: "init",
  11199. value: function init() {
  11200. this.setDefaultColors();
  11201. }
  11202. }, {
  11203. key: "setDefaultColors",
  11204. value: function setDefaultColors() {
  11205. var _this = this;
  11206. var w = this.w;
  11207. var utils = new Utils();
  11208. w.globals.dom.elWrap.classList.add("apexcharts-theme-".concat(w.config.theme.mode));
  11209. if (w.config.colors === undefined) {
  11210. w.globals.colors = this.predefined();
  11211. } else {
  11212. w.globals.colors = w.config.colors; // if user provided a function in colors, we need to eval here
  11213. if (Array.isArray(w.config.colors) && w.config.colors.length > 0 && typeof w.config.colors[0] === 'function') {
  11214. w.globals.colors = w.config.series.map(function (s, i) {
  11215. var c = w.config.colors[i];
  11216. if (!c) c = w.config.colors[0];
  11217. if (typeof c === 'function') {
  11218. _this.isColorFn = true;
  11219. return c({
  11220. value: w.globals.axisCharts ? w.globals.series[i][0] ? w.globals.series[i][0] : 0 : w.globals.series[i],
  11221. seriesIndex: i,
  11222. dataPointIndex: i,
  11223. w: w
  11224. });
  11225. }
  11226. return c;
  11227. });
  11228. }
  11229. }
  11230. if (w.config.theme.monochrome.enabled) {
  11231. var monoArr = [];
  11232. var glsCnt = w.globals.series.length;
  11233. if (this.isBarDistributed) {
  11234. glsCnt = w.globals.series[0].length * w.globals.series.length;
  11235. }
  11236. var mainColor = w.config.theme.monochrome.color;
  11237. var part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity);
  11238. var shade = w.config.theme.monochrome.shadeTo;
  11239. var percent = 0;
  11240. for (var gsl = 0; gsl < glsCnt; gsl++) {
  11241. var newColor = void 0;
  11242. if (shade === 'dark') {
  11243. newColor = utils.shadeColor(percent * -1, mainColor);
  11244. percent = percent + part;
  11245. } else {
  11246. newColor = utils.shadeColor(percent, mainColor);
  11247. percent = percent + part;
  11248. }
  11249. monoArr.push(newColor);
  11250. }
  11251. w.globals.colors = monoArr.slice();
  11252. }
  11253. var defaultColors = w.globals.colors.slice(); // if user specfied less colors than no. of series, push the same colors again
  11254. this.pushExtraColors(w.globals.colors);
  11255. var colorTypes = ['fill', 'stroke'];
  11256. colorTypes.forEach(function (c) {
  11257. if (w.config[c].colors === undefined) {
  11258. w.globals[c].colors = _this.isColorFn ? w.config.colors : defaultColors;
  11259. } else {
  11260. w.globals[c].colors = w.config[c].colors.slice();
  11261. }
  11262. _this.pushExtraColors(w.globals[c].colors);
  11263. });
  11264. if (w.config.dataLabels.style.colors === undefined) {
  11265. w.globals.dataLabels.style.colors = defaultColors;
  11266. } else {
  11267. w.globals.dataLabels.style.colors = w.config.dataLabels.style.colors.slice();
  11268. }
  11269. this.pushExtraColors(w.globals.dataLabels.style.colors, 50);
  11270. if (w.config.plotOptions.radar.polygons.fill.colors === undefined) {
  11271. w.globals.radarPolygons.fill.colors = [w.config.theme.mode === 'dark' ? '#424242' : '#fff'];
  11272. } else {
  11273. w.globals.radarPolygons.fill.colors = w.config.plotOptions.radar.polygons.fill.colors.slice();
  11274. }
  11275. this.pushExtraColors(w.globals.radarPolygons.fill.colors, 20); // The point colors
  11276. if (w.config.markers.colors === undefined) {
  11277. w.globals.markers.colors = defaultColors;
  11278. } else {
  11279. w.globals.markers.colors = w.config.markers.colors.slice();
  11280. }
  11281. this.pushExtraColors(w.globals.markers.colors);
  11282. } // When the number of colors provided is less than the number of series, this method
  11283. // will push same colors to the list
  11284. // params:
  11285. // distributed is only valid for distributed column/bar charts
  11286. }, {
  11287. key: "pushExtraColors",
  11288. value: function pushExtraColors(colorSeries, length) {
  11289. var distributed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11290. var w = this.w;
  11291. var len = length || w.globals.series.length;
  11292. if (distributed === null) {
  11293. distributed = this.isBarDistributed || w.config.chart.type === 'heatmap' && w.config.plotOptions.heatmap.colorScale.inverse;
  11294. }
  11295. if (distributed) {
  11296. len = w.globals.series[0].length * w.globals.series.length;
  11297. }
  11298. if (colorSeries.length < len) {
  11299. var diff = len - colorSeries.length;
  11300. for (var i = 0; i < diff; i++) {
  11301. colorSeries.push(colorSeries[i]);
  11302. }
  11303. }
  11304. }
  11305. }, {
  11306. key: "updateThemeOptions",
  11307. value: function updateThemeOptions(options) {
  11308. options.chart = options.chart || {};
  11309. options.tooltip = options.tooltip || {};
  11310. var mode = options.theme.mode || 'light';
  11311. var palette = options.theme.palette ? options.theme.palette : mode === 'dark' ? 'palette4' : 'palette1';
  11312. var foreColor = options.chart.foreColor ? options.chart.foreColor : mode === 'dark' ? '#f6f7f8' : '#373d3f';
  11313. options.tooltip.theme = mode;
  11314. options.chart.foreColor = foreColor;
  11315. options.theme.palette = palette;
  11316. return options;
  11317. }
  11318. }, {
  11319. key: "predefined",
  11320. value: function predefined() {
  11321. var palette = this.w.config.theme.palette; // D6E3F8, FCEFEF, DCE0D9, A5978B, EDDDD4, D6E3F8, FEF5EF
  11322. switch (palette) {
  11323. case 'palette1':
  11324. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  11325. break;
  11326. case 'palette2':
  11327. this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800'];
  11328. break;
  11329. case 'palette3':
  11330. this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B'];
  11331. break;
  11332. case 'palette4':
  11333. this.colors = ['#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a', '#546E7A'];
  11334. break;
  11335. case 'palette5':
  11336. this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7'];
  11337. break;
  11338. case 'palette6':
  11339. this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D'];
  11340. break;
  11341. case 'palette7':
  11342. this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#E2C044'];
  11343. break;
  11344. case 'palette8':
  11345. this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD'];
  11346. break;
  11347. case 'palette9':
  11348. this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF'];
  11349. break;
  11350. case 'palette10':
  11351. this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2'];
  11352. break;
  11353. default:
  11354. this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0'];
  11355. break;
  11356. }
  11357. return this.colors;
  11358. }
  11359. }]);
  11360. return Theme;
  11361. }();
  11362. var TitleSubtitle = /*#__PURE__*/function () {
  11363. function TitleSubtitle(ctx) {
  11364. _classCallCheck(this, TitleSubtitle);
  11365. this.ctx = ctx;
  11366. this.w = ctx.w;
  11367. }
  11368. _createClass(TitleSubtitle, [{
  11369. key: "draw",
  11370. value: function draw() {
  11371. this.drawTitleSubtitle('title');
  11372. this.drawTitleSubtitle('subtitle');
  11373. }
  11374. }, {
  11375. key: "drawTitleSubtitle",
  11376. value: function drawTitleSubtitle(type) {
  11377. var w = this.w;
  11378. var tsConfig = type === 'title' ? w.config.title : w.config.subtitle;
  11379. var x = w.globals.svgWidth / 2;
  11380. var y = tsConfig.offsetY;
  11381. var textAnchor = 'middle';
  11382. if (tsConfig.align === 'left') {
  11383. x = 10;
  11384. textAnchor = 'start';
  11385. } else if (tsConfig.align === 'right') {
  11386. x = w.globals.svgWidth - 10;
  11387. textAnchor = 'end';
  11388. }
  11389. x = x + tsConfig.offsetX;
  11390. y = y + parseInt(tsConfig.style.fontSize, 10) + tsConfig.margin / 2;
  11391. if (tsConfig.text !== undefined) {
  11392. var graphics = new Graphics(this.ctx);
  11393. var titleText = graphics.drawText({
  11394. x: x,
  11395. y: y,
  11396. text: tsConfig.text,
  11397. textAnchor: textAnchor,
  11398. fontSize: tsConfig.style.fontSize,
  11399. fontFamily: tsConfig.style.fontFamily,
  11400. fontWeight: tsConfig.style.fontWeight,
  11401. foreColor: tsConfig.style.color,
  11402. opacity: 1
  11403. });
  11404. titleText.node.setAttribute('class', "apexcharts-".concat(type, "-text"));
  11405. w.globals.dom.Paper.add(titleText);
  11406. }
  11407. }
  11408. }]);
  11409. return TitleSubtitle;
  11410. }();
  11411. var Helpers$2 = /*#__PURE__*/function () {
  11412. function Helpers(dCtx) {
  11413. _classCallCheck(this, Helpers);
  11414. this.w = dCtx.w;
  11415. this.dCtx = dCtx;
  11416. }
  11417. /**
  11418. * Get Chart Title/Subtitle Dimensions
  11419. * @memberof Dimensions
  11420. * @return {{width, height}}
  11421. **/
  11422. _createClass(Helpers, [{
  11423. key: "getTitleSubtitleCoords",
  11424. value: function getTitleSubtitleCoords(type) {
  11425. var w = this.w;
  11426. var width = 0;
  11427. var height = 0;
  11428. var floating = type === 'title' ? w.config.title.floating : w.config.subtitle.floating;
  11429. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(type, "-text"));
  11430. if (el !== null && !floating) {
  11431. var coord = el.getBoundingClientRect();
  11432. width = coord.width;
  11433. height = w.globals.axisCharts ? coord.height + 5 : coord.height;
  11434. }
  11435. return {
  11436. width: width,
  11437. height: height
  11438. };
  11439. }
  11440. }, {
  11441. key: "getLegendsRect",
  11442. value: function getLegendsRect() {
  11443. var w = this.w;
  11444. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  11445. var lgRect = Object.assign({}, Utils.getBoundingClientRect(elLegendWrap));
  11446. if (elLegendWrap !== null && !w.config.legend.floating && w.config.legend.show) {
  11447. this.dCtx.lgRect = {
  11448. x: lgRect.x,
  11449. y: lgRect.y,
  11450. height: lgRect.height,
  11451. width: lgRect.height === 0 ? 0 : lgRect.width
  11452. };
  11453. } else {
  11454. this.dCtx.lgRect = {
  11455. x: 0,
  11456. y: 0,
  11457. height: 0,
  11458. width: 0
  11459. };
  11460. } // if legend takes up all of the chart space, we need to restrict it.
  11461. if (w.config.legend.position === 'left' || w.config.legend.position === 'right') {
  11462. if (this.dCtx.lgRect.width * 1.5 > w.globals.svgWidth) {
  11463. this.dCtx.lgRect.width = w.globals.svgWidth / 1.5;
  11464. }
  11465. }
  11466. return this.dCtx.lgRect;
  11467. }
  11468. }, {
  11469. key: "getLargestStringFromMultiArr",
  11470. value: function getLargestStringFromMultiArr(val, arr) {
  11471. var w = this.w;
  11472. var valArr = val;
  11473. if (w.globals.isMultiLineX) {
  11474. // if the xaxis labels has multiline texts (array)
  11475. var maxArrs = arr.map(function (xl, idx) {
  11476. return Array.isArray(xl) ? xl.length : 1;
  11477. });
  11478. var maxArrLen = Math.max.apply(Math, _toConsumableArray(maxArrs));
  11479. var maxArrIndex = maxArrs.indexOf(maxArrLen);
  11480. valArr = arr[maxArrIndex];
  11481. }
  11482. return valArr;
  11483. }
  11484. }]);
  11485. return Helpers;
  11486. }();
  11487. var DimXAxis = /*#__PURE__*/function () {
  11488. function DimXAxis(dCtx) {
  11489. _classCallCheck(this, DimXAxis);
  11490. this.w = dCtx.w;
  11491. this.dCtx = dCtx;
  11492. }
  11493. /**
  11494. * Get X Axis Dimensions
  11495. * @memberof Dimensions
  11496. * @return {{width, height}}
  11497. **/
  11498. _createClass(DimXAxis, [{
  11499. key: "getxAxisLabelsCoords",
  11500. value: function getxAxisLabelsCoords() {
  11501. var w = this.w;
  11502. var xaxisLabels = w.globals.labels.slice();
  11503. if (w.config.xaxis.convertedCatToNumeric && xaxisLabels.length === 0) {
  11504. xaxisLabels = w.globals.categoryLabels;
  11505. }
  11506. var rect;
  11507. if (w.globals.timescaleLabels.length > 0) {
  11508. var coords = this.getxAxisTimeScaleLabelsCoords();
  11509. rect = {
  11510. width: coords.width,
  11511. height: coords.height
  11512. };
  11513. w.globals.rotateXLabels = false;
  11514. } else {
  11515. 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
  11516. var xlbFormatter = w.globals.xLabelFormatter; // prevent changing xaxisLabels to avoid issues in multi-yaxes - fix #522
  11517. var val = Utils.getLargestStringFromArr(xaxisLabels);
  11518. var valArr = this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, xaxisLabels); // the labels gets changed for bar charts
  11519. if (w.globals.isBarHorizontal) {
  11520. val = w.globals.yAxisScale[0].result.reduce(function (a, b) {
  11521. return a.length > b.length ? a : b;
  11522. }, 0);
  11523. valArr = val;
  11524. }
  11525. var xFormat = new Formatters(this.dCtx.ctx);
  11526. var timestamp = val;
  11527. val = xFormat.xLabelFormat(xlbFormatter, val, timestamp);
  11528. valArr = xFormat.xLabelFormat(xlbFormatter, valArr, timestamp);
  11529. if (w.config.xaxis.convertedCatToNumeric && typeof val === 'undefined' || String(val).trim() === '') {
  11530. val = '1';
  11531. valArr = val;
  11532. }
  11533. var graphics = new Graphics(this.dCtx.ctx);
  11534. var xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  11535. var xArrLabelrect = xLabelrect;
  11536. if (val !== valArr) {
  11537. xArrLabelrect = graphics.getTextRects(valArr, w.config.xaxis.labels.style.fontSize);
  11538. }
  11539. rect = {
  11540. width: xLabelrect.width >= xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width,
  11541. height: xLabelrect.height >= xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height
  11542. };
  11543. 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) {
  11544. if (!w.globals.isBarHorizontal) {
  11545. w.globals.rotateXLabels = true;
  11546. var getRotatedTextRects = function getRotatedTextRects(text) {
  11547. 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);
  11548. };
  11549. xLabelrect = getRotatedTextRects(val);
  11550. if (val !== valArr) {
  11551. xArrLabelrect = getRotatedTextRects(valArr);
  11552. }
  11553. rect.height = (xLabelrect.height > xArrLabelrect.height ? xLabelrect.height : xArrLabelrect.height) / 1.5;
  11554. rect.width = xLabelrect.width > xArrLabelrect.width ? xLabelrect.width : xArrLabelrect.width;
  11555. }
  11556. } else {
  11557. w.globals.rotateXLabels = false;
  11558. }
  11559. }
  11560. if (!w.config.xaxis.labels.show) {
  11561. rect = {
  11562. width: 0,
  11563. height: 0
  11564. };
  11565. }
  11566. return {
  11567. width: rect.width,
  11568. height: rect.height
  11569. };
  11570. }
  11571. /**
  11572. * Get X Axis Title Dimensions
  11573. * @memberof Dimensions
  11574. * @return {{width, height}}
  11575. **/
  11576. }, {
  11577. key: "getxAxisTitleCoords",
  11578. value: function getxAxisTitleCoords() {
  11579. var w = this.w;
  11580. var width = 0;
  11581. var height = 0;
  11582. if (w.config.xaxis.title.text !== undefined) {
  11583. var graphics = new Graphics(this.dCtx.ctx);
  11584. var rect = graphics.getTextRects(w.config.xaxis.title.text, w.config.xaxis.title.style.fontSize);
  11585. width = rect.width;
  11586. height = rect.height;
  11587. }
  11588. return {
  11589. width: width,
  11590. height: height
  11591. };
  11592. }
  11593. }, {
  11594. key: "getxAxisTimeScaleLabelsCoords",
  11595. value: function getxAxisTimeScaleLabelsCoords() {
  11596. var w = this.w;
  11597. var rect;
  11598. this.dCtx.timescaleLabels = w.globals.timescaleLabels.slice();
  11599. var labels = this.dCtx.timescaleLabels.map(function (label) {
  11600. return label.value;
  11601. }); // get the longest string from the labels array and also apply label formatter to it
  11602. var val = labels.reduce(function (a, b) {
  11603. // if undefined, maybe user didn't pass the datetime(x) values
  11604. if (typeof a === 'undefined') {
  11605. console.error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date');
  11606. return 0;
  11607. } else {
  11608. return a.length > b.length ? a : b;
  11609. }
  11610. }, 0);
  11611. var graphics = new Graphics(this.dCtx.ctx);
  11612. rect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize);
  11613. var totalWidthRotated = rect.width * 1.05 * labels.length;
  11614. if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) {
  11615. w.globals.overlappingXLabels = true;
  11616. }
  11617. return rect;
  11618. } // In certain cases, the last labels gets cropped in xaxis.
  11619. // 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
  11620. }, {
  11621. key: "additionalPaddingXLabels",
  11622. value: function additionalPaddingXLabels(xaxisLabelCoords) {
  11623. var _this = this;
  11624. var w = this.w;
  11625. var gl = w.globals;
  11626. var cnf = w.config;
  11627. var xtype = cnf.xaxis.type; // const predictedGridWidth =
  11628. // gl.svgWidth -
  11629. // this.dCtx.lgWidthForSideLegends -
  11630. // this.dCtx.yAxisWidth -
  11631. // this.dCtx.gridPad.left -
  11632. // this.dCtx.gridPad.right
  11633. var lbWidth = xaxisLabelCoords.width;
  11634. gl.skipLastTimelinelabel = false;
  11635. gl.skipFirstTimelinelabel = false;
  11636. var isBarOpposite = w.config.yaxis[0].opposite && w.globals.isBarHorizontal;
  11637. var isCollapsed = function isCollapsed(i) {
  11638. return gl.collapsedSeriesIndices.indexOf(i) !== -1;
  11639. };
  11640. var rightPad = function rightPad(yaxe) {
  11641. if (_this.dCtx.timescaleLabels && _this.dCtx.timescaleLabels.length) {
  11642. // for timeline labels, we take the last label and check if it exceeds gridWidth
  11643. var firstimescaleLabel = _this.dCtx.timescaleLabels[0];
  11644. var lastTimescaleLabel = _this.dCtx.timescaleLabels[_this.dCtx.timescaleLabels.length - 1];
  11645. var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 - // replace + with - ;
  11646. // allow the last label to intersect with the right y axis
  11647. _this.dCtx.yAxisWidthRight;
  11648. var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 + // remove conditional since the first label is always at the very left
  11649. // allow the first label to intersect with the left y axes
  11650. _this.dCtx.yAxisWidthLeft;
  11651. if (lastLabelPosition > gl.gridWidth) {
  11652. gl.skipLastTimelinelabel = true;
  11653. }
  11654. if (firstLabelPosition < 0) {
  11655. gl.skipFirstTimelinelabel = true;
  11656. }
  11657. } else if (xtype === 'datetime') {
  11658. // If user has enabled DateTime, but uses own's formatter
  11659. if (_this.dCtx.gridPad.right < lbWidth && !gl.rotateXLabels) {
  11660. gl.skipLastTimelinelabel = true;
  11661. }
  11662. } else if (xtype !== 'datetime') {
  11663. if (_this.dCtx.gridPad.right < lbWidth / 2 - _this.dCtx.yAxisWidthRight && !gl.rotateXLabels && (w.config.xaxis.tickPlacement !== 'between' || w.globals.isBarHorizontal)) {
  11664. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  11665. }
  11666. }
  11667. };
  11668. var padYAxe = function padYAxe(yaxe, i) {
  11669. if (isCollapsed(i)) return;
  11670. if (xtype !== 'datetime') {
  11671. if (_this.dCtx.gridPad.left < lbWidth / 2 - _this.dCtx.yAxisWidthLeft && !gl.rotateXLabels && !cnf.xaxis.labels.trim) {
  11672. _this.dCtx.xPadLeft = lbWidth / 2 + 1;
  11673. }
  11674. }
  11675. rightPad();
  11676. };
  11677. cnf.yaxis.forEach(function (yaxe, i) {
  11678. if (isBarOpposite) {
  11679. if (_this.dCtx.gridPad.left < lbWidth) {
  11680. _this.dCtx.xPadLeft = lbWidth / 2 + 1;
  11681. }
  11682. _this.dCtx.xPadRight = lbWidth / 2 + 1;
  11683. } else {
  11684. padYAxe(yaxe, i);
  11685. }
  11686. });
  11687. }
  11688. }]);
  11689. return DimXAxis;
  11690. }();
  11691. var DimYAxis = /*#__PURE__*/function () {
  11692. function DimYAxis(dCtx) {
  11693. _classCallCheck(this, DimYAxis);
  11694. this.w = dCtx.w;
  11695. this.dCtx = dCtx;
  11696. }
  11697. /**
  11698. * Get Y Axis Dimensions
  11699. * @memberof Dimensions
  11700. * @return {{width, height}}
  11701. **/
  11702. _createClass(DimYAxis, [{
  11703. key: "getyAxisLabelsCoords",
  11704. value: function getyAxisLabelsCoords() {
  11705. var _this = this;
  11706. var w = this.w;
  11707. var width = 0;
  11708. var height = 0;
  11709. var ret = [];
  11710. var labelPad = 10;
  11711. var axesUtils = new AxesUtils(this.dCtx.ctx);
  11712. w.config.yaxis.map(function (yaxe, index) {
  11713. var yS = w.globals.yAxisScale[index];
  11714. if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && yS.result.length) {
  11715. var lbFormatter = w.globals.yLabelFormatters[index];
  11716. var longestStr = String(yS.niceMin).length > String(yS.niceMax).length ? yS.niceMin : yS.niceMax; // the second parameter -1 is the index of tick which user can use in the formatter
  11717. var val = lbFormatter(longestStr, {
  11718. seriesIndex: index,
  11719. dataPointIndex: -1,
  11720. w: w
  11721. });
  11722. 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.
  11723. if (typeof val === 'undefined' || val.length === 0) {
  11724. val = longestStr;
  11725. }
  11726. if (w.globals.isBarHorizontal) {
  11727. labelPad = 0;
  11728. var barYaxisLabels = w.globals.labels.slice(); // get the longest string from the labels array and also apply label formatter to it
  11729. val = Utils.getLargestStringFromArr(barYaxisLabels);
  11730. val = lbFormatter(val, {
  11731. seriesIndex: index,
  11732. dataPointIndex: -1,
  11733. w: w
  11734. });
  11735. valArr = _this.dCtx.dimHelpers.getLargestStringFromMultiArr(val, barYaxisLabels);
  11736. }
  11737. var graphics = new Graphics(_this.dCtx.ctx);
  11738. var rect = graphics.getTextRects(val, yaxe.labels.style.fontSize);
  11739. var arrLabelrect = rect;
  11740. if (val !== valArr) {
  11741. arrLabelrect = graphics.getTextRects(valArr, yaxe.labels.style.fontSize);
  11742. }
  11743. ret.push({
  11744. width: (arrLabelrect.width > rect.width ? arrLabelrect.width : rect.width) + labelPad,
  11745. height: arrLabelrect.height > rect.height ? arrLabelrect.height : rect.height
  11746. });
  11747. } else {
  11748. ret.push({
  11749. width: width,
  11750. height: height
  11751. });
  11752. }
  11753. });
  11754. return ret;
  11755. }
  11756. /**
  11757. * Get Y Axis Dimensions
  11758. * @memberof Dimensions
  11759. * @return {{width, height}}
  11760. **/
  11761. }, {
  11762. key: "getyAxisTitleCoords",
  11763. value: function getyAxisTitleCoords() {
  11764. var _this2 = this;
  11765. var w = this.w;
  11766. var ret = [];
  11767. w.config.yaxis.map(function (yaxe, index) {
  11768. if (yaxe.show && yaxe.title.text !== undefined) {
  11769. var graphics = new Graphics(_this2.dCtx.ctx);
  11770. var rect = graphics.getTextRects(yaxe.title.text, yaxe.title.style.fontSize, yaxe.title.style.fontFamily, 'rotate(-90 0 0)', false);
  11771. ret.push({
  11772. width: rect.width,
  11773. height: rect.height
  11774. });
  11775. } else {
  11776. ret.push({
  11777. width: 0,
  11778. height: 0
  11779. });
  11780. }
  11781. });
  11782. return ret;
  11783. }
  11784. }, {
  11785. key: "getTotalYAxisWidth",
  11786. value: function getTotalYAxisWidth() {
  11787. var w = this.w;
  11788. var yAxisWidth = 0;
  11789. var yAxisWidthLeft = 0;
  11790. var yAxisWidthRight = 0;
  11791. var padding = w.globals.yAxisScale.length > 1 ? 10 : 0;
  11792. var axesUtils = new AxesUtils(this.dCtx.ctx);
  11793. var isHiddenYAxis = function isHiddenYAxis(index) {
  11794. return w.globals.ignoreYAxisIndexes.indexOf(index) > -1;
  11795. };
  11796. var padForLabelTitle = function padForLabelTitle(coord, index) {
  11797. var floating = w.config.yaxis[index].floating;
  11798. var width = 0;
  11799. if (coord.width > 0 && !floating) {
  11800. width = coord.width + padding;
  11801. if (isHiddenYAxis(index)) {
  11802. width = width - coord.width - padding;
  11803. }
  11804. } else {
  11805. width = floating || axesUtils.isYAxisHidden(index) ? 0 : 5;
  11806. }
  11807. w.config.yaxis[index].opposite ? yAxisWidthRight = yAxisWidthRight + width : yAxisWidthLeft = yAxisWidthLeft + width;
  11808. yAxisWidth = yAxisWidth + width;
  11809. };
  11810. w.globals.yLabelsCoords.map(function (yLabelCoord, index) {
  11811. padForLabelTitle(yLabelCoord, index);
  11812. });
  11813. w.globals.yTitleCoords.map(function (yTitleCoord, index) {
  11814. padForLabelTitle(yTitleCoord, index);
  11815. });
  11816. if (w.globals.isBarHorizontal) {
  11817. yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15;
  11818. }
  11819. this.dCtx.yAxisWidthLeft = yAxisWidthLeft;
  11820. this.dCtx.yAxisWidthRight = yAxisWidthRight;
  11821. return yAxisWidth;
  11822. }
  11823. }]);
  11824. return DimYAxis;
  11825. }();
  11826. var DimGrid = /*#__PURE__*/function () {
  11827. function DimGrid(dCtx) {
  11828. _classCallCheck(this, DimGrid);
  11829. this.w = dCtx.w;
  11830. this.dCtx = dCtx;
  11831. }
  11832. _createClass(DimGrid, [{
  11833. key: "gridPadForColumnsInNumericAxis",
  11834. value: function gridPadForColumnsInNumericAxis(gridWidth) {
  11835. var w = this.w;
  11836. if (w.globals.noData || w.globals.allSeriesCollapsed) {
  11837. return 0;
  11838. }
  11839. var type = w.config.chart.type;
  11840. var barWidth = 0;
  11841. var seriesLen = type === 'bar' || type === 'rangeBar' ? w.config.series.length : 1;
  11842. if (w.globals.comboBarCount > 0) {
  11843. seriesLen = w.globals.comboBarCount;
  11844. }
  11845. w.globals.collapsedSeries.forEach(function (c) {
  11846. if (c.type === 'bar' || c.type === 'rangeBar') {
  11847. seriesLen = seriesLen - 1;
  11848. }
  11849. });
  11850. if (w.config.chart.stacked) {
  11851. seriesLen = 1;
  11852. }
  11853. var hasBar = type === 'bar' || type === 'rangeBar' || w.globals.comboBarCount > 0;
  11854. if (hasBar && w.globals.isXNumeric && !w.globals.isBarHorizontal && seriesLen > 0) {
  11855. var xRatio = 0;
  11856. var xRange = Math.abs(w.globals.initialMaxX - w.globals.initialMinX);
  11857. if (xRange <= 3) {
  11858. xRange = w.globals.dataPoints;
  11859. }
  11860. xRatio = xRange / gridWidth;
  11861. var xDivision; // max barwidth should be equal to minXDiff to avoid overlap
  11862. if (w.globals.minXDiff && w.globals.minXDiff / xRatio > 0) {
  11863. xDivision = w.globals.minXDiff / xRatio;
  11864. }
  11865. if (xDivision > gridWidth / 2) {
  11866. xDivision = xDivision / 2;
  11867. }
  11868. barWidth = xDivision / seriesLen * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  11869. if (barWidth < 1) {
  11870. barWidth = 1;
  11871. }
  11872. barWidth = barWidth / (seriesLen > 1 ? 1 : 1.5) + 5;
  11873. w.globals.barPadForNumericAxis = barWidth;
  11874. }
  11875. return barWidth;
  11876. }
  11877. }, {
  11878. key: "gridPadFortitleSubtitle",
  11879. value: function gridPadFortitleSubtitle() {
  11880. var _this = this;
  11881. var w = this.w;
  11882. var gl = w.globals;
  11883. var gridShrinkOffset = this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 10;
  11884. var titleSubtitle = ['title', 'subtitle'];
  11885. titleSubtitle.forEach(function (t) {
  11886. if (w.config[t].text !== undefined) {
  11887. gridShrinkOffset += w.config[t].margin;
  11888. } else {
  11889. gridShrinkOffset += _this.dCtx.isSparkline || !w.globals.axisCharts ? 0 : 5;
  11890. }
  11891. });
  11892. var nonAxisOrMultiSeriesCharts = w.config.series.length > 1 || !w.globals.axisCharts || w.config.legend.showForSingleSeries;
  11893. if (w.config.legend.show && w.config.legend.position === 'bottom' && !w.config.legend.floating && nonAxisOrMultiSeriesCharts) {
  11894. gridShrinkOffset += 10;
  11895. }
  11896. var titleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('title');
  11897. var subtitleCoords = this.dCtx.dimHelpers.getTitleSubtitleCoords('subtitle');
  11898. gl.gridHeight = gl.gridHeight - titleCoords.height - subtitleCoords.height - gridShrinkOffset;
  11899. gl.translateY = gl.translateY + titleCoords.height + subtitleCoords.height + gridShrinkOffset;
  11900. }
  11901. }, {
  11902. key: "setGridXPosForDualYAxis",
  11903. value: function setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords) {
  11904. var w = this.w;
  11905. var axesUtils = new AxesUtils(this.dCtx.ctx);
  11906. w.config.yaxis.map(function (yaxe, index) {
  11907. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1 && !yaxe.floating && !axesUtils.isYAxisHidden(index)) {
  11908. if (yaxe.opposite) {
  11909. w.globals.translateX = w.globals.translateX - (yaxisLabelCoords[index].width + yTitleCoords[index].width) - parseInt(w.config.yaxis[index].labels.style.fontSize, 10) / 1.2 - 12;
  11910. }
  11911. }
  11912. });
  11913. }
  11914. }]);
  11915. return DimGrid;
  11916. }();
  11917. /**
  11918. * ApexCharts Dimensions Class for calculating rects of all elements that are drawn and will be drawn.
  11919. *
  11920. * @module Dimensions
  11921. **/
  11922. var Dimensions = /*#__PURE__*/function () {
  11923. function Dimensions(ctx) {
  11924. _classCallCheck(this, Dimensions);
  11925. this.ctx = ctx;
  11926. this.w = ctx.w;
  11927. this.lgRect = {};
  11928. this.yAxisWidth = 0;
  11929. this.yAxisWidthLeft = 0;
  11930. this.yAxisWidthRight = 0;
  11931. this.xAxisHeight = 0;
  11932. this.isSparkline = this.w.config.chart.sparkline.enabled;
  11933. this.dimHelpers = new Helpers$2(this);
  11934. this.dimYAxis = new DimYAxis(this);
  11935. this.dimXAxis = new DimXAxis(this);
  11936. this.dimGrid = new DimGrid(this);
  11937. this.lgWidthForSideLegends = 0;
  11938. this.gridPad = this.w.config.grid.padding;
  11939. this.xPadRight = 0;
  11940. this.xPadLeft = 0;
  11941. }
  11942. /**
  11943. * @memberof Dimensions
  11944. * @param {object} w - chart context
  11945. **/
  11946. _createClass(Dimensions, [{
  11947. key: "plotCoords",
  11948. value: function plotCoords() {
  11949. var w = this.w;
  11950. var gl = w.globals;
  11951. this.lgRect = this.dimHelpers.getLegendsRect();
  11952. if (gl.axisCharts) {
  11953. // for line / area / scatter / column
  11954. this.setDimensionsForAxisCharts();
  11955. } else {
  11956. // for pie / donuts / circle
  11957. this.setDimensionsForNonAxisCharts();
  11958. }
  11959. this.dimGrid.gridPadFortitleSubtitle(); // after calculating everything, apply padding set by user
  11960. gl.gridHeight = gl.gridHeight - this.gridPad.top - this.gridPad.bottom;
  11961. gl.gridWidth = gl.gridWidth - this.gridPad.left - this.gridPad.right - this.xPadRight - this.xPadLeft;
  11962. var barWidth = this.dimGrid.gridPadForColumnsInNumericAxis(gl.gridWidth);
  11963. gl.gridWidth = gl.gridWidth - barWidth * 2;
  11964. gl.translateX = gl.translateX + this.gridPad.left + this.xPadLeft + (barWidth > 0 ? barWidth + 4 : 0);
  11965. gl.translateY = gl.translateY + this.gridPad.top;
  11966. }
  11967. }, {
  11968. key: "setDimensionsForAxisCharts",
  11969. value: function setDimensionsForAxisCharts() {
  11970. var _this = this;
  11971. var w = this.w;
  11972. var gl = w.globals;
  11973. var yaxisLabelCoords = this.dimYAxis.getyAxisLabelsCoords();
  11974. var yTitleCoords = this.dimYAxis.getyAxisTitleCoords();
  11975. w.globals.yLabelsCoords = [];
  11976. w.globals.yTitleCoords = [];
  11977. w.config.yaxis.map(function (yaxe, index) {
  11978. // store the labels and titles coords in global vars
  11979. w.globals.yLabelsCoords.push({
  11980. width: yaxisLabelCoords[index].width,
  11981. index: index
  11982. });
  11983. w.globals.yTitleCoords.push({
  11984. width: yTitleCoords[index].width,
  11985. index: index
  11986. });
  11987. });
  11988. this.yAxisWidth = this.dimYAxis.getTotalYAxisWidth();
  11989. var xaxisLabelCoords = this.dimXAxis.getxAxisLabelsCoords();
  11990. var xtitleCoords = this.dimXAxis.getxAxisTitleCoords();
  11991. this.conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords);
  11992. gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4;
  11993. gl.translateXAxisX = w.globals.rotateXLabels && w.globals.isXNumeric && w.config.xaxis.labels.rotate <= -45 ? -this.xAxisWidth / 4 : 0;
  11994. if (w.globals.isBarHorizontal) {
  11995. gl.rotateXLabels = false;
  11996. gl.translateXAxisY = -1 * (parseInt(w.config.xaxis.labels.style.fontSize, 10) / 1.5);
  11997. }
  11998. gl.translateXAxisY = gl.translateXAxisY + w.config.xaxis.labels.offsetY;
  11999. gl.translateXAxisX = gl.translateXAxisX + w.config.xaxis.labels.offsetX;
  12000. var yAxisWidth = this.yAxisWidth;
  12001. var xAxisHeight = this.xAxisHeight;
  12002. gl.xAxisLabelsHeight = this.xAxisHeight;
  12003. gl.xAxisHeight = this.xAxisHeight;
  12004. var translateY = 10;
  12005. if (w.config.chart.type === 'radar' || this.isSparkline) {
  12006. yAxisWidth = 0;
  12007. xAxisHeight = gl.goldenPadding;
  12008. }
  12009. if (this.isSparkline) {
  12010. this.lgRect = {
  12011. height: 0,
  12012. width: 0
  12013. };
  12014. xAxisHeight = 0;
  12015. yAxisWidth = 0;
  12016. translateY = 0;
  12017. }
  12018. this.dimXAxis.additionalPaddingXLabels(xaxisLabelCoords);
  12019. var legendTopBottom = function legendTopBottom() {
  12020. gl.translateX = yAxisWidth;
  12021. gl.gridHeight = gl.svgHeight - _this.lgRect.height - xAxisHeight - (!_this.isSparkline ? w.globals.rotateXLabels ? 10 : 15 : 0);
  12022. gl.gridWidth = gl.svgWidth - yAxisWidth;
  12023. };
  12024. if (w.config.xaxis.position === 'top') translateY = gl.xAxisHeight - w.config.xaxis.axisTicks.height - 5;
  12025. switch (w.config.legend.position) {
  12026. case 'bottom':
  12027. gl.translateY = translateY;
  12028. legendTopBottom();
  12029. break;
  12030. case 'top':
  12031. gl.translateY = this.lgRect.height + translateY;
  12032. legendTopBottom();
  12033. break;
  12034. case 'left':
  12035. gl.translateY = translateY;
  12036. gl.translateX = this.lgRect.width + yAxisWidth;
  12037. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  12038. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth;
  12039. break;
  12040. case 'right':
  12041. gl.translateY = translateY;
  12042. gl.translateX = yAxisWidth;
  12043. gl.gridHeight = gl.svgHeight - xAxisHeight - 12;
  12044. gl.gridWidth = gl.svgWidth - this.lgRect.width - yAxisWidth - 5;
  12045. break;
  12046. default:
  12047. throw new Error('Legend position not supported');
  12048. }
  12049. this.dimGrid.setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords); // after drawing everything, set the Y axis positions
  12050. var objyAxis = new YAxis(this.ctx);
  12051. objyAxis.setYAxisXPosition(yaxisLabelCoords, yTitleCoords);
  12052. }
  12053. }, {
  12054. key: "setDimensionsForNonAxisCharts",
  12055. value: function setDimensionsForNonAxisCharts() {
  12056. var w = this.w;
  12057. var gl = w.globals;
  12058. var cnf = w.config;
  12059. var xPad = 0;
  12060. if (w.config.legend.show && !w.config.legend.floating) {
  12061. xPad = 20;
  12062. }
  12063. var type = cnf.chart.type === 'pie' || cnf.chart.type === 'polarArea' || cnf.chart.type === 'donut' ? 'pie' : 'radialBar';
  12064. var offY = cnf.plotOptions[type].offsetY;
  12065. var offX = cnf.plotOptions[type].offsetX;
  12066. if (!cnf.legend.show || cnf.legend.floating) {
  12067. gl.gridHeight = gl.svgHeight - cnf.grid.padding.left + cnf.grid.padding.right;
  12068. gl.gridWidth = gl.gridHeight;
  12069. gl.translateY = offY;
  12070. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12071. return;
  12072. }
  12073. switch (cnf.legend.position) {
  12074. case 'bottom':
  12075. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  12076. gl.gridWidth = gl.gridHeight;
  12077. gl.translateY = offY - 10;
  12078. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12079. break;
  12080. case 'top':
  12081. gl.gridHeight = gl.svgHeight - this.lgRect.height - gl.goldenPadding;
  12082. gl.gridWidth = gl.gridHeight;
  12083. gl.translateY = this.lgRect.height + offY + 10;
  12084. gl.translateX = offX + (gl.svgWidth - gl.gridWidth) / 2;
  12085. break;
  12086. case 'left':
  12087. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad;
  12088. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  12089. gl.translateY = offY;
  12090. gl.translateX = offX + this.lgRect.width + xPad;
  12091. break;
  12092. case 'right':
  12093. gl.gridWidth = gl.svgWidth - this.lgRect.width - xPad - 5;
  12094. gl.gridHeight = cnf.chart.height !== 'auto' ? gl.svgHeight : gl.gridWidth;
  12095. gl.translateY = offY;
  12096. gl.translateX = offX + 10;
  12097. break;
  12098. default:
  12099. throw new Error('Legend position not supported');
  12100. }
  12101. }
  12102. }, {
  12103. key: "conditionalChecksForAxisCoords",
  12104. value: function conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords) {
  12105. var w = this.w;
  12106. this.xAxisHeight = (xaxisLabelCoords.height + xtitleCoords.height) * (w.globals.isMultiLineX ? 1.2 : w.globals.LINE_HEIGHT_RATIO) + (w.globals.rotateXLabels ? 22 : 10);
  12107. this.xAxisWidth = xaxisLabelCoords.width;
  12108. if (this.xAxisHeight - xtitleCoords.height > w.config.xaxis.labels.maxHeight) {
  12109. this.xAxisHeight = w.config.xaxis.labels.maxHeight;
  12110. }
  12111. if (w.config.xaxis.labels.minHeight && this.xAxisHeight < w.config.xaxis.labels.minHeight) {
  12112. this.xAxisHeight = w.config.xaxis.labels.minHeight;
  12113. }
  12114. if (w.config.xaxis.floating) {
  12115. this.xAxisHeight = 0;
  12116. }
  12117. var minYAxisWidth = 0;
  12118. var maxYAxisWidth = 0;
  12119. w.config.yaxis.forEach(function (y) {
  12120. minYAxisWidth += y.labels.minWidth;
  12121. maxYAxisWidth += y.labels.maxWidth;
  12122. });
  12123. if (this.yAxisWidth < minYAxisWidth) {
  12124. this.yAxisWidth = minYAxisWidth;
  12125. }
  12126. if (this.yAxisWidth > maxYAxisWidth) {
  12127. this.yAxisWidth = maxYAxisWidth;
  12128. }
  12129. }
  12130. }]);
  12131. return Dimensions;
  12132. }();
  12133. var Helpers$3 = /*#__PURE__*/function () {
  12134. function Helpers(lgCtx) {
  12135. _classCallCheck(this, Helpers);
  12136. this.w = lgCtx.w;
  12137. this.lgCtx = lgCtx;
  12138. }
  12139. _createClass(Helpers, [{
  12140. key: "getLegendStyles",
  12141. value: function getLegendStyles() {
  12142. var stylesheet = document.createElement('style');
  12143. stylesheet.setAttribute('type', 'text/css');
  12144. var text = "\t\n \t\n .apexcharts-legend {\t\n display: flex;\t\n overflow: auto;\t\n padding: 0 10px;\t\n }\t\n .apexcharts-legend.position-bottom, .apexcharts-legend.position-top {\t\n flex-wrap: wrap\t\n }\t\n .apexcharts-legend.position-right, .apexcharts-legend.position-left {\t\n flex-direction: column;\t\n bottom: 0;\t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-left, .apexcharts-legend.position-top.apexcharts-align-left, .apexcharts-legend.position-right, .apexcharts-legend.position-left {\t\n justify-content: flex-start;\t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-center, .apexcharts-legend.position-top.apexcharts-align-center {\t\n justify-content: center; \t\n }\t\n .apexcharts-legend.position-bottom.apexcharts-align-right, .apexcharts-legend.position-top.apexcharts-align-right {\t\n justify-content: flex-end;\t\n }\t\n .apexcharts-legend-series {\t\n cursor: pointer;\t\n line-height: normal;\t\n }\t\n .apexcharts-legend.position-bottom .apexcharts-legend-series, .apexcharts-legend.position-top .apexcharts-legend-series{\t\n display: flex;\t\n align-items: center;\t\n }\t\n .apexcharts-legend-text {\t\n position: relative;\t\n font-size: 14px;\t\n }\t\n .apexcharts-legend-text *, .apexcharts-legend-marker * {\t\n pointer-events: none;\t\n }\t\n .apexcharts-legend-marker {\t\n position: relative;\t\n display: inline-block;\t\n cursor: pointer;\t\n margin-right: 3px;\t\n border-style: solid;\n }\t\n \t\n .apexcharts-legend.apexcharts-align-right .apexcharts-legend-series, .apexcharts-legend.apexcharts-align-left .apexcharts-legend-series{\t\n display: inline-block;\t\n }\t\n .apexcharts-legend-series.apexcharts-no-click {\t\n cursor: auto;\t\n }\t\n .apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\t\n display: none !important;\t\n }\t\n .apexcharts-inactive-legend {\t\n opacity: 0.45;\t\n }";
  12145. var rules = document.createTextNode(text);
  12146. stylesheet.appendChild(rules);
  12147. return stylesheet;
  12148. }
  12149. }, {
  12150. key: "getLegendBBox",
  12151. value: function getLegendBBox() {
  12152. var w = this.w;
  12153. var currLegendsWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  12154. var currLegendsWrapRect = currLegendsWrap.getBoundingClientRect();
  12155. var currLegendsWrapWidth = currLegendsWrapRect.width;
  12156. var currLegendsWrapHeight = currLegendsWrapRect.height;
  12157. return {
  12158. clwh: currLegendsWrapHeight,
  12159. clww: currLegendsWrapWidth
  12160. };
  12161. }
  12162. }, {
  12163. key: "appendToForeignObject",
  12164. value: function appendToForeignObject() {
  12165. var gl = this.w.globals;
  12166. gl.dom.elLegendForeign = document.createElementNS(gl.SVGNS, 'foreignObject');
  12167. var elForeign = gl.dom.elLegendForeign;
  12168. elForeign.setAttribute('x', 0);
  12169. elForeign.setAttribute('y', 0);
  12170. elForeign.setAttribute('width', gl.svgWidth);
  12171. elForeign.setAttribute('height', gl.svgHeight);
  12172. gl.dom.elLegendWrap.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
  12173. elForeign.appendChild(gl.dom.elLegendWrap);
  12174. elForeign.appendChild(this.getLegendStyles());
  12175. gl.dom.Paper.node.insertBefore(elForeign, gl.dom.elGraphical.node);
  12176. }
  12177. }, {
  12178. key: "toggleDataSeries",
  12179. value: function toggleDataSeries(seriesCnt, isHidden) {
  12180. var _this = this;
  12181. var w = this.w;
  12182. if (w.globals.axisCharts || w.config.chart.type === 'radialBar') {
  12183. w.globals.resized = true; // we don't want initial animations again
  12184. var seriesEl = null;
  12185. var realIndex = null; // yes, make it null. 1 series will rise at a time
  12186. w.globals.risingSeries = [];
  12187. if (w.globals.axisCharts) {
  12188. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(seriesCnt, "']"));
  12189. realIndex = parseInt(seriesEl.getAttribute('data:realIndex'), 10);
  12190. } else {
  12191. seriesEl = w.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(seriesCnt + 1, "']"));
  12192. realIndex = parseInt(seriesEl.getAttribute('rel'), 10) - 1;
  12193. }
  12194. if (isHidden) {
  12195. var seriesToMakeVisible = [{
  12196. cs: w.globals.collapsedSeries,
  12197. csi: w.globals.collapsedSeriesIndices
  12198. }, {
  12199. cs: w.globals.ancillaryCollapsedSeries,
  12200. csi: w.globals.ancillaryCollapsedSeriesIndices
  12201. }];
  12202. seriesToMakeVisible.forEach(function (r) {
  12203. _this.riseCollapsedSeries(r.cs, r.csi, realIndex);
  12204. });
  12205. } else {
  12206. this.hideSeries({
  12207. seriesEl: seriesEl,
  12208. realIndex: realIndex
  12209. });
  12210. }
  12211. } else {
  12212. // for non-axis charts i.e pie / donuts
  12213. var _seriesEl = w.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(seriesCnt + 1, "'] path"));
  12214. var type = w.config.chart.type;
  12215. if (type === 'pie' || type === 'polarArea' || type === 'donut') {
  12216. var dataLabels = w.config.plotOptions.pie.donut.labels;
  12217. var graphics = new Graphics(this.lgCtx.ctx);
  12218. graphics.pathMouseDown(_seriesEl.members[0], null);
  12219. this.lgCtx.ctx.pie.printDataLabelsInner(_seriesEl.members[0].node, dataLabels);
  12220. }
  12221. _seriesEl.fire('click');
  12222. }
  12223. }
  12224. }, {
  12225. key: "hideSeries",
  12226. value: function hideSeries(_ref) {
  12227. var seriesEl = _ref.seriesEl,
  12228. realIndex = _ref.realIndex;
  12229. var w = this.w;
  12230. var series = Utils.clone(w.config.series);
  12231. if (w.globals.axisCharts) {
  12232. var shouldNotHideYAxis = false;
  12233. if (w.config.yaxis[realIndex] && w.config.yaxis[realIndex].show && w.config.yaxis[realIndex].showAlways) {
  12234. shouldNotHideYAxis = true;
  12235. if (w.globals.ancillaryCollapsedSeriesIndices.indexOf(realIndex) < 0) {
  12236. w.globals.ancillaryCollapsedSeries.push({
  12237. index: realIndex,
  12238. data: series[realIndex].data.slice(),
  12239. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  12240. });
  12241. w.globals.ancillaryCollapsedSeriesIndices.push(realIndex);
  12242. }
  12243. }
  12244. if (!shouldNotHideYAxis) {
  12245. w.globals.collapsedSeries.push({
  12246. index: realIndex,
  12247. data: series[realIndex].data.slice(),
  12248. type: seriesEl.parentNode.className.baseVal.split('-')[1]
  12249. });
  12250. w.globals.collapsedSeriesIndices.push(realIndex);
  12251. var removeIndexOfRising = w.globals.risingSeries.indexOf(realIndex);
  12252. w.globals.risingSeries.splice(removeIndexOfRising, 1);
  12253. }
  12254. series[realIndex].data = [];
  12255. } else {
  12256. w.globals.collapsedSeries.push({
  12257. index: realIndex,
  12258. data: series[realIndex]
  12259. });
  12260. w.globals.collapsedSeriesIndices.push(realIndex);
  12261. series[realIndex] = 0;
  12262. }
  12263. var seriesChildren = seriesEl.childNodes;
  12264. for (var sc = 0; sc < seriesChildren.length; sc++) {
  12265. if (seriesChildren[sc].classList.contains('apexcharts-series-markers-wrap')) {
  12266. if (seriesChildren[sc].classList.contains('apexcharts-hide')) {
  12267. seriesChildren[sc].classList.remove('apexcharts-hide');
  12268. } else {
  12269. seriesChildren[sc].classList.add('apexcharts-hide');
  12270. }
  12271. }
  12272. }
  12273. w.globals.allSeriesCollapsed = w.globals.collapsedSeries.length === w.config.series.length;
  12274. this.lgCtx.ctx.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  12275. }
  12276. }, {
  12277. key: "riseCollapsedSeries",
  12278. value: function riseCollapsedSeries(series, seriesIndices, realIndex) {
  12279. var w = this.w;
  12280. if (series.length > 0) {
  12281. for (var c = 0; c < series.length; c++) {
  12282. if (series[c].index === realIndex) {
  12283. if (w.globals.axisCharts) {
  12284. w.config.series[realIndex].data = series[c].data.slice();
  12285. series.splice(c, 1);
  12286. seriesIndices.splice(c, 1);
  12287. w.globals.risingSeries.push(realIndex);
  12288. } else {
  12289. w.config.series[realIndex] = series[c].data;
  12290. series.splice(c, 1);
  12291. seriesIndices.splice(c, 1);
  12292. w.globals.risingSeries.push(realIndex);
  12293. }
  12294. this.lgCtx.ctx.updateHelpers._updateSeries(w.config.series, w.config.chart.animations.dynamicAnimation.enabled);
  12295. }
  12296. }
  12297. }
  12298. }
  12299. }]);
  12300. return Helpers;
  12301. }();
  12302. /**
  12303. * ApexCharts Legend Class to draw legend.
  12304. *
  12305. * @module Legend
  12306. **/
  12307. var Legend = /*#__PURE__*/function () {
  12308. function Legend(ctx, opts) {
  12309. _classCallCheck(this, Legend);
  12310. this.ctx = ctx;
  12311. this.w = ctx.w;
  12312. this.onLegendClick = this.onLegendClick.bind(this);
  12313. this.onLegendHovered = this.onLegendHovered.bind(this);
  12314. this.isBarsDistributed = this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.distributed && this.w.config.series.length === 1;
  12315. this.legendHelpers = new Helpers$3(this);
  12316. }
  12317. _createClass(Legend, [{
  12318. key: "init",
  12319. value: function init() {
  12320. var w = this.w;
  12321. var gl = w.globals;
  12322. var cnf = w.config;
  12323. var showLegendAlways = cnf.legend.showForSingleSeries && gl.series.length === 1 || this.isBarsDistributed || gl.series.length > 1;
  12324. if ((showLegendAlways || !gl.axisCharts) && cnf.legend.show) {
  12325. while (gl.dom.elLegendWrap.firstChild) {
  12326. gl.dom.elLegendWrap.removeChild(gl.dom.elLegendWrap.firstChild);
  12327. }
  12328. this.drawLegends();
  12329. if (!Utils.isIE11()) {
  12330. this.legendHelpers.appendToForeignObject();
  12331. } else {
  12332. // IE11 doesn't supports foreignObject, hence append it to <head>
  12333. document.getElementsByTagName('head')[0].appendChild(this.legendHelpers.getLegendStyles());
  12334. }
  12335. if (cnf.legend.position === 'bottom' || cnf.legend.position === 'top') {
  12336. this.legendAlignHorizontal();
  12337. } else if (cnf.legend.position === 'right' || cnf.legend.position === 'left') {
  12338. this.legendAlignVertical();
  12339. }
  12340. }
  12341. }
  12342. }, {
  12343. key: "drawLegends",
  12344. value: function drawLegends() {
  12345. var self = this;
  12346. var w = this.w;
  12347. var fontFamily = w.config.legend.fontFamily;
  12348. var legendNames = w.globals.seriesNames;
  12349. var fillcolor = w.globals.colors.slice();
  12350. if (w.config.chart.type === 'heatmap') {
  12351. var ranges = w.config.plotOptions.heatmap.colorScale.ranges;
  12352. legendNames = ranges.map(function (colorScale) {
  12353. return colorScale.name ? colorScale.name : colorScale.from + ' - ' + colorScale.to;
  12354. });
  12355. fillcolor = ranges.map(function (color) {
  12356. return color.color;
  12357. });
  12358. } else if (this.isBarsDistributed) {
  12359. legendNames = w.globals.labels.slice();
  12360. }
  12361. var legendFormatter = w.globals.legendFormatter;
  12362. var isLegendInversed = w.config.legend.inverseOrder;
  12363. for (var i = isLegendInversed ? legendNames.length - 1 : 0; isLegendInversed ? i >= 0 : i <= legendNames.length - 1; isLegendInversed ? i-- : i++) {
  12364. var text = legendFormatter(legendNames[i], {
  12365. seriesIndex: i,
  12366. w: w
  12367. });
  12368. var collapsedSeries = false;
  12369. var ancillaryCollapsedSeries = false;
  12370. if (w.globals.collapsedSeries.length > 0) {
  12371. for (var c = 0; c < w.globals.collapsedSeries.length; c++) {
  12372. if (w.globals.collapsedSeries[c].index === i) {
  12373. collapsedSeries = true;
  12374. }
  12375. }
  12376. }
  12377. if (w.globals.ancillaryCollapsedSeriesIndices.length > 0) {
  12378. for (var _c = 0; _c < w.globals.ancillaryCollapsedSeriesIndices.length; _c++) {
  12379. if (w.globals.ancillaryCollapsedSeriesIndices[_c] === i) {
  12380. ancillaryCollapsedSeries = true;
  12381. }
  12382. }
  12383. }
  12384. var elMarker = document.createElement('span');
  12385. elMarker.classList.add('apexcharts-legend-marker');
  12386. var mOffsetX = w.config.legend.markers.offsetX;
  12387. var mOffsetY = w.config.legend.markers.offsetY;
  12388. var mHeight = w.config.legend.markers.height;
  12389. var mWidth = w.config.legend.markers.width;
  12390. var mBorderWidth = w.config.legend.markers.strokeWidth;
  12391. var mBorderColor = w.config.legend.markers.strokeColor;
  12392. var mBorderRadius = w.config.legend.markers.radius;
  12393. var mStyle = elMarker.style;
  12394. mStyle.background = fillcolor[i];
  12395. mStyle.color = fillcolor[i]; // override fill color with custom legend.markers.fillColors
  12396. if (w.config.legend.markers.fillColors && w.config.legend.markers.fillColors[i]) {
  12397. mStyle.background = w.config.legend.markers.fillColors[i];
  12398. }
  12399. mStyle.height = Array.isArray(mHeight) ? parseFloat(mHeight[i]) + 'px' : parseFloat(mHeight) + 'px';
  12400. mStyle.width = Array.isArray(mWidth) ? parseFloat(mWidth[i]) + 'px' : parseFloat(mWidth) + 'px';
  12401. mStyle.left = Array.isArray(mOffsetX) ? mOffsetX[i] : mOffsetX;
  12402. mStyle.top = Array.isArray(mOffsetY) ? mOffsetY[i] : mOffsetY;
  12403. mStyle.borderWidth = Array.isArray(mBorderWidth) ? mBorderWidth[i] : mBorderWidth;
  12404. mStyle.borderColor = Array.isArray(mBorderColor) ? mBorderColor[i] : mBorderColor;
  12405. mStyle.borderRadius = Array.isArray(mBorderRadius) ? parseFloat(mBorderRadius[i]) + 'px' : parseFloat(mBorderRadius) + 'px';
  12406. if (w.config.legend.markers.customHTML) {
  12407. if (Array.isArray(w.config.legend.markers.customHTML)) {
  12408. if (w.config.legend.markers.customHTML[i]) {
  12409. elMarker.innerHTML = w.config.legend.markers.customHTML[i]();
  12410. }
  12411. } else {
  12412. elMarker.innerHTML = w.config.legend.markers.customHTML();
  12413. }
  12414. }
  12415. Graphics.setAttrs(elMarker, {
  12416. rel: i + 1,
  12417. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  12418. });
  12419. if (collapsedSeries || ancillaryCollapsedSeries) {
  12420. elMarker.classList.add('apexcharts-inactive-legend');
  12421. }
  12422. var elLegend = document.createElement('div');
  12423. var elLegendText = document.createElement('span');
  12424. elLegendText.classList.add('apexcharts-legend-text');
  12425. elLegendText.innerHTML = Array.isArray(text) ? text.join(' ') : text;
  12426. var textColor = w.config.legend.labels.useSeriesColors ? w.globals.colors[i] : w.config.legend.labels.colors;
  12427. if (!textColor) {
  12428. textColor = w.config.chart.foreColor;
  12429. }
  12430. elLegendText.style.color = textColor;
  12431. elLegendText.style.fontSize = parseFloat(w.config.legend.fontSize) + 'px';
  12432. elLegendText.style.fontWeight = w.config.legend.fontWeight;
  12433. elLegendText.style.fontFamily = fontFamily || w.config.chart.fontFamily;
  12434. Graphics.setAttrs(elLegendText, {
  12435. rel: i + 1,
  12436. i: i,
  12437. 'data:default-text': encodeURIComponent(text),
  12438. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  12439. });
  12440. elLegend.appendChild(elMarker);
  12441. elLegend.appendChild(elLegendText);
  12442. var coreUtils = new CoreUtils(this.ctx);
  12443. if (!w.config.legend.showForZeroSeries) {
  12444. var total = coreUtils.getSeriesTotalByIndex(i);
  12445. if (total === 0 && coreUtils.seriesHaveSameValues(i) && !coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  12446. elLegend.classList.add('apexcharts-hidden-zero-series');
  12447. }
  12448. }
  12449. if (!w.config.legend.showForNullSeries) {
  12450. if (coreUtils.isSeriesNull(i) && w.globals.collapsedSeriesIndices.indexOf(i) === -1 && w.globals.ancillaryCollapsedSeriesIndices.indexOf(i) === -1) {
  12451. elLegend.classList.add('apexcharts-hidden-null-series');
  12452. }
  12453. }
  12454. w.globals.dom.elLegendWrap.appendChild(elLegend);
  12455. w.globals.dom.elLegendWrap.classList.add("apexcharts-align-".concat(w.config.legend.horizontalAlign));
  12456. w.globals.dom.elLegendWrap.classList.add('position-' + w.config.legend.position);
  12457. elLegend.classList.add('apexcharts-legend-series');
  12458. elLegend.style.margin = "".concat(w.config.legend.itemMargin.vertical, "px ").concat(w.config.legend.itemMargin.horizontal, "px");
  12459. w.globals.dom.elLegendWrap.style.width = w.config.legend.width ? w.config.legend.width + 'px' : '';
  12460. w.globals.dom.elLegendWrap.style.height = w.config.legend.height ? w.config.legend.height + 'px' : '';
  12461. Graphics.setAttrs(elLegend, {
  12462. rel: i + 1,
  12463. 'data:collapsed': collapsedSeries || ancillaryCollapsedSeries
  12464. });
  12465. if (collapsedSeries || ancillaryCollapsedSeries) {
  12466. elLegend.classList.add('apexcharts-inactive-legend');
  12467. }
  12468. if (!w.config.legend.onItemClick.toggleDataSeries) {
  12469. elLegend.classList.add('apexcharts-no-click');
  12470. }
  12471. } // for now - just prevent click on heatmap legend - and allow hover only
  12472. var clickAllowed = w.config.chart.type !== 'heatmap' && !this.isBarsDistributed;
  12473. if (clickAllowed && w.config.legend.onItemClick.toggleDataSeries) {
  12474. w.globals.dom.elWrap.addEventListener('click', self.onLegendClick, true);
  12475. }
  12476. if (w.config.legend.onItemHover.highlightDataSeries) {
  12477. w.globals.dom.elWrap.addEventListener('mousemove', self.onLegendHovered, true);
  12478. w.globals.dom.elWrap.addEventListener('mouseout', self.onLegendHovered, true);
  12479. }
  12480. }
  12481. }, {
  12482. key: "setLegendWrapXY",
  12483. value: function setLegendWrapXY(offsetX, offsetY) {
  12484. var w = this.w;
  12485. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  12486. var legendRect = elLegendWrap.getBoundingClientRect();
  12487. var x = 0;
  12488. var y = 0;
  12489. if (w.config.legend.position === 'bottom') {
  12490. y = y + (w.globals.svgHeight - legendRect.height / 2);
  12491. } else if (w.config.legend.position === 'top') {
  12492. var dim = new Dimensions(this.ctx);
  12493. var titleH = dim.dimHelpers.getTitleSubtitleCoords('title').height;
  12494. var subtitleH = dim.dimHelpers.getTitleSubtitleCoords('subtitle').height;
  12495. y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0);
  12496. }
  12497. elLegendWrap.style.position = 'absolute';
  12498. x = x + offsetX + w.config.legend.offsetX;
  12499. y = y + offsetY + w.config.legend.offsetY;
  12500. elLegendWrap.style.left = x + 'px';
  12501. elLegendWrap.style.top = y + 'px';
  12502. if (w.config.legend.position === 'bottom') {
  12503. elLegendWrap.style.top = 'auto';
  12504. elLegendWrap.style.bottom = 5 - w.config.legend.offsetY + 'px';
  12505. } else if (w.config.legend.position === 'right') {
  12506. elLegendWrap.style.left = 'auto';
  12507. elLegendWrap.style.right = 25 + w.config.legend.offsetX + 'px';
  12508. }
  12509. var fixedHeigthWidth = ['width', 'height'];
  12510. fixedHeigthWidth.forEach(function (hw) {
  12511. if (elLegendWrap.style[hw]) {
  12512. elLegendWrap.style[hw] = parseInt(w.config.legend[hw], 10) + 'px';
  12513. }
  12514. });
  12515. }
  12516. }, {
  12517. key: "legendAlignHorizontal",
  12518. value: function legendAlignHorizontal() {
  12519. var w = this.w;
  12520. var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend');
  12521. elLegendWrap.style.right = 0;
  12522. var lRect = this.legendHelpers.getLegendBBox();
  12523. var dimensions = new Dimensions(this.ctx);
  12524. var titleRect = dimensions.dimHelpers.getTitleSubtitleCoords('title');
  12525. var subtitleRect = dimensions.dimHelpers.getTitleSubtitleCoords('subtitle');
  12526. var offsetX = 20;
  12527. var offsetY = 0; // the whole legend box is set to bottom
  12528. if (w.config.legend.position === 'bottom') {
  12529. offsetY = -lRect.clwh / 1.8;
  12530. } else if (w.config.legend.position === 'top') {
  12531. offsetY = titleRect.height + subtitleRect.height + w.config.title.margin + w.config.subtitle.margin - 10;
  12532. }
  12533. this.setLegendWrapXY(offsetX, offsetY);
  12534. }
  12535. }, {
  12536. key: "legendAlignVertical",
  12537. value: function legendAlignVertical() {
  12538. var w = this.w;
  12539. var lRect = this.legendHelpers.getLegendBBox();
  12540. var offsetY = 20;
  12541. var offsetX = 0;
  12542. if (w.config.legend.position === 'left') {
  12543. offsetX = 20;
  12544. }
  12545. if (w.config.legend.position === 'right') {
  12546. offsetX = w.globals.svgWidth - lRect.clww - 10;
  12547. }
  12548. this.setLegendWrapXY(offsetX, offsetY);
  12549. }
  12550. }, {
  12551. key: "onLegendHovered",
  12552. value: function onLegendHovered(e) {
  12553. var w = this.w;
  12554. var hoverOverLegend = e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker');
  12555. if (w.config.chart.type !== 'heatmap' && !this.isBarsDistributed) {
  12556. if (!e.target.classList.contains('apexcharts-inactive-legend') && hoverOverLegend) {
  12557. var series = new Series(this.ctx);
  12558. series.toggleSeriesOnHover(e, e.target);
  12559. }
  12560. } else {
  12561. // for heatmap handling
  12562. if (hoverOverLegend) {
  12563. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  12564. this.ctx.events.fireEvent('legendHover', [this.ctx, seriesCnt, this.w]);
  12565. var _series = new Series(this.ctx);
  12566. _series.highlightRangeInSeries(e, e.target);
  12567. }
  12568. }
  12569. }
  12570. }, {
  12571. key: "onLegendClick",
  12572. value: function onLegendClick(e) {
  12573. if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-marker')) {
  12574. var seriesCnt = parseInt(e.target.getAttribute('rel'), 10) - 1;
  12575. var isHidden = e.target.getAttribute('data:collapsed') === 'true';
  12576. var legendClick = this.w.config.chart.events.legendClick;
  12577. if (typeof legendClick === 'function') {
  12578. legendClick(this.ctx, seriesCnt, this.w);
  12579. }
  12580. this.ctx.events.fireEvent('legendClick', [this.ctx, seriesCnt, this.w]);
  12581. var markerClick = this.w.config.legend.markers.onClick;
  12582. if (typeof markerClick === 'function' && e.target.classList.contains('apexcharts-legend-marker')) {
  12583. markerClick(this.ctx, seriesCnt, this.w);
  12584. this.ctx.events.fireEvent('legendMarkerClick', [this.ctx, seriesCnt, this.w]);
  12585. }
  12586. this.legendHelpers.toggleDataSeries(seriesCnt, isHidden);
  12587. }
  12588. }
  12589. }]);
  12590. return Legend;
  12591. }();
  12592. 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>";
  12593. 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>";
  12594. 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>";
  12595. 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";
  12596. 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";
  12597. 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>";
  12598. 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>";
  12599. /**
  12600. * ApexCharts Toolbar Class for creating toolbar in axis based charts.
  12601. *
  12602. * @module Toolbar
  12603. **/
  12604. var Toolbar = /*#__PURE__*/function () {
  12605. function Toolbar(ctx) {
  12606. _classCallCheck(this, Toolbar);
  12607. this.ctx = ctx;
  12608. this.w = ctx.w;
  12609. this.ev = this.w.config.chart.events;
  12610. this.selectedClass = 'apexcharts-selected';
  12611. this.localeValues = this.w.globals.locale.toolbar;
  12612. }
  12613. _createClass(Toolbar, [{
  12614. key: "createToolbar",
  12615. value: function createToolbar() {
  12616. var _this = this;
  12617. var w = this.w;
  12618. var createDiv = function createDiv() {
  12619. return document.createElement('div');
  12620. };
  12621. var elToolbarWrap = createDiv();
  12622. elToolbarWrap.setAttribute('class', 'apexcharts-toolbar');
  12623. elToolbarWrap.style.top = w.config.chart.toolbar.offsetY + 'px';
  12624. elToolbarWrap.style.right = -w.config.chart.toolbar.offsetX + 3 + 'px';
  12625. w.globals.dom.elWrap.appendChild(elToolbarWrap);
  12626. this.elZoom = createDiv();
  12627. this.elZoomIn = createDiv();
  12628. this.elZoomOut = createDiv();
  12629. this.elPan = createDiv();
  12630. this.elSelection = createDiv();
  12631. this.elZoomReset = createDiv();
  12632. this.elMenuIcon = createDiv();
  12633. this.elMenu = createDiv();
  12634. this.elCustomIcons = [];
  12635. this.t = w.config.chart.toolbar.tools;
  12636. if (Array.isArray(this.t.customIcons)) {
  12637. for (var i = 0; i < this.t.customIcons.length; i++) {
  12638. this.elCustomIcons.push(createDiv());
  12639. }
  12640. }
  12641. var toolbarControls = [];
  12642. var appendZoomControl = function appendZoomControl(type, el, ico) {
  12643. var tool = type.toLowerCase();
  12644. if (_this.t[tool] && w.config.chart.zoom.enabled) {
  12645. toolbarControls.push({
  12646. el: el,
  12647. icon: typeof _this.t[tool] === 'string' ? _this.t[tool] : ico,
  12648. title: _this.localeValues[type],
  12649. class: "apexcharts-".concat(tool, "-icon")
  12650. });
  12651. }
  12652. };
  12653. appendZoomControl('zoomIn', this.elZoomIn, icoZoomIn);
  12654. appendZoomControl('zoomOut', this.elZoomOut, icoZoomOut);
  12655. var zoomSelectionCtrls = function zoomSelectionCtrls(z) {
  12656. if (_this.t[z] && w.config.chart[z].enabled) {
  12657. toolbarControls.push({
  12658. el: z === 'zoom' ? _this.elZoom : _this.elSelection,
  12659. icon: typeof _this.t[z] === 'string' ? _this.t[z] : z === 'zoom' ? icoZoom : icoSelect,
  12660. title: _this.localeValues[z === 'zoom' ? 'selectionZoom' : 'selection'],
  12661. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : "apexcharts-".concat(z, "-icon")
  12662. });
  12663. }
  12664. };
  12665. zoomSelectionCtrls('zoom');
  12666. zoomSelectionCtrls('selection');
  12667. if (this.t.pan && w.config.chart.zoom.enabled) {
  12668. toolbarControls.push({
  12669. el: this.elPan,
  12670. icon: typeof this.t.pan === 'string' ? this.t.pan : icoPan,
  12671. title: this.localeValues.pan,
  12672. class: w.globals.isTouchDevice ? 'apexcharts-element-hidden' : 'apexcharts-pan-icon'
  12673. });
  12674. }
  12675. appendZoomControl('reset', this.elZoomReset, icoReset);
  12676. if (this.t.download) {
  12677. toolbarControls.push({
  12678. el: this.elMenuIcon,
  12679. icon: typeof this.t.download === 'string' ? this.t.download : icoMenu,
  12680. title: this.localeValues.menu,
  12681. class: 'apexcharts-menu-icon'
  12682. });
  12683. }
  12684. for (var _i = 0; _i < this.elCustomIcons.length; _i++) {
  12685. toolbarControls.push({
  12686. el: this.elCustomIcons[_i],
  12687. icon: this.t.customIcons[_i].icon,
  12688. title: this.t.customIcons[_i].title,
  12689. index: this.t.customIcons[_i].index,
  12690. class: 'apexcharts-toolbar-custom-icon ' + this.t.customIcons[_i].class
  12691. });
  12692. }
  12693. toolbarControls.forEach(function (t, index) {
  12694. if (t.index) {
  12695. Utils.moveIndexInArray(toolbarControls, index, t.index);
  12696. }
  12697. });
  12698. for (var _i2 = 0; _i2 < toolbarControls.length; _i2++) {
  12699. Graphics.setAttrs(toolbarControls[_i2].el, {
  12700. class: toolbarControls[_i2].class,
  12701. title: toolbarControls[_i2].title
  12702. });
  12703. toolbarControls[_i2].el.innerHTML = toolbarControls[_i2].icon;
  12704. elToolbarWrap.appendChild(toolbarControls[_i2].el);
  12705. }
  12706. this._createHamburgerMenu(elToolbarWrap);
  12707. if (w.globals.zoomEnabled) {
  12708. this.elZoom.classList.add(this.selectedClass);
  12709. } else if (w.globals.panEnabled) {
  12710. this.elPan.classList.add(this.selectedClass);
  12711. } else if (w.globals.selectionEnabled) {
  12712. this.elSelection.classList.add(this.selectedClass);
  12713. }
  12714. this.addToolbarEventListeners();
  12715. }
  12716. }, {
  12717. key: "_createHamburgerMenu",
  12718. value: function _createHamburgerMenu(parent) {
  12719. this.elMenuItems = [];
  12720. parent.appendChild(this.elMenu);
  12721. Graphics.setAttrs(this.elMenu, {
  12722. class: 'apexcharts-menu'
  12723. });
  12724. var menuItems = [{
  12725. name: 'exportSVG',
  12726. title: this.localeValues.exportToSVG
  12727. }, {
  12728. name: 'exportPNG',
  12729. title: this.localeValues.exportToPNG
  12730. }, {
  12731. name: 'exportCSV',
  12732. title: this.localeValues.exportToCSV
  12733. }];
  12734. if (!this.w.globals.allSeriesHasEqualX) {
  12735. // if it is a multi series, and all series have variable x values, export CSV won't work
  12736. menuItems.splice(2, 1);
  12737. }
  12738. for (var i = 0; i < menuItems.length; i++) {
  12739. this.elMenuItems.push(document.createElement('div'));
  12740. this.elMenuItems[i].innerHTML = menuItems[i].title;
  12741. Graphics.setAttrs(this.elMenuItems[i], {
  12742. class: "apexcharts-menu-item ".concat(menuItems[i].name),
  12743. title: menuItems[i].title
  12744. });
  12745. this.elMenu.appendChild(this.elMenuItems[i]);
  12746. }
  12747. }
  12748. }, {
  12749. key: "addToolbarEventListeners",
  12750. value: function addToolbarEventListeners() {
  12751. var _this2 = this;
  12752. this.elZoomReset.addEventListener('click', this.handleZoomReset.bind(this));
  12753. this.elSelection.addEventListener('click', this.toggleZoomSelection.bind(this, 'selection'));
  12754. this.elZoom.addEventListener('click', this.toggleZoomSelection.bind(this, 'zoom'));
  12755. this.elZoomIn.addEventListener('click', this.handleZoomIn.bind(this));
  12756. this.elZoomOut.addEventListener('click', this.handleZoomOut.bind(this));
  12757. this.elPan.addEventListener('click', this.togglePanning.bind(this));
  12758. this.elMenuIcon.addEventListener('click', this.toggleMenu.bind(this));
  12759. this.elMenuItems.forEach(function (m) {
  12760. if (m.classList.contains('exportSVG')) {
  12761. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'svg'));
  12762. } else if (m.classList.contains('exportPNG')) {
  12763. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'png'));
  12764. } else if (m.classList.contains('exportCSV')) {
  12765. m.addEventListener('click', _this2.handleDownload.bind(_this2, 'csv'));
  12766. }
  12767. });
  12768. for (var i = 0; i < this.t.customIcons.length; i++) {
  12769. this.elCustomIcons[i].addEventListener('click', this.t.customIcons[i].click.bind(this, this.ctx, this.ctx.w));
  12770. }
  12771. }
  12772. }, {
  12773. key: "toggleZoomSelection",
  12774. value: function toggleZoomSelection(type) {
  12775. var charts = this.ctx.getSyncedCharts();
  12776. charts.forEach(function (ch) {
  12777. ch.ctx.toolbar.toggleOtherControls();
  12778. var el = type === 'selection' ? ch.ctx.toolbar.elSelection : ch.ctx.toolbar.elZoom;
  12779. var enabledType = type === 'selection' ? 'selectionEnabled' : 'zoomEnabled';
  12780. ch.w.globals[enabledType] = !ch.w.globals[enabledType];
  12781. if (!el.classList.contains(ch.ctx.toolbar.selectedClass)) {
  12782. el.classList.add(ch.ctx.toolbar.selectedClass);
  12783. } else {
  12784. el.classList.remove(ch.ctx.toolbar.selectedClass);
  12785. }
  12786. });
  12787. }
  12788. }, {
  12789. key: "getToolbarIconsReference",
  12790. value: function getToolbarIconsReference() {
  12791. var w = this.w;
  12792. if (!this.elZoom) {
  12793. this.elZoom = w.globals.dom.baseEl.querySelector('.apexcharts-zoom-icon');
  12794. }
  12795. if (!this.elPan) {
  12796. this.elPan = w.globals.dom.baseEl.querySelector('.apexcharts-pan-icon');
  12797. }
  12798. if (!this.elSelection) {
  12799. this.elSelection = w.globals.dom.baseEl.querySelector('.apexcharts-selection-icon');
  12800. }
  12801. }
  12802. }, {
  12803. key: "enableZoomPanFromToolbar",
  12804. value: function enableZoomPanFromToolbar(type) {
  12805. this.toggleOtherControls();
  12806. type === 'pan' ? this.w.globals.panEnabled = true : this.w.globals.zoomEnabled = true;
  12807. var el = type === 'pan' ? this.elPan : this.elZoom;
  12808. var el2 = type === 'pan' ? this.elZoom : this.elPan;
  12809. if (el) {
  12810. el.classList.add(this.selectedClass);
  12811. }
  12812. if (el2) {
  12813. el2.classList.remove(this.selectedClass);
  12814. }
  12815. }
  12816. }, {
  12817. key: "togglePanning",
  12818. value: function togglePanning() {
  12819. var charts = this.ctx.getSyncedCharts();
  12820. charts.forEach(function (ch) {
  12821. ch.ctx.toolbar.toggleOtherControls();
  12822. ch.w.globals.panEnabled = !ch.w.globals.panEnabled;
  12823. if (!ch.ctx.toolbar.elPan.classList.contains(ch.ctx.toolbar.selectedClass)) {
  12824. ch.ctx.toolbar.elPan.classList.add(ch.ctx.toolbar.selectedClass);
  12825. } else {
  12826. ch.ctx.toolbar.elPan.classList.remove(ch.ctx.toolbar.selectedClass);
  12827. }
  12828. });
  12829. }
  12830. }, {
  12831. key: "toggleOtherControls",
  12832. value: function toggleOtherControls() {
  12833. var _this3 = this;
  12834. var w = this.w;
  12835. w.globals.panEnabled = false;
  12836. w.globals.zoomEnabled = false;
  12837. w.globals.selectionEnabled = false;
  12838. this.getToolbarIconsReference();
  12839. var toggleEls = [this.elPan, this.elSelection, this.elZoom];
  12840. toggleEls.forEach(function (el) {
  12841. if (el) {
  12842. el.classList.remove(_this3.selectedClass);
  12843. }
  12844. });
  12845. }
  12846. }, {
  12847. key: "handleZoomIn",
  12848. value: function handleZoomIn() {
  12849. var w = this.w;
  12850. var centerX = (w.globals.minX + w.globals.maxX) / 2;
  12851. var newMinX = (w.globals.minX + centerX) / 2;
  12852. var newMaxX = (w.globals.maxX + centerX) / 2;
  12853. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  12854. if (!w.globals.disableZoomIn) {
  12855. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  12856. }
  12857. }
  12858. }, {
  12859. key: "handleZoomOut",
  12860. value: function handleZoomOut() {
  12861. var w = this.w; // avoid zooming out beyond 1000 which may result in NaN values being printed on x-axis
  12862. if (w.config.xaxis.type === 'datetime' && new Date(w.globals.minX).getUTCFullYear() < 1000) {
  12863. return;
  12864. }
  12865. var centerX = (w.globals.minX + w.globals.maxX) / 2;
  12866. var newMinX = w.globals.minX - (centerX - w.globals.minX);
  12867. var newMaxX = w.globals.maxX - (centerX - w.globals.maxX);
  12868. var newMinXMaxX = this._getNewMinXMaxX(newMinX, newMaxX);
  12869. if (!w.globals.disableZoomOut) {
  12870. this.zoomUpdateOptions(newMinXMaxX.minX, newMinXMaxX.maxX);
  12871. }
  12872. }
  12873. }, {
  12874. key: "_getNewMinXMaxX",
  12875. value: function _getNewMinXMaxX(newMinX, newMaxX) {
  12876. var shouldFloor = this.w.config.xaxis.convertedCatToNumeric;
  12877. return {
  12878. minX: shouldFloor ? Math.floor(newMinX) : newMinX,
  12879. maxX: shouldFloor ? Math.floor(newMaxX) : newMaxX
  12880. };
  12881. }
  12882. }, {
  12883. key: "zoomUpdateOptions",
  12884. value: function zoomUpdateOptions(newMinX, newMaxX) {
  12885. var w = this.w;
  12886. if (newMinX === undefined && newMaxX === undefined) {
  12887. this.handleZoomReset();
  12888. return;
  12889. }
  12890. if (w.config.xaxis.convertedCatToNumeric) {
  12891. // in category charts, avoid zooming out beyond min and max
  12892. if (newMinX < 1) {
  12893. newMinX = 1;
  12894. newMaxX = w.globals.dataPoints;
  12895. }
  12896. if (newMaxX - newMinX < 2) {
  12897. return;
  12898. }
  12899. }
  12900. var xaxis = {
  12901. min: newMinX,
  12902. max: newMaxX
  12903. };
  12904. var beforeZoomRange = this.getBeforeZoomRange(xaxis);
  12905. if (beforeZoomRange) {
  12906. xaxis = beforeZoomRange.xaxis;
  12907. }
  12908. var options = {
  12909. xaxis: xaxis
  12910. };
  12911. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  12912. if (w.config.chart.zoom.autoScaleYaxis) {
  12913. var scale = new Range(this.ctx);
  12914. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  12915. xaxis: xaxis
  12916. });
  12917. }
  12918. if (!w.config.chart.group) {
  12919. // if chart in a group, prevent yaxis update here
  12920. // fix issue #650
  12921. options.yaxis = yaxis;
  12922. }
  12923. this.w.globals.zoomed = true;
  12924. this.ctx.updateHelpers._updateOptions(options, false, this.w.config.chart.animations.dynamicAnimation.enabled);
  12925. this.zoomCallback(xaxis, yaxis);
  12926. }
  12927. }, {
  12928. key: "zoomCallback",
  12929. value: function zoomCallback(xaxis, yaxis) {
  12930. if (typeof this.ev.zoomed === 'function') {
  12931. this.ev.zoomed(this.ctx, {
  12932. xaxis: xaxis,
  12933. yaxis: yaxis
  12934. });
  12935. }
  12936. }
  12937. }, {
  12938. key: "getBeforeZoomRange",
  12939. value: function getBeforeZoomRange(xaxis, yaxis) {
  12940. var newRange = null;
  12941. if (typeof this.ev.beforeZoom === 'function') {
  12942. newRange = this.ev.beforeZoom(this, {
  12943. xaxis: xaxis,
  12944. yaxis: yaxis
  12945. });
  12946. }
  12947. return newRange;
  12948. }
  12949. }, {
  12950. key: "toggleMenu",
  12951. value: function toggleMenu() {
  12952. var _this4 = this;
  12953. window.setTimeout(function () {
  12954. if (_this4.elMenu.classList.contains('apexcharts-menu-open')) {
  12955. _this4.elMenu.classList.remove('apexcharts-menu-open');
  12956. } else {
  12957. _this4.elMenu.classList.add('apexcharts-menu-open');
  12958. }
  12959. }, 0);
  12960. }
  12961. }, {
  12962. key: "handleDownload",
  12963. value: function handleDownload(type) {
  12964. var w = this.w;
  12965. var exprt = new Exports(this.ctx);
  12966. switch (type) {
  12967. case 'svg':
  12968. exprt.exportToSVG(this.ctx);
  12969. break;
  12970. case 'png':
  12971. exprt.exportToPng(this.ctx);
  12972. break;
  12973. case 'csv':
  12974. exprt.exportToCSV({
  12975. series: w.config.series
  12976. });
  12977. break;
  12978. }
  12979. }
  12980. }, {
  12981. key: "handleZoomReset",
  12982. value: function handleZoomReset(e) {
  12983. var charts = this.ctx.getSyncedCharts();
  12984. charts.forEach(function (ch) {
  12985. var w = ch.w; // forget lastXAxis min/max as reset button isn't resetting the x-axis completely if zoomX is called before
  12986. w.globals.lastXAxis.min = undefined;
  12987. w.globals.lastXAxis.max = undefined;
  12988. ch.updateHelpers.revertDefaultAxisMinMax();
  12989. if (typeof w.config.chart.events.zoomed === 'function') {
  12990. ch.ctx.toolbar.zoomCallback({
  12991. min: w.config.xaxis.min,
  12992. max: w.config.xaxis.max
  12993. });
  12994. }
  12995. w.globals.zoomed = false; // if user has some series collapsed before hitting zoom reset button,
  12996. // those series should stay collapsed
  12997. var series = ch.ctx.series.emptyCollapsedSeries(Utils.clone(w.globals.initialSeries));
  12998. ch.updateHelpers._updateSeries(series, w.config.chart.animations.dynamicAnimation.enabled);
  12999. });
  13000. }
  13001. }, {
  13002. key: "destroy",
  13003. value: function destroy() {
  13004. this.elZoom = null;
  13005. this.elZoomIn = null;
  13006. this.elZoomOut = null;
  13007. this.elPan = null;
  13008. this.elSelection = null;
  13009. this.elZoomReset = null;
  13010. this.elMenuIcon = null;
  13011. }
  13012. }]);
  13013. return Toolbar;
  13014. }();
  13015. /**
  13016. * ApexCharts Zoom Class for handling zooming and panning on axes based charts.
  13017. *
  13018. * @module ZoomPanSelection
  13019. **/
  13020. var ZoomPanSelection = /*#__PURE__*/function (_Toolbar) {
  13021. _inherits(ZoomPanSelection, _Toolbar);
  13022. function ZoomPanSelection(ctx) {
  13023. var _this;
  13024. _classCallCheck(this, ZoomPanSelection);
  13025. _this = _possibleConstructorReturn(this, _getPrototypeOf(ZoomPanSelection).call(this, ctx));
  13026. _this.ctx = ctx;
  13027. _this.w = ctx.w;
  13028. _this.dragged = false;
  13029. _this.graphics = new Graphics(_this.ctx);
  13030. _this.eventList = ['mousedown', 'mouseleave', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
  13031. _this.clientX = 0;
  13032. _this.clientY = 0;
  13033. _this.startX = 0;
  13034. _this.endX = 0;
  13035. _this.dragX = 0;
  13036. _this.startY = 0;
  13037. _this.endY = 0;
  13038. _this.dragY = 0;
  13039. _this.moveDirection = 'none';
  13040. return _this;
  13041. }
  13042. _createClass(ZoomPanSelection, [{
  13043. key: "init",
  13044. value: function init(_ref) {
  13045. var _this2 = this;
  13046. var xyRatios = _ref.xyRatios;
  13047. var w = this.w;
  13048. var me = this;
  13049. this.xyRatios = xyRatios;
  13050. this.zoomRect = this.graphics.drawRect(0, 0, 0, 0);
  13051. this.selectionRect = this.graphics.drawRect(0, 0, 0, 0);
  13052. this.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  13053. this.zoomRect.node.classList.add('apexcharts-zoom-rect');
  13054. this.selectionRect.node.classList.add('apexcharts-selection-rect');
  13055. w.globals.dom.elGraphical.add(this.zoomRect);
  13056. w.globals.dom.elGraphical.add(this.selectionRect);
  13057. if (w.config.chart.selection.type === 'x') {
  13058. this.slDraggableRect = this.selectionRect.draggable({
  13059. minX: 0,
  13060. minY: 0,
  13061. maxX: w.globals.gridWidth,
  13062. maxY: w.globals.gridHeight
  13063. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13064. } else if (w.config.chart.selection.type === 'y') {
  13065. this.slDraggableRect = this.selectionRect.draggable({
  13066. minX: 0,
  13067. maxX: w.globals.gridWidth
  13068. }).on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13069. } else {
  13070. this.slDraggableRect = this.selectionRect.draggable().on('dragmove', this.selectionDragging.bind(this, 'dragging'));
  13071. }
  13072. this.preselectedSelection();
  13073. this.hoverArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass);
  13074. this.hoverArea.classList.add('apexcharts-zoomable');
  13075. this.eventList.forEach(function (event) {
  13076. _this2.hoverArea.addEventListener(event, me.svgMouseEvents.bind(me, xyRatios), {
  13077. capture: false,
  13078. passive: true
  13079. });
  13080. });
  13081. } // remove the event listeners which were previously added on hover area
  13082. }, {
  13083. key: "destroy",
  13084. value: function destroy() {
  13085. if (this.slDraggableRect) {
  13086. this.slDraggableRect.draggable(false);
  13087. this.slDraggableRect.off();
  13088. this.selectionRect.off();
  13089. }
  13090. this.selectionRect = null;
  13091. this.zoomRect = null;
  13092. this.gridRect = null;
  13093. }
  13094. }, {
  13095. key: "svgMouseEvents",
  13096. value: function svgMouseEvents(xyRatios, e) {
  13097. var w = this.w;
  13098. var me = this;
  13099. var toolbar = this.ctx.toolbar;
  13100. var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type;
  13101. if (e.shiftKey) {
  13102. this.shiftWasPressed = true;
  13103. toolbar.enableZoomPanFromToolbar('pan');
  13104. } else {
  13105. if (this.shiftWasPressed) {
  13106. toolbar.enableZoomPanFromToolbar('zoom');
  13107. this.shiftWasPressed = false;
  13108. }
  13109. }
  13110. var falsePositives = e.target.classList.contains('apexcharts-selection-rect') || e.target.parentNode.classList.contains('apexcharts-toolbar');
  13111. if (falsePositives) return;
  13112. me.clientX = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientX : e.type === 'touchend' ? e.changedTouches[0].clientX : e.clientX;
  13113. me.clientY = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientY : e.type === 'touchend' ? e.changedTouches[0].clientY : e.clientY;
  13114. if (e.type === 'mousedown' && e.which === 1) {
  13115. var gridRectDim = me.gridRect.getBoundingClientRect();
  13116. me.startX = me.clientX - gridRectDim.left;
  13117. me.startY = me.clientY - gridRectDim.top;
  13118. me.dragged = false;
  13119. me.w.globals.mousedown = true;
  13120. }
  13121. if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') {
  13122. me.dragged = true;
  13123. if (w.globals.panEnabled) {
  13124. w.globals.selection = null;
  13125. if (me.w.globals.mousedown) {
  13126. me.panDragging({
  13127. context: me,
  13128. zoomtype: zoomtype,
  13129. xyRatios: xyRatios
  13130. });
  13131. }
  13132. } else {
  13133. if (me.w.globals.mousedown && w.globals.zoomEnabled || me.w.globals.mousedown && w.globals.selectionEnabled) {
  13134. me.selection = me.selectionDrawing({
  13135. context: me,
  13136. zoomtype: zoomtype
  13137. });
  13138. }
  13139. }
  13140. }
  13141. if (e.type === 'mouseup' || e.type === 'touchend' || e.type === 'mouseleave') {
  13142. // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup
  13143. var _gridRectDim = me.gridRect.getBoundingClientRect();
  13144. if (me.w.globals.mousedown) {
  13145. // user released the drag, now do all the calculations
  13146. me.endX = me.clientX - _gridRectDim.left;
  13147. me.endY = me.clientY - _gridRectDim.top;
  13148. me.dragX = Math.abs(me.endX - me.startX);
  13149. me.dragY = Math.abs(me.endY - me.startY);
  13150. if (w.globals.zoomEnabled || w.globals.selectionEnabled) {
  13151. me.selectionDrawn({
  13152. context: me,
  13153. zoomtype: zoomtype
  13154. });
  13155. }
  13156. if (w.globals.panEnabled && w.config.xaxis.convertedCatToNumeric) {
  13157. me.delayedPanScrolled();
  13158. }
  13159. }
  13160. if (w.globals.zoomEnabled) {
  13161. me.hideSelectionRect(this.selectionRect);
  13162. }
  13163. me.dragged = false;
  13164. me.w.globals.mousedown = false;
  13165. }
  13166. this.makeSelectionRectDraggable();
  13167. }
  13168. }, {
  13169. key: "makeSelectionRectDraggable",
  13170. value: function makeSelectionRectDraggable() {
  13171. var w = this.w;
  13172. if (!this.selectionRect) return;
  13173. var rectDim = this.selectionRect.node.getBoundingClientRect();
  13174. if (rectDim.width > 0 && rectDim.height > 0) {
  13175. this.slDraggableRect.selectize({
  13176. points: 'l, r',
  13177. pointSize: 8,
  13178. pointType: 'rect'
  13179. }).resize({
  13180. constraint: {
  13181. minX: 0,
  13182. minY: 0,
  13183. maxX: w.globals.gridWidth,
  13184. maxY: w.globals.gridHeight
  13185. }
  13186. }).on('resizing', this.selectionDragging.bind(this, 'resizing'));
  13187. }
  13188. }
  13189. }, {
  13190. key: "preselectedSelection",
  13191. value: function preselectedSelection() {
  13192. var w = this.w;
  13193. var xyRatios = this.xyRatios;
  13194. if (!w.globals.zoomEnabled) {
  13195. if (typeof w.globals.selection !== 'undefined' && w.globals.selection !== null) {
  13196. this.drawSelectionRect(w.globals.selection);
  13197. } else {
  13198. if (w.config.chart.selection.xaxis.min !== undefined && w.config.chart.selection.xaxis.max !== undefined) {
  13199. var x = (w.config.chart.selection.xaxis.min - w.globals.minX) / xyRatios.xRatio;
  13200. var width = w.globals.gridWidth - (w.globals.maxX - w.config.chart.selection.xaxis.max) / xyRatios.xRatio - x;
  13201. var selectionRect = {
  13202. x: x,
  13203. y: 0,
  13204. width: width,
  13205. height: w.globals.gridHeight,
  13206. translateX: 0,
  13207. translateY: 0,
  13208. selectionEnabled: true
  13209. };
  13210. this.drawSelectionRect(selectionRect);
  13211. this.makeSelectionRectDraggable();
  13212. if (typeof w.config.chart.events.selection === 'function') {
  13213. w.config.chart.events.selection(this.ctx, {
  13214. xaxis: {
  13215. min: w.config.chart.selection.xaxis.min,
  13216. max: w.config.chart.selection.xaxis.max
  13217. },
  13218. yaxis: {}
  13219. });
  13220. }
  13221. }
  13222. }
  13223. }
  13224. }
  13225. }, {
  13226. key: "drawSelectionRect",
  13227. value: function drawSelectionRect(_ref2) {
  13228. var x = _ref2.x,
  13229. y = _ref2.y,
  13230. width = _ref2.width,
  13231. height = _ref2.height,
  13232. _ref2$translateX = _ref2.translateX,
  13233. translateX = _ref2$translateX === void 0 ? 0 : _ref2$translateX,
  13234. _ref2$translateY = _ref2.translateY,
  13235. translateY = _ref2$translateY === void 0 ? 0 : _ref2$translateY;
  13236. var w = this.w;
  13237. var zoomRect = this.zoomRect;
  13238. var selectionRect = this.selectionRect;
  13239. if (this.dragged || w.globals.selection !== null) {
  13240. var scalingAttrs = {
  13241. transform: 'translate(' + translateX + ', ' + translateY + ')'
  13242. }; // change styles based on zoom or selection
  13243. // zoom is Enabled and user has dragged, so draw blue rect
  13244. if (w.globals.zoomEnabled && this.dragged) {
  13245. if (width < 0) width = 1; // fixes apexcharts.js#1168
  13246. zoomRect.attr({
  13247. x: x,
  13248. y: y,
  13249. width: width,
  13250. height: height,
  13251. fill: w.config.chart.zoom.zoomedArea.fill.color,
  13252. 'fill-opacity': w.config.chart.zoom.zoomedArea.fill.opacity,
  13253. stroke: w.config.chart.zoom.zoomedArea.stroke.color,
  13254. 'stroke-width': w.config.chart.zoom.zoomedArea.stroke.width,
  13255. 'stroke-opacity': w.config.chart.zoom.zoomedArea.stroke.opacity
  13256. });
  13257. Graphics.setAttrs(zoomRect.node, scalingAttrs);
  13258. } // selection is enabled
  13259. if (w.globals.selectionEnabled) {
  13260. selectionRect.attr({
  13261. x: x,
  13262. y: y,
  13263. width: width > 0 ? width : 0,
  13264. height: height > 0 ? height : 0,
  13265. fill: w.config.chart.selection.fill.color,
  13266. 'fill-opacity': w.config.chart.selection.fill.opacity,
  13267. stroke: w.config.chart.selection.stroke.color,
  13268. 'stroke-width': w.config.chart.selection.stroke.width,
  13269. 'stroke-dasharray': w.config.chart.selection.stroke.dashArray,
  13270. 'stroke-opacity': w.config.chart.selection.stroke.opacity
  13271. });
  13272. Graphics.setAttrs(selectionRect.node, scalingAttrs);
  13273. }
  13274. }
  13275. }
  13276. }, {
  13277. key: "hideSelectionRect",
  13278. value: function hideSelectionRect(rect) {
  13279. if (rect) {
  13280. rect.attr({
  13281. x: 0,
  13282. y: 0,
  13283. width: 0,
  13284. height: 0
  13285. });
  13286. }
  13287. }
  13288. }, {
  13289. key: "selectionDrawing",
  13290. value: function selectionDrawing(_ref3) {
  13291. var context = _ref3.context,
  13292. zoomtype = _ref3.zoomtype;
  13293. var w = this.w;
  13294. var me = context;
  13295. var gridRectDim = this.gridRect.getBoundingClientRect();
  13296. var startX = me.startX - 1;
  13297. var startY = me.startY;
  13298. var selectionWidth = me.clientX - gridRectDim.left - startX;
  13299. var selectionHeight = me.clientY - gridRectDim.top - startY;
  13300. var translateX = 0;
  13301. var translateY = 0;
  13302. var selectionRect = {};
  13303. if (Math.abs(selectionWidth + startX) > w.globals.gridWidth) {
  13304. // user dragged the mouse outside drawing area to the right
  13305. selectionWidth = w.globals.gridWidth - startX;
  13306. } else if (me.clientX - gridRectDim.left < 0) {
  13307. // user dragged the mouse outside drawing area to the left
  13308. selectionWidth = startX;
  13309. } // inverse selection X
  13310. if (startX > me.clientX - gridRectDim.left) {
  13311. selectionWidth = Math.abs(selectionWidth);
  13312. translateX = -selectionWidth;
  13313. } // inverse selection Y
  13314. if (startY > me.clientY - gridRectDim.top) {
  13315. selectionHeight = Math.abs(selectionHeight);
  13316. translateY = -selectionHeight;
  13317. }
  13318. if (zoomtype === 'x') {
  13319. selectionRect = {
  13320. x: startX,
  13321. y: 0,
  13322. width: selectionWidth,
  13323. height: w.globals.gridHeight,
  13324. translateX: translateX,
  13325. translateY: 0
  13326. };
  13327. } else if (zoomtype === 'y') {
  13328. selectionRect = {
  13329. x: 0,
  13330. y: startY,
  13331. width: w.globals.gridWidth,
  13332. height: selectionHeight,
  13333. translateX: 0,
  13334. translateY: translateY
  13335. };
  13336. } else {
  13337. selectionRect = {
  13338. x: startX,
  13339. y: startY,
  13340. width: selectionWidth,
  13341. height: selectionHeight,
  13342. translateX: translateX,
  13343. translateY: translateY
  13344. };
  13345. }
  13346. me.drawSelectionRect(selectionRect);
  13347. me.selectionDragging('resizing');
  13348. return selectionRect;
  13349. }
  13350. }, {
  13351. key: "selectionDragging",
  13352. value: function selectionDragging(type, e) {
  13353. var _this3 = this;
  13354. var w = this.w;
  13355. var xyRatios = this.xyRatios;
  13356. var selRect = this.selectionRect;
  13357. var timerInterval = 0;
  13358. if (type === 'resizing') {
  13359. timerInterval = 30;
  13360. } // update selection when selection rect is dragged
  13361. var getSelAttr = function getSelAttr(attr) {
  13362. return parseFloat(selRect.node.getAttribute(attr));
  13363. };
  13364. var draggedProps = {
  13365. x: getSelAttr('x'),
  13366. y: getSelAttr('y'),
  13367. width: getSelAttr('width'),
  13368. height: getSelAttr('height')
  13369. };
  13370. w.globals.selection = draggedProps; // update selection ends
  13371. if (typeof w.config.chart.events.selection === 'function' && w.globals.selectionEnabled) {
  13372. // a small debouncer is required when resizing to avoid freezing the chart
  13373. clearTimeout(this.w.globals.selectionResizeTimer);
  13374. this.w.globals.selectionResizeTimer = window.setTimeout(function () {
  13375. var gridRectDim = _this3.gridRect.getBoundingClientRect();
  13376. var selectionRect = selRect.node.getBoundingClientRect();
  13377. var minX = w.globals.xAxisScale.niceMin + (selectionRect.left - gridRectDim.left) * xyRatios.xRatio;
  13378. var maxX = w.globals.xAxisScale.niceMin + (selectionRect.right - gridRectDim.left) * xyRatios.xRatio;
  13379. var minY = w.globals.yAxisScale[0].niceMin + (gridRectDim.bottom - selectionRect.bottom) * xyRatios.yRatio[0];
  13380. var maxY = w.globals.yAxisScale[0].niceMax - (selectionRect.top - gridRectDim.top) * xyRatios.yRatio[0];
  13381. w.config.chart.events.selection(_this3.ctx, {
  13382. xaxis: {
  13383. min: minX,
  13384. max: maxX
  13385. },
  13386. yaxis: {
  13387. min: minY,
  13388. max: maxY
  13389. }
  13390. });
  13391. }, timerInterval);
  13392. }
  13393. }
  13394. }, {
  13395. key: "selectionDrawn",
  13396. value: function selectionDrawn(_ref4) {
  13397. var context = _ref4.context,
  13398. zoomtype = _ref4.zoomtype;
  13399. var w = this.w;
  13400. var me = context;
  13401. var xyRatios = this.xyRatios;
  13402. var toolbar = this.ctx.toolbar;
  13403. if (me.startX > me.endX) {
  13404. var tempX = me.startX;
  13405. me.startX = me.endX;
  13406. me.endX = tempX;
  13407. }
  13408. if (me.startY > me.endY) {
  13409. var tempY = me.startY;
  13410. me.startY = me.endY;
  13411. me.endY = tempY;
  13412. }
  13413. var xLowestValue = w.globals.xAxisScale.niceMin + me.startX * xyRatios.xRatio;
  13414. var xHighestValue = w.globals.xAxisScale.niceMin + me.endX * xyRatios.xRatio; // TODO: we will consider the 1st y axis values here for getting highest and lowest y
  13415. var yHighestValue = [];
  13416. var yLowestValue = [];
  13417. w.config.yaxis.forEach(function (yaxe, index) {
  13418. yHighestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.startY);
  13419. yLowestValue.push(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.endY);
  13420. });
  13421. if (me.dragged && (me.dragX > 10 || me.dragY > 10) && xLowestValue !== xHighestValue) {
  13422. if (w.globals.zoomEnabled) {
  13423. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  13424. var xaxis = Utils.clone(w.globals.initialConfig.xaxis);
  13425. w.globals.zoomed = true; // before zooming in/out, store the last yaxis and xaxis range, so that when user hits the RESET button, we get the original range
  13426. // also - make sure user is not already zoomed in/out - otherwise we will store zoomed values in lastAxis
  13427. // DEAD code - the below condition will never run now as zoomed is made false above
  13428. if (!w.globals.zoomed) {
  13429. w.globals.lastXAxis = Utils.clone(w.config.xaxis);
  13430. w.globals.lastYAxis = Utils.clone(w.config.yaxis);
  13431. }
  13432. if (w.config.xaxis.convertedCatToNumeric) {
  13433. xLowestValue = Math.floor(xLowestValue);
  13434. xHighestValue = Math.floor(xHighestValue);
  13435. if (xLowestValue < 1) {
  13436. xLowestValue = 1;
  13437. xHighestValue = w.globals.dataPoints;
  13438. }
  13439. if (xHighestValue - xLowestValue < 2) {
  13440. xHighestValue = xLowestValue + 1;
  13441. }
  13442. }
  13443. if (zoomtype === 'xy' || zoomtype === 'x') {
  13444. xaxis = {
  13445. min: xLowestValue,
  13446. max: xHighestValue
  13447. };
  13448. }
  13449. if (zoomtype === 'xy' || zoomtype === 'y') {
  13450. yaxis.forEach(function (yaxe, index) {
  13451. yaxis[index].min = yLowestValue[index];
  13452. yaxis[index].max = yHighestValue[index];
  13453. });
  13454. }
  13455. if (w.config.chart.zoom.autoScaleYaxis) {
  13456. var scale = new Range(me.ctx);
  13457. yaxis = scale.autoScaleY(me.ctx, yaxis, {
  13458. xaxis: xaxis
  13459. });
  13460. }
  13461. if (toolbar) {
  13462. var beforeZoomRange = toolbar.getBeforeZoomRange(xaxis, yaxis);
  13463. if (beforeZoomRange) {
  13464. xaxis = beforeZoomRange.xaxis ? beforeZoomRange.xaxis : xaxis;
  13465. yaxis = beforeZoomRange.yaxis ? beforeZoomRange.yaxe : yaxis;
  13466. }
  13467. }
  13468. var options = {
  13469. xaxis: xaxis
  13470. };
  13471. if (!w.config.chart.group) {
  13472. // if chart in a group, prevent yaxis update here
  13473. // fix issue #650
  13474. options.yaxis = yaxis;
  13475. }
  13476. me.ctx.updateHelpers._updateOptions(options, false, me.w.config.chart.animations.dynamicAnimation.enabled);
  13477. if (typeof w.config.chart.events.zoomed === 'function') {
  13478. toolbar.zoomCallback(xaxis, yaxis);
  13479. }
  13480. } else if (w.globals.selectionEnabled) {
  13481. var _yaxis = null;
  13482. var _xaxis = null;
  13483. _xaxis = {
  13484. min: xLowestValue,
  13485. max: xHighestValue
  13486. };
  13487. if (zoomtype === 'xy' || zoomtype === 'y') {
  13488. _yaxis = Utils.clone(w.config.yaxis);
  13489. _yaxis.forEach(function (yaxe, index) {
  13490. _yaxis[index].min = yLowestValue[index];
  13491. _yaxis[index].max = yHighestValue[index];
  13492. });
  13493. }
  13494. w.globals.selection = me.selection;
  13495. if (typeof w.config.chart.events.selection === 'function') {
  13496. w.config.chart.events.selection(me.ctx, {
  13497. xaxis: _xaxis,
  13498. yaxis: _yaxis
  13499. });
  13500. }
  13501. }
  13502. }
  13503. }
  13504. }, {
  13505. key: "panDragging",
  13506. value: function panDragging(_ref5) {
  13507. var context = _ref5.context;
  13508. var w = this.w;
  13509. var me = context; // check to make sure there is data to compare against
  13510. if (typeof w.globals.lastClientPosition.x !== 'undefined') {
  13511. // get the change from last position to this position
  13512. var deltaX = w.globals.lastClientPosition.x - me.clientX;
  13513. 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
  13514. if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) {
  13515. this.moveDirection = 'left';
  13516. } else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) {
  13517. this.moveDirection = 'right';
  13518. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
  13519. this.moveDirection = 'up';
  13520. } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) {
  13521. this.moveDirection = 'down';
  13522. }
  13523. } // set the new last position to the current for next time (to get the position of drag)
  13524. w.globals.lastClientPosition = {
  13525. x: me.clientX,
  13526. y: me.clientY
  13527. };
  13528. var xLowestValue = w.globals.minX;
  13529. var xHighestValue = w.globals.maxX; // on a category, we don't pan continuosly as it causes bugs
  13530. if (!w.config.xaxis.convertedCatToNumeric) {
  13531. me.panScrolled(xLowestValue, xHighestValue);
  13532. }
  13533. }
  13534. }, {
  13535. key: "delayedPanScrolled",
  13536. value: function delayedPanScrolled() {
  13537. var w = this.w;
  13538. var newMinX = w.globals.minX;
  13539. var newMaxX = w.globals.maxX;
  13540. var centerX = (w.globals.maxX - w.globals.minX) / 2;
  13541. if (this.moveDirection === 'left') {
  13542. newMinX = w.globals.minX + centerX;
  13543. newMaxX = w.globals.maxX + centerX;
  13544. } else if (this.moveDirection === 'right') {
  13545. newMinX = w.globals.minX - centerX;
  13546. newMaxX = w.globals.maxX - centerX;
  13547. }
  13548. newMinX = Math.floor(newMinX);
  13549. newMaxX = Math.floor(newMaxX);
  13550. this.updateScrolledChart({
  13551. xaxis: {
  13552. min: newMinX,
  13553. max: newMaxX
  13554. }
  13555. }, newMinX, newMaxX);
  13556. }
  13557. }, {
  13558. key: "panScrolled",
  13559. value: function panScrolled(xLowestValue, xHighestValue) {
  13560. var w = this.w;
  13561. var xyRatios = this.xyRatios;
  13562. var yaxis = Utils.clone(w.globals.initialConfig.yaxis);
  13563. if (this.moveDirection === 'left') {
  13564. xLowestValue = w.globals.minX + w.globals.gridWidth / 15 * xyRatios.xRatio;
  13565. xHighestValue = w.globals.maxX + w.globals.gridWidth / 15 * xyRatios.xRatio;
  13566. } else if (this.moveDirection === 'right') {
  13567. xLowestValue = w.globals.minX - w.globals.gridWidth / 15 * xyRatios.xRatio;
  13568. xHighestValue = w.globals.maxX - w.globals.gridWidth / 15 * xyRatios.xRatio;
  13569. }
  13570. if (xLowestValue < w.globals.initialMinX || xHighestValue > w.globals.initialMaxX) {
  13571. xLowestValue = w.globals.minX;
  13572. xHighestValue = w.globals.maxX;
  13573. }
  13574. var xaxis = {
  13575. min: xLowestValue,
  13576. max: xHighestValue
  13577. };
  13578. if (w.config.chart.zoom.autoScaleYaxis) {
  13579. var scale = new Range(this.ctx);
  13580. yaxis = scale.autoScaleY(this.ctx, yaxis, {
  13581. xaxis: xaxis
  13582. });
  13583. }
  13584. var options = {
  13585. xaxis: {
  13586. min: xLowestValue,
  13587. max: xHighestValue
  13588. }
  13589. };
  13590. if (!w.config.chart.group) {
  13591. // if chart in a group, prevent yaxis update here
  13592. // fix issue #650
  13593. options.yaxis = yaxis;
  13594. }
  13595. this.updateScrolledChart(options, xLowestValue, xHighestValue);
  13596. }
  13597. }, {
  13598. key: "updateScrolledChart",
  13599. value: function updateScrolledChart(options, xLowestValue, xHighestValue) {
  13600. var w = this.w;
  13601. this.ctx.updateHelpers._updateOptions(options, false, false);
  13602. if (typeof w.config.chart.events.scrolled === 'function') {
  13603. w.config.chart.events.scrolled(this.ctx, {
  13604. xaxis: {
  13605. min: xLowestValue,
  13606. max: xHighestValue
  13607. }
  13608. });
  13609. }
  13610. }
  13611. }]);
  13612. return ZoomPanSelection;
  13613. }(Toolbar);
  13614. var Utils$1 = /*#__PURE__*/function () {
  13615. function Utils$1(tooltipContext) {
  13616. _classCallCheck(this, Utils$1);
  13617. this.w = tooltipContext.w;
  13618. this.ttCtx = tooltipContext;
  13619. this.ctx = tooltipContext.ctx;
  13620. }
  13621. /**
  13622. ** When hovering over series, you need to capture which series is being hovered on.
  13623. ** This function will return both capturedseries index as well as inner index of that series
  13624. * @memberof Utils
  13625. * @param {object}
  13626. * - hoverArea = the rect on which user hovers
  13627. * - elGrid = dimensions of the hover rect (it can be different than hoverarea)
  13628. */
  13629. _createClass(Utils$1, [{
  13630. key: "getNearestValues",
  13631. value: function getNearestValues(_ref) {
  13632. var hoverArea = _ref.hoverArea,
  13633. elGrid = _ref.elGrid,
  13634. clientX = _ref.clientX,
  13635. clientY = _ref.clientY;
  13636. var w = this.w;
  13637. var hoverWidth = w.globals.gridWidth;
  13638. var xDivisor = hoverWidth / (w.globals.dataPoints - 1);
  13639. var seriesBound = elGrid.getBoundingClientRect();
  13640. var hasBars = this.hasBars();
  13641. if (w.globals.comboCharts || hasBars) {
  13642. xDivisor = hoverWidth / w.globals.dataPoints;
  13643. }
  13644. var hoverX = clientX - seriesBound.left;
  13645. var hoverY = clientY - seriesBound.top;
  13646. var notInRect = hoverX < 0 || hoverY < 0 || hoverX > w.globals.gridWidth || hoverY > w.globals.gridHeight;
  13647. if (notInRect) {
  13648. hoverArea.classList.remove('hovering-zoom');
  13649. hoverArea.classList.remove('hovering-pan');
  13650. } else {
  13651. if (w.globals.zoomEnabled) {
  13652. hoverArea.classList.remove('hovering-pan');
  13653. hoverArea.classList.add('hovering-zoom');
  13654. } else if (w.globals.panEnabled) {
  13655. hoverArea.classList.remove('hovering-zoom');
  13656. hoverArea.classList.add('hovering-pan');
  13657. }
  13658. }
  13659. var j = Math.round(hoverX / xDivisor);
  13660. if (hasBars) {
  13661. j = Math.ceil(hoverX / xDivisor);
  13662. j = j - 1;
  13663. }
  13664. var capturedSeries = null;
  13665. var closest = null;
  13666. var seriesXValArr = [];
  13667. var seriesYValArr = [];
  13668. for (var s = 0; s < w.globals.seriesXvalues.length; s++) {
  13669. seriesXValArr.push([w.globals.seriesXvalues[s][0] - 0.000001].concat(w.globals.seriesXvalues[s]));
  13670. }
  13671. seriesXValArr = seriesXValArr.map(function (seriesXVal) {
  13672. return seriesXVal.filter(function (s) {
  13673. return s;
  13674. });
  13675. });
  13676. seriesYValArr = w.globals.seriesYvalues.map(function (seriesYVal) {
  13677. return seriesYVal.filter(function (s) {
  13678. return Utils.isNumber(s);
  13679. });
  13680. }); // 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
  13681. if (w.globals.isXNumeric) {
  13682. closest = this.closestInMultiArray(hoverX, hoverY, seriesXValArr, seriesYValArr);
  13683. capturedSeries = closest.index;
  13684. j = closest.j;
  13685. if (capturedSeries !== null) {
  13686. // initial push, it should be a little smaller than the 1st val
  13687. seriesXValArr = w.globals.seriesXvalues[capturedSeries];
  13688. closest = this.closestInArray(hoverX, seriesXValArr);
  13689. j = closest.index;
  13690. }
  13691. }
  13692. w.globals.capturedSeriesIndex = capturedSeries === null ? -1 : capturedSeries;
  13693. if (!j || j < 1) j = 0;
  13694. w.globals.capturedDataPointIndex = j;
  13695. return {
  13696. capturedSeries: capturedSeries,
  13697. j: j,
  13698. hoverX: hoverX,
  13699. hoverY: hoverY
  13700. };
  13701. }
  13702. }, {
  13703. key: "closestInMultiArray",
  13704. value: function closestInMultiArray(hoverX, hoverY, Xarrays, Yarrays) {
  13705. var w = this.w;
  13706. var activeIndex = 0;
  13707. var currIndex = null;
  13708. var j = -1;
  13709. if (w.globals.series.length > 1) {
  13710. activeIndex = this.getFirstActiveXArray(Xarrays);
  13711. } else {
  13712. currIndex = 0;
  13713. }
  13714. var currY = Yarrays[activeIndex][0];
  13715. var currX = Xarrays[activeIndex][0];
  13716. var diffX = Math.abs(hoverX - currX);
  13717. var diffY = Math.abs(hoverY - currY);
  13718. var diff = diffY + diffX;
  13719. Yarrays.map(function (arrY, arrIndex) {
  13720. arrY.map(function (y, innerKey) {
  13721. var newdiffY = Math.abs(hoverY - Yarrays[arrIndex][innerKey]);
  13722. var newdiffX = Math.abs(hoverX - Xarrays[arrIndex][innerKey]);
  13723. var newdiff = newdiffX + newdiffY;
  13724. if (newdiff < diff) {
  13725. diff = newdiff;
  13726. diffX = newdiffX;
  13727. diffY = newdiffY;
  13728. currIndex = arrIndex;
  13729. j = innerKey;
  13730. }
  13731. });
  13732. });
  13733. return {
  13734. index: currIndex,
  13735. j: j
  13736. };
  13737. }
  13738. }, {
  13739. key: "getFirstActiveXArray",
  13740. value: function getFirstActiveXArray(Xarrays) {
  13741. var activeIndex = 0;
  13742. var coreUtils = new CoreUtils(this.ctx);
  13743. var firstActiveSeriesIndex = Xarrays.map(function (xarr, index) {
  13744. return xarr.length > 0 ? index : -1;
  13745. });
  13746. for (var a = 0; a < firstActiveSeriesIndex.length; a++) {
  13747. var total = coreUtils.getSeriesTotalByIndex(a);
  13748. if (firstActiveSeriesIndex[a] !== -1 && total !== 0 && !coreUtils.seriesHaveSameValues(a)) {
  13749. activeIndex = firstActiveSeriesIndex[a];
  13750. break;
  13751. }
  13752. }
  13753. return activeIndex;
  13754. }
  13755. }, {
  13756. key: "closestInArray",
  13757. value: function closestInArray(val, arr) {
  13758. var curr = arr[0];
  13759. var currIndex = null;
  13760. var diff = Math.abs(val - curr);
  13761. for (var i = 0; i < arr.length; i++) {
  13762. var newdiff = Math.abs(val - arr[i]);
  13763. if (newdiff < diff) {
  13764. diff = newdiff;
  13765. currIndex = i;
  13766. }
  13767. }
  13768. return {
  13769. index: currIndex
  13770. };
  13771. }
  13772. /**
  13773. * When there are multiple series, it is possible to have different x values for each series.
  13774. * But it may be possible in those multiple series, that there is same x value for 2 or more
  13775. * series.
  13776. * @memberof Utils
  13777. * @param {int}
  13778. * - j = is the inner index of series -> (series[i][j])
  13779. * @return {bool}
  13780. */
  13781. }, {
  13782. key: "isXoverlap",
  13783. value: function isXoverlap(j) {
  13784. var w = this.w;
  13785. var xSameForAllSeriesJArr = [];
  13786. var seriesX = w.globals.seriesX.filter(function (s) {
  13787. return typeof s[0] !== 'undefined';
  13788. });
  13789. if (seriesX.length > 0) {
  13790. for (var i = 0; i < seriesX.length - 1; i++) {
  13791. if (typeof seriesX[i][j] !== 'undefined' && typeof seriesX[i + 1][j] !== 'undefined') {
  13792. if (seriesX[i][j] !== seriesX[i + 1][j]) {
  13793. xSameForAllSeriesJArr.push('unEqual');
  13794. }
  13795. }
  13796. }
  13797. }
  13798. if (xSameForAllSeriesJArr.length === 0) {
  13799. return true;
  13800. }
  13801. return false;
  13802. }
  13803. }, {
  13804. key: "isInitialSeriesSameLen",
  13805. value: function isInitialSeriesSameLen() {
  13806. var sameLen = true;
  13807. var initialSeries = this.w.globals.initialSeries;
  13808. for (var i = 0; i < initialSeries.length - 1; i++) {
  13809. if (initialSeries[i].data.length !== initialSeries[i + 1].data.length) {
  13810. sameLen = false;
  13811. break;
  13812. }
  13813. }
  13814. return sameLen;
  13815. }
  13816. }, {
  13817. key: "getBarsHeight",
  13818. value: function getBarsHeight(allbars) {
  13819. var bars = _toConsumableArray(allbars);
  13820. var totalHeight = bars.reduce(function (acc, bar) {
  13821. return acc + bar.getBBox().height;
  13822. }, 0);
  13823. return totalHeight;
  13824. }
  13825. }, {
  13826. key: "getElMarkers",
  13827. value: function getElMarkers() {
  13828. return this.w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers');
  13829. }
  13830. }, {
  13831. key: "getAllMarkers",
  13832. value: function getAllMarkers() {
  13833. // first get all marker parents. This parent class contains series-index
  13834. // which helps to sort the markers as they are dynamic
  13835. var markersWraps = this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers-wrap');
  13836. markersWraps = _toConsumableArray(markersWraps);
  13837. markersWraps.sort(function (a, b) {
  13838. return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
  13839. });
  13840. var markers = [];
  13841. markersWraps.forEach(function (m) {
  13842. markers.push(m.querySelector('.apexcharts-marker'));
  13843. });
  13844. return markers;
  13845. }
  13846. }, {
  13847. key: "hasMarkers",
  13848. value: function hasMarkers() {
  13849. var markers = this.getElMarkers();
  13850. return markers.length > 0;
  13851. }
  13852. }, {
  13853. key: "getElBars",
  13854. value: function getElBars() {
  13855. return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-rangebar-series');
  13856. }
  13857. }, {
  13858. key: "hasBars",
  13859. value: function hasBars() {
  13860. var bars = this.getElBars();
  13861. return bars.length > 0;
  13862. }
  13863. }, {
  13864. key: "getHoverMarkerSize",
  13865. value: function getHoverMarkerSize(index) {
  13866. var w = this.w;
  13867. var hoverSize = w.config.markers.hover.size;
  13868. if (hoverSize === undefined) {
  13869. hoverSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  13870. }
  13871. return hoverSize;
  13872. }
  13873. }, {
  13874. key: "toggleAllTooltipSeriesGroups",
  13875. value: function toggleAllTooltipSeriesGroups(state) {
  13876. var w = this.w;
  13877. var ttCtx = this.ttCtx;
  13878. if (ttCtx.allTooltipSeriesGroups.length === 0) {
  13879. ttCtx.allTooltipSeriesGroups = w.globals.dom.baseEl.querySelectorAll('.apexcharts-tooltip-series-group');
  13880. }
  13881. var allTooltipSeriesGroups = ttCtx.allTooltipSeriesGroups;
  13882. for (var i = 0; i < allTooltipSeriesGroups.length; i++) {
  13883. if (state === 'enable') {
  13884. allTooltipSeriesGroups[i].classList.add('apexcharts-active');
  13885. allTooltipSeriesGroups[i].style.display = w.config.tooltip.items.display;
  13886. } else {
  13887. allTooltipSeriesGroups[i].classList.remove('apexcharts-active');
  13888. allTooltipSeriesGroups[i].style.display = 'none';
  13889. }
  13890. }
  13891. }
  13892. }]);
  13893. return Utils$1;
  13894. }();
  13895. /**
  13896. * ApexCharts Tooltip.Labels Class to draw texts on the tooltip.
  13897. *
  13898. * @module Tooltip.Labels
  13899. **/
  13900. var Labels = /*#__PURE__*/function () {
  13901. function Labels(tooltipContext) {
  13902. _classCallCheck(this, Labels);
  13903. this.w = tooltipContext.w;
  13904. this.ctx = tooltipContext.ctx;
  13905. this.ttCtx = tooltipContext;
  13906. this.tooltipUtil = new Utils$1(tooltipContext);
  13907. }
  13908. _createClass(Labels, [{
  13909. key: "drawSeriesTexts",
  13910. value: function drawSeriesTexts(_ref) {
  13911. var _ref$shared = _ref.shared,
  13912. shared = _ref$shared === void 0 ? true : _ref$shared,
  13913. ttItems = _ref.ttItems,
  13914. _ref$i = _ref.i,
  13915. i = _ref$i === void 0 ? 0 : _ref$i,
  13916. _ref$j = _ref.j,
  13917. j = _ref$j === void 0 ? null : _ref$j,
  13918. y1 = _ref.y1,
  13919. y2 = _ref.y2;
  13920. var w = this.w;
  13921. if (w.config.tooltip.custom !== undefined) {
  13922. this.handleCustomTooltip({
  13923. i: i,
  13924. j: j,
  13925. y1: y1,
  13926. y2: y2,
  13927. w: w
  13928. });
  13929. } else {
  13930. this.toggleActiveInactiveSeries(shared);
  13931. }
  13932. var values = this.getValuesToPrint({
  13933. i: i,
  13934. j: j
  13935. });
  13936. this.printLabels({
  13937. i: i,
  13938. j: j,
  13939. values: values,
  13940. ttItems: ttItems,
  13941. shared: shared
  13942. }); // Re-calculate tooltip dimensions now that we have drawn the text
  13943. var tooltipEl = this.ttCtx.getElTooltip();
  13944. this.ttCtx.tooltipRect.ttWidth = tooltipEl.getBoundingClientRect().width;
  13945. this.ttCtx.tooltipRect.ttHeight = tooltipEl.getBoundingClientRect().height;
  13946. }
  13947. }, {
  13948. key: "printLabels",
  13949. value: function printLabels(_ref2) {
  13950. var _this = this;
  13951. var i = _ref2.i,
  13952. j = _ref2.j,
  13953. values = _ref2.values,
  13954. ttItems = _ref2.ttItems,
  13955. shared = _ref2.shared;
  13956. var w = this.w;
  13957. var val;
  13958. var xVal = values.xVal,
  13959. zVal = values.zVal,
  13960. xAxisTTVal = values.xAxisTTVal;
  13961. var seriesName = '';
  13962. var pColor = w.globals.colors[i];
  13963. if (j !== null && w.config.plotOptions.bar.distributed) {
  13964. pColor = w.globals.colors[j];
  13965. }
  13966. var _loop = function _loop(t, inverset) {
  13967. var f = _this.getFormatters(i);
  13968. seriesName = _this.getSeriesName({
  13969. fn: f.yLbTitleFormatter,
  13970. index: i,
  13971. seriesIndex: i,
  13972. j: j
  13973. });
  13974. var tIndex = w.config.tooltip.inverseOrder ? inverset : t;
  13975. if (w.globals.axisCharts) {
  13976. var generalFormatter = function generalFormatter(index) {
  13977. return f.yLbFormatter(w.globals.series[index][j], {
  13978. series: w.globals.series,
  13979. seriesIndex: index,
  13980. dataPointIndex: j,
  13981. w: w
  13982. });
  13983. };
  13984. if (shared) {
  13985. f = _this.getFormatters(tIndex);
  13986. seriesName = _this.getSeriesName({
  13987. fn: f.yLbTitleFormatter,
  13988. index: tIndex,
  13989. seriesIndex: i,
  13990. j: j
  13991. });
  13992. pColor = w.globals.colors[tIndex];
  13993. val = generalFormatter(tIndex);
  13994. } else {
  13995. val = generalFormatter(i);
  13996. }
  13997. } // for pie / donuts
  13998. if (j === null) {
  13999. val = f.yLbFormatter(w.globals.series[i], w);
  14000. }
  14001. _this.DOMHandling({
  14002. i: i,
  14003. t: tIndex,
  14004. j: j,
  14005. ttItems: ttItems,
  14006. values: {
  14007. val: val,
  14008. xVal: xVal,
  14009. xAxisTTVal: xAxisTTVal,
  14010. zVal: zVal
  14011. },
  14012. seriesName: seriesName,
  14013. shared: shared,
  14014. pColor: pColor
  14015. });
  14016. };
  14017. for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) {
  14018. _loop(t, inverset);
  14019. }
  14020. }
  14021. }, {
  14022. key: "getFormatters",
  14023. value: function getFormatters(i) {
  14024. var w = this.w;
  14025. var yLbFormatter = w.globals.yLabelFormatters[i];
  14026. var yLbTitleFormatter;
  14027. if (w.globals.ttVal !== undefined) {
  14028. if (Array.isArray(w.globals.ttVal)) {
  14029. yLbFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].formatter;
  14030. yLbTitleFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].title && w.globals.ttVal[i].title.formatter;
  14031. } else {
  14032. yLbFormatter = w.globals.ttVal.formatter;
  14033. if (typeof w.globals.ttVal.title.formatter === 'function') {
  14034. yLbTitleFormatter = w.globals.ttVal.title.formatter;
  14035. }
  14036. }
  14037. } else {
  14038. yLbTitleFormatter = w.config.tooltip.y.title.formatter;
  14039. }
  14040. if (typeof yLbFormatter !== 'function') {
  14041. if (w.globals.yLabelFormatters[0]) {
  14042. yLbFormatter = w.globals.yLabelFormatters[0];
  14043. } else {
  14044. yLbFormatter = function yLbFormatter(label) {
  14045. return label;
  14046. };
  14047. }
  14048. }
  14049. if (typeof yLbTitleFormatter !== 'function') {
  14050. yLbTitleFormatter = function yLbTitleFormatter(label) {
  14051. return label;
  14052. };
  14053. }
  14054. return {
  14055. yLbFormatter: yLbFormatter,
  14056. yLbTitleFormatter: yLbTitleFormatter
  14057. };
  14058. }
  14059. }, {
  14060. key: "getSeriesName",
  14061. value: function getSeriesName(_ref3) {
  14062. var fn = _ref3.fn,
  14063. index = _ref3.index,
  14064. seriesIndex = _ref3.seriesIndex,
  14065. j = _ref3.j;
  14066. var w = this.w;
  14067. return fn(String(w.globals.seriesNames[index]), {
  14068. series: w.globals.series,
  14069. seriesIndex: seriesIndex,
  14070. dataPointIndex: j,
  14071. w: w
  14072. });
  14073. }
  14074. }, {
  14075. key: "DOMHandling",
  14076. value: function DOMHandling(_ref4) {
  14077. var i = _ref4.i,
  14078. t = _ref4.t,
  14079. j = _ref4.j,
  14080. ttItems = _ref4.ttItems,
  14081. values = _ref4.values,
  14082. seriesName = _ref4.seriesName,
  14083. shared = _ref4.shared,
  14084. pColor = _ref4.pColor;
  14085. var w = this.w;
  14086. var ttCtx = this.ttCtx;
  14087. var val = values.val,
  14088. xVal = values.xVal,
  14089. xAxisTTVal = values.xAxisTTVal,
  14090. zVal = values.zVal;
  14091. var ttItemsChildren = null;
  14092. ttItemsChildren = ttItems[t].children;
  14093. if (w.config.tooltip.fillSeriesColor) {
  14094. // elTooltip.style.backgroundColor = pColor
  14095. ttItems[t].style.backgroundColor = pColor;
  14096. ttItemsChildren[0].style.display = 'none';
  14097. }
  14098. if (ttCtx.showTooltipTitle) {
  14099. if (ttCtx.tooltipTitle === null) {
  14100. // get it once if null, and store it in class property
  14101. ttCtx.tooltipTitle = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-title');
  14102. }
  14103. ttCtx.tooltipTitle.innerHTML = xVal;
  14104. } // if xaxis tooltip is constructed, we need to replace the innerHTML
  14105. if (ttCtx.blxaxisTooltip) {
  14106. ttCtx.xaxisTooltipText.innerHTML = xAxisTTVal !== '' ? xAxisTTVal : xVal;
  14107. }
  14108. var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-label');
  14109. if (ttYLabel) {
  14110. ttYLabel.innerHTML = seriesName ? seriesName + ': ' : '';
  14111. }
  14112. var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-value');
  14113. if (ttYVal) {
  14114. ttYVal.innerHTML = typeof val !== 'undefined' ? val : '';
  14115. }
  14116. if (ttItemsChildren[0] && ttItemsChildren[0].classList.contains('apexcharts-tooltip-marker')) {
  14117. if (w.config.tooltip.marker.fillColors && Array.isArray(w.config.tooltip.marker.fillColors)) {
  14118. pColor = w.config.tooltip.marker.fillColors[i];
  14119. }
  14120. ttItemsChildren[0].style.backgroundColor = pColor;
  14121. }
  14122. if (!w.config.tooltip.marker.show) {
  14123. ttItemsChildren[0].style.display = 'none';
  14124. }
  14125. if (zVal !== null) {
  14126. var ttZLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-z-label');
  14127. ttZLabel.innerHTML = w.config.tooltip.z.title;
  14128. var ttZVal = ttItems[t].querySelector('.apexcharts-tooltip-text-z-value');
  14129. ttZVal.innerHTML = typeof zVal !== 'undefined' ? zVal : '';
  14130. }
  14131. if (shared && ttItemsChildren[0]) {
  14132. // hide when no Val or series collapsed
  14133. if (typeof val === 'undefined' || val === null || w.globals.collapsedSeriesIndices.indexOf(t) > -1) {
  14134. ttItemsChildren[0].parentNode.style.display = 'none';
  14135. } else {
  14136. ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display;
  14137. } // TODO: issue #1240 needs to be looked at again. commenting it because this also hides single series values with 0 in it (shared tooltip)
  14138. // if (w.globals.stackedSeriesTotals[j] === 0) {
  14139. // // shared tooltip and all values are null, so we need to hide the x value too
  14140. // let allYZeroForJ = false
  14141. // for (let si = 1; si < w.globals.seriesYvalues.length; si++) {
  14142. // if (
  14143. // w.globals.seriesYvalues[si][j] ===
  14144. // w.globals.seriesYvalues[si - 1][j]
  14145. // ) {
  14146. // allYZeroForJ = true
  14147. // }
  14148. // }
  14149. // if (allYZeroForJ) {
  14150. // ttCtx.tooltipTitle.style.display = 'none'
  14151. // } else {
  14152. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  14153. // }
  14154. // } else {
  14155. // ttCtx.tooltipTitle.style.display = w.config.tooltip.items.display
  14156. // }
  14157. }
  14158. }
  14159. }, {
  14160. key: "toggleActiveInactiveSeries",
  14161. value: function toggleActiveInactiveSeries(shared) {
  14162. var w = this.w;
  14163. if (shared) {
  14164. // make all tooltips active
  14165. this.tooltipUtil.toggleAllTooltipSeriesGroups('enable');
  14166. } else {
  14167. // disable all tooltip text groups
  14168. this.tooltipUtil.toggleAllTooltipSeriesGroups('disable'); // enable the first tooltip text group
  14169. var firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-series-group');
  14170. if (firstTooltipSeriesGroup) {
  14171. firstTooltipSeriesGroup.classList.add('apexcharts-active');
  14172. firstTooltipSeriesGroup.style.display = w.config.tooltip.items.display;
  14173. }
  14174. }
  14175. }
  14176. }, {
  14177. key: "getValuesToPrint",
  14178. value: function getValuesToPrint(_ref5) {
  14179. var i = _ref5.i,
  14180. j = _ref5.j;
  14181. var w = this.w;
  14182. var filteredSeriesX = this.ctx.series.filteredSeriesX();
  14183. var xVal = '';
  14184. var xAxisTTVal = '';
  14185. var zVal = null;
  14186. var val = null;
  14187. var customFormatterOpts = {
  14188. series: w.globals.series,
  14189. seriesIndex: i,
  14190. dataPointIndex: j,
  14191. w: w
  14192. };
  14193. var zFormatter = w.globals.ttZFormatter;
  14194. if (j === null) {
  14195. val = w.globals.series[i];
  14196. } else {
  14197. if (w.globals.isXNumeric) {
  14198. xVal = filteredSeriesX[i][j];
  14199. if (filteredSeriesX[i].length === 0) {
  14200. // a series (possibly the first one) might be collapsed, so get the next active index
  14201. var firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(filteredSeriesX);
  14202. xVal = filteredSeriesX[firstActiveSeriesIndex][j];
  14203. }
  14204. } else {
  14205. xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : '';
  14206. }
  14207. }
  14208. var bufferXVal = xVal;
  14209. if (w.globals.isXNumeric && w.config.xaxis.type === 'datetime') {
  14210. var xFormat = new Formatters(this.ctx);
  14211. xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal, bufferXVal);
  14212. } else {
  14213. if (!w.globals.isBarHorizontal) {
  14214. xVal = w.globals.xLabelFormatter(bufferXVal, customFormatterOpts);
  14215. }
  14216. } // override default x-axis formatter with tooltip formatter
  14217. if (w.config.tooltip.x.formatter !== undefined) {
  14218. xVal = w.globals.ttKeyFormatter(bufferXVal, customFormatterOpts);
  14219. }
  14220. if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[0].length > 0) {
  14221. zVal = zFormatter(w.globals.seriesZ[i][j], w);
  14222. }
  14223. if (typeof w.config.xaxis.tooltip.formatter === 'function') {
  14224. xAxisTTVal = w.globals.xaxisTooltipFormatter(bufferXVal, customFormatterOpts);
  14225. } else {
  14226. xAxisTTVal = xVal;
  14227. }
  14228. return {
  14229. val: Array.isArray(val) ? val.join(' ') : val,
  14230. xVal: Array.isArray(xVal) ? xVal.join(' ') : xVal,
  14231. xAxisTTVal: Array.isArray(xAxisTTVal) ? xAxisTTVal.join(' ') : xAxisTTVal,
  14232. zVal: zVal
  14233. };
  14234. }
  14235. }, {
  14236. key: "handleCustomTooltip",
  14237. value: function handleCustomTooltip(_ref6) {
  14238. var i = _ref6.i,
  14239. j = _ref6.j,
  14240. y1 = _ref6.y1,
  14241. y2 = _ref6.y2,
  14242. w = _ref6.w;
  14243. var tooltipEl = this.ttCtx.getElTooltip();
  14244. var fn = w.config.tooltip.custom;
  14245. if (Array.isArray(fn) && fn[i]) {
  14246. fn = fn[i];
  14247. } // override everything with a custom html tooltip and replace it
  14248. tooltipEl.innerHTML = fn({
  14249. ctx: this.ctx,
  14250. series: w.globals.series,
  14251. seriesIndex: i,
  14252. dataPointIndex: j,
  14253. y1: y1,
  14254. y2: y2,
  14255. w: w
  14256. });
  14257. }
  14258. }]);
  14259. return Labels;
  14260. }();
  14261. /**
  14262. * ApexCharts Tooltip.Position Class to move the tooltip based on x and y position.
  14263. *
  14264. * @module Tooltip.Position
  14265. **/
  14266. var Position = /*#__PURE__*/function () {
  14267. function Position(tooltipContext) {
  14268. _classCallCheck(this, Position);
  14269. this.ttCtx = tooltipContext;
  14270. this.ctx = tooltipContext.ctx;
  14271. this.w = tooltipContext.w;
  14272. }
  14273. /**
  14274. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  14275. * Along with this, this function also calls the xaxisMove function
  14276. * @memberof Position
  14277. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  14278. */
  14279. _createClass(Position, [{
  14280. key: "moveXCrosshairs",
  14281. value: function moveXCrosshairs(cx) {
  14282. var j = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  14283. var ttCtx = this.ttCtx;
  14284. var w = this.w;
  14285. var xcrosshairs = ttCtx.getElXCrosshairs();
  14286. var x = cx - ttCtx.xcrosshairsWidth / 2;
  14287. var tickAmount = w.globals.labels.slice().length;
  14288. if (j !== null) {
  14289. x = w.globals.gridWidth / tickAmount * j;
  14290. }
  14291. if (xcrosshairs !== null) {
  14292. xcrosshairs.setAttribute('x', x);
  14293. xcrosshairs.setAttribute('x1', x);
  14294. xcrosshairs.setAttribute('x2', x);
  14295. xcrosshairs.setAttribute('y2', w.globals.gridHeight);
  14296. xcrosshairs.classList.add('apexcharts-active');
  14297. }
  14298. if (x < 0) {
  14299. x = 0;
  14300. }
  14301. if (x > w.globals.gridWidth) {
  14302. x = w.globals.gridWidth;
  14303. }
  14304. if (ttCtx.blxaxisTooltip) {
  14305. var tx = x;
  14306. if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') {
  14307. tx = x + ttCtx.xcrosshairsWidth / 2;
  14308. }
  14309. this.moveXAxisTooltip(tx);
  14310. }
  14311. }
  14312. /**
  14313. * This will move the crosshair (the vertical/horz line that moves along with mouse)
  14314. * Along with this, this function also calls the xaxisMove function
  14315. * @memberof Position
  14316. * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair
  14317. */
  14318. }, {
  14319. key: "moveYCrosshairs",
  14320. value: function moveYCrosshairs(cy) {
  14321. var ttCtx = this.ttCtx;
  14322. if (ttCtx.ycrosshairs !== null) {
  14323. Graphics.setAttrs(ttCtx.ycrosshairs, {
  14324. y1: cy,
  14325. y2: cy
  14326. });
  14327. }
  14328. if (ttCtx.ycrosshairsHidden !== null) {
  14329. Graphics.setAttrs(ttCtx.ycrosshairsHidden, {
  14330. y1: cy,
  14331. y2: cy
  14332. });
  14333. }
  14334. }
  14335. /**
  14336. ** AxisTooltip is the small rectangle which appears on x axis with x value, when user moves
  14337. * @memberof Position
  14338. * @param {int} - cx = point's x position, wherever point's x is, you need to move
  14339. */
  14340. }, {
  14341. key: "moveXAxisTooltip",
  14342. value: function moveXAxisTooltip(cx) {
  14343. var w = this.w;
  14344. var ttCtx = this.ttCtx;
  14345. if (ttCtx.xaxisTooltip !== null) {
  14346. ttCtx.xaxisTooltip.classList.add('apexcharts-active');
  14347. var cy = ttCtx.xaxisOffY + w.config.xaxis.tooltip.offsetY + w.globals.translateY + 1 + w.config.xaxis.offsetY;
  14348. var xaxisTTText = ttCtx.xaxisTooltip.getBoundingClientRect();
  14349. var xaxisTTTextWidth = xaxisTTText.width;
  14350. cx = cx - xaxisTTTextWidth / 2;
  14351. if (!isNaN(cx)) {
  14352. cx = cx + w.globals.translateX;
  14353. var textRect = 0;
  14354. var graphics = new Graphics(this.ctx);
  14355. textRect = graphics.getTextRects(ttCtx.xaxisTooltipText.innerHTML);
  14356. ttCtx.xaxisTooltipText.style.minWidth = textRect.width + 'px';
  14357. ttCtx.xaxisTooltip.style.left = cx + 'px';
  14358. ttCtx.xaxisTooltip.style.top = cy + 'px';
  14359. }
  14360. }
  14361. }
  14362. }, {
  14363. key: "moveYAxisTooltip",
  14364. value: function moveYAxisTooltip(index) {
  14365. var w = this.w;
  14366. var ttCtx = this.ttCtx;
  14367. if (ttCtx.yaxisTTEls === null) {
  14368. ttCtx.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  14369. }
  14370. var ycrosshairsHiddenRectY1 = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1'), 10);
  14371. var cy = w.globals.translateY + ycrosshairsHiddenRectY1;
  14372. var yAxisTTRect = ttCtx.yaxisTTEls[index].getBoundingClientRect();
  14373. var yAxisTTHeight = yAxisTTRect.height;
  14374. var cx = w.globals.translateYAxisX[index] - 2;
  14375. if (w.config.yaxis[index].opposite) {
  14376. cx = cx - 26;
  14377. }
  14378. cy = cy - yAxisTTHeight / 2;
  14379. if (w.globals.ignoreYAxisIndexes.indexOf(index) === -1) {
  14380. ttCtx.yaxisTTEls[index].classList.add('apexcharts-active');
  14381. ttCtx.yaxisTTEls[index].style.top = cy + 'px';
  14382. ttCtx.yaxisTTEls[index].style.left = cx + w.config.yaxis[index].tooltip.offsetX + 'px';
  14383. } else {
  14384. ttCtx.yaxisTTEls[index].classList.remove('apexcharts-active');
  14385. }
  14386. }
  14387. /**
  14388. ** moves the whole tooltip by changing x, y attrs
  14389. * @memberof Position
  14390. * @param {int} - cx = point's x position, wherever point's x is, you need to move tooltip
  14391. * @param {int} - cy = point's y position, wherever point's y is, you need to move tooltip
  14392. * @param {int} - r = point's radius
  14393. */
  14394. }, {
  14395. key: "moveTooltip",
  14396. value: function moveTooltip(cx, cy) {
  14397. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  14398. var w = this.w;
  14399. var ttCtx = this.ttCtx;
  14400. var tooltipEl = ttCtx.getElTooltip();
  14401. var tooltipRect = ttCtx.tooltipRect;
  14402. var pointR = r !== null ? parseFloat(r) : 1;
  14403. var x = parseFloat(cx) + pointR + 5;
  14404. var y = parseFloat(cy) + pointR / 2; // - tooltipRect.ttHeight / 2
  14405. if (x > w.globals.gridWidth / 2) {
  14406. x = x - tooltipRect.ttWidth - pointR - 15;
  14407. }
  14408. if (x > w.globals.gridWidth - tooltipRect.ttWidth - 10) {
  14409. x = w.globals.gridWidth - tooltipRect.ttWidth;
  14410. }
  14411. if (x < -20) {
  14412. x = -20;
  14413. }
  14414. if (w.config.tooltip.followCursor) {
  14415. var elGrid = ttCtx.getElGrid();
  14416. var seriesBound = elGrid.getBoundingClientRect();
  14417. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top - tooltipRect.ttHeight / 2;
  14418. }
  14419. if (!w.config.tooltip.followCursor) {
  14420. var newPositions = this.positionChecks(tooltipRect, x, y);
  14421. x = newPositions.x;
  14422. y = newPositions.y;
  14423. }
  14424. if (!isNaN(x)) {
  14425. x = x + w.globals.translateX;
  14426. tooltipEl.style.left = x + 'px';
  14427. tooltipEl.style.top = y + 'px';
  14428. }
  14429. }
  14430. }, {
  14431. key: "positionChecks",
  14432. value: function positionChecks(tooltipRect, x, y) {
  14433. var w = this.w;
  14434. if (tooltipRect.ttHeight / 2 + y > w.globals.gridHeight) {
  14435. y = w.globals.gridHeight - tooltipRect.ttHeight + w.globals.translateY;
  14436. }
  14437. if (y < 0) {
  14438. y = 0;
  14439. }
  14440. return {
  14441. x: x,
  14442. y: y
  14443. };
  14444. }
  14445. }, {
  14446. key: "moveMarkers",
  14447. value: function moveMarkers(i, j) {
  14448. var w = this.w;
  14449. var ttCtx = this.ttCtx;
  14450. if (w.globals.markers.size[i] > 0) {
  14451. var allPoints = w.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(i, "'] .apexcharts-marker"));
  14452. for (var p = 0; p < allPoints.length; p++) {
  14453. if (parseInt(allPoints[p].getAttribute('rel'), 10) === j) {
  14454. ttCtx.marker.resetPointsSize();
  14455. ttCtx.marker.enlargeCurrentPoint(j, allPoints[p]);
  14456. }
  14457. }
  14458. } else {
  14459. ttCtx.marker.resetPointsSize();
  14460. this.moveDynamicPointOnHover(j, i);
  14461. }
  14462. } // This function is used when you need to show markers/points only on hover -
  14463. // DIFFERENT X VALUES in multiple series
  14464. }, {
  14465. key: "moveDynamicPointOnHover",
  14466. value: function moveDynamicPointOnHover(j, capturedSeries) {
  14467. var w = this.w;
  14468. var ttCtx = this.ttCtx;
  14469. var cx = 0;
  14470. var cy = 0;
  14471. var pointsArr = w.globals.pointsArray;
  14472. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(capturedSeries);
  14473. var serType = w.config.series[capturedSeries].type;
  14474. if (serType && (serType === 'column' || serType === 'candlestick')) {
  14475. // fix error mentioned in #811
  14476. return;
  14477. }
  14478. cx = pointsArr[capturedSeries][j][0];
  14479. cy = pointsArr[capturedSeries][j][1] ? pointsArr[capturedSeries][j][1] : 0;
  14480. var point = w.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(capturedSeries, "'] .apexcharts-series-markers circle"));
  14481. if (point && cy < w.globals.gridHeight && cy > 0) {
  14482. point.setAttribute('r', hoverSize);
  14483. point.setAttribute('cx', cx);
  14484. point.setAttribute('cy', cy);
  14485. } // point.style.opacity = w.config.markers.hover.opacity
  14486. this.moveXCrosshairs(cx);
  14487. if (!ttCtx.fixedTooltip) {
  14488. this.moveTooltip(cx, cy, hoverSize);
  14489. }
  14490. } // This function is used when you need to show markers/points only on hover -
  14491. // SAME X VALUES in multiple series
  14492. }, {
  14493. key: "moveDynamicPointsOnHover",
  14494. value: function moveDynamicPointsOnHover(j) {
  14495. var ttCtx = this.ttCtx;
  14496. var w = ttCtx.w;
  14497. var cx = 0;
  14498. var cy = 0;
  14499. var activeSeries = 0;
  14500. var pointsArr = w.globals.pointsArray;
  14501. var series = new Series(this.ctx);
  14502. activeSeries = series.getActiveConfigSeriesIndex(true);
  14503. var hoverSize = ttCtx.tooltipUtil.getHoverMarkerSize(activeSeries);
  14504. if (pointsArr[activeSeries]) {
  14505. cx = pointsArr[activeSeries][j][0];
  14506. cy = pointsArr[activeSeries][j][1];
  14507. }
  14508. var points = ttCtx.tooltipUtil.getAllMarkers();
  14509. if (points !== null) {
  14510. for (var p = 0; p < w.globals.series.length; p++) {
  14511. var pointArr = pointsArr[p];
  14512. if (w.globals.comboCharts) {
  14513. // 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
  14514. if (typeof pointArr === 'undefined') {
  14515. // nodelist to array
  14516. points.splice(p, 0, null);
  14517. }
  14518. }
  14519. if (pointArr && pointArr.length) {
  14520. var pcy = pointsArr[p][j][1];
  14521. points[p].setAttribute('cx', cx);
  14522. if (pcy !== null && !isNaN(pcy) && pcy < w.globals.gridHeight && pcy > 0) {
  14523. points[p] && points[p].setAttribute('r', hoverSize);
  14524. points[p] && points[p].setAttribute('cy', pcy);
  14525. } else {
  14526. points[p] && points[p].setAttribute('r', 0);
  14527. }
  14528. }
  14529. }
  14530. }
  14531. this.moveXCrosshairs(cx);
  14532. if (!ttCtx.fixedTooltip) {
  14533. var tcy = cy || w.globals.gridHeight;
  14534. this.moveTooltip(cx, tcy, hoverSize);
  14535. }
  14536. }
  14537. }, {
  14538. key: "moveStickyTooltipOverBars",
  14539. value: function moveStickyTooltipOverBars(j) {
  14540. var w = this.w;
  14541. var ttCtx = this.ttCtx;
  14542. var barLen = w.globals.columnSeries ? w.globals.columnSeries.length : w.globals.series.length;
  14543. var i = barLen >= 2 && barLen % 2 === 0 ? Math.floor(barLen / 2) : Math.floor(barLen / 2) + 1;
  14544. var jBar = w.globals.dom.baseEl.querySelector(".apexcharts-bar-series .apexcharts-series[rel='".concat(i, "'] path[j='").concat(j, "'], .apexcharts-candlestick-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "'], .apexcharts-rangebar-series .apexcharts-series[rel='").concat(i, "'] path[j='").concat(j, "']"));
  14545. var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0;
  14546. var bcy = 0;
  14547. var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0;
  14548. if (w.globals.isXNumeric) {
  14549. bcx = bcx - (barLen % 2 !== 0 ? bw / 2 : 0);
  14550. } else {
  14551. bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2;
  14552. if (isNaN(bcx)) {
  14553. bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2;
  14554. }
  14555. } // tooltip will move vertically along with mouse as it is a shared tooltip
  14556. var elGrid = ttCtx.getElGrid();
  14557. var seriesBound = elGrid.getBoundingClientRect();
  14558. bcy = ttCtx.e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2;
  14559. this.moveXCrosshairs(bcx);
  14560. if (!ttCtx.fixedTooltip) {
  14561. var tcy = bcy || w.globals.gridHeight;
  14562. this.moveTooltip(bcx, tcy);
  14563. }
  14564. }
  14565. }]);
  14566. return Position;
  14567. }();
  14568. /**
  14569. * ApexCharts Tooltip.Marker Class to draw texts on the tooltip.
  14570. *
  14571. * @module Tooltip.Marker
  14572. **/
  14573. var Marker = /*#__PURE__*/function () {
  14574. function Marker(tooltipContext) {
  14575. _classCallCheck(this, Marker);
  14576. this.w = tooltipContext.w;
  14577. this.ttCtx = tooltipContext;
  14578. this.ctx = tooltipContext.ctx;
  14579. this.tooltipPosition = new Position(tooltipContext);
  14580. }
  14581. _createClass(Marker, [{
  14582. key: "drawDynamicPoints",
  14583. value: function drawDynamicPoints() {
  14584. var w = this.w;
  14585. var graphics = new Graphics(this.ctx);
  14586. var marker = new Markers(this.ctx);
  14587. var elsSeries = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  14588. elsSeries = _toConsumableArray(elsSeries);
  14589. elsSeries.sort(function (a, b) {
  14590. return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1;
  14591. });
  14592. for (var i = 0; i < elsSeries.length; i++) {
  14593. var pointsMain = elsSeries[i].querySelector(".apexcharts-series-markers-wrap");
  14594. if (pointsMain !== null) {
  14595. // it can be null as we have tooltips in donut/bar charts
  14596. var point = void 0;
  14597. var PointClasses = "apexcharts-marker w".concat((Math.random() + 1).toString(36).substring(4));
  14598. if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) {
  14599. PointClasses += ' no-pointer-events';
  14600. }
  14601. var elPointOptions = marker.getMarkerConfig(PointClasses, i);
  14602. point = graphics.drawMarker(0, 0, elPointOptions);
  14603. point.node.setAttribute('default-marker-size', 0);
  14604. var elPointsG = document.createElementNS(w.globals.SVGNS, 'g');
  14605. elPointsG.classList.add('apexcharts-series-markers');
  14606. elPointsG.appendChild(point.node);
  14607. pointsMain.appendChild(elPointsG);
  14608. }
  14609. }
  14610. }
  14611. }, {
  14612. key: "enlargeCurrentPoint",
  14613. value: function enlargeCurrentPoint(rel, point) {
  14614. var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  14615. var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  14616. var w = this.w;
  14617. if (w.config.chart.type !== 'bubble') {
  14618. this.newPointSize(rel, point);
  14619. }
  14620. var cx = point.getAttribute('cx');
  14621. var cy = point.getAttribute('cy');
  14622. if (x !== null && y !== null) {
  14623. cx = x;
  14624. cy = y;
  14625. }
  14626. this.tooltipPosition.moveXCrosshairs(cx);
  14627. if (!this.fixedTooltip) {
  14628. if (w.config.chart.type === 'radar') {
  14629. var elGrid = this.ttCtx.getElGrid();
  14630. var seriesBound = elGrid.getBoundingClientRect();
  14631. cx = this.ttCtx.e.clientX - seriesBound.left;
  14632. }
  14633. this.tooltipPosition.moveTooltip(cx, cy, w.config.markers.hover.size);
  14634. }
  14635. }
  14636. }, {
  14637. key: "enlargePoints",
  14638. value: function enlargePoints(j) {
  14639. var w = this.w;
  14640. var me = this;
  14641. var ttCtx = this.ttCtx;
  14642. var col = j;
  14643. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  14644. var newSize = w.config.markers.hover.size;
  14645. for (var p = 0; p < points.length; p++) {
  14646. var rel = points[p].getAttribute('rel');
  14647. var index = points[p].getAttribute('index');
  14648. if (newSize === undefined) {
  14649. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  14650. }
  14651. if (col === parseInt(rel, 10)) {
  14652. me.newPointSize(col, points[p]);
  14653. var cx = points[p].getAttribute('cx');
  14654. var cy = points[p].getAttribute('cy');
  14655. me.tooltipPosition.moveXCrosshairs(cx);
  14656. if (!ttCtx.fixedTooltip) {
  14657. me.tooltipPosition.moveTooltip(cx, cy, newSize);
  14658. }
  14659. } else {
  14660. me.oldPointSize(points[p]);
  14661. }
  14662. }
  14663. }
  14664. }, {
  14665. key: "newPointSize",
  14666. value: function newPointSize(rel, point) {
  14667. var w = this.w;
  14668. var newSize = w.config.markers.hover.size;
  14669. var elPoint = rel === 0 ? point.parentNode.firstChild : point.parentNode.lastChild;
  14670. if (elPoint.getAttribute('default-marker-size') !== '0') {
  14671. var index = parseInt(elPoint.getAttribute('index'), 10);
  14672. if (newSize === undefined) {
  14673. newSize = w.globals.markers.size[index] + w.config.markers.hover.sizeOffset;
  14674. }
  14675. elPoint.setAttribute('r', newSize);
  14676. }
  14677. }
  14678. }, {
  14679. key: "oldPointSize",
  14680. value: function oldPointSize(point) {
  14681. var size = parseFloat(point.getAttribute('default-marker-size'));
  14682. point.setAttribute('r', size);
  14683. }
  14684. }, {
  14685. key: "resetPointsSize",
  14686. value: function resetPointsSize() {
  14687. var w = this.w;
  14688. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker');
  14689. for (var p = 0; p < points.length; p++) {
  14690. var size = parseFloat(points[p].getAttribute('default-marker-size'));
  14691. if (Utils.isNumber(size)) {
  14692. points[p].setAttribute('r', size);
  14693. } else {
  14694. points[p].setAttribute('r', 0);
  14695. }
  14696. }
  14697. }
  14698. }]);
  14699. return Marker;
  14700. }();
  14701. /**
  14702. * ApexCharts Tooltip.Intersect Class.
  14703. *
  14704. * @module Tooltip.Intersect
  14705. **/
  14706. var Intersect = /*#__PURE__*/function () {
  14707. function Intersect(tooltipContext) {
  14708. _classCallCheck(this, Intersect);
  14709. this.w = tooltipContext.w;
  14710. this.ttCtx = tooltipContext;
  14711. }
  14712. _createClass(Intersect, [{
  14713. key: "getAttr",
  14714. value: function getAttr(e, attr) {
  14715. return parseFloat(e.target.getAttribute(attr));
  14716. }
  14717. }, {
  14718. key: "handleHeatTooltip",
  14719. value: function handleHeatTooltip(_ref) {
  14720. var e = _ref.e,
  14721. opt = _ref.opt,
  14722. x = _ref.x,
  14723. y = _ref.y;
  14724. var ttCtx = this.ttCtx;
  14725. var w = this.w;
  14726. if (e.target.classList.contains('apexcharts-heatmap-rect')) {
  14727. var i = this.getAttr(e, 'i');
  14728. var j = this.getAttr(e, 'j');
  14729. var cx = this.getAttr(e, 'cx');
  14730. var cy = this.getAttr(e, 'cy');
  14731. var width = this.getAttr(e, 'width');
  14732. var height = this.getAttr(e, 'height');
  14733. ttCtx.tooltipLabels.drawSeriesTexts({
  14734. ttItems: opt.ttItems,
  14735. i: i,
  14736. j: j,
  14737. shared: false
  14738. });
  14739. w.globals.capturedSeriesIndex = i;
  14740. w.globals.capturedDataPointIndex = j;
  14741. x = cx + ttCtx.tooltipRect.ttWidth / 2 + width;
  14742. y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2;
  14743. ttCtx.tooltipPosition.moveXCrosshairs(cx + width / 2);
  14744. if (x > w.globals.gridWidth / 2) {
  14745. x = cx - ttCtx.tooltipRect.ttWidth / 2 + width;
  14746. }
  14747. if (ttCtx.w.config.tooltip.followCursor) {
  14748. var elGrid = ttCtx.getElGrid();
  14749. var seriesBound = elGrid.getBoundingClientRect(); // x = ttCtx.e.clientX - seriesBound.left
  14750. y = ttCtx.e.clientY - seriesBound.top + w.globals.translateY / 2 - 10;
  14751. }
  14752. }
  14753. return {
  14754. x: x,
  14755. y: y
  14756. };
  14757. }
  14758. }, {
  14759. key: "handleMarkerTooltip",
  14760. value: function handleMarkerTooltip(_ref2) {
  14761. var e = _ref2.e,
  14762. opt = _ref2.opt,
  14763. x = _ref2.x,
  14764. y = _ref2.y;
  14765. var w = this.w;
  14766. var ttCtx = this.ttCtx;
  14767. var i;
  14768. var j;
  14769. if (e.target.classList.contains('apexcharts-marker')) {
  14770. var cx = parseInt(opt.paths.getAttribute('cx'), 10);
  14771. var cy = parseInt(opt.paths.getAttribute('cy'), 10);
  14772. var val = parseFloat(opt.paths.getAttribute('val'));
  14773. j = parseInt(opt.paths.getAttribute('rel'), 10);
  14774. i = parseInt(opt.paths.parentNode.parentNode.parentNode.getAttribute('rel'), 10) - 1;
  14775. if (ttCtx.intersect) {
  14776. var el = Utils.findAncestor(opt.paths, 'apexcharts-series');
  14777. if (el) {
  14778. i = parseInt(el.getAttribute('data:realIndex'), 10);
  14779. }
  14780. }
  14781. ttCtx.tooltipLabels.drawSeriesTexts({
  14782. ttItems: opt.ttItems,
  14783. i: i,
  14784. j: j,
  14785. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
  14786. });
  14787. if (e.type === 'mouseup') {
  14788. ttCtx.markerClick(e, i, j);
  14789. }
  14790. w.globals.capturedSeriesIndex = i;
  14791. w.globals.capturedDataPointIndex = j;
  14792. x = cx;
  14793. y = cy + w.globals.translateY - ttCtx.tooltipRect.ttHeight * 1.4;
  14794. if (ttCtx.w.config.tooltip.followCursor) {
  14795. var elGrid = ttCtx.getElGrid();
  14796. var seriesBound = elGrid.getBoundingClientRect();
  14797. y = ttCtx.e.clientY + w.globals.translateY - seriesBound.top;
  14798. }
  14799. if (val < 0) {
  14800. y = cy;
  14801. }
  14802. ttCtx.marker.enlargeCurrentPoint(j, opt.paths, x, y);
  14803. }
  14804. return {
  14805. x: x,
  14806. y: y
  14807. };
  14808. }
  14809. }, {
  14810. key: "handleBarTooltip",
  14811. value: function handleBarTooltip(_ref3) {
  14812. var e = _ref3.e,
  14813. opt = _ref3.opt;
  14814. var w = this.w;
  14815. var ttCtx = this.ttCtx;
  14816. var tooltipEl = ttCtx.getElTooltip();
  14817. var bx = 0;
  14818. var x = 0;
  14819. var y = 0;
  14820. var i = 0;
  14821. var strokeWidth;
  14822. var barXY = this.getBarTooltipXY({
  14823. e: e,
  14824. opt: opt
  14825. });
  14826. i = barXY.i;
  14827. var barHeight = barXY.barHeight;
  14828. var j = barXY.j;
  14829. w.globals.capturedSeriesIndex = i;
  14830. w.globals.capturedDataPointIndex = j;
  14831. if (w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars() || !w.config.tooltip.shared) {
  14832. x = barXY.x;
  14833. y = barXY.y;
  14834. strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[i] : w.config.stroke.width;
  14835. bx = x;
  14836. } else {
  14837. if (!w.globals.comboCharts && !w.config.tooltip.shared) {
  14838. bx = bx / 2;
  14839. }
  14840. } // y is NaN, make it touch the bottom of grid area
  14841. if (isNaN(y)) {
  14842. y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight;
  14843. } else if (y < 0) {
  14844. y = 0;
  14845. }
  14846. if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth) {
  14847. x = x - ttCtx.tooltipRect.ttWidth;
  14848. } else if (x < 0) {
  14849. x = 0;
  14850. }
  14851. if (ttCtx.w.config.tooltip.followCursor) {
  14852. var elGrid = ttCtx.getElGrid();
  14853. var seriesBound = elGrid.getBoundingClientRect();
  14854. y = ttCtx.e.clientY - seriesBound.top;
  14855. } // if tooltip is still null, querySelector
  14856. if (ttCtx.tooltip === null) {
  14857. ttCtx.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  14858. }
  14859. if (!w.config.tooltip.shared) {
  14860. if (w.globals.comboBarCount > 0) {
  14861. ttCtx.tooltipPosition.moveXCrosshairs(bx + strokeWidth / 2);
  14862. } else {
  14863. ttCtx.tooltipPosition.moveXCrosshairs(bx);
  14864. }
  14865. } // move tooltip here
  14866. if (!ttCtx.fixedTooltip && (!w.config.tooltip.shared || w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  14867. var isReversed = w.globals.isMultipleYAxis ? w.config.yaxis[seriesIndex] && w.config.yaxis[seriesIndex].reversed : w.config.yaxis[0].reversed;
  14868. if (isReversed) {
  14869. x = x - ttCtx.tooltipRect.ttWidth;
  14870. if (x < 0) {
  14871. x = 0;
  14872. }
  14873. }
  14874. tooltipEl.style.left = x + w.globals.translateX + 'px';
  14875. var seriesIndex = parseInt(opt.paths.parentNode.getAttribute('data:realIndex'), 10);
  14876. if (isReversed && !(w.globals.isBarHorizontal && ttCtx.tooltipUtil.hasBars())) {
  14877. y = y + barHeight - (w.globals.series[i][j] < 0 ? barHeight : 0) * 2;
  14878. }
  14879. if (ttCtx.tooltipRect.ttHeight + y > w.globals.gridHeight) {
  14880. y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight + w.globals.translateY;
  14881. tooltipEl.style.top = y + 'px';
  14882. } else {
  14883. tooltipEl.style.top = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2 + 'px';
  14884. }
  14885. }
  14886. }
  14887. }, {
  14888. key: "getBarTooltipXY",
  14889. value: function getBarTooltipXY(_ref4) {
  14890. var e = _ref4.e,
  14891. opt = _ref4.opt;
  14892. var w = this.w;
  14893. var j = null;
  14894. var ttCtx = this.ttCtx;
  14895. var i = 0;
  14896. var x = 0;
  14897. var y = 0;
  14898. var barWidth = 0;
  14899. var barHeight = 0;
  14900. var cl = e.target.classList;
  14901. if (cl.contains('apexcharts-bar-area') || cl.contains('apexcharts-candlestick-area') || cl.contains('apexcharts-rangebar-area')) {
  14902. var bar = e.target;
  14903. var barRect = bar.getBoundingClientRect();
  14904. var seriesBound = opt.elGrid.getBoundingClientRect();
  14905. var bh = barRect.height;
  14906. barHeight = barRect.height;
  14907. var bw = barRect.width;
  14908. var cx = parseInt(bar.getAttribute('cx'), 10);
  14909. var cy = parseInt(bar.getAttribute('cy'), 10);
  14910. barWidth = parseFloat(bar.getAttribute('barWidth'));
  14911. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  14912. j = parseInt(bar.getAttribute('j'), 10);
  14913. i = parseInt(bar.parentNode.getAttribute('rel'), 10) - 1;
  14914. var y1 = bar.getAttribute('data-range-y1');
  14915. var y2 = bar.getAttribute('data-range-y2');
  14916. if (w.globals.comboCharts) {
  14917. i = parseInt(bar.parentNode.getAttribute('data:realIndex'), 10);
  14918. } // if (w.config.tooltip.shared) {
  14919. // this check not needed at the moment
  14920. // const yDivisor = w.globals.gridHeight / (w.globals.series.length)
  14921. // const hoverY = ttCtx.clientY - ttCtx.seriesBound.top
  14922. // j = Math.ceil(hoverY / yDivisor)
  14923. // }
  14924. ttCtx.tooltipLabels.drawSeriesTexts({
  14925. ttItems: opt.ttItems,
  14926. i: i,
  14927. j: j,
  14928. y1: y1 ? parseInt(y1, 10) : null,
  14929. y2: y2 ? parseInt(y2, 10) : null,
  14930. shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared
  14931. });
  14932. if (w.config.tooltip.followCursor) {
  14933. if (w.globals.isBarHorizontal) {
  14934. x = clientX - seriesBound.left + 15;
  14935. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  14936. } else {
  14937. if (w.globals.isXNumeric) {
  14938. x = cx - bw / 2;
  14939. } else {
  14940. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  14941. }
  14942. y = e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2 - 15;
  14943. }
  14944. } else {
  14945. if (w.globals.isBarHorizontal) {
  14946. x = cx;
  14947. if (x < ttCtx.xyRatios.baseLineInvertedY) {
  14948. x = cx - ttCtx.tooltipRect.ttWidth;
  14949. }
  14950. y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2;
  14951. } else {
  14952. // if columns
  14953. if (w.globals.isXNumeric) {
  14954. x = cx - bw / 2;
  14955. } else {
  14956. x = cx - ttCtx.dataPointsDividedWidth + bw / 2;
  14957. }
  14958. y = cy; // - ttCtx.tooltipRect.ttHeight / 2 + 10
  14959. }
  14960. }
  14961. }
  14962. return {
  14963. x: x,
  14964. y: y,
  14965. barHeight: barHeight,
  14966. barWidth: barWidth,
  14967. i: i,
  14968. j: j
  14969. };
  14970. }
  14971. }]);
  14972. return Intersect;
  14973. }();
  14974. /**
  14975. * ApexCharts Tooltip.AxesTooltip Class.
  14976. *
  14977. * @module Tooltip.AxesTooltip
  14978. **/
  14979. var AxesTooltip = /*#__PURE__*/function () {
  14980. function AxesTooltip(tooltipContext) {
  14981. _classCallCheck(this, AxesTooltip);
  14982. this.w = tooltipContext.w;
  14983. this.ttCtx = tooltipContext;
  14984. }
  14985. /**
  14986. * This method adds the secondary tooltip which appears below x axis
  14987. * @memberof Tooltip
  14988. **/
  14989. _createClass(AxesTooltip, [{
  14990. key: "drawXaxisTooltip",
  14991. value: function drawXaxisTooltip() {
  14992. var w = this.w;
  14993. var ttCtx = this.ttCtx;
  14994. var isBottom = w.config.xaxis.position === 'bottom';
  14995. ttCtx.xaxisOffY = isBottom ? w.globals.gridHeight + 1 : -w.globals.xAxisHeight - w.config.xaxis.axisTicks.height + 3;
  14996. var tooltipCssClass = isBottom ? 'apexcharts-xaxistooltip apexcharts-xaxistooltip-bottom' : 'apexcharts-xaxistooltip apexcharts-xaxistooltip-top';
  14997. var renderTo = w.globals.dom.elWrap;
  14998. if (ttCtx.blxaxisTooltip) {
  14999. var xaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-xaxistooltip');
  15000. if (xaxisTooltip === null) {
  15001. ttCtx.xaxisTooltip = document.createElement('div');
  15002. ttCtx.xaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  15003. renderTo.appendChild(ttCtx.xaxisTooltip);
  15004. ttCtx.xaxisTooltipText = document.createElement('div');
  15005. ttCtx.xaxisTooltipText.classList.add('apexcharts-xaxistooltip-text');
  15006. ttCtx.xaxisTooltipText.style.fontFamily = w.config.xaxis.tooltip.style.fontFamily || w.config.chart.fontFamily;
  15007. ttCtx.xaxisTooltipText.style.fontSize = w.config.xaxis.tooltip.style.fontSize;
  15008. ttCtx.xaxisTooltip.appendChild(ttCtx.xaxisTooltipText);
  15009. }
  15010. }
  15011. }
  15012. /**
  15013. * This method adds the secondary tooltip which appears below x axis
  15014. * @memberof Tooltip
  15015. **/
  15016. }, {
  15017. key: "drawYaxisTooltip",
  15018. value: function drawYaxisTooltip() {
  15019. var w = this.w;
  15020. var ttCtx = this.ttCtx;
  15021. var _loop = function _loop(i) {
  15022. var isRight = w.config.yaxis[i].opposite || w.config.yaxis[i].crosshairs.opposite;
  15023. ttCtx.yaxisOffX = isRight ? w.globals.gridWidth + 1 : 1;
  15024. var tooltipCssClass = isRight ? "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-right") : "apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i, " apexcharts-yaxistooltip-left");
  15025. w.globals.yAxisSameScaleIndices.map(function (samescales, ssi) {
  15026. samescales.map(function (s, si) {
  15027. if (si === i) {
  15028. tooltipCssClass += w.config.yaxis[si].show ? " " : " apexcharts-yaxistooltip-hidden";
  15029. }
  15030. });
  15031. });
  15032. var renderTo = w.globals.dom.elWrap;
  15033. var yaxisTooltip = w.globals.dom.baseEl.querySelector(".apexcharts-yaxistooltip apexcharts-yaxistooltip-".concat(i));
  15034. if (yaxisTooltip === null) {
  15035. ttCtx.yaxisTooltip = document.createElement('div');
  15036. ttCtx.yaxisTooltip.setAttribute('class', tooltipCssClass + ' apexcharts-theme-' + w.config.tooltip.theme);
  15037. renderTo.appendChild(ttCtx.yaxisTooltip);
  15038. if (i === 0) ttCtx.yaxisTooltipText = [];
  15039. ttCtx.yaxisTooltipText[i] = document.createElement('div');
  15040. ttCtx.yaxisTooltipText[i].classList.add('apexcharts-yaxistooltip-text');
  15041. ttCtx.yaxisTooltip.appendChild(ttCtx.yaxisTooltipText[i]);
  15042. }
  15043. };
  15044. for (var i = 0; i < w.config.yaxis.length; i++) {
  15045. _loop(i);
  15046. }
  15047. }
  15048. /**
  15049. * @memberof Tooltip
  15050. **/
  15051. }, {
  15052. key: "setXCrosshairWidth",
  15053. value: function setXCrosshairWidth() {
  15054. var w = this.w;
  15055. var ttCtx = this.ttCtx; // set xcrosshairs width
  15056. var xcrosshairs = ttCtx.getElXCrosshairs();
  15057. ttCtx.xcrosshairsWidth = parseInt(w.config.xaxis.crosshairs.width, 10);
  15058. if (!w.globals.comboCharts) {
  15059. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  15060. var count = w.globals.labels.length;
  15061. ttCtx.xcrosshairsWidth = w.globals.gridWidth / count;
  15062. } else if (w.config.xaxis.crosshairs.width === 'barWidth') {
  15063. var bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  15064. if (bar !== null) {
  15065. var barWidth = parseFloat(bar.getAttribute('barWidth'));
  15066. ttCtx.xcrosshairsWidth = barWidth;
  15067. } else {
  15068. ttCtx.xcrosshairsWidth = 1;
  15069. }
  15070. }
  15071. } else {
  15072. var _bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area');
  15073. if (_bar !== null && w.config.xaxis.crosshairs.width === 'barWidth') {
  15074. var _barWidth = parseFloat(_bar.getAttribute('barWidth'));
  15075. ttCtx.xcrosshairsWidth = _barWidth;
  15076. } else {
  15077. if (w.config.xaxis.crosshairs.width === 'tickWidth') {
  15078. var _count = w.globals.labels.length;
  15079. ttCtx.xcrosshairsWidth = w.globals.gridWidth / _count;
  15080. }
  15081. }
  15082. }
  15083. if (w.globals.isBarHorizontal) {
  15084. ttCtx.xcrosshairsWidth = 0;
  15085. }
  15086. if (xcrosshairs !== null && ttCtx.xcrosshairsWidth > 0) {
  15087. xcrosshairs.setAttribute('width', ttCtx.xcrosshairsWidth);
  15088. }
  15089. }
  15090. }, {
  15091. key: "handleYCrosshair",
  15092. value: function handleYCrosshair() {
  15093. var w = this.w;
  15094. var ttCtx = this.ttCtx; // set ycrosshairs height
  15095. ttCtx.ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs');
  15096. ttCtx.ycrosshairsHidden = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs-hidden');
  15097. }
  15098. }, {
  15099. key: "drawYaxisTooltipText",
  15100. value: function drawYaxisTooltipText(index, clientY, xyRatios) {
  15101. var ttCtx = this.ttCtx;
  15102. var w = this.w;
  15103. var lbFormatter = w.globals.yLabelFormatters[index];
  15104. if (ttCtx.yaxisTooltips[index]) {
  15105. var elGrid = ttCtx.getElGrid();
  15106. var seriesBound = elGrid.getBoundingClientRect();
  15107. var hoverY = (clientY - seriesBound.top) * xyRatios.yRatio[index];
  15108. var height = w.globals.maxYArr[index] - w.globals.minYArr[index];
  15109. var val = w.globals.minYArr[index] + (height - hoverY);
  15110. ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top);
  15111. ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val);
  15112. ttCtx.tooltipPosition.moveYAxisTooltip(index);
  15113. }
  15114. }
  15115. }]);
  15116. return AxesTooltip;
  15117. }();
  15118. /**
  15119. * ApexCharts Core Tooltip Class to handle the tooltip generation.
  15120. *
  15121. * @module Tooltip
  15122. **/
  15123. var Tooltip = /*#__PURE__*/function () {
  15124. function Tooltip(ctx) {
  15125. _classCallCheck(this, Tooltip);
  15126. this.ctx = ctx;
  15127. this.w = ctx.w;
  15128. var w = this.w;
  15129. this.tConfig = w.config.tooltip;
  15130. this.tooltipUtil = new Utils$1(this);
  15131. this.tooltipLabels = new Labels(this);
  15132. this.tooltipPosition = new Position(this);
  15133. this.marker = new Marker(this);
  15134. this.intersect = new Intersect(this);
  15135. this.axesTooltip = new AxesTooltip(this);
  15136. this.showOnIntersect = this.tConfig.intersect;
  15137. this.showTooltipTitle = this.tConfig.x.show;
  15138. this.fixedTooltip = this.tConfig.fixed.enabled;
  15139. this.xaxisTooltip = null;
  15140. this.yaxisTTEls = null;
  15141. this.isBarShared = !w.globals.isBarHorizontal && this.tConfig.shared;
  15142. }
  15143. _createClass(Tooltip, [{
  15144. key: "getElTooltip",
  15145. value: function getElTooltip(ctx) {
  15146. if (!ctx) ctx = this;
  15147. return ctx.w.globals.dom.baseEl.querySelector('.apexcharts-tooltip');
  15148. }
  15149. }, {
  15150. key: "getElXCrosshairs",
  15151. value: function getElXCrosshairs() {
  15152. return this.w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs');
  15153. }
  15154. }, {
  15155. key: "getElGrid",
  15156. value: function getElGrid() {
  15157. return this.w.globals.dom.baseEl.querySelector('.apexcharts-grid');
  15158. }
  15159. }, {
  15160. key: "drawTooltip",
  15161. value: function drawTooltip(xyRatios) {
  15162. var w = this.w;
  15163. this.xyRatios = xyRatios;
  15164. this.blxaxisTooltip = w.config.xaxis.tooltip.enabled && w.globals.axisCharts;
  15165. this.yaxisTooltips = w.config.yaxis.map(function (y, i) {
  15166. return y.show && y.tooltip.enabled && w.globals.axisCharts ? true : false;
  15167. });
  15168. this.allTooltipSeriesGroups = [];
  15169. if (!w.globals.axisCharts) {
  15170. this.showTooltipTitle = false;
  15171. }
  15172. var tooltipEl = document.createElement('div');
  15173. tooltipEl.classList.add('apexcharts-tooltip');
  15174. tooltipEl.classList.add("apexcharts-theme-".concat(this.tConfig.theme));
  15175. w.globals.dom.elWrap.appendChild(tooltipEl);
  15176. if (w.globals.axisCharts) {
  15177. this.axesTooltip.drawXaxisTooltip();
  15178. this.axesTooltip.drawYaxisTooltip();
  15179. this.axesTooltip.setXCrosshairWidth();
  15180. this.axesTooltip.handleYCrosshair();
  15181. var xAxis = new XAxis(this.ctx);
  15182. this.xAxisTicksPositions = xAxis.getXAxisTicksPositions();
  15183. } // we forcefully set intersect true for these conditions
  15184. if ((w.globals.comboCharts || this.tConfig.intersect || w.config.chart.type === 'bar' || w.config.chart.type === 'rangeBar') && !this.tConfig.shared) {
  15185. this.showOnIntersect = true;
  15186. }
  15187. if (w.config.markers.size === 0 || w.globals.markers.largestSize === 0) {
  15188. // when user don't want to show points all the time, but only on when hovering on series
  15189. this.marker.drawDynamicPoints(this);
  15190. } // no visible series, exit
  15191. if (w.globals.collapsedSeries.length === w.globals.series.length) return;
  15192. this.dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints;
  15193. this.dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints;
  15194. if (this.showTooltipTitle) {
  15195. this.tooltipTitle = document.createElement('div');
  15196. this.tooltipTitle.classList.add('apexcharts-tooltip-title');
  15197. this.tooltipTitle.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  15198. this.tooltipTitle.style.fontSize = this.tConfig.style.fontSize;
  15199. tooltipEl.appendChild(this.tooltipTitle);
  15200. }
  15201. var ttItemsCnt = w.globals.series.length; // whether shared or not, default is shared
  15202. if ((w.globals.xyCharts || w.globals.comboCharts) && this.tConfig.shared) {
  15203. if (!this.showOnIntersect) {
  15204. ttItemsCnt = w.globals.series.length;
  15205. } else {
  15206. ttItemsCnt = 1;
  15207. }
  15208. }
  15209. this.legendLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-text');
  15210. this.ttItems = this.createTTElements(ttItemsCnt);
  15211. this.addSVGEvents();
  15212. }
  15213. }, {
  15214. key: "createTTElements",
  15215. value: function createTTElements(ttItemsCnt) {
  15216. var w = this.w;
  15217. var ttItems = [];
  15218. var tooltipEl = this.getElTooltip();
  15219. for (var i = 0; i < ttItemsCnt; i++) {
  15220. var gTxt = document.createElement('div');
  15221. gTxt.classList.add('apexcharts-tooltip-series-group');
  15222. if (this.tConfig.shared && this.tConfig.enabledOnSeries && Array.isArray(this.tConfig.enabledOnSeries)) {
  15223. if (this.tConfig.enabledOnSeries.indexOf(i) < 0) {
  15224. gTxt.classList.add('apexcharts-tooltip-series-group-hidden');
  15225. }
  15226. }
  15227. var point = document.createElement('span');
  15228. point.classList.add('apexcharts-tooltip-marker');
  15229. point.style.backgroundColor = w.globals.colors[i];
  15230. gTxt.appendChild(point);
  15231. var gYZ = document.createElement('div');
  15232. gYZ.classList.add('apexcharts-tooltip-text');
  15233. gYZ.style.fontFamily = this.tConfig.style.fontFamily || w.config.chart.fontFamily;
  15234. gYZ.style.fontSize = this.tConfig.style.fontSize; // y values group
  15235. var gYValText = document.createElement('div');
  15236. gYValText.classList.add('apexcharts-tooltip-y-group');
  15237. var txtLabel = document.createElement('span');
  15238. txtLabel.classList.add('apexcharts-tooltip-text-label');
  15239. gYValText.appendChild(txtLabel);
  15240. var txtValue = document.createElement('span');
  15241. txtValue.classList.add('apexcharts-tooltip-text-value');
  15242. gYValText.appendChild(txtValue); // z values group
  15243. var gZValText = document.createElement('div');
  15244. gZValText.classList.add('apexcharts-tooltip-z-group');
  15245. var txtZLabel = document.createElement('span');
  15246. txtZLabel.classList.add('apexcharts-tooltip-text-z-label');
  15247. gZValText.appendChild(txtZLabel);
  15248. var txtZValue = document.createElement('span');
  15249. txtZValue.classList.add('apexcharts-tooltip-text-z-value');
  15250. gZValText.appendChild(txtZValue);
  15251. gYZ.appendChild(gYValText);
  15252. gYZ.appendChild(gZValText);
  15253. gTxt.appendChild(gYZ);
  15254. tooltipEl.appendChild(gTxt);
  15255. ttItems.push(gTxt);
  15256. }
  15257. return ttItems;
  15258. }
  15259. }, {
  15260. key: "addSVGEvents",
  15261. value: function addSVGEvents() {
  15262. var w = this.w;
  15263. var type = w.config.chart.type;
  15264. var tooltipEl = this.getElTooltip();
  15265. var commonBar = !!(type === 'bar' || type === 'candlestick' || type === 'rangeBar');
  15266. var chartWithmarkers = type === 'area' || type === 'line' || type === 'scatter' || type === 'bubble' || type === 'radar';
  15267. var hoverArea = w.globals.dom.Paper.node;
  15268. var elGrid = this.getElGrid();
  15269. if (elGrid) {
  15270. this.seriesBound = elGrid.getBoundingClientRect();
  15271. }
  15272. var tooltipY = [];
  15273. var tooltipX = [];
  15274. var seriesHoverParams = {
  15275. hoverArea: hoverArea,
  15276. elGrid: elGrid,
  15277. tooltipEl: tooltipEl,
  15278. tooltipY: tooltipY,
  15279. tooltipX: tooltipX,
  15280. ttItems: this.ttItems
  15281. };
  15282. var points;
  15283. if (w.globals.axisCharts) {
  15284. if (chartWithmarkers) {
  15285. points = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series[data\\:longestSeries='true'] .apexcharts-marker");
  15286. } else if (commonBar) {
  15287. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area, .apexcharts-series .apexcharts-candlestick-area, .apexcharts-series .apexcharts-rangebar-area');
  15288. } else if (type === 'heatmap') {
  15289. points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap');
  15290. }
  15291. if (points && points.length) {
  15292. for (var p = 0; p < points.length; p++) {
  15293. tooltipY.push(points[p].getAttribute('cy'));
  15294. tooltipX.push(points[p].getAttribute('cx'));
  15295. }
  15296. }
  15297. }
  15298. var validSharedChartTypes = w.globals.xyCharts && !this.showOnIntersect || w.globals.comboCharts && !this.showOnIntersect || commonBar && this.tooltipUtil.hasBars() && this.tConfig.shared;
  15299. if (validSharedChartTypes) {
  15300. this.addPathsEventListeners([hoverArea], seriesHoverParams);
  15301. } else if (commonBar && !w.globals.comboCharts || chartWithmarkers && this.showOnIntersect) {
  15302. this.addDatapointEventsListeners(seriesHoverParams);
  15303. } else if (!w.globals.axisCharts || type === 'heatmap') {
  15304. var seriesAll = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series');
  15305. this.addPathsEventListeners(seriesAll, seriesHoverParams);
  15306. }
  15307. if (this.showOnIntersect) {
  15308. var lineAreaPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-marker, .apexcharts-area-series .apexcharts-marker');
  15309. if (lineAreaPoints.length > 0) {
  15310. // if we find any lineSeries, addEventListeners for them
  15311. this.addPathsEventListeners(lineAreaPoints, seriesHoverParams);
  15312. } // combo charts may have bars, so add event listeners here too
  15313. if (this.tooltipUtil.hasBars() && !this.tConfig.shared) {
  15314. this.addDatapointEventsListeners(seriesHoverParams);
  15315. }
  15316. }
  15317. }
  15318. }, {
  15319. key: "drawFixedTooltipRect",
  15320. value: function drawFixedTooltipRect() {
  15321. var w = this.w;
  15322. var tooltipEl = this.getElTooltip();
  15323. var tooltipRect = tooltipEl.getBoundingClientRect();
  15324. var ttWidth = tooltipRect.width + 10;
  15325. var ttHeight = tooltipRect.height + 10;
  15326. var x = this.tConfig.fixed.offsetX;
  15327. var y = this.tConfig.fixed.offsetY;
  15328. var fixed = this.tConfig.fixed.position.toLowerCase();
  15329. if (fixed.indexOf('right') > -1) {
  15330. x = x + w.globals.svgWidth - ttWidth + 10;
  15331. }
  15332. if (fixed.indexOf('bottom') > -1) {
  15333. y = y + w.globals.svgHeight - ttHeight - 10;
  15334. }
  15335. tooltipEl.style.left = x + 'px';
  15336. tooltipEl.style.top = y + 'px';
  15337. return {
  15338. x: x,
  15339. y: y,
  15340. ttWidth: ttWidth,
  15341. ttHeight: ttHeight
  15342. };
  15343. }
  15344. }, {
  15345. key: "addDatapointEventsListeners",
  15346. value: function addDatapointEventsListeners(seriesHoverParams) {
  15347. var w = this.w;
  15348. var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-rangebar-area');
  15349. this.addPathsEventListeners(points, seriesHoverParams);
  15350. }
  15351. }, {
  15352. key: "addPathsEventListeners",
  15353. value: function addPathsEventListeners(paths, opts) {
  15354. var self = this;
  15355. var _loop = function _loop(p) {
  15356. var extendedOpts = {
  15357. paths: paths[p],
  15358. tooltipEl: opts.tooltipEl,
  15359. tooltipY: opts.tooltipY,
  15360. tooltipX: opts.tooltipX,
  15361. elGrid: opts.elGrid,
  15362. hoverArea: opts.hoverArea,
  15363. ttItems: opts.ttItems
  15364. };
  15365. var events = ['mousemove', 'mouseup', 'touchmove', 'mouseout', 'touchend'];
  15366. events.map(function (ev) {
  15367. return paths[p].addEventListener(ev, self.seriesHover.bind(self, extendedOpts), {
  15368. capture: false,
  15369. passive: true
  15370. });
  15371. });
  15372. };
  15373. for (var p = 0; p < paths.length; p++) {
  15374. _loop(p);
  15375. }
  15376. }
  15377. /*
  15378. ** The actual series hover function
  15379. */
  15380. }, {
  15381. key: "seriesHover",
  15382. value: function seriesHover(opt, e) {
  15383. var _this = this;
  15384. var chartGroups = [];
  15385. var w = this.w; // if user has more than one charts in group, we need to sync
  15386. if (w.config.chart.group) {
  15387. chartGroups = this.ctx.getGroupedCharts();
  15388. }
  15389. if (w.globals.axisCharts && (w.globals.minX === -Infinity && w.globals.maxX === Infinity || w.globals.dataPoints === 0)) {
  15390. return;
  15391. }
  15392. if (chartGroups.length) {
  15393. chartGroups.forEach(function (ch) {
  15394. var tooltipEl = _this.getElTooltip(ch);
  15395. var newOpts = {
  15396. paths: opt.paths,
  15397. tooltipEl: tooltipEl,
  15398. tooltipY: opt.tooltipY,
  15399. tooltipX: opt.tooltipX,
  15400. elGrid: opt.elGrid,
  15401. hoverArea: opt.hoverArea,
  15402. ttItems: ch.w.globals.tooltip.ttItems
  15403. }; // all the charts should have the same minX and maxX (same xaxis) for multiple tooltips to work correctly
  15404. if (ch.w.globals.minX === _this.w.globals.minX && ch.w.globals.maxX === _this.w.globals.maxX) {
  15405. ch.w.globals.tooltip.seriesHoverByContext({
  15406. chartCtx: ch,
  15407. ttCtx: ch.w.globals.tooltip,
  15408. opt: newOpts,
  15409. e: e
  15410. });
  15411. }
  15412. });
  15413. } else {
  15414. this.seriesHoverByContext({
  15415. chartCtx: this.ctx,
  15416. ttCtx: this.w.globals.tooltip,
  15417. opt: opt,
  15418. e: e
  15419. });
  15420. }
  15421. }
  15422. }, {
  15423. key: "seriesHoverByContext",
  15424. value: function seriesHoverByContext(_ref) {
  15425. var chartCtx = _ref.chartCtx,
  15426. ttCtx = _ref.ttCtx,
  15427. opt = _ref.opt,
  15428. e = _ref.e;
  15429. var w = chartCtx.w;
  15430. var tooltipEl = this.getElTooltip(); // tooltipRect is calculated on every mousemove, because the text is dynamic
  15431. ttCtx.tooltipRect = {
  15432. x: 0,
  15433. y: 0,
  15434. ttWidth: tooltipEl.getBoundingClientRect().width,
  15435. ttHeight: tooltipEl.getBoundingClientRect().height
  15436. };
  15437. ttCtx.e = e; // highlight the current hovered bars
  15438. if (ttCtx.tooltipUtil.hasBars() && !w.globals.comboCharts && !ttCtx.isBarShared) {
  15439. if (this.tConfig.onDatasetHover.highlightDataSeries) {
  15440. var series = new Series(chartCtx);
  15441. series.toggleSeriesOnHover(e, e.target.parentNode);
  15442. }
  15443. }
  15444. if (ttCtx.fixedTooltip) {
  15445. ttCtx.drawFixedTooltipRect();
  15446. }
  15447. if (w.globals.axisCharts) {
  15448. ttCtx.axisChartsTooltips({
  15449. e: e,
  15450. opt: opt,
  15451. tooltipRect: ttCtx.tooltipRect
  15452. });
  15453. } else {
  15454. // non-plot charts i.e pie/donut/circle
  15455. ttCtx.nonAxisChartsTooltips({
  15456. e: e,
  15457. opt: opt,
  15458. tooltipRect: ttCtx.tooltipRect
  15459. });
  15460. }
  15461. } // tooltip handling for line/area/bar/columns/scatter
  15462. }, {
  15463. key: "axisChartsTooltips",
  15464. value: function axisChartsTooltips(_ref2) {
  15465. var e = _ref2.e,
  15466. opt = _ref2.opt;
  15467. var w = this.w;
  15468. var x, y;
  15469. var seriesBound = opt.elGrid.getBoundingClientRect();
  15470. var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
  15471. var clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY;
  15472. this.clientY = clientY;
  15473. this.clientX = clientX;
  15474. w.globals.capturedSeriesIndex = -1;
  15475. w.globals.capturedDataPointIndex = -1;
  15476. if (clientY < seriesBound.top || clientY > seriesBound.top + seriesBound.height) {
  15477. this.handleMouseOut(opt);
  15478. return;
  15479. }
  15480. if (Array.isArray(this.tConfig.enabledOnSeries) && !w.config.tooltip.shared) {
  15481. var index = parseInt(opt.paths.getAttribute('index'), 10);
  15482. if (this.tConfig.enabledOnSeries.indexOf(index) < 0) {
  15483. this.handleMouseOut(opt);
  15484. return;
  15485. }
  15486. }
  15487. var tooltipEl = this.getElTooltip();
  15488. var xcrosshairs = this.getElXCrosshairs();
  15489. 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();
  15490. if (w.globals.isBarHorizontal && this.tooltipUtil.hasBars()) {
  15491. isStickyTooltip = false;
  15492. }
  15493. if (e.type === 'mousemove' || e.type === 'touchmove' || e.type === 'mouseup') {
  15494. if (xcrosshairs !== null) {
  15495. xcrosshairs.classList.add('apexcharts-active');
  15496. }
  15497. var hasYAxisTooltip = this.yaxisTooltips.filter(function (b) {
  15498. return b === true;
  15499. });
  15500. if (this.ycrosshairs !== null && hasYAxisTooltip.length) {
  15501. this.ycrosshairs.classList.add('apexcharts-active');
  15502. }
  15503. if (isStickyTooltip && !this.showOnIntersect) {
  15504. this.handleStickyTooltip(e, clientX, clientY, opt);
  15505. } else {
  15506. if (w.config.chart.type === 'heatmap') {
  15507. var markerXY = this.intersect.handleHeatTooltip({
  15508. e: e,
  15509. opt: opt,
  15510. x: x,
  15511. y: y
  15512. });
  15513. x = markerXY.x;
  15514. y = markerXY.y;
  15515. tooltipEl.style.left = x + 'px';
  15516. tooltipEl.style.top = y + 'px';
  15517. } else {
  15518. if (this.tooltipUtil.hasBars()) {
  15519. this.intersect.handleBarTooltip({
  15520. e: e,
  15521. opt: opt
  15522. });
  15523. }
  15524. if (this.tooltipUtil.hasMarkers()) {
  15525. // intersect - line/area/scatter/bubble
  15526. this.intersect.handleMarkerTooltip({
  15527. e: e,
  15528. opt: opt,
  15529. x: x,
  15530. y: y
  15531. });
  15532. }
  15533. }
  15534. }
  15535. if (this.yaxisTooltips.length) {
  15536. for (var yt = 0; yt < w.config.yaxis.length; yt++) {
  15537. this.axesTooltip.drawYaxisTooltipText(yt, clientY, this.xyRatios);
  15538. }
  15539. }
  15540. opt.tooltipEl.classList.add('apexcharts-active');
  15541. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  15542. this.handleMouseOut(opt);
  15543. }
  15544. } // tooltip handling for pie/donuts
  15545. }, {
  15546. key: "nonAxisChartsTooltips",
  15547. value: function nonAxisChartsTooltips(_ref3) {
  15548. var e = _ref3.e,
  15549. opt = _ref3.opt,
  15550. tooltipRect = _ref3.tooltipRect;
  15551. var w = this.w;
  15552. var rel = opt.paths.getAttribute('rel');
  15553. var tooltipEl = this.getElTooltip();
  15554. var seriesBound = w.globals.dom.elWrap.getBoundingClientRect();
  15555. if (e.type === 'mousemove' || e.type === 'touchmove') {
  15556. tooltipEl.classList.add('apexcharts-active');
  15557. this.tooltipLabels.drawSeriesTexts({
  15558. ttItems: opt.ttItems,
  15559. i: parseInt(rel, 10) - 1,
  15560. shared: false
  15561. });
  15562. var x = w.globals.clientX - seriesBound.left - tooltipRect.ttWidth / 2;
  15563. var y = w.globals.clientY - seriesBound.top - tooltipRect.ttHeight - 10;
  15564. tooltipEl.style.left = x + 'px';
  15565. tooltipEl.style.top = y + 'px';
  15566. } else if (e.type === 'mouseout' || e.type === 'touchend') {
  15567. tooltipEl.classList.remove('apexcharts-active');
  15568. }
  15569. }
  15570. }, {
  15571. key: "handleStickyTooltip",
  15572. value: function handleStickyTooltip(e, clientX, clientY, opt) {
  15573. var w = this.w;
  15574. var capj = this.tooltipUtil.getNearestValues({
  15575. context: this,
  15576. hoverArea: opt.hoverArea,
  15577. elGrid: opt.elGrid,
  15578. clientX: clientX,
  15579. clientY: clientY
  15580. });
  15581. var j = capj.j;
  15582. var capturedSeries = capj.capturedSeries;
  15583. if (capj.hoverX < 0 || capj.hoverX > w.globals.gridWidth) {
  15584. this.handleMouseOut(opt);
  15585. return;
  15586. }
  15587. if (capturedSeries !== null) {
  15588. this.handleStickyCapturedSeries(e, capturedSeries, opt, j);
  15589. } else {
  15590. // couldn't capture any series. check if shared X is same,
  15591. // if yes, draw a grouped tooltip
  15592. if (this.tooltipUtil.isXoverlap(j)) {
  15593. this.create(e, this, 0, j, opt.ttItems);
  15594. }
  15595. }
  15596. }
  15597. }, {
  15598. key: "handleStickyCapturedSeries",
  15599. value: function handleStickyCapturedSeries(e, capturedSeries, opt, j) {
  15600. var w = this.w;
  15601. var ignoreNull = w.globals.series[capturedSeries][j] === null;
  15602. if (ignoreNull) {
  15603. this.handleMouseOut(opt);
  15604. return;
  15605. }
  15606. if (typeof w.globals.series[capturedSeries][j] !== 'undefined') {
  15607. if (this.tConfig.shared && this.tooltipUtil.isXoverlap(j) && this.tooltipUtil.isInitialSeriesSameLen()) {
  15608. this.create(e, this, capturedSeries, j, opt.ttItems);
  15609. } else {
  15610. this.create(e, this, capturedSeries, j, opt.ttItems, false);
  15611. }
  15612. } else {
  15613. if (this.tooltipUtil.isXoverlap(j)) {
  15614. this.create(e, this, 0, j, opt.ttItems);
  15615. }
  15616. }
  15617. }
  15618. }, {
  15619. key: "deactivateHoverFilter",
  15620. value: function deactivateHoverFilter() {
  15621. var w = this.w;
  15622. var graphics = new Graphics(this.ctx);
  15623. var allPaths = w.globals.dom.Paper.select(".apexcharts-bar-area");
  15624. for (var b = 0; b < allPaths.length; b++) {
  15625. graphics.pathMouseLeave(allPaths[b]);
  15626. }
  15627. }
  15628. }, {
  15629. key: "handleMouseOut",
  15630. value: function handleMouseOut(opt) {
  15631. var w = this.w;
  15632. var xcrosshairs = this.getElXCrosshairs();
  15633. opt.tooltipEl.classList.remove('apexcharts-active');
  15634. this.deactivateHoverFilter();
  15635. if (w.config.chart.type !== 'bubble') {
  15636. this.marker.resetPointsSize();
  15637. }
  15638. if (xcrosshairs !== null) {
  15639. xcrosshairs.classList.remove('apexcharts-active');
  15640. }
  15641. if (this.ycrosshairs !== null) {
  15642. this.ycrosshairs.classList.remove('apexcharts-active');
  15643. }
  15644. if (this.blxaxisTooltip) {
  15645. this.xaxisTooltip.classList.remove('apexcharts-active');
  15646. }
  15647. if (this.yaxisTooltips.length) {
  15648. if (this.yaxisTTEls === null) {
  15649. this.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip');
  15650. }
  15651. for (var i = 0; i < this.yaxisTTEls.length; i++) {
  15652. this.yaxisTTEls[i].classList.remove('apexcharts-active');
  15653. }
  15654. }
  15655. if (w.config.legend.tooltipHoverFormatter) {
  15656. this.legendLabels.forEach(function (l) {
  15657. var defaultText = l.getAttribute('data:default-text');
  15658. l.innerHTML = decodeURIComponent(defaultText);
  15659. });
  15660. }
  15661. }
  15662. }, {
  15663. key: "markerClick",
  15664. value: function markerClick(e, seriesIndex, dataPointIndex) {
  15665. var w = this.w;
  15666. if (typeof w.config.chart.events.markerClick === 'function') {
  15667. w.config.chart.events.markerClick(e, this.ctx, {
  15668. seriesIndex: seriesIndex,
  15669. dataPointIndex: dataPointIndex,
  15670. w: w
  15671. });
  15672. }
  15673. this.ctx.events.fireEvent('markerClick', [e, this.ctx, {
  15674. seriesIndex: seriesIndex,
  15675. dataPointIndex: dataPointIndex,
  15676. w: w
  15677. }]);
  15678. }
  15679. }, {
  15680. key: "create",
  15681. value: function create(e, context, capturedSeries, j, ttItems) {
  15682. var shared = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  15683. var w = this.w;
  15684. var ttCtx = context;
  15685. if (e.type === 'mouseup') {
  15686. this.markerClick(e, capturedSeries, j);
  15687. }
  15688. if (shared === null) shared = this.tConfig.shared;
  15689. var hasMarkers = this.tooltipUtil.hasMarkers();
  15690. var bars = this.tooltipUtil.getElBars();
  15691. if (w.config.legend.tooltipHoverFormatter) {
  15692. var legendFormatter = w.config.legend.tooltipHoverFormatter;
  15693. var els = Array.from(this.legendLabels); // reset all legend values first
  15694. els.forEach(function (l) {
  15695. var legendName = l.getAttribute('data:default-text');
  15696. l.innerHTML = decodeURIComponent(legendName);
  15697. }); // for irregular time series
  15698. for (var i = 0; i < els.length; i++) {
  15699. var l = els[i];
  15700. var lsIndex = parseInt(l.getAttribute('i'), 10);
  15701. var legendName = decodeURIComponent(l.getAttribute('data:default-text'));
  15702. var text = legendFormatter(legendName, {
  15703. seriesIndex: shared ? lsIndex : capturedSeries,
  15704. dataPointIndex: j,
  15705. w: w
  15706. });
  15707. if (!shared) {
  15708. l.innerHTML = lsIndex === capturedSeries ? text : legendName;
  15709. if (capturedSeries === lsIndex) {
  15710. break;
  15711. }
  15712. } else {
  15713. l.innerHTML = w.globals.collapsedSeriesIndices.indexOf(lsIndex) < 0 ? text : legendName;
  15714. }
  15715. }
  15716. }
  15717. if (shared) {
  15718. ttCtx.tooltipLabels.drawSeriesTexts({
  15719. ttItems: ttItems,
  15720. i: capturedSeries,
  15721. j: j,
  15722. shared: this.showOnIntersect ? false : this.tConfig.shared
  15723. });
  15724. if (hasMarkers) {
  15725. if (w.globals.markers.largestSize > 0) {
  15726. ttCtx.marker.enlargePoints(j);
  15727. } else {
  15728. ttCtx.tooltipPosition.moveDynamicPointsOnHover(j);
  15729. }
  15730. }
  15731. if (this.tooltipUtil.hasBars()) {
  15732. this.barSeriesHeight = this.tooltipUtil.getBarsHeight(bars);
  15733. if (this.barSeriesHeight > 0) {
  15734. // hover state, activate snap filter
  15735. var graphics = new Graphics(this.ctx);
  15736. var paths = w.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(j, "']")); // de-activate first
  15737. this.deactivateHoverFilter();
  15738. this.tooltipPosition.moveStickyTooltipOverBars(j);
  15739. for (var b = 0; b < paths.length; b++) {
  15740. graphics.pathMouseEnter(paths[b]);
  15741. }
  15742. }
  15743. }
  15744. } else {
  15745. ttCtx.tooltipLabels.drawSeriesTexts({
  15746. shared: false,
  15747. ttItems: ttItems,
  15748. i: capturedSeries,
  15749. j: j
  15750. });
  15751. if (this.tooltipUtil.hasBars()) {
  15752. ttCtx.tooltipPosition.moveStickyTooltipOverBars(j);
  15753. }
  15754. if (hasMarkers) {
  15755. ttCtx.tooltipPosition.moveMarkers(capturedSeries, j);
  15756. }
  15757. }
  15758. }
  15759. }]);
  15760. return Tooltip;
  15761. }();
  15762. /**
  15763. * ApexCharts BarStacked Class responsible for drawing both Stacked Columns and Bars.
  15764. *
  15765. * @module BarStacked
  15766. * The whole calculation for stacked bar/column is different from normal bar/column,
  15767. * hence it makes sense to derive a new class for it extending most of the props of Parent Bar
  15768. **/
  15769. var BarStacked = /*#__PURE__*/function (_Bar) {
  15770. _inherits(BarStacked, _Bar);
  15771. function BarStacked() {
  15772. _classCallCheck(this, BarStacked);
  15773. return _possibleConstructorReturn(this, _getPrototypeOf(BarStacked).apply(this, arguments));
  15774. }
  15775. _createClass(BarStacked, [{
  15776. key: "draw",
  15777. value: function draw(series, seriesIndex) {
  15778. var _this = this;
  15779. var w = this.w;
  15780. this.graphics = new Graphics(this.ctx);
  15781. this.bar = new Bar(this.ctx, this.xyRatios);
  15782. var coreUtils = new CoreUtils(this.ctx, w);
  15783. series = coreUtils.getLogSeries(series);
  15784. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  15785. this.barHelpers.initVariables(series);
  15786. if (w.config.chart.stackType === '100%') {
  15787. series = w.globals.seriesPercent.slice();
  15788. }
  15789. this.series = series;
  15790. this.totalItems = 0;
  15791. this.prevY = []; // y position on chart
  15792. this.prevX = []; // x position on chart
  15793. this.prevYF = []; // y position including shapes on chart
  15794. this.prevXF = []; // x position including shapes on chart
  15795. this.prevYVal = []; // y values (series[i][j]) in columns
  15796. this.prevXVal = []; // x values (series[i][j]) in bars
  15797. this.xArrj = []; // xj indicates x position on graph in bars
  15798. this.xArrjF = []; // xjF indicates bar's x position + roundedShape's positions in bars
  15799. this.xArrjVal = []; // x val means the actual series's y values in horizontal/bars
  15800. this.yArrj = []; // yj indicates y position on graph in columns
  15801. this.yArrjF = []; // yjF indicates bar's y position + roundedShape's positions in columns
  15802. this.yArrjVal = []; // y val means the actual series's y values in columns
  15803. for (var sl = 0; sl < series.length; sl++) {
  15804. if (series[sl].length > 0) {
  15805. this.totalItems += series[sl].length;
  15806. }
  15807. }
  15808. var ret = this.graphics.group({
  15809. class: 'apexcharts-bar-series apexcharts-plot-series'
  15810. });
  15811. var x = 0;
  15812. var y = 0;
  15813. var _loop = function _loop(i, bc) {
  15814. var xDivision = void 0; // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  15815. var yDivision = void 0; // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
  15816. var zeroH = void 0; // zeroH is the baseline where 0 meets y axis
  15817. var zeroW = void 0; // zeroW is the baseline where 0 meets x axis
  15818. var xArrValues = [];
  15819. var yArrValues = [];
  15820. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  15821. if (_this.yRatio.length > 1) {
  15822. _this.yaxisIndex = realIndex;
  15823. }
  15824. _this.isReversed = w.config.yaxis[_this.yaxisIndex] && w.config.yaxis[_this.yaxisIndex].reversed; // el to which series will be drawn
  15825. var elSeries = _this.graphics.group({
  15826. class: "apexcharts-series",
  15827. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  15828. rel: i + 1,
  15829. 'data:realIndex': realIndex
  15830. });
  15831. _this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex); // eldatalabels
  15832. var elDataLabelsWrap = _this.graphics.group({
  15833. class: 'apexcharts-datalabels',
  15834. 'data:realIndex': realIndex
  15835. });
  15836. var barHeight = 0;
  15837. var barWidth = 0;
  15838. var initPositions = _this.initialPositions(x, y, xDivision, yDivision, zeroH, zeroW);
  15839. y = initPositions.y;
  15840. barHeight = initPositions.barHeight;
  15841. yDivision = initPositions.yDivision;
  15842. zeroW = initPositions.zeroW;
  15843. x = initPositions.x;
  15844. barWidth = initPositions.barWidth;
  15845. xDivision = initPositions.xDivision;
  15846. zeroH = initPositions.zeroH;
  15847. _this.yArrj = [];
  15848. _this.yArrjF = [];
  15849. _this.yArrjVal = [];
  15850. _this.xArrj = [];
  15851. _this.xArrjF = [];
  15852. _this.xArrjVal = []; // if (!this.horizontal) {
  15853. // this.xArrj.push(x + barWidth / 2)
  15854. // }
  15855. // fix issue #1215;
  15856. // where all stack bar disappear after collapsing the first series
  15857. // sol: if only 1 arr in this.prevY(this.prevY.length === 1) and all are NaN
  15858. if (_this.prevY.length === 1 && _this.prevY[0].every(function (val) {
  15859. return isNaN(val);
  15860. })) {
  15861. // make this.prevY[0] all zeroH
  15862. _this.prevY[0] = _this.prevY[0].map(function (val) {
  15863. return zeroH;
  15864. }); // make this.prevYF[0] all 0
  15865. _this.prevYF[0] = _this.prevYF[0].map(function (val) {
  15866. return 0;
  15867. });
  15868. }
  15869. for (var j = 0; j < w.globals.dataPoints; j++) {
  15870. var strokeWidth = _this.barHelpers.getStrokeWidth(i, j, realIndex);
  15871. var commonPathOpts = {
  15872. indexes: {
  15873. i: i,
  15874. j: j,
  15875. realIndex: realIndex,
  15876. bc: bc
  15877. },
  15878. strokeWidth: strokeWidth,
  15879. x: x,
  15880. y: y,
  15881. elSeries: elSeries
  15882. };
  15883. var paths = null;
  15884. if (_this.isHorizontal) {
  15885. paths = _this.drawStackedBarPaths(_objectSpread2({}, commonPathOpts, {
  15886. zeroW: zeroW,
  15887. barHeight: barHeight,
  15888. yDivision: yDivision
  15889. }));
  15890. barWidth = _this.series[i][j] / _this.invertedYRatio;
  15891. } else {
  15892. paths = _this.drawStackedColumnPaths(_objectSpread2({}, commonPathOpts, {
  15893. xDivision: xDivision,
  15894. barWidth: barWidth,
  15895. zeroH: zeroH
  15896. }));
  15897. barHeight = _this.series[i][j] / _this.yRatio[_this.yaxisIndex];
  15898. }
  15899. y = paths.y;
  15900. x = paths.x;
  15901. xArrValues.push(x);
  15902. yArrValues.push(y);
  15903. var pathFill = _this.barHelpers.getPathFillColor(series, i, j, realIndex);
  15904. elSeries = _this.renderSeries({
  15905. realIndex: realIndex,
  15906. pathFill: pathFill,
  15907. j: j,
  15908. i: i,
  15909. pathFrom: paths.pathFrom,
  15910. pathTo: paths.pathTo,
  15911. strokeWidth: strokeWidth,
  15912. elSeries: elSeries,
  15913. x: x,
  15914. y: y,
  15915. series: series,
  15916. barHeight: barHeight,
  15917. barWidth: barWidth,
  15918. elDataLabelsWrap: elDataLabelsWrap,
  15919. type: 'bar',
  15920. visibleSeries: 0
  15921. });
  15922. } // push all x val arrays into main xArr
  15923. w.globals.seriesXvalues[realIndex] = xArrValues;
  15924. w.globals.seriesYvalues[realIndex] = yArrValues; // push all current y values array to main PrevY Array
  15925. _this.prevY.push(_this.yArrj);
  15926. _this.prevYF.push(_this.yArrjF);
  15927. _this.prevYVal.push(_this.yArrjVal);
  15928. _this.prevX.push(_this.xArrj);
  15929. _this.prevXF.push(_this.xArrjF);
  15930. _this.prevXVal.push(_this.xArrjVal);
  15931. ret.add(elSeries);
  15932. };
  15933. for (var i = 0, bc = 0; i < series.length; i++, bc++) {
  15934. _loop(i, bc);
  15935. }
  15936. return ret;
  15937. }
  15938. }, {
  15939. key: "initialPositions",
  15940. value: function initialPositions(x, y, xDivision, yDivision, zeroH, zeroW) {
  15941. var w = this.w;
  15942. var barHeight, barWidth;
  15943. if (this.isHorizontal) {
  15944. // height divided into equal parts
  15945. yDivision = w.globals.gridHeight / w.globals.dataPoints;
  15946. barHeight = yDivision;
  15947. barHeight = barHeight * parseInt(w.config.plotOptions.bar.barHeight, 10) / 100;
  15948. 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
  15949. y = (yDivision - barHeight) / 2;
  15950. } else {
  15951. // width divided into equal parts
  15952. xDivision = w.globals.gridWidth / w.globals.dataPoints;
  15953. barWidth = xDivision;
  15954. if (w.globals.isXNumeric) {
  15955. xDivision = w.globals.minXDiff / this.xRatio;
  15956. barWidth = xDivision * parseInt(this.barOptions.columnWidth, 10) / 100;
  15957. } else {
  15958. barWidth = barWidth * parseInt(w.config.plotOptions.bar.columnWidth, 10) / 100;
  15959. }
  15960. 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
  15961. x = w.globals.padHorizontal + (xDivision - barWidth) / 2;
  15962. }
  15963. return {
  15964. x: x,
  15965. y: y,
  15966. yDivision: yDivision,
  15967. xDivision: xDivision,
  15968. barHeight: barHeight,
  15969. barWidth: barWidth,
  15970. zeroH: zeroH,
  15971. zeroW: zeroW
  15972. };
  15973. }
  15974. }, {
  15975. key: "drawStackedBarPaths",
  15976. value: function drawStackedBarPaths(_ref) {
  15977. var indexes = _ref.indexes,
  15978. barHeight = _ref.barHeight,
  15979. strokeWidth = _ref.strokeWidth,
  15980. zeroW = _ref.zeroW,
  15981. x = _ref.x,
  15982. y = _ref.y,
  15983. yDivision = _ref.yDivision,
  15984. elSeries = _ref.elSeries;
  15985. var w = this.w;
  15986. var barYPosition = y;
  15987. var barXPosition;
  15988. var i = indexes.i;
  15989. var j = indexes.j;
  15990. var bc = indexes.bc;
  15991. var prevBarW = 0;
  15992. for (var k = 0; k < this.prevXF.length; k++) {
  15993. prevBarW = prevBarW + this.prevXF[k][j];
  15994. }
  15995. if (i > 0) {
  15996. var bXP = zeroW;
  15997. if (this.prevXVal[i - 1][j] < 0) {
  15998. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] + prevBarW - (this.isReversed ? prevBarW : 0) * 2 : this.prevX[i - 1][j];
  15999. } else if (this.prevXVal[i - 1][j] >= 0) {
  16000. bXP = this.series[i][j] >= 0 ? this.prevX[i - 1][j] : this.prevX[i - 1][j] - prevBarW + (this.isReversed ? prevBarW : 0) * 2;
  16001. }
  16002. barXPosition = bXP;
  16003. } else {
  16004. // the first series will not have prevX values
  16005. barXPosition = zeroW;
  16006. }
  16007. if (this.series[i][j] === null) {
  16008. x = barXPosition;
  16009. } else {
  16010. x = barXPosition + this.series[i][j] / this.invertedYRatio - (this.isReversed ? this.series[i][j] / this.invertedYRatio : 0) * 2;
  16011. }
  16012. this.xArrj.push(x);
  16013. this.xArrjF.push(Math.abs(barXPosition - x));
  16014. this.xArrjVal.push(this.series[i][j]);
  16015. var paths = this.barHelpers.getBarpaths({
  16016. barYPosition: barYPosition,
  16017. barHeight: barHeight,
  16018. x1: barXPosition,
  16019. x2: x,
  16020. strokeWidth: strokeWidth,
  16021. series: this.series,
  16022. realIndex: indexes.realIndex,
  16023. i: i,
  16024. j: j,
  16025. w: w
  16026. });
  16027. this.barHelpers.barBackground({
  16028. bc: bc,
  16029. i: i,
  16030. y1: barYPosition,
  16031. y2: barHeight,
  16032. elSeries: elSeries
  16033. });
  16034. y = y + yDivision;
  16035. return {
  16036. pathTo: paths.pathTo,
  16037. pathFrom: paths.pathFrom,
  16038. x: x,
  16039. y: y
  16040. };
  16041. }
  16042. }, {
  16043. key: "drawStackedColumnPaths",
  16044. value: function drawStackedColumnPaths(_ref2) {
  16045. var indexes = _ref2.indexes,
  16046. x = _ref2.x,
  16047. y = _ref2.y,
  16048. xDivision = _ref2.xDivision,
  16049. barWidth = _ref2.barWidth,
  16050. zeroH = _ref2.zeroH,
  16051. strokeWidth = _ref2.strokeWidth,
  16052. elSeries = _ref2.elSeries;
  16053. var w = this.w;
  16054. var i = indexes.i;
  16055. var j = indexes.j;
  16056. var bc = indexes.bc;
  16057. if (w.globals.isXNumeric) {
  16058. var seriesVal = w.globals.seriesX[i][j];
  16059. if (!seriesVal) seriesVal = 0;
  16060. x = (seriesVal - w.globals.minX) / this.xRatio - barWidth / 2;
  16061. }
  16062. var barXPosition = x;
  16063. var barYPosition;
  16064. var prevBarH = 0;
  16065. for (var k = 0; k < this.prevYF.length; k++) {
  16066. // fix issue #1215
  16067. // in case where this.prevYF[k][j] is NaN, use 0 instead
  16068. prevBarH = prevBarH + (!isNaN(this.prevYF[k][j]) ? this.prevYF[k][j] : 0);
  16069. }
  16070. if (i > 0 && !w.globals.isXNumeric || i > 0 && w.globals.isXNumeric && w.globals.seriesX[i - 1][j] === w.globals.seriesX[i][j]) {
  16071. var bYP;
  16072. var prevYValue;
  16073. var p = Math.min(this.yRatio.length + 1, i + 1);
  16074. if (this.prevY[i - 1] !== undefined) {
  16075. for (var ii = 1; ii < p; ii++) {
  16076. if (!isNaN(this.prevY[i - ii][j])) {
  16077. // find the previous available value to give prevYValue
  16078. prevYValue = this.prevY[i - ii][j]; // if found it, break the loop
  16079. break;
  16080. }
  16081. }
  16082. }
  16083. for (var _ii = 1; _ii < p; _ii++) {
  16084. // find the previous available value(non-NaN) to give bYP
  16085. if (this.prevYVal[i - _ii][j] < 0) {
  16086. bYP = this.series[i][j] >= 0 ? prevYValue - prevBarH + (this.isReversed ? prevBarH : 0) * 2 : prevYValue; // found it? break the loop
  16087. break;
  16088. } else if (this.prevYVal[i - _ii][j] >= 0) {
  16089. bYP = this.series[i][j] >= 0 ? prevYValue : prevYValue + prevBarH - (this.isReversed ? prevBarH : 0) * 2; // found it? break the loop
  16090. break;
  16091. }
  16092. }
  16093. if (typeof bYP === 'undefined') bYP = w.globals.gridHeight; // if this.prevYF[0] is all 0 resulted from line #486
  16094. // AND every arr starting from the second only contains NaN
  16095. if (this.prevYF[0].every(function (val) {
  16096. return val === 0;
  16097. }) && this.prevYF.slice(1, i).every(function (arr) {
  16098. return arr.every(function (val) {
  16099. return isNaN(val);
  16100. });
  16101. })) {
  16102. // Use the same calc way as line #485
  16103. barYPosition = w.globals.gridHeight - zeroH;
  16104. } else {
  16105. // Nothing special
  16106. barYPosition = bYP;
  16107. }
  16108. } else {
  16109. // 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
  16110. barYPosition = w.globals.gridHeight - zeroH;
  16111. }
  16112. y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex] + (this.isReversed ? this.series[i][j] / this.yRatio[this.yaxisIndex] : 0) * 2;
  16113. this.yArrj.push(y);
  16114. this.yArrjF.push(Math.abs(barYPosition - y));
  16115. this.yArrjVal.push(this.series[i][j]);
  16116. var paths = this.barHelpers.getColumnPaths({
  16117. barXPosition: barXPosition,
  16118. barWidth: barWidth,
  16119. y1: barYPosition,
  16120. y2: y,
  16121. yRatio: this.yRatio[this.yaxisIndex],
  16122. strokeWidth: this.strokeWidth,
  16123. series: this.series,
  16124. realIndex: indexes.realIndex,
  16125. i: i,
  16126. j: j,
  16127. w: w
  16128. });
  16129. this.barHelpers.barBackground({
  16130. bc: bc,
  16131. i: i,
  16132. x1: barXPosition,
  16133. x2: barWidth,
  16134. elSeries: elSeries
  16135. });
  16136. x = x + xDivision;
  16137. return {
  16138. pathTo: paths.pathTo,
  16139. pathFrom: paths.pathFrom,
  16140. x: w.globals.isXNumeric ? x - xDivision : x,
  16141. y: y
  16142. };
  16143. }
  16144. }]);
  16145. return BarStacked;
  16146. }(Bar);
  16147. /**
  16148. * ApexCharts CandleStick Class responsible for drawing both Stacked Columns and Bars.
  16149. *
  16150. * @module CandleStick
  16151. **/
  16152. var CandleStick = /*#__PURE__*/function (_Bar) {
  16153. _inherits(CandleStick, _Bar);
  16154. function CandleStick() {
  16155. _classCallCheck(this, CandleStick);
  16156. return _possibleConstructorReturn(this, _getPrototypeOf(CandleStick).apply(this, arguments));
  16157. }
  16158. _createClass(CandleStick, [{
  16159. key: "draw",
  16160. value: function draw(series, seriesIndex) {
  16161. var w = this.w;
  16162. var graphics = new Graphics(this.ctx);
  16163. var fill = new Fill(this.ctx);
  16164. this.candlestickOptions = this.w.config.plotOptions.candlestick;
  16165. var coreUtils = new CoreUtils(this.ctx, w);
  16166. series = coreUtils.getLogSeries(series);
  16167. this.series = series;
  16168. this.yRatio = coreUtils.getLogYRatios(this.yRatio);
  16169. this.barHelpers.initVariables(series);
  16170. var ret = graphics.group({
  16171. class: 'apexcharts-candlestick-series apexcharts-plot-series'
  16172. });
  16173. for (var i = 0; i < series.length; i++) {
  16174. var x = void 0,
  16175. y = void 0,
  16176. xDivision = void 0,
  16177. // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
  16178. zeroH = void 0; // zeroH is the baseline where 0 meets y axis
  16179. var yArrj = []; // hold y values of current iterating series
  16180. var xArrj = []; // hold x values of current iterating series
  16181. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn
  16182. var elSeries = graphics.group({
  16183. class: "apexcharts-series",
  16184. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex]),
  16185. rel: i + 1,
  16186. 'data:realIndex': realIndex
  16187. });
  16188. if (series[i].length > 0) {
  16189. this.visibleI = this.visibleI + 1;
  16190. }
  16191. var barHeight = 0;
  16192. var barWidth = 0;
  16193. if (this.yRatio.length > 1) {
  16194. this.yaxisIndex = realIndex;
  16195. }
  16196. var initPositions = this.barHelpers.initialPositions();
  16197. y = initPositions.y;
  16198. barHeight = initPositions.barHeight;
  16199. x = initPositions.x;
  16200. barWidth = initPositions.barWidth;
  16201. xDivision = initPositions.xDivision;
  16202. zeroH = initPositions.zeroH;
  16203. xArrj.push(x + barWidth / 2); // eldatalabels
  16204. var elDataLabelsWrap = graphics.group({
  16205. class: 'apexcharts-datalabels',
  16206. 'data:realIndex': realIndex
  16207. });
  16208. for (var j = 0; j < w.globals.dataPoints; j++) {
  16209. var strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex);
  16210. var color = void 0;
  16211. var paths = this.drawCandleStickPaths({
  16212. indexes: {
  16213. i: i,
  16214. j: j,
  16215. realIndex: realIndex
  16216. },
  16217. x: x,
  16218. y: y,
  16219. xDivision: xDivision,
  16220. barWidth: barWidth,
  16221. zeroH: zeroH,
  16222. strokeWidth: strokeWidth,
  16223. elSeries: elSeries
  16224. });
  16225. y = paths.y;
  16226. x = paths.x;
  16227. color = paths.color; // push current X
  16228. if (j > 0) {
  16229. xArrj.push(x + barWidth / 2);
  16230. }
  16231. yArrj.push(y);
  16232. var pathFill = fill.fillPath({
  16233. seriesNumber: realIndex,
  16234. dataPointIndex: j,
  16235. color: color,
  16236. value: series[i][j]
  16237. });
  16238. var lineFill = this.candlestickOptions.wick.useFillColor ? color : undefined;
  16239. this.renderSeries({
  16240. realIndex: realIndex,
  16241. pathFill: pathFill,
  16242. lineFill: lineFill,
  16243. j: j,
  16244. i: i,
  16245. pathFrom: paths.pathFrom,
  16246. pathTo: paths.pathTo,
  16247. strokeWidth: strokeWidth,
  16248. elSeries: elSeries,
  16249. x: x,
  16250. y: y,
  16251. series: series,
  16252. barHeight: barHeight,
  16253. barWidth: barWidth,
  16254. elDataLabelsWrap: elDataLabelsWrap,
  16255. visibleSeries: this.visibleI,
  16256. type: 'candlestick'
  16257. });
  16258. } // push all x val arrays into main xArr
  16259. w.globals.seriesXvalues[realIndex] = xArrj;
  16260. w.globals.seriesYvalues[realIndex] = yArrj;
  16261. ret.add(elSeries);
  16262. }
  16263. return ret;
  16264. }
  16265. }, {
  16266. key: "drawCandleStickPaths",
  16267. value: function drawCandleStickPaths(_ref) {
  16268. var indexes = _ref.indexes,
  16269. x = _ref.x,
  16270. y = _ref.y,
  16271. xDivision = _ref.xDivision,
  16272. barWidth = _ref.barWidth,
  16273. zeroH = _ref.zeroH,
  16274. strokeWidth = _ref.strokeWidth;
  16275. var w = this.w;
  16276. var graphics = new Graphics(this.ctx);
  16277. var i = indexes.i;
  16278. var j = indexes.j;
  16279. var isPositive = true;
  16280. var colorPos = w.config.plotOptions.candlestick.colors.upward;
  16281. var colorNeg = w.config.plotOptions.candlestick.colors.downward;
  16282. var yRatio = this.yRatio[this.yaxisIndex];
  16283. var realIndex = indexes.realIndex;
  16284. var ohlc = this.getOHLCValue(realIndex, j);
  16285. var l1 = zeroH;
  16286. var l2 = zeroH;
  16287. if (ohlc.o > ohlc.c) {
  16288. isPositive = false;
  16289. }
  16290. var y1 = Math.min(ohlc.o, ohlc.c);
  16291. var y2 = Math.max(ohlc.o, ohlc.c);
  16292. if (w.globals.isXNumeric) {
  16293. x = (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio - barWidth / 2;
  16294. }
  16295. var barXPosition = x + barWidth * this.visibleI;
  16296. if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) {
  16297. y1 = zeroH;
  16298. } else {
  16299. y1 = zeroH - y1 / yRatio;
  16300. y2 = zeroH - y2 / yRatio;
  16301. l1 = zeroH - ohlc.h / yRatio;
  16302. l2 = zeroH - ohlc.l / yRatio;
  16303. }
  16304. var pathTo = graphics.move(barXPosition, zeroH);
  16305. var pathFrom = graphics.move(barXPosition, y1);
  16306. if (w.globals.previousPaths.length > 0) {
  16307. pathFrom = this.getPreviousPath(realIndex, j, true);
  16308. }
  16309. 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);
  16310. pathFrom = pathFrom + graphics.move(barXPosition, y1);
  16311. if (!w.globals.isXNumeric) {
  16312. x = x + xDivision;
  16313. }
  16314. return {
  16315. pathTo: pathTo,
  16316. pathFrom: pathFrom,
  16317. x: x,
  16318. y: y2,
  16319. barXPosition: barXPosition,
  16320. color: isPositive ? colorPos : colorNeg
  16321. };
  16322. }
  16323. }, {
  16324. key: "getOHLCValue",
  16325. value: function getOHLCValue(i, j) {
  16326. var w = this.w;
  16327. return {
  16328. o: w.globals.seriesCandleO[i][j],
  16329. h: w.globals.seriesCandleH[i][j],
  16330. l: w.globals.seriesCandleL[i][j],
  16331. c: w.globals.seriesCandleC[i][j]
  16332. };
  16333. }
  16334. }]);
  16335. return CandleStick;
  16336. }(Bar);
  16337. /**
  16338. * ApexCharts HeatMap Class.
  16339. * @module HeatMap
  16340. **/
  16341. var HeatMap = /*#__PURE__*/function () {
  16342. function HeatMap(ctx, xyRatios) {
  16343. _classCallCheck(this, HeatMap);
  16344. this.ctx = ctx;
  16345. this.w = ctx.w;
  16346. this.xRatio = xyRatios.xRatio;
  16347. this.yRatio = xyRatios.yRatio;
  16348. this.negRange = false;
  16349. this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation;
  16350. this.rectRadius = this.w.config.plotOptions.heatmap.radius;
  16351. this.strokeWidth = this.w.config.stroke.show ? this.w.config.stroke.width : 0;
  16352. }
  16353. _createClass(HeatMap, [{
  16354. key: "draw",
  16355. value: function draw(series) {
  16356. var w = this.w;
  16357. var graphics = new Graphics(this.ctx);
  16358. var ret = graphics.group({
  16359. class: 'apexcharts-heatmap'
  16360. });
  16361. ret.attr('clip-path', "url(#gridRectMask".concat(w.globals.cuid, ")")); // width divided into equal parts
  16362. var xDivision = w.globals.gridWidth / w.globals.dataPoints;
  16363. var yDivision = w.globals.gridHeight / w.globals.series.length;
  16364. var y1 = 0;
  16365. var rev = false;
  16366. this.checkColorRange();
  16367. var heatSeries = series.slice();
  16368. if (w.config.yaxis[0].reversed) {
  16369. rev = true;
  16370. heatSeries.reverse();
  16371. }
  16372. for (var i = rev ? 0 : heatSeries.length - 1; rev ? i < heatSeries.length : i >= 0; rev ? i++ : i--) {
  16373. // el to which series will be drawn
  16374. var elSeries = graphics.group({
  16375. class: "apexcharts-series apexcharts-heatmap-series",
  16376. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  16377. rel: i + 1,
  16378. 'data:realIndex': i
  16379. });
  16380. this.ctx.series.addCollapsedClassToSeries(elSeries, i);
  16381. if (w.config.chart.dropShadow.enabled) {
  16382. var shadow = w.config.chart.dropShadow;
  16383. var filters = new Filters(this.ctx);
  16384. filters.dropShadow(elSeries, shadow, i);
  16385. }
  16386. var x1 = 0;
  16387. for (var j = 0; j < heatSeries[i].length; j++) {
  16388. var colorShadePercent = 1;
  16389. var shadeIntensity = w.config.plotOptions.heatmap.shadeIntensity;
  16390. var heatColorProps = this.determineHeatColor(i, j);
  16391. if (w.globals.hasNegs || this.negRange) {
  16392. if (w.config.plotOptions.heatmap.reverseNegativeShade) {
  16393. if (heatColorProps.percent < 0) {
  16394. colorShadePercent = heatColorProps.percent / 100 * (shadeIntensity * 1.25);
  16395. } else {
  16396. colorShadePercent = (1 - heatColorProps.percent / 100) * (shadeIntensity * 1.25);
  16397. }
  16398. } else {
  16399. if (heatColorProps.percent <= 0) {
  16400. colorShadePercent = 1 - (1 + heatColorProps.percent / 100) * shadeIntensity;
  16401. } else {
  16402. colorShadePercent = (1 - heatColorProps.percent / 100) * shadeIntensity;
  16403. }
  16404. }
  16405. } else {
  16406. colorShadePercent = 1 - heatColorProps.percent / 100;
  16407. }
  16408. var color = heatColorProps.color;
  16409. var utils = new Utils();
  16410. if (w.config.plotOptions.heatmap.enableShades) {
  16411. if (colorShadePercent < 0) colorShadePercent = 0;
  16412. color = Utils.hexToRgba(utils.shadeColor(colorShadePercent, heatColorProps.color), w.config.fill.opacity);
  16413. }
  16414. if (w.config.fill.type === 'image') {
  16415. var fill = new Fill(this.ctx);
  16416. color = fill.fillPath({
  16417. seriesNumber: i,
  16418. dataPointIndex: j,
  16419. opacity: w.globals.hasNegs ? heatColorProps.percent < 0 ? 1 - (1 + heatColorProps.percent / 100) : shadeIntensity + heatColorProps.percent / 100 : heatColorProps.percent / 100,
  16420. patternID: Utils.randomId(),
  16421. width: w.config.fill.image.width ? w.config.fill.image.width : xDivision,
  16422. height: w.config.fill.image.height ? w.config.fill.image.height : yDivision
  16423. });
  16424. }
  16425. var radius = this.rectRadius;
  16426. var rect = graphics.drawRect(x1, y1, xDivision, yDivision, radius);
  16427. rect.attr({
  16428. cx: x1,
  16429. cy: y1
  16430. });
  16431. rect.node.classList.add('apexcharts-heatmap-rect');
  16432. elSeries.add(rect);
  16433. rect.attr({
  16434. fill: color,
  16435. i: i,
  16436. index: i,
  16437. j: j,
  16438. val: heatSeries[i][j],
  16439. 'stroke-width': this.strokeWidth,
  16440. stroke: w.config.plotOptions.heatmap.useFillColorAsStroke ? color : w.globals.stroke.colors[0],
  16441. color: color
  16442. });
  16443. rect.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, rect));
  16444. rect.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, rect));
  16445. rect.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, rect));
  16446. if (w.config.chart.animations.enabled && !w.globals.dataChanged) {
  16447. var speed = 1;
  16448. if (!w.globals.resized) {
  16449. speed = w.config.chart.animations.speed;
  16450. }
  16451. this.animateHeatMap(rect, x1, y1, xDivision, yDivision, speed);
  16452. }
  16453. if (w.globals.dataChanged) {
  16454. var _speed = 1;
  16455. if (this.dynamicAnim.enabled && w.globals.shouldAnimate) {
  16456. _speed = this.dynamicAnim.speed;
  16457. var colorFrom = w.globals.previousPaths[i] && w.globals.previousPaths[i][j] && w.globals.previousPaths[i][j].color;
  16458. if (!colorFrom) colorFrom = 'rgba(255, 255, 255, 0)';
  16459. this.animateHeatColor(rect, Utils.isColorHex(colorFrom) ? colorFrom : Utils.rgb2hex(colorFrom), Utils.isColorHex(color) ? color : Utils.rgb2hex(color), _speed);
  16460. }
  16461. }
  16462. var dataLabels = this.calculateHeatmapDataLabels({
  16463. x: x1,
  16464. y: y1,
  16465. i: i,
  16466. j: j,
  16467. heatColorProps: heatColorProps,
  16468. series: heatSeries,
  16469. rectHeight: yDivision,
  16470. rectWidth: xDivision
  16471. });
  16472. if (dataLabels !== null) {
  16473. elSeries.add(dataLabels);
  16474. }
  16475. x1 = x1 + xDivision;
  16476. }
  16477. y1 = y1 + yDivision;
  16478. ret.add(elSeries);
  16479. } // adjust yaxis labels for heatmap
  16480. var yAxisScale = w.globals.yAxisScale[0].result.slice();
  16481. if (w.config.yaxis[0].reversed) {
  16482. yAxisScale.unshift('');
  16483. } else {
  16484. yAxisScale.push('');
  16485. }
  16486. w.globals.yAxisScale[0].result = yAxisScale;
  16487. var divisor = w.globals.gridHeight / w.globals.series.length;
  16488. w.config.yaxis[0].labels.offsetY = -(divisor / 2);
  16489. return ret;
  16490. }
  16491. }, {
  16492. key: "checkColorRange",
  16493. value: function checkColorRange() {
  16494. var _this = this;
  16495. var w = this.w;
  16496. var heatmap = w.config.plotOptions.heatmap;
  16497. if (heatmap.colorScale.ranges.length > 0) {
  16498. heatmap.colorScale.ranges.map(function (range, index) {
  16499. if (range.from <= 0) {
  16500. _this.negRange = true;
  16501. }
  16502. });
  16503. }
  16504. }
  16505. }, {
  16506. key: "determineHeatColor",
  16507. value: function determineHeatColor(i, j) {
  16508. var w = this.w;
  16509. var val = w.globals.series[i][j];
  16510. var heatmap = w.config.plotOptions.heatmap;
  16511. var seriesNumber = heatmap.colorScale.inverse ? j : i;
  16512. var color = w.globals.colors[seriesNumber];
  16513. var foreColor = null;
  16514. var min = Math.min.apply(Math, _toConsumableArray(w.globals.series[i]));
  16515. var max = Math.max.apply(Math, _toConsumableArray(w.globals.series[i]));
  16516. if (!heatmap.distributed) {
  16517. min = w.globals.minY;
  16518. max = w.globals.maxY;
  16519. }
  16520. if (typeof heatmap.colorScale.min !== 'undefined') {
  16521. min = heatmap.colorScale.min < w.globals.minY ? heatmap.colorScale.min : w.globals.minY;
  16522. max = heatmap.colorScale.max > w.globals.maxY ? heatmap.colorScale.max : w.globals.maxY;
  16523. }
  16524. var total = Math.abs(max) + Math.abs(min);
  16525. var percent = 100 * val / (total === 0 ? total - 0.000001 : total);
  16526. if (heatmap.colorScale.ranges.length > 0) {
  16527. var colorRange = heatmap.colorScale.ranges;
  16528. colorRange.map(function (range, index) {
  16529. if (val >= range.from && val <= range.to) {
  16530. color = range.color;
  16531. foreColor = range.foreColor ? range.foreColor : null;
  16532. min = range.from;
  16533. max = range.to;
  16534. var rTotal = Math.abs(max) + Math.abs(min);
  16535. percent = 100 * val / (rTotal === 0 ? rTotal - 0.000001 : rTotal);
  16536. }
  16537. });
  16538. }
  16539. return {
  16540. color: color,
  16541. foreColor: foreColor,
  16542. percent: percent
  16543. };
  16544. }
  16545. }, {
  16546. key: "calculateHeatmapDataLabels",
  16547. value: function calculateHeatmapDataLabels(_ref) {
  16548. var x = _ref.x,
  16549. y = _ref.y,
  16550. i = _ref.i,
  16551. j = _ref.j,
  16552. heatColorProps = _ref.heatColorProps,
  16553. series = _ref.series,
  16554. rectHeight = _ref.rectHeight,
  16555. rectWidth = _ref.rectWidth;
  16556. var w = this.w; // let graphics = new Graphics(this.ctx)
  16557. var dataLabelsConfig = w.config.dataLabels;
  16558. var graphics = new Graphics(this.ctx);
  16559. var dataLabels = new DataLabels(this.ctx);
  16560. var formatter = dataLabelsConfig.formatter;
  16561. var elDataLabelsWrap = null;
  16562. if (dataLabelsConfig.enabled) {
  16563. elDataLabelsWrap = graphics.group({
  16564. class: 'apexcharts-data-labels'
  16565. });
  16566. var offX = dataLabelsConfig.offsetX;
  16567. var offY = dataLabelsConfig.offsetY;
  16568. var dataLabelsX = x + rectWidth / 2 + offX;
  16569. var dataLabelsY = y + rectHeight / 2 + parseFloat(dataLabelsConfig.style.fontSize) / 3 + offY;
  16570. var text = formatter(w.globals.series[i][j], {
  16571. seriesIndex: i,
  16572. dataPointIndex: j,
  16573. w: w
  16574. });
  16575. dataLabels.plotDataLabelsText({
  16576. x: dataLabelsX,
  16577. y: dataLabelsY,
  16578. text: text,
  16579. i: i,
  16580. j: j,
  16581. color: heatColorProps.foreColor,
  16582. parent: elDataLabelsWrap,
  16583. dataLabelsConfig: dataLabelsConfig
  16584. });
  16585. }
  16586. return elDataLabelsWrap;
  16587. }
  16588. }, {
  16589. key: "animateHeatMap",
  16590. value: function animateHeatMap(el, x, y, width, height, speed) {
  16591. var animations = new Animations(this.ctx);
  16592. animations.animateRect(el, {
  16593. x: x + width / 2,
  16594. y: y + height / 2,
  16595. width: 0,
  16596. height: 0
  16597. }, {
  16598. x: x,
  16599. y: y,
  16600. width: width,
  16601. height: height
  16602. }, speed, function () {
  16603. animations.animationCompleted(el);
  16604. });
  16605. }
  16606. }, {
  16607. key: "animateHeatColor",
  16608. value: function animateHeatColor(el, colorFrom, colorTo, speed) {
  16609. el.attr({
  16610. fill: colorFrom
  16611. }).animate(speed).attr({
  16612. fill: colorTo
  16613. });
  16614. }
  16615. }]);
  16616. return HeatMap;
  16617. }();
  16618. var CircularChartsHelpers = /*#__PURE__*/function () {
  16619. function CircularChartsHelpers(ctx) {
  16620. _classCallCheck(this, CircularChartsHelpers);
  16621. this.ctx = ctx;
  16622. this.w = ctx.w;
  16623. }
  16624. _createClass(CircularChartsHelpers, [{
  16625. key: "drawYAxisTexts",
  16626. value: function drawYAxisTexts(x, y, i, text) {
  16627. var w = this.w;
  16628. var yaxisConfig = w.config.yaxis[0];
  16629. var formatter = w.globals.yLabelFormatters[0];
  16630. var graphics = new Graphics(this.ctx);
  16631. var yaxisLabel = graphics.drawText({
  16632. x: x + yaxisConfig.labels.offsetX,
  16633. y: y + yaxisConfig.labels.offsetY,
  16634. text: formatter(text, i),
  16635. textAnchor: 'middle',
  16636. fontSize: yaxisConfig.labels.style.fontSize,
  16637. fontFamily: yaxisConfig.labels.style.fontFamily,
  16638. foreColor: Array.isArray(yaxisConfig.labels.style.colors) ? yaxisConfig.labels.style.colors[i] : yaxisConfig.labels.style.colors
  16639. });
  16640. return yaxisLabel;
  16641. }
  16642. }]);
  16643. return CircularChartsHelpers;
  16644. }();
  16645. /**
  16646. * ApexCharts Pie Class for drawing Pie / Donut Charts.
  16647. * @module Pie
  16648. **/
  16649. var Pie = /*#__PURE__*/function () {
  16650. function Pie(ctx) {
  16651. _classCallCheck(this, Pie);
  16652. this.ctx = ctx;
  16653. this.w = ctx.w;
  16654. this.chartType = this.w.config.chart.type;
  16655. this.initialAnim = this.w.config.chart.animations.enabled;
  16656. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  16657. this.animBeginArr = [0];
  16658. this.animDur = 0;
  16659. this.donutDataLabels = this.w.config.plotOptions.pie.donut.labels;
  16660. var w = this.w;
  16661. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  16662. this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight : w.globals.gridWidth;
  16663. this.centerY = this.defaultSize / 2;
  16664. this.centerX = w.globals.gridWidth / 2;
  16665. this.fullAngle = 360;
  16666. w.globals.radialSize = this.defaultSize / 2.05 - w.config.stroke.width - (!w.config.chart.sparkline.enabled ? w.config.chart.dropShadow.blur : 0);
  16667. this.donutSize = w.globals.radialSize * parseInt(w.config.plotOptions.pie.donut.size, 10) / 100;
  16668. this.maxY = 0;
  16669. this.sliceLabels = [];
  16670. this.sliceSizes = [];
  16671. this.prevSectorAngleArr = []; // for dynamic animations
  16672. }
  16673. _createClass(Pie, [{
  16674. key: "draw",
  16675. value: function draw(series) {
  16676. var _this = this;
  16677. var self = this;
  16678. var w = this.w;
  16679. var graphics = new Graphics(this.ctx);
  16680. this.ret = graphics.group({
  16681. class: 'apexcharts-pie'
  16682. });
  16683. if (w.globals.noData) return this.ret;
  16684. var total = 0;
  16685. for (var k = 0; k < series.length; k++) {
  16686. // CALCULATE THE TOTAL
  16687. total += Utils.negToZero(series[k]);
  16688. }
  16689. var sectorAngleArr = []; // el to which series will be drawn
  16690. var elSeries = graphics.group(); // prevent division by zero error if there is no data
  16691. if (total === 0) {
  16692. total = 0.00001;
  16693. }
  16694. series.forEach(function (m) {
  16695. _this.maxY = Math.max(_this.maxY, m);
  16696. });
  16697. if (this.chartType === 'polarArea') {
  16698. this.drawPolarElements();
  16699. }
  16700. for (var i = 0; i < series.length; i++) {
  16701. // CALCULATE THE ANGLES
  16702. var angle = this.fullAngle * Utils.negToZero(series[i]) / total;
  16703. sectorAngleArr.push(angle);
  16704. if (this.chartType === 'polarArea') {
  16705. sectorAngleArr[i] = this.fullAngle / series.length;
  16706. this.sliceSizes.push(w.globals.radialSize * series[i] / this.maxY);
  16707. } else {
  16708. this.sliceSizes.push(w.globals.radialSize);
  16709. }
  16710. }
  16711. if (w.globals.dataChanged) {
  16712. var prevTotal = 0;
  16713. for (var _k = 0; _k < w.globals.previousPaths.length; _k++) {
  16714. // CALCULATE THE PREV TOTAL
  16715. prevTotal += Utils.negToZero(w.globals.previousPaths[_k]);
  16716. }
  16717. var previousAngle;
  16718. for (var _i = 0; _i < w.globals.previousPaths.length; _i++) {
  16719. // CALCULATE THE PREVIOUS ANGLES
  16720. previousAngle = this.fullAngle * Utils.negToZero(w.globals.previousPaths[_i]) / prevTotal;
  16721. this.prevSectorAngleArr.push(previousAngle);
  16722. }
  16723. } // on small chart size after few count of resizes browser window donutSize can be negative
  16724. if (this.donutSize < 0) {
  16725. this.donutSize = 0;
  16726. }
  16727. var scaleSize = w.config.plotOptions.pie.customScale;
  16728. var halfW = w.globals.gridWidth / 2;
  16729. var halfH = w.globals.gridHeight / 2;
  16730. var translateX = halfW - w.globals.gridWidth / 2 * scaleSize;
  16731. var translateY = halfH - w.globals.gridHeight / 2 * scaleSize;
  16732. if (this.chartType === 'donut') {
  16733. // draw the inner circle and add some text to it
  16734. var circle = graphics.drawCircle(this.donutSize);
  16735. circle.attr({
  16736. cx: this.centerX,
  16737. cy: this.centerY,
  16738. fill: w.config.plotOptions.pie.donut.background ? w.config.plotOptions.pie.donut.background : 'transparent'
  16739. });
  16740. elSeries.add(circle);
  16741. }
  16742. var elG = self.drawArcs(sectorAngleArr, series); // add slice dataLabels at the end
  16743. this.sliceLabels.forEach(function (s) {
  16744. elG.add(s);
  16745. });
  16746. elSeries.attr({
  16747. transform: "translate(".concat(translateX, ", ").concat(translateY, ") scale(").concat(scaleSize, ")")
  16748. });
  16749. elSeries.add(elG);
  16750. this.ret.add(elSeries);
  16751. if (this.donutDataLabels.show) {
  16752. var dataLabels = this.renderInnerDataLabels(this.donutDataLabels, {
  16753. hollowSize: this.donutSize,
  16754. centerX: this.centerX,
  16755. centerY: this.centerY,
  16756. opacity: this.donutDataLabels.show,
  16757. translateX: translateX,
  16758. translateY: translateY
  16759. });
  16760. this.ret.add(dataLabels);
  16761. }
  16762. return this.ret;
  16763. } // core function for drawing pie arcs
  16764. }, {
  16765. key: "drawArcs",
  16766. value: function drawArcs(sectorAngleArr, series) {
  16767. var w = this.w;
  16768. var filters = new Filters(this.ctx);
  16769. var graphics = new Graphics(this.ctx);
  16770. var fill = new Fill(this.ctx);
  16771. var g = graphics.group({
  16772. class: 'apexcharts-slices'
  16773. });
  16774. var startAngle = 0;
  16775. var prevStartAngle = 0;
  16776. var endAngle = 0;
  16777. var prevEndAngle = 0;
  16778. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  16779. for (var i = 0; i < sectorAngleArr.length; i++) {
  16780. var elPieArc = graphics.group({
  16781. class: "apexcharts-series apexcharts-pie-series",
  16782. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  16783. rel: i + 1,
  16784. 'data:realIndex': i
  16785. });
  16786. g.add(elPieArc);
  16787. startAngle = endAngle;
  16788. prevStartAngle = prevEndAngle;
  16789. endAngle = startAngle + sectorAngleArr[i];
  16790. prevEndAngle = prevStartAngle + this.prevSectorAngleArr[i];
  16791. var angle = endAngle - startAngle;
  16792. var pathFill = fill.fillPath({
  16793. seriesNumber: i,
  16794. size: this.sliceSizes[i],
  16795. value: series[i]
  16796. }); // additionaly, pass size for gradient drawing in the fillPath function
  16797. var path = this.getChangedPath(prevStartAngle, prevEndAngle);
  16798. var elPath = graphics.drawPath({
  16799. d: path,
  16800. stroke: this.lineColorArr instanceof Array ? this.lineColorArr[i] : this.lineColorArr,
  16801. strokeWidth: 0,
  16802. fill: pathFill,
  16803. fillOpacity: w.config.fill.opacity,
  16804. classes: "apexcharts-pie-area apexcharts-".concat(this.chartType.toLowerCase(), "-slice-").concat(i)
  16805. });
  16806. elPath.attr({
  16807. index: 0,
  16808. j: i
  16809. });
  16810. if (w.config.chart.dropShadow.enabled) {
  16811. var shadow = w.config.chart.dropShadow;
  16812. filters.dropShadow(elPath, shadow, i);
  16813. }
  16814. this.addListeners(elPath, this.donutDataLabels);
  16815. Graphics.setAttrs(elPath.node, {
  16816. 'data:angle': angle,
  16817. 'data:startAngle': startAngle,
  16818. 'data:strokeWidth': this.strokeWidth,
  16819. 'data:value': series[i]
  16820. });
  16821. var labelPosition = {
  16822. x: 0,
  16823. y: 0
  16824. };
  16825. if (this.chartType === 'pie' || this.chartType === 'polarArea') {
  16826. labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, w.globals.radialSize / 1.25 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
  16827. } else if (this.chartType === 'donut') {
  16828. labelPosition = Utils.polarToCartesian(this.centerX, this.centerY, (w.globals.radialSize + this.donutSize) / 2 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2);
  16829. }
  16830. elPieArc.add(elPath); // Animation code starts
  16831. var dur = 0;
  16832. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  16833. dur = (endAngle - startAngle) / this.fullAngle * w.config.chart.animations.speed;
  16834. if (dur === 0) dur = 1;
  16835. this.animDur = dur + this.animDur;
  16836. this.animBeginArr.push(this.animDur);
  16837. } else {
  16838. this.animBeginArr.push(0);
  16839. }
  16840. if (this.dynamicAnim && w.globals.dataChanged) {
  16841. this.animatePaths(elPath, {
  16842. size: this.sliceSizes[i],
  16843. endAngle: endAngle,
  16844. startAngle: startAngle,
  16845. prevStartAngle: prevStartAngle,
  16846. prevEndAngle: prevEndAngle,
  16847. animateStartingPos: true,
  16848. i: i,
  16849. animBeginArr: this.animBeginArr,
  16850. shouldSetPrevPaths: true,
  16851. dur: w.config.chart.animations.dynamicAnimation.speed
  16852. });
  16853. } else {
  16854. this.animatePaths(elPath, {
  16855. size: this.sliceSizes[i],
  16856. endAngle: endAngle,
  16857. startAngle: startAngle,
  16858. i: i,
  16859. totalItems: sectorAngleArr.length - 1,
  16860. animBeginArr: this.animBeginArr,
  16861. dur: dur
  16862. });
  16863. } // animation code ends
  16864. if (w.config.plotOptions.pie.expandOnClick && this.chartType !== 'polarArea') {
  16865. elPath.click(this.pieClicked.bind(this, i));
  16866. }
  16867. if (w.config.dataLabels.enabled) {
  16868. var xPos = labelPosition.x;
  16869. var yPos = labelPosition.y;
  16870. var text = 100 * (endAngle - startAngle) / 360 + '%';
  16871. if (angle !== 0 && w.config.plotOptions.pie.dataLabels.minAngleToShowLabel < sectorAngleArr[i]) {
  16872. var formatter = w.config.dataLabels.formatter;
  16873. if (formatter !== undefined) {
  16874. text = formatter(w.globals.seriesPercent[i][0], {
  16875. seriesIndex: i,
  16876. w: w
  16877. });
  16878. }
  16879. var foreColor = w.globals.dataLabels.style.colors[i];
  16880. var elPieLabel = graphics.drawText({
  16881. x: xPos,
  16882. y: yPos,
  16883. text: text,
  16884. textAnchor: 'middle',
  16885. fontSize: w.config.dataLabels.style.fontSize,
  16886. fontFamily: w.config.dataLabels.style.fontFamily,
  16887. fontWeight: w.config.dataLabels.style.fontWeight,
  16888. foreColor: foreColor
  16889. });
  16890. if (w.config.dataLabels.dropShadow.enabled) {
  16891. var textShadow = w.config.dataLabels.dropShadow;
  16892. filters.dropShadow(elPieLabel, textShadow);
  16893. }
  16894. elPieLabel.node.classList.add('apexcharts-pie-label');
  16895. if (w.config.chart.animations.animate && w.globals.resized === false) {
  16896. elPieLabel.node.classList.add('apexcharts-pie-label-delay');
  16897. elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + 's';
  16898. }
  16899. this.sliceLabels.push(elPieLabel);
  16900. }
  16901. }
  16902. }
  16903. return g;
  16904. }
  16905. }, {
  16906. key: "addListeners",
  16907. value: function addListeners(elPath, dataLabels) {
  16908. var graphics = new Graphics(this.ctx); // append filters on mouseenter and mouseleave
  16909. elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath));
  16910. elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elPath));
  16911. elPath.node.addEventListener('mouseleave', this.revertDataLabelsInner.bind(this, elPath.node, dataLabels));
  16912. elPath.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elPath));
  16913. if (!this.donutDataLabels.total.showAlways) {
  16914. elPath.node.addEventListener('mouseenter', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  16915. elPath.node.addEventListener('mousedown', this.printDataLabelsInner.bind(this, elPath.node, dataLabels));
  16916. }
  16917. } // This function can be used for other circle charts too
  16918. }, {
  16919. key: "animatePaths",
  16920. value: function animatePaths(el, opts) {
  16921. var w = this.w;
  16922. var me = this;
  16923. var angle = opts.endAngle - opts.startAngle;
  16924. var prevAngle = angle;
  16925. var fromStartAngle = opts.startAngle;
  16926. var toStartAngle = opts.startAngle;
  16927. if (opts.prevStartAngle !== undefined && opts.prevEndAngle !== undefined) {
  16928. fromStartAngle = opts.prevEndAngle;
  16929. prevAngle = opts.prevEndAngle - opts.prevStartAngle;
  16930. }
  16931. if (opts.i === w.config.series.length - 1) {
  16932. // some adjustments for the last overlapping paths
  16933. if (angle + toStartAngle > this.fullAngle) {
  16934. opts.endAngle = opts.endAngle - (angle + toStartAngle);
  16935. } else if (angle + toStartAngle < this.fullAngle) {
  16936. opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle));
  16937. }
  16938. }
  16939. if (angle === this.fullAngle) angle = this.fullAngle - 0.01;
  16940. me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts);
  16941. }
  16942. }, {
  16943. key: "animateArc",
  16944. value: function animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts) {
  16945. var me = this;
  16946. var w = this.w;
  16947. var animations = new Animations(this.ctx);
  16948. var size = opts.size;
  16949. var path;
  16950. if (isNaN(fromStartAngle) || isNaN(prevAngle)) {
  16951. fromStartAngle = toStartAngle;
  16952. prevAngle = angle;
  16953. opts.dur = 0;
  16954. }
  16955. var currAngle = angle;
  16956. var startAngle = toStartAngle;
  16957. var fromAngle = fromStartAngle - toStartAngle;
  16958. if (w.globals.dataChanged && opts.shouldSetPrevPaths) {
  16959. // to avoid flicker when updating, set prev path first and then animate from there
  16960. if (opts.prevEndAngle) {
  16961. path = me.getPiePath({
  16962. me: me,
  16963. startAngle: opts.prevStartAngle,
  16964. angle: opts.prevEndAngle - opts.prevStartAngle,
  16965. size: size
  16966. });
  16967. el.attr({
  16968. d: path
  16969. });
  16970. }
  16971. }
  16972. if (opts.dur !== 0) {
  16973. el.animate(opts.dur, w.globals.easing, opts.animBeginArr[opts.i]).afterAll(function () {
  16974. if (me.chartType === 'pie' || me.chartType === 'donut' || me.chartType === 'polarArea') {
  16975. this.animate(w.config.chart.animations.dynamicAnimation.speed).attr({
  16976. 'stroke-width': me.strokeWidth
  16977. });
  16978. }
  16979. if (opts.i === w.config.series.length - 1) {
  16980. animations.animationCompleted(el);
  16981. }
  16982. }).during(function (pos) {
  16983. currAngle = fromAngle + (angle - fromAngle) * pos;
  16984. if (opts.animateStartingPos) {
  16985. currAngle = prevAngle + (angle - prevAngle) * pos;
  16986. startAngle = fromStartAngle - prevAngle + (toStartAngle - (fromStartAngle - prevAngle)) * pos;
  16987. }
  16988. path = me.getPiePath({
  16989. me: me,
  16990. startAngle: startAngle,
  16991. angle: currAngle,
  16992. size: size
  16993. });
  16994. el.node.setAttribute('data:pathOrig', path);
  16995. el.attr({
  16996. d: path
  16997. });
  16998. });
  16999. } else {
  17000. path = me.getPiePath({
  17001. me: me,
  17002. startAngle: startAngle,
  17003. angle: angle,
  17004. size: size
  17005. });
  17006. if (!opts.isTrack) {
  17007. w.globals.animationEnded = true;
  17008. }
  17009. el.node.setAttribute('data:pathOrig', path);
  17010. el.attr({
  17011. d: path,
  17012. 'stroke-width': me.strokeWidth
  17013. });
  17014. }
  17015. }
  17016. }, {
  17017. key: "pieClicked",
  17018. value: function pieClicked(i) {
  17019. var w = this.w;
  17020. var me = this;
  17021. var path;
  17022. var size = me.sliceSizes[i] + (w.config.plotOptions.pie.expandOnClick ? 4 : 0);
  17023. var elPath = w.globals.dom.Paper.select(".apexcharts-".concat(me.chartType.toLowerCase(), "-slice-").concat(i)).members[0];
  17024. if (elPath.attr('data:pieClicked') === 'true') {
  17025. elPath.attr({
  17026. 'data:pieClicked': 'false'
  17027. });
  17028. this.revertDataLabelsInner(elPath.node, this.donutDataLabels);
  17029. var origPath = elPath.attr('data:pathOrig');
  17030. elPath.attr({
  17031. d: origPath
  17032. });
  17033. return;
  17034. } else {
  17035. // reset all elems
  17036. var allEls = w.globals.dom.baseEl.getElementsByClassName('apexcharts-pie-area');
  17037. Array.prototype.forEach.call(allEls, function (pieSlice) {
  17038. pieSlice.setAttribute('data:pieClicked', 'false');
  17039. var origPath = pieSlice.getAttribute('data:pathOrig');
  17040. pieSlice.setAttribute('d', origPath);
  17041. });
  17042. elPath.attr('data:pieClicked', 'true');
  17043. }
  17044. var startAngle = parseInt(elPath.attr('data:startAngle'), 10);
  17045. var angle = parseInt(elPath.attr('data:angle'), 10);
  17046. path = me.getPiePath({
  17047. me: me,
  17048. startAngle: startAngle,
  17049. angle: angle,
  17050. size: size
  17051. });
  17052. if (angle === 360) return;
  17053. elPath.plot(path);
  17054. }
  17055. }, {
  17056. key: "getChangedPath",
  17057. value: function getChangedPath(prevStartAngle, prevEndAngle) {
  17058. var path = '';
  17059. if (this.dynamicAnim && this.w.globals.dataChanged) {
  17060. path = this.getPiePath({
  17061. me: this,
  17062. startAngle: prevStartAngle,
  17063. angle: prevEndAngle - prevStartAngle,
  17064. size: this.size
  17065. });
  17066. }
  17067. return path;
  17068. }
  17069. }, {
  17070. key: "getPiePath",
  17071. value: function getPiePath(_ref) {
  17072. var me = _ref.me,
  17073. startAngle = _ref.startAngle,
  17074. angle = _ref.angle,
  17075. size = _ref.size;
  17076. var path;
  17077. var startDeg = startAngle;
  17078. var startRadians = Math.PI * (startDeg - 90) / 180;
  17079. var endDeg = angle + startAngle;
  17080. if (Math.ceil(endDeg) >= 360) endDeg = 359.99;
  17081. var endRadians = Math.PI * (endDeg - 90) / 180;
  17082. var x1 = me.centerX + size * Math.cos(startRadians);
  17083. var y1 = me.centerY + size * Math.sin(startRadians);
  17084. var x2 = me.centerX + size * Math.cos(endRadians);
  17085. var y2 = me.centerY + size * Math.sin(endRadians);
  17086. var startInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, endDeg);
  17087. var endInner = Utils.polarToCartesian(me.centerX, me.centerY, me.donutSize, startDeg);
  17088. var largeArc = angle > 180 ? 1 : 0;
  17089. var pathBeginning = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2];
  17090. if (me.chartType === 'donut') {
  17091. 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(' ');
  17092. } else if (me.chartType === 'pie' || me.chartType === 'polarArea') {
  17093. path = [].concat(pathBeginning, ['L', me.centerX, me.centerY, 'L', x1, y1]).join(' ');
  17094. } else {
  17095. path = [].concat(pathBeginning).join(' ');
  17096. }
  17097. return path;
  17098. }
  17099. }, {
  17100. key: "drawPolarElements",
  17101. value: function drawPolarElements() {
  17102. var w = this.w;
  17103. var scale = new Range(this.ctx);
  17104. var graphics = new Graphics(this.ctx);
  17105. var helpers = new CircularChartsHelpers(this.ctx);
  17106. var gCircles = graphics.group();
  17107. var gYAxis = graphics.group();
  17108. var noMinMaxProvided = w.config.yaxis[0].max === undefined && w.config.yaxis[0].min === undefined;
  17109. var yScale = scale.niceScale(0, Math.ceil(this.maxY), w.config.yaxis[0].tickAmount, 0, noMinMaxProvided);
  17110. var yTexts = yScale.result.reverse();
  17111. var len = yScale.result.length;
  17112. this.maxY = yScale.niceMax;
  17113. var circleSize = w.globals.radialSize;
  17114. var diff = circleSize / (len - 1);
  17115. for (var i = 0; i < len - 1; i++) {
  17116. var circle = graphics.drawCircle(circleSize);
  17117. circle.attr({
  17118. cx: this.centerX,
  17119. cy: this.centerY,
  17120. fill: 'none',
  17121. 'stroke-width': w.config.plotOptions.polarArea.rings.strokeWidth,
  17122. stroke: w.config.plotOptions.polarArea.rings.strokeColor
  17123. });
  17124. if (w.config.yaxis[0].show) {
  17125. var yLabel = helpers.drawYAxisTexts(this.centerX, this.centerY - circleSize + parseInt(w.config.yaxis[0].labels.style.fontSize, 10) / 2, i, yTexts[i]);
  17126. gYAxis.add(yLabel);
  17127. }
  17128. gCircles.add(circle);
  17129. circleSize = circleSize - diff;
  17130. }
  17131. this.ret.add(gCircles);
  17132. this.ret.add(gYAxis);
  17133. }
  17134. }, {
  17135. key: "renderInnerDataLabels",
  17136. value: function renderInnerDataLabels(dataLabelsConfig, opts) {
  17137. var w = this.w;
  17138. var graphics = new Graphics(this.ctx);
  17139. var g = graphics.group({
  17140. class: 'apexcharts-datalabels-group',
  17141. transform: "translate(".concat(opts.translateX ? opts.translateX : 0, ", ").concat(opts.translateY ? opts.translateY : 0, ") scale(").concat(w.config.plotOptions.pie.customScale, ")")
  17142. });
  17143. var showTotal = dataLabelsConfig.total.show;
  17144. g.node.style.opacity = opts.opacity;
  17145. var x = opts.centerX;
  17146. var y = opts.centerY;
  17147. var labelColor, valueColor;
  17148. if (dataLabelsConfig.name.color === undefined) {
  17149. labelColor = w.globals.colors[0];
  17150. } else {
  17151. labelColor = dataLabelsConfig.name.color;
  17152. }
  17153. var labelFontSize = dataLabelsConfig.name.fontSize;
  17154. var labelFontFamily = dataLabelsConfig.name.fontFamily;
  17155. var labelFontWeight = dataLabelsConfig.value.fontWeight;
  17156. if (dataLabelsConfig.value.color === undefined) {
  17157. valueColor = w.config.chart.foreColor;
  17158. } else {
  17159. valueColor = dataLabelsConfig.value.color;
  17160. }
  17161. var lbFormatter = dataLabelsConfig.value.formatter;
  17162. var val = '';
  17163. var name = '';
  17164. if (showTotal) {
  17165. labelColor = dataLabelsConfig.total.color;
  17166. labelFontSize = dataLabelsConfig.total.fontSize;
  17167. labelFontFamily = dataLabelsConfig.total.fontFamily;
  17168. labelFontWeight = dataLabelsConfig.total.fontWeight;
  17169. name = dataLabelsConfig.total.label;
  17170. val = dataLabelsConfig.total.formatter(w);
  17171. } else {
  17172. if (w.globals.series.length === 1) {
  17173. val = lbFormatter(w.globals.series[0], w);
  17174. name = w.globals.seriesNames[0];
  17175. }
  17176. }
  17177. if (name) {
  17178. name = dataLabelsConfig.name.formatter(name, dataLabelsConfig.total.show, w);
  17179. }
  17180. if (dataLabelsConfig.name.show) {
  17181. var elLabel = graphics.drawText({
  17182. x: x,
  17183. y: y + parseFloat(dataLabelsConfig.name.offsetY),
  17184. text: name,
  17185. textAnchor: 'middle',
  17186. foreColor: labelColor,
  17187. fontSize: labelFontSize,
  17188. fontWeight: labelFontWeight,
  17189. fontFamily: labelFontFamily
  17190. });
  17191. elLabel.node.classList.add('apexcharts-datalabel-label');
  17192. g.add(elLabel);
  17193. }
  17194. if (dataLabelsConfig.value.show) {
  17195. var valOffset = dataLabelsConfig.name.show ? parseFloat(dataLabelsConfig.value.offsetY) + 16 : dataLabelsConfig.value.offsetY;
  17196. var elValue = graphics.drawText({
  17197. x: x,
  17198. y: y + valOffset,
  17199. text: val,
  17200. textAnchor: 'middle',
  17201. foreColor: valueColor,
  17202. fontWeight: dataLabelsConfig.value.fontWeight,
  17203. fontSize: dataLabelsConfig.value.fontSize,
  17204. fontFamily: dataLabelsConfig.value.fontFamily
  17205. });
  17206. elValue.node.classList.add('apexcharts-datalabel-value');
  17207. g.add(elValue);
  17208. } // for a multi-series circle chart, we need to show total value instead of first series labels
  17209. return g;
  17210. }
  17211. /**
  17212. *
  17213. * @param {string} name - The name of the series
  17214. * @param {string} val - The value of that series
  17215. * @param {object} el - Optional el (indicates which series was hovered/clicked). If this param is not present, means we need to show total
  17216. */
  17217. }, {
  17218. key: "printInnerLabels",
  17219. value: function printInnerLabels(labelsConfig, name, val, el) {
  17220. var w = this.w;
  17221. var labelColor;
  17222. if (el) {
  17223. if (labelsConfig.name.color === undefined) {
  17224. labelColor = w.globals.colors[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  17225. } else {
  17226. labelColor = labelsConfig.name.color;
  17227. }
  17228. } else {
  17229. if (w.globals.series.length > 1 && labelsConfig.total.show) {
  17230. labelColor = labelsConfig.total.color;
  17231. }
  17232. }
  17233. var elLabel = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-label');
  17234. var elValue = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-value');
  17235. var lbFormatter = labelsConfig.value.formatter;
  17236. val = lbFormatter(val, w); // we need to show Total Val - so get the formatter of it
  17237. if (!el && typeof labelsConfig.total.formatter === 'function') {
  17238. val = labelsConfig.total.formatter(w);
  17239. }
  17240. var isTotal = name === labelsConfig.total.label;
  17241. name = labelsConfig.name.formatter(name, isTotal, w);
  17242. if (elLabel !== null) {
  17243. elLabel.textContent = name;
  17244. }
  17245. if (elValue !== null) {
  17246. elValue.textContent = val;
  17247. }
  17248. if (elLabel !== null) {
  17249. elLabel.style.fill = labelColor;
  17250. }
  17251. }
  17252. }, {
  17253. key: "printDataLabelsInner",
  17254. value: function printDataLabelsInner(el, dataLabelsConfig) {
  17255. var w = this.w;
  17256. var val = el.getAttribute('data:value');
  17257. var name = w.globals.seriesNames[parseInt(el.parentNode.getAttribute('rel'), 10) - 1];
  17258. if (w.globals.series.length > 1) {
  17259. this.printInnerLabels(dataLabelsConfig, name, val, el);
  17260. }
  17261. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  17262. if (dataLabelsGroup !== null) {
  17263. dataLabelsGroup.style.opacity = 1;
  17264. }
  17265. }
  17266. }, {
  17267. key: "revertDataLabelsInner",
  17268. value: function revertDataLabelsInner(elem, dataLabelsConfig, event) {
  17269. var _this2 = this;
  17270. var w = this.w;
  17271. var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group');
  17272. var sliceOut = false;
  17273. var slices = w.globals.dom.baseEl.getElementsByClassName("apexcharts-pie-area");
  17274. var selectSlice = function selectSlice(_ref2) {
  17275. var makeSliceOut = _ref2.makeSliceOut,
  17276. printLabel = _ref2.printLabel;
  17277. Array.prototype.forEach.call(slices, function (s) {
  17278. if (s.getAttribute('data:pieClicked') === 'true') {
  17279. if (makeSliceOut) {
  17280. sliceOut = true;
  17281. }
  17282. if (printLabel) {
  17283. _this2.printDataLabelsInner(s, dataLabelsConfig);
  17284. }
  17285. }
  17286. });
  17287. };
  17288. selectSlice({
  17289. makeSliceOut: true,
  17290. printLabel: false
  17291. });
  17292. if (dataLabelsConfig.total.show && w.globals.series.length > 1) {
  17293. if (sliceOut && !dataLabelsConfig.total.showAlways) {
  17294. selectSlice({
  17295. makeSliceOut: false,
  17296. printLabel: true
  17297. });
  17298. } else {
  17299. this.printInnerLabels(dataLabelsConfig, dataLabelsConfig.total.label, dataLabelsConfig.total.formatter(w));
  17300. }
  17301. } else {
  17302. selectSlice({
  17303. makeSliceOut: false,
  17304. printLabel: true
  17305. });
  17306. if (!sliceOut) {
  17307. if (w.globals.selectedDataPoints.length && w.globals.series.length > 1) {
  17308. if (w.globals.selectedDataPoints[0].length > 0) {
  17309. var index = w.globals.selectedDataPoints[0];
  17310. var el = w.globals.dom.baseEl.querySelector(".apexcharts-".concat(this.chartType.toLowerCase(), "-slice-").concat(index));
  17311. this.printDataLabelsInner(el, dataLabelsConfig);
  17312. } else if (dataLabelsGroup && w.globals.selectedDataPoints.length && w.globals.selectedDataPoints[0].length === 0) {
  17313. dataLabelsGroup.style.opacity = 0;
  17314. }
  17315. } else {
  17316. if (dataLabelsGroup && w.globals.series.length > 1) {
  17317. dataLabelsGroup.style.opacity = 0;
  17318. }
  17319. }
  17320. }
  17321. }
  17322. }
  17323. }]);
  17324. return Pie;
  17325. }();
  17326. /**
  17327. * ApexCharts Radar Class for Spider/Radar Charts.
  17328. * @module Radar
  17329. **/
  17330. var Radar = /*#__PURE__*/function () {
  17331. function Radar(ctx) {
  17332. _classCallCheck(this, Radar);
  17333. this.ctx = ctx;
  17334. this.w = ctx.w;
  17335. this.chartType = this.w.config.chart.type;
  17336. this.initialAnim = this.w.config.chart.animations.enabled;
  17337. this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled;
  17338. this.animDur = 0;
  17339. var w = this.w;
  17340. this.graphics = new Graphics(this.ctx);
  17341. this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors;
  17342. this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.gridHeight + w.globals.goldenPadding * 1.5 : w.globals.gridWidth;
  17343. this.maxValue = this.w.globals.maxY;
  17344. this.minValue = this.w.globals.minY;
  17345. this.polygons = w.config.plotOptions.radar.polygons;
  17346. var longestXaxisLabel = w.globals.labels.slice().sort(function (a, b) {
  17347. return b.length - a.length;
  17348. })[0];
  17349. var labelWidth = this.graphics.getTextRects(longestXaxisLabel, w.config.xaxis.labels.style.fontSize);
  17350. this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0;
  17351. this.size = this.defaultSize / 2.1 - this.strokeWidth - w.config.chart.dropShadow.blur;
  17352. if (w.config.xaxis.labels.show) {
  17353. this.size = this.size - labelWidth.width / 1.75;
  17354. }
  17355. if (w.config.plotOptions.radar.size !== undefined) {
  17356. this.size = w.config.plotOptions.radar.size;
  17357. }
  17358. this.dataRadiusOfPercent = [];
  17359. this.dataRadius = [];
  17360. this.angleArr = [];
  17361. this.yaxisLabelsTextsPos = [];
  17362. }
  17363. _createClass(Radar, [{
  17364. key: "draw",
  17365. value: function draw(series) {
  17366. var _this = this;
  17367. var w = this.w;
  17368. var fill = new Fill(this.ctx);
  17369. var allSeries = [];
  17370. var dataLabels = new DataLabels(this.ctx);
  17371. if (series.length) {
  17372. this.dataPointsLen = series[w.globals.maxValsInArrayIndex].length;
  17373. }
  17374. this.disAngle = Math.PI * 2 / this.dataPointsLen;
  17375. var halfW = w.globals.gridWidth / 2;
  17376. var halfH = w.globals.gridHeight / 2;
  17377. var translateX = halfW + w.config.plotOptions.radar.offsetX;
  17378. var translateY = halfH + w.config.plotOptions.radar.offsetY;
  17379. var ret = this.graphics.group({
  17380. class: 'apexcharts-radar-series apexcharts-plot-series',
  17381. transform: "translate(".concat(translateX || 0, ", ").concat(translateY || 0, ")")
  17382. });
  17383. var dataPointsPos = [];
  17384. var elPointsMain = null;
  17385. var elDataPointsMain = null;
  17386. this.yaxisLabels = this.graphics.group({
  17387. class: 'apexcharts-yaxis'
  17388. });
  17389. series.forEach(function (s, i) {
  17390. var longestSeries = s.length === w.globals.dataPoints; // el to which series will be drawn
  17391. var elSeries = _this.graphics.group().attr({
  17392. class: "apexcharts-series",
  17393. 'data:longestSeries': longestSeries,
  17394. seriesName: Utils.escapeString(w.globals.seriesNames[i]),
  17395. rel: i + 1,
  17396. 'data:realIndex': i
  17397. });
  17398. _this.dataRadiusOfPercent[i] = [];
  17399. _this.dataRadius[i] = [];
  17400. _this.angleArr[i] = [];
  17401. s.forEach(function (dv, j) {
  17402. var range = Math.abs(_this.maxValue - _this.minValue);
  17403. dv = dv + Math.abs(_this.minValue);
  17404. _this.dataRadiusOfPercent[i][j] = dv / range;
  17405. _this.dataRadius[i][j] = _this.dataRadiusOfPercent[i][j] * _this.size;
  17406. _this.angleArr[i][j] = j * _this.disAngle;
  17407. });
  17408. dataPointsPos = _this.getDataPointsPos(_this.dataRadius[i], _this.angleArr[i]);
  17409. var paths = _this.createPaths(dataPointsPos, {
  17410. x: 0,
  17411. y: 0
  17412. }); // points
  17413. elPointsMain = _this.graphics.group({
  17414. class: 'apexcharts-series-markers-wrap apexcharts-element-hidden'
  17415. }); // datapoints
  17416. elDataPointsMain = _this.graphics.group({
  17417. class: "apexcharts-datalabels",
  17418. 'data:realIndex': i
  17419. });
  17420. w.globals.delayedElements.push({
  17421. el: elPointsMain.node,
  17422. index: i
  17423. });
  17424. var defaultRenderedPathOptions = {
  17425. i: i,
  17426. realIndex: i,
  17427. animationDelay: i,
  17428. initialSpeed: w.config.chart.animations.speed,
  17429. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  17430. className: "apexcharts-radar",
  17431. shouldClipToGrid: false,
  17432. bindEventsOnPaths: false,
  17433. stroke: w.globals.stroke.colors[i],
  17434. strokeLineCap: w.config.stroke.lineCap
  17435. };
  17436. var pathFrom = null;
  17437. if (w.globals.previousPaths.length > 0) {
  17438. pathFrom = _this.getPreviousPath(i);
  17439. }
  17440. for (var p = 0; p < paths.linePathsTo.length; p++) {
  17441. var renderedLinePath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  17442. pathFrom: pathFrom === null ? paths.linePathsFrom[p] : pathFrom,
  17443. pathTo: paths.linePathsTo[p],
  17444. strokeWidth: Array.isArray(_this.strokeWidth) ? _this.strokeWidth[i] : _this.strokeWidth,
  17445. fill: 'none',
  17446. drawShadow: false
  17447. }));
  17448. elSeries.add(renderedLinePath);
  17449. var pathFill = fill.fillPath({
  17450. seriesNumber: i
  17451. });
  17452. var renderedAreaPath = _this.graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  17453. pathFrom: pathFrom === null ? paths.areaPathsFrom[p] : pathFrom,
  17454. pathTo: paths.areaPathsTo[p],
  17455. strokeWidth: 0,
  17456. fill: pathFill,
  17457. drawShadow: false
  17458. }));
  17459. if (w.config.chart.dropShadow.enabled) {
  17460. var filters = new Filters(_this.ctx);
  17461. var shadow = w.config.chart.dropShadow;
  17462. filters.dropShadow(renderedAreaPath, Object.assign({}, shadow, {
  17463. noUserSpaceOnUse: true
  17464. }), i);
  17465. }
  17466. elSeries.add(renderedAreaPath);
  17467. }
  17468. s.forEach(function (sj, j) {
  17469. var markers = new Markers(_this.ctx);
  17470. var opts = markers.getMarkerConfig('apexcharts-marker', i, j);
  17471. var point = _this.graphics.drawMarker(dataPointsPos[j].x, dataPointsPos[j].y, opts);
  17472. point.attr('rel', j);
  17473. point.attr('j', j);
  17474. point.attr('index', i);
  17475. point.node.setAttribute('default-marker-size', opts.pSize);
  17476. var elPointsWrap = _this.graphics.group({
  17477. class: 'apexcharts-series-markers'
  17478. });
  17479. if (elPointsWrap) {
  17480. elPointsWrap.add(point);
  17481. }
  17482. elPointsMain.add(elPointsWrap);
  17483. elSeries.add(elPointsMain);
  17484. var dataLabelsConfig = w.config.dataLabels;
  17485. if (dataLabelsConfig.enabled) {
  17486. var text = dataLabelsConfig.formatter(w.globals.series[i][j], {
  17487. seriesIndex: i,
  17488. dataPointIndex: j,
  17489. w: w
  17490. });
  17491. dataLabels.plotDataLabelsText({
  17492. x: dataPointsPos[j].x,
  17493. y: dataPointsPos[j].y,
  17494. text: text,
  17495. textAnchor: 'middle',
  17496. i: i,
  17497. j: i,
  17498. parent: elDataPointsMain,
  17499. offsetCorrection: false,
  17500. dataLabelsConfig: _objectSpread2({}, dataLabelsConfig)
  17501. });
  17502. }
  17503. elSeries.add(elDataPointsMain);
  17504. });
  17505. allSeries.push(elSeries);
  17506. });
  17507. this.drawPolygons({
  17508. parent: ret
  17509. });
  17510. if (w.config.xaxis.labels.show) {
  17511. var xaxisTexts = this.drawXAxisTexts();
  17512. ret.add(xaxisTexts);
  17513. }
  17514. ret.add(this.yaxisLabels);
  17515. allSeries.forEach(function (elS) {
  17516. ret.add(elS);
  17517. });
  17518. return ret;
  17519. }
  17520. }, {
  17521. key: "drawPolygons",
  17522. value: function drawPolygons(opts) {
  17523. var _this2 = this;
  17524. var w = this.w;
  17525. var parent = opts.parent;
  17526. var helpers = new CircularChartsHelpers(this.ctx);
  17527. var yaxisTexts = w.globals.yAxisScale[0].result.reverse();
  17528. var layers = yaxisTexts.length;
  17529. var radiusSizes = [];
  17530. var layerDis = this.size / (layers - 1);
  17531. for (var i = 0; i < layers; i++) {
  17532. radiusSizes[i] = layerDis * i;
  17533. }
  17534. radiusSizes.reverse();
  17535. var polygonStrings = [];
  17536. var lines = [];
  17537. radiusSizes.forEach(function (radiusSize, r) {
  17538. var polygon = _this2.getPolygonPos(radiusSize);
  17539. var string = '';
  17540. polygon.forEach(function (p, i) {
  17541. if (r === 0) {
  17542. var line = _this2.graphics.drawLine(p.x, p.y, 0, 0, Array.isArray(_this2.polygons.connectorColors) ? _this2.polygons.connectorColors[i] : _this2.polygons.connectorColors);
  17543. lines.push(line);
  17544. }
  17545. if (i === 0) {
  17546. _this2.yaxisLabelsTextsPos.push({
  17547. x: p.x,
  17548. y: p.y
  17549. });
  17550. }
  17551. string += p.x + ',' + p.y + ' ';
  17552. });
  17553. polygonStrings.push(string);
  17554. });
  17555. polygonStrings.forEach(function (p, i) {
  17556. var strokeColors = _this2.polygons.strokeColors;
  17557. var strokeWidth = _this2.polygons.strokeWidth;
  17558. var polygon = _this2.graphics.drawPolygon(p, Array.isArray(strokeColors) ? strokeColors[i] : strokeColors, Array.isArray(strokeWidth) ? strokeWidth[i] : strokeWidth, w.globals.radarPolygons.fill.colors[i]);
  17559. parent.add(polygon);
  17560. });
  17561. lines.forEach(function (l) {
  17562. parent.add(l);
  17563. });
  17564. if (w.config.yaxis[0].show) {
  17565. this.yaxisLabelsTextsPos.forEach(function (p, i) {
  17566. var yText = helpers.drawYAxisTexts(p.x, p.y, i, yaxisTexts[i]);
  17567. _this2.yaxisLabels.add(yText);
  17568. });
  17569. }
  17570. }
  17571. }, {
  17572. key: "drawXAxisTexts",
  17573. value: function drawXAxisTexts() {
  17574. var _this3 = this;
  17575. var w = this.w;
  17576. var xaxisLabelsConfig = w.config.xaxis.labels;
  17577. var elXAxisWrap = this.graphics.group({
  17578. class: 'apexcharts-xaxis'
  17579. });
  17580. var polygonPos = this.getPolygonPos(this.size);
  17581. w.globals.labels.forEach(function (label, i) {
  17582. var formatter = w.config.xaxis.labels.formatter;
  17583. var dataLabels = new DataLabels(_this3.ctx);
  17584. if (polygonPos[i]) {
  17585. var textPos = _this3.getTextPos(polygonPos[i], _this3.size);
  17586. var text = formatter(label, {
  17587. seriesIndex: -1,
  17588. dataPointIndex: i,
  17589. w: w
  17590. });
  17591. dataLabels.plotDataLabelsText({
  17592. x: textPos.newX,
  17593. y: textPos.newY,
  17594. text: text,
  17595. textAnchor: textPos.textAnchor,
  17596. i: i,
  17597. j: i,
  17598. parent: elXAxisWrap,
  17599. color: xaxisLabelsConfig.style.colors[i] ? xaxisLabelsConfig.style.colors[i] : '#a8a8a8',
  17600. dataLabelsConfig: _objectSpread2({
  17601. textAnchor: textPos.textAnchor,
  17602. dropShadow: {
  17603. enabled: false
  17604. }
  17605. }, xaxisLabelsConfig),
  17606. offsetCorrection: false
  17607. });
  17608. }
  17609. });
  17610. return elXAxisWrap;
  17611. }
  17612. }, {
  17613. key: "createPaths",
  17614. value: function createPaths(pos, origin) {
  17615. var _this4 = this;
  17616. var linePathsTo = [];
  17617. var linePathsFrom = [];
  17618. var areaPathsTo = [];
  17619. var areaPathsFrom = [];
  17620. if (pos.length) {
  17621. linePathsFrom = [this.graphics.move(origin.x, origin.y)];
  17622. areaPathsFrom = [this.graphics.move(origin.x, origin.y)];
  17623. var linePathTo = this.graphics.move(pos[0].x, pos[0].y);
  17624. var areaPathTo = this.graphics.move(pos[0].x, pos[0].y);
  17625. pos.forEach(function (p, i) {
  17626. linePathTo += _this4.graphics.line(p.x, p.y);
  17627. areaPathTo += _this4.graphics.line(p.x, p.y);
  17628. if (i === pos.length - 1) {
  17629. linePathTo += 'Z';
  17630. areaPathTo += 'Z';
  17631. }
  17632. });
  17633. linePathsTo.push(linePathTo);
  17634. areaPathsTo.push(areaPathTo);
  17635. }
  17636. return {
  17637. linePathsFrom: linePathsFrom,
  17638. linePathsTo: linePathsTo,
  17639. areaPathsFrom: areaPathsFrom,
  17640. areaPathsTo: areaPathsTo
  17641. };
  17642. }
  17643. }, {
  17644. key: "getTextPos",
  17645. value: function getTextPos(pos, polygonSize) {
  17646. var limit = 10;
  17647. var textAnchor = 'middle';
  17648. var newX = pos.x;
  17649. var newY = pos.y;
  17650. if (Math.abs(pos.x) >= limit) {
  17651. if (pos.x > 0) {
  17652. textAnchor = 'start';
  17653. newX += 10;
  17654. } else if (pos.x < 0) {
  17655. textAnchor = 'end';
  17656. newX -= 10;
  17657. }
  17658. } else {
  17659. textAnchor = 'middle';
  17660. }
  17661. if (Math.abs(pos.y) >= polygonSize - limit) {
  17662. if (pos.y < 0) {
  17663. newY -= 10;
  17664. } else if (pos.y > 0) {
  17665. newY += 10;
  17666. }
  17667. }
  17668. return {
  17669. textAnchor: textAnchor,
  17670. newX: newX,
  17671. newY: newY
  17672. };
  17673. }
  17674. }, {
  17675. key: "getPreviousPath",
  17676. value: function getPreviousPath(realIndex) {
  17677. var w = this.w;
  17678. var pathFrom = null;
  17679. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  17680. var gpp = w.globals.previousPaths[pp];
  17681. if (gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  17682. if (typeof w.globals.previousPaths[pp].paths[0] !== 'undefined') {
  17683. pathFrom = w.globals.previousPaths[pp].paths[0].d;
  17684. }
  17685. }
  17686. }
  17687. return pathFrom;
  17688. }
  17689. }, {
  17690. key: "getDataPointsPos",
  17691. value: function getDataPointsPos(dataRadiusArr, angleArr) {
  17692. var dataPointsLen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.dataPointsLen;
  17693. dataRadiusArr = dataRadiusArr || [];
  17694. angleArr = angleArr || [];
  17695. var dataPointsPosArray = [];
  17696. for (var j = 0; j < dataPointsLen; j++) {
  17697. var curPointPos = {};
  17698. curPointPos.x = dataRadiusArr[j] * Math.sin(angleArr[j]);
  17699. curPointPos.y = -dataRadiusArr[j] * Math.cos(angleArr[j]);
  17700. dataPointsPosArray.push(curPointPos);
  17701. }
  17702. return dataPointsPosArray;
  17703. }
  17704. }, {
  17705. key: "getPolygonPos",
  17706. value: function getPolygonPos(size) {
  17707. var dotsArray = [];
  17708. var angle = Math.PI * 2 / this.dataPointsLen;
  17709. for (var i = 0; i < this.dataPointsLen; i++) {
  17710. var curPos = {};
  17711. curPos.x = size * Math.sin(i * angle);
  17712. curPos.y = -size * Math.cos(i * angle);
  17713. dotsArray.push(curPos);
  17714. }
  17715. return dotsArray;
  17716. }
  17717. }]);
  17718. return Radar;
  17719. }();
  17720. /**
  17721. * ApexCharts Radial Class for drawing Circle / Semi Circle Charts.
  17722. * @module Radial
  17723. **/
  17724. var Radial = /*#__PURE__*/function (_Pie) {
  17725. _inherits(Radial, _Pie);
  17726. function Radial(ctx) {
  17727. var _this;
  17728. _classCallCheck(this, Radial);
  17729. _this = _possibleConstructorReturn(this, _getPrototypeOf(Radial).call(this, ctx));
  17730. _this.ctx = ctx;
  17731. _this.w = ctx.w;
  17732. _this.animBeginArr = [0];
  17733. _this.animDur = 0;
  17734. var w = _this.w;
  17735. _this.startAngle = w.config.plotOptions.radialBar.startAngle;
  17736. _this.endAngle = w.config.plotOptions.radialBar.endAngle;
  17737. _this.totalAngle = Math.abs(w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle);
  17738. _this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle;
  17739. _this.trackEndAngle = w.config.plotOptions.radialBar.track.endAngle;
  17740. _this.radialDataLabels = w.config.plotOptions.radialBar.dataLabels;
  17741. if (!_this.trackStartAngle) _this.trackStartAngle = _this.startAngle;
  17742. if (!_this.trackEndAngle) _this.trackEndAngle = _this.endAngle;
  17743. if (_this.endAngle === 360) _this.endAngle = 359.99;
  17744. _this.fullAngle = 360 - w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle;
  17745. _this.margin = parseInt(w.config.plotOptions.radialBar.track.margin, 10);
  17746. return _this;
  17747. }
  17748. _createClass(Radial, [{
  17749. key: "draw",
  17750. value: function draw(series) {
  17751. var w = this.w;
  17752. var graphics = new Graphics(this.ctx);
  17753. var ret = graphics.group({
  17754. class: 'apexcharts-radialbar'
  17755. });
  17756. if (w.globals.noData) return ret;
  17757. var elSeries = graphics.group();
  17758. var centerY = this.defaultSize / 2;
  17759. var centerX = w.globals.gridWidth / 2;
  17760. var size = this.defaultSize / 2.05;
  17761. if (!w.config.chart.sparkline.enabled) {
  17762. size = size - w.config.stroke.width - w.config.chart.dropShadow.blur;
  17763. }
  17764. var colorArr = w.globals.fill.colors;
  17765. if (w.config.plotOptions.radialBar.track.show) {
  17766. var elTracks = this.drawTracks({
  17767. size: size,
  17768. centerX: centerX,
  17769. centerY: centerY,
  17770. colorArr: colorArr,
  17771. series: series
  17772. });
  17773. elSeries.add(elTracks);
  17774. }
  17775. var elG = this.drawArcs({
  17776. size: size,
  17777. centerX: centerX,
  17778. centerY: centerY,
  17779. colorArr: colorArr,
  17780. series: series
  17781. });
  17782. var totalAngle = 360;
  17783. if (w.config.plotOptions.radialBar.startAngle < 0) {
  17784. totalAngle = this.totalAngle;
  17785. }
  17786. var angleRatio = (360 - totalAngle) / 360;
  17787. w.globals.radialSize = size - size * angleRatio;
  17788. if (this.radialDataLabels.value.show) {
  17789. var offset = Math.max(this.radialDataLabels.value.offsetY, this.radialDataLabels.name.offsetY);
  17790. w.globals.radialSize += offset * angleRatio;
  17791. }
  17792. elSeries.add(elG.g);
  17793. if (w.config.plotOptions.radialBar.hollow.position === 'front') {
  17794. elG.g.add(elG.elHollow);
  17795. if (elG.dataLabels) {
  17796. elG.g.add(elG.dataLabels);
  17797. }
  17798. }
  17799. ret.add(elSeries);
  17800. return ret;
  17801. }
  17802. }, {
  17803. key: "drawTracks",
  17804. value: function drawTracks(opts) {
  17805. var w = this.w;
  17806. var graphics = new Graphics(this.ctx);
  17807. var g = graphics.group({
  17808. class: 'apexcharts-tracks'
  17809. });
  17810. var filters = new Filters(this.ctx);
  17811. var fill = new Fill(this.ctx);
  17812. var strokeWidth = this.getStrokeWidth(opts);
  17813. opts.size = opts.size - strokeWidth / 2;
  17814. for (var i = 0; i < opts.series.length; i++) {
  17815. var elRadialBarTrack = graphics.group({
  17816. class: 'apexcharts-radialbar-track apexcharts-track'
  17817. });
  17818. g.add(elRadialBarTrack);
  17819. elRadialBarTrack.attr({
  17820. rel: i + 1
  17821. });
  17822. opts.size = opts.size - strokeWidth - this.margin;
  17823. var trackConfig = w.config.plotOptions.radialBar.track;
  17824. var pathFill = fill.fillPath({
  17825. seriesNumber: 0,
  17826. size: opts.size,
  17827. fillColors: Array.isArray(trackConfig.background) ? trackConfig.background[i] : trackConfig.background,
  17828. solid: true
  17829. });
  17830. var startAngle = this.trackStartAngle;
  17831. var endAngle = this.trackEndAngle;
  17832. if (Math.abs(endAngle) + Math.abs(startAngle) >= 360) endAngle = 360 - Math.abs(this.startAngle) - 0.1;
  17833. var elPath = graphics.drawPath({
  17834. d: '',
  17835. stroke: pathFill,
  17836. strokeWidth: strokeWidth * parseInt(trackConfig.strokeWidth, 10) / 100,
  17837. fill: 'none',
  17838. strokeOpacity: trackConfig.opacity,
  17839. classes: 'apexcharts-radialbar-area'
  17840. });
  17841. if (trackConfig.dropShadow.enabled) {
  17842. var shadow = trackConfig.dropShadow;
  17843. filters.dropShadow(elPath, shadow);
  17844. }
  17845. elRadialBarTrack.add(elPath);
  17846. elPath.attr('id', 'apexcharts-radialbarTrack-' + i);
  17847. this.animatePaths(elPath, {
  17848. centerX: opts.centerX,
  17849. centerY: opts.centerY,
  17850. endAngle: endAngle,
  17851. startAngle: startAngle,
  17852. size: opts.size,
  17853. i: i,
  17854. totalItems: 2,
  17855. animBeginArr: 0,
  17856. dur: 0,
  17857. isTrack: true,
  17858. easing: w.globals.easing
  17859. });
  17860. }
  17861. return g;
  17862. }
  17863. }, {
  17864. key: "drawArcs",
  17865. value: function drawArcs(opts) {
  17866. var w = this.w; // size, donutSize, centerX, centerY, colorArr, lineColorArr, sectorAngleArr, series
  17867. var graphics = new Graphics(this.ctx);
  17868. var fill = new Fill(this.ctx);
  17869. var filters = new Filters(this.ctx);
  17870. var g = graphics.group();
  17871. var strokeWidth = this.getStrokeWidth(opts);
  17872. opts.size = opts.size - strokeWidth / 2;
  17873. var hollowFillID = w.config.plotOptions.radialBar.hollow.background;
  17874. var hollowSize = opts.size - strokeWidth * opts.series.length - this.margin * opts.series.length - strokeWidth * parseInt(w.config.plotOptions.radialBar.track.strokeWidth, 10) / 100 / 2;
  17875. var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin;
  17876. if (w.config.plotOptions.radialBar.hollow.image !== undefined) {
  17877. hollowFillID = this.drawHollowImage(opts, g, hollowSize, hollowFillID);
  17878. }
  17879. var elHollow = this.drawHollow({
  17880. size: hollowRadius,
  17881. centerX: opts.centerX,
  17882. centerY: opts.centerY,
  17883. fill: hollowFillID ? hollowFillID : 'transparent'
  17884. });
  17885. if (w.config.plotOptions.radialBar.hollow.dropShadow.enabled) {
  17886. var shadow = w.config.plotOptions.radialBar.hollow.dropShadow;
  17887. filters.dropShadow(elHollow, shadow);
  17888. }
  17889. var shown = 1;
  17890. if (!this.radialDataLabels.total.show && w.globals.series.length > 1) {
  17891. shown = 0;
  17892. }
  17893. var dataLabels = null;
  17894. if (this.radialDataLabels.show) {
  17895. dataLabels = this.renderInnerDataLabels(this.radialDataLabels, {
  17896. hollowSize: hollowSize,
  17897. centerX: opts.centerX,
  17898. centerY: opts.centerY,
  17899. opacity: shown
  17900. });
  17901. }
  17902. if (w.config.plotOptions.radialBar.hollow.position === 'back') {
  17903. g.add(elHollow);
  17904. if (dataLabels) {
  17905. g.add(dataLabels);
  17906. }
  17907. }
  17908. var reverseLoop = false;
  17909. if (w.config.plotOptions.radialBar.inverseOrder) {
  17910. reverseLoop = true;
  17911. }
  17912. for (var i = reverseLoop ? opts.series.length - 1 : 0; reverseLoop ? i >= 0 : i < opts.series.length; reverseLoop ? i-- : i++) {
  17913. var elRadialBarArc = graphics.group({
  17914. class: "apexcharts-series apexcharts-radial-series",
  17915. seriesName: Utils.escapeString(w.globals.seriesNames[i])
  17916. });
  17917. g.add(elRadialBarArc);
  17918. elRadialBarArc.attr({
  17919. rel: i + 1,
  17920. 'data:realIndex': i
  17921. });
  17922. this.ctx.series.addCollapsedClassToSeries(elRadialBarArc, i);
  17923. opts.size = opts.size - strokeWidth - this.margin;
  17924. var pathFill = fill.fillPath({
  17925. seriesNumber: i,
  17926. size: opts.size,
  17927. value: opts.series[i]
  17928. });
  17929. var startAngle = this.startAngle;
  17930. var prevStartAngle = void 0; // if data exceeds 100, make it 100
  17931. var dataValue = Utils.negToZero(opts.series[i] > 100 ? 100 : opts.series[i]) / 100;
  17932. var endAngle = Math.round(this.totalAngle * dataValue) + this.startAngle;
  17933. var prevEndAngle = void 0;
  17934. if (w.globals.dataChanged) {
  17935. prevStartAngle = this.startAngle;
  17936. prevEndAngle = Math.round(this.totalAngle * Utils.negToZero(w.globals.previousPaths[i]) / 100) + prevStartAngle;
  17937. }
  17938. var currFullAngle = Math.abs(endAngle) + Math.abs(startAngle);
  17939. if (currFullAngle >= 360) {
  17940. endAngle = endAngle - 0.01;
  17941. }
  17942. var prevFullAngle = Math.abs(prevEndAngle) + Math.abs(prevStartAngle);
  17943. if (prevFullAngle >= 360) {
  17944. prevEndAngle = prevEndAngle - 0.01;
  17945. }
  17946. var angle = endAngle - startAngle;
  17947. var dashArray = Array.isArray(w.config.stroke.dashArray) ? w.config.stroke.dashArray[i] : w.config.stroke.dashArray;
  17948. var elPath = graphics.drawPath({
  17949. d: '',
  17950. stroke: pathFill,
  17951. strokeWidth: strokeWidth,
  17952. fill: 'none',
  17953. fillOpacity: w.config.fill.opacity,
  17954. classes: 'apexcharts-radialbar-area apexcharts-radialbar-slice-' + i,
  17955. strokeDashArray: dashArray
  17956. });
  17957. Graphics.setAttrs(elPath.node, {
  17958. 'data:angle': angle,
  17959. 'data:value': opts.series[i]
  17960. });
  17961. if (w.config.chart.dropShadow.enabled) {
  17962. var _shadow = w.config.chart.dropShadow;
  17963. filters.dropShadow(elPath, _shadow, i);
  17964. }
  17965. this.addListeners(elPath, this.radialDataLabels);
  17966. elRadialBarArc.add(elPath);
  17967. elPath.attr({
  17968. index: 0,
  17969. j: i
  17970. });
  17971. var dur = 0;
  17972. if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) {
  17973. dur = (endAngle - startAngle) / 360 * w.config.chart.animations.speed;
  17974. this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
  17975. this.animBeginArr.push(this.animDur);
  17976. }
  17977. if (w.globals.dataChanged) {
  17978. dur = (endAngle - startAngle) / 360 * w.config.chart.animations.dynamicAnimation.speed;
  17979. this.animDur = dur / (opts.series.length * 1.2) + this.animDur;
  17980. this.animBeginArr.push(this.animDur);
  17981. }
  17982. this.animatePaths(elPath, {
  17983. centerX: opts.centerX,
  17984. centerY: opts.centerY,
  17985. endAngle: endAngle,
  17986. startAngle: startAngle,
  17987. prevEndAngle: prevEndAngle,
  17988. prevStartAngle: prevStartAngle,
  17989. size: opts.size,
  17990. i: i,
  17991. totalItems: 2,
  17992. animBeginArr: this.animBeginArr,
  17993. dur: dur,
  17994. shouldSetPrevPaths: true,
  17995. easing: w.globals.easing
  17996. });
  17997. }
  17998. return {
  17999. g: g,
  18000. elHollow: elHollow,
  18001. dataLabels: dataLabels
  18002. };
  18003. }
  18004. }, {
  18005. key: "drawHollow",
  18006. value: function drawHollow(opts) {
  18007. var graphics = new Graphics(this.ctx);
  18008. var circle = graphics.drawCircle(opts.size * 2);
  18009. circle.attr({
  18010. class: 'apexcharts-radialbar-hollow',
  18011. cx: opts.centerX,
  18012. cy: opts.centerY,
  18013. r: opts.size,
  18014. fill: opts.fill
  18015. });
  18016. return circle;
  18017. }
  18018. }, {
  18019. key: "drawHollowImage",
  18020. value: function drawHollowImage(opts, g, hollowSize, hollowFillID) {
  18021. var w = this.w;
  18022. var fill = new Fill(this.ctx);
  18023. var randID = Utils.randomId();
  18024. var hollowFillImg = w.config.plotOptions.radialBar.hollow.image;
  18025. if (w.config.plotOptions.radialBar.hollow.imageClipped) {
  18026. fill.clippedImgArea({
  18027. width: hollowSize,
  18028. height: hollowSize,
  18029. image: hollowFillImg,
  18030. patternID: "pattern".concat(w.globals.cuid).concat(randID)
  18031. });
  18032. hollowFillID = "url(#pattern".concat(w.globals.cuid).concat(randID, ")");
  18033. } else {
  18034. var imgWidth = w.config.plotOptions.radialBar.hollow.imageWidth;
  18035. var imgHeight = w.config.plotOptions.radialBar.hollow.imageHeight;
  18036. if (imgWidth === undefined && imgHeight === undefined) {
  18037. var image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  18038. this.move(opts.centerX - loader.width / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - loader.height / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  18039. });
  18040. g.add(image);
  18041. } else {
  18042. var _image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) {
  18043. this.move(opts.centerX - imgWidth / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - imgHeight / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY);
  18044. this.size(imgWidth, imgHeight);
  18045. });
  18046. g.add(_image);
  18047. }
  18048. }
  18049. return hollowFillID;
  18050. }
  18051. }, {
  18052. key: "getStrokeWidth",
  18053. value: function getStrokeWidth(opts) {
  18054. var w = this.w;
  18055. return opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size, 10)) / 100 / (opts.series.length + 1) - this.margin;
  18056. }
  18057. }]);
  18058. return Radial;
  18059. }(Pie);
  18060. var Helpers$4 = /*#__PURE__*/function () {
  18061. function Helpers(lineCtx) {
  18062. _classCallCheck(this, Helpers);
  18063. this.w = lineCtx.w;
  18064. this.lineCtx = lineCtx;
  18065. }
  18066. _createClass(Helpers, [{
  18067. key: "sameValueSeriesFix",
  18068. value: function sameValueSeriesFix(i, series) {
  18069. var w = this.w;
  18070. if (w.config.chart.type === 'line' && (w.config.fill.type === 'gradient' || w.config.fill.type[i] === 'gradient')) {
  18071. var coreUtils = new CoreUtils(this.lineCtx.ctx, w); // a small adjustment to allow gradient line to draw correctly for all same values
  18072. /* #fix https://github.com/apexcharts/apexcharts.js/issues/358 */
  18073. if (coreUtils.seriesHaveSameValues(i)) {
  18074. var gSeries = series[i].slice();
  18075. gSeries[gSeries.length - 1] = gSeries[gSeries.length - 1] + 0.000001;
  18076. series[i] = gSeries;
  18077. }
  18078. }
  18079. return series;
  18080. }
  18081. }, {
  18082. key: "calculatePoints",
  18083. value: function calculatePoints(_ref) {
  18084. var series = _ref.series,
  18085. realIndex = _ref.realIndex,
  18086. x = _ref.x,
  18087. y = _ref.y,
  18088. i = _ref.i,
  18089. j = _ref.j,
  18090. prevY = _ref.prevY;
  18091. var w = this.w;
  18092. var ptX = [];
  18093. var ptY = [];
  18094. if (j === 0) {
  18095. var xPT1st = this.lineCtx.categoryAxisCorrection + w.config.markers.offsetX; // the first point for line series
  18096. // we need to check whether it's not a time series, because a time series may
  18097. // start from the middle of the x axis
  18098. if (w.globals.isXNumeric) {
  18099. xPT1st = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.lineCtx.xRatio + w.config.markers.offsetX;
  18100. } // push 2 points for the first data values
  18101. ptX.push(xPT1st);
  18102. ptY.push(Utils.isNumber(series[i][0]) ? prevY + w.config.markers.offsetY : null);
  18103. ptX.push(x + w.config.markers.offsetX);
  18104. ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  18105. } else {
  18106. ptX.push(x + w.config.markers.offsetX);
  18107. ptY.push(Utils.isNumber(series[i][j + 1]) ? y + w.config.markers.offsetY : null);
  18108. }
  18109. var pointsPos = {
  18110. x: ptX,
  18111. y: ptY
  18112. };
  18113. return pointsPos;
  18114. }
  18115. }, {
  18116. key: "checkPreviousPaths",
  18117. value: function checkPreviousPaths(_ref2) {
  18118. var pathFromLine = _ref2.pathFromLine,
  18119. pathFromArea = _ref2.pathFromArea,
  18120. realIndex = _ref2.realIndex;
  18121. var w = this.w;
  18122. for (var pp = 0; pp < w.globals.previousPaths.length; pp++) {
  18123. var gpp = w.globals.previousPaths[pp];
  18124. if ((gpp.type === 'line' || gpp.type === 'area') && gpp.paths.length > 0 && parseInt(gpp.realIndex, 10) === parseInt(realIndex, 10)) {
  18125. if (gpp.type === 'line') {
  18126. this.lineCtx.appendPathFrom = false;
  18127. pathFromLine = w.globals.previousPaths[pp].paths[0].d;
  18128. } else if (gpp.type === 'area') {
  18129. this.lineCtx.appendPathFrom = false;
  18130. pathFromArea = w.globals.previousPaths[pp].paths[0].d;
  18131. if (w.config.stroke.show && w.globals.previousPaths[pp].paths[1]) {
  18132. pathFromLine = w.globals.previousPaths[pp].paths[1].d;
  18133. }
  18134. }
  18135. }
  18136. }
  18137. return {
  18138. pathFromLine: pathFromLine,
  18139. pathFromArea: pathFromArea
  18140. };
  18141. }
  18142. }, {
  18143. key: "determineFirstPrevY",
  18144. value: function determineFirstPrevY(_ref3) {
  18145. var i = _ref3.i,
  18146. series = _ref3.series,
  18147. prevY = _ref3.prevY,
  18148. lineYPosition = _ref3.lineYPosition;
  18149. var w = this.w;
  18150. if (typeof series[i][0] !== 'undefined') {
  18151. if (w.config.chart.stacked) {
  18152. if (i > 0) {
  18153. // 1st y value of previous series
  18154. lineYPosition = this.lineCtx.prevSeriesY[i - 1][0];
  18155. } else {
  18156. // the first series will not have prevY values
  18157. lineYPosition = this.lineCtx.zeroY;
  18158. }
  18159. } else {
  18160. lineYPosition = this.lineCtx.zeroY;
  18161. }
  18162. 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;
  18163. } else {
  18164. // the first value in the current series is null
  18165. if (w.config.chart.stacked && i > 0 && typeof series[i][0] === 'undefined') {
  18166. // check for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses)
  18167. for (var s = i - 1; s >= 0; s--) {
  18168. // for loop to get to 1st previous value until we get it
  18169. if (series[s][0] !== null && typeof series[s][0] !== 'undefined') {
  18170. lineYPosition = this.lineCtx.prevSeriesY[s][0];
  18171. prevY = lineYPosition;
  18172. break;
  18173. }
  18174. }
  18175. }
  18176. }
  18177. return {
  18178. prevY: prevY,
  18179. lineYPosition: lineYPosition
  18180. };
  18181. }
  18182. }]);
  18183. return Helpers;
  18184. }();
  18185. /**
  18186. * ApexCharts Line Class responsible for drawing Line / Area Charts.
  18187. * This class is also responsible for generating values for Bubble/Scatter charts, so need to rename it to Axis Charts to avoid confusions
  18188. * @module Line
  18189. **/
  18190. var Line = /*#__PURE__*/function () {
  18191. function Line(ctx, xyRatios, isPointsChart) {
  18192. _classCallCheck(this, Line);
  18193. this.ctx = ctx;
  18194. this.w = ctx.w;
  18195. this.xyRatios = xyRatios;
  18196. this.pointsChart = !(this.w.config.chart.type !== 'bubble' && this.w.config.chart.type !== 'scatter') || isPointsChart;
  18197. this.scatter = new Scatter(this.ctx);
  18198. this.noNegatives = this.w.globals.minX === Number.MAX_VALUE;
  18199. this.lineHelpers = new Helpers$4(this);
  18200. this.markers = new Markers(this.ctx);
  18201. this.prevSeriesY = [];
  18202. this.categoryAxisCorrection = 0;
  18203. this.yaxisIndex = 0;
  18204. }
  18205. _createClass(Line, [{
  18206. key: "draw",
  18207. value: function draw(series, ptype, seriesIndex) {
  18208. var w = this.w;
  18209. var graphics = new Graphics(this.ctx);
  18210. var type = w.globals.comboCharts ? ptype : w.config.chart.type;
  18211. var ret = graphics.group({
  18212. class: "apexcharts-".concat(type, "-series apexcharts-plot-series")
  18213. });
  18214. var coreUtils = new CoreUtils(this.ctx, w);
  18215. this.yRatio = this.xyRatios.yRatio;
  18216. this.zRatio = this.xyRatios.zRatio;
  18217. this.xRatio = this.xyRatios.xRatio;
  18218. this.baseLineY = this.xyRatios.baseLineY;
  18219. series = coreUtils.getLogSeries(series);
  18220. this.yRatio = coreUtils.getLogYRatios(this.yRatio); // push all series in an array, so we can draw in reverse order (for stacked charts)
  18221. var allSeries = [];
  18222. for (var i = 0; i < series.length; i++) {
  18223. series = this.lineHelpers.sameValueSeriesFix(i, series);
  18224. var realIndex = w.globals.comboCharts ? seriesIndex[i] : i;
  18225. this._initSerieVariables(series, i, realIndex);
  18226. var yArrj = []; // hold y values of current iterating series
  18227. var xArrj = []; // hold x values of current iterating series
  18228. var x = w.globals.padHorizontal + this.categoryAxisCorrection;
  18229. var y = 1;
  18230. var linePaths = [];
  18231. var areaPaths = [];
  18232. this.ctx.series.addCollapsedClassToSeries(this.elSeries, realIndex);
  18233. if (w.globals.isXNumeric && w.globals.seriesX.length > 0) {
  18234. x = (w.globals.seriesX[realIndex][0] - w.globals.minX) / this.xRatio;
  18235. }
  18236. xArrj.push(x);
  18237. var pX = x;
  18238. var pY = void 0;
  18239. var prevX = pX;
  18240. var prevY = this.zeroY;
  18241. var lineYPosition = 0; // the first value in the current series is not null or undefined
  18242. var firstPrevY = this.lineHelpers.determineFirstPrevY({
  18243. i: i,
  18244. series: series,
  18245. prevY: prevY,
  18246. lineYPosition: lineYPosition
  18247. });
  18248. prevY = firstPrevY.prevY;
  18249. yArrj.push(prevY);
  18250. pY = prevY;
  18251. var pathsFrom = this._calculatePathsFrom({
  18252. series: series,
  18253. i: i,
  18254. realIndex: realIndex,
  18255. prevX: prevX,
  18256. prevY: prevY
  18257. });
  18258. var paths = this._iterateOverDataPoints({
  18259. series: series,
  18260. realIndex: realIndex,
  18261. i: i,
  18262. x: x,
  18263. y: y,
  18264. pX: pX,
  18265. pY: pY,
  18266. pathsFrom: pathsFrom,
  18267. linePaths: linePaths,
  18268. areaPaths: areaPaths,
  18269. seriesIndex: seriesIndex,
  18270. lineYPosition: lineYPosition,
  18271. xArrj: xArrj,
  18272. yArrj: yArrj
  18273. });
  18274. this._handlePaths({
  18275. type: type,
  18276. realIndex: realIndex,
  18277. i: i,
  18278. paths: paths
  18279. });
  18280. this.elSeries.add(this.elPointsMain);
  18281. this.elSeries.add(this.elDataLabelsWrap);
  18282. allSeries.push(this.elSeries);
  18283. }
  18284. for (var s = allSeries.length; s > 0; s--) {
  18285. ret.add(allSeries[s - 1]);
  18286. }
  18287. return ret;
  18288. }
  18289. }, {
  18290. key: "_initSerieVariables",
  18291. value: function _initSerieVariables(series, i, realIndex) {
  18292. var w = this.w;
  18293. var graphics = new Graphics(this.ctx); // width divided into equal parts
  18294. this.xDivision = w.globals.gridWidth / (w.globals.dataPoints - (w.config.xaxis.tickPlacement === 'on' ? 1 : 0));
  18295. this.strokeWidth = Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width;
  18296. if (this.yRatio.length > 1) {
  18297. this.yaxisIndex = realIndex;
  18298. }
  18299. 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
  18300. this.zeroY = w.globals.gridHeight - this.baseLineY[this.yaxisIndex] - (this.isReversed ? w.globals.gridHeight : 0) + (this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0);
  18301. this.areaBottomY = this.zeroY;
  18302. if (this.zeroY > w.globals.gridHeight) {
  18303. this.areaBottomY = w.globals.gridHeight;
  18304. }
  18305. this.categoryAxisCorrection = this.xDivision / 2; // el to which series will be drawn
  18306. this.elSeries = graphics.group({
  18307. class: "apexcharts-series",
  18308. seriesName: Utils.escapeString(w.globals.seriesNames[realIndex])
  18309. }); // points
  18310. this.elPointsMain = graphics.group({
  18311. class: 'apexcharts-series-markers-wrap',
  18312. 'data:realIndex': realIndex
  18313. }); // eldatalabels
  18314. this.elDataLabelsWrap = graphics.group({
  18315. class: 'apexcharts-datalabels',
  18316. 'data:realIndex': realIndex
  18317. });
  18318. var longestSeries = series[i].length === w.globals.dataPoints;
  18319. this.elSeries.attr({
  18320. 'data:longestSeries': longestSeries,
  18321. rel: i + 1,
  18322. 'data:realIndex': realIndex
  18323. });
  18324. this.appendPathFrom = true;
  18325. }
  18326. }, {
  18327. key: "_calculatePathsFrom",
  18328. value: function _calculatePathsFrom(_ref) {
  18329. var series = _ref.series,
  18330. i = _ref.i,
  18331. realIndex = _ref.realIndex,
  18332. prevX = _ref.prevX,
  18333. prevY = _ref.prevY;
  18334. var w = this.w;
  18335. var graphics = new Graphics(this.ctx);
  18336. var linePath, areaPath, pathFromLine, pathFromArea;
  18337. if (series[i][0] === null) {
  18338. // when the first value itself is null, we need to move the pointer to a location where a null value is not found
  18339. for (var s = 0; s < series[i].length; s++) {
  18340. if (series[i][s] !== null) {
  18341. prevX = this.xDivision * s;
  18342. prevY = this.zeroY - series[i][s] / this.yRatio[this.yaxisIndex];
  18343. linePath = graphics.move(prevX, prevY);
  18344. areaPath = graphics.move(prevX, this.areaBottomY);
  18345. break;
  18346. }
  18347. }
  18348. } else {
  18349. linePath = graphics.move(prevX, prevY);
  18350. areaPath = graphics.move(prevX, this.areaBottomY) + graphics.line(prevX, prevY);
  18351. }
  18352. pathFromLine = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  18353. pathFromArea = graphics.move(-1, this.zeroY) + graphics.line(-1, this.zeroY);
  18354. if (w.globals.previousPaths.length > 0) {
  18355. var pathFrom = this.lineHelpers.checkPreviousPaths({
  18356. pathFromLine: pathFromLine,
  18357. pathFromArea: pathFromArea,
  18358. realIndex: realIndex
  18359. });
  18360. pathFromLine = pathFrom.pathFromLine;
  18361. pathFromArea = pathFrom.pathFromArea;
  18362. }
  18363. return {
  18364. prevX: prevX,
  18365. prevY: prevY,
  18366. linePath: linePath,
  18367. areaPath: areaPath,
  18368. pathFromLine: pathFromLine,
  18369. pathFromArea: pathFromArea
  18370. };
  18371. }
  18372. }, {
  18373. key: "_handlePaths",
  18374. value: function _handlePaths(_ref2) {
  18375. var type = _ref2.type,
  18376. realIndex = _ref2.realIndex,
  18377. i = _ref2.i,
  18378. paths = _ref2.paths;
  18379. var w = this.w;
  18380. var graphics = new Graphics(this.ctx);
  18381. var fill = new Fill(this.ctx); // push all current y values array to main PrevY Array
  18382. this.prevSeriesY.push(paths.yArrj); // push all x val arrays into main xArr
  18383. w.globals.seriesXvalues[realIndex] = paths.xArrj;
  18384. w.globals.seriesYvalues[realIndex] = paths.yArrj; // these elements will be shown after area path animation completes
  18385. if (!this.pointsChart) {
  18386. w.globals.delayedElements.push({
  18387. el: this.elPointsMain.node,
  18388. index: realIndex
  18389. });
  18390. }
  18391. var defaultRenderedPathOptions = {
  18392. i: i,
  18393. realIndex: realIndex,
  18394. animationDelay: i,
  18395. initialSpeed: w.config.chart.animations.speed,
  18396. dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed,
  18397. className: "apexcharts-".concat(type)
  18398. };
  18399. if (type === 'area') {
  18400. var pathFill = fill.fillPath({
  18401. seriesNumber: realIndex
  18402. });
  18403. for (var p = 0; p < paths.areaPaths.length; p++) {
  18404. var renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  18405. pathFrom: paths.pathFromArea,
  18406. pathTo: paths.areaPaths[p],
  18407. stroke: 'none',
  18408. strokeWidth: 0,
  18409. strokeLineCap: null,
  18410. fill: pathFill
  18411. }));
  18412. this.elSeries.add(renderedPath);
  18413. }
  18414. }
  18415. if (w.config.stroke.show && !this.pointsChart) {
  18416. var lineFill = null;
  18417. if (type === 'line') {
  18418. // fillable lines only for lineChart
  18419. lineFill = fill.fillPath({
  18420. seriesNumber: realIndex,
  18421. i: i
  18422. });
  18423. } else {
  18424. lineFill = w.globals.stroke.colors[realIndex];
  18425. }
  18426. for (var _p = 0; _p < paths.linePaths.length; _p++) {
  18427. var _renderedPath = graphics.renderPaths(_objectSpread2({}, defaultRenderedPathOptions, {
  18428. pathFrom: paths.pathFromLine,
  18429. pathTo: paths.linePaths[_p],
  18430. stroke: lineFill,
  18431. strokeWidth: this.strokeWidth,
  18432. strokeLineCap: w.config.stroke.lineCap,
  18433. fill: 'none'
  18434. }));
  18435. this.elSeries.add(_renderedPath);
  18436. }
  18437. }
  18438. }
  18439. }, {
  18440. key: "_iterateOverDataPoints",
  18441. value: function _iterateOverDataPoints(_ref3) {
  18442. var series = _ref3.series,
  18443. realIndex = _ref3.realIndex,
  18444. i = _ref3.i,
  18445. x = _ref3.x,
  18446. y = _ref3.y,
  18447. pX = _ref3.pX,
  18448. pY = _ref3.pY,
  18449. pathsFrom = _ref3.pathsFrom,
  18450. linePaths = _ref3.linePaths,
  18451. areaPaths = _ref3.areaPaths,
  18452. seriesIndex = _ref3.seriesIndex,
  18453. lineYPosition = _ref3.lineYPosition,
  18454. xArrj = _ref3.xArrj,
  18455. yArrj = _ref3.yArrj;
  18456. var w = this.w;
  18457. var graphics = new Graphics(this.ctx);
  18458. var yRatio = this.yRatio;
  18459. var prevY = pathsFrom.prevY,
  18460. linePath = pathsFrom.linePath,
  18461. areaPath = pathsFrom.areaPath,
  18462. pathFromLine = pathsFrom.pathFromLine,
  18463. pathFromArea = pathsFrom.pathFromArea;
  18464. var minY = Utils.isNumber(w.globals.minYArr[realIndex]) ? w.globals.minYArr[realIndex] : w.globals.minY;
  18465. var iterations = w.globals.dataPoints > 1 ? w.globals.dataPoints - 1 : w.globals.dataPoints;
  18466. for (var j = 0; j < iterations; j++) {
  18467. var isNull = typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null;
  18468. if (w.globals.isXNumeric) {
  18469. var sX = w.globals.seriesX[realIndex][j + 1];
  18470. if (typeof w.globals.seriesX[realIndex][j + 1] === 'undefined') {
  18471. /* fix #374 */
  18472. sX = w.globals.seriesX[realIndex][iterations - 1];
  18473. }
  18474. x = (sX - w.globals.minX) / this.xRatio;
  18475. } else {
  18476. x = x + this.xDivision;
  18477. }
  18478. if (w.config.chart.stacked) {
  18479. if (i > 0 && w.globals.collapsedSeries.length < w.config.series.length - 1) {
  18480. // 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
  18481. var prevIndex = function prevIndex(pi) {
  18482. var pii = pi;
  18483. for (var cpi = 0; cpi < w.globals.series.length; cpi++) {
  18484. if (w.globals.collapsedSeriesIndices.indexOf(pi) > -1) {
  18485. pii--;
  18486. break;
  18487. }
  18488. }
  18489. return pii >= 0 ? pii : 0;
  18490. };
  18491. lineYPosition = this.prevSeriesY[prevIndex(i - 1)][j + 1];
  18492. } else {
  18493. // the first series will not have prevY values
  18494. lineYPosition = this.zeroY;
  18495. }
  18496. } else {
  18497. lineYPosition = this.zeroY;
  18498. }
  18499. if (isNull) {
  18500. y = lineYPosition - minY / yRatio[this.yaxisIndex] + (this.isReversed ? minY / yRatio[this.yaxisIndex] : 0) * 2;
  18501. } else {
  18502. y = lineYPosition - series[i][j + 1] / yRatio[this.yaxisIndex] + (this.isReversed ? series[i][j + 1] / yRatio[this.yaxisIndex] : 0) * 2;
  18503. } // push current X
  18504. xArrj.push(x); // push current Y that will be used as next series's bottom position
  18505. yArrj.push(y);
  18506. var pointsPos = this.lineHelpers.calculatePoints({
  18507. series: series,
  18508. x: x,
  18509. y: y,
  18510. realIndex: realIndex,
  18511. i: i,
  18512. j: j,
  18513. prevY: prevY
  18514. });
  18515. var calculatedPaths = this._createPaths({
  18516. series: series,
  18517. i: i,
  18518. realIndex: realIndex,
  18519. j: j,
  18520. x: x,
  18521. y: y,
  18522. pX: pX,
  18523. pY: pY,
  18524. linePath: linePath,
  18525. areaPath: areaPath,
  18526. linePaths: linePaths,
  18527. areaPaths: areaPaths,
  18528. seriesIndex: seriesIndex
  18529. });
  18530. areaPaths = calculatedPaths.areaPaths;
  18531. linePaths = calculatedPaths.linePaths;
  18532. pX = calculatedPaths.pX;
  18533. pY = calculatedPaths.pY;
  18534. areaPath = calculatedPaths.areaPath;
  18535. linePath = calculatedPaths.linePath;
  18536. if (this.appendPathFrom) {
  18537. pathFromLine = pathFromLine + graphics.line(x, this.zeroY);
  18538. pathFromArea = pathFromArea + graphics.line(x, this.zeroY);
  18539. }
  18540. this.handleNullDataPoints(series, pointsPos, i, j, realIndex);
  18541. this._handleMarkersAndLabels({
  18542. pointsPos: pointsPos,
  18543. series: series,
  18544. x: x,
  18545. y: y,
  18546. prevY: prevY,
  18547. i: i,
  18548. j: j,
  18549. realIndex: realIndex
  18550. });
  18551. }
  18552. return {
  18553. yArrj: yArrj,
  18554. xArrj: xArrj,
  18555. pathFromArea: pathFromArea,
  18556. areaPaths: areaPaths,
  18557. pathFromLine: pathFromLine,
  18558. linePaths: linePaths
  18559. };
  18560. }
  18561. }, {
  18562. key: "_handleMarkersAndLabels",
  18563. value: function _handleMarkersAndLabels(_ref4) {
  18564. var pointsPos = _ref4.pointsPos,
  18565. series = _ref4.series,
  18566. x = _ref4.x,
  18567. y = _ref4.y,
  18568. prevY = _ref4.prevY,
  18569. i = _ref4.i,
  18570. j = _ref4.j,
  18571. realIndex = _ref4.realIndex;
  18572. var w = this.w;
  18573. var dataLabels = new DataLabels(this.ctx);
  18574. if (!this.pointsChart) {
  18575. if (w.globals.series[i].length > 1) {
  18576. this.elPointsMain.node.classList.add('apexcharts-element-hidden');
  18577. }
  18578. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1);
  18579. if (elPointsWrap !== null) {
  18580. this.elPointsMain.add(elPointsWrap);
  18581. }
  18582. } else {
  18583. // scatter / bubble chart points creation
  18584. this.scatter.draw(this.elSeries, j, {
  18585. realIndex: realIndex,
  18586. pointsPos: pointsPos,
  18587. zRatio: this.zRatio,
  18588. elParent: this.elPointsMain
  18589. });
  18590. }
  18591. var drawnLabels = dataLabels.drawDataLabel(pointsPos, realIndex, j + 1, null);
  18592. if (drawnLabels !== null) {
  18593. this.elDataLabelsWrap.add(drawnLabels);
  18594. }
  18595. }
  18596. }, {
  18597. key: "_createPaths",
  18598. value: function _createPaths(_ref5) {
  18599. var series = _ref5.series,
  18600. i = _ref5.i,
  18601. realIndex = _ref5.realIndex,
  18602. j = _ref5.j,
  18603. x = _ref5.x,
  18604. y = _ref5.y,
  18605. pX = _ref5.pX,
  18606. pY = _ref5.pY,
  18607. linePath = _ref5.linePath,
  18608. areaPath = _ref5.areaPath,
  18609. linePaths = _ref5.linePaths,
  18610. areaPaths = _ref5.areaPaths,
  18611. seriesIndex = _ref5.seriesIndex;
  18612. var w = this.w;
  18613. var graphics = new Graphics(this.ctx);
  18614. var curve = w.config.stroke.curve;
  18615. var areaBottomY = this.areaBottomY;
  18616. if (Array.isArray(w.config.stroke.curve)) {
  18617. if (Array.isArray(seriesIndex)) {
  18618. curve = w.config.stroke.curve[seriesIndex[i]];
  18619. } else {
  18620. curve = w.config.stroke.curve[i];
  18621. }
  18622. } // logic of smooth curve derived from chartist
  18623. // CREDITS: https://gionkunz.github.io/chartist-js/
  18624. if (curve === 'smooth') {
  18625. var length = (x - pX) * 0.35;
  18626. if (w.globals.hasNullValues) {
  18627. if (series[i][j] !== null) {
  18628. if (series[i][j + 1] !== null) {
  18629. linePath = graphics.move(pX, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y);
  18630. 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';
  18631. } else {
  18632. linePath = graphics.move(pX, pY);
  18633. areaPath = graphics.move(pX, pY) + 'z';
  18634. }
  18635. }
  18636. linePaths.push(linePath);
  18637. areaPaths.push(areaPath);
  18638. } else {
  18639. linePath = linePath + graphics.curve(pX + length, pY, x - length, y, x, y);
  18640. areaPath = areaPath + graphics.curve(pX + length, pY, x - length, y, x, y);
  18641. }
  18642. pX = x;
  18643. pY = y;
  18644. if (j === series[i].length - 2) {
  18645. // last loop, close path
  18646. areaPath = areaPath + graphics.curve(pX, pY, x, y, x, areaBottomY) + graphics.move(x, y) + 'z';
  18647. if (!w.globals.hasNullValues) {
  18648. linePaths.push(linePath);
  18649. areaPaths.push(areaPath);
  18650. }
  18651. }
  18652. } else {
  18653. if (series[i][j + 1] === null) {
  18654. linePath = linePath + graphics.move(x, y);
  18655. var numericOrCatX = w.globals.isXNumeric ? (w.globals.seriesX[realIndex][j] - w.globals.minX) / this.xRatio : x - this.xDivision;
  18656. areaPath = areaPath + graphics.line(numericOrCatX, areaBottomY) + graphics.move(x, y) + 'z';
  18657. }
  18658. if (series[i][j] === null) {
  18659. linePath = linePath + graphics.move(x, y);
  18660. areaPath = areaPath + graphics.move(x, areaBottomY);
  18661. }
  18662. if (curve === 'stepline') {
  18663. linePath = linePath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  18664. areaPath = areaPath + graphics.line(x, null, 'H') + graphics.line(null, y, 'V');
  18665. } else if (curve === 'straight') {
  18666. linePath = linePath + graphics.line(x, y);
  18667. areaPath = areaPath + graphics.line(x, y);
  18668. }
  18669. if (j === series[i].length - 2) {
  18670. // last loop, close path
  18671. areaPath = areaPath + graphics.line(x, areaBottomY) + graphics.move(x, y) + 'z';
  18672. linePaths.push(linePath);
  18673. areaPaths.push(areaPath);
  18674. }
  18675. }
  18676. return {
  18677. linePaths: linePaths,
  18678. areaPaths: areaPaths,
  18679. pX: pX,
  18680. pY: pY,
  18681. linePath: linePath,
  18682. areaPath: areaPath
  18683. };
  18684. }
  18685. }, {
  18686. key: "handleNullDataPoints",
  18687. value: function handleNullDataPoints(series, pointsPos, i, j, realIndex) {
  18688. var w = this.w;
  18689. if (series[i][j] === null && w.config.markers.showNullDataPoints || series[i].length === 1) {
  18690. // fixes apexcharts.js#1282, #1252
  18691. var elPointsWrap = this.markers.plotChartMarkers(pointsPos, realIndex, j + 1, this.strokeWidth - w.config.markers.strokeWidth / 2, true);
  18692. if (elPointsWrap !== null) {
  18693. this.elPointsMain.add(elPointsWrap);
  18694. }
  18695. }
  18696. }
  18697. }]);
  18698. return Line;
  18699. }();
  18700. /**
  18701. * ApexCharts TimeScale Class for generating time ticks for x-axis.
  18702. *
  18703. * @module TimeScale
  18704. **/
  18705. var TimeScale = /*#__PURE__*/function () {
  18706. function TimeScale(ctx) {
  18707. _classCallCheck(this, TimeScale);
  18708. this.ctx = ctx;
  18709. this.w = ctx.w;
  18710. this.timeScaleArray = [];
  18711. this.utc = this.w.config.xaxis.labels.datetimeUTC;
  18712. }
  18713. _createClass(TimeScale, [{
  18714. key: "calculateTimeScaleTicks",
  18715. value: function calculateTimeScaleTicks(minX, maxX) {
  18716. var _this = this;
  18717. var w = this.w; // null check when no series to show
  18718. if (w.globals.allSeriesCollapsed) {
  18719. w.globals.labels = [];
  18720. w.globals.timescaleLabels = [];
  18721. return [];
  18722. }
  18723. var dt = new DateTime(this.ctx);
  18724. var daysDiff = (maxX - minX) / (1000 * 60 * 60 * 24);
  18725. this.determineInterval(daysDiff);
  18726. w.globals.disableZoomIn = false;
  18727. w.globals.disableZoomOut = false;
  18728. if (daysDiff < 0.005) {
  18729. w.globals.disableZoomIn = true;
  18730. } else if (daysDiff > 50000) {
  18731. w.globals.disableZoomOut = true;
  18732. }
  18733. var timeIntervals = dt.getTimeUnitsfromTimestamp(minX, maxX, this.utc);
  18734. var daysWidthOnXAxis = w.globals.gridWidth / daysDiff;
  18735. var hoursWidthOnXAxis = daysWidthOnXAxis / 24;
  18736. var minutesWidthOnXAxis = hoursWidthOnXAxis / 60;
  18737. var numberOfHours = Math.floor(daysDiff * 24);
  18738. var numberOfMinutes = Math.floor(daysDiff * 24 * 60);
  18739. var numberOfDays = Math.floor(daysDiff);
  18740. var numberOfMonths = Math.floor(daysDiff / 30);
  18741. var numberOfYears = Math.floor(daysDiff / 365);
  18742. var firstVal = {
  18743. minMinute: timeIntervals.minMinute,
  18744. minHour: timeIntervals.minHour,
  18745. minDate: timeIntervals.minDate,
  18746. minMonth: timeIntervals.minMonth,
  18747. minYear: timeIntervals.minYear
  18748. };
  18749. var currentMinute = firstVal.minMinute;
  18750. var currentHour = firstVal.minHour;
  18751. var currentMonthDate = firstVal.minDate;
  18752. var currentDate = firstVal.minDate;
  18753. var currentMonth = firstVal.minMonth;
  18754. var currentYear = firstVal.minYear;
  18755. var params = {
  18756. firstVal: firstVal,
  18757. currentMinute: currentMinute,
  18758. currentHour: currentHour,
  18759. currentMonthDate: currentMonthDate,
  18760. currentDate: currentDate,
  18761. currentMonth: currentMonth,
  18762. currentYear: currentYear,
  18763. daysWidthOnXAxis: daysWidthOnXAxis,
  18764. hoursWidthOnXAxis: hoursWidthOnXAxis,
  18765. minutesWidthOnXAxis: minutesWidthOnXAxis,
  18766. numberOfMinutes: numberOfMinutes,
  18767. numberOfHours: numberOfHours,
  18768. numberOfDays: numberOfDays,
  18769. numberOfMonths: numberOfMonths,
  18770. numberOfYears: numberOfYears
  18771. };
  18772. switch (this.tickInterval) {
  18773. case 'years':
  18774. {
  18775. this.generateYearScale(params);
  18776. break;
  18777. }
  18778. case 'months':
  18779. case 'half_year':
  18780. {
  18781. this.generateMonthScale(params);
  18782. break;
  18783. }
  18784. case 'months_days':
  18785. case 'months_fortnight':
  18786. case 'days':
  18787. case 'week_days':
  18788. {
  18789. this.generateDayScale(params);
  18790. break;
  18791. }
  18792. case 'hours':
  18793. {
  18794. this.generateHourScale(params);
  18795. break;
  18796. }
  18797. case 'minutes':
  18798. this.generateMinuteScale(params);
  18799. break;
  18800. } // first, we will adjust the month values index
  18801. // as in the upper function, it is starting from 0
  18802. // we will start them from 1
  18803. var adjustedMonthInTimeScaleArray = this.timeScaleArray.map(function (ts) {
  18804. var defaultReturn = {
  18805. position: ts.position,
  18806. unit: ts.unit,
  18807. year: ts.year,
  18808. day: ts.day ? ts.day : 1,
  18809. hour: ts.hour ? ts.hour : 0,
  18810. month: ts.month + 1
  18811. };
  18812. if (ts.unit === 'month') {
  18813. return _objectSpread2({}, defaultReturn, {
  18814. day: 1,
  18815. value: ts.value + 1
  18816. });
  18817. } else if (ts.unit === 'day' || ts.unit === 'hour') {
  18818. return _objectSpread2({}, defaultReturn, {
  18819. value: ts.value
  18820. });
  18821. } else if (ts.unit === 'minute') {
  18822. return _objectSpread2({}, defaultReturn, {
  18823. value: ts.value,
  18824. minute: ts.value
  18825. });
  18826. }
  18827. return ts;
  18828. });
  18829. var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts) {
  18830. var modulo = 1;
  18831. var ticks = Math.ceil(w.globals.gridWidth / 120);
  18832. var value = ts.value;
  18833. if (w.config.xaxis.tickAmount !== undefined) {
  18834. ticks = w.config.xaxis.tickAmount;
  18835. }
  18836. if (adjustedMonthInTimeScaleArray.length > ticks) {
  18837. modulo = Math.floor(adjustedMonthInTimeScaleArray.length / ticks);
  18838. }
  18839. var shouldNotSkipUnit = false; // there is a big change in unit i.e days to months
  18840. var shouldNotPrint = false; // should skip these values
  18841. switch (_this.tickInterval) {
  18842. case 'years':
  18843. // make years label denser
  18844. if (ts.unit === 'year') {
  18845. shouldNotSkipUnit = true;
  18846. }
  18847. break;
  18848. case 'half_year':
  18849. modulo = 7;
  18850. if (ts.unit === 'year') {
  18851. shouldNotSkipUnit = true;
  18852. }
  18853. break;
  18854. case 'months':
  18855. modulo = 1;
  18856. if (ts.unit === 'year') {
  18857. shouldNotSkipUnit = true;
  18858. }
  18859. break;
  18860. case 'months_fortnight':
  18861. modulo = 15;
  18862. if (ts.unit === 'year' || ts.unit === 'month') {
  18863. shouldNotSkipUnit = true;
  18864. }
  18865. if (value === 30) {
  18866. shouldNotPrint = true;
  18867. }
  18868. break;
  18869. case 'months_days':
  18870. modulo = 10;
  18871. if (ts.unit === 'month') {
  18872. shouldNotSkipUnit = true;
  18873. }
  18874. if (value === 30) {
  18875. shouldNotPrint = true;
  18876. }
  18877. break;
  18878. case 'week_days':
  18879. modulo = 8;
  18880. if (ts.unit === 'month') {
  18881. shouldNotSkipUnit = true;
  18882. }
  18883. break;
  18884. case 'days':
  18885. modulo = 1;
  18886. if (ts.unit === 'month') {
  18887. shouldNotSkipUnit = true;
  18888. }
  18889. break;
  18890. case 'hours':
  18891. if (ts.unit === 'day') {
  18892. shouldNotSkipUnit = true;
  18893. }
  18894. break;
  18895. case 'minutes':
  18896. if (value % 5 !== 0) {
  18897. shouldNotPrint = true;
  18898. }
  18899. break;
  18900. }
  18901. if (_this.tickInterval === 'minutes' || _this.tickInterval === 'hours') {
  18902. if (!shouldNotPrint) {
  18903. return true;
  18904. }
  18905. } else {
  18906. if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) {
  18907. return true;
  18908. }
  18909. }
  18910. });
  18911. return filteredTimeScale;
  18912. }
  18913. }, {
  18914. key: "recalcDimensionsBasedOnFormat",
  18915. value: function recalcDimensionsBasedOnFormat(filteredTimeScale, inverted) {
  18916. var w = this.w;
  18917. var reformattedTimescaleArray = this.formatDates(filteredTimeScale);
  18918. var removedOverlappingTS = this.removeOverlappingTS(reformattedTimescaleArray);
  18919. 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
  18920. // 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
  18921. // Dependency on Dimensions(), need to refactor correctly
  18922. // TODO - find an alternate way to avoid calling this Heavy method twice
  18923. var dimensions = new Dimensions(this.ctx);
  18924. dimensions.plotCoords();
  18925. }
  18926. }, {
  18927. key: "determineInterval",
  18928. value: function determineInterval(daysDiff) {
  18929. switch (true) {
  18930. case daysDiff > 1825:
  18931. // difference is more than 5 years
  18932. this.tickInterval = 'years';
  18933. break;
  18934. case daysDiff > 800 && daysDiff <= 1825:
  18935. this.tickInterval = 'half_year';
  18936. break;
  18937. case daysDiff > 180 && daysDiff <= 800:
  18938. this.tickInterval = 'months';
  18939. break;
  18940. case daysDiff > 90 && daysDiff <= 180:
  18941. this.tickInterval = 'months_fortnight';
  18942. break;
  18943. case daysDiff > 60 && daysDiff <= 90:
  18944. this.tickInterval = 'months_days';
  18945. break;
  18946. case daysDiff > 30 && daysDiff <= 60:
  18947. this.tickInterval = 'week_days';
  18948. break;
  18949. case daysDiff > 2 && daysDiff <= 30:
  18950. this.tickInterval = 'days';
  18951. break;
  18952. case daysDiff > 0.1 && daysDiff <= 2:
  18953. // less than 2 days
  18954. this.tickInterval = 'hours';
  18955. break;
  18956. case daysDiff < 0.1:
  18957. this.tickInterval = 'minutes';
  18958. break;
  18959. default:
  18960. this.tickInterval = 'days';
  18961. break;
  18962. }
  18963. }
  18964. }, {
  18965. key: "generateYearScale",
  18966. value: function generateYearScale(_ref) {
  18967. var firstVal = _ref.firstVal,
  18968. currentMonth = _ref.currentMonth,
  18969. currentYear = _ref.currentYear,
  18970. daysWidthOnXAxis = _ref.daysWidthOnXAxis,
  18971. numberOfYears = _ref.numberOfYears;
  18972. var firstTickValue = firstVal.minYear;
  18973. var firstTickPosition = 0;
  18974. var dt = new DateTime(this.ctx);
  18975. var unit = 'year';
  18976. if (firstVal.minDate > 1 || firstVal.minMonth > 0) {
  18977. var remainingDays = dt.determineRemainingDaysOfYear(firstVal.minYear, firstVal.minMonth, firstVal.minDate); // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  18978. var remainingDaysOfFirstYear = dt.determineDaysOfYear(firstVal.minYear) - remainingDays + 1; // calculate the first tick position
  18979. firstTickPosition = remainingDaysOfFirstYear * daysWidthOnXAxis;
  18980. firstTickValue = firstVal.minYear + 1; // push the first tick in the array
  18981. this.timeScaleArray.push({
  18982. position: firstTickPosition,
  18983. value: firstTickValue,
  18984. unit: unit,
  18985. year: firstTickValue,
  18986. month: Utils.monthMod(currentMonth + 1)
  18987. });
  18988. } else if (firstVal.minDate === 1 && firstVal.minMonth === 0) {
  18989. // push the first tick in the array
  18990. this.timeScaleArray.push({
  18991. position: firstTickPosition,
  18992. value: firstTickValue,
  18993. unit: unit,
  18994. year: currentYear,
  18995. month: Utils.monthMod(currentMonth + 1)
  18996. });
  18997. }
  18998. var year = firstTickValue;
  18999. var pos = firstTickPosition; // keep drawing rest of the ticks
  19000. for (var i = 0; i < numberOfYears; i++) {
  19001. year++;
  19002. pos = dt.determineDaysOfYear(year - 1) * daysWidthOnXAxis + pos;
  19003. this.timeScaleArray.push({
  19004. position: pos,
  19005. value: year,
  19006. unit: unit,
  19007. year: year,
  19008. month: 1
  19009. });
  19010. }
  19011. }
  19012. }, {
  19013. key: "generateMonthScale",
  19014. value: function generateMonthScale(_ref2) {
  19015. var firstVal = _ref2.firstVal,
  19016. currentMonthDate = _ref2.currentMonthDate,
  19017. currentMonth = _ref2.currentMonth,
  19018. currentYear = _ref2.currentYear,
  19019. daysWidthOnXAxis = _ref2.daysWidthOnXAxis,
  19020. numberOfMonths = _ref2.numberOfMonths;
  19021. var firstTickValue = currentMonth;
  19022. var firstTickPosition = 0;
  19023. var dt = new DateTime(this.ctx);
  19024. var unit = 'month';
  19025. var yrCounter = 0;
  19026. if (firstVal.minDate > 1) {
  19027. // remainingDaysofFirstMonth is used to reacht the 2nd tick position
  19028. var remainingDaysOfFirstMonth = dt.determineDaysOfMonths(currentMonth + 1, firstVal.minYear) - currentMonthDate + 1; // calculate the first tick position
  19029. firstTickPosition = remainingDaysOfFirstMonth * daysWidthOnXAxis;
  19030. firstTickValue = Utils.monthMod(currentMonth + 1);
  19031. var year = currentYear + yrCounter;
  19032. var _month = Utils.monthMod(firstTickValue);
  19033. var value = firstTickValue; // it's Jan, so update the year
  19034. if (firstTickValue === 0) {
  19035. unit = 'year';
  19036. value = year;
  19037. _month = 1;
  19038. yrCounter += 1;
  19039. year = year + yrCounter;
  19040. } // push the first tick in the array
  19041. this.timeScaleArray.push({
  19042. position: firstTickPosition,
  19043. value: value,
  19044. unit: unit,
  19045. year: year,
  19046. month: _month
  19047. });
  19048. } else {
  19049. // push the first tick in the array
  19050. this.timeScaleArray.push({
  19051. position: firstTickPosition,
  19052. value: firstTickValue,
  19053. unit: unit,
  19054. year: currentYear,
  19055. month: Utils.monthMod(currentMonth)
  19056. });
  19057. }
  19058. var month = firstTickValue + 1;
  19059. var pos = firstTickPosition; // keep drawing rest of the ticks
  19060. for (var i = 0, j = 1; i < numberOfMonths; i++, j++) {
  19061. month = Utils.monthMod(month);
  19062. if (month === 0) {
  19063. unit = 'year';
  19064. yrCounter += 1;
  19065. } else {
  19066. unit = 'month';
  19067. }
  19068. var _year = this._getYear(currentYear, month, yrCounter);
  19069. pos = dt.determineDaysOfMonths(month, _year) * daysWidthOnXAxis + pos;
  19070. var monthVal = month === 0 ? _year : month;
  19071. this.timeScaleArray.push({
  19072. position: pos,
  19073. value: monthVal,
  19074. unit: unit,
  19075. year: _year,
  19076. month: month === 0 ? 1 : month
  19077. });
  19078. month++;
  19079. }
  19080. }
  19081. }, {
  19082. key: "generateDayScale",
  19083. value: function generateDayScale(_ref3) {
  19084. var firstVal = _ref3.firstVal,
  19085. currentMonth = _ref3.currentMonth,
  19086. currentYear = _ref3.currentYear,
  19087. hoursWidthOnXAxis = _ref3.hoursWidthOnXAxis,
  19088. numberOfDays = _ref3.numberOfDays;
  19089. var dt = new DateTime(this.ctx);
  19090. var unit = 'day';
  19091. var firstTickValue = firstVal.minDate + 1;
  19092. var date = firstTickValue;
  19093. var changeMonth = function changeMonth(dateVal, month, year) {
  19094. var monthdays = dt.determineDaysOfMonths(month + 1, year);
  19095. if (dateVal > monthdays) {
  19096. month = month + 1;
  19097. date = 1;
  19098. unit = 'month';
  19099. val = month;
  19100. return month;
  19101. }
  19102. return month;
  19103. };
  19104. var remainingHours = 24 - firstVal.minHour;
  19105. var yrCounter = 0; // calculate the first tick position
  19106. var firstTickPosition = remainingHours * hoursWidthOnXAxis;
  19107. var val = firstTickValue;
  19108. var month = changeMonth(date, currentMonth, currentYear);
  19109. if (firstVal.minHour === 0 && firstVal.minDate === 1) {
  19110. // the first value is the first day of month
  19111. firstTickPosition = 0;
  19112. val = Utils.monthMod(firstVal.minMonth);
  19113. unit = 'month';
  19114. date = firstVal.minDate;
  19115. numberOfDays++;
  19116. } // push the first tick in the array
  19117. this.timeScaleArray.push({
  19118. position: firstTickPosition,
  19119. value: val,
  19120. unit: unit,
  19121. year: this._getYear(currentYear, month, yrCounter),
  19122. month: Utils.monthMod(month),
  19123. day: date
  19124. });
  19125. var pos = firstTickPosition; // keep drawing rest of the ticks
  19126. for (var i = 0; i < numberOfDays; i++) {
  19127. date += 1;
  19128. unit = 'day';
  19129. month = changeMonth(date, month, this._getYear(currentYear, month, yrCounter));
  19130. var year = this._getYear(currentYear, month, yrCounter);
  19131. pos = 24 * hoursWidthOnXAxis + pos;
  19132. var value = date === 1 ? Utils.monthMod(month) : date;
  19133. this.timeScaleArray.push({
  19134. position: pos,
  19135. value: value,
  19136. unit: unit,
  19137. year: year,
  19138. month: Utils.monthMod(month),
  19139. day: value
  19140. });
  19141. }
  19142. }
  19143. }, {
  19144. key: "generateHourScale",
  19145. value: function generateHourScale(_ref4) {
  19146. var firstVal = _ref4.firstVal,
  19147. currentDate = _ref4.currentDate,
  19148. currentMonth = _ref4.currentMonth,
  19149. currentYear = _ref4.currentYear,
  19150. minutesWidthOnXAxis = _ref4.minutesWidthOnXAxis,
  19151. numberOfHours = _ref4.numberOfHours;
  19152. var dt = new DateTime(this.ctx);
  19153. var yrCounter = 0;
  19154. var unit = 'hour';
  19155. var changeDate = function changeDate(dateVal, month) {
  19156. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  19157. if (dateVal > monthdays) {
  19158. date = 1;
  19159. month = month + 1;
  19160. }
  19161. return {
  19162. month: month,
  19163. date: date
  19164. };
  19165. };
  19166. var changeMonth = function changeMonth(dateVal, month) {
  19167. var monthdays = dt.determineDaysOfMonths(month + 1, currentYear);
  19168. if (dateVal > monthdays) {
  19169. month = month + 1;
  19170. return month;
  19171. }
  19172. return month;
  19173. };
  19174. var remainingMins = 60 - firstVal.minMinute;
  19175. var firstTickPosition = remainingMins * minutesWidthOnXAxis;
  19176. var firstTickValue = firstVal.minHour + 1;
  19177. var hour = firstTickValue + 1;
  19178. if (remainingMins === 60) {
  19179. firstTickPosition = 0;
  19180. firstTickValue = firstVal.minHour;
  19181. hour = firstTickValue + 1;
  19182. }
  19183. var date = currentDate;
  19184. var month = changeMonth(date, currentMonth); // push the first tick in the array
  19185. this.timeScaleArray.push({
  19186. position: firstTickPosition,
  19187. value: firstTickValue,
  19188. unit: unit,
  19189. day: date,
  19190. hour: hour,
  19191. year: currentYear,
  19192. month: Utils.monthMod(month)
  19193. });
  19194. var pos = firstTickPosition; // keep drawing rest of the ticks
  19195. for (var i = 0; i < numberOfHours; i++) {
  19196. unit = 'hour';
  19197. if (hour >= 24) {
  19198. hour = 0;
  19199. date += 1;
  19200. unit = 'day';
  19201. var checkNextMonth = changeDate(date, month);
  19202. month = checkNextMonth.month;
  19203. month = changeMonth(date, month);
  19204. }
  19205. var year = this._getYear(currentYear, month, yrCounter);
  19206. pos = hour === 0 && i === 0 ? remainingMins * minutesWidthOnXAxis : 60 * minutesWidthOnXAxis + pos;
  19207. var val = hour === 0 ? date : hour;
  19208. this.timeScaleArray.push({
  19209. position: pos,
  19210. value: val,
  19211. unit: unit,
  19212. hour: hour,
  19213. day: date,
  19214. year: year,
  19215. month: Utils.monthMod(month)
  19216. });
  19217. hour++;
  19218. }
  19219. }
  19220. }, {
  19221. key: "generateMinuteScale",
  19222. value: function generateMinuteScale(_ref5) {
  19223. var firstVal = _ref5.firstVal,
  19224. currentMinute = _ref5.currentMinute,
  19225. currentHour = _ref5.currentHour,
  19226. currentDate = _ref5.currentDate,
  19227. currentMonth = _ref5.currentMonth,
  19228. currentYear = _ref5.currentYear,
  19229. minutesWidthOnXAxis = _ref5.minutesWidthOnXAxis,
  19230. numberOfMinutes = _ref5.numberOfMinutes;
  19231. var yrCounter = 0;
  19232. var unit = 'minute';
  19233. var remainingMins = currentMinute - firstVal.minMinute;
  19234. var firstTickPosition = minutesWidthOnXAxis - remainingMins;
  19235. var firstTickValue = firstVal.minMinute + 1;
  19236. var minute = firstTickValue + 1;
  19237. var date = currentDate;
  19238. var month = currentMonth;
  19239. var year = currentYear;
  19240. var hour = currentHour; // push the first tick in the array
  19241. this.timeScaleArray.push({
  19242. position: firstTickPosition,
  19243. value: firstTickValue,
  19244. unit: unit,
  19245. day: date,
  19246. hour: hour,
  19247. minute: minute,
  19248. year: year,
  19249. month: Utils.monthMod(month)
  19250. });
  19251. var pos = firstTickPosition; // keep drawing rest of the ticks
  19252. for (var i = 0; i < numberOfMinutes; i++) {
  19253. if (minute >= 60) {
  19254. minute = 0;
  19255. hour += 1;
  19256. if (hour === 24) {
  19257. hour = 0;
  19258. }
  19259. }
  19260. pos = minutesWidthOnXAxis + pos;
  19261. this.timeScaleArray.push({
  19262. position: pos,
  19263. value: minute,
  19264. unit: unit,
  19265. hour: hour,
  19266. minute: minute,
  19267. day: date,
  19268. year: this._getYear(currentYear, month, yrCounter),
  19269. month: Utils.monthMod(month)
  19270. });
  19271. minute++;
  19272. }
  19273. }
  19274. }, {
  19275. key: "createRawDateString",
  19276. value: function createRawDateString(ts, value) {
  19277. var raw = ts.year;
  19278. raw += '-' + ('0' + ts.month.toString()).slice(-2); // unit is day
  19279. if (ts.unit === 'day') {
  19280. raw += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01';
  19281. } else {
  19282. raw += '-' + ('0' + (ts.day ? ts.day : '1')).slice(-2);
  19283. } // unit is hour
  19284. if (ts.unit === 'hour') {
  19285. raw += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) : 'T00';
  19286. } else {
  19287. raw += 'T' + ('0' + (ts.hour ? ts.hour : '0')).slice(-2);
  19288. } // unit is minute
  19289. raw += ts.unit === 'minute' ? ':' + ('0' + value).slice(-2) + ':00' : ':00:00';
  19290. if (this.utc) {
  19291. raw += '.000Z';
  19292. }
  19293. return raw;
  19294. }
  19295. }, {
  19296. key: "formatDates",
  19297. value: function formatDates(filteredTimeScale) {
  19298. var _this2 = this;
  19299. var w = this.w;
  19300. var reformattedTimescaleArray = filteredTimeScale.map(function (ts) {
  19301. var value = ts.value.toString();
  19302. var dt = new DateTime(_this2.ctx);
  19303. var raw = _this2.createRawDateString(ts, value);
  19304. var dateToFormat = dt.getDate(raw);
  19305. if (w.config.xaxis.labels.format === undefined) {
  19306. var customFormat = 'dd MMM';
  19307. var dtFormatter = w.config.xaxis.labels.datetimeFormatter;
  19308. if (ts.unit === 'year') customFormat = dtFormatter.year;
  19309. if (ts.unit === 'month') customFormat = dtFormatter.month;
  19310. if (ts.unit === 'day') customFormat = dtFormatter.day;
  19311. if (ts.unit === 'hour') customFormat = dtFormatter.hour;
  19312. if (ts.unit === 'minute') customFormat = dtFormatter.minute;
  19313. value = dt.formatDate(dateToFormat, customFormat);
  19314. } else {
  19315. value = dt.formatDate(dateToFormat, w.config.xaxis.labels.format);
  19316. }
  19317. return {
  19318. dateString: raw,
  19319. position: ts.position,
  19320. value: value,
  19321. unit: ts.unit,
  19322. year: ts.year,
  19323. month: ts.month
  19324. };
  19325. });
  19326. return reformattedTimescaleArray;
  19327. }
  19328. }, {
  19329. key: "removeOverlappingTS",
  19330. value: function removeOverlappingTS(arr) {
  19331. var _this3 = this;
  19332. var graphics = new Graphics(this.ctx);
  19333. var equalLabelLengthFlag = false; // These labels got same length?
  19334. var constantLabelWidth; // If true, what is the constant length to use
  19335. if (arr.length > 0 && // check arr length
  19336. arr[0].value && // check arr[0] contains value
  19337. arr.every(function (lb) {
  19338. return lb.value.length === arr[0].value.length;
  19339. }) // check every arr label value is the same as the first one
  19340. ) {
  19341. equalLabelLengthFlag = true; // These labels got same length
  19342. constantLabelWidth = graphics.getTextRects(arr[0].value).width; // The constant label width to use
  19343. }
  19344. var lastDrawnIndex = 0;
  19345. var filteredArray = arr.map(function (item, index) {
  19346. if (index > 0 && _this3.w.config.xaxis.labels.hideOverlappingLabels) {
  19347. var prevLabelWidth = !equalLabelLengthFlag // if vary in label length
  19348. ? graphics.getTextRects(arr[lastDrawnIndex].value).width // get individual length
  19349. : constantLabelWidth; // else: use constant length
  19350. var prevPos = arr[lastDrawnIndex].position;
  19351. var pos = item.position;
  19352. if (pos > prevPos + prevLabelWidth + 10) {
  19353. lastDrawnIndex = index;
  19354. return item;
  19355. } else {
  19356. return null;
  19357. }
  19358. } else {
  19359. return item;
  19360. }
  19361. });
  19362. filteredArray = filteredArray.filter(function (f) {
  19363. return f !== null;
  19364. });
  19365. return filteredArray;
  19366. }
  19367. }, {
  19368. key: "_getYear",
  19369. value: function _getYear(currentYear, month, yrCounter) {
  19370. return currentYear + Math.floor(month / 12) + yrCounter;
  19371. }
  19372. }]);
  19373. return TimeScale;
  19374. }();
  19375. /**
  19376. * ApexCharts Core Class responsible for major calculations and creating elements.
  19377. *
  19378. * @module Core
  19379. **/
  19380. var Core = /*#__PURE__*/function () {
  19381. function Core(el, ctx) {
  19382. _classCallCheck(this, Core);
  19383. this.ctx = ctx;
  19384. this.w = ctx.w;
  19385. this.el = el;
  19386. } // get data and store into appropriate vars
  19387. _createClass(Core, [{
  19388. key: "setupElements",
  19389. value: function setupElements() {
  19390. var gl = this.w.globals;
  19391. var cnf = this.w.config; // const graphics = new Graphics(this.ctx)
  19392. var ct = cnf.chart.type;
  19393. var axisChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble', 'radar', 'heatmap'];
  19394. var xyChartsArrTypes = ['line', 'area', 'bar', 'rangeBar', 'candlestick', 'scatter', 'bubble'];
  19395. gl.axisCharts = axisChartsArrTypes.indexOf(ct) > -1;
  19396. gl.xyCharts = xyChartsArrTypes.indexOf(ct) > -1;
  19397. gl.isBarHorizontal = (cnf.chart.type === 'bar' || cnf.chart.type === 'rangeBar') && cnf.plotOptions.bar.horizontal;
  19398. gl.chartClass = '.apexcharts' + gl.cuid;
  19399. gl.dom.baseEl = this.el;
  19400. gl.dom.elWrap = document.createElement('div');
  19401. Graphics.setAttrs(gl.dom.elWrap, {
  19402. id: gl.chartClass.substring(1),
  19403. class: 'apexcharts-canvas ' + gl.chartClass.substring(1)
  19404. });
  19405. this.el.appendChild(gl.dom.elWrap);
  19406. gl.dom.Paper = new window.SVG.Doc(gl.dom.elWrap);
  19407. gl.dom.Paper.attr({
  19408. class: 'apexcharts-svg',
  19409. 'xmlns:data': 'ApexChartsNS',
  19410. transform: "translate(".concat(cnf.chart.offsetX, ", ").concat(cnf.chart.offsetY, ")")
  19411. });
  19412. gl.dom.Paper.node.style.background = cnf.chart.background;
  19413. this.setSVGDimensions();
  19414. gl.dom.elGraphical = gl.dom.Paper.group().attr({
  19415. class: 'apexcharts-inner apexcharts-graphical'
  19416. });
  19417. gl.dom.elAnnotations = gl.dom.Paper.group().attr({
  19418. class: 'apexcharts-annotations'
  19419. });
  19420. gl.dom.elDefs = gl.dom.Paper.defs();
  19421. gl.dom.elLegendWrap = document.createElement('div');
  19422. gl.dom.elLegendWrap.classList.add('apexcharts-legend');
  19423. gl.dom.elWrap.appendChild(gl.dom.elLegendWrap);
  19424. gl.dom.Paper.add(gl.dom.elGraphical);
  19425. gl.dom.elGraphical.add(gl.dom.elDefs);
  19426. }
  19427. }, {
  19428. key: "plotChartType",
  19429. value: function plotChartType(ser, xyRatios) {
  19430. var w = this.w;
  19431. var cnf = w.config;
  19432. var gl = w.globals;
  19433. var lineSeries = {
  19434. series: [],
  19435. i: []
  19436. };
  19437. var areaSeries = {
  19438. series: [],
  19439. i: []
  19440. };
  19441. var scatterSeries = {
  19442. series: [],
  19443. i: []
  19444. };
  19445. var bubbleSeries = {
  19446. series: [],
  19447. i: []
  19448. };
  19449. var columnSeries = {
  19450. series: [],
  19451. i: []
  19452. };
  19453. var candlestickSeries = {
  19454. series: [],
  19455. i: []
  19456. };
  19457. gl.series.map(function (series, st) {
  19458. // if user has specified a particular type for particular series
  19459. if (typeof ser[st].type !== 'undefined') {
  19460. if (ser[st].type === 'column' || ser[st].type === 'bar') {
  19461. if (gl.series.length > 1 && cnf.plotOptions.bar.horizontal) {
  19462. // horizontal bars not supported in mixed charts, hence show a warning
  19463. console.warn('Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`');
  19464. }
  19465. columnSeries.series.push(series);
  19466. columnSeries.i.push(st);
  19467. w.globals.columnSeries = columnSeries.series;
  19468. } else if (ser[st].type === 'area') {
  19469. areaSeries.series.push(series);
  19470. areaSeries.i.push(st);
  19471. } else if (ser[st].type === 'line') {
  19472. lineSeries.series.push(series);
  19473. lineSeries.i.push(st);
  19474. } else if (ser[st].type === 'scatter') {
  19475. scatterSeries.series.push(series);
  19476. scatterSeries.i.push(st);
  19477. } else if (ser[st].type === 'bubble') {
  19478. bubbleSeries.series.push(series);
  19479. bubbleSeries.i.push(st);
  19480. } else if (ser[st].type === 'candlestick') {
  19481. candlestickSeries.series.push(series);
  19482. candlestickSeries.i.push(st);
  19483. } else {
  19484. // user has specified type, but it is not valid (other than line/area/column)
  19485. console.warn('You have specified an unrecognized chart type. Available types for this propery are line/area/column/bar/scatter/bubble');
  19486. }
  19487. gl.comboCharts = true;
  19488. } else {
  19489. lineSeries.series.push(series);
  19490. lineSeries.i.push(st);
  19491. }
  19492. });
  19493. var line = new Line(this.ctx, xyRatios);
  19494. var candlestick = new CandleStick(this.ctx, xyRatios);
  19495. this.ctx.pie = new Pie(this.ctx);
  19496. var radialBar = new Radial(this.ctx);
  19497. var rangeBar = new RangeBar(this.ctx, xyRatios);
  19498. var radar = new Radar(this.ctx);
  19499. var elGraph = [];
  19500. if (gl.comboCharts) {
  19501. if (areaSeries.series.length > 0) {
  19502. elGraph.push(line.draw(areaSeries.series, 'area', areaSeries.i));
  19503. }
  19504. if (columnSeries.series.length > 0) {
  19505. if (w.config.chart.stacked) {
  19506. var barStacked = new BarStacked(this.ctx, xyRatios);
  19507. elGraph.push(barStacked.draw(columnSeries.series, columnSeries.i));
  19508. } else {
  19509. var bar = new Bar(this.ctx, xyRatios);
  19510. elGraph.push(bar.draw(columnSeries.series, columnSeries.i));
  19511. }
  19512. }
  19513. if (lineSeries.series.length > 0) {
  19514. elGraph.push(line.draw(lineSeries.series, 'line', lineSeries.i));
  19515. }
  19516. if (candlestickSeries.series.length > 0) {
  19517. elGraph.push(candlestick.draw(candlestickSeries.series, candlestickSeries.i));
  19518. }
  19519. if (scatterSeries.series.length > 0) {
  19520. var scatterLine = new Line(this.ctx, xyRatios, true);
  19521. elGraph.push(scatterLine.draw(scatterSeries.series, 'scatter', scatterSeries.i));
  19522. }
  19523. if (bubbleSeries.series.length > 0) {
  19524. var bubbleLine = new Line(this.ctx, xyRatios, true);
  19525. elGraph.push(bubbleLine.draw(bubbleSeries.series, 'bubble', bubbleSeries.i));
  19526. }
  19527. } else {
  19528. switch (cnf.chart.type) {
  19529. case 'line':
  19530. elGraph = line.draw(gl.series, 'line');
  19531. break;
  19532. case 'area':
  19533. elGraph = line.draw(gl.series, 'area');
  19534. break;
  19535. case 'bar':
  19536. if (cnf.chart.stacked) {
  19537. var _barStacked = new BarStacked(this.ctx, xyRatios);
  19538. elGraph = _barStacked.draw(gl.series);
  19539. } else {
  19540. var _bar = new Bar(this.ctx, xyRatios);
  19541. elGraph = _bar.draw(gl.series);
  19542. }
  19543. break;
  19544. case 'candlestick':
  19545. var candleStick = new CandleStick(this.ctx, xyRatios);
  19546. elGraph = candleStick.draw(gl.series);
  19547. break;
  19548. case 'rangeBar':
  19549. elGraph = rangeBar.draw(gl.series);
  19550. break;
  19551. case 'heatmap':
  19552. var heatmap = new HeatMap(this.ctx, xyRatios);
  19553. elGraph = heatmap.draw(gl.series);
  19554. break;
  19555. case 'pie':
  19556. case 'donut':
  19557. case 'polarArea':
  19558. elGraph = this.ctx.pie.draw(gl.series);
  19559. break;
  19560. case 'radialBar':
  19561. elGraph = radialBar.draw(gl.series);
  19562. break;
  19563. case 'radar':
  19564. elGraph = radar.draw(gl.series);
  19565. break;
  19566. default:
  19567. elGraph = line.draw(gl.series);
  19568. }
  19569. }
  19570. return elGraph;
  19571. }
  19572. }, {
  19573. key: "setSVGDimensions",
  19574. value: function setSVGDimensions() {
  19575. var gl = this.w.globals;
  19576. var cnf = this.w.config;
  19577. gl.svgWidth = cnf.chart.width;
  19578. gl.svgHeight = cnf.chart.height;
  19579. var elDim = Utils.getDimensions(this.el);
  19580. var widthUnit = cnf.chart.width.toString().split(/[0-9]+/g).pop();
  19581. if (widthUnit === '%') {
  19582. if (Utils.isNumber(elDim[0])) {
  19583. if (elDim[0].width === 0) {
  19584. elDim = Utils.getDimensions(this.el.parentNode);
  19585. }
  19586. gl.svgWidth = elDim[0] * parseInt(cnf.chart.width, 10) / 100;
  19587. }
  19588. } else if (widthUnit === 'px' || widthUnit === '') {
  19589. gl.svgWidth = parseInt(cnf.chart.width, 10);
  19590. }
  19591. if (gl.svgHeight !== 'auto' && gl.svgHeight !== '') {
  19592. var heightUnit = cnf.chart.height.toString().split(/[0-9]+/g).pop();
  19593. if (heightUnit === '%') {
  19594. var elParentDim = Utils.getDimensions(this.el.parentNode);
  19595. gl.svgHeight = elParentDim[1] * parseInt(cnf.chart.height, 10) / 100;
  19596. } else {
  19597. gl.svgHeight = parseInt(cnf.chart.height, 10);
  19598. }
  19599. } else {
  19600. if (gl.axisCharts) {
  19601. gl.svgHeight = gl.svgWidth / 1.61;
  19602. } else {
  19603. gl.svgHeight = gl.svgWidth / 1.2;
  19604. }
  19605. }
  19606. if (gl.svgWidth < 0) gl.svgWidth = 0;
  19607. if (gl.svgHeight < 0) gl.svgHeight = 0;
  19608. Graphics.setAttrs(gl.dom.Paper.node, {
  19609. width: gl.svgWidth,
  19610. height: gl.svgHeight
  19611. }); // gl.dom.Paper.node.parentNode.parentNode.style.minWidth = gl.svgWidth + "px";
  19612. var offsetY = cnf.chart.sparkline.enabled ? 0 : gl.axisCharts ? cnf.chart.parentHeightOffset : 0;
  19613. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = gl.svgHeight + offsetY + 'px';
  19614. gl.dom.elWrap.style.width = gl.svgWidth + 'px';
  19615. gl.dom.elWrap.style.height = gl.svgHeight + 'px';
  19616. }
  19617. }, {
  19618. key: "shiftGraphPosition",
  19619. value: function shiftGraphPosition() {
  19620. var gl = this.w.globals;
  19621. var tY = gl.translateY;
  19622. var tX = gl.translateX;
  19623. var scalingAttrs = {
  19624. transform: 'translate(' + tX + ', ' + tY + ')'
  19625. };
  19626. Graphics.setAttrs(gl.dom.elGraphical.node, scalingAttrs);
  19627. gl.x2SpaceAvailable = gl.svgWidth - gl.dom.elGraphical.x() - gl.gridWidth;
  19628. } // To prevent extra spacings in the bottom of the chart, we need to recalculate the height for pie/donut/radialbar charts
  19629. }, {
  19630. key: "resizeNonAxisCharts",
  19631. value: function resizeNonAxisCharts() {
  19632. var w = this.w;
  19633. var gl = w.globals;
  19634. var legendHeight = 0;
  19635. var offY = w.config.chart.sparkline.enabled ? 1 : 15;
  19636. offY = offY + w.config.grid.padding.bottom;
  19637. if ((w.config.legend.position === 'top' || w.config.legend.position === 'bottom') && w.config.legend.show && !w.config.legend.floating) {
  19638. legendHeight = new Legend(this.ctx).legendHelpers.getLegendBBox().clwh + 10;
  19639. }
  19640. var radialEl = w.globals.dom.baseEl.querySelector('.apexcharts-radialbar');
  19641. var chartInnerDimensions = w.globals.radialSize * 2.05;
  19642. if (radialEl && !w.config.chart.sparkline.enabled) {
  19643. var elRadialRect = Utils.getBoundingClientRect(radialEl);
  19644. chartInnerDimensions = elRadialRect.bottom;
  19645. var maxHeight = elRadialRect.bottom - elRadialRect.top;
  19646. chartInnerDimensions = Math.max(w.globals.radialSize * 2.05, maxHeight);
  19647. }
  19648. var newHeight = chartInnerDimensions + gl.translateY + legendHeight + offY;
  19649. if (gl.dom.elLegendForeign) {
  19650. gl.dom.elLegendForeign.setAttribute('height', newHeight);
  19651. }
  19652. gl.dom.elWrap.style.height = newHeight + 'px';
  19653. Graphics.setAttrs(gl.dom.Paper.node, {
  19654. height: newHeight
  19655. });
  19656. gl.dom.Paper.node.parentNode.parentNode.style.minHeight = newHeight + 'px';
  19657. }
  19658. /*
  19659. ** All the calculations for setting range in charts will be done here
  19660. */
  19661. }, {
  19662. key: "coreCalculations",
  19663. value: function coreCalculations() {
  19664. var range = new Range$1(this.ctx);
  19665. range.init();
  19666. }
  19667. }, {
  19668. key: "resetGlobals",
  19669. value: function resetGlobals() {
  19670. var _this = this;
  19671. var resetxyValues = function resetxyValues() {
  19672. return _this.w.config.series.map(function (s) {
  19673. return [];
  19674. });
  19675. };
  19676. var globalObj = new Globals();
  19677. var gl = this.w.globals;
  19678. globalObj.initGlobalVars(gl);
  19679. gl.seriesXvalues = resetxyValues();
  19680. gl.seriesYvalues = resetxyValues();
  19681. }
  19682. }, {
  19683. key: "isMultipleY",
  19684. value: function isMultipleY() {
  19685. // user has supplied an array in yaxis property. So, turn on multipleYAxis flag
  19686. if (this.w.config.yaxis.constructor === Array && this.w.config.yaxis.length > 1) {
  19687. this.w.globals.isMultipleYAxis = true;
  19688. return true;
  19689. }
  19690. }
  19691. }, {
  19692. key: "xySettings",
  19693. value: function xySettings() {
  19694. var xyRatios = null;
  19695. var w = this.w;
  19696. if (w.globals.axisCharts) {
  19697. if (w.config.xaxis.crosshairs.position === 'back') {
  19698. var crosshairs = new Crosshairs(this.ctx);
  19699. crosshairs.drawXCrosshairs();
  19700. }
  19701. if (w.config.yaxis[0].crosshairs.position === 'back') {
  19702. var _crosshairs = new Crosshairs(this.ctx);
  19703. _crosshairs.drawYCrosshairs();
  19704. }
  19705. if (w.config.xaxis.type === 'datetime' && w.config.xaxis.labels.formatter === undefined) {
  19706. var ts = new TimeScale(this.ctx);
  19707. var formattedTimeScale = [];
  19708. if (isFinite(w.globals.minX) && isFinite(w.globals.maxX) && !w.globals.isBarHorizontal) {
  19709. formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minX, w.globals.maxX);
  19710. } else if (w.globals.isBarHorizontal) {
  19711. formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minY, w.globals.maxY);
  19712. }
  19713. ts.recalcDimensionsBasedOnFormat(formattedTimeScale);
  19714. }
  19715. var coreUtils = new CoreUtils(this.ctx);
  19716. xyRatios = coreUtils.getCalculatedRatios();
  19717. }
  19718. return xyRatios;
  19719. }
  19720. }, {
  19721. key: "updateSourceChart",
  19722. value: function updateSourceChart(targetChart) {
  19723. this.ctx.w.globals.selection = undefined;
  19724. this.ctx.updateHelpers._updateOptions({
  19725. chart: {
  19726. selection: {
  19727. xaxis: {
  19728. min: targetChart.w.globals.minX,
  19729. max: targetChart.w.globals.maxX
  19730. }
  19731. }
  19732. }
  19733. }, false, false);
  19734. }
  19735. }, {
  19736. key: "setupBrushHandler",
  19737. value: function setupBrushHandler() {
  19738. var _this2 = this;
  19739. var w = this.w; // only for brush charts
  19740. if (!w.config.chart.brush.enabled) {
  19741. return;
  19742. } // if user has not defined a custom function for selection - we handle the brush chart
  19743. // otherwise we leave it to the user to define the functionality for selection
  19744. if (typeof w.config.chart.events.selection !== 'function') {
  19745. var targets = w.config.chart.brush.targets || [w.config.chart.brush.target]; // retro compatibility with single target option
  19746. targets.forEach(function (target) {
  19747. var targetChart = ApexCharts.getChartByID(target);
  19748. targetChart.w.globals.brushSource = _this2.ctx;
  19749. if (typeof targetChart.w.config.chart.events.zoomed !== 'function') {
  19750. targetChart.w.config.chart.events.zoomed = function () {
  19751. _this2.updateSourceChart(targetChart);
  19752. };
  19753. }
  19754. if (typeof targetChart.w.config.chart.events.scrolled !== 'function') {
  19755. targetChart.w.config.chart.events.scrolled = function () {
  19756. _this2.updateSourceChart(targetChart);
  19757. };
  19758. }
  19759. });
  19760. w.config.chart.events.selection = function (chart, e) {
  19761. targets.forEach(function (target) {
  19762. var targetChart = ApexCharts.getChartByID(target);
  19763. var yaxis = Utils.clone(w.config.yaxis);
  19764. if (w.config.chart.brush.autoScaleYaxis && targetChart.w.globals.series.length === 1) {
  19765. var scale = new Range(targetChart);
  19766. yaxis = scale.autoScaleY(targetChart, yaxis, e);
  19767. }
  19768. targetChart.ctx.updateHelpers._updateOptions({
  19769. xaxis: {
  19770. min: e.xaxis.min,
  19771. max: e.xaxis.max
  19772. },
  19773. yaxis: _objectSpread2({}, targetChart.w.config.yaxis[0], {
  19774. min: yaxis[0].min,
  19775. max: yaxis[0].max
  19776. })
  19777. }, false, false, false, false);
  19778. });
  19779. };
  19780. }
  19781. }
  19782. }]);
  19783. return Core;
  19784. }();
  19785. var UpdateHelpers = /*#__PURE__*/function () {
  19786. function UpdateHelpers(ctx) {
  19787. _classCallCheck(this, UpdateHelpers);
  19788. this.ctx = ctx;
  19789. this.w = ctx.w;
  19790. }
  19791. /**
  19792. * private method to update Options.
  19793. *
  19794. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  19795. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  19796. * @param {boolean} animate - should animate or not on updating Options
  19797. * @param {boolean} overwriteInitialConfig - should update the initial config or not
  19798. */
  19799. _createClass(UpdateHelpers, [{
  19800. key: "_updateOptions",
  19801. value: function _updateOptions(options) {
  19802. var _this = this;
  19803. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19804. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  19805. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  19806. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  19807. var charts = [this.ctx];
  19808. if (updateSyncedCharts) {
  19809. charts = this.ctx.getSyncedCharts();
  19810. }
  19811. if (this.ctx.w.globals.isExecCalled) {
  19812. // If the user called exec method, we don't want to get grouped charts as user specifically provided a chartID to update
  19813. charts = [this.ctx];
  19814. this.ctx.w.globals.isExecCalled = false;
  19815. }
  19816. charts.forEach(function (ch) {
  19817. var w = ch.w;
  19818. w.globals.shouldAnimate = animate;
  19819. if (!redraw) {
  19820. w.globals.resized = true;
  19821. w.globals.dataChanged = true;
  19822. if (animate) {
  19823. ch.series.getPreviousPaths();
  19824. }
  19825. }
  19826. if (options && _typeof(options) === 'object') {
  19827. ch.config = new Config(options);
  19828. options = CoreUtils.extendArrayProps(ch.config, options, w); // fixes #914, #623
  19829. if (ch.w.globals.chartID !== _this.ctx.w.globals.chartID) {
  19830. // don't overwrite series of synchronized charts
  19831. delete options.series;
  19832. }
  19833. w.config = Utils.extend(w.config, options);
  19834. if (overwriteInitialConfig) {
  19835. // we need to forget the lastXAxis and lastYAxis is user forcefully overwriteInitialConfig. If we do not do this, and next time when user zooms the chart after setting yaxis.min/max or xaxis.min/max - the stored lastXAxis will never allow the chart to use the updated min/max by user.
  19836. w.globals.lastXAxis = [];
  19837. w.globals.lastYAxis = []; // After forgetting lastAxes, we need to restore the new config in initialConfig/initialSeries
  19838. w.globals.initialConfig = Utils.extend({}, w.config);
  19839. w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
  19840. }
  19841. }
  19842. return ch.update(options);
  19843. });
  19844. }
  19845. /**
  19846. * Private method to update Series.
  19847. *
  19848. * @param {array} series - New series which will override the existing
  19849. */
  19850. }, {
  19851. key: "_updateSeries",
  19852. value: function _updateSeries(newSeries, animate) {
  19853. var _this2 = this;
  19854. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19855. var w = this.w;
  19856. w.globals.shouldAnimate = animate;
  19857. w.globals.dataChanged = true;
  19858. if (animate) {
  19859. this.ctx.series.getPreviousPaths();
  19860. }
  19861. var existingSeries; // axis charts
  19862. if (w.globals.axisCharts) {
  19863. existingSeries = newSeries.map(function (s, i) {
  19864. return _this2._extendSeries(s, i);
  19865. });
  19866. if (existingSeries.length === 0) {
  19867. existingSeries = [{
  19868. data: []
  19869. }];
  19870. }
  19871. w.config.series = existingSeries;
  19872. } else {
  19873. // non-axis chart (pie/radialbar)
  19874. w.config.series = newSeries.slice();
  19875. }
  19876. if (overwriteInitialSeries) {
  19877. w.globals.initialConfig.series = JSON.parse(JSON.stringify(w.config.series));
  19878. w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series));
  19879. }
  19880. return this.ctx.update();
  19881. }
  19882. }, {
  19883. key: "_extendSeries",
  19884. value: function _extendSeries(s, i) {
  19885. var w = this.w;
  19886. return _objectSpread2({}, w.config.series[i], {
  19887. name: s.name ? s.name : w.config.series[i] && w.config.series[i].name,
  19888. type: s.type ? s.type : w.config.series[i] && w.config.series[i].type,
  19889. data: s.data ? s.data : w.config.series[i] && w.config.series[i].data
  19890. });
  19891. }
  19892. }, {
  19893. key: "toggleDataPointSelection",
  19894. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  19895. var w = this.w;
  19896. var elPath = null;
  19897. var parent = ".apexcharts-series[data\\:realIndex='".concat(seriesIndex, "']");
  19898. if (w.globals.axisCharts) {
  19899. 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];
  19900. } else {
  19901. // dataPointIndex will be undefined here, hence using seriesIndex
  19902. if (typeof dataPointIndex === 'undefined') {
  19903. elPath = w.globals.dom.Paper.select("".concat(parent, " path[j='").concat(seriesIndex, "']")).members[0];
  19904. if (w.config.chart.type === 'pie' || w.config.chart.type === 'polarArea' || w.config.chart.type === 'donut') {
  19905. this.ctx.pie.pieClicked(seriesIndex);
  19906. }
  19907. }
  19908. }
  19909. if (elPath) {
  19910. var graphics = new Graphics(this.ctx);
  19911. graphics.pathMouseDown(elPath, null);
  19912. } else {
  19913. console.warn('toggleDataPointSelection: Element not found');
  19914. return null;
  19915. }
  19916. return elPath.node ? elPath.node : null;
  19917. }
  19918. }, {
  19919. key: "forceXAxisUpdate",
  19920. value: function forceXAxisUpdate(options) {
  19921. var w = this.w;
  19922. var minmax = ['min', 'max'];
  19923. minmax.forEach(function (a) {
  19924. if (typeof options.xaxis[a] !== 'undefined') {
  19925. w.config.xaxis[a] = options.xaxis[a];
  19926. w.globals.lastXAxis[a] = options.xaxis[a];
  19927. }
  19928. });
  19929. if (options.xaxis.categories && options.xaxis.categories.length) {
  19930. w.config.xaxis.categories = options.xaxis.categories;
  19931. }
  19932. if (w.config.xaxis.convertedCatToNumeric) {
  19933. var defaults = new Defaults(options);
  19934. options = defaults.convertCatToNumericXaxis(options, this.ctx);
  19935. }
  19936. return options;
  19937. }
  19938. }, {
  19939. key: "forceYAxisUpdate",
  19940. value: function forceYAxisUpdate(options) {
  19941. var w = this.w;
  19942. if (w.config.chart.stacked && w.config.chart.stackType === '100%') {
  19943. if (Array.isArray(options.yaxis)) {
  19944. options.yaxis.forEach(function (yaxe, index) {
  19945. options.yaxis[index].min = 0;
  19946. options.yaxis[index].max = 100;
  19947. });
  19948. } else {
  19949. options.yaxis.min = 0;
  19950. options.yaxis.max = 100;
  19951. }
  19952. }
  19953. return options;
  19954. }
  19955. /**
  19956. * This function reverts the yaxis and xaxis min/max values to what it was when the chart was defined.
  19957. * 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
  19958. * Also, this should never be called internally on zoom/pan - the reset should only happen when user calls the updateSeries() function externally
  19959. */
  19960. }, {
  19961. key: "revertDefaultAxisMinMax",
  19962. value: function revertDefaultAxisMinMax() {
  19963. var _this3 = this;
  19964. var w = this.w;
  19965. w.config.xaxis.min = w.globals.lastXAxis.min;
  19966. w.config.xaxis.max = w.globals.lastXAxis.max;
  19967. w.config.yaxis.map(function (yaxe, index) {
  19968. if (w.globals.zoomed) {
  19969. // user has zoomed, check the last yaxis
  19970. if (typeof w.globals.lastYAxis[index] !== 'undefined') {
  19971. yaxe.min = w.globals.lastYAxis[index].min;
  19972. yaxe.max = w.globals.lastYAxis[index].max;
  19973. }
  19974. } else {
  19975. // user hasn't zoomed, check the original yaxis
  19976. if (typeof _this3.ctx.opts.yaxis[index] !== 'undefined') {
  19977. yaxe.min = _this3.ctx.opts.yaxis[index].min;
  19978. yaxe.max = _this3.ctx.opts.yaxis[index].max;
  19979. }
  19980. }
  19981. });
  19982. }
  19983. }]);
  19984. return UpdateHelpers;
  19985. }();
  19986. (function (root, factory) {
  19987. /* istanbul ignore next */
  19988. if (typeof define === 'function' && define.amd) {
  19989. define(function () {
  19990. return factory(root, root.document);
  19991. });
  19992. /* below check fixes #412 */
  19993. } else if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
  19994. module.exports = root.document ? factory(root, root.document) : function (w) {
  19995. return factory(w, w.document);
  19996. };
  19997. } else {
  19998. root.SVG = factory(root, root.document);
  19999. }
  20000. })(typeof window !== 'undefined' ? window : undefined, function (window, document) {
  20001. // Find global reference - uses 'this' by default when available,
  20002. // falls back to 'window' otherwise (for bundlers like Webpack)
  20003. var globalRef = typeof this !== 'undefined' ? this : window; // The main wrapping element
  20004. var SVG = globalRef.SVG = function (element) {
  20005. if (SVG.supported) {
  20006. element = new SVG.Doc(element);
  20007. if (!SVG.parser.draw) {
  20008. SVG.prepare();
  20009. }
  20010. return element;
  20011. }
  20012. }; // Default namespaces
  20013. SVG.ns = 'http://www.w3.org/2000/svg';
  20014. SVG.xmlns = 'http://www.w3.org/2000/xmlns/';
  20015. SVG.xlink = 'http://www.w3.org/1999/xlink';
  20016. SVG.svgjs = 'http://svgjs.com/svgjs'; // Svg support test
  20017. SVG.supported = function () {
  20018. return true; // !!document.createElementNS &&
  20019. // !! document.createElementNS(SVG.ns,'svg').createSVGRect
  20020. }(); // Don't bother to continue if SVG is not supported
  20021. if (!SVG.supported) return false; // Element id sequence
  20022. SVG.did = 1000; // Get next named element id
  20023. SVG.eid = function (name) {
  20024. return 'Svgjs' + capitalize(name) + SVG.did++;
  20025. }; // Method for element creation
  20026. SVG.create = function (name) {
  20027. // create element
  20028. var element = document.createElementNS(this.ns, name); // apply unique id
  20029. element.setAttribute('id', this.eid(name));
  20030. return element;
  20031. }; // Method for extending objects
  20032. SVG.extend = function () {
  20033. var modules, methods; // Get list of modules
  20034. modules = [].slice.call(arguments); // Get object with extensions
  20035. methods = modules.pop();
  20036. for (var i = modules.length - 1; i >= 0; i--) {
  20037. if (modules[i]) {
  20038. for (var key in methods) {
  20039. modules[i].prototype[key] = methods[key];
  20040. }
  20041. }
  20042. } // Make sure SVG.Set inherits any newly added methods
  20043. if (SVG.Set && SVG.Set.inherit) {
  20044. SVG.Set.inherit();
  20045. }
  20046. }; // Invent new element
  20047. SVG.invent = function (config) {
  20048. // Create element initializer
  20049. var initializer = typeof config.create === 'function' ? config.create : function () {
  20050. this.constructor.call(this, SVG.create(config.create));
  20051. }; // Inherit prototype
  20052. if (config.inherit) {
  20053. initializer.prototype = new config.inherit();
  20054. } // Extend with methods
  20055. if (config.extend) {
  20056. SVG.extend(initializer, config.extend);
  20057. } // Attach construct method to parent
  20058. if (config.construct) {
  20059. SVG.extend(config.parent || SVG.Container, config.construct);
  20060. }
  20061. return initializer;
  20062. }; // Adopt existing svg elements
  20063. SVG.adopt = function (node) {
  20064. // check for presence of node
  20065. if (!node) return null; // make sure a node isn't already adopted
  20066. if (node.instance) return node.instance; // initialize variables
  20067. var element; // adopt with element-specific settings
  20068. if (node.nodeName == 'svg') {
  20069. element = node.parentNode instanceof window.SVGElement ? new SVG.Nested() : new SVG.Doc();
  20070. } else if (node.nodeName == 'linearGradient') {
  20071. element = new SVG.Gradient('linear');
  20072. } else if (node.nodeName == 'radialGradient') {
  20073. element = new SVG.Gradient('radial');
  20074. } else if (SVG[capitalize(node.nodeName)]) {
  20075. element = new SVG[capitalize(node.nodeName)]();
  20076. } else {
  20077. element = new SVG.Element(node);
  20078. } // ensure references
  20079. element.type = node.nodeName;
  20080. element.node = node;
  20081. node.instance = element; // SVG.Class specific preparations
  20082. if (element instanceof SVG.Doc) {
  20083. element.namespace().defs();
  20084. } // pull svgjs data from the dom (getAttributeNS doesn't work in html5)
  20085. element.setData(JSON.parse(node.getAttribute('svgjs:data')) || {});
  20086. return element;
  20087. }; // Initialize parsing element
  20088. SVG.prepare = function () {
  20089. // Select document body and create invisible svg element
  20090. var body = document.getElementsByTagName('body')[0],
  20091. draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0); // Create parser object
  20092. SVG.parser = {
  20093. body: body || document.documentElement,
  20094. draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node,
  20095. poly: draw.polyline().node,
  20096. path: draw.path().node,
  20097. native: SVG.create('svg')
  20098. };
  20099. };
  20100. SVG.parser = {
  20101. native: SVG.create('svg')
  20102. };
  20103. document.addEventListener('DOMContentLoaded', function () {
  20104. if (!SVG.parser.draw) {
  20105. SVG.prepare();
  20106. }
  20107. }, false); // Storage for regular expressions
  20108. SVG.regex = {
  20109. // Parse unit value
  20110. numberAndUnit: /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,
  20111. // Parse hex value
  20112. hex: /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
  20113. // Parse rgb value
  20114. rgb: /rgb\((\d+),(\d+),(\d+)\)/,
  20115. // Parse reference id
  20116. reference: /#([a-z0-9\-_]+)/i,
  20117. // splits a transformation chain
  20118. transforms: /\)\s*,?\s*/,
  20119. // Whitespace
  20120. whitespace: /\s/g,
  20121. // Test hex value
  20122. isHex: /^#[a-f0-9]{3,6}$/i,
  20123. // Test rgb value
  20124. isRgb: /^rgb\(/,
  20125. // Test css declaration
  20126. isCss: /[^:]+:[^;]+;?/,
  20127. // Test for blank string
  20128. isBlank: /^(\s+)?$/,
  20129. // Test for numeric string
  20130. isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  20131. // Test for percent value
  20132. isPercent: /^-?[\d\.]+%$/,
  20133. // Test for image url
  20134. isImage: /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,
  20135. // split at whitespace and comma
  20136. delimiter: /[\s,]+/,
  20137. // The following regex are used to parse the d attribute of a path
  20138. // Matches all hyphens which are not after an exponent
  20139. hyphen: /([^e])\-/gi,
  20140. // Replaces and tests for all path letters
  20141. pathLetters: /[MLHVCSQTAZ]/gi,
  20142. // yes we need this one, too
  20143. isPathLetter: /[MLHVCSQTAZ]/i,
  20144. // matches 0.154.23.45
  20145. numbersWithDots: /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,
  20146. // matches .
  20147. dots: /\./g
  20148. };
  20149. SVG.utils = {
  20150. // Map function
  20151. map: function map(array, block) {
  20152. var il = array.length,
  20153. result = [];
  20154. for (var i = 0; i < il; i++) {
  20155. result.push(block(array[i]));
  20156. }
  20157. return result;
  20158. },
  20159. // Filter function
  20160. filter: function filter(array, block) {
  20161. var il = array.length,
  20162. result = [];
  20163. for (var i = 0; i < il; i++) {
  20164. if (block(array[i])) {
  20165. result.push(array[i]);
  20166. }
  20167. }
  20168. return result;
  20169. },
  20170. filterSVGElements: function filterSVGElements(nodes) {
  20171. return this.filter(nodes, function (el) {
  20172. return el instanceof window.SVGElement;
  20173. });
  20174. }
  20175. };
  20176. SVG.defaults = {
  20177. // Default attribute values
  20178. attrs: {
  20179. // fill and stroke
  20180. 'fill-opacity': 1,
  20181. 'stroke-opacity': 1,
  20182. 'stroke-width': 0,
  20183. 'stroke-linejoin': 'miter',
  20184. 'stroke-linecap': 'butt',
  20185. fill: '#000000',
  20186. stroke: '#000000',
  20187. opacity: 1,
  20188. // position
  20189. x: 0,
  20190. y: 0,
  20191. cx: 0,
  20192. cy: 0,
  20193. // size
  20194. width: 0,
  20195. height: 0,
  20196. // radius
  20197. r: 0,
  20198. rx: 0,
  20199. ry: 0,
  20200. // gradient
  20201. offset: 0,
  20202. 'stop-opacity': 1,
  20203. 'stop-color': '#000000',
  20204. // text
  20205. 'font-size': 16,
  20206. 'font-family': 'Helvetica, Arial, sans-serif',
  20207. 'text-anchor': 'start'
  20208. }
  20209. }; // Module for color convertions
  20210. SVG.Color = function (color) {
  20211. var match; // initialize defaults
  20212. this.r = 0;
  20213. this.g = 0;
  20214. this.b = 0;
  20215. if (!color) return; // parse color
  20216. if (typeof color === 'string') {
  20217. if (SVG.regex.isRgb.test(color)) {
  20218. // get rgb values
  20219. match = SVG.regex.rgb.exec(color.replace(SVG.regex.whitespace, '')); // parse numeric values
  20220. this.r = parseInt(match[1]);
  20221. this.g = parseInt(match[2]);
  20222. this.b = parseInt(match[3]);
  20223. } else if (SVG.regex.isHex.test(color)) {
  20224. // get hex values
  20225. match = SVG.regex.hex.exec(fullHex(color)); // parse numeric values
  20226. this.r = parseInt(match[1], 16);
  20227. this.g = parseInt(match[2], 16);
  20228. this.b = parseInt(match[3], 16);
  20229. }
  20230. } else if (_typeof(color) === 'object') {
  20231. this.r = color.r;
  20232. this.g = color.g;
  20233. this.b = color.b;
  20234. }
  20235. };
  20236. SVG.extend(SVG.Color, {
  20237. // Default to hex conversion
  20238. toString: function toString() {
  20239. return this.toHex();
  20240. },
  20241. // Build hex value
  20242. toHex: function toHex() {
  20243. return '#' + compToHex(this.r) + compToHex(this.g) + compToHex(this.b);
  20244. },
  20245. // Build rgb value
  20246. toRgb: function toRgb() {
  20247. return 'rgb(' + [this.r, this.g, this.b].join() + ')';
  20248. },
  20249. // Calculate true brightness
  20250. brightness: function brightness() {
  20251. return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11;
  20252. },
  20253. // Make color morphable
  20254. morph: function morph(color) {
  20255. this.destination = new SVG.Color(color);
  20256. return this;
  20257. },
  20258. // Get morphed color at given position
  20259. at: function at(pos) {
  20260. // make sure a destination is defined
  20261. if (!this.destination) return this; // normalise pos
  20262. pos = pos < 0 ? 0 : pos > 1 ? 1 : pos; // generate morphed color
  20263. return new SVG.Color({
  20264. r: ~~(this.r + (this.destination.r - this.r) * pos),
  20265. g: ~~(this.g + (this.destination.g - this.g) * pos),
  20266. b: ~~(this.b + (this.destination.b - this.b) * pos)
  20267. });
  20268. }
  20269. }); // Testers
  20270. // Test if given value is a color string
  20271. SVG.Color.test = function (color) {
  20272. color += '';
  20273. return SVG.regex.isHex.test(color) || SVG.regex.isRgb.test(color);
  20274. }; // Test if given value is a rgb object
  20275. SVG.Color.isRgb = function (color) {
  20276. return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number';
  20277. }; // Test if given value is a color
  20278. SVG.Color.isColor = function (color) {
  20279. return SVG.Color.isRgb(color) || SVG.Color.test(color);
  20280. }; // Module for array conversion
  20281. SVG.Array = function (array, fallback) {
  20282. array = (array || []).valueOf(); // if array is empty and fallback is provided, use fallback
  20283. if (array.length == 0 && fallback) {
  20284. array = fallback.valueOf();
  20285. } // parse array
  20286. this.value = this.parse(array);
  20287. };
  20288. SVG.extend(SVG.Array, {
  20289. // Convert array to string
  20290. toString: function toString() {
  20291. return this.value.join(' ');
  20292. },
  20293. // Real value
  20294. valueOf: function valueOf() {
  20295. return this.value;
  20296. },
  20297. // Parse whitespace separated string
  20298. parse: function parse(array) {
  20299. array = array.valueOf(); // if already is an array, no need to parse it
  20300. if (Array.isArray(array)) return array;
  20301. return this.split(array);
  20302. }
  20303. }); // Poly points array
  20304. SVG.PointArray = function (array, fallback) {
  20305. SVG.Array.call(this, array, fallback || [[0, 0]]);
  20306. }; // Inherit from SVG.Array
  20307. SVG.PointArray.prototype = new SVG.Array();
  20308. SVG.PointArray.prototype.constructor = SVG.PointArray;
  20309. var pathHandlers = {
  20310. M: function M(c, p, p0) {
  20311. p.x = p0.x = c[0];
  20312. p.y = p0.y = c[1];
  20313. return ['M', p.x, p.y];
  20314. },
  20315. L: function L(c, p) {
  20316. p.x = c[0];
  20317. p.y = c[1];
  20318. return ['L', c[0], c[1]];
  20319. },
  20320. H: function H(c, p) {
  20321. p.x = c[0];
  20322. return ['H', c[0]];
  20323. },
  20324. V: function V(c, p) {
  20325. p.y = c[0];
  20326. return ['V', c[0]];
  20327. },
  20328. C: function C(c, p) {
  20329. p.x = c[4];
  20330. p.y = c[5];
  20331. return ['C', c[0], c[1], c[2], c[3], c[4], c[5]];
  20332. },
  20333. Q: function Q(c, p) {
  20334. p.x = c[2];
  20335. p.y = c[3];
  20336. return ['Q', c[0], c[1], c[2], c[3]];
  20337. },
  20338. Z: function Z(c, p, p0) {
  20339. p.x = p0.x;
  20340. p.y = p0.y;
  20341. return ['Z'];
  20342. }
  20343. };
  20344. var mlhvqtcsa = 'mlhvqtcsaz'.split('');
  20345. for (var i = 0, il = mlhvqtcsa.length; i < il; ++i) {
  20346. pathHandlers[mlhvqtcsa[i]] = function (i) {
  20347. return function (c, p, p0) {
  20348. if (i == 'H') c[0] = c[0] + p.x;else if (i == 'V') c[0] = c[0] + p.y;else if (i == 'A') {
  20349. c[5] = c[5] + p.x, c[6] = c[6] + p.y;
  20350. } else {
  20351. for (var j = 0, jl = c.length; j < jl; ++j) {
  20352. c[j] = c[j] + (j % 2 ? p.y : p.x);
  20353. }
  20354. }
  20355. return pathHandlers[i](c, p, p0);
  20356. };
  20357. }(mlhvqtcsa[i].toUpperCase());
  20358. } // Path points array
  20359. SVG.PathArray = function (array, fallback) {
  20360. SVG.Array.call(this, array, fallback || [['M', 0, 0]]);
  20361. }; // Inherit from SVG.Array
  20362. SVG.PathArray.prototype = new SVG.Array();
  20363. SVG.PathArray.prototype.constructor = SVG.PathArray;
  20364. SVG.extend(SVG.PathArray, {
  20365. // Convert array to string
  20366. toString: function toString() {
  20367. return arrayToString(this.value);
  20368. },
  20369. // Move path string
  20370. move: function move(x, y) {
  20371. // get bounding box of current situation
  20372. var box = this.bbox(); // get relative offset
  20373. x -= box.x;
  20374. y -= box.y;
  20375. return this;
  20376. },
  20377. // Get morphed path array at given position
  20378. at: function at(pos) {
  20379. // make sure a destination is defined
  20380. if (!this.destination) return this;
  20381. var sourceArray = this.value,
  20382. destinationArray = this.destination.value,
  20383. array = [],
  20384. pathArray = new SVG.PathArray(),
  20385. il,
  20386. jl; // Animate has specified in the SVG spec
  20387. // See: https://www.w3.org/TR/SVG11/paths.html#PathElement
  20388. for (var i = 0, il = sourceArray.length; i < il; i++) {
  20389. array[i] = [sourceArray[i][0]];
  20390. for (var j = 1, jl = sourceArray[i].length; j < jl; j++) {
  20391. array[i][j] = sourceArray[i][j] + (destinationArray[i][j] - sourceArray[i][j]) * pos;
  20392. } // For the two flags of the elliptical arc command, the SVG spec say:
  20393. // Flags and booleans are interpolated as fractions between zero and one, with any non-zero value considered to be a value of one/true
  20394. // Elliptical arc command as an array followed by corresponding indexes:
  20395. // ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
  20396. // 0 1 2 3 4 5 6 7
  20397. if (array[i][0] === 'A') {
  20398. array[i][4] = +(array[i][4] != 0);
  20399. array[i][5] = +(array[i][5] != 0);
  20400. }
  20401. } // Directly modify the value of a path array, this is done this way for performance
  20402. pathArray.value = array;
  20403. return pathArray;
  20404. },
  20405. // Absolutize and parse path to array
  20406. parse: function parse(array) {
  20407. // if it's already a patharray, no need to parse it
  20408. if (array instanceof SVG.PathArray) return array.valueOf(); // prepare for parsing
  20409. var s,
  20410. arr,
  20411. paramCnt = {
  20412. 'M': 2,
  20413. 'L': 2,
  20414. 'H': 1,
  20415. 'V': 1,
  20416. 'C': 6,
  20417. 'S': 4,
  20418. 'Q': 4,
  20419. 'T': 2,
  20420. 'A': 7,
  20421. 'Z': 0
  20422. };
  20423. if (typeof array === 'string') {
  20424. array = array.replace(SVG.regex.numbersWithDots, pathRegReplace) // convert 45.123.123 to 45.123 .123
  20425. .replace(SVG.regex.pathLetters, ' $& ') // put some room between letters and numbers
  20426. .replace(SVG.regex.hyphen, '$1 -') // add space before hyphen
  20427. .trim() // trim
  20428. .split(SVG.regex.delimiter); // split into array
  20429. } else {
  20430. array = array.reduce(function (prev, curr) {
  20431. return [].concat.call(prev, curr);
  20432. }, []);
  20433. } // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...]
  20434. var arr = [],
  20435. p = new SVG.Point(),
  20436. p0 = new SVG.Point(),
  20437. index = 0,
  20438. len = array.length;
  20439. do {
  20440. // Test if we have a path letter
  20441. if (SVG.regex.isPathLetter.test(array[index])) {
  20442. s = array[index];
  20443. ++index; // If last letter was a move command and we got no new, it defaults to [L]ine
  20444. } else if (s == 'M') {
  20445. s = 'L';
  20446. } else if (s == 'm') {
  20447. s = 'l';
  20448. }
  20449. arr.push(pathHandlers[s].call(null, array.slice(index, index = index + paramCnt[s.toUpperCase()]).map(parseFloat), p, p0));
  20450. } while (len > index);
  20451. return arr;
  20452. },
  20453. // Get bounding box of path
  20454. bbox: function bbox() {
  20455. if (!SVG.parser.draw) {
  20456. SVG.prepare();
  20457. }
  20458. SVG.parser.path.setAttribute('d', this.toString());
  20459. return SVG.parser.path.getBBox();
  20460. }
  20461. }); // Module for unit convertions
  20462. SVG.Number = SVG.invent({
  20463. // Initialize
  20464. create: function create(value, unit) {
  20465. // initialize defaults
  20466. this.value = 0;
  20467. this.unit = unit || ''; // parse value
  20468. if (typeof value === 'number') {
  20469. // ensure a valid numeric value
  20470. this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -3.4e+38 : +3.4e+38 : value;
  20471. } else if (typeof value === 'string') {
  20472. unit = value.match(SVG.regex.numberAndUnit);
  20473. if (unit) {
  20474. // make value numeric
  20475. this.value = parseFloat(unit[1]); // normalize
  20476. if (unit[5] == '%') {
  20477. this.value /= 100;
  20478. } else if (unit[5] == 's') {
  20479. this.value *= 1000;
  20480. } // store unit
  20481. this.unit = unit[5];
  20482. }
  20483. } else {
  20484. if (value instanceof SVG.Number) {
  20485. this.value = value.valueOf();
  20486. this.unit = value.unit;
  20487. }
  20488. }
  20489. },
  20490. // Add methods
  20491. extend: {
  20492. // Stringalize
  20493. toString: function toString() {
  20494. return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.unit == 's' ? this.value / 1e3 : this.value) + this.unit;
  20495. },
  20496. toJSON: function toJSON() {
  20497. return this.toString();
  20498. },
  20499. // Convert to primitive
  20500. valueOf: function valueOf() {
  20501. return this.value;
  20502. },
  20503. // Add number
  20504. plus: function plus(number) {
  20505. number = new SVG.Number(number);
  20506. return new SVG.Number(this + number, this.unit || number.unit);
  20507. },
  20508. // Subtract number
  20509. minus: function minus(number) {
  20510. number = new SVG.Number(number);
  20511. return new SVG.Number(this - number, this.unit || number.unit);
  20512. },
  20513. // Multiply number
  20514. times: function times(number) {
  20515. number = new SVG.Number(number);
  20516. return new SVG.Number(this * number, this.unit || number.unit);
  20517. },
  20518. // Divide number
  20519. divide: function divide(number) {
  20520. number = new SVG.Number(number);
  20521. return new SVG.Number(this / number, this.unit || number.unit);
  20522. },
  20523. // Convert to different unit
  20524. to: function to(unit) {
  20525. var number = new SVG.Number(this);
  20526. if (typeof unit === 'string') {
  20527. number.unit = unit;
  20528. }
  20529. return number;
  20530. },
  20531. // Make number morphable
  20532. morph: function morph(number) {
  20533. this.destination = new SVG.Number(number);
  20534. if (number.relative) {
  20535. this.destination.value += this.value;
  20536. }
  20537. return this;
  20538. },
  20539. // Get morphed number at given position
  20540. at: function at(pos) {
  20541. // Make sure a destination is defined
  20542. if (!this.destination) return this; // Generate new morphed number
  20543. return new SVG.Number(this.destination).minus(this).times(pos).plus(this);
  20544. }
  20545. }
  20546. });
  20547. SVG.Element = SVG.invent({
  20548. // Initialize node
  20549. create: function create(node) {
  20550. // make stroke value accessible dynamically
  20551. this._stroke = SVG.defaults.attrs.stroke;
  20552. this._event = null; // initialize data object
  20553. this.dom = {}; // create circular reference
  20554. if (this.node = node) {
  20555. this.type = node.nodeName;
  20556. this.node.instance = this; // store current attribute value
  20557. this._stroke = node.getAttribute('stroke') || this._stroke;
  20558. }
  20559. },
  20560. // Add class methods
  20561. extend: {
  20562. // Move over x-axis
  20563. x: function x(_x) {
  20564. return this.attr('x', _x);
  20565. },
  20566. // Move over y-axis
  20567. y: function y(_y) {
  20568. return this.attr('y', _y);
  20569. },
  20570. // Move by center over x-axis
  20571. cx: function cx(x) {
  20572. return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2);
  20573. },
  20574. // Move by center over y-axis
  20575. cy: function cy(y) {
  20576. return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2);
  20577. },
  20578. // Move element to given x and y values
  20579. move: function move(x, y) {
  20580. return this.x(x).y(y);
  20581. },
  20582. // Move element by its center
  20583. center: function center(x, y) {
  20584. return this.cx(x).cy(y);
  20585. },
  20586. // Set width of element
  20587. width: function width(_width) {
  20588. return this.attr('width', _width);
  20589. },
  20590. // Set height of element
  20591. height: function height(_height) {
  20592. return this.attr('height', _height);
  20593. },
  20594. // Set element size to given width and height
  20595. size: function size(width, height) {
  20596. var p = proportionalSize(this, width, height);
  20597. return this.width(new SVG.Number(p.width)).height(new SVG.Number(p.height));
  20598. },
  20599. // Clone element
  20600. clone: function clone(parent) {
  20601. // write dom data to the dom so the clone can pickup the data
  20602. this.writeDataToDom(); // clone element and assign new id
  20603. var clone = assignNewId(this.node.cloneNode(true)); // insert the clone in the given parent or after myself
  20604. if (parent) parent.add(clone);else this.after(clone);
  20605. return clone;
  20606. },
  20607. // Remove element
  20608. remove: function remove() {
  20609. if (this.parent()) {
  20610. this.parent().removeElement(this);
  20611. }
  20612. return this;
  20613. },
  20614. // Replace element
  20615. replace: function replace(element) {
  20616. this.after(element).remove();
  20617. return element;
  20618. },
  20619. // Add element to given container and return self
  20620. addTo: function addTo(parent) {
  20621. return parent.put(this);
  20622. },
  20623. // Add element to given container and return container
  20624. putIn: function putIn(parent) {
  20625. return parent.add(this);
  20626. },
  20627. // Get / set id
  20628. id: function id(_id) {
  20629. return this.attr('id', _id);
  20630. },
  20631. // Show element
  20632. show: function show() {
  20633. return this.style('display', '');
  20634. },
  20635. // Hide element
  20636. hide: function hide() {
  20637. return this.style('display', 'none');
  20638. },
  20639. // Is element visible?
  20640. visible: function visible() {
  20641. return this.style('display') != 'none';
  20642. },
  20643. // Return id on string conversion
  20644. toString: function toString() {
  20645. return this.attr('id');
  20646. },
  20647. // Return array of classes on the node
  20648. classes: function classes() {
  20649. var attr = this.attr('class');
  20650. return attr == null ? [] : attr.trim().split(SVG.regex.delimiter);
  20651. },
  20652. // Return true if class exists on the node, false otherwise
  20653. hasClass: function hasClass(name) {
  20654. return this.classes().indexOf(name) != -1;
  20655. },
  20656. // Add class to the node
  20657. addClass: function addClass(name) {
  20658. if (!this.hasClass(name)) {
  20659. var array = this.classes();
  20660. array.push(name);
  20661. this.attr('class', array.join(' '));
  20662. }
  20663. return this;
  20664. },
  20665. // Remove class from the node
  20666. removeClass: function removeClass(name) {
  20667. if (this.hasClass(name)) {
  20668. this.attr('class', this.classes().filter(function (c) {
  20669. return c != name;
  20670. }).join(' '));
  20671. }
  20672. return this;
  20673. },
  20674. // Toggle the presence of a class on the node
  20675. toggleClass: function toggleClass(name) {
  20676. return this.hasClass(name) ? this.removeClass(name) : this.addClass(name);
  20677. },
  20678. // Get referenced element form attribute value
  20679. reference: function reference(attr) {
  20680. return SVG.get(this.attr(attr));
  20681. },
  20682. // Returns the parent element instance
  20683. parent: function parent(type) {
  20684. var parent = this; // check for parent
  20685. if (!parent.node.parentNode) return null; // get parent element
  20686. parent = SVG.adopt(parent.node.parentNode);
  20687. if (!type) return parent; // loop trough ancestors if type is given
  20688. while (parent && parent.node instanceof window.SVGElement) {
  20689. if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent;
  20690. if (!parent.node.parentNode || parent.node.parentNode.nodeName == '#document') return null; // #759, #720
  20691. parent = SVG.adopt(parent.node.parentNode);
  20692. }
  20693. },
  20694. // Get parent document
  20695. doc: function doc() {
  20696. return this instanceof SVG.Doc ? this : this.parent(SVG.Doc);
  20697. },
  20698. // return array of all ancestors of given type up to the root svg
  20699. parents: function parents(type) {
  20700. var parents = [],
  20701. parent = this;
  20702. do {
  20703. parent = parent.parent(type);
  20704. if (!parent || !parent.node) break;
  20705. parents.push(parent);
  20706. } while (parent.parent);
  20707. return parents;
  20708. },
  20709. // matches the element vs a css selector
  20710. matches: function matches(selector) {
  20711. return _matches(this.node, selector);
  20712. },
  20713. // Returns the svg node to call native svg methods on it
  20714. native: function native() {
  20715. return this.node;
  20716. },
  20717. // Import raw svg
  20718. svg: function svg(_svg) {
  20719. // create temporary holder
  20720. var well = document.createElement('svg'); // act as a setter if svg is given
  20721. if (_svg && this instanceof SVG.Parent) {
  20722. // dump raw svg
  20723. well.innerHTML = '<svg>' + _svg.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2></$1>') + '</svg>'; // transplant nodes
  20724. for (var i = 0, il = well.firstChild.childNodes.length; i < il; i++) {
  20725. this.node.appendChild(well.firstChild.firstChild);
  20726. } // otherwise act as a getter
  20727. } else {
  20728. // create a wrapping svg element in case of partial content
  20729. well.appendChild(_svg = document.createElement('svg')); // write svgjs data to the dom
  20730. this.writeDataToDom(); // insert a copy of this node
  20731. _svg.appendChild(this.node.cloneNode(true)); // return target element
  20732. return well.innerHTML.replace(/^<svg>/, '').replace(/<\/svg>$/, '');
  20733. }
  20734. return this;
  20735. },
  20736. // write svgjs data to the dom
  20737. writeDataToDom: function writeDataToDom() {
  20738. // dump variables recursively
  20739. if (this.each || this.lines) {
  20740. var fn = this.each ? this : this.lines();
  20741. fn.each(function () {
  20742. this.writeDataToDom();
  20743. });
  20744. } // remove previously set data
  20745. this.node.removeAttribute('svgjs:data');
  20746. if (Object.keys(this.dom).length) {
  20747. this.node.setAttribute('svgjs:data', JSON.stringify(this.dom));
  20748. } // see #428
  20749. return this;
  20750. },
  20751. // set given data to the elements data property
  20752. setData: function setData(o) {
  20753. this.dom = o;
  20754. return this;
  20755. },
  20756. is: function is(obj) {
  20757. return _is(this, obj);
  20758. }
  20759. }
  20760. });
  20761. SVG.easing = {
  20762. '-': function _(pos) {
  20763. return pos;
  20764. },
  20765. '<>': function _(pos) {
  20766. return -Math.cos(pos * Math.PI) / 2 + 0.5;
  20767. },
  20768. '>': function _(pos) {
  20769. return Math.sin(pos * Math.PI / 2);
  20770. },
  20771. '<': function _(pos) {
  20772. return -Math.cos(pos * Math.PI / 2) + 1;
  20773. }
  20774. };
  20775. SVG.morph = function (pos) {
  20776. return function (from, to) {
  20777. return new SVG.MorphObj(from, to).at(pos);
  20778. };
  20779. };
  20780. SVG.Situation = SVG.invent({
  20781. create: function create(o) {
  20782. this.init = false;
  20783. this.reversed = false;
  20784. this.reversing = false;
  20785. this.duration = new SVG.Number(o.duration).valueOf();
  20786. this.delay = new SVG.Number(o.delay).valueOf();
  20787. this.start = +new Date() + this.delay;
  20788. this.finish = this.start + this.duration;
  20789. this.ease = o.ease; // this.loop is incremented from 0 to this.loops
  20790. // it is also incremented when in an infinite loop (when this.loops is true)
  20791. this.loop = 0;
  20792. this.loops = false;
  20793. this.animations = {// functionToCall: [list of morphable objects]
  20794. // e.g. move: [SVG.Number, SVG.Number]
  20795. };
  20796. this.attrs = {// holds all attributes which are not represented from a function svg.js provides
  20797. // e.g. someAttr: SVG.Number
  20798. };
  20799. this.styles = {// holds all styles which should be animated
  20800. // e.g. fill-color: SVG.Color
  20801. };
  20802. this.transforms = [// holds all transformations as transformation objects
  20803. // e.g. [SVG.Rotate, SVG.Translate, SVG.Matrix]
  20804. ];
  20805. this.once = {// functions to fire at a specific position
  20806. // e.g. "0.5": function foo(){}
  20807. };
  20808. }
  20809. });
  20810. SVG.FX = SVG.invent({
  20811. create: function create(element) {
  20812. this._target = element;
  20813. this.situations = [];
  20814. this.active = false;
  20815. this.situation = null;
  20816. this.paused = false;
  20817. this.lastPos = 0;
  20818. this.pos = 0; // The absolute position of an animation is its position in the context of its complete duration (including delay and loops)
  20819. // When performing a delay, absPos is below 0 and when performing a loop, its value is above 1
  20820. this.absPos = 0;
  20821. this._speed = 1;
  20822. },
  20823. extend: {
  20824. /**
  20825. * sets or returns the target of this animation
  20826. * @param o object || number In case of Object it holds all parameters. In case of number its the duration of the animation
  20827. * @param ease function || string Function which should be used for easing or easing keyword
  20828. * @param delay Number indicating the delay before the animation starts
  20829. * @return target || this
  20830. */
  20831. animate: function animate(o, ease, delay) {
  20832. if (_typeof(o) === 'object') {
  20833. ease = o.ease;
  20834. delay = o.delay;
  20835. o = o.duration;
  20836. }
  20837. var situation = new SVG.Situation({
  20838. duration: o || 1000,
  20839. delay: delay || 0,
  20840. ease: SVG.easing[ease || '-'] || ease
  20841. });
  20842. this.queue(situation);
  20843. return this;
  20844. },
  20845. /**
  20846. * sets a delay before the next element of the queue is called
  20847. * @param delay Duration of delay in milliseconds
  20848. * @return this.target()
  20849. */
  20850. /**
  20851. * sets or returns the target of this animation
  20852. * @param null || target SVG.Element which should be set as new target
  20853. * @return target || this
  20854. */
  20855. target: function target(_target) {
  20856. if (_target && _target instanceof SVG.Element) {
  20857. this._target = _target;
  20858. return this;
  20859. }
  20860. return this._target;
  20861. },
  20862. // returns the absolute position at a given time
  20863. timeToAbsPos: function timeToAbsPos(timestamp) {
  20864. return (timestamp - this.situation.start) / (this.situation.duration / this._speed);
  20865. },
  20866. // returns the timestamp from a given absolute positon
  20867. absPosToTime: function absPosToTime(absPos) {
  20868. return this.situation.duration / this._speed * absPos + this.situation.start;
  20869. },
  20870. // starts the animationloop
  20871. startAnimFrame: function startAnimFrame() {
  20872. this.stopAnimFrame();
  20873. this.animationFrame = window.requestAnimationFrame(function () {
  20874. this.step();
  20875. }.bind(this));
  20876. },
  20877. // cancels the animationframe
  20878. stopAnimFrame: function stopAnimFrame() {
  20879. window.cancelAnimationFrame(this.animationFrame);
  20880. },
  20881. // kicks off the animation - only does something when the queue is currently not active and at least one situation is set
  20882. start: function start() {
  20883. // dont start if already started
  20884. if (!this.active && this.situation) {
  20885. this.active = true;
  20886. this.startCurrent();
  20887. }
  20888. return this;
  20889. },
  20890. // start the current situation
  20891. startCurrent: function startCurrent() {
  20892. this.situation.start = +new Date() + this.situation.delay / this._speed;
  20893. this.situation.finish = this.situation.start + this.situation.duration / this._speed;
  20894. return this.initAnimations().step();
  20895. },
  20896. /**
  20897. * adds a function / Situation to the animation queue
  20898. * @param fn function / situation to add
  20899. * @return this
  20900. */
  20901. queue: function queue(fn) {
  20902. if (typeof fn === 'function' || fn instanceof SVG.Situation) {
  20903. this.situations.push(fn);
  20904. }
  20905. if (!this.situation) this.situation = this.situations.shift();
  20906. return this;
  20907. },
  20908. /**
  20909. * pulls next element from the queue and execute it
  20910. * @return this
  20911. */
  20912. dequeue: function dequeue() {
  20913. // stop current animation
  20914. this.stop(); // get next animation from queue
  20915. this.situation = this.situations.shift();
  20916. if (this.situation) {
  20917. if (this.situation instanceof SVG.Situation) {
  20918. this.start();
  20919. } else {
  20920. // If it is not a SVG.Situation, then it is a function, we execute it
  20921. this.situation.call(this);
  20922. }
  20923. }
  20924. return this;
  20925. },
  20926. // updates all animations to the current state of the element
  20927. // this is important when one property could be changed from another property
  20928. initAnimations: function initAnimations() {
  20929. var source;
  20930. var s = this.situation;
  20931. if (s.init) return this;
  20932. for (var i in s.animations) {
  20933. source = this.target()[i]();
  20934. if (!Array.isArray(source)) {
  20935. source = [source];
  20936. }
  20937. if (!Array.isArray(s.animations[i])) {
  20938. s.animations[i] = [s.animations[i]];
  20939. } // if(s.animations[i].length > source.length) {
  20940. // source.concat = source.concat(s.animations[i].slice(source.length, s.animations[i].length))
  20941. // }
  20942. for (var j = source.length; j--;) {
  20943. // The condition is because some methods return a normal number instead
  20944. // of a SVG.Number
  20945. if (s.animations[i][j] instanceof SVG.Number) {
  20946. source[j] = new SVG.Number(source[j]);
  20947. }
  20948. s.animations[i][j] = source[j].morph(s.animations[i][j]);
  20949. }
  20950. }
  20951. for (var i in s.attrs) {
  20952. s.attrs[i] = new SVG.MorphObj(this.target().attr(i), s.attrs[i]);
  20953. }
  20954. for (var i in s.styles) {
  20955. s.styles[i] = new SVG.MorphObj(this.target().style(i), s.styles[i]);
  20956. }
  20957. s.initialTransformation = this.target().matrixify();
  20958. s.init = true;
  20959. return this;
  20960. },
  20961. clearQueue: function clearQueue() {
  20962. this.situations = [];
  20963. return this;
  20964. },
  20965. clearCurrent: function clearCurrent() {
  20966. this.situation = null;
  20967. return this;
  20968. },
  20969. /** stops the animation immediately
  20970. * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately.
  20971. * @param clearQueue A Boolean indicating whether to remove queued animation as well.
  20972. * @return this
  20973. */
  20974. stop: function stop(jumpToEnd, clearQueue) {
  20975. var active = this.active;
  20976. this.active = false;
  20977. if (clearQueue) {
  20978. this.clearQueue();
  20979. }
  20980. if (jumpToEnd && this.situation) {
  20981. // initialize the situation if it was not
  20982. !active && this.startCurrent();
  20983. this.atEnd();
  20984. }
  20985. this.stopAnimFrame();
  20986. return this.clearCurrent();
  20987. },
  20988. after: function after(fn) {
  20989. var c = this.last(),
  20990. wrapper = function wrapper(e) {
  20991. if (e.detail.situation == c) {
  20992. fn.call(this, c);
  20993. this.off('finished.fx', wrapper); // prevent memory leak
  20994. }
  20995. };
  20996. this.target().on('finished.fx', wrapper);
  20997. return this._callStart();
  20998. },
  20999. // adds a callback which is called whenever one animation step is performed
  21000. during: function during(fn) {
  21001. var c = this.last(),
  21002. wrapper = function wrapper(e) {
  21003. if (e.detail.situation == c) {
  21004. fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, c);
  21005. }
  21006. }; // see above
  21007. this.target().off('during.fx', wrapper).on('during.fx', wrapper);
  21008. this.after(function () {
  21009. this.off('during.fx', wrapper);
  21010. });
  21011. return this._callStart();
  21012. },
  21013. // calls after ALL animations in the queue are finished
  21014. afterAll: function afterAll(fn) {
  21015. var wrapper = function wrapper(e) {
  21016. fn.call(this);
  21017. this.off('allfinished.fx', wrapper);
  21018. }; // see above
  21019. this.target().off('allfinished.fx', wrapper).on('allfinished.fx', wrapper);
  21020. return this._callStart();
  21021. },
  21022. last: function last() {
  21023. return this.situations.length ? this.situations[this.situations.length - 1] : this.situation;
  21024. },
  21025. // adds one property to the animations
  21026. add: function add(method, args, type) {
  21027. this.last()[type || 'animations'][method] = args;
  21028. return this._callStart();
  21029. },
  21030. /** perform one step of the animation
  21031. * @param ignoreTime Boolean indicating whether to ignore time and use position directly or recalculate position based on time
  21032. * @return this
  21033. */
  21034. step: function step(ignoreTime) {
  21035. // convert current time to an absolute position
  21036. if (!ignoreTime) this.absPos = this.timeToAbsPos(+new Date()); // This part convert an absolute position to a position
  21037. if (this.situation.loops !== false) {
  21038. var absPos, absPosInt, lastLoop; // If the absolute position is below 0, we just treat it as if it was 0
  21039. absPos = Math.max(this.absPos, 0);
  21040. absPosInt = Math.floor(absPos);
  21041. if (this.situation.loops === true || absPosInt < this.situation.loops) {
  21042. this.pos = absPos - absPosInt;
  21043. lastLoop = this.situation.loop;
  21044. this.situation.loop = absPosInt;
  21045. } else {
  21046. this.absPos = this.situation.loops;
  21047. this.pos = 1; // The -1 here is because we don't want to toggle reversed when all the loops have been completed
  21048. lastLoop = this.situation.loop - 1;
  21049. this.situation.loop = this.situation.loops;
  21050. }
  21051. if (this.situation.reversing) {
  21052. // Toggle reversed if an odd number of loops as occured since the last call of step
  21053. this.situation.reversed = this.situation.reversed != Boolean((this.situation.loop - lastLoop) % 2);
  21054. }
  21055. } else {
  21056. // If there are no loop, the absolute position must not be above 1
  21057. this.absPos = Math.min(this.absPos, 1);
  21058. this.pos = this.absPos;
  21059. } // while the absolute position can be below 0, the position must not be below 0
  21060. if (this.pos < 0) this.pos = 0;
  21061. if (this.situation.reversed) this.pos = 1 - this.pos; // apply easing
  21062. var eased = this.situation.ease(this.pos); // call once-callbacks
  21063. for (var i in this.situation.once) {
  21064. if (i > this.lastPos && i <= eased) {
  21065. this.situation.once[i].call(this.target(), this.pos, eased);
  21066. delete this.situation.once[i];
  21067. }
  21068. } // fire during callback with position, eased position and current situation as parameter
  21069. if (this.active) this.target().fire('during', {
  21070. pos: this.pos,
  21071. eased: eased,
  21072. fx: this,
  21073. situation: this.situation
  21074. }); // the user may call stop or finish in the during callback
  21075. // so make sure that we still have a valid situation
  21076. if (!this.situation) {
  21077. return this;
  21078. } // apply the actual animation to every property
  21079. this.eachAt(); // do final code when situation is finished
  21080. if (this.pos == 1 && !this.situation.reversed || this.situation.reversed && this.pos == 0) {
  21081. // stop animation callback
  21082. this.stopAnimFrame(); // fire finished callback with current situation as parameter
  21083. this.target().fire('finished', {
  21084. fx: this,
  21085. situation: this.situation
  21086. });
  21087. if (!this.situations.length) {
  21088. this.target().fire('allfinished'); // Recheck the length since the user may call animate in the afterAll callback
  21089. if (!this.situations.length) {
  21090. this.target().off('.fx'); // there shouldnt be any binding left, but to make sure...
  21091. this.active = false;
  21092. }
  21093. } // start next animation
  21094. if (this.active) this.dequeue();else this.clearCurrent();
  21095. } else if (!this.paused && this.active) {
  21096. // we continue animating when we are not at the end
  21097. this.startAnimFrame();
  21098. } // save last eased position for once callback triggering
  21099. this.lastPos = eased;
  21100. return this;
  21101. },
  21102. // calculates the step for every property and calls block with it
  21103. eachAt: function eachAt() {
  21104. var len,
  21105. at,
  21106. self = this,
  21107. target = this.target(),
  21108. s = this.situation; // apply animations which can be called trough a method
  21109. for (var i in s.animations) {
  21110. at = [].concat(s.animations[i]).map(function (el) {
  21111. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  21112. });
  21113. target[i].apply(target, at);
  21114. } // apply animation which has to be applied with attr()
  21115. for (var i in s.attrs) {
  21116. at = [i].concat(s.attrs[i]).map(function (el) {
  21117. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  21118. });
  21119. target.attr.apply(target, at);
  21120. } // apply animation which has to be applied with style()
  21121. for (var i in s.styles) {
  21122. at = [i].concat(s.styles[i]).map(function (el) {
  21123. return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el;
  21124. });
  21125. target.style.apply(target, at);
  21126. } // animate initialTransformation which has to be chained
  21127. if (s.transforms.length) {
  21128. // get initial initialTransformation
  21129. at = s.initialTransformation;
  21130. for (var i = 0, len = s.transforms.length; i < len; i++) {
  21131. // get next transformation in chain
  21132. var a = s.transforms[i]; // multiply matrix directly
  21133. if (a instanceof SVG.Matrix) {
  21134. if (a.relative) {
  21135. at = at.multiply(new SVG.Matrix().morph(a).at(s.ease(this.pos)));
  21136. } else {
  21137. at = at.morph(a).at(s.ease(this.pos));
  21138. }
  21139. continue;
  21140. } // when transformation is absolute we have to reset the needed transformation first
  21141. if (!a.relative) {
  21142. a.undo(at.extract());
  21143. } // and reapply it after
  21144. at = at.multiply(a.at(s.ease(this.pos)));
  21145. } // set new matrix on element
  21146. target.matrix(at);
  21147. }
  21148. return this;
  21149. },
  21150. // adds an once-callback which is called at a specific position and never again
  21151. once: function once(pos, fn, isEased) {
  21152. var c = this.last();
  21153. if (!isEased) pos = c.ease(pos);
  21154. c.once[pos] = fn;
  21155. return this;
  21156. },
  21157. _callStart: function _callStart() {
  21158. setTimeout(function () {
  21159. this.start();
  21160. }.bind(this), 0);
  21161. return this;
  21162. }
  21163. },
  21164. parent: SVG.Element,
  21165. // Add method to parent elements
  21166. construct: {
  21167. // Get fx module or create a new one, then animate with given duration and ease
  21168. animate: function animate(o, ease, delay) {
  21169. return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay);
  21170. },
  21171. delay: function delay(_delay) {
  21172. return (this.fx || (this.fx = new SVG.FX(this))).delay(_delay);
  21173. },
  21174. stop: function stop(jumpToEnd, clearQueue) {
  21175. if (this.fx) {
  21176. this.fx.stop(jumpToEnd, clearQueue);
  21177. }
  21178. return this;
  21179. },
  21180. finish: function finish() {
  21181. if (this.fx) {
  21182. this.fx.finish();
  21183. }
  21184. return this;
  21185. }
  21186. }
  21187. }); // MorphObj is used whenever no morphable object is given
  21188. SVG.MorphObj = SVG.invent({
  21189. create: function create(from, to) {
  21190. // prepare color for morphing
  21191. if (SVG.Color.isColor(to)) return new SVG.Color(from).morph(to); // check if we have a list of values
  21192. if (SVG.regex.delimiter.test(from)) {
  21193. // prepare path for morphing
  21194. if (SVG.regex.pathLetters.test(from)) return new SVG.PathArray(from).morph(to); // prepare value list for morphing
  21195. else return new SVG.Array(from).morph(to);
  21196. } // prepare number for morphing
  21197. if (SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to); // prepare for plain morphing
  21198. this.value = from;
  21199. this.destination = to;
  21200. },
  21201. extend: {
  21202. at: function at(pos, real) {
  21203. return real < 1 ? this.value : this.destination;
  21204. },
  21205. valueOf: function valueOf() {
  21206. return this.value;
  21207. }
  21208. }
  21209. });
  21210. SVG.extend(SVG.FX, {
  21211. // Add animatable attributes
  21212. attr: function attr(a, v, relative) {
  21213. // apply attributes individually
  21214. if (_typeof(a) === 'object') {
  21215. for (var key in a) {
  21216. this.attr(key, a[key]);
  21217. }
  21218. } else {
  21219. this.add(a, v, 'attrs');
  21220. }
  21221. return this;
  21222. },
  21223. // Add animatable plot
  21224. plot: function plot(a, b, c, d) {
  21225. // Lines can be plotted with 4 arguments
  21226. if (arguments.length == 4) {
  21227. return this.plot([a, b, c, d]);
  21228. }
  21229. return this.add('plot', new (this.target().morphArray)(a));
  21230. }
  21231. });
  21232. SVG.Box = SVG.invent({
  21233. create: function create(x, y, width, height) {
  21234. if (_typeof(x) === 'object' && !(x instanceof SVG.Element)) {
  21235. // chromes getBoundingClientRect has no x and y property
  21236. return SVG.Box.call(this, x.left != null ? x.left : x.x, x.top != null ? x.top : x.y, x.width, x.height);
  21237. } else if (arguments.length == 4) {
  21238. this.x = x;
  21239. this.y = y;
  21240. this.width = width;
  21241. this.height = height;
  21242. } // add center, right, bottom...
  21243. fullBox(this);
  21244. }
  21245. });
  21246. SVG.BBox = SVG.invent({
  21247. // Initialize
  21248. create: function create(element) {
  21249. SVG.Box.apply(this, [].slice.call(arguments)); // get values if element is given
  21250. if (element instanceof SVG.Element) {
  21251. var box; // yes this is ugly, but Firefox can be a pain when it comes to elements that are not yet rendered
  21252. try {
  21253. if (!document.documentElement.contains) {
  21254. // This is IE - it does not support contains() for top-level SVGs
  21255. var topParent = element.node;
  21256. while (topParent.parentNode) {
  21257. topParent = topParent.parentNode;
  21258. }
  21259. if (topParent != document) throw new Error('Element not in the dom');
  21260. } else {} // the element is NOT in the dom, throw error
  21261. // disabling the check below which fixes issue #76
  21262. // if (!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom')
  21263. // find native bbox
  21264. box = element.node.getBBox();
  21265. } catch (e) {
  21266. if (element instanceof SVG.Shape) {
  21267. if (!SVG.parser.draw) {
  21268. // fixes apexcharts/vue-apexcharts #14
  21269. SVG.prepare();
  21270. }
  21271. var clone = element.clone(SVG.parser.draw.instance).show();
  21272. box = clone.node.getBBox();
  21273. clone.remove();
  21274. } else {
  21275. box = {
  21276. x: element.node.clientLeft,
  21277. y: element.node.clientTop,
  21278. width: element.node.clientWidth,
  21279. height: element.node.clientHeight
  21280. };
  21281. }
  21282. }
  21283. SVG.Box.call(this, box);
  21284. }
  21285. },
  21286. // Define ancestor
  21287. inherit: SVG.Box,
  21288. // Define Parent
  21289. parent: SVG.Element,
  21290. // Constructor
  21291. construct: {
  21292. // Get bounding box
  21293. bbox: function bbox() {
  21294. return new SVG.BBox(this);
  21295. }
  21296. }
  21297. });
  21298. SVG.BBox.prototype.constructor = SVG.BBox;
  21299. SVG.Matrix = SVG.invent({
  21300. // Initialize
  21301. create: function create(source) {
  21302. var base = arrayToMatrix([1, 0, 0, 1, 0, 0]); // ensure source as object
  21303. source = source instanceof SVG.Element ? source.matrixify() : typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat)) : arguments.length == 6 ? arrayToMatrix([].slice.call(arguments)) : Array.isArray(source) ? arrayToMatrix(source) : _typeof(source) === 'object' ? source : base; // merge source
  21304. for (var i = abcdef.length - 1; i >= 0; --i) {
  21305. this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]];
  21306. }
  21307. },
  21308. // Add methods
  21309. extend: {
  21310. // Extract individual transformations
  21311. extract: function extract() {
  21312. // find delta transform points
  21313. var px = deltaTransformPoint(this, 0, 1),
  21314. py = deltaTransformPoint(this, 1, 0),
  21315. skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90;
  21316. return {
  21317. // translation
  21318. x: this.e,
  21319. y: this.f,
  21320. 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),
  21321. 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),
  21322. // rotation
  21323. rotation: skewX,
  21324. a: this.a,
  21325. b: this.b,
  21326. c: this.c,
  21327. d: this.d,
  21328. e: this.e,
  21329. f: this.f,
  21330. matrix: new SVG.Matrix(this)
  21331. };
  21332. },
  21333. // Clone matrix
  21334. clone: function clone() {
  21335. return new SVG.Matrix(this);
  21336. },
  21337. // Morph one matrix into another
  21338. morph: function morph(matrix) {
  21339. // store new destination
  21340. this.destination = new SVG.Matrix(matrix);
  21341. return this;
  21342. },
  21343. // Multiplies by given matrix
  21344. multiply: function multiply(matrix) {
  21345. return new SVG.Matrix(this.native().multiply(parseMatrix(matrix).native()));
  21346. },
  21347. // Inverses matrix
  21348. inverse: function inverse() {
  21349. return new SVG.Matrix(this.native().inverse());
  21350. },
  21351. // Translate matrix
  21352. translate: function translate(x, y) {
  21353. return new SVG.Matrix(this.native().translate(x || 0, y || 0));
  21354. },
  21355. // Convert to native SVGMatrix
  21356. native: function native() {
  21357. // create new matrix
  21358. var matrix = SVG.parser.native.createSVGMatrix(); // update with current values
  21359. for (var i = abcdef.length - 1; i >= 0; i--) {
  21360. matrix[abcdef[i]] = this[abcdef[i]];
  21361. }
  21362. return matrix;
  21363. },
  21364. // Convert matrix to string
  21365. toString: function toString() {
  21366. // Construct the matrix directly, avoid values that are too small
  21367. return 'matrix(' + float32String(this.a) + ',' + float32String(this.b) + ',' + float32String(this.c) + ',' + float32String(this.d) + ',' + float32String(this.e) + ',' + float32String(this.f) + ')';
  21368. }
  21369. },
  21370. // Define parent
  21371. parent: SVG.Element,
  21372. // Add parent method
  21373. construct: {
  21374. // Get current matrix
  21375. ctm: function ctm() {
  21376. return new SVG.Matrix(this.node.getCTM());
  21377. },
  21378. // Get current screen matrix
  21379. screenCTM: function screenCTM() {
  21380. /* https://bugzilla.mozilla.org/show_bug.cgi?id=1344537
  21381. This is needed because FF does not return the transformation matrix
  21382. for the inner coordinate system when getScreenCTM() is called on nested svgs.
  21383. However all other Browsers do that */
  21384. if (this instanceof SVG.Nested) {
  21385. var rect = this.rect(1, 1);
  21386. var m = rect.node.getScreenCTM();
  21387. rect.remove();
  21388. return new SVG.Matrix(m);
  21389. }
  21390. return new SVG.Matrix(this.node.getScreenCTM());
  21391. }
  21392. }
  21393. });
  21394. SVG.Point = SVG.invent({
  21395. // Initialize
  21396. create: function create(x, y) {
  21397. var source,
  21398. base = {
  21399. x: 0,
  21400. y: 0
  21401. }; // ensure source as object
  21402. source = Array.isArray(x) ? {
  21403. x: x[0],
  21404. y: x[1]
  21405. } : _typeof(x) === 'object' ? {
  21406. x: x.x,
  21407. y: x.y
  21408. } : x != null ? {
  21409. x: x,
  21410. y: y != null ? y : x
  21411. } : base; // If y has no value, then x is used has its value
  21412. // merge source
  21413. this.x = source.x;
  21414. this.y = source.y;
  21415. },
  21416. // Add methods
  21417. extend: {
  21418. // Clone point
  21419. clone: function clone() {
  21420. return new SVG.Point(this);
  21421. },
  21422. // Morph one point into another
  21423. morph: function morph(x, y) {
  21424. // store new destination
  21425. this.destination = new SVG.Point(x, y);
  21426. return this;
  21427. }
  21428. }
  21429. });
  21430. SVG.extend(SVG.Element, {
  21431. // Get point
  21432. point: function point(x, y) {
  21433. return new SVG.Point(x, y).transform(this.screenCTM().inverse());
  21434. }
  21435. });
  21436. SVG.extend(SVG.Element, {
  21437. // Set svg element attribute
  21438. attr: function attr(a, v, n) {
  21439. // act as full getter
  21440. if (a == null) {
  21441. // get an object of attributes
  21442. a = {};
  21443. v = this.node.attributes;
  21444. for (var n = v.length - 1; n >= 0; n--) {
  21445. a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue;
  21446. }
  21447. return a;
  21448. } else if (_typeof(a) === 'object') {
  21449. // apply every attribute individually if an object is passed
  21450. for (var v_ in a) {
  21451. this.attr(v_, a[v_]);
  21452. }
  21453. } else if (v === null) {
  21454. // remove value
  21455. this.node.removeAttribute(a);
  21456. } else if (v == null) {
  21457. // act as a getter if the first and only argument is not an object
  21458. v = this.node.getAttribute(a);
  21459. return v == null ? SVG.defaults.attrs[a] : SVG.regex.isNumber.test(v) ? parseFloat(v) : v;
  21460. } else {
  21461. // BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0
  21462. if (a == 'stroke-width') {
  21463. this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null);
  21464. } else if (a == 'stroke') {
  21465. this._stroke = v;
  21466. } // convert image fill and stroke to patterns
  21467. if (a == 'fill' || a == 'stroke') {
  21468. if (SVG.regex.isImage.test(v)) {
  21469. v = this.doc().defs().image(v, 0, 0);
  21470. }
  21471. if (v instanceof SVG.Image) {
  21472. v = this.doc().defs().pattern(0, 0, function () {
  21473. this.add(v);
  21474. });
  21475. }
  21476. } // ensure correct numeric values (also accepts NaN and Infinity)
  21477. if (typeof v === 'number') {
  21478. v = new SVG.Number(v);
  21479. } // ensure full hex color
  21480. else if (SVG.Color.isColor(v)) {
  21481. v = new SVG.Color(v);
  21482. } // parse array values
  21483. else if (Array.isArray(v)) {
  21484. v = new SVG.Array(v);
  21485. } // if the passed attribute is leading...
  21486. if (a == 'leading') {
  21487. // ... call the leading method instead
  21488. if (this.leading) {
  21489. this.leading(v);
  21490. }
  21491. } else {
  21492. // set given attribute on node
  21493. typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString());
  21494. } // rebuild if required
  21495. if (this.rebuild && (a == 'font-size' || a == 'x')) {
  21496. this.rebuild(a, v);
  21497. }
  21498. }
  21499. return this;
  21500. }
  21501. });
  21502. SVG.extend(SVG.Element, {
  21503. // Add transformations
  21504. transform: function transform(o, relative) {
  21505. // get target in case of the fx module, otherwise reference this
  21506. var target = this,
  21507. matrix;
  21508. // act as a getter
  21509. if (_typeof(o) !== 'object') {
  21510. // get current matrix
  21511. matrix = new SVG.Matrix(target).extract();
  21512. return typeof o === 'string' ? matrix[o] : matrix;
  21513. } // get current matrix
  21514. matrix = new SVG.Matrix(target); // ensure relative flag
  21515. relative = !!relative || !!o.relative; // act on matrix
  21516. if (o.a != null) {
  21517. matrix = relative // relative
  21518. ? matrix.multiply(new SVG.Matrix(o)) // absolute
  21519. : new SVG.Matrix(o);
  21520. }
  21521. return this.attr('transform', matrix);
  21522. }
  21523. });
  21524. SVG.extend(SVG.Element, {
  21525. // Reset all transformations
  21526. untransform: function untransform() {
  21527. return this.attr('transform', null);
  21528. },
  21529. // merge the whole transformation chain into one matrix and returns it
  21530. matrixify: function matrixify() {
  21531. var matrix = (this.attr('transform') || ''). // split transformations
  21532. split(SVG.regex.transforms).slice(0, -1).map(function (str) {
  21533. // generate key => value pairs
  21534. var kv = str.trim().split('(');
  21535. return [kv[0], kv[1].split(SVG.regex.delimiter).map(function (str) {
  21536. return parseFloat(str);
  21537. })];
  21538. }) // merge every transformation into one matrix
  21539. .reduce(function (matrix, transform) {
  21540. if (transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]));
  21541. return matrix[transform[0]].apply(matrix, transform[1]);
  21542. }, new SVG.Matrix());
  21543. return matrix;
  21544. },
  21545. // add an element to another parent without changing the visual representation on the screen
  21546. toParent: function toParent(parent) {
  21547. if (this == parent) return this;
  21548. var ctm = this.screenCTM();
  21549. var pCtm = parent.screenCTM().inverse();
  21550. this.addTo(parent).untransform().transform(pCtm.multiply(ctm));
  21551. return this;
  21552. },
  21553. // same as above with parent equals root-svg
  21554. toDoc: function toDoc() {
  21555. return this.toParent(this.doc());
  21556. }
  21557. });
  21558. SVG.Transformation = SVG.invent({
  21559. create: function create(source, inversed) {
  21560. if (arguments.length > 1 && typeof inversed !== 'boolean') {
  21561. return this.constructor.call(this, [].slice.call(arguments));
  21562. }
  21563. if (Array.isArray(source)) {
  21564. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  21565. this[this.arguments[i]] = source[i];
  21566. }
  21567. } else if (_typeof(source) === 'object') {
  21568. for (var i = 0, len = this.arguments.length; i < len; ++i) {
  21569. this[this.arguments[i]] = source[this.arguments[i]];
  21570. }
  21571. }
  21572. this.inversed = false;
  21573. if (inversed === true) {
  21574. this.inversed = true;
  21575. }
  21576. }
  21577. });
  21578. SVG.Translate = SVG.invent({
  21579. parent: SVG.Matrix,
  21580. inherit: SVG.Transformation,
  21581. create: function create(source, inversed) {
  21582. this.constructor.apply(this, [].slice.call(arguments));
  21583. },
  21584. extend: {
  21585. arguments: ['transformedX', 'transformedY'],
  21586. method: 'translate'
  21587. }
  21588. });
  21589. SVG.extend(SVG.Element, {
  21590. // Dynamic style generator
  21591. style: function style(s, v) {
  21592. if (arguments.length == 0) {
  21593. // get full style
  21594. return this.node.style.cssText || '';
  21595. } else if (arguments.length < 2) {
  21596. // apply every style individually if an object is passed
  21597. if (_typeof(s) === 'object') {
  21598. for (var v_ in s) {
  21599. this.style(v_, s[v_]);
  21600. }
  21601. } else if (SVG.regex.isCss.test(s)) {
  21602. // parse css string
  21603. s = s.split(/\s*;\s*/) // filter out suffix ; and stuff like ;;
  21604. .filter(function (e) {
  21605. return !!e;
  21606. }).map(function (e) {
  21607. return e.split(/\s*:\s*/);
  21608. }); // apply every definition individually
  21609. while (v = s.pop()) {
  21610. this.style(v[0], v[1]);
  21611. }
  21612. } else {
  21613. // act as a getter if the first and only argument is not an object
  21614. return this.node.style[camelCase(s)];
  21615. }
  21616. } else {
  21617. this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v;
  21618. }
  21619. return this;
  21620. }
  21621. });
  21622. SVG.Parent = SVG.invent({
  21623. // Initialize node
  21624. create: function create(element) {
  21625. this.constructor.call(this, element);
  21626. },
  21627. // Inherit from
  21628. inherit: SVG.Element,
  21629. // Add class methods
  21630. extend: {
  21631. // Returns all child elements
  21632. children: function children() {
  21633. return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function (node) {
  21634. return SVG.adopt(node);
  21635. });
  21636. },
  21637. // Add given element at a position
  21638. add: function add(element, i) {
  21639. if (i == null) {
  21640. this.node.appendChild(element.node);
  21641. } else if (element.node != this.node.childNodes[i]) {
  21642. this.node.insertBefore(element.node, this.node.childNodes[i]);
  21643. }
  21644. return this;
  21645. },
  21646. // Basically does the same as `add()` but returns the added element instead
  21647. put: function put(element, i) {
  21648. this.add(element, i);
  21649. return element;
  21650. },
  21651. // Checks if the given element is a child
  21652. has: function has(element) {
  21653. return this.index(element) >= 0;
  21654. },
  21655. // Gets index of given element
  21656. index: function index(element) {
  21657. return [].slice.call(this.node.childNodes).indexOf(element.node);
  21658. },
  21659. // Get a element at the given index
  21660. get: function get(i) {
  21661. return SVG.adopt(this.node.childNodes[i]);
  21662. },
  21663. // Get first child
  21664. first: function first() {
  21665. return this.get(0);
  21666. },
  21667. // Get the last child
  21668. last: function last() {
  21669. return this.get(this.node.childNodes.length - 1);
  21670. },
  21671. // Iterates over all children and invokes a given block
  21672. each: function each(block, deep) {
  21673. var il,
  21674. children = this.children();
  21675. for (var i = 0, il = children.length; i < il; i++) {
  21676. if (children[i] instanceof SVG.Element) {
  21677. block.apply(children[i], [i, children]);
  21678. }
  21679. if (deep && children[i] instanceof SVG.Container) {
  21680. children[i].each(block, deep);
  21681. }
  21682. }
  21683. return this;
  21684. },
  21685. // Remove a given child
  21686. removeElement: function removeElement(element) {
  21687. this.node.removeChild(element.node);
  21688. return this;
  21689. },
  21690. // Remove all elements in this container
  21691. clear: function clear() {
  21692. // remove children
  21693. while (this.node.hasChildNodes()) {
  21694. this.node.removeChild(this.node.lastChild);
  21695. } // remove defs reference
  21696. delete this._defs;
  21697. return this;
  21698. },
  21699. // Get defs
  21700. defs: function defs() {
  21701. return this.doc().defs();
  21702. }
  21703. }
  21704. });
  21705. SVG.extend(SVG.Parent, {
  21706. ungroup: function ungroup(parent, depth) {
  21707. if (depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this;
  21708. parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent));
  21709. depth = depth || Infinity;
  21710. this.each(function () {
  21711. if (this instanceof SVG.Defs) return this;
  21712. if (this instanceof SVG.Parent) return this.ungroup(parent, depth - 1);
  21713. return this.toParent(parent);
  21714. });
  21715. this.node.firstChild || this.remove();
  21716. return this;
  21717. },
  21718. flatten: function flatten(parent, depth) {
  21719. return this.ungroup(parent, depth);
  21720. }
  21721. });
  21722. SVG.Container = SVG.invent({
  21723. // Initialize node
  21724. create: function create(element) {
  21725. this.constructor.call(this, element);
  21726. },
  21727. // Inherit from
  21728. inherit: SVG.Parent
  21729. });
  21730. SVG.ViewBox = SVG.invent({
  21731. // Define parent
  21732. parent: SVG.Container,
  21733. // Add parent method
  21734. construct: {}
  21735. }) // Add events to elements
  21736. ;
  21737. ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove', // , 'mouseenter' -> not supported by IE
  21738. // , 'mouseleave' -> not supported by IE
  21739. 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].forEach(function (event) {
  21740. // add event to SVG.Element
  21741. SVG.Element.prototype[event] = function (f) {
  21742. // bind event to element rather than element node
  21743. SVG.on(this.node, event, f);
  21744. return this;
  21745. };
  21746. }); // Initialize listeners stack
  21747. SVG.listeners = [];
  21748. SVG.handlerMap = [];
  21749. SVG.listenerId = 0; // Add event binder in the SVG namespace
  21750. SVG.on = function (node, event, listener, binding, options) {
  21751. // create listener, get object-index
  21752. var l = listener.bind(binding || node.instance || node),
  21753. index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1,
  21754. ev = event.split('.')[0],
  21755. ns = event.split('.')[1] || '*'; // ensure valid object
  21756. SVG.listeners[index] = SVG.listeners[index] || {};
  21757. SVG.listeners[index][ev] = SVG.listeners[index][ev] || {};
  21758. SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {};
  21759. if (!listener._svgjsListenerId) {
  21760. listener._svgjsListenerId = ++SVG.listenerId;
  21761. } // reference listener
  21762. SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l; // add listener
  21763. node.addEventListener(ev, l, options || false);
  21764. }; // Add event unbinder in the SVG namespace
  21765. SVG.off = function (node, event, listener) {
  21766. var index = SVG.handlerMap.indexOf(node),
  21767. ev = event && event.split('.')[0],
  21768. ns = event && event.split('.')[1],
  21769. namespace = '';
  21770. if (index == -1) return;
  21771. if (listener) {
  21772. if (typeof listener === 'function') listener = listener._svgjsListenerId;
  21773. if (!listener) return; // remove listener reference
  21774. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) {
  21775. // remove listener
  21776. node.removeEventListener(ev, SVG.listeners[index][ev][ns || '*'][listener], false);
  21777. delete SVG.listeners[index][ev][ns || '*'][listener];
  21778. }
  21779. } else if (ns && ev) {
  21780. // remove all listeners for a namespaced event
  21781. if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns]) {
  21782. for (var listener_ in SVG.listeners[index][ev][ns]) {
  21783. SVG.off(node, [ev, ns].join('.'), listener_);
  21784. }
  21785. delete SVG.listeners[index][ev][ns];
  21786. }
  21787. } else if (ns) {
  21788. // remove all listeners for a specific namespace
  21789. for (var event_ in SVG.listeners[index]) {
  21790. for (var namespace in SVG.listeners[index][event_]) {
  21791. if (ns === namespace) {
  21792. SVG.off(node, [event_, ns].join('.'));
  21793. }
  21794. }
  21795. }
  21796. } else if (ev) {
  21797. // remove all listeners for the event
  21798. if (SVG.listeners[index][ev]) {
  21799. for (var namespace in SVG.listeners[index][ev]) {
  21800. SVG.off(node, [ev, namespace].join('.'));
  21801. }
  21802. delete SVG.listeners[index][ev];
  21803. }
  21804. } else {
  21805. // remove all listeners on a given node
  21806. for (var event_ in SVG.listeners[index]) {
  21807. SVG.off(node, event_);
  21808. }
  21809. delete SVG.listeners[index];
  21810. delete SVG.handlerMap[index];
  21811. }
  21812. }; //
  21813. SVG.extend(SVG.Element, {
  21814. // Bind given event to listener
  21815. on: function on(event, listener, binding, options) {
  21816. SVG.on(this.node, event, listener, binding, options);
  21817. return this;
  21818. },
  21819. // Unbind event from listener
  21820. off: function off(event, listener) {
  21821. SVG.off(this.node, event, listener);
  21822. return this;
  21823. },
  21824. // Fire given event
  21825. fire: function fire(event, data) {
  21826. // Dispatch event
  21827. if (event instanceof window.Event) {
  21828. this.node.dispatchEvent(event);
  21829. } else {
  21830. this.node.dispatchEvent(event = new SVG.CustomEvent(event, {
  21831. detail: data,
  21832. cancelable: true
  21833. }));
  21834. }
  21835. this._event = event;
  21836. return this;
  21837. },
  21838. event: function event() {
  21839. return this._event;
  21840. }
  21841. });
  21842. SVG.Defs = SVG.invent({
  21843. // Initialize node
  21844. create: 'defs',
  21845. // Inherit from
  21846. inherit: SVG.Container
  21847. });
  21848. SVG.G = SVG.invent({
  21849. // Initialize node
  21850. create: 'g',
  21851. // Inherit from
  21852. inherit: SVG.Container,
  21853. // Add class methods
  21854. extend: {
  21855. // Move over x-axis
  21856. x: function x(_x2) {
  21857. return _x2 == null ? this.transform('x') : this.transform({
  21858. x: _x2 - this.x()
  21859. }, true);
  21860. }
  21861. },
  21862. // Add parent method
  21863. construct: {
  21864. // Create a group element
  21865. group: function group() {
  21866. return this.put(new SVG.G());
  21867. }
  21868. }
  21869. });
  21870. SVG.Doc = SVG.invent({
  21871. // Initialize node
  21872. create: function create(element) {
  21873. if (element) {
  21874. // ensure the presence of a dom element
  21875. element = typeof element === 'string' ? document.getElementById(element) : element; // If the target is an svg element, use that element as the main wrapper.
  21876. // This allows svg.js to work with svg documents as well.
  21877. if (element.nodeName == 'svg') {
  21878. this.constructor.call(this, element);
  21879. } else {
  21880. this.constructor.call(this, SVG.create('svg'));
  21881. element.appendChild(this.node);
  21882. this.size('100%', '100%');
  21883. } // set svg element attributes and ensure defs node
  21884. this.namespace().defs();
  21885. }
  21886. },
  21887. // Inherit from
  21888. inherit: SVG.Container,
  21889. // Add class methods
  21890. extend: {
  21891. // Add namespaces
  21892. namespace: function namespace() {
  21893. return this.attr({
  21894. xmlns: SVG.ns,
  21895. version: '1.1'
  21896. }).attr('xmlns:xlink', SVG.xlink, SVG.xmlns).attr('xmlns:svgjs', SVG.svgjs, SVG.xmlns);
  21897. },
  21898. // Creates and returns defs element
  21899. defs: function defs() {
  21900. if (!this._defs) {
  21901. var defs; // Find or create a defs element in this instance
  21902. if (defs = this.node.getElementsByTagName('defs')[0]) {
  21903. this._defs = SVG.adopt(defs);
  21904. } else {
  21905. this._defs = new SVG.Defs();
  21906. } // Make sure the defs node is at the end of the stack
  21907. this.node.appendChild(this._defs.node);
  21908. }
  21909. return this._defs;
  21910. },
  21911. // custom parent method
  21912. parent: function parent() {
  21913. if (!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null;
  21914. return this.node.parentNode;
  21915. },
  21916. // Removes the doc from the DOM
  21917. remove: function remove() {
  21918. if (this.parent()) {
  21919. this.parent().removeChild(this.node);
  21920. }
  21921. return this;
  21922. },
  21923. clear: function clear() {
  21924. // remove children
  21925. while (this.node.hasChildNodes()) {
  21926. this.node.removeChild(this.node.lastChild);
  21927. } // remove defs reference
  21928. delete this._defs; // add back parser
  21929. if (SVG.parser.draw && !SVG.parser.draw.parentNode) {
  21930. this.node.appendChild(SVG.parser.draw);
  21931. }
  21932. return this;
  21933. },
  21934. clone: function clone(parent) {
  21935. // write dom data to the dom so the clone can pickup the data
  21936. this.writeDataToDom(); // get reference to node
  21937. var node = this.node; // clone element and assign new id
  21938. var clone = assignNewId(node.cloneNode(true)); // insert the clone in the given parent or after myself
  21939. if (parent) {
  21940. (parent.node || parent).appendChild(clone.node);
  21941. } else {
  21942. node.parentNode.insertBefore(clone.node, node.nextSibling);
  21943. }
  21944. return clone;
  21945. }
  21946. }
  21947. }); // ### This module adds backward / forward functionality to elements.
  21948. //
  21949. SVG.extend(SVG.Element, {// Get all siblings, including myself
  21950. });
  21951. SVG.Gradient = SVG.invent({
  21952. // Initialize node
  21953. create: function create(type) {
  21954. this.constructor.call(this, SVG.create(type + 'Gradient')); // store type
  21955. this.type = type;
  21956. },
  21957. // Inherit from
  21958. inherit: SVG.Container,
  21959. // Add class methods
  21960. extend: {
  21961. // Add a color stop
  21962. at: function at(offset, color, opacity) {
  21963. return this.put(new SVG.Stop()).update(offset, color, opacity);
  21964. },
  21965. // Update gradient
  21966. update: function update(block) {
  21967. // remove all stops
  21968. this.clear(); // invoke passed block
  21969. if (typeof block === 'function') {
  21970. block.call(this, this);
  21971. }
  21972. return this;
  21973. },
  21974. // Return the fill id
  21975. fill: function fill() {
  21976. return 'url(#' + this.id() + ')';
  21977. },
  21978. // Alias string convertion to fill
  21979. toString: function toString() {
  21980. return this.fill();
  21981. },
  21982. // custom attr to handle transform
  21983. attr: function attr(a, b, c) {
  21984. if (a == 'transform') a = 'gradientTransform';
  21985. return SVG.Container.prototype.attr.call(this, a, b, c);
  21986. }
  21987. },
  21988. // Add parent method
  21989. construct: {
  21990. // Create gradient element in defs
  21991. gradient: function gradient(type, block) {
  21992. return this.defs().gradient(type, block);
  21993. }
  21994. }
  21995. }); // Add animatable methods to both gradient and fx module
  21996. SVG.extend(SVG.Gradient, SVG.FX, {
  21997. // From position
  21998. from: function from(x, y) {
  21999. return (this._target || this).type == 'radial' ? this.attr({
  22000. fx: new SVG.Number(x),
  22001. fy: new SVG.Number(y)
  22002. }) : this.attr({
  22003. x1: new SVG.Number(x),
  22004. y1: new SVG.Number(y)
  22005. });
  22006. },
  22007. // To position
  22008. to: function to(x, y) {
  22009. return (this._target || this).type == 'radial' ? this.attr({
  22010. cx: new SVG.Number(x),
  22011. cy: new SVG.Number(y)
  22012. }) : this.attr({
  22013. x2: new SVG.Number(x),
  22014. y2: new SVG.Number(y)
  22015. });
  22016. }
  22017. }); // Base gradient generation
  22018. SVG.extend(SVG.Defs, {
  22019. // define gradient
  22020. gradient: function gradient(type, block) {
  22021. return this.put(new SVG.Gradient(type)).update(block);
  22022. }
  22023. });
  22024. SVG.Stop = SVG.invent({
  22025. // Initialize node
  22026. create: 'stop',
  22027. // Inherit from
  22028. inherit: SVG.Element,
  22029. // Add class methods
  22030. extend: {
  22031. // add color stops
  22032. update: function update(o) {
  22033. if (typeof o === 'number' || o instanceof SVG.Number) {
  22034. o = {
  22035. offset: arguments[0],
  22036. color: arguments[1],
  22037. opacity: arguments[2]
  22038. };
  22039. } // set attributes
  22040. if (o.opacity != null) this.attr('stop-opacity', o.opacity);
  22041. if (o.color != null) this.attr('stop-color', o.color);
  22042. if (o.offset != null) this.attr('offset', new SVG.Number(o.offset));
  22043. return this;
  22044. }
  22045. }
  22046. });
  22047. SVG.Pattern = SVG.invent({
  22048. // Initialize node
  22049. create: 'pattern',
  22050. // Inherit from
  22051. inherit: SVG.Container,
  22052. // Add class methods
  22053. extend: {
  22054. // Return the fill id
  22055. fill: function fill() {
  22056. return 'url(#' + this.id() + ')';
  22057. },
  22058. // Update pattern by rebuilding
  22059. update: function update(block) {
  22060. // remove content
  22061. this.clear(); // invoke passed block
  22062. if (typeof block === 'function') {
  22063. block.call(this, this);
  22064. }
  22065. return this;
  22066. },
  22067. // Alias string convertion to fill
  22068. toString: function toString() {
  22069. return this.fill();
  22070. },
  22071. // custom attr to handle transform
  22072. attr: function attr(a, b, c) {
  22073. if (a == 'transform') a = 'patternTransform';
  22074. return SVG.Container.prototype.attr.call(this, a, b, c);
  22075. }
  22076. },
  22077. // Add parent method
  22078. construct: {
  22079. // Create pattern element in defs
  22080. pattern: function pattern(width, height, block) {
  22081. return this.defs().pattern(width, height, block);
  22082. }
  22083. }
  22084. });
  22085. SVG.extend(SVG.Defs, {
  22086. // Define gradient
  22087. pattern: function pattern(width, height, block) {
  22088. return this.put(new SVG.Pattern()).update(block).attr({
  22089. x: 0,
  22090. y: 0,
  22091. width: width,
  22092. height: height,
  22093. patternUnits: 'userSpaceOnUse'
  22094. });
  22095. }
  22096. });
  22097. SVG.Shape = SVG.invent({
  22098. // Initialize node
  22099. create: function create(element) {
  22100. this.constructor.call(this, element);
  22101. },
  22102. // Inherit from
  22103. inherit: SVG.Element
  22104. });
  22105. SVG.Symbol = SVG.invent({
  22106. // Initialize node
  22107. create: 'symbol',
  22108. // Inherit from
  22109. inherit: SVG.Container,
  22110. construct: {
  22111. // create symbol
  22112. symbol: function symbol() {
  22113. return this.put(new SVG.Symbol());
  22114. }
  22115. }
  22116. });
  22117. SVG.Use = SVG.invent({
  22118. // Initialize node
  22119. create: 'use',
  22120. // Inherit from
  22121. inherit: SVG.Shape,
  22122. // Add class methods
  22123. extend: {
  22124. // Use element as a reference
  22125. element: function element(_element, file) {
  22126. // Set lined element
  22127. return this.attr('href', (file || '') + '#' + _element, SVG.xlink);
  22128. }
  22129. },
  22130. // Add parent method
  22131. construct: {
  22132. // Create a use element
  22133. use: function use(element, file) {
  22134. return this.put(new SVG.Use()).element(element, file);
  22135. }
  22136. }
  22137. });
  22138. SVG.Rect = SVG.invent({
  22139. // Initialize node
  22140. create: 'rect',
  22141. // Inherit from
  22142. inherit: SVG.Shape,
  22143. // Add parent method
  22144. construct: {
  22145. // Create a rect element
  22146. rect: function rect(width, height) {
  22147. return this.put(new SVG.Rect()).size(width, height);
  22148. }
  22149. }
  22150. });
  22151. SVG.Circle = SVG.invent({
  22152. // Initialize node
  22153. create: 'circle',
  22154. // Inherit from
  22155. inherit: SVG.Shape,
  22156. // Add parent method
  22157. construct: {
  22158. // Create circle element, based on ellipse
  22159. circle: function circle(size) {
  22160. return this.put(new SVG.Circle()).rx(new SVG.Number(size).divide(2)).move(0, 0);
  22161. }
  22162. }
  22163. });
  22164. SVG.extend(SVG.Circle, SVG.FX, {
  22165. // Radius x value
  22166. rx: function rx(_rx) {
  22167. return this.attr('r', _rx);
  22168. },
  22169. // Alias radius x value
  22170. ry: function ry(_ry) {
  22171. return this.rx(_ry);
  22172. }
  22173. });
  22174. SVG.Ellipse = SVG.invent({
  22175. // Initialize node
  22176. create: 'ellipse',
  22177. // Inherit from
  22178. inherit: SVG.Shape,
  22179. // Add parent method
  22180. construct: {
  22181. // Create an ellipse
  22182. ellipse: function ellipse(width, height) {
  22183. return this.put(new SVG.Ellipse()).size(width, height).move(0, 0);
  22184. }
  22185. }
  22186. });
  22187. SVG.extend(SVG.Ellipse, SVG.Rect, SVG.FX, {
  22188. // Radius x value
  22189. rx: function rx(_rx2) {
  22190. return this.attr('rx', _rx2);
  22191. },
  22192. // Radius y value
  22193. ry: function ry(_ry2) {
  22194. return this.attr('ry', _ry2);
  22195. }
  22196. }); // Add common method
  22197. SVG.extend(SVG.Circle, SVG.Ellipse, {
  22198. // Move over x-axis
  22199. x: function x(_x3) {
  22200. return _x3 == null ? this.cx() - this.rx() : this.cx(_x3 + this.rx());
  22201. },
  22202. // Move over y-axis
  22203. y: function y(_y2) {
  22204. return _y2 == null ? this.cy() - this.ry() : this.cy(_y2 + this.ry());
  22205. },
  22206. // Move by center over x-axis
  22207. cx: function cx(x) {
  22208. return x == null ? this.attr('cx') : this.attr('cx', x);
  22209. },
  22210. // Move by center over y-axis
  22211. cy: function cy(y) {
  22212. return y == null ? this.attr('cy') : this.attr('cy', y);
  22213. },
  22214. // Set width of element
  22215. width: function width(_width2) {
  22216. return _width2 == null ? this.rx() * 2 : this.rx(new SVG.Number(_width2).divide(2));
  22217. },
  22218. // Set height of element
  22219. height: function height(_height2) {
  22220. return _height2 == null ? this.ry() * 2 : this.ry(new SVG.Number(_height2).divide(2));
  22221. },
  22222. // Custom size function
  22223. size: function size(width, height) {
  22224. var p = proportionalSize(this, width, height);
  22225. return this.rx(new SVG.Number(p.width).divide(2)).ry(new SVG.Number(p.height).divide(2));
  22226. }
  22227. });
  22228. SVG.Line = SVG.invent({
  22229. // Initialize node
  22230. create: 'line',
  22231. // Inherit from
  22232. inherit: SVG.Shape,
  22233. // Add class methods
  22234. extend: {
  22235. // Get array
  22236. array: function array() {
  22237. return new SVG.PointArray([[this.attr('x1'), this.attr('y1')], [this.attr('x2'), this.attr('y2')]]);
  22238. },
  22239. // Overwrite native plot() method
  22240. plot: function plot(x1, y1, x2, y2) {
  22241. if (x1 == null) {
  22242. return this.array();
  22243. } else if (typeof y1 !== 'undefined') {
  22244. x1 = {
  22245. x1: x1,
  22246. y1: y1,
  22247. x2: x2,
  22248. y2: y2
  22249. };
  22250. } else {
  22251. x1 = new SVG.PointArray(x1).toLine();
  22252. }
  22253. return this.attr(x1);
  22254. },
  22255. // Move by left top corner
  22256. move: function move(x, y) {
  22257. return this.attr(this.array().move(x, y).toLine());
  22258. },
  22259. // Set element size to given width and height
  22260. size: function size(width, height) {
  22261. var p = proportionalSize(this, width, height);
  22262. return this.attr(this.array().size(p.width, p.height).toLine());
  22263. }
  22264. },
  22265. // Add parent method
  22266. construct: {
  22267. // Create a line element
  22268. line: function line(x1, y1, x2, y2) {
  22269. // make sure plot is called as a setter
  22270. // x1 is not necessarily a number, it can also be an array, a string and a SVG.PointArray
  22271. return SVG.Line.prototype.plot.apply(this.put(new SVG.Line()), x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]);
  22272. }
  22273. }
  22274. });
  22275. SVG.Polyline = SVG.invent({
  22276. // Initialize node
  22277. create: 'polyline',
  22278. // Inherit from
  22279. inherit: SVG.Shape,
  22280. // Add parent method
  22281. construct: {
  22282. // Create a wrapped polyline element
  22283. polyline: function polyline(p) {
  22284. // make sure plot is called as a setter
  22285. return this.put(new SVG.Polyline()).plot(p || new SVG.PointArray());
  22286. }
  22287. }
  22288. });
  22289. SVG.Polygon = SVG.invent({
  22290. // Initialize node
  22291. create: 'polygon',
  22292. // Inherit from
  22293. inherit: SVG.Shape,
  22294. // Add parent method
  22295. construct: {
  22296. // Create a wrapped polygon element
  22297. polygon: function polygon(p) {
  22298. // make sure plot is called as a setter
  22299. return this.put(new SVG.Polygon()).plot(p || new SVG.PointArray());
  22300. }
  22301. }
  22302. }); // Add polygon-specific functions
  22303. SVG.extend(SVG.Polyline, SVG.Polygon, {
  22304. // Get array
  22305. array: function array() {
  22306. return this._array || (this._array = new SVG.PointArray(this.attr('points')));
  22307. },
  22308. // Plot new path
  22309. plot: function plot(p) {
  22310. return p == null ? this.array() : this.clear().attr('points', typeof p === 'string' ? p : this._array = new SVG.PointArray(p));
  22311. },
  22312. // Clear array cache
  22313. clear: function clear() {
  22314. delete this._array;
  22315. return this;
  22316. },
  22317. // Move by left top corner
  22318. move: function move(x, y) {
  22319. return this.attr('points', this.array().move(x, y));
  22320. },
  22321. // Set element size to given width and height
  22322. size: function size(width, height) {
  22323. var p = proportionalSize(this, width, height);
  22324. return this.attr('points', this.array().size(p.width, p.height));
  22325. }
  22326. }); // unify all point to point elements
  22327. SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, {
  22328. // Define morphable array
  22329. morphArray: SVG.PointArray,
  22330. // Move by left top corner over x-axis
  22331. x: function x(_x4) {
  22332. return _x4 == null ? this.bbox().x : this.move(_x4, this.bbox().y);
  22333. },
  22334. // Move by left top corner over y-axis
  22335. y: function y(_y3) {
  22336. return _y3 == null ? this.bbox().y : this.move(this.bbox().x, _y3);
  22337. },
  22338. // Set width of element
  22339. width: function width(_width3) {
  22340. var b = this.bbox();
  22341. return _width3 == null ? b.width : this.size(_width3, b.height);
  22342. },
  22343. // Set height of element
  22344. height: function height(_height3) {
  22345. var b = this.bbox();
  22346. return _height3 == null ? b.height : this.size(b.width, _height3);
  22347. }
  22348. });
  22349. SVG.Path = SVG.invent({
  22350. // Initialize node
  22351. create: 'path',
  22352. // Inherit from
  22353. inherit: SVG.Shape,
  22354. // Add class methods
  22355. extend: {
  22356. // Define morphable array
  22357. morphArray: SVG.PathArray,
  22358. // Get array
  22359. array: function array() {
  22360. return this._array || (this._array = new SVG.PathArray(this.attr('d')));
  22361. },
  22362. // Plot new path
  22363. plot: function plot(d) {
  22364. return d == null ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : this._array = new SVG.PathArray(d));
  22365. },
  22366. // Clear array cache
  22367. clear: function clear() {
  22368. delete this._array;
  22369. return this;
  22370. }
  22371. },
  22372. // Add parent method
  22373. construct: {
  22374. // Create a wrapped path element
  22375. path: function path(d) {
  22376. // make sure plot is called as a setter
  22377. return this.put(new SVG.Path()).plot(d || new SVG.PathArray());
  22378. }
  22379. }
  22380. });
  22381. SVG.Image = SVG.invent({
  22382. // Initialize node
  22383. create: 'image',
  22384. // Inherit from
  22385. inherit: SVG.Shape,
  22386. // Add class methods
  22387. extend: {
  22388. // (re)load image
  22389. load: function load(url) {
  22390. if (!url) return this;
  22391. var self = this,
  22392. img = new window.Image(); // preload image
  22393. SVG.on(img, 'load', function () {
  22394. SVG.off(img);
  22395. var p = self.parent(SVG.Pattern);
  22396. if (p === null) return; // ensure image size
  22397. if (self.width() == 0 && self.height() == 0) {
  22398. self.size(img.width, img.height);
  22399. } // ensure pattern size if not set
  22400. if (p && p.width() == 0 && p.height() == 0) {
  22401. p.size(self.width(), self.height());
  22402. } // callback
  22403. if (typeof self._loaded === 'function') {
  22404. self._loaded.call(self, {
  22405. width: img.width,
  22406. height: img.height,
  22407. ratio: img.width / img.height,
  22408. url: url
  22409. });
  22410. }
  22411. });
  22412. SVG.on(img, 'error', function (e) {
  22413. SVG.off(img);
  22414. if (typeof self._error === 'function') {
  22415. self._error.call(self, e);
  22416. }
  22417. });
  22418. return this.attr('href', img.src = this.src = url, SVG.xlink);
  22419. },
  22420. // Add loaded callback
  22421. loaded: function loaded(_loaded) {
  22422. this._loaded = _loaded;
  22423. return this;
  22424. },
  22425. error: function error(_error) {
  22426. this._error = _error;
  22427. return this;
  22428. }
  22429. },
  22430. // Add parent method
  22431. construct: {
  22432. // create image element, load image and set its size
  22433. image: function image(source, width, height) {
  22434. return this.put(new SVG.Image()).load(source).size(width || 0, height || width || 0);
  22435. }
  22436. }
  22437. });
  22438. SVG.Text = SVG.invent({
  22439. // Initialize node
  22440. create: function create() {
  22441. this.constructor.call(this, SVG.create('text'));
  22442. this.dom.leading = new SVG.Number(1.3); // store leading value for rebuilding
  22443. this._rebuild = true; // enable automatic updating of dy values
  22444. this._build = false; // disable build mode for adding multiple lines
  22445. // set default font
  22446. this.attr('font-family', SVG.defaults.attrs['font-family']);
  22447. },
  22448. // Inherit from
  22449. inherit: SVG.Shape,
  22450. // Add class methods
  22451. extend: {
  22452. // Move over x-axis
  22453. x: function x(_x5) {
  22454. // act as getter
  22455. if (_x5 == null) {
  22456. return this.attr('x');
  22457. }
  22458. return this.attr('x', _x5);
  22459. },
  22460. // Set the text content
  22461. text: function text(_text) {
  22462. // act as getter
  22463. if (typeof _text === 'undefined') {
  22464. var _text = '';
  22465. var children = this.node.childNodes;
  22466. for (var i = 0, len = children.length; i < len; ++i) {
  22467. // add newline if its not the first child and newLined is set to true
  22468. if (i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true) {
  22469. _text += '\n';
  22470. } // add content of this node
  22471. _text += children[i].textContent;
  22472. }
  22473. return _text;
  22474. } // remove existing content
  22475. this.clear().build(true);
  22476. if (typeof _text === 'function') {
  22477. // call block
  22478. _text.call(this, this);
  22479. } else {
  22480. // store text and make sure text is not blank
  22481. _text = _text.split('\n'); // build new lines
  22482. for (var i = 0, il = _text.length; i < il; i++) {
  22483. this.tspan(_text[i]).newLine();
  22484. }
  22485. } // disable build mode and rebuild lines
  22486. return this.build(false).rebuild();
  22487. },
  22488. // Set font size
  22489. size: function size(_size) {
  22490. return this.attr('font-size', _size).rebuild();
  22491. },
  22492. // Set / get leading
  22493. leading: function leading(value) {
  22494. // act as getter
  22495. if (value == null) {
  22496. return this.dom.leading;
  22497. } // act as setter
  22498. this.dom.leading = new SVG.Number(value);
  22499. return this.rebuild();
  22500. },
  22501. // Get all the first level lines
  22502. lines: function lines() {
  22503. var node = (this.textPath && this.textPath() || this).node; // filter tspans and map them to SVG.js instances
  22504. var lines = SVG.utils.map(SVG.utils.filterSVGElements(node.childNodes), function (el) {
  22505. return SVG.adopt(el);
  22506. }); // return an instance of SVG.set
  22507. return new SVG.Set(lines);
  22508. },
  22509. // Rebuild appearance type
  22510. rebuild: function rebuild(_rebuild) {
  22511. // store new rebuild flag if given
  22512. if (typeof _rebuild === 'boolean') {
  22513. this._rebuild = _rebuild;
  22514. } // define position of all lines
  22515. if (this._rebuild) {
  22516. var self = this,
  22517. blankLineOffset = 0,
  22518. dy = this.dom.leading * new SVG.Number(this.attr('font-size'));
  22519. this.lines().each(function () {
  22520. if (this.dom.newLined) {
  22521. if (!self.textPath()) {
  22522. this.attr('x', self.attr('x'));
  22523. }
  22524. if (this.text() == '\n') {
  22525. blankLineOffset += dy;
  22526. } else {
  22527. this.attr('dy', dy + blankLineOffset);
  22528. blankLineOffset = 0;
  22529. }
  22530. }
  22531. });
  22532. this.fire('rebuild');
  22533. }
  22534. return this;
  22535. },
  22536. // Enable / disable build mode
  22537. build: function build(_build) {
  22538. this._build = !!_build;
  22539. return this;
  22540. },
  22541. // overwrite method from parent to set data properly
  22542. setData: function setData(o) {
  22543. this.dom = o;
  22544. this.dom.leading = new SVG.Number(o.leading || 1.3);
  22545. return this;
  22546. }
  22547. },
  22548. // Add parent method
  22549. construct: {
  22550. // Create text element
  22551. text: function text(_text2) {
  22552. return this.put(new SVG.Text()).text(_text2);
  22553. },
  22554. // Create plain text element
  22555. plain: function plain(text) {
  22556. return this.put(new SVG.Text()).plain(text);
  22557. }
  22558. }
  22559. });
  22560. SVG.Tspan = SVG.invent({
  22561. // Initialize node
  22562. create: 'tspan',
  22563. // Inherit from
  22564. inherit: SVG.Shape,
  22565. // Add class methods
  22566. extend: {
  22567. // Set text content
  22568. text: function text(_text3) {
  22569. if (_text3 == null) return this.node.textContent + (this.dom.newLined ? '\n' : '');
  22570. typeof _text3 === 'function' ? _text3.call(this, this) : this.plain(_text3);
  22571. return this;
  22572. },
  22573. // Shortcut dx
  22574. dx: function dx(_dx) {
  22575. return this.attr('dx', _dx);
  22576. },
  22577. // Shortcut dy
  22578. dy: function dy(_dy) {
  22579. return this.attr('dy', _dy);
  22580. },
  22581. // Create new line
  22582. newLine: function newLine() {
  22583. // fetch text parent
  22584. var t = this.parent(SVG.Text); // mark new line
  22585. this.dom.newLined = true; // apply new hy¡n
  22586. return this.dy(t.dom.leading * t.attr('font-size')).attr('x', t.x());
  22587. }
  22588. }
  22589. });
  22590. SVG.extend(SVG.Text, SVG.Tspan, {
  22591. // Create plain text node
  22592. plain: function plain(text) {
  22593. // clear if build mode is disabled
  22594. if (this._build === false) {
  22595. this.clear();
  22596. } // create text node
  22597. this.node.appendChild(document.createTextNode(text));
  22598. return this;
  22599. },
  22600. // Create a tspan
  22601. tspan: function tspan(text) {
  22602. var node = (this.textPath && this.textPath() || this).node,
  22603. tspan = new SVG.Tspan(); // clear if build mode is disabled
  22604. if (this._build === false) {
  22605. this.clear();
  22606. } // add new tspan
  22607. node.appendChild(tspan.node);
  22608. return tspan.text(text);
  22609. },
  22610. // Clear all lines
  22611. clear: function clear() {
  22612. var node = (this.textPath && this.textPath() || this).node; // remove existing child nodes
  22613. while (node.hasChildNodes()) {
  22614. node.removeChild(node.lastChild);
  22615. }
  22616. return this;
  22617. },
  22618. // Get length of text element
  22619. length: function length() {
  22620. return this.node.getComputedTextLength();
  22621. }
  22622. });
  22623. SVG.TextPath = SVG.invent({
  22624. // Initialize node
  22625. create: 'textPath',
  22626. // Inherit from
  22627. inherit: SVG.Parent,
  22628. // Define parent class
  22629. parent: SVG.Text,
  22630. // Add parent method
  22631. construct: {
  22632. morphArray: SVG.PathArray,
  22633. // return the array of the path track element
  22634. array: function array() {
  22635. var track = this.track();
  22636. return track ? track.array() : null;
  22637. },
  22638. // Plot path if any
  22639. plot: function plot(d) {
  22640. var track = this.track(),
  22641. pathArray = null;
  22642. if (track) {
  22643. pathArray = track.plot(d);
  22644. }
  22645. return d == null ? pathArray : this;
  22646. },
  22647. // Get the path track element
  22648. track: function track() {
  22649. var path = this.textPath();
  22650. if (path) {
  22651. return path.reference('href');
  22652. }
  22653. },
  22654. // Get the textPath child
  22655. textPath: function textPath() {
  22656. if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') {
  22657. return SVG.adopt(this.node.firstChild);
  22658. }
  22659. }
  22660. }
  22661. });
  22662. SVG.Nested = SVG.invent({
  22663. // Initialize node
  22664. create: function create() {
  22665. this.constructor.call(this, SVG.create('svg'));
  22666. this.style('overflow', 'visible');
  22667. },
  22668. // Inherit from
  22669. inherit: SVG.Container,
  22670. // Add parent method
  22671. construct: {
  22672. // Create nested svg document
  22673. nested: function nested() {
  22674. return this.put(new SVG.Nested());
  22675. }
  22676. }
  22677. }); // Define list of available attributes for stroke and fill
  22678. var sugar = {
  22679. stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'],
  22680. fill: ['color', 'opacity', 'rule'],
  22681. prefix: function prefix(t, a) {
  22682. return a == 'color' ? t : t + '-' + a;
  22683. }
  22684. } // Add sugar for fill and stroke
  22685. ;
  22686. ['fill', 'stroke'].forEach(function (m) {
  22687. var extension = {};
  22688. extension[m] = function (o) {
  22689. if (typeof o === 'undefined') {
  22690. return this;
  22691. }
  22692. if (typeof o === 'string' || SVG.Color.isRgb(o) || o && typeof o.fill === 'function') {
  22693. this.attr(m, o);
  22694. } else // set all attributes from sugar.fill and sugar.stroke list
  22695. {
  22696. for (var i = sugar[m].length - 1; i >= 0; i--) {
  22697. if (o[sugar[m][i]] != null) {
  22698. this.attr(sugar.prefix(m, sugar[m][i]), o[sugar[m][i]]);
  22699. }
  22700. }
  22701. }
  22702. return this;
  22703. };
  22704. SVG.extend(SVG.Element, SVG.FX, extension);
  22705. });
  22706. SVG.extend(SVG.Element, SVG.FX, {
  22707. // Map translate to transform
  22708. translate: function translate(x, y) {
  22709. return this.transform({
  22710. x: x,
  22711. y: y
  22712. });
  22713. },
  22714. // Map matrix to transform
  22715. matrix: function matrix(m) {
  22716. return this.attr('transform', new SVG.Matrix(arguments.length == 6 ? [].slice.call(arguments) : m));
  22717. },
  22718. // Opacity
  22719. opacity: function opacity(value) {
  22720. return this.attr('opacity', value);
  22721. },
  22722. // Relative move over x axis
  22723. dx: function dx(x) {
  22724. return this.x(new SVG.Number(x).plus(this instanceof SVG.FX ? 0 : this.x()), true);
  22725. },
  22726. // Relative move over y axis
  22727. dy: function dy(y) {
  22728. return this.y(new SVG.Number(y).plus(this instanceof SVG.FX ? 0 : this.y()), true);
  22729. }
  22730. });
  22731. SVG.extend(SVG.Path, {
  22732. // Get path length
  22733. length: function length() {
  22734. return this.node.getTotalLength();
  22735. },
  22736. // Get point at length
  22737. pointAt: function pointAt(length) {
  22738. return this.node.getPointAtLength(length);
  22739. }
  22740. });
  22741. SVG.Set = SVG.invent({
  22742. // Initialize
  22743. create: function create(members) {
  22744. // Set initial state
  22745. Array.isArray(members) ? this.members = members : this.clear();
  22746. },
  22747. // Add class methods
  22748. extend: {
  22749. // Add element to set
  22750. add: function add() {
  22751. var il,
  22752. elements = [].slice.call(arguments);
  22753. for (var i = 0, il = elements.length; i < il; i++) {
  22754. this.members.push(elements[i]);
  22755. }
  22756. return this;
  22757. },
  22758. // Remove element from set
  22759. remove: function remove(element) {
  22760. var i = this.index(element); // remove given child
  22761. if (i > -1) {
  22762. this.members.splice(i, 1);
  22763. }
  22764. return this;
  22765. },
  22766. // Iterate over all members
  22767. each: function each(block) {
  22768. for (var i = 0, il = this.members.length; i < il; i++) {
  22769. block.apply(this.members[i], [i, this.members]);
  22770. }
  22771. return this;
  22772. },
  22773. // Restore to defaults
  22774. clear: function clear() {
  22775. // initialize store
  22776. this.members = [];
  22777. return this;
  22778. },
  22779. // Get the length of a set
  22780. length: function length() {
  22781. return this.members.length;
  22782. },
  22783. // Checks if a given element is present in set
  22784. has: function has(element) {
  22785. return this.index(element) >= 0;
  22786. },
  22787. // retuns index of given element in set
  22788. index: function index(element) {
  22789. return this.members.indexOf(element);
  22790. },
  22791. // Get member at given index
  22792. get: function get(i) {
  22793. return this.members[i];
  22794. },
  22795. // Get first member
  22796. first: function first() {
  22797. return this.get(0);
  22798. },
  22799. // Get last member
  22800. last: function last() {
  22801. return this.get(this.members.length - 1);
  22802. },
  22803. // Default value
  22804. valueOf: function valueOf() {
  22805. return this.members;
  22806. }
  22807. },
  22808. // Add parent method
  22809. construct: {
  22810. // Create a new set
  22811. set: function set(members) {
  22812. return new SVG.Set(members);
  22813. }
  22814. }
  22815. });
  22816. SVG.FX.Set = SVG.invent({
  22817. // Initialize node
  22818. create: function create(set) {
  22819. // store reference to set
  22820. this.set = set;
  22821. }
  22822. }); // Alias methods
  22823. SVG.Set.inherit = function () {
  22824. var methods = []; // gather shape methods
  22825. for (var m in SVG.Shape.prototype) {
  22826. if (typeof SVG.Shape.prototype[m] === 'function' && typeof SVG.Set.prototype[m] !== 'function') {
  22827. methods.push(m);
  22828. }
  22829. } // apply shape aliasses
  22830. methods.forEach(function (method) {
  22831. SVG.Set.prototype[method] = function () {
  22832. for (var i = 0, il = this.members.length; i < il; i++) {
  22833. if (this.members[i] && typeof this.members[i][method] === 'function') {
  22834. this.members[i][method].apply(this.members[i], arguments);
  22835. }
  22836. }
  22837. return method == 'animate' ? this.fx || (this.fx = new SVG.FX.Set(this)) : this;
  22838. };
  22839. }); // clear methods for the next round
  22840. methods = []; // gather fx methods
  22841. for (var m in SVG.FX.prototype) {
  22842. if (typeof SVG.FX.prototype[m] === 'function' && typeof SVG.FX.Set.prototype[m] !== 'function') {
  22843. methods.push(m);
  22844. }
  22845. } // apply fx aliasses
  22846. methods.forEach(function (method) {
  22847. SVG.FX.Set.prototype[method] = function () {
  22848. for (var i = 0, il = this.set.members.length; i < il; i++) {
  22849. this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments);
  22850. }
  22851. return this;
  22852. };
  22853. });
  22854. };
  22855. SVG.extend(SVG.Element, {});
  22856. SVG.extend(SVG.Element, {
  22857. // Remember arbitrary data
  22858. remember: function remember(k, v) {
  22859. // remember every item in an object individually
  22860. if (_typeof(arguments[0]) === 'object') {
  22861. for (var v_ in k) {
  22862. this.remember(v_, k[v_]);
  22863. }
  22864. } // retrieve memory
  22865. else if (arguments.length == 1) {
  22866. return this.memory()[k];
  22867. } // store memory
  22868. else {
  22869. this.memory()[k] = v;
  22870. }
  22871. return this;
  22872. },
  22873. // Erase a given memory
  22874. forget: function forget() {
  22875. if (arguments.length == 0) {
  22876. this._memory = {};
  22877. } else {
  22878. for (var i = arguments.length - 1; i >= 0; i--) {
  22879. delete this.memory()[arguments[i]];
  22880. }
  22881. }
  22882. return this;
  22883. },
  22884. // Initialize or return local memory object
  22885. memory: function memory() {
  22886. return this._memory || (this._memory = {});
  22887. }
  22888. }); // Method for getting an element by id
  22889. SVG.get = function (id) {
  22890. var node = document.getElementById(idFromReference(id) || id);
  22891. return SVG.adopt(node);
  22892. }; // Select elements by query string
  22893. SVG.select = function (query, parent) {
  22894. return new SVG.Set(SVG.utils.map((parent || document).querySelectorAll(query), function (node) {
  22895. return SVG.adopt(node);
  22896. }));
  22897. };
  22898. SVG.extend(SVG.Parent, {
  22899. // Scoped select method
  22900. select: function select(query) {
  22901. return SVG.select(query, this.node);
  22902. }
  22903. });
  22904. function pathRegReplace(a, b, c, d) {
  22905. return c + d.replace(SVG.regex.dots, ' .');
  22906. } // creates deep clone of array
  22907. function _is(el, obj) {
  22908. return el instanceof obj;
  22909. } // tests if a given selector matches an element
  22910. function _matches(el, selector) {
  22911. return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
  22912. } // Convert dash-separated-string to camelCase
  22913. function camelCase(s) {
  22914. return s.toLowerCase().replace(/-(.)/g, function (m, g) {
  22915. return g.toUpperCase();
  22916. });
  22917. } // Capitalize first letter of a string
  22918. function capitalize(s) {
  22919. return s.charAt(0).toUpperCase() + s.slice(1);
  22920. } // Ensure to six-based hex
  22921. function fullHex(hex) {
  22922. 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;
  22923. } // Component to hex value
  22924. function compToHex(comp) {
  22925. var hex = comp.toString(16);
  22926. return hex.length == 1 ? '0' + hex : hex;
  22927. } // Calculate proportional width and height values when necessary
  22928. function proportionalSize(element, width, height) {
  22929. if (width == null || height == null) {
  22930. var box = element.bbox();
  22931. if (width == null) {
  22932. width = box.width / box.height * height;
  22933. } else if (height == null) {
  22934. height = box.height / box.width * width;
  22935. }
  22936. }
  22937. return {
  22938. width: width,
  22939. height: height
  22940. };
  22941. } // Delta transform point
  22942. function deltaTransformPoint(matrix, x, y) {
  22943. return {
  22944. x: x * matrix.a + y * matrix.c + 0,
  22945. y: x * matrix.b + y * matrix.d + 0
  22946. };
  22947. } // Map matrix array to object
  22948. function arrayToMatrix(a) {
  22949. return {
  22950. a: a[0],
  22951. b: a[1],
  22952. c: a[2],
  22953. d: a[3],
  22954. e: a[4],
  22955. f: a[5]
  22956. };
  22957. } // Parse matrix if required
  22958. function parseMatrix(matrix) {
  22959. if (!(matrix instanceof SVG.Matrix)) {
  22960. matrix = new SVG.Matrix(matrix);
  22961. }
  22962. return matrix;
  22963. } // Add centre point to transform object
  22964. function arrayToString(a) {
  22965. for (var i = 0, il = a.length, s = ''; i < il; i++) {
  22966. s += a[i][0];
  22967. if (a[i][1] != null) {
  22968. s += a[i][1];
  22969. if (a[i][2] != null) {
  22970. s += ' ';
  22971. s += a[i][2];
  22972. if (a[i][3] != null) {
  22973. s += ' ';
  22974. s += a[i][3];
  22975. s += ' ';
  22976. s += a[i][4];
  22977. if (a[i][5] != null) {
  22978. s += ' ';
  22979. s += a[i][5];
  22980. s += ' ';
  22981. s += a[i][6];
  22982. if (a[i][7] != null) {
  22983. s += ' ';
  22984. s += a[i][7];
  22985. }
  22986. }
  22987. }
  22988. }
  22989. }
  22990. }
  22991. return s + ' ';
  22992. } // Deep new id assignment
  22993. function assignNewId(node) {
  22994. // do the same for SVG child nodes as well
  22995. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  22996. if (node.childNodes[i] instanceof window.SVGElement) {
  22997. assignNewId(node.childNodes[i]);
  22998. }
  22999. }
  23000. return SVG.adopt(node).id(SVG.eid(node.nodeName));
  23001. } // Add more bounding box properties
  23002. function fullBox(b) {
  23003. if (b.x == null) {
  23004. b.x = 0;
  23005. b.y = 0;
  23006. b.width = 0;
  23007. b.height = 0;
  23008. }
  23009. b.w = b.width;
  23010. b.h = b.height;
  23011. b.x2 = b.x + b.width;
  23012. b.y2 = b.y + b.height;
  23013. b.cx = b.x + b.width / 2;
  23014. b.cy = b.y + b.height / 2;
  23015. return b;
  23016. } // Get id from reference string
  23017. function idFromReference(url) {
  23018. var m = (url || '').toString().match(SVG.regex.reference);
  23019. if (m) return m[1];
  23020. } // If values like 1e-88 are passed, this is not a valid 32 bit float,
  23021. // but in those cases, we are so close to 0 that 0 works well!
  23022. function float32String(v) {
  23023. return Math.abs(v) > 1e-37 ? v : 0;
  23024. } // Create matrix array for looping
  23025. var abcdef = 'abcdef'.split(''); // Add CustomEvent to IE9 and IE10
  23026. if (typeof window.CustomEvent !== 'function') {
  23027. // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
  23028. var CustomEventPoly = function CustomEventPoly(event, options) {
  23029. options = options || {
  23030. bubbles: false,
  23031. cancelable: false,
  23032. detail: undefined
  23033. };
  23034. var e = document.createEvent('CustomEvent');
  23035. e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail);
  23036. return e;
  23037. };
  23038. CustomEventPoly.prototype = window.Event.prototype;
  23039. SVG.CustomEvent = CustomEventPoly;
  23040. } else {
  23041. SVG.CustomEvent = window.CustomEvent;
  23042. }
  23043. return SVG;
  23044. });
  23045. /*! svg.filter.js - v2.0.2 - 2016-02-24
  23046. * https://github.com/wout/svg.filter.js
  23047. * Copyright (c) 2016 Wout Fierens; Licensed MIT */
  23048. (function() {
  23049. // Main filter class
  23050. SVG.Filter = SVG.invent({
  23051. create: 'filter',
  23052. inherit: SVG.Parent,
  23053. extend: {
  23054. // Static strings
  23055. source: 'SourceGraphic',
  23056. sourceAlpha: 'SourceAlpha',
  23057. background: 'BackgroundImage',
  23058. backgroundAlpha: 'BackgroundAlpha',
  23059. fill: 'FillPaint',
  23060. stroke: 'StrokePaint',
  23061. autoSetIn: true,
  23062. // Custom put method for leaner code
  23063. put: function(element, i) {
  23064. this.add(element, i);
  23065. if(!element.attr('in') && this.autoSetIn){
  23066. element.attr('in',this.source);
  23067. }
  23068. if(!element.attr('result')){
  23069. element.attr('result',element);
  23070. }
  23071. return element
  23072. },
  23073. // Blend effect
  23074. blend: function(in1, in2, mode) {
  23075. return this.put(new SVG.BlendEffect(in1, in2, mode))
  23076. },
  23077. // ColorMatrix effect
  23078. colorMatrix: function(type, values) {
  23079. return this.put(new SVG.ColorMatrixEffect(type, values))
  23080. },
  23081. // ConvolveMatrix effect
  23082. convolveMatrix: function(matrix) {
  23083. return this.put(new SVG.ConvolveMatrixEffect(matrix))
  23084. },
  23085. // ComponentTransfer effect
  23086. componentTransfer: function(components) {
  23087. return this.put(new SVG.ComponentTransferEffect(components))
  23088. },
  23089. // Composite effect
  23090. composite: function(in1, in2, operator) {
  23091. return this.put(new SVG.CompositeEffect(in1, in2, operator))
  23092. },
  23093. // Flood effect
  23094. flood: function(color, opacity) {
  23095. return this.put(new SVG.FloodEffect(color, opacity))
  23096. },
  23097. // Offset effect
  23098. offset: function(x, y) {
  23099. return this.put(new SVG.OffsetEffect(x,y))
  23100. },
  23101. // Image effect
  23102. image: function(src) {
  23103. return this.put(new SVG.ImageEffect(src))
  23104. },
  23105. // Merge effect
  23106. merge: function() {
  23107. //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
  23108. var args = [undefined];
  23109. for(var i in arguments) args.push(arguments[i]);
  23110. return this.put(new (SVG.MergeEffect.bind.apply(SVG.MergeEffect,args)))
  23111. },
  23112. // Gaussian Blur effect
  23113. gaussianBlur: function(x,y) {
  23114. return this.put(new SVG.GaussianBlurEffect(x,y))
  23115. },
  23116. // Morphology effect
  23117. morphology: function(operator,radius){
  23118. return this.put(new SVG.MorphologyEffect(operator,radius))
  23119. },
  23120. // DiffuseLighting effect
  23121. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  23122. return this.put(new SVG.DiffuseLightingEffect(surfaceScale,diffuseConstant,kernelUnitLength))
  23123. },
  23124. // DisplacementMap effect
  23125. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  23126. return this.put(new SVG.DisplacementMapEffect(in1,in2,scale,xChannelSelector,yChannelSelector))
  23127. },
  23128. // SpecularLighting effect
  23129. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  23130. return this.put(new SVG.SpecularLightingEffect(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength))
  23131. },
  23132. // Tile effect
  23133. tile: function(){
  23134. return this.put(new SVG.TileEffect());
  23135. },
  23136. // Turbulence effect
  23137. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  23138. return this.put(new SVG.TurbulenceEffect(baseFrequency,numOctaves,seed,stitchTiles,type))
  23139. },
  23140. // Default string value
  23141. toString: function() {
  23142. return 'url(#' + this.attr('id') + ')'
  23143. }
  23144. }
  23145. });
  23146. //add .filter function
  23147. SVG.extend(SVG.Defs, {
  23148. // Define filter
  23149. filter: function(block) {
  23150. var filter = this.put(new SVG.Filter);
  23151. /* invoke passed block */
  23152. if (typeof block === 'function')
  23153. block.call(filter, filter);
  23154. return filter
  23155. }
  23156. });
  23157. SVG.extend(SVG.Container, {
  23158. // Define filter on defs
  23159. filter: function(block) {
  23160. return this.defs().filter(block)
  23161. }
  23162. });
  23163. SVG.extend(SVG.Element, SVG.G, SVG.Nested, {
  23164. // Create filter element in defs and store reference
  23165. filter: function(block) {
  23166. this.filterer = block instanceof SVG.Element ?
  23167. block : this.doc().filter(block);
  23168. if(this.doc() && this.filterer.doc() !== this.doc()){
  23169. this.doc().defs().add(this.filterer);
  23170. }
  23171. this.attr('filter', this.filterer);
  23172. return this.filterer
  23173. },
  23174. // Remove filter
  23175. unfilter: function(remove) {
  23176. /* also remove the filter node */
  23177. if (this.filterer && remove === true)
  23178. this.filterer.remove();
  23179. /* delete reference to filterer */
  23180. delete this.filterer;
  23181. /* remove filter attribute */
  23182. return this.attr('filter', null)
  23183. }
  23184. });
  23185. // Create SVG.Effect class
  23186. SVG.Effect = SVG.invent({
  23187. create: function(){
  23188. this.constructor.call(this);
  23189. },
  23190. inherit: SVG.Element,
  23191. extend: {
  23192. // Set in attribute
  23193. in: function(effect) {
  23194. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  23195. },
  23196. // Named result
  23197. result: function(result) {
  23198. return result == null? this.attr('result') : this.attr('result',result)
  23199. },
  23200. // Stringification
  23201. toString: function() {
  23202. return this.result()
  23203. }
  23204. }
  23205. });
  23206. // create class for parent effects like merge
  23207. // Inherit from SVG.Parent
  23208. SVG.ParentEffect = SVG.invent({
  23209. create: function(){
  23210. this.constructor.call(this);
  23211. },
  23212. inherit: SVG.Parent,
  23213. extend: {
  23214. // Set in attribute
  23215. in: function(effect) {
  23216. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in')+'"]').get(0) || this.attr('in') : this.attr('in', effect)
  23217. },
  23218. // Named result
  23219. result: function(result) {
  23220. return result == null? this.attr('result') : this.attr('result',result)
  23221. },
  23222. // Stringification
  23223. toString: function() {
  23224. return this.result()
  23225. }
  23226. }
  23227. });
  23228. //chaining
  23229. var chainingEffects = {
  23230. // Blend effect
  23231. blend: function(in2, mode) {
  23232. return this.parent() && this.parent().blend(this, in2, mode) //pass this as the first input
  23233. },
  23234. // ColorMatrix effect
  23235. colorMatrix: function(type, values) {
  23236. return this.parent() && this.parent().colorMatrix(type, values).in(this)
  23237. },
  23238. // ConvolveMatrix effect
  23239. convolveMatrix: function(matrix) {
  23240. return this.parent() && this.parent().convolveMatrix(matrix).in(this)
  23241. },
  23242. // ComponentTransfer effect
  23243. componentTransfer: function(components) {
  23244. return this.parent() && this.parent().componentTransfer(components).in(this)
  23245. },
  23246. // Composite effect
  23247. composite: function(in2, operator) {
  23248. return this.parent() && this.parent().composite(this, in2, operator) //pass this as the first input
  23249. },
  23250. // Flood effect
  23251. flood: function(color, opacity) {
  23252. return this.parent() && this.parent().flood(color, opacity) //this effect dont have inputs
  23253. },
  23254. // Offset effect
  23255. offset: function(x, y) {
  23256. return this.parent() && this.parent().offset(x,y).in(this)
  23257. },
  23258. // Image effect
  23259. image: function(src) {
  23260. return this.parent() && this.parent().image(src) //this effect dont have inputs
  23261. },
  23262. // Merge effect
  23263. merge: function() {
  23264. return this.parent() && this.parent().merge.apply(this.parent(),[this].concat(arguments)) //pass this as the first argument
  23265. },
  23266. // Gaussian Blur effect
  23267. gaussianBlur: function(x,y) {
  23268. return this.parent() && this.parent().gaussianBlur(x,y).in(this)
  23269. },
  23270. // Morphology effect
  23271. morphology: function(operator,radius){
  23272. return this.parent() && this.parent().morphology(operator,radius).in(this)
  23273. },
  23274. // DiffuseLighting effect
  23275. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  23276. return this.parent() && this.parent().diffuseLighting(surfaceScale,diffuseConstant,kernelUnitLength).in(this)
  23277. },
  23278. // DisplacementMap effect
  23279. displacementMap: function(in2,scale,xChannelSelector,yChannelSelector){
  23280. return this.parent() && this.parent().displacementMap(this,in2,scale,xChannelSelector,yChannelSelector) //pass this as the first input
  23281. },
  23282. // SpecularLighting effect
  23283. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  23284. return this.parent() && this.parent().specularLighting(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength).in(this)
  23285. },
  23286. // Tile effect
  23287. tile: function(){
  23288. return this.parent() && this.parent().tile().in(this)
  23289. },
  23290. // Turbulence effect
  23291. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  23292. return this.parent() && this.parent().turbulence(baseFrequency,numOctaves,seed,stitchTiles,type).in(this)
  23293. }
  23294. };
  23295. SVG.extend(SVG.Effect,chainingEffects);
  23296. SVG.extend(SVG.ParentEffect,chainingEffects);
  23297. //crea class for child effects, like MergeNode, FuncR and lights
  23298. SVG.ChildEffect = SVG.invent({
  23299. create: function(){
  23300. this.constructor.call(this);
  23301. },
  23302. inherit: SVG.Element,
  23303. extend: {
  23304. in: function(effect){
  23305. this.attr('in',effect);
  23306. }
  23307. //dont include any "result" functions because these types of nodes dont have them
  23308. }
  23309. });
  23310. // Create all different effects
  23311. var effects = {
  23312. blend: function(in1,in2,mode){
  23313. this.attr({
  23314. in: in1,
  23315. in2: in2,
  23316. mode: mode || 'normal'
  23317. });
  23318. },
  23319. colorMatrix: function(type,values){
  23320. if (type == 'matrix')
  23321. values = normaliseMatrix(values);
  23322. this.attr({
  23323. type: type
  23324. , values: typeof values == 'undefined' ? null : values
  23325. });
  23326. },
  23327. convolveMatrix: function(matrix){
  23328. matrix = normaliseMatrix(matrix);
  23329. this.attr({
  23330. order: Math.sqrt(matrix.split(' ').length)
  23331. , kernelMatrix: matrix
  23332. });
  23333. },
  23334. composite: function(in1, in2, operator){
  23335. this.attr({
  23336. in: in1,
  23337. in2: in2,
  23338. operator: operator
  23339. });
  23340. },
  23341. flood: function(color,opacity){
  23342. this.attr('flood-color',color);
  23343. if(opacity != null) this.attr('flood-opacity',opacity);
  23344. },
  23345. offset: function(x,y){
  23346. this.attr({
  23347. dx: x,
  23348. dy: y
  23349. });
  23350. },
  23351. image: function(src){
  23352. this.attr('href', src, SVG.xlink);
  23353. },
  23354. displacementMap: function(in1,in2,scale,xChannelSelector,yChannelSelector){
  23355. this.attr({
  23356. in: in1,
  23357. in2: in2,
  23358. scale: scale,
  23359. xChannelSelector: xChannelSelector,
  23360. yChannelSelector: yChannelSelector
  23361. });
  23362. },
  23363. gaussianBlur: function(x,y){
  23364. if(x != null || y != null)
  23365. this.attr('stdDeviation', listString(Array.prototype.slice.call(arguments)));
  23366. else
  23367. this.attr('stdDeviation', '0 0');
  23368. },
  23369. morphology: function(operator,radius){
  23370. this.attr({
  23371. operator: operator,
  23372. radius: radius
  23373. });
  23374. },
  23375. tile: function(){
  23376. },
  23377. turbulence: function(baseFrequency,numOctaves,seed,stitchTiles,type){
  23378. this.attr({
  23379. numOctaves: numOctaves,
  23380. seed: seed,
  23381. stitchTiles: stitchTiles,
  23382. baseFrequency: baseFrequency,
  23383. type: type
  23384. });
  23385. }
  23386. };
  23387. // Create all parent effects
  23388. var parentEffects = {
  23389. merge: function(){
  23390. var children;
  23391. //test to see if we have a set
  23392. if(arguments[0] instanceof SVG.Set){
  23393. var that = this;
  23394. arguments[0].each(function(i){
  23395. if(this instanceof SVG.MergeNode)
  23396. that.put(this);
  23397. else if(this instanceof SVG.Effect || this instanceof SVG.ParentEffect)
  23398. that.put(new SVG.MergeNode(this));
  23399. });
  23400. }
  23401. else{
  23402. //if the first argument is an array use it
  23403. if(Array.isArray(arguments[0]))
  23404. children = arguments[0];
  23405. else
  23406. children = arguments;
  23407. for(var i = 0; i < children.length; i++){
  23408. if(children[i] instanceof SVG.MergeNode){
  23409. this.put(children[i]);
  23410. }
  23411. else this.put(new SVG.MergeNode(children[i]));
  23412. }
  23413. }
  23414. },
  23415. componentTransfer: function(compontents){
  23416. /* create rgb set */
  23417. this.rgb = new SVG.Set
  23418. /* create components */
  23419. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  23420. /* create component */
  23421. this[c] = new SVG['Func' + c.toUpperCase()]('identity');
  23422. /* store component in set */
  23423. this.rgb.add(this[c]);
  23424. /* add component node */
  23425. this.node.appendChild(this[c].node);
  23426. }.bind(this)); //lost context in foreach
  23427. /* set components */
  23428. if (compontents) {
  23429. if (compontents.rgb) {
  23430. (['r', 'g', 'b']).forEach(function(c) {
  23431. this[c].attr(compontents.rgb);
  23432. }.bind(this));
  23433. delete compontents.rgb;
  23434. }
  23435. /* set individual components */
  23436. for (var c in compontents)
  23437. this[c].attr(compontents[c]);
  23438. }
  23439. },
  23440. diffuseLighting: function(surfaceScale,diffuseConstant,kernelUnitLength){
  23441. this.attr({
  23442. surfaceScale: surfaceScale,
  23443. diffuseConstant: diffuseConstant,
  23444. kernelUnitLength: kernelUnitLength
  23445. });
  23446. },
  23447. specularLighting: function(surfaceScale,diffuseConstant,specularExponent,kernelUnitLength){
  23448. this.attr({
  23449. surfaceScale: surfaceScale,
  23450. diffuseConstant: diffuseConstant,
  23451. specularExponent: specularExponent,
  23452. kernelUnitLength: kernelUnitLength
  23453. });
  23454. },
  23455. };
  23456. // Create child effects like PointLight and MergeNode
  23457. var childEffects = {
  23458. distantLight: function(azimuth, elevation){
  23459. this.attr({
  23460. azimuth: azimuth,
  23461. elevation: elevation
  23462. });
  23463. },
  23464. pointLight: function(x,y,z){
  23465. this.attr({
  23466. x: x,
  23467. y: y,
  23468. z: z
  23469. });
  23470. },
  23471. spotLight: function(x,y,z,pointsAtX,pointsAtY,pointsAtZ){
  23472. this.attr({
  23473. x: x,
  23474. y: y,
  23475. z: z,
  23476. pointsAtX: pointsAtX,
  23477. pointsAtY: pointsAtY,
  23478. pointsAtZ: pointsAtZ
  23479. });
  23480. },
  23481. mergeNode: function(in1){
  23482. this.attr('in',in1);
  23483. }
  23484. }
  23485. // Create compontent functions
  23486. ;(['r', 'g', 'b', 'a']).forEach(function(c) {
  23487. /* create class */
  23488. childEffects['Func' + c.toUpperCase()] = function(type) {
  23489. this.attr('type',type);
  23490. // take diffent arguments based on the type
  23491. switch(type){
  23492. case 'table':
  23493. this.attr('tableValues',arguments[1]);
  23494. break
  23495. case 'linear':
  23496. this.attr('slope',arguments[1]);
  23497. this.attr('intercept',arguments[2]);
  23498. break
  23499. case 'gamma':
  23500. this.attr('amplitude',arguments[1]);
  23501. this.attr('exponent',arguments[2]);
  23502. this.attr('offset',arguments[2]);
  23503. break
  23504. }
  23505. };
  23506. });
  23507. //create effects
  23508. foreach(effects,function(effect,i){
  23509. /* capitalize name */
  23510. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23511. var proto = {};
  23512. /* create class */
  23513. SVG[name + 'Effect'] = SVG.invent({
  23514. create: function() {
  23515. //call super
  23516. this.constructor.call(this, SVG.create('fe' + name));
  23517. //call constructor for this effect
  23518. effect.apply(this,arguments);
  23519. //set the result
  23520. this.result(this.attr('id') + 'Out');
  23521. },
  23522. inherit: SVG.Effect,
  23523. extend: proto
  23524. });
  23525. });
  23526. //create parent effects
  23527. foreach(parentEffects,function(effect,i){
  23528. /* capitalize name */
  23529. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23530. var proto = {};
  23531. /* create class */
  23532. SVG[name + 'Effect'] = SVG.invent({
  23533. create: function() {
  23534. //call super
  23535. this.constructor.call(this, SVG.create('fe' + name));
  23536. //call constructor for this effect
  23537. effect.apply(this,arguments);
  23538. //set the result
  23539. this.result(this.attr('id') + 'Out');
  23540. },
  23541. inherit: SVG.ParentEffect,
  23542. extend: proto
  23543. });
  23544. });
  23545. //create child effects
  23546. foreach(childEffects,function(effect,i){
  23547. /* capitalize name */
  23548. var name = i.charAt(0).toUpperCase() + i.slice(1);
  23549. var proto = {};
  23550. /* create class */
  23551. SVG[name] = SVG.invent({
  23552. create: function() {
  23553. //call super
  23554. this.constructor.call(this, SVG.create('fe' + name));
  23555. //call constructor for this effect
  23556. effect.apply(this,arguments);
  23557. },
  23558. inherit: SVG.ChildEffect,
  23559. extend: proto
  23560. });
  23561. });
  23562. // Effect-specific extensions
  23563. SVG.extend(SVG.MergeEffect,{
  23564. in: function(effect){
  23565. if(effect instanceof SVG.MergeNode)
  23566. this.add(effect,0);
  23567. else
  23568. this.add(new SVG.MergeNode(effect),0);
  23569. return this
  23570. }
  23571. });
  23572. SVG.extend(SVG.CompositeEffect,SVG.BlendEffect,SVG.DisplacementMapEffect,{
  23573. in2: function(effect){
  23574. return effect == null? this.parent() && this.parent().select('[result="'+this.attr('in2')+'"]').get(0) || this.attr('in2') : this.attr('in2', effect)
  23575. }
  23576. });
  23577. // Presets
  23578. SVG.filter = {
  23579. sepiatone: [ .343, .669, .119, 0, 0
  23580. , .249, .626, .130, 0, 0
  23581. , .172, .334, .111, 0, 0
  23582. , .000, .000, .000, 1, 0 ]
  23583. };
  23584. // Helpers
  23585. function normaliseMatrix(matrix) {
  23586. /* convert possible array value to string */
  23587. if (Array.isArray(matrix))
  23588. matrix = new SVG.Array(matrix);
  23589. /* ensure there are no leading, tailing or double spaces */
  23590. return matrix.toString().replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' ')
  23591. }
  23592. function listString(list) {
  23593. if (!Array.isArray(list))
  23594. return list
  23595. for (var i = 0, l = list.length, s = []; i < l; i++)
  23596. s.push(list[i]);
  23597. return s.join(' ')
  23598. }
  23599. function foreach(){ //loops through mutiple objects
  23600. var fn = function(){};
  23601. if(typeof arguments[arguments.length-1] == 'function'){
  23602. fn = arguments[arguments.length-1];
  23603. Array.prototype.splice.call(arguments,arguments.length-1,1);
  23604. }
  23605. for(var k in arguments){
  23606. for(var i in arguments[k]){
  23607. fn(arguments[k][i],i,arguments[k]);
  23608. }
  23609. }
  23610. }
  23611. }).call(undefined);
  23612. (function() {
  23613. SVG.extend(SVG.PathArray, {
  23614. morph: function(array) {
  23615. var startArr = this.value
  23616. , destArr = this.parse(array);
  23617. var startOffsetM = 0
  23618. , destOffsetM = 0;
  23619. var startOffsetNextM = false
  23620. , destOffsetNextM = false;
  23621. while(true){
  23622. // stop if there is no M anymore
  23623. if(startOffsetM === false && destOffsetM === false) break
  23624. // find the next M in path array
  23625. startOffsetNextM = findNextM(startArr, startOffsetM === false ? false : startOffsetM+1);
  23626. destOffsetNextM = findNextM( destArr, destOffsetM === false ? false : destOffsetM+1);
  23627. // We have to add one M to the startArray
  23628. if(startOffsetM === false){
  23629. var bbox = new SVG.PathArray(result.start).bbox();
  23630. // when the last block had no bounding box we simply take the first M we got
  23631. if(bbox.height == 0 || bbox.width == 0){
  23632. startOffsetM = startArr.push(startArr[0]) - 1;
  23633. }else{
  23634. // we take the middle of the bbox instead when we got one
  23635. startOffsetM = startArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  23636. }
  23637. }
  23638. // We have to add one M to the destArray
  23639. if( destOffsetM === false){
  23640. var bbox = new SVG.PathArray(result.dest).bbox();
  23641. if(bbox.height == 0 || bbox.width == 0){
  23642. destOffsetM = destArr.push(destArr[0]) - 1;
  23643. }else{
  23644. destOffsetM = destArr.push( ['M', bbox.x + bbox.width/2, bbox.y + bbox.height/2 ] ) - 1;
  23645. }
  23646. }
  23647. // handle block from M to next M
  23648. var result = handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM);
  23649. // update the arrays to their new values
  23650. startArr = startArr.slice(0, startOffsetM).concat(result.start, startOffsetNextM === false ? [] : startArr.slice(startOffsetNextM));
  23651. destArr = destArr.slice(0, destOffsetM).concat(result.dest , destOffsetNextM === false ? [] : destArr.slice( destOffsetNextM));
  23652. // update offsets
  23653. startOffsetM = startOffsetNextM === false ? false : startOffsetM + result.start.length;
  23654. destOffsetM = destOffsetNextM === false ? false : destOffsetM + result.dest.length;
  23655. }
  23656. // copy back arrays
  23657. this.value = startArr;
  23658. this.destination = new SVG.PathArray();
  23659. this.destination.value = destArr;
  23660. return this
  23661. }
  23662. });
  23663. // sorry for the long declaration
  23664. // slices out one block (from M to M) and syncronize it so the types and length match
  23665. function handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM, undefined$1){
  23666. // slice out the block we need
  23667. var startArrTemp = startArr.slice(startOffsetM, startOffsetNextM || undefined$1)
  23668. , destArrTemp = destArr.slice( destOffsetM, destOffsetNextM || undefined$1);
  23669. var i = 0
  23670. , posStart = {pos:[0,0], start:[0,0]}
  23671. , posDest = {pos:[0,0], start:[0,0]};
  23672. do{
  23673. // convert shorthand types to long form
  23674. startArrTemp[i] = simplyfy.call(posStart, startArrTemp[i]);
  23675. destArrTemp[i] = simplyfy.call(posDest , destArrTemp[i]);
  23676. // check if both shape types match
  23677. // 2 elliptical arc curve commands ('A'), are considered different if the
  23678. // flags (large-arc-flag, sweep-flag) don't match
  23679. if(startArrTemp[i][0] != destArrTemp[i][0] || startArrTemp[i][0] == 'M' ||
  23680. (startArrTemp[i][0] == 'A' &&
  23681. (startArrTemp[i][4] != destArrTemp[i][4] || startArrTemp[i][5] != destArrTemp[i][5])
  23682. )
  23683. ) {
  23684. // if not, convert shapes to beziere
  23685. Array.prototype.splice.apply(startArrTemp, [i, 1].concat(toBeziere.call(posStart, startArrTemp[i])));
  23686. Array.prototype.splice.apply(destArrTemp, [i, 1].concat(toBeziere.call(posDest, destArrTemp[i])));
  23687. } else {
  23688. // only update positions otherwise
  23689. startArrTemp[i] = setPosAndReflection.call(posStart, startArrTemp[i]);
  23690. destArrTemp[i] = setPosAndReflection.call(posDest , destArrTemp[i]);
  23691. }
  23692. // we are at the end at both arrays. stop here
  23693. if(++i == startArrTemp.length && i == destArrTemp.length) break
  23694. // destArray is longer. Add one element
  23695. if(i == startArrTemp.length){
  23696. startArrTemp.push([
  23697. 'C',
  23698. posStart.pos[0],
  23699. posStart.pos[1],
  23700. posStart.pos[0],
  23701. posStart.pos[1],
  23702. posStart.pos[0],
  23703. posStart.pos[1],
  23704. ]);
  23705. }
  23706. // startArr is longer. Add one element
  23707. if(i == destArrTemp.length){
  23708. destArrTemp.push([
  23709. 'C',
  23710. posDest.pos[0],
  23711. posDest.pos[1],
  23712. posDest.pos[0],
  23713. posDest.pos[1],
  23714. posDest.pos[0],
  23715. posDest.pos[1]
  23716. ]);
  23717. }
  23718. }while(true)
  23719. // return the updated block
  23720. return {start:startArrTemp, dest:destArrTemp}
  23721. }
  23722. // converts shorthand types to long form
  23723. function simplyfy(val){
  23724. switch(val[0]){
  23725. case 'z': // shorthand line to start
  23726. case 'Z':
  23727. val[0] = 'L';
  23728. val[1] = this.start[0];
  23729. val[2] = this.start[1];
  23730. break
  23731. case 'H': // shorthand horizontal line
  23732. val[0] = 'L';
  23733. val[2] = this.pos[1];
  23734. break
  23735. case 'V': // shorthand vertical line
  23736. val[0] = 'L';
  23737. val[2] = val[1];
  23738. val[1] = this.pos[0];
  23739. break
  23740. case 'T': // shorthand quadratic beziere
  23741. val[0] = 'Q';
  23742. val[3] = val[1];
  23743. val[4] = val[2];
  23744. val[1] = this.reflection[1];
  23745. val[2] = this.reflection[0];
  23746. break
  23747. case 'S': // shorthand cubic beziere
  23748. val[0] = 'C';
  23749. val[6] = val[4];
  23750. val[5] = val[3];
  23751. val[4] = val[2];
  23752. val[3] = val[1];
  23753. val[2] = this.reflection[1];
  23754. val[1] = this.reflection[0];
  23755. break
  23756. }
  23757. return val
  23758. }
  23759. // updates reflection point and current position
  23760. function setPosAndReflection(val){
  23761. var len = val.length;
  23762. this.pos = [ val[len-2], val[len-1] ];
  23763. if('SCQT'.indexOf(val[0]) != -1)
  23764. this.reflection = [ 2 * this.pos[0] - val[len-4], 2 * this.pos[1] - val[len-3] ];
  23765. return val
  23766. }
  23767. // converts all types to cubic beziere
  23768. function toBeziere(val){
  23769. var retVal = [val];
  23770. switch(val[0]){
  23771. case 'M': // special handling for M
  23772. this.pos = this.start = [val[1], val[2]];
  23773. return retVal
  23774. case 'L':
  23775. val[5] = val[3] = val[1];
  23776. val[6] = val[4] = val[2];
  23777. val[1] = this.pos[0];
  23778. val[2] = this.pos[1];
  23779. break
  23780. case 'Q':
  23781. val[6] = val[4];
  23782. val[5] = val[3];
  23783. val[4] = val[4] * 1/3 + val[2] * 2/3;
  23784. val[3] = val[3] * 1/3 + val[1] * 2/3;
  23785. val[2] = this.pos[1] * 1/3 + val[2] * 2/3;
  23786. val[1] = this.pos[0] * 1/3 + val[1] * 2/3;
  23787. break
  23788. case 'A':
  23789. retVal = arcToBeziere(this.pos, val);
  23790. val = retVal[0];
  23791. break
  23792. }
  23793. val[0] = 'C';
  23794. this.pos = [val[5], val[6]];
  23795. this.reflection = [2 * val[5] - val[3], 2 * val[6] - val[4]];
  23796. return retVal
  23797. }
  23798. // finds the next position of type M
  23799. function findNextM(arr, offset){
  23800. if(offset === false) return false
  23801. for(var i = offset, len = arr.length;i < len;++i){
  23802. if(arr[i][0] == 'M') return i
  23803. }
  23804. return false
  23805. }
  23806. // Convert an arc segment into equivalent cubic Bezier curves
  23807. // Depending on the arc, up to 4 curves might be used to represent it since a
  23808. // curve gives a good approximation for only a quarter of an ellipse
  23809. // The curves are returned as an array of SVG curve commands:
  23810. // [ ['C', x1, y1, x2, y2, x, y] ... ]
  23811. function arcToBeziere(pos, val) {
  23812. // Parameters extraction, handle out-of-range parameters as specified in the SVG spec
  23813. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcOutOfRangeParameters
  23814. var rx = Math.abs(val[1]), ry = Math.abs(val[2]), xAxisRotation = val[3] % 360
  23815. , largeArcFlag = val[4], sweepFlag = val[5], x = val[6], y = val[7]
  23816. , A = new SVG.Point(pos), B = new SVG.Point(x, y)
  23817. , primedCoord, lambda, mat, k, c, cSquare, t, O, OA, OB, tetaStart, tetaEnd
  23818. , deltaTeta, nbSectors, f, arcSegPoints, angle, sinAngle, cosAngle, pt, i, il
  23819. , retVal = [], x1, y1, x2, y2;
  23820. // Ensure radii are non-zero
  23821. if(rx === 0 || ry === 0 || (A.x === B.x && A.y === B.y)) {
  23822. // treat this arc as a straight line segment
  23823. return [['C', A.x, A.y, B.x, B.y, B.x, B.y]]
  23824. }
  23825. // Ensure radii are large enough using the algorithm provided in the SVG spec
  23826. // See: https://www.w3.org/TR/SVG11/implnote.html#ArcCorrectionOutOfRangeRadii
  23827. primedCoord = new SVG.Point((A.x-B.x)/2, (A.y-B.y)/2).transform(new SVG.Matrix().rotate(xAxisRotation));
  23828. lambda = (primedCoord.x * primedCoord.x) / (rx * rx) + (primedCoord.y * primedCoord.y) / (ry * ry);
  23829. if(lambda > 1) {
  23830. lambda = Math.sqrt(lambda);
  23831. rx = lambda*rx;
  23832. ry = lambda*ry;
  23833. }
  23834. // To simplify calculations, we make the arc part of a unit circle (rayon is 1) instead of an ellipse
  23835. mat = new SVG.Matrix().rotate(xAxisRotation).scale(1/rx, 1/ry).rotate(-xAxisRotation);
  23836. A = A.transform(mat);
  23837. B = B.transform(mat);
  23838. // Calculate the horizontal and vertical distance between the initial and final point of the arc
  23839. k = [B.x-A.x, B.y-A.y];
  23840. // Find the length of the chord formed by A and B
  23841. cSquare = k[0]*k[0] + k[1]*k[1];
  23842. c = Math.sqrt(cSquare);
  23843. // Calculate the ratios of the horizontal and vertical distance on the length of the chord
  23844. k[0] /= c;
  23845. k[1] /= c;
  23846. // Calculate the distance between the circle center and the chord midpoint
  23847. // using this formula: t = sqrt(r^2 - c^2 / 4)
  23848. // where t is the distance between the cirle center and the chord midpoint,
  23849. // r is the rayon of the circle and c is the chord length
  23850. // From: http://www.ajdesigner.com/phpcircle/circle_segment_chord_t.php
  23851. // Because of the imprecision of floating point numbers, cSquare might end
  23852. // up being slightly above 4 which would result in a negative radicand
  23853. // To prevent that, a test is made before computing the square root
  23854. t = (cSquare < 4) ? Math.sqrt(1 - cSquare/4) : 0;
  23855. // For most situations, there are actually two different ellipses that
  23856. // satisfy the constraints imposed by the points A and B, the radii rx and ry,
  23857. // and the xAxisRotation
  23858. // When the flags largeArcFlag and sweepFlag are equal, it means that the
  23859. // second ellipse is used as a solution
  23860. // See: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
  23861. if(largeArcFlag === sweepFlag) {
  23862. t *= -1;
  23863. }
  23864. // Calculate the coordinates of the center of the circle from the midpoint of the chord
  23865. // This is done by multiplying the ratios calculated previously by the distance between
  23866. // the circle center and the chord midpoint and using these values to go from the midpoint
  23867. // to the center of the circle
  23868. // The negative of the vertical distance ratio is used to modify the x coordinate while
  23869. // the horizontal distance ratio is used to modify the y coordinate
  23870. // That is because the center of the circle is perpendicular to the chord and perpendicular
  23871. // lines are negative reciprocals
  23872. O = new SVG.Point((B.x+A.x)/2 + t*-k[1], (B.y+A.y)/2 + t*k[0]);
  23873. // Move the center of the circle at the origin
  23874. OA = new SVG.Point(A.x-O.x, A.y-O.y);
  23875. OB = new SVG.Point(B.x-O.x, B.y-O.y);
  23876. // Calculate the start and end angle
  23877. tetaStart = Math.acos(OA.x/Math.sqrt(OA.x*OA.x + OA.y*OA.y));
  23878. if (OA.y < 0) {
  23879. tetaStart *= -1;
  23880. }
  23881. tetaEnd = Math.acos(OB.x/Math.sqrt(OB.x*OB.x + OB.y*OB.y));
  23882. if (OB.y < 0) {
  23883. tetaEnd *= -1;
  23884. }
  23885. // If sweep-flag is '1', then the arc will be drawn in a "positive-angle" direction,
  23886. // make sure that the end angle is above the start angle
  23887. if (sweepFlag && tetaStart > tetaEnd) {
  23888. tetaEnd += 2*Math.PI;
  23889. }
  23890. // If sweep-flag is '0', then the arc will be drawn in a "negative-angle" direction,
  23891. // make sure that the end angle is below the start angle
  23892. if (!sweepFlag && tetaStart < tetaEnd) {
  23893. tetaEnd -= 2*Math.PI;
  23894. }
  23895. // Find the number of Bezier curves that are required to represent the arc
  23896. // A cubic Bezier curve gives a good enough approximation when representing at most a quarter of a circle
  23897. nbSectors = Math.ceil(Math.abs(tetaStart-tetaEnd) * 2/Math.PI);
  23898. // Calculate the coordinates of the points of all the Bezier curves required to represent the arc
  23899. // For an in-depth explanation of this part see: http://pomax.github.io/bezierinfo/#circles_cubic
  23900. arcSegPoints = [];
  23901. angle = tetaStart;
  23902. deltaTeta = (tetaEnd-tetaStart)/nbSectors;
  23903. f = 4*Math.tan(deltaTeta/4)/3;
  23904. for (i = 0; i <= nbSectors; i++) { // The <= is because a Bezier curve have a start and a endpoint
  23905. cosAngle = Math.cos(angle);
  23906. sinAngle = Math.sin(angle);
  23907. pt = new SVG.Point(O.x+cosAngle, O.y+sinAngle);
  23908. 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)];
  23909. angle += deltaTeta;
  23910. }
  23911. // Remove the first control point of the first segment point and remove the second control point of the last segment point
  23912. // These two control points are not used in the approximation of the arc, that is why they are removed
  23913. arcSegPoints[0][0] = arcSegPoints[0][1].clone();
  23914. arcSegPoints[arcSegPoints.length-1][2] = arcSegPoints[arcSegPoints.length-1][1].clone();
  23915. // Revert the transformation that was applied to make the arc part of a unit circle instead of an ellipse
  23916. mat = new SVG.Matrix().rotate(xAxisRotation).scale(rx, ry).rotate(-xAxisRotation);
  23917. for (i = 0, il = arcSegPoints.length; i < il; i++) {
  23918. arcSegPoints[i][0] = arcSegPoints[i][0].transform(mat);
  23919. arcSegPoints[i][1] = arcSegPoints[i][1].transform(mat);
  23920. arcSegPoints[i][2] = arcSegPoints[i][2].transform(mat);
  23921. }
  23922. // Convert the segments points to SVG curve commands
  23923. for (i = 1, il = arcSegPoints.length; i < il; i++) {
  23924. pt = arcSegPoints[i-1][2];
  23925. x1 = pt.x;
  23926. y1 = pt.y;
  23927. pt = arcSegPoints[i][0];
  23928. x2 = pt.x;
  23929. y2 = pt.y;
  23930. pt = arcSegPoints[i][1];
  23931. x = pt.x;
  23932. y = pt.y;
  23933. retVal.push(['C', x1, y1, x2, y2, x, y]);
  23934. }
  23935. return retVal
  23936. }
  23937. }());
  23938. /*! svg.draggable.js - v2.2.2 - 2019-01-08
  23939. * https://github.com/svgdotjs/svg.draggable.js
  23940. * Copyright (c) 2019 Wout Fierens; Licensed MIT */
  23941. (function() {
  23942. // creates handler, saves it
  23943. function DragHandler(el){
  23944. el.remember('_draggable', this);
  23945. this.el = el;
  23946. }
  23947. // Sets new parameter, starts dragging
  23948. DragHandler.prototype.init = function(constraint, val){
  23949. var _this = this;
  23950. this.constraint = constraint;
  23951. this.value = val;
  23952. this.el.on('mousedown.drag', function(e){ _this.start(e); });
  23953. this.el.on('touchstart.drag', function(e){ _this.start(e); });
  23954. };
  23955. // transforms one point from screen to user coords
  23956. DragHandler.prototype.transformPoint = function(event, offset){
  23957. event = event || window.event;
  23958. var touches = event.changedTouches && event.changedTouches[0] || event;
  23959. this.p.x = touches.clientX - (offset || 0);
  23960. this.p.y = touches.clientY;
  23961. return this.p.matrixTransform(this.m)
  23962. };
  23963. // gets elements bounding box with special handling of groups, nested and use
  23964. DragHandler.prototype.getBBox = function(){
  23965. var box = this.el.bbox();
  23966. if(this.el instanceof SVG.Nested) box = this.el.rbox();
  23967. if (this.el instanceof SVG.G || this.el instanceof SVG.Use || this.el instanceof SVG.Nested) {
  23968. box.x = this.el.x();
  23969. box.y = this.el.y();
  23970. }
  23971. return box
  23972. };
  23973. // start dragging
  23974. DragHandler.prototype.start = function(e){
  23975. // check for left button
  23976. if(e.type == 'click'|| e.type == 'mousedown' || e.type == 'mousemove'){
  23977. if((e.which || e.buttons) != 1){
  23978. return
  23979. }
  23980. }
  23981. var _this = this;
  23982. // fire beforedrag event
  23983. this.el.fire('beforedrag', { event: e, handler: this });
  23984. if(this.el.event().defaultPrevented) return;
  23985. // prevent browser drag behavior as soon as possible
  23986. e.preventDefault();
  23987. // prevent propagation to a parent that might also have dragging enabled
  23988. e.stopPropagation();
  23989. // search for parent on the fly to make sure we can call
  23990. // draggable() even when element is not in the dom currently
  23991. this.parent = this.parent || this.el.parent(SVG.Nested) || this.el.parent(SVG.Doc);
  23992. this.p = this.parent.node.createSVGPoint();
  23993. // save current transformation matrix
  23994. this.m = this.el.node.getScreenCTM().inverse();
  23995. var box = this.getBBox();
  23996. var anchorOffset;
  23997. // fix text-anchor in text-element (#37)
  23998. if(this.el instanceof SVG.Text){
  23999. anchorOffset = this.el.node.getComputedTextLength();
  24000. switch(this.el.attr('text-anchor')){
  24001. case 'middle':
  24002. anchorOffset /= 2;
  24003. break
  24004. case 'start':
  24005. anchorOffset = 0;
  24006. break;
  24007. }
  24008. }
  24009. this.startPoints = {
  24010. // We take absolute coordinates since we are just using a delta here
  24011. point: this.transformPoint(e, anchorOffset),
  24012. box: box,
  24013. transform: this.el.transform()
  24014. };
  24015. // add drag and end events to window
  24016. SVG.on(window, 'mousemove.drag', function(e){ _this.drag(e); });
  24017. SVG.on(window, 'touchmove.drag', function(e){ _this.drag(e); });
  24018. SVG.on(window, 'mouseup.drag', function(e){ _this.end(e); });
  24019. SVG.on(window, 'touchend.drag', function(e){ _this.end(e); });
  24020. // fire dragstart event
  24021. this.el.fire('dragstart', {event: e, p: this.startPoints.point, m: this.m, handler: this});
  24022. };
  24023. // while dragging
  24024. DragHandler.prototype.drag = function(e){
  24025. var box = this.getBBox()
  24026. , p = this.transformPoint(e)
  24027. , x = this.startPoints.box.x + p.x - this.startPoints.point.x
  24028. , y = this.startPoints.box.y + p.y - this.startPoints.point.y
  24029. , c = this.constraint
  24030. , gx = p.x - this.startPoints.point.x
  24031. , gy = p.y - this.startPoints.point.y;
  24032. this.el.fire('dragmove', {
  24033. event: e
  24034. , p: p
  24035. , m: this.m
  24036. , handler: this
  24037. });
  24038. if(this.el.event().defaultPrevented) return p
  24039. // move the element to its new position, if possible by constraint
  24040. if (typeof c == 'function') {
  24041. var coord = c.call(this.el, x, y, this.m);
  24042. // bool, just show us if movement is allowed or not
  24043. if (typeof coord == 'boolean') {
  24044. coord = {
  24045. x: coord,
  24046. y: coord
  24047. };
  24048. }
  24049. // if true, we just move. If !false its a number and we move it there
  24050. if (coord.x === true) {
  24051. this.el.x(x);
  24052. } else if (coord.x !== false) {
  24053. this.el.x(coord.x);
  24054. }
  24055. if (coord.y === true) {
  24056. this.el.y(y);
  24057. } else if (coord.y !== false) {
  24058. this.el.y(coord.y);
  24059. }
  24060. } else if (typeof c == 'object') {
  24061. // keep element within constrained box
  24062. if (c.minX != null && x < c.minX) {
  24063. x = c.minX;
  24064. gx = x - this.startPoints.box.x;
  24065. } else if (c.maxX != null && x > c.maxX - box.width) {
  24066. x = c.maxX - box.width;
  24067. gx = x - this.startPoints.box.x;
  24068. } if (c.minY != null && y < c.minY) {
  24069. y = c.minY;
  24070. gy = y - this.startPoints.box.y;
  24071. } else if (c.maxY != null && y > c.maxY - box.height) {
  24072. y = c.maxY - box.height;
  24073. gy = y - this.startPoints.box.y;
  24074. }
  24075. if (c.snapToGrid != null) {
  24076. x = x - (x % c.snapToGrid);
  24077. y = y - (y % c.snapToGrid);
  24078. gx = gx - (gx % c.snapToGrid);
  24079. gy = gy - (gy % c.snapToGrid);
  24080. }
  24081. if(this.el instanceof SVG.G)
  24082. this.el.matrix(this.startPoints.transform).transform({x:gx, y: gy}, true);
  24083. else
  24084. this.el.move(x, y);
  24085. }
  24086. // so we can use it in the end-method, too
  24087. return p
  24088. };
  24089. DragHandler.prototype.end = function(e){
  24090. // final drag
  24091. var p = this.drag(e);
  24092. // fire dragend event
  24093. this.el.fire('dragend', { event: e, p: p, m: this.m, handler: this });
  24094. // unbind events
  24095. SVG.off(window, 'mousemove.drag');
  24096. SVG.off(window, 'touchmove.drag');
  24097. SVG.off(window, 'mouseup.drag');
  24098. SVG.off(window, 'touchend.drag');
  24099. };
  24100. SVG.extend(SVG.Element, {
  24101. // Make element draggable
  24102. // 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.
  24103. // 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.
  24104. draggable: function(value, constraint) {
  24105. // Check the parameters and reassign if needed
  24106. if (typeof value == 'function' || typeof value == 'object') {
  24107. constraint = value;
  24108. value = true;
  24109. }
  24110. var dragHandler = this.remember('_draggable') || new DragHandler(this);
  24111. // When no parameter is given, value is true
  24112. value = typeof value === 'undefined' ? true : value;
  24113. if(value) dragHandler.init(constraint || {}, value);
  24114. else {
  24115. this.off('mousedown.drag');
  24116. this.off('touchstart.drag');
  24117. }
  24118. return this
  24119. }
  24120. });
  24121. }).call(undefined);
  24122. (function() {
  24123. function SelectHandler(el) {
  24124. this.el = el;
  24125. el.remember('_selectHandler', this);
  24126. this.pointSelection = {isSelected: false};
  24127. this.rectSelection = {isSelected: false};
  24128. // helper list with position settings of each type of point
  24129. this.pointsList = {
  24130. lt: [ 0, 0 ],
  24131. rt: [ 'width', 0 ],
  24132. rb: [ 'width', 'height' ],
  24133. lb: [ 0, 'height' ],
  24134. t: [ 'width', 0 ],
  24135. r: [ 'width', 'height' ],
  24136. b: [ 'width', 'height' ],
  24137. l: [ 0, 'height' ]
  24138. };
  24139. // helper function to get point coordinates based on settings above and an object (bbox in our case)
  24140. this.pointCoord = function (setting, object, isPointCentered) {
  24141. var coord = typeof setting !== 'string' ? setting : object[setting];
  24142. // Top, bottom, right and left points are placed in the center of element width/height
  24143. return isPointCentered ? coord / 2 : coord
  24144. };
  24145. this.pointCoords = function (point, object) {
  24146. var settings = this.pointsList[point];
  24147. return {
  24148. x: this.pointCoord(settings[0], object, (point === 't' || point === 'b')),
  24149. y: this.pointCoord(settings[1], object, (point === 'r' || point === 'l'))
  24150. }
  24151. };
  24152. }
  24153. SelectHandler.prototype.init = function (value, options) {
  24154. var bbox = this.el.bbox();
  24155. this.options = {};
  24156. // store defaults list of points in order to verify users config
  24157. var points = this.el.selectize.defaults.points;
  24158. // Merging the defaults and the options-object together
  24159. for (var i in this.el.selectize.defaults) {
  24160. this.options[i] = this.el.selectize.defaults[i];
  24161. if (options[i] !== undefined) {
  24162. this.options[i] = options[i];
  24163. }
  24164. }
  24165. // prepare & validate list of points to be added (or excluded)
  24166. var pointsLists = ['points', 'pointsExclude'];
  24167. for (var i in pointsLists) {
  24168. var option = this.options[pointsLists[i]];
  24169. if (typeof option === 'string') {
  24170. if (option.length > 0) {
  24171. // if set as comma separated string list => convert it into an array
  24172. option = option.split(/\s*,\s*/i);
  24173. } else {
  24174. option = [];
  24175. }
  24176. } else if (typeof option === 'boolean' && pointsLists[i] === 'points') {
  24177. // this is not needed, but let's have it for legacy support
  24178. option = option ? points : [];
  24179. }
  24180. this.options[pointsLists[i]] = option;
  24181. }
  24182. // intersect correct all points options with users config (exclude unwanted points)
  24183. // ES5 -> NO arrow functions nor Array.includes()
  24184. this.options.points = [ points, this.options.points ].reduce(
  24185. function (a, b) {
  24186. return a.filter(
  24187. function (c) {
  24188. return b.indexOf(c) > -1;
  24189. }
  24190. )
  24191. }
  24192. );
  24193. // exclude pointsExclude, if wanted
  24194. this.options.points = [ this.options.points, this.options.pointsExclude ].reduce(
  24195. function (a, b) {
  24196. return a.filter(
  24197. function (c) {
  24198. return b.indexOf(c) < 0;
  24199. }
  24200. )
  24201. }
  24202. );
  24203. this.parent = this.el.parent();
  24204. this.nested = (this.nested || this.parent.group());
  24205. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  24206. // When deepSelect is enabled and the element is a line/polyline/polygon, draw only points for moving
  24207. if (this.options.deepSelect && ['line', 'polyline', 'polygon'].indexOf(this.el.type) !== -1) {
  24208. this.selectPoints(value);
  24209. } else {
  24210. this.selectRect(value);
  24211. }
  24212. this.observe();
  24213. this.cleanup();
  24214. };
  24215. SelectHandler.prototype.selectPoints = function (value) {
  24216. this.pointSelection.isSelected = value;
  24217. // When set is already there we dont have to create one
  24218. if (this.pointSelection.set) {
  24219. return this;
  24220. }
  24221. // Create our set of elements
  24222. this.pointSelection.set = this.parent.set();
  24223. // draw the points and mark the element as selected
  24224. this.drawPoints();
  24225. return this;
  24226. };
  24227. // create the point-array which contains the 2 points of a line or simply the points-array of polyline/polygon
  24228. SelectHandler.prototype.getPointArray = function () {
  24229. var bbox = this.el.bbox();
  24230. return this.el.array().valueOf().map(function (el) {
  24231. return [el[0] - bbox.x, el[1] - bbox.y];
  24232. });
  24233. };
  24234. // Draws a points
  24235. SelectHandler.prototype.drawPoints = function () {
  24236. var _this = this, array = this.getPointArray();
  24237. // go through the array of points
  24238. for (var i = 0, len = array.length; i < len; ++i) {
  24239. var curriedEvent = (function (k) {
  24240. return function (ev) {
  24241. ev = ev || window.event;
  24242. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  24243. ev.stopPropagation();
  24244. var x = ev.pageX || ev.touches[0].pageX;
  24245. var y = ev.pageY || ev.touches[0].pageY;
  24246. _this.el.fire('point', {x: x, y: y, i: k, event: ev});
  24247. };
  24248. })(i);
  24249. // add every point to the set
  24250. // add css-classes and a touchstart-event which fires our event for moving points
  24251. var point = this.drawPoint(array[i][0], array[i][1])
  24252. .addClass(this.options.classPoints)
  24253. .addClass(this.options.classPoints + '_point')
  24254. .on('touchstart', curriedEvent)
  24255. .on('mousedown', curriedEvent);
  24256. this.pointSelection.set.add(point);
  24257. }
  24258. };
  24259. // The function to draw single point
  24260. SelectHandler.prototype.drawPoint = function (cx, cy) {
  24261. var pointType = this.options.pointType;
  24262. switch (pointType) {
  24263. case 'circle':
  24264. return this.drawCircle(cx, cy);
  24265. case 'rect':
  24266. return this.drawRect(cx, cy);
  24267. default:
  24268. if (typeof pointType === 'function') {
  24269. return pointType.call(this, cx, cy);
  24270. }
  24271. throw new Error('Unknown ' + pointType + ' point type!');
  24272. }
  24273. };
  24274. // The function to draw the circle point
  24275. SelectHandler.prototype.drawCircle = function (cx, cy) {
  24276. return this.nested.circle(this.options.pointSize)
  24277. .center(cx, cy);
  24278. };
  24279. // The function to draw the rect point
  24280. SelectHandler.prototype.drawRect = function (cx, cy) {
  24281. return this.nested.rect(this.options.pointSize, this.options.pointSize)
  24282. .center(cx, cy);
  24283. };
  24284. // every time a point is moved, we have to update the positions of our point
  24285. SelectHandler.prototype.updatePointSelection = function () {
  24286. var array = this.getPointArray();
  24287. this.pointSelection.set.each(function (i) {
  24288. if (this.cx() === array[i][0] && this.cy() === array[i][1]) {
  24289. return;
  24290. }
  24291. this.center(array[i][0], array[i][1]);
  24292. });
  24293. };
  24294. SelectHandler.prototype.updateRectSelection = function () {
  24295. var _this = this, bbox = this.el.bbox();
  24296. this.rectSelection.set.get(0).attr({
  24297. width: bbox.width,
  24298. height: bbox.height
  24299. });
  24300. // set.get(1) is always in the upper left corner. no need to move it
  24301. if (this.options.points.length) {
  24302. this.options.points.map(function (point, index) {
  24303. var coords = _this.pointCoords(point, bbox);
  24304. _this.rectSelection.set.get(index + 1).center(coords.x, coords.y);
  24305. });
  24306. }
  24307. if (this.options.rotationPoint) {
  24308. var length = this.rectSelection.set.length();
  24309. this.rectSelection.set.get(length - 1).center(bbox.width / 2, 20);
  24310. }
  24311. };
  24312. SelectHandler.prototype.selectRect = function (value) {
  24313. var _this = this, bbox = this.el.bbox();
  24314. this.rectSelection.isSelected = value;
  24315. // when set is already p
  24316. this.rectSelection.set = this.rectSelection.set || this.parent.set();
  24317. // helperFunction to create a mouse-down function which triggers the event specified in `eventName`
  24318. function getMoseDownFunc(eventName) {
  24319. return function (ev) {
  24320. ev = ev || window.event;
  24321. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  24322. ev.stopPropagation();
  24323. var x = ev.pageX || ev.touches[0].pageX;
  24324. var y = ev.pageY || ev.touches[0].pageY;
  24325. _this.el.fire(eventName, {x: x, y: y, event: ev});
  24326. };
  24327. }
  24328. // create the selection-rectangle and add the css-class
  24329. if (!this.rectSelection.set.get(0)) {
  24330. this.rectSelection.set.add(this.nested.rect(bbox.width, bbox.height).addClass(this.options.classRect));
  24331. }
  24332. // Draw Points at the edges, if enabled
  24333. if (this.options.points.length && this.rectSelection.set.length() < 2) {
  24334. var ename ="touchstart", mname = "mousedown";
  24335. this.options.points.map(function (point, index) {
  24336. var coords = _this.pointCoords(point, bbox);
  24337. var pointElement = _this.drawPoint(coords.x, coords.y)
  24338. .attr('class', _this.options.classPoints + '_' + point)
  24339. .on(mname, getMoseDownFunc(point))
  24340. .on(ename, getMoseDownFunc(point));
  24341. _this.rectSelection.set.add(pointElement);
  24342. });
  24343. this.rectSelection.set.each(function () {
  24344. this.addClass(_this.options.classPoints);
  24345. });
  24346. }
  24347. // draw rotationPint, if enabled
  24348. if (this.options.rotationPoint && ((this.options.points && !this.rectSelection.set.get(9)) || (!this.options.points && !this.rectSelection.set.get(1)))) {
  24349. var curriedEvent = function (ev) {
  24350. ev = ev || window.event;
  24351. ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
  24352. ev.stopPropagation();
  24353. var x = ev.pageX || ev.touches[0].pageX;
  24354. var y = ev.pageY || ev.touches[0].pageY;
  24355. _this.el.fire('rot', {x: x, y: y, event: ev});
  24356. };
  24357. var pointElement = this.drawPoint(bbox.width / 2, 20)
  24358. .attr('class', this.options.classPoints + '_rot')
  24359. .on("touchstart", curriedEvent)
  24360. .on("mousedown", curriedEvent);
  24361. this.rectSelection.set.add(pointElement);
  24362. }
  24363. };
  24364. SelectHandler.prototype.handler = function () {
  24365. var bbox = this.el.bbox();
  24366. this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y));
  24367. if (this.rectSelection.isSelected) {
  24368. this.updateRectSelection();
  24369. }
  24370. if (this.pointSelection.isSelected) {
  24371. this.updatePointSelection();
  24372. }
  24373. };
  24374. SelectHandler.prototype.observe = function () {
  24375. var _this = this;
  24376. if (MutationObserver) {
  24377. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  24378. this.observerInst = this.observerInst || new MutationObserver(function () {
  24379. _this.handler();
  24380. });
  24381. this.observerInst.observe(this.el.node, {attributes: true});
  24382. } else {
  24383. try {
  24384. this.observerInst.disconnect();
  24385. delete this.observerInst;
  24386. } catch (e) {
  24387. }
  24388. }
  24389. } else {
  24390. this.el.off('DOMAttrModified.select');
  24391. if (this.rectSelection.isSelected || this.pointSelection.isSelected) {
  24392. this.el.on('DOMAttrModified.select', function () {
  24393. _this.handler();
  24394. });
  24395. }
  24396. }
  24397. };
  24398. SelectHandler.prototype.cleanup = function () {
  24399. //var _this = this;
  24400. if (!this.rectSelection.isSelected && this.rectSelection.set) {
  24401. // stop watching the element, remove the selection
  24402. this.rectSelection.set.each(function () {
  24403. this.remove();
  24404. });
  24405. this.rectSelection.set.clear();
  24406. delete this.rectSelection.set;
  24407. }
  24408. if (!this.pointSelection.isSelected && this.pointSelection.set) {
  24409. // Remove all points, clear the set, stop watching the element
  24410. this.pointSelection.set.each(function () {
  24411. this.remove();
  24412. });
  24413. this.pointSelection.set.clear();
  24414. delete this.pointSelection.set;
  24415. }
  24416. if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
  24417. this.nested.remove();
  24418. delete this.nested;
  24419. }
  24420. };
  24421. SVG.extend(SVG.Element, {
  24422. // Select element with mouse
  24423. selectize: function (value, options) {
  24424. // Check the parameters and reassign if needed
  24425. if (typeof value === 'object') {
  24426. options = value;
  24427. value = true;
  24428. }
  24429. var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
  24430. selectHandler.init(value === undefined ? true : value, options || {});
  24431. return this;
  24432. }
  24433. });
  24434. SVG.Element.prototype.selectize.defaults = {
  24435. points: ['lt', 'rt', 'rb', 'lb', 't', 'r', 'b', 'l'], // which points to draw, default all
  24436. pointsExclude: [], // easier option if to exclude few than rewrite all
  24437. classRect: 'svg_select_boundingRect', // Css-class added to the rect
  24438. classPoints: 'svg_select_points', // Css-class added to the points
  24439. pointSize: 7, // size of point
  24440. rotationPoint: true, // If true, rotation point is drawn. Needed for rotation!
  24441. deepSelect: false, // If true, moving of single points is possible (only line, polyline, polyon)
  24442. pointType: 'circle' // Point type: circle or rect, default circle
  24443. };
  24444. }());
  24445. (function() {
  24446. (function () {
  24447. function ResizeHandler(el) {
  24448. el.remember('_resizeHandler', this);
  24449. this.el = el;
  24450. this.parameters = {};
  24451. this.lastUpdateCall = null;
  24452. this.p = el.doc().node.createSVGPoint();
  24453. }
  24454. ResizeHandler.prototype.transformPoint = function(x, y, m){
  24455. this.p.x = x - (this.offset.x - window.pageXOffset);
  24456. this.p.y = y - (this.offset.y - window.pageYOffset);
  24457. return this.p.matrixTransform(m || this.m);
  24458. };
  24459. ResizeHandler.prototype._extractPosition = function(event) {
  24460. // Extract a position from a mouse/touch event.
  24461. // Returns { x: .., y: .. }
  24462. return {
  24463. x: event.clientX != null ? event.clientX : event.touches[0].clientX,
  24464. y: event.clientY != null ? event.clientY : event.touches[0].clientY
  24465. }
  24466. };
  24467. ResizeHandler.prototype.init = function (options) {
  24468. var _this = this;
  24469. this.stop();
  24470. if (options === 'stop') {
  24471. return;
  24472. }
  24473. this.options = {};
  24474. // Merge options and defaults
  24475. for (var i in this.el.resize.defaults) {
  24476. this.options[i] = this.el.resize.defaults[i];
  24477. if (typeof options[i] !== 'undefined') {
  24478. this.options[i] = options[i];
  24479. }
  24480. }
  24481. // We listen to all these events which are specifying different edges
  24482. this.el.on('lt.resize', function(e){ _this.resize(e || window.event); }); // Left-Top
  24483. this.el.on('rt.resize', function(e){ _this.resize(e || window.event); }); // Right-Top
  24484. this.el.on('rb.resize', function(e){ _this.resize(e || window.event); }); // Right-Bottom
  24485. this.el.on('lb.resize', function(e){ _this.resize(e || window.event); }); // Left-Bottom
  24486. this.el.on('t.resize', function(e){ _this.resize(e || window.event); }); // Top
  24487. this.el.on('r.resize', function(e){ _this.resize(e || window.event); }); // Right
  24488. this.el.on('b.resize', function(e){ _this.resize(e || window.event); }); // Bottom
  24489. this.el.on('l.resize', function(e){ _this.resize(e || window.event); }); // Left
  24490. this.el.on('rot.resize', function(e){ _this.resize(e || window.event); }); // Rotation
  24491. this.el.on('point.resize', function(e){ _this.resize(e || window.event); }); // Point-Moving
  24492. // This call ensures, that the plugin reacts to a change of snapToGrid immediately
  24493. this.update();
  24494. };
  24495. ResizeHandler.prototype.stop = function(){
  24496. this.el.off('lt.resize');
  24497. this.el.off('rt.resize');
  24498. this.el.off('rb.resize');
  24499. this.el.off('lb.resize');
  24500. this.el.off('t.resize');
  24501. this.el.off('r.resize');
  24502. this.el.off('b.resize');
  24503. this.el.off('l.resize');
  24504. this.el.off('rot.resize');
  24505. this.el.off('point.resize');
  24506. return this;
  24507. };
  24508. ResizeHandler.prototype.resize = function (event) {
  24509. var _this = this;
  24510. this.m = this.el.node.getScreenCTM().inverse();
  24511. this.offset = { x: window.pageXOffset, y: window.pageYOffset };
  24512. var txPt = this._extractPosition(event.detail.event);
  24513. this.parameters = {
  24514. type: this.el.type, // the type of element
  24515. p: this.transformPoint(txPt.x, txPt.y),
  24516. x: event.detail.x, // x-position of the mouse when resizing started
  24517. y: event.detail.y, // y-position of the mouse when resizing started
  24518. box: this.el.bbox(), // The bounding-box of the element
  24519. rotation: this.el.transform().rotation // The current rotation of the element
  24520. };
  24521. // Add font-size parameter if the element type is text
  24522. if (this.el.type === "text") {
  24523. this.parameters.fontSize = this.el.attr()["font-size"];
  24524. }
  24525. // the i-param in the event holds the index of the point which is moved, when using `deepSelect`
  24526. if (event.detail.i !== undefined) {
  24527. // get the point array
  24528. var array = this.el.array().valueOf();
  24529. // Save the index and the point which is moved
  24530. this.parameters.i = event.detail.i;
  24531. this.parameters.pointCoords = [array[event.detail.i][0], array[event.detail.i][1]];
  24532. }
  24533. // Lets check which edge of the bounding-box was clicked and resize the this.el according to this
  24534. switch (event.type) {
  24535. // Left-Top-Edge
  24536. case 'lt':
  24537. // We build a calculating function for every case which gives us the new position of the this.el
  24538. this.calc = function (diffX, diffY) {
  24539. // The procedure is always the same
  24540. // First we snap the edge to the given grid (snapping to 1px grid is normal resizing)
  24541. var snap = this.snapToGrid(diffX, diffY);
  24542. // Now we check if the new height and width still valid (> 0)
  24543. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  24544. // ...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)
  24545. /*
  24546. * but first check if the element is text box, so we can change the font size instead of
  24547. * the width and height
  24548. */
  24549. if (this.parameters.type === "text") {
  24550. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  24551. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  24552. return;
  24553. }
  24554. snap = this.checkAspectRatio(snap);
  24555. 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]);
  24556. }
  24557. };
  24558. break;
  24559. // Right-Top
  24560. case 'rt':
  24561. // s.a.
  24562. this.calc = function (diffX, diffY) {
  24563. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  24564. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height - snap[1] > 0) {
  24565. if (this.parameters.type === "text") {
  24566. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  24567. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  24568. return;
  24569. }
  24570. snap = this.checkAspectRatio(snap, true);
  24571. 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]);
  24572. }
  24573. };
  24574. break;
  24575. // Right-Bottom
  24576. case 'rb':
  24577. // s.a.
  24578. this.calc = function (diffX, diffY) {
  24579. var snap = this.snapToGrid(diffX, diffY, 0);
  24580. if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  24581. if (this.parameters.type === "text") {
  24582. this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y);
  24583. this.el.attr("font-size", this.parameters.fontSize + snap[0]);
  24584. return;
  24585. }
  24586. snap = this.checkAspectRatio(snap);
  24587. this.el.move(this.parameters.box.x, this.parameters.box.y).size(this.parameters.box.width + snap[0], this.parameters.box.height + snap[1]);
  24588. }
  24589. };
  24590. break;
  24591. // Left-Bottom
  24592. case 'lb':
  24593. // s.a.
  24594. this.calc = function (diffX, diffY) {
  24595. var snap = this.snapToGrid(diffX, diffY, 1);
  24596. if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height + snap[1] > 0) {
  24597. if (this.parameters.type === "text") {
  24598. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y);
  24599. this.el.attr("font-size", this.parameters.fontSize - snap[0]);
  24600. return;
  24601. }
  24602. snap = this.checkAspectRatio(snap, true);
  24603. 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]);
  24604. }
  24605. };
  24606. break;
  24607. // Top
  24608. case 't':
  24609. // s.a.
  24610. this.calc = function (diffX, diffY) {
  24611. var snap = this.snapToGrid(diffX, diffY, 1 << 1);
  24612. if (this.parameters.box.height - snap[1] > 0) {
  24613. // Disable the font-resizing if it is not from the corner of bounding-box
  24614. if (this.parameters.type === "text") {
  24615. return;
  24616. }
  24617. this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).height(this.parameters.box.height - snap[1]);
  24618. }
  24619. };
  24620. break;
  24621. // Right
  24622. case 'r':
  24623. // s.a.
  24624. this.calc = function (diffX, diffY) {
  24625. var snap = this.snapToGrid(diffX, diffY, 0);
  24626. if (this.parameters.box.width + snap[0] > 0) {
  24627. if (this.parameters.type === "text") {
  24628. return;
  24629. }
  24630. this.el.move(this.parameters.box.x, this.parameters.box.y).width(this.parameters.box.width + snap[0]);
  24631. }
  24632. };
  24633. break;
  24634. // Bottom
  24635. case 'b':
  24636. // s.a.
  24637. this.calc = function (diffX, diffY) {
  24638. var snap = this.snapToGrid(diffX, diffY, 0);
  24639. if (this.parameters.box.height + snap[1] > 0) {
  24640. if (this.parameters.type === "text") {
  24641. return;
  24642. }
  24643. this.el.move(this.parameters.box.x, this.parameters.box.y).height(this.parameters.box.height + snap[1]);
  24644. }
  24645. };
  24646. break;
  24647. // Left
  24648. case 'l':
  24649. // s.a.
  24650. this.calc = function (diffX, diffY) {
  24651. var snap = this.snapToGrid(diffX, diffY, 1);
  24652. if (this.parameters.box.width - snap[0] > 0) {
  24653. if (this.parameters.type === "text") {
  24654. return;
  24655. }
  24656. this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).width(this.parameters.box.width - snap[0]);
  24657. }
  24658. };
  24659. break;
  24660. // Rotation
  24661. case 'rot':
  24662. // s.a.
  24663. this.calc = function (diffX, diffY) {
  24664. // yes this is kinda stupid but we need the mouse coords back...
  24665. var current = {x: diffX + this.parameters.p.x, y: diffY + this.parameters.p.y};
  24666. // start minus middle
  24667. 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));
  24668. // end minus middle
  24669. 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));
  24670. var angle = this.parameters.rotation + (pAngle - sAngle) * 180 / Math.PI + this.options.snapToAngle / 2;
  24671. // We have to move the element to the center of the box first and change the rotation afterwards
  24672. // because rotation always works around a rotation-center, which is changed when moving the element
  24673. // We also set the new rotation center to the center of the box.
  24674. 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);
  24675. };
  24676. break;
  24677. // Moving one single Point (needed when an element is deepSelected which means you can move every single point of the object)
  24678. case 'point':
  24679. this.calc = function (diffX, diffY) {
  24680. // Snapping the point to the grid
  24681. var snap = this.snapToGrid(diffX, diffY, this.parameters.pointCoords[0], this.parameters.pointCoords[1]);
  24682. // Get the point array
  24683. var array = this.el.array().valueOf();
  24684. // Changing the moved point in the array
  24685. array[this.parameters.i][0] = this.parameters.pointCoords[0] + snap[0];
  24686. array[this.parameters.i][1] = this.parameters.pointCoords[1] + snap[1];
  24687. // And plot the new this.el
  24688. this.el.plot(array);
  24689. };
  24690. }
  24691. this.el.fire('resizestart', {dx: this.parameters.x, dy: this.parameters.y, event: event});
  24692. // When resizing started, we have to register events for...
  24693. // Touches.
  24694. SVG.on(window, 'touchmove.resize', function(e) {
  24695. _this.update(e || window.event);
  24696. });
  24697. SVG.on(window, 'touchend.resize', function() {
  24698. _this.done();
  24699. });
  24700. // Mouse.
  24701. SVG.on(window, 'mousemove.resize', function (e) {
  24702. _this.update(e || window.event);
  24703. });
  24704. SVG.on(window, 'mouseup.resize', function () {
  24705. _this.done();
  24706. });
  24707. };
  24708. // The update-function redraws the element every time the mouse is moving
  24709. ResizeHandler.prototype.update = function (event) {
  24710. if (!event) {
  24711. if (this.lastUpdateCall) {
  24712. this.calc(this.lastUpdateCall[0], this.lastUpdateCall[1]);
  24713. }
  24714. return;
  24715. }
  24716. // Calculate the difference between the mouseposition at start and now
  24717. var txPt = this._extractPosition(event);
  24718. var p = this.transformPoint(txPt.x, txPt.y);
  24719. var diffX = p.x - this.parameters.p.x,
  24720. diffY = p.y - this.parameters.p.y;
  24721. this.lastUpdateCall = [diffX, diffY];
  24722. // Calculate the new position and height / width of the element
  24723. this.calc(diffX, diffY);
  24724. // Emit an event to say we have changed.
  24725. this.el.fire('resizing', {dx: diffX, dy: diffY, event: event});
  24726. };
  24727. // Is called on mouseup.
  24728. // Removes the update-function from the mousemove event
  24729. ResizeHandler.prototype.done = function () {
  24730. this.lastUpdateCall = null;
  24731. SVG.off(window, 'mousemove.resize');
  24732. SVG.off(window, 'mouseup.resize');
  24733. SVG.off(window, 'touchmove.resize');
  24734. SVG.off(window, 'touchend.resize');
  24735. this.el.fire('resizedone');
  24736. };
  24737. // The flag is used to determine whether the resizing is used with a left-Point (first bit) and top-point (second bit)
  24738. // In this cases the temp-values are calculated differently
  24739. ResizeHandler.prototype.snapToGrid = function (diffX, diffY, flag, pointCoordsY) {
  24740. var temp;
  24741. // If `pointCoordsY` is given, a single Point has to be snapped (deepSelect). That's why we need a different temp-value
  24742. if (typeof pointCoordsY !== 'undefined') {
  24743. // Note that flag = pointCoordsX in this case
  24744. temp = [(flag + diffX) % this.options.snapToGrid, (pointCoordsY + diffY) % this.options.snapToGrid];
  24745. } else {
  24746. // We check if the flag is set and if not we set a default-value (both bits set - which means upper-left-edge)
  24747. flag = flag == null ? 1 | 1 << 1 : flag;
  24748. 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];
  24749. }
  24750. if(diffX < 0) {
  24751. temp[0] -= this.options.snapToGrid;
  24752. }
  24753. if(diffY < 0) {
  24754. temp[1] -= this.options.snapToGrid;
  24755. }
  24756. diffX -= (Math.abs(temp[0]) < this.options.snapToGrid / 2 ?
  24757. temp[0] :
  24758. temp[0] - (diffX < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  24759. diffY -= (Math.abs(temp[1]) < this.options.snapToGrid / 2 ?
  24760. temp[1] :
  24761. temp[1] - (diffY < 0 ? -this.options.snapToGrid : this.options.snapToGrid));
  24762. return this.constraintToBox(diffX, diffY, flag, pointCoordsY);
  24763. };
  24764. // keep element within constrained box
  24765. ResizeHandler.prototype.constraintToBox = function (diffX, diffY, flag, pointCoordsY) {
  24766. //return [diffX, diffY]
  24767. var c = this.options.constraint || {};
  24768. var orgX, orgY;
  24769. if (typeof pointCoordsY !== 'undefined') {
  24770. orgX = flag;
  24771. orgY = pointCoordsY;
  24772. } else {
  24773. orgX = this.parameters.box.x + (flag & 1 ? 0 : this.parameters.box.width);
  24774. orgY = this.parameters.box.y + (flag & (1<<1) ? 0 : this.parameters.box.height);
  24775. }
  24776. if (typeof c.minX !== 'undefined' && orgX + diffX < c.minX) {
  24777. diffX = c.minX - orgX;
  24778. }
  24779. if (typeof c.maxX !== 'undefined' && orgX + diffX > c.maxX) {
  24780. diffX = c.maxX - orgX;
  24781. }
  24782. if (typeof c.minY !== 'undefined' && orgY + diffY < c.minY) {
  24783. diffY = c.minY - orgY;
  24784. }
  24785. if (typeof c.maxY !== 'undefined' && orgY + diffY > c.maxY) {
  24786. diffY = c.maxY - orgY;
  24787. }
  24788. return [diffX, diffY];
  24789. };
  24790. ResizeHandler.prototype.checkAspectRatio = function (snap, isReverse) {
  24791. if (!this.options.saveAspectRatio) {
  24792. return snap;
  24793. }
  24794. var updatedSnap = snap.slice();
  24795. var aspectRatio = this.parameters.box.width / this.parameters.box.height;
  24796. var newW = this.parameters.box.width + snap[0];
  24797. var newH = this.parameters.box.height - snap[1];
  24798. var newAspectRatio = newW / newH;
  24799. if (newAspectRatio < aspectRatio) {
  24800. // Height is too big. Adapt it
  24801. updatedSnap[1] = newW / aspectRatio - this.parameters.box.height;
  24802. isReverse && (updatedSnap[1] = -updatedSnap[1]);
  24803. } else if (newAspectRatio > aspectRatio) {
  24804. // Width is too big. Adapt it
  24805. updatedSnap[0] = this.parameters.box.width - newH * aspectRatio;
  24806. isReverse && (updatedSnap[0] = -updatedSnap[0]);
  24807. }
  24808. return updatedSnap;
  24809. };
  24810. SVG.extend(SVG.Element, {
  24811. // Resize element with mouse
  24812. resize: function (options) {
  24813. (this.remember('_resizeHandler') || new ResizeHandler(this)).init(options || {});
  24814. return this;
  24815. }
  24816. });
  24817. SVG.Element.prototype.resize.defaults = {
  24818. snapToAngle: 0.1, // Specifies the speed the rotation is happening when moving the mouse
  24819. snapToGrid: 1, // Snaps to a grid of `snapToGrid` Pixels
  24820. constraint: {}, // keep element within constrained box
  24821. saveAspectRatio: false // Save aspect ratio when resizing using lt, rt, rb or lb points
  24822. };
  24823. }).call(this);
  24824. }());
  24825. function styleInject(css, ref) {
  24826. if ( ref === void 0 ) ref = {};
  24827. var insertAt = ref.insertAt;
  24828. if (!css || typeof document === 'undefined') { return; }
  24829. var head = document.head || document.getElementsByTagName('head')[0];
  24830. var style = document.createElement('style');
  24831. style.type = 'text/css';
  24832. if (insertAt === 'top') {
  24833. if (head.firstChild) {
  24834. head.insertBefore(style, head.firstChild);
  24835. } else {
  24836. head.appendChild(style);
  24837. }
  24838. } else {
  24839. head.appendChild(style);
  24840. }
  24841. if (style.styleSheet) {
  24842. style.styleSheet.cssText = css;
  24843. } else {
  24844. style.appendChild(document.createTextNode(css));
  24845. }
  24846. }
  24847. var css = ".apexcharts-canvas {\n position: relative;\n user-select: none;\n /* cannot give overflow: hidden as it will crop tooltips which overflow outside chart area */\n}\n\n\n/* scrollbar is not visible by default for legend, hence forcing the visibility */\n.apexcharts-canvas ::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 6px;\n}\n\n.apexcharts-canvas ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0, 0, 0, .5);\n box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);\n}\n\n.apexcharts-canvas.apexcharts-theme-dark {\n background: #424242;\n}\n\n.apexcharts-inner {\n position: relative;\n}\n\n.apexcharts-text tspan {\n font-family: inherit;\n}\n\n.legend-mouseover-inactive {\n transition: 0.15s ease all;\n opacity: 0.20;\n}\n\n.apexcharts-series-collapsed {\n opacity: 0;\n}\n\n.apexcharts-tooltip {\n border-radius: 5px;\n box-shadow: 2px 2px 6px -4px #999;\n cursor: default;\n font-size: 14px;\n left: 62px;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n top: 20px;\n overflow: hidden;\n white-space: nowrap;\n z-index: 12;\n transition: 0.15s ease all;\n}\n\n.apexcharts-tooltip.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-tooltip.apexcharts-theme-light {\n border: 1px solid #e3e3e3;\n background: rgba(255, 255, 255, 0.96);\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark {\n color: #fff;\n background: rgba(30, 30, 30, 0.8);\n}\n\n.apexcharts-tooltip * {\n font-family: inherit;\n}\n\n\n.apexcharts-tooltip-title {\n padding: 6px;\n font-size: 15px;\n margin-bottom: 4px;\n}\n\n.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title {\n background: #ECEFF1;\n border-bottom: 1px solid #ddd;\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title {\n background: rgba(0, 0, 0, 0.7);\n border-bottom: 1px solid #333;\n}\n\n.apexcharts-tooltip-text-value,\n.apexcharts-tooltip-text-z-value {\n display: inline-block;\n font-weight: 600;\n margin-left: 5px;\n}\n\n.apexcharts-tooltip-text-z-label:empty,\n.apexcharts-tooltip-text-z-value:empty {\n display: none;\n}\n\n.apexcharts-tooltip-text-value,\n.apexcharts-tooltip-text-z-value {\n font-weight: 600;\n}\n\n.apexcharts-tooltip-marker {\n width: 12px;\n height: 12px;\n position: relative;\n top: 0px;\n margin-right: 10px;\n border-radius: 50%;\n}\n\n.apexcharts-tooltip-series-group {\n padding: 0 10px;\n display: none;\n text-align: left;\n justify-content: left;\n align-items: center;\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active .apexcharts-tooltip-marker {\n opacity: 1;\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active,\n.apexcharts-tooltip-series-group:last-child {\n padding-bottom: 4px;\n}\n\n.apexcharts-tooltip-series-group-hidden {\n opacity: 0;\n height: 0;\n line-height: 0;\n padding: 0 !important;\n}\n\n.apexcharts-tooltip-y-group {\n padding: 6px 0 5px;\n}\n\n.apexcharts-tooltip-candlestick {\n padding: 4px 8px;\n}\n\n.apexcharts-tooltip-candlestick>div {\n margin: 4px 0;\n}\n\n.apexcharts-tooltip-candlestick span.value {\n font-weight: bold;\n}\n\n.apexcharts-tooltip-rangebar {\n padding: 5px 8px;\n}\n\n.apexcharts-tooltip-rangebar .category {\n font-weight: 600;\n color: #777;\n}\n\n.apexcharts-tooltip-rangebar .series-name {\n font-weight: bold;\n display: block;\n margin-bottom: 5px;\n}\n\n.apexcharts-xaxistooltip {\n opacity: 0;\n padding: 9px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #ECEFF1;\n border: 1px solid #90A4AE;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xaxistooltip.apexcharts-theme-dark {\n background: rgba(0, 0, 0, 0.7);\n border: 1px solid rgba(0, 0, 0, 0.5);\n color: #fff;\n}\n\n.apexcharts-xaxistooltip:after,\n.apexcharts-xaxistooltip:before {\n left: 50%;\n border: solid transparent;\n content: \" \";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n}\n\n.apexcharts-xaxistooltip:after {\n border-color: rgba(236, 239, 241, 0);\n border-width: 6px;\n margin-left: -6px;\n}\n\n.apexcharts-xaxistooltip:before {\n border-color: rgba(144, 164, 174, 0);\n border-width: 7px;\n margin-left: -7px;\n}\n\n.apexcharts-xaxistooltip-bottom:after,\n.apexcharts-xaxistooltip-bottom:before {\n bottom: 100%;\n}\n\n.apexcharts-xaxistooltip-top:after,\n.apexcharts-xaxistooltip-top:before {\n top: 100%;\n}\n\n.apexcharts-xaxistooltip-bottom:after {\n border-bottom-color: #ECEFF1;\n}\n\n.apexcharts-xaxistooltip-bottom:before {\n border-bottom-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:after {\n border-bottom-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:before {\n border-bottom-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-top:after {\n border-top-color: #ECEFF1\n}\n\n.apexcharts-xaxistooltip-top:before {\n border-top-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:after {\n border-top-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:before {\n border-top-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-xaxistooltip.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-yaxistooltip {\n opacity: 0;\n padding: 4px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #ECEFF1;\n border: 1px solid #90A4AE;\n}\n\n.apexcharts-yaxistooltip.apexcharts-theme-dark {\n background: rgba(0, 0, 0, 0.7);\n border: 1px solid rgba(0, 0, 0, 0.5);\n color: #fff;\n}\n\n.apexcharts-yaxistooltip:after,\n.apexcharts-yaxistooltip:before {\n top: 50%;\n border: solid transparent;\n content: \" \";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n}\n\n.apexcharts-yaxistooltip:after {\n border-color: rgba(236, 239, 241, 0);\n border-width: 6px;\n margin-top: -6px;\n}\n\n.apexcharts-yaxistooltip:before {\n border-color: rgba(144, 164, 174, 0);\n border-width: 7px;\n margin-top: -7px;\n}\n\n.apexcharts-yaxistooltip-left:after,\n.apexcharts-yaxistooltip-left:before {\n left: 100%;\n}\n\n.apexcharts-yaxistooltip-right:after,\n.apexcharts-yaxistooltip-right:before {\n right: 100%;\n}\n\n.apexcharts-yaxistooltip-left:after {\n border-left-color: #ECEFF1;\n}\n\n.apexcharts-yaxistooltip-left:before {\n border-left-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:after {\n border-left-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:before {\n border-left-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-right:after {\n border-right-color: #ECEFF1;\n}\n\n.apexcharts-yaxistooltip-right:before {\n border-right-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:after {\n border-right-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:before {\n border-right-color: rgba(0, 0, 0, 0.5);\n}\n\n.apexcharts-yaxistooltip.apexcharts-active {\n opacity: 1;\n}\n\n.apexcharts-yaxistooltip-hidden {\n display: none;\n}\n\n.apexcharts-xcrosshairs,\n.apexcharts-ycrosshairs {\n pointer-events: none;\n opacity: 0;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xcrosshairs.apexcharts-active,\n.apexcharts-ycrosshairs.apexcharts-active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-ycrosshairs-hidden {\n opacity: 0;\n}\n\n.apexcharts-selection-rect {\n cursor: move;\n}\n\n.svg_select_boundingRect, .svg_select_points_rot {\n pointer-events: none;\n opacity: 0;\n visibility: hidden;\n}\n.apexcharts-selection-rect + g .svg_select_boundingRect,\n.apexcharts-selection-rect + g .svg_select_points_rot {\n opacity: 0;\n visibility: hidden;\n}\n\n.apexcharts-selection-rect + g .svg_select_points_l,\n.apexcharts-selection-rect + g .svg_select_points_r {\n cursor: ew-resize;\n opacity: 1;\n visibility: visible;\n}\n\n.svg_select_points {\n fill: #efefef;\n stroke: #333;\n rx: 2;\n}\n\n.apexcharts-canvas.apexcharts-zoomable .hovering-zoom {\n cursor: crosshair\n}\n\n.apexcharts-canvas.apexcharts-zoomable .hovering-pan {\n cursor: move\n}\n\n.apexcharts-zoom-icon,\n.apexcharts-zoomin-icon,\n.apexcharts-zoomout-icon,\n.apexcharts-reset-icon,\n.apexcharts-pan-icon,\n.apexcharts-selection-icon,\n.apexcharts-menu-icon,\n.apexcharts-toolbar-custom-icon {\n cursor: pointer;\n width: 20px;\n height: 20px;\n line-height: 24px;\n color: #6E8192;\n text-align: center;\n}\n\n.apexcharts-zoom-icon svg,\n.apexcharts-zoomin-icon svg,\n.apexcharts-zoomout-icon svg,\n.apexcharts-reset-icon svg,\n.apexcharts-menu-icon svg {\n fill: #6E8192;\n}\n\n.apexcharts-selection-icon svg {\n fill: #444;\n transform: scale(0.76)\n}\n\n.apexcharts-theme-dark .apexcharts-zoom-icon svg,\n.apexcharts-theme-dark .apexcharts-zoomin-icon svg,\n.apexcharts-theme-dark .apexcharts-zoomout-icon svg,\n.apexcharts-theme-dark .apexcharts-reset-icon svg,\n.apexcharts-theme-dark .apexcharts-pan-icon svg,\n.apexcharts-theme-dark .apexcharts-selection-icon svg,\n.apexcharts-theme-dark .apexcharts-menu-icon svg,\n.apexcharts-theme-dark .apexcharts-toolbar-custom-icon svg {\n fill: #f3f4f5;\n}\n\n.apexcharts-canvas .apexcharts-zoom-icon.apexcharts-selected svg,\n.apexcharts-canvas .apexcharts-selection-icon.apexcharts-selected svg,\n.apexcharts-canvas .apexcharts-reset-zoom-icon.apexcharts-selected svg {\n fill: #008FFB;\n}\n\n.apexcharts-theme-light .apexcharts-selection-icon:not(.apexcharts-selected):hover svg,\n.apexcharts-theme-light .apexcharts-zoom-icon:not(.apexcharts-selected):hover svg,\n.apexcharts-theme-light .apexcharts-zoomin-icon:hover svg,\n.apexcharts-theme-light .apexcharts-zoomout-icon:hover svg,\n.apexcharts-theme-light .apexcharts-reset-icon:hover svg,\n.apexcharts-theme-light .apexcharts-menu-icon:hover svg {\n fill: #333;\n}\n\n.apexcharts-selection-icon,\n.apexcharts-menu-icon {\n position: relative;\n}\n\n.apexcharts-reset-icon {\n margin-left: 5px;\n}\n\n.apexcharts-zoom-icon,\n.apexcharts-reset-icon,\n.apexcharts-menu-icon {\n transform: scale(0.85);\n}\n\n.apexcharts-zoomin-icon,\n.apexcharts-zoomout-icon {\n transform: scale(0.7)\n}\n\n.apexcharts-zoomout-icon {\n margin-right: 3px;\n}\n\n.apexcharts-pan-icon {\n transform: scale(0.62);\n position: relative;\n left: 1px;\n top: 0px;\n}\n\n.apexcharts-pan-icon svg {\n fill: #fff;\n stroke: #6E8192;\n stroke-width: 2;\n}\n\n.apexcharts-pan-icon.apexcharts-selected svg {\n stroke: #008FFB;\n}\n\n.apexcharts-pan-icon:not(.apexcharts-selected):hover svg {\n stroke: #333;\n}\n\n.apexcharts-toolbar {\n position: absolute;\n z-index: 11;\n max-width: 176px;\n text-align: right;\n border-radius: 3px;\n padding: 0px 6px 2px 6px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.apexcharts-menu {\n background: #fff;\n position: absolute;\n top: 100%;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 3px;\n right: 10px;\n opacity: 0;\n min-width: 110px;\n transition: 0.15s ease all;\n pointer-events: none;\n}\n\n.apexcharts-menu.apexcharts-menu-open {\n opacity: 1;\n pointer-events: all;\n transition: 0.15s ease all;\n}\n\n.apexcharts-menu-item {\n padding: 6px 7px;\n font-size: 12px;\n cursor: pointer;\n}\n\n.apexcharts-theme-light .apexcharts-menu-item:hover {\n background: #eee;\n}\n\n.apexcharts-theme-dark .apexcharts-menu {\n background: rgba(0, 0, 0, 0.7);\n color: #fff;\n}\n\n@media screen and (min-width: 768px) {\n .apexcharts-canvas:hover .apexcharts-toolbar {\n opacity: 1;\n }\n}\n\n.apexcharts-datalabel.apexcharts-element-hidden {\n opacity: 0;\n}\n\n.apexcharts-pie-label,\n.apexcharts-datalabels,\n.apexcharts-datalabel,\n.apexcharts-datalabel-label,\n.apexcharts-datalabel-value {\n cursor: default;\n pointer-events: none;\n}\n\n.apexcharts-pie-label-delay {\n opacity: 0;\n animation-name: opaque;\n animation-duration: 0.3s;\n animation-fill-mode: forwards;\n animation-timing-function: ease;\n}\n\n.apexcharts-canvas .apexcharts-element-hidden {\n opacity: 0;\n}\n\n.apexcharts-hide .apexcharts-series-points {\n opacity: 0;\n}\n\n.apexcharts-gridline,\n.apexcharts-annotation-rect,\n.apexcharts-tooltip .apexcharts-marker,\n.apexcharts-area-series .apexcharts-area,\n.apexcharts-line,\n.apexcharts-zoom-rect,\n.apexcharts-toolbar svg,\n.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\n.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\n.apexcharts-radar-series path,\n.apexcharts-radar-series polygon {\n pointer-events: none;\n}\n\n\n/* markers */\n\n.apexcharts-marker {\n transition: 0.15s ease all;\n}\n\n@keyframes opaque {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n\n\n/* Resize generated styles */\n\n@keyframes resizeanim {\n from {\n opacity: 0;\n }\n to {\n opacity: 0;\n }\n}\n\n.resize-triggers {\n animation: 1ms resizeanim;\n visibility: hidden;\n opacity: 0;\n}\n\n.resize-triggers,\n.resize-triggers>div,\n.contract-trigger:before {\n content: \" \";\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n overflow: hidden;\n}\n\n.resize-triggers>div {\n background: #eee;\n overflow: auto;\n}\n\n.contract-trigger:before {\n width: 200%;\n height: 200%;\n}";
  24848. styleInject(css);
  24849. /**
  24850. * Detect Element Resize
  24851. *
  24852. * https://github.com/sdecima/javascript-detect-element-resize
  24853. * Sebastian Decima
  24854. *
  24855. * version: 0.5.3
  24856. **/
  24857. (function () {
  24858. function resetTriggers(element) {
  24859. var triggers = element.__resizeTriggers__,
  24860. expand = triggers.firstElementChild,
  24861. contract = triggers.lastElementChild,
  24862. expandChild = expand ? expand.firstElementChild : null;
  24863. if (contract) {
  24864. contract.scrollLeft = contract.scrollWidth;
  24865. contract.scrollTop = contract.scrollHeight;
  24866. }
  24867. if (expandChild) {
  24868. expandChild.style.width = expand.offsetWidth + 1 + 'px';
  24869. expandChild.style.height = expand.offsetHeight + 1 + 'px';
  24870. }
  24871. if (expand) {
  24872. expand.scrollLeft = expand.scrollWidth;
  24873. expand.scrollTop = expand.scrollHeight;
  24874. }
  24875. }
  24876. function checkTriggers(element) {
  24877. return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
  24878. }
  24879. function scrollListener(e) {
  24880. var element = this;
  24881. resetTriggers(this);
  24882. if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__);
  24883. this.__resizeRAF__ = requestFrame(function () {
  24884. if (checkTriggers(element)) {
  24885. element.__resizeLast__.width = element.offsetWidth;
  24886. element.__resizeLast__.height = element.offsetHeight;
  24887. element.__resizeListeners__.forEach(function (fn) {
  24888. fn.call(e);
  24889. });
  24890. }
  24891. });
  24892. }
  24893. var requestFrame = function () {
  24894. var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
  24895. return window.setTimeout(fn, 20);
  24896. };
  24897. return function (fn) {
  24898. return raf(fn);
  24899. };
  24900. }();
  24901. var cancelFrame = function () {
  24902. var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.clearTimeout;
  24903. return function (id) {
  24904. return cancel(id);
  24905. };
  24906. }();
  24907. /* Detect CSS Animations support to detect element display/re-attach */
  24908. var animation = false,
  24909. animationstartevent = 'animationstart',
  24910. domPrefixes = 'Webkit Moz O ms'.split(' '),
  24911. startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' ');
  24912. {
  24913. var elm = document.createElement('fakeelement');
  24914. if (elm.style.animationName !== undefined) {
  24915. animation = true;
  24916. }
  24917. if (animation === false) {
  24918. for (var i = 0; i < domPrefixes.length; i++) {
  24919. if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
  24920. animationstartevent = startEvents[i];
  24921. break;
  24922. }
  24923. }
  24924. }
  24925. }
  24926. var animationName = 'resizeanim';
  24927. window.addResizeListener = function (element, fn) {
  24928. if (!element.__resizeTriggers__) {
  24929. if (getComputedStyle(element).position == 'static') element.style.position = 'relative';
  24930. element.__resizeLast__ = {};
  24931. element.__resizeListeners__ = [];
  24932. (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
  24933. element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + '<div class="contract-trigger"></div>';
  24934. element.appendChild(element.__resizeTriggers__);
  24935. resetTriggers(element);
  24936. element.addEventListener('scroll', scrollListener, true);
  24937. /* Listen for a css animation to detect element display/re-attach */
  24938. animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
  24939. if (e.animationName == animationName) {
  24940. resetTriggers(element);
  24941. }
  24942. });
  24943. }
  24944. element.__resizeListeners__.push(fn);
  24945. };
  24946. window.removeResizeListener = function (element, fn) {
  24947. if (element) {
  24948. element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
  24949. if (!element.__resizeListeners__.length) {
  24950. element.removeEventListener('scroll', scrollListener);
  24951. if (element.__resizeTriggers__.parentNode) {
  24952. element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
  24953. }
  24954. }
  24955. }
  24956. };
  24957. })();
  24958. window.Apex = {};
  24959. var InitCtxVariables = /*#__PURE__*/function () {
  24960. function InitCtxVariables(ctx) {
  24961. _classCallCheck(this, InitCtxVariables);
  24962. this.ctx = ctx;
  24963. this.w = ctx.w;
  24964. }
  24965. _createClass(InitCtxVariables, [{
  24966. key: "initModules",
  24967. value: function initModules() {
  24968. this.ctx.publicMethods = ['updateOptions', 'updateSeries', 'appendData', 'appendSeries', 'toggleSeries', 'showSeries', 'hideSeries', 'setLocale', 'resetSeries', 'zoomX', 'toggleDataPointSelection', 'dataURI', 'addXaxisAnnotation', 'addYaxisAnnotation', 'addPointAnnotation', 'clearAnnotations', 'removeAnnotation', 'paper', 'destroy'];
  24969. this.ctx.eventList = ['click', 'mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend'];
  24970. this.ctx.animations = new Animations(this.ctx);
  24971. this.ctx.axes = new Axes(this.ctx);
  24972. this.ctx.core = new Core(this.ctx.el, this.ctx);
  24973. this.ctx.config = new Config({});
  24974. this.ctx.data = new Data(this.ctx);
  24975. this.ctx.grid = new Grid(this.ctx);
  24976. this.ctx.graphics = new Graphics(this.ctx);
  24977. this.ctx.coreUtils = new CoreUtils(this.ctx);
  24978. this.ctx.crosshairs = new Crosshairs(this.ctx);
  24979. this.ctx.events = new Events(this.ctx);
  24980. this.ctx.exports = new Exports(this.ctx);
  24981. this.ctx.localization = new Localization(this.ctx);
  24982. this.ctx.options = new Options();
  24983. this.ctx.responsive = new Responsive(this.ctx);
  24984. this.ctx.series = new Series(this.ctx);
  24985. this.ctx.theme = new Theme(this.ctx);
  24986. this.ctx.formatters = new Formatters(this.ctx);
  24987. this.ctx.titleSubtitle = new TitleSubtitle(this.ctx);
  24988. this.ctx.legend = new Legend(this.ctx);
  24989. this.ctx.toolbar = new Toolbar(this.ctx);
  24990. this.ctx.dimensions = new Dimensions(this.ctx);
  24991. this.ctx.updateHelpers = new UpdateHelpers(this.ctx);
  24992. this.ctx.zoomPanSelection = new ZoomPanSelection(this.ctx);
  24993. this.ctx.w.globals.tooltip = new Tooltip(this.ctx);
  24994. }
  24995. }]);
  24996. return InitCtxVariables;
  24997. }();
  24998. var Destroy = /*#__PURE__*/function () {
  24999. function Destroy(ctx) {
  25000. _classCallCheck(this, Destroy);
  25001. this.ctx = ctx;
  25002. this.w = ctx.w;
  25003. }
  25004. _createClass(Destroy, [{
  25005. key: "clear",
  25006. value: function clear() {
  25007. if (this.ctx.zoomPanSelection) {
  25008. this.ctx.zoomPanSelection.destroy();
  25009. }
  25010. if (this.ctx.toolbar) {
  25011. this.ctx.toolbar.destroy();
  25012. }
  25013. this.ctx.animations = null;
  25014. this.ctx.axes = null;
  25015. this.ctx.annotations = null;
  25016. this.ctx.core = null;
  25017. this.ctx.data = null;
  25018. this.ctx.grid = null;
  25019. this.ctx.series = null;
  25020. this.ctx.responsive = null;
  25021. this.ctx.theme = null;
  25022. this.ctx.formatters = null;
  25023. this.ctx.titleSubtitle = null;
  25024. this.ctx.legend = null;
  25025. this.ctx.dimensions = null;
  25026. this.ctx.options = null;
  25027. this.ctx.crosshairs = null;
  25028. this.ctx.zoomPanSelection = null;
  25029. this.ctx.updateHelpers = null;
  25030. this.ctx.toolbar = null;
  25031. this.ctx.localization = null;
  25032. this.ctx.w.globals.tooltip = null;
  25033. this.clearDomElements();
  25034. }
  25035. }, {
  25036. key: "killSVG",
  25037. value: function killSVG(draw) {
  25038. draw.each(function (i, children) {
  25039. this.removeClass('*');
  25040. this.off();
  25041. this.stop();
  25042. }, true);
  25043. draw.ungroup();
  25044. draw.clear();
  25045. }
  25046. }, {
  25047. key: "clearDomElements",
  25048. value: function clearDomElements() {
  25049. var _this = this;
  25050. // detach document event
  25051. this.ctx.eventList.forEach(function (event) {
  25052. document.removeEventListener(event, _this.ctx.events.documentEvent);
  25053. });
  25054. var domEls = this.w.globals.dom;
  25055. if (this.ctx.el !== null) {
  25056. // remove all child elements - resetting the whole chart
  25057. while (this.ctx.el.firstChild) {
  25058. this.ctx.el.removeChild(this.ctx.el.firstChild);
  25059. }
  25060. }
  25061. this.killSVG(domEls.Paper);
  25062. domEls.Paper.remove();
  25063. domEls.elWrap = null;
  25064. domEls.elGraphical = null;
  25065. domEls.elAnnotations = null;
  25066. domEls.elLegendWrap = null;
  25067. domEls.baseEl = null;
  25068. domEls.elGridRect = null;
  25069. domEls.elGridRectMask = null;
  25070. domEls.elGridRectMarkerMask = null;
  25071. domEls.elDefs = null;
  25072. }
  25073. }]);
  25074. return Destroy;
  25075. }();
  25076. /**
  25077. *
  25078. * @module ApexCharts
  25079. **/
  25080. var ApexCharts$1 = /*#__PURE__*/function () {
  25081. function ApexCharts(el, opts) {
  25082. _classCallCheck(this, ApexCharts);
  25083. this.opts = opts;
  25084. 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.
  25085. this.w = new Base(opts).init();
  25086. this.el = el;
  25087. this.w.globals.cuid = Utils.randomId();
  25088. this.w.globals.chartID = this.w.config.chart.id ? this.w.config.chart.id : this.w.globals.cuid;
  25089. var initCtx = new InitCtxVariables(this);
  25090. initCtx.initModules();
  25091. this.create = Utils.bind(this.create, this);
  25092. this.windowResizeHandler = this._windowResize.bind(this);
  25093. }
  25094. /**
  25095. * The primary method user will call to render the chart.
  25096. */
  25097. _createClass(ApexCharts, [{
  25098. key: "render",
  25099. value: function render() {
  25100. var _this = this;
  25101. // main method
  25102. return new Promise(function (resolve, reject) {
  25103. // only draw chart, if element found
  25104. if (_this.el !== null) {
  25105. if (typeof Apex._chartInstances === 'undefined') {
  25106. Apex._chartInstances = [];
  25107. }
  25108. if (_this.w.config.chart.id) {
  25109. Apex._chartInstances.push({
  25110. id: _this.w.globals.chartID,
  25111. group: _this.w.config.chart.group,
  25112. chart: _this
  25113. });
  25114. } // set the locale here
  25115. _this.setLocale(_this.w.config.chart.defaultLocale);
  25116. var beforeMount = _this.w.config.chart.events.beforeMount;
  25117. if (typeof beforeMount === 'function') {
  25118. beforeMount(_this, _this.w);
  25119. }
  25120. _this.events.fireEvent('beforeMount', [_this, _this.w]);
  25121. window.addEventListener('resize', _this.windowResizeHandler);
  25122. window.addResizeListener(_this.el.parentNode, _this._parentResizeCallback.bind(_this));
  25123. var graphData = _this.create(_this.w.config.series, {});
  25124. if (!graphData) return resolve(_this);
  25125. _this.mount(graphData).then(function () {
  25126. if (typeof _this.w.config.chart.events.mounted === 'function') {
  25127. _this.w.config.chart.events.mounted(_this, _this.w);
  25128. }
  25129. _this.events.fireEvent('mounted', [_this, _this.w]);
  25130. resolve(graphData);
  25131. }).catch(function (e) {
  25132. reject(e); // handle error in case no data or element not found
  25133. });
  25134. } else {
  25135. reject(new Error('Element not found'));
  25136. }
  25137. });
  25138. }
  25139. }, {
  25140. key: "create",
  25141. value: function create(ser, opts) {
  25142. var w = this.w;
  25143. var initCtx = new InitCtxVariables(this);
  25144. initCtx.initModules();
  25145. var gl = this.w.globals;
  25146. gl.noData = false;
  25147. gl.animationEnded = false;
  25148. this.responsive.checkResponsiveConfig(opts);
  25149. if (w.config.xaxis.convertedCatToNumeric) {
  25150. var defaults = new Defaults(w.config);
  25151. defaults.convertCatToNumericXaxis(w.config, this.ctx);
  25152. }
  25153. if (this.el === null) {
  25154. gl.animationEnded = true;
  25155. return null;
  25156. }
  25157. this.core.setupElements();
  25158. if (gl.svgWidth === 0) {
  25159. // if the element is hidden, skip drawing
  25160. gl.animationEnded = true;
  25161. return null;
  25162. }
  25163. var combo = CoreUtils.checkComboSeries(ser);
  25164. gl.comboCharts = combo.comboCharts;
  25165. gl.comboBarCount = combo.comboBarCount;
  25166. if (ser.length === 0 || ser.length === 1 && ser[0].data && ser[0].data.length === 0) {
  25167. this.series.handleNoData();
  25168. }
  25169. 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
  25170. this.data.parseData(ser); // this is a good time to set theme colors first
  25171. this.theme.init(); // as markers accepts array, we need to setup global markers for easier access
  25172. var markers = new Markers(this);
  25173. markers.setGlobalMarkerSize(); // labelFormatters should be called before dimensions as in dimensions we need text labels width
  25174. this.formatters.setLabelFormatters();
  25175. this.titleSubtitle.draw(); // legend is calculated here before coreCalculations because it affects the plottable area
  25176. // if there is some data to show or user collapsed all series, then proceed drawing legend
  25177. if (!gl.noData || gl.collapsedSeries.length === gl.series.length) {
  25178. this.legend.init();
  25179. } // check whether in multiple series, all series share the same X
  25180. 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
  25181. if (gl.axisCharts) {
  25182. this.core.coreCalculations();
  25183. if (w.config.xaxis.type !== 'category') {
  25184. // as we have minX and maxX values, determine the default DateTimeFormat for time series
  25185. this.formatters.setLabelFormatters();
  25186. }
  25187. } // 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
  25188. // Also we need to do this before calcuting Dimentions plotCoords() method of Dimensions
  25189. this.formatters.heatmapLabelFormatters(); // We got plottable area here, next task would be to calculate axis areas
  25190. this.dimensions.plotCoords();
  25191. var xyRatios = this.core.xySettings();
  25192. this.grid.createGridMask();
  25193. var elGraph = this.core.plotChartType(ser, xyRatios);
  25194. var dataLabels = new DataLabels(this);
  25195. dataLabels.bringForward();
  25196. if (w.config.dataLabels.background.enabled) {
  25197. dataLabels.dataLabelsBackground();
  25198. } // after all the drawing calculations, shift the graphical area (actual charts/bars) excluding legends
  25199. this.core.shiftGraphPosition();
  25200. var dim = {
  25201. plot: {
  25202. left: w.globals.translateX,
  25203. top: w.globals.translateY,
  25204. width: w.globals.gridWidth,
  25205. height: w.globals.gridHeight
  25206. }
  25207. };
  25208. return {
  25209. elGraph: elGraph,
  25210. xyRatios: xyRatios,
  25211. elInner: w.globals.dom.elGraphical,
  25212. dimensions: dim
  25213. };
  25214. }
  25215. }, {
  25216. key: "mount",
  25217. value: function mount() {
  25218. var _this2 = this;
  25219. var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  25220. var me = this;
  25221. var w = me.w;
  25222. return new Promise(function (resolve, reject) {
  25223. // no data to display
  25224. if (me.el === null) {
  25225. return reject(new Error('Not enough data to display or target element not found'));
  25226. } else if (graphData === null || w.globals.allSeriesCollapsed) {
  25227. me.series.handleNoData();
  25228. }
  25229. me.axes.drawAxis(w.config.chart.type, graphData.xyRatios);
  25230. me.grid = new Grid(me);
  25231. var elgrid = me.grid.drawGrid();
  25232. me.annotations = new Annotations(me);
  25233. me.annotations.drawShapeAnnos();
  25234. me.annotations.drawImageAnnos();
  25235. me.annotations.drawTextAnnos();
  25236. if (w.config.grid.position === 'back' && elgrid) {
  25237. w.globals.dom.elGraphical.add(elgrid.el);
  25238. }
  25239. var xAxis = new XAxis(_this2.ctx);
  25240. var yaxis = new YAxis(_this2.ctx);
  25241. if (elgrid !== null) {
  25242. xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth);
  25243. yaxis.setYAxisTextAlignments();
  25244. }
  25245. if (w.config.annotations.position === 'back') {
  25246. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  25247. me.annotations.drawAxesAnnotations();
  25248. }
  25249. if (graphData.elGraph instanceof Array) {
  25250. for (var g = 0; g < graphData.elGraph.length; g++) {
  25251. w.globals.dom.elGraphical.add(graphData.elGraph[g]);
  25252. }
  25253. } else {
  25254. w.globals.dom.elGraphical.add(graphData.elGraph);
  25255. }
  25256. if (w.config.grid.position === 'front' && elgrid) {
  25257. w.globals.dom.elGraphical.add(elgrid.el);
  25258. }
  25259. if (w.config.xaxis.crosshairs.position === 'front') {
  25260. me.crosshairs.drawXCrosshairs();
  25261. }
  25262. if (w.config.yaxis[0].crosshairs.position === 'front') {
  25263. me.crosshairs.drawYCrosshairs();
  25264. }
  25265. if (w.config.annotations.position === 'front') {
  25266. w.globals.dom.Paper.add(w.globals.dom.elAnnotations);
  25267. me.annotations.drawAxesAnnotations();
  25268. }
  25269. if (!w.globals.noData) {
  25270. // draw tooltips at the end
  25271. if (w.config.tooltip.enabled && !w.globals.noData) {
  25272. me.w.globals.tooltip.drawTooltip(graphData.xyRatios);
  25273. }
  25274. if (w.globals.axisCharts && (w.globals.isXNumeric || w.config.xaxis.convertedCatToNumeric)) {
  25275. if (w.config.chart.zoom.enabled || w.config.chart.selection && w.config.chart.selection.enabled || w.config.chart.pan && w.config.chart.pan.enabled) {
  25276. me.zoomPanSelection.init({
  25277. xyRatios: graphData.xyRatios
  25278. });
  25279. }
  25280. } else {
  25281. var tools = w.config.chart.toolbar.tools;
  25282. var toolsArr = ['zoom', 'zoomin', 'zoomout', 'selection', 'pan', 'reset'];
  25283. toolsArr.forEach(function (t) {
  25284. tools[t] = false;
  25285. });
  25286. }
  25287. if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) {
  25288. me.toolbar.createToolbar();
  25289. }
  25290. }
  25291. if (w.globals.memory.methodsToExec.length > 0) {
  25292. w.globals.memory.methodsToExec.forEach(function (fn) {
  25293. fn.method(fn.params, false, fn.context);
  25294. });
  25295. }
  25296. if (!w.globals.axisCharts && !w.globals.noData) {
  25297. me.core.resizeNonAxisCharts();
  25298. }
  25299. resolve(me);
  25300. });
  25301. }
  25302. /**
  25303. * Destroy the chart instance by removing all elements which also clean up event listeners on those elements.
  25304. */
  25305. }, {
  25306. key: "destroy",
  25307. value: function destroy() {
  25308. window.removeEventListener('resize', this.windowResizeHandler);
  25309. window.removeResizeListener(this.el.parentNode, this._parentResizeCallback.bind(this)); // remove the chart's instance from the global Apex._chartInstances
  25310. var chartID = this.w.config.chart.id;
  25311. if (chartID) {
  25312. Apex._chartInstances.forEach(function (c, i) {
  25313. if (c.id === chartID) {
  25314. Apex._chartInstances.splice(i, 1);
  25315. }
  25316. });
  25317. }
  25318. new Destroy(this.ctx).clear();
  25319. }
  25320. /**
  25321. * Allows users to update Options after the chart has rendered.
  25322. *
  25323. * @param {object} options - A new config object can be passed which will be merged with the existing config object
  25324. * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there
  25325. * @param {boolean} animate - should animate or not on updating Options
  25326. */
  25327. }, {
  25328. key: "updateOptions",
  25329. value: function updateOptions(options) {
  25330. var _this3 = this;
  25331. var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  25332. var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25333. var updateSyncedCharts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  25334. var overwriteInitialConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  25335. var w = this.w;
  25336. if (options.series) {
  25337. this.series.resetSeries(false, true, false);
  25338. if (options.series.length && options.series[0].data) {
  25339. options.series = options.series.map(function (s, i) {
  25340. return _this3.updateHelpers._extendSeries(s, i);
  25341. });
  25342. } // user updated the series via updateOptions() function.
  25343. // Hence, we need to reset axis min/max to avoid zooming issues
  25344. this.updateHelpers.revertDefaultAxisMinMax();
  25345. } // user has set x-axis min/max externally - hence we need to forcefully set the xaxis min/max
  25346. if (options.xaxis) {
  25347. options = this.updateHelpers.forceXAxisUpdate(options);
  25348. }
  25349. if (options.yaxis) {
  25350. options = this.updateHelpers.forceYAxisUpdate(options);
  25351. }
  25352. if (w.globals.collapsedSeriesIndices.length > 0) {
  25353. this.series.clearPreviousPaths();
  25354. }
  25355. /* update theme mode#459 */
  25356. if (options.theme) {
  25357. options = this.theme.updateThemeOptions(options);
  25358. }
  25359. return this.updateHelpers._updateOptions(options, redraw, animate, updateSyncedCharts, overwriteInitialConfig);
  25360. }
  25361. /**
  25362. * Allows users to update Series after the chart has rendered.
  25363. *
  25364. * @param {array} series - New series which will override the existing
  25365. */
  25366. }, {
  25367. key: "updateSeries",
  25368. value: function updateSeries() {
  25369. var newSeries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  25370. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25371. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25372. this.series.resetSeries(false);
  25373. this.updateHelpers.revertDefaultAxisMinMax();
  25374. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  25375. }
  25376. /**
  25377. * Allows users to append a new series after the chart has rendered.
  25378. *
  25379. * @param {array} newSerie - New serie which will be appended to the existing series
  25380. */
  25381. }, {
  25382. key: "appendSeries",
  25383. value: function appendSeries(newSerie) {
  25384. var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25385. var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25386. var newSeries = this.w.config.series.slice();
  25387. newSeries.push(newSerie);
  25388. this.series.resetSeries(false);
  25389. this.updateHelpers.revertDefaultAxisMinMax();
  25390. return this.updateHelpers._updateSeries(newSeries, animate, overwriteInitialSeries);
  25391. }
  25392. /**
  25393. * Allows users to append Data to series.
  25394. *
  25395. * @param {array} newData - New data in the same format as series
  25396. */
  25397. }, {
  25398. key: "appendData",
  25399. value: function appendData(newData) {
  25400. var overwriteInitialSeries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25401. var me = this;
  25402. me.w.globals.dataChanged = true;
  25403. me.series.getPreviousPaths();
  25404. var newSeries = me.w.config.series.slice();
  25405. for (var i = 0; i < newSeries.length; i++) {
  25406. if (newData[i] !== null && typeof newData[i] !== 'undefined') {
  25407. for (var j = 0; j < newData[i].data.length; j++) {
  25408. newSeries[i].data.push(newData[i].data[j]);
  25409. }
  25410. }
  25411. }
  25412. me.w.config.series = newSeries;
  25413. if (overwriteInitialSeries) {
  25414. me.w.globals.initialSeries = JSON.parse(JSON.stringify(me.w.config.series));
  25415. }
  25416. return this.update();
  25417. }
  25418. }, {
  25419. key: "update",
  25420. value: function update(options) {
  25421. var _this4 = this;
  25422. return new Promise(function (resolve, reject) {
  25423. new Destroy(_this4.ctx).clear();
  25424. var graphData = _this4.create(_this4.w.config.series, options);
  25425. if (!graphData) return resolve(_this4);
  25426. _this4.mount(graphData).then(function () {
  25427. if (typeof _this4.w.config.chart.events.updated === 'function') {
  25428. _this4.w.config.chart.events.updated(_this4, _this4.w);
  25429. }
  25430. _this4.events.fireEvent('updated', [_this4, _this4.w]);
  25431. _this4.w.globals.isDirty = true;
  25432. resolve(_this4);
  25433. }).catch(function (e) {
  25434. reject(e);
  25435. });
  25436. });
  25437. }
  25438. /**
  25439. * Get all charts in the same "group" (including the instance which is called upon) to sync them when user zooms in/out or pan.
  25440. */
  25441. }, {
  25442. key: "getSyncedCharts",
  25443. value: function getSyncedCharts() {
  25444. var chartGroups = this.getGroupedCharts();
  25445. var allCharts = [this];
  25446. if (chartGroups.length) {
  25447. allCharts = [];
  25448. chartGroups.forEach(function (ch) {
  25449. allCharts.push(ch);
  25450. });
  25451. }
  25452. return allCharts;
  25453. }
  25454. /**
  25455. * 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)
  25456. */
  25457. }, {
  25458. key: "getGroupedCharts",
  25459. value: function getGroupedCharts() {
  25460. var _this5 = this;
  25461. return Apex._chartInstances.filter(function (ch) {
  25462. if (ch.group) {
  25463. return true;
  25464. }
  25465. }).map(function (ch) {
  25466. return _this5.w.config.chart.group === ch.group ? ch.chart : _this5;
  25467. });
  25468. }
  25469. }, {
  25470. key: "toggleSeries",
  25471. value: function toggleSeries(seriesName) {
  25472. return this.series.toggleSeries(seriesName);
  25473. }
  25474. }, {
  25475. key: "showSeries",
  25476. value: function showSeries(seriesName) {
  25477. this.series.showSeries(seriesName);
  25478. }
  25479. }, {
  25480. key: "hideSeries",
  25481. value: function hideSeries(seriesName) {
  25482. this.series.hideSeries(seriesName);
  25483. }
  25484. }, {
  25485. key: "resetSeries",
  25486. value: function resetSeries() {
  25487. var shouldUpdateChart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  25488. var shouldResetZoom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25489. this.series.resetSeries(shouldUpdateChart, shouldResetZoom);
  25490. } // Public method to add event listener on chart context
  25491. }, {
  25492. key: "addEventListener",
  25493. value: function addEventListener(name, handler) {
  25494. this.events.addEventListener(name, handler);
  25495. } // Public method to remove event listener on chart context
  25496. }, {
  25497. key: "removeEventListener",
  25498. value: function removeEventListener(name, handler) {
  25499. this.events.removeEventListener(name, handler);
  25500. }
  25501. }, {
  25502. key: "addXaxisAnnotation",
  25503. value: function addXaxisAnnotation(opts) {
  25504. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25505. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25506. var me = this;
  25507. if (context) {
  25508. me = context;
  25509. }
  25510. me.annotations.addXaxisAnnotationExternal(opts, pushToMemory, me);
  25511. }
  25512. }, {
  25513. key: "addYaxisAnnotation",
  25514. value: function addYaxisAnnotation(opts) {
  25515. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25516. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25517. var me = this;
  25518. if (context) {
  25519. me = context;
  25520. }
  25521. me.annotations.addYaxisAnnotationExternal(opts, pushToMemory, me);
  25522. }
  25523. }, {
  25524. key: "addPointAnnotation",
  25525. value: function addPointAnnotation(opts) {
  25526. var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  25527. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
  25528. var me = this;
  25529. if (context) {
  25530. me = context;
  25531. }
  25532. me.annotations.addPointAnnotationExternal(opts, pushToMemory, me);
  25533. }
  25534. }, {
  25535. key: "clearAnnotations",
  25536. value: function clearAnnotations() {
  25537. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
  25538. var me = this;
  25539. if (context) {
  25540. me = context;
  25541. }
  25542. me.annotations.clearAnnotations(me);
  25543. }
  25544. }, {
  25545. key: "removeAnnotation",
  25546. value: function removeAnnotation(id) {
  25547. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  25548. var me = this;
  25549. if (context) {
  25550. me = context;
  25551. }
  25552. me.annotations.removeAnnotation(me, id);
  25553. }
  25554. }, {
  25555. key: "getChartArea",
  25556. value: function getChartArea() {
  25557. var el = this.w.globals.dom.baseEl.querySelector('.apexcharts-inner');
  25558. return el;
  25559. }
  25560. }, {
  25561. key: "getSeriesTotalXRange",
  25562. value: function getSeriesTotalXRange(minX, maxX) {
  25563. return this.coreUtils.getSeriesTotalsXRange(minX, maxX);
  25564. }
  25565. }, {
  25566. key: "getHighestValueInSeries",
  25567. value: function getHighestValueInSeries() {
  25568. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  25569. var range = new Range$1(this.ctx);
  25570. return range.getMinYMaxY(seriesIndex).highestY;
  25571. }
  25572. }, {
  25573. key: "getLowestValueInSeries",
  25574. value: function getLowestValueInSeries() {
  25575. var seriesIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  25576. var range = new Range$1(this.ctx);
  25577. return range.getMinYMaxY(seriesIndex).lowestY;
  25578. }
  25579. }, {
  25580. key: "getSeriesTotal",
  25581. value: function getSeriesTotal() {
  25582. return this.w.globals.seriesTotals;
  25583. }
  25584. }, {
  25585. key: "toggleDataPointSelection",
  25586. value: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
  25587. return this.updateHelpers.toggleDataPointSelection(seriesIndex, dataPointIndex);
  25588. }
  25589. }, {
  25590. key: "zoomX",
  25591. value: function zoomX(min, max) {
  25592. this.ctx.toolbar.zoomUpdateOptions(min, max);
  25593. }
  25594. }, {
  25595. key: "setLocale",
  25596. value: function setLocale(localeName) {
  25597. this.localization.setCurrentLocaleValues(localeName);
  25598. }
  25599. }, {
  25600. key: "dataURI",
  25601. value: function dataURI() {
  25602. var exp = new Exports(this.ctx);
  25603. return exp.dataURI();
  25604. }
  25605. }, {
  25606. key: "paper",
  25607. value: function paper() {
  25608. return this.w.globals.dom.Paper;
  25609. }
  25610. }, {
  25611. key: "_parentResizeCallback",
  25612. value: function _parentResizeCallback() {
  25613. if (!this.w.globals.noData && this.w.globals.animationEnded && this.w.config.chart.redrawOnParentResize) {
  25614. this._windowResize();
  25615. }
  25616. }
  25617. /**
  25618. * Handle window resize and re-draw the whole chart.
  25619. */
  25620. }, {
  25621. key: "_windowResize",
  25622. value: function _windowResize() {
  25623. var _this6 = this;
  25624. clearTimeout(this.w.globals.resizeTimer);
  25625. this.w.globals.resizeTimer = window.setTimeout(function () {
  25626. _this6.w.globals.resized = true;
  25627. _this6.w.globals.dataChanged = false; // we need to redraw the whole chart on window resize (with a small delay).
  25628. _this6.ctx.update();
  25629. }, 150);
  25630. }
  25631. }], [{
  25632. key: "getChartByID",
  25633. value: function getChartByID(chartID) {
  25634. var c = Apex._chartInstances.filter(function (ch) {
  25635. return ch.id === chartID;
  25636. })[0];
  25637. return c && c.chart;
  25638. }
  25639. /**
  25640. * 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
  25641. */
  25642. }, {
  25643. key: "initOnLoad",
  25644. value: function initOnLoad() {
  25645. var els = document.querySelectorAll('[data-apexcharts]');
  25646. for (var i = 0; i < els.length; i++) {
  25647. var el = els[i];
  25648. var options = JSON.parse(els[i].getAttribute('data-options'));
  25649. var apexChart = new ApexCharts(el, options);
  25650. apexChart.render();
  25651. }
  25652. }
  25653. /**
  25654. * This static method allows users to call chart methods without necessarily from the
  25655. * instance of the chart in case user has assigned chartID to the targetted chart.
  25656. * The chartID is used for mapping the instance stored in Apex._chartInstances global variable
  25657. *
  25658. * This is helpful in cases when you don't have reference of the chart instance
  25659. * easily and need to call the method from anywhere.
  25660. * For eg, in React/Vue applications when you have many parent/child components,
  25661. * and need easy reference to other charts for performing dynamic operations
  25662. *
  25663. * @param {string} chartID - The unique identifier which will be used to call methods
  25664. * on that chart instance
  25665. * @param {function} fn - The method name to call
  25666. * @param {object} opts - The parameters which are accepted in the original method will be passed here in the same order.
  25667. */
  25668. }, {
  25669. key: "exec",
  25670. value: function exec(chartID, fn) {
  25671. var chart = this.getChartByID(chartID);
  25672. if (!chart) return; // turn on the global exec flag to indicate this method was called
  25673. chart.w.globals.isExecCalled = true;
  25674. var ret = null;
  25675. if (chart.publicMethods.indexOf(fn) !== -1) {
  25676. for (var _len = arguments.length, opts = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  25677. opts[_key - 2] = arguments[_key];
  25678. }
  25679. ret = chart[fn].apply(chart, opts);
  25680. }
  25681. return ret;
  25682. }
  25683. }, {
  25684. key: "merge",
  25685. value: function merge(target, source) {
  25686. return Utils.extend(target, source);
  25687. }
  25688. }]);
  25689. return ApexCharts;
  25690. }();
  25691. return ApexCharts$1;
  25692. })));