highcharts.src.js 2.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * (c) 2009-2021 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (root, factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = root.document ?
  13. factory(root) :
  14. factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/highcharts', function () {
  17. return factory(root);
  18. });
  19. } else {
  20. if (root.Highcharts) {
  21. root.Highcharts.error(16, true);
  22. }
  23. root.Highcharts = factory(root);
  24. }
  25. }(typeof window !== 'undefined' ? window : this, function (win) {
  26. var _modules = {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Core/Globals.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2021 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. /* *
  43. *
  44. * Constants
  45. *
  46. * */
  47. /**
  48. * @private
  49. * @deprecated
  50. * @todo Rename UMD argument `win` to `window`; move code to `Globals.win`
  51. */
  52. var w = (typeof win !== 'undefined' ?
  53. win :
  54. typeof window !== 'undefined' ?
  55. window :
  56. {}
  57. // eslint-disable-next-line node/no-unsupported-features/es-builtins
  58. );
  59. /* *
  60. *
  61. * Namespace
  62. *
  63. * */
  64. /**
  65. * Shared Highcharts properties.
  66. */
  67. var Globals;
  68. (function (Globals) {
  69. /* *
  70. *
  71. * Constants
  72. *
  73. * */
  74. Globals.SVG_NS = 'http://www.w3.org/2000/svg', Globals.product = 'Highcharts', Globals.version = '9.1.1', Globals.win = w, Globals.doc = Globals.win.document, Globals.svg = (Globals.doc &&
  75. Globals.doc.createElementNS &&
  76. !!Globals.doc.createElementNS(Globals.SVG_NS, 'svg').createSVGRect), Globals.userAgent = (Globals.win.navigator && Globals.win.navigator.userAgent) || '', Globals.isChrome = Globals.userAgent.indexOf('Chrome') !== -1, Globals.isFirefox = Globals.userAgent.indexOf('Firefox') !== -1, Globals.isMS = /(edge|msie|trident)/i.test(Globals.userAgent) && !Globals.win.opera, Globals.isSafari = !Globals.isChrome && Globals.userAgent.indexOf('Safari') !== -1, Globals.isTouchDevice = /(Mobile|Android|Windows Phone)/.test(Globals.userAgent), Globals.isWebKit = Globals.userAgent.indexOf('AppleWebKit') !== -1, Globals.deg2rad = Math.PI * 2 / 360, Globals.hasBidiBug = (Globals.isFirefox &&
  77. parseInt(Globals.userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  78. ), Globals.hasTouch = !!Globals.win.TouchEvent, Globals.marginNames = [
  79. 'plotTop',
  80. 'marginRight',
  81. 'marginBottom',
  82. 'plotLeft'
  83. ], Globals.noop = function () { }, Globals.supportsPassiveEvents = (function () {
  84. // Checks whether the browser supports passive events, (#11353).
  85. var supportsPassive = false;
  86. // Object.defineProperty doesn't work on IE as well as passive
  87. // events - instead of using polyfill, we can exclude IE totally.
  88. if (!Globals.isMS) {
  89. var opts = Object.defineProperty({}, 'passive', {
  90. get: function () {
  91. supportsPassive = true;
  92. }
  93. });
  94. if (Globals.win.addEventListener && Globals.win.removeEventListener) {
  95. Globals.win.addEventListener('testPassive', Globals.noop, opts);
  96. Globals.win.removeEventListener('testPassive', Globals.noop, opts);
  97. }
  98. }
  99. return supportsPassive;
  100. }());
  101. /**
  102. * An array containing the current chart objects in the page. A chart's
  103. * position in the array is preserved throughout the page's lifetime. When
  104. * a chart is destroyed, the array item becomes `undefined`.
  105. *
  106. * @name Highcharts.charts
  107. * @type {Array<Highcharts.Chart|undefined>}
  108. */
  109. Globals.charts = [];
  110. /**
  111. * A hook for defining additional date format specifiers. New
  112. * specifiers are defined as key-value pairs by using the
  113. * specifier as key, and a function which takes the timestamp as
  114. * value. This function returns the formatted portion of the
  115. * date.
  116. *
  117. * @sample highcharts/global/dateformats/
  118. * Adding support for week number
  119. *
  120. * @name Highcharts.dateFormats
  121. * @type {Record<string, Highcharts.TimeFormatCallbackFunction>}
  122. */
  123. Globals.dateFormats = {};
  124. /**
  125. * @private
  126. * @deprecated
  127. * @todo Use only `Core/Series/SeriesRegistry.seriesTypes`
  128. */
  129. Globals.seriesTypes = {};
  130. /**
  131. * @private
  132. */
  133. Globals.symbolSizes = {};
  134. })(Globals || (Globals = {}));
  135. /* *
  136. *
  137. * Default Export
  138. *
  139. * */
  140. return Globals;
  141. });
  142. _registerModule(_modules, 'Core/Utilities.js', [_modules['Core/Globals.js']], function (H) {
  143. /* *
  144. *
  145. * (c) 2010-2021 Torstein Honsi
  146. *
  147. * License: www.highcharts.com/license
  148. *
  149. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  150. *
  151. * */
  152. var charts = H.charts,
  153. doc = H.doc,
  154. win = H.win;
  155. /**
  156. * An animation configuration. Animation configurations can also be defined as
  157. * booleans, where `false` turns off animation and `true` defaults to a duration
  158. * of 500ms and defer of 0ms.
  159. *
  160. * @interface Highcharts.AnimationOptionsObject
  161. */ /**
  162. * A callback function to exectute when the animation finishes.
  163. * @name Highcharts.AnimationOptionsObject#complete
  164. * @type {Function|undefined}
  165. */ /**
  166. * The animation defer in milliseconds.
  167. * @name Highcharts.AnimationOptionsObject#defer
  168. * @type {number|undefined}
  169. */ /**
  170. * The animation duration in milliseconds.
  171. * @name Highcharts.AnimationOptionsObject#duration
  172. * @type {number|undefined}
  173. */ /**
  174. * The name of an easing function as defined on the `Math` object.
  175. * @name Highcharts.AnimationOptionsObject#easing
  176. * @type {string|Function|undefined}
  177. */ /**
  178. * A callback function to execute on each step of each attribute or CSS property
  179. * that's being animated. The first argument contains information about the
  180. * animation and progress.
  181. * @name Highcharts.AnimationOptionsObject#step
  182. * @type {Function|undefined}
  183. */
  184. /**
  185. * Creates a frame for the animated SVG element.
  186. *
  187. * @callback Highcharts.AnimationStepCallbackFunction
  188. *
  189. * @param {Highcharts.SVGElement} this
  190. * The SVG element to animate.
  191. *
  192. * @return {void}
  193. */
  194. /**
  195. * Interface description for a class.
  196. *
  197. * @interface Highcharts.Class<T>
  198. * @extends Function
  199. */ /**
  200. * Class costructor.
  201. * @function Highcharts.Class<T>#new
  202. * @param {...Array<*>} args
  203. * Constructor arguments.
  204. * @return {T}
  205. * Class instance.
  206. */
  207. /**
  208. * A style object with camel case property names to define visual appearance of
  209. * a SVG element or HTML element. The properties can be whatever styles are
  210. * supported on the given SVG or HTML element.
  211. *
  212. * @example
  213. * {
  214. * fontFamily: 'monospace',
  215. * fontSize: '1.2em'
  216. * }
  217. *
  218. * @interface Highcharts.CSSObject
  219. */ /**
  220. * @name Highcharts.CSSObject#[key:string]
  221. * @type {boolean|number|string|undefined}
  222. */ /**
  223. * Background style for the element.
  224. * @name Highcharts.CSSObject#background
  225. * @type {string|undefined}
  226. */ /**
  227. * Background color of the element.
  228. * @name Highcharts.CSSObject#backgroundColor
  229. * @type {Highcharts.ColorString|undefined}
  230. */ /**
  231. * Border style for the element.
  232. * @name Highcharts.CSSObject#border
  233. * @type {string|undefined}
  234. */ /**
  235. * Radius of the element border.
  236. * @name Highcharts.CSSObject#borderRadius
  237. * @type {number|undefined}
  238. */ /**
  239. * Color used in the element. The 'contrast' option is a Highcharts custom
  240. * property that results in black or white, depending on the background of the
  241. * element.
  242. * @name Highcharts.CSSObject#color
  243. * @type {'contrast'|Highcharts.ColorString|undefined}
  244. */ /**
  245. * Style of the mouse cursor when resting over the element.
  246. * @name Highcharts.CSSObject#cursor
  247. * @type {Highcharts.CursorValue|undefined}
  248. */ /**
  249. * Font family of the element text. Multiple values have to be in decreasing
  250. * preference order and separated by comma.
  251. * @name Highcharts.CSSObject#fontFamily
  252. * @type {string|undefined}
  253. */ /**
  254. * Font size of the element text.
  255. * @name Highcharts.CSSObject#fontSize
  256. * @type {string|undefined}
  257. */ /**
  258. * Font weight of the element text.
  259. * @name Highcharts.CSSObject#fontWeight
  260. * @type {string|undefined}
  261. */ /**
  262. * Height of the element.
  263. * @name Highcharts.CSSObject#height
  264. * @type {number|undefined}
  265. */ /**
  266. * Width of the element border.
  267. * @name Highcharts.CSSObject#lineWidth
  268. * @type {number|undefined}
  269. */ /**
  270. * Opacity of the element.
  271. * @name Highcharts.CSSObject#opacity
  272. * @type {number|undefined}
  273. */ /**
  274. * Space around the element content.
  275. * @name Highcharts.CSSObject#padding
  276. * @type {string|undefined}
  277. */ /**
  278. * Behaviour of the element when the mouse cursor rests over it.
  279. * @name Highcharts.CSSObject#pointerEvents
  280. * @type {string|undefined}
  281. */ /**
  282. * Positioning of the element.
  283. * @name Highcharts.CSSObject#position
  284. * @type {string|undefined}
  285. */ /**
  286. * Alignment of the element text.
  287. * @name Highcharts.CSSObject#textAlign
  288. * @type {string|undefined}
  289. */ /**
  290. * Additional decoration of the element text.
  291. * @name Highcharts.CSSObject#textDecoration
  292. * @type {string|undefined}
  293. */ /**
  294. * Outline style of the element text.
  295. * @name Highcharts.CSSObject#textOutline
  296. * @type {string|undefined}
  297. */ /**
  298. * Line break style of the element text. Highcharts SVG elements support
  299. * `ellipsis` when a `width` is set.
  300. * @name Highcharts.CSSObject#textOverflow
  301. * @type {string|undefined}
  302. */ /**
  303. * Top spacing of the element relative to the parent element.
  304. * @name Highcharts.CSSObject#top
  305. * @type {string|undefined}
  306. */ /**
  307. * Animated transition of selected element properties.
  308. * @name Highcharts.CSSObject#transition
  309. * @type {string|undefined}
  310. */ /**
  311. * Line break style of the element text.
  312. * @name Highcharts.CSSObject#whiteSpace
  313. * @type {string|undefined}
  314. */ /**
  315. * Width of the element.
  316. * @name Highcharts.CSSObject#width
  317. * @type {number|undefined}
  318. */
  319. /**
  320. * All possible cursor styles.
  321. *
  322. * @typedef {'alias'|'all-scroll'|'auto'|'cell'|'col-resize'|'context-menu'|'copy'|'crosshair'|'default'|'e-resize'|'ew-resize'|'grab'|'grabbing'|'help'|'move'|'n-resize'|'ne-resize'|'nesw-resize'|'no-drop'|'none'|'not-allowed'|'ns-resize'|'nw-resize'|'nwse-resize'|'pointer'|'progress'|'row-resize'|'s-resize'|'se-resize'|'sw-resize'|'text'|'vertical-text'|'w-resize'|'wait'|'zoom-in'|'zoom-out'} Highcharts.CursorValue
  323. */
  324. /**
  325. * All possible dash styles.
  326. *
  327. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  328. */
  329. /**
  330. * Generic dictionary in TypeScript notation.
  331. * Use the native `AnyRecord` instead.
  332. *
  333. * @deprecated
  334. * @interface Highcharts.Dictionary<T>
  335. */ /**
  336. * @name Highcharts.Dictionary<T>#[key:string]
  337. * @type {T}
  338. */
  339. /**
  340. * The function callback to execute when the event is fired. The `this` context
  341. * contains the instance, that fired the event.
  342. *
  343. * @callback Highcharts.EventCallbackFunction<T>
  344. *
  345. * @param {T} this
  346. *
  347. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  348. * Event arguments.
  349. *
  350. * @return {boolean|void}
  351. */
  352. /**
  353. * The event options for adding function callback.
  354. *
  355. * @interface Highcharts.EventOptionsObject
  356. */ /**
  357. * The order the event handler should be called. This opens for having one
  358. * handler be called before another, independent of in which order they were
  359. * added.
  360. * @name Highcharts.EventOptionsObject#order
  361. * @type {number}
  362. */ /**
  363. * Whether an event should be passive or not.
  364. * When set to `true`, the function specified by listener will never call
  365. * `preventDefault()`.
  366. * @name Highcharts.EventOptionsObject#passive
  367. * @type boolean
  368. */
  369. /**
  370. * Formats data as a string. Usually the data is accessible throught the `this`
  371. * keyword.
  372. *
  373. * @callback Highcharts.FormatterCallbackFunction<T>
  374. *
  375. * @param {T} this
  376. * Context to format
  377. *
  378. * @return {string}
  379. * Formatted text
  380. */
  381. /**
  382. * An object of key-value pairs for HTML attributes.
  383. *
  384. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  385. */
  386. /**
  387. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  388. * the global scope.
  389. *
  390. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  391. *
  392. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  393. */
  394. /**
  395. * The iterator callback.
  396. *
  397. * @callback Highcharts.ObjectEachCallbackFunction<T>
  398. *
  399. * @param {T} this
  400. * The context.
  401. *
  402. * @param {*} value
  403. * The property value.
  404. *
  405. * @param {string} key
  406. * The property key.
  407. *
  408. * @param {*} obj
  409. * The object that objectEach is being applied to.
  410. */
  411. /**
  412. * An object containing `left` and `top` properties for the position in the
  413. * page.
  414. *
  415. * @interface Highcharts.OffsetObject
  416. */ /**
  417. * Left distance to the page border.
  418. * @name Highcharts.OffsetObject#left
  419. * @type {number}
  420. */ /**
  421. * Top distance to the page border.
  422. * @name Highcharts.OffsetObject#top
  423. * @type {number}
  424. */
  425. /**
  426. * Describes a range.
  427. *
  428. * @interface Highcharts.RangeObject
  429. */ /**
  430. * Maximum number of the range.
  431. * @name Highcharts.RangeObject#max
  432. * @type {number}
  433. */ /**
  434. * Minimum number of the range.
  435. * @name Highcharts.RangeObject#min
  436. * @type {number}
  437. */
  438. /**
  439. * If a number is given, it defines the pixel length. If a percentage string is
  440. * given, like for example `'50%'`, the setting defines a length relative to a
  441. * base size, for example the size of a container.
  442. *
  443. * @typedef {number|string} Highcharts.RelativeSize
  444. */
  445. /**
  446. * Proceed function to call original (wrapped) function.
  447. *
  448. * @callback Highcharts.WrapProceedFunction
  449. *
  450. * @param {*} [arg1]
  451. * Optional argument. Without any arguments defaults to first argument of
  452. * the wrapping function.
  453. *
  454. * @param {*} [arg2]
  455. * Optional argument. Without any arguments defaults to second argument
  456. * of the wrapping function.
  457. *
  458. * @param {*} [arg3]
  459. * Optional argument. Without any arguments defaults to third argument of
  460. * the wrapping function.
  461. *
  462. * @return {*}
  463. * Return value of the original function.
  464. */
  465. /**
  466. * The Highcharts object is the placeholder for all other members, and various
  467. * utility functions. The most important member of the namespace would be the
  468. * chart constructor.
  469. *
  470. * @example
  471. * let chart = Highcharts.chart('container', { ... });
  472. *
  473. * @namespace Highcharts
  474. */
  475. ''; // detach doclets above
  476. /**
  477. * Provide error messages for debugging, with links to online explanation. This
  478. * function can be overridden to provide custom error handling.
  479. *
  480. * @sample highcharts/chart/highcharts-error/
  481. * Custom error handler
  482. *
  483. * @function Highcharts.error
  484. *
  485. * @param {number|string} code
  486. * The error code. See
  487. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  488. * for available codes. If it is a string, the error message is printed
  489. * directly in the console.
  490. *
  491. * @param {boolean} [stop=false]
  492. * Whether to throw an error or just log a warning in the console.
  493. *
  494. * @param {Highcharts.Chart} [chart]
  495. * Reference to the chart that causes the error. Used in 'debugger'
  496. * module to display errors directly on the chart.
  497. * Important note: This argument is undefined for errors that lack
  498. * access to the Chart instance. In such case, the error will be
  499. * displayed on the last created chart.
  500. *
  501. * @param {Highcharts.Dictionary<string>} [params]
  502. * Additional parameters for the generated message.
  503. *
  504. * @return {void}
  505. */
  506. function error(code, stop, chart, params) {
  507. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  508. if (code === 32) {
  509. code = severity + ": Deprecated member";
  510. }
  511. var isCode = isNumber(code);
  512. var message = isCode ?
  513. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  514. code.toString();
  515. var defaultHandler = function () {
  516. if (stop) {
  517. throw new Error(message);
  518. }
  519. // else ...
  520. if (win.console &&
  521. error.messages.indexOf(message) === -1 // prevent console flooting
  522. ) {
  523. console.warn(message); // eslint-disable-line no-console
  524. }
  525. };
  526. if (typeof params !== 'undefined') {
  527. var additionalMessages_1 = '';
  528. if (isCode) {
  529. message += '?';
  530. }
  531. objectEach(params, function (value, key) {
  532. additionalMessages_1 += "\n - " + key + ": " + value;
  533. if (isCode) {
  534. message += encodeURI(key) + '=' + encodeURI(value);
  535. }
  536. });
  537. message += additionalMessages_1;
  538. }
  539. fireEvent(H, 'displayError', { chart: chart, code: code, message: message, params: params }, defaultHandler);
  540. error.messages.push(message);
  541. }
  542. (function (error) {
  543. error.messages = [];
  544. })(error || (error = {}));
  545. /* eslint-disable valid-jsdoc */
  546. /**
  547. * Utility function to deep merge two or more objects and return a third object.
  548. * If the first argument is true, the contents of the second object is copied
  549. * into the first object. The merge function can also be used with a single
  550. * object argument to create a deep copy of an object.
  551. *
  552. * @function Highcharts.merge<T>
  553. *
  554. * @param {boolean} extend
  555. * Whether to extend the left-side object (a) or return a whole new
  556. * object.
  557. *
  558. * @param {T|undefined} a
  559. * The first object to extend. When only this is given, the function
  560. * returns a deep copy.
  561. *
  562. * @param {...Array<object|undefined>} [n]
  563. * An object to merge into the previous one.
  564. *
  565. * @return {T}
  566. * The merged object. If the first argument is true, the return is the
  567. * same as the second argument.
  568. */ /**
  569. * Utility function to deep merge two or more objects and return a third object.
  570. * The merge function can also be used with a single object argument to create a
  571. * deep copy of an object.
  572. *
  573. * @function Highcharts.merge<T>
  574. *
  575. * @param {T|undefined} a
  576. * The first object to extend. When only this is given, the function
  577. * returns a deep copy.
  578. *
  579. * @param {...Array<object|undefined>} [n]
  580. * An object to merge into the previous one.
  581. *
  582. * @return {T}
  583. * The merged object. If the first argument is true, the return is the
  584. * same as the second argument.
  585. */
  586. function merge() {
  587. /* eslint-enable valid-jsdoc */
  588. var i,
  589. args = arguments,
  590. ret = {};
  591. var doCopy = function (copy,
  592. original) {
  593. // An object is replacing a primitive
  594. if (typeof copy !== 'object') {
  595. copy = {};
  596. }
  597. objectEach(original, function (value, key) {
  598. // Prototype pollution (#14883)
  599. if (key === '__proto__' || key === 'constructor') {
  600. return;
  601. }
  602. // Copy the contents of objects, but not arrays or DOM nodes
  603. if (isObject(value, true) &&
  604. !isClass(value) &&
  605. !isDOMElement(value)) {
  606. copy[key] = doCopy(copy[key] || {}, value);
  607. // Primitives and arrays are copied over directly
  608. }
  609. else {
  610. copy[key] = original[key];
  611. }
  612. });
  613. return copy;
  614. };
  615. // If first argument is true, copy into the existing object. Used in
  616. // setOptions.
  617. if (args[0] === true) {
  618. ret = args[1];
  619. args = Array.prototype.slice.call(args, 2);
  620. }
  621. // For each argument, extend the return
  622. var len = args.length;
  623. for (i = 0; i < len; i++) {
  624. ret = doCopy(ret, args[i]);
  625. }
  626. return ret;
  627. }
  628. /**
  629. * Constrain a value to within a lower and upper threshold.
  630. *
  631. * @private
  632. * @param {number} value The initial value
  633. * @param {number} min The lower threshold
  634. * @param {number} max The upper threshold
  635. * @return {number} Returns a number value within min and max.
  636. */
  637. function clamp(value, min, max) {
  638. return value > min ? value < max ? value : max : min;
  639. }
  640. // eslint-disable-next-line valid-jsdoc
  641. /**
  642. * Remove settings that have not changed, to avoid unnecessary rendering or
  643. * computing (#9197).
  644. * @private
  645. */
  646. function cleanRecursively(newer, older) {
  647. var result = {};
  648. objectEach(newer, function (_val, key) {
  649. var ob;
  650. // Dive into objects (except DOM nodes)
  651. if (isObject(newer[key], true) &&
  652. !newer.nodeType && // #10044
  653. older[key]) {
  654. ob = cleanRecursively(newer[key], older[key]);
  655. if (Object.keys(ob).length) {
  656. result[key] = ob;
  657. }
  658. // Arrays, primitives and DOM nodes are copied directly
  659. }
  660. else if (isObject(newer[key]) ||
  661. newer[key] !== older[key]) {
  662. result[key] = newer[key];
  663. }
  664. });
  665. return result;
  666. }
  667. /**
  668. * Shortcut for parseInt
  669. *
  670. * @private
  671. * @function Highcharts.pInt
  672. *
  673. * @param {*} s
  674. * any
  675. *
  676. * @param {number} [mag]
  677. * Magnitude
  678. *
  679. * @return {number}
  680. * number
  681. */
  682. function pInt(s, mag) {
  683. return parseInt(s, mag || 10);
  684. }
  685. /**
  686. * Utility function to check for string type.
  687. *
  688. * @function Highcharts.isString
  689. *
  690. * @param {*} s
  691. * The item to check.
  692. *
  693. * @return {boolean}
  694. * True if the argument is a string.
  695. */
  696. function isString(s) {
  697. return typeof s === 'string';
  698. }
  699. /**
  700. * Utility function to check if an item is an array.
  701. *
  702. * @function Highcharts.isArray
  703. *
  704. * @param {*} obj
  705. * The item to check.
  706. *
  707. * @return {boolean}
  708. * True if the argument is an array.
  709. */
  710. function isArray(obj) {
  711. var str = Object.prototype.toString.call(obj);
  712. return str === '[object Array]' || str === '[object Array Iterator]';
  713. }
  714. /**
  715. * Utility function to check if an item is of type object.
  716. *
  717. * @function Highcharts.isObject
  718. *
  719. * @param {*} obj
  720. * The item to check.
  721. *
  722. * @param {boolean} [strict=false]
  723. * Also checks that the object is not an array.
  724. *
  725. * @return {boolean}
  726. * True if the argument is an object.
  727. */
  728. function isObject(obj, strict) {
  729. return (!!obj &&
  730. typeof obj === 'object' &&
  731. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  732. }
  733. /**
  734. * Utility function to check if an Object is a HTML Element.
  735. *
  736. * @function Highcharts.isDOMElement
  737. *
  738. * @param {*} obj
  739. * The item to check.
  740. *
  741. * @return {boolean}
  742. * True if the argument is a HTML Element.
  743. */
  744. function isDOMElement(obj) {
  745. return isObject(obj) && typeof obj.nodeType === 'number';
  746. }
  747. /**
  748. * Utility function to check if an Object is a class.
  749. *
  750. * @function Highcharts.isClass
  751. *
  752. * @param {object|undefined} obj
  753. * The item to check.
  754. *
  755. * @return {boolean}
  756. * True if the argument is a class.
  757. */
  758. function isClass(obj) {
  759. var c = obj && obj.constructor;
  760. return !!(isObject(obj, true) &&
  761. !isDOMElement(obj) &&
  762. (c && c.name && c.name !== 'Object'));
  763. }
  764. /**
  765. * Utility function to check if an item is a number and it is finite (not NaN,
  766. * Infinity or -Infinity).
  767. *
  768. * @function Highcharts.isNumber
  769. *
  770. * @param {*} n
  771. * The item to check.
  772. *
  773. * @return {boolean}
  774. * True if the item is a finite number
  775. */
  776. function isNumber(n) {
  777. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  778. }
  779. /**
  780. * Remove the last occurence of an item from an array.
  781. *
  782. * @function Highcharts.erase
  783. *
  784. * @param {Array<*>} arr
  785. * The array.
  786. *
  787. * @param {*} item
  788. * The item to remove.
  789. *
  790. * @return {void}
  791. */
  792. function erase(arr, item) {
  793. var i = arr.length;
  794. while (i--) {
  795. if (arr[i] === item) {
  796. arr.splice(i, 1);
  797. break;
  798. }
  799. }
  800. }
  801. /**
  802. * Check if an object is null or undefined.
  803. *
  804. * @function Highcharts.defined
  805. *
  806. * @param {*} obj
  807. * The object to check.
  808. *
  809. * @return {boolean}
  810. * False if the object is null or undefined, otherwise true.
  811. */
  812. function defined(obj) {
  813. return typeof obj !== 'undefined' && obj !== null;
  814. }
  815. /**
  816. * Set or get an attribute or an object of attributes. To use as a setter, pass
  817. * a key and a value, or let the second argument be a collection of keys and
  818. * values. To use as a getter, pass only a string as the second argument.
  819. *
  820. * @function Highcharts.attr
  821. *
  822. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  823. * The DOM element to receive the attribute(s).
  824. *
  825. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  826. * The property or an object of key-value pairs.
  827. *
  828. * @param {number|string} [value]
  829. * The value if a single property is set.
  830. *
  831. * @return {string|null|undefined}
  832. * When used as a getter, return the value.
  833. */
  834. function attr(elem, prop, value) {
  835. var ret;
  836. // if the prop is a string
  837. if (isString(prop)) {
  838. // set the value
  839. if (defined(value)) {
  840. elem.setAttribute(prop, value);
  841. // get the value
  842. }
  843. else if (elem && elem.getAttribute) {
  844. ret = elem.getAttribute(prop);
  845. // IE7 and below cannot get class through getAttribute (#7850)
  846. if (!ret && prop === 'class') {
  847. ret = elem.getAttribute(prop + 'Name');
  848. }
  849. }
  850. // else if prop is defined, it is a hash of key/value pairs
  851. }
  852. else {
  853. objectEach(prop, function (val, key) {
  854. elem.setAttribute(key, val);
  855. });
  856. }
  857. return ret;
  858. }
  859. /**
  860. * Check if an element is an array, and if not, make it into an array.
  861. *
  862. * @function Highcharts.splat
  863. *
  864. * @param {*} obj
  865. * The object to splat.
  866. *
  867. * @return {Array}
  868. * The produced or original array.
  869. */
  870. function splat(obj) {
  871. return isArray(obj) ? obj : [obj];
  872. }
  873. /**
  874. * Set a timeout if the delay is given, otherwise perform the function
  875. * synchronously.
  876. *
  877. * @function Highcharts.syncTimeout
  878. *
  879. * @param {Function} fn
  880. * The function callback.
  881. *
  882. * @param {number} delay
  883. * Delay in milliseconds.
  884. *
  885. * @param {*} [context]
  886. * An optional context to send to the function callback.
  887. *
  888. * @return {number}
  889. * An identifier for the timeout that can later be cleared with
  890. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  891. */
  892. function syncTimeout(fn, delay, context) {
  893. if (delay > 0) {
  894. return setTimeout(fn, delay, context);
  895. }
  896. fn.call(0, context);
  897. return -1;
  898. }
  899. /**
  900. * Internal clear timeout. The function checks that the `id` was not removed
  901. * (e.g. by `chart.destroy()`). For the details see
  902. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  903. *
  904. * @function Highcharts.clearTimeout
  905. *
  906. * @param {number} id
  907. * Id of a timeout.
  908. *
  909. * @return {void}
  910. */
  911. function internalClearTimeout(id) {
  912. if (defined(id)) {
  913. clearTimeout(id);
  914. }
  915. }
  916. /* eslint-disable valid-jsdoc */
  917. /**
  918. * Utility function to extend an object with the members of another.
  919. *
  920. * @function Highcharts.extend<T>
  921. *
  922. * @param {T|undefined} a
  923. * The object to be extended.
  924. *
  925. * @param {Partial<T>} b
  926. * The object to add to the first one.
  927. *
  928. * @return {T}
  929. * Object a, the original object.
  930. */
  931. function extend(a, b) {
  932. /* eslint-enable valid-jsdoc */
  933. var n;
  934. if (!a) {
  935. a = {};
  936. }
  937. for (n in b) { // eslint-disable-line guard-for-in
  938. a[n] = b[n];
  939. }
  940. return a;
  941. }
  942. /* eslint-disable valid-jsdoc */
  943. /**
  944. * Return the first value that is not null or undefined.
  945. *
  946. * @function Highcharts.pick<T>
  947. *
  948. * @param {...Array<T|null|undefined>} items
  949. * Variable number of arguments to inspect.
  950. *
  951. * @return {T}
  952. * The value of the first argument that is not null or undefined.
  953. */
  954. function pick() {
  955. var args = arguments;
  956. var length = args.length;
  957. for (var i = 0; i < length; i++) {
  958. var arg = args[i];
  959. if (typeof arg !== 'undefined' && arg !== null) {
  960. return arg;
  961. }
  962. }
  963. }
  964. /**
  965. * Set CSS on a given element.
  966. *
  967. * @function Highcharts.css
  968. *
  969. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  970. * An HTML DOM element.
  971. *
  972. * @param {Highcharts.CSSObject} styles
  973. * Style object with camel case property names.
  974. *
  975. * @return {void}
  976. */
  977. function css(el, styles) {
  978. if (H.isMS && !H.svg) { // #2686
  979. if (styles && typeof styles.opacity !== 'undefined') {
  980. styles.filter =
  981. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  982. }
  983. }
  984. extend(el.style, styles);
  985. }
  986. /**
  987. * Utility function to create an HTML element with attributes and styles.
  988. *
  989. * @function Highcharts.createElement
  990. *
  991. * @param {string} tag
  992. * The HTML tag.
  993. *
  994. * @param {Highcharts.HTMLAttributes} [attribs]
  995. * Attributes as an object of key-value pairs.
  996. *
  997. * @param {Highcharts.CSSObject} [styles]
  998. * Styles as an object of key-value pairs.
  999. *
  1000. * @param {Highcharts.HTMLDOMElement} [parent]
  1001. * The parent HTML object.
  1002. *
  1003. * @param {boolean} [nopad=false]
  1004. * If true, remove all padding, border and margin.
  1005. *
  1006. * @return {Highcharts.HTMLDOMElement}
  1007. * The created DOM element.
  1008. */
  1009. function createElement(tag, attribs, styles, parent, nopad) {
  1010. var el = doc.createElement(tag);
  1011. if (attribs) {
  1012. extend(el, attribs);
  1013. }
  1014. if (nopad) {
  1015. css(el, { padding: '0', border: 'none', margin: '0' });
  1016. }
  1017. if (styles) {
  1018. css(el, styles);
  1019. }
  1020. if (parent) {
  1021. parent.appendChild(el);
  1022. }
  1023. return el;
  1024. }
  1025. // eslint-disable-next-line valid-jsdoc
  1026. /**
  1027. * Extend a prototyped class by new members.
  1028. *
  1029. * @function Highcharts.extendClass<T>
  1030. *
  1031. * @param {Highcharts.Class<T>} parent
  1032. * The parent prototype to inherit.
  1033. *
  1034. * @param {Highcharts.Dictionary<*>} members
  1035. * A collection of prototype members to add or override compared to the
  1036. * parent prototype.
  1037. *
  1038. * @return {Highcharts.Class<T>}
  1039. * A new prototype.
  1040. */
  1041. function extendClass(parent, members) {
  1042. var obj = (function () { });
  1043. obj.prototype = new parent(); // eslint-disable-line new-cap
  1044. extend(obj.prototype, members);
  1045. return obj;
  1046. }
  1047. /**
  1048. * Left-pad a string to a given length by adding a character repetetively.
  1049. *
  1050. * @function Highcharts.pad
  1051. *
  1052. * @param {number} number
  1053. * The input string or number.
  1054. *
  1055. * @param {number} [length]
  1056. * The desired string length.
  1057. *
  1058. * @param {string} [padder=0]
  1059. * The character to pad with.
  1060. *
  1061. * @return {string}
  1062. * The padded string.
  1063. */
  1064. function pad(number, length, padder) {
  1065. return new Array((length || 2) +
  1066. 1 -
  1067. String(number)
  1068. .replace('-', '')
  1069. .length).join(padder || '0') + number;
  1070. }
  1071. /**
  1072. * Return a length based on either the integer value, or a percentage of a base.
  1073. *
  1074. * @function Highcharts.relativeLength
  1075. *
  1076. * @param {Highcharts.RelativeSize} value
  1077. * A percentage string or a number.
  1078. *
  1079. * @param {number} base
  1080. * The full length that represents 100%.
  1081. *
  1082. * @param {number} [offset=0]
  1083. * A pixel offset to apply for percentage values. Used internally in
  1084. * axis positioning.
  1085. *
  1086. * @return {number}
  1087. * The computed length.
  1088. */
  1089. function relativeLength(value, base, offset) {
  1090. return (/%$/).test(value) ?
  1091. (base * parseFloat(value) / 100) + (offset || 0) :
  1092. parseFloat(value);
  1093. }
  1094. /**
  1095. * Wrap a method with extended functionality, preserving the original function.
  1096. *
  1097. * @function Highcharts.wrap
  1098. *
  1099. * @param {*} obj
  1100. * The context object that the method belongs to. In real cases, this is
  1101. * often a prototype.
  1102. *
  1103. * @param {string} method
  1104. * The name of the method to extend.
  1105. *
  1106. * @param {Highcharts.WrapProceedFunction} func
  1107. * A wrapper function callback. This function is called with the same
  1108. * arguments as the original function, except that the original function
  1109. * is unshifted and passed as the first argument.
  1110. */
  1111. function wrap(obj, method, func) {
  1112. var proceed = obj[method];
  1113. obj[method] = function () {
  1114. var args = Array.prototype.slice.call(arguments),
  1115. outerArgs = arguments,
  1116. ctx = this;
  1117. ctx.proceed = function () {
  1118. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1119. };
  1120. args.unshift(proceed);
  1121. var ret = func.apply(this,
  1122. args);
  1123. ctx.proceed = null;
  1124. return ret;
  1125. };
  1126. }
  1127. /**
  1128. * Get the magnitude of a number.
  1129. *
  1130. * @function Highcharts.getMagnitude
  1131. *
  1132. * @param {number} num
  1133. * The number.
  1134. *
  1135. * @return {number}
  1136. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1137. */
  1138. function getMagnitude(num) {
  1139. return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
  1140. }
  1141. /**
  1142. * Take an interval and normalize it to multiples of round numbers.
  1143. *
  1144. * @deprecated
  1145. * @function Highcharts.normalizeTickInterval
  1146. *
  1147. * @param {number} interval
  1148. * The raw, un-rounded interval.
  1149. *
  1150. * @param {Array<*>} [multiples]
  1151. * Allowed multiples.
  1152. *
  1153. * @param {number} [magnitude]
  1154. * The magnitude of the number.
  1155. *
  1156. * @param {boolean} [allowDecimals]
  1157. * Whether to allow decimals.
  1158. *
  1159. * @param {boolean} [hasTickAmount]
  1160. * If it has tickAmount, avoid landing on tick intervals lower than
  1161. * original.
  1162. *
  1163. * @return {number}
  1164. * The normalized interval.
  1165. *
  1166. * @todo
  1167. * Move this function to the Axis prototype. It is here only for historical
  1168. * reasons.
  1169. */
  1170. function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) {
  1171. var i,
  1172. retInterval = interval;
  1173. // round to a tenfold of 1, 2, 2.5 or 5
  1174. magnitude = pick(magnitude, 1);
  1175. var normalized = interval / magnitude;
  1176. // multiples for a linear scale
  1177. if (!multiples) {
  1178. multiples = hasTickAmount ?
  1179. // Finer grained ticks when the tick amount is hard set, including
  1180. // when alignTicks is true on multiple axes (#4580).
  1181. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1182. // Else, let ticks fall on rounder numbers
  1183. [1, 2, 2.5, 5, 10];
  1184. // the allowDecimals option
  1185. if (allowDecimals === false) {
  1186. if (magnitude === 1) {
  1187. multiples = multiples.filter(function (num) {
  1188. return num % 1 === 0;
  1189. });
  1190. }
  1191. else if (magnitude <= 0.1) {
  1192. multiples = [1 / magnitude];
  1193. }
  1194. }
  1195. }
  1196. // normalize the interval to the nearest multiple
  1197. for (i = 0; i < multiples.length; i++) {
  1198. retInterval = multiples[i];
  1199. // only allow tick amounts smaller than natural
  1200. if ((hasTickAmount &&
  1201. retInterval * magnitude >= interval) ||
  1202. (!hasTickAmount &&
  1203. (normalized <=
  1204. (multiples[i] +
  1205. (multiples[i + 1] || multiples[i])) / 2))) {
  1206. break;
  1207. }
  1208. }
  1209. // Multiply back to the correct magnitude. Correct floats to appropriate
  1210. // precision (#6085).
  1211. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1212. return retInterval;
  1213. }
  1214. /**
  1215. * Sort an object array and keep the order of equal items. The ECMAScript
  1216. * standard does not specify the behaviour when items are equal.
  1217. *
  1218. * @function Highcharts.stableSort
  1219. *
  1220. * @param {Array<*>} arr
  1221. * The array to sort.
  1222. *
  1223. * @param {Function} sortFunction
  1224. * The function to sort it with, like with regular Array.prototype.sort.
  1225. *
  1226. * @return {void}
  1227. */
  1228. function stableSort(arr, sortFunction) {
  1229. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1230. // plus all other browsers do it, so over time we may be able to remove this
  1231. // function
  1232. var length = arr.length;
  1233. var sortValue,
  1234. i;
  1235. // Add index to each item
  1236. for (i = 0; i < length; i++) {
  1237. arr[i].safeI = i; // stable sort index
  1238. }
  1239. arr.sort(function (a, b) {
  1240. sortValue = sortFunction(a, b);
  1241. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1242. });
  1243. // Remove index from items
  1244. for (i = 0; i < length; i++) {
  1245. delete arr[i].safeI; // stable sort index
  1246. }
  1247. }
  1248. /**
  1249. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1250. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1251. * than 150.000 points. This method is slightly slower, but safe.
  1252. *
  1253. * @function Highcharts.arrayMin
  1254. *
  1255. * @param {Array<*>} data
  1256. * An array of numbers.
  1257. *
  1258. * @return {number}
  1259. * The lowest number.
  1260. */
  1261. function arrayMin(data) {
  1262. var i = data.length,
  1263. min = data[0];
  1264. while (i--) {
  1265. if (data[i] < min) {
  1266. min = data[i];
  1267. }
  1268. }
  1269. return min;
  1270. }
  1271. /**
  1272. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1273. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1274. * than 150.000 points. This method is slightly slower, but safe.
  1275. *
  1276. * @function Highcharts.arrayMax
  1277. *
  1278. * @param {Array<*>} data
  1279. * An array of numbers.
  1280. *
  1281. * @return {number}
  1282. * The highest number.
  1283. */
  1284. function arrayMax(data) {
  1285. var i = data.length,
  1286. max = data[0];
  1287. while (i--) {
  1288. if (data[i] > max) {
  1289. max = data[i];
  1290. }
  1291. }
  1292. return max;
  1293. }
  1294. /**
  1295. * Utility method that destroys any SVGElement instances that are properties on
  1296. * the given object. It loops all properties and invokes destroy if there is a
  1297. * destroy method. The property is then delete.
  1298. *
  1299. * @function Highcharts.destroyObjectProperties
  1300. *
  1301. * @param {*} obj
  1302. * The object to destroy properties on.
  1303. *
  1304. * @param {*} [except]
  1305. * Exception, do not destroy this property, only delete it.
  1306. */
  1307. function destroyObjectProperties(obj, except) {
  1308. objectEach(obj, function (val, n) {
  1309. // If the object is non-null and destroy is defined
  1310. if (val && val !== except && val.destroy) {
  1311. // Invoke the destroy
  1312. val.destroy();
  1313. }
  1314. // Delete the property from the object.
  1315. delete obj[n];
  1316. });
  1317. }
  1318. /**
  1319. * Discard a HTML element by moving it to the bin and delete.
  1320. *
  1321. * @function Highcharts.discardElement
  1322. *
  1323. * @param {Highcharts.HTMLDOMElement} element
  1324. * The HTML node to discard.
  1325. */
  1326. function discardElement(element) {
  1327. // create a garbage bin element, not part of the DOM
  1328. if (!garbageBin) {
  1329. garbageBin = createElement('div');
  1330. }
  1331. // move the node and empty bin
  1332. if (element) {
  1333. garbageBin.appendChild(element);
  1334. }
  1335. garbageBin.innerHTML = '';
  1336. }
  1337. var garbageBin;
  1338. /**
  1339. * Fix JS round off float errors.
  1340. *
  1341. * @function Highcharts.correctFloat
  1342. *
  1343. * @param {number} num
  1344. * A float number to fix.
  1345. *
  1346. * @param {number} [prec=14]
  1347. * The precision.
  1348. *
  1349. * @return {number}
  1350. * The corrected float number.
  1351. */
  1352. function correctFloat(num, prec) {
  1353. return parseFloat(num.toPrecision(prec || 14));
  1354. }
  1355. /**
  1356. * The time unit lookup
  1357. *
  1358. * @ignore
  1359. */
  1360. var timeUnits = {
  1361. millisecond: 1,
  1362. second: 1000,
  1363. minute: 60000,
  1364. hour: 3600000,
  1365. day: 24 * 3600000,
  1366. week: 7 * 24 * 3600000,
  1367. month: 28 * 24 * 3600000,
  1368. year: 364 * 24 * 3600000
  1369. };
  1370. /**
  1371. * Easing definition
  1372. *
  1373. * @private
  1374. * @function Math.easeInOutSine
  1375. *
  1376. * @param {number} pos
  1377. * Current position, ranging from 0 to 1.
  1378. *
  1379. * @return {number}
  1380. * Ease result
  1381. */
  1382. Math.easeInOutSine = function (pos) {
  1383. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1384. };
  1385. /**
  1386. * Returns the value of a property path on a given object.
  1387. *
  1388. * @private
  1389. * @function getNestedProperty
  1390. *
  1391. * @param {string} path
  1392. * Path to the property, for example `custom.myValue`.
  1393. *
  1394. * @param {unknown} obj
  1395. * Instance containing the property on the specific path.
  1396. *
  1397. * @return {unknown}
  1398. * The unknown property value.
  1399. */
  1400. function getNestedProperty(path, parent) {
  1401. var pathElements = path.split('.');
  1402. while (pathElements.length && defined(parent)) {
  1403. var pathElement = pathElements.shift();
  1404. // Filter on the key
  1405. if (typeof pathElement === 'undefined' ||
  1406. pathElement === '__proto__') {
  1407. return; // undefined
  1408. }
  1409. var child = parent[pathElement];
  1410. // Filter on the child
  1411. if (!defined(child) ||
  1412. typeof child === 'function' ||
  1413. typeof child.nodeType === 'number' ||
  1414. child === win) {
  1415. return; // undefined
  1416. }
  1417. // Else, proceed
  1418. parent = child;
  1419. }
  1420. return parent;
  1421. }
  1422. /**
  1423. * Get the computed CSS value for given element and property, only for numerical
  1424. * properties. For width and height, the dimension of the inner box (excluding
  1425. * padding) is returned. Used for fitting the chart within the container.
  1426. *
  1427. * @function Highcharts.getStyle
  1428. *
  1429. * @param {Highcharts.HTMLDOMElement} el
  1430. * An HTML element.
  1431. *
  1432. * @param {string} prop
  1433. * The property name.
  1434. *
  1435. * @param {boolean} [toInt=true]
  1436. * Parse to integer.
  1437. *
  1438. * @return {number|string|undefined}
  1439. * The style value.
  1440. */
  1441. function getStyle(el, prop, toInt) {
  1442. var customGetStyle = (H.getStyle || // oldie getStyle
  1443. getStyle);
  1444. var style;
  1445. // For width and height, return the actual inner pixel size (#4913)
  1446. if (prop === 'width') {
  1447. var offsetWidth = Math.min(el.offsetWidth,
  1448. el.scrollWidth);
  1449. // In flex boxes, we need to use getBoundingClientRect and floor it,
  1450. // because scrollWidth doesn't support subpixel precision (#6427) ...
  1451. var boundingClientRectWidth = el.getBoundingClientRect &&
  1452. el.getBoundingClientRect().width;
  1453. // ...unless if the containing div or its parents are transform-scaled
  1454. // down, in which case the boundingClientRect can't be used as it is
  1455. // also scaled down (#9871, #10498).
  1456. if (boundingClientRectWidth < offsetWidth &&
  1457. boundingClientRectWidth >= offsetWidth - 1) {
  1458. offsetWidth = Math.floor(boundingClientRectWidth);
  1459. }
  1460. return Math.max(0, // #8377
  1461. (offsetWidth -
  1462. (customGetStyle(el, 'padding-left', true) || 0) -
  1463. (customGetStyle(el, 'padding-right', true) || 0)));
  1464. }
  1465. if (prop === 'height') {
  1466. return Math.max(0, // #8377
  1467. (Math.min(el.offsetHeight, el.scrollHeight) -
  1468. (customGetStyle(el, 'padding-top', true) || 0) -
  1469. (customGetStyle(el, 'padding-bottom', true) || 0)));
  1470. }
  1471. if (!win.getComputedStyle) {
  1472. // SVG not supported, forgot to load oldie.js?
  1473. error(27, true);
  1474. }
  1475. // Otherwise, get the computed style
  1476. var css = win.getComputedStyle(el,
  1477. undefined); // eslint-disable-line no-undefined
  1478. if (css) {
  1479. style = css.getPropertyValue(prop);
  1480. if (pick(toInt, prop !== 'opacity')) {
  1481. style = pInt(style);
  1482. }
  1483. }
  1484. return style;
  1485. }
  1486. /**
  1487. * Search for an item in an array.
  1488. *
  1489. * @function Highcharts.inArray
  1490. *
  1491. * @deprecated
  1492. *
  1493. * @param {*} item
  1494. * The item to search for.
  1495. *
  1496. * @param {Array<*>} arr
  1497. * The array or node collection to search in.
  1498. *
  1499. * @param {number} [fromIndex=0]
  1500. * The index to start searching from.
  1501. *
  1502. * @return {number}
  1503. * The index within the array, or -1 if not found.
  1504. */
  1505. function inArray(item, arr, fromIndex) {
  1506. error(32, false, void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  1507. return arr.indexOf(item, fromIndex);
  1508. }
  1509. /**
  1510. * Return the value of the first element in the array that satisfies the
  1511. * provided testing function.
  1512. *
  1513. * @function Highcharts.find<T>
  1514. *
  1515. * @param {Array<T>} arr
  1516. * The array to test.
  1517. *
  1518. * @param {Function} callback
  1519. * The callback function. The function receives the item as the first
  1520. * argument. Return `true` if this item satisfies the condition.
  1521. *
  1522. * @return {T|undefined}
  1523. * The value of the element.
  1524. */
  1525. var find = Array.prototype.find ?
  1526. function (arr,
  1527. callback) {
  1528. return arr.find(callback);
  1529. } :
  1530. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1531. function (arr, callback) {
  1532. var i;
  1533. var length = arr.length;
  1534. for (i = 0; i < length; i++) {
  1535. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1536. return arr[i];
  1537. }
  1538. }
  1539. };
  1540. /**
  1541. * Returns an array of a given object's own properties.
  1542. *
  1543. * @function Highcharts.keys
  1544. * @deprecated
  1545. *
  1546. * @param {*} obj
  1547. * The object of which the properties are to be returned.
  1548. *
  1549. * @return {Array<string>}
  1550. * An array of strings that represents all the properties.
  1551. */
  1552. function keys(obj) {
  1553. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1554. return Object.keys(obj);
  1555. }
  1556. /**
  1557. * Get the element's offset position, corrected for `overflow: auto`.
  1558. *
  1559. * @function Highcharts.offset
  1560. *
  1561. * @param {global.Element} el
  1562. * The DOM element.
  1563. *
  1564. * @return {Highcharts.OffsetObject}
  1565. * An object containing `left` and `top` properties for the position in
  1566. * the page.
  1567. */
  1568. function offset(el) {
  1569. var docElem = doc.documentElement,
  1570. box = (el.parentElement || el.parentNode) ?
  1571. el.getBoundingClientRect() :
  1572. { top: 0,
  1573. left: 0,
  1574. width: 0,
  1575. height: 0 };
  1576. return {
  1577. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1578. (docElem.clientTop || 0),
  1579. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1580. (docElem.clientLeft || 0),
  1581. width: box.width,
  1582. height: box.height
  1583. };
  1584. }
  1585. /* eslint-disable valid-jsdoc */
  1586. /**
  1587. * Iterate over object key pairs in an object.
  1588. *
  1589. * @function Highcharts.objectEach<T>
  1590. *
  1591. * @param {*} obj
  1592. * The object to iterate over.
  1593. *
  1594. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1595. * The iterator callback. It passes three arguments:
  1596. * * value - The property value.
  1597. * * key - The property key.
  1598. * * obj - The object that objectEach is being applied to.
  1599. *
  1600. * @param {T} [ctx]
  1601. * The context.
  1602. *
  1603. * @return {void}
  1604. */
  1605. function objectEach(obj, fn, ctx) {
  1606. /* eslint-enable valid-jsdoc */
  1607. for (var key in obj) {
  1608. if (Object.hasOwnProperty.call(obj, key)) {
  1609. fn.call(ctx || obj[key], obj[key], key, obj);
  1610. }
  1611. }
  1612. }
  1613. /**
  1614. * Iterate over an array.
  1615. *
  1616. * @deprecated
  1617. * @function Highcharts.each
  1618. *
  1619. * @param {Array<*>} arr
  1620. * The array to iterate over.
  1621. *
  1622. * @param {Function} fn
  1623. * The iterator callback. It passes three arguments:
  1624. * - `item`: The array item.
  1625. * - `index`: The item's index in the array.
  1626. * - `arr`: The array that each is being applied to.
  1627. *
  1628. * @param {*} [ctx]
  1629. * The context.
  1630. *
  1631. * @return {void}
  1632. */
  1633. /**
  1634. * Filter an array by a callback.
  1635. *
  1636. * @deprecated
  1637. * @function Highcharts.grep
  1638. *
  1639. * @param {Array<*>} arr
  1640. * The array to filter.
  1641. *
  1642. * @param {Function} callback
  1643. * The callback function. The function receives the item as the first
  1644. * argument. Return `true` if the item is to be preserved.
  1645. *
  1646. * @return {Array<*>}
  1647. * A new, filtered array.
  1648. */
  1649. /**
  1650. * Map an array by a callback.
  1651. *
  1652. * @deprecated
  1653. * @function Highcharts.map
  1654. *
  1655. * @param {Array<*>} arr
  1656. * The array to map.
  1657. *
  1658. * @param {Function} fn
  1659. * The callback function. Return the new value for the new array.
  1660. *
  1661. * @return {Array<*>}
  1662. * A new array item with modified items.
  1663. */
  1664. /**
  1665. * Reduce an array to a single value.
  1666. *
  1667. * @deprecated
  1668. * @function Highcharts.reduce
  1669. *
  1670. * @param {Array<*>} arr
  1671. * The array to reduce.
  1672. *
  1673. * @param {Function} fn
  1674. * The callback function. Return the reduced value. Receives 4
  1675. * arguments: Accumulated/reduced value, current value, current array
  1676. * index, and the array.
  1677. *
  1678. * @param {*} initialValue
  1679. * The initial value of the accumulator.
  1680. *
  1681. * @return {*}
  1682. * The reduced value.
  1683. */
  1684. /**
  1685. * Test whether at least one element in the array passes the test implemented by
  1686. * the provided function.
  1687. *
  1688. * @deprecated
  1689. * @function Highcharts.some
  1690. *
  1691. * @param {Array<*>} arr
  1692. * The array to test
  1693. *
  1694. * @param {Function} fn
  1695. * The function to run on each item. Return truty to pass the test.
  1696. * Receives arguments `currentValue`, `index` and `array`.
  1697. *
  1698. * @param {*} ctx
  1699. * The context.
  1700. *
  1701. * @return {boolean}
  1702. */
  1703. objectEach({
  1704. map: 'map',
  1705. each: 'forEach',
  1706. grep: 'filter',
  1707. reduce: 'reduce',
  1708. some: 'some'
  1709. }, function (val, key) {
  1710. H[key] = function (arr) {
  1711. var _a;
  1712. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1713. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1714. };
  1715. });
  1716. /* eslint-disable valid-jsdoc */
  1717. /**
  1718. * Add an event listener.
  1719. *
  1720. * @function Highcharts.addEvent<T>
  1721. *
  1722. * @param {Highcharts.Class<T>|T} el
  1723. * The element or object to add a listener to. It can be a
  1724. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1725. *
  1726. * @param {string} type
  1727. * The event type.
  1728. *
  1729. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1730. * The function callback to execute when the event is fired.
  1731. *
  1732. * @param {Highcharts.EventOptionsObject} [options]
  1733. * Options for adding the event.
  1734. *
  1735. * @return {Function}
  1736. * A callback function to remove the added event.
  1737. */
  1738. function addEvent(el, type, fn, options) {
  1739. /* eslint-enable valid-jsdoc */
  1740. if (options === void 0) { options = {}; }
  1741. // Add hcEvents to either the prototype (in case we're running addEvent on a
  1742. // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
  1743. // inherited down the prototype chain, in which case we need to set the
  1744. // property on this instance (which may itself be a prototype).
  1745. var owner = typeof el === 'function' && el.prototype || el;
  1746. if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1747. owner.hcEvents = {};
  1748. }
  1749. var events = owner.hcEvents;
  1750. // Allow click events added to points, otherwise they will be prevented by
  1751. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1752. if (H.Point && // without H a dependency loop occurs
  1753. el instanceof H.Point &&
  1754. el.series &&
  1755. el.series.chart) {
  1756. el.series.chart.runTrackerClick = true;
  1757. }
  1758. // Handle DOM events
  1759. // If the browser supports passive events, add it to improve performance
  1760. // on touch events (#11353).
  1761. var addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1762. if (addEventListener) {
  1763. addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
  1764. passive: options.passive === void 0 ?
  1765. type.indexOf('touch') !== -1 : options.passive,
  1766. capture: false
  1767. } : false);
  1768. }
  1769. if (!events[type]) {
  1770. events[type] = [];
  1771. }
  1772. var eventObject = {
  1773. fn: fn,
  1774. order: typeof options.order === 'number' ? options.order : Infinity
  1775. };
  1776. events[type].push(eventObject);
  1777. // Order the calls
  1778. events[type].sort(function (a, b) { return a.order - b.order; });
  1779. // Return a function that can be called to remove this event.
  1780. return function () {
  1781. removeEvent(el, type, fn);
  1782. };
  1783. }
  1784. /* eslint-disable valid-jsdoc */
  1785. /**
  1786. * Remove an event that was added with {@link Highcharts#addEvent}.
  1787. *
  1788. * @function Highcharts.removeEvent<T>
  1789. *
  1790. * @param {Highcharts.Class<T>|T} el
  1791. * The element to remove events on.
  1792. *
  1793. * @param {string} [type]
  1794. * The type of events to remove. If undefined, all events are removed
  1795. * from the element.
  1796. *
  1797. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1798. * The specific callback to remove. If undefined, all events that match
  1799. * the element and optionally the type are removed.
  1800. *
  1801. * @return {void}
  1802. */
  1803. function removeEvent(el, type, fn) {
  1804. /* eslint-enable valid-jsdoc */
  1805. /**
  1806. * @private
  1807. * @param {string} type - event type
  1808. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1809. * @return {void}
  1810. */
  1811. function removeOneEvent(type, fn) {
  1812. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1813. if (removeEventListener) {
  1814. removeEventListener.call(el, type, fn, false);
  1815. }
  1816. }
  1817. /**
  1818. * @private
  1819. * @param {any} eventCollection - collection
  1820. * @return {void}
  1821. */
  1822. function removeAllEvents(eventCollection) {
  1823. var types,
  1824. len;
  1825. if (!el.nodeName) {
  1826. return; // break on non-DOM events
  1827. }
  1828. if (type) {
  1829. types = {};
  1830. types[type] = true;
  1831. }
  1832. else {
  1833. types = eventCollection;
  1834. }
  1835. objectEach(types, function (_val, n) {
  1836. if (eventCollection[n]) {
  1837. len = eventCollection[n].length;
  1838. while (len--) {
  1839. removeOneEvent(n, eventCollection[n][len].fn);
  1840. }
  1841. }
  1842. });
  1843. }
  1844. var owner = typeof el === 'function' && el.prototype || el;
  1845. if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1846. var events = owner.hcEvents;
  1847. if (type) {
  1848. var typeEvents = (events[type] || []);
  1849. if (fn) {
  1850. events[type] = typeEvents.filter(function (obj) {
  1851. return fn !== obj.fn;
  1852. });
  1853. removeOneEvent(type, fn);
  1854. }
  1855. else {
  1856. removeAllEvents(events);
  1857. events[type] = [];
  1858. }
  1859. }
  1860. else {
  1861. removeAllEvents(events);
  1862. delete owner.hcEvents;
  1863. }
  1864. }
  1865. }
  1866. /* eslint-disable valid-jsdoc */
  1867. /**
  1868. * Fire an event that was registered with {@link Highcharts#addEvent}.
  1869. *
  1870. * @function Highcharts.fireEvent<T>
  1871. *
  1872. * @param {T} el
  1873. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  1874. * an {@link SVGElement} or any other object.
  1875. *
  1876. * @param {string} type
  1877. * The type of event.
  1878. *
  1879. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  1880. * Custom event arguments that are passed on as an argument to the event
  1881. * handler.
  1882. *
  1883. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  1884. * The default function to execute if the other listeners haven't
  1885. * returned false.
  1886. *
  1887. * @return {void}
  1888. */
  1889. function fireEvent(el, type, eventArguments, defaultFunction) {
  1890. /* eslint-enable valid-jsdoc */
  1891. var e,
  1892. i;
  1893. eventArguments = eventArguments || {};
  1894. if (doc.createEvent &&
  1895. (el.dispatchEvent ||
  1896. (el.fireEvent &&
  1897. // Enable firing events on Highcharts instance.
  1898. el !== H))) {
  1899. e = doc.createEvent('Events');
  1900. e.initEvent(type, true, true);
  1901. eventArguments = extend(e, eventArguments);
  1902. if (el.dispatchEvent) {
  1903. el.dispatchEvent(eventArguments);
  1904. }
  1905. else {
  1906. el.fireEvent(type, eventArguments);
  1907. }
  1908. }
  1909. else if (el.hcEvents) {
  1910. if (!eventArguments.target) {
  1911. // We're running a custom event
  1912. extend(eventArguments, {
  1913. // Attach a simple preventDefault function to skip
  1914. // default handler if called. The built-in
  1915. // defaultPrevented property is not overwritable (#5112)
  1916. preventDefault: function () {
  1917. eventArguments.defaultPrevented = true;
  1918. },
  1919. // Setting target to native events fails with clicking
  1920. // the zoom-out button in Chrome.
  1921. target: el,
  1922. // If the type is not set, we're running a custom event
  1923. // (#2297). If it is set, we're running a browser event,
  1924. // and setting it will cause en error in IE8 (#2465).
  1925. type: type
  1926. });
  1927. }
  1928. var events = [];
  1929. var object = el;
  1930. var multilevel = false;
  1931. // Recurse up the inheritance chain and collect hcEvents set as own
  1932. // objects on the prototypes.
  1933. while (object.hcEvents) {
  1934. if (Object.hasOwnProperty.call(object, 'hcEvents') &&
  1935. object.hcEvents[type]) {
  1936. if (events.length) {
  1937. multilevel = true;
  1938. }
  1939. events.unshift.apply(events, object.hcEvents[type]);
  1940. }
  1941. object = Object.getPrototypeOf(object);
  1942. }
  1943. // For performance reasons, only sort the event handlers in case we are
  1944. // dealing with multiple levels in the prototype chain. Otherwise, the
  1945. // events are already sorted in the addEvent function.
  1946. if (multilevel) {
  1947. // Order the calls
  1948. events.sort(function (a, b) { return a.order - b.order; });
  1949. }
  1950. // Call the collected event handlers
  1951. events.forEach(function (obj) {
  1952. // If the event handler returns false, prevent the default handler
  1953. // from executing
  1954. if (obj.fn.call(el, eventArguments) === false) {
  1955. eventArguments.preventDefault();
  1956. }
  1957. });
  1958. }
  1959. // Run the default if not prevented
  1960. if (defaultFunction && !eventArguments.defaultPrevented) {
  1961. defaultFunction.call(el, eventArguments);
  1962. }
  1963. }
  1964. var serialMode;
  1965. /**
  1966. * Get a unique key for using in internal element id's and pointers. The key is
  1967. * composed of a random hash specific to this Highcharts instance, and a
  1968. * counter.
  1969. *
  1970. * @example
  1971. * let id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  1972. *
  1973. * @function Highcharts.uniqueKey
  1974. *
  1975. * @return {string}
  1976. * A unique key.
  1977. */
  1978. var uniqueKey = (function () {
  1979. var hash = Math.random().toString(36).substring(2, 9) + '-';
  1980. var id = 0;
  1981. return function () {
  1982. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  1983. };
  1984. }());
  1985. /**
  1986. * Activates a serial mode for element IDs provided by
  1987. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  1988. * a simple comparison of two rendered SVG graphics is needed.
  1989. *
  1990. * **Note:** This is only for testing purposes and will break functionality in
  1991. * webpages with multiple charts.
  1992. *
  1993. * @example
  1994. * if (
  1995. * process &&
  1996. * process.env.NODE_ENV === 'development'
  1997. * ) {
  1998. * Highcharts.useSerialIds(true);
  1999. * }
  2000. *
  2001. * @function Highcharts.useSerialIds
  2002. *
  2003. * @param {boolean} [mode]
  2004. * Changes the state of serial mode.
  2005. *
  2006. * @return {boolean|undefined}
  2007. * State of the serial mode.
  2008. */
  2009. function useSerialIds(mode) {
  2010. return (serialMode = pick(mode, serialMode));
  2011. }
  2012. function isFunction(obj) {
  2013. return typeof obj === 'function';
  2014. }
  2015. // Register Highcharts as a plugin in jQuery
  2016. if (win.jQuery) {
  2017. /**
  2018. * Highcharts-extended JQuery.
  2019. *
  2020. * @external JQuery
  2021. */
  2022. /**
  2023. * Helper function to return the chart of the current JQuery selector
  2024. * element.
  2025. *
  2026. * @function external:JQuery#highcharts
  2027. *
  2028. * @return {Highcharts.Chart}
  2029. * The chart that is linked to the JQuery selector element.
  2030. */ /**
  2031. * Factory function to create a chart in the current JQuery selector
  2032. * element.
  2033. *
  2034. * @function external:JQuery#highcharts
  2035. *
  2036. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2037. * Name of the factory class in the Highcharts namespace.
  2038. *
  2039. * @param {Highcharts.Options} [options]
  2040. * The chart options structure.
  2041. *
  2042. * @param {Highcharts.ChartCallbackFunction} [callback]
  2043. * Function to run when the chart has loaded and and all external
  2044. * images are loaded. Defining a
  2045. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2046. * handler is equivalent.
  2047. *
  2048. * @return {JQuery}
  2049. * The current JQuery selector.
  2050. */
  2051. win.jQuery.fn.highcharts = function () {
  2052. var args = [].slice.call(arguments);
  2053. if (this[0]) { // this[0] is the renderTo div
  2054. // Create the chart
  2055. if (args[0]) {
  2056. new H[ // eslint-disable-line computed-property-spacing, no-new
  2057. // Constructor defaults to Chart
  2058. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2059. return this;
  2060. }
  2061. // When called without parameters or with the return argument,
  2062. // return an existing chart
  2063. return charts[attr(this[0], 'data-highcharts-chart')];
  2064. }
  2065. };
  2066. }
  2067. // TODO use named exports when supported.
  2068. var Utilities = {
  2069. addEvent: addEvent,
  2070. arrayMax: arrayMax,
  2071. arrayMin: arrayMin,
  2072. attr: attr,
  2073. clamp: clamp,
  2074. cleanRecursively: cleanRecursively,
  2075. clearTimeout: internalClearTimeout,
  2076. correctFloat: correctFloat,
  2077. createElement: createElement,
  2078. css: css,
  2079. defined: defined,
  2080. destroyObjectProperties: destroyObjectProperties,
  2081. discardElement: discardElement,
  2082. erase: erase,
  2083. error: error,
  2084. extend: extend,
  2085. extendClass: extendClass,
  2086. find: find,
  2087. fireEvent: fireEvent,
  2088. getMagnitude: getMagnitude,
  2089. getNestedProperty: getNestedProperty,
  2090. getStyle: getStyle,
  2091. inArray: inArray,
  2092. isArray: isArray,
  2093. isClass: isClass,
  2094. isDOMElement: isDOMElement,
  2095. isFunction: isFunction,
  2096. isNumber: isNumber,
  2097. isObject: isObject,
  2098. isString: isString,
  2099. keys: keys,
  2100. merge: merge,
  2101. normalizeTickInterval: normalizeTickInterval,
  2102. objectEach: objectEach,
  2103. offset: offset,
  2104. pad: pad,
  2105. pick: pick,
  2106. pInt: pInt,
  2107. relativeLength: relativeLength,
  2108. removeEvent: removeEvent,
  2109. splat: splat,
  2110. stableSort: stableSort,
  2111. syncTimeout: syncTimeout,
  2112. timeUnits: timeUnits,
  2113. uniqueKey: uniqueKey,
  2114. useSerialIds: useSerialIds,
  2115. wrap: wrap
  2116. };
  2117. return Utilities;
  2118. });
  2119. _registerModule(_modules, 'Core/Color/Palette.js', [], function () {
  2120. var palette = {
  2121. /**
  2122. * Colors for data series and points.
  2123. */
  2124. colors: [
  2125. '#7cb5ec',
  2126. '#434348',
  2127. '#90ed7d',
  2128. '#f7a35c',
  2129. '#8085e9',
  2130. '#f15c80',
  2131. '#e4d354',
  2132. '#2b908f',
  2133. '#f45b5b',
  2134. '#91e8e1'
  2135. ],
  2136. /**
  2137. * Chart background,
  2138. point stroke for markers and columns etc
  2139. */
  2140. backgroundColor: '#ffffff',
  2141. /**
  2142. * Strong text.
  2143. */
  2144. neutralColor100: '#000000',
  2145. /**
  2146. * Main text and some strokes.
  2147. */
  2148. neutralColor80: '#333333',
  2149. /**
  2150. * Axis labels,
  2151. axis title,
  2152. connector fallback.
  2153. */
  2154. neutralColor60: '#666666',
  2155. /**
  2156. * Credits text,
  2157. export menu stroke.
  2158. */
  2159. neutralColor40: '#999999',
  2160. /**
  2161. * Disabled texts,
  2162. button strokes,
  2163. crosshair etc.
  2164. */
  2165. neutralColor20: '#cccccc',
  2166. /**
  2167. * Grid lines etc.
  2168. */
  2169. neutralColor10: '#e6e6e6',
  2170. /**
  2171. * Minor grid lines etc.
  2172. */
  2173. neutralColor5: '#f2f2f2',
  2174. /**
  2175. * Tooltip backgroud,
  2176. button fills,
  2177. map null points.
  2178. */
  2179. neutralColor3: '#f7f7f7',
  2180. /**
  2181. * Drilldown clickable labels,
  2182. color axis max color.
  2183. */
  2184. highlightColor100: '#003399',
  2185. /**
  2186. * Selection marker,
  2187. menu hover,
  2188. button hover,
  2189. chart border,
  2190. navigator series.
  2191. */
  2192. highlightColor80: '#335cad',
  2193. /**
  2194. * Navigator mask fill.
  2195. */
  2196. highlightColor60: '#6685c2',
  2197. /**
  2198. * Ticks and axis line.
  2199. */
  2200. highlightColor20: '#ccd6eb',
  2201. /**
  2202. * Pressed button,
  2203. color axis min color.
  2204. */
  2205. highlightColor10: '#e6ebf5',
  2206. /**
  2207. * Positive indicator color
  2208. */
  2209. positiveColor: '#06b535',
  2210. /**
  2211. * Negative indicator color
  2212. */
  2213. negativeColor: '#f21313'
  2214. };
  2215. return palette;
  2216. });
  2217. _registerModule(_modules, 'Core/Chart/ChartDefaults.js', [_modules['Core/Color/Palette.js']], function (Palette) {
  2218. /* *
  2219. *
  2220. * (c) 2010-2021 Torstein Honsi
  2221. *
  2222. * License: www.highcharts.com/license
  2223. *
  2224. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2225. *
  2226. * */
  2227. /* *
  2228. *
  2229. * Constants
  2230. *
  2231. * */
  2232. /**
  2233. * General options for the chart.
  2234. *
  2235. * @optionparent chart
  2236. */
  2237. var ChartDefaults = {
  2238. /**
  2239. * Default `mapData` for all series. If set to a string,
  2240. it functions
  2241. * as an index into the `Highcharts.maps` array. Otherwise it is
  2242. * interpreted as map data.
  2243. *
  2244. * @see [mapData](#series.map.mapData)
  2245. *
  2246. * @sample maps/demo/geojson
  2247. * Loading geoJSON data
  2248. * @sample maps/chart/topojson
  2249. * Loading topoJSON converted to geoJSON
  2250. *
  2251. * @type {string|Array<*>|Highcharts.GeoJSON}
  2252. * @since 5.0.0
  2253. * @product highmaps
  2254. * @apioption chart.map
  2255. */
  2256. /**
  2257. * Set lat/lon transformation definitions for the chart. If not defined,
  2258. * these are extracted from the map data.
  2259. *
  2260. * @type {*}
  2261. * @since 5.0.0
  2262. * @product highmaps
  2263. * @apioption chart.mapTransforms
  2264. */
  2265. /**
  2266. * When using multiple axis,
  2267. the ticks of two or more opposite axes
  2268. * will automatically be aligned by adding ticks to the axis or axes
  2269. * with the least ticks,
  2270. as if `tickAmount` were specified.
  2271. *
  2272. * This can be prevented by setting `alignTicks` to false. If the grid
  2273. * lines look messy,
  2274. it's a good idea to hide them for the secondary
  2275. * axis by setting `gridLineWidth` to 0.
  2276. *
  2277. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  2278. * then the `alignTicks ` will be disabled for the Axis.
  2279. *
  2280. * Disabled for logarithmic axes.
  2281. *
  2282. * @sample {highcharts} highcharts/chart/alignticks-true/
  2283. * True by default
  2284. * @sample {highcharts} highcharts/chart/alignticks-false/
  2285. * False
  2286. * @sample {highstock} stock/chart/alignticks-true/
  2287. * True by default
  2288. * @sample {highstock} stock/chart/alignticks-false/
  2289. * False
  2290. *
  2291. * @type {boolean}
  2292. * @default true
  2293. * @product highcharts highstock gantt
  2294. * @apioption chart.alignTicks
  2295. */
  2296. /**
  2297. * Set the overall animation for all chart updating. Animation can be
  2298. * disabled throughout the chart by setting it to false here. It can
  2299. * be overridden for each individual API method as a function parameter.
  2300. * The only animation not affected by this option is the initial series
  2301. * animation,
  2302. see [plotOptions.series.animation](
  2303. * #plotOptions.series.animation).
  2304. *
  2305. * The animation can either be set as a boolean or a configuration
  2306. * object. If `true`,
  2307. it will use the 'swing' jQuery easing and a
  2308. * duration of 500 ms. If used as a configuration object,
  2309. the following
  2310. * properties are supported:
  2311. *
  2312. * - `defer`: The animation delay time in milliseconds.
  2313. *
  2314. * - `duration`: The duration of the animation in milliseconds.
  2315. *
  2316. * - `easing`: A string reference to an easing function set on the
  2317. * `Math` object. See
  2318. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  2319. *
  2320. * When zooming on a series with less than 100 points,
  2321. the chart redraw
  2322. * will be done with animation,
  2323. but in case of more data points,
  2324. it is
  2325. * necessary to set this option to ensure animation on zoom.
  2326. *
  2327. * @sample {highcharts} highcharts/chart/animation-none/
  2328. * Updating with no animation
  2329. * @sample {highcharts} highcharts/chart/animation-duration/
  2330. * With a longer duration
  2331. * @sample {highcharts} highcharts/chart/animation-easing/
  2332. * With a jQuery UI easing
  2333. * @sample {highmaps} maps/chart/animation-none/
  2334. * Updating with no animation
  2335. * @sample {highmaps} maps/chart/animation-duration/
  2336. * With a longer duration
  2337. *
  2338. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  2339. * @default undefined
  2340. * @apioption chart.animation
  2341. */
  2342. /**
  2343. * A CSS class name to apply to the charts container `div`,
  2344. allowing
  2345. * unique CSS styling for each chart.
  2346. *
  2347. * @type {string}
  2348. * @apioption chart.className
  2349. */
  2350. /**
  2351. * Event listeners for the chart.
  2352. *
  2353. * @apioption chart.events
  2354. */
  2355. /**
  2356. * Fires when a series is added to the chart after load time,
  2357. using the
  2358. * `addSeries` method. One parameter,
  2359. `event`,
  2360. is passed to the
  2361. * function,
  2362. containing common event information. Through
  2363. * `event.options` you can access the series options that were passed to
  2364. * the `addSeries` method. Returning false prevents the series from
  2365. * being added.
  2366. *
  2367. * @sample {highcharts} highcharts/chart/events-addseries/
  2368. * Alert on add series
  2369. * @sample {highstock} stock/chart/events-addseries/
  2370. * Alert on add series
  2371. *
  2372. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  2373. * @since 1.2.0
  2374. * @context Highcharts.Chart
  2375. * @apioption chart.events.addSeries
  2376. */
  2377. /**
  2378. * Fires when clicking on the plot background. One parameter,
  2379. `event`,
  2380. * is passed to the function,
  2381. containing common event information.
  2382. *
  2383. * Information on the clicked spot can be found through `event.xAxis`
  2384. * and `event.yAxis`,
  2385. which are arrays containing the axes of each
  2386. * dimension and each axis' value at the clicked spot. The primary axes
  2387. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  2388. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  2389. *
  2390. * ```js
  2391. * click: function(e) {
  2392. * console.log(
  2393. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S',
  2394. e.xAxis[0].value),
  2395. * e.yAxis[0].value
  2396. * )
  2397. * }
  2398. * ```
  2399. *
  2400. * @sample {highcharts} highcharts/chart/events-click/
  2401. * Alert coordinates on click
  2402. * @sample {highcharts} highcharts/chart/events-container/
  2403. * Alternatively,
  2404. attach event to container
  2405. * @sample {highstock} stock/chart/events-click/
  2406. * Alert coordinates on click
  2407. * @sample {highstock} highcharts/chart/events-container/
  2408. * Alternatively,
  2409. attach event to container
  2410. * @sample {highmaps} maps/chart/events-click/
  2411. * Record coordinates on click
  2412. * @sample {highmaps} highcharts/chart/events-container/
  2413. * Alternatively,
  2414. attach event to container
  2415. *
  2416. * @type {Highcharts.ChartClickCallbackFunction}
  2417. * @since 1.2.0
  2418. * @context Highcharts.Chart
  2419. * @apioption chart.events.click
  2420. */
  2421. /**
  2422. * Fires when the chart is finished loading. Since v4.2.2,
  2423. it also waits
  2424. * for images to be loaded,
  2425. for example from point markers. One
  2426. * parameter,
  2427. `event`,
  2428. is passed to the function,
  2429. containing common
  2430. * event information.
  2431. *
  2432. * There is also a second parameter to the chart constructor where a
  2433. * callback function can be passed to be executed on chart.load.
  2434. *
  2435. * @sample {highcharts} highcharts/chart/events-load/
  2436. * Alert on chart load
  2437. * @sample {highstock} stock/chart/events-load/
  2438. * Alert on chart load
  2439. * @sample {highmaps} maps/chart/events-load/
  2440. * Add series on chart load
  2441. *
  2442. * @type {Highcharts.ChartLoadCallbackFunction}
  2443. * @context Highcharts.Chart
  2444. * @apioption chart.events.load
  2445. */
  2446. /**
  2447. * Fires when the chart is redrawn,
  2448. either after a call to
  2449. * `chart.redraw()` or after an axis,
  2450. series or point is modified with
  2451. * the `redraw` option set to `true`. One parameter,
  2452. `event`,
  2453. is passed
  2454. * to the function,
  2455. containing common event information.
  2456. *
  2457. * @sample {highcharts} highcharts/chart/events-redraw/
  2458. * Alert on chart redraw
  2459. * @sample {highstock} stock/chart/events-redraw/
  2460. * Alert on chart redraw when adding a series or moving the
  2461. * zoomed range
  2462. * @sample {highmaps} maps/chart/events-redraw/
  2463. * Set subtitle on chart redraw
  2464. *
  2465. * @type {Highcharts.ChartRedrawCallbackFunction}
  2466. * @since 1.2.0
  2467. * @context Highcharts.Chart
  2468. * @apioption chart.events.redraw
  2469. */
  2470. /**
  2471. * Fires after initial load of the chart (directly after the `load`
  2472. * event),
  2473. and after each redraw (directly after the `redraw` event).
  2474. *
  2475. * @type {Highcharts.ChartRenderCallbackFunction}
  2476. * @since 5.0.7
  2477. * @context Highcharts.Chart
  2478. * @apioption chart.events.render
  2479. */
  2480. /**
  2481. * Fires when an area of the chart has been selected. Selection is
  2482. * enabled by setting the chart's zoomType. One parameter,
  2483. `event`,
  2484. is
  2485. * passed to the function,
  2486. containing common event information. The
  2487. * default action for the selection event is to zoom the chart to the
  2488. * selected area. It can be prevented by calling
  2489. * `event.preventDefault()` or return false.
  2490. *
  2491. * Information on the selected area can be found through `event.xAxis`
  2492. * and `event.yAxis`,
  2493. which are arrays containing the axes of each
  2494. * dimension and each axis' min and max values. The primary axes are
  2495. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  2496. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  2497. *
  2498. * ```js
  2499. * selection: function(event) {
  2500. * // log the min and max of the primary, datetime x-axis
  2501. * console.log(
  2502. * Highcharts.dateFormat(
  2503. * '%Y-%m-%d %H:%M:%S',
  2504. * event.xAxis[0].min
  2505. * ),
  2506. * Highcharts.dateFormat(
  2507. * '%Y-%m-%d %H:%M:%S',
  2508. * event.xAxis[0].max
  2509. * )
  2510. * );
  2511. * // log the min and max of the y axis
  2512. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  2513. * }
  2514. * ```
  2515. *
  2516. * @sample {highcharts} highcharts/chart/events-selection/
  2517. * Report on selection and reset
  2518. * @sample {highcharts} highcharts/chart/events-selection-points/
  2519. * Select a range of points through a drag selection
  2520. * @sample {highstock} stock/chart/events-selection/
  2521. * Report on selection and reset
  2522. * @sample {highstock} highcharts/chart/events-selection-points/
  2523. * Select a range of points through a drag selection
  2524. * (Highcharts)
  2525. *
  2526. * @type {Highcharts.ChartSelectionCallbackFunction}
  2527. * @apioption chart.events.selection
  2528. */
  2529. /**
  2530. * The margin between the outer edge of the chart and the plot area.
  2531. * The numbers in the array designate top, right, bottom and left
  2532. * respectively. Use the options `marginTop`, `marginRight`,
  2533. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  2534. *
  2535. * By default there is no margin. The actual space is dynamically
  2536. * calculated from the offset of axis labels, axis title, title,
  2537. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  2538. * `spacingBottom` and `spacingLeft` options.
  2539. *
  2540. * @sample {highcharts} highcharts/chart/margins-zero/
  2541. * Zero margins
  2542. * @sample {highstock} stock/chart/margin-zero/
  2543. * Zero margins
  2544. *
  2545. * @type {number|Array<number>}
  2546. * @apioption chart.margin
  2547. */
  2548. /**
  2549. * The margin between the bottom outer edge of the chart and the plot
  2550. * area. Use this to set a fixed pixel value for the margin as opposed
  2551. * to the default dynamic margin. See also `spacingBottom`.
  2552. *
  2553. * @sample {highcharts} highcharts/chart/marginbottom/
  2554. * 100px bottom margin
  2555. * @sample {highstock} stock/chart/marginbottom/
  2556. * 100px bottom margin
  2557. * @sample {highmaps} maps/chart/margin/
  2558. * 100px margins
  2559. *
  2560. * @type {number}
  2561. * @since 2.0
  2562. * @apioption chart.marginBottom
  2563. */
  2564. /**
  2565. * The margin between the left outer edge of the chart and the plot
  2566. * area. Use this to set a fixed pixel value for the margin as opposed
  2567. * to the default dynamic margin. See also `spacingLeft`.
  2568. *
  2569. * @sample {highcharts} highcharts/chart/marginleft/
  2570. * 150px left margin
  2571. * @sample {highstock} stock/chart/marginleft/
  2572. * 150px left margin
  2573. * @sample {highmaps} maps/chart/margin/
  2574. * 100px margins
  2575. *
  2576. * @type {number}
  2577. * @since 2.0
  2578. * @apioption chart.marginLeft
  2579. */
  2580. /**
  2581. * The margin between the right outer edge of the chart and the plot
  2582. * area. Use this to set a fixed pixel value for the margin as opposed
  2583. * to the default dynamic margin. See also `spacingRight`.
  2584. *
  2585. * @sample {highcharts} highcharts/chart/marginright/
  2586. * 100px right margin
  2587. * @sample {highstock} stock/chart/marginright/
  2588. * 100px right margin
  2589. * @sample {highmaps} maps/chart/margin/
  2590. * 100px margins
  2591. *
  2592. * @type {number}
  2593. * @since 2.0
  2594. * @apioption chart.marginRight
  2595. */
  2596. /**
  2597. * The margin between the top outer edge of the chart and the plot area.
  2598. * Use this to set a fixed pixel value for the margin as opposed to
  2599. * the default dynamic margin. See also `spacingTop`.
  2600. *
  2601. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  2602. * @sample {highstock} stock/chart/margintop/
  2603. * 100px top margin
  2604. * @sample {highmaps} maps/chart/margin/
  2605. * 100px margins
  2606. *
  2607. * @type {number}
  2608. * @since 2.0
  2609. * @apioption chart.marginTop
  2610. */
  2611. /**
  2612. * Callback function to override the default function that formats all
  2613. * the numbers in the chart. Returns a string with the formatted number.
  2614. *
  2615. * @sample highcharts/members/highcharts-numberformat
  2616. * Arabic digits in Highcharts
  2617. * @type {Highcharts.NumberFormatterCallbackFunction}
  2618. * @since 8.0.0
  2619. * @apioption chart.numberFormatter
  2620. */
  2621. /**
  2622. * Allows setting a key to switch between zooming and panning. Can be
  2623. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  2624. * key on Windows) or `shift`. The keys are mapped directly to the key
  2625. * properties of the click event argument (`event.altKey`,
  2626. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  2627. *
  2628. * @type {string}
  2629. * @since 4.0.3
  2630. * @product highcharts gantt
  2631. * @validvalue ["alt", "ctrl", "meta", "shift"]
  2632. * @apioption chart.panKey
  2633. */
  2634. /**
  2635. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  2636. * to combine zooming and panning.
  2637. *
  2638. * On touch devices, when the [tooltip.followTouchMove](
  2639. * #tooltip.followTouchMove) option is `true` (default), panning
  2640. * requires two fingers. To allow panning with one finger, set
  2641. * `followTouchMove` to `false`.
  2642. *
  2643. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  2644. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  2645. */
  2646. panning: {
  2647. /**
  2648. * Enable or disable chart panning.
  2649. *
  2650. * @type {boolean}
  2651. * @default {highcharts} false
  2652. * @default {highstock|highmaps} true
  2653. */
  2654. enabled: false,
  2655. /**
  2656. * Decides in what dimensions the user can pan the chart. Can be
  2657. * one of `x`, `y`, or `xy`.
  2658. *
  2659. * @sample {highcharts} highcharts/chart/panning-type
  2660. * Zooming and xy panning
  2661. *
  2662. * @type {string}
  2663. * @validvalue ["x", "y", "xy"]
  2664. * @default {highcharts|highstock} x
  2665. * @default {highmaps} xy
  2666. */
  2667. type: 'x'
  2668. },
  2669. /**
  2670. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  2671. * gestures only. By default, the `pinchType` is the same as the
  2672. * `zoomType` setting. However, pinching can be enabled separately in
  2673. * some cases, for example in stock charts where a mouse drag pans the
  2674. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  2675. * #tooltip.followTouchMove) is true, pinchType only applies to
  2676. * two-finger touches.
  2677. *
  2678. * @type {string}
  2679. * @default {highcharts} undefined
  2680. * @default {highstock} x
  2681. * @since 3.0
  2682. * @product highcharts highstock gantt
  2683. * @validvalue ["x", "y", "xy"]
  2684. * @apioption chart.pinchType
  2685. */
  2686. /**
  2687. * Whether to apply styled mode. When in styled mode, no presentational
  2688. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  2689. * are required to style the chart. The default style sheet is
  2690. * available from `https://code.highcharts.com/css/highcharts.css`.
  2691. *
  2692. * @type {boolean}
  2693. * @default false
  2694. * @since 7.0
  2695. * @apioption chart.styledMode
  2696. */
  2697. styledMode: false,
  2698. /**
  2699. * The corner radius of the outer chart border.
  2700. *
  2701. * @sample {highcharts} highcharts/chart/borderradius/
  2702. * 20px radius
  2703. * @sample {highstock} stock/chart/border/
  2704. * 10px radius
  2705. * @sample {highmaps} maps/chart/border/
  2706. * Border options
  2707. *
  2708. */
  2709. borderRadius: 0,
  2710. /**
  2711. * In styled mode, this sets how many colors the class names
  2712. * should rotate between. With ten colors, series (or points) are
  2713. * given class names like `highcharts-color-0`, `highcharts-color-0`
  2714. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  2715. * is to set colors using the [colors](#colors) setting.
  2716. *
  2717. * @since 5.0.0
  2718. */
  2719. colorCount: 10,
  2720. /**
  2721. * Alias of `type`.
  2722. *
  2723. * @sample {highcharts} highcharts/chart/defaultseriestype/
  2724. * Bar
  2725. *
  2726. * @deprecated
  2727. *
  2728. * @product highcharts
  2729. */
  2730. defaultSeriesType: 'line',
  2731. /**
  2732. * If true, the axes will scale to the remaining visible series once
  2733. * one series is hidden. If false, hiding and showing a series will
  2734. * not affect the axes or the other series. For stacks, once one series
  2735. * within the stack is hidden, the rest of the stack will close in
  2736. * around it even if the axis is not affected.
  2737. *
  2738. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  2739. * True by default
  2740. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  2741. * False
  2742. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  2743. * True with stack
  2744. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  2745. * True by default
  2746. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  2747. * False
  2748. *
  2749. * @since 1.2.0
  2750. * @product highcharts highstock gantt
  2751. */
  2752. ignoreHiddenSeries: true,
  2753. /**
  2754. * Whether to invert the axes so that the x axis is vertical and y axis
  2755. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  2756. * by default.
  2757. *
  2758. * @productdesc {highcharts}
  2759. * If a bar series is present in the chart, it will be inverted
  2760. * automatically. Inverting the chart doesn't have an effect if there
  2761. * are no cartesian series in the chart, or if the chart is
  2762. * [polar](#chart.polar).
  2763. *
  2764. * @sample {highcharts} highcharts/chart/inverted/
  2765. * Inverted line
  2766. * @sample {highstock} stock/navigator/inverted/
  2767. * Inverted stock chart
  2768. *
  2769. * @type {boolean}
  2770. * @default false
  2771. * @product highcharts highstock gantt
  2772. * @apioption chart.inverted
  2773. */
  2774. /**
  2775. * The distance between the outer edge of the chart and the content,
  2776. * like title or legend, or axis title and labels if present. The
  2777. * numbers in the array designate top, right, bottom and left
  2778. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  2779. * and spacingLeft options for shorthand setting of one option.
  2780. *
  2781. * @type {Array<number>}
  2782. * @see [chart.margin](#chart.margin)
  2783. * @default [10, 10, 15, 10]
  2784. * @since 3.0.6
  2785. */
  2786. spacing: [10, 10, 15, 10],
  2787. /**
  2788. * The button that appears after a selection zoom, allowing the user
  2789. * to reset zoom.
  2790. */
  2791. resetZoomButton: {
  2792. /**
  2793. * What frame the button placement should be related to. Can be
  2794. * either `plotBox` or `spacingBox`.
  2795. *
  2796. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  2797. * Relative to the chart
  2798. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  2799. * Relative to the chart
  2800. *
  2801. * @type {Highcharts.ButtonRelativeToValue}
  2802. * @default plot
  2803. * @since 2.2
  2804. * @apioption chart.resetZoomButton.relativeTo
  2805. */
  2806. /**
  2807. * A collection of attributes for the button. The object takes SVG
  2808. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  2809. * border radius. The theme also supports `style`, a collection of
  2810. * CSS properties for the text. Equivalent attributes for the hover
  2811. * state are given in `theme.states.hover`.
  2812. *
  2813. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  2814. * Theming the button
  2815. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  2816. * Theming the button
  2817. *
  2818. * @type {Highcharts.SVGAttributes}
  2819. * @since 2.2
  2820. */
  2821. theme: {
  2822. /** @internal */
  2823. zIndex: 6
  2824. },
  2825. /**
  2826. * The position of the button.
  2827. *
  2828. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  2829. * Above the plot area
  2830. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  2831. * Above the plot area
  2832. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  2833. * Above the plot area
  2834. *
  2835. * @type {Highcharts.AlignObject}
  2836. * @since 2.2
  2837. */
  2838. position: {
  2839. /**
  2840. * The horizontal alignment of the button.
  2841. */
  2842. align: 'right',
  2843. /**
  2844. * The horizontal offset of the button.
  2845. */
  2846. x: -10,
  2847. /**
  2848. * The vertical alignment of the button.
  2849. *
  2850. * @type {Highcharts.VerticalAlignValue}
  2851. * @default top
  2852. * @apioption chart.resetZoomButton.position.verticalAlign
  2853. */
  2854. /**
  2855. * The vertical offset of the button.
  2856. */
  2857. y: 10
  2858. }
  2859. },
  2860. /**
  2861. * The pixel width of the plot area border.
  2862. *
  2863. * @sample {highcharts} highcharts/chart/plotborderwidth/
  2864. * 1px border
  2865. * @sample {highstock} stock/chart/plotborder/
  2866. * 2px border
  2867. * @sample {highmaps} maps/chart/plotborder/
  2868. * Plot border options
  2869. *
  2870. * @type {number}
  2871. * @default 0
  2872. * @apioption chart.plotBorderWidth
  2873. */
  2874. /**
  2875. * Whether to apply a drop shadow to the plot area. Requires that
  2876. * plotBackgroundColor be set. The shadow can be an object configuration
  2877. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  2878. *
  2879. * @sample {highcharts} highcharts/chart/plotshadow/
  2880. * Plot shadow
  2881. * @sample {highstock} stock/chart/plotshadow/
  2882. * Plot shadow
  2883. * @sample {highmaps} maps/chart/plotborder/
  2884. * Plot border options
  2885. *
  2886. * @type {boolean|Highcharts.CSSObject}
  2887. * @default false
  2888. * @apioption chart.plotShadow
  2889. */
  2890. /**
  2891. * When true, cartesian charts like line, spline, area and column are
  2892. * transformed into the polar coordinate system. This produces _polar
  2893. * charts_, also known as _radar charts_.
  2894. *
  2895. * @sample {highcharts} highcharts/demo/polar/
  2896. * Polar chart
  2897. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  2898. * Wind rose, stacked polar column chart
  2899. * @sample {highcharts} highcharts/demo/polar-spider/
  2900. * Spider web chart
  2901. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  2902. * Star plot, multivariate data in a polar chart
  2903. *
  2904. * @type {boolean}
  2905. * @default false
  2906. * @since 2.3.0
  2907. * @product highcharts
  2908. * @requires highcharts-more
  2909. * @apioption chart.polar
  2910. */
  2911. /**
  2912. * Whether to reflow the chart to fit the width of the container div
  2913. * on resizing the window.
  2914. *
  2915. * @sample {highcharts} highcharts/chart/reflow-true/
  2916. * True by default
  2917. * @sample {highcharts} highcharts/chart/reflow-false/
  2918. * False
  2919. * @sample {highstock} stock/chart/reflow-true/
  2920. * True by default
  2921. * @sample {highstock} stock/chart/reflow-false/
  2922. * False
  2923. * @sample {highmaps} maps/chart/reflow-true/
  2924. * True by default
  2925. * @sample {highmaps} maps/chart/reflow-false/
  2926. * False
  2927. *
  2928. * @type {boolean}
  2929. * @default true
  2930. * @since 2.1
  2931. * @apioption chart.reflow
  2932. */
  2933. /**
  2934. * The HTML element where the chart will be rendered. If it is a string,
  2935. * the element by that id is used. The HTML element can also be passed
  2936. * by direct reference, or as the first argument of the chart
  2937. * constructor, in which case the option is not needed.
  2938. *
  2939. * @sample {highcharts} highcharts/chart/reflow-true/
  2940. * String
  2941. * @sample {highcharts} highcharts/chart/renderto-object/
  2942. * Object reference
  2943. * @sample {highstock} stock/chart/renderto-string/
  2944. * String
  2945. * @sample {highstock} stock/chart/renderto-object/
  2946. * Object reference
  2947. *
  2948. * @type {string|Highcharts.HTMLDOMElement}
  2949. * @apioption chart.renderTo
  2950. */
  2951. /**
  2952. * The background color of the marker square when selecting (zooming
  2953. * in on) an area of the chart.
  2954. *
  2955. * @see In styled mode, the selection marker fill is set with the
  2956. * `.highcharts-selection-marker` class.
  2957. *
  2958. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2959. * @default rgba(51,92,173,0.25)
  2960. * @since 2.1.7
  2961. * @apioption chart.selectionMarkerFill
  2962. */
  2963. /**
  2964. * Whether to apply a drop shadow to the outer chart area. Requires
  2965. * that backgroundColor be set. The shadow can be an object
  2966. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  2967. * `width`.
  2968. *
  2969. * @sample {highcharts} highcharts/chart/shadow/
  2970. * Shadow
  2971. * @sample {highstock} stock/chart/shadow/
  2972. * Shadow
  2973. * @sample {highmaps} maps/chart/border/
  2974. * Chart border and shadow
  2975. *
  2976. * @type {boolean|Highcharts.CSSObject}
  2977. * @default false
  2978. * @apioption chart.shadow
  2979. */
  2980. /**
  2981. * Whether to show the axes initially. This only applies to empty charts
  2982. * where series are added dynamically, as axes are automatically added
  2983. * to cartesian series.
  2984. *
  2985. * @sample {highcharts} highcharts/chart/showaxes-false/
  2986. * False by default
  2987. * @sample {highcharts} highcharts/chart/showaxes-true/
  2988. * True
  2989. *
  2990. * @type {boolean}
  2991. * @since 1.2.5
  2992. * @product highcharts gantt
  2993. * @apioption chart.showAxes
  2994. */
  2995. /**
  2996. * The space between the bottom edge of the chart and the content (plot
  2997. * area, axis title and labels, title, subtitle or legend in top
  2998. * position).
  2999. *
  3000. * @sample {highcharts} highcharts/chart/spacingbottom/
  3001. * Spacing bottom set to 100
  3002. * @sample {highstock} stock/chart/spacingbottom/
  3003. * Spacing bottom set to 100
  3004. * @sample {highmaps} maps/chart/spacing/
  3005. * Spacing 100 all around
  3006. *
  3007. * @type {number}
  3008. * @default 15
  3009. * @since 2.1
  3010. * @apioption chart.spacingBottom
  3011. */
  3012. /**
  3013. * The space between the left edge of the chart and the content (plot
  3014. * area, axis title and labels, title, subtitle or legend in top
  3015. * position).
  3016. *
  3017. * @sample {highcharts} highcharts/chart/spacingleft/
  3018. * Spacing left set to 100
  3019. * @sample {highstock} stock/chart/spacingleft/
  3020. * Spacing left set to 100
  3021. * @sample {highmaps} maps/chart/spacing/
  3022. * Spacing 100 all around
  3023. *
  3024. * @type {number}
  3025. * @default 10
  3026. * @since 2.1
  3027. * @apioption chart.spacingLeft
  3028. */
  3029. /**
  3030. * The space between the right edge of the chart and the content (plot
  3031. * area, axis title and labels, title, subtitle or legend in top
  3032. * position).
  3033. *
  3034. * @sample {highcharts} highcharts/chart/spacingright-100/
  3035. * Spacing set to 100
  3036. * @sample {highcharts} highcharts/chart/spacingright-legend/
  3037. * Legend in right position with default spacing
  3038. * @sample {highstock} stock/chart/spacingright/
  3039. * Spacing set to 100
  3040. * @sample {highmaps} maps/chart/spacing/
  3041. * Spacing 100 all around
  3042. *
  3043. * @type {number}
  3044. * @default 10
  3045. * @since 2.1
  3046. * @apioption chart.spacingRight
  3047. */
  3048. /**
  3049. * The space between the top edge of the chart and the content (plot
  3050. * area, axis title and labels, title, subtitle or legend in top
  3051. * position).
  3052. *
  3053. * @sample {highcharts} highcharts/chart/spacingtop-100/
  3054. * A top spacing of 100
  3055. * @sample {highcharts} highcharts/chart/spacingtop-10/
  3056. * Floating chart title makes the plot area align to the default
  3057. * spacingTop of 10.
  3058. * @sample {highstock} stock/chart/spacingtop/
  3059. * A top spacing of 100
  3060. * @sample {highmaps} maps/chart/spacing/
  3061. * Spacing 100 all around
  3062. *
  3063. * @type {number}
  3064. * @default 10
  3065. * @since 2.1
  3066. * @apioption chart.spacingTop
  3067. */
  3068. /**
  3069. * Additional CSS styles to apply inline to the container `div`. Note
  3070. * that since the default font styles are applied in the renderer, it
  3071. * is ignorant of the individual chart options and must be set globally.
  3072. *
  3073. * @see In styled mode, general chart styles can be set with the
  3074. * `.highcharts-root` class.
  3075. * @sample {highcharts} highcharts/chart/style-serif-font/
  3076. * Using a serif type font
  3077. * @sample {highcharts} highcharts/css/em/
  3078. * Styled mode with relative font sizes
  3079. * @sample {highstock} stock/chart/style/
  3080. * Using a serif type font
  3081. * @sample {highmaps} maps/chart/style-serif-font/
  3082. * Using a serif type font
  3083. *
  3084. * @type {Highcharts.CSSObject}
  3085. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  3086. * @apioption chart.style
  3087. */
  3088. /**
  3089. * The default series type for the chart. Can be any of the chart types
  3090. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  3091. * be a series provided by an additional module.
  3092. *
  3093. * In TypeScript this option has no effect in sense of typing and
  3094. * instead the `type` option must always be set in the series.
  3095. *
  3096. * @sample {highcharts} highcharts/chart/type-bar/
  3097. * Bar
  3098. * @sample {highstock} stock/chart/type/
  3099. * Areaspline
  3100. * @sample {highmaps} maps/chart/type-mapline/
  3101. * Mapline
  3102. *
  3103. * @type {string}
  3104. * @default {highcharts} line
  3105. * @default {highstock} line
  3106. * @default {highmaps} map
  3107. * @since 2.1.0
  3108. * @apioption chart.type
  3109. */
  3110. /**
  3111. * Decides in what dimensions the user can zoom by dragging the mouse.
  3112. * Can be one of `x`, `y` or `xy`.
  3113. *
  3114. * @see [panKey](#chart.panKey)
  3115. *
  3116. * @sample {highcharts} highcharts/chart/zoomtype-none/
  3117. * None by default
  3118. * @sample {highcharts} highcharts/chart/zoomtype-x/
  3119. * X
  3120. * @sample {highcharts} highcharts/chart/zoomtype-y/
  3121. * Y
  3122. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  3123. * Xy
  3124. * @sample {highstock} stock/demo/basic-line/
  3125. * None by default
  3126. * @sample {highstock} stock/chart/zoomtype-x/
  3127. * X
  3128. * @sample {highstock} stock/chart/zoomtype-y/
  3129. * Y
  3130. * @sample {highstock} stock/chart/zoomtype-xy/
  3131. * Xy
  3132. *
  3133. * @type {string}
  3134. * @product highcharts highstock gantt
  3135. * @validvalue ["x", "y", "xy"]
  3136. * @apioption chart.zoomType
  3137. */
  3138. /**
  3139. * Enables zooming by a single touch, in combination with
  3140. * [chart.zoomType](#chart.zoomType). When enabled, two-finger pinch
  3141. * will still work as set up by [chart.pinchType](#chart.pinchType).
  3142. * However, `zoomBySingleTouch` will interfere with touch-dragging the
  3143. * chart to read the tooltip. And especially when vertical zooming is
  3144. * enabled, it will make it hard to scroll vertically on the page.
  3145. * @since 9.0.0
  3146. * @sample highcharts/chart/zoombysingletouch
  3147. * Zoom by single touch enabled, with buttons to toggle
  3148. * @product highcharts highstock gantt
  3149. */
  3150. zoomBySingleTouch: false,
  3151. /**
  3152. * An explicit width for the chart. By default (when `null`) the width
  3153. * is calculated from the offset width of the containing element.
  3154. *
  3155. * @sample {highcharts} highcharts/chart/width/
  3156. * 800px wide
  3157. * @sample {highstock} stock/chart/width/
  3158. * 800px wide
  3159. * @sample {highmaps} maps/chart/size/
  3160. * Chart with explicit size
  3161. *
  3162. * @type {null|number|string}
  3163. */
  3164. width: null,
  3165. /**
  3166. * An explicit height for the chart. If a _number_, the height is
  3167. * given in pixels. If given a _percentage string_ (for example
  3168. * `'56%'`), the height is given as the percentage of the actual chart
  3169. * width. This allows for preserving the aspect ratio across responsive
  3170. * sizes.
  3171. *
  3172. * By default (when `null`) the height is calculated from the offset
  3173. * height of the containing element, or 400 pixels if the containing
  3174. * element's height is 0.
  3175. *
  3176. * @sample {highcharts} highcharts/chart/height/
  3177. * 500px height
  3178. * @sample {highstock} stock/chart/height/
  3179. * 300px height
  3180. * @sample {highmaps} maps/chart/size/
  3181. * Chart with explicit size
  3182. * @sample highcharts/chart/height-percent/
  3183. * Highcharts with percentage height
  3184. *
  3185. * @type {null|number|string}
  3186. */
  3187. height: null,
  3188. /**
  3189. * The color of the outer chart border.
  3190. *
  3191. * @see In styled mode, the stroke is set with the
  3192. * `.highcharts-background` class.
  3193. *
  3194. * @sample {highcharts} highcharts/chart/bordercolor/
  3195. * Brown border
  3196. * @sample {highstock} stock/chart/border/
  3197. * Brown border
  3198. * @sample {highmaps} maps/chart/border/
  3199. * Border options
  3200. *
  3201. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3202. */
  3203. borderColor: Palette.highlightColor80,
  3204. /**
  3205. * The pixel width of the outer chart border.
  3206. *
  3207. * @see In styled mode, the stroke is set with the
  3208. * `.highcharts-background` class.
  3209. *
  3210. * @sample {highcharts} highcharts/chart/borderwidth/
  3211. * 5px border
  3212. * @sample {highstock} stock/chart/border/
  3213. * 2px border
  3214. * @sample {highmaps} maps/chart/border/
  3215. * Border options
  3216. *
  3217. * @type {number}
  3218. * @default 0
  3219. * @apioption chart.borderWidth
  3220. */
  3221. /**
  3222. * The background color or gradient for the outer chart area.
  3223. *
  3224. * @see In styled mode, the background is set with the
  3225. * `.highcharts-background` class.
  3226. *
  3227. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  3228. * Color
  3229. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  3230. * Gradient
  3231. * @sample {highstock} stock/chart/backgroundcolor-color/
  3232. * Color
  3233. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  3234. * Gradient
  3235. * @sample {highmaps} maps/chart/backgroundcolor-color/
  3236. * Color
  3237. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  3238. * Gradient
  3239. *
  3240. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3241. */
  3242. backgroundColor: Palette.backgroundColor,
  3243. /**
  3244. * The background color or gradient for the plot area.
  3245. *
  3246. * @see In styled mode, the plot background is set with the
  3247. * `.highcharts-plot-background` class.
  3248. *
  3249. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  3250. * Color
  3251. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  3252. * Gradient
  3253. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  3254. * Color
  3255. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  3256. * Gradient
  3257. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  3258. * Color
  3259. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  3260. * Gradient
  3261. *
  3262. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3263. * @apioption chart.plotBackgroundColor
  3264. */
  3265. /**
  3266. * The URL for an image to use as the plot background. To set an image
  3267. * as the background for the entire chart, set a CSS background image
  3268. * to the container element. Note that for the image to be applied to
  3269. * exported charts, its URL needs to be accessible by the export server.
  3270. *
  3271. * @see In styled mode, a plot background image can be set with the
  3272. * `.highcharts-plot-background` class and a [custom pattern](
  3273. * https://www.highcharts.com/docs/chart-design-and-style/
  3274. * gradients-shadows-and-patterns).
  3275. *
  3276. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  3277. * Skies
  3278. * @sample {highstock} stock/chart/plotbackgroundimage/
  3279. * Skies
  3280. *
  3281. * @type {string}
  3282. * @apioption chart.plotBackgroundImage
  3283. */
  3284. /**
  3285. * The color of the inner chart or plot area border.
  3286. *
  3287. * @see In styled mode, a plot border stroke can be set with the
  3288. * `.highcharts-plot-border` class.
  3289. *
  3290. * @sample {highcharts} highcharts/chart/plotbordercolor/
  3291. * Blue border
  3292. * @sample {highstock} stock/chart/plotborder/
  3293. * Blue border
  3294. * @sample {highmaps} maps/chart/plotborder/
  3295. * Plot border options
  3296. *
  3297. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3298. */
  3299. plotBorderColor: Palette.neutralColor20
  3300. };
  3301. /* *
  3302. *
  3303. * Default Export
  3304. *
  3305. * */
  3306. return ChartDefaults;
  3307. });
  3308. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  3309. /* *
  3310. *
  3311. * (c) 2010-2021 Torstein Honsi
  3312. *
  3313. * License: www.highcharts.com/license
  3314. *
  3315. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3316. *
  3317. * */
  3318. var isNumber = U.isNumber,
  3319. merge = U.merge,
  3320. pInt = U.pInt;
  3321. /* *
  3322. *
  3323. * Class
  3324. *
  3325. * */
  3326. /* eslint-disable no-invalid-this, valid-jsdoc */
  3327. /**
  3328. * Handle color operations. Some object methods are chainable.
  3329. *
  3330. * @class
  3331. * @name Highcharts.Color
  3332. *
  3333. * @param {Highcharts.ColorType} input
  3334. * The input color in either rbga or hex format
  3335. */
  3336. var Color = /** @class */ (function () {
  3337. /* *
  3338. *
  3339. * Constructors
  3340. *
  3341. * */
  3342. function Color(input) {
  3343. // Collection of parsers. This can be extended from the outside by pushing
  3344. // parsers to Highcharts.Color.prototype.parsers.
  3345. this.parsers = [{
  3346. // RGBA color
  3347. // eslint-disable-next-line max-len
  3348. regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
  3349. parse: function (result) {
  3350. return [
  3351. pInt(result[1]),
  3352. pInt(result[2]),
  3353. pInt(result[3]),
  3354. parseFloat(result[4], 10)
  3355. ];
  3356. }
  3357. }, {
  3358. // RGB color
  3359. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  3360. parse: function (result) {
  3361. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  3362. }
  3363. }];
  3364. this.rgba = [];
  3365. var GlobalColor = H.Color;
  3366. // Backwards compatibility, allow class overwrite
  3367. if (GlobalColor && GlobalColor !== Color) {
  3368. return new GlobalColor(input);
  3369. }
  3370. // Backwards compatibility, allow instanciation without new (#13053)
  3371. if (!(this instanceof Color)) {
  3372. return new Color(input);
  3373. }
  3374. this.init(input);
  3375. }
  3376. /* *
  3377. *
  3378. * Static Functions
  3379. *
  3380. * */
  3381. /**
  3382. * Creates a color instance out of a color string or object.
  3383. *
  3384. * @function Highcharts.Color.parse
  3385. *
  3386. * @param {Highcharts.ColorType} input
  3387. * The input color in either rbga or hex format.
  3388. *
  3389. * @return {Highcharts.Color}
  3390. * Color instance.
  3391. */
  3392. Color.parse = function (input) {
  3393. return new Color(input);
  3394. };
  3395. /* *
  3396. *
  3397. * Functions
  3398. *
  3399. * */
  3400. /**
  3401. * Parse the input color to rgba array
  3402. *
  3403. * @private
  3404. * @function Highcharts.Color#init
  3405. *
  3406. * @param {Highcharts.ColorType} input
  3407. * The input color in either rbga or hex format
  3408. *
  3409. * @return {void}
  3410. */
  3411. Color.prototype.init = function (input) {
  3412. var result,
  3413. rgba,
  3414. i,
  3415. parser,
  3416. len;
  3417. this.input = input = Color.names[input && input.toLowerCase ?
  3418. input.toLowerCase() :
  3419. ''] || input;
  3420. // Gradients
  3421. if (input && input.stops) {
  3422. this.stops = input.stops.map(function (stop) {
  3423. return new Color(stop[1]);
  3424. });
  3425. // Solid colors
  3426. }
  3427. else {
  3428. // Bitmasking as input[0] is not working for legacy IE.
  3429. if (input &&
  3430. input.charAt &&
  3431. input.charAt() === '#') {
  3432. len = input.length;
  3433. input = parseInt(input.substr(1), 16);
  3434. // Handle long-form, e.g. #AABBCC
  3435. if (len === 7) {
  3436. rgba = [
  3437. (input & 0xFF0000) >> 16,
  3438. (input & 0xFF00) >> 8,
  3439. (input & 0xFF),
  3440. 1
  3441. ];
  3442. // Handle short-form, e.g. #ABC
  3443. // In short form, the value is assumed to be the same
  3444. // for both nibbles for each component. e.g. #ABC = #AABBCC
  3445. }
  3446. else if (len === 4) {
  3447. rgba = [
  3448. (((input & 0xF00) >> 4) |
  3449. (input & 0xF00) >> 8),
  3450. (((input & 0xF0) >> 4) |
  3451. (input & 0xF0)),
  3452. ((input & 0xF) << 4) | (input & 0xF),
  3453. 1
  3454. ];
  3455. }
  3456. }
  3457. // Otherwise, check regex parsers
  3458. if (!rgba) {
  3459. i = this.parsers.length;
  3460. while (i-- && !rgba) {
  3461. parser = this.parsers[i];
  3462. result = parser.regex.exec(input);
  3463. if (result) {
  3464. rgba = parser.parse(result);
  3465. }
  3466. }
  3467. }
  3468. }
  3469. this.rgba = rgba || [];
  3470. };
  3471. /**
  3472. * Return the color or gradient stops in the specified format
  3473. *
  3474. * @function Highcharts.Color#get
  3475. *
  3476. * @param {string} [format]
  3477. * Possible values are 'a', 'rgb', 'rgba' (default).
  3478. *
  3479. * @return {Highcharts.ColorType}
  3480. * This color as a string or gradient stops.
  3481. */
  3482. Color.prototype.get = function (format) {
  3483. var input = this.input,
  3484. rgba = this.rgba,
  3485. ret;
  3486. if (typeof this.stops !== 'undefined') {
  3487. ret = merge(input);
  3488. ret.stops = [].concat(ret.stops);
  3489. this.stops.forEach(function (stop, i) {
  3490. ret.stops[i] = [
  3491. ret.stops[i][0],
  3492. stop.get(format)
  3493. ];
  3494. });
  3495. // it's NaN if gradient colors on a column chart
  3496. }
  3497. else if (rgba && isNumber(rgba[0])) {
  3498. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  3499. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  3500. }
  3501. else if (format === 'a') {
  3502. ret = rgba[3];
  3503. }
  3504. else {
  3505. ret = 'rgba(' + rgba.join(',') + ')';
  3506. }
  3507. }
  3508. else {
  3509. ret = input;
  3510. }
  3511. return ret;
  3512. };
  3513. /**
  3514. * Brighten the color instance.
  3515. *
  3516. * @function Highcharts.Color#brighten
  3517. *
  3518. * @param {number} alpha
  3519. * The alpha value.
  3520. *
  3521. * @return {Highcharts.Color}
  3522. * This color with modifications.
  3523. */
  3524. Color.prototype.brighten = function (alpha) {
  3525. var i,
  3526. rgba = this.rgba;
  3527. if (this.stops) {
  3528. this.stops.forEach(function (stop) {
  3529. stop.brighten(alpha);
  3530. });
  3531. }
  3532. else if (isNumber(alpha) && alpha !== 0) {
  3533. for (i = 0; i < 3; i++) {
  3534. rgba[i] += pInt(alpha * 255);
  3535. if (rgba[i] < 0) {
  3536. rgba[i] = 0;
  3537. }
  3538. if (rgba[i] > 255) {
  3539. rgba[i] = 255;
  3540. }
  3541. }
  3542. }
  3543. return this;
  3544. };
  3545. /**
  3546. * Set the color's opacity to a given alpha value.
  3547. *
  3548. * @function Highcharts.Color#setOpacity
  3549. *
  3550. * @param {number} alpha
  3551. * Opacity between 0 and 1.
  3552. *
  3553. * @return {Highcharts.Color}
  3554. * Color with modifications.
  3555. */
  3556. Color.prototype.setOpacity = function (alpha) {
  3557. this.rgba[3] = alpha;
  3558. return this;
  3559. };
  3560. /**
  3561. * Return an intermediate color between two colors.
  3562. *
  3563. * @function Highcharts.Color#tweenTo
  3564. *
  3565. * @param {Highcharts.Color} to
  3566. * The color object to tween to.
  3567. *
  3568. * @param {number} pos
  3569. * The intermediate position, where 0 is the from color (current
  3570. * color item), and 1 is the `to` color.
  3571. *
  3572. * @return {Highcharts.ColorString}
  3573. * The intermediate color in rgba notation.
  3574. */
  3575. Color.prototype.tweenTo = function (to, pos) {
  3576. // Check for has alpha, because rgba colors perform worse due to lack of
  3577. // support in WebKit.
  3578. var fromRgba = this.rgba,
  3579. toRgba = to.rgba,
  3580. hasAlpha,
  3581. ret;
  3582. // Unsupported color, return to-color (#3920, #7034)
  3583. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  3584. ret = to.input || 'none';
  3585. // Interpolate
  3586. }
  3587. else {
  3588. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  3589. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  3590. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  3591. ',' +
  3592. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  3593. ',' +
  3594. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  3595. (hasAlpha ?
  3596. (',' +
  3597. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  3598. '') +
  3599. ')';
  3600. }
  3601. return ret;
  3602. };
  3603. /* *
  3604. *
  3605. * Static Properties
  3606. *
  3607. * */
  3608. /**
  3609. * Collection of named colors. Can be extended from the outside by adding
  3610. * colors to Highcharts.Color.names.
  3611. * @private
  3612. */
  3613. Color.names = {
  3614. white: '#ffffff',
  3615. black: '#000000'
  3616. };
  3617. return Color;
  3618. }());
  3619. /* *
  3620. *
  3621. * Default Export
  3622. *
  3623. * */
  3624. /* *
  3625. *
  3626. * API Declarations
  3627. *
  3628. * */
  3629. /**
  3630. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  3631. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  3632. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  3633. * browsers and displayed correctly, but Highcharts is not able to process them
  3634. * and apply concepts like opacity and brightening.
  3635. *
  3636. * @typedef {string} Highcharts.ColorString
  3637. */
  3638. /**
  3639. * A valid color type than can be parsed and handled by Highcharts. It can be a
  3640. * color string, a gradient object, or a pattern object.
  3641. *
  3642. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  3643. */
  3644. /**
  3645. * Gradient options instead of a solid color.
  3646. *
  3647. * @example
  3648. * // Linear gradient used as a color option
  3649. * color: {
  3650. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  3651. * stops: [
  3652. * [0, '#003399'], // start
  3653. * [0.5, '#ffffff'], // middle
  3654. * [1, '#3366AA'] // end
  3655. * ]
  3656. * }
  3657. *
  3658. * @interface Highcharts.GradientColorObject
  3659. */ /**
  3660. * Holds an object that defines the start position and the end position relative
  3661. * to the shape.
  3662. * @name Highcharts.GradientColorObject#linearGradient
  3663. * @type {Highcharts.LinearGradientColorObject|undefined}
  3664. */ /**
  3665. * Holds an object that defines the center position and the radius.
  3666. * @name Highcharts.GradientColorObject#radialGradient
  3667. * @type {Highcharts.RadialGradientColorObject|undefined}
  3668. */ /**
  3669. * The first item in each tuple is the position in the gradient, where 0 is the
  3670. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  3671. * applied. The second item is the color for each stop. This color can also be
  3672. * given in the rgba format.
  3673. * @name Highcharts.GradientColorObject#stops
  3674. * @type {Array<Highcharts.GradientColorStopObject>}
  3675. */
  3676. /**
  3677. * Color stop tuple.
  3678. *
  3679. * @see Highcharts.GradientColorObject
  3680. *
  3681. * @interface Highcharts.GradientColorStopObject
  3682. */ /**
  3683. * @name Highcharts.GradientColorStopObject#0
  3684. * @type {number}
  3685. */ /**
  3686. * @name Highcharts.GradientColorStopObject#1
  3687. * @type {Highcharts.ColorString}
  3688. */ /**
  3689. * @name Highcharts.GradientColorStopObject#color
  3690. * @type {Highcharts.Color|undefined}
  3691. */
  3692. /**
  3693. * Defines the start position and the end position for a gradient relative
  3694. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  3695. * to the shape, where 0 means top/left and 1 is bottom/right.
  3696. *
  3697. * @interface Highcharts.LinearGradientColorObject
  3698. */ /**
  3699. * Start horizontal position of the gradient. Float ranges 0-1.
  3700. * @name Highcharts.LinearGradientColorObject#x1
  3701. * @type {number}
  3702. */ /**
  3703. * End horizontal position of the gradient. Float ranges 0-1.
  3704. * @name Highcharts.LinearGradientColorObject#x2
  3705. * @type {number}
  3706. */ /**
  3707. * Start vertical position of the gradient. Float ranges 0-1.
  3708. * @name Highcharts.LinearGradientColorObject#y1
  3709. * @type {number}
  3710. */ /**
  3711. * End vertical position of the gradient. Float ranges 0-1.
  3712. * @name Highcharts.LinearGradientColorObject#y2
  3713. * @type {number}
  3714. */
  3715. /**
  3716. * Defines the center position and the radius for a gradient.
  3717. *
  3718. * @interface Highcharts.RadialGradientColorObject
  3719. */ /**
  3720. * Center horizontal position relative to the shape. Float ranges 0-1.
  3721. * @name Highcharts.RadialGradientColorObject#cx
  3722. * @type {number}
  3723. */ /**
  3724. * Center vertical position relative to the shape. Float ranges 0-1.
  3725. * @name Highcharts.RadialGradientColorObject#cy
  3726. * @type {number}
  3727. */ /**
  3728. * Radius relative to the shape. Float ranges 0-1.
  3729. * @name Highcharts.RadialGradientColorObject#r
  3730. * @type {number}
  3731. */
  3732. /**
  3733. * Creates a color instance out of a color string.
  3734. *
  3735. * @function Highcharts.color
  3736. *
  3737. * @param {Highcharts.ColorType} input
  3738. * The input color in either rbga or hex format
  3739. *
  3740. * @return {Highcharts.Color}
  3741. * Color instance
  3742. */
  3743. (''); // detach doclets above
  3744. return Color;
  3745. });
  3746. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  3747. /* *
  3748. *
  3749. * (c) 2010-2021 Torstein Honsi
  3750. *
  3751. * License: www.highcharts.com/license
  3752. *
  3753. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3754. *
  3755. * */
  3756. var win = H.win;
  3757. var defined = U.defined,
  3758. error = U.error,
  3759. extend = U.extend,
  3760. isObject = U.isObject,
  3761. merge = U.merge,
  3762. objectEach = U.objectEach,
  3763. pad = U.pad,
  3764. pick = U.pick,
  3765. splat = U.splat,
  3766. timeUnits = U.timeUnits;
  3767. /* *
  3768. *
  3769. * Constants
  3770. *
  3771. * */
  3772. var hasNewSafariBug = (H.isSafari && Intl.DateTimeFormat.prototype.formatRange);
  3773. // To do: Remove this when we no longer need support for Safari < v14.1
  3774. var hasOldSafariBug = (H.isSafari && !Intl.DateTimeFormat.prototype.formatRange);
  3775. /* *
  3776. *
  3777. * Class
  3778. *
  3779. * */
  3780. /* eslint-disable no-invalid-this, valid-jsdoc */
  3781. /**
  3782. * The Time class. Time settings are applied in general for each page using
  3783. * `Highcharts.setOptions`, or individually for each Chart item through the
  3784. * [time](https://api.highcharts.com/highcharts/time) options set.
  3785. *
  3786. * The Time object is available from {@link Highcharts.Chart#time},
  3787. * which refers to `Highcharts.time` if no individual time settings are
  3788. * applied.
  3789. *
  3790. * @example
  3791. * // Apply time settings globally
  3792. * Highcharts.setOptions({
  3793. * time: {
  3794. * timezone: 'Europe/London'
  3795. * }
  3796. * });
  3797. *
  3798. * // Apply time settings by instance
  3799. * let chart = Highcharts.chart('container', {
  3800. * time: {
  3801. * timezone: 'America/New_York'
  3802. * },
  3803. * series: [{
  3804. * data: [1, 4, 3, 5]
  3805. * }]
  3806. * });
  3807. *
  3808. * // Use the Time object
  3809. * console.log(
  3810. * 'Current time in New York',
  3811. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  3812. * );
  3813. *
  3814. * @since 6.0.5
  3815. *
  3816. * @class
  3817. * @name Highcharts.Time
  3818. *
  3819. * @param {Highcharts.TimeOptions} options
  3820. * Time options as defined in [chart.options.time](/highcharts/time).
  3821. */
  3822. var Time = /** @class */ (function () {
  3823. /* *
  3824. *
  3825. * Constructors
  3826. *
  3827. * */
  3828. function Time(options) {
  3829. /* *
  3830. *
  3831. * Properties
  3832. *
  3833. * */
  3834. this.options = {};
  3835. this.useUTC = false;
  3836. this.variableTimezone = false;
  3837. this.Date = win.Date;
  3838. /**
  3839. * Get the time zone offset based on the current timezone information as
  3840. * set in the global options.
  3841. *
  3842. * @function Highcharts.Time#getTimezoneOffset
  3843. *
  3844. * @param {number} timestamp
  3845. * The JavaScript timestamp to inspect.
  3846. *
  3847. * @return {number}
  3848. * The timezone offset in minutes compared to UTC.
  3849. */
  3850. this.getTimezoneOffset = this.timezoneOffsetFunction();
  3851. this.update(options);
  3852. }
  3853. /* *
  3854. *
  3855. * Functions
  3856. *
  3857. * */
  3858. /**
  3859. * Time units used in `Time.get` and `Time.set`
  3860. *
  3861. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  3862. */
  3863. /**
  3864. * Get the value of a date object in given units, and subject to the Time
  3865. * object's current timezone settings. This function corresponds directly to
  3866. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  3867. * `date.getHours()` or `date.getUTCHours()` we will call
  3868. * `time.get('Hours')`.
  3869. *
  3870. * @function Highcharts.Time#get
  3871. *
  3872. * @param {Highcharts.TimeUnitValue} unit
  3873. * @param {Date} date
  3874. *
  3875. * @return {number}
  3876. * The given time unit
  3877. */
  3878. Time.prototype.get = function (unit, date) {
  3879. if (this.variableTimezone || this.timezoneOffset) {
  3880. var realMs = date.getTime();
  3881. var ms = realMs - this.getTimezoneOffset(date);
  3882. date.setTime(ms); // Temporary adjust to timezone
  3883. var ret = date['getUTC' + unit]();
  3884. date.setTime(realMs); // Reset
  3885. return ret;
  3886. }
  3887. // UTC time with no timezone handling
  3888. if (this.useUTC) {
  3889. return date['getUTC' + unit]();
  3890. }
  3891. // Else, local time
  3892. return date['get' + unit]();
  3893. };
  3894. /**
  3895. * Set the value of a date object in given units, and subject to the Time
  3896. * object's current timezone settings. This function corresponds directly to
  3897. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  3898. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  3899. * `time.set('Hours', 0)`.
  3900. *
  3901. * @function Highcharts.Time#set
  3902. *
  3903. * @param {Highcharts.TimeUnitValue} unit
  3904. * @param {Date} date
  3905. * @param {number} value
  3906. *
  3907. * @return {number}
  3908. * The epoch milliseconds of the updated date
  3909. */
  3910. Time.prototype.set = function (unit, date, value) {
  3911. // UTC time with timezone handling
  3912. if (this.variableTimezone || this.timezoneOffset) {
  3913. // For lower order time units, just set it directly using UTC
  3914. // time
  3915. if (unit === 'Milliseconds' ||
  3916. unit === 'Seconds' ||
  3917. (unit === 'Minutes' && this.getTimezoneOffset(date) % 3600000 === 0) // #13961
  3918. ) {
  3919. return date['setUTC' + unit](value);
  3920. }
  3921. // Higher order time units need to take the time zone into
  3922. // account
  3923. // Adjust by timezone
  3924. var offset = this.getTimezoneOffset(date);
  3925. var ms = date.getTime() - offset;
  3926. date.setTime(ms);
  3927. date['setUTC' + unit](value);
  3928. var newOffset = this.getTimezoneOffset(date);
  3929. ms = date.getTime() + newOffset;
  3930. return date.setTime(ms);
  3931. }
  3932. // UTC time with no timezone handling
  3933. if (this.useUTC ||
  3934. (hasNewSafariBug && unit === 'FullYear') // leap calculation in UTC only
  3935. ) {
  3936. return date['setUTC' + unit](value);
  3937. }
  3938. // Else, local time
  3939. return date['set' + unit](value);
  3940. };
  3941. /**
  3942. * Update the Time object with current options. It is called internally on
  3943. * initializing Highcharts, after running `Highcharts.setOptions` and on
  3944. * `Chart.update`.
  3945. *
  3946. * @private
  3947. * @function Highcharts.Time#update
  3948. *
  3949. * @param {Highcharts.TimeOptions} options
  3950. *
  3951. * @return {void}
  3952. */
  3953. Time.prototype.update = function (options) {
  3954. var useUTC = pick(options && options.useUTC,
  3955. true),
  3956. time = this;
  3957. this.options = options = merge(true, this.options || {}, options);
  3958. // Allow using a different Date class
  3959. this.Date = options.Date || win.Date || Date;
  3960. this.useUTC = useUTC;
  3961. this.timezoneOffset = (useUTC && options.timezoneOffset);
  3962. this.getTimezoneOffset = this.timezoneOffsetFunction();
  3963. /*
  3964. * The time object has options allowing for variable time zones, meaning
  3965. * the axis ticks or series data needs to consider this.
  3966. */
  3967. this.variableTimezone = useUTC && !!(options.getTimezoneOffset ||
  3968. options.timezone);
  3969. };
  3970. /**
  3971. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  3972. * local time or a specific timezone time depending on the current time
  3973. * settings.
  3974. *
  3975. * @function Highcharts.Time#makeTime
  3976. *
  3977. * @param {number} year
  3978. * The year
  3979. *
  3980. * @param {number} month
  3981. * The month. Zero-based, so January is 0.
  3982. *
  3983. * @param {number} [date=1]
  3984. * The day of the month
  3985. *
  3986. * @param {number} [hours=0]
  3987. * The hour of the day, 0-23.
  3988. *
  3989. * @param {number} [minutes=0]
  3990. * The minutes
  3991. *
  3992. * @param {number} [seconds=0]
  3993. * The seconds
  3994. *
  3995. * @return {number}
  3996. * The time in milliseconds since January 1st 1970.
  3997. */
  3998. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  3999. var d,
  4000. offset,
  4001. newOffset;
  4002. if (this.useUTC) {
  4003. d = this.Date.UTC.apply(0, arguments);
  4004. offset = this.getTimezoneOffset(d);
  4005. d += offset;
  4006. newOffset = this.getTimezoneOffset(d);
  4007. if (offset !== newOffset) {
  4008. d += newOffset - offset;
  4009. // A special case for transitioning from summer time to winter time.
  4010. // When the clock is set back, the same time is repeated twice, i.e.
  4011. // 02:30 am is repeated since the clock is set back from 3 am to
  4012. // 2 am. We need to make the same time as local Date does.
  4013. }
  4014. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  4015. !hasOldSafariBug) {
  4016. d -= 36e5;
  4017. }
  4018. }
  4019. else {
  4020. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  4021. }
  4022. return d;
  4023. };
  4024. /**
  4025. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  4026. * default getTimezoneOffset function with that timezone is returned. If
  4027. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  4028. * specified, the function using the `timezoneOffset` option or 0 offset is
  4029. * returned.
  4030. *
  4031. * @private
  4032. * @function Highcharts.Time#timezoneOffsetFunction
  4033. *
  4034. * @return {Function}
  4035. * A getTimezoneOffset function
  4036. */
  4037. Time.prototype.timezoneOffsetFunction = function () {
  4038. var time = this,
  4039. options = this.options,
  4040. moment = options.moment || win.moment;
  4041. if (!this.useUTC) {
  4042. return function (timestamp) {
  4043. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  4044. };
  4045. }
  4046. if (options.timezone) {
  4047. if (!moment) {
  4048. // getTimezoneOffset-function stays undefined because it depends
  4049. // on Moment.js
  4050. error(25);
  4051. }
  4052. else {
  4053. return function (timestamp) {
  4054. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  4055. };
  4056. }
  4057. }
  4058. // If not timezone is set, look for the getTimezoneOffset callback
  4059. if (this.useUTC && options.getTimezoneOffset) {
  4060. return function (timestamp) {
  4061. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  4062. };
  4063. }
  4064. // Last, use the `timezoneOffset` option if set
  4065. return function () {
  4066. return (time.timezoneOffset || 0) * 60000;
  4067. };
  4068. };
  4069. /**
  4070. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  4071. * into a human readable date string. The available format keys are listed
  4072. * below. Additional formats can be given in the
  4073. * {@link Highcharts.dateFormats} hook.
  4074. *
  4075. * Supported format keys:
  4076. * - `%a`: Short weekday, like 'Mon'
  4077. * - `%A`: Long weekday, like 'Monday'
  4078. * - `%d`: Two digit day of the month, 01 to 31
  4079. * - `%e`: Day of the month, 1 through 31
  4080. * - `%w`: Day of the week, 0 through 6
  4081. * - `%b`: Short month, like 'Jan'
  4082. * - `%B`: Long month, like 'January'
  4083. * - `%m`: Two digit month number, 01 through 12
  4084. * - `%y`: Two digits year, like 09 for 2009
  4085. * - `%Y`: Four digits year, like 2009
  4086. * - `%H`: Two digits hours in 24h format, 00 through 23
  4087. * - `%k`: Hours in 24h format, 0 through 23
  4088. * - `%I`: Two digits hours in 12h format, 00 through 11
  4089. * - `%l`: Hours in 12h format, 1 through 12
  4090. * - `%M`: Two digits minutes, 00 through 59
  4091. * - `%p`: Upper case AM or PM
  4092. * - `%P`: Lower case AM or PM
  4093. * - `%S`: Two digits seconds, 00 through 59
  4094. * - `%L`: Milliseconds (naming from Ruby)
  4095. *
  4096. * @example
  4097. * const time = new Highcharts.Time();
  4098. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  4099. * console.log(s); // => 2020-01-01 00:00:00
  4100. *
  4101. * @function Highcharts.Time#dateFormat
  4102. *
  4103. * @param {string} format
  4104. * The desired format where various time representations are
  4105. * prefixed with %.
  4106. *
  4107. * @param {number} [timestamp]
  4108. * The JavaScript timestamp.
  4109. *
  4110. * @param {boolean} [capitalize=false]
  4111. * Upper case first letter in the return.
  4112. *
  4113. * @return {string}
  4114. * The formatted date.
  4115. */
  4116. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  4117. if (!defined(timestamp) || isNaN(timestamp)) {
  4118. return (H.defaultOptions.lang &&
  4119. H.defaultOptions.lang.invalidDate ||
  4120. '');
  4121. }
  4122. format = pick(format, '%Y-%m-%d %H:%M:%S');
  4123. var time = this, date = new this.Date(timestamp),
  4124. // get the basic time values
  4125. hours = this.get('Hours', date), day = this.get('Day', date), dayOfMonth = this.get('Date', date), month = this.get('Month', date), fullYear = this.get('FullYear', date), lang = H.defaultOptions.lang, langWeekdays = (lang && lang.weekdays), shortWeekdays = (lang && lang.shortWeekdays),
  4126. // List all format keys. Custom formats can be added from the
  4127. // outside.
  4128. replacements = extend({
  4129. // Day
  4130. // Short weekday, like 'Mon'
  4131. a: shortWeekdays ?
  4132. shortWeekdays[day] :
  4133. langWeekdays[day].substr(0, 3),
  4134. // Long weekday, like 'Monday'
  4135. A: langWeekdays[day],
  4136. // Two digit day of the month, 01 to 31
  4137. d: pad(dayOfMonth),
  4138. // Day of the month, 1 through 31
  4139. e: pad(dayOfMonth, 2, ' '),
  4140. // Day of the week, 0 through 6
  4141. w: day,
  4142. // Week (none implemented)
  4143. // 'W': weekNumber(),
  4144. // Month
  4145. // Short month, like 'Jan'
  4146. b: lang.shortMonths[month],
  4147. // Long month, like 'January'
  4148. B: lang.months[month],
  4149. // Two digit month number, 01 through 12
  4150. m: pad(month + 1),
  4151. // Month number, 1 through 12 (#8150)
  4152. o: month + 1,
  4153. // Year
  4154. // Two digits year, like 09 for 2009
  4155. y: fullYear.toString().substr(2, 2),
  4156. // Four digits year, like 2009
  4157. Y: fullYear,
  4158. // Time
  4159. // Two digits hours in 24h format, 00 through 23
  4160. H: pad(hours),
  4161. // Hours in 24h format, 0 through 23
  4162. k: hours,
  4163. // Two digits hours in 12h format, 00 through 11
  4164. I: pad((hours % 12) || 12),
  4165. // Hours in 12h format, 1 through 12
  4166. l: (hours % 12) || 12,
  4167. // Two digits minutes, 00 through 59
  4168. M: pad(this.get('Minutes', date)),
  4169. // Upper case AM or PM
  4170. p: hours < 12 ? 'AM' : 'PM',
  4171. // Lower case AM or PM
  4172. P: hours < 12 ? 'am' : 'pm',
  4173. // Two digits seconds, 00 through 59
  4174. S: pad(date.getSeconds()),
  4175. // Milliseconds (naming from Ruby)
  4176. L: pad(Math.floor(timestamp % 1000), 3)
  4177. }, H.dateFormats);
  4178. // Do the replaces
  4179. objectEach(replacements, function (val, key) {
  4180. // Regex would do it in one line, but this is faster
  4181. while (format.indexOf('%' + key) !== -1) {
  4182. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  4183. }
  4184. });
  4185. // Optionally capitalize the string and return
  4186. return capitalize ?
  4187. (format.substr(0, 1).toUpperCase() +
  4188. format.substr(1)) :
  4189. format;
  4190. };
  4191. /**
  4192. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  4193. * an object.
  4194. * @private
  4195. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  4196. * @return {Highcharts.Dictionary<T>} - The object definition
  4197. */
  4198. Time.prototype.resolveDTLFormat = function (f) {
  4199. if (!isObject(f, true)) { // check for string or array
  4200. f = splat(f);
  4201. return {
  4202. main: f[0],
  4203. from: f[1],
  4204. to: f[2]
  4205. };
  4206. }
  4207. return f;
  4208. };
  4209. /**
  4210. * Return an array with time positions distributed on round time values
  4211. * right and right after min and max. Used in datetime axes as well as for
  4212. * grouping data on a datetime axis.
  4213. *
  4214. * @function Highcharts.Time#getTimeTicks
  4215. *
  4216. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  4217. * The interval in axis values (ms) and the count
  4218. *
  4219. * @param {number} [min]
  4220. * The minimum in axis values
  4221. *
  4222. * @param {number} [max]
  4223. * The maximum in axis values
  4224. *
  4225. * @param {number} [startOfWeek=1]
  4226. *
  4227. * @return {Highcharts.AxisTickPositionsArray}
  4228. */
  4229. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  4230. var time = this,
  4231. Date = time.Date,
  4232. tickPositions = [],
  4233. higherRanks = {},
  4234. // When crossing DST, use the max. Resolves #6278.
  4235. minDate = new Date(min),
  4236. interval = normalizedInterval.unitRange,
  4237. count = normalizedInterval.count || 1;
  4238. var i,
  4239. minYear, // used in months and years as a basis for Date.UTC()
  4240. variableDayLength,
  4241. minDay;
  4242. startOfWeek = pick(startOfWeek, 1);
  4243. if (defined(min)) { // #1300
  4244. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  4245. 0 : // #3935
  4246. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  4247. if (interval >= timeUnits.second) { // second
  4248. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  4249. 0 : // #3935
  4250. count * Math.floor(time.get('Seconds', minDate) / count));
  4251. }
  4252. if (interval >= timeUnits.minute) { // minute
  4253. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  4254. 0 :
  4255. count * Math.floor(time.get('Minutes', minDate) / count));
  4256. }
  4257. if (interval >= timeUnits.hour) { // hour
  4258. time.set('Hours', minDate, interval >= timeUnits.day ?
  4259. 0 :
  4260. count * Math.floor(time.get('Hours', minDate) / count));
  4261. }
  4262. if (interval >= timeUnits.day) { // day
  4263. time.set('Date', minDate, interval >= timeUnits.month ?
  4264. 1 :
  4265. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  4266. }
  4267. if (interval >= timeUnits.month) { // month
  4268. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  4269. count * Math.floor(time.get('Month', minDate) / count));
  4270. minYear = time.get('FullYear', minDate);
  4271. }
  4272. if (interval >= timeUnits.year) { // year
  4273. minYear -= minYear % count;
  4274. time.set('FullYear', minDate, minYear);
  4275. }
  4276. // week is a special case that runs outside the hierarchy
  4277. if (interval === timeUnits.week) {
  4278. // get start of current week, independent of count
  4279. minDay = time.get('Day', minDate);
  4280. time.set('Date', minDate, (time.get('Date', minDate) -
  4281. minDay + startOfWeek +
  4282. // We don't want to skip days that are before
  4283. // startOfWeek (#7051)
  4284. (minDay < startOfWeek ? -7 : 0)));
  4285. }
  4286. // Get basics for variable time spans
  4287. minYear = time.get('FullYear', minDate);
  4288. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  4289. // Redefine min to the floored/rounded minimum time (#7432)
  4290. min = minDate.getTime();
  4291. // Handle local timezone offset
  4292. if ((time.variableTimezone || !time.useUTC) && defined(max)) {
  4293. // Detect whether we need to take the DST crossover into
  4294. // consideration. If we're crossing over DST, the day length may
  4295. // be 23h or 25h and we need to compute the exact clock time for
  4296. // each tick instead of just adding hours. This comes at a cost,
  4297. // so first we find out if it is needed (#4951).
  4298. variableDayLength = (
  4299. // Long range, assume we're crossing over.
  4300. max - min > 4 * timeUnits.month ||
  4301. // Short range, check if min and max are in different time
  4302. // zones.
  4303. time.getTimezoneOffset(min) !==
  4304. time.getTimezoneOffset(max));
  4305. }
  4306. // Iterate and add tick positions at appropriate values
  4307. var t = minDate.getTime();
  4308. i = 1;
  4309. while (t < max) {
  4310. tickPositions.push(t);
  4311. // if the interval is years, use Date.UTC to increase years
  4312. if (interval === timeUnits.year) {
  4313. t = time.makeTime(minYear + i * count, 0);
  4314. // if the interval is months, use Date.UTC to increase months
  4315. }
  4316. else if (interval === timeUnits.month) {
  4317. t = time.makeTime(minYear, minMonth + i * count);
  4318. // if we're using global time, the interval is not fixed as it
  4319. // jumps one hour at the DST crossover
  4320. }
  4321. else if (variableDayLength &&
  4322. (interval === timeUnits.day || interval === timeUnits.week)) {
  4323. t = time.makeTime(minYear, minMonth, minDateDate +
  4324. i * count * (interval === timeUnits.day ? 1 : 7));
  4325. }
  4326. else if (variableDayLength &&
  4327. interval === timeUnits.hour &&
  4328. count > 1) {
  4329. // make sure higher ranks are preserved across DST (#6797,
  4330. // #7621)
  4331. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  4332. // else, the interval is fixed and we use simple addition
  4333. }
  4334. else {
  4335. t += interval * count;
  4336. }
  4337. i++;
  4338. }
  4339. // push the last time
  4340. tickPositions.push(t);
  4341. // Handle higher ranks. Mark new days if the time is on midnight
  4342. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  4343. // to prevent looping over dense data grouping (#6156).
  4344. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  4345. tickPositions.forEach(function (t) {
  4346. if (
  4347. // Speed optimization, no need to run dateFormat unless
  4348. // we're on a full or half hour
  4349. t % 1800000 === 0 &&
  4350. // Check for local or global midnight
  4351. time.dateFormat('%H%M%S%L', t) === '000000000') {
  4352. higherRanks[t] = 'day';
  4353. }
  4354. });
  4355. }
  4356. }
  4357. // record information on the chosen unit - for dynamic label formatter
  4358. tickPositions.info = extend(normalizedInterval, {
  4359. higherRanks: higherRanks,
  4360. totalRange: interval * count
  4361. });
  4362. return tickPositions;
  4363. };
  4364. return Time;
  4365. }());
  4366. /**
  4367. * Normalized interval.
  4368. *
  4369. * @interface Highcharts.TimeNormalizedObject
  4370. */ /**
  4371. * The count.
  4372. *
  4373. * @name Highcharts.TimeNormalizedObject#count
  4374. * @type {number}
  4375. */ /**
  4376. * The interval in axis values (ms).
  4377. *
  4378. * @name Highcharts.TimeNormalizedObject#unitRange
  4379. * @type {number}
  4380. */
  4381. /**
  4382. * Function of an additional date format specifier.
  4383. *
  4384. * @callback Highcharts.TimeFormatCallbackFunction
  4385. *
  4386. * @param {number} timestamp
  4387. * The time to format.
  4388. *
  4389. * @return {string}
  4390. * The formatted portion of the date.
  4391. */
  4392. /**
  4393. * Time ticks.
  4394. *
  4395. * @interface Highcharts.AxisTickPositionsArray
  4396. * @extends global.Array<number>
  4397. */ /**
  4398. * @name Highcharts.AxisTickPositionsArray#info
  4399. * @type {Highcharts.TimeTicksInfoObject|undefined}
  4400. */
  4401. /**
  4402. * A callback to return the time zone offset for a given datetime. It
  4403. * takes the timestamp in terms of milliseconds since January 1 1970,
  4404. * and returns the timezone offset in minutes. This provides a hook
  4405. * for drawing time based charts in specific time zones using their
  4406. * local DST crossover dates, with the help of external libraries.
  4407. *
  4408. * @callback Highcharts.TimezoneOffsetCallbackFunction
  4409. *
  4410. * @param {number} timestamp
  4411. * Timestamp in terms of milliseconds since January 1 1970.
  4412. *
  4413. * @return {number}
  4414. * Timezone offset in minutes.
  4415. */
  4416. /**
  4417. * Allows to manually load the `moment.js` library from Highcharts options
  4418. * instead of the `window`.
  4419. * In case of loading the library from a `script` tag,
  4420. * this option is not needed, it will be loaded from there by default.
  4421. *
  4422. * @type {function}
  4423. * @since 8.2.0
  4424. * @apioption time.moment
  4425. */
  4426. ''; // keeps doclets above in JS file
  4427. return Time;
  4428. });
  4429. _registerModule(_modules, 'Core/DefaultOptions.js', [_modules['Core/Globals.js'], _modules['Core/Chart/ChartDefaults.js'], _modules['Core/Color/Color.js'], _modules['Core/Color/Palette.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, ChartDefaults, Color, palette, Time, U) {
  4430. /* *
  4431. *
  4432. * (c) 2010-2021 Torstein Honsi
  4433. *
  4434. * License: www.highcharts.com/license
  4435. *
  4436. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4437. *
  4438. * */
  4439. var isTouchDevice = H.isTouchDevice,
  4440. svg = H.svg;
  4441. var color = Color.parse;
  4442. var merge = U.merge;
  4443. /* *
  4444. *
  4445. * API Declarations
  4446. *
  4447. * */
  4448. /**
  4449. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  4450. */
  4451. /**
  4452. * Gets fired when a series is added to the chart after load time, using the
  4453. * `addSeries` method. Returning `false` prevents the series from being added.
  4454. *
  4455. * @callback Highcharts.ChartAddSeriesCallbackFunction
  4456. *
  4457. * @param {Highcharts.Chart} this
  4458. * The chart on which the event occured.
  4459. *
  4460. * @param {Highcharts.ChartAddSeriesEventObject} event
  4461. * The event that occured.
  4462. */
  4463. /**
  4464. * Contains common event information. Through the `options` property you can
  4465. * access the series options that were passed to the `addSeries` method.
  4466. *
  4467. * @interface Highcharts.ChartAddSeriesEventObject
  4468. */ /**
  4469. * The series options that were passed to the `addSeries` method.
  4470. * @name Highcharts.ChartAddSeriesEventObject#options
  4471. * @type {Highcharts.SeriesOptionsType}
  4472. */ /**
  4473. * Prevents the default behaviour of the event.
  4474. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  4475. * @type {Function}
  4476. */ /**
  4477. * The event target.
  4478. * @name Highcharts.ChartAddSeriesEventObject#target
  4479. * @type {Highcharts.Chart}
  4480. */ /**
  4481. * The event type.
  4482. * @name Highcharts.ChartAddSeriesEventObject#type
  4483. * @type {"addSeries"}
  4484. */
  4485. /**
  4486. * Gets fired when clicking on the plot background.
  4487. *
  4488. * @callback Highcharts.ChartClickCallbackFunction
  4489. *
  4490. * @param {Highcharts.Chart} this
  4491. * The chart on which the event occured.
  4492. *
  4493. * @param {Highcharts.PointerEventObject} event
  4494. * The event that occured.
  4495. */
  4496. /**
  4497. * Contains an axes of the clicked spot.
  4498. *
  4499. * @interface Highcharts.ChartClickEventAxisObject
  4500. */ /**
  4501. * Axis at the clicked spot.
  4502. * @name Highcharts.ChartClickEventAxisObject#axis
  4503. * @type {Highcharts.Axis}
  4504. */ /**
  4505. * Axis value at the clicked spot.
  4506. * @name Highcharts.ChartClickEventAxisObject#value
  4507. * @type {number}
  4508. */
  4509. /**
  4510. * Contains information about the clicked spot on the chart. Remember the unit
  4511. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  4512. *
  4513. * @interface Highcharts.ChartClickEventObject
  4514. * @extends Highcharts.PointerEventObject
  4515. */ /**
  4516. * Information about the x-axis on the clicked spot.
  4517. * @name Highcharts.ChartClickEventObject#xAxis
  4518. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  4519. */ /**
  4520. * Information about the y-axis on the clicked spot.
  4521. * @name Highcharts.ChartClickEventObject#yAxis
  4522. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  4523. */ /**
  4524. * Information about the z-axis on the clicked spot.
  4525. * @name Highcharts.ChartClickEventObject#zAxis
  4526. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  4527. */
  4528. /**
  4529. * Gets fired when the chart is finished loading.
  4530. *
  4531. * @callback Highcharts.ChartLoadCallbackFunction
  4532. *
  4533. * @param {Highcharts.Chart} this
  4534. * The chart on which the event occured.
  4535. *
  4536. * @param {global.Event} event
  4537. * The event that occured.
  4538. */
  4539. /**
  4540. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  4541. * after an axis, series or point is modified with the `redraw` option set to
  4542. * `true`.
  4543. *
  4544. * @callback Highcharts.ChartRedrawCallbackFunction
  4545. *
  4546. * @param {Highcharts.Chart} this
  4547. * The chart on which the event occured.
  4548. *
  4549. * @param {global.Event} event
  4550. * The event that occured.
  4551. */
  4552. /**
  4553. * Gets fired after initial load of the chart (directly after the `load` event),
  4554. * and after each redraw (directly after the `redraw` event).
  4555. *
  4556. * @callback Highcharts.ChartRenderCallbackFunction
  4557. *
  4558. * @param {Highcharts.Chart} this
  4559. * The chart on which the event occured.
  4560. *
  4561. * @param {global.Event} event
  4562. * The event that occured.
  4563. */
  4564. /**
  4565. * Gets fired when an area of the chart has been selected. The default action
  4566. * for the selection event is to zoom the chart to the selected area. It can be
  4567. * prevented by calling `event.preventDefault()` or return false.
  4568. *
  4569. * @callback Highcharts.ChartSelectionCallbackFunction
  4570. *
  4571. * @param {Highcharts.Chart} this
  4572. * The chart on which the event occured.
  4573. *
  4574. * @param {global.ChartSelectionContextObject} event
  4575. * Event informations
  4576. *
  4577. * @return {boolean|undefined}
  4578. * Return false to prevent the default action, usually zoom.
  4579. */
  4580. /**
  4581. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  4582. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4583. *
  4584. * @interface Highcharts.ChartSelectionContextObject
  4585. * @extends global.Event
  4586. */ /**
  4587. * Arrays containing the axes of each dimension and each axis' min and max
  4588. * values.
  4589. * @name Highcharts.ChartSelectionContextObject#xAxis
  4590. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  4591. */ /**
  4592. * Arrays containing the axes of each dimension and each axis' min and max
  4593. * values.
  4594. * @name Highcharts.ChartSelectionContextObject#yAxis
  4595. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  4596. */
  4597. /**
  4598. * Axis context of the selection.
  4599. *
  4600. * @interface Highcharts.ChartSelectionAxisContextObject
  4601. */ /**
  4602. * The selected Axis.
  4603. * @name Highcharts.ChartSelectionAxisContextObject#axis
  4604. * @type {Highcharts.Axis}
  4605. */ /**
  4606. * The maximum axis value, either automatic or set manually.
  4607. * @name Highcharts.ChartSelectionAxisContextObject#max
  4608. * @type {number}
  4609. */ /**
  4610. * The minimum axis value, either automatic or set manually.
  4611. * @name Highcharts.ChartSelectionAxisContextObject#min
  4612. * @type {number}
  4613. */
  4614. (''); // detach doclets above
  4615. /* *
  4616. *
  4617. * API Options
  4618. *
  4619. * */
  4620. /**
  4621. * Global default settings.
  4622. *
  4623. * @name Highcharts.defaultOptions
  4624. * @type {Highcharts.Options}
  4625. */ /**
  4626. * @optionparent
  4627. */
  4628. var defaultOptions = {
  4629. /**
  4630. * An array containing the default colors for the chart's series. When
  4631. * all colors are used, new colors are pulled from the start again.
  4632. *
  4633. * Default colors can also be set on a series or series.type basis,
  4634. * see [column.colors](#plotOptions.column.colors),
  4635. * [pie.colors](#plotOptions.pie.colors).
  4636. *
  4637. * In styled mode, the colors option doesn't exist. Instead, colors
  4638. * are defined in CSS and applied either through series or point class
  4639. * names, or through the [chart.colorCount](#chart.colorCount) option.
  4640. *
  4641. *
  4642. * ### Legacy
  4643. *
  4644. * In Highcharts 3.x, the default colors were:
  4645. * ```js
  4646. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  4647. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  4648. * ```
  4649. *
  4650. * In Highcharts 2.x, the default colors were:
  4651. * ```js
  4652. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  4653. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  4654. * ```
  4655. *
  4656. * @sample {highcharts} highcharts/chart/colors/
  4657. * Assign a global color theme
  4658. *
  4659. * @type {Array<Highcharts.ColorString>}
  4660. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  4661. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  4662. */
  4663. colors: palette.colors,
  4664. /**
  4665. * Styled mode only. Configuration object for adding SVG definitions for
  4666. * reusable elements. See [gradients, shadows and
  4667. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  4668. * for more information and code examples.
  4669. *
  4670. * @type {*}
  4671. * @since 5.0.0
  4672. * @apioption defs
  4673. */
  4674. /**
  4675. * @ignore-option
  4676. */
  4677. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  4678. /**
  4679. * The language object is global and it can't be set on each chart
  4680. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  4681. * chart is initialized.
  4682. *
  4683. * ```js
  4684. * Highcharts.setOptions({
  4685. * lang: {
  4686. * months: [
  4687. * 'Janvier', 'Février', 'Mars', 'Avril',
  4688. * 'Mai', 'Juin', 'Juillet', 'Août',
  4689. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  4690. * ],
  4691. * weekdays: [
  4692. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  4693. * 'Jeudi', 'Vendredi', 'Samedi'
  4694. * ]
  4695. * }
  4696. * });
  4697. * ```
  4698. */
  4699. lang: {
  4700. /**
  4701. * The loading text that appears when the chart is set into the loading
  4702. * state following a call to `chart.showLoading`.
  4703. */
  4704. loading: 'Loading...',
  4705. /**
  4706. * An array containing the months names. Corresponds to the `%B` format
  4707. * in `Highcharts.dateFormat()`.
  4708. *
  4709. * @type {Array<string>}
  4710. * @default ["January", "February", "March", "April", "May", "June",
  4711. * "July", "August", "September", "October", "November",
  4712. * "December"]
  4713. */
  4714. months: [
  4715. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  4716. 'August', 'September', 'October', 'November', 'December'
  4717. ],
  4718. /**
  4719. * An array containing the months names in abbreviated form. Corresponds
  4720. * to the `%b` format in `Highcharts.dateFormat()`.
  4721. *
  4722. * @type {Array<string>}
  4723. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  4724. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  4725. */
  4726. shortMonths: [
  4727. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  4728. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  4729. ],
  4730. /**
  4731. * An array containing the weekday names.
  4732. *
  4733. * @type {Array<string>}
  4734. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  4735. * "Friday", "Saturday"]
  4736. */
  4737. weekdays: [
  4738. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  4739. 'Thursday', 'Friday', 'Saturday'
  4740. ],
  4741. /**
  4742. * Short week days, starting Sunday. If not specified, Highcharts uses
  4743. * the first three letters of the `lang.weekdays` option.
  4744. *
  4745. * @sample highcharts/lang/shortweekdays/
  4746. * Finnish two-letter abbreviations
  4747. *
  4748. * @type {Array<string>}
  4749. * @since 4.2.4
  4750. * @apioption lang.shortWeekdays
  4751. */
  4752. /**
  4753. * What to show in a date field for invalid dates. Defaults to an empty
  4754. * string.
  4755. *
  4756. * @type {string}
  4757. * @since 4.1.8
  4758. * @product highcharts highstock
  4759. * @apioption lang.invalidDate
  4760. */
  4761. /**
  4762. * The title appearing on hovering the zoom in button. The text itself
  4763. * defaults to "+" and can be changed in the button options.
  4764. *
  4765. * @type {string}
  4766. * @default Zoom in
  4767. * @product highmaps
  4768. * @apioption lang.zoomIn
  4769. */
  4770. /**
  4771. * The title appearing on hovering the zoom out button. The text itself
  4772. * defaults to "-" and can be changed in the button options.
  4773. *
  4774. * @type {string}
  4775. * @default Zoom out
  4776. * @product highmaps
  4777. * @apioption lang.zoomOut
  4778. */
  4779. /**
  4780. * The default decimal point used in the `Highcharts.numberFormat`
  4781. * method unless otherwise specified in the function arguments.
  4782. *
  4783. * @since 1.2.2
  4784. */
  4785. decimalPoint: '.',
  4786. /**
  4787. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  4788. * to shorten high numbers in axis labels. Replacing any of the
  4789. * positions with `null` causes the full number to be written. Setting
  4790. * `numericSymbols` to `null` disables shortening altogether.
  4791. *
  4792. * @sample {highcharts} highcharts/lang/numericsymbols/
  4793. * Replacing the symbols with text
  4794. * @sample {highstock} highcharts/lang/numericsymbols/
  4795. * Replacing the symbols with text
  4796. *
  4797. * @type {Array<string>}
  4798. * @default ["k", "M", "G", "T", "P", "E"]
  4799. * @since 2.3.0
  4800. */
  4801. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  4802. /**
  4803. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  4804. * Use 10000 for Japanese, Korean and various Chinese locales, which
  4805. * use symbols for 10^4, 10^8 and 10^12.
  4806. *
  4807. * @sample highcharts/lang/numericsymbolmagnitude/
  4808. * 10000 magnitude for Japanese
  4809. *
  4810. * @type {number}
  4811. * @default 1000
  4812. * @since 5.0.3
  4813. * @apioption lang.numericSymbolMagnitude
  4814. */
  4815. /**
  4816. * The text for the label appearing when a chart is zoomed.
  4817. *
  4818. * @since 1.2.4
  4819. */
  4820. resetZoom: 'Reset zoom',
  4821. /**
  4822. * The tooltip title for the label appearing when a chart is zoomed.
  4823. *
  4824. * @since 1.2.4
  4825. */
  4826. resetZoomTitle: 'Reset zoom level 1:1',
  4827. /**
  4828. * The default thousands separator used in the `Highcharts.numberFormat`
  4829. * method unless otherwise specified in the function arguments. Defaults
  4830. * to a single space character, which is recommended in
  4831. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  4832. * across Anglo-American and continental European languages.
  4833. *
  4834. * @default \u0020
  4835. * @since 1.2.2
  4836. */
  4837. thousandsSep: ' '
  4838. },
  4839. /**
  4840. * Global options that don't apply to each chart. These options, like
  4841. * the `lang` options, must be set using the `Highcharts.setOptions`
  4842. * method.
  4843. *
  4844. * ```js
  4845. * Highcharts.setOptions({
  4846. * global: {
  4847. * useUTC: false
  4848. * }
  4849. * });
  4850. * ```
  4851. */
  4852. /**
  4853. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  4854. * Use the [libURL](#exporting.libURL) option to configure exporting._
  4855. *
  4856. * The URL to the additional file to lazy load for Android 2.x devices.
  4857. * These devices don't support SVG, so we download a helper file that
  4858. * contains [canvg](https://github.com/canvg/canvg), its dependency
  4859. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  4860. * our site, you can install canvas-tools.js on your own server and
  4861. * change this option accordingly.
  4862. *
  4863. * @deprecated
  4864. *
  4865. * @type {string}
  4866. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  4867. * @product highcharts highmaps
  4868. * @apioption global.canvasToolsURL
  4869. */
  4870. /**
  4871. * This option is deprecated since v6.0.5. Instead, use
  4872. * [time.useUTC](#time.useUTC) that supports individual time settings
  4873. * per chart.
  4874. *
  4875. * @deprecated
  4876. *
  4877. * @type {boolean}
  4878. * @apioption global.useUTC
  4879. */
  4880. /**
  4881. * This option is deprecated since v6.0.5. Instead, use
  4882. * [time.Date](#time.Date) that supports individual time settings
  4883. * per chart.
  4884. *
  4885. * @deprecated
  4886. *
  4887. * @type {Function}
  4888. * @product highcharts highstock
  4889. * @apioption global.Date
  4890. */
  4891. /**
  4892. * This option is deprecated since v6.0.5. Instead, use
  4893. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  4894. * individual time settings per chart.
  4895. *
  4896. * @deprecated
  4897. *
  4898. * @type {Function}
  4899. * @product highcharts highstock
  4900. * @apioption global.getTimezoneOffset
  4901. */
  4902. /**
  4903. * This option is deprecated since v6.0.5. Instead, use
  4904. * [time.timezone](#time.timezone) that supports individual time
  4905. * settings per chart.
  4906. *
  4907. * @deprecated
  4908. *
  4909. * @type {string}
  4910. * @product highcharts highstock
  4911. * @apioption global.timezone
  4912. */
  4913. /**
  4914. * This option is deprecated since v6.0.5. Instead, use
  4915. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  4916. * time settings per chart.
  4917. *
  4918. * @deprecated
  4919. *
  4920. * @type {number}
  4921. * @product highcharts highstock
  4922. * @apioption global.timezoneOffset
  4923. */
  4924. global: {},
  4925. /**
  4926. * Time options that can apply globally or to individual charts. These
  4927. * settings affect how `datetime` axes are laid out, how tooltips are
  4928. * formatted, how series
  4929. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  4930. * the Highcharts Stock range selector handles time.
  4931. *
  4932. * The common use case is that all charts in the same Highcharts object
  4933. * share the same time settings, in which case the global settings are set
  4934. * using `setOptions`.
  4935. *
  4936. * ```js
  4937. * // Apply time settings globally
  4938. * Highcharts.setOptions({
  4939. * time: {
  4940. * timezone: 'Europe/London'
  4941. * }
  4942. * });
  4943. * // Apply time settings by instance
  4944. * let chart = Highcharts.chart('container', {
  4945. * time: {
  4946. * timezone: 'America/New_York'
  4947. * },
  4948. * series: [{
  4949. * data: [1, 4, 3, 5]
  4950. * }]
  4951. * });
  4952. *
  4953. * // Use the Time object
  4954. * console.log(
  4955. * 'Current time in New York',
  4956. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  4957. * );
  4958. * ```
  4959. *
  4960. * Since v6.0.5, the time options were moved from the `global` obect to the
  4961. * `time` object, and time options can be set on each individual chart.
  4962. *
  4963. * @sample {highcharts|highstock}
  4964. * highcharts/time/timezone/
  4965. * Set the timezone globally
  4966. * @sample {highcharts}
  4967. * highcharts/time/individual/
  4968. * Set the timezone per chart instance
  4969. * @sample {highstock}
  4970. * stock/time/individual/
  4971. * Set the timezone per chart instance
  4972. *
  4973. * @since 6.0.5
  4974. * @optionparent time
  4975. */
  4976. time: {
  4977. /**
  4978. * A custom `Date` class for advanced date handling. For example,
  4979. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  4980. * handle Jalali dates.
  4981. *
  4982. * @type {*}
  4983. * @since 4.0.4
  4984. * @product highcharts highstock gantt
  4985. */
  4986. Date: void 0,
  4987. /**
  4988. * A callback to return the time zone offset for a given datetime. It
  4989. * takes the timestamp in terms of milliseconds since January 1 1970,
  4990. * and returns the timezone offset in minutes. This provides a hook
  4991. * for drawing time based charts in specific time zones using their
  4992. * local DST crossover dates, with the help of external libraries.
  4993. *
  4994. * @see [global.timezoneOffset](#global.timezoneOffset)
  4995. *
  4996. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  4997. * Use moment.js to draw Oslo time regardless of browser locale
  4998. *
  4999. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  5000. * @since 4.1.0
  5001. * @product highcharts highstock gantt
  5002. */
  5003. getTimezoneOffset: void 0,
  5004. /**
  5005. * Requires [moment.js](https://momentjs.com/). If the timezone option
  5006. * is specified, it creates a default
  5007. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  5008. * up the specified timezone in moment.js. If moment.js is not included,
  5009. * this throws a Highcharts error in the console, but does not crash the
  5010. * chart.
  5011. *
  5012. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  5013. *
  5014. * @sample {highcharts|highstock} highcharts/time/timezone/
  5015. * Europe/Oslo
  5016. *
  5017. * @type {string}
  5018. * @since 5.0.7
  5019. * @product highcharts highstock gantt
  5020. */
  5021. timezone: void 0,
  5022. /**
  5023. * The timezone offset in minutes. Positive values are west, negative
  5024. * values are east of UTC, as in the ECMAScript
  5025. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  5026. * method. Use this to display UTC based data in a predefined time zone.
  5027. *
  5028. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  5029. *
  5030. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  5031. * Timezone offset
  5032. *
  5033. * @since 3.0.8
  5034. * @product highcharts highstock gantt
  5035. */
  5036. timezoneOffset: 0,
  5037. /**
  5038. * Whether to use UTC time for axis scaling, tickmark placement and
  5039. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  5040. * is that the time displays equally regardless of the user agent's
  5041. * time zone settings. Local time can be used when the data is loaded
  5042. * in real time or when correct Daylight Saving Time transitions are
  5043. * required.
  5044. *
  5045. * @sample {highcharts} highcharts/time/useutc-true/
  5046. * True by default
  5047. * @sample {highcharts} highcharts/time/useutc-false/
  5048. * False
  5049. */
  5050. useUTC: true
  5051. },
  5052. chart: ChartDefaults,
  5053. /**
  5054. * The chart's main title.
  5055. *
  5056. * @sample {highmaps} maps/title/title/
  5057. * Title options demonstrated
  5058. */
  5059. title: {
  5060. /**
  5061. * When the title is floating, the plot area will not move to make space
  5062. * for it.
  5063. *
  5064. * @sample {highcharts} highcharts/chart/zoomtype-none/
  5065. * False by default
  5066. * @sample {highcharts} highcharts/title/floating/
  5067. * True - title on top of the plot area
  5068. * @sample {highstock} stock/chart/title-floating/
  5069. * True - title on top of the plot area
  5070. *
  5071. * @type {boolean}
  5072. * @default false
  5073. * @since 2.1
  5074. * @apioption title.floating
  5075. */
  5076. /**
  5077. * CSS styles for the title. Use this for font styling, but use `align`,
  5078. * `x` and `y` for text alignment.
  5079. *
  5080. * In styled mode, the title style is given in the `.highcharts-title`
  5081. * class.
  5082. *
  5083. * @sample {highcharts} highcharts/title/style/
  5084. * Custom color and weight
  5085. * @sample {highstock} stock/chart/title-style/
  5086. * Custom color and weight
  5087. * @sample highcharts/css/titles/
  5088. * Styled mode
  5089. *
  5090. * @type {Highcharts.CSSObject}
  5091. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  5092. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  5093. * @apioption title.style
  5094. */
  5095. /**
  5096. * Whether to
  5097. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5098. * to render the text.
  5099. *
  5100. * @type {boolean}
  5101. * @default false
  5102. * @apioption title.useHTML
  5103. */
  5104. /**
  5105. * The vertical alignment of the title. Can be one of `"top"`,
  5106. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  5107. * as if [floating](#title.floating) were `true`.
  5108. *
  5109. * @sample {highcharts} highcharts/title/verticalalign/
  5110. * Chart title in bottom right corner
  5111. * @sample {highstock} stock/chart/title-verticalalign/
  5112. * Chart title in bottom right corner
  5113. *
  5114. * @type {Highcharts.VerticalAlignValue}
  5115. * @since 2.1
  5116. * @apioption title.verticalAlign
  5117. */
  5118. /**
  5119. * The x position of the title relative to the alignment within
  5120. * `chart.spacingLeft` and `chart.spacingRight`.
  5121. *
  5122. * @sample {highcharts} highcharts/title/align/
  5123. * Aligned to the plot area (x = 70px = margin left - spacing
  5124. * left)
  5125. * @sample {highstock} stock/chart/title-align/
  5126. * Aligned to the plot area (x = 50px = margin left - spacing
  5127. * left)
  5128. *
  5129. * @type {number}
  5130. * @default 0
  5131. * @since 2.0
  5132. * @apioption title.x
  5133. */
  5134. /**
  5135. * The y position of the title relative to the alignment within
  5136. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  5137. * #chart.spacingBottom). By default it depends on the font size.
  5138. *
  5139. * @sample {highcharts} highcharts/title/y/
  5140. * Title inside the plot area
  5141. * @sample {highstock} stock/chart/title-verticalalign/
  5142. * Chart title in bottom right corner
  5143. *
  5144. * @type {number}
  5145. * @since 2.0
  5146. * @apioption title.y
  5147. */
  5148. /**
  5149. * The title of the chart. To disable the title, set the `text` to
  5150. * `undefined`.
  5151. *
  5152. * @sample {highcharts} highcharts/title/text/
  5153. * Custom title
  5154. * @sample {highstock} stock/chart/title-text/
  5155. * Custom title
  5156. *
  5157. * @default {highcharts|highmaps} Chart title
  5158. * @default {highstock} undefined
  5159. */
  5160. text: 'Chart title',
  5161. /**
  5162. * The horizontal alignment of the title. Can be one of "left", "center"
  5163. * and "right".
  5164. *
  5165. * @sample {highcharts} highcharts/title/align/
  5166. * Aligned to the plot area (x = 70px = margin left - spacing
  5167. * left)
  5168. * @sample {highstock} stock/chart/title-align/
  5169. * Aligned to the plot area (x = 50px = margin left - spacing
  5170. * left)
  5171. *
  5172. * @type {Highcharts.AlignValue}
  5173. * @since 2.0
  5174. */
  5175. align: 'center',
  5176. /**
  5177. * The margin between the title and the plot area, or if a subtitle
  5178. * is present, the margin between the subtitle and the plot area.
  5179. *
  5180. * @sample {highcharts} highcharts/title/margin-50/
  5181. * A chart title margin of 50
  5182. * @sample {highcharts} highcharts/title/margin-subtitle/
  5183. * The same margin applied with a subtitle
  5184. * @sample {highstock} stock/chart/title-margin/
  5185. * A chart title margin of 50
  5186. *
  5187. * @since 2.1
  5188. */
  5189. margin: 15,
  5190. /**
  5191. * Adjustment made to the title width, normally to reserve space for
  5192. * the exporting burger menu.
  5193. *
  5194. * @sample highcharts/title/widthadjust/
  5195. * Wider menu, greater padding
  5196. *
  5197. * @since 4.2.5
  5198. */
  5199. widthAdjust: -44
  5200. },
  5201. /**
  5202. * The chart's subtitle. This can be used both to display a subtitle below
  5203. * the main title, and to display random text anywhere in the chart. The
  5204. * subtitle can be updated after chart initialization through the
  5205. * `Chart.setTitle` method.
  5206. *
  5207. * @sample {highmaps} maps/title/subtitle/
  5208. * Subtitle options demonstrated
  5209. */
  5210. subtitle: {
  5211. /**
  5212. * When the subtitle is floating, the plot area will not move to make
  5213. * space for it.
  5214. *
  5215. * @sample {highcharts} highcharts/subtitle/floating/
  5216. * Floating title and subtitle
  5217. * @sample {highstock} stock/chart/subtitle-footnote
  5218. * Footnote floating at bottom right of plot area
  5219. *
  5220. * @type {boolean}
  5221. * @default false
  5222. * @since 2.1
  5223. * @apioption subtitle.floating
  5224. */
  5225. /**
  5226. * CSS styles for the title.
  5227. *
  5228. * In styled mode, the subtitle style is given in the
  5229. * `.highcharts-subtitle` class.
  5230. *
  5231. * @sample {highcharts} highcharts/subtitle/style/
  5232. * Custom color and weight
  5233. * @sample {highcharts} highcharts/css/titles/
  5234. * Styled mode
  5235. * @sample {highstock} stock/chart/subtitle-style
  5236. * Custom color and weight
  5237. * @sample {highstock} highcharts/css/titles/
  5238. * Styled mode
  5239. * @sample {highmaps} highcharts/css/titles/
  5240. * Styled mode
  5241. *
  5242. * @type {Highcharts.CSSObject}
  5243. * @default {"color": "#666666"}
  5244. * @apioption subtitle.style
  5245. */
  5246. /**
  5247. * Whether to
  5248. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5249. * to render the text.
  5250. *
  5251. * @type {boolean}
  5252. * @default false
  5253. * @apioption subtitle.useHTML
  5254. */
  5255. /**
  5256. * The vertical alignment of the title. Can be one of `"top"`,
  5257. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  5258. * floating.
  5259. *
  5260. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5261. * Footnote at the bottom right of plot area
  5262. * @sample {highstock} stock/chart/subtitle-footnote
  5263. * Footnote at the bottom right of plot area
  5264. *
  5265. * @type {Highcharts.VerticalAlignValue}
  5266. * @since 2.1
  5267. * @apioption subtitle.verticalAlign
  5268. */
  5269. /**
  5270. * The x position of the subtitle relative to the alignment within
  5271. * `chart.spacingLeft` and `chart.spacingRight`.
  5272. *
  5273. * @sample {highcharts} highcharts/subtitle/align/
  5274. * Footnote at right of plot area
  5275. * @sample {highstock} stock/chart/subtitle-footnote
  5276. * Footnote at the bottom right of plot area
  5277. *
  5278. * @type {number}
  5279. * @default 0
  5280. * @since 2.0
  5281. * @apioption subtitle.x
  5282. */
  5283. /**
  5284. * The y position of the subtitle relative to the alignment within
  5285. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  5286. * is laid out below the title unless the title is floating.
  5287. *
  5288. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5289. * Footnote at the bottom right of plot area
  5290. * @sample {highstock} stock/chart/subtitle-footnote
  5291. * Footnote at the bottom right of plot area
  5292. *
  5293. * @type {number}
  5294. * @since 2.0
  5295. * @apioption subtitle.y
  5296. */
  5297. /**
  5298. * The subtitle of the chart.
  5299. *
  5300. * @sample {highcharts|highstock} highcharts/subtitle/text/
  5301. * Custom subtitle
  5302. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  5303. * Formatted and linked text.
  5304. */
  5305. text: '',
  5306. /**
  5307. * The horizontal alignment of the subtitle. Can be one of "left",
  5308. * "center" and "right".
  5309. *
  5310. * @sample {highcharts} highcharts/subtitle/align/
  5311. * Footnote at right of plot area
  5312. * @sample {highstock} stock/chart/subtitle-footnote
  5313. * Footnote at bottom right of plot area
  5314. *
  5315. * @type {Highcharts.AlignValue}
  5316. * @since 2.0
  5317. */
  5318. align: 'center',
  5319. /**
  5320. * Adjustment made to the subtitle width, normally to reserve space
  5321. * for the exporting burger menu.
  5322. *
  5323. * @see [title.widthAdjust](#title.widthAdjust)
  5324. *
  5325. * @sample highcharts/title/widthadjust/
  5326. * Wider menu, greater padding
  5327. *
  5328. * @since 4.2.5
  5329. */
  5330. widthAdjust: -44
  5331. },
  5332. /**
  5333. * The chart's caption, which will render below the chart and will be part
  5334. * of exported charts. The caption can be updated after chart initialization
  5335. * through the `Chart.update` or `Chart.caption.update` methods.
  5336. *
  5337. * @sample highcharts/caption/text/
  5338. * A chart with a caption
  5339. * @since 7.2.0
  5340. */
  5341. caption: {
  5342. /**
  5343. * When the caption is floating, the plot area will not move to make
  5344. * space for it.
  5345. *
  5346. * @type {boolean}
  5347. * @default false
  5348. * @apioption caption.floating
  5349. */
  5350. /**
  5351. * The margin between the caption and the plot area.
  5352. */
  5353. margin: 15,
  5354. /**
  5355. * CSS styles for the caption.
  5356. *
  5357. * In styled mode, the caption style is given in the
  5358. * `.highcharts-caption` class.
  5359. *
  5360. * @sample {highcharts} highcharts/css/titles/
  5361. * Styled mode
  5362. *
  5363. * @type {Highcharts.CSSObject}
  5364. * @default {"color": "#666666"}
  5365. * @apioption caption.style
  5366. */
  5367. /**
  5368. * Whether to
  5369. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5370. * to render the text.
  5371. *
  5372. * @type {boolean}
  5373. * @default false
  5374. * @apioption caption.useHTML
  5375. */
  5376. /**
  5377. * The x position of the caption relative to the alignment within
  5378. * `chart.spacingLeft` and `chart.spacingRight`.
  5379. *
  5380. * @type {number}
  5381. * @default 0
  5382. * @apioption caption.x
  5383. */
  5384. /**
  5385. * The y position of the caption relative to the alignment within
  5386. * `chart.spacingTop` and `chart.spacingBottom`.
  5387. *
  5388. * @type {number}
  5389. * @apioption caption.y
  5390. */
  5391. /**
  5392. * The caption text of the chart.
  5393. *
  5394. * @sample {highcharts} highcharts/caption/text/
  5395. * Custom caption
  5396. */
  5397. text: '',
  5398. /**
  5399. * The horizontal alignment of the caption. Can be one of "left",
  5400. * "center" and "right".
  5401. *
  5402. * @type {Highcharts.AlignValue}
  5403. */
  5404. align: 'left',
  5405. /**
  5406. * The vertical alignment of the caption. Can be one of `"top"`,
  5407. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  5408. * floating.
  5409. *
  5410. * @type {Highcharts.VerticalAlignValue}
  5411. */
  5412. verticalAlign: 'bottom'
  5413. },
  5414. /**
  5415. * The plotOptions is a wrapper object for config objects for each series
  5416. * type. The config objects for each series can also be overridden for
  5417. * each series item as given in the series array.
  5418. *
  5419. * Configuration options for the series are given in three levels. Options
  5420. * for all series in a chart are given in the [plotOptions.series](
  5421. * #plotOptions.series) object. Then options for all series of a specific
  5422. * type are given in the plotOptions of that type, for example
  5423. * `plotOptions.line`. Next, options for one single series are given in
  5424. * [the series array](#series).
  5425. */
  5426. plotOptions: {},
  5427. /**
  5428. * HTML labels that can be positioned anywhere in the chart area.
  5429. *
  5430. * This option is deprecated since v7.1.2. Instead, use
  5431. * [annotations](#annotations) that support labels.
  5432. *
  5433. * @deprecated
  5434. * @product highcharts highstock
  5435. */
  5436. labels: {
  5437. /**
  5438. * An HTML label that can be positioned anywhere in the chart area.
  5439. *
  5440. * @deprecated
  5441. * @type {Array<*>}
  5442. * @apioption labels.items
  5443. */
  5444. /**
  5445. * Inner HTML or text for the label.
  5446. *
  5447. * @deprecated
  5448. * @type {string}
  5449. * @apioption labels.items.html
  5450. */
  5451. /**
  5452. * CSS styles for each label. To position the label, use left and top
  5453. * like this:
  5454. * ```js
  5455. * style: {
  5456. * left: '100px',
  5457. * top: '100px'
  5458. * }
  5459. * ```
  5460. *
  5461. * @deprecated
  5462. * @type {Highcharts.CSSObject}
  5463. * @apioption labels.items.style
  5464. */
  5465. /**
  5466. * Shared CSS styles for all labels.
  5467. *
  5468. * @deprecated
  5469. * @type {Highcharts.CSSObject}
  5470. * @default {"color": "#333333", "position": "absolute"}
  5471. */
  5472. style: {
  5473. /**
  5474. * @ignore-option
  5475. */
  5476. position: 'absolute',
  5477. /**
  5478. * @ignore-option
  5479. */
  5480. color: palette.neutralColor80
  5481. }
  5482. },
  5483. /**
  5484. * The legend is a box containing a symbol and name for each series
  5485. * item or point item in the chart. Each series (or points in case
  5486. * of pie charts) is represented by a symbol and its name in the legend.
  5487. *
  5488. * It is possible to override the symbol creator function and create
  5489. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  5490. *
  5491. * @productdesc {highmaps}
  5492. * A Highmaps legend by default contains one legend item per series, but if
  5493. * a `colorAxis` is defined, the axis will be displayed in the legend.
  5494. * Either as a gradient, or as multiple legend items for `dataClasses`.
  5495. */
  5496. legend: {
  5497. /**
  5498. * The background color of the legend.
  5499. *
  5500. * @see In styled mode, the legend background fill can be applied with
  5501. * the `.highcharts-legend-box` class.
  5502. *
  5503. * @sample {highcharts} highcharts/legend/backgroundcolor/
  5504. * Yellowish background
  5505. * @sample {highstock} stock/legend/align/
  5506. * Various legend options
  5507. * @sample {highmaps} maps/legend/border-background/
  5508. * Border and background options
  5509. *
  5510. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5511. * @apioption legend.backgroundColor
  5512. */
  5513. /**
  5514. * The width of the drawn border around the legend.
  5515. *
  5516. * @see In styled mode, the legend border stroke width can be applied
  5517. * with the `.highcharts-legend-box` class.
  5518. *
  5519. * @sample {highcharts} highcharts/legend/borderwidth/
  5520. * 2px border width
  5521. * @sample {highstock} stock/legend/align/
  5522. * Various legend options
  5523. * @sample {highmaps} maps/legend/border-background/
  5524. * Border and background options
  5525. *
  5526. * @type {number}
  5527. * @default 0
  5528. * @apioption legend.borderWidth
  5529. */
  5530. /**
  5531. * Enable or disable the legend. There is also a series-specific option,
  5532. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  5533. * series from the legend. In some series types this is `false` by
  5534. * default, so it must set to `true` in order to show the legend for the
  5535. * series.
  5536. *
  5537. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  5538. * @sample {highstock} stock/legend/align/ Various legend options
  5539. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  5540. *
  5541. * @default {highstock} false
  5542. * @default {highmaps} true
  5543. * @default {gantt} false
  5544. */
  5545. enabled: true,
  5546. /**
  5547. * The horizontal alignment of the legend box within the chart area.
  5548. * Valid values are `left`, `center` and `right`.
  5549. *
  5550. * In the case that the legend is aligned in a corner position, the
  5551. * `layout` option will determine whether to place it above/below
  5552. * or on the side of the plot area.
  5553. *
  5554. * @sample {highcharts} highcharts/legend/align/
  5555. * Legend at the right of the chart
  5556. * @sample {highstock} stock/legend/align/
  5557. * Various legend options
  5558. * @sample {highmaps} maps/legend/alignment/
  5559. * Legend alignment
  5560. *
  5561. * @type {Highcharts.AlignValue}
  5562. * @since 2.0
  5563. */
  5564. align: 'center',
  5565. /**
  5566. * If the [layout](legend.layout) is `horizontal` and the legend items
  5567. * span over two lines or more, whether to align the items into vertical
  5568. * columns. Setting this to `false` makes room for more items, but will
  5569. * look more messy.
  5570. *
  5571. * @since 6.1.0
  5572. */
  5573. alignColumns: true,
  5574. /**
  5575. * A CSS class name to apply to the legend group.
  5576. */
  5577. className: 'highcharts-no-tooltip',
  5578. /**
  5579. * When the legend is floating, the plot area ignores it and is allowed
  5580. * to be placed below it.
  5581. *
  5582. * @sample {highcharts} highcharts/legend/floating-false/
  5583. * False by default
  5584. * @sample {highcharts} highcharts/legend/floating-true/
  5585. * True
  5586. * @sample {highmaps} maps/legend/alignment/
  5587. * Floating legend
  5588. *
  5589. * @type {boolean}
  5590. * @default false
  5591. * @since 2.1
  5592. * @apioption legend.floating
  5593. */
  5594. /**
  5595. * The layout of the legend items. Can be one of `horizontal` or
  5596. * `vertical` or `proximate`. When `proximate`, the legend items will be
  5597. * placed as close as possible to the graphs they're representing,
  5598. * except in inverted charts or when the legend position doesn't allow
  5599. * it.
  5600. *
  5601. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5602. * Horizontal by default
  5603. * @sample {highcharts} highcharts/legend/layout-vertical/
  5604. * Vertical
  5605. * @sample highcharts/legend/layout-proximate
  5606. * Labels proximate to the data
  5607. * @sample {highstock} stock/legend/layout-horizontal/
  5608. * Horizontal by default
  5609. * @sample {highmaps} maps/legend/padding-itemmargin/
  5610. * Vertical with data classes
  5611. * @sample {highmaps} maps/legend/layout-vertical/
  5612. * Vertical with color axis gradient
  5613. *
  5614. * @validvalue ["horizontal", "vertical", "proximate"]
  5615. */
  5616. layout: 'horizontal',
  5617. /**
  5618. * In a legend with horizontal layout, the itemDistance defines the
  5619. * pixel distance between each item.
  5620. *
  5621. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5622. * 50px item distance
  5623. * @sample {highstock} highcharts/legend/layout-horizontal/
  5624. * 50px item distance
  5625. *
  5626. * @type {number}
  5627. * @default {highcharts} 20
  5628. * @default {highstock} 20
  5629. * @default {highmaps} 8
  5630. * @since 3.0.3
  5631. * @apioption legend.itemDistance
  5632. */
  5633. /**
  5634. * The pixel bottom margin for each legend item.
  5635. *
  5636. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5637. * Padding and item margins demonstrated
  5638. * @sample {highmaps} maps/legend/padding-itemmargin/
  5639. * Padding and item margins demonstrated
  5640. *
  5641. * @type {number}
  5642. * @default 0
  5643. * @since 2.2.0
  5644. * @apioption legend.itemMarginBottom
  5645. */
  5646. /**
  5647. * The pixel top margin for each legend item.
  5648. *
  5649. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5650. * Padding and item margins demonstrated
  5651. * @sample {highmaps} maps/legend/padding-itemmargin/
  5652. * Padding and item margins demonstrated
  5653. *
  5654. * @type {number}
  5655. * @default 0
  5656. * @since 2.2.0
  5657. * @apioption legend.itemMarginTop
  5658. */
  5659. /**
  5660. * The width for each legend item. By default the items are laid out
  5661. * successively. In a [horizontal layout](legend.layout), if the items
  5662. * are laid out across two rows or more, they will be vertically aligned
  5663. * depending on the [legend.alignColumns](legend.alignColumns) option.
  5664. *
  5665. * @sample {highcharts} highcharts/legend/itemwidth-default/
  5666. * Undefined by default
  5667. * @sample {highcharts} highcharts/legend/itemwidth-80/
  5668. * 80 for aligned legend items
  5669. *
  5670. * @type {number}
  5671. * @since 2.0
  5672. * @apioption legend.itemWidth
  5673. */
  5674. /**
  5675. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  5676. * for each legend label. Available variables relates to properties on
  5677. * the series, or the point in case of pies.
  5678. *
  5679. * @type {string}
  5680. * @default {name}
  5681. * @since 1.3
  5682. * @apioption legend.labelFormat
  5683. */
  5684. /* eslint-disable valid-jsdoc */
  5685. /**
  5686. * Callback function to format each of the series' labels. The `this`
  5687. * keyword refers to the series object, or the point object in case of
  5688. * pie charts. By default the series or point name is printed.
  5689. *
  5690. * @productdesc {highmaps}
  5691. * In Highmaps the context can also be a data class in case of a
  5692. * `colorAxis`.
  5693. *
  5694. * @sample {highcharts} highcharts/legend/labelformatter/
  5695. * Add text
  5696. * @sample {highmaps} maps/legend/labelformatter/
  5697. * Data classes with label formatter
  5698. *
  5699. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  5700. */
  5701. labelFormatter: function () {
  5702. /** eslint-enable valid-jsdoc */
  5703. return this.name;
  5704. },
  5705. /**
  5706. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  5707. * the line height for each item can be set using
  5708. * `itemStyle.lineHeight`, and the padding between items using
  5709. * `itemMarginTop` and `itemMarginBottom`.
  5710. *
  5711. * @sample {highcharts} highcharts/legend/lineheight/
  5712. * Setting padding
  5713. *
  5714. * @deprecated
  5715. *
  5716. * @type {number}
  5717. * @default 16
  5718. * @since 2.0
  5719. * @product highcharts gantt
  5720. * @apioption legend.lineHeight
  5721. */
  5722. /**
  5723. * If the plot area sized is calculated automatically and the legend is
  5724. * not floating, the legend margin is the space between the legend and
  5725. * the axis labels or plot area.
  5726. *
  5727. * @sample {highcharts} highcharts/legend/margin-default/
  5728. * 12 pixels by default
  5729. * @sample {highcharts} highcharts/legend/margin-30/
  5730. * 30 pixels
  5731. *
  5732. * @type {number}
  5733. * @default 12
  5734. * @since 2.1
  5735. * @apioption legend.margin
  5736. */
  5737. /**
  5738. * Maximum pixel height for the legend. When the maximum height is
  5739. * extended, navigation will show.
  5740. *
  5741. * @type {number}
  5742. * @since 2.3.0
  5743. * @apioption legend.maxHeight
  5744. */
  5745. /**
  5746. * The color of the drawn border around the legend.
  5747. *
  5748. * @see In styled mode, the legend border stroke can be applied with the
  5749. * `.highcharts-legend-box` class.
  5750. *
  5751. * @sample {highcharts} highcharts/legend/bordercolor/
  5752. * Brown border
  5753. * @sample {highstock} stock/legend/align/
  5754. * Various legend options
  5755. * @sample {highmaps} maps/legend/border-background/
  5756. * Border and background options
  5757. *
  5758. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5759. */
  5760. borderColor: palette.neutralColor40,
  5761. /**
  5762. * The border corner radius of the legend.
  5763. *
  5764. * @sample {highcharts} highcharts/legend/borderradius-default/
  5765. * Square by default
  5766. * @sample {highcharts} highcharts/legend/borderradius-round/
  5767. * 5px rounded
  5768. * @sample {highmaps} maps/legend/border-background/
  5769. * Border and background options
  5770. */
  5771. borderRadius: 0,
  5772. /**
  5773. * Options for the paging or navigation appearing when the legend is
  5774. * overflown. Navigation works well on screen, but not in static
  5775. * exported images. One way of working around that is to
  5776. * [increase the chart height in
  5777. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  5778. */
  5779. navigation: {
  5780. /**
  5781. * How to animate the pages when navigating up or down. A value of
  5782. * `true` applies the default navigation given in the
  5783. * `chart.animation` option. Additional options can be given as an
  5784. * object containing values for easing and duration.
  5785. *
  5786. * @sample {highcharts} highcharts/legend/navigation/
  5787. * Legend page navigation demonstrated
  5788. * @sample {highstock} highcharts/legend/navigation/
  5789. * Legend page navigation demonstrated
  5790. *
  5791. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  5792. * @default true
  5793. * @since 2.2.4
  5794. * @apioption legend.navigation.animation
  5795. */
  5796. /**
  5797. * The pixel size of the up and down arrows in the legend paging
  5798. * navigation.
  5799. *
  5800. * @sample {highcharts} highcharts/legend/navigation/
  5801. * Legend page navigation demonstrated
  5802. * @sample {highstock} highcharts/legend/navigation/
  5803. * Legend page navigation demonstrated
  5804. *
  5805. * @type {number}
  5806. * @default 12
  5807. * @since 2.2.4
  5808. * @apioption legend.navigation.arrowSize
  5809. */
  5810. /**
  5811. * Whether to enable the legend navigation. In most cases, disabling
  5812. * the navigation results in an unwanted overflow.
  5813. *
  5814. * See also the [adapt chart to legend](
  5815. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  5816. * plugin for a solution to extend the chart height to make room for
  5817. * the legend, optionally in exported charts only.
  5818. *
  5819. * @type {boolean}
  5820. * @default true
  5821. * @since 4.2.4
  5822. * @apioption legend.navigation.enabled
  5823. */
  5824. /**
  5825. * Text styles for the legend page navigation.
  5826. *
  5827. * @see In styled mode, the navigation items are styled with the
  5828. * `.highcharts-legend-navigation` class.
  5829. *
  5830. * @sample {highcharts} highcharts/legend/navigation/
  5831. * Legend page navigation demonstrated
  5832. * @sample {highstock} highcharts/legend/navigation/
  5833. * Legend page navigation demonstrated
  5834. *
  5835. * @type {Highcharts.CSSObject}
  5836. * @since 2.2.4
  5837. * @apioption legend.navigation.style
  5838. */
  5839. /**
  5840. * The color for the active up or down arrow in the legend page
  5841. * navigation.
  5842. *
  5843. * @see In styled mode, the active arrow be styled with the
  5844. * `.highcharts-legend-nav-active` class.
  5845. *
  5846. * @sample {highcharts} highcharts/legend/navigation/
  5847. * Legend page navigation demonstrated
  5848. * @sample {highstock} highcharts/legend/navigation/
  5849. * Legend page navigation demonstrated
  5850. *
  5851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5852. * @since 2.2.4
  5853. */
  5854. activeColor: palette.highlightColor100,
  5855. /**
  5856. * The color of the inactive up or down arrow in the legend page
  5857. * navigation. .
  5858. *
  5859. * @see In styled mode, the inactive arrow be styled with the
  5860. * `.highcharts-legend-nav-inactive` class.
  5861. *
  5862. * @sample {highcharts} highcharts/legend/navigation/
  5863. * Legend page navigation demonstrated
  5864. * @sample {highstock} highcharts/legend/navigation/
  5865. * Legend page navigation demonstrated
  5866. *
  5867. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5868. * @since 2.2.4
  5869. */
  5870. inactiveColor: palette.neutralColor20
  5871. },
  5872. /**
  5873. * The inner padding of the legend box.
  5874. *
  5875. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5876. * Padding and item margins demonstrated
  5877. * @sample {highmaps} maps/legend/padding-itemmargin/
  5878. * Padding and item margins demonstrated
  5879. *
  5880. * @type {number}
  5881. * @default 8
  5882. * @since 2.2.0
  5883. * @apioption legend.padding
  5884. */
  5885. /**
  5886. * Whether to reverse the order of the legend items compared to the
  5887. * order of the series or points as defined in the configuration object.
  5888. *
  5889. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  5890. * [series.legendIndex](#series.legendIndex)
  5891. *
  5892. * @sample {highcharts} highcharts/legend/reversed/
  5893. * Stacked bar with reversed legend
  5894. *
  5895. * @type {boolean}
  5896. * @default false
  5897. * @since 1.2.5
  5898. * @apioption legend.reversed
  5899. */
  5900. /**
  5901. * Whether to show the symbol on the right side of the text rather than
  5902. * the left side. This is common in Arabic and Hebrew.
  5903. *
  5904. * @sample {highcharts} highcharts/legend/rtl/
  5905. * Symbol to the right
  5906. *
  5907. * @type {boolean}
  5908. * @default false
  5909. * @since 2.2
  5910. * @apioption legend.rtl
  5911. */
  5912. /**
  5913. * CSS styles for the legend area. In the 1.x versions the position
  5914. * of the legend area was determined by CSS. In 2.x, the position is
  5915. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  5916. * but the styles are still parsed for backwards compatibility.
  5917. *
  5918. * @deprecated
  5919. *
  5920. * @type {Highcharts.CSSObject}
  5921. * @product highcharts highstock
  5922. * @apioption legend.style
  5923. */
  5924. /**
  5925. * CSS styles for each legend item. Only a subset of CSS is supported,
  5926. * notably those options related to text. The default `textOverflow`
  5927. * property makes long texts truncate. Set it to `undefined` to wrap
  5928. * text instead. A `width` property can be added to control the text
  5929. * width.
  5930. *
  5931. * @see In styled mode, the legend items can be styled with the
  5932. * `.highcharts-legend-item` class.
  5933. *
  5934. * @sample {highcharts} highcharts/legend/itemstyle/
  5935. * Bold black text
  5936. * @sample {highmaps} maps/legend/itemstyle/
  5937. * Item text styles
  5938. *
  5939. * @type {Highcharts.CSSObject}
  5940. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  5941. */
  5942. itemStyle: {
  5943. /**
  5944. * @ignore
  5945. */
  5946. color: palette.neutralColor80,
  5947. /**
  5948. * @ignore
  5949. */
  5950. cursor: 'pointer',
  5951. /**
  5952. * @ignore
  5953. */
  5954. fontSize: '12px',
  5955. /**
  5956. * @ignore
  5957. */
  5958. fontWeight: 'bold',
  5959. /**
  5960. * @ignore
  5961. */
  5962. textOverflow: 'ellipsis'
  5963. },
  5964. /**
  5965. * CSS styles for each legend item in hover mode. Only a subset of
  5966. * CSS is supported, notably those options related to text. Properties
  5967. * are inherited from `style` unless overridden here.
  5968. *
  5969. * @see In styled mode, the hovered legend items can be styled with
  5970. * the `.highcharts-legend-item:hover` pesudo-class.
  5971. *
  5972. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  5973. * Red on hover
  5974. * @sample {highmaps} maps/legend/itemstyle/
  5975. * Item text styles
  5976. *
  5977. * @type {Highcharts.CSSObject}
  5978. * @default {"color": "#000000"}
  5979. */
  5980. itemHoverStyle: {
  5981. /**
  5982. * @ignore
  5983. */
  5984. color: palette.neutralColor100
  5985. },
  5986. /**
  5987. * CSS styles for each legend item when the corresponding series or
  5988. * point is hidden. Only a subset of CSS is supported, notably those
  5989. * options related to text. Properties are inherited from `style`
  5990. * unless overridden here.
  5991. *
  5992. * @see In styled mode, the hidden legend items can be styled with
  5993. * the `.highcharts-legend-item-hidden` class.
  5994. *
  5995. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  5996. * Darker gray color
  5997. *
  5998. * @type {Highcharts.CSSObject}
  5999. * @default {"color": "#cccccc"}
  6000. */
  6001. itemHiddenStyle: {
  6002. /**
  6003. * @ignore
  6004. */
  6005. color: palette.neutralColor20
  6006. },
  6007. /**
  6008. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  6009. * also needs to be applied for this to take effect. The shadow can be
  6010. * an object configuration containing `color`, `offsetX`, `offsetY`,
  6011. * `opacity` and `width`.
  6012. *
  6013. * @sample {highcharts} highcharts/legend/shadow/
  6014. * White background and drop shadow
  6015. * @sample {highstock} stock/legend/align/
  6016. * Various legend options
  6017. * @sample {highmaps} maps/legend/border-background/
  6018. * Border and background options
  6019. *
  6020. * @type {boolean|Highcharts.CSSObject}
  6021. */
  6022. shadow: false,
  6023. /**
  6024. * Default styling for the checkbox next to a legend item when
  6025. * `showCheckbox` is true.
  6026. *
  6027. * @type {Highcharts.CSSObject}
  6028. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  6029. */
  6030. itemCheckboxStyle: {
  6031. /**
  6032. * @ignore
  6033. */
  6034. position: 'absolute',
  6035. /**
  6036. * @ignore
  6037. */
  6038. width: '13px',
  6039. /**
  6040. * @ignore
  6041. */
  6042. height: '13px'
  6043. },
  6044. // itemWidth: undefined,
  6045. /**
  6046. * When this is true, the legend symbol width will be the same as
  6047. * the symbol height, which in turn defaults to the font size of the
  6048. * legend items.
  6049. *
  6050. * @since 5.0.0
  6051. */
  6052. squareSymbol: true,
  6053. /**
  6054. * The pixel height of the symbol for series types that use a rectangle
  6055. * in the legend. Defaults to the font size of legend items.
  6056. *
  6057. * @productdesc {highmaps}
  6058. * In Highmaps, when the symbol is the gradient of a vertical color
  6059. * axis, the height defaults to 200.
  6060. *
  6061. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6062. * Sized vertical gradient
  6063. * @sample {highmaps} maps/legend/padding-itemmargin/
  6064. * No distance between data classes
  6065. *
  6066. * @type {number}
  6067. * @since 3.0.8
  6068. * @apioption legend.symbolHeight
  6069. */
  6070. /**
  6071. * The border radius of the symbol for series types that use a rectangle
  6072. * in the legend. Defaults to half the `symbolHeight`.
  6073. *
  6074. * @sample {highcharts} highcharts/legend/symbolradius/
  6075. * Round symbols
  6076. * @sample {highstock} highcharts/legend/symbolradius/
  6077. * Round symbols
  6078. * @sample {highmaps} highcharts/legend/symbolradius/
  6079. * Round symbols
  6080. *
  6081. * @type {number}
  6082. * @since 3.0.8
  6083. * @apioption legend.symbolRadius
  6084. */
  6085. /**
  6086. * The pixel width of the legend item symbol. When the `squareSymbol`
  6087. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  6088. *
  6089. * @productdesc {highmaps}
  6090. * In Highmaps, when the symbol is the gradient of a horizontal color
  6091. * axis, the width defaults to 200.
  6092. *
  6093. * @sample {highcharts} highcharts/legend/symbolwidth/
  6094. * Greater symbol width and padding
  6095. * @sample {highmaps} maps/legend/padding-itemmargin/
  6096. * Padding and item margins demonstrated
  6097. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6098. * Sized vertical gradient
  6099. *
  6100. * @type {number}
  6101. * @apioption legend.symbolWidth
  6102. */
  6103. /**
  6104. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  6105. * to render the legend item texts.
  6106. *
  6107. * Prior to 4.1.7, when using HTML, [legend.navigation](
  6108. * #legend.navigation) was disabled.
  6109. *
  6110. * @type {boolean}
  6111. * @default false
  6112. * @apioption legend.useHTML
  6113. */
  6114. /**
  6115. * The width of the legend box. If a number is set, it translates to
  6116. * pixels. Since v7.0.2 it allows setting a percent string of the full
  6117. * chart width, for example `40%`.
  6118. *
  6119. * Defaults to the full chart width for legends below or above the
  6120. * chart, half the chart width for legends to the left and right.
  6121. *
  6122. * @sample {highcharts} highcharts/legend/width/
  6123. * Aligned to the plot area
  6124. * @sample {highcharts} highcharts/legend/width-percent/
  6125. * A percent of the chart width
  6126. *
  6127. * @type {number|string}
  6128. * @since 2.0
  6129. * @apioption legend.width
  6130. */
  6131. /**
  6132. * The pixel padding between the legend item symbol and the legend
  6133. * item text.
  6134. *
  6135. * @sample {highcharts} highcharts/legend/symbolpadding/
  6136. * Greater symbol width and padding
  6137. */
  6138. symbolPadding: 5,
  6139. /**
  6140. * The vertical alignment of the legend box. Can be one of `top`,
  6141. * `middle` or `bottom`. Vertical position can be further determined
  6142. * by the `y` option.
  6143. *
  6144. * In the case that the legend is aligned in a corner position, the
  6145. * `layout` option will determine whether to place it above/below
  6146. * or on the side of the plot area.
  6147. *
  6148. * When the [layout](#legend.layout) option is `proximate`, the
  6149. * `verticalAlign` option doesn't apply.
  6150. *
  6151. * @sample {highcharts} highcharts/legend/verticalalign/
  6152. * Legend 100px from the top of the chart
  6153. * @sample {highstock} stock/legend/align/
  6154. * Various legend options
  6155. * @sample {highmaps} maps/legend/alignment/
  6156. * Legend alignment
  6157. *
  6158. * @type {Highcharts.VerticalAlignValue}
  6159. * @since 2.0
  6160. */
  6161. verticalAlign: 'bottom',
  6162. // width: undefined,
  6163. /**
  6164. * The x offset of the legend relative to its horizontal alignment
  6165. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  6166. * x moves it to the left, positive x moves it to the right.
  6167. *
  6168. * @sample {highcharts} highcharts/legend/width/
  6169. * Aligned to the plot area
  6170. *
  6171. * @since 2.0
  6172. */
  6173. x: 0,
  6174. /**
  6175. * The vertical offset of the legend relative to it's vertical alignment
  6176. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  6177. * Negative y moves it up, positive y moves it down.
  6178. *
  6179. * @sample {highcharts} highcharts/legend/verticalalign/
  6180. * Legend 100px from the top of the chart
  6181. * @sample {highstock} stock/legend/align/
  6182. * Various legend options
  6183. * @sample {highmaps} maps/legend/alignment/
  6184. * Legend alignment
  6185. *
  6186. * @since 2.0
  6187. */
  6188. y: 0,
  6189. /**
  6190. * A title to be added on top of the legend.
  6191. *
  6192. * @sample {highcharts} highcharts/legend/title/
  6193. * Legend title
  6194. * @sample {highmaps} maps/legend/alignment/
  6195. * Legend with title
  6196. *
  6197. * @since 3.0
  6198. */
  6199. title: {
  6200. /**
  6201. * A text or HTML string for the title.
  6202. *
  6203. * @type {string}
  6204. * @since 3.0
  6205. * @apioption legend.title.text
  6206. */
  6207. /**
  6208. * Generic CSS styles for the legend title.
  6209. *
  6210. * @see In styled mode, the legend title is styled with the
  6211. * `.highcharts-legend-title` class.
  6212. *
  6213. * @type {Highcharts.CSSObject}
  6214. * @default {"fontWeight": "bold"}
  6215. * @since 3.0
  6216. */
  6217. style: {
  6218. /**
  6219. * @ignore
  6220. */
  6221. fontWeight: 'bold'
  6222. }
  6223. }
  6224. },
  6225. /**
  6226. * The loading options control the appearance of the loading screen
  6227. * that covers the plot area on chart operations. This screen only
  6228. * appears after an explicit call to `chart.showLoading()`. It is a
  6229. * utility for developers to communicate to the end user that something
  6230. * is going on, for example while retrieving new data via an XHR connection.
  6231. * The "Loading..." text itself is not part of this configuration
  6232. * object, but part of the `lang` object.
  6233. */
  6234. loading: {
  6235. /**
  6236. * The duration in milliseconds of the fade out effect.
  6237. *
  6238. * @sample highcharts/loading/hideduration/
  6239. * Fade in and out over a second
  6240. *
  6241. * @type {number}
  6242. * @default 100
  6243. * @since 1.2.0
  6244. * @apioption loading.hideDuration
  6245. */
  6246. /**
  6247. * The duration in milliseconds of the fade in effect.
  6248. *
  6249. * @sample highcharts/loading/hideduration/
  6250. * Fade in and out over a second
  6251. *
  6252. * @type {number}
  6253. * @default 100
  6254. * @since 1.2.0
  6255. * @apioption loading.showDuration
  6256. */
  6257. /**
  6258. * CSS styles for the loading label `span`.
  6259. *
  6260. * @see In styled mode, the loading label is styled with the
  6261. * `.highcharts-loading-inner` class.
  6262. *
  6263. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  6264. * Vertically centered
  6265. * @sample {highstock} stock/loading/general/
  6266. * Label styles
  6267. *
  6268. * @type {Highcharts.CSSObject}
  6269. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  6270. * @since 1.2.0
  6271. */
  6272. labelStyle: {
  6273. /**
  6274. * @ignore
  6275. */
  6276. fontWeight: 'bold',
  6277. /**
  6278. * @ignore
  6279. */
  6280. position: 'relative',
  6281. /**
  6282. * @ignore
  6283. */
  6284. top: '45%'
  6285. },
  6286. /**
  6287. * CSS styles for the loading screen that covers the plot area.
  6288. *
  6289. * In styled mode, the loading label is styled with the
  6290. * `.highcharts-loading` class.
  6291. *
  6292. * @sample {highcharts|highmaps} highcharts/loading/style/
  6293. * Gray plot area, white text
  6294. * @sample {highstock} stock/loading/general/
  6295. * Gray plot area, white text
  6296. *
  6297. * @type {Highcharts.CSSObject}
  6298. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  6299. * @since 1.2.0
  6300. */
  6301. style: {
  6302. /**
  6303. * @ignore
  6304. */
  6305. position: 'absolute',
  6306. /**
  6307. * @ignore
  6308. */
  6309. backgroundColor: palette.backgroundColor,
  6310. /**
  6311. * @ignore
  6312. */
  6313. opacity: 0.5,
  6314. /**
  6315. * @ignore
  6316. */
  6317. textAlign: 'center'
  6318. }
  6319. },
  6320. /**
  6321. * Options for the tooltip that appears when the user hovers over a
  6322. * series or point.
  6323. *
  6324. * @declare Highcharts.TooltipOptions
  6325. */
  6326. tooltip: {
  6327. /**
  6328. * The color of the tooltip border. When `undefined`, the border takes
  6329. * the color of the corresponding series or point.
  6330. *
  6331. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6332. * Follow series by default
  6333. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  6334. * Black border
  6335. * @sample {highstock} stock/tooltip/general/
  6336. * Styled tooltip
  6337. * @sample {highmaps} maps/tooltip/background-border/
  6338. * Background and border demo
  6339. *
  6340. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6341. * @apioption tooltip.borderColor
  6342. */
  6343. /**
  6344. * A CSS class name to apply to the tooltip's container div,
  6345. * allowing unique CSS styling for each chart.
  6346. *
  6347. * @type {string}
  6348. * @apioption tooltip.className
  6349. */
  6350. /**
  6351. * Since 4.1, the crosshair definitions are moved to the Axis object
  6352. * in order for a better separation from the tooltip. See
  6353. * [xAxis.crosshair](#xAxis.crosshair).
  6354. *
  6355. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  6356. * Enable a crosshair for the x value
  6357. *
  6358. * @deprecated
  6359. *
  6360. * @type {*}
  6361. * @default true
  6362. * @apioption tooltip.crosshairs
  6363. */
  6364. /**
  6365. * Distance from point to tooltip in pixels.
  6366. *
  6367. * @type {number}
  6368. * @default 16
  6369. * @apioption tooltip.distance
  6370. */
  6371. /**
  6372. * Whether the tooltip should follow the mouse as it moves across
  6373. * columns, pie slices and other point types with an extent.
  6374. * By default it behaves this way for pie, polygon, map, sankey
  6375. * and wordcloud series by override in the `plotOptions`
  6376. * for those series types.
  6377. *
  6378. * Does not apply if [split](#tooltip.split) is `true`.
  6379. *
  6380. * For touch moves to behave the same way, [followTouchMove](
  6381. * #tooltip.followTouchMove) must be `true` also.
  6382. *
  6383. * @type {boolean}
  6384. * @default {highcharts} false
  6385. * @default {highstock} false
  6386. * @default {highmaps} true
  6387. * @since 3.0
  6388. * @apioption tooltip.followPointer
  6389. */
  6390. /**
  6391. * Whether the tooltip should update as the finger moves on a touch
  6392. * device. If this is `true` and [chart.panning](#chart.panning) is
  6393. * set,`followTouchMove` will take over one-finger touches, so the user
  6394. * needs to use two fingers for zooming and panning.
  6395. *
  6396. * Note the difference to [followPointer](#tooltip.followPointer) that
  6397. * only defines the _position_ of the tooltip. If `followPointer` is
  6398. * false in for example a column series, the tooltip will show above or
  6399. * below the column, but as `followTouchMove` is true, the tooltip will
  6400. * jump from column to column as the user swipes across the plot area.
  6401. *
  6402. * @type {boolean}
  6403. * @default {highcharts} true
  6404. * @default {highstock} true
  6405. * @default {highmaps} false
  6406. * @since 3.0.1
  6407. * @apioption tooltip.followTouchMove
  6408. */
  6409. /**
  6410. * Callback function to format the text of the tooltip from scratch. In
  6411. * case of single or [shared](#tooltip.shared) tooltips, a string should
  6412. * be returned. In case of [split](#tooltip.split) tooltips, it should
  6413. * return an array where the first item is the header, and subsequent
  6414. * items are mapped to the points. Return `false` to disable tooltip for
  6415. * a specific point on series.
  6416. *
  6417. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  6418. * the tooltip is parsed and converted to SVG, therefore this isn't a
  6419. * complete HTML renderer. The following HTML tags are supported: `b`,
  6420. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  6421. * attribute, but only text-related CSS, that is shared with SVG, is
  6422. * handled.
  6423. *
  6424. * The available data in the formatter differ a bit depending on whether
  6425. * the tooltip is shared or split, or belongs to a single point. In a
  6426. * shared/split tooltip, all properties except `x`, which is common for
  6427. * all points, are kept in an array, `this.points`.
  6428. *
  6429. * Available data are:
  6430. *
  6431. * - **this.percentage (not shared) /**
  6432. * **this.points[i].percentage (shared)**:
  6433. * Stacked series and pies only. The point's percentage of the total.
  6434. *
  6435. * - **this.point (not shared) / this.points[i].point (shared)**:
  6436. * The point object. The point name, if defined, is available through
  6437. * `this.point.name`.
  6438. *
  6439. * - **this.points**:
  6440. * In a shared tooltip, this is an array containing all other
  6441. * properties for each point.
  6442. *
  6443. * - **this.series (not shared) / this.points[i].series (shared)**:
  6444. * The series object. The series name is available through
  6445. * `this.series.name`.
  6446. *
  6447. * - **this.total (not shared) / this.points[i].total (shared)**:
  6448. * Stacked series only. The total value at this point's x value.
  6449. *
  6450. * - **this.x**:
  6451. * The x value. This property is the same regardless of the tooltip
  6452. * being shared or not.
  6453. *
  6454. * - **this.y (not shared) / this.points[i].y (shared)**:
  6455. * The y value.
  6456. *
  6457. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  6458. * Simple string formatting
  6459. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  6460. * Formatting with shared tooltip
  6461. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6462. * Formatting with split tooltip
  6463. * @sample highcharts/tooltip/formatter-conditional-default/
  6464. * Extending default formatter
  6465. * @sample {highstock} stock/tooltip/formatter/
  6466. * Formatting with shared tooltip
  6467. * @sample {highmaps} maps/tooltip/formatter/
  6468. * String formatting
  6469. *
  6470. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6471. * @apioption tooltip.formatter
  6472. */
  6473. /**
  6474. * Callback function to format the text of the tooltip for
  6475. * visible null points.
  6476. * Works analogously to [formatter](#tooltip.formatter).
  6477. *
  6478. * @sample highcharts/plotoptions/series-nullformat
  6479. * Format data label and tooltip for null point.
  6480. *
  6481. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6482. * @apioption tooltip.nullFormatter
  6483. */
  6484. /**
  6485. * The number of milliseconds to wait until the tooltip is hidden when
  6486. * mouse out from a point or chart.
  6487. *
  6488. * @type {number}
  6489. * @default 500
  6490. * @since 3.0
  6491. * @apioption tooltip.hideDelay
  6492. */
  6493. /**
  6494. * Whether to allow the tooltip to render outside the chart's SVG
  6495. * element box. By default (`false`), the tooltip is rendered within the
  6496. * chart's SVG element, which results in the tooltip being aligned
  6497. * inside the chart area. For small charts, this may result in clipping
  6498. * or overlapping. When `true`, a separate SVG element is created and
  6499. * overlaid on the page, allowing the tooltip to be aligned inside the
  6500. * page itself.
  6501. *
  6502. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  6503. * otherwise `false`.
  6504. *
  6505. * @sample highcharts/tooltip/outside
  6506. * Small charts with tooltips outside
  6507. *
  6508. * @type {boolean|undefined}
  6509. * @default undefined
  6510. * @since 6.1.1
  6511. * @apioption tooltip.outside
  6512. */
  6513. /**
  6514. * A callback function for formatting the HTML output for a single point
  6515. * in the tooltip. Like the `pointFormat` string, but with more
  6516. * flexibility.
  6517. *
  6518. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  6519. * @since 4.1.0
  6520. * @context Highcharts.Point
  6521. * @apioption tooltip.pointFormatter
  6522. */
  6523. /**
  6524. * A callback function to place the tooltip in a default position. The
  6525. * callback receives three parameters: `labelWidth`, `labelHeight` and
  6526. * `point`, where point contains values for `plotX` and `plotY` telling
  6527. * where the reference point is in the plot area. Add `chart.plotLeft`
  6528. * and `chart.plotTop` to get the full coordinates.
  6529. *
  6530. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  6531. * positioner is called for each of the boxes separately, including
  6532. * xAxis header. xAxis header is not a point, instead `point` argument
  6533. * contains info:
  6534. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  6535. *
  6536. *
  6537. * The return should be an object containing x and y values, for example
  6538. * `{ x: 100, y: 100 }`.
  6539. *
  6540. * @sample {highcharts} highcharts/tooltip/positioner/
  6541. * A fixed tooltip position
  6542. * @sample {highstock} stock/tooltip/positioner/
  6543. * A fixed tooltip position on top of the chart
  6544. * @sample {highmaps} maps/tooltip/positioner/
  6545. * A fixed tooltip position
  6546. * @sample {highstock} stock/tooltip/split-positioner/
  6547. * Split tooltip with fixed positions
  6548. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  6549. * Scrollable plot area combined with tooltip positioner
  6550. *
  6551. * @type {Highcharts.TooltipPositionerCallbackFunction}
  6552. * @since 2.2.4
  6553. * @apioption tooltip.positioner
  6554. */
  6555. /**
  6556. * The name of a symbol to use for the border around the tooltip. Can
  6557. * be one of: `"callout"`, `"circle"` or `"rect"`. When
  6558. * [tooltip.split](#tooltip.split)
  6559. * option is enabled, shape is applied to all boxes except header, which
  6560. * is controlled by
  6561. * [tooltip.headerShape](#tooltip.headerShape).
  6562. *
  6563. * Custom callbacks for symbol path generation can also be added to
  6564. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6565. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6566. *
  6567. * @type {Highcharts.TooltipShapeValue}
  6568. * @default callout
  6569. * @since 4.0
  6570. * @apioption tooltip.shape
  6571. */
  6572. /**
  6573. * The name of a symbol to use for the border around the tooltip
  6574. * header. Applies only when [tooltip.split](#tooltip.split) is
  6575. * enabled.
  6576. *
  6577. * Custom callbacks for symbol path generation can also be added to
  6578. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6579. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6580. *
  6581. * @see [tooltip.shape](#tooltip.shape)
  6582. *
  6583. * @sample {highstock} stock/tooltip/split-positioner/
  6584. * Different shapes for header and split boxes
  6585. *
  6586. * @type {Highcharts.TooltipShapeValue}
  6587. * @default callout
  6588. * @validvalue ["callout", "square"]
  6589. * @since 7.0
  6590. * @apioption tooltip.headerShape
  6591. */
  6592. /**
  6593. * When the tooltip is shared, the entire plot area will capture mouse
  6594. * movement or touch events. Tooltip texts for series types with ordered
  6595. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  6596. * This is recommended for single series charts and for tablet/mobile
  6597. * optimized charts.
  6598. *
  6599. * See also [tooltip.split](#tooltip.split), that is better suited for
  6600. * charts with many series, especially line-type series. The
  6601. * `tooltip.split` option takes precedence over `tooltip.shared`.
  6602. *
  6603. * @sample {highcharts} highcharts/tooltip/shared-false/
  6604. * False by default
  6605. * @sample {highcharts} highcharts/tooltip/shared-true/
  6606. * True
  6607. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  6608. * True with x axis crosshair
  6609. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  6610. * True with mixed series types
  6611. *
  6612. * @type {boolean}
  6613. * @default false
  6614. * @since 2.1
  6615. * @product highcharts highstock
  6616. * @apioption tooltip.shared
  6617. */
  6618. /**
  6619. * Split the tooltip into one label per series, with the header close
  6620. * to the axis. This is recommended over [shared](#tooltip.shared)
  6621. * tooltips for charts with multiple line series, generally making them
  6622. * easier to read. This option takes precedence over `tooltip.shared`.
  6623. *
  6624. * @productdesc {highstock} In Highcharts Stock, tooltips are split
  6625. * by default since v6.0.0. Stock charts typically contain
  6626. * multi-dimension points and multiple panes, making split tooltips
  6627. * the preferred layout over
  6628. * the previous `shared` tooltip.
  6629. *
  6630. * @sample highcharts/tooltip/split/
  6631. * Split tooltip
  6632. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6633. * Split tooltip and custom formatter callback
  6634. *
  6635. * @type {boolean}
  6636. * @default {highcharts} false
  6637. * @default {highstock} true
  6638. * @since 5.0.0
  6639. * @product highcharts highstock
  6640. * @apioption tooltip.split
  6641. */
  6642. /**
  6643. * Prevents the tooltip from switching or closing, when touched or
  6644. * pointed.
  6645. *
  6646. * @sample highcharts/tooltip/stickoncontact/
  6647. * Tooltip sticks on pointer contact
  6648. *
  6649. * @type {boolean}
  6650. * @since 8.0.1
  6651. * @apioption tooltip.stickOnContact
  6652. */
  6653. /**
  6654. * Use HTML to render the contents of the tooltip instead of SVG. Using
  6655. * HTML allows advanced formatting like tables and images in the
  6656. * tooltip. It is also recommended for rtl languages as it works around
  6657. * rtl bugs in early Firefox.
  6658. *
  6659. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  6660. * A table for value alignment
  6661. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  6662. * Full HTML tooltip
  6663. * @sample {highmaps} maps/tooltip/usehtml/
  6664. * Pure HTML tooltip
  6665. *
  6666. * @type {boolean}
  6667. * @default false
  6668. * @since 2.2
  6669. * @apioption tooltip.useHTML
  6670. */
  6671. /**
  6672. * How many decimals to show in each series' y value. This is
  6673. * overridable in each series' tooltip options object. The default is to
  6674. * preserve all decimals.
  6675. *
  6676. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6677. * Set decimals, prefix and suffix for the value
  6678. * @sample {highmaps} maps/tooltip/valuedecimals/
  6679. * Set decimals, prefix and suffix for the value
  6680. *
  6681. * @type {number}
  6682. * @since 2.2
  6683. * @apioption tooltip.valueDecimals
  6684. */
  6685. /**
  6686. * A string to prepend to each series' y value. Overridable in each
  6687. * series' tooltip options object.
  6688. *
  6689. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6690. * Set decimals, prefix and suffix for the value
  6691. * @sample {highmaps} maps/tooltip/valuedecimals/
  6692. * Set decimals, prefix and suffix for the value
  6693. *
  6694. * @type {string}
  6695. * @since 2.2
  6696. * @apioption tooltip.valuePrefix
  6697. */
  6698. /**
  6699. * A string to append to each series' y value. Overridable in each
  6700. * series' tooltip options object.
  6701. *
  6702. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6703. * Set decimals, prefix and suffix for the value
  6704. * @sample {highmaps} maps/tooltip/valuedecimals/
  6705. * Set decimals, prefix and suffix for the value
  6706. *
  6707. * @type {string}
  6708. * @since 2.2
  6709. * @apioption tooltip.valueSuffix
  6710. */
  6711. /**
  6712. * The format for the date in the tooltip header if the X axis is a
  6713. * datetime axis. The default is a best guess based on the smallest
  6714. * distance between points in the chart.
  6715. *
  6716. * @sample {highcharts} highcharts/tooltip/xdateformat/
  6717. * A different format
  6718. *
  6719. * @type {string}
  6720. * @product highcharts highstock gantt
  6721. * @apioption tooltip.xDateFormat
  6722. */
  6723. /**
  6724. * How many decimals to show for the `point.change` value when the
  6725. * `series.compare` option is set. This is overridable in each series'
  6726. * tooltip options object. The default is to preserve all decimals.
  6727. *
  6728. * @type {number}
  6729. * @since 1.0.1
  6730. * @product highstock
  6731. * @apioption tooltip.changeDecimals
  6732. */
  6733. /**
  6734. * Enable or disable the tooltip.
  6735. *
  6736. * @sample {highcharts} highcharts/tooltip/enabled/
  6737. * Disabled
  6738. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  6739. * Disable tooltip and show values on chart instead
  6740. */
  6741. enabled: true,
  6742. /**
  6743. * Enable or disable animation of the tooltip.
  6744. *
  6745. * @type {boolean}
  6746. * @default true
  6747. * @since 2.3.0
  6748. */
  6749. animation: svg,
  6750. /**
  6751. * The radius of the rounded border corners.
  6752. *
  6753. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6754. * 5px by default
  6755. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  6756. * Square borders
  6757. * @sample {highmaps} maps/tooltip/background-border/
  6758. * Background and border demo
  6759. */
  6760. borderRadius: 3,
  6761. /**
  6762. * For series on datetime axes, the date format in the tooltip's
  6763. * header will by default be guessed based on the closest data points.
  6764. * This member gives the default string representations used for
  6765. * each unit. For an overview of the replacement codes, see
  6766. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  6767. *
  6768. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  6769. *
  6770. * @type {Highcharts.Dictionary<string>}
  6771. * @product highcharts highstock gantt
  6772. */
  6773. dateTimeLabelFormats: {
  6774. /** @internal */
  6775. millisecond: '%A, %b %e, %H:%M:%S.%L',
  6776. /** @internal */
  6777. second: '%A, %b %e, %H:%M:%S',
  6778. /** @internal */
  6779. minute: '%A, %b %e, %H:%M',
  6780. /** @internal */
  6781. hour: '%A, %b %e, %H:%M',
  6782. /** @internal */
  6783. day: '%A, %b %e, %Y',
  6784. /** @internal */
  6785. week: 'Week from %A, %b %e, %Y',
  6786. /** @internal */
  6787. month: '%B %Y',
  6788. /** @internal */
  6789. year: '%Y'
  6790. },
  6791. /**
  6792. * A string to append to the tooltip format.
  6793. *
  6794. * @sample {highcharts} highcharts/tooltip/footerformat/
  6795. * A table for value alignment
  6796. * @sample {highmaps} maps/tooltip/format/
  6797. * Format demo
  6798. *
  6799. * @since 2.2
  6800. */
  6801. footerFormat: '',
  6802. /**
  6803. * Padding inside the tooltip, in pixels.
  6804. *
  6805. * @since 5.0.0
  6806. */
  6807. padding: 8,
  6808. /**
  6809. * Proximity snap for graphs or single points. It defaults to 10 for
  6810. * mouse-powered devices and 25 for touch devices.
  6811. *
  6812. * Note that in most cases the whole plot area captures the mouse
  6813. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  6814. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  6815. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  6816. * or [split](#tooltip.split).
  6817. *
  6818. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6819. * 10 px by default
  6820. * @sample {highcharts} highcharts/tooltip/snap-50/
  6821. * 50 px on graph
  6822. *
  6823. * @type {number}
  6824. * @default 10/25
  6825. * @since 1.2.0
  6826. * @product highcharts highstock
  6827. */
  6828. snap: isTouchDevice ? 25 : 10,
  6829. /**
  6830. * The HTML of the tooltip header line. Variables are enclosed by
  6831. * curly brackets. Available variables are `point.key`, `series.name`,
  6832. * `series.color` and other members from the `point` and `series`
  6833. * objects. The `point.key` variable contains the category name, x
  6834. * value or datetime string depending on the type of axis. For datetime
  6835. * axes, the `point.key` date format can be set using
  6836. * `tooltip.xDateFormat`.
  6837. *
  6838. * @sample {highcharts} highcharts/tooltip/footerformat/
  6839. * An HTML table in the tooltip
  6840. * @sample {highstock} highcharts/tooltip/footerformat/
  6841. * An HTML table in the tooltip
  6842. * @sample {highmaps} maps/tooltip/format/
  6843. * Format demo
  6844. *
  6845. * @type {string}
  6846. * @apioption tooltip.headerFormat
  6847. */
  6848. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  6849. /**
  6850. * The HTML of the null point's line in the tooltip. Works analogously
  6851. * to [pointFormat](#tooltip.pointFormat).
  6852. *
  6853. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  6854. * Format data label and tooltip for null point.
  6855. *
  6856. * @type {string}
  6857. * @apioption tooltip.nullFormat
  6858. */
  6859. /**
  6860. * The HTML of the point's line in the tooltip. Variables are enclosed
  6861. * by curly brackets. Available variables are `point.x`, `point.y`,
  6862. * `series.name` and `series.color` and other properties on the same
  6863. * form. Furthermore, `point.y` can be extended by the
  6864. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  6865. * also be overridden for each series, which makes it a good hook for
  6866. * displaying units.
  6867. *
  6868. * In styled mode, the dot is colored by a class name rather
  6869. * than the point color.
  6870. *
  6871. * @sample {highcharts} highcharts/tooltip/pointformat/
  6872. * A different point format with value suffix
  6873. * @sample {highmaps} maps/tooltip/format/
  6874. * Format demo
  6875. *
  6876. * @type {string}
  6877. * @since 2.2
  6878. * @apioption tooltip.pointFormat
  6879. */
  6880. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  6881. /**
  6882. * The background color or gradient for the tooltip.
  6883. *
  6884. * In styled mode, the stroke width is set in the
  6885. * `.highcharts-tooltip-box` class.
  6886. *
  6887. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  6888. * Yellowish background
  6889. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  6890. * Gradient
  6891. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6892. * Tooltip in styled mode
  6893. * @sample {highstock} stock/tooltip/general/
  6894. * Custom tooltip
  6895. * @sample {highstock} highcharts/css/tooltip-border-background/
  6896. * Tooltip in styled mode
  6897. * @sample {highmaps} maps/tooltip/background-border/
  6898. * Background and border demo
  6899. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6900. * Tooltip in styled mode
  6901. *
  6902. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6903. */
  6904. backgroundColor: color(palette.neutralColor3)
  6905. .setOpacity(0.85).get(),
  6906. /**
  6907. * The pixel width of the tooltip border.
  6908. *
  6909. * In styled mode, the stroke width is set in the
  6910. * `.highcharts-tooltip-box` class.
  6911. *
  6912. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6913. * 2px by default
  6914. * @sample {highcharts} highcharts/tooltip/borderwidth/
  6915. * No border (shadow only)
  6916. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6917. * Tooltip in styled mode
  6918. * @sample {highstock} stock/tooltip/general/
  6919. * Custom tooltip
  6920. * @sample {highstock} highcharts/css/tooltip-border-background/
  6921. * Tooltip in styled mode
  6922. * @sample {highmaps} maps/tooltip/background-border/
  6923. * Background and border demo
  6924. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6925. * Tooltip in styled mode
  6926. */
  6927. borderWidth: 1,
  6928. /**
  6929. * Whether to apply a drop shadow to the tooltip.
  6930. *
  6931. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6932. * True by default
  6933. * @sample {highcharts} highcharts/tooltip/shadow/
  6934. * False
  6935. * @sample {highmaps} maps/tooltip/positioner/
  6936. * Fixed tooltip position, border and shadow disabled
  6937. *
  6938. * @type {boolean|Highcharts.ShadowOptionsObject}
  6939. */
  6940. shadow: true,
  6941. /**
  6942. * CSS styles for the tooltip. The tooltip can also be styled through
  6943. * the CSS class `.highcharts-tooltip`.
  6944. *
  6945. * Note that the default `pointerEvents` style makes the tooltip ignore
  6946. * mouse events, so in order to use clickable tooltips, this value must
  6947. * be set to `auto`.
  6948. *
  6949. * @sample {highcharts} highcharts/tooltip/style/
  6950. * Greater padding, bold text
  6951. *
  6952. * @type {Highcharts.CSSObject}
  6953. */
  6954. style: {
  6955. /** @internal */
  6956. color: palette.neutralColor80,
  6957. /** @internal */
  6958. cursor: 'default',
  6959. /** @internal */
  6960. fontSize: '12px',
  6961. /** @internal */
  6962. whiteSpace: 'nowrap'
  6963. }
  6964. },
  6965. /**
  6966. * Highchart by default puts a credits label in the lower right corner
  6967. * of the chart. This can be changed using these options.
  6968. */
  6969. credits: {
  6970. /**
  6971. * Credits for map source to be concatenated with conventional credit
  6972. * text. By default this is a format string that collects copyright
  6973. * information from the map if available.
  6974. *
  6975. * @see [mapTextFull](#credits.mapTextFull)
  6976. * @see [text](#credits.text)
  6977. *
  6978. * @type {string}
  6979. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  6980. * @since 4.2.2
  6981. * @product highmaps
  6982. * @apioption credits.mapText
  6983. */
  6984. /**
  6985. * Detailed credits for map source to be displayed on hover of credits
  6986. * text. By default this is a format string that collects copyright
  6987. * information from the map if available.
  6988. *
  6989. * @see [mapText](#credits.mapText)
  6990. * @see [text](#credits.text)
  6991. *
  6992. * @type {string}
  6993. * @default {geojson.copyright}
  6994. * @since 4.2.2
  6995. * @product highmaps
  6996. * @apioption credits.mapTextFull
  6997. */
  6998. /**
  6999. * Whether to show the credits text.
  7000. *
  7001. * @sample {highcharts} highcharts/credits/enabled-false/
  7002. * Credits disabled
  7003. * @sample {highstock} stock/credits/enabled/
  7004. * Credits disabled
  7005. * @sample {highmaps} maps/credits/enabled-false/
  7006. * Credits disabled
  7007. */
  7008. enabled: true,
  7009. /**
  7010. * The URL for the credits label.
  7011. *
  7012. * @sample {highcharts} highcharts/credits/href/
  7013. * Custom URL and text
  7014. * @sample {highmaps} maps/credits/customized/
  7015. * Custom URL and text
  7016. */
  7017. href: 'https://www.highcharts.com?credits',
  7018. /**
  7019. * Position configuration for the credits label.
  7020. *
  7021. * @sample {highcharts} highcharts/credits/position-left/
  7022. * Left aligned
  7023. * @sample {highcharts} highcharts/credits/position-left/
  7024. * Left aligned
  7025. * @sample {highmaps} maps/credits/customized/
  7026. * Left aligned
  7027. * @sample {highmaps} maps/credits/customized/
  7028. * Left aligned
  7029. *
  7030. * @type {Highcharts.AlignObject}
  7031. * @since 2.1
  7032. */
  7033. position: {
  7034. /** @internal */
  7035. align: 'right',
  7036. /** @internal */
  7037. x: -10,
  7038. /** @internal */
  7039. verticalAlign: 'bottom',
  7040. /** @internal */
  7041. y: -5
  7042. },
  7043. /**
  7044. * CSS styles for the credits label.
  7045. *
  7046. * @see In styled mode, credits styles can be set with the
  7047. * `.highcharts-credits` class.
  7048. *
  7049. * @type {Highcharts.CSSObject}
  7050. */
  7051. style: {
  7052. /** @internal */
  7053. cursor: 'pointer',
  7054. /** @internal */
  7055. color: palette.neutralColor40,
  7056. /** @internal */
  7057. fontSize: '9px'
  7058. },
  7059. /**
  7060. * The text for the credits label.
  7061. *
  7062. * @productdesc {highmaps}
  7063. * If a map is loaded as GeoJSON, the text defaults to
  7064. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  7065. * `Highcharts.com`.
  7066. *
  7067. * @sample {highcharts} highcharts/credits/href/
  7068. * Custom URL and text
  7069. * @sample {highmaps} maps/credits/customized/
  7070. * Custom URL and text
  7071. */
  7072. text: 'Highcharts.com'
  7073. }
  7074. };
  7075. /* eslint-disable spaced-comment */
  7076. defaultOptions.chart.styledMode = false;
  7077. '';
  7078. var defaultTime = new Time(merge(defaultOptions.global,
  7079. defaultOptions.time));
  7080. /**
  7081. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  7082. * for outside modules wasn't enough because the setOptions method created a new
  7083. * object.
  7084. *
  7085. * @function Highcharts.getOptions
  7086. *
  7087. * @return {Highcharts.Options}
  7088. */
  7089. function getOptions() {
  7090. return defaultOptions;
  7091. }
  7092. /**
  7093. * Merge the default options with custom options and return the new options
  7094. * structure. Commonly used for defining reusable templates.
  7095. *
  7096. * @sample highcharts/global/useutc-false Setting a global option
  7097. * @sample highcharts/members/setoptions Applying a global theme
  7098. *
  7099. * @function Highcharts.setOptions
  7100. *
  7101. * @param {Highcharts.Options} options
  7102. * The new custom chart options.
  7103. *
  7104. * @return {Highcharts.Options}
  7105. * Updated options.
  7106. */
  7107. function setOptions(options) {
  7108. // Copy in the default options
  7109. merge(true, defaultOptions, options);
  7110. // Update the time object
  7111. if (options.time || options.global) {
  7112. if (H.time) {
  7113. H.time.update(merge(defaultOptions.global, defaultOptions.time, options.global, options.time));
  7114. }
  7115. else {
  7116. /**
  7117. * Global `Time` object with default options. Since v6.0.5, time
  7118. * settings can be applied individually for each chart. If no
  7119. * individual settings apply, this `Time` object is shared by all
  7120. * instances.
  7121. *
  7122. * @name Highcharts.time
  7123. * @type {Highcharts.Time}
  7124. */
  7125. H.time = defaultTime;
  7126. }
  7127. }
  7128. return defaultOptions;
  7129. }
  7130. /* *
  7131. *
  7132. * Default Export
  7133. *
  7134. * */
  7135. var DefaultOptions = {
  7136. defaultOptions: defaultOptions,
  7137. defaultTime: defaultTime,
  7138. getOptions: getOptions,
  7139. setOptions: setOptions
  7140. };
  7141. return DefaultOptions;
  7142. });
  7143. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  7144. /* *
  7145. *
  7146. * (c) 2010-2021 Torstein Honsi
  7147. *
  7148. * License: www.highcharts.com/license
  7149. *
  7150. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7151. *
  7152. * */
  7153. var color = Color.parse;
  7154. var win = H.win;
  7155. var isNumber = U.isNumber,
  7156. objectEach = U.objectEach;
  7157. /* eslint-disable no-invalid-this, valid-jsdoc */
  7158. /**
  7159. * An animator object used internally. One instance applies to one property
  7160. * (attribute or style prop) on one element. Animation is always initiated
  7161. * through {@link SVGElement#animate}.
  7162. *
  7163. * @example
  7164. * let rect = renderer.rect(0, 0, 10, 10).add();
  7165. * rect.animate({ width: 100 });
  7166. *
  7167. * @private
  7168. * @class
  7169. * @name Highcharts.Fx
  7170. */
  7171. var Fx = /** @class */ (function () {
  7172. /* *
  7173. *
  7174. * Constructors
  7175. *
  7176. * */
  7177. /**
  7178. *
  7179. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  7180. * The element to animate.
  7181. *
  7182. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  7183. * Animation options.
  7184. *
  7185. * @param {string} prop
  7186. * The single attribute or CSS property to animate.
  7187. */
  7188. function Fx(elem, options, prop) {
  7189. this.pos = NaN;
  7190. this.options = options;
  7191. this.elem = elem;
  7192. this.prop = prop;
  7193. }
  7194. /* *
  7195. *
  7196. * Functions
  7197. *
  7198. * */
  7199. /**
  7200. * Set the current step of a path definition on SVGElement.
  7201. *
  7202. * @function Highcharts.Fx#dSetter
  7203. *
  7204. * @return {void}
  7205. */
  7206. Fx.prototype.dSetter = function () {
  7207. var paths = this.paths,
  7208. start = paths && paths[0],
  7209. end = paths && paths[1],
  7210. now = this.now || 0;
  7211. var path = [];
  7212. // Land on the final path without adjustment points appended in the ends
  7213. if (now === 1 || !start || !end) {
  7214. path = this.toD || [];
  7215. }
  7216. else if (start.length === end.length && now < 1) {
  7217. for (var i = 0; i < end.length; i++) {
  7218. // Tween between the start segment and the end segment. Start
  7219. // with a copy of the end segment and tween the appropriate
  7220. // numerics
  7221. var startSeg = start[i];
  7222. var endSeg = end[i];
  7223. var tweenSeg = [];
  7224. for (var j = 0; j < endSeg.length; j++) {
  7225. var startItem = startSeg[j];
  7226. var endItem = endSeg[j];
  7227. // Tween numbers
  7228. if (isNumber(startItem) &&
  7229. isNumber(endItem) &&
  7230. // Arc boolean flags
  7231. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  7232. tweenSeg[j] = startItem + now * (endItem - startItem);
  7233. // Strings, take directly from the end segment
  7234. }
  7235. else {
  7236. tweenSeg[j] = endItem;
  7237. }
  7238. }
  7239. path.push(tweenSeg);
  7240. }
  7241. // If animation is finished or length not matching, land on right value
  7242. }
  7243. else {
  7244. path = end;
  7245. }
  7246. this.elem.attr('d', path, void 0, true);
  7247. };
  7248. /**
  7249. * Update the element with the current animation step.
  7250. *
  7251. * @function Highcharts.Fx#update
  7252. *
  7253. * @return {void}
  7254. */
  7255. Fx.prototype.update = function () {
  7256. var elem = this.elem,
  7257. prop = this.prop, // if destroyed, it is null
  7258. now = this.now,
  7259. step = this.options.step;
  7260. // Animation setter defined from outside
  7261. if (this[prop + 'Setter']) {
  7262. this[prop + 'Setter']();
  7263. // Other animations on SVGElement
  7264. }
  7265. else if (elem.attr) {
  7266. if (elem.element) {
  7267. elem.attr(prop, now, null, true);
  7268. }
  7269. // HTML styles, raw HTML content like container size
  7270. }
  7271. else {
  7272. elem.style[prop] = now + this.unit;
  7273. }
  7274. if (step) {
  7275. step.call(elem, now, this);
  7276. }
  7277. };
  7278. /**
  7279. * Run an animation.
  7280. *
  7281. * @function Highcharts.Fx#run
  7282. *
  7283. * @param {number} from
  7284. * The current value, value to start from.
  7285. *
  7286. * @param {number} to
  7287. * The end value, value to land on.
  7288. *
  7289. * @param {string} unit
  7290. * The property unit, for example `px`.
  7291. *
  7292. * @return {void}
  7293. */
  7294. Fx.prototype.run = function (from, to, unit) {
  7295. var self = this,
  7296. options = self.options,
  7297. timer = function (gotoEnd) {
  7298. return timer.stopped ? false : self.step(gotoEnd);
  7299. }, requestAnimationFrame = win.requestAnimationFrame ||
  7300. function (step) {
  7301. setTimeout(step, 13);
  7302. }, step = function () {
  7303. for (var i = 0; i < Fx.timers.length; i++) {
  7304. if (!Fx.timers[i]()) {
  7305. Fx.timers.splice(i--, 1);
  7306. }
  7307. }
  7308. if (Fx.timers.length) {
  7309. requestAnimationFrame(step);
  7310. }
  7311. };
  7312. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  7313. delete options.curAnim[this.prop];
  7314. if (options.complete && Object.keys(options.curAnim).length === 0) {
  7315. options.complete.call(this.elem);
  7316. }
  7317. }
  7318. else { // #7166
  7319. this.startTime = +new Date();
  7320. this.start = from;
  7321. this.end = to;
  7322. this.unit = unit;
  7323. this.now = this.start;
  7324. this.pos = 0;
  7325. timer.elem = this.elem;
  7326. timer.prop = this.prop;
  7327. if (timer() && Fx.timers.push(timer) === 1) {
  7328. requestAnimationFrame(step);
  7329. }
  7330. }
  7331. };
  7332. /**
  7333. * Run a single step in the animation.
  7334. *
  7335. * @function Highcharts.Fx#step
  7336. *
  7337. * @param {boolean} [gotoEnd]
  7338. * Whether to go to the endpoint of the animation after abort.
  7339. *
  7340. * @return {boolean}
  7341. * Returns `true` if animation continues.
  7342. */
  7343. Fx.prototype.step = function (gotoEnd) {
  7344. var t = +new Date(),
  7345. options = this.options,
  7346. elem = this.elem,
  7347. complete = options.complete,
  7348. duration = options.duration,
  7349. curAnim = options.curAnim;
  7350. var ret,
  7351. done;
  7352. if (elem.attr && !elem.element) { // #2616, element is destroyed
  7353. ret = false;
  7354. }
  7355. else if (gotoEnd || t >= duration + this.startTime) {
  7356. this.now = this.end;
  7357. this.pos = 1;
  7358. this.update();
  7359. curAnim[this.prop] = true;
  7360. done = true;
  7361. objectEach(curAnim, function (val) {
  7362. if (val !== true) {
  7363. done = false;
  7364. }
  7365. });
  7366. if (done && complete) {
  7367. complete.call(elem);
  7368. }
  7369. ret = false;
  7370. }
  7371. else {
  7372. this.pos = options.easing((t - this.startTime) / duration);
  7373. this.now = this.start + ((this.end - this.start) * this.pos);
  7374. this.update();
  7375. ret = true;
  7376. }
  7377. return ret;
  7378. };
  7379. /**
  7380. * Prepare start and end values so that the path can be animated one to one.
  7381. *
  7382. * @function Highcharts.Fx#initPath
  7383. *
  7384. * @param {Highcharts.SVGElement} elem
  7385. * The SVGElement item.
  7386. *
  7387. * @param {Highcharts.SVGPathArray|undefined} fromD
  7388. * Starting path definition.
  7389. *
  7390. * @param {Highcharts.SVGPathArray} toD
  7391. * Ending path definition.
  7392. *
  7393. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  7394. * An array containing start and end paths in array form so that
  7395. * they can be animated in parallel.
  7396. */
  7397. Fx.prototype.initPath = function (elem, fromD, toD) {
  7398. var startX = elem.startX,
  7399. endX = elem.endX,
  7400. end = toD.slice(), // copy
  7401. isArea = elem.isArea,
  7402. positionFactor = isArea ? 2 : 1;
  7403. var shift,
  7404. fullLength,
  7405. i,
  7406. reverse,
  7407. start = fromD && fromD.slice(); // copy
  7408. if (!start) {
  7409. return [end,
  7410. end];
  7411. }
  7412. /**
  7413. * If shifting points, prepend a dummy point to the end path.
  7414. * @private
  7415. * @param {Highcharts.SVGPathArray} arr - array
  7416. * @param {Highcharts.SVGPathArray} other - array
  7417. * @return {void}
  7418. */
  7419. function prepend(arr, other) {
  7420. while (arr.length < fullLength) {
  7421. // Move to, line to or curve to?
  7422. var moveSegment = arr[0],
  7423. otherSegment = other[fullLength - arr.length];
  7424. if (otherSegment && moveSegment[0] === 'M') {
  7425. if (otherSegment[0] === 'C') {
  7426. arr[0] = [
  7427. 'C',
  7428. moveSegment[1],
  7429. moveSegment[2],
  7430. moveSegment[1],
  7431. moveSegment[2],
  7432. moveSegment[1],
  7433. moveSegment[2]
  7434. ];
  7435. }
  7436. else {
  7437. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  7438. }
  7439. }
  7440. // Prepend a copy of the first point
  7441. arr.unshift(moveSegment);
  7442. // For areas, the bottom path goes back again to the left, so we
  7443. // need to append a copy of the last point.
  7444. if (isArea) {
  7445. var z = arr.pop();
  7446. arr.push(arr[arr.length - 1], z); // append point and the Z
  7447. }
  7448. }
  7449. }
  7450. /**
  7451. * Copy and append last point until the length matches the end length.
  7452. * @private
  7453. * @param {Highcharts.SVGPathArray} arr - array
  7454. * @param {Highcharts.SVGPathArray} other - array
  7455. * @return {void}
  7456. */
  7457. function append(arr, other) {
  7458. while (arr.length < fullLength) {
  7459. // Pull out the slice that is going to be appended or inserted.
  7460. // In a line graph, the positionFactor is 1, and the last point
  7461. // is sliced out. In an area graph, the positionFactor is 2,
  7462. // causing the middle two points to be sliced out, since an area
  7463. // path starts at left, follows the upper path then turns and
  7464. // follows the bottom back.
  7465. var segmentToAdd = arr[Math.floor(arr.length / positionFactor) - 1].slice();
  7466. // Disable the first control point of curve segments
  7467. if (segmentToAdd[0] === 'C') {
  7468. segmentToAdd[1] = segmentToAdd[5];
  7469. segmentToAdd[2] = segmentToAdd[6];
  7470. }
  7471. if (!isArea) {
  7472. arr.push(segmentToAdd);
  7473. }
  7474. else {
  7475. var lowerSegmentToAdd = arr[Math.floor(arr.length / positionFactor)].slice();
  7476. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  7477. }
  7478. }
  7479. }
  7480. // For sideways animation, find out how much we need to shift to get the
  7481. // start path Xs to match the end path Xs.
  7482. if (startX && endX && endX.length) {
  7483. for (i = 0; i < startX.length; i++) {
  7484. // Moving left, new points coming in on right
  7485. if (startX[i] === endX[0]) {
  7486. shift = i;
  7487. break;
  7488. // Moving right
  7489. }
  7490. else if (startX[0] ===
  7491. endX[endX.length - startX.length + i]) {
  7492. shift = i;
  7493. reverse = true;
  7494. break;
  7495. // Fixed from the right side, "scaling" left
  7496. }
  7497. else if (startX[startX.length - 1] ===
  7498. endX[endX.length - startX.length + i]) {
  7499. shift = startX.length - i;
  7500. break;
  7501. }
  7502. }
  7503. if (typeof shift === 'undefined') {
  7504. start = [];
  7505. }
  7506. }
  7507. if (start.length && isNumber(shift)) {
  7508. // The common target length for the start and end array, where both
  7509. // arrays are padded in opposite ends
  7510. fullLength = end.length + shift * positionFactor;
  7511. if (!reverse) {
  7512. prepend(end, start);
  7513. append(start, end);
  7514. }
  7515. else {
  7516. prepend(start, end);
  7517. append(end, start);
  7518. }
  7519. }
  7520. return [start, end];
  7521. };
  7522. /**
  7523. * Handle animation of the color attributes directly.
  7524. *
  7525. * @function Highcharts.Fx#fillSetter
  7526. *
  7527. * @return {void}
  7528. */
  7529. Fx.prototype.fillSetter = function () {
  7530. Fx.prototype.strokeSetter.apply(this, arguments);
  7531. };
  7532. /**
  7533. * Handle animation of the color attributes directly.
  7534. *
  7535. * @function Highcharts.Fx#strokeSetter
  7536. *
  7537. * @return {void}
  7538. */
  7539. Fx.prototype.strokeSetter = function () {
  7540. this.elem.attr(this.prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  7541. };
  7542. /* *
  7543. *
  7544. * Static properties
  7545. *
  7546. * */
  7547. Fx.timers = [];
  7548. return Fx;
  7549. }());
  7550. /* *
  7551. *
  7552. * Default Export
  7553. *
  7554. * */
  7555. return Fx;
  7556. });
  7557. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Utilities.js']], function (Fx, U) {
  7558. /* *
  7559. *
  7560. * (c) 2010-2021 Torstein Honsi
  7561. *
  7562. * License: www.highcharts.com/license
  7563. *
  7564. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7565. *
  7566. * */
  7567. var defined = U.defined,
  7568. getStyle = U.getStyle,
  7569. isArray = U.isArray,
  7570. isNumber = U.isNumber,
  7571. isObject = U.isObject,
  7572. merge = U.merge,
  7573. objectEach = U.objectEach,
  7574. pick = U.pick;
  7575. /**
  7576. * Set the global animation to either a given value, or fall back to the given
  7577. * chart's animation option.
  7578. *
  7579. * @function Highcharts.setAnimation
  7580. *
  7581. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  7582. * The animation object.
  7583. *
  7584. * @param {Highcharts.Chart} chart
  7585. * The chart instance.
  7586. *
  7587. * @todo
  7588. * This function always relates to a chart, and sets a property on the renderer,
  7589. * so it should be moved to the SVGRenderer.
  7590. */
  7591. function setAnimation(animation, chart) {
  7592. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  7593. }
  7594. /**
  7595. * Get the animation in object form, where a disabled animation is always
  7596. * returned as `{ duration: 0 }`.
  7597. *
  7598. * @function Highcharts.animObject
  7599. *
  7600. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  7601. * An animation setting. Can be an object with duration, complete and
  7602. * easing properties, or a boolean to enable or disable.
  7603. *
  7604. * @return {Highcharts.AnimationOptionsObject}
  7605. * An object with at least a duration property.
  7606. */
  7607. function animObject(animation) {
  7608. return isObject(animation) ?
  7609. merge({ duration: 500, defer: 0 }, animation) :
  7610. { duration: animation ? 500 : 0, defer: 0 };
  7611. }
  7612. /**
  7613. * Get the defer as a number value from series animation options.
  7614. *
  7615. * @function Highcharts.getDeferredAnimation
  7616. *
  7617. * @param {Highcharts.Chart} chart
  7618. * The chart instance.
  7619. *
  7620. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  7621. * An animation setting. Can be an object with duration, complete and
  7622. * easing properties, or a boolean to enable or disable.
  7623. *
  7624. * @param {Highcharts.Series} [series]
  7625. * Series to defer animation.
  7626. *
  7627. * @return {number}
  7628. * The numeric value.
  7629. */
  7630. function getDeferredAnimation(chart, animation, series) {
  7631. var labelAnimation = animObject(animation);
  7632. var s = series ? [series] : chart.series;
  7633. var defer = 0;
  7634. var duration = 0;
  7635. s.forEach(function (series) {
  7636. var seriesAnim = animObject(series.options.animation);
  7637. defer = animation && defined(animation.defer) ?
  7638. labelAnimation.defer :
  7639. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  7640. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  7641. });
  7642. // Disable defer for exporting
  7643. if (chart.renderer.forExport) {
  7644. defer = 0;
  7645. }
  7646. var anim = {
  7647. defer: Math.max(0,
  7648. defer - duration),
  7649. duration: Math.min(defer,
  7650. duration)
  7651. };
  7652. return anim;
  7653. }
  7654. /**
  7655. * The global animate method, which uses Fx to create individual animators.
  7656. *
  7657. * @function Highcharts.animate
  7658. *
  7659. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  7660. * The element to animate.
  7661. *
  7662. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  7663. * An object containing key-value pairs of the properties to animate.
  7664. * Supports numeric as pixel-based CSS properties for HTML objects and
  7665. * attributes for SVGElements.
  7666. *
  7667. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  7668. * Animation options.
  7669. *
  7670. * @return {void}
  7671. */
  7672. function animate(el, params, opt) {
  7673. var start,
  7674. unit = '',
  7675. end,
  7676. fx,
  7677. args;
  7678. if (!isObject(opt)) { // Number or undefined/null
  7679. args = arguments;
  7680. opt = {
  7681. duration: args[2],
  7682. easing: args[3],
  7683. complete: args[4]
  7684. };
  7685. }
  7686. if (!isNumber(opt.duration)) {
  7687. opt.duration = 400;
  7688. }
  7689. opt.easing = typeof opt.easing === 'function' ?
  7690. opt.easing :
  7691. (Math[opt.easing] || Math.easeInOutSine);
  7692. opt.curAnim = merge(params);
  7693. objectEach(params, function (val, prop) {
  7694. // Stop current running animation of this property
  7695. stop(el, prop);
  7696. fx = new Fx(el, opt, prop);
  7697. end = void 0;
  7698. if (prop === 'd' && isArray(params.d)) {
  7699. fx.paths = fx.initPath(el, el.pathArray, params.d);
  7700. fx.toD = params.d;
  7701. start = 0;
  7702. end = 1;
  7703. }
  7704. else if (el.attr) {
  7705. start = el.attr(prop);
  7706. }
  7707. else {
  7708. start = parseFloat(getStyle(el, prop)) || 0;
  7709. if (prop !== 'opacity') {
  7710. unit = 'px';
  7711. }
  7712. }
  7713. if (!end) {
  7714. end = val;
  7715. }
  7716. if (typeof end === 'string' && end.match('px')) {
  7717. end = end.replace(/px/g, ''); // #4351
  7718. }
  7719. fx.run(start, end, unit);
  7720. });
  7721. }
  7722. /**
  7723. * Stop running animation.
  7724. *
  7725. * @function Highcharts.stop
  7726. *
  7727. * @param {Highcharts.SVGElement} el
  7728. * The SVGElement to stop animation on.
  7729. *
  7730. * @param {string} [prop]
  7731. * The property to stop animating. If given, the stop method will stop a
  7732. * single property from animating, while others continue.
  7733. *
  7734. * @return {void}
  7735. *
  7736. * @todo
  7737. * A possible extension to this would be to stop a single property, when
  7738. * we want to continue animating others. Then assign the prop to the timer
  7739. * in the Fx.run method, and check for the prop here. This would be an
  7740. * improvement in all cases where we stop the animation from .attr. Instead of
  7741. * stopping everything, we can just stop the actual attributes we're setting.
  7742. */
  7743. function stop(el, prop) {
  7744. var i = Fx.timers.length;
  7745. // Remove timers related to this element (#4519)
  7746. while (i--) {
  7747. if (Fx.timers[i].elem === el && (!prop || prop === Fx.timers[i].prop)) {
  7748. Fx.timers[i].stopped = true; // #4667
  7749. }
  7750. }
  7751. }
  7752. var animationExports = {
  7753. animate: animate,
  7754. animObject: animObject,
  7755. getDeferredAnimation: getDeferredAnimation,
  7756. setAnimation: setAnimation,
  7757. stop: stop
  7758. };
  7759. return animationExports;
  7760. });
  7761. _registerModule(_modules, 'Core/Renderer/HTML/AST.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7762. /* *
  7763. *
  7764. * (c) 2010-2020 Torstein Honsi
  7765. *
  7766. * License: www.highcharts.com/license
  7767. *
  7768. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7769. *
  7770. * */
  7771. var SVG_NS = H.SVG_NS;
  7772. var attr = U.attr,
  7773. createElement = U.createElement,
  7774. discardElement = U.discardElement,
  7775. error = U.error,
  7776. isString = U.isString,
  7777. objectEach = U.objectEach,
  7778. splat = U.splat;
  7779. /* *
  7780. *
  7781. * Constants
  7782. *
  7783. * */
  7784. // In IE8, DOMParser is undefined. IE9 and PhantomJS are only able to parse XML.
  7785. var hasValidDOMParser = (function () {
  7786. try {
  7787. return Boolean(new DOMParser().parseFromString('', 'text/html'));
  7788. }
  7789. catch (e) {
  7790. return false;
  7791. }
  7792. }());
  7793. /* *
  7794. *
  7795. * Class
  7796. *
  7797. * */
  7798. /**
  7799. * The AST class represents an abstract syntax tree of HTML or SVG content. It
  7800. * can take HTML as an argument, parse it, optionally transform it to SVG, then
  7801. * perform sanitation before inserting it into the DOM.
  7802. *
  7803. * @class
  7804. * @name Highcharts.AST
  7805. *
  7806. * @param {string|Array<Highcharts.ASTNode>} source
  7807. * Either an HTML string or an ASTNode list to populate the tree.
  7808. */
  7809. var AST = /** @class */ (function () {
  7810. // Construct an AST from HTML markup, or wrap an array of existing AST nodes
  7811. function AST(source) {
  7812. this.nodes = typeof source === 'string' ?
  7813. this.parseMarkup(source) : source;
  7814. }
  7815. /**
  7816. * Filter an object of SVG or HTML attributes against the allow list.
  7817. *
  7818. * @static
  7819. *
  7820. * @function Highcharts.AST#filterUserAttributes
  7821. *
  7822. * @param {Highcharts.SVGAttributes} attributes The attributes to filter
  7823. *
  7824. * @return {Highcharts.SVGAttributes}
  7825. * The filtered attributes
  7826. */
  7827. AST.filterUserAttributes = function (attributes) {
  7828. objectEach(attributes, function (val, key) {
  7829. var valid = true;
  7830. if (AST.allowedAttributes.indexOf(key) === -1) {
  7831. valid = false;
  7832. }
  7833. if (['background', 'dynsrc', 'href', 'lowsrc', 'src']
  7834. .indexOf(key) !== -1) {
  7835. valid = isString(val) && AST.allowedReferences.some(function (ref) { return val.indexOf(ref) === 0; });
  7836. }
  7837. if (!valid) {
  7838. error("Highcharts warning: Invalid attribute '" + key + "' in config");
  7839. delete attributes[key];
  7840. }
  7841. });
  7842. return attributes;
  7843. };
  7844. /**
  7845. * Utility function to set html content for an element by passing in a
  7846. * markup string. The markup is safely parsed by the AST class to avoid
  7847. * XSS vulnerabilities. This function should be used instead of setting
  7848. * `innerHTML` in all cases where the content is not fully trusted.
  7849. *
  7850. * @static
  7851. *
  7852. * @function Highcharts.AST#setElementHTML
  7853. *
  7854. * @param {SVGDOMElement|HTMLDOMElement} el The node to set content of
  7855. * @param {string} html The markup string
  7856. */
  7857. AST.setElementHTML = function (el, html) {
  7858. el.innerHTML = ''; // Clear previous
  7859. if (html) {
  7860. var ast = new AST(html);
  7861. ast.addToDOM(el);
  7862. }
  7863. };
  7864. /**
  7865. * Add the tree defined as a hierarchical JS structure to the DOM
  7866. *
  7867. * @function Highcharts.AST#addToDOM
  7868. *
  7869. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} parent
  7870. * The node where it should be added
  7871. *
  7872. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement}
  7873. * The inserted node.
  7874. */
  7875. AST.prototype.addToDOM = function (parent) {
  7876. /**
  7877. * @private
  7878. * @param {Highcharts.ASTNode} subtree - HTML/SVG definition
  7879. * @param {Element} [subParent] - parent node
  7880. * @return {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} The inserted node.
  7881. */
  7882. function recurse(subtree, subParent) {
  7883. var ret;
  7884. splat(subtree).forEach(function (item) {
  7885. var tagName = item.tagName;
  7886. var textNode = item.textContent ?
  7887. H.doc.createTextNode(item.textContent) :
  7888. void 0;
  7889. var node;
  7890. if (tagName) {
  7891. if (tagName === '#text') {
  7892. node = textNode;
  7893. }
  7894. else if (AST.allowedTags.indexOf(tagName) !== -1) {
  7895. var NS = tagName === 'svg' ?
  7896. SVG_NS :
  7897. (subParent.namespaceURI || SVG_NS);
  7898. var element = H.doc.createElementNS(NS,
  7899. tagName);
  7900. var attributes_1 = item.attributes || {};
  7901. // Apply attributes from root of AST node, legacy from
  7902. // from before TextBuilder
  7903. objectEach(item, function (val, key) {
  7904. if (key !== 'tagName' &&
  7905. key !== 'attributes' &&
  7906. key !== 'children' &&
  7907. key !== 'textContent') {
  7908. attributes_1[key] = val;
  7909. }
  7910. });
  7911. attr(element, AST.filterUserAttributes(attributes_1));
  7912. // Add text content
  7913. if (textNode) {
  7914. element.appendChild(textNode);
  7915. }
  7916. // Recurse
  7917. recurse(item.children || [], element);
  7918. node = element;
  7919. }
  7920. else {
  7921. error("Highcharts warning: Invalid tagName '" + tagName + "' in config");
  7922. }
  7923. }
  7924. // Add to the tree
  7925. if (node) {
  7926. subParent.appendChild(node);
  7927. }
  7928. ret = node;
  7929. });
  7930. // Return last node added (on top level it's the only one)
  7931. return ret;
  7932. }
  7933. return recurse(this.nodes, parent);
  7934. };
  7935. /**
  7936. * Parse HTML/SVG markup into AST Node objects. Used internally from the
  7937. * constructor.
  7938. *
  7939. * @private
  7940. *
  7941. * @function Highcharts.AST#getNodesFromMarkup
  7942. *
  7943. * @param {string} markup The markup string.
  7944. *
  7945. * @return {Array<Highcharts.ASTNode>} The parsed nodes.
  7946. */
  7947. AST.prototype.parseMarkup = function (markup) {
  7948. var nodes = [];
  7949. var doc;
  7950. var body;
  7951. if (hasValidDOMParser) {
  7952. doc = new DOMParser().parseFromString(markup, 'text/html');
  7953. }
  7954. else {
  7955. body = createElement('div');
  7956. body.innerHTML = markup;
  7957. doc = { body: body };
  7958. }
  7959. var appendChildNodes = function (node,
  7960. addTo) {
  7961. var tagName = node.nodeName.toLowerCase();
  7962. // Add allowed tags
  7963. var astNode = {
  7964. tagName: tagName
  7965. };
  7966. if (tagName === '#text') {
  7967. var textContent = node.textContent || '';
  7968. // Whitespace text node, don't append it to the AST
  7969. if (/^[\s]*$/.test(textContent)) {
  7970. return;
  7971. }
  7972. astNode.textContent = textContent;
  7973. }
  7974. var parsedAttributes = node.attributes;
  7975. // Add attributes
  7976. if (parsedAttributes) {
  7977. var attributes_2 = {};
  7978. [].forEach.call(parsedAttributes, function (attrib) {
  7979. attributes_2[attrib.name] = attrib.value;
  7980. });
  7981. astNode.attributes = attributes_2;
  7982. }
  7983. // Handle children
  7984. if (node.childNodes.length) {
  7985. var children_1 = [];
  7986. [].forEach.call(node.childNodes, function (childNode) {
  7987. appendChildNodes(childNode, children_1);
  7988. });
  7989. if (children_1.length) {
  7990. astNode.children = children_1;
  7991. }
  7992. }
  7993. addTo.push(astNode);
  7994. };
  7995. [].forEach.call(doc.body.childNodes, function (childNode) { return appendChildNodes(childNode, nodes); });
  7996. if (body) {
  7997. discardElement(body);
  7998. }
  7999. return nodes;
  8000. };
  8001. /**
  8002. * The list of allowed SVG or HTML tags, used for sanitizing potentially
  8003. * harmful content from the chart configuration before adding to the DOM.
  8004. *
  8005. * @example
  8006. * // Allow a custom, trusted tag
  8007. * Highcharts.AST.allowedTags.push('blink'); // ;)
  8008. *
  8009. * @name Highcharts.AST.allowedTags
  8010. * @static
  8011. */
  8012. AST.allowedTags = [
  8013. 'a',
  8014. 'b',
  8015. 'br',
  8016. 'button',
  8017. 'caption',
  8018. 'circle',
  8019. 'clipPath',
  8020. 'code',
  8021. 'dd',
  8022. 'defs',
  8023. 'div',
  8024. 'dl',
  8025. 'dt',
  8026. 'em',
  8027. 'feComponentTransfer',
  8028. 'feFuncA',
  8029. 'feFuncB',
  8030. 'feFuncG',
  8031. 'feFuncR',
  8032. 'feGaussianBlur',
  8033. 'feOffset',
  8034. 'feMerge',
  8035. 'feMergeNode',
  8036. 'filter',
  8037. 'h1',
  8038. 'h2',
  8039. 'h3',
  8040. 'h4',
  8041. 'h5',
  8042. 'h6',
  8043. 'hr',
  8044. 'i',
  8045. 'img',
  8046. 'li',
  8047. 'linearGradient',
  8048. 'marker',
  8049. 'ol',
  8050. 'p',
  8051. 'path',
  8052. 'pattern',
  8053. 'pre',
  8054. 'rect',
  8055. 'small',
  8056. 'span',
  8057. 'stop',
  8058. 'strong',
  8059. 'style',
  8060. 'sub',
  8061. 'sup',
  8062. 'svg',
  8063. 'table',
  8064. 'text',
  8065. 'thead',
  8066. 'tbody',
  8067. 'tspan',
  8068. 'td',
  8069. 'th',
  8070. 'tr',
  8071. 'u',
  8072. 'ul',
  8073. '#text'
  8074. ];
  8075. /**
  8076. * The list of allowed SVG or HTML attributes, used for sanitizing
  8077. * potentially harmful content from the chart configuration before adding to
  8078. * the DOM.
  8079. *
  8080. * @example
  8081. * // Allow a custom, trusted attribute
  8082. * Highcharts.AST.allowedAttributes.push('data-value');
  8083. *
  8084. * @name Highcharts.AST.allowedAttributes
  8085. * @static
  8086. */
  8087. AST.allowedAttributes = [
  8088. 'aria-controls',
  8089. 'aria-describedby',
  8090. 'aria-expanded',
  8091. 'aria-haspopup',
  8092. 'aria-hidden',
  8093. 'aria-label',
  8094. 'aria-labelledby',
  8095. 'aria-live',
  8096. 'aria-pressed',
  8097. 'aria-readonly',
  8098. 'aria-roledescription',
  8099. 'aria-selected',
  8100. 'class',
  8101. 'clip-path',
  8102. 'color',
  8103. 'colspan',
  8104. 'cx',
  8105. 'cy',
  8106. 'd',
  8107. 'dx',
  8108. 'dy',
  8109. 'disabled',
  8110. 'fill',
  8111. 'height',
  8112. 'href',
  8113. 'id',
  8114. 'in',
  8115. 'markerHeight',
  8116. 'markerWidth',
  8117. 'offset',
  8118. 'opacity',
  8119. 'orient',
  8120. 'padding',
  8121. 'paddingLeft',
  8122. 'paddingRight',
  8123. 'patternUnits',
  8124. 'r',
  8125. 'refX',
  8126. 'refY',
  8127. 'role',
  8128. 'scope',
  8129. 'slope',
  8130. 'src',
  8131. 'startOffset',
  8132. 'stdDeviation',
  8133. 'stroke',
  8134. 'stroke-linecap',
  8135. 'stroke-width',
  8136. 'style',
  8137. 'tableValues',
  8138. 'result',
  8139. 'rowspan',
  8140. 'summary',
  8141. 'target',
  8142. 'tabindex',
  8143. 'text-align',
  8144. 'textAnchor',
  8145. 'textLength',
  8146. 'type',
  8147. 'valign',
  8148. 'width',
  8149. 'x',
  8150. 'x1',
  8151. 'x2',
  8152. 'y',
  8153. 'y1',
  8154. 'y2',
  8155. 'zIndex'
  8156. ];
  8157. /**
  8158. * The list of allowed references for referring attributes like `href` and
  8159. * `src`. Attribute values will only be allowed if they start with one of
  8160. * these strings.
  8161. *
  8162. * @example
  8163. * // Allow tel:
  8164. * Highcharts.AST.allowedReferences.push('tel:');
  8165. *
  8166. * @name Highcharts.AST.allowedReferences
  8167. * @static
  8168. */
  8169. AST.allowedReferences = [
  8170. 'https://',
  8171. 'http://',
  8172. 'mailto:',
  8173. '/',
  8174. '../',
  8175. './',
  8176. '#'
  8177. ];
  8178. return AST;
  8179. }());
  8180. /* *
  8181. *
  8182. * Default Export
  8183. *
  8184. * */
  8185. /* *
  8186. *
  8187. * API Declarations
  8188. *
  8189. * */
  8190. /**
  8191. * Serialized form of an SVG/HTML definition, including children.
  8192. *
  8193. * @interface Highcharts.ASTNode
  8194. */ /**
  8195. * @name Highcharts.ASTNode#attributes
  8196. * @type {Highcharts.SVGAttributes|undefined}
  8197. */ /**
  8198. * @name Highcharts.ASTNode#children
  8199. * @type {Array<Highcharts.ASTNode>|undefined}
  8200. */ /**
  8201. * @name Highcharts.ASTNode#tagName
  8202. * @type {string|undefined}
  8203. */ /**
  8204. * @name Highcharts.ASTNode#textContent
  8205. * @type {string|undefined}
  8206. */
  8207. ''; // detach doclets above
  8208. return AST;
  8209. });
  8210. _registerModule(_modules, 'Core/FormatUtilities.js', [_modules['Core/DefaultOptions.js'], _modules['Core/Utilities.js']], function (D, U) {
  8211. /* *
  8212. *
  8213. * (c) 2010-2021 Torstein Honsi
  8214. *
  8215. * License: www.highcharts.com/license
  8216. *
  8217. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8218. *
  8219. * */
  8220. var defaultOptions = D.defaultOptions,
  8221. defaultTime = D.defaultTime;
  8222. var getNestedProperty = U.getNestedProperty,
  8223. isNumber = U.isNumber,
  8224. pick = U.pick,
  8225. pInt = U.pInt;
  8226. /* *
  8227. *
  8228. * Functions
  8229. *
  8230. * */
  8231. /**
  8232. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  8233. * human readable date string. The format is a subset of the formats for PHP's
  8234. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  8235. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  8236. *
  8237. * Since v6.0.5, all internal dates are formatted through the
  8238. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  8239. * The `Highcharts.dateFormat` function only reflects global time settings set
  8240. * with `setOptions`.
  8241. *
  8242. * Supported format keys:
  8243. * - `%a`: Short weekday, like 'Mon'
  8244. * - `%A`: Long weekday, like 'Monday'
  8245. * - `%d`: Two digit day of the month, 01 to 31
  8246. * - `%e`: Day of the month, 1 through 31
  8247. * - `%w`: Day of the week, 0 through 6
  8248. * - `%b`: Short month, like 'Jan'
  8249. * - `%B`: Long month, like 'January'
  8250. * - `%m`: Two digit month number, 01 through 12
  8251. * - `%y`: Two digits year, like 09 for 2009
  8252. * - `%Y`: Four digits year, like 2009
  8253. * - `%H`: Two digits hours in 24h format, 00 through 23
  8254. * - `%k`: Hours in 24h format, 0 through 23
  8255. * - `%I`: Two digits hours in 12h format, 00 through 11
  8256. * - `%l`: Hours in 12h format, 1 through 12
  8257. * - `%M`: Two digits minutes, 00 through 59
  8258. * - `%p`: Upper case AM or PM
  8259. * - `%P`: Lower case AM or PM
  8260. * - `%S`: Two digits seconds, 00 through 59
  8261. * - `%L`: Milliseconds (naming from Ruby)
  8262. *
  8263. * @function Highcharts.dateFormat
  8264. *
  8265. * @param {string} format
  8266. * The desired format where various time representations are prefixed
  8267. * with `%`.
  8268. *
  8269. * @param {number} timestamp
  8270. * The JavaScript timestamp.
  8271. *
  8272. * @param {boolean} [capitalize=false]
  8273. * Upper case first letter in the return.
  8274. *
  8275. * @return {string}
  8276. * The formatted date.
  8277. */
  8278. function dateFormat(format, timestamp, capitalize) {
  8279. return defaultTime.dateFormat(format, timestamp, capitalize);
  8280. }
  8281. /**
  8282. * Format a string according to a subset of the rules of Python's String.format
  8283. * method.
  8284. *
  8285. * @example
  8286. * let s = Highcharts.format(
  8287. * 'The {color} fox was {len:.2f} feet long',
  8288. * { color: 'red', len: Math.PI }
  8289. * );
  8290. * // => The red fox was 3.14 feet long
  8291. *
  8292. * @function Highcharts.format
  8293. *
  8294. * @param {string} str
  8295. * The string to format.
  8296. *
  8297. * @param {Record<string, *>} ctx
  8298. * The context, a collection of key-value pairs where each key is
  8299. * replaced by its value.
  8300. *
  8301. * @param {Highcharts.Chart} [chart]
  8302. * A `Chart` instance used to get numberFormatter and time.
  8303. *
  8304. * @return {string}
  8305. * The formatted string.
  8306. */
  8307. function format(str, ctx, chart) {
  8308. var splitter = '{',
  8309. isInside = false,
  8310. segment,
  8311. valueAndFormat,
  8312. val,
  8313. index;
  8314. var floatRegex = /f$/;
  8315. var decRegex = /\.([0-9])/;
  8316. var lang = defaultOptions.lang;
  8317. var time = chart && chart.time || defaultTime;
  8318. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  8319. var ret = [];
  8320. while (str) {
  8321. index = str.indexOf(splitter);
  8322. if (index === -1) {
  8323. break;
  8324. }
  8325. segment = str.slice(0, index);
  8326. if (isInside) { // we're on the closing bracket looking back
  8327. valueAndFormat = segment.split(':');
  8328. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  8329. // Format the replacement
  8330. if (valueAndFormat.length && typeof val === 'number') {
  8331. segment = valueAndFormat.join(':');
  8332. if (floatRegex.test(segment)) { // float
  8333. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  8334. if (val !== null) {
  8335. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  8336. }
  8337. }
  8338. else {
  8339. val = time.dateFormat(segment, val);
  8340. }
  8341. }
  8342. // Push the result and advance the cursor
  8343. ret.push(val);
  8344. }
  8345. else {
  8346. ret.push(segment);
  8347. }
  8348. str = str.slice(index + 1); // the rest
  8349. isInside = !isInside; // toggle
  8350. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  8351. }
  8352. ret.push(str);
  8353. return ret.join('');
  8354. }
  8355. /**
  8356. * Format a number and return a string based on input settings.
  8357. *
  8358. * @sample highcharts/members/highcharts-numberformat/
  8359. * Custom number format
  8360. *
  8361. * @function Highcharts.numberFormat
  8362. *
  8363. * @param {number} number
  8364. * The input number to format.
  8365. *
  8366. * @param {number} decimals
  8367. * The amount of decimals. A value of -1 preserves the amount in the
  8368. * input number.
  8369. *
  8370. * @param {string} [decimalPoint]
  8371. * The decimal point, defaults to the one given in the lang options, or
  8372. * a dot.
  8373. *
  8374. * @param {string} [thousandsSep]
  8375. * The thousands separator, defaults to the one given in the lang
  8376. * options, or a space character.
  8377. *
  8378. * @return {string}
  8379. * The formatted number.
  8380. */
  8381. function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  8382. number = +number || 0;
  8383. decimals = +decimals;
  8384. var ret,
  8385. fractionDigits;
  8386. var lang = defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, exponent = number.toString().split('e'), firstDecimals = decimals;
  8387. if (decimals === -1) {
  8388. // Preserve decimals. Not huge numbers (#3793).
  8389. decimals = Math.min(origDec, 20);
  8390. }
  8391. else if (!isNumber(decimals)) {
  8392. decimals = 2;
  8393. }
  8394. else if (decimals && exponent[1] && exponent[1] < 0) {
  8395. // Expose decimals from exponential notation (#7042)
  8396. fractionDigits = decimals + +exponent[1];
  8397. if (fractionDigits >= 0) {
  8398. // remove too small part of the number while keeping the notation
  8399. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  8400. .split('e')[0];
  8401. decimals = fractionDigits;
  8402. }
  8403. else {
  8404. // fractionDigits < 0
  8405. exponent[0] = exponent[0].split('.')[0] || 0;
  8406. if (decimals < 20) {
  8407. // use number instead of exponential notation (#7405)
  8408. number = (exponent[0] * Math.pow(10, exponent[1]))
  8409. .toFixed(decimals);
  8410. }
  8411. else {
  8412. // or zero
  8413. number = 0;
  8414. }
  8415. exponent[1] = 0;
  8416. }
  8417. }
  8418. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  8419. // Then use toFixed to handle rounding.
  8420. var roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  8421. Math.pow(10, -Math.max(decimals,
  8422. origDec) - 1)).toFixed(decimals);
  8423. // A string containing the positive integer component of the number
  8424. var strinteger = String(pInt(roundedNumber));
  8425. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  8426. var thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  8427. // Language
  8428. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  8429. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  8430. // Start building the return
  8431. ret = number < 0 ? '-' : '';
  8432. // Add the leftover after grouping into thousands. For example, in the
  8433. // number 42 000 000, this line adds 42.
  8434. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  8435. if (+exponent[1] < 0 && !firstDecimals) {
  8436. ret = '0';
  8437. }
  8438. else {
  8439. // Add the remaining thousands groups, joined by the thousands separator
  8440. ret += strinteger
  8441. .substr(thousands)
  8442. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  8443. }
  8444. // Add the decimal point and the decimal component
  8445. if (decimals) {
  8446. // Get the decimal component
  8447. ret += decimalPoint + roundedNumber.slice(-decimals);
  8448. }
  8449. if (exponent[1] && +ret !== 0) {
  8450. ret += 'e' + exponent[1];
  8451. }
  8452. return ret;
  8453. }
  8454. /* *
  8455. *
  8456. * Default Export
  8457. *
  8458. * */
  8459. var FormatUtilities = {
  8460. dateFormat: dateFormat,
  8461. format: format,
  8462. numberFormat: numberFormat
  8463. };
  8464. return FormatUtilities;
  8465. });
  8466. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (A, AST, Color, H, palette, U) {
  8467. /* *
  8468. *
  8469. * (c) 2010-2021 Torstein Honsi
  8470. *
  8471. * License: www.highcharts.com/license
  8472. *
  8473. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8474. *
  8475. * */
  8476. var animate = A.animate,
  8477. animObject = A.animObject,
  8478. stop = A.stop;
  8479. var deg2rad = H.deg2rad,
  8480. doc = H.doc,
  8481. hasTouch = H.hasTouch,
  8482. noop = H.noop,
  8483. svg = H.svg,
  8484. SVG_NS = H.SVG_NS,
  8485. win = H.win;
  8486. var addEvent = U.addEvent,
  8487. attr = U.attr,
  8488. createElement = U.createElement,
  8489. css = U.css,
  8490. defined = U.defined,
  8491. erase = U.erase,
  8492. extend = U.extend,
  8493. fireEvent = U.fireEvent,
  8494. isArray = U.isArray,
  8495. isFunction = U.isFunction,
  8496. isNumber = U.isNumber,
  8497. isString = U.isString,
  8498. merge = U.merge,
  8499. objectEach = U.objectEach,
  8500. pick = U.pick,
  8501. pInt = U.pInt,
  8502. syncTimeout = U.syncTimeout,
  8503. uniqueKey = U.uniqueKey;
  8504. /* *
  8505. *
  8506. * Class
  8507. *
  8508. * */
  8509. /* eslint-disable no-invalid-this, valid-jsdoc */
  8510. /**
  8511. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  8512. * rendering layer of Highcharts. Combined with the
  8513. * {@link Highcharts.SVGRenderer}
  8514. * object, these prototypes allow freeform annotation in the charts or even in
  8515. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  8516. * labels, when `text` or `label` elements are created with the `useHTML`
  8517. * parameter.
  8518. *
  8519. * The SVGElement instances are created through factory functions on the
  8520. * {@link Highcharts.SVGRenderer}
  8521. * object, like
  8522. * {@link Highcharts.SVGRenderer#rect|rect},
  8523. * {@link Highcharts.SVGRenderer#path|path},
  8524. * {@link Highcharts.SVGRenderer#text|text},
  8525. * {@link Highcharts.SVGRenderer#label|label},
  8526. * {@link Highcharts.SVGRenderer#g|g}
  8527. * and more.
  8528. *
  8529. * @class
  8530. * @name Highcharts.SVGElement
  8531. */
  8532. var SVGElement = /** @class */ (function () {
  8533. function SVGElement() {
  8534. /* *
  8535. *
  8536. * Properties
  8537. *
  8538. * */
  8539. this.element = void 0;
  8540. this.onEvents = {};
  8541. this.opacity = 1; // Default base for animation
  8542. this.renderer = void 0;
  8543. this.SVG_NS = SVG_NS;
  8544. // Custom attributes used for symbols, these should be filtered out when
  8545. // setting SVGElement attributes (#9375).
  8546. this.symbolCustomAttribs = [
  8547. 'x',
  8548. 'y',
  8549. 'width',
  8550. 'height',
  8551. 'r',
  8552. 'start',
  8553. 'end',
  8554. 'innerR',
  8555. 'anchorX',
  8556. 'anchorY',
  8557. 'rounded'
  8558. ];
  8559. }
  8560. // @todo public zIndex?: number;
  8561. /* *
  8562. *
  8563. * Functions
  8564. *
  8565. * */
  8566. /**
  8567. * Get the current value of an attribute or pseudo attribute,
  8568. * used mainly for animation. Called internally from
  8569. * the {@link Highcharts.SVGRenderer#attr} function.
  8570. *
  8571. * @private
  8572. * @function Highcharts.SVGElement#_defaultGetter
  8573. *
  8574. * @param {string} key
  8575. * Property key.
  8576. *
  8577. * @return {number|string}
  8578. * Property value.
  8579. */
  8580. SVGElement.prototype._defaultGetter = function (key) {
  8581. var ret = pick(this[key + 'Value'], // align getter
  8582. this[key],
  8583. this.element ? this.element.getAttribute(key) : null, 0);
  8584. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  8585. ret = parseFloat(ret);
  8586. }
  8587. return ret;
  8588. };
  8589. /**
  8590. * @private
  8591. * @function Highcharts.SVGElement#_defaultSetter
  8592. *
  8593. * @param {string} value
  8594. *
  8595. * @param {string} key
  8596. *
  8597. * @param {Highcharts.SVGDOMElement} element
  8598. *
  8599. * @return {void}
  8600. */
  8601. SVGElement.prototype._defaultSetter = function (value, key, element) {
  8602. element.setAttribute(key, value);
  8603. };
  8604. /**
  8605. * Add the element to the DOM. All elements must be added this way.
  8606. *
  8607. * @sample highcharts/members/renderer-g
  8608. * Elements added to a group
  8609. *
  8610. * @function Highcharts.SVGElement#add
  8611. *
  8612. * @param {Highcharts.SVGElement} [parent]
  8613. * The parent item to add it to. If undefined, the element is added
  8614. * to the {@link Highcharts.SVGRenderer.box}.
  8615. *
  8616. * @return {Highcharts.SVGElement}
  8617. * Returns the SVGElement for chaining.
  8618. */
  8619. SVGElement.prototype.add = function (parent) {
  8620. var renderer = this.renderer,
  8621. element = this.element;
  8622. var inserted;
  8623. if (parent) {
  8624. this.parentGroup = parent;
  8625. }
  8626. // Mark as inverted
  8627. this.parentInverted = parent && parent.inverted;
  8628. // Build formatted text
  8629. if (typeof this.textStr !== 'undefined' &&
  8630. this.element.nodeName === 'text' // Not for SVGLabel instances
  8631. ) {
  8632. renderer.buildText(this);
  8633. }
  8634. // Mark as added
  8635. this.added = true;
  8636. // If we're adding to renderer root, or other elements in the group
  8637. // have a z index, we need to handle it
  8638. if (!parent || parent.handleZ || this.zIndex) {
  8639. inserted = this.zIndexSetter();
  8640. }
  8641. // If zIndex is not handled, append at the end
  8642. if (!inserted) {
  8643. (parent ?
  8644. parent.element :
  8645. renderer.box).appendChild(element);
  8646. }
  8647. // fire an event for internal hooks
  8648. if (this.onAdd) {
  8649. this.onAdd();
  8650. }
  8651. return this;
  8652. };
  8653. /**
  8654. * Add a class name to an element.
  8655. *
  8656. * @function Highcharts.SVGElement#addClass
  8657. *
  8658. * @param {string} className
  8659. * The new class name to add.
  8660. *
  8661. * @param {boolean} [replace=false]
  8662. * When true, the existing class name(s) will be overwritten with the new
  8663. * one. When false, the new one is added.
  8664. *
  8665. * @return {Highcharts.SVGElement}
  8666. * Return the SVG element for chainability.
  8667. */
  8668. SVGElement.prototype.addClass = function (className, replace) {
  8669. var currentClassName = replace ? '' : (this.attr('class') || '');
  8670. // Trim the string and remove duplicates
  8671. className = (className || '')
  8672. .split(/ /g)
  8673. .reduce(function (newClassName, name) {
  8674. if (currentClassName.indexOf(name) === -1) {
  8675. newClassName.push(name);
  8676. }
  8677. return newClassName;
  8678. }, (currentClassName ?
  8679. [currentClassName] :
  8680. []))
  8681. .join(' ');
  8682. if (className !== currentClassName) {
  8683. this.attr('class', className);
  8684. }
  8685. return this;
  8686. };
  8687. /**
  8688. * This method is executed in the end of `attr()`, after setting all
  8689. * attributes in the hash. In can be used to efficiently consolidate
  8690. * multiple attributes in one SVG property -- e.g., translate, rotate and
  8691. * scale are merged in one "transform" attribute in the SVG node.
  8692. *
  8693. * @private
  8694. * @function Highcharts.SVGElement#afterSetters
  8695. */
  8696. SVGElement.prototype.afterSetters = function () {
  8697. // Update transform. Do this outside the loop to prevent redundant
  8698. // updating for batch setting of attributes.
  8699. if (this.doTransform) {
  8700. this.updateTransform();
  8701. this.doTransform = false;
  8702. }
  8703. };
  8704. /**
  8705. * Align the element relative to the chart or another box.
  8706. *
  8707. * @function Highcharts.SVGElement#align
  8708. *
  8709. * @param {Highcharts.AlignObject} [alignOptions]
  8710. * The alignment options. The function can be called without this
  8711. * parameter in order to re-align an element after the box has been
  8712. * updated.
  8713. *
  8714. * @param {boolean} [alignByTranslate]
  8715. * Align element by translation.
  8716. *
  8717. * @param {string|Highcharts.BBoxObject} [box]
  8718. * The box to align to, needs a width and height. When the box is a
  8719. * string, it refers to an object in the Renderer. For example, when
  8720. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  8721. * holds `width`, `height`, `x` and `y` properties.
  8722. *
  8723. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  8724. */
  8725. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  8726. var attribs = {},
  8727. renderer = this.renderer,
  8728. alignedObjects = renderer.alignedObjects;
  8729. var x,
  8730. y,
  8731. alignTo,
  8732. alignFactor,
  8733. vAlignFactor;
  8734. // First call on instanciate
  8735. if (alignOptions) {
  8736. this.alignOptions = alignOptions;
  8737. this.alignByTranslate = alignByTranslate;
  8738. if (!box || isString(box)) {
  8739. this.alignTo = alignTo = box || 'renderer';
  8740. // prevent duplicates, like legendGroup after resize
  8741. erase(alignedObjects, this);
  8742. alignedObjects.push(this);
  8743. box = void 0; // reassign it below
  8744. }
  8745. // When called on resize, no arguments are supplied
  8746. }
  8747. else {
  8748. alignOptions = this.alignOptions;
  8749. alignByTranslate = this.alignByTranslate;
  8750. alignTo = this.alignTo;
  8751. }
  8752. box = pick(box, renderer[alignTo], alignTo === 'scrollablePlotBox' ? renderer.plotBox : void 0, renderer);
  8753. // Assign variables
  8754. var align = alignOptions.align,
  8755. vAlign = alignOptions.verticalAlign;
  8756. // default: left align
  8757. x = (box.x || 0) + (alignOptions.x || 0);
  8758. // default: top align
  8759. y = (box.y || 0) + (alignOptions.y || 0);
  8760. // Align
  8761. if (align === 'right') {
  8762. alignFactor = 1;
  8763. }
  8764. else if (align === 'center') {
  8765. alignFactor = 2;
  8766. }
  8767. if (alignFactor) {
  8768. x += (box.width - (alignOptions.width || 0)) /
  8769. alignFactor;
  8770. }
  8771. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  8772. // Vertical align
  8773. if (vAlign === 'bottom') {
  8774. vAlignFactor = 1;
  8775. }
  8776. else if (vAlign === 'middle') {
  8777. vAlignFactor = 2;
  8778. }
  8779. if (vAlignFactor) {
  8780. y += (box.height - (alignOptions.height || 0)) /
  8781. vAlignFactor;
  8782. }
  8783. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  8784. // Animate only if already placed
  8785. this[this.placed ? 'animate' : 'attr'](attribs);
  8786. this.placed = true;
  8787. this.alignAttr = attribs;
  8788. return this;
  8789. };
  8790. /**
  8791. * @private
  8792. * @function Highcharts.SVGElement#alignSetter
  8793. * @param {"left"|"center"|"right"} value
  8794. */
  8795. SVGElement.prototype.alignSetter = function (value) {
  8796. var convert = {
  8797. left: 'start',
  8798. center: 'middle',
  8799. right: 'end'
  8800. };
  8801. if (convert[value]) {
  8802. this.alignValue = value;
  8803. this.element.setAttribute('text-anchor', convert[value]);
  8804. }
  8805. };
  8806. /**
  8807. * Animate to given attributes or CSS properties.
  8808. *
  8809. * @sample highcharts/members/element-on/
  8810. * Setting some attributes by animation
  8811. *
  8812. * @function Highcharts.SVGElement#animate
  8813. *
  8814. * @param {Highcharts.SVGAttributes} params
  8815. * SVG attributes or CSS to animate.
  8816. *
  8817. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  8818. * Animation options.
  8819. *
  8820. * @param {Function} [complete]
  8821. * Function to perform at the end of animation.
  8822. *
  8823. * @return {Highcharts.SVGElement}
  8824. * Returns the SVGElement for chaining.
  8825. */
  8826. SVGElement.prototype.animate = function (params, options, complete) {
  8827. var _this = this;
  8828. var animOptions = animObject(pick(options,
  8829. this.renderer.globalAnimation,
  8830. true)),
  8831. deferTime = animOptions.defer;
  8832. // When the page is hidden save resources in the background by not
  8833. // running animation at all (#9749).
  8834. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  8835. animOptions.duration = 0;
  8836. }
  8837. if (animOptions.duration !== 0) {
  8838. // allows using a callback with the global animation without
  8839. // overwriting it
  8840. if (complete) {
  8841. animOptions.complete = complete;
  8842. }
  8843. // If defer option is defined delay the animation #12901
  8844. syncTimeout(function () {
  8845. if (_this.element) {
  8846. animate(_this, params, animOptions);
  8847. }
  8848. }, deferTime);
  8849. }
  8850. else {
  8851. this.attr(params, void 0, complete);
  8852. // Call the end step synchronously
  8853. objectEach(params, function (val, prop) {
  8854. if (animOptions.step) {
  8855. animOptions.step.call(this, val, { prop: prop, pos: 1, elem: this });
  8856. }
  8857. }, this);
  8858. }
  8859. return this;
  8860. };
  8861. /**
  8862. * Apply a text outline through a custom CSS property, by copying the text
  8863. * element and apply stroke to the copy. Used internally. Contrast checks at
  8864. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  8865. *
  8866. * @example
  8867. * // Specific color
  8868. * text.css({
  8869. * textOutline: '1px black'
  8870. * });
  8871. * // Automatic contrast
  8872. * text.css({
  8873. * color: '#000000', // black text
  8874. * textOutline: '1px contrast' // => white outline
  8875. * });
  8876. *
  8877. * @private
  8878. * @function Highcharts.SVGElement#applyTextOutline
  8879. *
  8880. * @param {string} textOutline
  8881. * A custom CSS `text-outline` setting, defined by `width color`.
  8882. */
  8883. SVGElement.prototype.applyTextOutline = function (textOutline) {
  8884. var elem = this.element,
  8885. hasContrast = textOutline.indexOf('contrast') !== -1,
  8886. styles = {};
  8887. // When the text shadow is set to contrast, use dark stroke for light
  8888. // text and vice versa.
  8889. if (hasContrast) {
  8890. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  8891. }
  8892. // Extract the stroke width and color
  8893. var parts = textOutline.split(' ');
  8894. var color = parts[parts.length - 1];
  8895. var strokeWidth = parts[0];
  8896. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  8897. this.fakeTS = true; // Fake text shadow
  8898. // In order to get the right y position of the clone,
  8899. // copy over the y setter
  8900. this.ySetter = this.xSetter;
  8901. // Since the stroke is applied on center of the actual outline, we
  8902. // need to double it to get the correct stroke-width outside the
  8903. // glyphs.
  8904. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  8905. return (2 * Number(digit)) + unit;
  8906. });
  8907. // Remove shadows from previous runs.
  8908. this.removeTextOutline();
  8909. var outline_1 = doc.createElementNS(SVG_NS, 'tspan');
  8910. attr(outline_1, {
  8911. 'class': 'highcharts-text-outline',
  8912. fill: color,
  8913. stroke: color,
  8914. 'stroke-width': strokeWidth,
  8915. 'stroke-linejoin': 'round'
  8916. });
  8917. // For each of the tspans and text nodes, create a copy in the
  8918. // outline.
  8919. [].forEach.call(elem.childNodes, function (childNode) {
  8920. var clone = childNode.cloneNode(true);
  8921. if (clone.removeAttribute) {
  8922. ['fill', 'stroke', 'stroke-width', 'stroke'].forEach(function (prop) { return clone.removeAttribute(prop); });
  8923. }
  8924. outline_1.appendChild(clone);
  8925. });
  8926. // Insert an absolutely positioned break before the original text
  8927. // to keep it in place
  8928. var br_1 = doc.createElementNS(SVG_NS, 'tspan');
  8929. br_1.textContent = '\u200B';
  8930. // Copy x and y if not null
  8931. ['x', 'y'].forEach(function (key) {
  8932. var value = elem.getAttribute(key);
  8933. if (value) {
  8934. br_1.setAttribute(key, value);
  8935. }
  8936. });
  8937. // Insert the outline
  8938. outline_1.appendChild(br_1);
  8939. elem.insertBefore(outline_1, elem.firstChild);
  8940. }
  8941. };
  8942. /**
  8943. * @function Highcharts.SVGElement#attr
  8944. * @param {string} key
  8945. * @return {number|string}
  8946. */ /**
  8947. * Apply native and custom attributes to the SVG elements.
  8948. *
  8949. * In order to set the rotation center for rotation, set x and y to 0 and
  8950. * use `translateX` and `translateY` attributes to position the element
  8951. * instead.
  8952. *
  8953. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  8954. * `stroke-width`.
  8955. *
  8956. * @sample highcharts/members/renderer-rect/
  8957. * Setting some attributes
  8958. *
  8959. * @example
  8960. * // Set multiple attributes
  8961. * element.attr({
  8962. * stroke: 'red',
  8963. * fill: 'blue',
  8964. * x: 10,
  8965. * y: 10
  8966. * });
  8967. *
  8968. * // Set a single attribute
  8969. * element.attr('stroke', 'red');
  8970. *
  8971. * // Get an attribute
  8972. * element.attr('stroke'); // => 'red'
  8973. *
  8974. * @function Highcharts.SVGElement#attr
  8975. *
  8976. * @param {string|Highcharts.SVGAttributes} [hash]
  8977. * The native and custom SVG attributes.
  8978. *
  8979. * @param {number|string|Highcharts.SVGPathArray} [val]
  8980. * If the type of the first argument is `string`, the second can be a
  8981. * value, which will serve as a single attribute setter. If the first
  8982. * argument is a string and the second is undefined, the function
  8983. * serves as a getter and the current value of the property is
  8984. * returned.
  8985. *
  8986. * @param {Function} [complete]
  8987. * A callback function to execute after setting the attributes. This
  8988. * makes the function compliant and interchangeable with the
  8989. * {@link SVGElement#animate} function.
  8990. *
  8991. * @param {boolean} [continueAnimation=true]
  8992. * Used internally when `.attr` is called as part of an animation
  8993. * step. Otherwise, calling `.attr` for an attribute will stop
  8994. * animation for that attribute.
  8995. *
  8996. * @return {Highcharts.SVGElement}
  8997. * If used as a setter, it returns the current
  8998. * {@link Highcharts.SVGElement} so the calls can be chained. If
  8999. * used as a getter, the current value of the attribute is returned.
  9000. */
  9001. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  9002. var element = this.element,
  9003. symbolCustomAttribs = this.symbolCustomAttribs;
  9004. var key,
  9005. hasSetSymbolSize,
  9006. ret = this,
  9007. skipAttr,
  9008. setter;
  9009. // single key-value pair
  9010. if (typeof hash === 'string' && typeof val !== 'undefined') {
  9011. key = hash;
  9012. hash = {};
  9013. hash[key] = val;
  9014. }
  9015. // used as a getter: first argument is a string, second is undefined
  9016. if (typeof hash === 'string') {
  9017. ret = (this[hash + 'Getter'] ||
  9018. this._defaultGetter).call(this, hash, element);
  9019. // setter
  9020. }
  9021. else {
  9022. objectEach(hash, function eachAttribute(val, key) {
  9023. skipAttr = false;
  9024. // Unless .attr is from the animator update, stop current
  9025. // running animation of this property
  9026. if (!continueAnimation) {
  9027. stop(this, key);
  9028. }
  9029. // Special handling of symbol attributes
  9030. if (this.symbolName &&
  9031. symbolCustomAttribs.indexOf(key) !== -1) {
  9032. if (!hasSetSymbolSize) {
  9033. this.symbolAttr(hash);
  9034. hasSetSymbolSize = true;
  9035. }
  9036. skipAttr = true;
  9037. }
  9038. if (this.rotation && (key === 'x' || key === 'y')) {
  9039. this.doTransform = true;
  9040. }
  9041. if (!skipAttr) {
  9042. setter = (this[key + 'Setter'] ||
  9043. this._defaultSetter);
  9044. setter.call(this, val, key, element);
  9045. // Let the shadow follow the main element
  9046. if (!this.styledMode &&
  9047. this.shadows &&
  9048. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  9049. this.updateShadows(key, val, setter);
  9050. }
  9051. }
  9052. }, this);
  9053. this.afterSetters();
  9054. }
  9055. // In accordance with animate, run a complete callback
  9056. if (complete) {
  9057. complete.call(this);
  9058. }
  9059. return ret;
  9060. };
  9061. /**
  9062. * Apply a clipping rectangle to this element.
  9063. *
  9064. * @function Highcharts.SVGElement#clip
  9065. *
  9066. * @param {Highcharts.ClipRectElement} [clipRect]
  9067. * The clipping rectangle. If skipped, the current clip is removed.
  9068. *
  9069. * @return {Highcharts.SVGElement}
  9070. * Returns the SVG element to allow chaining.
  9071. */
  9072. SVGElement.prototype.clip = function (clipRect) {
  9073. return this.attr('clip-path', clipRect ?
  9074. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  9075. 'none');
  9076. };
  9077. /**
  9078. * Calculate the coordinates needed for drawing a rectangle crisply and
  9079. * return the calculated attributes.
  9080. *
  9081. * @function Highcharts.SVGElement#crisp
  9082. *
  9083. * @param {Highcharts.RectangleObject} rect
  9084. * Rectangle to crisp.
  9085. *
  9086. * @param {number} [strokeWidth]
  9087. * The stroke width to consider when computing crisp positioning. It can
  9088. * also be set directly on the rect parameter.
  9089. *
  9090. * @return {Highcharts.RectangleObject}
  9091. * The modified rectangle arguments.
  9092. */
  9093. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  9094. var wrapper = this;
  9095. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  9096. // Math.round because strokeWidth can sometimes have roundoff errors
  9097. var normalizer = Math.round(strokeWidth) % 2 / 2;
  9098. // normalize for crisp edges
  9099. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  9100. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  9101. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  9102. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  9103. if (defined(rect.strokeWidth)) {
  9104. rect.strokeWidth = strokeWidth;
  9105. }
  9106. return rect;
  9107. };
  9108. /**
  9109. * Build and apply an SVG gradient out of a common JavaScript configuration
  9110. * object. This function is called from the attribute setters. An event
  9111. * hook is added for supporting other complex color types.
  9112. *
  9113. * @private
  9114. * @function Highcharts.SVGElement#complexColor
  9115. *
  9116. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  9117. * The gradient or pattern options structure.
  9118. *
  9119. * @param {string} prop
  9120. * The property to apply, can either be `fill` or `stroke`.
  9121. *
  9122. * @param {Highcharts.SVGDOMElement} elem
  9123. * SVG element to apply the gradient on.
  9124. */
  9125. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  9126. var renderer = this.renderer;
  9127. var colorObject,
  9128. gradName,
  9129. gradAttr,
  9130. radAttr,
  9131. gradients,
  9132. stops,
  9133. stopColor,
  9134. stopOpacity,
  9135. radialReference,
  9136. id,
  9137. key = [],
  9138. value;
  9139. fireEvent(this.renderer, 'complexColor', {
  9140. args: arguments
  9141. }, function () {
  9142. // Apply linear or radial gradients
  9143. if (colorOptions.radialGradient) {
  9144. gradName = 'radialGradient';
  9145. }
  9146. else if (colorOptions.linearGradient) {
  9147. gradName = 'linearGradient';
  9148. }
  9149. if (gradName) {
  9150. gradAttr = colorOptions[gradName];
  9151. gradients = renderer.gradients;
  9152. stops = colorOptions.stops;
  9153. radialReference = elem.radialReference;
  9154. // Keep < 2.2 kompatibility
  9155. if (isArray(gradAttr)) {
  9156. colorOptions[gradName] = gradAttr = {
  9157. x1: gradAttr[0],
  9158. y1: gradAttr[1],
  9159. x2: gradAttr[2],
  9160. y2: gradAttr[3],
  9161. gradientUnits: 'userSpaceOnUse'
  9162. };
  9163. }
  9164. // Correct the radial gradient for the radial reference system
  9165. if (gradName === 'radialGradient' &&
  9166. radialReference &&
  9167. !defined(gradAttr.gradientUnits)) {
  9168. // Save the radial attributes for updating
  9169. radAttr = gradAttr;
  9170. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  9171. }
  9172. // Build the unique key to detect whether we need to create a
  9173. // new element (#1282)
  9174. objectEach(gradAttr, function (value, n) {
  9175. if (n !== 'id') {
  9176. key.push(n, value);
  9177. }
  9178. });
  9179. objectEach(stops, function (val) {
  9180. key.push(val);
  9181. });
  9182. key = key.join(',');
  9183. // Check if a gradient object with the same config object is
  9184. // created within this renderer
  9185. if (gradients[key]) {
  9186. id = gradients[key].attr('id');
  9187. }
  9188. else {
  9189. // Set the id and create the element
  9190. gradAttr.id = id = uniqueKey();
  9191. var gradientObject_1 = gradients[key] =
  9192. renderer.createElement(gradName)
  9193. .attr(gradAttr)
  9194. .add(renderer.defs);
  9195. gradientObject_1.radAttr = radAttr;
  9196. // The gradient needs to keep a list of stops to be able to
  9197. // destroy them
  9198. gradientObject_1.stops = [];
  9199. stops.forEach(function (stop) {
  9200. if (stop[1].indexOf('rgba') === 0) {
  9201. colorObject = Color.parse(stop[1]);
  9202. stopColor = colorObject.get('rgb');
  9203. stopOpacity = colorObject.get('a');
  9204. }
  9205. else {
  9206. stopColor = stop[1];
  9207. stopOpacity = 1;
  9208. }
  9209. var stopObject = renderer.createElement('stop').attr({
  9210. offset: stop[0],
  9211. 'stop-color': stopColor,
  9212. 'stop-opacity': stopOpacity
  9213. }).add(gradientObject_1);
  9214. // Add the stop element to the gradient
  9215. gradientObject_1.stops.push(stopObject);
  9216. });
  9217. }
  9218. // Set the reference to the gradient object
  9219. value = 'url(' + renderer.url + '#' + id + ')';
  9220. elem.setAttribute(prop, value);
  9221. elem.gradient = key;
  9222. // Allow the color to be concatenated into tooltips formatters
  9223. // etc. (#2995)
  9224. colorOptions.toString = function () {
  9225. return value;
  9226. };
  9227. }
  9228. });
  9229. };
  9230. /**
  9231. * Set styles for the element. In addition to CSS styles supported by
  9232. * native SVG and HTML elements, there are also some custom made for
  9233. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  9234. * elements.
  9235. *
  9236. * @sample highcharts/members/renderer-text-on-chart/
  9237. * Styled text
  9238. *
  9239. * @function Highcharts.SVGElement#css
  9240. *
  9241. * @param {Highcharts.CSSObject} styles
  9242. * The new CSS styles.
  9243. *
  9244. * @return {Highcharts.SVGElement}
  9245. * Return the SVG element for chaining.
  9246. */
  9247. SVGElement.prototype.css = function (styles) {
  9248. var oldStyles = this.styles, newStyles = {}, elem = this.element,
  9249. // These CSS properties are interpreted internally by the SVG
  9250. // renderer, but are not supported by SVG and should not be added to
  9251. // the DOM. In styled mode, no CSS should find its way to the DOM
  9252. // whatsoever (#6173, #6474).
  9253. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  9254. var textWidth,
  9255. serializedCss = '',
  9256. hyphenate,
  9257. hasNew = !oldStyles;
  9258. // convert legacy
  9259. if (styles && styles.color) {
  9260. styles.fill = styles.color;
  9261. }
  9262. // Filter out existing styles to increase performance (#2640)
  9263. if (oldStyles) {
  9264. objectEach(styles, function (style, n) {
  9265. if (oldStyles && oldStyles[n] !== style) {
  9266. newStyles[n] = style;
  9267. hasNew = true;
  9268. }
  9269. });
  9270. }
  9271. if (hasNew) {
  9272. // Merge the new styles with the old ones
  9273. if (oldStyles) {
  9274. styles = extend(oldStyles, newStyles);
  9275. }
  9276. // Get the text width from style
  9277. if (styles) {
  9278. // Previously set, unset it (#8234)
  9279. if (styles.width === null || styles.width === 'auto') {
  9280. delete this.textWidth;
  9281. // Apply new
  9282. }
  9283. else if (elem.nodeName.toLowerCase() === 'text' &&
  9284. styles.width) {
  9285. textWidth = this.textWidth = pInt(styles.width);
  9286. }
  9287. }
  9288. // store object
  9289. this.styles = styles;
  9290. if (textWidth && (!svg && this.renderer.forExport)) {
  9291. delete styles.width;
  9292. }
  9293. // Serialize and set style attribute
  9294. if (elem.namespaceURI === this.SVG_NS) { // #7633
  9295. hyphenate = function (a, b) {
  9296. return '-' + b.toLowerCase();
  9297. };
  9298. objectEach(styles, function (style, n) {
  9299. if (svgPseudoProps.indexOf(n) === -1) {
  9300. serializedCss +=
  9301. n.replace(/([A-Z])/g, hyphenate) + ':' +
  9302. style + ';';
  9303. }
  9304. });
  9305. if (serializedCss) {
  9306. attr(elem, 'style', serializedCss); // #1881
  9307. }
  9308. }
  9309. else {
  9310. css(elem, styles);
  9311. }
  9312. if (this.added) {
  9313. // Rebuild text after added. Cache mechanisms in the buildText
  9314. // will prevent building if there are no significant changes.
  9315. if (this.element.nodeName === 'text') {
  9316. this.renderer.buildText(this);
  9317. }
  9318. // Apply text outline after added
  9319. if (styles && styles.textOutline) {
  9320. this.applyTextOutline(styles.textOutline);
  9321. }
  9322. }
  9323. }
  9324. return this;
  9325. };
  9326. /**
  9327. * @private
  9328. * @function Highcharts.SVGElement#dashstyleSetter
  9329. * @param {string} value
  9330. */
  9331. SVGElement.prototype.dashstyleSetter = function (value) {
  9332. var i,
  9333. strokeWidth = this['stroke-width'];
  9334. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  9335. // strokeWidth function, we should be able to use that instead.
  9336. if (strokeWidth === 'inherit') {
  9337. strokeWidth = 1;
  9338. }
  9339. value = value && value.toLowerCase();
  9340. if (value) {
  9341. var v = value
  9342. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  9343. .replace('shortdashdot', '3,1,1,1')
  9344. .replace('shortdot', '1,1,')
  9345. .replace('shortdash', '3,1,')
  9346. .replace('longdash', '8,3,')
  9347. .replace(/dot/g, '1,3,')
  9348. .replace('dash', '4,3,')
  9349. .replace(/,$/, '')
  9350. .split(','); // ending comma
  9351. i = v.length;
  9352. while (i--) {
  9353. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  9354. }
  9355. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  9356. this.element.setAttribute('stroke-dasharray', value);
  9357. }
  9358. };
  9359. /**
  9360. * Destroy the element and element wrapper and clear up the DOM and event
  9361. * hooks.
  9362. *
  9363. * @function Highcharts.SVGElement#destroy
  9364. */
  9365. SVGElement.prototype.destroy = function () {
  9366. var wrapper = this,
  9367. element = wrapper.element || {},
  9368. renderer = wrapper.renderer,
  9369. ownerSVGElement = element.ownerSVGElement;
  9370. var parentToClean = (renderer.isSVG &&
  9371. element.nodeName === 'SPAN' &&
  9372. wrapper.parentGroup ||
  9373. void 0),
  9374. grandParent,
  9375. i;
  9376. // remove events
  9377. element.onclick = element.onmouseout = element.onmouseover =
  9378. element.onmousemove = element.point = null;
  9379. stop(wrapper); // stop running animations
  9380. if (wrapper.clipPath && ownerSVGElement) {
  9381. var clipPath_1 = wrapper.clipPath;
  9382. // Look for existing references to this clipPath and remove them
  9383. // before destroying the element (#6196).
  9384. // The upper case version is for Edge
  9385. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  9386. if (el.getAttribute('clip-path').indexOf(clipPath_1.element.id) > -1) {
  9387. el.removeAttribute('clip-path');
  9388. }
  9389. });
  9390. wrapper.clipPath = clipPath_1.destroy();
  9391. }
  9392. // Destroy stops in case this is a gradient object @todo old code?
  9393. if (wrapper.stops) {
  9394. for (i = 0; i < wrapper.stops.length; i++) {
  9395. wrapper.stops[i].destroy();
  9396. }
  9397. wrapper.stops.length = 0;
  9398. wrapper.stops = void 0;
  9399. }
  9400. // remove element
  9401. wrapper.safeRemoveChild(element);
  9402. if (!renderer.styledMode) {
  9403. wrapper.destroyShadows();
  9404. }
  9405. // In case of useHTML, clean up empty containers emulating SVG groups
  9406. // (#1960, #2393, #2697).
  9407. while (parentToClean &&
  9408. parentToClean.div &&
  9409. parentToClean.div.childNodes.length === 0) {
  9410. grandParent = parentToClean.parentGroup;
  9411. wrapper.safeRemoveChild(parentToClean.div);
  9412. delete parentToClean.div;
  9413. parentToClean = grandParent;
  9414. }
  9415. // remove from alignObjects
  9416. if (wrapper.alignTo) {
  9417. erase(renderer.alignedObjects, wrapper);
  9418. }
  9419. objectEach(wrapper, function (val, key) {
  9420. // Destroy child elements of a group
  9421. if (wrapper[key] &&
  9422. wrapper[key].parentGroup === wrapper &&
  9423. wrapper[key].destroy) {
  9424. wrapper[key].destroy();
  9425. }
  9426. // Delete all properties
  9427. delete wrapper[key];
  9428. });
  9429. return;
  9430. };
  9431. /**
  9432. * Destroy shadows on the element.
  9433. *
  9434. * @private
  9435. * @function Highcharts.SVGElement#destroyShadows
  9436. *
  9437. * @return {void}
  9438. */
  9439. SVGElement.prototype.destroyShadows = function () {
  9440. (this.shadows || []).forEach(function (shadow) {
  9441. this.safeRemoveChild(shadow);
  9442. }, this);
  9443. this.shadows = void 0;
  9444. };
  9445. /**
  9446. * @private
  9447. */
  9448. SVGElement.prototype.destroyTextPath = function (elem, path) {
  9449. var textElement = elem.getElementsByTagName('text')[0];
  9450. var childNodes;
  9451. if (textElement) {
  9452. // Remove textPath attributes
  9453. textElement.removeAttribute('dx');
  9454. textElement.removeAttribute('dy');
  9455. // Remove ID's:
  9456. path.element.setAttribute('id', '');
  9457. // Check if textElement includes textPath,
  9458. if (this.textPathWrapper &&
  9459. textElement.getElementsByTagName('textPath').length) {
  9460. // Move nodes to <text>
  9461. childNodes = this.textPathWrapper.element.childNodes;
  9462. // Now move all <tspan>'s and text nodes to the <textPath> node
  9463. while (childNodes.length) {
  9464. textElement.appendChild(childNodes[0]);
  9465. }
  9466. // Remove <textPath> from the DOM
  9467. textElement.removeChild(this.textPathWrapper.element);
  9468. }
  9469. }
  9470. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  9471. // Remove textPath attributes from elem
  9472. // to get correct text-outline position
  9473. elem.removeAttribute('dx');
  9474. elem.removeAttribute('dy');
  9475. }
  9476. if (this.textPathWrapper) {
  9477. // Set textPathWrapper to undefined and destroy it
  9478. this.textPathWrapper = this.textPathWrapper.destroy();
  9479. }
  9480. };
  9481. /**
  9482. * @private
  9483. * @function Highcharts.SVGElement#dSettter
  9484. * @param {number|string|Highcharts.SVGPathArray} value
  9485. * @param {string} key
  9486. * @param {Highcharts.SVGDOMElement} element
  9487. */
  9488. SVGElement.prototype.dSetter = function (value, key, element) {
  9489. if (isArray(value)) {
  9490. // Backwards compatibility, convert one-dimensional array into an
  9491. // array of segments
  9492. if (typeof value[0] === 'string') {
  9493. value = this.renderer.pathToSegments(value);
  9494. }
  9495. this.pathArray = value;
  9496. value = value.reduce(function (acc, seg, i) {
  9497. if (!seg || !seg.join) {
  9498. return (seg || '').toString();
  9499. }
  9500. return (i ? acc + ' ' : '') + seg.join(' ');
  9501. }, '');
  9502. }
  9503. if (/(NaN| {2}|^$)/.test(value)) {
  9504. value = 'M 0 0';
  9505. }
  9506. // Check for cache before resetting. Resetting causes disturbance in the
  9507. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  9508. // possible performance gain.
  9509. if (this[key] !== value) {
  9510. element.setAttribute(key, value);
  9511. this[key] = value;
  9512. }
  9513. };
  9514. /**
  9515. * Fade out an element by animating its opacity down to 0, and hide it on
  9516. * complete. Used internally for the tooltip.
  9517. *
  9518. * @function Highcharts.SVGElement#fadeOut
  9519. *
  9520. * @param {number} [duration=150]
  9521. * The fade duration in milliseconds.
  9522. */
  9523. SVGElement.prototype.fadeOut = function (duration) {
  9524. var elemWrapper = this;
  9525. elemWrapper.animate({
  9526. opacity: 0
  9527. }, {
  9528. duration: pick(duration, 150),
  9529. complete: function () {
  9530. // #3088, assuming we're only using this for tooltips
  9531. elemWrapper.attr({ y: -9999 }).hide();
  9532. }
  9533. });
  9534. };
  9535. /**
  9536. * @private
  9537. * @function Highcharts.SVGElement#fillSetter
  9538. * @param {Highcharts.ColorType} value
  9539. * @param {string} key
  9540. * @param {Highcharts.SVGDOMElement} element
  9541. */
  9542. SVGElement.prototype.fillSetter = function (value, key, element) {
  9543. if (typeof value === 'string') {
  9544. element.setAttribute(key, value);
  9545. }
  9546. else if (value) {
  9547. this.complexColor(value, key, element);
  9548. }
  9549. };
  9550. /**
  9551. * Get the bounding box (width, height, x and y) for the element. Generally
  9552. * used to get rendered text size. Since this is called a lot in charts,
  9553. * the results are cached based on text properties, in order to save DOM
  9554. * traffic. The returned bounding box includes the rotation, so for example
  9555. * a single text line of rotation 90 will report a greater height, and a
  9556. * width corresponding to the line-height.
  9557. *
  9558. * @sample highcharts/members/renderer-on-chart/
  9559. * Draw a rectangle based on a text's bounding box
  9560. *
  9561. * @function Highcharts.SVGElement#getBBox
  9562. *
  9563. * @param {boolean} [reload]
  9564. * Skip the cache and get the updated DOM bouding box.
  9565. *
  9566. * @param {number} [rot]
  9567. * Override the element's rotation. This is internally used on axis
  9568. * labels with a value of 0 to find out what the bounding box would
  9569. * be have been if it were not rotated.
  9570. *
  9571. * @return {Highcharts.BBoxObject}
  9572. * The bounding box with `x`, `y`, `width` and `height` properties.
  9573. */
  9574. SVGElement.prototype.getBBox = function (reload, rot) {
  9575. var wrapper = this,
  9576. renderer = wrapper.renderer,
  9577. element = wrapper.element,
  9578. styles = wrapper.styles,
  9579. textStr = wrapper.textStr,
  9580. cache = renderer.cache,
  9581. cacheKeys = renderer.cacheKeys,
  9582. isSVG = element.namespaceURI === wrapper.SVG_NS,
  9583. rotation = pick(rot,
  9584. wrapper.rotation, 0),
  9585. fontSize = renderer.styledMode ? (element &&
  9586. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  9587. var bBox, // = wrapper.bBox,
  9588. width,
  9589. height,
  9590. toggleTextShadowShim,
  9591. cacheKey;
  9592. // Avoid undefined and null (#7316)
  9593. if (defined(textStr)) {
  9594. cacheKey = textStr.toString();
  9595. // Since numbers are monospaced, and numerical labels appear a lot
  9596. // in a chart, we assume that a label of n characters has the same
  9597. // bounding box as others of the same length. Unless there is inner
  9598. // HTML in the label. In that case, leave the numbers as is (#5899).
  9599. if (cacheKey.indexOf('<') === -1) {
  9600. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  9601. }
  9602. // Properties that affect bounding box
  9603. cacheKey += [
  9604. '',
  9605. rotation,
  9606. fontSize,
  9607. wrapper.textWidth,
  9608. styles && styles.textOverflow,
  9609. styles && styles.fontWeight // #12163
  9610. ].join(',');
  9611. }
  9612. if (cacheKey && !reload) {
  9613. bBox = cache[cacheKey];
  9614. }
  9615. // No cache found
  9616. if (!bBox) {
  9617. // SVG elements
  9618. if (isSVG || renderer.forExport) {
  9619. try { // Fails in Firefox if the container has display: none.
  9620. // When the text shadow shim is used, we need to hide the
  9621. // fake shadows to get the correct bounding box (#3872)
  9622. toggleTextShadowShim = this.fakeTS && function (display) {
  9623. var outline = element.querySelector('.highcharts-text-outline');
  9624. if (outline) {
  9625. css(outline, { display: display });
  9626. }
  9627. };
  9628. // Workaround for #3842, Firefox reporting wrong bounding
  9629. // box for shadows
  9630. if (isFunction(toggleTextShadowShim)) {
  9631. toggleTextShadowShim('none');
  9632. }
  9633. bBox = element.getBBox ?
  9634. // SVG: use extend because IE9 is not allowed to change
  9635. // width and height in case of rotation (below)
  9636. extend({}, element.getBBox()) : {
  9637. // Legacy IE in export mode
  9638. width: element.offsetWidth,
  9639. height: element.offsetHeight
  9640. };
  9641. // #3842
  9642. if (isFunction(toggleTextShadowShim)) {
  9643. toggleTextShadowShim('');
  9644. }
  9645. }
  9646. catch (e) {
  9647. '';
  9648. }
  9649. // If the bBox is not set, the try-catch block above failed. The
  9650. // other condition is for Opera that returns a width of
  9651. // -Infinity on hidden elements.
  9652. if (!bBox || bBox.width < 0) {
  9653. bBox = { width: 0, height: 0 };
  9654. }
  9655. // VML Renderer or useHTML within SVG
  9656. }
  9657. else {
  9658. bBox = wrapper.htmlGetBBox();
  9659. }
  9660. // True SVG elements as well as HTML elements in modern browsers
  9661. // using the .useHTML option need to compensated for rotation
  9662. if (renderer.isSVG) {
  9663. width = bBox.width;
  9664. height = bBox.height;
  9665. // Workaround for wrong bounding box in IE, Edge and Chrome on
  9666. // Windows. With Highcharts' default font, IE and Edge report
  9667. // a box height of 16.899 and Chrome rounds it to 17. If this
  9668. // stands uncorrected, it results in more padding added below
  9669. // the text than above when adding a label border or background.
  9670. // Also vertical positioning is affected.
  9671. // https://jsfiddle.net/highcharts/em37nvuj/
  9672. // (#1101, #1505, #1669, #2568, #6213).
  9673. if (isSVG) {
  9674. bBox.height = height = ({
  9675. '11px,17': 14,
  9676. '13px,20': 16
  9677. }[styles &&
  9678. styles.fontSize + ',' + Math.round(height)] ||
  9679. height);
  9680. }
  9681. // Adjust for rotated text
  9682. if (rotation) {
  9683. var rad = rotation * deg2rad;
  9684. bBox.width = Math.abs(height * Math.sin(rad)) +
  9685. Math.abs(width * Math.cos(rad));
  9686. bBox.height = Math.abs(height * Math.cos(rad)) +
  9687. Math.abs(width * Math.sin(rad));
  9688. }
  9689. }
  9690. // Cache it. When loading a chart in a hidden iframe in Firefox and
  9691. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  9692. if (cacheKey && bBox.height > 0) {
  9693. // Rotate (#4681)
  9694. while (cacheKeys.length > 250) {
  9695. delete cache[cacheKeys.shift()];
  9696. }
  9697. if (!cache[cacheKey]) {
  9698. cacheKeys.push(cacheKey);
  9699. }
  9700. cache[cacheKey] = bBox;
  9701. }
  9702. }
  9703. return bBox;
  9704. };
  9705. /**
  9706. * Get the computed style. Only in styled mode.
  9707. *
  9708. * @example
  9709. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  9710. *
  9711. * @function Highcharts.SVGElement#getStyle
  9712. *
  9713. * @param {string} prop
  9714. * The property name to check for.
  9715. *
  9716. * @return {string}
  9717. * The current computed value.
  9718. */
  9719. SVGElement.prototype.getStyle = function (prop) {
  9720. return win
  9721. .getComputedStyle(this.element || this, '')
  9722. .getPropertyValue(prop);
  9723. };
  9724. /**
  9725. * Check if an element has the given class name.
  9726. *
  9727. * @function Highcharts.SVGElement#hasClass
  9728. *
  9729. * @param {string} className
  9730. * The class name to check for.
  9731. *
  9732. * @return {boolean}
  9733. * Whether the class name is found.
  9734. */
  9735. SVGElement.prototype.hasClass = function (className) {
  9736. return ('' + this.attr('class'))
  9737. .split(' ')
  9738. .indexOf(className) !== -1;
  9739. };
  9740. /**
  9741. * Hide the element, similar to setting the `visibility` attribute to
  9742. * `hidden`.
  9743. *
  9744. * @function Highcharts.SVGElement#hide
  9745. *
  9746. * @param {boolean} [hideByTranslation=false]
  9747. * The flag to determine if element should be hidden by moving out
  9748. * of the viewport. Used for example for dataLabels.
  9749. *
  9750. * @return {Highcharts.SVGElement}
  9751. * Returns the SVGElement for chaining.
  9752. */
  9753. SVGElement.prototype.hide = function (hideByTranslation) {
  9754. if (hideByTranslation) {
  9755. this.attr({ y: -9999 });
  9756. }
  9757. else {
  9758. this.attr({ visibility: 'hidden' });
  9759. }
  9760. return this;
  9761. };
  9762. /**
  9763. * @private
  9764. */
  9765. SVGElement.prototype.htmlGetBBox = function () {
  9766. return { height: 0, width: 0, x: 0, y: 0 };
  9767. };
  9768. /**
  9769. * Initialize the SVG element. This function only exists to make the
  9770. * initialization process overridable. It should not be called directly.
  9771. *
  9772. * @function Highcharts.SVGElement#init
  9773. *
  9774. * @param {Highcharts.SVGRenderer} renderer
  9775. * The SVGRenderer instance to initialize to.
  9776. *
  9777. * @param {string} nodeName
  9778. * The SVG node name.
  9779. */
  9780. SVGElement.prototype.init = function (renderer, nodeName) {
  9781. /**
  9782. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  9783. * node, but may also represent more nodes.
  9784. *
  9785. * @name Highcharts.SVGElement#element
  9786. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  9787. */
  9788. this.element = nodeName === 'span' ?
  9789. createElement(nodeName) :
  9790. doc.createElementNS(this.SVG_NS, nodeName);
  9791. /**
  9792. * The renderer that the SVGElement belongs to.
  9793. *
  9794. * @name Highcharts.SVGElement#renderer
  9795. * @type {Highcharts.SVGRenderer}
  9796. */
  9797. this.renderer = renderer;
  9798. fireEvent(this, 'afterInit');
  9799. };
  9800. /**
  9801. * Invert a group, rotate and flip. This is used internally on inverted
  9802. * charts, where the points and graphs are drawn as if not inverted, then
  9803. * the series group elements are inverted.
  9804. *
  9805. * @function Highcharts.SVGElement#invert
  9806. *
  9807. * @param {boolean} inverted
  9808. * Whether to invert or not. An inverted shape can be un-inverted by
  9809. * setting it to false.
  9810. *
  9811. * @return {Highcharts.SVGElement}
  9812. * Return the SVGElement for chaining.
  9813. */
  9814. SVGElement.prototype.invert = function (inverted) {
  9815. this.inverted = inverted;
  9816. this.updateTransform();
  9817. return this;
  9818. };
  9819. /**
  9820. * Add an event listener. This is a simple setter that replaces the
  9821. * previous event of the same type added by this function, as opposed to
  9822. * the {@link Highcharts#addEvent} function.
  9823. *
  9824. * @sample highcharts/members/element-on/
  9825. * A clickable rectangle
  9826. *
  9827. * @function Highcharts.SVGElement#on
  9828. *
  9829. * @param {string} eventType
  9830. * The event type.
  9831. *
  9832. * @param {Function} handler
  9833. * The handler callback.
  9834. *
  9835. * @return {Highcharts.SVGElement}
  9836. * The SVGElement for chaining.
  9837. */
  9838. SVGElement.prototype.on = function (eventType, handler) {
  9839. var onEvents = this.onEvents;
  9840. if (onEvents[eventType]) {
  9841. // Unbind existing event
  9842. onEvents[eventType]();
  9843. }
  9844. onEvents[eventType] = addEvent(this.element, eventType, handler);
  9845. return this;
  9846. };
  9847. /**
  9848. * @private
  9849. * @function Highcharts.SVGElement#opacitySetter
  9850. * @param {string} value
  9851. * @param {string} key
  9852. * @param {Highcharts.SVGDOMElement} element
  9853. */
  9854. SVGElement.prototype.opacitySetter = function (value, key, element) {
  9855. // Round off to avoid float errors, like tests where opacity lands on
  9856. // 9.86957e-06 instead of 0
  9857. var opacity = Number(Number(value).toFixed(3));
  9858. this.opacity = opacity;
  9859. element.setAttribute(key, opacity);
  9860. };
  9861. /**
  9862. * Remove a class name from the element.
  9863. *
  9864. * @function Highcharts.SVGElement#removeClass
  9865. *
  9866. * @param {string|RegExp} className
  9867. * The class name to remove.
  9868. *
  9869. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  9870. */
  9871. SVGElement.prototype.removeClass = function (className) {
  9872. return this.attr('class', ('' + this.attr('class'))
  9873. .replace(isString(className) ?
  9874. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  9875. className, ' ')
  9876. .replace(/ +/g, ' ')
  9877. .trim());
  9878. };
  9879. /**
  9880. *
  9881. * @private
  9882. */
  9883. SVGElement.prototype.removeTextOutline = function () {
  9884. var outline = this.element
  9885. .querySelector('tspan.highcharts-text-outline');
  9886. if (outline) {
  9887. this.safeRemoveChild(outline);
  9888. }
  9889. };
  9890. /**
  9891. * Removes an element from the DOM.
  9892. *
  9893. * @private
  9894. * @function Highcharts.SVGElement#safeRemoveChild
  9895. *
  9896. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  9897. * The DOM node to remove.
  9898. */
  9899. SVGElement.prototype.safeRemoveChild = function (element) {
  9900. var parentNode = element.parentNode;
  9901. if (parentNode) {
  9902. parentNode.removeChild(element);
  9903. }
  9904. };
  9905. /**
  9906. * Set the coordinates needed to draw a consistent radial gradient across
  9907. * a shape regardless of positioning inside the chart. Used on pie slices
  9908. * to make all the slices have the same radial reference point.
  9909. *
  9910. * @function Highcharts.SVGElement#setRadialReference
  9911. *
  9912. * @param {Array<number>} coordinates
  9913. * The center reference. The format is `[centerX, centerY, diameter]` in
  9914. * pixels.
  9915. *
  9916. * @return {Highcharts.SVGElement}
  9917. * Returns the SVGElement for chaining.
  9918. */
  9919. SVGElement.prototype.setRadialReference = function (coordinates) {
  9920. var existingGradient = (this.element.gradient &&
  9921. this.renderer.gradients[this.element.gradient]);
  9922. this.element.radialReference = coordinates;
  9923. // On redrawing objects with an existing gradient, the gradient needs
  9924. // to be repositioned (#3801)
  9925. if (existingGradient && existingGradient.radAttr) {
  9926. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  9927. }
  9928. return this;
  9929. };
  9930. /**
  9931. * @private
  9932. * @function Highcharts.SVGElement#setTextPath
  9933. * @param {Highcharts.SVGElement} path
  9934. * Path to follow.
  9935. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  9936. * Options.
  9937. * @return {Highcharts.SVGElement}
  9938. * Returns the SVGElement for chaining.
  9939. */
  9940. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  9941. var elem = this.element,
  9942. textNode = this.text ? this.text.element : elem,
  9943. attribsMap = {
  9944. textAnchor: 'text-anchor'
  9945. };
  9946. var adder = false,
  9947. textPathElement,
  9948. textPathId,
  9949. textPathWrapper = this.textPathWrapper,
  9950. firstTime = !textPathWrapper;
  9951. // Defaults
  9952. textPathOptions = merge(true, {
  9953. enabled: true,
  9954. attributes: {
  9955. dy: -5,
  9956. startOffset: '50%',
  9957. textAnchor: 'middle'
  9958. }
  9959. }, textPathOptions);
  9960. var attrs = AST.filterUserAttributes(textPathOptions.attributes);
  9961. if (path && textPathOptions && textPathOptions.enabled) {
  9962. // In case of fixed width for a text, string is rebuilt
  9963. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  9964. if (textPathWrapper &&
  9965. textPathWrapper.element.parentNode === null) {
  9966. // When buildText functionality was triggered again
  9967. // and deletes textPathWrapper parentNode
  9968. firstTime = true;
  9969. textPathWrapper = textPathWrapper.destroy();
  9970. }
  9971. else if (textPathWrapper) {
  9972. // Case after drillup when spans were added into
  9973. // the DOM outside the textPathWrapper parentGroup
  9974. this.removeTextOutline.call(textPathWrapper.parentGroup);
  9975. }
  9976. // label() has padding, text() doesn't
  9977. if (this.options && this.options.padding) {
  9978. attrs.dx = -this.options.padding;
  9979. }
  9980. if (!textPathWrapper) {
  9981. // Create <textPath>, defer the DOM adder
  9982. this.textPathWrapper = textPathWrapper =
  9983. this.renderer.createElement('textPath');
  9984. adder = true;
  9985. }
  9986. textPathElement = textPathWrapper.element;
  9987. // Set ID for the path
  9988. textPathId = path.element.getAttribute('id');
  9989. if (!textPathId) {
  9990. path.element.setAttribute('id', textPathId = uniqueKey());
  9991. }
  9992. // Change DOM structure, by placing <textPath> tag in <text>
  9993. if (firstTime) {
  9994. // Adjust the position
  9995. textNode.setAttribute('y', 0); // Firefox
  9996. if (isNumber(attrs.dx)) {
  9997. textNode.setAttribute('x', -attrs.dx);
  9998. }
  9999. // Move all <tspan>'s and text nodes to the <textPath> node. Do
  10000. // not move other elements like <title> or <path>
  10001. var childNodes = [].slice.call(textNode.childNodes);
  10002. for (var i = 0; i < childNodes.length; i++) {
  10003. var childNode = childNodes[i];
  10004. if (childNode.nodeType === Node.TEXT_NODE ||
  10005. childNode.nodeName === 'tspan') {
  10006. textPathElement.appendChild(childNode);
  10007. }
  10008. }
  10009. }
  10010. // Add <textPath> to the DOM
  10011. if (adder && textPathWrapper) {
  10012. textPathWrapper.add({ element: textNode });
  10013. }
  10014. // Set basic options:
  10015. // Use `setAttributeNS` because Safari needs this..
  10016. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  10017. // Presentation attributes:
  10018. // dx/dy options must by set on <text> (parent),
  10019. // the rest should be set on <textPath>
  10020. if (defined(attrs.dy)) {
  10021. textPathElement.parentNode
  10022. .setAttribute('dy', attrs.dy);
  10023. delete attrs.dy;
  10024. }
  10025. if (defined(attrs.dx)) {
  10026. textPathElement.parentNode
  10027. .setAttribute('dx', attrs.dx);
  10028. delete attrs.dx;
  10029. }
  10030. // Additional attributes
  10031. objectEach(attrs, function (val, key) {
  10032. textPathElement.setAttribute(attribsMap[key] || key, val);
  10033. });
  10034. // Remove translation, text that follows path does not need that
  10035. elem.removeAttribute('transform');
  10036. // Remove shadows and text outlines
  10037. this.removeTextOutline.call(textPathWrapper);
  10038. // Remove background and border for label(), see #10545
  10039. // Alternatively, we can disable setting background rects in
  10040. // series.drawDataLabels()
  10041. if (this.text && !this.renderer.styledMode) {
  10042. this.attr({
  10043. fill: 'none',
  10044. 'stroke-width': 0
  10045. });
  10046. }
  10047. // Disable some functions
  10048. this.updateTransform = noop;
  10049. this.applyTextOutline = noop;
  10050. }
  10051. else if (textPathWrapper) {
  10052. // Reset to prototype
  10053. delete this.updateTransform;
  10054. delete this.applyTextOutline;
  10055. // Restore DOM structure:
  10056. this.destroyTextPath(elem, path);
  10057. // Bring attributes back
  10058. this.updateTransform();
  10059. // Set textOutline back for text()
  10060. if (this.options && this.options.rotation) {
  10061. this.applyTextOutline(this.options.style.textOutline);
  10062. }
  10063. }
  10064. return this;
  10065. };
  10066. /**
  10067. * Add a shadow to the element. Must be called after the element is added to
  10068. * the DOM. In styled mode, this method is not used, instead use `defs` and
  10069. * filters.
  10070. *
  10071. * @example
  10072. * renderer.rect(10, 100, 100, 100)
  10073. * .attr({ fill: 'red' })
  10074. * .shadow(true);
  10075. *
  10076. * @function Highcharts.SVGElement#shadow
  10077. *
  10078. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  10079. * The shadow options. If `true`, the default options are applied. If
  10080. * `false`, the current shadow will be removed.
  10081. *
  10082. * @param {Highcharts.SVGElement} [group]
  10083. * The SVG group element where the shadows will be applied. The
  10084. * default is to add it to the same parent as the current element.
  10085. * Internally, this is ised for pie slices, where all the shadows are
  10086. * added to an element behind all the slices.
  10087. *
  10088. * @param {boolean} [cutOff]
  10089. * Used internally for column shadows.
  10090. *
  10091. * @return {Highcharts.SVGElement}
  10092. * Returns the SVGElement for chaining.
  10093. */
  10094. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  10095. var shadows = [],
  10096. element = this.element,
  10097. oldShadowOptions = this.oldShadowOptions,
  10098. defaultShadowOptions = {
  10099. color: palette.neutralColor100,
  10100. offsetX: this.parentInverted ? -1 : 1,
  10101. offsetY: this.parentInverted ? -1 : 1,
  10102. opacity: 0.15,
  10103. width: 3
  10104. };
  10105. var i,
  10106. shadow,
  10107. strokeWidth,
  10108. shadowElementOpacity,
  10109. update = false,
  10110. // compensate for inverted plot area
  10111. transform,
  10112. options;
  10113. if (shadowOptions === true) {
  10114. options = defaultShadowOptions;
  10115. }
  10116. else if (typeof shadowOptions === 'object') {
  10117. options = extend(defaultShadowOptions, shadowOptions);
  10118. }
  10119. // Update shadow when options change (#12091).
  10120. if (options) {
  10121. // Go over each key to look for change
  10122. if (options && oldShadowOptions) {
  10123. objectEach(options, function (value, key) {
  10124. if (value !== oldShadowOptions[key]) {
  10125. update = true;
  10126. }
  10127. });
  10128. }
  10129. if (update) {
  10130. this.destroyShadows();
  10131. }
  10132. this.oldShadowOptions = options;
  10133. }
  10134. if (!options) {
  10135. this.destroyShadows();
  10136. }
  10137. else if (!this.shadows) {
  10138. shadowElementOpacity = options.opacity / options.width;
  10139. transform = this.parentInverted ?
  10140. "translate(" + options.offsetY + ", " + options.offsetX + ")" :
  10141. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  10142. for (i = 1; i <= options.width; i++) {
  10143. shadow = element.cloneNode(false);
  10144. strokeWidth = (options.width * 2) + 1 - (2 * i);
  10145. attr(shadow, {
  10146. stroke: (shadowOptions.color ||
  10147. palette.neutralColor100),
  10148. 'stroke-opacity': shadowElementOpacity * i,
  10149. 'stroke-width': strokeWidth,
  10150. transform: transform,
  10151. fill: 'none'
  10152. });
  10153. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  10154. if (cutOff) {
  10155. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  10156. shadow.cutHeight = strokeWidth;
  10157. }
  10158. if (group) {
  10159. group.element.appendChild(shadow);
  10160. }
  10161. else if (element.parentNode) {
  10162. element.parentNode.insertBefore(shadow, element);
  10163. }
  10164. shadows.push(shadow);
  10165. }
  10166. this.shadows = shadows;
  10167. }
  10168. return this;
  10169. };
  10170. /**
  10171. * Show the element after it has been hidden.
  10172. *
  10173. * @function Highcharts.SVGElement#show
  10174. *
  10175. * @param {boolean} [inherit=false]
  10176. * Set the visibility attribute to `inherit` rather than `visible`.
  10177. * The difference is that an element with `visibility="visible"`
  10178. * will be visible even if the parent is hidden.
  10179. *
  10180. * @return {Highcharts.SVGElement}
  10181. * Returns the SVGElement for chaining.
  10182. */
  10183. SVGElement.prototype.show = function (inherit) {
  10184. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  10185. };
  10186. /**
  10187. * WebKit and Batik have problems with a stroke-width of zero, so in this
  10188. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  10189. * #3072.
  10190. *
  10191. * @private
  10192. * @function Highcharts.SVGElement#strokeSetter
  10193. * @param {number|string|ColorType} value
  10194. * @param {string} key
  10195. * @param {Highcharts.SVGDOMElement} element
  10196. */
  10197. SVGElement.prototype.strokeSetter = function (value, key, element) {
  10198. this[key] = value;
  10199. // Only apply the stroke attribute if the stroke width is defined and
  10200. // larger than 0
  10201. if (this.stroke && this['stroke-width']) {
  10202. // Use prototype as instance may be overridden
  10203. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  10204. element.setAttribute('stroke-width', this['stroke-width']);
  10205. this.hasStroke = true;
  10206. }
  10207. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  10208. element.removeAttribute('stroke');
  10209. this.hasStroke = false;
  10210. }
  10211. else if (this.renderer.styledMode && this['stroke-width']) {
  10212. element.setAttribute('stroke-width', this['stroke-width']);
  10213. this.hasStroke = true;
  10214. }
  10215. };
  10216. /**
  10217. * Get the computed stroke width in pixel values. This is used extensively
  10218. * when drawing shapes to ensure the shapes are rendered crisp and
  10219. * positioned correctly relative to each other. Using
  10220. * `shape-rendering: crispEdges` leaves us less control over positioning,
  10221. * for example when we want to stack columns next to each other, or position
  10222. * things pixel-perfectly within the plot box.
  10223. *
  10224. * The common pattern when placing a shape is:
  10225. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  10226. * now receive a stroke width from the style sheet. In classic mode we
  10227. * will add the `stroke-width` attribute.
  10228. * - Read the computed `elem.strokeWidth()`.
  10229. * - Place it based on the stroke width.
  10230. *
  10231. * @function Highcharts.SVGElement#strokeWidth
  10232. *
  10233. * @return {number}
  10234. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  10235. * attributes) is based on `em` or other units, the pixel size is returned.
  10236. */
  10237. SVGElement.prototype.strokeWidth = function () {
  10238. // In non-styled mode, read the stroke width as set by .attr
  10239. if (!this.renderer.styledMode) {
  10240. return this['stroke-width'] || 0;
  10241. }
  10242. // In styled mode, read computed stroke width
  10243. var val = this.getStyle('stroke-width');
  10244. var ret = 0,
  10245. dummy;
  10246. // Read pixel values directly
  10247. if (val.indexOf('px') === val.length - 2) {
  10248. ret = pInt(val);
  10249. // Other values like em, pt etc need to be measured
  10250. }
  10251. else if (val !== '') {
  10252. dummy = doc.createElementNS(SVG_NS, 'rect');
  10253. attr(dummy, {
  10254. width: val,
  10255. 'stroke-width': 0
  10256. });
  10257. this.element.parentNode.appendChild(dummy);
  10258. ret = dummy.getBBox().width;
  10259. dummy.parentNode.removeChild(dummy);
  10260. }
  10261. return ret;
  10262. };
  10263. /**
  10264. * If one of the symbol size affecting parameters are changed,
  10265. * check all the others only once for each call to an element's
  10266. * .attr() method
  10267. *
  10268. * @private
  10269. * @function Highcharts.SVGElement#symbolAttr
  10270. *
  10271. * @param {Highcharts.SVGAttributes} hash
  10272. * The attributes to set.
  10273. */
  10274. SVGElement.prototype.symbolAttr = function (hash) {
  10275. var wrapper = this;
  10276. [
  10277. 'x',
  10278. 'y',
  10279. 'r',
  10280. 'start',
  10281. 'end',
  10282. 'width',
  10283. 'height',
  10284. 'innerR',
  10285. 'anchorX',
  10286. 'anchorY',
  10287. 'clockwise'
  10288. ].forEach(function (key) {
  10289. wrapper[key] = pick(hash[key], wrapper[key]);
  10290. });
  10291. wrapper.attr({
  10292. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  10293. });
  10294. };
  10295. /**
  10296. * @private
  10297. * @function Highcharts.SVGElement#textSetter
  10298. * @param {string} value
  10299. */
  10300. SVGElement.prototype.textSetter = function (value) {
  10301. if (value !== this.textStr) {
  10302. // Delete size caches when the text changes
  10303. // delete this.bBox; // old code in series-label
  10304. delete this.textPxLength;
  10305. this.textStr = value;
  10306. if (this.added) {
  10307. this.renderer.buildText(this);
  10308. }
  10309. }
  10310. };
  10311. /**
  10312. * @private
  10313. * @function Highcharts.SVGElement#titleSetter
  10314. * @param {string} value
  10315. */
  10316. SVGElement.prototype.titleSetter = function (value) {
  10317. var el = this.element;
  10318. var titleNode = el.getElementsByTagName('title')[0] ||
  10319. doc.createElementNS(this.SVG_NS, 'title');
  10320. // Move to first child
  10321. if (el.insertBefore) {
  10322. el.insertBefore(titleNode, el.firstChild);
  10323. }
  10324. else {
  10325. el.appendChild(titleNode);
  10326. }
  10327. // Replace text content and escape markup
  10328. titleNode.textContent =
  10329. // #3276, #3895
  10330. String(pick(value, ''))
  10331. .replace(/<[^>]*>/g, '')
  10332. .replace(/&lt;/g, '<')
  10333. .replace(/&gt;/g, '>');
  10334. };
  10335. /**
  10336. * Bring the element to the front. Alternatively, a new zIndex can be set.
  10337. *
  10338. * @sample highcharts/members/element-tofront/
  10339. * Click an element to bring it to front
  10340. *
  10341. * @function Highcharts.SVGElement#toFront
  10342. *
  10343. * @return {Highcharts.SVGElement}
  10344. * Returns the SVGElement for chaining.
  10345. */
  10346. SVGElement.prototype.toFront = function () {
  10347. var element = this.element;
  10348. element.parentNode.appendChild(element);
  10349. return this;
  10350. };
  10351. /**
  10352. * Move an object and its children by x and y values.
  10353. *
  10354. * @function Highcharts.SVGElement#translate
  10355. *
  10356. * @param {number} x
  10357. * The x value.
  10358. *
  10359. * @param {number} y
  10360. * The y value.
  10361. *
  10362. * @return {Highcharts.SVGElement}
  10363. */
  10364. SVGElement.prototype.translate = function (x, y) {
  10365. return this.attr({
  10366. translateX: x,
  10367. translateY: y
  10368. });
  10369. };
  10370. /**
  10371. * Update the shadow elements with new attributes.
  10372. *
  10373. * @private
  10374. * @function Highcharts.SVGElement#updateShadows
  10375. *
  10376. * @param {string} key
  10377. * The attribute name.
  10378. *
  10379. * @param {number} value
  10380. * The value of the attribute.
  10381. *
  10382. * @param {Function} setter
  10383. * The setter function, inherited from the parent wrapper.
  10384. */
  10385. SVGElement.prototype.updateShadows = function (key, value, setter) {
  10386. var shadows = this.shadows;
  10387. if (shadows) {
  10388. var i = shadows.length;
  10389. while (i--) {
  10390. setter.call(shadows[i], key === 'height' ?
  10391. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  10392. key === 'd' ? this.d : value, key, shadows[i]);
  10393. }
  10394. }
  10395. };
  10396. /**
  10397. * Update the transform attribute based on internal properties. Deals with
  10398. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  10399. * attributes and updates the SVG `transform` attribute.
  10400. *
  10401. * @private
  10402. * @function Highcharts.SVGElement#updateTransform
  10403. */
  10404. SVGElement.prototype.updateTransform = function () {
  10405. var wrapper = this,
  10406. scaleX = wrapper.scaleX,
  10407. scaleY = wrapper.scaleY,
  10408. inverted = wrapper.inverted,
  10409. rotation = wrapper.rotation,
  10410. matrix = wrapper.matrix,
  10411. element = wrapper.element;
  10412. var translateX = wrapper.translateX || 0,
  10413. translateY = wrapper.translateY || 0;
  10414. // Flipping affects translate as adjustment for flipping around the
  10415. // group's axis
  10416. if (inverted) {
  10417. translateX += wrapper.width;
  10418. translateY += wrapper.height;
  10419. }
  10420. // Apply translate. Nearly all transformed elements have translation,
  10421. // so instead of checking for translate = 0, do it always (#1767,
  10422. // #1846).
  10423. var transform = ['translate(' + translateX + ',' + translateY + ')'];
  10424. // apply matrix
  10425. if (defined(matrix)) {
  10426. transform.push('matrix(' + matrix.join(',') + ')');
  10427. }
  10428. // apply rotation
  10429. if (inverted) {
  10430. transform.push('rotate(90) scale(-1,1)');
  10431. }
  10432. else if (rotation) { // text rotation
  10433. transform.push('rotate(' + rotation + ' ' +
  10434. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  10435. ' ' +
  10436. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  10437. }
  10438. // apply scale
  10439. if (defined(scaleX) || defined(scaleY)) {
  10440. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  10441. }
  10442. if (transform.length) {
  10443. element.setAttribute('transform', transform.join(' '));
  10444. }
  10445. };
  10446. /**
  10447. * @private
  10448. * @function Highcharts.SVGElement#visibilitySetter
  10449. *
  10450. * @param {string} value
  10451. *
  10452. * @param {string} key
  10453. *
  10454. * @param {Highcharts.SVGDOMElement} element
  10455. *
  10456. * @return {void}
  10457. */
  10458. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  10459. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  10460. // attribute instead (#2881, #3909)
  10461. if (value === 'inherit') {
  10462. element.removeAttribute(key);
  10463. }
  10464. else if (this[key] !== value) { // #6747
  10465. element.setAttribute(key, value);
  10466. }
  10467. this[key] = value;
  10468. };
  10469. /**
  10470. * @private
  10471. * @function Highcharts.SVGElement#xGetter
  10472. *
  10473. * @param {string} key
  10474. *
  10475. * @return {number|string|null}
  10476. */
  10477. SVGElement.prototype.xGetter = function (key) {
  10478. if (this.element.nodeName === 'circle') {
  10479. if (key === 'x') {
  10480. key = 'cx';
  10481. }
  10482. else if (key === 'y') {
  10483. key = 'cy';
  10484. }
  10485. }
  10486. return this._defaultGetter(key);
  10487. };
  10488. /**
  10489. * @private
  10490. * @function Highcharts.SVGElement#zIndexSetter
  10491. * @param {number} [value]
  10492. * @param {string} [key]
  10493. * @return {boolean}
  10494. */
  10495. SVGElement.prototype.zIndexSetter = function (value, key) {
  10496. var renderer = this.renderer,
  10497. parentGroup = this.parentGroup,
  10498. parentWrapper = parentGroup || renderer,
  10499. parentNode = parentWrapper.element || renderer.box,
  10500. element = this.element,
  10501. svgParent = parentNode === renderer.box;
  10502. var childNodes,
  10503. otherElement,
  10504. otherZIndex,
  10505. inserted = false,
  10506. undefinedOtherZIndex,
  10507. run = this.added,
  10508. i;
  10509. if (defined(value)) {
  10510. // So we can read it for other elements in the group
  10511. element.setAttribute('data-z-index', value);
  10512. value = +value;
  10513. if (this[key] === value) {
  10514. // Only update when needed (#3865)
  10515. run = false;
  10516. }
  10517. }
  10518. else if (defined(this[key])) {
  10519. element.removeAttribute('data-z-index');
  10520. }
  10521. this[key] = value;
  10522. // Insert according to this and other elements' zIndex. Before .add() is
  10523. // called, nothing is done. Then on add, or by later calls to
  10524. // zIndexSetter, the node is placed on the right place in the DOM.
  10525. if (run) {
  10526. value = this.zIndex;
  10527. if (value && parentGroup) {
  10528. parentGroup.handleZ = true;
  10529. }
  10530. childNodes = parentNode.childNodes;
  10531. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  10532. otherElement = childNodes[i];
  10533. otherZIndex = otherElement.getAttribute('data-z-index');
  10534. undefinedOtherZIndex = !defined(otherZIndex);
  10535. if (otherElement !== element) {
  10536. if (
  10537. // Negative zIndex versus no zIndex:
  10538. // On all levels except the highest. If the parent is
  10539. // <svg>, then we don't want to put items before <desc>
  10540. // or <defs>
  10541. value < 0 &&
  10542. undefinedOtherZIndex &&
  10543. !svgParent &&
  10544. !i) {
  10545. parentNode.insertBefore(element, childNodes[i]);
  10546. inserted = true;
  10547. }
  10548. else if (
  10549. // Insert after the first element with a lower zIndex
  10550. pInt(otherZIndex) <= value ||
  10551. // If negative zIndex, add this before first undefined
  10552. // zIndex element
  10553. (undefinedOtherZIndex &&
  10554. (!defined(value) || value >= 0))) {
  10555. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  10556. );
  10557. inserted = true;
  10558. }
  10559. }
  10560. }
  10561. if (!inserted) {
  10562. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  10563. );
  10564. inserted = true;
  10565. }
  10566. }
  10567. return inserted;
  10568. };
  10569. return SVGElement;
  10570. }());
  10571. // Some shared setters and getters
  10572. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  10573. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  10574. SVGElement.prototype.matrixSetter =
  10575. SVGElement.prototype.rotationOriginXSetter =
  10576. SVGElement.prototype.rotationOriginYSetter =
  10577. SVGElement.prototype.rotationSetter =
  10578. SVGElement.prototype.scaleXSetter =
  10579. SVGElement.prototype.scaleYSetter =
  10580. SVGElement.prototype.translateXSetter =
  10581. SVGElement.prototype.translateYSetter =
  10582. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  10583. this[key] = value;
  10584. this.doTransform = true;
  10585. };
  10586. /* *
  10587. *
  10588. * API Declarations
  10589. *
  10590. * */
  10591. /**
  10592. * Reference to the global SVGElement class as a workaround for a name conflict
  10593. * in the Highcharts namespace.
  10594. *
  10595. * @global
  10596. * @typedef {global.SVGElement} GlobalSVGElement
  10597. *
  10598. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10599. */
  10600. /**
  10601. * The horizontal alignment of an element.
  10602. *
  10603. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  10604. */
  10605. /**
  10606. * Options to align the element relative to the chart or another box.
  10607. *
  10608. * @interface Highcharts.AlignObject
  10609. */ /**
  10610. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  10611. *
  10612. * @name Highcharts.AlignObject#align
  10613. * @type {Highcharts.AlignValue|undefined}
  10614. *
  10615. * @default left
  10616. */ /**
  10617. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  10618. *
  10619. * @name Highcharts.AlignObject#verticalAlign
  10620. * @type {Highcharts.VerticalAlignValue|undefined}
  10621. *
  10622. * @default top
  10623. */ /**
  10624. * Horizontal pixel offset from alignment.
  10625. *
  10626. * @name Highcharts.AlignObject#x
  10627. * @type {number|undefined}
  10628. *
  10629. * @default 0
  10630. */ /**
  10631. * Vertical pixel offset from alignment.
  10632. *
  10633. * @name Highcharts.AlignObject#y
  10634. * @type {number|undefined}
  10635. *
  10636. * @default 0
  10637. */ /**
  10638. * Use the `transform` attribute with translateX and translateY custom
  10639. * attributes to align this elements rather than `x` and `y` attributes.
  10640. *
  10641. * @name Highcharts.AlignObject#alignByTranslate
  10642. * @type {boolean|undefined}
  10643. *
  10644. * @default false
  10645. */
  10646. /**
  10647. * Bounding box of an element.
  10648. *
  10649. * @interface Highcharts.BBoxObject
  10650. * @extends Highcharts.PositionObject
  10651. */ /**
  10652. * Height of the bounding box.
  10653. *
  10654. * @name Highcharts.BBoxObject#height
  10655. * @type {number}
  10656. */ /**
  10657. * Width of the bounding box.
  10658. *
  10659. * @name Highcharts.BBoxObject#width
  10660. * @type {number}
  10661. */ /**
  10662. * Horizontal position of the bounding box.
  10663. *
  10664. * @name Highcharts.BBoxObject#x
  10665. * @type {number}
  10666. */ /**
  10667. * Vertical position of the bounding box.
  10668. *
  10669. * @name Highcharts.BBoxObject#y
  10670. * @type {number}
  10671. */
  10672. /**
  10673. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  10674. * elements for the most parts correspond to SVG, but some are specific to
  10675. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  10676. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  10677. * attributes containing a hyphen are _not_ camel-cased, they should be
  10678. * quoted to preserve the hyphen.
  10679. *
  10680. * @example
  10681. * {
  10682. * 'stroke': '#ff0000', // basic
  10683. * 'stroke-width': 2, // hyphenated
  10684. * 'rotation': 45 // custom
  10685. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  10686. * }
  10687. *
  10688. * @interface Highcharts.SVGAttributes
  10689. */ /**
  10690. * @name Highcharts.SVGAttributes#[key:string]
  10691. * @type {*}
  10692. */ /**
  10693. * @name Highcharts.SVGAttributes#d
  10694. * @type {string|Highcharts.SVGPathArray|undefined}
  10695. */ /**
  10696. * @name Highcharts.SVGAttributes#fill
  10697. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10698. */ /**
  10699. * @name Highcharts.SVGAttributes#inverted
  10700. * @type {boolean|undefined}
  10701. */ /**
  10702. * @name Highcharts.SVGAttributes#matrix
  10703. * @type {Array<number>|undefined}
  10704. */ /**
  10705. * @name Highcharts.SVGAttributes#rotation
  10706. * @type {number|undefined}
  10707. */ /**
  10708. * @name Highcharts.SVGAttributes#rotationOriginX
  10709. * @type {number|undefined}
  10710. */ /**
  10711. * @name Highcharts.SVGAttributes#rotationOriginY
  10712. * @type {number|undefined}
  10713. */ /**
  10714. * @name Highcharts.SVGAttributes#scaleX
  10715. * @type {number|undefined}
  10716. */ /**
  10717. * @name Highcharts.SVGAttributes#scaleY
  10718. * @type {number|undefined}
  10719. */ /**
  10720. * @name Highcharts.SVGAttributes#stroke
  10721. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10722. */ /**
  10723. * @name Highcharts.SVGAttributes#style
  10724. * @type {string|Highcharts.CSSObject|undefined}
  10725. */ /**
  10726. * @name Highcharts.SVGAttributes#translateX
  10727. * @type {number|undefined}
  10728. */ /**
  10729. * @name Highcharts.SVGAttributes#translateY
  10730. * @type {number|undefined}
  10731. */ /**
  10732. * @name Highcharts.SVGAttributes#zIndex
  10733. * @type {number|undefined}
  10734. */
  10735. /**
  10736. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  10737. * global scope.
  10738. *
  10739. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  10740. *
  10741. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10742. */
  10743. /**
  10744. * The vertical alignment of an element.
  10745. *
  10746. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  10747. */
  10748. ''; // detach doclets above
  10749. return SVGElement;
  10750. });
  10751. _registerModule(_modules, 'Core/Renderer/RendererRegistry.js', [_modules['Core/Globals.js']], function (H) {
  10752. /* *
  10753. *
  10754. * (c) 2010-2021 Torstein Honsi
  10755. *
  10756. * License: www.highcharts.com/license
  10757. *
  10758. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10759. *
  10760. * */
  10761. /* *
  10762. *
  10763. * Namespace
  10764. *
  10765. * */
  10766. var RendererRegistry;
  10767. (function (RendererRegistry) {
  10768. /* *
  10769. *
  10770. * Static Properties
  10771. *
  10772. * */
  10773. var defaultRenderer;
  10774. RendererRegistry.rendererTypes = {};
  10775. /* *
  10776. *
  10777. * Static Functions
  10778. *
  10779. * */
  10780. /**
  10781. * Gets a registered renderer class. If no renderer type is provided or the
  10782. * requested renderer was not founded, the default renderer is returned.
  10783. *
  10784. * @param {string} [rendererType]
  10785. * Renderer type or the default renderer.
  10786. *
  10787. * @return {Highcharts.Class<Highcharts.SVGRenderer>}
  10788. * Returns the requested renderer class or the default renderer class.
  10789. */
  10790. function getRendererType(rendererType) {
  10791. if (rendererType === void 0) { rendererType = defaultRenderer; }
  10792. return (RendererRegistry.rendererTypes[rendererType] || RendererRegistry.rendererTypes[defaultRenderer]);
  10793. }
  10794. RendererRegistry.getRendererType = getRendererType;
  10795. /**
  10796. * Register a renderer class.
  10797. *
  10798. * @param {string} rendererType
  10799. * Renderer type to register.
  10800. *
  10801. * @param {Highcharts.Class<Highcharts.SVGRenderer>} rendererClass
  10802. * Returns the requested renderer class or the default renderer class.
  10803. *
  10804. * @param {boolean} setAsDefault
  10805. * Sets the renderer class as the default renderer.
  10806. */
  10807. function registerRendererType(rendererType, rendererClass, setAsDefault) {
  10808. RendererRegistry.rendererTypes[rendererType] = rendererClass;
  10809. if (!defaultRenderer || setAsDefault) {
  10810. defaultRenderer = rendererType;
  10811. H.Renderer = rendererClass; // compatibility
  10812. }
  10813. }
  10814. RendererRegistry.registerRendererType = registerRendererType;
  10815. })(RendererRegistry || (RendererRegistry = {}));
  10816. /* *
  10817. *
  10818. * Export
  10819. *
  10820. * */
  10821. return RendererRegistry;
  10822. });
  10823. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  10824. /* *
  10825. *
  10826. * (c) 2010-2021 Torstein Honsi
  10827. *
  10828. * License: www.highcharts.com/license
  10829. *
  10830. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10831. *
  10832. * */
  10833. var __extends = (this && this.__extends) || (function () {
  10834. var extendStatics = function (d,
  10835. b) {
  10836. extendStatics = Object.setPrototypeOf ||
  10837. ({ __proto__: [] } instanceof Array && function (d,
  10838. b) { d.__proto__ = b; }) ||
  10839. function (d,
  10840. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10841. return extendStatics(d, b);
  10842. };
  10843. return function (d, b) {
  10844. extendStatics(d, b);
  10845. function __() { this.constructor = d; }
  10846. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10847. };
  10848. })();
  10849. var defined = U.defined,
  10850. extend = U.extend,
  10851. isNumber = U.isNumber,
  10852. merge = U.merge,
  10853. pick = U.pick,
  10854. removeEvent = U.removeEvent;
  10855. /* *
  10856. *
  10857. * Class
  10858. *
  10859. * */
  10860. /**
  10861. * SVG label to render text.
  10862. * @private
  10863. * @class
  10864. * @name Highcharts.SVGLabel
  10865. * @augments Highcharts.SVGElement
  10866. */
  10867. var SVGLabel = /** @class */ (function (_super) {
  10868. __extends(SVGLabel, _super);
  10869. /* *
  10870. *
  10871. * Constructors
  10872. *
  10873. * */
  10874. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  10875. var _this = _super.call(this) || this;
  10876. _this.paddingLeftSetter = _this.paddingSetter;
  10877. _this.paddingRightSetter = _this.paddingSetter;
  10878. _this.init(renderer, 'g');
  10879. _this.textStr = str;
  10880. _this.x = x;
  10881. _this.y = y;
  10882. _this.anchorX = anchorX;
  10883. _this.anchorY = anchorY;
  10884. _this.baseline = baseline;
  10885. _this.className = className;
  10886. _this.addClass(className === 'button' ?
  10887. 'highcharts-no-tooltip' :
  10888. 'highcharts-label');
  10889. if (className) {
  10890. _this.addClass('highcharts-' + className);
  10891. }
  10892. _this.text = renderer.text('', 0, 0, useHTML).attr({ zIndex: 1 });
  10893. // Validate the shape argument
  10894. var hasBGImage;
  10895. if (typeof shape === 'string') {
  10896. hasBGImage = /^url\((.*?)\)$/.test(shape);
  10897. if (hasBGImage || _this.renderer.symbols[shape]) {
  10898. _this.symbolKey = shape;
  10899. }
  10900. }
  10901. _this.bBox = SVGLabel.emptyBBox;
  10902. _this.padding = 3;
  10903. _this.baselineOffset = 0;
  10904. _this.needsBox = renderer.styledMode || hasBGImage;
  10905. _this.deferredAttr = {};
  10906. _this.alignFactor = 0;
  10907. return _this;
  10908. }
  10909. /* *
  10910. *
  10911. * Functions
  10912. *
  10913. * */
  10914. SVGLabel.prototype.alignSetter = function (value) {
  10915. var alignFactor = ({
  10916. left: 0,
  10917. center: 0.5,
  10918. right: 1
  10919. })[value];
  10920. if (alignFactor !== this.alignFactor) {
  10921. this.alignFactor = alignFactor;
  10922. // Bounding box exists, means we're dynamically changing
  10923. if (this.bBox && isNumber(this.xSetting)) {
  10924. this.attr({ x: this.xSetting }); // #5134
  10925. }
  10926. }
  10927. };
  10928. SVGLabel.prototype.anchorXSetter = function (value, key) {
  10929. this.anchorX = value;
  10930. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  10931. };
  10932. SVGLabel.prototype.anchorYSetter = function (value, key) {
  10933. this.anchorY = value;
  10934. this.boxAttr(key, value - this.ySetting);
  10935. };
  10936. /*
  10937. * Set a box attribute, or defer it if the box is not yet created
  10938. */
  10939. SVGLabel.prototype.boxAttr = function (key, value) {
  10940. if (this.box) {
  10941. this.box.attr(key, value);
  10942. }
  10943. else {
  10944. this.deferredAttr[key] = value;
  10945. }
  10946. };
  10947. /*
  10948. * Pick up some properties and apply them to the text instead of the
  10949. * wrapper.
  10950. */
  10951. SVGLabel.prototype.css = function (styles) {
  10952. if (styles) {
  10953. var textStyles_1 = {};
  10954. // Create a copy to avoid altering the original object
  10955. // (#537)
  10956. styles = merge(styles);
  10957. SVGLabel.textProps.forEach(function (prop) {
  10958. if (typeof styles[prop] !== 'undefined') {
  10959. textStyles_1[prop] = styles[prop];
  10960. delete styles[prop];
  10961. }
  10962. });
  10963. this.text.css(textStyles_1);
  10964. var isWidth = 'width' in textStyles_1, isFontStyle = ('fontSize' in textStyles_1 || 'fontWeight' in textStyles_1);
  10965. // Update existing text, box (#9400, #12163)
  10966. if (isFontStyle) {
  10967. this.updateTextPadding();
  10968. }
  10969. else if (isWidth) {
  10970. this.updateBoxSize();
  10971. }
  10972. }
  10973. return SVGElement.prototype.css.call(this, styles);
  10974. };
  10975. /*
  10976. * Destroy and release memory.
  10977. */
  10978. SVGLabel.prototype.destroy = function () {
  10979. // Added by button implementation
  10980. removeEvent(this.element, 'mouseenter');
  10981. removeEvent(this.element, 'mouseleave');
  10982. if (this.text) {
  10983. this.text.destroy();
  10984. }
  10985. if (this.box) {
  10986. this.box = this.box.destroy();
  10987. }
  10988. // Call base implementation to destroy the rest
  10989. SVGElement.prototype.destroy.call(this);
  10990. return void 0;
  10991. };
  10992. SVGLabel.prototype.fillSetter = function (value, key) {
  10993. if (value) {
  10994. this.needsBox = true;
  10995. }
  10996. // for animation getter (#6776)
  10997. this.fill = value;
  10998. this.boxAttr(key, value);
  10999. };
  11000. /*
  11001. * Return the bounding box of the box, not the group.
  11002. */
  11003. SVGLabel.prototype.getBBox = function () {
  11004. // If we have a text string and the DOM bBox was 0, it typically means
  11005. // that the label was first rendered hidden, so we need to update the
  11006. // bBox (#15246)
  11007. if (this.textStr && this.bBox.width === 0 && this.bBox.height === 0) {
  11008. this.updateBoxSize();
  11009. }
  11010. var padding = this.padding;
  11011. var paddingLeft = pick(this.paddingLeft,
  11012. padding);
  11013. return {
  11014. width: this.width,
  11015. height: this.height,
  11016. x: this.bBox.x - paddingLeft,
  11017. y: this.bBox.y - padding
  11018. };
  11019. };
  11020. SVGLabel.prototype.getCrispAdjust = function () {
  11021. return this.renderer.styledMode && this.box ?
  11022. this.box.strokeWidth() % 2 / 2 :
  11023. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  11024. };
  11025. SVGLabel.prototype.heightSetter = function (value) {
  11026. this.heightSetting = value;
  11027. };
  11028. // Event handling. In case of useHTML, we need to make sure that events
  11029. // are captured on the span as well, and that mouseenter/mouseleave
  11030. // between the SVG group and the HTML span are not treated as real
  11031. // enter/leave events. #13310.
  11032. SVGLabel.prototype.on = function (eventType, handler) {
  11033. var label = this;
  11034. var text = label.text;
  11035. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  11036. var selectiveHandler;
  11037. if (span) {
  11038. selectiveHandler = function (e) {
  11039. if ((eventType === 'mouseenter' ||
  11040. eventType === 'mouseleave') &&
  11041. e.relatedTarget instanceof Element &&
  11042. (
  11043. // #14110
  11044. label.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY ||
  11045. span.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
  11046. return;
  11047. }
  11048. handler.call(label.element, e);
  11049. };
  11050. span.on(eventType, selectiveHandler);
  11051. }
  11052. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  11053. return label;
  11054. };
  11055. /*
  11056. * After the text element is added, get the desired size of the border
  11057. * box and add it before the text in the DOM.
  11058. */
  11059. SVGLabel.prototype.onAdd = function () {
  11060. var str = this.textStr;
  11061. this.text.add(this);
  11062. this.attr({
  11063. // Alignment is available now (#3295, 0 not rendered if given
  11064. // as a value)
  11065. text: (defined(str) ? str : ''),
  11066. x: this.x,
  11067. y: this.y
  11068. });
  11069. if (this.box && defined(this.anchorX)) {
  11070. this.attr({
  11071. anchorX: this.anchorX,
  11072. anchorY: this.anchorY
  11073. });
  11074. }
  11075. };
  11076. SVGLabel.prototype.paddingSetter = function (value, key) {
  11077. if (!isNumber(value)) {
  11078. this[key] = void 0;
  11079. }
  11080. else if (value !== this[key]) {
  11081. this[key] = value;
  11082. this.updateTextPadding();
  11083. }
  11084. };
  11085. SVGLabel.prototype.rSetter = function (value, key) {
  11086. this.boxAttr(key, value);
  11087. };
  11088. SVGLabel.prototype.shadow = function (b) {
  11089. if (b && !this.renderer.styledMode) {
  11090. this.updateBoxSize();
  11091. if (this.box) {
  11092. this.box.shadow(b);
  11093. }
  11094. }
  11095. return this;
  11096. };
  11097. SVGLabel.prototype.strokeSetter = function (value, key) {
  11098. // for animation getter (#6776)
  11099. this.stroke = value;
  11100. this.boxAttr(key, value);
  11101. };
  11102. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  11103. if (value) {
  11104. this.needsBox = true;
  11105. }
  11106. this['stroke-width'] = value;
  11107. this.boxAttr(key, value);
  11108. };
  11109. SVGLabel.prototype['text-alignSetter'] = function (value) {
  11110. this.textAlign = value;
  11111. };
  11112. SVGLabel.prototype.textSetter = function (text) {
  11113. if (typeof text !== 'undefined') {
  11114. // Must use .attr to ensure transforms are done (#10009)
  11115. this.text.attr({ text: text });
  11116. }
  11117. this.updateTextPadding();
  11118. };
  11119. /*
  11120. * This function runs after the label is added to the DOM (when the bounding
  11121. * box is available), and after the text of the label is updated to detect
  11122. * the new bounding box and reflect it in the border box.
  11123. */
  11124. SVGLabel.prototype.updateBoxSize = function () {
  11125. var style = this.text.element.style,
  11126. attribs = {},
  11127. padding = this.padding,
  11128. // #12165 error when width is null (auto)
  11129. // #12163 when fontweight: bold, recalculate bBox withot cache
  11130. // #3295 && 3514 box failure when string equals 0
  11131. bBox = this.bBox = (((!isNumber(this.widthSetting) ||
  11132. !isNumber(this.heightSetting) ||
  11133. this.textAlign) && defined(this.text.textStr)) ?
  11134. this.text.getBBox() :
  11135. SVGLabel.emptyBBox);
  11136. var crispAdjust;
  11137. this.width = this.getPaddedWidth();
  11138. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  11139. var metrics = this.renderer.fontMetrics(style && style.fontSize,
  11140. this.text);
  11141. // Update the label-scoped y offset. Math.min because of inline
  11142. // style (#9400)
  11143. this.baselineOffset = padding + Math.min(
  11144. // When applicable, use the font size of the first line (#15707)
  11145. (this.text.firstLineMetrics || metrics).b,
  11146. // When the height is 0, there is no bBox, so go with the font
  11147. // metrics. Highmaps CSS demos.
  11148. bBox.height || Infinity);
  11149. // #15491: Vertical centering
  11150. if (this.heightSetting) {
  11151. this.baselineOffset += (this.heightSetting - metrics.h) / 2;
  11152. }
  11153. if (this.needsBox) {
  11154. // Create the border box if it is not already present
  11155. if (!this.box) {
  11156. // Symbol definition exists (#5324)
  11157. var box = this.box = this.symbolKey ?
  11158. this.renderer.symbol(this.symbolKey) :
  11159. this.renderer.rect();
  11160. box.addClass(// Don't use label className for buttons
  11161. (this.className === 'button' ? '' : 'highcharts-label-box') +
  11162. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  11163. box.add(this);
  11164. }
  11165. crispAdjust = this.getCrispAdjust();
  11166. attribs.x = crispAdjust;
  11167. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  11168. // Apply the box attributes
  11169. attribs.width = Math.round(this.width);
  11170. attribs.height = Math.round(this.height);
  11171. this.box.attr(extend(attribs, this.deferredAttr));
  11172. this.deferredAttr = {};
  11173. }
  11174. };
  11175. /*
  11176. * This function runs after setting text or padding, but only if padding
  11177. * is changed.
  11178. */
  11179. SVGLabel.prototype.updateTextPadding = function () {
  11180. var text = this.text;
  11181. this.updateBoxSize();
  11182. // Determine y based on the baseline
  11183. var textY = this.baseline ? 0 : this.baselineOffset;
  11184. var textX = pick(this.paddingLeft,
  11185. this.padding);
  11186. // compensate for alignment
  11187. if (defined(this.widthSetting) &&
  11188. this.bBox &&
  11189. (this.textAlign === 'center' || this.textAlign === 'right')) {
  11190. textX += { center: 0.5, right: 1 }[this.textAlign] *
  11191. (this.widthSetting - this.bBox.width);
  11192. }
  11193. // update if anything changed
  11194. if (textX !== text.x || textY !== text.y) {
  11195. text.attr('x', textX);
  11196. // #8159 - prevent misplaced data labels in treemap
  11197. // (useHTML: true)
  11198. if (text.hasBoxWidthChanged) {
  11199. this.bBox = text.getBBox(true);
  11200. }
  11201. if (typeof textY !== 'undefined') {
  11202. text.attr('y', textY);
  11203. }
  11204. }
  11205. // record current values
  11206. text.x = textX;
  11207. text.y = textY;
  11208. };
  11209. SVGLabel.prototype.widthSetter = function (value) {
  11210. // width:auto => null
  11211. this.widthSetting = isNumber(value) ? value : void 0;
  11212. };
  11213. SVGLabel.prototype.getPaddedWidth = function () {
  11214. var padding = this.padding;
  11215. var paddingLeft = pick(this.paddingLeft,
  11216. padding);
  11217. var paddingRight = pick(this.paddingRight,
  11218. padding);
  11219. return (this.widthSetting || this.bBox.width || 0) + paddingLeft + paddingRight;
  11220. };
  11221. SVGLabel.prototype.xSetter = function (value) {
  11222. this.x = value; // for animation getter
  11223. if (this.alignFactor) {
  11224. value -= this.alignFactor * this.getPaddedWidth();
  11225. // Force animation even when setting to the same value (#7898)
  11226. this['forceAnimate:x'] = true;
  11227. }
  11228. this.xSetting = Math.round(value);
  11229. this.attr('translateX', this.xSetting);
  11230. };
  11231. SVGLabel.prototype.ySetter = function (value) {
  11232. this.ySetting = this.y = Math.round(value);
  11233. this.attr('translateY', this.ySetting);
  11234. };
  11235. /* *
  11236. *
  11237. * Static Properties
  11238. *
  11239. * */
  11240. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  11241. /**
  11242. * For labels, these CSS properties are applied to the `text` node directly.
  11243. *
  11244. * @private
  11245. * @name Highcharts.SVGLabel#textProps
  11246. * @type {Array<string>}
  11247. */
  11248. SVGLabel.textProps = [
  11249. 'color', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  11250. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  11251. 'textOutline', 'textOverflow', 'width'
  11252. ];
  11253. return SVGLabel;
  11254. }(SVGElement));
  11255. return SVGLabel;
  11256. });
  11257. _registerModule(_modules, 'Core/Renderer/SVG/Symbols.js', [_modules['Core/Utilities.js']], function (U) {
  11258. /* *
  11259. *
  11260. * (c) 2010-2021 Torstein Honsi
  11261. *
  11262. * License: www.highcharts.com/license
  11263. *
  11264. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11265. *
  11266. * */
  11267. var defined = U.defined,
  11268. isNumber = U.isNumber,
  11269. pick = U.pick;
  11270. /* *
  11271. *
  11272. * Functions
  11273. *
  11274. * */
  11275. /* eslint-disable require-jsdoc, valid-jsdoc */
  11276. function arc(x, y, w, h, options) {
  11277. var arc = [];
  11278. if (options) {
  11279. var start = options.start || 0,
  11280. rx = pick(options.r,
  11281. w),
  11282. ry = pick(options.r,
  11283. h || w),
  11284. proximity = 0.001,
  11285. fullCircle = (Math.abs((options.end || 0) - start - 2 * Math.PI) <
  11286. proximity),
  11287. // Substract a small number to prevent cos and sin of start
  11288. // and end from becoming equal on 360 arcs (related: #1561)
  11289. end = (options.end || 0) - proximity,
  11290. innerRadius = options.innerR,
  11291. open_1 = pick(options.open,
  11292. fullCircle),
  11293. cosStart = Math.cos(start),
  11294. sinStart = Math.sin(start),
  11295. cosEnd = Math.cos(end),
  11296. sinEnd = Math.sin(end),
  11297. // Proximity takes care of rounding errors around PI (#6971)
  11298. longArc = pick(options.longArc,
  11299. end - start - Math.PI < proximity ? 0 : 1);
  11300. arc.push([
  11301. 'M',
  11302. x + rx * cosStart,
  11303. y + ry * sinStart
  11304. ], [
  11305. 'A',
  11306. rx,
  11307. ry,
  11308. 0,
  11309. longArc,
  11310. pick(options.clockwise, 1),
  11311. x + rx * cosEnd,
  11312. y + ry * sinEnd
  11313. ]);
  11314. if (defined(innerRadius)) {
  11315. arc.push(open_1 ?
  11316. [
  11317. 'M',
  11318. x + innerRadius * cosEnd,
  11319. y + innerRadius * sinEnd
  11320. ] : [
  11321. 'L',
  11322. x + innerRadius * cosEnd,
  11323. y + innerRadius * sinEnd
  11324. ], [
  11325. 'A',
  11326. innerRadius,
  11327. innerRadius,
  11328. 0,
  11329. longArc,
  11330. // Clockwise - opposite to the outer arc clockwise
  11331. defined(options.clockwise) ? 1 - options.clockwise : 0,
  11332. x + innerRadius * cosStart,
  11333. y + innerRadius * sinStart
  11334. ]);
  11335. }
  11336. if (!open_1) {
  11337. arc.push(['Z']);
  11338. }
  11339. }
  11340. return arc;
  11341. }
  11342. /**
  11343. * Callout shape used for default tooltips, also used for rounded
  11344. * rectangles in VML
  11345. */
  11346. function callout(x, y, w, h, options) {
  11347. var arrowLength = 6,
  11348. halfDistance = 6,
  11349. r = Math.min((options && options.r) || 0,
  11350. w,
  11351. h),
  11352. safeDistance = r + halfDistance,
  11353. anchorX = options && options.anchorX,
  11354. anchorY = options && options.anchorY || 0;
  11355. var path = roundedRect(x,
  11356. y,
  11357. w,
  11358. h, { r: r });
  11359. if (!isNumber(anchorX)) {
  11360. return path;
  11361. }
  11362. // Anchor on right side
  11363. if (x + anchorX >= w) {
  11364. // Chevron
  11365. if (anchorY > y + safeDistance &&
  11366. anchorY < y + h - safeDistance) {
  11367. path.splice(3, 1, ['L', x + w, anchorY - halfDistance], ['L', x + w + arrowLength, anchorY], ['L', x + w, anchorY + halfDistance], ['L', x + w, y + h - r]);
  11368. // Simple connector
  11369. }
  11370. else {
  11371. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  11372. }
  11373. // Anchor on left side
  11374. }
  11375. else if (x + anchorX <= 0) {
  11376. // Chevron
  11377. if (anchorY > y + safeDistance &&
  11378. anchorY < y + h - safeDistance) {
  11379. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  11380. // Simple connector
  11381. }
  11382. else {
  11383. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  11384. }
  11385. }
  11386. else if ( // replace bottom
  11387. anchorY &&
  11388. anchorY > h &&
  11389. anchorX > x + safeDistance &&
  11390. anchorX < x + w - safeDistance) {
  11391. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  11392. }
  11393. else if ( // replace top
  11394. anchorY &&
  11395. anchorY < 0 &&
  11396. anchorX > x + safeDistance &&
  11397. anchorX < x + w - safeDistance) {
  11398. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  11399. }
  11400. return path;
  11401. }
  11402. function circle(x, y, w, h) {
  11403. // Return a full arc
  11404. return arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  11405. start: Math.PI * 0.5,
  11406. end: Math.PI * 2.5,
  11407. open: false
  11408. });
  11409. }
  11410. function diamond(x, y, w, h) {
  11411. return [
  11412. ['M', x + w / 2, y],
  11413. ['L', x + w, y + h / 2],
  11414. ['L', x + w / 2, y + h],
  11415. ['L', x, y + h / 2],
  11416. ['Z']
  11417. ];
  11418. }
  11419. // #15291
  11420. function rect(x, y, w, h, options) {
  11421. if (options && options.r) {
  11422. return roundedRect(x, y, w, h, options);
  11423. }
  11424. return [
  11425. ['M', x, y],
  11426. ['L', x + w, y],
  11427. ['L', x + w, y + h],
  11428. ['L', x, y + h],
  11429. ['Z']
  11430. ];
  11431. }
  11432. function roundedRect(x, y, w, h, options) {
  11433. var r = (options && options.r) || 0;
  11434. return [
  11435. ['M', x + r, y],
  11436. ['L', x + w - r, y],
  11437. ['C', x + w, y, x + w, y, x + w, y + r],
  11438. ['L', x + w, y + h - r],
  11439. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  11440. ['L', x + r, y + h],
  11441. ['C', x, y + h, x, y + h, x, y + h - r],
  11442. ['L', x, y + r],
  11443. ['C', x, y, x, y, x + r, y] // top-left corner
  11444. ];
  11445. }
  11446. function triangle(x, y, w, h) {
  11447. return [
  11448. ['M', x + w / 2, y],
  11449. ['L', x + w, y + h],
  11450. ['L', x, y + h],
  11451. ['Z']
  11452. ];
  11453. }
  11454. function triangleDown(x, y, w, h) {
  11455. return [
  11456. ['M', x, y],
  11457. ['L', x + w, y],
  11458. ['L', x + w / 2, y + h],
  11459. ['Z']
  11460. ];
  11461. }
  11462. var Symbols = {
  11463. arc: arc,
  11464. callout: callout,
  11465. circle: circle,
  11466. diamond: diamond,
  11467. rect: rect,
  11468. roundedRect: roundedRect,
  11469. square: rect,
  11470. triangle: triangle,
  11471. 'triangle-down': triangleDown
  11472. };
  11473. /* *
  11474. *
  11475. * Default Export
  11476. *
  11477. * */
  11478. return Symbols;
  11479. });
  11480. _registerModule(_modules, 'Core/Renderer/SVG/TextBuilder.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (AST, H, U) {
  11481. /* *
  11482. *
  11483. * (c) 2010-2020 Torstein Honsi
  11484. *
  11485. * License: www.highcharts.com/license
  11486. *
  11487. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11488. *
  11489. * */
  11490. var doc = H.doc,
  11491. SVG_NS = H.SVG_NS;
  11492. var attr = U.attr,
  11493. isString = U.isString,
  11494. objectEach = U.objectEach,
  11495. pick = U.pick;
  11496. /* *
  11497. *
  11498. * Class
  11499. *
  11500. * */
  11501. /**
  11502. * SVG Text Builder
  11503. * @private
  11504. * @class
  11505. * @name Highcharts.TextBuilder
  11506. */
  11507. var TextBuilder = /** @class */ (function () {
  11508. function TextBuilder(svgElement) {
  11509. var textStyles = svgElement.styles;
  11510. this.renderer = svgElement.renderer;
  11511. this.svgElement = svgElement;
  11512. this.width = svgElement.textWidth;
  11513. this.textLineHeight = textStyles && textStyles.lineHeight;
  11514. this.textOutline = textStyles && textStyles.textOutline;
  11515. this.ellipsis = Boolean(textStyles && textStyles.textOverflow === 'ellipsis');
  11516. this.noWrap = Boolean(textStyles && textStyles.whiteSpace === 'nowrap');
  11517. this.fontSize = textStyles && textStyles.fontSize;
  11518. }
  11519. /**
  11520. * Build an SVG representation of the pseudo HTML given in the object's
  11521. * svgElement.
  11522. *
  11523. * @private
  11524. *
  11525. * @return {void}.
  11526. */
  11527. TextBuilder.prototype.buildSVG = function () {
  11528. var wrapper = this.svgElement;
  11529. var textNode = wrapper.element, renderer = wrapper.renderer, textStr = pick(wrapper.textStr, '').toString(), hasMarkup = textStr.indexOf('<') !== -1, childNodes = textNode.childNodes, textCache, i = childNodes.length, tempParent = this.width && !wrapper.added && renderer.box;
  11530. var regexMatchBreaks = /<br.*?>/g;
  11531. // The buildText code is quite heavy, so if we're not changing something
  11532. // that affects the text, skip it (#6113).
  11533. textCache = [
  11534. textStr,
  11535. this.ellipsis,
  11536. this.noWrap,
  11537. this.textLineHeight,
  11538. this.textOutline,
  11539. this.fontSize,
  11540. this.width
  11541. ].join(',');
  11542. if (textCache === wrapper.textCache) {
  11543. return;
  11544. }
  11545. wrapper.textCache = textCache;
  11546. delete wrapper.actualWidth;
  11547. // Remove old text
  11548. while (i--) {
  11549. textNode.removeChild(childNodes[i]);
  11550. }
  11551. // Simple strings, add text directly and return
  11552. if (!hasMarkup &&
  11553. !this.ellipsis &&
  11554. !this.width &&
  11555. (textStr.indexOf(' ') === -1 ||
  11556. (this.noWrap && !regexMatchBreaks.test(textStr)))) {
  11557. textNode.appendChild(doc.createTextNode(this.unescapeEntities(textStr)));
  11558. // Complex strings, add more logic
  11559. }
  11560. else if (textStr !== '') {
  11561. if (tempParent) {
  11562. // attach it to the DOM to read offset width
  11563. tempParent.appendChild(textNode);
  11564. }
  11565. // Step 1. Parse the markup safely and directly into a tree
  11566. // structure.
  11567. var ast = new AST(textStr);
  11568. // Step 2. Do as many as we can of the modifications to the tree
  11569. // structure before it is added to the DOM
  11570. this.modifyTree(ast.nodes);
  11571. ast.addToDOM(wrapper.element);
  11572. // Step 3. Some modifications can't be done until the structure is
  11573. // in the DOM, because we need to read computed metrics.
  11574. this.modifyDOM();
  11575. // Add title if an ellipsis was added
  11576. if (this.ellipsis &&
  11577. (textNode.textContent || '').indexOf('\u2026') !== -1) {
  11578. wrapper.attr('title', this.unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  11579. );
  11580. }
  11581. if (tempParent) {
  11582. tempParent.removeChild(textNode);
  11583. }
  11584. }
  11585. // Apply the text outline
  11586. if (isString(this.textOutline) && wrapper.applyTextOutline) {
  11587. wrapper.applyTextOutline(this.textOutline);
  11588. }
  11589. };
  11590. /**
  11591. * Modify the DOM of the generated SVG structure. This function only does
  11592. * operations that cannot be done until the elements are attached to the
  11593. * DOM, like doing layout based on rendered metrics of the added elements.
  11594. *
  11595. * @private
  11596. *
  11597. * @return {void}
  11598. */
  11599. TextBuilder.prototype.modifyDOM = function () {
  11600. var _this = this;
  11601. var wrapper = this.svgElement;
  11602. var x = attr(wrapper.element, 'x');
  11603. wrapper.firstLineMetrics = void 0;
  11604. // Modify hard line breaks by applying the rendered line height
  11605. [].forEach.call(wrapper.element.querySelectorAll('tspan.highcharts-br'), function (br, i) {
  11606. if (br.nextSibling && br.previousSibling) { // #5261
  11607. if (i === 0 && br.previousSibling.nodeType === 1) {
  11608. wrapper.firstLineMetrics = wrapper.renderer
  11609. .fontMetrics(void 0, br.previousSibling);
  11610. }
  11611. attr(br, {
  11612. // Since the break is inserted in front of the next
  11613. // line, we need to use the next sibling for the line
  11614. // height
  11615. dy: _this.getLineHeight(br.nextSibling),
  11616. x: x
  11617. });
  11618. }
  11619. });
  11620. // Constrain the line width, either by ellipsis or wrapping
  11621. var width = this.width || 0;
  11622. if (!width) {
  11623. return;
  11624. }
  11625. // Insert soft line breaks into each text node
  11626. var modifyTextNode = function (textNode,
  11627. parentElement) {
  11628. var text = textNode.textContent || '';
  11629. var words = text
  11630. .replace(/([^\^])-/g, '$1- ') // Split on hyphens
  11631. // .trim()
  11632. .split(' '); // #1273
  11633. var hasWhiteSpace = !_this.noWrap && (words.length > 1 || wrapper.element.childNodes.length > 1);
  11634. var dy = _this.getLineHeight(parentElement);
  11635. var lineNo = 0;
  11636. var startAt = wrapper.actualWidth;
  11637. if (_this.ellipsis) {
  11638. if (text) {
  11639. _this.truncate(textNode, text, void 0, 0,
  11640. // Target width
  11641. Math.max(0,
  11642. // Substract the font face to make room for the
  11643. // ellipsis itself
  11644. width - parseInt(_this.fontSize || 12, 10)),
  11645. // Build the text to test for
  11646. function (text, currentIndex) {
  11647. return text.substring(0, currentIndex) + '\u2026';
  11648. });
  11649. }
  11650. }
  11651. else if (hasWhiteSpace) {
  11652. var lines = [];
  11653. // Remove preceding siblings in order to make the text length
  11654. // calculation correct in the truncate function
  11655. var precedingSiblings = [];
  11656. while (parentElement.firstChild &&
  11657. parentElement.firstChild !== textNode) {
  11658. precedingSiblings.push(parentElement.firstChild);
  11659. parentElement.removeChild(parentElement.firstChild);
  11660. }
  11661. while (words.length) {
  11662. // Apply the previous line
  11663. if (words.length && !_this.noWrap && lineNo > 0) {
  11664. lines.push(textNode.textContent || '');
  11665. textNode.textContent = words.join(' ')
  11666. .replace(/- /g, '-');
  11667. }
  11668. // For each line, truncate the remaining
  11669. // words into the line length.
  11670. _this.truncate(textNode, void 0, words, lineNo === 0 ? (startAt || 0) : 0, width,
  11671. // Build the text to test for
  11672. function (t, currentIndex) {
  11673. return words
  11674. .slice(0, currentIndex)
  11675. .join(' ')
  11676. .replace(/- /g, '-');
  11677. });
  11678. startAt = wrapper.actualWidth;
  11679. lineNo++;
  11680. }
  11681. // Reinsert the preceding child nodes
  11682. precedingSiblings.forEach(function (childNode) {
  11683. parentElement.insertBefore(childNode, textNode);
  11684. });
  11685. // Insert the previous lines before the original text node
  11686. lines.forEach(function (line) {
  11687. // Insert the line
  11688. parentElement.insertBefore(doc.createTextNode(line), textNode);
  11689. // Insert a break
  11690. var br = doc.createElementNS(SVG_NS, 'tspan');
  11691. br.textContent = '\u200B'; // zero-width space
  11692. attr(br, { dy: dy, x: x });
  11693. parentElement.insertBefore(br, textNode);
  11694. });
  11695. }
  11696. };
  11697. // Recurse down the DOM tree and handle line breaks for each text node
  11698. var modifyChildren = (function (node) {
  11699. var childNodes = [].slice.call(node.childNodes);
  11700. childNodes.forEach(function (childNode) {
  11701. if (childNode.nodeType === Node.TEXT_NODE) {
  11702. modifyTextNode(childNode, node);
  11703. }
  11704. else {
  11705. // Reset word-wrap width readings after hard breaks
  11706. if (childNode.className.baseVal
  11707. .indexOf('highcharts-br') !== -1) {
  11708. wrapper.actualWidth = 0;
  11709. }
  11710. // Recurse down to child node
  11711. modifyChildren(childNode);
  11712. }
  11713. });
  11714. });
  11715. modifyChildren(wrapper.element);
  11716. };
  11717. /**
  11718. * Get the rendered line height of a <text>, <tspan> or pure text node.
  11719. *
  11720. * @param {DOMElementType|Text} node The node to check for
  11721. *
  11722. * @return {number} The rendered line height
  11723. */
  11724. TextBuilder.prototype.getLineHeight = function (node) {
  11725. var fontSizeStyle;
  11726. // If the node is a text node, use its parent
  11727. var element = node.nodeType === Node.TEXT_NODE ?
  11728. node.parentElement :
  11729. node;
  11730. if (!this.renderer.styledMode) {
  11731. fontSizeStyle =
  11732. element && /(px|em)$/.test(element.style.fontSize) ?
  11733. element.style.fontSize :
  11734. (this.fontSize || this.renderer.style.fontSize || 12);
  11735. }
  11736. return this.textLineHeight ?
  11737. parseInt(this.textLineHeight.toString(), 10) :
  11738. this.renderer.fontMetrics(fontSizeStyle, element || this.svgElement.element).h;
  11739. };
  11740. /**
  11741. * Transform a pseudo HTML AST node tree into an SVG structure. We do as
  11742. * much heavy lifting as we can here, before doing the final processing in
  11743. * the modifyDOM function. The original data is mutated.
  11744. *
  11745. * @private
  11746. *
  11747. * @param {ASTNode[]} nodes The AST nodes
  11748. *
  11749. * @return {void}
  11750. */
  11751. TextBuilder.prototype.modifyTree = function (nodes) {
  11752. var _this = this;
  11753. var modifyChild = function (node,
  11754. i) {
  11755. var tagName = node.tagName;
  11756. var styledMode = _this.renderer.styledMode;
  11757. var attributes = node.attributes || {};
  11758. // Apply styling to text tags
  11759. if (tagName === 'b' || tagName === 'strong') {
  11760. if (styledMode) {
  11761. attributes['class'] = 'highcharts-strong'; // eslint-disable-line dot-notation
  11762. }
  11763. else {
  11764. attributes.style = 'font-weight:bold;' + (attributes.style || '');
  11765. }
  11766. }
  11767. else if (tagName === 'i' || tagName === 'em') {
  11768. if (styledMode) {
  11769. attributes['class'] = 'highcharts-emphasized'; // eslint-disable-line dot-notation
  11770. }
  11771. else {
  11772. attributes.style = 'font-style:italic;' + (attributes.style || '');
  11773. }
  11774. }
  11775. // Modify attributes
  11776. if (isString(attributes.style)) {
  11777. attributes.style = attributes.style.replace(/(;| |^)color([ :])/, '$1fill$2');
  11778. }
  11779. if (tagName === 'br') {
  11780. attributes['class'] = 'highcharts-br'; // eslint-disable-line dot-notation
  11781. node.textContent = '\u200B'; // zero-width space
  11782. // Trim whitespace off the beginning of new lines
  11783. var nextNode = nodes[i + 1];
  11784. if (nextNode && nextNode.textContent) {
  11785. nextNode.textContent =
  11786. nextNode.textContent.replace(/^ +/gm, '');
  11787. }
  11788. }
  11789. if (tagName !== '#text' && tagName !== 'a') {
  11790. node.tagName = 'tspan';
  11791. }
  11792. node.attributes = attributes;
  11793. // Recurse
  11794. if (node.children) {
  11795. node.children
  11796. .filter(function (c) { return c.tagName !== '#text'; })
  11797. .forEach(modifyChild);
  11798. }
  11799. };
  11800. nodes.forEach(modifyChild);
  11801. // Remove empty spans from the beginning because SVG's getBBox doesn't
  11802. // count empty lines. The use case is tooltip where the header is empty.
  11803. while (nodes[0]) {
  11804. if (nodes[0].tagName === 'tspan' && !nodes[0].children) {
  11805. nodes.splice(0, 1);
  11806. }
  11807. else {
  11808. break;
  11809. }
  11810. }
  11811. };
  11812. /*
  11813. * Truncate the text node contents to a given length. Used when the css
  11814. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  11815. * character by character to the given length. If not, the text is
  11816. * word-wrapped line by line.
  11817. */
  11818. TextBuilder.prototype.truncate = function (textNode, text, words, startAt, width, getString) {
  11819. var svgElement = this.svgElement;
  11820. var renderer = svgElement.renderer,
  11821. rotation = svgElement.rotation;
  11822. // Cache the lengths to avoid checking the same twice
  11823. var lengths = [];
  11824. // Word wrap can not be truncated to shorter than one word, ellipsis
  11825. // text can be completely blank.
  11826. var minIndex = words ? 1 : 0;
  11827. var maxIndex = (text || words || '').length;
  11828. var currentIndex = maxIndex;
  11829. var str;
  11830. var actualWidth;
  11831. var getSubStringLength = function (charEnd,
  11832. concatenatedEnd) {
  11833. // charEnd is used when finding the character-by-character
  11834. // break for ellipsis, concatenatedEnd is used for word-by-word
  11835. // break for word wrapping.
  11836. var end = concatenatedEnd || charEnd;
  11837. var parentNode = textNode.parentNode;
  11838. if (parentNode && typeof lengths[end] === 'undefined') {
  11839. // Modern browsers
  11840. if (parentNode.getSubStringLength) {
  11841. // Fails with DOM exception on unit-tests/legend/members
  11842. // of unknown reason. Desired width is 0, text content
  11843. // is "5" and end is 1.
  11844. try {
  11845. lengths[end] = startAt +
  11846. parentNode.getSubStringLength(0, words ? end + 1 : end);
  11847. }
  11848. catch (e) {
  11849. '';
  11850. }
  11851. // Legacy
  11852. }
  11853. else if (renderer.getSpanWidth) { // #9058 jsdom
  11854. textNode.textContent = getString(text || words, charEnd);
  11855. lengths[end] = startAt +
  11856. renderer.getSpanWidth(svgElement, textNode);
  11857. }
  11858. }
  11859. return lengths[end];
  11860. };
  11861. svgElement.rotation = 0; // discard rotation when computing box
  11862. actualWidth = getSubStringLength(textNode.textContent.length);
  11863. if (startAt + actualWidth > width) {
  11864. // Do a binary search for the index where to truncate the text
  11865. while (minIndex <= maxIndex) {
  11866. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  11867. // When checking words for word-wrap, we need to build the
  11868. // string and measure the subStringLength at the concatenated
  11869. // word length.
  11870. if (words) {
  11871. str = getString(words, currentIndex);
  11872. }
  11873. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  11874. if (minIndex === maxIndex) {
  11875. // Complete
  11876. minIndex = maxIndex + 1;
  11877. }
  11878. else if (actualWidth > width) {
  11879. // Too large. Set max index to current.
  11880. maxIndex = currentIndex - 1;
  11881. }
  11882. else {
  11883. // Within width. Set min index to current.
  11884. minIndex = currentIndex;
  11885. }
  11886. }
  11887. // If max index was 0 it means the shortest possible text was also
  11888. // too large. For ellipsis that means only the ellipsis, while for
  11889. // word wrap it means the whole first word.
  11890. if (maxIndex === 0) {
  11891. // Remove ellipsis
  11892. textNode.textContent = '';
  11893. // If the new text length is one less than the original, we don't
  11894. // need the ellipsis
  11895. }
  11896. else if (!(text && maxIndex === text.length - 1)) {
  11897. textNode.textContent = str || getString(text || words, currentIndex);
  11898. }
  11899. }
  11900. // When doing line wrapping, prepare for the next line by removing the
  11901. // items from this line.
  11902. if (words) {
  11903. words.splice(0, currentIndex);
  11904. }
  11905. svgElement.actualWidth = actualWidth;
  11906. svgElement.rotation = rotation; // Apply rotation again.
  11907. };
  11908. /*
  11909. * Un-escape HTML entities based on the public `renderer.escapes` list
  11910. *
  11911. * @private
  11912. *
  11913. * @param {string} inputStr The string to unescape
  11914. * @param {Array<string>} [except] Exceptions
  11915. *
  11916. * @return {string} The processed string
  11917. */
  11918. TextBuilder.prototype.unescapeEntities = function (inputStr, except) {
  11919. objectEach(this.renderer.escapes, function (value, key) {
  11920. if (!except || except.indexOf(value) === -1) {
  11921. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  11922. }
  11923. });
  11924. return inputStr;
  11925. };
  11926. return TextBuilder;
  11927. }());
  11928. return TextBuilder;
  11929. });
  11930. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Renderer/SVG/Symbols.js'], _modules['Core/Renderer/SVG/TextBuilder.js'], _modules['Core/Utilities.js']], function (AST, Color, H, Palette, RendererRegistry, SVGElement, SVGLabel, Symbols, TextBuilder, U) {
  11931. /* *
  11932. *
  11933. * (c) 2010-2021 Torstein Honsi
  11934. *
  11935. * License: www.highcharts.com/license
  11936. *
  11937. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11938. *
  11939. * */
  11940. var charts = H.charts,
  11941. deg2rad = H.deg2rad,
  11942. doc = H.doc,
  11943. isFirefox = H.isFirefox,
  11944. isMS = H.isMS,
  11945. isWebKit = H.isWebKit,
  11946. noop = H.noop,
  11947. SVG_NS = H.SVG_NS,
  11948. symbolSizes = H.symbolSizes,
  11949. win = H.win;
  11950. var addEvent = U.addEvent,
  11951. attr = U.attr,
  11952. createElement = U.createElement,
  11953. css = U.css,
  11954. defined = U.defined,
  11955. destroyObjectProperties = U.destroyObjectProperties,
  11956. extend = U.extend,
  11957. isArray = U.isArray,
  11958. isNumber = U.isNumber,
  11959. isObject = U.isObject,
  11960. isString = U.isString,
  11961. merge = U.merge,
  11962. pick = U.pick,
  11963. pInt = U.pInt,
  11964. uniqueKey = U.uniqueKey;
  11965. /* *
  11966. *
  11967. * Variables
  11968. *
  11969. * */
  11970. var hasInternalReferenceBug;
  11971. /* *
  11972. *
  11973. * Class
  11974. *
  11975. * */
  11976. /* eslint-disable no-invalid-this, valid-jsdoc */
  11977. /**
  11978. * Allows direct access to the Highcharts rendering layer in order to draw
  11979. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  11980. * or independent from any chart. The SVGRenderer represents a wrapper object
  11981. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  11982. * module, it also brings vector graphics to IE <= 8.
  11983. *
  11984. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  11985. * The renderer can also be used completely decoupled from a chart.
  11986. *
  11987. * @sample highcharts/members/renderer-on-chart
  11988. * Annotating a chart programmatically.
  11989. * @sample highcharts/members/renderer-basic
  11990. * Independent SVG drawing.
  11991. *
  11992. * @example
  11993. * // Use directly without a chart object.
  11994. * let renderer = new Highcharts.Renderer(parentNode, 600, 400);
  11995. *
  11996. * @class
  11997. * @name Highcharts.SVGRenderer
  11998. *
  11999. * @param {Highcharts.HTMLDOMElement} container
  12000. * Where to put the SVG in the web page.
  12001. *
  12002. * @param {number} width
  12003. * The width of the SVG.
  12004. *
  12005. * @param {number} height
  12006. * The height of the SVG.
  12007. *
  12008. * @param {Highcharts.CSSObject} [style]
  12009. * The box style, if not in styleMode
  12010. *
  12011. * @param {boolean} [forExport=false]
  12012. * Whether the rendered content is intended for export.
  12013. *
  12014. * @param {boolean} [allowHTML=true]
  12015. * Whether the renderer is allowed to include HTML text, which will be
  12016. * projected on top of the SVG.
  12017. *
  12018. * @param {boolean} [styledMode=false]
  12019. * Whether the renderer belongs to a chart that is in styled mode.
  12020. * If it does, it will avoid setting presentational attributes in
  12021. * some cases, but not when set explicitly through `.attr` and `.css`
  12022. * etc.
  12023. */
  12024. var SVGRenderer = /** @class */ (function () {
  12025. /* *
  12026. *
  12027. * Constructors
  12028. *
  12029. * */
  12030. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  12031. /* *
  12032. *
  12033. * Properties
  12034. *
  12035. * */
  12036. this.alignedObjects = void 0;
  12037. /**
  12038. * The root `svg` node of the renderer.
  12039. *
  12040. * @name Highcharts.SVGRenderer#box
  12041. * @type {Highcharts.SVGDOMElement}
  12042. */
  12043. this.box = void 0;
  12044. /**
  12045. * The wrapper for the root `svg` node of the renderer.
  12046. *
  12047. * @name Highcharts.SVGRenderer#boxWrapper
  12048. * @type {Highcharts.SVGElement}
  12049. */
  12050. this.boxWrapper = void 0;
  12051. this.cache = void 0;
  12052. this.cacheKeys = void 0;
  12053. this.chartIndex = void 0;
  12054. /**
  12055. * A pointer to the `defs` node of the root SVG.
  12056. *
  12057. * @name Highcharts.SVGRenderer#defs
  12058. * @type {Highcharts.SVGElement}
  12059. */
  12060. this.defs = void 0;
  12061. this.globalAnimation = void 0;
  12062. this.gradients = void 0;
  12063. this.height = void 0;
  12064. this.imgCount = void 0;
  12065. this.isSVG = void 0;
  12066. this.style = void 0;
  12067. /**
  12068. * Page url used for internal references.
  12069. *
  12070. * @private
  12071. * @name Highcharts.SVGRenderer#url
  12072. * @type {string}
  12073. */
  12074. this.url = void 0;
  12075. this.width = void 0;
  12076. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  12077. }
  12078. /* *
  12079. *
  12080. * Functions
  12081. *
  12082. * */
  12083. /**
  12084. * Initialize the SVGRenderer. Overridable initializer function that takes
  12085. * the same parameters as the constructor.
  12086. *
  12087. * @function Highcharts.SVGRenderer#init
  12088. *
  12089. * @param {Highcharts.HTMLDOMElement} container
  12090. * Where to put the SVG in the web page.
  12091. *
  12092. * @param {number} width
  12093. * The width of the SVG.
  12094. *
  12095. * @param {number} height
  12096. * The height of the SVG.
  12097. *
  12098. * @param {Highcharts.CSSObject} [style]
  12099. * The box style, if not in styleMode
  12100. *
  12101. * @param {boolean} [forExport=false]
  12102. * Whether the rendered content is intended for export.
  12103. *
  12104. * @param {boolean} [allowHTML=true]
  12105. * Whether the renderer is allowed to include HTML text, which will be
  12106. * projected on top of the SVG.
  12107. *
  12108. * @param {boolean} [styledMode=false]
  12109. * Whether the renderer belongs to a chart that is in styled mode. If it
  12110. * does, it will avoid setting presentational attributes in some cases, but
  12111. * not when set explicitly through `.attr` and `.css` etc.
  12112. */
  12113. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  12114. var renderer = this,
  12115. boxWrapper = renderer
  12116. .createElement('svg')
  12117. .attr({
  12118. version: '1.1',
  12119. 'class': 'highcharts-root'
  12120. }),
  12121. element = boxWrapper.element;
  12122. if (!styledMode) {
  12123. boxWrapper.css(this.getStyle(style));
  12124. }
  12125. container.appendChild(element);
  12126. // Always use ltr on the container, otherwise text-anchor will be
  12127. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  12128. attr(container, 'dir', 'ltr');
  12129. // For browsers other than IE, add the namespace attribute (#1978)
  12130. if (container.innerHTML.indexOf('xmlns') === -1) {
  12131. attr(element, 'xmlns', this.SVG_NS);
  12132. }
  12133. // object properties
  12134. renderer.isSVG = true;
  12135. this.box = element;
  12136. this.boxWrapper = boxWrapper;
  12137. renderer.alignedObjects = [];
  12138. this.url = this.getReferenceURL();
  12139. // Add description
  12140. var desc = this.createElement('desc').add();
  12141. desc.element.appendChild(doc.createTextNode('Created with Highcharts 9.1.1'));
  12142. renderer.defs = this.createElement('defs').add();
  12143. renderer.allowHTML = allowHTML;
  12144. renderer.forExport = forExport;
  12145. renderer.styledMode = styledMode;
  12146. renderer.gradients = {}; // Object where gradient SvgElements are stored
  12147. renderer.cache = {}; // Cache for numerical bounding boxes
  12148. renderer.cacheKeys = [];
  12149. renderer.imgCount = 0;
  12150. renderer.setSize(width, height, false);
  12151. // Issue 110 workaround:
  12152. // In Firefox, if a div is positioned by percentage, its pixel position
  12153. // may land between pixels. The container itself doesn't display this,
  12154. // but an SVG element inside this container will be drawn at subpixel
  12155. // precision. In order to draw sharp lines, this must be compensated
  12156. // for. This doesn't seem to work inside iframes though (like in
  12157. // jsFiddle).
  12158. var subPixelFix,
  12159. rect;
  12160. if (isFirefox && container.getBoundingClientRect) {
  12161. subPixelFix = function () {
  12162. css(container, { left: 0, top: 0 });
  12163. rect = container.getBoundingClientRect();
  12164. css(container, {
  12165. left: (Math.ceil(rect.left) - rect.left) + 'px',
  12166. top: (Math.ceil(rect.top) - rect.top) + 'px'
  12167. });
  12168. };
  12169. // run the fix now
  12170. subPixelFix();
  12171. // run it on resize
  12172. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  12173. }
  12174. };
  12175. /**
  12176. * General method for adding a definition to the SVG `defs` tag. Can be used
  12177. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  12178. * general definitions to the SVG's defs tag. Definitions can be referenced
  12179. * from the CSS by its `id`. Read more in
  12180. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  12181. * Styled mode only.
  12182. *
  12183. * @function Highcharts.SVGRenderer#definition
  12184. *
  12185. * @param {Highcharts.ASTNode} def
  12186. * A serialized form of an SVG definition, including children.
  12187. *
  12188. * @return {Highcharts.SVGElement}
  12189. * The inserted node.
  12190. */
  12191. SVGRenderer.prototype.definition = function (def) {
  12192. var ast = new AST([def]);
  12193. return ast.addToDOM(this.defs.element);
  12194. };
  12195. /**
  12196. * Get the prefix needed for internal URL references to work in certain
  12197. * cases. Some older browser versions had a bug where internal url
  12198. * references in SVG attributes, on the form `url(#some-id)`, would fail if
  12199. * a base tag was present in the page. There were also issues with
  12200. * `history.pushState` related to this prefix.
  12201. *
  12202. * Related issues: #24, #672, #1070, #5244.
  12203. *
  12204. * The affected browsers are:
  12205. * - Chrome <= 53 (May 2018)
  12206. * - Firefox <= 51 (January 2017)
  12207. * - Safari/Mac <= 12.1 (2018 or 2019)
  12208. * - Safari/iOS <= 13
  12209. *
  12210. * @todo Remove this hack when time has passed. All the affected browsers
  12211. * are evergreens, so it is increasingly unlikely that users are affected by
  12212. * the bug.
  12213. *
  12214. * @return {string}
  12215. * The prefix to use. An empty string for modern browsers.
  12216. */
  12217. SVGRenderer.prototype.getReferenceURL = function () {
  12218. if ((isFirefox || isWebKit) &&
  12219. doc.getElementsByTagName('base').length) {
  12220. // Detect if a clip path is taking effect by performing a hit test
  12221. // outside the clipped area. If the hit element is the rectangle
  12222. // that was supposed to be clipped, the bug is present. This only
  12223. // has to be performed once per page load, so we store the result
  12224. // locally in the module.
  12225. if (!defined(hasInternalReferenceBug)) {
  12226. var id = uniqueKey();
  12227. var ast = new AST([{
  12228. tagName: 'svg',
  12229. attributes: {
  12230. width: 8,
  12231. height: 8
  12232. },
  12233. children: [{
  12234. tagName: 'defs',
  12235. children: [{
  12236. tagName: 'clipPath',
  12237. attributes: {
  12238. id: id
  12239. },
  12240. children: [{
  12241. tagName: 'rect',
  12242. attributes: {
  12243. width: 4,
  12244. height: 4
  12245. }
  12246. }]
  12247. }]
  12248. }, {
  12249. tagName: 'rect',
  12250. attributes: {
  12251. id: 'hitme',
  12252. width: 8,
  12253. height: 8,
  12254. 'clip-path': "url(#" + id + ")",
  12255. fill: 'rgba(0,0,0,0.001)'
  12256. }
  12257. }]
  12258. }]);
  12259. var svg = ast.addToDOM(doc.body);
  12260. css(svg, {
  12261. position: 'fixed',
  12262. top: 0,
  12263. left: 0,
  12264. zIndex: 9e5
  12265. });
  12266. var hitElement = doc.elementFromPoint(6, 6);
  12267. hasInternalReferenceBug = (hitElement && hitElement.id) === 'hitme';
  12268. doc.body.removeChild(svg);
  12269. }
  12270. if (hasInternalReferenceBug) {
  12271. return win.location.href
  12272. .split('#')[0] // remove the hash
  12273. .replace(/<[^>]*>/g, '') // wing cut HTML
  12274. // escape parantheses and quotes
  12275. .replace(/([\('\)])/g, '\\$1')
  12276. // replace spaces (needed for Safari only)
  12277. .replace(/ /g, '%20');
  12278. }
  12279. }
  12280. return '';
  12281. };
  12282. /**
  12283. * Get the global style setting for the renderer.
  12284. *
  12285. * @private
  12286. * @function Highcharts.SVGRenderer#getStyle
  12287. *
  12288. * @param {Highcharts.CSSObject} style
  12289. * Style settings.
  12290. *
  12291. * @return {Highcharts.CSSObject}
  12292. * The style settings mixed with defaults.
  12293. */
  12294. SVGRenderer.prototype.getStyle = function (style) {
  12295. this.style = extend({
  12296. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  12297. 'Arial, Helvetica, sans-serif',
  12298. fontSize: '12px'
  12299. }, style);
  12300. return this.style;
  12301. };
  12302. /**
  12303. * Apply the global style on the renderer, mixed with the default styles.
  12304. *
  12305. * @function Highcharts.SVGRenderer#setStyle
  12306. *
  12307. * @param {Highcharts.CSSObject} style
  12308. * CSS to apply.
  12309. */
  12310. SVGRenderer.prototype.setStyle = function (style) {
  12311. this.boxWrapper.css(this.getStyle(style));
  12312. };
  12313. /**
  12314. * Detect whether the renderer is hidden. This happens when one of the
  12315. * parent elements has `display: none`. Used internally to detect when we
  12316. * needto render preliminarily in another div to get the text bounding boxes
  12317. * right.
  12318. *
  12319. * @function Highcharts.SVGRenderer#isHidden
  12320. *
  12321. * @return {boolean}
  12322. * True if it is hidden.
  12323. */
  12324. SVGRenderer.prototype.isHidden = function () {
  12325. return !this.boxWrapper.getBBox().width;
  12326. };
  12327. /**
  12328. * Destroys the renderer and its allocated members.
  12329. *
  12330. * @function Highcharts.SVGRenderer#destroy
  12331. *
  12332. * @return {null}
  12333. */
  12334. SVGRenderer.prototype.destroy = function () {
  12335. var renderer = this,
  12336. rendererDefs = renderer.defs;
  12337. renderer.box = null;
  12338. renderer.boxWrapper = renderer.boxWrapper.destroy();
  12339. // Call destroy on all gradient elements
  12340. destroyObjectProperties(renderer.gradients || {});
  12341. renderer.gradients = null;
  12342. // Defs are null in VMLRenderer
  12343. // Otherwise, destroy them here.
  12344. if (rendererDefs) {
  12345. renderer.defs = rendererDefs.destroy();
  12346. }
  12347. // Remove sub pixel fix handler (#982)
  12348. if (renderer.unSubPixelFix) {
  12349. renderer.unSubPixelFix();
  12350. }
  12351. renderer.alignedObjects = null;
  12352. return null;
  12353. };
  12354. /**
  12355. * Create a wrapper for an SVG element. Serves as a factory for
  12356. * {@link SVGElement}, but this function is itself mostly called from
  12357. * primitive factories like {@link SVGRenderer#path}, {@link
  12358. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  12359. *
  12360. * @function Highcharts.SVGRenderer#createElement
  12361. *
  12362. * @param {string} nodeName
  12363. * The node name, for example `rect`, `g` etc.
  12364. *
  12365. * @return {Highcharts.SVGElement}
  12366. * The generated SVGElement.
  12367. */
  12368. SVGRenderer.prototype.createElement = function (nodeName) {
  12369. var wrapper = new this.Element();
  12370. wrapper.init(this, nodeName);
  12371. return wrapper;
  12372. };
  12373. /**
  12374. * Get converted radial gradient attributes according to the radial
  12375. * reference. Used internally from the {@link SVGElement#colorGradient}
  12376. * function.
  12377. *
  12378. * @private
  12379. * @function Highcharts.SVGRenderer#getRadialAttr
  12380. */
  12381. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  12382. return {
  12383. cx: (radialReference[0] - radialReference[2] / 2) +
  12384. (gradAttr.cx || 0) * radialReference[2],
  12385. cy: (radialReference[1] - radialReference[2] / 2) +
  12386. (gradAttr.cy || 0) * radialReference[2],
  12387. r: (gradAttr.r || 0) * radialReference[2]
  12388. };
  12389. };
  12390. /**
  12391. * Parse a simple HTML string into SVG tspans. Called internally when text
  12392. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  12393. * text features like `width`, `text-overflow`, `white-space`, and also
  12394. * attributes like `href` and `style`.
  12395. *
  12396. * @private
  12397. * @function Highcharts.SVGRenderer#buildText
  12398. *
  12399. * @param {Highcharts.SVGElement} wrapper
  12400. * The parent SVGElement.
  12401. */
  12402. SVGRenderer.prototype.buildText = function (wrapper) {
  12403. new TextBuilder(wrapper).buildSVG();
  12404. };
  12405. /**
  12406. * Returns white for dark colors and black for bright colors.
  12407. *
  12408. * @function Highcharts.SVGRenderer#getContrast
  12409. *
  12410. * @param {Highcharts.ColorString} rgba
  12411. * The color to get the contrast for.
  12412. *
  12413. * @return {Highcharts.ColorString}
  12414. * The contrast color, either `#000000` or `#FFFFFF`.
  12415. */
  12416. SVGRenderer.prototype.getContrast = function (rgba) {
  12417. rgba = Color.parse(rgba).rgba;
  12418. // The threshold may be discussed. Here's a proposal for adding
  12419. // different weight to the color channels (#6216)
  12420. rgba[0] *= 1; // red
  12421. rgba[1] *= 1.2; // green
  12422. rgba[2] *= 0.5; // blue
  12423. return rgba[0] + rgba[1] + rgba[2] >
  12424. 1.8 * 255 ?
  12425. '#000000' :
  12426. '#FFFFFF';
  12427. };
  12428. /**
  12429. * Create a button with preset states.
  12430. *
  12431. * @function Highcharts.SVGRenderer#button
  12432. *
  12433. * @param {string} text
  12434. * The text or HTML to draw.
  12435. *
  12436. * @param {number} x
  12437. * The x position of the button's left side.
  12438. *
  12439. * @param {number} y
  12440. * The y position of the button's top side.
  12441. *
  12442. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  12443. * The function to execute on button click or touch.
  12444. *
  12445. * @param {Highcharts.SVGAttributes} [theme]
  12446. * SVG attributes for the normal state.
  12447. *
  12448. * @param {Highcharts.SVGAttributes} [hoverState]
  12449. * SVG attributes for the hover state.
  12450. *
  12451. * @param {Highcharts.SVGAttributes} [pressedState]
  12452. * SVG attributes for the pressed state.
  12453. *
  12454. * @param {Highcharts.SVGAttributes} [disabledState]
  12455. * SVG attributes for the disabled state.
  12456. *
  12457. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  12458. * The shape type.
  12459. *
  12460. * @param {boolean} [useHTML=false]
  12461. * Wether to use HTML to render the label.
  12462. *
  12463. * @return {Highcharts.SVGElement}
  12464. * The button element.
  12465. */
  12466. SVGRenderer.prototype.button = function (text, x, y, callback, theme, hoverState, pressedState, disabledState, shape, useHTML) {
  12467. var label = this.label(text,
  12468. x,
  12469. y,
  12470. shape,
  12471. void 0,
  12472. void 0,
  12473. useHTML,
  12474. void 0, 'button'),
  12475. styledMode = this.styledMode;
  12476. var curState = 0,
  12477. // Make a copy of normalState (#13798)
  12478. // (reference to options.rangeSelector.buttonTheme)
  12479. normalState = theme ? merge(theme) : {};
  12480. var userNormalStyle = normalState && normalState.style || {};
  12481. // Remove stylable attributes
  12482. normalState = AST.filterUserAttributes(normalState);
  12483. // Default, non-stylable attributes
  12484. label.attr(merge({ padding: 8, r: 2 }, normalState));
  12485. // Presentational
  12486. var normalStyle,
  12487. hoverStyle,
  12488. pressedStyle,
  12489. disabledStyle;
  12490. if (!styledMode) {
  12491. // Normal state - prepare the attributes
  12492. normalState = merge({
  12493. fill: Palette.neutralColor3,
  12494. stroke: Palette.neutralColor20,
  12495. 'stroke-width': 1,
  12496. style: {
  12497. color: Palette.neutralColor80,
  12498. cursor: 'pointer',
  12499. fontWeight: 'normal'
  12500. }
  12501. }, {
  12502. style: userNormalStyle
  12503. }, normalState);
  12504. normalStyle = normalState.style;
  12505. delete normalState.style;
  12506. // Hover state
  12507. hoverState = merge(normalState, {
  12508. fill: Palette.neutralColor10
  12509. }, AST.filterUserAttributes(hoverState || {}));
  12510. hoverStyle = hoverState.style;
  12511. delete hoverState.style;
  12512. // Pressed state
  12513. pressedState = merge(normalState, {
  12514. fill: Palette.highlightColor10,
  12515. style: {
  12516. color: Palette.neutralColor100,
  12517. fontWeight: 'bold'
  12518. }
  12519. }, AST.filterUserAttributes(pressedState || {}));
  12520. pressedStyle = pressedState.style;
  12521. delete pressedState.style;
  12522. // Disabled state
  12523. disabledState = merge(normalState, {
  12524. style: {
  12525. color: Palette.neutralColor20
  12526. }
  12527. }, AST.filterUserAttributes(disabledState || {}));
  12528. disabledStyle = disabledState.style;
  12529. delete disabledState.style;
  12530. }
  12531. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  12532. // (#667).
  12533. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  12534. if (curState !== 3) {
  12535. label.setState(1);
  12536. }
  12537. });
  12538. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  12539. if (curState !== 3) {
  12540. label.setState(curState);
  12541. }
  12542. });
  12543. label.setState = function (state) {
  12544. // Hover state is temporary, don't record it
  12545. if (state !== 1) {
  12546. label.state = curState = state;
  12547. }
  12548. // Update visuals
  12549. label
  12550. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  12551. .addClass('highcharts-button-' +
  12552. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  12553. if (!styledMode) {
  12554. label
  12555. .attr([
  12556. normalState,
  12557. hoverState,
  12558. pressedState,
  12559. disabledState
  12560. ][state || 0])
  12561. .css([
  12562. normalStyle,
  12563. hoverStyle,
  12564. pressedStyle,
  12565. disabledStyle
  12566. ][state || 0]);
  12567. }
  12568. };
  12569. // Presentational attributes
  12570. if (!styledMode) {
  12571. label
  12572. .attr(normalState)
  12573. .css(extend({ cursor: 'default' }, normalStyle));
  12574. }
  12575. return label
  12576. .on('touchstart', function (e) { return e.stopPropagation(); })
  12577. .on('click', function (e) {
  12578. if (curState !== 3) {
  12579. callback.call(label, e);
  12580. }
  12581. });
  12582. };
  12583. /**
  12584. * Make a straight line crisper by not spilling out to neighbour pixels.
  12585. *
  12586. * @function Highcharts.SVGRenderer#crispLine
  12587. *
  12588. * @param {Highcharts.SVGPathArray} points
  12589. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  12590. *
  12591. * @param {number} width
  12592. * The width of the line.
  12593. *
  12594. * @param {string} [roundingFunction=round]
  12595. * The rounding function name on the `Math` object, can be one of
  12596. * `round`, `floor` or `ceil`.
  12597. *
  12598. * @return {Highcharts.SVGPathArray}
  12599. * The original points array, but modified to render crisply.
  12600. */
  12601. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  12602. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  12603. var start = points[0];
  12604. var end = points[1];
  12605. // Normalize to a crisp line
  12606. if (defined(start[1]) && start[1] === end[1]) {
  12607. // Substract due to #1129. Now bottom and left axis gridlines behave
  12608. // the same.
  12609. start[1] = end[1] =
  12610. Math[roundingFunction](start[1]) - (width % 2 / 2);
  12611. }
  12612. if (defined(start[2]) && start[2] === end[2]) {
  12613. start[2] = end[2] =
  12614. Math[roundingFunction](start[2]) + (width % 2 / 2);
  12615. }
  12616. return points;
  12617. };
  12618. /**
  12619. * Draw a path, wraps the SVG `path` element.
  12620. *
  12621. * @sample highcharts/members/renderer-path-on-chart/
  12622. * Draw a path in a chart
  12623. * @sample highcharts/members/renderer-path/
  12624. * Draw a path independent from a chart
  12625. *
  12626. * @example
  12627. * let path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  12628. * .attr({ stroke: '#ff00ff' })
  12629. * .add();
  12630. *
  12631. * @function Highcharts.SVGRenderer#path
  12632. *
  12633. * @param {Highcharts.SVGPathArray} [path]
  12634. * An SVG path definition in array form.
  12635. *
  12636. * @return {Highcharts.SVGElement}
  12637. * The generated wrapper element.
  12638. *
  12639. */ /**
  12640. * Draw a path, wraps the SVG `path` element.
  12641. *
  12642. * @function Highcharts.SVGRenderer#path
  12643. *
  12644. * @param {Highcharts.SVGAttributes} [attribs]
  12645. * The initial attributes.
  12646. *
  12647. * @return {Highcharts.SVGElement}
  12648. * The generated wrapper element.
  12649. */
  12650. SVGRenderer.prototype.path = function (path) {
  12651. var attribs = (this.styledMode ? {} : {
  12652. fill: 'none'
  12653. });
  12654. if (isArray(path)) {
  12655. attribs.d = path;
  12656. }
  12657. else if (isObject(path)) { // attributes
  12658. extend(attribs, path);
  12659. }
  12660. return this.createElement('path').attr(attribs);
  12661. };
  12662. /**
  12663. * Draw a circle, wraps the SVG `circle` element.
  12664. *
  12665. * @sample highcharts/members/renderer-circle/
  12666. * Drawing a circle
  12667. *
  12668. * @function Highcharts.SVGRenderer#circle
  12669. *
  12670. * @param {number} [x]
  12671. * The center x position.
  12672. *
  12673. * @param {number} [y]
  12674. * The center y position.
  12675. *
  12676. * @param {number} [r]
  12677. * The radius.
  12678. *
  12679. * @return {Highcharts.SVGElement}
  12680. * The generated wrapper element.
  12681. */ /**
  12682. * Draw a circle, wraps the SVG `circle` element.
  12683. *
  12684. * @function Highcharts.SVGRenderer#circle
  12685. *
  12686. * @param {Highcharts.SVGAttributes} [attribs]
  12687. * The initial attributes.
  12688. *
  12689. * @return {Highcharts.SVGElement}
  12690. * The generated wrapper element.
  12691. */
  12692. SVGRenderer.prototype.circle = function (x, y, r) {
  12693. var attribs = (isObject(x) ?
  12694. x :
  12695. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  12696. // Setting x or y translates to cx and cy
  12697. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  12698. element.setAttribute('c' + key, value);
  12699. };
  12700. return wrapper.attr(attribs);
  12701. };
  12702. /**
  12703. * Draw and return an arc.
  12704. *
  12705. * @sample highcharts/members/renderer-arc/
  12706. * Drawing an arc
  12707. *
  12708. * @function Highcharts.SVGRenderer#arc
  12709. *
  12710. * @param {number} [x=0]
  12711. * Center X position.
  12712. *
  12713. * @param {number} [y=0]
  12714. * Center Y position.
  12715. *
  12716. * @param {number} [r=0]
  12717. * The outer radius' of the arc.
  12718. *
  12719. * @param {number} [innerR=0]
  12720. * Inner radius like used in donut charts.
  12721. *
  12722. * @param {number} [start=0]
  12723. * The starting angle of the arc in radians, where 0 is to the right and
  12724. * `-Math.PI/2` is up.
  12725. *
  12726. * @param {number} [end=0]
  12727. * The ending angle of the arc in radians, where 0 is to the right and
  12728. * `-Math.PI/2` is up.
  12729. *
  12730. * @return {Highcharts.SVGElement}
  12731. * The generated wrapper element.
  12732. */ /**
  12733. * Draw and return an arc. Overloaded function that takes arguments object.
  12734. *
  12735. * @function Highcharts.SVGRenderer#arc
  12736. *
  12737. * @param {Highcharts.SVGAttributes} attribs
  12738. * Initial SVG attributes.
  12739. *
  12740. * @return {Highcharts.SVGElement}
  12741. * The generated wrapper element.
  12742. */
  12743. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  12744. var options;
  12745. if (isObject(x)) {
  12746. options = x;
  12747. y = options.y;
  12748. r = options.r;
  12749. innerR = options.innerR;
  12750. start = options.start;
  12751. end = options.end;
  12752. x = options.x;
  12753. }
  12754. else {
  12755. options = { innerR: innerR, start: start, end: end };
  12756. }
  12757. // Arcs are defined as symbols for the ability to set
  12758. // attributes in attr and animate
  12759. var arc = this.symbol('arc',
  12760. x,
  12761. y,
  12762. r,
  12763. r,
  12764. options);
  12765. arc.r = r; // #959
  12766. return arc;
  12767. };
  12768. /**
  12769. * Draw and return a rectangle.
  12770. *
  12771. * @function Highcharts.SVGRenderer#rect
  12772. *
  12773. * @param {number} [x]
  12774. * Left position.
  12775. *
  12776. * @param {number} [y]
  12777. * Top position.
  12778. *
  12779. * @param {number} [width]
  12780. * Width of the rectangle.
  12781. *
  12782. * @param {number} [height]
  12783. * Height of the rectangle.
  12784. *
  12785. * @param {number} [r]
  12786. * Border corner radius.
  12787. *
  12788. * @param {number} [strokeWidth]
  12789. * A stroke width can be supplied to allow crisp drawing.
  12790. *
  12791. * @return {Highcharts.SVGElement}
  12792. * The generated wrapper element.
  12793. */ /**
  12794. * Draw and return a rectangle.
  12795. *
  12796. * @sample highcharts/members/renderer-rect-on-chart/
  12797. * Draw a rectangle in a chart
  12798. * @sample highcharts/members/renderer-rect/
  12799. * Draw a rectangle independent from a chart
  12800. *
  12801. * @function Highcharts.SVGRenderer#rect
  12802. *
  12803. * @param {Highcharts.SVGAttributes} [attributes]
  12804. * General SVG attributes for the rectangle.
  12805. *
  12806. * @return {Highcharts.SVGElement}
  12807. * The generated wrapper element.
  12808. */
  12809. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  12810. r = isObject(x) ? x.r : r;
  12811. var wrapper = this.createElement('rect');
  12812. var attribs = (isObject(x) ?
  12813. x :
  12814. typeof x === 'undefined' ?
  12815. {} :
  12816. {
  12817. x: x,
  12818. y: y,
  12819. width: Math.max(width, 0),
  12820. height: Math.max(height, 0)
  12821. });
  12822. if (!this.styledMode) {
  12823. if (typeof strokeWidth !== 'undefined') {
  12824. attribs['stroke-width'] = strokeWidth;
  12825. attribs = wrapper.crisp(attribs);
  12826. }
  12827. attribs.fill = 'none';
  12828. }
  12829. if (r) {
  12830. attribs.r = r;
  12831. }
  12832. wrapper.rSetter = function (value, _key, element) {
  12833. wrapper.r = value;
  12834. attr(element, {
  12835. rx: value,
  12836. ry: value
  12837. });
  12838. };
  12839. wrapper.rGetter = function () {
  12840. return wrapper.r || 0;
  12841. };
  12842. return wrapper.attr(attribs);
  12843. };
  12844. /**
  12845. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  12846. * elements.
  12847. *
  12848. * @sample highcharts/members/renderer-g/
  12849. * Show and hide grouped objects
  12850. *
  12851. * @function Highcharts.SVGRenderer#setSize
  12852. *
  12853. * @param {number} width
  12854. * The new pixel width.
  12855. *
  12856. * @param {number} height
  12857. * The new pixel height.
  12858. *
  12859. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  12860. * Whether and how to animate.
  12861. */
  12862. SVGRenderer.prototype.setSize = function (width, height, animate) {
  12863. var renderer = this;
  12864. renderer.width = width;
  12865. renderer.height = height;
  12866. renderer.boxWrapper.animate({
  12867. width: width,
  12868. height: height
  12869. }, {
  12870. step: function () {
  12871. this.attr({
  12872. viewBox: '0 0 ' + this.attr('width') + ' ' +
  12873. this.attr('height')
  12874. });
  12875. },
  12876. duration: pick(animate, true) ? void 0 : 0
  12877. });
  12878. renderer.alignElements();
  12879. };
  12880. /**
  12881. * Create and return an svg group element. Child
  12882. * {@link Highcharts.SVGElement} objects are added to the group by using the
  12883. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  12884. *
  12885. * @function Highcharts.SVGRenderer#g
  12886. *
  12887. * @param {string} [name]
  12888. * The group will be given a class name of `highcharts-{name}`. This
  12889. * can be used for styling and scripting.
  12890. *
  12891. * @return {Highcharts.SVGElement}
  12892. * The generated wrapper element.
  12893. */
  12894. SVGRenderer.prototype.g = function (name) {
  12895. var elem = this.createElement('g');
  12896. return name ?
  12897. elem.attr({ 'class': 'highcharts-' + name }) :
  12898. elem;
  12899. };
  12900. /**
  12901. * Display an image.
  12902. *
  12903. * @sample highcharts/members/renderer-image-on-chart/
  12904. * Add an image in a chart
  12905. * @sample highcharts/members/renderer-image/
  12906. * Add an image independent of a chart
  12907. *
  12908. * @function Highcharts.SVGRenderer#image
  12909. *
  12910. * @param {string} src
  12911. * The image source.
  12912. *
  12913. * @param {number} [x]
  12914. * The X position.
  12915. *
  12916. * @param {number} [y]
  12917. * The Y position.
  12918. *
  12919. * @param {number} [width]
  12920. * The image width. If omitted, it defaults to the image file width.
  12921. *
  12922. * @param {number} [height]
  12923. * The image height. If omitted it defaults to the image file
  12924. * height.
  12925. *
  12926. * @param {Function} [onload]
  12927. * Event handler for image load.
  12928. *
  12929. * @return {Highcharts.SVGElement}
  12930. * The generated wrapper element.
  12931. */
  12932. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  12933. var attribs = { preserveAspectRatio: 'none' }, setSVGImageSource = function (el, src) {
  12934. // Set the href in the xlink namespace
  12935. if (el.setAttributeNS) {
  12936. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  12937. }
  12938. else {
  12939. // could be exporting in IE
  12940. // using href throws "not supported" in ie7 and under,
  12941. // requries regex shim to fix later
  12942. el.setAttribute('hc-svg-href', src);
  12943. }
  12944. };
  12945. // optional properties
  12946. if (arguments.length > 1) {
  12947. extend(attribs, {
  12948. x: x,
  12949. y: y,
  12950. width: width,
  12951. height: height
  12952. });
  12953. }
  12954. var elemWrapper = this.createElement('image').attr(attribs),
  12955. onDummyLoad = function (e) {
  12956. setSVGImageSource(elemWrapper.element,
  12957. src);
  12958. onload.call(elemWrapper, e);
  12959. };
  12960. // Add load event if supplied
  12961. if (onload) {
  12962. // We have to use a dummy HTML image since IE support for SVG image
  12963. // load events is very buggy. First set a transparent src, wait for
  12964. // dummy to load, and then add the real src to the SVG image.
  12965. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  12966. var dummy = new win.Image();
  12967. addEvent(dummy, 'load', onDummyLoad);
  12968. dummy.src = src;
  12969. if (dummy.complete) {
  12970. onDummyLoad({});
  12971. }
  12972. }
  12973. else {
  12974. setSVGImageSource(elemWrapper.element, src);
  12975. }
  12976. return elemWrapper;
  12977. };
  12978. /**
  12979. * Draw a symbol out of pre-defined shape paths from
  12980. * {@link SVGRenderer#symbols}.
  12981. * It is used in Highcharts for point makers, which cake a `symbol` option,
  12982. * and label and button backgrounds like in the tooltip and stock flags.
  12983. *
  12984. * @function Highcharts.SVGRenderer#symbol
  12985. *
  12986. * @param {string} symbol
  12987. * The symbol name.
  12988. *
  12989. * @param {number} [x]
  12990. * The X coordinate for the top left position.
  12991. *
  12992. * @param {number} [y]
  12993. * The Y coordinate for the top left position.
  12994. *
  12995. * @param {number} [width]
  12996. * The pixel width.
  12997. *
  12998. * @param {number} [height]
  12999. * The pixel height.
  13000. *
  13001. * @param {Highcharts.SymbolOptionsObject} [options]
  13002. * Additional options, depending on the actual symbol drawn.
  13003. *
  13004. * @return {Highcharts.SVGElement}
  13005. */
  13006. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  13007. var ren = this,
  13008. imageRegex = /^url\((.*?)\)$/,
  13009. isImage = imageRegex.test(symbol),
  13010. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  13011. // get the symbol definition function
  13012. symbolFn = (sym && this.symbols[sym]);
  13013. var obj,
  13014. path,
  13015. imageSrc,
  13016. centerImage;
  13017. if (symbolFn) {
  13018. // Check if there's a path defined for this symbol
  13019. if (typeof x === 'number') {
  13020. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  13021. }
  13022. obj = this.path(path);
  13023. if (!ren.styledMode) {
  13024. obj.attr('fill', 'none');
  13025. }
  13026. // expando properties for use in animate and attr
  13027. extend(obj, {
  13028. symbolName: (sym || void 0),
  13029. x: x,
  13030. y: y,
  13031. width: width,
  13032. height: height
  13033. });
  13034. if (options) {
  13035. extend(obj, options);
  13036. }
  13037. // Image symbols
  13038. }
  13039. else if (isImage) {
  13040. imageSrc = symbol.match(imageRegex)[1];
  13041. // Create the image synchronously, add attribs async
  13042. var img_1 = obj = this.image(imageSrc);
  13043. // The image width is not always the same as the symbol width. The
  13044. // image may be centered within the symbol, as is the case when
  13045. // image shapes are used as label backgrounds, for example in flags.
  13046. img_1.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  13047. img_1.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  13048. /**
  13049. * Set the size and position
  13050. */
  13051. centerImage = function (obj) { return obj.attr({
  13052. width: obj.width,
  13053. height: obj.height
  13054. }); };
  13055. /**
  13056. * Width and height setters that take both the image's physical size
  13057. * and the label size into consideration, and translates the image
  13058. * to center within the label.
  13059. */
  13060. ['width', 'height'].forEach(function (key) {
  13061. img_1[key + 'Setter'] = function (value, key) {
  13062. var imgSize = this['img' + key];
  13063. this[key] = value;
  13064. if (defined(imgSize)) {
  13065. // Scale and center the image within its container.
  13066. // The name `backgroundSize` is taken from the CSS spec,
  13067. // but the value `within` is made up. Other possible
  13068. // values in the spec, `cover` and `contain`, can be
  13069. // implemented if needed.
  13070. if (options &&
  13071. options.backgroundSize === 'within' &&
  13072. this.width &&
  13073. this.height) {
  13074. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  13075. }
  13076. if (this.element) {
  13077. this.element.setAttribute(key, imgSize);
  13078. }
  13079. if (!this.alignByTranslate) {
  13080. var translate = ((this[key] || 0) - imgSize) / 2;
  13081. var attribs = key === 'width' ?
  13082. { translateX: translate } :
  13083. { translateY: translate };
  13084. this.attr(attribs);
  13085. }
  13086. }
  13087. };
  13088. });
  13089. if (defined(x)) {
  13090. img_1.attr({
  13091. x: x,
  13092. y: y
  13093. });
  13094. }
  13095. img_1.isImg = true;
  13096. if (defined(img_1.imgwidth) && defined(img_1.imgheight)) {
  13097. centerImage(img_1);
  13098. }
  13099. else {
  13100. // Initialize image to be 0 size so export will still function
  13101. // if there's no cached sizes.
  13102. img_1.attr({ width: 0, height: 0 });
  13103. // Create a dummy JavaScript image to get the width and height.
  13104. createElement('img', {
  13105. onload: function () {
  13106. var chart = charts[ren.chartIndex];
  13107. // Special case for SVGs on IE11, the width is not
  13108. // accessible until the image is part of the DOM
  13109. // (#2854).
  13110. if (this.width === 0) {
  13111. css(this, {
  13112. position: 'absolute',
  13113. top: '-999em'
  13114. });
  13115. doc.body.appendChild(this);
  13116. }
  13117. // Center the image
  13118. symbolSizes[imageSrc] = {
  13119. width: this.width,
  13120. height: this.height
  13121. };
  13122. img_1.imgwidth = this.width;
  13123. img_1.imgheight = this.height;
  13124. if (img_1.element) {
  13125. centerImage(img_1);
  13126. }
  13127. // Clean up after #2854 workaround.
  13128. if (this.parentNode) {
  13129. this.parentNode.removeChild(this);
  13130. }
  13131. // Fire the load event when all external images are
  13132. // loaded
  13133. ren.imgCount--;
  13134. if (!ren.imgCount && chart && !chart.hasLoaded) {
  13135. chart.onload();
  13136. }
  13137. },
  13138. src: imageSrc
  13139. });
  13140. this.imgCount++;
  13141. }
  13142. }
  13143. return obj;
  13144. };
  13145. /**
  13146. * Define a clipping rectangle. The clipping rectangle is later applied
  13147. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  13148. * function.
  13149. *
  13150. * @example
  13151. * let circle = renderer.circle(100, 100, 100)
  13152. * .attr({ fill: 'red' })
  13153. * .add();
  13154. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  13155. *
  13156. * // Leave only the lower right quarter visible
  13157. * circle.clip(clipRect);
  13158. *
  13159. * @function Highcharts.SVGRenderer#clipRect
  13160. *
  13161. * @param {number} [x]
  13162. *
  13163. * @param {number} [y]
  13164. *
  13165. * @param {number} [width]
  13166. *
  13167. * @param {number} [height]
  13168. *
  13169. * @return {Highcharts.ClipRectElement}
  13170. * A clipping rectangle.
  13171. */
  13172. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  13173. var
  13174. // Add a hyphen at the end to avoid confusion in testing indexes
  13175. // -1 and -10, -11 etc (#6550)
  13176. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  13177. id: id
  13178. }).add(this.defs), wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  13179. wrapper.id = id;
  13180. wrapper.clipPath = clipPath;
  13181. wrapper.count = 0;
  13182. return wrapper;
  13183. };
  13184. /**
  13185. * Draw text. The text can contain a subset of HTML, like spans and anchors
  13186. * and some basic text styling of these. For more advanced features like
  13187. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  13188. * To update the text after render, run `text.attr({ text: 'New text' })`.
  13189. *
  13190. * @sample highcharts/members/renderer-text-on-chart/
  13191. * Annotate the chart freely
  13192. * @sample highcharts/members/renderer-on-chart/
  13193. * Annotate with a border and in response to the data
  13194. * @sample highcharts/members/renderer-text/
  13195. * Formatted text
  13196. *
  13197. * @function Highcharts.SVGRenderer#text
  13198. *
  13199. * @param {string} [str]
  13200. * The text of (subset) HTML to draw.
  13201. *
  13202. * @param {number} [x]
  13203. * The x position of the text's lower left corner.
  13204. *
  13205. * @param {number} [y]
  13206. * The y position of the text's lower left corner.
  13207. *
  13208. * @param {boolean} [useHTML=false]
  13209. * Use HTML to render the text.
  13210. *
  13211. * @return {Highcharts.SVGElement}
  13212. * The text object.
  13213. */
  13214. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  13215. var renderer = this,
  13216. attribs = {};
  13217. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  13218. return renderer.html(str, x, y);
  13219. }
  13220. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  13221. if (y) {
  13222. attribs.y = Math.round(y);
  13223. }
  13224. if (defined(str)) {
  13225. attribs.text = str;
  13226. }
  13227. var wrapper = renderer.createElement('text').attr(attribs);
  13228. if (!useHTML) {
  13229. wrapper.xSetter = function (value, key, element) {
  13230. var tspans = element.getElementsByTagName('tspan'),
  13231. parentVal = element.getAttribute(key);
  13232. for (var i = 0, tspan = void 0; i < tspans.length; i++) {
  13233. tspan = tspans[i];
  13234. // If the x values are equal, the tspan represents a
  13235. // linebreak
  13236. if (tspan.getAttribute(key) === parentVal) {
  13237. tspan.setAttribute(key, value);
  13238. }
  13239. }
  13240. element.setAttribute(key, value);
  13241. };
  13242. }
  13243. return wrapper;
  13244. };
  13245. /**
  13246. * Utility to return the baseline offset and total line height from the font
  13247. * size.
  13248. *
  13249. * @function Highcharts.SVGRenderer#fontMetrics
  13250. *
  13251. * @param {number|string} [fontSize]
  13252. * The current font size to inspect. If not given, the font size
  13253. * will be found from the DOM element.
  13254. *
  13255. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  13256. * The element to inspect for a current font size.
  13257. *
  13258. * @return {Highcharts.FontMetricsObject}
  13259. * The font metrics.
  13260. */
  13261. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  13262. if ((this.styledMode || !/px/.test(fontSize)) &&
  13263. win.getComputedStyle // old IE doesn't support it
  13264. ) {
  13265. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  13266. }
  13267. else {
  13268. fontSize = fontSize ||
  13269. // When the elem is a DOM element (#5932)
  13270. (elem && elem.style && elem.style.fontSize) ||
  13271. // Fall back on the renderer style default
  13272. (this.style && this.style.fontSize);
  13273. }
  13274. // Handle different units
  13275. if (/px/.test(fontSize)) {
  13276. fontSize = pInt(fontSize);
  13277. }
  13278. else {
  13279. fontSize = 12;
  13280. }
  13281. // Empirical values found by comparing font size and bounding box
  13282. // height. Applies to the default font family.
  13283. // https://jsfiddle.net/highcharts/7xvn7/
  13284. var lineHeight = (fontSize < 24 ?
  13285. fontSize + 3 :
  13286. Math.round(fontSize * 1.2)),
  13287. baseline = Math.round(lineHeight * 0.8);
  13288. return {
  13289. h: lineHeight,
  13290. b: baseline,
  13291. f: fontSize
  13292. };
  13293. };
  13294. /**
  13295. * Correct X and Y positioning of a label for rotation (#1764).
  13296. *
  13297. * @private
  13298. * @function Highcharts.SVGRenderer#rotCorr
  13299. *
  13300. * @param {number} baseline
  13301. *
  13302. * @param {number} rotation
  13303. *
  13304. * @param {boolean} [alterY]
  13305. *
  13306. * @param {Highcharts.PositionObject}
  13307. */
  13308. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  13309. var y = baseline;
  13310. if (rotation && alterY) {
  13311. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  13312. }
  13313. return {
  13314. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  13315. y: y
  13316. };
  13317. };
  13318. /**
  13319. * Compatibility function to convert the legacy one-dimensional path array
  13320. * into an array of segments.
  13321. *
  13322. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  13323. * to support legacy paths from demos.
  13324. *
  13325. * @private
  13326. * @function Highcharts.SVGRenderer#pathToSegments
  13327. */
  13328. SVGRenderer.prototype.pathToSegments = function (path) {
  13329. var ret = [];
  13330. var segment = [];
  13331. var commandLength = {
  13332. A: 8,
  13333. C: 7,
  13334. H: 2,
  13335. L: 3,
  13336. M: 3,
  13337. Q: 5,
  13338. S: 5,
  13339. T: 3,
  13340. V: 2
  13341. };
  13342. // Short, non-typesafe parsing of the one-dimensional array. It splits
  13343. // the path on any string. This is not type checked against the tuple
  13344. // types, but is shorter, and doesn't require specific checks for any
  13345. // command type in SVG.
  13346. for (var i = 0; i < path.length; i++) {
  13347. // Command skipped, repeat previous or insert L/l for M/m
  13348. if (isString(segment[0]) &&
  13349. isNumber(path[i]) &&
  13350. segment.length === commandLength[(segment[0].toUpperCase())]) {
  13351. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  13352. }
  13353. // Split on string
  13354. if (typeof path[i] === 'string') {
  13355. if (segment.length) {
  13356. ret.push(segment.slice(0));
  13357. }
  13358. segment.length = 0;
  13359. }
  13360. segment.push(path[i]);
  13361. }
  13362. ret.push(segment.slice(0));
  13363. return ret;
  13364. /*
  13365. // Fully type-safe version where each tuple type is checked. The
  13366. // downside is filesize and a lack of flexibility for unsupported
  13367. // commands
  13368. const ret: SVGPath = [],
  13369. commands = {
  13370. A: 7,
  13371. C: 6,
  13372. H: 1,
  13373. L: 2,
  13374. M: 2,
  13375. Q: 4,
  13376. S: 4,
  13377. T: 2,
  13378. V: 1,
  13379. Z: 0
  13380. };
  13381. let i = 0,
  13382. lastI = 0,
  13383. lastCommand;
  13384. while (i < path.length) {
  13385. const item = path[i];
  13386. let command;
  13387. if (typeof item === 'string') {
  13388. command = item;
  13389. i += 1;
  13390. } else {
  13391. command = lastCommand || 'M';
  13392. }
  13393. // Upper case
  13394. const commandUC = command.toUpperCase();
  13395. if (commandUC in commands) {
  13396. // No numeric parameters
  13397. if (command === 'Z' || command === 'z') {
  13398. ret.push([command]);
  13399. // One numeric parameter
  13400. } else {
  13401. const val0 = path[i];
  13402. if (typeof val0 === 'number') {
  13403. // Horizontal line to
  13404. if (command === 'H' || command === 'h') {
  13405. ret.push([command, val0]);
  13406. i += 1;
  13407. // Vertical line to
  13408. } else if (command === 'V' || command === 'v') {
  13409. ret.push([command, val0]);
  13410. i += 1;
  13411. // Two numeric parameters
  13412. } else {
  13413. const val1 = path[i + 1];
  13414. if (typeof val1 === 'number') {
  13415. // lineTo
  13416. if (command === 'L' || command === 'l') {
  13417. ret.push([command, val0, val1]);
  13418. i += 2;
  13419. // moveTo
  13420. } else if (command === 'M' || command === 'm') {
  13421. ret.push([command, val0, val1]);
  13422. i += 2;
  13423. // Smooth quadratic bezier
  13424. } else if (command === 'T' || command === 't') {
  13425. ret.push([command, val0, val1]);
  13426. i += 2;
  13427. // Four numeric parameters
  13428. } else {
  13429. const val2 = path[i + 2],
  13430. val3 = path[i + 3];
  13431. if (
  13432. typeof val2 === 'number' &&
  13433. typeof val3 === 'number'
  13434. ) {
  13435. // Quadratic bezier to
  13436. if (
  13437. command === 'Q' ||
  13438. command === 'q'
  13439. ) {
  13440. ret.push([
  13441. command,
  13442. val0,
  13443. val1,
  13444. val2,
  13445. val3
  13446. ]);
  13447. i += 4;
  13448. // Smooth cubic bezier to
  13449. } else if (
  13450. command === 'S' ||
  13451. command === 's'
  13452. ) {
  13453. ret.push([
  13454. command,
  13455. val0,
  13456. val1,
  13457. val2,
  13458. val3
  13459. ]);
  13460. i += 4;
  13461. // Six numeric parameters
  13462. } else {
  13463. const val4 = path[i + 4],
  13464. val5 = path[i + 5];
  13465. if (
  13466. typeof val4 === 'number' &&
  13467. typeof val5 === 'number'
  13468. ) {
  13469. // Curve to
  13470. if (
  13471. command === 'C' ||
  13472. command === 'c'
  13473. ) {
  13474. ret.push([
  13475. command,
  13476. val0,
  13477. val1,
  13478. val2,
  13479. val3,
  13480. val4,
  13481. val5
  13482. ]);
  13483. i += 6;
  13484. // Seven numeric parameters
  13485. } else {
  13486. const val6 = path[i + 6];
  13487. // Arc to
  13488. if (
  13489. typeof val6 ===
  13490. 'number' &&
  13491. (
  13492. command === 'A' ||
  13493. command === 'a'
  13494. )
  13495. ) {
  13496. ret.push([
  13497. command,
  13498. val0,
  13499. val1,
  13500. val2,
  13501. val3,
  13502. val4,
  13503. val5,
  13504. val6
  13505. ]);
  13506. i += 7;
  13507. }
  13508. }
  13509. }
  13510. }
  13511. }
  13512. }
  13513. }
  13514. }
  13515. }
  13516. }
  13517. }
  13518. // An unmarked command following a moveTo is a lineTo
  13519. lastCommand = command === 'M' ? 'L' : command;
  13520. if (i === lastI) {
  13521. break;
  13522. }
  13523. lastI = i;
  13524. }
  13525. return ret;
  13526. */
  13527. };
  13528. /**
  13529. * Draw a label, which is an extended text element with support for border
  13530. * and background. Highcharts creates a `g` element with a text and a `path`
  13531. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  13532. * background are set through `stroke`, `stroke-width` and `fill` attributes
  13533. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  13534. * text after render, run `label.attr({ text: 'New text' })`.
  13535. *
  13536. * @sample highcharts/members/renderer-label-on-chart/
  13537. * A label on the chart
  13538. *
  13539. * @function Highcharts.SVGRenderer#label
  13540. *
  13541. * @param {string} str
  13542. * The initial text string or (subset) HTML to render.
  13543. *
  13544. * @param {number} x
  13545. * The x position of the label's left side.
  13546. *
  13547. * @param {number} [y]
  13548. * The y position of the label's top side or baseline, depending on
  13549. * the `baseline` parameter.
  13550. *
  13551. * @param {string} [shape='rect']
  13552. * The shape of the label's border/background, if any. Defaults to
  13553. * `rect`. Other possible values are `callout` or other shapes
  13554. * defined in {@link Highcharts.SVGRenderer#symbols}.
  13555. *
  13556. * @param {number} [anchorX]
  13557. * In case the `shape` has a pointer, like a flag, this is the
  13558. * coordinates it should be pinned to.
  13559. *
  13560. * @param {number} [anchorY]
  13561. * In case the `shape` has a pointer, like a flag, this is the
  13562. * coordinates it should be pinned to.
  13563. *
  13564. * @param {boolean} [useHTML=false]
  13565. * Wether to use HTML to render the label.
  13566. *
  13567. * @param {boolean} [baseline=false]
  13568. * Whether to position the label relative to the text baseline,
  13569. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  13570. * upper border of the rectangle.
  13571. *
  13572. * @param {string} [className]
  13573. * Class name for the group.
  13574. *
  13575. * @return {Highcharts.SVGElement}
  13576. * The generated label.
  13577. */
  13578. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  13579. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  13580. };
  13581. /**
  13582. * Re-align all aligned elements.
  13583. *
  13584. * @private
  13585. * @function Highcharts.SVGRenderer#alignElements
  13586. * @return {void}
  13587. */
  13588. SVGRenderer.prototype.alignElements = function () {
  13589. this.alignedObjects.forEach(function (el) { return el.align(); });
  13590. };
  13591. return SVGRenderer;
  13592. }());
  13593. extend(SVGRenderer.prototype, {
  13594. /**
  13595. * A pointer to the renderer's associated Element class. The VMLRenderer
  13596. * will have a pointer to VMLElement here.
  13597. *
  13598. * @name Highcharts.SVGRenderer#Element
  13599. * @type {Highcharts.SVGElement}
  13600. */
  13601. Element: SVGElement,
  13602. SVG_NS: SVG_NS,
  13603. /**
  13604. * A collection of characters mapped to HTML entities. When `useHTML` on an
  13605. * element is true, these entities will be rendered correctly by HTML. In
  13606. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  13607. * so for example `&lt;` will render as `<`.
  13608. *
  13609. * @example
  13610. * // Add support for unescaping quotes
  13611. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  13612. *
  13613. * @name Highcharts.SVGRenderer#escapes
  13614. * @type {Highcharts.Dictionary<string>}
  13615. */
  13616. escapes: {
  13617. '&': '&amp;',
  13618. '<': '&lt;',
  13619. '>': '&gt;',
  13620. "'": '&#39;',
  13621. '"': '&quot;'
  13622. },
  13623. /**
  13624. * An extendable collection of functions for defining symbol paths.
  13625. *
  13626. * @name Highcharts.SVGRenderer#symbols
  13627. * @type {Highcharts.SymbolDictionary}
  13628. */
  13629. symbols: Symbols,
  13630. /**
  13631. * Dummy function for plugins, called every time the renderer is updated.
  13632. * Prior to Highcharts 5, this was used for the canvg renderer.
  13633. *
  13634. * @deprecated
  13635. * @function Highcharts.SVGRenderer#draw
  13636. */
  13637. draw: noop
  13638. });
  13639. /* *
  13640. *
  13641. * Registry
  13642. *
  13643. * */
  13644. RendererRegistry.registerRendererType('svg', SVGRenderer, true);
  13645. /* *
  13646. *
  13647. * Export Default
  13648. *
  13649. * */
  13650. /* *
  13651. *
  13652. * API Declarations
  13653. *
  13654. * */
  13655. /**
  13656. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  13657. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  13658. * and applied with the {@link SVGElement#clip} function.
  13659. *
  13660. * @example
  13661. * let circle = renderer.circle(100, 100, 100)
  13662. * .attr({ fill: 'red' })
  13663. * .add();
  13664. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  13665. *
  13666. * // Leave only the lower right quarter visible
  13667. * circle.clip(clipRect);
  13668. *
  13669. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  13670. */
  13671. /**
  13672. * The font metrics.
  13673. *
  13674. * @interface Highcharts.FontMetricsObject
  13675. */ /**
  13676. * The baseline relative to the top of the box.
  13677. *
  13678. * @name Highcharts.FontMetricsObject#b
  13679. * @type {number}
  13680. */ /**
  13681. * The font size.
  13682. *
  13683. * @name Highcharts.FontMetricsObject#f
  13684. * @type {number}
  13685. */ /**
  13686. * The line height.
  13687. *
  13688. * @name Highcharts.FontMetricsObject#h
  13689. * @type {number}
  13690. */
  13691. /**
  13692. * An object containing `x` and `y` properties for the position of an element.
  13693. *
  13694. * @interface Highcharts.PositionObject
  13695. */ /**
  13696. * X position of the element.
  13697. * @name Highcharts.PositionObject#x
  13698. * @type {number}
  13699. */ /**
  13700. * Y position of the element.
  13701. * @name Highcharts.PositionObject#y
  13702. * @type {number}
  13703. */
  13704. /**
  13705. * A rectangle.
  13706. *
  13707. * @interface Highcharts.RectangleObject
  13708. */ /**
  13709. * Height of the rectangle.
  13710. * @name Highcharts.RectangleObject#height
  13711. * @type {number}
  13712. */ /**
  13713. * Width of the rectangle.
  13714. * @name Highcharts.RectangleObject#width
  13715. * @type {number}
  13716. */ /**
  13717. * Horizontal position of the rectangle.
  13718. * @name Highcharts.RectangleObject#x
  13719. * @type {number}
  13720. */ /**
  13721. * Vertical position of the rectangle.
  13722. * @name Highcharts.RectangleObject#y
  13723. * @type {number}
  13724. */
  13725. /**
  13726. * The shadow options.
  13727. *
  13728. * @interface Highcharts.ShadowOptionsObject
  13729. */ /**
  13730. * The shadow color.
  13731. * @name Highcharts.ShadowOptionsObject#color
  13732. * @type {Highcharts.ColorString|undefined}
  13733. * @default ${palette.neutralColor100}
  13734. */ /**
  13735. * The horizontal offset from the element.
  13736. *
  13737. * @name Highcharts.ShadowOptionsObject#offsetX
  13738. * @type {number|undefined}
  13739. * @default 1
  13740. */ /**
  13741. * The vertical offset from the element.
  13742. * @name Highcharts.ShadowOptionsObject#offsetY
  13743. * @type {number|undefined}
  13744. * @default 1
  13745. */ /**
  13746. * The shadow opacity.
  13747. *
  13748. * @name Highcharts.ShadowOptionsObject#opacity
  13749. * @type {number|undefined}
  13750. * @default 0.15
  13751. */ /**
  13752. * The shadow width or distance from the element.
  13753. * @name Highcharts.ShadowOptionsObject#width
  13754. * @type {number|undefined}
  13755. * @default 3
  13756. */
  13757. /**
  13758. * @interface Highcharts.SizeObject
  13759. */ /**
  13760. * @name Highcharts.SizeObject#height
  13761. * @type {number}
  13762. */ /**
  13763. * @name Highcharts.SizeObject#width
  13764. * @type {number}
  13765. */
  13766. /**
  13767. * Array of path commands, that will go into the `d` attribute of an SVG
  13768. * element.
  13769. *
  13770. * @typedef {Array<(Array<Highcharts.SVGPathCommand>|Array<Highcharts.SVGPathCommand,number>|Array<Highcharts.SVGPathCommand,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number,number>)>} Highcharts.SVGPathArray
  13771. */
  13772. /**
  13773. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  13774. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  13775. *
  13776. * @typedef {string} Highcharts.SVGPathCommand
  13777. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  13778. */
  13779. /**
  13780. * An extendable collection of functions for defining symbol paths. Symbols are
  13781. * used internally for point markers, button and label borders and backgrounds,
  13782. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  13783. *
  13784. * @interface Highcharts.SymbolDictionary
  13785. */ /**
  13786. * @name Highcharts.SymbolDictionary#[key:string]
  13787. * @type {Function|undefined}
  13788. */ /**
  13789. * @name Highcharts.SymbolDictionary#arc
  13790. * @type {Function|undefined}
  13791. */ /**
  13792. * @name Highcharts.SymbolDictionary#callout
  13793. * @type {Function|undefined}
  13794. */ /**
  13795. * @name Highcharts.SymbolDictionary#circle
  13796. * @type {Function|undefined}
  13797. */ /**
  13798. * @name Highcharts.SymbolDictionary#diamond
  13799. * @type {Function|undefined}
  13800. */ /**
  13801. * @name Highcharts.SymbolDictionary#square
  13802. * @type {Function|undefined}
  13803. */ /**
  13804. * @name Highcharts.SymbolDictionary#triangle
  13805. * @type {Function|undefined}
  13806. */
  13807. /**
  13808. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  13809. * and `triangle-down`. Symbols are used internally for point markers, button
  13810. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  13811. * {@link SVGRenderer#symbols}.
  13812. *
  13813. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  13814. */
  13815. /**
  13816. * Additional options, depending on the actual symbol drawn.
  13817. *
  13818. * @interface Highcharts.SymbolOptionsObject
  13819. */ /**
  13820. * The anchor X position for the `callout` symbol. This is where the chevron
  13821. * points to.
  13822. *
  13823. * @name Highcharts.SymbolOptionsObject#anchorX
  13824. * @type {number|undefined}
  13825. */ /**
  13826. * The anchor Y position for the `callout` symbol. This is where the chevron
  13827. * points to.
  13828. *
  13829. * @name Highcharts.SymbolOptionsObject#anchorY
  13830. * @type {number|undefined}
  13831. */ /**
  13832. * The end angle of an `arc` symbol.
  13833. *
  13834. * @name Highcharts.SymbolOptionsObject#end
  13835. * @type {number|undefined}
  13836. */ /**
  13837. * Whether to draw `arc` symbol open or closed.
  13838. *
  13839. * @name Highcharts.SymbolOptionsObject#open
  13840. * @type {boolean|undefined}
  13841. */ /**
  13842. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  13843. *
  13844. * @name Highcharts.SymbolOptionsObject#r
  13845. * @type {number|undefined}
  13846. */ /**
  13847. * The start angle of an `arc` symbol.
  13848. *
  13849. * @name Highcharts.SymbolOptionsObject#start
  13850. * @type {number|undefined}
  13851. */
  13852. (''); // keeps doclets above in transpiled file
  13853. return SVGRenderer;
  13854. });
  13855. _registerModule(_modules, 'Core/Renderer/HTML/HTMLElement.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (H, SVGElement, U) {
  13856. /* *
  13857. *
  13858. * (c) 2010-2021 Torstein Honsi
  13859. *
  13860. * License: www.highcharts.com/license
  13861. *
  13862. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13863. *
  13864. * */
  13865. var __extends = (this && this.__extends) || (function () {
  13866. var extendStatics = function (d,
  13867. b) {
  13868. extendStatics = Object.setPrototypeOf ||
  13869. ({ __proto__: [] } instanceof Array && function (d,
  13870. b) { d.__proto__ = b; }) ||
  13871. function (d,
  13872. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13873. return extendStatics(d, b);
  13874. };
  13875. return function (d, b) {
  13876. extendStatics(d, b);
  13877. function __() { this.constructor = d; }
  13878. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13879. };
  13880. })();
  13881. var isFirefox = H.isFirefox,
  13882. isMS = H.isMS,
  13883. isWebKit = H.isWebKit,
  13884. win = H.win;
  13885. var css = U.css,
  13886. defined = U.defined,
  13887. extend = U.extend,
  13888. pick = U.pick,
  13889. pInt = U.pInt;
  13890. /* *
  13891. *
  13892. * Composition
  13893. *
  13894. * */
  13895. /* eslint-disable valid-jsdoc */
  13896. var HTMLElement = /** @class */ (function (_super) {
  13897. __extends(HTMLElement, _super);
  13898. function HTMLElement() {
  13899. return _super !== null && _super.apply(this, arguments) || this;
  13900. }
  13901. /* *
  13902. *
  13903. * Static Functions
  13904. *
  13905. * */
  13906. /**
  13907. * Modifies SVGElement to support HTML elements.
  13908. * @private
  13909. */
  13910. HTMLElement.compose = function (SVGElementClass) {
  13911. var svgElementProto = SVGElementClass.prototype,
  13912. htmlElementProto = HTMLElement.prototype;
  13913. svgElementProto.getSpanCorrection = htmlElementProto.getSpanCorrection;
  13914. svgElementProto.htmlCss = htmlElementProto.htmlCss;
  13915. svgElementProto.htmlGetBBox = htmlElementProto.htmlGetBBox;
  13916. svgElementProto.htmlUpdateTransform = htmlElementProto.htmlUpdateTransform;
  13917. svgElementProto.setSpanRotation = htmlElementProto.setSpanRotation;
  13918. };
  13919. /* *
  13920. *
  13921. * Functions
  13922. *
  13923. * */
  13924. /**
  13925. * Get the correction in X and Y positioning as the element is rotated.
  13926. * @private
  13927. */
  13928. HTMLElement.prototype.getSpanCorrection = function (width, baseline, alignCorrection) {
  13929. this.xCorr = -width * alignCorrection;
  13930. this.yCorr = -baseline;
  13931. };
  13932. /**
  13933. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  13934. * by the VML renderer
  13935. * @private
  13936. */
  13937. HTMLElement.prototype.htmlCss = function (styles) {
  13938. var wrapper = this,
  13939. element = wrapper.element,
  13940. // When setting or unsetting the width style, we need to update
  13941. // transform (#8809)
  13942. isSettingWidth = (element.tagName === 'SPAN' &&
  13943. styles &&
  13944. 'width' in styles),
  13945. textWidth = pick(isSettingWidth && styles.width,
  13946. void 0);
  13947. var doTransform;
  13948. if (isSettingWidth) {
  13949. delete styles.width;
  13950. wrapper.textWidth = textWidth;
  13951. doTransform = true;
  13952. }
  13953. if (styles && styles.textOverflow === 'ellipsis') {
  13954. styles.whiteSpace = 'nowrap';
  13955. styles.overflow = 'hidden';
  13956. }
  13957. wrapper.styles = extend(wrapper.styles, styles);
  13958. css(wrapper.element, styles);
  13959. // Now that all styles are applied, to the transform
  13960. if (doTransform) {
  13961. wrapper.htmlUpdateTransform();
  13962. }
  13963. return wrapper;
  13964. };
  13965. /**
  13966. * VML and useHTML method for calculating the bounding box based on offsets.
  13967. */
  13968. HTMLElement.prototype.htmlGetBBox = function () {
  13969. var wrapper = this,
  13970. element = wrapper.element;
  13971. return {
  13972. x: element.offsetLeft,
  13973. y: element.offsetTop,
  13974. width: element.offsetWidth,
  13975. height: element.offsetHeight
  13976. };
  13977. };
  13978. /**
  13979. * VML override private method to update elements based on internal
  13980. * properties based on SVG transform.
  13981. * @private
  13982. */
  13983. HTMLElement.prototype.htmlUpdateTransform = function () {
  13984. // aligning non added elements is expensive
  13985. if (!this.added) {
  13986. this.alignOnAdd = true;
  13987. return;
  13988. }
  13989. var wrapper = this,
  13990. renderer = wrapper.renderer,
  13991. elem = wrapper.element,
  13992. translateX = wrapper.translateX || 0,
  13993. translateY = wrapper.translateY || 0,
  13994. x = wrapper.x || 0,
  13995. y = wrapper.y || 0,
  13996. align = wrapper.textAlign || 'left',
  13997. alignCorrection = {
  13998. left: 0,
  13999. center: 0.5,
  14000. right: 1
  14001. }[align],
  14002. styles = wrapper.styles,
  14003. whiteSpace = styles && styles.whiteSpace;
  14004. /** @private */
  14005. function getTextPxLength() {
  14006. // Reset multiline/ellipsis in order to read width (#4928,
  14007. // #5417)
  14008. css(elem, {
  14009. width: '',
  14010. whiteSpace: whiteSpace || 'nowrap'
  14011. });
  14012. return elem.offsetWidth;
  14013. }
  14014. // apply translate
  14015. css(elem, {
  14016. marginLeft: translateX,
  14017. marginTop: translateY
  14018. });
  14019. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  14020. wrapper.shadows.forEach(function (shadow) {
  14021. css(shadow, {
  14022. marginLeft: translateX + 1,
  14023. marginTop: translateY + 1
  14024. });
  14025. });
  14026. }
  14027. // apply inversion
  14028. if (wrapper.inverted) { // wrapper is a group
  14029. [].forEach.call(elem.childNodes, function (child) {
  14030. renderer.invertChild(child, elem);
  14031. });
  14032. }
  14033. if (elem.tagName === 'SPAN') {
  14034. var rotation = wrapper.rotation, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  14035. rotation,
  14036. align,
  14037. elem.innerHTML,
  14038. wrapper.textWidth,
  14039. wrapper.textAlign
  14040. ].join(',');
  14041. var baseline = void 0;
  14042. // Update textWidth. Use the memoized textPxLength if possible, to
  14043. // avoid the getTextPxLength function using elem.offsetWidth.
  14044. // Calling offsetWidth affects rendering time as it forces layout
  14045. // (#7656).
  14046. if (textWidth !== wrapper.oldTextWidth &&
  14047. ((textWidth > wrapper.oldTextWidth) ||
  14048. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  14049. // Only set the width if the text is able to word-wrap, or
  14050. // text-overflow is ellipsis (#9537)
  14051. /[ \-]/.test(elem.textContent || elem.innerText) ||
  14052. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  14053. css(elem, {
  14054. width: textWidth + 'px',
  14055. display: 'block',
  14056. whiteSpace: whiteSpace || 'normal' // #3331
  14057. });
  14058. wrapper.oldTextWidth = textWidth;
  14059. wrapper.hasBoxWidthChanged = true; // #8159
  14060. }
  14061. else {
  14062. wrapper.hasBoxWidthChanged = false; // #8159
  14063. }
  14064. // Do the calculations and DOM access only if properties changed
  14065. if (currentTextTransform !== wrapper.cTT) {
  14066. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  14067. // Renderer specific handling of span rotation, but only if we
  14068. // have something to update.
  14069. if (defined(rotation) &&
  14070. ((rotation !== (wrapper.oldRotation || 0)) ||
  14071. (align !== wrapper.oldAlign))) {
  14072. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  14073. }
  14074. wrapper.getSpanCorrection(
  14075. // Avoid elem.offsetWidth if we can, it affects rendering
  14076. // time heavily (#7656)
  14077. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  14078. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  14079. }
  14080. // apply position with correction
  14081. css(elem, {
  14082. left: (x + (wrapper.xCorr || 0)) + 'px',
  14083. top: (y + (wrapper.yCorr || 0)) + 'px'
  14084. });
  14085. // record current text transform
  14086. wrapper.cTT = currentTextTransform;
  14087. wrapper.oldRotation = rotation;
  14088. wrapper.oldAlign = align;
  14089. }
  14090. };
  14091. /**
  14092. * Set the rotation of an individual HTML span.
  14093. * @private
  14094. */
  14095. HTMLElement.prototype.setSpanRotation = function (rotation, alignCorrection, baseline) {
  14096. var getTransformKey = function () { return (isMS &&
  14097. !/Edge/.test(win.navigator.userAgent) ?
  14098. '-ms-transform' :
  14099. isWebKit ?
  14100. '-webkit-transform' :
  14101. isFirefox ?
  14102. 'MozTransform' :
  14103. win.opera ?
  14104. '-o-transform' :
  14105. void 0); };
  14106. var rotationStyle = {},
  14107. cssTransformKey = getTransformKey();
  14108. if (cssTransformKey) {
  14109. rotationStyle[cssTransformKey] = rotationStyle.transform =
  14110. 'rotate(' + rotation + 'deg)';
  14111. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin =
  14112. (alignCorrection * 100) + '% ' + baseline + 'px';
  14113. css(this.element, rotationStyle);
  14114. }
  14115. };
  14116. return HTMLElement;
  14117. }(SVGElement));
  14118. /* *
  14119. *
  14120. * Default Export
  14121. *
  14122. * */
  14123. return HTMLElement;
  14124. });
  14125. _registerModule(_modules, 'Core/Renderer/HTML/HTMLRenderer.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (AST, SVGElement, SVGRenderer, U) {
  14126. /* *
  14127. *
  14128. * (c) 2010-2021 Torstein Honsi
  14129. *
  14130. * License: www.highcharts.com/license
  14131. *
  14132. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14133. *
  14134. * */
  14135. var __extends = (this && this.__extends) || (function () {
  14136. var extendStatics = function (d,
  14137. b) {
  14138. extendStatics = Object.setPrototypeOf ||
  14139. ({ __proto__: [] } instanceof Array && function (d,
  14140. b) { d.__proto__ = b; }) ||
  14141. function (d,
  14142. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14143. return extendStatics(d, b);
  14144. };
  14145. return function (d, b) {
  14146. extendStatics(d, b);
  14147. function __() { this.constructor = d; }
  14148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14149. };
  14150. })();
  14151. var attr = U.attr,
  14152. createElement = U.createElement,
  14153. extend = U.extend,
  14154. pick = U.pick;
  14155. /* *
  14156. *
  14157. * Composition
  14158. *
  14159. * */
  14160. /* eslint-disable valid-jsdoc */
  14161. // Extend SvgRenderer for useHTML option.
  14162. var HTMLRenderer = /** @class */ (function (_super) {
  14163. __extends(HTMLRenderer, _super);
  14164. function HTMLRenderer() {
  14165. return _super !== null && _super.apply(this, arguments) || this;
  14166. }
  14167. /* *
  14168. *
  14169. * Functions
  14170. *
  14171. * */
  14172. /** @private */
  14173. HTMLRenderer.compose = function (SVGRendererClass) {
  14174. var svgRendererProto = SVGRendererClass.prototype,
  14175. htmlRendererProto = HTMLRenderer.prototype;
  14176. svgRendererProto.html = htmlRendererProto.html;
  14177. };
  14178. /**
  14179. * Create HTML text node. This is used by the VML renderer as well as the
  14180. * SVG renderer through the useHTML option.
  14181. *
  14182. * @private
  14183. * @function Highcharts.SVGRenderer#html
  14184. *
  14185. * @param {string} str
  14186. * The text of (subset) HTML to draw.
  14187. *
  14188. * @param {number} x
  14189. * The x position of the text's lower left corner.
  14190. *
  14191. * @param {number} y
  14192. * The y position of the text's lower left corner.
  14193. *
  14194. * @return {Highcharts.HTMLDOMElement}
  14195. */
  14196. HTMLRenderer.prototype.html = function (str, x, y) {
  14197. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  14198. // These properties are set as attributes on the SVG group, and
  14199. // as identical CSS properties on the div. (#3542)
  14200. ['opacity', 'visibility'].forEach(function (prop) {
  14201. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  14202. var styleObject = gWrapper.div ?
  14203. gWrapper.div.style :
  14204. style;
  14205. SVGElement.prototype[prop + 'Setter']
  14206. .call(this, value, key, elem);
  14207. if (styleObject) {
  14208. styleObject[key] = value;
  14209. }
  14210. };
  14211. });
  14212. gWrapper.addedSetters = true;
  14213. };
  14214. // Text setter
  14215. wrapper.textSetter = function (value) {
  14216. if (value !== this.textStr) {
  14217. delete this.bBox;
  14218. delete this.oldTextWidth;
  14219. AST.setElementHTML(this.element, pick(value, ''));
  14220. this.textStr = value;
  14221. wrapper.doTransform = true;
  14222. }
  14223. };
  14224. // Add setters for the element itself (#4938)
  14225. if (isSVG) { // #4938, only for HTML within SVG
  14226. addSetters(wrapper, wrapper.element.style);
  14227. }
  14228. // Various setters which rely on update transform
  14229. wrapper.xSetter =
  14230. wrapper.ySetter =
  14231. wrapper.alignSetter =
  14232. wrapper.rotationSetter =
  14233. function (value, key) {
  14234. if (key === 'align') {
  14235. // Do not overwrite the SVGElement.align method. Same as VML.
  14236. wrapper.alignValue = wrapper.textAlign = value;
  14237. }
  14238. else {
  14239. wrapper[key] = value;
  14240. }
  14241. wrapper.doTransform = true;
  14242. };
  14243. // Runs at the end of .attr()
  14244. wrapper.afterSetters = function () {
  14245. // Update transform. Do this outside the loop to prevent redundant
  14246. // updating for batch setting of attributes.
  14247. if (this.doTransform) {
  14248. this.htmlUpdateTransform();
  14249. this.doTransform = false;
  14250. }
  14251. };
  14252. // Set the default attributes
  14253. wrapper
  14254. .attr({
  14255. text: str,
  14256. x: Math.round(x),
  14257. y: Math.round(y)
  14258. })
  14259. .css({
  14260. position: 'absolute'
  14261. });
  14262. if (!renderer.styledMode) {
  14263. wrapper.css({
  14264. fontFamily: this.style.fontFamily,
  14265. fontSize: this.style.fontSize
  14266. });
  14267. }
  14268. // Keep the whiteSpace style outside the wrapper.styles collection
  14269. element.style.whiteSpace = 'nowrap';
  14270. // Use the HTML specific .css method
  14271. wrapper.css = wrapper.htmlCss;
  14272. // This is specific for HTML within SVG
  14273. if (isSVG) {
  14274. wrapper.add = function (svgGroupWrapper) {
  14275. var htmlGroup,
  14276. container = renderer.box.parentNode,
  14277. parentGroup,
  14278. parents = [];
  14279. this.parentGroup = svgGroupWrapper;
  14280. // Create a mock group to hold the HTML elements
  14281. if (svgGroupWrapper) {
  14282. htmlGroup = svgGroupWrapper.div;
  14283. if (!htmlGroup) {
  14284. // Read the parent chain into an array and read from top
  14285. // down
  14286. parentGroup = svgGroupWrapper;
  14287. while (parentGroup) {
  14288. parents.push(parentGroup);
  14289. // Move up to the next parent group
  14290. parentGroup = parentGroup.parentGroup;
  14291. }
  14292. // Ensure dynamically updating position when any parent
  14293. // is translated
  14294. parents.reverse().forEach(function (parentGroup) {
  14295. var htmlGroupStyle,
  14296. cls = attr(parentGroup.element, 'class');
  14297. /**
  14298. * Common translate setter for X and Y on the HTML
  14299. * group. Reverted the fix for #6957 du to
  14300. * positioning problems and offline export (#7254,
  14301. * #7280, #7529)
  14302. * @private
  14303. * @param {*} value
  14304. * @param {string} key
  14305. * @return {void}
  14306. */
  14307. function translateSetter(value, key) {
  14308. parentGroup[key] = value;
  14309. if (key === 'translateX') {
  14310. htmlGroupStyle.left = value + 'px';
  14311. }
  14312. else {
  14313. htmlGroupStyle.top = value + 'px';
  14314. }
  14315. parentGroup.doTransform = true;
  14316. }
  14317. // Create a HTML div and append it to the parent div
  14318. // to emulate the SVG group structure
  14319. var parentGroupStyles = parentGroup.styles || {};
  14320. htmlGroup =
  14321. parentGroup.div =
  14322. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  14323. position: 'absolute',
  14324. left: (parentGroup.translateX || 0) + 'px',
  14325. top: (parentGroup.translateY || 0) + 'px',
  14326. display: parentGroup.display,
  14327. opacity: parentGroup.opacity,
  14328. cursor: parentGroupStyles.cursor,
  14329. pointerEvents: parentGroupStyles.pointerEvents // #5595
  14330. // the top group is appended to container
  14331. }, htmlGroup || container);
  14332. // Shortcut
  14333. htmlGroupStyle = htmlGroup.style;
  14334. // Set listeners to update the HTML div's position
  14335. // whenever the SVG group position is changed.
  14336. extend(parentGroup, {
  14337. // (#7287) Pass htmlGroup to use
  14338. // the related group
  14339. classSetter: (function (htmlGroup) {
  14340. return function (value) {
  14341. this.element.setAttribute('class', value);
  14342. htmlGroup.className = value;
  14343. };
  14344. }(htmlGroup)),
  14345. on: function () {
  14346. if (parents[0].div) { // #6418
  14347. wrapper.on.apply({
  14348. element: parents[0].div,
  14349. onEvents: wrapper.onEvents
  14350. }, arguments);
  14351. }
  14352. return parentGroup;
  14353. },
  14354. translateXSetter: translateSetter,
  14355. translateYSetter: translateSetter
  14356. });
  14357. if (!parentGroup.addedSetters) {
  14358. addSetters(parentGroup);
  14359. }
  14360. });
  14361. }
  14362. }
  14363. else {
  14364. htmlGroup = container;
  14365. }
  14366. htmlGroup.appendChild(element);
  14367. // Shared with VML:
  14368. wrapper.added = true;
  14369. if (wrapper.alignOnAdd) {
  14370. wrapper.htmlUpdateTransform();
  14371. }
  14372. return wrapper;
  14373. };
  14374. }
  14375. return wrapper;
  14376. };
  14377. return HTMLRenderer;
  14378. }(SVGRenderer));
  14379. /* *
  14380. *
  14381. * Default Export
  14382. *
  14383. * */
  14384. return HTMLRenderer;
  14385. });
  14386. _registerModule(_modules, 'Core/Axis/AxisDefaults.js', [_modules['Core/Color/Palette.js']], function (Palette) {
  14387. /* *
  14388. *
  14389. * (c) 2010-2021 Torstein Honsi
  14390. *
  14391. * License: www.highcharts.com/license
  14392. *
  14393. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14394. *
  14395. * */
  14396. /* *
  14397. *
  14398. * Namespace
  14399. *
  14400. * */
  14401. var AxisDefaults;
  14402. (function (AxisDefaults) {
  14403. /* *
  14404. *
  14405. * Constants
  14406. *
  14407. * */
  14408. /**
  14409. * The X axis or category axis. Normally this is the horizontal axis,
  14410. * though if the chart is inverted this is the vertical axis. In case of
  14411. * multiple axes, the xAxis node is an array of configuration objects.
  14412. *
  14413. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  14414. * access to the axis.
  14415. *
  14416. * @productdesc {highmaps}
  14417. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  14418. * control features like zooming and panning. Zooming is in effect the same
  14419. * as setting the extremes of one of the exes.
  14420. *
  14421. * @type {*|Array<*>}
  14422. * @optionparent xAxis
  14423. */
  14424. AxisDefaults.defaultXAxisOptions = {
  14425. /**
  14426. * When using multiple axis, the ticks of two or more opposite axes
  14427. * will automatically be aligned by adding ticks to the axis or axes
  14428. * with the least ticks, as if `tickAmount` were specified.
  14429. *
  14430. * This can be prevented by setting `alignTicks` to false. If the grid
  14431. * lines look messy, it's a good idea to hide them for the secondary
  14432. * axis by setting `gridLineWidth` to 0.
  14433. *
  14434. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  14435. * then the `alignTicks ` will be disabled for the Axis.
  14436. *
  14437. * Disabled for logarithmic axes.
  14438. *
  14439. * @product highcharts highstock gantt
  14440. */
  14441. alignTicks: true,
  14442. /**
  14443. * Whether to allow decimals in this axis' ticks. When counting
  14444. * integers, like persons or hits on a web page, decimals should
  14445. * be avoided in the labels. By default, decimals are allowed on small
  14446. * scale axes.
  14447. *
  14448. * @see [minTickInterval](#xAxis.minTickInterval)
  14449. *
  14450. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  14451. * True by default
  14452. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  14453. * False
  14454. *
  14455. * @type {boolean|undefined}
  14456. * @default undefined
  14457. * @since 2.0
  14458. */
  14459. allowDecimals: void 0,
  14460. /**
  14461. * When using an alternate grid color, a band is painted across the
  14462. * plot area between every other grid line.
  14463. *
  14464. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  14465. * Alternate grid color on the Y axis
  14466. * @sample {highstock} stock/xaxis/alternategridcolor/
  14467. * Alternate grid color on the Y axis
  14468. *
  14469. * @type {Highcharts.ColorType}
  14470. * @apioption xAxis.alternateGridColor
  14471. */
  14472. /**
  14473. * An array defining breaks in the axis, the sections defined will be
  14474. * left out and all the points shifted closer to each other.
  14475. *
  14476. * @productdesc {highcharts}
  14477. * Requires that the broken-axis.js module is loaded.
  14478. *
  14479. * @sample {highcharts} highcharts/axisbreak/break-simple/
  14480. * Simple break
  14481. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  14482. * Advanced with callback
  14483. * @sample {highstock} stock/demo/intraday-breaks/
  14484. * Break on nights and weekends
  14485. *
  14486. * @type {Array<*>}
  14487. * @since 4.1.0
  14488. * @product highcharts highstock gantt
  14489. * @apioption xAxis.breaks
  14490. */
  14491. /**
  14492. * A number indicating how much space should be left between the start
  14493. * and the end of the break. The break size is given in axis units,
  14494. * so for instance on a `datetime` axis, a break size of 3600000 would
  14495. * indicate the equivalent of an hour.
  14496. *
  14497. * @type {number}
  14498. * @default 0
  14499. * @since 4.1.0
  14500. * @product highcharts highstock gantt
  14501. * @apioption xAxis.breaks.breakSize
  14502. */
  14503. /**
  14504. * The point where the break starts.
  14505. *
  14506. * @type {number}
  14507. * @since 4.1.0
  14508. * @product highcharts highstock gantt
  14509. * @apioption xAxis.breaks.from
  14510. */
  14511. /**
  14512. * Defines an interval after which the break appears again. By default
  14513. * the breaks do not repeat.
  14514. *
  14515. * @type {number}
  14516. * @default 0
  14517. * @since 4.1.0
  14518. * @product highcharts highstock gantt
  14519. * @apioption xAxis.breaks.repeat
  14520. */
  14521. /**
  14522. * The point where the break ends.
  14523. *
  14524. * @type {number}
  14525. * @since 4.1.0
  14526. * @product highcharts highstock gantt
  14527. * @apioption xAxis.breaks.to
  14528. */
  14529. /**
  14530. * If categories are present for the xAxis, names are used instead of
  14531. * numbers for that axis.
  14532. *
  14533. * Since Highcharts 3.0, categories can also
  14534. * be extracted by giving each point a [name](#series.data) and setting
  14535. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  14536. * series, best practice remains defining the `categories` array.
  14537. *
  14538. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  14539. *
  14540. * @sample {highcharts} highcharts/demo/line-labels/
  14541. * With
  14542. * @sample {highcharts} highcharts/xaxis/categories/
  14543. * Without
  14544. *
  14545. * @type {Array<string>}
  14546. * @product highcharts gantt
  14547. * @apioption xAxis.categories
  14548. */
  14549. /**
  14550. * The highest allowed value for automatically computed axis extremes.
  14551. *
  14552. * @see [floor](#xAxis.floor)
  14553. *
  14554. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  14555. * Floor and ceiling
  14556. *
  14557. * @type {number}
  14558. * @since 4.0
  14559. * @product highcharts highstock gantt
  14560. * @apioption xAxis.ceiling
  14561. */
  14562. /**
  14563. * A class name that opens for styling the axis by CSS, especially in
  14564. * Highcharts styled mode. The class name is applied to group elements
  14565. * for the grid, axis elements and labels.
  14566. *
  14567. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  14568. * Multiple axes with separate styling
  14569. *
  14570. * @type {string}
  14571. * @since 5.0.0
  14572. * @apioption xAxis.className
  14573. */
  14574. /**
  14575. * Configure a crosshair that follows either the mouse pointer or the
  14576. * hovered point.
  14577. *
  14578. * In styled mode, the crosshairs are styled in the
  14579. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  14580. * `.highcharts-xaxis-category` classes.
  14581. *
  14582. * @productdesc {highstock}
  14583. * In Highcharts stock, by default, the crosshair is enabled on the
  14584. * X axis and disabled on the Y axis.
  14585. *
  14586. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  14587. * Crosshair on both axes
  14588. * @sample {highstock} stock/xaxis/crosshairs-xy/
  14589. * Crosshair on both axes
  14590. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  14591. * Crosshair on both axes
  14592. *
  14593. * @declare Highcharts.AxisCrosshairOptions
  14594. * @type {boolean|*}
  14595. * @default false
  14596. * @since 4.1
  14597. * @apioption xAxis.crosshair
  14598. */
  14599. /**
  14600. * A class name for the crosshair, especially as a hook for styling.
  14601. *
  14602. * @type {string}
  14603. * @since 5.0.0
  14604. * @apioption xAxis.crosshair.className
  14605. */
  14606. /**
  14607. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  14608. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  14609. * the crosshair by default highlights the whole category.
  14610. *
  14611. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  14612. * Customized crosshairs
  14613. *
  14614. * @type {Highcharts.ColorType}
  14615. * @default #cccccc
  14616. * @since 4.1
  14617. * @apioption xAxis.crosshair.color
  14618. */
  14619. /**
  14620. * The dash style for the crosshair. See
  14621. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  14622. * for possible values.
  14623. *
  14624. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  14625. * Dotted crosshair
  14626. * @sample {highstock} stock/xaxis/crosshair-dashed/
  14627. * Dashed X axis crosshair
  14628. *
  14629. * @type {Highcharts.DashStyleValue}
  14630. * @default Solid
  14631. * @since 4.1
  14632. * @apioption xAxis.crosshair.dashStyle
  14633. */
  14634. /**
  14635. * A label on the axis next to the crosshair.
  14636. *
  14637. * In styled mode, the label is styled with the
  14638. * `.highcharts-crosshair-label` class.
  14639. *
  14640. * @sample {highstock} stock/xaxis/crosshair-label/
  14641. * Crosshair labels
  14642. * @sample {highstock} highcharts/css/crosshair-label/
  14643. * Style mode
  14644. *
  14645. * @declare Highcharts.AxisCrosshairLabelOptions
  14646. * @since 2.1
  14647. * @product highstock
  14648. * @apioption xAxis.crosshair.label
  14649. */
  14650. /**
  14651. * Alignment of the label compared to the axis. Defaults to `"left"` for
  14652. * right-side axes, `"right"` for left-side axes and `"center"` for
  14653. * horizontal axes.
  14654. *
  14655. * @type {Highcharts.AlignValue}
  14656. * @since 2.1
  14657. * @product highstock
  14658. * @apioption xAxis.crosshair.label.align
  14659. */
  14660. /**
  14661. * The background color for the label. Defaults to the related series
  14662. * color, or `#666666` if that is not available.
  14663. *
  14664. * @type {Highcharts.ColorType}
  14665. * @since 2.1
  14666. * @product highstock
  14667. * @apioption xAxis.crosshair.label.backgroundColor
  14668. */
  14669. /**
  14670. * The border color for the crosshair label
  14671. *
  14672. * @type {Highcharts.ColorType}
  14673. * @since 2.1
  14674. * @product highstock
  14675. * @apioption xAxis.crosshair.label.borderColor
  14676. */
  14677. /**
  14678. * The border corner radius of the crosshair label.
  14679. *
  14680. * @type {number}
  14681. * @default 3
  14682. * @since 2.1.10
  14683. * @product highstock
  14684. * @apioption xAxis.crosshair.label.borderRadius
  14685. */
  14686. /**
  14687. * The border width for the crosshair label.
  14688. *
  14689. * @type {number}
  14690. * @default 0
  14691. * @since 2.1
  14692. * @product highstock
  14693. * @apioption xAxis.crosshair.label.borderWidth
  14694. */
  14695. /**
  14696. * Flag to enable crosshair's label.
  14697. *
  14698. * @sample {highstock} stock/xaxis/crosshairs-xy/
  14699. * Enabled label for yAxis' crosshair
  14700. *
  14701. * @type {boolean}
  14702. * @default false
  14703. * @since 2.1
  14704. * @product highstock
  14705. * @apioption xAxis.crosshair.label.enabled
  14706. */
  14707. /**
  14708. * A format string for the crosshair label. Defaults to `{value}` for
  14709. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  14710. *
  14711. * @type {string}
  14712. * @since 2.1
  14713. * @product highstock
  14714. * @apioption xAxis.crosshair.label.format
  14715. */
  14716. /**
  14717. * Formatter function for the label text.
  14718. *
  14719. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  14720. * @since 2.1
  14721. * @product highstock
  14722. * @apioption xAxis.crosshair.label.formatter
  14723. */
  14724. /**
  14725. * Padding inside the crosshair label.
  14726. *
  14727. * @type {number}
  14728. * @default 8
  14729. * @since 2.1
  14730. * @product highstock
  14731. * @apioption xAxis.crosshair.label.padding
  14732. */
  14733. /**
  14734. * The shape to use for the label box.
  14735. *
  14736. * @type {string}
  14737. * @default callout
  14738. * @since 2.1
  14739. * @product highstock
  14740. * @apioption xAxis.crosshair.label.shape
  14741. */
  14742. /**
  14743. * Text styles for the crosshair label.
  14744. *
  14745. * @type {Highcharts.CSSObject}
  14746. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  14747. * @since 2.1
  14748. * @product highstock
  14749. * @apioption xAxis.crosshair.label.style
  14750. */
  14751. /**
  14752. * Whether the crosshair should snap to the point or follow the pointer
  14753. * independent of points.
  14754. *
  14755. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  14756. * True by default
  14757. * @sample {highmaps} maps/demo/latlon-advanced/
  14758. * Snap is false
  14759. *
  14760. * @type {boolean}
  14761. * @default true
  14762. * @since 4.1
  14763. * @apioption xAxis.crosshair.snap
  14764. */
  14765. /**
  14766. * The pixel width of the crosshair. Defaults to 1 for numeric or
  14767. * datetime axes, and for one category width for category axes.
  14768. *
  14769. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  14770. * Customized crosshairs
  14771. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  14772. * Customized crosshairs
  14773. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  14774. * Customized crosshairs
  14775. *
  14776. * @type {number}
  14777. * @default 1
  14778. * @since 4.1
  14779. * @apioption xAxis.crosshair.width
  14780. */
  14781. /**
  14782. * The Z index of the crosshair. Higher Z indices allow drawing the
  14783. * crosshair on top of the series or behind the grid lines.
  14784. *
  14785. * @type {number}
  14786. * @default 2
  14787. * @since 4.1
  14788. * @apioption xAxis.crosshair.zIndex
  14789. */
  14790. /**
  14791. * Whether to pan axis. If `chart.panning` is enabled, the option
  14792. * allows to disable panning on an individual axis.
  14793. */
  14794. panningEnabled: true,
  14795. /**
  14796. * The Z index for the axis group.
  14797. */
  14798. zIndex: 2,
  14799. /**
  14800. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  14801. * to disable zooming on an individual axis.
  14802. *
  14803. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  14804. * Zoom enabled is false
  14805. */
  14806. zoomEnabled: true,
  14807. /**
  14808. * For a datetime axis, the scale will automatically adjust to the
  14809. * appropriate unit. This member gives the default string
  14810. * representations used for each unit. For intermediate values,
  14811. * different units may be used, for example the `day` unit can be used
  14812. * on midnight and `hour` unit be used for intermediate values on the
  14813. * same axis.
  14814. *
  14815. * For an overview of the replacement codes, see
  14816. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  14817. *
  14818. * Defaults to:
  14819. * ```js
  14820. * {
  14821. * millisecond: '%H:%M:%S.%L',
  14822. * second: '%H:%M:%S',
  14823. * minute: '%H:%M',
  14824. * hour: '%H:%M',
  14825. * day: '%e. %b',
  14826. * week: '%e. %b',
  14827. * month: '%b \'%y',
  14828. * year: '%Y'
  14829. * }
  14830. * ```
  14831. *
  14832. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  14833. * Different day format on X axis
  14834. * @sample {highstock} stock/xaxis/datetimelabelformats/
  14835. * More information in x axis labels
  14836. *
  14837. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  14838. * @product highcharts highstock gantt
  14839. */
  14840. dateTimeLabelFormats: {
  14841. /**
  14842. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14843. * @type {string|*}
  14844. */
  14845. millisecond: {
  14846. main: '%H:%M:%S.%L',
  14847. range: false
  14848. },
  14849. /**
  14850. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14851. * @type {string|*}
  14852. */
  14853. second: {
  14854. main: '%H:%M:%S',
  14855. range: false
  14856. },
  14857. /**
  14858. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14859. * @type {string|*}
  14860. */
  14861. minute: {
  14862. main: '%H:%M',
  14863. range: false
  14864. },
  14865. /**
  14866. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14867. * @type {string|*}
  14868. */
  14869. hour: {
  14870. main: '%H:%M',
  14871. range: false
  14872. },
  14873. /**
  14874. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14875. * @type {string|*}
  14876. */
  14877. day: {
  14878. main: '%e. %b'
  14879. },
  14880. /**
  14881. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14882. * @type {string|*}
  14883. */
  14884. week: {
  14885. main: '%e. %b'
  14886. },
  14887. /**
  14888. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14889. * @type {string|*}
  14890. */
  14891. month: {
  14892. main: '%b \'%y'
  14893. },
  14894. /**
  14895. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14896. * @type {string|*}
  14897. */
  14898. year: {
  14899. main: '%Y'
  14900. }
  14901. },
  14902. /**
  14903. * Whether to force the axis to end on a tick. Use this option with
  14904. * the `maxPadding` option to control the axis end.
  14905. *
  14906. * @productdesc {highstock}
  14907. * In Highcharts Stock, `endOnTick` is always `false` when the navigator
  14908. * is enabled, to prevent jumpy scrolling.
  14909. *
  14910. * @sample {highcharts} highcharts/chart/reflow-true/
  14911. * True by default
  14912. * @sample {highcharts} highcharts/yaxis/endontick/
  14913. * False
  14914. * @sample {highstock} stock/demo/basic-line/
  14915. * True by default
  14916. * @sample {highstock} stock/xaxis/endontick/
  14917. * False
  14918. *
  14919. * @since 1.2.0
  14920. */
  14921. endOnTick: false,
  14922. /**
  14923. * Event handlers for the axis.
  14924. *
  14925. * @type {*}
  14926. * @apioption xAxis.events
  14927. */
  14928. /**
  14929. * An event fired after the breaks have rendered.
  14930. *
  14931. * @see [breaks](#xAxis.breaks)
  14932. *
  14933. * @sample {highcharts} highcharts/axisbreak/break-event/
  14934. * AfterBreak Event
  14935. *
  14936. * @type {Highcharts.AxisEventCallbackFunction}
  14937. * @since 4.1.0
  14938. * @product highcharts gantt
  14939. * @apioption xAxis.events.afterBreaks
  14940. */
  14941. /**
  14942. * As opposed to the `setExtremes` event, this event fires after the
  14943. * final min and max values are computed and corrected for `minRange`.
  14944. *
  14945. * Fires when the minimum and maximum is set for the axis, either by
  14946. * calling the `.setExtremes()` method or by selecting an area in the
  14947. * chart. One parameter, `event`, is passed to the function, containing
  14948. * common event information.
  14949. *
  14950. * The new user set minimum and maximum values can be found by
  14951. * `event.min` and `event.max`. These reflect the axis minimum and
  14952. * maximum in axis values. The actual data extremes are found in
  14953. * `event.dataMin` and `event.dataMax`.
  14954. *
  14955. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  14956. * @since 2.3
  14957. * @context Highcharts.Axis
  14958. * @apioption xAxis.events.afterSetExtremes
  14959. */
  14960. /**
  14961. * An event fired when a break from this axis occurs on a point.
  14962. *
  14963. * @see [breaks](#xAxis.breaks)
  14964. *
  14965. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  14966. * Visualization of a Break
  14967. *
  14968. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  14969. * @since 4.1.0
  14970. * @product highcharts gantt
  14971. * @context Highcharts.Axis
  14972. * @apioption xAxis.events.pointBreak
  14973. */
  14974. /**
  14975. * An event fired when a point falls inside a break from this axis.
  14976. *
  14977. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  14978. * @product highcharts highstock gantt
  14979. * @context Highcharts.Axis
  14980. * @apioption xAxis.events.pointInBreak
  14981. */
  14982. /**
  14983. * Fires when the minimum and maximum is set for the axis, either by
  14984. * calling the `.setExtremes()` method or by selecting an area in the
  14985. * chart. One parameter, `event`, is passed to the function,
  14986. * containing common event information.
  14987. *
  14988. * The new user set minimum and maximum values can be found by
  14989. * `event.min` and `event.max`. These reflect the axis minimum and
  14990. * maximum in data values. When an axis is zoomed all the way out from
  14991. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  14992. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  14993. *
  14994. * @sample {highstock} stock/xaxis/events-setextremes/
  14995. * Log new extremes on x axis
  14996. *
  14997. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  14998. * @since 1.2.0
  14999. * @context Highcharts.Axis
  15000. * @apioption xAxis.events.setExtremes
  15001. */
  15002. /**
  15003. * The lowest allowed value for automatically computed axis extremes.
  15004. *
  15005. * @see [ceiling](#yAxis.ceiling)
  15006. *
  15007. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  15008. * Floor and ceiling
  15009. * @sample {highstock} stock/demo/lazy-loading/
  15010. * Prevent negative stock price on Y axis
  15011. *
  15012. * @type {number}
  15013. * @since 4.0
  15014. * @product highcharts highstock gantt
  15015. * @apioption xAxis.floor
  15016. */
  15017. /**
  15018. * The dash or dot style of the grid lines. For possible values, see
  15019. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  15020. *
  15021. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  15022. * Long dashes
  15023. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  15024. * Long dashes
  15025. *
  15026. * @type {Highcharts.DashStyleValue}
  15027. * @since 1.2
  15028. */
  15029. gridLineDashStyle: 'Solid',
  15030. /**
  15031. * The Z index of the grid lines.
  15032. *
  15033. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  15034. * A Z index of 4 renders the grid above the graph
  15035. *
  15036. * @product highcharts highstock gantt
  15037. */
  15038. gridZIndex: 1,
  15039. /**
  15040. * An id for the axis. This can be used after render time to get
  15041. * a pointer to the axis object through `chart.get()`.
  15042. *
  15043. * @sample {highcharts} highcharts/xaxis/id/
  15044. * Get the object
  15045. * @sample {highstock} stock/xaxis/id/
  15046. * Get the object
  15047. *
  15048. * @type {string}
  15049. * @since 1.2.0
  15050. * @apioption xAxis.id
  15051. */
  15052. /**
  15053. * The axis labels show the number or category for each tick.
  15054. *
  15055. * Since v8.0.0: Labels are animated in categorized x-axis with
  15056. * updating data if `tickInterval` and `step` is set to 1.
  15057. *
  15058. * @productdesc {highmaps}
  15059. * X and Y axis labels are by default disabled in Highmaps, but the
  15060. * functionality is inherited from Highcharts and used on `colorAxis`,
  15061. * and can be enabled on X and Y axes too.
  15062. */
  15063. labels: {
  15064. /**
  15065. * What part of the string the given position is anchored to.
  15066. * If `left`, the left side of the string is at the axis position.
  15067. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  15068. * an intelligent guess based on which side of the chart the axis
  15069. * is on and the rotation of the label.
  15070. *
  15071. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  15072. *
  15073. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  15074. * Left
  15075. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  15076. * Right
  15077. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  15078. * Left-aligned labels on a vertical category axis
  15079. *
  15080. * @type {Highcharts.AlignValue}
  15081. * @apioption xAxis.labels.align
  15082. */
  15083. /**
  15084. * Whether to allow the axis labels to overlap.
  15085. * When false, overlapping labels are hidden.
  15086. *
  15087. * @sample {highcharts} highcharts/xaxis/labels-allowoverlap-true/
  15088. * X axis labels overlap enabled
  15089. *
  15090. * @type {boolean}
  15091. * @default false
  15092. * @apioption xAxis.labels.allowOverlap
  15093. *
  15094. */
  15095. /**
  15096. * For horizontal axes, the allowed degrees of label rotation
  15097. * to prevent overlapping labels. If there is enough space,
  15098. * labels are not rotated. As the chart gets narrower, it
  15099. * will start rotating the labels -45 degrees, then remove
  15100. * every second label and try again with rotations 0 and -45 etc.
  15101. * Set it to `undefined` to disable rotation, which will
  15102. * cause the labels to word-wrap if possible. Defaults to `[-45]``
  15103. * on bottom and top axes, `undefined` on left and right axes.
  15104. *
  15105. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  15106. * Default auto rotation of 0 or -45
  15107. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  15108. * Custom graded auto rotation
  15109. *
  15110. * @type {Array<number>}
  15111. * @default undefined
  15112. * @since 4.1.0
  15113. * @product highcharts highstock gantt
  15114. * @apioption xAxis.labels.autoRotation
  15115. */
  15116. autoRotation: void 0,
  15117. /**
  15118. * When each category width is more than this many pixels, we don't
  15119. * apply auto rotation. Instead, we lay out the axis label with word
  15120. * wrap. A lower limit makes sense when the label contains multiple
  15121. * short words that don't extend the available horizontal space for
  15122. * each label.
  15123. *
  15124. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  15125. * Lower limit
  15126. *
  15127. * @since 4.1.5
  15128. * @product highcharts gantt
  15129. */
  15130. autoRotationLimit: 80,
  15131. /**
  15132. * Polar charts only. The label's pixel distance from the perimeter
  15133. * of the plot area.
  15134. *
  15135. * @type {number}
  15136. * @default undefined
  15137. * @product highcharts gantt
  15138. */
  15139. distance: void 0,
  15140. /**
  15141. * Enable or disable the axis labels.
  15142. *
  15143. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  15144. * X axis labels disabled
  15145. * @sample {highstock} stock/xaxis/labels-enabled/
  15146. * X axis labels disabled
  15147. *
  15148. * @default {highcharts|highstock|gantt} true
  15149. * @default {highmaps} false
  15150. */
  15151. enabled: true,
  15152. /**
  15153. * A format string for the axis label. The context is available as
  15154. * format string variables. For example, you can use `{text}` to
  15155. * insert the default formatted text. The recommended way of adding
  15156. * units for the label is using `text`, for example `{text} km`.
  15157. *
  15158. * To add custom numeric or datetime formatting, use `{value}` with
  15159. * formatting, for example `{value:.1f}` or `{value:%Y-%m-%d}`.
  15160. *
  15161. * See
  15162. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  15163. * for more examples of formatting.
  15164. *
  15165. * The default value is not specified due to the dynamic
  15166. * nature of the default implementation.
  15167. *
  15168. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  15169. * Add units to Y axis label
  15170. * @sample {highcharts} highcharts/xaxis/labels-format-linked/
  15171. * Linked category names
  15172. * @sample {highcharts} highcharts/xaxis/labels-format-custom/
  15173. * Custom number format
  15174. *
  15175. * @type {string}
  15176. * @since 3.0
  15177. * @apioption xAxis.labels.format
  15178. */
  15179. /**
  15180. * Callback JavaScript function to format the label. The value
  15181. * is given by `this.value`. Additional properties for `this` are
  15182. * `axis`, `chart`, `isFirst`, `isLast` and `text` which holds the
  15183. * value of the default formatter.
  15184. *
  15185. * Defaults to a built in function returning a formatted string
  15186. * depending on whether the axis is `category`, `datetime`,
  15187. * `numeric` or other.
  15188. *
  15189. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  15190. * Linked category names
  15191. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  15192. * Modified numeric labels
  15193. * @sample {highstock} stock/xaxis/labels-formatter/
  15194. * Added units on Y axis
  15195. *
  15196. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  15197. * @apioption xAxis.labels.formatter
  15198. */
  15199. /**
  15200. * The number of pixels to indent the labels per level in a treegrid
  15201. * axis.
  15202. *
  15203. * @sample gantt/treegrid-axis/demo
  15204. * Indentation 10px by default.
  15205. * @sample gantt/treegrid-axis/indentation-0px
  15206. * Indentation set to 0px.
  15207. *
  15208. * @product gantt
  15209. */
  15210. indentation: 10,
  15211. /**
  15212. * Horizontal axis only. When `staggerLines` is not set,
  15213. * `maxStaggerLines` defines how many lines the axis is allowed to
  15214. * add to automatically avoid overlapping X labels. Set to `1` to
  15215. * disable overlap detection.
  15216. *
  15217. * @deprecated
  15218. * @type {number}
  15219. * @default 5
  15220. * @since 1.3.3
  15221. * @apioption xAxis.labels.maxStaggerLines
  15222. */
  15223. /**
  15224. * How to handle overflowing labels on horizontal axis. If set to
  15225. * `"allow"`, it will not be aligned at all. By default it
  15226. * `"justify"` labels inside the chart area. If there is room to
  15227. * move it, it will be aligned to the edge, else it will be removed.
  15228. *
  15229. * @since 2.2.5
  15230. * @validvalue ["allow", "justify"]
  15231. */
  15232. overflow: 'justify',
  15233. /**
  15234. * The pixel padding for axis labels, to ensure white space between
  15235. * them.
  15236. *
  15237. * @product highcharts gantt
  15238. */
  15239. padding: 5,
  15240. /**
  15241. * Whether to reserve space for the labels. By default, space is
  15242. * reserved for the labels in these cases:
  15243. *
  15244. * * On all horizontal axes.
  15245. * * On vertical axes if `label.align` is `right` on a left-side
  15246. * axis or `left` on a right-side axis.
  15247. * * On vertical axes if `label.align` is `center`.
  15248. *
  15249. * This can be turned off when for example the labels are rendered
  15250. * inside the plot area instead of outside.
  15251. *
  15252. * @see [labels.align](#xAxis.labels.align)
  15253. *
  15254. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  15255. * No reserved space, labels inside plot
  15256. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  15257. * Left-aligned labels on a vertical category axis
  15258. *
  15259. * @type {boolean}
  15260. * @since 4.1.10
  15261. * @product highcharts gantt
  15262. * @apioption xAxis.labels.reserveSpace
  15263. */
  15264. reserveSpace: void 0,
  15265. /**
  15266. * Rotation of the labels in degrees. When `undefined`, the
  15267. * `autoRotation` option takes precedence.
  15268. *
  15269. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  15270. * X axis labels rotated 90°
  15271. *
  15272. * @type {number}
  15273. * @default 0
  15274. * @apioption xAxis.labels.rotation
  15275. */
  15276. rotation: void 0,
  15277. /**
  15278. * Horizontal axes only. The number of lines to spread the labels
  15279. * over to make room or tighter labels. 0 disables staggering.
  15280. *
  15281. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  15282. * Show labels over two lines
  15283. * @sample {highstock} stock/xaxis/labels-staggerlines/
  15284. * Show labels over two lines
  15285. *
  15286. * @since 2.1
  15287. * @apioption xAxis.labels.staggerLines
  15288. */
  15289. staggerLines: 0,
  15290. /**
  15291. * To show only every _n_'th label on the axis, set the step to _n_.
  15292. * Setting the step to 2 shows every other label.
  15293. *
  15294. * By default, when 0, the step is calculated automatically to avoid
  15295. * overlap. To prevent this, set it to 1\. This usually only
  15296. * happens on a category axis, and is often a sign that you have
  15297. * chosen the wrong axis type.
  15298. *
  15299. * Read more at
  15300. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  15301. * => What axis should I use?
  15302. *
  15303. * @sample {highcharts} highcharts/xaxis/labels-step/
  15304. * Showing only every other axis label on a categorized
  15305. * x-axis
  15306. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  15307. * Auto steps on a category axis
  15308. *
  15309. * @since 2.1
  15310. */
  15311. step: 0,
  15312. /**
  15313. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  15314. * to render the labels.
  15315. */
  15316. useHTML: false,
  15317. /**
  15318. * The x position offset of all labels relative to the tick
  15319. * positions on the axis.
  15320. *
  15321. * @sample {highcharts} highcharts/xaxis/labels-x/
  15322. * Y axis labels placed on grid lines
  15323. */
  15324. x: 0,
  15325. /**
  15326. * The y position offset of all labels relative to the tick
  15327. * positions on the axis. The default makes it adapt to the font
  15328. * size of the bottom axis.
  15329. *
  15330. * @sample {highcharts} highcharts/xaxis/labels-x/
  15331. * Y axis labels placed on grid lines
  15332. *
  15333. * @type {number}
  15334. * @apioption xAxis.labels.y
  15335. */
  15336. /**
  15337. * The Z index for the axis labels.
  15338. */
  15339. zIndex: 7,
  15340. /**
  15341. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  15342. * wrapping of category labels. Use `textOverflow: 'none'` to
  15343. * prevent ellipsis (dots).
  15344. *
  15345. * In styled mode, the labels are styled with the
  15346. * `.highcharts-axis-labels` class.
  15347. *
  15348. * @sample {highcharts} highcharts/xaxis/labels-style/
  15349. * Red X axis labels
  15350. *
  15351. * @type {Highcharts.CSSObject}
  15352. */
  15353. style: {
  15354. /** @internal */
  15355. color: Palette.neutralColor60,
  15356. /** @internal */
  15357. cursor: 'default',
  15358. /** @internal */
  15359. fontSize: '11px'
  15360. }
  15361. },
  15362. /**
  15363. * The left position as the horizontal axis. If it's a number, it is
  15364. * interpreted as pixel position relative to the chart.
  15365. *
  15366. * Since Highcharts v5.0.13: If it's a percentage string, it is
  15367. * interpreted as percentages of the plot width, offset from plot area
  15368. * left.
  15369. *
  15370. * @type {number|string}
  15371. * @product highcharts highstock
  15372. * @apioption xAxis.left
  15373. */
  15374. /**
  15375. * The top position as the vertical axis. If it's a number, it is
  15376. * interpreted as pixel position relative to the chart.
  15377. *
  15378. * Since Highcharts 2: If it's a percentage string, it is interpreted
  15379. * as percentages of the plot height, offset from plot area top.
  15380. *
  15381. * @type {number|string}
  15382. * @product highcharts highstock
  15383. * @apioption xAxis.top
  15384. */
  15385. /**
  15386. * Index of another axis that this axis is linked to. When an axis is
  15387. * linked to a master axis, it will take the same extremes as
  15388. * the master, but as assigned by min or max or by setExtremes.
  15389. * It can be used to show additional info, or to ease reading the
  15390. * chart by duplicating the scales.
  15391. *
  15392. * @sample {highcharts} highcharts/xaxis/linkedto/
  15393. * Different string formats of the same date
  15394. * @sample {highcharts} highcharts/yaxis/linkedto/
  15395. * Y values on both sides
  15396. *
  15397. * @type {number}
  15398. * @since 2.0.2
  15399. * @product highcharts highstock gantt
  15400. * @apioption xAxis.linkedTo
  15401. */
  15402. /**
  15403. * The maximum value of the axis. If `null`, the max value is
  15404. * automatically calculated.
  15405. *
  15406. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  15407. * might be rounded up.
  15408. *
  15409. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  15410. * beyond the set max in order to reach the given number of ticks. The
  15411. * same may happen in a chart with multiple axes, determined by [chart.
  15412. * alignTicks](#chart), where a `tickAmount` is applied internally.
  15413. *
  15414. * @sample {highcharts} highcharts/yaxis/max-200/
  15415. * Y axis max of 200
  15416. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  15417. * Y axis max on logarithmic axis
  15418. * @sample {highstock} stock/xaxis/min-max/
  15419. * Fixed min and max on X axis
  15420. * @sample {highmaps} maps/axis/min-max/
  15421. * Pre-zoomed to a specific area
  15422. *
  15423. * @type {number|null}
  15424. * @apioption xAxis.max
  15425. */
  15426. /**
  15427. * Padding of the max value relative to the length of the axis. A
  15428. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  15429. * when you don't want the highest data value to appear on the edge
  15430. * of the plot area. When the axis' `max` option is set or a max extreme
  15431. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  15432. *
  15433. * @productdesc {highstock}
  15434. * For an [ordinal](#xAxis.ordinal) axis, `minPadding` and `maxPadding`
  15435. * are ignored. Use [overscroll](#xAxis.overscroll) instead.
  15436. *
  15437. * @sample {highcharts} highcharts/yaxis/maxpadding/
  15438. * Max padding of 0.25 on y axis
  15439. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  15440. * Greater min- and maxPadding
  15441. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  15442. * Add some padding
  15443. *
  15444. * @default {highcharts} 0.01
  15445. * @default {highstock|highmaps} 0
  15446. * @since 1.2.0
  15447. */
  15448. maxPadding: 0.01,
  15449. /**
  15450. * Deprecated. Use `minRange` instead.
  15451. *
  15452. * @deprecated
  15453. * @type {number}
  15454. * @product highcharts highstock
  15455. * @apioption xAxis.maxZoom
  15456. */
  15457. /**
  15458. * The minimum value of the axis. If `null` the min value is
  15459. * automatically calculated.
  15460. *
  15461. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  15462. * the `min` value might be rounded down.
  15463. *
  15464. * The automatically calculated minimum value is also affected by
  15465. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  15466. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  15467. * as well as [series.threshold](#plotOptions.series.threshold)
  15468. * and [series.softThreshold](#plotOptions.series.softThreshold).
  15469. *
  15470. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  15471. * -50 with startOnTick to false
  15472. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  15473. * -50 with startOnTick true by default
  15474. * @sample {highstock} stock/xaxis/min-max/
  15475. * Set min and max on X axis
  15476. * @sample {highmaps} maps/axis/min-max/
  15477. * Pre-zoomed to a specific area
  15478. *
  15479. * @type {number|null}
  15480. * @apioption xAxis.min
  15481. */
  15482. /**
  15483. * The dash or dot style of the minor grid lines. For possible values,
  15484. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  15485. *
  15486. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  15487. * Long dashes on minor grid lines
  15488. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  15489. * Long dashes on minor grid lines
  15490. *
  15491. * @type {Highcharts.DashStyleValue}
  15492. * @since 1.2
  15493. */
  15494. minorGridLineDashStyle: 'Solid',
  15495. /**
  15496. * Specific tick interval in axis units for the minor ticks. On a linear
  15497. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  15498. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  15499. * shown.
  15500. *
  15501. * On logarithmic axes, the unit is the power of the value. For example,
  15502. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  15503. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  15504. * between 1 and 10, 10 and 100 etc.
  15505. *
  15506. * If user settings dictate minor ticks to become too dense, they don't
  15507. * make sense, and will be ignored to prevent performance problems.
  15508. *
  15509. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  15510. * Null by default
  15511. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  15512. * 5 units
  15513. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  15514. * "auto"
  15515. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  15516. * 0.1
  15517. * @sample {highstock} stock/demo/basic-line/
  15518. * Null by default
  15519. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  15520. * "auto"
  15521. *
  15522. * @type {number|string|null}
  15523. * @apioption xAxis.minorTickInterval
  15524. */
  15525. /**
  15526. * The pixel length of the minor tick marks.
  15527. *
  15528. * @sample {highcharts} highcharts/yaxis/minorticklength/
  15529. * 10px on Y axis
  15530. * @sample {highstock} stock/xaxis/minorticks/
  15531. * 10px on Y axis
  15532. */
  15533. minorTickLength: 2,
  15534. /**
  15535. * The position of the minor tick marks relative to the axis line.
  15536. * Can be one of `inside` and `outside`.
  15537. *
  15538. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  15539. * Outside by default
  15540. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  15541. * Inside
  15542. * @sample {highstock} stock/xaxis/minorticks/
  15543. * Inside
  15544. *
  15545. * @validvalue ["inside", "outside"]
  15546. */
  15547. minorTickPosition: 'outside',
  15548. /**
  15549. * Enable or disable minor ticks. Unless
  15550. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  15551. * interval is calculated as a fifth of the `tickInterval`.
  15552. *
  15553. * On a logarithmic axis, minor ticks are laid out based on a best
  15554. * guess, attempting to enter approximately 5 minor ticks between
  15555. * each major tick.
  15556. *
  15557. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  15558. * `minorTickInterval` to `"auto"`.
  15559. *
  15560. * @productdesc {highcharts}
  15561. * On axes using [categories](#xAxis.categories), minor ticks are not
  15562. * supported.
  15563. *
  15564. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  15565. * Enabled on linear Y axis
  15566. *
  15567. * @type {boolean}
  15568. * @default false
  15569. * @since 6.0.0
  15570. * @apioption xAxis.minorTicks
  15571. */
  15572. /**
  15573. * The pixel width of the minor tick mark.
  15574. *
  15575. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  15576. * 3px width
  15577. * @sample {highstock} stock/xaxis/minorticks/
  15578. * 1px width
  15579. *
  15580. * @type {number}
  15581. * @default 0
  15582. * @apioption xAxis.minorTickWidth
  15583. */
  15584. /**
  15585. * Padding of the min value relative to the length of the axis. A
  15586. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  15587. * when you don't want the lowest data value to appear on the edge
  15588. * of the plot area. When the axis' `min` option is set or a min extreme
  15589. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  15590. *
  15591. * @productdesc {highstock}
  15592. * For an [ordinal](#xAxis.ordinal) axis, `minPadding` and `maxPadding`
  15593. * are ignored. Use [overscroll](#xAxis.overscroll) instead.
  15594. *
  15595. * @sample {highcharts} highcharts/yaxis/minpadding/
  15596. * Min padding of 0.2
  15597. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  15598. * Greater min- and maxPadding
  15599. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  15600. * Add some padding
  15601. *
  15602. * @default {highcharts} 0.01
  15603. * @default {highstock|highmaps} 0
  15604. * @since 1.2.0
  15605. * @product highcharts highstock gantt
  15606. */
  15607. minPadding: 0.01,
  15608. /**
  15609. * The minimum range to display on this axis. The entire axis will not
  15610. * be allowed to span over a smaller interval than this. For example,
  15611. * for a datetime axis the main unit is milliseconds. If minRange is
  15612. * set to 3600000, you can't zoom in more than to one hour.
  15613. *
  15614. * The default minRange for the x axis is five times the smallest
  15615. * interval between any of the data points.
  15616. *
  15617. * On a logarithmic axis, the unit for the minimum range is the power.
  15618. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  15619. * 100-1000, 1000-10000 etc.
  15620. *
  15621. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  15622. * `endOnTick` settings also affect how the extremes of the axis
  15623. * are computed.
  15624. *
  15625. * @sample {highcharts} highcharts/xaxis/minrange/
  15626. * Minimum range of 5
  15627. * @sample {highstock} stock/xaxis/minrange/
  15628. * Max zoom of 6 months overrides user selections
  15629. * @sample {highmaps} maps/axis/minrange/
  15630. * Minimum range of 1000
  15631. *
  15632. * @type {number}
  15633. * @apioption xAxis.minRange
  15634. */
  15635. /**
  15636. * The minimum tick interval allowed in axis values. For example on
  15637. * zooming in on an axis with daily data, this can be used to prevent
  15638. * the axis from showing hours. Defaults to the closest distance between
  15639. * two points on the axis.
  15640. *
  15641. * @type {number}
  15642. * @since 2.3.0
  15643. * @apioption xAxis.minTickInterval
  15644. */
  15645. /**
  15646. * The distance in pixels from the plot area to the axis line.
  15647. * A positive offset moves the axis with it's line, labels and ticks
  15648. * away from the plot area. This is typically used when two or more
  15649. * axes are displayed on the same side of the plot. With multiple
  15650. * axes the offset is dynamically adjusted to avoid collision, this
  15651. * can be overridden by setting offset explicitly.
  15652. *
  15653. * @sample {highcharts} highcharts/yaxis/offset/
  15654. * Y axis offset of 70
  15655. * @sample {highcharts} highcharts/yaxis/offset-centered/
  15656. * Axes positioned in the center of the plot
  15657. * @sample {highstock} stock/xaxis/offset/
  15658. * Y axis offset by 70 px
  15659. *
  15660. * @type {number}
  15661. */
  15662. offset: void 0,
  15663. /**
  15664. * Whether to display the axis on the opposite side of the normal. The
  15665. * normal is on the left side for vertical axes and bottom for
  15666. * horizontal, so the opposite sides will be right and top respectively.
  15667. * This is typically used with dual or multiple axes.
  15668. *
  15669. * @sample {highcharts} highcharts/yaxis/opposite/
  15670. * Secondary Y axis opposite
  15671. * @sample {highstock} stock/xaxis/opposite/
  15672. * Y axis on left side
  15673. *
  15674. * @default {highcharts|highstock|highmaps} false
  15675. * @default {gantt} true
  15676. */
  15677. opposite: false,
  15678. /**
  15679. * In an ordinal axis, the points are equally spaced in the chart
  15680. * regardless of the actual time or x distance between them. This means
  15681. * that missing data periods (e.g. nights or weekends for a stock chart)
  15682. * will not take up space in the chart.
  15683. * Having `ordinal: false` will show any gaps created by the `gapSize`
  15684. * setting proportionate to their duration.
  15685. *
  15686. * In stock charts the X axis is ordinal by default, unless
  15687. * the boost module is used and at least one of the series' data length
  15688. * exceeds the [boostThreshold](#series.line.boostThreshold).
  15689. *
  15690. * For an ordinal axis, `minPadding` and `maxPadding` are ignored. Use
  15691. * [overscroll](#xAxis.overscroll) instead.
  15692. *
  15693. * @sample {highstock} stock/xaxis/ordinal-true/
  15694. * True by default
  15695. * @sample {highstock} stock/xaxis/ordinal-false/
  15696. * False
  15697. *
  15698. * @see [overscroll](#xAxis.overscroll)
  15699. *
  15700. * @type {boolean}
  15701. * @default true
  15702. * @since 1.1
  15703. * @product highstock
  15704. * @apioption xAxis.ordinal
  15705. */
  15706. /**
  15707. * Additional range on the right side of the xAxis. Works similar to
  15708. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  15709. * both main `xAxis` and the navigator's `xAxis`.
  15710. *
  15711. * @sample {highstock} stock/xaxis/overscroll/
  15712. * One minute overscroll with live data
  15713. *
  15714. * @type {number}
  15715. * @default 0
  15716. * @since 6.0.0
  15717. * @product highstock
  15718. * @apioption xAxis.overscroll
  15719. */
  15720. /**
  15721. * Refers to the index in the [panes](#panes) array. Used for circular
  15722. * gauges and polar charts. When the option is not set then first pane
  15723. * will be used.
  15724. *
  15725. * @sample highcharts/demo/gauge-vu-meter
  15726. * Two gauges with different center
  15727. *
  15728. * @type {number}
  15729. * @product highcharts
  15730. * @apioption xAxis.pane
  15731. */
  15732. /**
  15733. * The zoomed range to display when only defining one or none of `min`
  15734. * or `max`. For example, to show the latest month, a range of one month
  15735. * can be set.
  15736. *
  15737. * @sample {highstock} stock/xaxis/range/
  15738. * Setting a zoomed range when the rangeSelector is disabled
  15739. *
  15740. * @type {number}
  15741. * @product highstock
  15742. * @apioption xAxis.range
  15743. */
  15744. /**
  15745. * Whether to reverse the axis so that the highest number is closest
  15746. * to the origin. If the chart is inverted, the x axis is reversed by
  15747. * default.
  15748. *
  15749. * @sample {highcharts} highcharts/yaxis/reversed/
  15750. * Reversed Y axis
  15751. * @sample {highstock} stock/xaxis/reversed/
  15752. * Reversed Y axis
  15753. *
  15754. * @type {boolean}
  15755. * @default undefined
  15756. * @apioption xAxis.reversed
  15757. */
  15758. reversed: void 0,
  15759. /**
  15760. * This option determines how stacks should be ordered within a group.
  15761. * For example reversed xAxis also reverses stacks, so first series
  15762. * comes last in a group. To keep order like for non-reversed xAxis
  15763. * enable this option.
  15764. *
  15765. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  15766. * Reversed stacks comparison
  15767. * @sample {highstock} highcharts/xaxis/reversedstacks/
  15768. * Reversed stacks comparison
  15769. *
  15770. * @since 6.1.1
  15771. * @product highcharts highstock
  15772. */
  15773. reversedStacks: false,
  15774. /**
  15775. * An optional scrollbar to display on the X axis in response to
  15776. * limiting the minimum and maximum of the axis values.
  15777. *
  15778. * In styled mode, all the presentational options for the scrollbar are
  15779. * replaced by the classes `.highcharts-scrollbar-thumb`,
  15780. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  15781. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  15782. *
  15783. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  15784. * Heatmap with both scrollbars
  15785. *
  15786. * @extends scrollbar
  15787. * @since 4.2.6
  15788. * @product highstock
  15789. * @apioption xAxis.scrollbar
  15790. */
  15791. /**
  15792. * Whether to show the axis line and title when the axis has no data.
  15793. *
  15794. * @sample {highcharts} highcharts/yaxis/showempty/
  15795. * When clicking the legend to hide series, one axis preserves
  15796. * line and title, the other doesn't
  15797. * @sample {highstock} highcharts/yaxis/showempty/
  15798. * When clicking the legend to hide series, one axis preserves
  15799. * line and title, the other doesn't
  15800. *
  15801. * @since 1.1
  15802. */
  15803. showEmpty: true,
  15804. /**
  15805. * Whether to show the first tick label.
  15806. *
  15807. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  15808. * Set to false on X axis
  15809. * @sample {highstock} stock/xaxis/showfirstlabel/
  15810. * Labels below plot lines on Y axis
  15811. */
  15812. showFirstLabel: true,
  15813. /**
  15814. * Whether to show the last tick label. Defaults to `true` on cartesian
  15815. * charts, and `false` on polar charts.
  15816. *
  15817. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  15818. * Set to true on X axis
  15819. * @sample {highstock} stock/xaxis/showfirstlabel/
  15820. * Labels below plot lines on Y axis
  15821. *
  15822. * @product highcharts highstock gantt
  15823. */
  15824. showLastLabel: true,
  15825. /**
  15826. * A soft maximum for the axis. If the series data maximum is less than
  15827. * this, the axis will stay at this maximum, but if the series data
  15828. * maximum is higher, the axis will flex to show all data.
  15829. *
  15830. * @sample highcharts/yaxis/softmin-softmax/
  15831. * Soft min and max
  15832. *
  15833. * @type {number}
  15834. * @since 5.0.1
  15835. * @product highcharts highstock gantt
  15836. * @apioption xAxis.softMax
  15837. */
  15838. /**
  15839. * A soft minimum for the axis. If the series data minimum is greater
  15840. * than this, the axis will stay at this minimum, but if the series
  15841. * data minimum is lower, the axis will flex to show all data.
  15842. *
  15843. * @sample highcharts/yaxis/softmin-softmax/
  15844. * Soft min and max
  15845. *
  15846. * @type {number}
  15847. * @since 5.0.1
  15848. * @product highcharts highstock gantt
  15849. * @apioption xAxis.softMin
  15850. */
  15851. /**
  15852. * For datetime axes, this decides where to put the tick between weeks.
  15853. * 0 = Sunday, 1 = Monday.
  15854. *
  15855. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  15856. * Monday by default
  15857. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  15858. * Sunday
  15859. * @sample {highstock} stock/xaxis/startofweek-1
  15860. * Monday by default
  15861. * @sample {highstock} stock/xaxis/startofweek-0
  15862. * Sunday
  15863. *
  15864. * @product highcharts highstock gantt
  15865. */
  15866. startOfWeek: 1,
  15867. /**
  15868. * Whether to force the axis to start on a tick. Use this option with
  15869. * the `minPadding` option to control the axis start.
  15870. *
  15871. * @productdesc {highstock}
  15872. * In Highcharts Stock, `startOnTick` is always `false` when
  15873. * the navigator is enabled, to prevent jumpy scrolling.
  15874. *
  15875. * @sample {highcharts} highcharts/xaxis/startontick-false/
  15876. * False by default
  15877. * @sample {highcharts} highcharts/xaxis/startontick-true/
  15878. * True
  15879. *
  15880. * @since 1.2.0
  15881. */
  15882. startOnTick: false,
  15883. /**
  15884. * The amount of ticks to draw on the axis. This opens up for aligning
  15885. * the ticks of multiple charts or panes within a chart. This option
  15886. * overrides the `tickPixelInterval` option.
  15887. *
  15888. * This option only has an effect on linear axes. Datetime, logarithmic
  15889. * or category axes are not affected.
  15890. *
  15891. * @sample {highcharts} highcharts/yaxis/tickamount/
  15892. * 8 ticks on Y axis
  15893. * @sample {highstock} highcharts/yaxis/tickamount/
  15894. * 8 ticks on Y axis
  15895. *
  15896. * @type {number}
  15897. * @since 4.1.0
  15898. * @product highcharts highstock gantt
  15899. * @apioption xAxis.tickAmount
  15900. */
  15901. /**
  15902. * The interval of the tick marks in axis units. When `undefined`, the
  15903. * tick interval is computed to approximately follow the
  15904. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  15905. * axes. On categorized axes, a `undefined` tickInterval will default to
  15906. * 1, one category. Note that datetime axes are based on milliseconds,
  15907. * so for example an interval of one day is expressed as
  15908. * `24 * 3600 * 1000`.
  15909. *
  15910. * On logarithmic axes, the tickInterval is based on powers, so a
  15911. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  15912. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  15913. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  15914. * 40 etc.
  15915. *
  15916. *
  15917. * If the tickInterval is too dense for labels to be drawn, Highcharts
  15918. * may remove ticks.
  15919. *
  15920. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  15921. * option may interfere with the `tickInterval` setting.
  15922. *
  15923. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  15924. * @see [tickPositions](#xAxis.tickPositions)
  15925. * @see [tickPositioner](#xAxis.tickPositioner)
  15926. *
  15927. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  15928. * Tick interval of 5 on a linear axis
  15929. * @sample {highstock} stock/xaxis/tickinterval/
  15930. * Tick interval of 0.01 on Y axis
  15931. *
  15932. * @type {number}
  15933. * @apioption xAxis.tickInterval
  15934. */
  15935. /**
  15936. * The pixel length of the main tick marks.
  15937. *
  15938. * @sample {highcharts} highcharts/xaxis/ticklength/
  15939. * 20 px tick length on the X axis
  15940. * @sample {highstock} stock/xaxis/ticks/
  15941. * Formatted ticks on X axis
  15942. */
  15943. tickLength: 10,
  15944. /**
  15945. * If tickInterval is `null` this option sets the approximate pixel
  15946. * interval of the tick marks. Not applicable to categorized axis.
  15947. *
  15948. * The tick interval is also influenced by the [minTickInterval](
  15949. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  15950. * being denser than the data points.
  15951. *
  15952. * @see [tickInterval](#xAxis.tickInterval)
  15953. * @see [tickPositioner](#xAxis.tickPositioner)
  15954. * @see [tickPositions](#xAxis.tickPositions)
  15955. *
  15956. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  15957. * 50 px on X axis
  15958. * @sample {highstock} stock/xaxis/tickpixelinterval/
  15959. * 200 px on X axis
  15960. */
  15961. tickPixelInterval: 100,
  15962. /**
  15963. * For categorized axes only. If `on` the tick mark is placed in the
  15964. * center of the category, if `between` the tick mark is placed between
  15965. * categories. The default is `between` if the `tickInterval` is 1, else
  15966. * `on`.
  15967. *
  15968. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  15969. * "between" by default
  15970. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  15971. * "on"
  15972. *
  15973. * @product highcharts gantt
  15974. * @validvalue ["on", "between"]
  15975. */
  15976. tickmarkPlacement: 'between',
  15977. /**
  15978. * The position of the major tick marks relative to the axis line.
  15979. * Can be one of `inside` and `outside`.
  15980. *
  15981. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  15982. * "outside" by default
  15983. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  15984. * "inside"
  15985. * @sample {highstock} stock/xaxis/ticks/
  15986. * Formatted ticks on X axis
  15987. *
  15988. * @validvalue ["inside", "outside"]
  15989. */
  15990. tickPosition: 'outside',
  15991. /**
  15992. * A callback function returning array defining where the ticks are
  15993. * laid out on the axis. This overrides the default behaviour of
  15994. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  15995. * #xAxis.tickInterval). The automatic tick positions are accessible
  15996. * through `this.tickPositions` and can be modified by the callback.
  15997. *
  15998. * @see [tickPositions](#xAxis.tickPositions)
  15999. *
  16000. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  16001. * Demo of tickPositions and tickPositioner
  16002. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  16003. * Demo of tickPositions and tickPositioner
  16004. *
  16005. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  16006. * @apioption xAxis.tickPositioner
  16007. */
  16008. /**
  16009. * An array defining where the ticks are laid out on the axis. This
  16010. * overrides the default behaviour of [tickPixelInterval](
  16011. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  16012. *
  16013. * @see [tickPositioner](#xAxis.tickPositioner)
  16014. *
  16015. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  16016. * Demo of tickPositions and tickPositioner
  16017. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  16018. * Demo of tickPositions and tickPositioner
  16019. *
  16020. * @type {Array<number>}
  16021. * @apioption xAxis.tickPositions
  16022. */
  16023. /**
  16024. * The pixel width of the major tick marks. Defaults to 0 on category
  16025. * axes, otherwise 1.
  16026. *
  16027. * In styled mode, the stroke width is given in the `.highcharts-tick`
  16028. * class, but in order for the element to be generated on category axes,
  16029. * the option must be explicitly set to 1.
  16030. *
  16031. * @sample {highcharts} highcharts/xaxis/tickwidth/
  16032. * 10 px width
  16033. * @sample {highcharts} highcharts/css/axis-grid/
  16034. * Styled mode
  16035. * @sample {highstock} stock/xaxis/ticks/
  16036. * Formatted ticks on X axis
  16037. * @sample {highstock} highcharts/css/axis-grid/
  16038. * Styled mode
  16039. *
  16040. * @type {undefined|number}
  16041. * @default {highstock} 1
  16042. * @default {highmaps} 0
  16043. * @apioption xAxis.tickWidth
  16044. */
  16045. /**
  16046. * The axis title, showing next to the axis line.
  16047. *
  16048. * @productdesc {highmaps}
  16049. * In Highmaps, the axis is hidden by default, but adding an axis title
  16050. * is still possible. X axis and Y axis titles will appear at the bottom
  16051. * and left by default.
  16052. */
  16053. title: {
  16054. /**
  16055. * Alignment of the title relative to the axis values. Possible
  16056. * values are "low", "middle" or "high".
  16057. *
  16058. * @sample {highcharts} highcharts/xaxis/title-align-low/
  16059. * "low"
  16060. * @sample {highcharts} highcharts/xaxis/title-align-center/
  16061. * "middle" by default
  16062. * @sample {highcharts} highcharts/xaxis/title-align-high/
  16063. * "high"
  16064. * @sample {highcharts} highcharts/yaxis/title-offset/
  16065. * Place the Y axis title on top of the axis
  16066. * @sample {highstock} stock/xaxis/title-align/
  16067. * Aligned to "high" value
  16068. *
  16069. * @type {Highcharts.AxisTitleAlignValue}
  16070. */
  16071. align: 'middle',
  16072. /**
  16073. * Deprecated. Set the `text` to `undefined` to disable the title.
  16074. *
  16075. * @deprecated
  16076. * @type {boolean}
  16077. * @product highcharts
  16078. * @apioption xAxis.title.enabled
  16079. */
  16080. /**
  16081. * The pixel distance between the axis labels or line and the title.
  16082. * Defaults to 0 for horizontal axes, 10 for vertical
  16083. *
  16084. * @sample {highcharts} highcharts/xaxis/title-margin/
  16085. * Y axis title margin of 60
  16086. *
  16087. * @type {number}
  16088. * @apioption xAxis.title.margin
  16089. */
  16090. /**
  16091. * The distance of the axis title from the axis line. By default,
  16092. * this distance is computed from the offset width of the labels,
  16093. * the labels' distance from the axis and the title's margin.
  16094. * However when the offset option is set, it overrides all this.
  16095. *
  16096. * @sample {highcharts} highcharts/yaxis/title-offset/
  16097. * Place the axis title on top of the axis
  16098. * @sample {highstock} highcharts/yaxis/title-offset/
  16099. * Place the axis title on top of the Y axis
  16100. *
  16101. * @type {number}
  16102. * @since 2.2.0
  16103. * @apioption xAxis.title.offset
  16104. */
  16105. /**
  16106. * Whether to reserve space for the title when laying out the axis.
  16107. *
  16108. * @type {boolean}
  16109. * @default true
  16110. * @since 5.0.11
  16111. * @product highcharts highstock gantt
  16112. * @apioption xAxis.title.reserveSpace
  16113. */
  16114. /**
  16115. * The rotation of the text in degrees. 0 is horizontal, 270 is
  16116. * vertical reading from bottom to top.
  16117. *
  16118. * @sample {highcharts} highcharts/yaxis/title-offset/
  16119. * Horizontal
  16120. */
  16121. rotation: 0,
  16122. /**
  16123. * The actual text of the axis title. It can contain basic HTML tags
  16124. * like `b`, `i` and `span` with style.
  16125. *
  16126. * @sample {highcharts} highcharts/xaxis/title-text/
  16127. * Custom HTML
  16128. * @sample {highstock} stock/xaxis/title-text/
  16129. * Titles for both axes
  16130. *
  16131. * @type {string|null}
  16132. * @apioption xAxis.title.text
  16133. */
  16134. /**
  16135. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  16136. * Default alignment depends on the
  16137. * [title.align](xAxis.title.align):
  16138. *
  16139. * Horizontal axes:
  16140. * - for `align` = `"low"`, `textAlign` is set to `left`
  16141. * - for `align` = `"middle"`, `textAlign` is set to `center`
  16142. * - for `align` = `"high"`, `textAlign` is set to `right`
  16143. *
  16144. * Vertical axes:
  16145. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  16146. * set to `right`
  16147. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  16148. * set to `left`
  16149. * - for `align` = `"middle"`, `textAlign` is set to `center`
  16150. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  16151. * set to `left`
  16152. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  16153. * set to `right`
  16154. *
  16155. * @type {Highcharts.AlignValue}
  16156. * @apioption xAxis.title.textAlign
  16157. */
  16158. /**
  16159. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  16160. * to render the axis title.
  16161. *
  16162. * @product highcharts highstock gantt
  16163. */
  16164. useHTML: false,
  16165. /**
  16166. * Horizontal pixel offset of the title position.
  16167. *
  16168. * @since 4.1.6
  16169. * @product highcharts highstock gantt
  16170. */
  16171. x: 0,
  16172. /**
  16173. * Vertical pixel offset of the title position.
  16174. *
  16175. * @product highcharts highstock gantt
  16176. */
  16177. y: 0,
  16178. /**
  16179. * CSS styles for the title. If the title text is longer than the
  16180. * axis length, it will wrap to multiple lines by default. This can
  16181. * be customized by setting `textOverflow: 'ellipsis'`, by
  16182. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  16183. *
  16184. * In styled mode, the stroke width is given in the
  16185. * `.highcharts-axis-title` class.
  16186. *
  16187. * @sample {highcharts} highcharts/xaxis/title-style/
  16188. * Red
  16189. * @sample {highcharts} highcharts/css/axis/
  16190. * Styled mode
  16191. *
  16192. * @type {Highcharts.CSSObject}
  16193. */
  16194. style: {
  16195. /** @internal */
  16196. color: Palette.neutralColor60
  16197. }
  16198. },
  16199. /**
  16200. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  16201. * or `category`. In a datetime axis, the numbers are given in
  16202. * milliseconds, and tick marks are placed on appropriate values like
  16203. * full hours or days. In a category axis, the
  16204. * [point names](#series.line.data.name) of the chart's series are used
  16205. * for categories, if not a [categories](#xAxis.categories) array is
  16206. * defined.
  16207. *
  16208. * @sample {highcharts} highcharts/xaxis/type-linear/
  16209. * Linear
  16210. * @sample {highcharts} highcharts/yaxis/type-log/
  16211. * Logarithmic
  16212. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  16213. * Logarithmic with minor grid lines
  16214. * @sample {highcharts} highcharts/xaxis/type-log-both/
  16215. * Logarithmic on two axes
  16216. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  16217. * Logarithmic with extension to emulate negative values
  16218. *
  16219. * @type {Highcharts.AxisTypeValue}
  16220. * @product highcharts gantt
  16221. */
  16222. type: 'linear',
  16223. /**
  16224. * If there are multiple axes on the same side of the chart, the pixel
  16225. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  16226. * horizontal axes.
  16227. *
  16228. * @type {number}
  16229. * @since 7.0.3
  16230. * @apioption xAxis.margin
  16231. */
  16232. /**
  16233. * Applies only when the axis `type` is `category`. When `uniqueNames`
  16234. * is true, points are placed on the X axis according to their names.
  16235. * If the same point name is repeated in the same or another series,
  16236. * the point is placed on the same X position as other points of the
  16237. * same name. When `uniqueNames` is false, the points are laid out in
  16238. * increasing X positions regardless of their names, and the X axis
  16239. * category will take the name of the last point in each position.
  16240. *
  16241. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  16242. * True by default
  16243. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  16244. * False
  16245. *
  16246. * @since 4.2.7
  16247. * @product highcharts gantt
  16248. */
  16249. uniqueNames: true,
  16250. /**
  16251. * Datetime axis only. An array determining what time intervals the
  16252. * ticks are allowed to fall on. Each array item is an array where the
  16253. * first value is the time unit and the second value another array of
  16254. * allowed multiples.
  16255. *
  16256. * Defaults to:
  16257. * ```js
  16258. * units: [[
  16259. * 'millisecond', // unit name
  16260. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  16261. * ], [
  16262. * 'second',
  16263. * [1, 2, 5, 10, 15, 30]
  16264. * ], [
  16265. * 'minute',
  16266. * [1, 2, 5, 10, 15, 30]
  16267. * ], [
  16268. * 'hour',
  16269. * [1, 2, 3, 4, 6, 8, 12]
  16270. * ], [
  16271. * 'day',
  16272. * [1, 2]
  16273. * ], [
  16274. * 'week',
  16275. * [1, 2]
  16276. * ], [
  16277. * 'month',
  16278. * [1, 2, 3, 4, 6]
  16279. * ], [
  16280. * 'year',
  16281. * null
  16282. * ]]
  16283. * ```
  16284. *
  16285. * @type {Array<Array<string,(Array<number>|null)>>}
  16286. * @product highcharts highstock gantt
  16287. * @apioption xAxis.units
  16288. */
  16289. /**
  16290. * Whether axis, including axis title, line, ticks and labels, should
  16291. * be visible.
  16292. *
  16293. * @since 4.1.9
  16294. * @product highcharts highstock gantt
  16295. */
  16296. visible: true,
  16297. /**
  16298. * Color of the minor, secondary grid lines.
  16299. *
  16300. * In styled mode, the stroke width is given in the
  16301. * `.highcharts-minor-grid-line` class.
  16302. *
  16303. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  16304. * Bright grey lines from Y axis
  16305. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16306. * Styled mode
  16307. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  16308. * Bright grey lines from Y axis
  16309. *
  16310. * @type {Highcharts.ColorType}
  16311. * @default #f2f2f2
  16312. */
  16313. minorGridLineColor: Palette.neutralColor5,
  16314. /**
  16315. * Width of the minor, secondary grid lines.
  16316. *
  16317. * In styled mode, the stroke width is given in the
  16318. * `.highcharts-grid-line` class.
  16319. *
  16320. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  16321. * 2px lines from Y axis
  16322. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16323. * Styled mode
  16324. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  16325. * 2px lines from Y axis
  16326. */
  16327. minorGridLineWidth: 1,
  16328. /**
  16329. * Color for the minor tick marks.
  16330. *
  16331. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  16332. * Black tick marks on Y axis
  16333. * @sample {highstock} stock/xaxis/minorticks/
  16334. * Black tick marks on Y axis
  16335. *
  16336. * @type {Highcharts.ColorType}
  16337. * @default #999999
  16338. */
  16339. minorTickColor: Palette.neutralColor40,
  16340. /**
  16341. * The color of the line marking the axis itself.
  16342. *
  16343. * In styled mode, the line stroke is given in the
  16344. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  16345. *
  16346. * @productdesc {highmaps}
  16347. * In Highmaps, the axis line is hidden by default, because the axis is
  16348. * not visible by default.
  16349. *
  16350. * @sample {highcharts} highcharts/yaxis/linecolor/
  16351. * A red line on Y axis
  16352. * @sample {highcharts|highstock} highcharts/css/axis/
  16353. * Axes in styled mode
  16354. * @sample {highstock} stock/xaxis/linecolor/
  16355. * A red line on X axis
  16356. *
  16357. * @type {Highcharts.ColorType}
  16358. * @default #ccd6eb
  16359. */
  16360. lineColor: Palette.highlightColor20,
  16361. /**
  16362. * The width of the line marking the axis itself.
  16363. *
  16364. * In styled mode, the stroke width is given in the
  16365. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  16366. *
  16367. * @sample {highcharts} highcharts/yaxis/linecolor/
  16368. * A 1px line on Y axis
  16369. * @sample {highcharts|highstock} highcharts/css/axis/
  16370. * Axes in styled mode
  16371. * @sample {highstock} stock/xaxis/linewidth/
  16372. * A 2px line on X axis
  16373. *
  16374. * @default {highcharts|highstock} 1
  16375. * @default {highmaps} 0
  16376. */
  16377. lineWidth: 1,
  16378. /**
  16379. * Color of the grid lines extending the ticks across the plot area.
  16380. *
  16381. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  16382. * class.
  16383. *
  16384. * @productdesc {highmaps}
  16385. * In Highmaps, the grid lines are hidden by default.
  16386. *
  16387. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  16388. * Green lines
  16389. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16390. * Styled mode
  16391. * @sample {highstock} stock/xaxis/gridlinecolor/
  16392. * Green lines
  16393. *
  16394. * @type {Highcharts.ColorType}
  16395. * @default #e6e6e6
  16396. */
  16397. gridLineColor: Palette.neutralColor10,
  16398. /**
  16399. * The width of the grid lines extending the ticks across the plot area.
  16400. * Defaults to 1 on the Y axis and 0 on the X axis, except for 3d
  16401. * charts.
  16402. *
  16403. * In styled mode, the stroke width is given in the
  16404. * `.highcharts-grid-line` class.
  16405. *
  16406. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  16407. * 2px lines
  16408. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16409. * Styled mode
  16410. * @sample {highstock} stock/xaxis/gridlinewidth/
  16411. * 2px lines
  16412. *
  16413. * @type {number}
  16414. * @apioption xAxis.gridLineWidth
  16415. */
  16416. gridLineWidth: void 0,
  16417. /**
  16418. * The height as the vertical axis. If it's a number, it is
  16419. * interpreted as pixels.
  16420. *
  16421. * Since Highcharts 2: If it's a percentage string, it is interpreted
  16422. * as percentages of the total plot height.
  16423. *
  16424. * @type {number|string}
  16425. * @product highcharts highstock
  16426. * @apioption xAxis.height
  16427. */
  16428. /**
  16429. * The width as the horizontal axis. If it's a number, it is interpreted
  16430. * as pixels.
  16431. *
  16432. * Since Highcharts v5.0.13: If it's a percentage string, it is
  16433. * interpreted as percentages of the total plot width.
  16434. *
  16435. * @type {number|string}
  16436. * @product highcharts highstock
  16437. * @apioption xAxis.width
  16438. */
  16439. /**
  16440. * Color for the main tick marks.
  16441. *
  16442. * In styled mode, the stroke is given in the `.highcharts-tick`
  16443. * class.
  16444. *
  16445. * @sample {highcharts} highcharts/xaxis/tickcolor/
  16446. * Red ticks on X axis
  16447. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16448. * Styled mode
  16449. * @sample {highstock} stock/xaxis/ticks/
  16450. * Formatted ticks on X axis
  16451. *
  16452. * @type {Highcharts.ColorType}
  16453. * @default #ccd6eb
  16454. */
  16455. tickColor: Palette.highlightColor20
  16456. // tickWidth: 1
  16457. };
  16458. /**
  16459. * The Y axis or value axis. Normally this is the vertical axis,
  16460. * though if the chart is inverted this is the horizontal axis.
  16461. * In case of multiple axes, the yAxis node is an array of
  16462. * configuration objects.
  16463. *
  16464. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  16465. * access to the axis.
  16466. *
  16467. * @type {*|Array<*>}
  16468. * @extends xAxis
  16469. * @excluding currentDateIndicator,ordinal,overscroll
  16470. * @optionparent yAxis
  16471. */
  16472. AxisDefaults.defaultYAxisOptions = {
  16473. /**
  16474. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  16475. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  16476. * `linear` for other chart types.
  16477. *
  16478. * In a datetime axis, the numbers are given in milliseconds, and tick
  16479. * marks are placed on appropriate values, like full hours or days. In a
  16480. * category or treegrid axis, the [point names](#series.line.data.name)
  16481. * of the chart's series are used for categories, if a
  16482. * [categories](#xAxis.categories) array is not defined.
  16483. *
  16484. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  16485. * Logarithmic with minor grid lines
  16486. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  16487. * Logarithmic with extension to emulate negative values
  16488. * @sample {gantt} gantt/treegrid-axis/demo
  16489. * Treegrid axis
  16490. *
  16491. * @type {Highcharts.AxisTypeValue}
  16492. * @default {highcharts} linear
  16493. * @default {gantt} treegrid
  16494. * @product highcharts gantt
  16495. * @apioption yAxis.type
  16496. */
  16497. /**
  16498. * The height of the Y axis. If it's a number, it is interpreted as
  16499. * pixels.
  16500. *
  16501. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  16502. * percentages of the total plot height.
  16503. *
  16504. * @see [yAxis.top](#yAxis.top)
  16505. *
  16506. * @sample {highstock} stock/demo/candlestick-and-volume/
  16507. * Percentage height panes
  16508. *
  16509. * @type {number|string}
  16510. * @product highcharts highstock
  16511. * @apioption yAxis.height
  16512. */
  16513. /**
  16514. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  16515. * to represent the maximum value of the Y axis.
  16516. *
  16517. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  16518. * Min and max colors
  16519. *
  16520. * @type {Highcharts.ColorType}
  16521. * @default #003399
  16522. * @since 4.0
  16523. * @product highcharts
  16524. * @apioption yAxis.maxColor
  16525. */
  16526. /**
  16527. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  16528. * to represent the minimum value of the Y axis.
  16529. *
  16530. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  16531. * Min and max color
  16532. *
  16533. * @type {Highcharts.ColorType}
  16534. * @default #e6ebf5
  16535. * @since 4.0
  16536. * @product highcharts
  16537. * @apioption yAxis.minColor
  16538. */
  16539. /**
  16540. * Whether to reverse the axis so that the highest number is closest
  16541. * to the origin.
  16542. *
  16543. * @sample {highcharts} highcharts/yaxis/reversed/
  16544. * Reversed Y axis
  16545. * @sample {highstock} stock/xaxis/reversed/
  16546. * Reversed Y axis
  16547. *
  16548. * @type {boolean}
  16549. * @default {highcharts} false
  16550. * @default {highstock} false
  16551. * @default {highmaps} true
  16552. * @default {gantt} true
  16553. * @apioption yAxis.reversed
  16554. */
  16555. /**
  16556. * If `true`, the first series in a stack will be drawn on top in a
  16557. * positive, non-reversed Y axis. If `false`, the first series is in
  16558. * the base of the stack.
  16559. *
  16560. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  16561. * Non-reversed stacks
  16562. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  16563. * Non-reversed stacks
  16564. *
  16565. * @type {boolean}
  16566. * @default true
  16567. * @since 3.0.10
  16568. * @product highcharts highstock
  16569. * @apioption yAxis.reversedStacks
  16570. */
  16571. reversedStacks: true,
  16572. /**
  16573. * Solid gauge series only. Color stops for the solid gauge. Use this
  16574. * in cases where a linear gradient between a `minColor` and `maxColor`
  16575. * is not sufficient. The stops is an array of tuples, where the first
  16576. * item is a float between 0 and 1 assigning the relative position in
  16577. * the gradient, and the second item is the color.
  16578. *
  16579. * For solid gauges, the Y axis also inherits the concept of
  16580. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  16581. * from the Highmaps color axis.
  16582. *
  16583. * @see [minColor](#yAxis.minColor)
  16584. * @see [maxColor](#yAxis.maxColor)
  16585. *
  16586. * @sample {highcharts} highcharts/demo/gauge-solid/
  16587. * True by default
  16588. *
  16589. * @type {Array<Array<number,Highcharts.ColorType>>}
  16590. * @since 4.0
  16591. * @product highcharts
  16592. * @apioption yAxis.stops
  16593. */
  16594. /**
  16595. * The pixel width of the major tick marks.
  16596. *
  16597. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  16598. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  16599. *
  16600. * @type {number}
  16601. * @default 0
  16602. * @product highcharts highstock gantt
  16603. * @apioption yAxis.tickWidth
  16604. */
  16605. /**
  16606. * Whether to force the axis to end on a tick. Use this option with
  16607. * the `maxPadding` option to control the axis end.
  16608. *
  16609. * This option is always disabled, when panning type is
  16610. * either `y` or `xy`.
  16611. *
  16612. * @see [type](#chart.panning.type)
  16613. *
  16614. *
  16615. * @sample {highcharts} highcharts/chart/reflow-true/
  16616. * True by default
  16617. * @sample {highcharts} highcharts/yaxis/endontick/
  16618. * False
  16619. * @sample {highstock} stock/demo/basic-line/
  16620. * True by default
  16621. * @sample {highstock} stock/xaxis/endontick/
  16622. * False for Y axis
  16623. *
  16624. * @since 1.2.0
  16625. */
  16626. endOnTick: true,
  16627. /**
  16628. * Padding of the max value relative to the length of the axis. A
  16629. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  16630. * when you don't want the highest data value to appear on the edge
  16631. * of the plot area. When the axis' `max` option is set or a max extreme
  16632. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  16633. *
  16634. * Also the `softThreshold` option takes precedence over `maxPadding`,
  16635. * so if the data is tangent to the threshold, `maxPadding` may not
  16636. * apply unless `softThreshold` is set to false.
  16637. *
  16638. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  16639. * Max padding of 0.2
  16640. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  16641. * Greater min- and maxPadding
  16642. *
  16643. * @since 1.2.0
  16644. * @product highcharts highstock gantt
  16645. */
  16646. maxPadding: 0.05,
  16647. /**
  16648. * Padding of the min value relative to the length of the axis. A
  16649. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  16650. * when you don't want the lowest data value to appear on the edge
  16651. * of the plot area. When the axis' `min` option is set or a max extreme
  16652. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  16653. *
  16654. * Also the `softThreshold` option takes precedence over `minPadding`,
  16655. * so if the data is tangent to the threshold, `minPadding` may not
  16656. * apply unless `softThreshold` is set to false.
  16657. *
  16658. * @sample {highcharts} highcharts/yaxis/minpadding/
  16659. * Min padding of 0.2
  16660. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  16661. * Greater min- and maxPadding
  16662. *
  16663. * @since 1.2.0
  16664. * @product highcharts highstock gantt
  16665. */
  16666. minPadding: 0.05,
  16667. /**
  16668. * @productdesc {highstock}
  16669. * In Highcharts Stock 1.x, the Y axis was placed
  16670. * on the left side by default.
  16671. *
  16672. * @sample {highcharts} highcharts/yaxis/opposite/
  16673. * Secondary Y axis opposite
  16674. * @sample {highstock} stock/xaxis/opposite/
  16675. * Y axis on left side
  16676. *
  16677. * @type {boolean}
  16678. * @default {highstock} true
  16679. * @default {highcharts} false
  16680. * @product highstock highcharts gantt
  16681. * @apioption yAxis.opposite
  16682. */
  16683. /**
  16684. * @see [tickInterval](#xAxis.tickInterval)
  16685. * @see [tickPositioner](#xAxis.tickPositioner)
  16686. * @see [tickPositions](#xAxis.tickPositions)
  16687. */
  16688. tickPixelInterval: 72,
  16689. showLastLabel: true,
  16690. /**
  16691. * @extends xAxis.labels
  16692. */
  16693. labels: {
  16694. /**
  16695. * Angular gauges and solid gauges only.
  16696. * The label's pixel distance from the perimeter of the plot area.
  16697. *
  16698. * Since v7.1.2: If it's a percentage string, it is interpreted the
  16699. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  16700. * aligned under the gauge's shape.
  16701. *
  16702. * @sample {highcharts} highcharts/yaxis/labels-distance/
  16703. * Labels centered under the arc
  16704. *
  16705. * @type {number|string}
  16706. * @default -25
  16707. * @product highcharts
  16708. * @apioption yAxis.labels.distance
  16709. */
  16710. /**
  16711. * The y position offset of all labels relative to the tick
  16712. * positions on the axis. For polar and radial axis consider the use
  16713. * of the [distance](#yAxis.labels.distance) option.
  16714. *
  16715. * @sample {highcharts} highcharts/xaxis/labels-x/
  16716. * Y axis labels placed on grid lines
  16717. *
  16718. * @type {number}
  16719. * @default {highcharts} 3
  16720. * @default {highstock} -2
  16721. * @default {highmaps} 3
  16722. * @apioption yAxis.labels.y
  16723. */
  16724. /**
  16725. * What part of the string the given position is anchored to. Can
  16726. * be one of `"left"`, `"center"` or `"right"`. The exact position
  16727. * also depends on the `labels.x` setting.
  16728. *
  16729. * Angular gauges and solid gauges defaults to `"center"`.
  16730. * Solid gauges with two labels have additional option `"auto"`
  16731. * for automatic horizontal and vertical alignment.
  16732. *
  16733. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  16734. *
  16735. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  16736. * Left
  16737. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  16738. * Solid gauge labels auto aligned
  16739. *
  16740. * @type {Highcharts.AlignValue}
  16741. * @default {highcharts|highmaps} right
  16742. * @default {highstock} left
  16743. * @apioption yAxis.labels.align
  16744. */
  16745. /**
  16746. * The x position offset of all labels relative to the tick
  16747. * positions on the axis. Defaults to -15 for left axis, 15 for
  16748. * right axis.
  16749. *
  16750. * @sample {highcharts} highcharts/xaxis/labels-x/
  16751. * Y axis labels placed on grid lines
  16752. */
  16753. x: -8
  16754. },
  16755. /**
  16756. * @productdesc {highmaps}
  16757. * In Highmaps, the axis line is hidden by default, because the axis is
  16758. * not visible by default.
  16759. *
  16760. * @type {Highcharts.ColorType}
  16761. * @apioption yAxis.lineColor
  16762. */
  16763. /**
  16764. * @sample {highcharts} highcharts/yaxis/max-200/
  16765. * Y axis max of 200
  16766. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  16767. * Y axis max on logarithmic axis
  16768. * @sample {highstock} stock/yaxis/min-max/
  16769. * Fixed min and max on Y axis
  16770. * @sample {highmaps} maps/axis/min-max/
  16771. * Pre-zoomed to a specific area
  16772. *
  16773. * @apioption yAxis.max
  16774. */
  16775. /**
  16776. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  16777. * -50 with startOnTick to false
  16778. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  16779. * -50 with startOnTick true by default
  16780. * @sample {highstock} stock/yaxis/min-max/
  16781. * Fixed min and max on Y axis
  16782. * @sample {highmaps} maps/axis/min-max/
  16783. * Pre-zoomed to a specific area
  16784. *
  16785. * @apioption yAxis.min
  16786. */
  16787. /**
  16788. * An optional scrollbar to display on the Y axis in response to
  16789. * limiting the minimum an maximum of the axis values.
  16790. *
  16791. * In styled mode, all the presentational options for the scrollbar
  16792. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  16793. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  16794. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  16795. *
  16796. * @sample {highstock} stock/yaxis/scrollbar/
  16797. * Scrollbar on the Y axis
  16798. *
  16799. * @extends scrollbar
  16800. * @since 4.2.6
  16801. * @product highstock
  16802. * @excluding height
  16803. * @apioption yAxis.scrollbar
  16804. */
  16805. /**
  16806. * Enable the scrollbar on the Y axis.
  16807. *
  16808. * @sample {highstock} stock/yaxis/scrollbar/
  16809. * Enabled on Y axis
  16810. *
  16811. * @type {boolean}
  16812. * @default false
  16813. * @since 4.2.6
  16814. * @product highstock
  16815. * @apioption yAxis.scrollbar.enabled
  16816. */
  16817. /**
  16818. * Pixel margin between the scrollbar and the axis elements.
  16819. *
  16820. * @type {number}
  16821. * @default 10
  16822. * @since 4.2.6
  16823. * @product highstock
  16824. * @apioption yAxis.scrollbar.margin
  16825. */
  16826. /**
  16827. * Whether to show the scrollbar when it is fully zoomed out at max
  16828. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  16829. * hidden until the user zooms in, like common in browsers.
  16830. *
  16831. * @type {boolean}
  16832. * @default true
  16833. * @since 4.2.6
  16834. * @product highstock
  16835. * @apioption yAxis.scrollbar.showFull
  16836. */
  16837. /**
  16838. * The width of a vertical scrollbar or height of a horizontal
  16839. * scrollbar. Defaults to 20 on touch devices.
  16840. *
  16841. * @type {number}
  16842. * @default 14
  16843. * @since 4.2.6
  16844. * @product highstock
  16845. * @apioption yAxis.scrollbar.size
  16846. */
  16847. /**
  16848. * Z index of the scrollbar elements.
  16849. *
  16850. * @type {number}
  16851. * @default 3
  16852. * @since 4.2.6
  16853. * @product highstock
  16854. * @apioption yAxis.scrollbar.zIndex
  16855. */
  16856. /**
  16857. * A soft maximum for the axis. If the series data maximum is less
  16858. * than this, the axis will stay at this maximum, but if the series
  16859. * data maximum is higher, the axis will flex to show all data.
  16860. *
  16861. * **Note**: The [series.softThreshold](
  16862. * #plotOptions.series.softThreshold) option takes precedence over this
  16863. * option.
  16864. *
  16865. * @sample highcharts/yaxis/softmin-softmax/
  16866. * Soft min and max
  16867. *
  16868. * @type {number}
  16869. * @since 5.0.1
  16870. * @product highcharts highstock gantt
  16871. * @apioption yAxis.softMax
  16872. */
  16873. /**
  16874. * A soft minimum for the axis. If the series data minimum is greater
  16875. * than this, the axis will stay at this minimum, but if the series
  16876. * data minimum is lower, the axis will flex to show all data.
  16877. *
  16878. * **Note**: The [series.softThreshold](
  16879. * #plotOptions.series.softThreshold) option takes precedence over this
  16880. * option.
  16881. *
  16882. * @sample highcharts/yaxis/softmin-softmax/
  16883. * Soft min and max
  16884. *
  16885. * @type {number}
  16886. * @since 5.0.1
  16887. * @product highcharts highstock gantt
  16888. * @apioption yAxis.softMin
  16889. */
  16890. /**
  16891. * Defines the horizontal alignment of the stack total label. Can be one
  16892. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  16893. * at runtime and depends on orientation and whether the stack is
  16894. * positive or negative.
  16895. *
  16896. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  16897. * Aligned to the left
  16898. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  16899. * Aligned in center
  16900. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  16901. * Aligned to the right
  16902. *
  16903. * @type {Highcharts.AlignValue}
  16904. * @since 2.1.5
  16905. * @product highcharts
  16906. * @apioption yAxis.stackLabels.align
  16907. */
  16908. /**
  16909. * A format string for the data label. Available variables are the same
  16910. * as for `formatter`.
  16911. *
  16912. * @type {string}
  16913. * @default {total}
  16914. * @since 3.0.2
  16915. * @product highcharts highstock
  16916. * @apioption yAxis.stackLabels.format
  16917. */
  16918. /**
  16919. * Rotation of the labels in degrees.
  16920. *
  16921. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  16922. * Labels rotated 45°
  16923. *
  16924. * @type {number}
  16925. * @default 0
  16926. * @since 2.1.5
  16927. * @product highcharts
  16928. * @apioption yAxis.stackLabels.rotation
  16929. */
  16930. /**
  16931. * The text alignment for the label. While `align` determines where the
  16932. * texts anchor point is placed with regards to the stack, `textAlign`
  16933. * determines how the text is aligned against its anchor point. Possible
  16934. * values are `"left"`, `"center"` and `"right"`. The default value is
  16935. * calculated at runtime and depends on orientation and whether the
  16936. * stack is positive or negative.
  16937. *
  16938. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  16939. * Label in center position but text-aligned left
  16940. *
  16941. * @type {Highcharts.AlignValue}
  16942. * @since 2.1.5
  16943. * @product highcharts
  16944. * @apioption yAxis.stackLabels.textAlign
  16945. */
  16946. /**
  16947. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  16948. * to render the labels.
  16949. *
  16950. * @type {boolean}
  16951. * @default false
  16952. * @since 3.0
  16953. * @product highcharts highstock
  16954. * @apioption yAxis.stackLabels.useHTML
  16955. */
  16956. /**
  16957. * Defines the vertical alignment of the stack total label. Can be one
  16958. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  16959. * at runtime and depends on orientation and whether the stack is
  16960. * positive or negative.
  16961. *
  16962. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  16963. * Vertically aligned top
  16964. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  16965. * Vertically aligned middle
  16966. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  16967. * Vertically aligned bottom
  16968. *
  16969. * @type {Highcharts.VerticalAlignValue}
  16970. * @since 2.1.5
  16971. * @product highcharts
  16972. * @apioption yAxis.stackLabels.verticalAlign
  16973. */
  16974. /**
  16975. * The x position offset of the label relative to the left of the
  16976. * stacked bar. The default value is calculated at runtime and depends
  16977. * on orientation and whether the stack is positive or negative.
  16978. *
  16979. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  16980. * Stack total labels with x offset
  16981. *
  16982. * @type {number}
  16983. * @since 2.1.5
  16984. * @product highcharts
  16985. * @apioption yAxis.stackLabels.x
  16986. */
  16987. /**
  16988. * The y position offset of the label relative to the tick position
  16989. * on the axis. The default value is calculated at runtime and depends
  16990. * on orientation and whether the stack is positive or negative.
  16991. *
  16992. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  16993. * Stack total labels with y offset
  16994. *
  16995. * @type {number}
  16996. * @since 2.1.5
  16997. * @product highcharts
  16998. * @apioption yAxis.stackLabels.y
  16999. */
  17000. /**
  17001. * Whether to force the axis to start on a tick. Use this option with
  17002. * the `maxPadding` option to control the axis start.
  17003. *
  17004. * This option is always disabled, when panning type is
  17005. * either `y` or `xy`.
  17006. *
  17007. * @see [type](#chart.panning.type)
  17008. *
  17009. * @sample {highcharts} highcharts/xaxis/startontick-false/
  17010. * False by default
  17011. * @sample {highcharts} highcharts/xaxis/startontick-true/
  17012. * True
  17013. * @sample {highstock} stock/xaxis/endontick/
  17014. * False for Y axis
  17015. *
  17016. * @since 1.2.0
  17017. * @product highcharts highstock gantt
  17018. */
  17019. startOnTick: true,
  17020. title: {
  17021. /**
  17022. * The pixel distance between the axis labels and the title.
  17023. * Positive values are outside the axis line, negative are inside.
  17024. *
  17025. * @sample {highcharts} highcharts/xaxis/title-margin/
  17026. * Y axis title margin of 60
  17027. *
  17028. * @type {number}
  17029. * @default 40
  17030. * @apioption yAxis.title.margin
  17031. */
  17032. /**
  17033. * The rotation of the text in degrees. 0 is horizontal, 270 is
  17034. * vertical reading from bottom to top.
  17035. *
  17036. * @sample {highcharts} highcharts/yaxis/title-offset/
  17037. * Horizontal
  17038. */
  17039. rotation: 270,
  17040. /**
  17041. * The actual text of the axis title. Horizontal texts can contain
  17042. * HTML, but rotated texts are painted using vector techniques and
  17043. * must be clean text. The Y axis title is disabled by setting the
  17044. * `text` option to `undefined`.
  17045. *
  17046. * @sample {highcharts} highcharts/xaxis/title-text/
  17047. * Custom HTML
  17048. *
  17049. * @type {string|null}
  17050. * @default {highcharts} Values
  17051. * @default {highstock} undefined
  17052. * @product highcharts highstock gantt
  17053. */
  17054. text: 'Values'
  17055. },
  17056. /**
  17057. * The top position of the Y axis. If it's a number, it is interpreted
  17058. * as pixel position relative to the chart.
  17059. *
  17060. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  17061. * percentages of the plot height, offset from plot area top.
  17062. *
  17063. * @see [yAxis.height](#yAxis.height)
  17064. *
  17065. * @sample {highstock} stock/demo/candlestick-and-volume/
  17066. * Percentage height panes
  17067. *
  17068. * @type {number|string}
  17069. * @product highcharts highstock
  17070. * @apioption yAxis.top
  17071. */
  17072. /**
  17073. * The stack labels show the total value for each bar in a stacked
  17074. * column or bar chart. The label will be placed on top of positive
  17075. * columns and below negative columns. In case of an inverted column
  17076. * chart or a bar chart the label is placed to the right of positive
  17077. * bars and to the left of negative bars.
  17078. *
  17079. * @product highcharts
  17080. */
  17081. stackLabels: {
  17082. /**
  17083. * Enable or disable the initial animation when a series is
  17084. * displayed for the `stackLabels`. The animation can also be set as
  17085. * a configuration object. Please note that this option only
  17086. * applies to the initial animation.
  17087. * For other animations, see [chart.animation](#chart.animation)
  17088. * and the animation parameter under the API methods.
  17089. * The following properties are supported:
  17090. *
  17091. * - `defer`: The animation delay time in milliseconds.
  17092. *
  17093. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  17094. * Animation defer settings
  17095. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  17096. * @since 8.2.0
  17097. * @apioption yAxis.stackLabels.animation
  17098. */
  17099. animation: {},
  17100. /**
  17101. * The animation delay time in milliseconds.
  17102. * Set to `0` renders stackLabel immediately.
  17103. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  17104. *
  17105. * @type {number}
  17106. * @since 8.2.0
  17107. * @apioption yAxis.stackLabels.animation.defer
  17108. */
  17109. /**
  17110. * Allow the stack labels to overlap.
  17111. *
  17112. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  17113. * Default false
  17114. *
  17115. * @since 5.0.13
  17116. * @product highcharts
  17117. */
  17118. allowOverlap: false,
  17119. /**
  17120. * The background color or gradient for the stack label.
  17121. *
  17122. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17123. * Stack labels box options
  17124. * @type {Highcharts.ColorType}
  17125. * @since 8.1.0
  17126. * @apioption yAxis.stackLabels.backgroundColor
  17127. */
  17128. /**
  17129. * The border color for the stack label. Defaults to `undefined`.
  17130. *
  17131. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17132. * Stack labels box options
  17133. * @type {Highcharts.ColorType}
  17134. * @since 8.1.0
  17135. * @apioption yAxis.stackLabels.borderColor
  17136. */
  17137. /**
  17138. * The border radius in pixels for the stack label.
  17139. *
  17140. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17141. * Stack labels box options
  17142. * @type {number}
  17143. * @default 0
  17144. * @since 8.1.0
  17145. * @apioption yAxis.stackLabels.borderRadius
  17146. */
  17147. /**
  17148. * The border width in pixels for the stack label.
  17149. *
  17150. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17151. * Stack labels box options
  17152. * @type {number}
  17153. * @default 0
  17154. * @since 8.1.0
  17155. * @apioption yAxis.stackLabels.borderWidth
  17156. */
  17157. /**
  17158. * Enable or disable the stack total labels.
  17159. *
  17160. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  17161. * Enabled stack total labels
  17162. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  17163. * Enabled stack labels in waterfall chart
  17164. *
  17165. * @since 2.1.5
  17166. * @product highcharts
  17167. */
  17168. enabled: false,
  17169. /**
  17170. * Whether to hide stack labels that are outside the plot area.
  17171. * By default, the stack label is moved
  17172. * inside the plot area according to the
  17173. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  17174. * option.
  17175. *
  17176. * @type {boolean}
  17177. * @since 7.1.3
  17178. */
  17179. crop: true,
  17180. /**
  17181. * How to handle stack total labels that flow outside the plot area.
  17182. * The default is set to `"justify"`,
  17183. * which aligns them inside the plot area.
  17184. * For columns and bars, this means it will be moved inside the bar.
  17185. * To display stack labels outside the plot area,
  17186. * set `crop` to `false` and `overflow` to `"allow"`.
  17187. *
  17188. * @sample highcharts/yaxis/stacklabels-overflow/
  17189. * Stack labels flows outside the plot area.
  17190. *
  17191. * @type {Highcharts.DataLabelsOverflowValue}
  17192. * @since 7.1.3
  17193. */
  17194. overflow: 'justify',
  17195. /* eslint-disable valid-jsdoc */
  17196. /**
  17197. * Callback JavaScript function to format the label. The value is
  17198. * given by `this.total`.
  17199. *
  17200. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  17201. * Added units to stack total value
  17202. *
  17203. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  17204. * @since 2.1.5
  17205. * @product highcharts
  17206. */
  17207. formatter: function () {
  17208. var numberFormatter = this.axis.chart.numberFormatter;
  17209. /* eslint-enable valid-jsdoc */
  17210. return numberFormatter(this.total, -1);
  17211. },
  17212. /**
  17213. * CSS styles for the label.
  17214. *
  17215. * In styled mode, the styles are set in the
  17216. * `.highcharts-stack-label` class.
  17217. *
  17218. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  17219. * Red stack total labels
  17220. *
  17221. * @type {Highcharts.CSSObject}
  17222. * @since 2.1.5
  17223. * @product highcharts
  17224. */
  17225. style: {
  17226. /** @internal */
  17227. color: Palette.neutralColor100,
  17228. /** @internal */
  17229. fontSize: '11px',
  17230. /** @internal */
  17231. fontWeight: 'bold',
  17232. /** @internal */
  17233. textOutline: '1px contrast'
  17234. }
  17235. },
  17236. gridLineWidth: 1,
  17237. lineWidth: 0
  17238. // tickWidth: 0
  17239. };
  17240. /**
  17241. * The Z axis or depth axis for 3D plots.
  17242. *
  17243. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  17244. * access to the axis.
  17245. *
  17246. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  17247. * Z-Axis with Categories
  17248. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  17249. * Z-Axis with styling
  17250. *
  17251. * @type {*|Array<*>}
  17252. * @extends xAxis
  17253. * @since 5.0.0
  17254. * @product highcharts
  17255. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  17256. * nameToX, showEmpty, top, width
  17257. * @apioption zAxis
  17258. */
  17259. // This variable extends the defaultOptions for left axes.
  17260. AxisDefaults.defaultLeftAxisOptions = {
  17261. labels: {
  17262. x: -15
  17263. },
  17264. title: {
  17265. rotation: 270
  17266. }
  17267. };
  17268. // This variable extends the defaultOptions for right axes.
  17269. AxisDefaults.defaultRightAxisOptions = {
  17270. labels: {
  17271. x: 15
  17272. },
  17273. title: {
  17274. rotation: 90
  17275. }
  17276. };
  17277. // This variable extends the defaultOptions for bottom axes.
  17278. AxisDefaults.defaultBottomAxisOptions = {
  17279. labels: {
  17280. autoRotation: [-45],
  17281. x: 0
  17282. // overflow: undefined,
  17283. // staggerLines: null
  17284. },
  17285. margin: 15,
  17286. title: {
  17287. rotation: 0
  17288. }
  17289. };
  17290. // This variable extends the defaultOptions for top axes.
  17291. AxisDefaults.defaultTopAxisOptions = {
  17292. labels: {
  17293. autoRotation: [-45],
  17294. x: 0
  17295. // overflow: undefined
  17296. // staggerLines: null
  17297. },
  17298. margin: 15,
  17299. title: {
  17300. rotation: 0
  17301. }
  17302. };
  17303. })(AxisDefaults || (AxisDefaults = {}));
  17304. /* *
  17305. *
  17306. * Default Export
  17307. *
  17308. * */
  17309. return AxisDefaults;
  17310. });
  17311. _registerModule(_modules, 'Core/Foundation.js', [_modules['Core/Utilities.js']], function (U) {
  17312. /* *
  17313. *
  17314. * (c) 2010-2021 Torstein Honsi
  17315. *
  17316. * License: www.highcharts.com/license
  17317. *
  17318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  17319. *
  17320. * */
  17321. var addEvent = U.addEvent,
  17322. isFunction = U.isFunction,
  17323. objectEach = U.objectEach,
  17324. removeEvent = U.removeEvent;
  17325. /* *
  17326. *
  17327. * Functions
  17328. *
  17329. * */
  17330. /*
  17331. * Register event options. If an event handler is set on the options, it should
  17332. * be subject to Chart.update, Axis.update and Series.update. This is contrary
  17333. * to general handlers that are set directly using addEvent either on the class
  17334. * or on the instance. #6538, #6943, #10861.
  17335. */
  17336. var registerEventOptions = function (component,
  17337. options) {
  17338. // A lookup over those events that are added by _options_ (not
  17339. // programmatically). These are updated through .update()
  17340. component.eventOptions = component.eventOptions || {};
  17341. // Register event listeners
  17342. objectEach(options.events, function (event, eventType) {
  17343. if (isFunction(event)) {
  17344. // If event does not exist, or is changed by the .update()
  17345. // function
  17346. if (component.eventOptions[eventType] !== event) {
  17347. // Remove existing if set by option
  17348. if (isFunction(component.eventOptions[eventType])) {
  17349. removeEvent(component, eventType, component.eventOptions[eventType]);
  17350. }
  17351. component.eventOptions[eventType] = event;
  17352. addEvent(component, eventType, event);
  17353. }
  17354. }
  17355. });
  17356. };
  17357. /* *
  17358. *
  17359. * Default Export
  17360. *
  17361. * */
  17362. var exports = {
  17363. registerEventOptions: registerEventOptions
  17364. };
  17365. return exports;
  17366. });
  17367. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (F, H, U) {
  17368. /* *
  17369. *
  17370. * (c) 2010-2021 Torstein Honsi
  17371. *
  17372. * License: www.highcharts.com/license
  17373. *
  17374. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  17375. *
  17376. * */
  17377. var deg2rad = H.deg2rad;
  17378. var clamp = U.clamp,
  17379. correctFloat = U.correctFloat,
  17380. defined = U.defined,
  17381. destroyObjectProperties = U.destroyObjectProperties,
  17382. extend = U.extend,
  17383. fireEvent = U.fireEvent,
  17384. isNumber = U.isNumber,
  17385. merge = U.merge,
  17386. objectEach = U.objectEach,
  17387. pick = U.pick;
  17388. /* *
  17389. *
  17390. * Class
  17391. *
  17392. * */
  17393. /* eslint-disable no-invalid-this, valid-jsdoc */
  17394. /**
  17395. * The Tick class.
  17396. *
  17397. * @class
  17398. * @name Highcharts.Tick
  17399. *
  17400. * @param {Highcharts.Axis} axis
  17401. * The axis of the tick.
  17402. *
  17403. * @param {number} pos
  17404. * The position of the tick on the axis in terms of axis values.
  17405. *
  17406. * @param {string} [type]
  17407. * The type of tick, either 'minor' or an empty string
  17408. *
  17409. * @param {boolean} [noLabel=false]
  17410. * Whether to disable the label or not. Defaults to false.
  17411. *
  17412. * @param {object} [parameters]
  17413. * Optional parameters for the tick.
  17414. */
  17415. var Tick = /** @class */ (function () {
  17416. /* *
  17417. *
  17418. * Constructors
  17419. *
  17420. * */
  17421. function Tick(axis, pos, type, noLabel, parameters) {
  17422. this.isNew = true;
  17423. this.isNewLabel = true;
  17424. /**
  17425. * The related axis of the tick.
  17426. * @name Highcharts.Tick#axis
  17427. * @type {Highcharts.Axis}
  17428. */
  17429. this.axis = axis;
  17430. /**
  17431. * The logical position of the tick on the axis in terms of axis values.
  17432. * @name Highcharts.Tick#pos
  17433. * @type {number}
  17434. */
  17435. this.pos = pos;
  17436. /**
  17437. * The tick type, which can be `"minor"`, or an empty string.
  17438. * @name Highcharts.Tick#type
  17439. * @type {string}
  17440. */
  17441. this.type = type || '';
  17442. this.parameters = parameters || {};
  17443. /**
  17444. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  17445. * for grid axes.
  17446. * @name Highcharts.Tick#tickmarkOffset
  17447. * @type {number|undefined}
  17448. */
  17449. this.tickmarkOffset = this.parameters.tickmarkOffset;
  17450. this.options = this.parameters.options;
  17451. fireEvent(this, 'init');
  17452. if (!type && !noLabel) {
  17453. this.addLabel();
  17454. }
  17455. }
  17456. /* *
  17457. *
  17458. * Functions
  17459. *
  17460. * */
  17461. /**
  17462. * Write the tick label.
  17463. *
  17464. * @private
  17465. * @function Highcharts.Tick#addLabel
  17466. * @return {void}
  17467. */
  17468. Tick.prototype.addLabel = function () {
  17469. var tick = this,
  17470. axis = tick.axis,
  17471. options = axis.options,
  17472. chart = axis.chart,
  17473. categories = axis.categories,
  17474. log = axis.logarithmic,
  17475. names = axis.names,
  17476. pos = tick.pos,
  17477. labelOptions = pick(tick.options && tick.options.labels,
  17478. options.labels),
  17479. tickPositions = axis.tickPositions,
  17480. isFirst = pos === tickPositions[0],
  17481. isLast = pos === tickPositions[tickPositions.length - 1],
  17482. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  17483. axis.tickInterval === 1,
  17484. tickPositionInfo = tickPositions.info;
  17485. var label = tick.label,
  17486. dateTimeLabelFormat,
  17487. dateTimeLabelFormats,
  17488. i;
  17489. // The context value
  17490. var value = this.parameters.category || (categories ?
  17491. pick(categories[pos],
  17492. names[pos],
  17493. pos) :
  17494. pos);
  17495. if (log && isNumber(value)) {
  17496. value = correctFloat(log.lin2log(value));
  17497. }
  17498. // Set the datetime label format. If a higher rank is set for this
  17499. // position, use that. If not, use the general format.
  17500. if (axis.dateTime && tickPositionInfo) {
  17501. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  17502. tickPositionInfo.higherRanks[pos]) ||
  17503. tickPositionInfo.unitName]);
  17504. dateTimeLabelFormat = dateTimeLabelFormats.main;
  17505. }
  17506. // set properties for access in render method
  17507. /**
  17508. * True if the tick is the first one on the axis.
  17509. * @name Highcharts.Tick#isFirst
  17510. * @readonly
  17511. * @type {boolean|undefined}
  17512. */
  17513. tick.isFirst = isFirst;
  17514. /**
  17515. * True if the tick is the last one on the axis.
  17516. * @name Highcharts.Tick#isLast
  17517. * @readonly
  17518. * @type {boolean|undefined}
  17519. */
  17520. tick.isLast = isLast;
  17521. // Get the string
  17522. var ctx = {
  17523. axis: axis,
  17524. chart: chart,
  17525. dateTimeLabelFormat: dateTimeLabelFormat,
  17526. isFirst: isFirst,
  17527. isLast: isLast,
  17528. pos: pos,
  17529. tick: tick,
  17530. tickPositionInfo: tickPositionInfo,
  17531. value: value
  17532. };
  17533. // Fire an event that allows modifying the context for use in
  17534. // `labels.format` and `labels.formatter`.
  17535. fireEvent(this, 'labelFormat', ctx);
  17536. // Label formatting. When `labels.format` is given, we first run the
  17537. // defaultFormatter and append the result to the context as `text`.
  17538. // Handy for adding prefix or suffix while keeping default number
  17539. // formatting.
  17540. var labelFormatter = function (ctx) {
  17541. if (labelOptions.formatter) {
  17542. return labelOptions.formatter.call(ctx,
  17543. ctx);
  17544. }
  17545. if (labelOptions.format) {
  17546. ctx.text = axis.defaultLabelFormatter.call(ctx);
  17547. return F.format(labelOptions.format, ctx, chart);
  17548. }
  17549. return axis.defaultLabelFormatter.call(ctx, ctx);
  17550. };
  17551. var str = labelFormatter.call(ctx,
  17552. ctx);
  17553. // Set up conditional formatting based on the format list if existing.
  17554. var list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  17555. if (list) {
  17556. tick.shortenLabel = function () {
  17557. for (i = 0; i < list.length; i++) {
  17558. extend(ctx, { dateTimeLabelFormat: list[i] });
  17559. label.attr({
  17560. text: labelFormatter.call(ctx, ctx)
  17561. });
  17562. if (label.getBBox().width <
  17563. axis.getSlotWidth(tick) - 2 *
  17564. labelOptions.padding) {
  17565. return;
  17566. }
  17567. }
  17568. label.attr({
  17569. text: ''
  17570. });
  17571. };
  17572. }
  17573. else {
  17574. // #15692
  17575. tick.shortenLabel = void 0;
  17576. }
  17577. // Call only after first render
  17578. if (animateLabels && axis._addedPlotLB) {
  17579. tick.moveLabel(str, labelOptions);
  17580. }
  17581. // First call
  17582. if (!defined(label) && !tick.movedLabel) {
  17583. /**
  17584. * The rendered text label of the tick.
  17585. * @name Highcharts.Tick#label
  17586. * @type {Highcharts.SVGElement|undefined}
  17587. */
  17588. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  17589. // Base value to detect change for new calls to getBBox
  17590. tick.rotation = 0;
  17591. // update
  17592. }
  17593. else if (label && label.textStr !== str && !animateLabels) {
  17594. // When resetting text, also reset the width if dynamically set
  17595. // (#8809)
  17596. if (label.textWidth &&
  17597. !labelOptions.style.width &&
  17598. !label.styles.width) {
  17599. label.css({ width: null });
  17600. }
  17601. label.attr({ text: str });
  17602. label.textPxLength = label.getBBox().width;
  17603. }
  17604. };
  17605. /**
  17606. * Render and return the label of the tick.
  17607. *
  17608. * @private
  17609. * @function Highcharts.Tick#createLabel
  17610. * @param {Highcharts.PositionObject} xy
  17611. * @param {string} str
  17612. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  17613. * @return {Highcharts.SVGElement|undefined}
  17614. */
  17615. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  17616. var axis = this.axis,
  17617. chart = axis.chart,
  17618. label = defined(str) && labelOptions.enabled ?
  17619. chart.renderer
  17620. .text(str,
  17621. xy.x,
  17622. xy.y,
  17623. labelOptions.useHTML)
  17624. .add(axis.labelGroup) :
  17625. null;
  17626. // Un-rotated length
  17627. if (label) {
  17628. // Without position absolute, IE export sometimes is wrong
  17629. if (!chart.styledMode) {
  17630. label.css(merge(labelOptions.style));
  17631. }
  17632. label.textPxLength = label.getBBox().width;
  17633. }
  17634. return label;
  17635. };
  17636. /**
  17637. * Destructor for the tick prototype
  17638. *
  17639. * @private
  17640. * @function Highcharts.Tick#destroy
  17641. * @return {void}
  17642. */
  17643. Tick.prototype.destroy = function () {
  17644. destroyObjectProperties(this, this.axis);
  17645. };
  17646. /**
  17647. * Gets the x and y positions for ticks in terms of pixels.
  17648. *
  17649. * @private
  17650. * @function Highcharts.Tick#getPosition
  17651. *
  17652. * @param {boolean} horiz
  17653. * Whether the tick is on an horizontal axis or not.
  17654. *
  17655. * @param {number} tickPos
  17656. * Position of the tick.
  17657. *
  17658. * @param {number} tickmarkOffset
  17659. * Tickmark offset for all ticks.
  17660. *
  17661. * @param {boolean} [old]
  17662. * Whether the axis has changed or not.
  17663. *
  17664. * @return {Highcharts.PositionObject}
  17665. * The tick position.
  17666. *
  17667. * @fires Highcharts.Tick#event:afterGetPosition
  17668. */
  17669. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  17670. var axis = this.axis,
  17671. chart = axis.chart,
  17672. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  17673. pos = {
  17674. x: horiz ?
  17675. correctFloat(axis.translate(tickPos + tickmarkOffset,
  17676. null,
  17677. null,
  17678. old) +
  17679. axis.transB) :
  17680. (axis.left +
  17681. axis.offset +
  17682. (axis.opposite ?
  17683. (((old && chart.oldChartWidth) ||
  17684. chart.chartWidth) -
  17685. axis.right -
  17686. axis.left) :
  17687. 0)),
  17688. y: horiz ?
  17689. (cHeight -
  17690. axis.bottom +
  17691. axis.offset -
  17692. (axis.opposite ? axis.height : 0)) :
  17693. correctFloat(cHeight -
  17694. axis.translate(tickPos + tickmarkOffset,
  17695. null,
  17696. null,
  17697. old) -
  17698. axis.transB)
  17699. };
  17700. // Chrome workaround for #10516
  17701. pos.y = clamp(pos.y, -1e5, 1e5);
  17702. fireEvent(this, 'afterGetPosition', { pos: pos });
  17703. return pos;
  17704. };
  17705. /**
  17706. * Get the x, y position of the tick label
  17707. *
  17708. * @private
  17709. * @return {Highcharts.PositionObject}
  17710. */
  17711. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  17712. var axis = this.axis,
  17713. transA = axis.transA,
  17714. reversed = ( // #7911
  17715. axis.isLinked && axis.linkedParent ?
  17716. axis.linkedParent.reversed :
  17717. axis.reversed),
  17718. staggerLines = axis.staggerLines,
  17719. rotCorr = axis.tickRotCorr || { x: 0,
  17720. y: 0 },
  17721. // Adjust for label alignment if we use reserveSpace: true (#5286)
  17722. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  17723. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  17724. 0),
  17725. pos = {};
  17726. var yOffset = labelOptions.y,
  17727. line;
  17728. if (!defined(yOffset)) {
  17729. if (axis.side === 0) {
  17730. yOffset = label.rotation ? -8 : -label.getBBox().height;
  17731. }
  17732. else if (axis.side === 2) {
  17733. yOffset = rotCorr.y + 8;
  17734. }
  17735. else {
  17736. // #3140, #3140
  17737. yOffset = Math.cos(label.rotation * deg2rad) *
  17738. (rotCorr.y - label.getBBox(false, 0).height / 2);
  17739. }
  17740. }
  17741. x = x +
  17742. labelOptions.x +
  17743. labelOffsetCorrection +
  17744. rotCorr.x -
  17745. (tickmarkOffset && horiz ?
  17746. tickmarkOffset * transA * (reversed ? -1 : 1) :
  17747. 0);
  17748. y = y + yOffset - (tickmarkOffset && !horiz ?
  17749. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  17750. // Correct for staggered labels
  17751. if (staggerLines) {
  17752. line = (index / (step || 1) % staggerLines);
  17753. if (axis.opposite) {
  17754. line = staggerLines - line - 1;
  17755. }
  17756. y += line * (axis.labelOffset / staggerLines);
  17757. }
  17758. pos.x = x;
  17759. pos.y = Math.round(y);
  17760. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  17761. return pos;
  17762. };
  17763. /**
  17764. * Get the offset height or width of the label
  17765. *
  17766. * @private
  17767. * @function Highcharts.Tick#getLabelSize
  17768. * @return {number}
  17769. */
  17770. Tick.prototype.getLabelSize = function () {
  17771. return this.label ?
  17772. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  17773. 0;
  17774. };
  17775. /**
  17776. * Extendible method to return the path of the marker
  17777. *
  17778. * @private
  17779. *
  17780. */
  17781. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  17782. return renderer.crispLine([[
  17783. 'M',
  17784. x,
  17785. y
  17786. ], [
  17787. 'L',
  17788. x + (horiz ? 0 : -tickLength),
  17789. y + (horiz ? tickLength : 0)
  17790. ]], tickWidth);
  17791. };
  17792. /**
  17793. * Handle the label overflow by adjusting the labels to the left and right
  17794. * edge, or hide them if they collide into the neighbour label.
  17795. *
  17796. * @private
  17797. * @function Highcharts.Tick#handleOverflow
  17798. * @param {Highcharts.PositionObject} xy
  17799. * @return {void}
  17800. */
  17801. Tick.prototype.handleOverflow = function (xy) {
  17802. var tick = this,
  17803. axis = this.axis,
  17804. labelOptions = axis.options.labels,
  17805. pxPos = xy.x,
  17806. chartWidth = axis.chart.chartWidth,
  17807. spacing = axis.chart.spacing,
  17808. leftBound = pick(axis.labelLeft,
  17809. Math.min(axis.pos,
  17810. spacing[3])),
  17811. rightBound = pick(axis.labelRight,
  17812. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  17813. chartWidth - spacing[1])),
  17814. label = this.label,
  17815. rotation = this.rotation,
  17816. factor = {
  17817. left: 0,
  17818. center: 0.5,
  17819. right: 1
  17820. }[axis.labelAlign || label.attr('align')],
  17821. labelWidth = label.getBBox().width,
  17822. slotWidth = axis.getSlotWidth(tick),
  17823. xCorrection = factor,
  17824. css = {};
  17825. var modifiedSlotWidth = slotWidth,
  17826. goRight = 1,
  17827. leftPos,
  17828. rightPos,
  17829. textWidth;
  17830. // Check if the label overshoots the chart spacing box. If it does, move
  17831. // it. If it now overshoots the slotWidth, add ellipsis.
  17832. if (!rotation && labelOptions.overflow === 'justify') {
  17833. leftPos = pxPos - factor * labelWidth;
  17834. rightPos = pxPos + (1 - factor) * labelWidth;
  17835. if (leftPos < leftBound) {
  17836. modifiedSlotWidth =
  17837. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  17838. }
  17839. else if (rightPos > rightBound) {
  17840. modifiedSlotWidth =
  17841. rightBound - xy.x + modifiedSlotWidth * factor;
  17842. goRight = -1;
  17843. }
  17844. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  17845. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  17846. xy.x += (goRight *
  17847. (slotWidth -
  17848. modifiedSlotWidth -
  17849. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  17850. }
  17851. // If the label width exceeds the available space, set a text width
  17852. // to be picked up below. Also, if a width has been set before, we
  17853. // need to set a new one because the reported labelWidth will be
  17854. // limited by the box (#3938).
  17855. if (labelWidth > modifiedSlotWidth ||
  17856. (axis.autoRotation && (label.styles || {}).width)) {
  17857. textWidth = modifiedSlotWidth;
  17858. }
  17859. // Add ellipsis to prevent rotated labels to be clipped against the edge
  17860. // of the chart
  17861. }
  17862. else if (rotation < 0 &&
  17863. pxPos - factor * labelWidth < leftBound) {
  17864. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  17865. }
  17866. else if (rotation > 0 &&
  17867. pxPos + factor * labelWidth > rightBound) {
  17868. textWidth = Math.round((chartWidth - pxPos) /
  17869. Math.cos(rotation * deg2rad));
  17870. }
  17871. if (textWidth) {
  17872. if (tick.shortenLabel) {
  17873. tick.shortenLabel();
  17874. }
  17875. else {
  17876. css.width = Math.floor(textWidth) + 'px';
  17877. if (!(labelOptions.style || {}).textOverflow) {
  17878. css.textOverflow = 'ellipsis';
  17879. }
  17880. label.css(css);
  17881. }
  17882. }
  17883. };
  17884. /**
  17885. * Try to replace the label if the same one already exists.
  17886. *
  17887. * @private
  17888. * @function Highcharts.Tick#moveLabel
  17889. * @param {string} str
  17890. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  17891. *
  17892. * @return {void}
  17893. */
  17894. Tick.prototype.moveLabel = function (str, labelOptions) {
  17895. var tick = this,
  17896. label = tick.label,
  17897. axis = tick.axis,
  17898. reversed = axis.reversed;
  17899. var moved = false,
  17900. labelPos,
  17901. xPos,
  17902. yPos;
  17903. if (label && label.textStr === str) {
  17904. tick.movedLabel = label;
  17905. moved = true;
  17906. delete tick.label;
  17907. }
  17908. else { // Find a label with the same string
  17909. objectEach(axis.ticks, function (currentTick) {
  17910. if (!moved &&
  17911. !currentTick.isNew &&
  17912. currentTick !== tick &&
  17913. currentTick.label &&
  17914. currentTick.label.textStr === str) {
  17915. tick.movedLabel = currentTick.label;
  17916. moved = true;
  17917. currentTick.labelPos = tick.movedLabel.xy;
  17918. delete currentTick.label;
  17919. }
  17920. });
  17921. }
  17922. // Create new label if the actual one is moved
  17923. if (!moved && (tick.labelPos || label)) {
  17924. labelPos = tick.labelPos || label.xy;
  17925. xPos = axis.horiz ?
  17926. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  17927. yPos = axis.horiz ?
  17928. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  17929. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  17930. if (tick.movedLabel) {
  17931. tick.movedLabel.attr({ opacity: 0 });
  17932. }
  17933. }
  17934. };
  17935. /**
  17936. * Put everything in place
  17937. *
  17938. * @private
  17939. * @param {number} index
  17940. * @param {boolean} [old]
  17941. * Use old coordinates to prepare an animation into new position
  17942. * @param {number} [opacity]
  17943. * @return {voids}
  17944. */
  17945. Tick.prototype.render = function (index, old, opacity) {
  17946. var tick = this,
  17947. axis = tick.axis,
  17948. horiz = axis.horiz,
  17949. pos = tick.pos,
  17950. tickmarkOffset = pick(tick.tickmarkOffset,
  17951. axis.tickmarkOffset),
  17952. xy = tick.getPosition(horiz,
  17953. pos,
  17954. tickmarkOffset,
  17955. old),
  17956. x = xy.x,
  17957. y = xy.y,
  17958. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  17959. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  17960. var labelOpacity = pick(opacity,
  17961. tick.label && tick.label.newOpacity, // #15528
  17962. 1);
  17963. opacity = pick(opacity, 1);
  17964. this.isActive = true;
  17965. // Create the grid line
  17966. this.renderGridLine(old, opacity, reverseCrisp);
  17967. // create the tick mark
  17968. this.renderMark(xy, opacity, reverseCrisp);
  17969. // the label is created on init - now move it into place
  17970. this.renderLabel(xy, old, labelOpacity, index);
  17971. tick.isNew = false;
  17972. fireEvent(this, 'afterRender');
  17973. };
  17974. /**
  17975. * Renders the gridLine.
  17976. *
  17977. * @private
  17978. * @param {boolean} old Whether or not the tick is old
  17979. * @param {number} opacity The opacity of the grid line
  17980. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  17981. * @return {void}
  17982. */
  17983. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  17984. var tick = this,
  17985. axis = tick.axis,
  17986. options = axis.options,
  17987. attribs = {},
  17988. pos = tick.pos,
  17989. type = tick.type,
  17990. tickmarkOffset = pick(tick.tickmarkOffset,
  17991. axis.tickmarkOffset),
  17992. renderer = axis.chart.renderer;
  17993. var gridLine = tick.gridLine,
  17994. gridLinePath,
  17995. gridLineWidth = options.gridLineWidth,
  17996. gridLineColor = options.gridLineColor,
  17997. dashStyle = options.gridLineDashStyle;
  17998. if (tick.type === 'minor') {
  17999. gridLineWidth = options.minorGridLineWidth;
  18000. gridLineColor = options.minorGridLineColor;
  18001. dashStyle = options.minorGridLineDashStyle;
  18002. }
  18003. if (!gridLine) {
  18004. if (!axis.chart.styledMode) {
  18005. attribs.stroke = gridLineColor;
  18006. attribs['stroke-width'] = gridLineWidth || 0;
  18007. attribs.dashstyle = dashStyle;
  18008. }
  18009. if (!type) {
  18010. attribs.zIndex = 1;
  18011. }
  18012. if (old) {
  18013. opacity = 0;
  18014. }
  18015. /**
  18016. * The rendered grid line of the tick.
  18017. * @name Highcharts.Tick#gridLine
  18018. * @type {Highcharts.SVGElement|undefined}
  18019. */
  18020. tick.gridLine = gridLine = renderer.path()
  18021. .attr(attribs)
  18022. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  18023. .add(axis.gridGroup);
  18024. }
  18025. if (gridLine) {
  18026. gridLinePath = axis.getPlotLinePath({
  18027. value: pos + tickmarkOffset,
  18028. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  18029. force: 'pass',
  18030. old: old
  18031. });
  18032. // If the parameter 'old' is set, the current call will be followed
  18033. // by another call, therefore do not do any animations this time
  18034. if (gridLinePath) {
  18035. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  18036. d: gridLinePath,
  18037. opacity: opacity
  18038. });
  18039. }
  18040. }
  18041. };
  18042. /**
  18043. * Renders the tick mark.
  18044. *
  18045. * @private
  18046. * @param {Highcharts.PositionObject} xy The position vector of the mark
  18047. * @param {number} opacity The opacity of the mark
  18048. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  18049. * @return {void}
  18050. */
  18051. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  18052. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickSize = axis.tickSize(type ? type + 'Tick' : 'tick'), x = xy.x, y = xy.y, tickWidth = pick(options[type !== 'minor' ? 'tickWidth' : 'minorTickWidth'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  18053. tickColor = options[type !== 'minor' ? 'tickColor' : 'minorTickColor'];
  18054. var mark = tick.mark;
  18055. var isNewMark = !mark;
  18056. if (tickSize) {
  18057. // negate the length
  18058. if (axis.opposite) {
  18059. tickSize[0] = -tickSize[0];
  18060. }
  18061. // First time, create it
  18062. if (!mark) {
  18063. /**
  18064. * The rendered mark of the tick.
  18065. * @name Highcharts.Tick#mark
  18066. * @type {Highcharts.SVGElement|undefined}
  18067. */
  18068. tick.mark = mark = renderer.path()
  18069. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  18070. .add(axis.axisGroup);
  18071. if (!axis.chart.styledMode) {
  18072. mark.attr({
  18073. stroke: tickColor,
  18074. 'stroke-width': tickWidth
  18075. });
  18076. }
  18077. }
  18078. mark[isNewMark ? 'attr' : 'animate']({
  18079. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  18080. opacity: opacity
  18081. });
  18082. }
  18083. };
  18084. /**
  18085. * Renders the tick label.
  18086. * Note: The label should already be created in init(), so it should only
  18087. * have to be moved into place.
  18088. *
  18089. * @private
  18090. * @param {Highcharts.PositionObject} xy The position vector of the label
  18091. * @param {boolean} old Whether or not the tick is old
  18092. * @param {number} opacity The opacity of the label
  18093. * @param {number} index The index of the tick
  18094. * @return {void}
  18095. */
  18096. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  18097. var tick = this,
  18098. axis = tick.axis,
  18099. horiz = axis.horiz,
  18100. options = axis.options,
  18101. label = tick.label,
  18102. labelOptions = options.labels,
  18103. step = labelOptions.step,
  18104. tickmarkOffset = pick(tick.tickmarkOffset,
  18105. axis.tickmarkOffset),
  18106. x = xy.x,
  18107. y = xy.y;
  18108. var show = true;
  18109. if (label && isNumber(x)) {
  18110. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  18111. // Apply show first and show last. If the tick is both first and
  18112. // last, it is a single centered tick, in which case we show the
  18113. // label anyway (#2100).
  18114. if ((tick.isFirst &&
  18115. !tick.isLast &&
  18116. !options.showFirstLabel) ||
  18117. (tick.isLast &&
  18118. !tick.isFirst &&
  18119. !options.showLastLabel)) {
  18120. show = false;
  18121. // Handle label overflow and show or hide accordingly
  18122. }
  18123. else if (horiz &&
  18124. !labelOptions.step &&
  18125. !labelOptions.rotation &&
  18126. !old &&
  18127. opacity !== 0) {
  18128. tick.handleOverflow(xy);
  18129. }
  18130. // apply step
  18131. if (step && index % step) {
  18132. // show those indices dividable by step
  18133. show = false;
  18134. }
  18135. // Set the new position, and show or hide
  18136. if (show && isNumber(xy.y)) {
  18137. xy.opacity = opacity;
  18138. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  18139. tick.isNewLabel = false;
  18140. }
  18141. else {
  18142. label.attr('y', -9999); // #1338
  18143. tick.isNewLabel = true;
  18144. }
  18145. }
  18146. };
  18147. /**
  18148. * Replace labels with the moved ones to perform animation. Additionally
  18149. * destroy unused labels.
  18150. *
  18151. * @private
  18152. * @function Highcharts.Tick#replaceMovedLabel
  18153. * @return {void}
  18154. */
  18155. Tick.prototype.replaceMovedLabel = function () {
  18156. var tick = this,
  18157. label = tick.label,
  18158. axis = tick.axis,
  18159. reversed = axis.reversed;
  18160. var x,
  18161. y;
  18162. // Animate and destroy
  18163. if (label && !tick.isNew) {
  18164. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  18165. y = axis.horiz ?
  18166. label.xy.y :
  18167. (reversed ? axis.width + axis.top : axis.top);
  18168. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  18169. delete tick.label;
  18170. }
  18171. axis.isDirty = true;
  18172. tick.label = tick.movedLabel;
  18173. delete tick.movedLabel;
  18174. };
  18175. return Tick;
  18176. }());
  18177. /* *
  18178. *
  18179. * Default Export
  18180. *
  18181. * */
  18182. /* *
  18183. *
  18184. * API Declarations
  18185. *
  18186. * */
  18187. /**
  18188. * Optional parameters for the tick.
  18189. * @private
  18190. * @interface Highcharts.TickParametersObject
  18191. */ /**
  18192. * Set category for the tick.
  18193. * @name Highcharts.TickParametersObject#category
  18194. * @type {string|undefined}
  18195. */ /**
  18196. * @name Highcharts.TickParametersObject#options
  18197. * @type {Highcharts.Dictionary<any>|undefined}
  18198. */ /**
  18199. * Set tickmarkOffset for the tick.
  18200. * @name Highcharts.TickParametersObject#tickmarkOffset
  18201. * @type {number|undefined}
  18202. */
  18203. /**
  18204. * Additonal time tick information.
  18205. *
  18206. * @interface Highcharts.TimeTicksInfoObject
  18207. * @extends Highcharts.TimeNormalizedObject
  18208. */ /**
  18209. * @name Highcharts.TimeTicksInfoObject#higherRanks
  18210. * @type {Array<string>}
  18211. */ /**
  18212. * @name Highcharts.TimeTicksInfoObject#totalRange
  18213. * @type {number}
  18214. */
  18215. ''; // detach doclets above
  18216. return Tick;
  18217. });
  18218. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/AxisDefaults.js'], _modules['Core/Color/Color.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, AxisDefaults, Color, F, H, Palette, D, Tick, U) {
  18219. /* *
  18220. *
  18221. * (c) 2010-2021 Torstein Honsi
  18222. *
  18223. * License: www.highcharts.com/license
  18224. *
  18225. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  18226. *
  18227. * */
  18228. var animObject = A.animObject;
  18229. var registerEventOptions = F.registerEventOptions;
  18230. var deg2rad = H.deg2rad;
  18231. var defaultOptions = D.defaultOptions;
  18232. var arrayMax = U.arrayMax,
  18233. arrayMin = U.arrayMin,
  18234. clamp = U.clamp,
  18235. correctFloat = U.correctFloat,
  18236. defined = U.defined,
  18237. destroyObjectProperties = U.destroyObjectProperties,
  18238. erase = U.erase,
  18239. error = U.error,
  18240. extend = U.extend,
  18241. fireEvent = U.fireEvent,
  18242. getMagnitude = U.getMagnitude,
  18243. isArray = U.isArray,
  18244. isNumber = U.isNumber,
  18245. isString = U.isString,
  18246. merge = U.merge,
  18247. normalizeTickInterval = U.normalizeTickInterval,
  18248. objectEach = U.objectEach,
  18249. pick = U.pick,
  18250. relativeLength = U.relativeLength,
  18251. removeEvent = U.removeEvent,
  18252. splat = U.splat,
  18253. syncTimeout = U.syncTimeout;
  18254. /* *
  18255. *
  18256. * Class
  18257. *
  18258. * */
  18259. /**
  18260. * Create a new axis object. Called internally when instanciating a new chart or
  18261. * adding axes by {@link Highcharts.Chart#addAxis}.
  18262. *
  18263. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  18264. * series cartesian chart, there is one X axis and one Y axis.
  18265. *
  18266. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  18267. * an array of Axis objects. If there is only one axis, it can be referenced
  18268. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  18269. * pattern goes for Y axes.
  18270. *
  18271. * If you need to get the axes from a series object, use the `series.xAxis` and
  18272. * `series.yAxis` properties. These are not arrays, as one series can only be
  18273. * associated to one X and one Y axis.
  18274. *
  18275. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  18276. * the axis configuration options, and get the axis by
  18277. * {@link Highcharts.Chart#get}.
  18278. *
  18279. * Configuration options for the axes are given in options.xAxis and
  18280. * options.yAxis.
  18281. *
  18282. * @class
  18283. * @name Highcharts.Axis
  18284. *
  18285. * @param {Highcharts.Chart} chart
  18286. * The Chart instance to apply the axis on.
  18287. *
  18288. * @param {Highcharts.AxisOptions} userOptions
  18289. * Axis options.
  18290. */
  18291. var Axis = /** @class */ (function () {
  18292. /* *
  18293. *
  18294. * Constructors
  18295. *
  18296. * */
  18297. function Axis(chart, userOptions) {
  18298. this.alternateBands = void 0;
  18299. this.bottom = void 0;
  18300. this.categories = void 0;
  18301. this.chart = void 0;
  18302. this.closestPointRange = void 0;
  18303. this.coll = void 0;
  18304. this.eventOptions = void 0;
  18305. this.hasNames = void 0;
  18306. this.hasVisibleSeries = void 0;
  18307. this.height = void 0;
  18308. this.isLinked = void 0;
  18309. this.labelEdge = void 0; // @todo
  18310. this.labelFormatter = void 0;
  18311. this.left = void 0;
  18312. this.len = void 0;
  18313. this.max = void 0;
  18314. this.maxLabelLength = void 0;
  18315. this.min = void 0;
  18316. this.minorTickInterval = void 0;
  18317. this.minorTicks = void 0;
  18318. this.minPixelPadding = void 0;
  18319. this.names = void 0;
  18320. this.offset = void 0;
  18321. this.options = void 0;
  18322. this.overlap = void 0;
  18323. this.paddedTicks = void 0;
  18324. this.plotLinesAndBands = void 0;
  18325. this.plotLinesAndBandsGroups = void 0;
  18326. this.pointRange = void 0;
  18327. this.pointRangePadding = void 0;
  18328. this.pos = void 0;
  18329. this.positiveValuesOnly = void 0;
  18330. this.right = void 0;
  18331. this.series = void 0;
  18332. this.side = void 0;
  18333. this.tickAmount = void 0;
  18334. this.tickInterval = void 0;
  18335. this.tickmarkOffset = void 0;
  18336. this.tickPositions = void 0;
  18337. this.tickRotCorr = void 0;
  18338. this.ticks = void 0;
  18339. this.top = void 0;
  18340. this.transA = void 0;
  18341. this.transB = void 0;
  18342. this.translationSlope = void 0;
  18343. this.userOptions = void 0;
  18344. this.visible = void 0;
  18345. this.width = void 0;
  18346. this.zoomEnabled = void 0;
  18347. this.init(chart, userOptions);
  18348. }
  18349. /* *
  18350. *
  18351. * Functions
  18352. *
  18353. * */
  18354. /**
  18355. * Overrideable function to initialize the axis.
  18356. *
  18357. * @see {@link Axis}
  18358. *
  18359. * @function Highcharts.Axis#init
  18360. *
  18361. * @param {Highcharts.Chart} chart
  18362. * The Chart instance to apply the axis on.
  18363. *
  18364. * @param {AxisOptions} userOptions
  18365. * Axis options.
  18366. *
  18367. * @fires Highcharts.Axis#event:afterInit
  18368. * @fires Highcharts.Axis#event:init
  18369. */
  18370. Axis.prototype.init = function (chart, userOptions) {
  18371. var isXAxis = userOptions.isX,
  18372. axis = this;
  18373. /**
  18374. * The Chart that the axis belongs to.
  18375. *
  18376. * @name Highcharts.Axis#chart
  18377. * @type {Highcharts.Chart}
  18378. */
  18379. axis.chart = chart;
  18380. /**
  18381. * Whether the axis is horizontal.
  18382. *
  18383. * @name Highcharts.Axis#horiz
  18384. * @type {boolean|undefined}
  18385. */
  18386. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  18387. /**
  18388. * Whether the axis is the x-axis.
  18389. *
  18390. * @name Highcharts.Axis#isXAxis
  18391. * @type {boolean|undefined}
  18392. */
  18393. axis.isXAxis = isXAxis;
  18394. /**
  18395. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  18396. * or `colorAxis`. Corresponds to properties on Chart, for example
  18397. * {@link Chart.xAxis}.
  18398. *
  18399. * @name Highcharts.Axis#coll
  18400. * @type {string}
  18401. */
  18402. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  18403. fireEvent(this, 'init', { userOptions: userOptions });
  18404. axis.opposite = pick(userOptions.opposite, axis.opposite); // needed in setOptions
  18405. /**
  18406. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  18407. * is bottom and 3 is left.
  18408. *
  18409. * @name Highcharts.Axis#side
  18410. * @type {number}
  18411. */
  18412. axis.side = pick(userOptions.side, axis.side, (axis.horiz ?
  18413. (axis.opposite ? 0 : 2) : // top : bottom
  18414. (axis.opposite ? 1 : 3)) // right : left
  18415. );
  18416. /**
  18417. * Current options for the axis after merge of defaults and user's
  18418. * options.
  18419. *
  18420. * @name Highcharts.Axis#options
  18421. * @type {Highcharts.AxisOptions}
  18422. */
  18423. axis.setOptions(userOptions);
  18424. var options = this.options,
  18425. labelsOptions = options.labels,
  18426. type = options.type;
  18427. /**
  18428. * User's options for this axis without defaults.
  18429. *
  18430. * @name Highcharts.Axis#userOptions
  18431. * @type {Highcharts.AxisOptions}
  18432. */
  18433. axis.userOptions = userOptions;
  18434. axis.minPixelPadding = 0;
  18435. /**
  18436. * Whether the axis is reversed. Based on the `axis.reversed`,
  18437. * option, but inverted charts have reversed xAxis by default.
  18438. *
  18439. * @name Highcharts.Axis#reversed
  18440. * @type {boolean}
  18441. */
  18442. axis.reversed = pick(options.reversed, axis.reversed);
  18443. axis.visible = options.visible;
  18444. axis.zoomEnabled = options.zoomEnabled;
  18445. // Initial categories
  18446. axis.hasNames =
  18447. type === 'category' || options.categories === true;
  18448. /**
  18449. * If categories are present for the axis, names are used instead of
  18450. * numbers for that axis.
  18451. *
  18452. * Since Highcharts 3.0, categories can also be extracted by giving each
  18453. * point a name and setting axis type to `category`. However, if you
  18454. * have multiple series, best practice remains defining the `categories`
  18455. * array.
  18456. *
  18457. * @see [xAxis.categories](/highcharts/xAxis.categories)
  18458. *
  18459. * @name Highcharts.Axis#categories
  18460. * @type {Array<string>}
  18461. * @readonly
  18462. */
  18463. axis.categories = options.categories || axis.hasNames;
  18464. if (!axis.names) { // Preserve on update (#3830)
  18465. axis.names = [];
  18466. axis.names.keys = {};
  18467. }
  18468. // Placeholder for plotlines and plotbands groups
  18469. axis.plotLinesAndBandsGroups = {};
  18470. // Shorthand types
  18471. axis.positiveValuesOnly = !!axis.logarithmic;
  18472. // Flag, if axis is linked to another axis
  18473. axis.isLinked = defined(options.linkedTo);
  18474. /**
  18475. * List of major ticks mapped by postition on axis.
  18476. *
  18477. * @see {@link Highcharts.Tick}
  18478. *
  18479. * @name Highcharts.Axis#ticks
  18480. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  18481. */
  18482. axis.ticks = {};
  18483. axis.labelEdge = [];
  18484. /**
  18485. * List of minor ticks mapped by position on the axis.
  18486. *
  18487. * @see {@link Highcharts.Tick}
  18488. *
  18489. * @name Highcharts.Axis#minorTicks
  18490. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  18491. */
  18492. axis.minorTicks = {};
  18493. // List of plotLines/Bands
  18494. axis.plotLinesAndBands = [];
  18495. // Alternate bands
  18496. axis.alternateBands = {};
  18497. // Axis metrics
  18498. axis.len = 0;
  18499. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  18500. axis.range = options.range;
  18501. axis.offset = options.offset || 0;
  18502. /**
  18503. * The maximum value of the axis. In a logarithmic axis, this is the
  18504. * logarithm of the real value, and the real value can be obtained from
  18505. * {@link Axis#getExtremes}.
  18506. *
  18507. * @name Highcharts.Axis#max
  18508. * @type {number|null}
  18509. */
  18510. axis.max = null;
  18511. /**
  18512. * The minimum value of the axis. In a logarithmic axis, this is the
  18513. * logarithm of the real value, and the real value can be obtained from
  18514. * {@link Axis#getExtremes}.
  18515. *
  18516. * @name Highcharts.Axis#min
  18517. * @type {number|null}
  18518. */
  18519. axis.min = null;
  18520. /**
  18521. * The processed crosshair options.
  18522. *
  18523. * @name Highcharts.Axis#crosshair
  18524. * @type {boolean|Highcharts.AxisCrosshairOptions}
  18525. */
  18526. var crosshair = pick(options.crosshair,
  18527. splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1]);
  18528. axis.crosshair = crosshair === true ? {} : crosshair;
  18529. // Register. Don't add it again on Axis.update().
  18530. if (chart.axes.indexOf(axis) === -1) { //
  18531. if (isXAxis) { // #2713
  18532. chart.axes.splice(chart.xAxis.length, 0, axis);
  18533. }
  18534. else {
  18535. chart.axes.push(axis);
  18536. }
  18537. chart[axis.coll].push(axis);
  18538. }
  18539. /**
  18540. * All series associated to the axis.
  18541. *
  18542. * @name Highcharts.Axis#series
  18543. * @type {Array<Highcharts.Series>}
  18544. */
  18545. axis.series = axis.series || []; // populated by Series
  18546. // Reversed axis
  18547. if (chart.inverted &&
  18548. !axis.isZAxis &&
  18549. isXAxis &&
  18550. typeof axis.reversed === 'undefined') {
  18551. axis.reversed = true;
  18552. }
  18553. axis.labelRotation = isNumber(labelsOptions.rotation) ?
  18554. labelsOptions.rotation :
  18555. void 0;
  18556. // Register event listeners
  18557. registerEventOptions(axis, options);
  18558. fireEvent(this, 'afterInit');
  18559. };
  18560. /**
  18561. * Merge and set options.
  18562. *
  18563. * @private
  18564. * @function Highcharts.Axis#setOptions
  18565. *
  18566. * @param {Highcharts.AxisOptions} userOptions
  18567. * Axis options.
  18568. *
  18569. * @fires Highcharts.Axis#event:afterSetOptions
  18570. */
  18571. Axis.prototype.setOptions = function (userOptions) {
  18572. this.options = merge(AxisDefaults.defaultXAxisOptions, (this.coll === 'yAxis') && AxisDefaults.defaultYAxisOptions, [
  18573. AxisDefaults.defaultTopAxisOptions,
  18574. AxisDefaults.defaultRightAxisOptions,
  18575. AxisDefaults.defaultBottomAxisOptions,
  18576. AxisDefaults.defaultLeftAxisOptions
  18577. ][this.side], merge(
  18578. // if set in setOptions (#1053):
  18579. defaultOptions[this.coll], userOptions));
  18580. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  18581. };
  18582. /**
  18583. * The default label formatter. The context is a special config object for
  18584. * the label. In apps, use the
  18585. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  18586. * instead, except when a modification is needed.
  18587. *
  18588. * @function Highcharts.Axis#defaultLabelFormatter
  18589. *
  18590. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  18591. * Formatter context of axis label.
  18592. *
  18593. * @param {Highcharts.AxisLabelsFormatterContextObject} [ctx]
  18594. * Formatter context of axis label.
  18595. *
  18596. * @return {string}
  18597. * The formatted label content.
  18598. */
  18599. Axis.prototype.defaultLabelFormatter = function (ctx) {
  18600. var axis = this.axis,
  18601. chart = this.chart,
  18602. numberFormatter = chart.numberFormatter,
  18603. value = isNumber(this.value) ? this.value : NaN,
  18604. time = axis.chart.time,
  18605. categories = axis.categories,
  18606. dateTimeLabelFormat = this.dateTimeLabelFormat,
  18607. lang = defaultOptions.lang,
  18608. numericSymbols = lang.numericSymbols,
  18609. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  18610. // make sure the same symbol is added for all labels on a linear
  18611. // axis
  18612. numericSymbolDetector = axis.logarithmic ?
  18613. Math.abs(value) :
  18614. axis.tickInterval;
  18615. var i = numericSymbols && numericSymbols.length,
  18616. multi,
  18617. ret;
  18618. if (categories) {
  18619. ret = "" + this.value;
  18620. }
  18621. else if (dateTimeLabelFormat) { // datetime axis
  18622. ret = time.dateFormat(dateTimeLabelFormat, value);
  18623. }
  18624. else if (i && numericSymbolDetector >= 1000) {
  18625. // Decide whether we should add a numeric symbol like k (thousands)
  18626. // or M (millions). If we are to enable this in tooltip or other
  18627. // places as well, we can move this logic to the numberFormatter and
  18628. // enable it by a parameter.
  18629. while (i-- && typeof ret === 'undefined') {
  18630. multi = Math.pow(numSymMagnitude, i + 1);
  18631. if (
  18632. // Only accept a numeric symbol when the distance is more
  18633. // than a full unit. So for example if the symbol is k, we
  18634. // don't accept numbers like 0.5k.
  18635. numericSymbolDetector >= multi &&
  18636. // Accept one decimal before the symbol. Accepts 0.5k but
  18637. // not 0.25k. How does this work with the previous?
  18638. (value * 10) % multi === 0 &&
  18639. numericSymbols[i] !== null &&
  18640. value !== 0) { // #5480
  18641. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  18642. }
  18643. }
  18644. }
  18645. if (typeof ret === 'undefined') {
  18646. if (Math.abs(value) >= 10000) { // add thousands separators
  18647. ret = numberFormatter(value, -1);
  18648. }
  18649. else { // small numbers
  18650. ret = numberFormatter(value, -1, void 0, ''); // #2466
  18651. }
  18652. }
  18653. return ret;
  18654. };
  18655. /**
  18656. * Get the minimum and maximum for the series of each axis. The function
  18657. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  18658. *
  18659. * @private
  18660. * @function Highcharts.Axis#getSeriesExtremes
  18661. *
  18662. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  18663. * @fires Highcharts.Axis#event:getSeriesExtremes
  18664. */
  18665. Axis.prototype.getSeriesExtremes = function () {
  18666. var axis = this,
  18667. chart = axis.chart;
  18668. var xExtremes;
  18669. fireEvent(this, 'getSeriesExtremes', null, function () {
  18670. axis.hasVisibleSeries = false;
  18671. // Reset properties in case we're redrawing (#3353)
  18672. axis.dataMin = axis.dataMax = axis.threshold = null;
  18673. axis.softThreshold = !axis.isXAxis;
  18674. if (axis.stacking) {
  18675. axis.stacking.buildStacks();
  18676. }
  18677. // loop through this axis' series
  18678. axis.series.forEach(function (series) {
  18679. if (series.visible ||
  18680. !chart.options.chart.ignoreHiddenSeries) {
  18681. var seriesOptions = series.options;
  18682. var xData = void 0,
  18683. threshold = seriesOptions.threshold,
  18684. seriesDataMin = void 0,
  18685. seriesDataMax = void 0;
  18686. axis.hasVisibleSeries = true;
  18687. // Validate threshold in logarithmic axes
  18688. if (axis.positiveValuesOnly && threshold <= 0) {
  18689. threshold = null;
  18690. }
  18691. // Get dataMin and dataMax for X axes
  18692. if (axis.isXAxis) {
  18693. xData = series.xData;
  18694. if (xData.length) {
  18695. var isPositive = function (number) { return number > 0; };
  18696. xData = axis.logarithmic ?
  18697. xData.filter(axis.validatePositiveValue) :
  18698. xData;
  18699. xExtremes = series.getXExtremes(xData);
  18700. // If xData contains values which is not numbers,
  18701. // then filter them out. To prevent performance hit,
  18702. // we only do this after we have already found
  18703. // seriesDataMin because in most cases all data is
  18704. // valid. #5234.
  18705. seriesDataMin = xExtremes.min;
  18706. seriesDataMax = xExtremes.max;
  18707. if (!isNumber(seriesDataMin) &&
  18708. // #5010:
  18709. !(seriesDataMin instanceof Date)) {
  18710. xData = xData.filter(isNumber);
  18711. xExtremes = series.getXExtremes(xData);
  18712. // Do it again with valid data
  18713. seriesDataMin = xExtremes.min;
  18714. seriesDataMax = xExtremes.max;
  18715. }
  18716. if (xData.length) {
  18717. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  18718. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  18719. }
  18720. }
  18721. // Get dataMin and dataMax for Y axes, as well as handle
  18722. // stacking and processed data
  18723. }
  18724. else {
  18725. // Get this particular series extremes
  18726. var dataExtremes = series.applyExtremes();
  18727. // Get the dataMin and dataMax so far. If percentage is
  18728. // used, the min and max are always 0 and 100. If
  18729. // seriesDataMin and seriesDataMax is null, then series
  18730. // doesn't have active y data, we continue with nulls
  18731. if (isNumber(dataExtremes.dataMin)) {
  18732. seriesDataMin = dataExtremes.dataMin;
  18733. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  18734. }
  18735. if (isNumber(dataExtremes.dataMax)) {
  18736. seriesDataMax = dataExtremes.dataMax;
  18737. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  18738. }
  18739. // Adjust to threshold
  18740. if (defined(threshold)) {
  18741. axis.threshold = threshold;
  18742. }
  18743. // If any series has a hard threshold, it takes
  18744. // precedence
  18745. if (!seriesOptions.softThreshold ||
  18746. axis.positiveValuesOnly) {
  18747. axis.softThreshold = false;
  18748. }
  18749. }
  18750. }
  18751. });
  18752. });
  18753. fireEvent(this, 'afterGetSeriesExtremes');
  18754. };
  18755. /**
  18756. * Translate from axis value to pixel position on the chart, or back. Use
  18757. * the `toPixels` and `toValue` functions in applications.
  18758. *
  18759. * @private
  18760. * @function Highcharts.Axis#translate
  18761. *
  18762. * @param {number} val
  18763. * TO-DO: parameter description
  18764. *
  18765. * @param {boolean|null} [backwards]
  18766. * TO-DO: parameter description
  18767. *
  18768. * @param {boolean|null} [cvsCoord]
  18769. * TO-DO: parameter description
  18770. *
  18771. * @param {boolean|null} [old]
  18772. * TO-DO: parameter description
  18773. *
  18774. * @param {boolean} [handleLog]
  18775. * TO-DO: parameter description
  18776. *
  18777. * @param {number} [pointPlacement]
  18778. * TO-DO: parameter description
  18779. *
  18780. * @return {number|undefined}
  18781. */
  18782. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  18783. var axis = (this.linkedParent || this), // #1417
  18784. localMin = old && axis.old ? axis.old.min : axis.min,
  18785. minPixelPadding = axis.minPixelPadding,
  18786. doPostTranslate = (axis.isOrdinal ||
  18787. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  18788. (axis.logarithmic && handleLog)) && axis.lin2val;
  18789. var sign = 1,
  18790. cvsOffset = 0,
  18791. localA = old && axis.old ? axis.old.transA : axis.transA,
  18792. returnValue = 0;
  18793. if (!localA) {
  18794. localA = axis.transA;
  18795. }
  18796. // In vertical axes, the canvas coordinates start from 0 at the top like
  18797. // in SVG.
  18798. if (cvsCoord) {
  18799. sign *= -1; // canvas coordinates inverts the value
  18800. cvsOffset = axis.len;
  18801. }
  18802. // Handle reversed axis
  18803. if (axis.reversed) {
  18804. sign *= -1;
  18805. cvsOffset -= sign * (axis.sector || axis.len);
  18806. }
  18807. // From pixels to value
  18808. if (backwards) { // reverse translation
  18809. val = val * sign + cvsOffset;
  18810. val -= minPixelPadding;
  18811. // from chart pixel to value:
  18812. returnValue = val / localA + localMin;
  18813. if (doPostTranslate) { // log and ordinal axes
  18814. returnValue = axis.lin2val(returnValue);
  18815. }
  18816. // From value to pixels
  18817. }
  18818. else {
  18819. if (doPostTranslate) { // log and ordinal axes
  18820. val = axis.val2lin(val);
  18821. }
  18822. returnValue = isNumber(localMin) ?
  18823. (sign * (val - localMin) * localA +
  18824. cvsOffset +
  18825. (sign * minPixelPadding) +
  18826. (isNumber(pointPlacement) ?
  18827. localA * pointPlacement :
  18828. 0)) :
  18829. void 0;
  18830. }
  18831. return returnValue;
  18832. };
  18833. /**
  18834. * Translate a value in terms of axis units into pixels within the chart.
  18835. *
  18836. * @function Highcharts.Axis#toPixels
  18837. *
  18838. * @param {number} value
  18839. * A value in terms of axis units.
  18840. *
  18841. * @param {boolean} paneCoordinates
  18842. * Whether to return the pixel coordinate relative to the chart or just the
  18843. * axis/pane itself.
  18844. *
  18845. * @return {number}
  18846. * Pixel position of the value on the chart or axis.
  18847. */
  18848. Axis.prototype.toPixels = function (value, paneCoordinates) {
  18849. return this.translate(value, false, !this.horiz, null, true) +
  18850. (paneCoordinates ? 0 : this.pos);
  18851. };
  18852. /**
  18853. * Translate a pixel position along the axis to a value in terms of axis
  18854. * units.
  18855. *
  18856. * @function Highcharts.Axis#toValue
  18857. *
  18858. * @param {number} pixel
  18859. * The pixel value coordinate.
  18860. *
  18861. * @param {boolean} [paneCoordinates=false]
  18862. * Whether the input pixel is relative to the chart or just the axis/pane
  18863. * itself.
  18864. *
  18865. * @return {number}
  18866. * The axis value.
  18867. */
  18868. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  18869. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  18870. };
  18871. /**
  18872. * Create the path for a plot line that goes from the given value on
  18873. * this axis, across the plot to the opposite side. Also used internally for
  18874. * grid lines and crosshairs.
  18875. *
  18876. * @function Highcharts.Axis#getPlotLinePath
  18877. *
  18878. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  18879. * Options for the path.
  18880. *
  18881. * @return {Highcharts.SVGPathArray|null}
  18882. * The SVG path definition for the plot line.
  18883. */
  18884. Axis.prototype.getPlotLinePath = function (options) {
  18885. var axis = this,
  18886. chart = axis.chart,
  18887. axisLeft = axis.left,
  18888. axisTop = axis.top,
  18889. old = options.old,
  18890. value = options.value,
  18891. lineWidth = options.lineWidth,
  18892. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  18893. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  18894. transB = axis.transB;
  18895. var translatedValue = options.translatedValue,
  18896. force = options.force,
  18897. x1,
  18898. y1,
  18899. x2,
  18900. y2,
  18901. skip;
  18902. // eslint-disable-next-line valid-jsdoc
  18903. /**
  18904. * Check if x is between a and b. If not, either move to a/b
  18905. * or skip, depending on the force parameter.
  18906. * @private
  18907. */
  18908. function between(x, a, b) {
  18909. if (force !== 'pass' && x < a || x > b) {
  18910. if (force) {
  18911. x = clamp(x, a, b);
  18912. }
  18913. else {
  18914. skip = true;
  18915. }
  18916. }
  18917. return x;
  18918. }
  18919. var evt = {
  18920. value: value,
  18921. lineWidth: lineWidth,
  18922. old: old,
  18923. force: force,
  18924. acrossPanes: options.acrossPanes,
  18925. translatedValue: translatedValue
  18926. };
  18927. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  18928. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  18929. // Keep the translated value within sane bounds, and avoid Infinity
  18930. // to fail the isNumber test (#7709).
  18931. translatedValue = clamp(translatedValue, -1e5, 1e5);
  18932. x1 = x2 = Math.round(translatedValue + transB);
  18933. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  18934. if (!isNumber(translatedValue)) { // no min or max
  18935. skip = true;
  18936. force = false; // #7175, don't force it when path is invalid
  18937. }
  18938. else if (axis.horiz) {
  18939. y1 = axisTop;
  18940. y2 = cHeight - axis.bottom;
  18941. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  18942. }
  18943. else {
  18944. x1 = axisLeft;
  18945. x2 = cWidth - axis.right;
  18946. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  18947. }
  18948. e.path = skip && !force ?
  18949. null :
  18950. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  18951. });
  18952. return evt.path;
  18953. };
  18954. /**
  18955. * Internal function to get the tick positions of a linear axis to round
  18956. * values like whole tens or every five.
  18957. *
  18958. * @function Highcharts.Axis#getLinearTickPositions
  18959. *
  18960. * @param {number} tickInterval
  18961. * The normalized tick interval.
  18962. *
  18963. * @param {number} min
  18964. * Axis minimum.
  18965. *
  18966. * @param {number} max
  18967. * Axis maximum.
  18968. *
  18969. * @return {Array<number>}
  18970. * An array of axis values where ticks should be placed.
  18971. */
  18972. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  18973. var roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  18974. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  18975. tickPositions = [];
  18976. var pos,
  18977. lastPos,
  18978. precision;
  18979. // When the precision is higher than what we filter out in
  18980. // correctFloat, skip it (#6183).
  18981. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  18982. precision = 20;
  18983. }
  18984. // For single points, add a tick regardless of the relative position
  18985. // (#2662, #6274)
  18986. if (this.single) {
  18987. return [min];
  18988. }
  18989. // Populate the intermediate values
  18990. pos = roundedMin;
  18991. while (pos <= roundedMax) {
  18992. // Place the tick on the rounded value
  18993. tickPositions.push(pos);
  18994. // Always add the raw tickInterval, not the corrected one.
  18995. pos = correctFloat(pos + tickInterval, precision);
  18996. // If the interval is not big enough in the current min - max range
  18997. // to actually increase the loop variable, we need to break out to
  18998. // prevent endless loop. Issue #619
  18999. if (pos === lastPos) {
  19000. break;
  19001. }
  19002. // Record the last value
  19003. lastPos = pos;
  19004. }
  19005. return tickPositions;
  19006. };
  19007. /**
  19008. * Resolve the new minorTicks/minorTickInterval options into the legacy
  19009. * loosely typed minorTickInterval option.
  19010. *
  19011. * @function Highcharts.Axis#getMinorTickInterval
  19012. *
  19013. * @return {number|"auto"|null}
  19014. */
  19015. Axis.prototype.getMinorTickInterval = function () {
  19016. var options = this.options;
  19017. if (options.minorTicks === true) {
  19018. return pick(options.minorTickInterval, 'auto');
  19019. }
  19020. if (options.minorTicks === false) {
  19021. return null;
  19022. }
  19023. return options.minorTickInterval;
  19024. };
  19025. /**
  19026. * Internal function to return the minor tick positions. For logarithmic
  19027. * axes, the same logic as for major ticks is reused.
  19028. *
  19029. * @function Highcharts.Axis#getMinorTickPositions
  19030. *
  19031. * @return {Array<number>}
  19032. * An array of axis values where ticks should be placed.
  19033. */
  19034. Axis.prototype.getMinorTickPositions = function () {
  19035. var axis = this,
  19036. options = axis.options,
  19037. tickPositions = axis.tickPositions,
  19038. minorTickInterval = axis.minorTickInterval,
  19039. pointRangePadding = axis.pointRangePadding || 0,
  19040. min = axis.min - pointRangePadding, // #1498
  19041. max = axis.max + pointRangePadding, // #1498
  19042. range = max - min;
  19043. var minorTickPositions = [],
  19044. pos;
  19045. // If minor ticks get too dense, they are hard to read, and may cause
  19046. // long running script. So we don't draw them.
  19047. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  19048. var logarithmic_1 = axis.logarithmic;
  19049. if (logarithmic_1) {
  19050. // For each interval in the major ticks, compute the minor ticks
  19051. // separately.
  19052. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  19053. if (i) {
  19054. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  19055. }
  19056. });
  19057. }
  19058. else if (axis.dateTime &&
  19059. this.getMinorTickInterval() === 'auto') { // #1314
  19060. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  19061. }
  19062. else {
  19063. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  19064. // Very, very, tight grid lines (#5771)
  19065. if (pos === minorTickPositions[0]) {
  19066. break;
  19067. }
  19068. minorTickPositions.push(pos);
  19069. }
  19070. }
  19071. }
  19072. if (minorTickPositions.length !== 0) {
  19073. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  19074. }
  19075. return minorTickPositions;
  19076. };
  19077. /**
  19078. * Adjust the min and max for the minimum range. Keep in mind that the
  19079. * series data is not yet processed, so we don't have information on data
  19080. * cropping and grouping, or updated `axis.pointRange` or
  19081. * `series.pointRange`. The data can't be processed until we have finally
  19082. * established min and max.
  19083. *
  19084. * @private
  19085. * @function Highcharts.Axis#adjustForMinRange
  19086. */
  19087. Axis.prototype.adjustForMinRange = function () {
  19088. var axis = this,
  19089. options = axis.options,
  19090. log = axis.logarithmic;
  19091. var min = axis.min,
  19092. max = axis.max,
  19093. zoomOffset,
  19094. spaceAvailable,
  19095. closestDataRange = 0,
  19096. i,
  19097. distance,
  19098. xData,
  19099. loopLength,
  19100. minArgs,
  19101. maxArgs,
  19102. minRange;
  19103. // Set the automatic minimum range based on the closest point distance
  19104. if (axis.isXAxis &&
  19105. typeof axis.minRange === 'undefined' &&
  19106. !log) {
  19107. if (defined(options.min) || defined(options.max)) {
  19108. axis.minRange = null; // don't do this again
  19109. }
  19110. else {
  19111. // Find the closest distance between raw data points, as opposed
  19112. // to closestPointRange that applies to processed points
  19113. // (cropped and grouped)
  19114. axis.series.forEach(function (series) {
  19115. xData = series.xData;
  19116. loopLength = series.xIncrement ? 1 : xData.length - 1;
  19117. if (xData.length > 1) {
  19118. for (i = loopLength; i > 0; i--) {
  19119. distance = xData[i] - xData[i - 1];
  19120. if (!closestDataRange || distance < closestDataRange) {
  19121. closestDataRange = distance;
  19122. }
  19123. }
  19124. }
  19125. });
  19126. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  19127. }
  19128. }
  19129. // if minRange is exceeded, adjust
  19130. if (max - min < axis.minRange) {
  19131. spaceAvailable =
  19132. axis.dataMax - axis.dataMin >=
  19133. axis.minRange;
  19134. minRange = axis.minRange;
  19135. zoomOffset = (minRange - max + min) / 2;
  19136. // if min and max options have been set, don't go beyond it
  19137. minArgs = [
  19138. min - zoomOffset,
  19139. pick(options.min, min - zoomOffset)
  19140. ];
  19141. // If space is available, stay within the data range
  19142. if (spaceAvailable) {
  19143. minArgs[2] = axis.logarithmic ?
  19144. axis.logarithmic.log2lin(axis.dataMin) :
  19145. axis.dataMin;
  19146. }
  19147. min = arrayMax(minArgs);
  19148. maxArgs = [
  19149. min + minRange,
  19150. pick(options.max, min + minRange)
  19151. ];
  19152. // If space is availabe, stay within the data range
  19153. if (spaceAvailable) {
  19154. maxArgs[2] = log ?
  19155. log.log2lin(axis.dataMax) :
  19156. axis.dataMax;
  19157. }
  19158. max = arrayMin(maxArgs);
  19159. // now if the max is adjusted, adjust the min back
  19160. if (max - min < minRange) {
  19161. minArgs[0] = max - minRange;
  19162. minArgs[1] = pick(options.min, max - minRange);
  19163. min = arrayMax(minArgs);
  19164. }
  19165. }
  19166. // Record modified extremes
  19167. axis.min = min;
  19168. axis.max = max;
  19169. };
  19170. /**
  19171. * Find the closestPointRange across all series.
  19172. *
  19173. * @private
  19174. * @function Highcharts.Axis#getClosest
  19175. *
  19176. * @return {number}
  19177. */
  19178. Axis.prototype.getClosest = function () {
  19179. var ret;
  19180. if (this.categories) {
  19181. ret = 1;
  19182. }
  19183. else {
  19184. this.series.forEach(function (series) {
  19185. var seriesClosest = series.closestPointRange,
  19186. visible = series.visible ||
  19187. !series.chart.options.chart.ignoreHiddenSeries;
  19188. if (!series.noSharedTooltip &&
  19189. defined(seriesClosest) &&
  19190. visible) {
  19191. ret = defined(ret) ?
  19192. Math.min(ret, seriesClosest) :
  19193. seriesClosest;
  19194. }
  19195. });
  19196. }
  19197. return ret;
  19198. };
  19199. /**
  19200. * When a point name is given and no x, search for the name in the existing
  19201. * categories, or if categories aren't provided, search names or create a
  19202. * new category (#2522).
  19203. *
  19204. * @private
  19205. * @function Highcharts.Axis#nameToX
  19206. *
  19207. * @param {Highcharts.Point} point
  19208. * The point to inspect.
  19209. *
  19210. * @return {number}
  19211. * The X value that the point is given.
  19212. */
  19213. Axis.prototype.nameToX = function (point) {
  19214. var explicitCategories = isArray(this.categories),
  19215. names = explicitCategories ? this.categories : this.names;
  19216. var nameX = point.options.x,
  19217. x;
  19218. point.series.requireSorting = false;
  19219. if (!defined(nameX)) {
  19220. nameX = this.options.uniqueNames ?
  19221. (explicitCategories ?
  19222. names.indexOf(point.name) :
  19223. pick(names.keys[point.name], -1)) :
  19224. point.series.autoIncrement();
  19225. }
  19226. if (nameX === -1) { // Not found in currenct categories
  19227. if (!explicitCategories) {
  19228. x = names.length;
  19229. }
  19230. }
  19231. else {
  19232. x = nameX;
  19233. }
  19234. // Write the last point's name to the names array
  19235. if (typeof x !== 'undefined') {
  19236. this.names[x] = point.name;
  19237. // Backwards mapping is much faster than array searching (#7725)
  19238. this.names.keys[point.name] = x;
  19239. }
  19240. return x;
  19241. };
  19242. /**
  19243. * When changes have been done to series data, update the axis.names.
  19244. *
  19245. * @private
  19246. * @function Highcharts.Axis#updateNames
  19247. */
  19248. Axis.prototype.updateNames = function () {
  19249. var axis = this,
  19250. names = this.names,
  19251. i = names.length;
  19252. if (i > 0) {
  19253. Object.keys(names.keys).forEach(function (key) {
  19254. delete (names.keys)[key];
  19255. });
  19256. names.length = 0;
  19257. this.minRange = this.userMinRange; // Reset
  19258. (this.series || []).forEach(function (series) {
  19259. // Reset incrementer (#5928)
  19260. series.xIncrement = null;
  19261. // When adding a series, points are not yet generated
  19262. if (!series.points || series.isDirtyData) {
  19263. // When we're updating the series with data that is longer
  19264. // than it was, and cropThreshold is passed, we need to make
  19265. // sure that the axis.max is increased _before_ running the
  19266. // premature processData. Otherwise this early iteration of
  19267. // processData will crop the points to axis.max, and the
  19268. // names array will be too short (#5857).
  19269. axis.max = Math.max(axis.max, series.xData.length - 1);
  19270. series.processData();
  19271. series.generatePoints();
  19272. }
  19273. series.data.forEach(function (point, i) {
  19274. var x;
  19275. if (point &&
  19276. point.options &&
  19277. typeof point.name !== 'undefined' // #9562
  19278. ) {
  19279. x = axis.nameToX(point);
  19280. if (typeof x !== 'undefined' && x !== point.x) {
  19281. point.x = x;
  19282. series.xData[i] = x;
  19283. }
  19284. }
  19285. });
  19286. });
  19287. }
  19288. };
  19289. /**
  19290. * Update translation information.
  19291. *
  19292. * @private
  19293. * @function Highcharts.Axis#setAxisTranslation
  19294. *
  19295. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  19296. */
  19297. Axis.prototype.setAxisTranslation = function () {
  19298. var axis = this,
  19299. range = axis.max - axis.min,
  19300. linkedParent = axis.linkedParent,
  19301. hasCategories = !!axis.categories,
  19302. isXAxis = axis.isXAxis;
  19303. var pointRange = axis.axisPointRange || 0,
  19304. closestPointRange,
  19305. minPointOffset = 0,
  19306. pointRangePadding = 0,
  19307. ordinalCorrection,
  19308. transA = axis.transA;
  19309. // Adjust translation for padding. Y axis with categories need to go
  19310. // through the same (#1784).
  19311. if (isXAxis || hasCategories || pointRange) {
  19312. // Get the closest points
  19313. closestPointRange = axis.getClosest();
  19314. if (linkedParent) {
  19315. minPointOffset = linkedParent.minPointOffset;
  19316. pointRangePadding = linkedParent.pointRangePadding;
  19317. }
  19318. else {
  19319. axis.series.forEach(function (series) {
  19320. var seriesPointRange = hasCategories ?
  19321. 1 :
  19322. (isXAxis ?
  19323. pick(series.options.pointRange,
  19324. closestPointRange, 0) :
  19325. (axis.axisPointRange || 0)), // #2806
  19326. pointPlacement = series.options.pointPlacement;
  19327. pointRange = Math.max(pointRange, seriesPointRange);
  19328. if (!axis.single || hasCategories) {
  19329. // TODO: series should internally set x- and y-
  19330. // pointPlacement to simplify this logic.
  19331. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  19332. // minPointOffset is the value padding to the left of
  19333. // the axis in order to make room for points with a
  19334. // pointRange, typically columns. When the
  19335. // pointPlacement option is 'between' or 'on', this
  19336. // padding does not apply.
  19337. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  19338. 0 :
  19339. seriesPointRange / 2);
  19340. // Determine the total padding needed to the length of
  19341. // the axis to make room for the pointRange. If the
  19342. // series' pointPlacement is 'on', no padding is added.
  19343. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  19344. 0 :
  19345. seriesPointRange);
  19346. }
  19347. });
  19348. }
  19349. // Record minPointOffset and pointRangePadding
  19350. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  19351. axis.ordinal.slope / closestPointRange :
  19352. 1; // #988, #1853
  19353. axis.minPointOffset = minPointOffset =
  19354. minPointOffset * ordinalCorrection;
  19355. axis.pointRangePadding =
  19356. pointRangePadding = pointRangePadding * ordinalCorrection;
  19357. // pointRange means the width reserved for each point, like in a
  19358. // column chart
  19359. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  19360. // closestPointRange means the closest distance between points. In
  19361. // columns it is mostly equal to pointRange, but in lines pointRange
  19362. // is 0 while closestPointRange is some other value
  19363. if (isXAxis) {
  19364. axis.closestPointRange = closestPointRange;
  19365. }
  19366. }
  19367. // Secondary values
  19368. axis.translationSlope = axis.transA = transA =
  19369. axis.staticScale ||
  19370. axis.len / ((range + pointRangePadding) || 1);
  19371. // Translation addend
  19372. axis.transB = axis.horiz ? axis.left : axis.bottom;
  19373. axis.minPixelPadding = transA * minPointOffset;
  19374. fireEvent(this, 'afterSetAxisTranslation');
  19375. };
  19376. /**
  19377. * @private
  19378. * @function Highcharts.Axis#minFromRange
  19379. *
  19380. * @return {number|undefined}
  19381. */
  19382. Axis.prototype.minFromRange = function () {
  19383. var axis = this;
  19384. return axis.max - axis.range;
  19385. };
  19386. /**
  19387. * Set the tick positions to round values and optionally extend the extremes
  19388. * to the nearest tick.
  19389. *
  19390. * @private
  19391. * @function Highcharts.Axis#setTickInterval
  19392. *
  19393. * @param {boolean} secondPass
  19394. * TO-DO: parameter description
  19395. *
  19396. * @fires Highcharts.Axis#event:foundExtremes
  19397. */
  19398. Axis.prototype.setTickInterval = function (secondPass) {
  19399. var axis = this,
  19400. chart = axis.chart,
  19401. log = axis.logarithmic,
  19402. options = axis.options,
  19403. isXAxis = axis.isXAxis,
  19404. isLinked = axis.isLinked,
  19405. tickPixelIntervalOption = options.tickPixelInterval,
  19406. categories = axis.categories,
  19407. softThreshold = axis.softThreshold;
  19408. var maxPadding = options.maxPadding,
  19409. minPadding = options.minPadding,
  19410. length,
  19411. linkedParentExtremes,
  19412. tickIntervalOption = options.tickInterval,
  19413. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  19414. thresholdMin,
  19415. thresholdMax,
  19416. hardMin,
  19417. hardMax;
  19418. if (!axis.dateTime && !categories && !isLinked) {
  19419. this.getTickAmount();
  19420. }
  19421. // Min or max set either by zooming/setExtremes or initial options
  19422. hardMin = pick(axis.userMin, options.min);
  19423. hardMax = pick(axis.userMax, options.max);
  19424. // Linked axis gets the extremes from the parent axis
  19425. if (isLinked) {
  19426. axis.linkedParent = chart[axis.coll][options.linkedTo];
  19427. linkedParentExtremes = axis.linkedParent.getExtremes();
  19428. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  19429. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  19430. if (options.type !== axis.linkedParent.options.type) {
  19431. // Can't link axes of different type
  19432. error(11, 1, chart);
  19433. }
  19434. // Initial min and max from the extreme data values
  19435. }
  19436. else {
  19437. // Adjust to hard threshold
  19438. if (softThreshold && defined(threshold)) {
  19439. if (axis.dataMin >= threshold) {
  19440. thresholdMin = threshold;
  19441. minPadding = 0;
  19442. }
  19443. else if (axis.dataMax <= threshold) {
  19444. thresholdMax = threshold;
  19445. maxPadding = 0;
  19446. }
  19447. }
  19448. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  19449. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  19450. }
  19451. if (log) {
  19452. if (axis.positiveValuesOnly &&
  19453. !secondPass &&
  19454. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  19455. // Can't plot negative values on log axis
  19456. error(10, 1, chart);
  19457. }
  19458. // The correctFloat cures #934, float errors on full tens. But it
  19459. // was too aggressive for #4360 because of conversion back to lin,
  19460. // therefore use precision 15.
  19461. axis.min = correctFloat(log.log2lin(axis.min), 16);
  19462. axis.max = correctFloat(log.log2lin(axis.max), 16);
  19463. }
  19464. // handle zoomed range
  19465. if (axis.range && defined(axis.max)) {
  19466. // #618, #6773:
  19467. axis.userMin = axis.min = hardMin =
  19468. Math.max(axis.dataMin, axis.minFromRange());
  19469. axis.userMax = hardMax = axis.max;
  19470. axis.range = null; // don't use it when running setExtremes
  19471. }
  19472. // Hook for Highcharts Stock Scroller.
  19473. // Consider combining with beforePadding.
  19474. fireEvent(axis, 'foundExtremes');
  19475. // Hook for adjusting this.min and this.max. Used by bubble series.
  19476. if (axis.beforePadding) {
  19477. axis.beforePadding();
  19478. }
  19479. // adjust min and max for the minimum range
  19480. axis.adjustForMinRange();
  19481. // Pad the values to get clear of the chart's edges. To avoid
  19482. // tickInterval taking the padding into account, we do this after
  19483. // computing tick interval (#1337).
  19484. if (!categories &&
  19485. !axis.axisPointRange &&
  19486. !(axis.stacking && axis.stacking.usePercentage) &&
  19487. !isLinked &&
  19488. defined(axis.min) &&
  19489. defined(axis.max)) {
  19490. length = axis.max - axis.min;
  19491. if (length) {
  19492. if (!defined(hardMin) && minPadding) {
  19493. axis.min -= length * minPadding;
  19494. }
  19495. if (!defined(hardMax) && maxPadding) {
  19496. axis.max += length * maxPadding;
  19497. }
  19498. }
  19499. }
  19500. // Handle options for floor, ceiling, softMin and softMax (#6359)
  19501. if (!isNumber(axis.userMin)) {
  19502. if (isNumber(options.softMin) && options.softMin < axis.min) {
  19503. axis.min = hardMin = options.softMin; // #6894
  19504. }
  19505. if (isNumber(options.floor)) {
  19506. axis.min = Math.max(axis.min, options.floor);
  19507. }
  19508. }
  19509. if (!isNumber(axis.userMax)) {
  19510. if (isNumber(options.softMax) && options.softMax > axis.max) {
  19511. axis.max = hardMax = options.softMax; // #6894
  19512. }
  19513. if (isNumber(options.ceiling)) {
  19514. axis.max = Math.min(axis.max, options.ceiling);
  19515. }
  19516. }
  19517. // When the threshold is soft, adjust the extreme value only if the data
  19518. // extreme and the padded extreme land on either side of the threshold.
  19519. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  19520. // for -1 because of the default minPadding and startOnTick options.
  19521. // This is prevented by the softThreshold option.
  19522. if (softThreshold && defined(axis.dataMin)) {
  19523. threshold = threshold || 0;
  19524. if (!defined(hardMin) &&
  19525. axis.min < threshold &&
  19526. axis.dataMin >= threshold) {
  19527. axis.min = axis.options.minRange ?
  19528. Math.min(threshold, axis.max -
  19529. axis.minRange) :
  19530. threshold;
  19531. }
  19532. else if (!defined(hardMax) &&
  19533. axis.max > threshold &&
  19534. axis.dataMax <= threshold) {
  19535. axis.max = axis.options.minRange ?
  19536. Math.max(threshold, axis.min +
  19537. axis.minRange) :
  19538. threshold;
  19539. }
  19540. }
  19541. // If min is bigger than highest, or if max less than lowest value, the
  19542. // chart should not render points. (#14417)
  19543. if (isNumber(axis.min) &&
  19544. isNumber(axis.max) &&
  19545. !this.chart.polar &&
  19546. (axis.min > axis.max)) {
  19547. if (defined(axis.options.min)) {
  19548. axis.max = axis.min;
  19549. }
  19550. else if (defined(axis.options.max)) {
  19551. axis.min = axis.max;
  19552. }
  19553. }
  19554. // get tickInterval
  19555. if (axis.min === axis.max ||
  19556. typeof axis.min === 'undefined' ||
  19557. typeof axis.max === 'undefined') {
  19558. axis.tickInterval = 1;
  19559. }
  19560. else if (isLinked &&
  19561. axis.linkedParent &&
  19562. !tickIntervalOption &&
  19563. tickPixelIntervalOption ===
  19564. axis.linkedParent.options.tickPixelInterval) {
  19565. axis.tickInterval = tickIntervalOption =
  19566. axis.linkedParent.tickInterval;
  19567. }
  19568. else {
  19569. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  19570. ((axis.max - axis.min) /
  19571. Math.max(this.tickAmount - 1, 1)) :
  19572. void 0,
  19573. // For categoried axis, 1 is default, for linear axis use
  19574. // tickPix
  19575. categories ?
  19576. 1 :
  19577. // don't let it be more than the data range
  19578. (axis.max - axis.min) *
  19579. tickPixelIntervalOption /
  19580. Math.max(axis.len, tickPixelIntervalOption));
  19581. }
  19582. // Now we're finished detecting min and max, crop and group series data.
  19583. // This is in turn needed in order to find tick positions in ordinal
  19584. // axes.
  19585. if (isXAxis && !secondPass) {
  19586. axis.series.forEach(function (series) {
  19587. series.processData(axis.min !== (axis.old && axis.old.min) ||
  19588. axis.max !== (axis.old && axis.old.max));
  19589. });
  19590. }
  19591. // set the translation factor used in translate function
  19592. axis.setAxisTranslation();
  19593. // hook for ordinal axes and radial axes
  19594. fireEvent(this, 'initialAxisTranslation');
  19595. // In column-like charts, don't cramp in more ticks than there are
  19596. // points (#1943, #4184)
  19597. if (axis.pointRange && !tickIntervalOption) {
  19598. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  19599. }
  19600. // Before normalizing the tick interval, handle minimum tick interval.
  19601. // This applies only if tickInterval is not defined.
  19602. var minTickInterval = pick(options.minTickInterval,
  19603. // In datetime axes, don't go below the data interval, except when
  19604. // there are scatter-like series involved (#13369).
  19605. axis.dateTime &&
  19606. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  19607. axis.closestPointRange : 0);
  19608. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  19609. axis.tickInterval = minTickInterval;
  19610. }
  19611. // for linear axes, get magnitude and normalize the interval
  19612. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  19613. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  19614. // If the tick interval is greather than 0.5, avoid
  19615. // decimals, as linear axes are often used to render
  19616. // discrete values. #3363. If a tick amount is set, allow
  19617. // decimals by default, as it increases the chances for a
  19618. // good fit.
  19619. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  19620. }
  19621. // Prevent ticks from getting so close that we can't draw the labels
  19622. if (!this.tickAmount) {
  19623. axis.tickInterval = axis.unsquish();
  19624. }
  19625. this.setTickPositions();
  19626. };
  19627. /**
  19628. * Now we have computed the normalized tickInterval, get the tick positions.
  19629. *
  19630. * @private
  19631. * @function Highcharts.Axis#setTickPositions
  19632. *
  19633. * @fires Highcharts.Axis#event:afterSetTickPositions
  19634. */
  19635. Axis.prototype.setTickPositions = function () {
  19636. var axis = this,
  19637. options = this.options,
  19638. tickPositionsOption = options.tickPositions,
  19639. minorTickIntervalOption = this.getMinorTickInterval(),
  19640. hasVerticalPanning = this.hasVerticalPanning(),
  19641. isColorAxis = this.coll === 'colorAxis',
  19642. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  19643. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  19644. var tickPositions,
  19645. tickPositioner = options.tickPositioner;
  19646. // Set the tickmarkOffset
  19647. this.tickmarkOffset = (this.categories &&
  19648. options.tickmarkPlacement === 'between' &&
  19649. this.tickInterval === 1) ? 0.5 : 0; // #3202
  19650. // get minorTickInterval
  19651. this.minorTickInterval =
  19652. minorTickIntervalOption === 'auto' &&
  19653. this.tickInterval ?
  19654. this.tickInterval / 5 :
  19655. minorTickIntervalOption;
  19656. // When there is only one point, or all points have the same value on
  19657. // this axis, then min and max are equal and tickPositions.length is 0
  19658. // or 1. In this case, add some padding in order to center the point,
  19659. // but leave it with one tick. #1337.
  19660. this.single =
  19661. this.min === this.max &&
  19662. defined(this.min) &&
  19663. !this.tickAmount &&
  19664. (
  19665. // Data is on integer (#6563)
  19666. parseInt(this.min, 10) === this.min ||
  19667. // Between integers and decimals are not allowed (#6274)
  19668. options.allowDecimals !== false);
  19669. /**
  19670. * Contains the current positions that are laid out on the axis. The
  19671. * positions are numbers in terms of axis values. In a category axis
  19672. * they are integers, in a datetime axis they are also integers, but
  19673. * designating milliseconds.
  19674. *
  19675. * This property is read only - for modifying the tick positions, use
  19676. * the `tickPositioner` callback or [axis.tickPositions(
  19677. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  19678. * instead.
  19679. *
  19680. * @name Highcharts.Axis#tickPositions
  19681. * @type {Highcharts.AxisTickPositionsArray|undefined}
  19682. */
  19683. this.tickPositions =
  19684. // Find the tick positions. Work on a copy (#1565)
  19685. tickPositions =
  19686. (tickPositionsOption && tickPositionsOption.slice());
  19687. if (!tickPositions) {
  19688. // Too many ticks (#6405). Create a friendly warning and provide two
  19689. // ticks so at least we can show the data series.
  19690. if ((!axis.ordinal || !axis.ordinal.positions) &&
  19691. ((this.max - this.min) /
  19692. this.tickInterval >
  19693. Math.max(2 * this.len, 200))) {
  19694. tickPositions = [this.min, this.max];
  19695. error(19, false, this.chart);
  19696. }
  19697. else if (axis.dateTime) {
  19698. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  19699. }
  19700. else if (axis.logarithmic) {
  19701. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  19702. }
  19703. else {
  19704. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  19705. }
  19706. // Too dense ticks, keep only the first and last (#4477)
  19707. if (tickPositions.length > this.len) {
  19708. tickPositions = [tickPositions[0], tickPositions.pop()];
  19709. // Reduce doubled value (#7339)
  19710. if (tickPositions[0] === tickPositions[1]) {
  19711. tickPositions.length = 1;
  19712. }
  19713. }
  19714. this.tickPositions = tickPositions;
  19715. // Run the tick positioner callback, that allows modifying auto tick
  19716. // positions.
  19717. if (tickPositioner) {
  19718. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  19719. if (tickPositioner) {
  19720. this.tickPositions = tickPositions = tickPositioner;
  19721. }
  19722. }
  19723. }
  19724. // Reset min/max or remove extremes based on start/end on tick
  19725. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  19726. this.trimTicks(tickPositions, startOnTick, endOnTick);
  19727. if (!this.isLinked) {
  19728. // Substract half a unit (#2619, #2846, #2515, #3390),
  19729. // but not in case of multiple ticks (#6897)
  19730. if (this.single &&
  19731. tickPositions.length < 2 &&
  19732. !this.categories &&
  19733. !this.series.some(function (s) {
  19734. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  19735. })) {
  19736. this.min -= 0.5;
  19737. this.max += 0.5;
  19738. }
  19739. if (!tickPositionsOption && !tickPositioner) {
  19740. this.adjustTickAmount();
  19741. }
  19742. }
  19743. fireEvent(this, 'afterSetTickPositions');
  19744. };
  19745. /**
  19746. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  19747. * rounded min/max. Also handle single data points.
  19748. *
  19749. * @private
  19750. * @function Highcharts.Axis#trimTicks
  19751. *
  19752. * @param {Array<number>} tickPositions
  19753. * TO-DO: parameter description
  19754. *
  19755. * @param {boolean} [startOnTick]
  19756. * TO-DO: parameter description
  19757. *
  19758. * @param {boolean} [endOnTick]
  19759. * TO-DO: parameter description
  19760. */
  19761. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  19762. var roundedMin = tickPositions[0],
  19763. roundedMax = tickPositions[tickPositions.length - 1],
  19764. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  19765. fireEvent(this, 'trimTicks');
  19766. if (!this.isLinked) {
  19767. if (startOnTick && roundedMin !== -Infinity) { // #6502
  19768. this.min = roundedMin;
  19769. }
  19770. else {
  19771. while (this.min - minPointOffset > tickPositions[0]) {
  19772. tickPositions.shift();
  19773. }
  19774. }
  19775. if (endOnTick) {
  19776. this.max = roundedMax;
  19777. }
  19778. else {
  19779. while (this.max + minPointOffset <
  19780. tickPositions[tickPositions.length - 1]) {
  19781. tickPositions.pop();
  19782. }
  19783. }
  19784. // If no tick are left, set one tick in the middle (#3195)
  19785. if (tickPositions.length === 0 &&
  19786. defined(roundedMin) &&
  19787. !this.options.tickPositions) {
  19788. tickPositions.push((roundedMax + roundedMin) / 2);
  19789. }
  19790. }
  19791. };
  19792. /**
  19793. * Check if there are multiple axes in the same pane.
  19794. *
  19795. * @private
  19796. * @function Highcharts.Axis#alignToOthers
  19797. *
  19798. * @return {boolean|undefined}
  19799. * True if there are other axes.
  19800. */
  19801. Axis.prototype.alignToOthers = function () {
  19802. var axis = this,
  19803. others = // Whether there is another axis to pair with this one
  19804. {},
  19805. options = axis.options;
  19806. var hasOther;
  19807. if (
  19808. // Only if alignTicks is true
  19809. this.chart.options.chart.alignTicks !== false &&
  19810. options.alignTicks &&
  19811. // Disabled when startOnTick or endOnTick are false (#7604)
  19812. options.startOnTick !== false &&
  19813. options.endOnTick !== false &&
  19814. // Don't try to align ticks on a log axis, they are not evenly
  19815. // spaced (#6021)
  19816. !axis.logarithmic) {
  19817. this.chart[this.coll].forEach(function (axis) {
  19818. var otherOptions = axis.options, horiz = axis.horiz, key = [
  19819. horiz ? otherOptions.left : otherOptions.top,
  19820. otherOptions.width,
  19821. otherOptions.height,
  19822. otherOptions.pane
  19823. ].join(',');
  19824. if (axis.series.length) { // #4442
  19825. if (others[key]) {
  19826. hasOther = true; // #4201
  19827. }
  19828. else {
  19829. others[key] = 1;
  19830. }
  19831. }
  19832. });
  19833. }
  19834. return hasOther;
  19835. };
  19836. /**
  19837. * Find the max ticks of either the x and y axis collection, and record it
  19838. * in `this.tickAmount`.
  19839. *
  19840. * @private
  19841. * @function Highcharts.Axis#getTickAmount
  19842. */
  19843. Axis.prototype.getTickAmount = function () {
  19844. var axis = this,
  19845. options = this.options,
  19846. tickPixelInterval = options.tickPixelInterval;
  19847. var tickAmount = options.tickAmount;
  19848. if (!defined(options.tickInterval) &&
  19849. !tickAmount &&
  19850. this.len < tickPixelInterval &&
  19851. !this.isRadial &&
  19852. !axis.logarithmic &&
  19853. options.startOnTick &&
  19854. options.endOnTick) {
  19855. tickAmount = 2;
  19856. }
  19857. if (!tickAmount && this.alignToOthers()) {
  19858. // Add 1 because 4 tick intervals require 5 ticks (including first
  19859. // and last)
  19860. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  19861. }
  19862. // For tick amounts of 2 and 3, compute five ticks and remove the
  19863. // intermediate ones. This prevents the axis from adding ticks that are
  19864. // too far away from the data extremes.
  19865. if (tickAmount < 4) {
  19866. this.finalTickAmt = tickAmount;
  19867. tickAmount = 5;
  19868. }
  19869. this.tickAmount = tickAmount;
  19870. };
  19871. /**
  19872. * When using multiple axes, adjust the number of ticks to match the highest
  19873. * number of ticks in that group.
  19874. *
  19875. * @private
  19876. * @function Highcharts.Axis#adjustTickAmount
  19877. */
  19878. Axis.prototype.adjustTickAmount = function () {
  19879. var axis = this,
  19880. axisOptions = axis.options,
  19881. tickInterval = axis.tickInterval,
  19882. tickPositions = axis.tickPositions,
  19883. tickAmount = axis.tickAmount,
  19884. finalTickAmt = axis.finalTickAmt,
  19885. currentTickAmount = tickPositions && tickPositions.length,
  19886. threshold = pick(axis.threshold,
  19887. axis.softThreshold ? 0 : null);
  19888. var len,
  19889. i;
  19890. if (axis.hasData() && isNumber(axis.min) && isNumber(axis.max)) { // #14769
  19891. if (currentTickAmount < tickAmount) {
  19892. while (tickPositions.length < tickAmount) {
  19893. // Extend evenly for both sides unless we're on the
  19894. // threshold (#3965)
  19895. if (tickPositions.length % 2 ||
  19896. axis.min === threshold) {
  19897. // to the end
  19898. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  19899. tickInterval));
  19900. }
  19901. else {
  19902. // to the start
  19903. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  19904. }
  19905. }
  19906. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  19907. // Do not crop when ticks are not extremes (#9841)
  19908. axis.min = axisOptions.startOnTick ?
  19909. tickPositions[0] :
  19910. Math.min(axis.min, tickPositions[0]);
  19911. axis.max = axisOptions.endOnTick ?
  19912. tickPositions[tickPositions.length - 1] :
  19913. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  19914. // We have too many ticks, run second pass to try to reduce ticks
  19915. }
  19916. else if (currentTickAmount > tickAmount) {
  19917. axis.tickInterval *= 2;
  19918. axis.setTickPositions();
  19919. }
  19920. // The finalTickAmt property is set in getTickAmount
  19921. if (defined(finalTickAmt)) {
  19922. i = len = tickPositions.length;
  19923. while (i--) {
  19924. if (
  19925. // Remove every other tick
  19926. (finalTickAmt === 3 && i % 2 === 1) ||
  19927. // Remove all but first and last
  19928. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  19929. tickPositions.splice(i, 1);
  19930. }
  19931. }
  19932. axis.finalTickAmt = void 0;
  19933. }
  19934. }
  19935. };
  19936. /**
  19937. * Set the scale based on data min and max, user set min and max or options.
  19938. *
  19939. * @private
  19940. * @function Highcharts.Axis#setScale
  19941. *
  19942. * @fires Highcharts.Axis#event:afterSetScale
  19943. */
  19944. Axis.prototype.setScale = function () {
  19945. var axis = this;
  19946. var isDirtyData = false,
  19947. isXAxisDirty = false;
  19948. axis.series.forEach(function (series) {
  19949. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  19950. // When x axis is dirty, we need new data extremes for y as
  19951. // well:
  19952. isXAxisDirty = (isXAxisDirty ||
  19953. (series.xAxis && series.xAxis.isDirty) ||
  19954. false);
  19955. });
  19956. // set the new axisLength
  19957. axis.setAxisSize();
  19958. var isDirtyAxisLength = axis.len !== (axis.old && axis.old.len);
  19959. // do we really need to go through all this?
  19960. if (isDirtyAxisLength ||
  19961. isDirtyData ||
  19962. isXAxisDirty ||
  19963. axis.isLinked ||
  19964. axis.forceRedraw ||
  19965. axis.userMin !== (axis.old && axis.old.userMin) ||
  19966. axis.userMax !== (axis.old && axis.old.userMax) ||
  19967. axis.alignToOthers()) {
  19968. if (axis.stacking) {
  19969. axis.stacking.resetStacks();
  19970. }
  19971. axis.forceRedraw = false;
  19972. // get data extremes if needed
  19973. axis.getSeriesExtremes();
  19974. // get fixed positions based on tickInterval
  19975. axis.setTickInterval();
  19976. // Mark as dirty if it is not already set to dirty and extremes have
  19977. // changed. #595.
  19978. if (!axis.isDirty) {
  19979. axis.isDirty =
  19980. isDirtyAxisLength ||
  19981. axis.min !== (axis.old && axis.old.min) ||
  19982. axis.max !== (axis.old && axis.old.max);
  19983. }
  19984. }
  19985. else if (axis.stacking) {
  19986. axis.stacking.cleanStacks();
  19987. }
  19988. // Recalculate panning state object, when the data
  19989. // has changed. It is required when vertical panning is enabled.
  19990. if (isDirtyData && axis.panningState) {
  19991. axis.panningState.isDirty = true;
  19992. }
  19993. fireEvent(this, 'afterSetScale');
  19994. };
  19995. /**
  19996. * Set the minimum and maximum of the axes after render time. If the
  19997. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  19998. * values are rounded off to the nearest tick. To prevent this, these
  19999. * options can be set to false before calling setExtremes. Also, setExtremes
  20000. * will not allow a range lower than the `minRange` option, which by default
  20001. * is the range of five points.
  20002. *
  20003. * @sample highcharts/members/axis-setextremes/
  20004. * Set extremes from a button
  20005. * @sample highcharts/members/axis-setextremes-datetime/
  20006. * Set extremes on a datetime axis
  20007. * @sample highcharts/members/axis-setextremes-off-ticks/
  20008. * Set extremes off ticks
  20009. * @sample stock/members/axis-setextremes/
  20010. * Set extremes in Highcharts Stock
  20011. * @sample maps/members/axis-setextremes/
  20012. * Set extremes in Highmaps
  20013. *
  20014. * @function Highcharts.Axis#setExtremes
  20015. *
  20016. * @param {number} [newMin]
  20017. * The new minimum value.
  20018. *
  20019. * @param {number} [newMax]
  20020. * The new maximum value.
  20021. *
  20022. * @param {boolean} [redraw=true]
  20023. * Whether to redraw the chart or wait for an explicit call to
  20024. * {@link Highcharts.Chart#redraw}
  20025. *
  20026. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  20027. * Enable or modify animations.
  20028. *
  20029. * @param {*} [eventArguments]
  20030. * Arguments to be accessed in event handler.
  20031. *
  20032. * @fires Highcharts.Axis#event:setExtremes
  20033. */
  20034. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  20035. var axis = this,
  20036. chart = axis.chart;
  20037. redraw = pick(redraw, true); // defaults to true
  20038. axis.series.forEach(function (serie) {
  20039. delete serie.kdTree;
  20040. });
  20041. // Extend the arguments with min and max
  20042. eventArguments = extend(eventArguments, {
  20043. min: newMin,
  20044. max: newMax
  20045. });
  20046. // Fire the event
  20047. fireEvent(axis, 'setExtremes', eventArguments, function () {
  20048. axis.userMin = newMin;
  20049. axis.userMax = newMax;
  20050. axis.eventArgs = eventArguments;
  20051. if (redraw) {
  20052. chart.redraw(animation);
  20053. }
  20054. });
  20055. };
  20056. /**
  20057. * Overridable method for zooming chart. Pulled out in a separate method to
  20058. * allow overriding in stock charts.
  20059. *
  20060. * @private
  20061. * @function Highcharts.Axis#zoom
  20062. *
  20063. * @param {number} newMin
  20064. * TO-DO: parameter description
  20065. *
  20066. * @param {number} newMax
  20067. * TO-DO: parameter description
  20068. *
  20069. * @return {boolean}
  20070. */
  20071. Axis.prototype.zoom = function (newMin, newMax) {
  20072. var axis = this,
  20073. dataMin = this.dataMin,
  20074. dataMax = this.dataMax,
  20075. options = this.options,
  20076. min = Math.min(dataMin,
  20077. pick(options.min,
  20078. dataMin)),
  20079. max = Math.max(dataMax,
  20080. pick(options.max,
  20081. dataMax)),
  20082. evt = {
  20083. newMin: newMin,
  20084. newMax: newMax
  20085. };
  20086. fireEvent(this, 'zoom', evt, function (e) {
  20087. // Use e.newMin and e.newMax - event handlers may have altered them
  20088. var newMin = e.newMin,
  20089. newMax = e.newMax;
  20090. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  20091. // Prevent pinch zooming out of range. Check for defined is for
  20092. // #1946. #1734.
  20093. if (!axis.allowZoomOutside) {
  20094. // #6014, sometimes newMax will be smaller than min (or
  20095. // newMin will be larger than max).
  20096. if (defined(dataMin)) {
  20097. if (newMin < min) {
  20098. newMin = min;
  20099. }
  20100. if (newMin > max) {
  20101. newMin = max;
  20102. }
  20103. }
  20104. if (defined(dataMax)) {
  20105. if (newMax < min) {
  20106. newMax = min;
  20107. }
  20108. if (newMax > max) {
  20109. newMax = max;
  20110. }
  20111. }
  20112. }
  20113. // In full view, displaying the reset zoom button is not
  20114. // required
  20115. axis.displayBtn = (typeof newMin !== 'undefined' ||
  20116. typeof newMax !== 'undefined');
  20117. // Do it
  20118. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  20119. }
  20120. e.zoomed = true;
  20121. });
  20122. return evt.zoomed;
  20123. };
  20124. /**
  20125. * Update the axis metrics.
  20126. *
  20127. * @private
  20128. * @function Highcharts.Axis#setAxisSize
  20129. */
  20130. Axis.prototype.setAxisSize = function () {
  20131. var chart = this.chart,
  20132. options = this.options,
  20133. // [top, right, bottom, left]
  20134. offsets = options.offsets || [0, 0, 0, 0],
  20135. horiz = this.horiz,
  20136. // Check for percentage based input values. Rounding fixes problems
  20137. // with column overflow and plot line filtering (#4898, #4899)
  20138. width = this.width = Math.round(relativeLength(pick(options.width,
  20139. chart.plotWidth - offsets[3] + offsets[1]),
  20140. chart.plotWidth)),
  20141. height = this.height = Math.round(relativeLength(pick(options.height,
  20142. chart.plotHeight - offsets[0] + offsets[2]),
  20143. chart.plotHeight)),
  20144. top = this.top = Math.round(relativeLength(pick(options.top,
  20145. chart.plotTop + offsets[0]),
  20146. chart.plotHeight,
  20147. chart.plotTop)),
  20148. left = this.left = Math.round(relativeLength(pick(options.left,
  20149. chart.plotLeft + offsets[3]),
  20150. chart.plotWidth,
  20151. chart.plotLeft));
  20152. // Expose basic values to use in Series object and navigator
  20153. this.bottom = chart.chartHeight - height - top;
  20154. this.right = chart.chartWidth - width - left;
  20155. // Direction agnostic properties
  20156. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  20157. this.pos = horiz ? left : top; // distance from SVG origin
  20158. };
  20159. /**
  20160. * Get the current extremes for the axis.
  20161. *
  20162. * @sample highcharts/members/axis-getextremes/
  20163. * Report extremes by click on a button
  20164. * @sample maps/members/axis-getextremes/
  20165. * Get extremes in Highmaps
  20166. *
  20167. * @function Highcharts.Axis#getExtremes
  20168. *
  20169. * @return {Highcharts.ExtremesObject}
  20170. * An object containing extremes information.
  20171. */
  20172. Axis.prototype.getExtremes = function () {
  20173. var axis = this,
  20174. log = axis.logarithmic;
  20175. return {
  20176. min: log ?
  20177. correctFloat(log.lin2log(axis.min)) :
  20178. axis.min,
  20179. max: log ?
  20180. correctFloat(log.lin2log(axis.max)) :
  20181. axis.max,
  20182. dataMin: axis.dataMin,
  20183. dataMax: axis.dataMax,
  20184. userMin: axis.userMin,
  20185. userMax: axis.userMax
  20186. };
  20187. };
  20188. /**
  20189. * Get the zero plane either based on zero or on the min or max value.
  20190. * Used in bar and area plots.
  20191. *
  20192. * @function Highcharts.Axis#getThreshold
  20193. *
  20194. * @param {number} threshold
  20195. * The threshold in axis values.
  20196. *
  20197. * @return {number|undefined}
  20198. * The translated threshold position in terms of pixels, and corrected to
  20199. * stay within the axis bounds.
  20200. */
  20201. Axis.prototype.getThreshold = function (threshold) {
  20202. var axis = this,
  20203. log = axis.logarithmic,
  20204. realMin = log ? log.lin2log(axis.min) : axis.min,
  20205. realMax = log ? log.lin2log(axis.max) : axis.max;
  20206. if (threshold === null || threshold === -Infinity) {
  20207. threshold = realMin;
  20208. }
  20209. else if (threshold === Infinity) {
  20210. threshold = realMax;
  20211. }
  20212. else if (realMin > threshold) {
  20213. threshold = realMin;
  20214. }
  20215. else if (realMax < threshold) {
  20216. threshold = realMax;
  20217. }
  20218. return axis.translate(threshold, 0, 1, 0, 1);
  20219. };
  20220. /**
  20221. * Compute auto alignment for the axis label based on which side the axis is
  20222. * on and the given rotation for the label.
  20223. *
  20224. * @private
  20225. * @function Highcharts.Axis#autoLabelAlign
  20226. *
  20227. * @param {number} rotation
  20228. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  20229. * options.
  20230. *
  20231. * @return {Highcharts.AlignValue}
  20232. * Can be `"center"`, `"left"` or `"right"`.
  20233. */
  20234. Axis.prototype.autoLabelAlign = function (rotation) {
  20235. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  20236. evt = { align: 'center' };
  20237. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  20238. if (angle > 15 && angle < 165) {
  20239. e.align = 'right';
  20240. }
  20241. else if (angle > 195 && angle < 345) {
  20242. e.align = 'left';
  20243. }
  20244. });
  20245. return evt.align;
  20246. };
  20247. /**
  20248. * Get the tick length and width for the axis based on axis options.
  20249. *
  20250. * @private
  20251. * @function Highcharts.Axis#tickSize
  20252. *
  20253. * @param {string} [prefix]
  20254. * 'tick' or 'minorTick'
  20255. *
  20256. * @return {Array<number,number>|undefined}
  20257. * An array of tickLength and tickWidth
  20258. */
  20259. Axis.prototype.tickSize = function (prefix) {
  20260. var options = this.options,
  20261. tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  20262. // Default to 1 on linear and datetime X axes
  20263. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0);
  20264. var tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'],
  20265. tickSize;
  20266. if (tickWidth && tickLength) {
  20267. // Negate the length
  20268. if (options[prefix + 'Position'] === 'inside') {
  20269. tickLength = -tickLength;
  20270. }
  20271. tickSize = [tickLength, tickWidth];
  20272. }
  20273. var e = { tickSize: tickSize };
  20274. fireEvent(this, 'afterTickSize', e);
  20275. return e.tickSize;
  20276. };
  20277. /**
  20278. * Return the size of the labels.
  20279. *
  20280. * @private
  20281. * @function Highcharts.Axis#labelMetrics
  20282. *
  20283. * @return {Highcharts.FontMetricsObject}
  20284. */
  20285. Axis.prototype.labelMetrics = function () {
  20286. var index = this.tickPositions && this.tickPositions[0] || 0;
  20287. return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  20288. };
  20289. /**
  20290. * Prevent the ticks from getting so close we can't draw the labels. On a
  20291. * horizontal axis, this is handled by rotating the labels, removing ticks
  20292. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  20293. *
  20294. * @private
  20295. * @function Highcharts.Axis#unsquish
  20296. *
  20297. * @return {number}
  20298. */
  20299. Axis.prototype.unsquish = function () {
  20300. var labelOptions = this.options.labels,
  20301. horiz = this.horiz,
  20302. tickInterval = this.tickInterval,
  20303. slotSize = this.len / (((this.categories ? 1 : 0) +
  20304. this.max -
  20305. this.min) /
  20306. tickInterval),
  20307. rotationOption = labelOptions.rotation,
  20308. labelMetrics = this.labelMetrics(),
  20309. range = Math.max(this.max - this.min, 0),
  20310. // Return the multiple of tickInterval that is needed to avoid
  20311. // collision
  20312. getStep = function (spaceNeeded) {
  20313. var step = spaceNeeded / (slotSize || 1);
  20314. step = step > 1 ? Math.ceil(step) : 1;
  20315. // Guard for very small or negative angles (#9835)
  20316. if (step * tickInterval > range &&
  20317. spaceNeeded !== Infinity &&
  20318. slotSize !== Infinity &&
  20319. range) {
  20320. step = Math.ceil(range / tickInterval);
  20321. }
  20322. return correctFloat(step * tickInterval);
  20323. };
  20324. var newTickInterval = tickInterval,
  20325. rotation,
  20326. step,
  20327. bestScore = Number.MAX_VALUE,
  20328. autoRotation;
  20329. if (horiz) {
  20330. if (!labelOptions.staggerLines && !labelOptions.step) {
  20331. if (isNumber(rotationOption)) {
  20332. autoRotation = [rotationOption];
  20333. }
  20334. else if (slotSize < labelOptions.autoRotationLimit) {
  20335. autoRotation = labelOptions.autoRotation;
  20336. }
  20337. }
  20338. if (autoRotation) {
  20339. // Loop over the given autoRotation options, and determine
  20340. // which gives the best score. The best score is that with
  20341. // the lowest number of steps and a rotation closest
  20342. // to horizontal.
  20343. autoRotation.forEach(function (rot) {
  20344. var score;
  20345. if (rot === rotationOption ||
  20346. (rot && rot >= -90 && rot <= 90)) { // #3891
  20347. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  20348. score = step + Math.abs(rot / 360);
  20349. if (score < bestScore) {
  20350. bestScore = score;
  20351. rotation = rot;
  20352. newTickInterval = step;
  20353. }
  20354. }
  20355. });
  20356. }
  20357. }
  20358. else if (!labelOptions.step) { // #4411
  20359. newTickInterval = getStep(labelMetrics.h);
  20360. }
  20361. this.autoRotation = autoRotation;
  20362. this.labelRotation = pick(rotation, isNumber(rotationOption) ? rotationOption : 0);
  20363. return newTickInterval;
  20364. };
  20365. /**
  20366. * Get the general slot width for labels/categories on this axis. This may
  20367. * change between the pre-render (from Axis.getOffset) and the final tick
  20368. * rendering and placement.
  20369. *
  20370. * @private
  20371. * @function Highcharts.Axis#getSlotWidth
  20372. *
  20373. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  20374. * basing on tick label. It is used in highcharts-3d module, where the slots
  20375. * has different widths depending on perspective angles.
  20376. *
  20377. * @return {number}
  20378. * The pixel width allocated to each axis label.
  20379. */
  20380. Axis.prototype.getSlotWidth = function (tick) {
  20381. // #5086, #1580, #1931
  20382. var chart = this.chart,
  20383. horiz = this.horiz,
  20384. labelOptions = this.options.labels,
  20385. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  20386. marginLeft = chart.margin[3];
  20387. // Used by grid axis
  20388. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  20389. return tick.slotWidth;
  20390. }
  20391. if (horiz && labelOptions.step < 2) {
  20392. if (labelOptions.rotation) { // #4415
  20393. return 0;
  20394. }
  20395. return ((this.staggerLines || 1) * this.len) / slotCount;
  20396. }
  20397. if (!horiz) {
  20398. // #7028
  20399. var cssWidth = labelOptions.style.width;
  20400. if (cssWidth !== void 0) {
  20401. return parseInt(String(cssWidth), 10);
  20402. }
  20403. if (marginLeft) {
  20404. return marginLeft - chart.spacing[3];
  20405. }
  20406. }
  20407. // Last resort, a fraction of the available size
  20408. return chart.chartWidth * 0.33;
  20409. };
  20410. /**
  20411. * Render the axis labels and determine whether ellipsis or rotation need to
  20412. * be applied.
  20413. *
  20414. * @private
  20415. * @function Highcharts.Axis#renderUnsquish
  20416. */
  20417. Axis.prototype.renderUnsquish = function () {
  20418. var chart = this.chart,
  20419. renderer = chart.renderer,
  20420. tickPositions = this.tickPositions,
  20421. ticks = this.ticks,
  20422. labelOptions = this.options.labels,
  20423. labelStyleOptions = labelOptions.style,
  20424. horiz = this.horiz,
  20425. slotWidth = this.getSlotWidth(),
  20426. innerWidth = Math.max(1,
  20427. Math.round(slotWidth - 2 * labelOptions.padding)),
  20428. attr = {},
  20429. labelMetrics = this.labelMetrics(),
  20430. textOverflowOption = labelStyleOptions.textOverflow;
  20431. var commonWidth,
  20432. commonTextOverflow,
  20433. maxLabelLength = 0,
  20434. label,
  20435. i,
  20436. pos;
  20437. // Set rotation option unless it is "auto", like in gauges
  20438. if (!isString(labelOptions.rotation)) {
  20439. // #4443
  20440. attr.rotation = labelOptions.rotation || 0;
  20441. }
  20442. // Get the longest label length
  20443. tickPositions.forEach(function (tickPosition) {
  20444. var tick = ticks[tickPosition];
  20445. // Replace label - sorting animation
  20446. if (tick.movedLabel) {
  20447. tick.replaceMovedLabel();
  20448. }
  20449. if (tick &&
  20450. tick.label &&
  20451. tick.label.textPxLength > maxLabelLength) {
  20452. maxLabelLength = tick.label.textPxLength;
  20453. }
  20454. });
  20455. this.maxLabelLength = maxLabelLength;
  20456. // Handle auto rotation on horizontal axis
  20457. if (this.autoRotation) {
  20458. // Apply rotation only if the label is too wide for the slot, and
  20459. // the label is wider than its height.
  20460. if (maxLabelLength > innerWidth &&
  20461. maxLabelLength > labelMetrics.h) {
  20462. attr.rotation = this.labelRotation;
  20463. }
  20464. else {
  20465. this.labelRotation = 0;
  20466. }
  20467. // Handle word-wrap or ellipsis on vertical axis
  20468. }
  20469. else if (slotWidth) {
  20470. // For word-wrap or ellipsis
  20471. commonWidth = innerWidth;
  20472. if (!textOverflowOption) {
  20473. commonTextOverflow = 'clip';
  20474. // On vertical axis, only allow word wrap if there is room
  20475. // for more lines.
  20476. i = tickPositions.length;
  20477. while (!horiz && i--) {
  20478. pos = tickPositions[i];
  20479. label = ticks[pos].label;
  20480. if (label) {
  20481. // Reset ellipsis in order to get the correct
  20482. // bounding box (#4070)
  20483. if (label.styles &&
  20484. label.styles.textOverflow === 'ellipsis') {
  20485. label.css({ textOverflow: 'clip' });
  20486. // Set the correct width in order to read
  20487. // the bounding box height (#4678, #5034)
  20488. }
  20489. else if (label.textPxLength > slotWidth) {
  20490. label.css({ width: slotWidth + 'px' });
  20491. }
  20492. if (label.getBBox().height > (this.len / tickPositions.length -
  20493. (labelMetrics.h - labelMetrics.f))) {
  20494. label.specificTextOverflow = 'ellipsis';
  20495. }
  20496. }
  20497. }
  20498. }
  20499. }
  20500. // Add ellipsis if the label length is significantly longer than ideal
  20501. if (attr.rotation) {
  20502. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  20503. chart.chartHeight * 0.33 :
  20504. maxLabelLength);
  20505. if (!textOverflowOption) {
  20506. commonTextOverflow = 'ellipsis';
  20507. }
  20508. }
  20509. // Set the explicit or automatic label alignment
  20510. this.labelAlign = labelOptions.align ||
  20511. this.autoLabelAlign(this.labelRotation);
  20512. if (this.labelAlign) {
  20513. attr.align = this.labelAlign;
  20514. }
  20515. // Apply general and specific CSS
  20516. tickPositions.forEach(function (pos) {
  20517. var tick = ticks[pos],
  20518. label = tick && tick.label,
  20519. widthOption = labelStyleOptions.width,
  20520. css = {};
  20521. if (label) {
  20522. // This needs to go before the CSS in old IE (#4502)
  20523. label.attr(attr);
  20524. if (tick.shortenLabel) {
  20525. tick.shortenLabel();
  20526. }
  20527. else if (commonWidth &&
  20528. !widthOption &&
  20529. // Setting width in this case messes with the bounding box
  20530. // (#7975)
  20531. labelStyleOptions.whiteSpace !== 'nowrap' &&
  20532. (
  20533. // Speed optimizing, #7656
  20534. commonWidth < label.textPxLength ||
  20535. // Resetting CSS, #4928
  20536. label.element.tagName === 'SPAN')) {
  20537. css.width = commonWidth + 'px';
  20538. if (!textOverflowOption) {
  20539. css.textOverflow = (label.specificTextOverflow ||
  20540. commonTextOverflow);
  20541. }
  20542. label.css(css);
  20543. // Reset previously shortened label (#8210)
  20544. }
  20545. else if (label.styles &&
  20546. label.styles.width &&
  20547. !css.width &&
  20548. !widthOption) {
  20549. label.css({ width: null });
  20550. }
  20551. delete label.specificTextOverflow;
  20552. tick.rotation = attr.rotation;
  20553. }
  20554. }, this);
  20555. // Note: Why is this not part of getLabelPosition?
  20556. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  20557. };
  20558. /**
  20559. * Return true if the axis has associated data.
  20560. *
  20561. * @function Highcharts.Axis#hasData
  20562. *
  20563. * @return {boolean}
  20564. * True if the axis has associated visible series and those series have
  20565. * either valid data points or explicit `min` and `max` settings.
  20566. */
  20567. Axis.prototype.hasData = function () {
  20568. return this.series.some(function (s) {
  20569. return s.hasData();
  20570. }) ||
  20571. (this.options.showEmpty &&
  20572. defined(this.min) &&
  20573. defined(this.max));
  20574. };
  20575. /**
  20576. * Adds the title defined in axis.options.title.
  20577. *
  20578. * @function Highcharts.Axis#addTitle
  20579. *
  20580. * @param {boolean} [display]
  20581. * Whether or not to display the title.
  20582. */
  20583. Axis.prototype.addTitle = function (display) {
  20584. var axis = this,
  20585. renderer = axis.chart.renderer,
  20586. horiz = axis.horiz,
  20587. opposite = axis.opposite,
  20588. options = axis.options,
  20589. axisTitleOptions = options.title,
  20590. styledMode = axis.chart.styledMode;
  20591. var textAlign;
  20592. if (!axis.axisTitle) {
  20593. textAlign = axisTitleOptions.textAlign;
  20594. if (!textAlign) {
  20595. textAlign = (horiz ? {
  20596. low: 'left',
  20597. middle: 'center',
  20598. high: 'right'
  20599. } : {
  20600. low: opposite ? 'right' : 'left',
  20601. middle: 'center',
  20602. high: opposite ? 'left' : 'right'
  20603. })[axisTitleOptions.align];
  20604. }
  20605. axis.axisTitle = renderer
  20606. .text(axisTitleOptions.text || '', 0, 0, axisTitleOptions.useHTML)
  20607. .attr({
  20608. zIndex: 7,
  20609. rotation: axisTitleOptions.rotation,
  20610. align: textAlign
  20611. })
  20612. .addClass('highcharts-axis-title');
  20613. // #7814, don't mutate style option
  20614. if (!styledMode) {
  20615. axis.axisTitle.css(merge(axisTitleOptions.style));
  20616. }
  20617. axis.axisTitle.add(axis.axisGroup);
  20618. axis.axisTitle.isNew = true;
  20619. }
  20620. // Max width defaults to the length of the axis
  20621. if (!styledMode &&
  20622. !axisTitleOptions.style.width &&
  20623. !axis.isRadial) {
  20624. axis.axisTitle.css({
  20625. width: axis.len + 'px'
  20626. });
  20627. }
  20628. // hide or show the title depending on whether showEmpty is set
  20629. axis.axisTitle[display ? 'show' : 'hide'](display);
  20630. };
  20631. /**
  20632. * Generates a tick for initial positioning.
  20633. *
  20634. * @private
  20635. * @function Highcharts.Axis#generateTick
  20636. *
  20637. * @param {number} pos
  20638. * The tick position in axis values.
  20639. *
  20640. * @param {number} [i]
  20641. * The index of the tick in {@link Axis.tickPositions}.
  20642. */
  20643. Axis.prototype.generateTick = function (pos) {
  20644. var axis = this,
  20645. ticks = axis.ticks;
  20646. if (!ticks[pos]) {
  20647. ticks[pos] = new Tick(axis, pos);
  20648. }
  20649. else {
  20650. ticks[pos].addLabel(); // update labels depending on tick interval
  20651. }
  20652. };
  20653. /**
  20654. * Render the tick labels to a preliminary position to get their sizes
  20655. *
  20656. * @private
  20657. * @function Highcharts.Axis#getOffset
  20658. *
  20659. * @fires Highcharts.Axis#event:afterGetOffset
  20660. */
  20661. Axis.prototype.getOffset = function () {
  20662. var _this = this;
  20663. var axis = this,
  20664. chart = axis.chart,
  20665. renderer = chart.renderer,
  20666. options = axis.options,
  20667. tickPositions = axis.tickPositions,
  20668. ticks = axis.ticks,
  20669. horiz = axis.horiz,
  20670. side = axis.side,
  20671. invertedSide = (chart.inverted && !axis.isZAxis ?
  20672. [1, 0, 3, 2][side] :
  20673. side),
  20674. hasData = axis.hasData(),
  20675. axisTitleOptions = options.title,
  20676. labelOptions = options.labels,
  20677. axisOffset = chart.axisOffset,
  20678. clipOffset = chart.clipOffset,
  20679. directionFactor = [-1, 1, 1, -1][side],
  20680. className = options.className,
  20681. axisParent = axis.axisParent; // Used in color axis
  20682. var showAxis,
  20683. titleOffset = 0,
  20684. titleOffsetOption,
  20685. titleMargin = 0,
  20686. labelOffset = 0, // reset
  20687. labelOffsetPadded,
  20688. lineHeightCorrection;
  20689. // For reuse in Axis.render
  20690. axis.showAxis = showAxis = hasData || options.showEmpty;
  20691. // Set/reset staggerLines
  20692. axis.staggerLines = (axis.horiz && labelOptions.staggerLines) || void 0;
  20693. // Create the axisGroup and gridGroup elements on first iteration
  20694. if (!axis.axisGroup) {
  20695. var createGroup = function (name,
  20696. suffix,
  20697. zIndex) { return renderer.g(name)
  20698. .attr({ zIndex: zIndex })
  20699. .addClass("highcharts-" + _this.coll.toLowerCase() + suffix + " " +
  20700. (_this.isRadial ? "highcharts-radial-axis" + suffix + " " : '') +
  20701. (className || ''))
  20702. .add(axisParent); };
  20703. axis.gridGroup = createGroup('grid', '-grid', options.gridZIndex);
  20704. axis.axisGroup = createGroup('axis', '', options.zIndex);
  20705. axis.labelGroup = createGroup('axis-labels', '-labels', labelOptions.zIndex);
  20706. }
  20707. if (hasData || axis.isLinked) {
  20708. // Generate ticks
  20709. tickPositions.forEach(function (pos) {
  20710. // i is not used here, but may be used in overrides
  20711. axis.generateTick(pos);
  20712. });
  20713. axis.renderUnsquish();
  20714. // Left side must be align: right and right side must
  20715. // have align: left for labels
  20716. axis.reserveSpaceDefault = (side === 0 ||
  20717. side === 2 ||
  20718. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  20719. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  20720. tickPositions.forEach(function (pos) {
  20721. // get the highest offset
  20722. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  20723. });
  20724. }
  20725. if (axis.staggerLines) {
  20726. labelOffset *= axis.staggerLines;
  20727. }
  20728. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  20729. }
  20730. else { // doesn't have data
  20731. objectEach(ticks, function (tick, n) {
  20732. tick.destroy();
  20733. delete ticks[n];
  20734. });
  20735. }
  20736. if (axisTitleOptions &&
  20737. axisTitleOptions.text &&
  20738. axisTitleOptions.enabled !== false) {
  20739. axis.addTitle(showAxis);
  20740. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  20741. axis.titleOffset = titleOffset =
  20742. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  20743. titleOffsetOption = axisTitleOptions.offset;
  20744. titleMargin = defined(titleOffsetOption) ?
  20745. 0 :
  20746. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  20747. }
  20748. }
  20749. // Render the axis line
  20750. axis.renderLine();
  20751. // handle automatic or user set offset
  20752. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  20753. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  20754. if (side === 0) {
  20755. lineHeightCorrection = -axis.labelMetrics().h;
  20756. }
  20757. else if (side === 2) {
  20758. lineHeightCorrection = axis.tickRotCorr.y;
  20759. }
  20760. else {
  20761. lineHeightCorrection = 0;
  20762. }
  20763. // Find the padded label offset
  20764. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  20765. if (labelOffset) {
  20766. labelOffsetPadded -= lineHeightCorrection;
  20767. labelOffsetPadded += directionFactor * (horiz ?
  20768. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  20769. labelOptions.x);
  20770. }
  20771. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  20772. if (axis.getMaxLabelDimensions) {
  20773. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  20774. }
  20775. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  20776. // has rendered.
  20777. var tickSize = this.tickSize('tick');
  20778. axisOffset[side] = Math.max(axisOffset[side], (axis.axisTitleMargin || 0) + titleOffset +
  20779. directionFactor * axis.offset, labelOffsetPadded, // #3027
  20780. tickPositions && tickPositions.length && tickSize ?
  20781. tickSize[0] + directionFactor * axis.offset :
  20782. 0 // #4866
  20783. );
  20784. // Decide the clipping needed to keep the graph inside
  20785. // the plot area and axis lines
  20786. var clip = options.offset ?
  20787. 0 :
  20788. // #4308, #4371:
  20789. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  20790. clipOffset[invertedSide] =
  20791. Math.max(clipOffset[invertedSide], clip);
  20792. fireEvent(this, 'afterGetOffset');
  20793. };
  20794. /**
  20795. * Internal function to get the path for the axis line. Extended for polar
  20796. * charts.
  20797. *
  20798. * @function Highcharts.Axis#getLinePath
  20799. *
  20800. * @param {number} lineWidth
  20801. * The line width in pixels.
  20802. *
  20803. * @return {Highcharts.SVGPathArray}
  20804. * The SVG path definition in array form.
  20805. */
  20806. Axis.prototype.getLinePath = function (lineWidth) {
  20807. var chart = this.chart,
  20808. opposite = this.opposite,
  20809. offset = this.offset,
  20810. horiz = this.horiz,
  20811. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  20812. lineTop = chart.chartHeight - this.bottom -
  20813. (opposite ? this.height : 0) + offset;
  20814. if (opposite) {
  20815. lineWidth *= -1; // crispify the other way - #1480, #1687
  20816. }
  20817. return chart.renderer
  20818. .crispLine([
  20819. [
  20820. 'M',
  20821. horiz ?
  20822. this.left :
  20823. lineLeft,
  20824. horiz ?
  20825. lineTop :
  20826. this.top
  20827. ],
  20828. [
  20829. 'L',
  20830. horiz ?
  20831. chart.chartWidth - this.right :
  20832. lineLeft,
  20833. horiz ?
  20834. lineTop :
  20835. chart.chartHeight - this.bottom
  20836. ]
  20837. ], lineWidth);
  20838. };
  20839. /**
  20840. * Render the axis line. Called internally when rendering and redrawing the
  20841. * axis.
  20842. *
  20843. * @function Highcharts.Axis#renderLine
  20844. */
  20845. Axis.prototype.renderLine = function () {
  20846. if (!this.axisLine) {
  20847. this.axisLine = this.chart.renderer.path()
  20848. .addClass('highcharts-axis-line')
  20849. .add(this.axisGroup);
  20850. if (!this.chart.styledMode) {
  20851. this.axisLine.attr({
  20852. stroke: this.options.lineColor,
  20853. 'stroke-width': this.options.lineWidth,
  20854. zIndex: 7
  20855. });
  20856. }
  20857. }
  20858. };
  20859. /**
  20860. * Position the axis title.
  20861. *
  20862. * @private
  20863. * @function Highcharts.Axis#getTitlePosition
  20864. *
  20865. * @return {Highcharts.PositionObject}
  20866. * X and Y positions for the title.
  20867. */
  20868. Axis.prototype.getTitlePosition = function () {
  20869. // compute anchor points for each of the title align options
  20870. var horiz = this.horiz,
  20871. axisLeft = this.left,
  20872. axisTop = this.top,
  20873. axisLength = this.len,
  20874. axisTitleOptions = this.options.title,
  20875. margin = horiz ? axisLeft : axisTop,
  20876. opposite = this.opposite,
  20877. offset = this.offset,
  20878. xOption = axisTitleOptions.x,
  20879. yOption = axisTitleOptions.y,
  20880. axisTitle = this.axisTitle,
  20881. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style.fontSize,
  20882. axisTitle),
  20883. // The part of a multiline text that is below the baseline of the
  20884. // first line. Subtract 1 to preserve pixel-perfectness from the
  20885. // old behaviour (v5.0.12), where only one line was allowed.
  20886. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  20887. // the position in the length direction of the axis
  20888. alongAxis = {
  20889. low: margin + (horiz ? 0 : axisLength),
  20890. middle: margin + axisLength / 2,
  20891. high: margin + (horiz ? axisLength : 0)
  20892. }[axisTitleOptions.align],
  20893. // the position in the perpendicular direction of the axis
  20894. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  20895. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  20896. (opposite ? -1 : 1) * // so does opposite axes
  20897. this.axisTitleMargin +
  20898. [
  20899. -textHeightOvershoot,
  20900. textHeightOvershoot,
  20901. fontMetrics.f,
  20902. -textHeightOvershoot // left
  20903. ][this.side],
  20904. titlePosition = {
  20905. x: horiz ?
  20906. alongAxis + xOption :
  20907. offAxis + (opposite ? this.width : 0) + offset + xOption,
  20908. y: horiz ?
  20909. offAxis + yOption - (opposite ? this.height : 0) + offset :
  20910. alongAxis + yOption
  20911. };
  20912. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  20913. return titlePosition;
  20914. };
  20915. /**
  20916. * Render a minor tick into the given position. If a minor tick already
  20917. * exists in this position, move it.
  20918. *
  20919. * @function Highcharts.Axis#renderMinorTick
  20920. *
  20921. * @param {number} pos
  20922. * The position in axis values.
  20923. */
  20924. Axis.prototype.renderMinorTick = function (pos) {
  20925. var axis = this;
  20926. var slideInTicks = axis.chart.hasRendered && axis.old;
  20927. var minorTicks = axis.minorTicks;
  20928. if (!minorTicks[pos]) {
  20929. minorTicks[pos] = new Tick(axis, pos, 'minor');
  20930. }
  20931. // Render new ticks in old position
  20932. if (slideInTicks && minorTicks[pos].isNew) {
  20933. minorTicks[pos].render(null, true);
  20934. }
  20935. minorTicks[pos].render(null, false, 1);
  20936. };
  20937. /**
  20938. * Render a major tick into the given position. If a tick already exists
  20939. * in this position, move it.
  20940. *
  20941. * @function Highcharts.Axis#renderTick
  20942. *
  20943. * @param {number} pos
  20944. * The position in axis values.
  20945. *
  20946. * @param {number} i
  20947. * The tick index.
  20948. */
  20949. Axis.prototype.renderTick = function (pos, i) {
  20950. var axis = this,
  20951. isLinked = axis.isLinked,
  20952. ticks = axis.ticks,
  20953. slideInTicks = axis.chart.hasRendered && axis.old;
  20954. // Linked axes need an extra check to find out if
  20955. if (!isLinked ||
  20956. (pos >= axis.min && pos <= axis.max) ||
  20957. (axis.grid && axis.grid.isColumn)) {
  20958. if (!ticks[pos]) {
  20959. ticks[pos] = new Tick(axis, pos);
  20960. }
  20961. // NOTE this seems like overkill. Could be handled in tick.render by
  20962. // setting old position in attr, then set new position in animate.
  20963. // render new ticks in old position
  20964. if (slideInTicks && ticks[pos].isNew) {
  20965. // Start with negative opacity so that it is visible from
  20966. // halfway into the animation
  20967. ticks[pos].render(i, true, -1);
  20968. }
  20969. ticks[pos].render(i);
  20970. }
  20971. };
  20972. /**
  20973. * Render the axis.
  20974. *
  20975. * @private
  20976. * @function Highcharts.Axis#render
  20977. *
  20978. * @fires Highcharts.Axis#event:afterRender
  20979. */
  20980. Axis.prototype.render = function () {
  20981. var axis = this,
  20982. chart = axis.chart,
  20983. log = axis.logarithmic,
  20984. renderer = chart.renderer,
  20985. options = axis.options,
  20986. isLinked = axis.isLinked,
  20987. tickPositions = axis.tickPositions,
  20988. axisTitle = axis.axisTitle,
  20989. ticks = axis.ticks,
  20990. minorTicks = axis.minorTicks,
  20991. alternateBands = axis.alternateBands,
  20992. stackLabelOptions = options.stackLabels,
  20993. alternateGridColor = options.alternateGridColor,
  20994. tickmarkOffset = axis.tickmarkOffset,
  20995. axisLine = axis.axisLine,
  20996. showAxis = axis.showAxis,
  20997. animation = animObject(renderer.globalAnimation);
  20998. var from,
  20999. to;
  21000. // Reset
  21001. axis.labelEdge.length = 0;
  21002. axis.overlap = false;
  21003. // Mark all elements inActive before we go over and mark the active ones
  21004. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  21005. objectEach(coll, function (tick) {
  21006. tick.isActive = false;
  21007. });
  21008. });
  21009. // If the series has data draw the ticks. Else only the line and title
  21010. if (axis.hasData() || isLinked) {
  21011. // minor ticks
  21012. if (axis.minorTickInterval && !axis.categories) {
  21013. axis.getMinorTickPositions().forEach(function (pos) {
  21014. axis.renderMinorTick(pos);
  21015. });
  21016. }
  21017. // Major ticks. Pull out the first item and render it last so that
  21018. // we can get the position of the neighbour label. #808.
  21019. if (tickPositions.length) { // #1300
  21020. tickPositions.forEach(function (pos, i) {
  21021. axis.renderTick(pos, i);
  21022. });
  21023. // In a categorized axis, the tick marks are displayed
  21024. // between labels. So we need to add a tick mark and
  21025. // grid line at the left edge of the X axis.
  21026. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  21027. if (!ticks[-1]) {
  21028. ticks[-1] = new Tick(axis, -1, null, true);
  21029. }
  21030. ticks[-1].render(-1);
  21031. }
  21032. }
  21033. // alternate grid color
  21034. if (alternateGridColor) {
  21035. tickPositions.forEach(function (pos, i) {
  21036. to = typeof tickPositions[i + 1] !== 'undefined' ?
  21037. tickPositions[i + 1] + tickmarkOffset :
  21038. axis.max - tickmarkOffset;
  21039. if (i % 2 === 0 &&
  21040. pos < axis.max &&
  21041. to <= axis.max + (chart.polar ?
  21042. -tickmarkOffset :
  21043. tickmarkOffset)) { // #2248, #4660
  21044. if (!alternateBands[pos]) {
  21045. // Should be imported from PlotLineOrBand.js, but
  21046. // the dependency cycle with axis is a problem
  21047. alternateBands[pos] = new H.PlotLineOrBand(axis);
  21048. }
  21049. from = pos + tickmarkOffset; // #949
  21050. alternateBands[pos].options = {
  21051. from: log ? log.lin2log(from) : from,
  21052. to: log ? log.lin2log(to) : to,
  21053. color: alternateGridColor,
  21054. className: 'highcharts-alternate-grid'
  21055. };
  21056. alternateBands[pos].render();
  21057. alternateBands[pos].isActive = true;
  21058. }
  21059. });
  21060. }
  21061. // custom plot lines and bands
  21062. if (!axis._addedPlotLB) { // only first time
  21063. axis._addedPlotLB = true;
  21064. (options.plotLines || [])
  21065. .concat(options.plotBands || [])
  21066. .forEach(function (plotLineOptions) {
  21067. axis.addPlotBandOrLine(plotLineOptions);
  21068. });
  21069. }
  21070. } // end if hasData
  21071. // Remove inactive ticks
  21072. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  21073. var forDestruction = [],
  21074. delay = animation.duration,
  21075. destroyInactiveItems = function () {
  21076. var i = forDestruction.length;
  21077. while (i--) {
  21078. // When resizing rapidly, the same items
  21079. // may be destroyed in different timeouts,
  21080. // or the may be reactivated
  21081. if (coll[forDestruction[i]] &&
  21082. !coll[forDestruction[i]].isActive) {
  21083. coll[forDestruction[i]].destroy();
  21084. delete coll[forDestruction[i]];
  21085. }
  21086. }
  21087. };
  21088. objectEach(coll, function (tick, pos) {
  21089. if (!tick.isActive) {
  21090. // Render to zero opacity
  21091. tick.render(pos, false, 0);
  21092. tick.isActive = false;
  21093. forDestruction.push(pos);
  21094. }
  21095. });
  21096. // When the objects are finished fading out, destroy them
  21097. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  21098. !chart.hasRendered ||
  21099. !delay ?
  21100. 0 :
  21101. delay);
  21102. });
  21103. // Set the axis line path
  21104. if (axisLine) {
  21105. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  21106. d: this.getLinePath(axisLine.strokeWidth())
  21107. });
  21108. axisLine.isPlaced = true;
  21109. // Show or hide the line depending on options.showEmpty
  21110. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  21111. }
  21112. if (axisTitle && showAxis) {
  21113. var titleXy = axis.getTitlePosition();
  21114. if (isNumber(titleXy.y)) {
  21115. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  21116. axisTitle.isNew = false;
  21117. }
  21118. else {
  21119. axisTitle.attr('y', -9999);
  21120. axisTitle.isNew = true;
  21121. }
  21122. }
  21123. // Stacked totals:
  21124. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  21125. axis.stacking.renderStackTotals();
  21126. }
  21127. // End stacked totals
  21128. // Record old scaling for updating/animation
  21129. axis.old = {
  21130. len: axis.len,
  21131. max: axis.max,
  21132. min: axis.min,
  21133. transA: axis.transA,
  21134. userMax: axis.userMax,
  21135. userMin: axis.userMin
  21136. };
  21137. axis.isDirty = false;
  21138. fireEvent(this, 'afterRender');
  21139. };
  21140. /**
  21141. * Redraw the axis to reflect changes in the data or axis extremes. Called
  21142. * internally from Highcharts.Chart#redraw.
  21143. *
  21144. * @private
  21145. * @function Highcharts.Axis#redraw
  21146. */
  21147. Axis.prototype.redraw = function () {
  21148. if (this.visible) {
  21149. // render the axis
  21150. this.render();
  21151. // move plot lines and bands
  21152. this.plotLinesAndBands.forEach(function (plotLine) {
  21153. plotLine.render();
  21154. });
  21155. }
  21156. // mark associated series as dirty and ready for redraw
  21157. this.series.forEach(function (series) {
  21158. series.isDirty = true;
  21159. });
  21160. };
  21161. /**
  21162. * Returns an array of axis properties, that should be untouched during
  21163. * reinitialization.
  21164. *
  21165. * @private
  21166. * @function Highcharts.Axis#getKeepProps
  21167. *
  21168. * @return {Array<string>}
  21169. */
  21170. Axis.prototype.getKeepProps = function () {
  21171. return (this.keepProps || Axis.keepProps);
  21172. };
  21173. /**
  21174. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  21175. * to fully remove the axis.
  21176. *
  21177. * @private
  21178. * @function Highcharts.Axis#destroy
  21179. *
  21180. * @param {boolean} [keepEvents]
  21181. * Whether to preserve events, used internally in Axis.update.
  21182. */
  21183. Axis.prototype.destroy = function (keepEvents) {
  21184. var axis = this,
  21185. plotLinesAndBands = axis.plotLinesAndBands,
  21186. eventOptions = this.eventOptions;
  21187. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  21188. // Remove the events
  21189. if (!keepEvents) {
  21190. removeEvent(axis);
  21191. }
  21192. // Destroy collections
  21193. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  21194. destroyObjectProperties(coll);
  21195. });
  21196. if (plotLinesAndBands) {
  21197. var i = plotLinesAndBands.length;
  21198. while (i--) { // #1975
  21199. plotLinesAndBands[i].destroy();
  21200. }
  21201. }
  21202. // Destroy elements
  21203. ['axisLine', 'axisTitle', 'axisGroup',
  21204. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  21205. if (axis[prop]) {
  21206. axis[prop] = axis[prop].destroy();
  21207. }
  21208. });
  21209. // Destroy each generated group for plotlines and plotbands
  21210. for (var plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  21211. axis.plotLinesAndBandsGroups[plotGroup] =
  21212. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  21213. }
  21214. // Delete all properties and fall back to the prototype.
  21215. objectEach(axis, function (val, key) {
  21216. if (axis.getKeepProps().indexOf(key) === -1) {
  21217. delete axis[key];
  21218. }
  21219. });
  21220. this.eventOptions = eventOptions;
  21221. };
  21222. /**
  21223. * Internal function to draw a crosshair.
  21224. *
  21225. * @function Highcharts.Axis#drawCrosshair
  21226. *
  21227. * @param {Highcharts.PointerEventObject} [e]
  21228. * The event arguments from the modified pointer event, extended with
  21229. * `chartX` and `chartY`
  21230. *
  21231. * @param {Highcharts.Point} [point]
  21232. * The Point object if the crosshair snaps to points.
  21233. *
  21234. * @fires Highcharts.Axis#event:afterDrawCrosshair
  21235. * @fires Highcharts.Axis#event:drawCrosshair
  21236. */
  21237. Axis.prototype.drawCrosshair = function (e, point) {
  21238. var options = this.crosshair,
  21239. snap = pick(options && options.snap,
  21240. true),
  21241. chart = this.chart;
  21242. var path,
  21243. pos,
  21244. categorized,
  21245. graphic = this.cross,
  21246. crossOptions;
  21247. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  21248. // Use last available event when updating non-snapped crosshairs without
  21249. // mouse interaction (#5287)
  21250. if (!e) {
  21251. e = this.cross && this.cross.e;
  21252. }
  21253. if (
  21254. // Disabled in options
  21255. !options ||
  21256. // Snap
  21257. ((defined(point) || !snap) === false)) {
  21258. this.hideCrosshair();
  21259. }
  21260. else {
  21261. // Get the path
  21262. if (!snap) {
  21263. pos = e &&
  21264. (this.horiz ?
  21265. e.chartX - this.pos :
  21266. this.len - e.chartY + this.pos);
  21267. }
  21268. else if (defined(point)) {
  21269. // #3834
  21270. pos = pick(this.coll !== 'colorAxis' ?
  21271. point.crosshairPos : // 3D axis extension
  21272. null, this.isXAxis ?
  21273. point.plotX :
  21274. this.len - point.plotY);
  21275. }
  21276. if (defined(pos)) {
  21277. crossOptions = {
  21278. // value, only used on radial
  21279. value: point && (this.isXAxis ?
  21280. point.x :
  21281. pick(point.stackY, point.y)),
  21282. translatedValue: pos
  21283. };
  21284. if (chart.polar) {
  21285. // Additional information required for crosshairs in
  21286. // polar chart
  21287. extend(crossOptions, {
  21288. isCrosshair: true,
  21289. chartX: e && e.chartX,
  21290. chartY: e && e.chartY,
  21291. point: point
  21292. });
  21293. }
  21294. path = this.getPlotLinePath(crossOptions) ||
  21295. null; // #3189
  21296. }
  21297. if (!defined(path)) {
  21298. this.hideCrosshair();
  21299. return;
  21300. }
  21301. categorized = this.categories && !this.isRadial;
  21302. // Draw the cross
  21303. if (!graphic) {
  21304. this.cross = graphic = chart.renderer
  21305. .path()
  21306. .addClass('highcharts-crosshair highcharts-crosshair-' +
  21307. (categorized ? 'category ' : 'thin ') +
  21308. (options.className || ''))
  21309. .attr({
  21310. zIndex: pick(options.zIndex, 2)
  21311. })
  21312. .add();
  21313. // Presentational attributes
  21314. if (!chart.styledMode) {
  21315. graphic.attr({
  21316. stroke: options.color ||
  21317. (categorized ?
  21318. Color
  21319. .parse(Palette.highlightColor20)
  21320. .setOpacity(0.25)
  21321. .get() :
  21322. Palette.neutralColor20),
  21323. 'stroke-width': pick(options.width, 1)
  21324. }).css({
  21325. 'pointer-events': 'none'
  21326. });
  21327. if (options.dashStyle) {
  21328. graphic.attr({
  21329. dashstyle: options.dashStyle
  21330. });
  21331. }
  21332. }
  21333. }
  21334. graphic.show().attr({
  21335. d: path
  21336. });
  21337. if (categorized && !options.width) {
  21338. graphic.attr({
  21339. 'stroke-width': this.transA
  21340. });
  21341. }
  21342. this.cross.e = e;
  21343. }
  21344. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  21345. };
  21346. /**
  21347. * Hide the crosshair if visible.
  21348. *
  21349. * @function Highcharts.Axis#hideCrosshair
  21350. */
  21351. Axis.prototype.hideCrosshair = function () {
  21352. if (this.cross) {
  21353. this.cross.hide();
  21354. }
  21355. fireEvent(this, 'afterHideCrosshair');
  21356. };
  21357. /**
  21358. * Check whether the chart has vertical panning ('y' or 'xy' type).
  21359. *
  21360. * @private
  21361. * @function Highcharts.Axis#hasVerticalPanning
  21362. *
  21363. * @return {boolean}
  21364. */
  21365. Axis.prototype.hasVerticalPanning = function () {
  21366. var panningOptions = this.chart.options.chart.panning;
  21367. return Boolean(panningOptions &&
  21368. panningOptions.enabled && // #14624
  21369. /y/.test(panningOptions.type));
  21370. };
  21371. /**
  21372. * Check whether the given value is a positive valid axis value.
  21373. *
  21374. * @private
  21375. * @function Highcharts.Axis#validatePositiveValue
  21376. *
  21377. * @param {unknown} value
  21378. * The axis value
  21379. *
  21380. * @return {boolean}
  21381. */
  21382. Axis.prototype.validatePositiveValue = function (value) {
  21383. return isNumber(value) && value > 0;
  21384. };
  21385. /**
  21386. * Update an axis object with a new set of options. The options are merged
  21387. * with the existing options, so only new or altered options need to be
  21388. * specified.
  21389. *
  21390. * @sample highcharts/members/axis-update/
  21391. * Axis update demo
  21392. *
  21393. * @function Highcharts.Axis#update
  21394. *
  21395. * @param {Highcharts.AxisOptions} options
  21396. * The new options that will be merged in with existing options on the axis.
  21397. *
  21398. * @param {boolean} [redraw=true]
  21399. * Whether to redraw the chart after the axis is altered. If doing more
  21400. * operations on the chart, it is a good idea to set redraw to false and
  21401. * call {@link Chart#redraw} after.
  21402. */
  21403. Axis.prototype.update = function (options, redraw) {
  21404. var chart = this.chart;
  21405. options = merge(this.userOptions, options);
  21406. this.destroy(true);
  21407. this.init(chart, options);
  21408. chart.isDirtyBox = true;
  21409. if (pick(redraw, true)) {
  21410. chart.redraw();
  21411. }
  21412. };
  21413. /**
  21414. * Remove the axis from the chart.
  21415. *
  21416. * @sample highcharts/members/chart-addaxis/
  21417. * Add and remove axes
  21418. *
  21419. * @function Highcharts.Axis#remove
  21420. *
  21421. * @param {boolean} [redraw=true]
  21422. * Whether to redraw the chart following the remove.
  21423. */
  21424. Axis.prototype.remove = function (redraw) {
  21425. var chart = this.chart,
  21426. key = this.coll, // xAxis or yAxis
  21427. axisSeries = this.series;
  21428. var i = axisSeries.length;
  21429. // Remove associated series (#2687)
  21430. while (i--) {
  21431. if (axisSeries[i]) {
  21432. axisSeries[i].remove(false);
  21433. }
  21434. }
  21435. // Remove the axis
  21436. erase(chart.axes, this);
  21437. erase(chart[key], this);
  21438. chart[key].forEach(function (axis, i) {
  21439. // Re-index, #1706, #8075
  21440. axis.options.index = axis.userOptions.index = i;
  21441. });
  21442. this.destroy();
  21443. chart.isDirtyBox = true;
  21444. if (pick(redraw, true)) {
  21445. chart.redraw();
  21446. }
  21447. };
  21448. /**
  21449. * Update the axis title by options after render time.
  21450. *
  21451. * @sample highcharts/members/axis-settitle/
  21452. * Set a new Y axis title
  21453. *
  21454. * @function Highcharts.Axis#setTitle
  21455. *
  21456. * @param {Highcharts.AxisTitleOptions} titleOptions
  21457. * The additional title options.
  21458. *
  21459. * @param {boolean} [redraw=true]
  21460. * Whether to redraw the chart after setting the title.
  21461. */
  21462. Axis.prototype.setTitle = function (titleOptions, redraw) {
  21463. this.update({ title: titleOptions }, redraw);
  21464. };
  21465. /**
  21466. * Set new axis categories and optionally redraw.
  21467. *
  21468. * @sample highcharts/members/axis-setcategories/
  21469. * Set categories by click on a button
  21470. *
  21471. * @function Highcharts.Axis#setCategories
  21472. *
  21473. * @param {Array<string>} categories
  21474. * The new categories.
  21475. *
  21476. * @param {boolean} [redraw=true]
  21477. * Whether to redraw the chart.
  21478. */
  21479. Axis.prototype.setCategories = function (categories, redraw) {
  21480. this.update({ categories: categories }, redraw);
  21481. };
  21482. /* *
  21483. *
  21484. * Static Properties
  21485. *
  21486. * */
  21487. Axis.defaultOptions = AxisDefaults.defaultXAxisOptions;
  21488. // Properties to survive after destroy, needed for Axis.update (#4317,
  21489. // #5773, #5881).
  21490. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  21491. return Axis;
  21492. }());
  21493. /* *
  21494. *
  21495. * Default Export
  21496. *
  21497. * */
  21498. /* *
  21499. *
  21500. * API Declarations
  21501. *
  21502. * */
  21503. /**
  21504. * Options for the path on the Axis to be calculated.
  21505. * @interface Highcharts.AxisPlotLinePathOptionsObject
  21506. */ /**
  21507. * Axis value.
  21508. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  21509. * @type {number|undefined}
  21510. */ /**
  21511. * Line width used for calculation crisp line coordinates. Defaults to 1.
  21512. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  21513. * @type {number|undefined}
  21514. */ /**
  21515. * If `false`, the function will return null when it falls outside the axis
  21516. * bounds. If `true`, the function will return a path aligned to the plot area
  21517. * sides if it falls outside. If `pass`, it will return a path outside.
  21518. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  21519. * @type {string|boolean|undefined}
  21520. */ /**
  21521. * Used in Highcharts Stock. When `true`, plot paths
  21522. * (crosshair, plotLines, gridLines)
  21523. * will be rendered on all axes when defined on the first axis.
  21524. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  21525. * @type {boolean|undefined}
  21526. */ /**
  21527. * Use old coordinates (for resizing and rescaling).
  21528. * If not set, defaults to `false`.
  21529. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  21530. * @type {boolean|undefined}
  21531. */ /**
  21532. * If given, return the plot line path of a pixel position on the axis.
  21533. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  21534. * @type {number|undefined}
  21535. */ /**
  21536. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  21537. * plot bands
  21538. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  21539. * @type {boolean|undefined}
  21540. */
  21541. /**
  21542. * Options for crosshairs on axes.
  21543. *
  21544. * @product highstock
  21545. *
  21546. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  21547. */
  21548. /**
  21549. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  21550. */
  21551. /**
  21552. * @callback Highcharts.AxisEventCallbackFunction
  21553. *
  21554. * @param {Highcharts.Axis} this
  21555. */
  21556. /**
  21557. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  21558. *
  21559. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  21560. *
  21561. * @param {Highcharts.AxisLabelsFormatterContextObject} ctx
  21562. *
  21563. * @return {string}
  21564. */
  21565. /**
  21566. * @interface Highcharts.AxisLabelsFormatterContextObject
  21567. */ /**
  21568. * The axis item of the label
  21569. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  21570. * @type {Highcharts.Axis}
  21571. */ /**
  21572. * The chart instance.
  21573. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  21574. * @type {Highcharts.Chart}
  21575. */ /**
  21576. * Whether the label belongs to the first tick on the axis.
  21577. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  21578. * @type {boolean}
  21579. */ /**
  21580. * Whether the label belongs to the last tick on the axis.
  21581. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  21582. * @type {boolean}
  21583. */ /**
  21584. * The position on the axis in terms of axis values. For category axes, a
  21585. * zero-based index. For datetime axes, the JavaScript time in milliseconds
  21586. * since 1970.
  21587. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  21588. * @type {number}
  21589. */ /**
  21590. * The preformatted text as the result of the default formatting. For example
  21591. * dates will be formatted as strings, and numbers with language-specific comma
  21592. * separators, thousands separators and numeric symbols like `k` or `M`.
  21593. * @name Highcharts.AxisLabelsFormatterContextObject#text
  21594. * @type {string}
  21595. */ /**
  21596. * The Tick instance.
  21597. * @name Highcharts.AxisLabelsFormatterContextObject#tick
  21598. * @type {Highcharts.Tick}
  21599. */ /**
  21600. * This can be either a numeric value or a category string.
  21601. * @name Highcharts.AxisLabelsFormatterContextObject#value
  21602. * @type {number|string}
  21603. */
  21604. /**
  21605. * Options for axes.
  21606. *
  21607. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  21608. */
  21609. /**
  21610. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  21611. *
  21612. * @param {Highcharts.Axis} this
  21613. *
  21614. * @param {Highcharts.AxisPointBreakEventObject} evt
  21615. */
  21616. /**
  21617. * @interface Highcharts.AxisPointBreakEventObject
  21618. */ /**
  21619. * @name Highcharts.AxisPointBreakEventObject#brk
  21620. * @type {Highcharts.Dictionary<number>}
  21621. */ /**
  21622. * @name Highcharts.AxisPointBreakEventObject#point
  21623. * @type {Highcharts.Point}
  21624. */ /**
  21625. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  21626. * @type {Function}
  21627. */ /**
  21628. * @name Highcharts.AxisPointBreakEventObject#target
  21629. * @type {Highcharts.SVGElement}
  21630. */ /**
  21631. * @name Highcharts.AxisPointBreakEventObject#type
  21632. * @type {"pointBreak"|"pointInBreak"}
  21633. */
  21634. /**
  21635. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  21636. *
  21637. * @param {Highcharts.Axis} this
  21638. *
  21639. * @param {Highcharts.AxisSetExtremesEventObject} evt
  21640. */
  21641. /**
  21642. * @interface Highcharts.AxisSetExtremesEventObject
  21643. * @extends Highcharts.ExtremesObject
  21644. */ /**
  21645. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  21646. * @type {Function}
  21647. */ /**
  21648. * @name Highcharts.AxisSetExtremesEventObject#target
  21649. * @type {Highcharts.SVGElement}
  21650. */ /**
  21651. * @name Highcharts.AxisSetExtremesEventObject#trigger
  21652. * @type {Highcharts.AxisExtremesTriggerValue|string}
  21653. */ /**
  21654. * @name Highcharts.AxisSetExtremesEventObject#type
  21655. * @type {"setExtremes"}
  21656. */
  21657. /**
  21658. * @callback Highcharts.AxisTickPositionerCallbackFunction
  21659. *
  21660. * @param {Highcharts.Axis} this
  21661. *
  21662. * @return {Highcharts.AxisTickPositionsArray}
  21663. */
  21664. /**
  21665. * @interface Highcharts.AxisTickPositionsArray
  21666. * @augments Array<number>
  21667. */
  21668. /**
  21669. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  21670. */
  21671. /**
  21672. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  21673. */
  21674. /**
  21675. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  21676. */
  21677. /**
  21678. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  21679. * function.
  21680. *
  21681. * @interface Highcharts.ExtremesObject
  21682. */ /**
  21683. * The maximum value of the axis' associated series.
  21684. * @name Highcharts.ExtremesObject#dataMax
  21685. * @type {number}
  21686. */ /**
  21687. * The minimum value of the axis' associated series.
  21688. * @name Highcharts.ExtremesObject#dataMin
  21689. * @type {number}
  21690. */ /**
  21691. * The maximum axis value, either automatic or set manually. If the `max` option
  21692. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  21693. * the same as `dataMax`.
  21694. * @name Highcharts.ExtremesObject#max
  21695. * @type {number}
  21696. */ /**
  21697. * The minimum axis value, either automatic or set manually. If the `min` option
  21698. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  21699. * the same as `dataMin`.
  21700. * @name Highcharts.ExtremesObject#min
  21701. * @type {number}
  21702. */ /**
  21703. * The user defined maximum, either from the `max` option or from a zoom or
  21704. * `setExtremes` action.
  21705. * @name Highcharts.ExtremesObject#userMax
  21706. * @type {number}
  21707. */ /**
  21708. * The user defined minimum, either from the `min` option or from a zoom or
  21709. * `setExtremes` action.
  21710. * @name Highcharts.ExtremesObject#userMin
  21711. * @type {number}
  21712. */
  21713. /**
  21714. * Formatter function for the text of a crosshair label.
  21715. *
  21716. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  21717. *
  21718. * @param {Highcharts.Axis} this
  21719. * Axis context
  21720. *
  21721. * @param {number} value
  21722. * Y value of the data point
  21723. *
  21724. * @return {string}
  21725. */
  21726. ''; // keeps doclets above in JS file
  21727. return Axis;
  21728. });
  21729. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21730. /* *
  21731. *
  21732. * (c) 2010-2021 Torstein Honsi
  21733. *
  21734. * License: www.highcharts.com/license
  21735. *
  21736. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21737. *
  21738. * */
  21739. var addEvent = U.addEvent,
  21740. getMagnitude = U.getMagnitude,
  21741. normalizeTickInterval = U.normalizeTickInterval,
  21742. timeUnits = U.timeUnits;
  21743. /* eslint-disable valid-jsdoc */
  21744. var DateTimeAxisAdditions = /** @class */ (function () {
  21745. /* *
  21746. *
  21747. * Constructors
  21748. *
  21749. * */
  21750. function DateTimeAxisAdditions(axis) {
  21751. this.axis = axis;
  21752. }
  21753. /* *
  21754. *
  21755. * Functions
  21756. *
  21757. * */
  21758. /**
  21759. * Get a normalized tick interval for dates. Returns a configuration object
  21760. * with unit range (interval), count and name. Used to prepare data for
  21761. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21762. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21763. * logic was extracted in order to prevent it for running over again for
  21764. * each segment having the same interval. #662, #697.
  21765. * @private
  21766. */
  21767. /**
  21768. * Get a normalized tick interval for dates. Returns a configuration object
  21769. * with unit range (interval), count and name. Used to prepare data for
  21770. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21771. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21772. * logic was extracted in order to prevent it for running over again for
  21773. * each segment having the same interval. #662, #697.
  21774. * @private
  21775. */
  21776. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  21777. var units = unitsOption || [[
  21778. 'millisecond',
  21779. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  21780. ],
  21781. [
  21782. 'second',
  21783. [1, 2, 5, 10, 15, 30]
  21784. ],
  21785. [
  21786. 'minute',
  21787. [1, 2, 5, 10, 15, 30]
  21788. ],
  21789. [
  21790. 'hour',
  21791. [1, 2, 3, 4, 6, 8, 12]
  21792. ],
  21793. [
  21794. 'day',
  21795. [1, 2]
  21796. ],
  21797. [
  21798. 'week',
  21799. [1, 2]
  21800. ],
  21801. [
  21802. 'month',
  21803. [1, 2, 3, 4, 6]
  21804. ],
  21805. [
  21806. 'year',
  21807. null
  21808. ]],
  21809. unit = units[units.length - 1], // default unit is years
  21810. interval = timeUnits[unit[0]],
  21811. multiples = unit[1],
  21812. count,
  21813. i;
  21814. // loop through the units to find the one that best fits the
  21815. // tickInterval
  21816. for (i = 0; i < units.length; i++) {
  21817. unit = units[i];
  21818. interval = timeUnits[unit[0]];
  21819. multiples = unit[1];
  21820. if (units[i + 1]) {
  21821. // lessThan is in the middle between the highest multiple and
  21822. // the next unit.
  21823. var lessThan = (interval *
  21824. multiples[multiples.length - 1] +
  21825. timeUnits[units[i + 1][0]]) / 2;
  21826. // break and keep the current unit
  21827. if (tickInterval <= lessThan) {
  21828. break;
  21829. }
  21830. }
  21831. }
  21832. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  21833. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  21834. multiples = [1, 2, 5];
  21835. }
  21836. // get the count
  21837. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  21838. Math.max(getMagnitude(tickInterval / interval), 1) :
  21839. 1);
  21840. return {
  21841. unitRange: interval,
  21842. count: count,
  21843. unitName: unit[0]
  21844. };
  21845. };
  21846. return DateTimeAxisAdditions;
  21847. }());
  21848. /**
  21849. * Date and time support for axes.
  21850. *
  21851. * @private
  21852. * @class
  21853. */
  21854. var DateTimeAxis = /** @class */ (function () {
  21855. function DateTimeAxis() {
  21856. }
  21857. /* *
  21858. *
  21859. * Static Functions
  21860. *
  21861. * */
  21862. /**
  21863. * Extends axis class with date and time support.
  21864. * @private
  21865. */
  21866. DateTimeAxis.compose = function (AxisClass) {
  21867. AxisClass.keepProps.push('dateTime');
  21868. var axisProto = AxisClass.prototype;
  21869. /**
  21870. * Set the tick positions to a time unit that makes sense, for example
  21871. * on the first of each month or on every Monday. Return an array with
  21872. * the time positions. Used in datetime axes as well as for grouping
  21873. * data on a datetime axis.
  21874. *
  21875. * @private
  21876. * @function Highcharts.Axis#getTimeTicks
  21877. *
  21878. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  21879. * The interval in axis values (ms) and thecount.
  21880. *
  21881. * @param {number} min
  21882. * The minimum in axis values.
  21883. *
  21884. * @param {number} max
  21885. * The maximum in axis values.
  21886. *
  21887. * @param {number} startOfWeek
  21888. *
  21889. * @return {Highcharts.AxisTickPositionsArray}
  21890. */
  21891. axisProto.getTimeTicks = function () {
  21892. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  21893. };
  21894. /* eslint-disable no-invalid-this */
  21895. addEvent(AxisClass, 'init', function (e) {
  21896. var axis = this;
  21897. var options = e.userOptions;
  21898. if (options.type !== 'datetime') {
  21899. axis.dateTime = void 0;
  21900. return;
  21901. }
  21902. if (!axis.dateTime) {
  21903. axis.dateTime = new DateTimeAxisAdditions(axis);
  21904. }
  21905. });
  21906. /* eslint-enable no-invalid-this */
  21907. };
  21908. /* *
  21909. *
  21910. * Static Properties
  21911. *
  21912. * */
  21913. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  21914. return DateTimeAxis;
  21915. }());
  21916. DateTimeAxis.compose(Axis);
  21917. return DateTimeAxis;
  21918. });
  21919. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21920. /* *
  21921. *
  21922. * (c) 2010-2021 Torstein Honsi
  21923. *
  21924. * License: www.highcharts.com/license
  21925. *
  21926. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21927. *
  21928. * */
  21929. var addEvent = U.addEvent,
  21930. getMagnitude = U.getMagnitude,
  21931. normalizeTickInterval = U.normalizeTickInterval,
  21932. pick = U.pick;
  21933. /* eslint-disable valid-jsdoc */
  21934. /**
  21935. * Provides logarithmic support for axes.
  21936. *
  21937. * @private
  21938. * @class
  21939. */
  21940. var LogarithmicAxisAdditions = /** @class */ (function () {
  21941. /* *
  21942. *
  21943. * Constructors
  21944. *
  21945. * */
  21946. function LogarithmicAxisAdditions(axis) {
  21947. this.axis = axis;
  21948. }
  21949. /* *
  21950. *
  21951. * Functions
  21952. *
  21953. * */
  21954. /**
  21955. * Set the tick positions of a logarithmic axis.
  21956. */
  21957. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  21958. var log = this;
  21959. var axis = log.axis;
  21960. var axisLength = axis.len;
  21961. var options = axis.options;
  21962. // Since we use this method for both major and minor ticks,
  21963. // use a local variable and return the result
  21964. var positions = [];
  21965. // Reset
  21966. if (!minor) {
  21967. log.minorAutoInterval = void 0;
  21968. }
  21969. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  21970. if (interval >= 0.5) {
  21971. interval = Math.round(interval);
  21972. positions = axis.getLinearTickPositions(interval, min, max);
  21973. // Second case: We need intermediary ticks. For example
  21974. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  21975. }
  21976. else if (interval >= 0.08) {
  21977. var roundedMin = Math.floor(min),
  21978. intermediate = void 0,
  21979. i = void 0,
  21980. j = void 0,
  21981. len = void 0,
  21982. pos = void 0,
  21983. lastPos = void 0,
  21984. break2 = void 0;
  21985. if (interval > 0.3) {
  21986. intermediate = [1, 2, 4];
  21987. // 0.2 equals five minor ticks per 1, 10, 100 etc
  21988. }
  21989. else if (interval > 0.15) {
  21990. intermediate = [1, 2, 4, 6, 8];
  21991. }
  21992. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  21993. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  21994. }
  21995. for (i = roundedMin; i < max + 1 && !break2; i++) {
  21996. len = intermediate.length;
  21997. for (j = 0; j < len && !break2; j++) {
  21998. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  21999. // #1670, lastPos is #3113
  22000. if (pos > min &&
  22001. (!minor || lastPos <= max) &&
  22002. typeof lastPos !== 'undefined') {
  22003. positions.push(lastPos);
  22004. }
  22005. if (lastPos > max) {
  22006. break2 = true;
  22007. }
  22008. lastPos = pos;
  22009. }
  22010. }
  22011. // Third case: We are so deep in between whole logarithmic values that
  22012. // we might as well handle the tick positions like a linear axis. For
  22013. // example 1.01, 1.02, 1.03, 1.04.
  22014. }
  22015. else {
  22016. var realMin = log.lin2log(min),
  22017. realMax = log.lin2log(max),
  22018. tickIntervalOption = minor ?
  22019. axis.getMinorTickInterval() :
  22020. options.tickInterval,
  22021. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  22022. null :
  22023. tickIntervalOption,
  22024. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  22025. totalPixelLength = minor ?
  22026. axisLength / axis.tickPositions.length :
  22027. axisLength;
  22028. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  22029. tickPixelIntervalOption / (totalPixelLength || 1));
  22030. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  22031. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  22032. if (!minor) {
  22033. log.minorAutoInterval = interval / 5;
  22034. }
  22035. }
  22036. // Set the axis-level tickInterval variable
  22037. if (!minor) {
  22038. axis.tickInterval = interval;
  22039. }
  22040. return positions;
  22041. };
  22042. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  22043. return Math.pow(10, num);
  22044. };
  22045. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  22046. return Math.log(num) / Math.LN10;
  22047. };
  22048. return LogarithmicAxisAdditions;
  22049. }());
  22050. var LogarithmicAxis = /** @class */ (function () {
  22051. function LogarithmicAxis() {
  22052. }
  22053. /**
  22054. * Provides logarithmic support for axes.
  22055. *
  22056. * @private
  22057. */
  22058. LogarithmicAxis.compose = function (AxisClass) {
  22059. AxisClass.keepProps.push('logarithmic');
  22060. /* eslint-disable no-invalid-this */
  22061. addEvent(AxisClass, 'init', function (e) {
  22062. var axis = this;
  22063. var options = e.userOptions;
  22064. var logarithmic = axis.logarithmic;
  22065. if (options.type !== 'logarithmic') {
  22066. axis.logarithmic = void 0;
  22067. }
  22068. else {
  22069. if (!logarithmic) {
  22070. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  22071. }
  22072. }
  22073. });
  22074. addEvent(AxisClass, 'afterInit', function () {
  22075. var axis = this;
  22076. var log = axis.logarithmic;
  22077. // extend logarithmic axis
  22078. if (log) {
  22079. axis.lin2val = function (num) {
  22080. return log.lin2log(num);
  22081. };
  22082. axis.val2lin = function (num) {
  22083. return log.log2lin(num);
  22084. };
  22085. }
  22086. });
  22087. };
  22088. return LogarithmicAxis;
  22089. }());
  22090. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  22091. return LogarithmicAxis;
  22092. });
  22093. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (Axis, palette, U) {
  22094. /* *
  22095. *
  22096. * (c) 2010-2021 Torstein Honsi
  22097. *
  22098. * License: www.highcharts.com/license
  22099. *
  22100. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22101. *
  22102. * */
  22103. /**
  22104. * Options for plot bands on axes.
  22105. *
  22106. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  22107. */
  22108. /**
  22109. * Options for plot band labels on axes.
  22110. *
  22111. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  22112. */
  22113. /**
  22114. * Options for plot lines on axes.
  22115. *
  22116. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  22117. */
  22118. /**
  22119. * Options for plot line labels on axes.
  22120. *
  22121. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  22122. */
  22123. var arrayMax = U.arrayMax,
  22124. arrayMin = U.arrayMin,
  22125. defined = U.defined,
  22126. destroyObjectProperties = U.destroyObjectProperties,
  22127. erase = U.erase,
  22128. extend = U.extend,
  22129. fireEvent = U.fireEvent,
  22130. isNumber = U.isNumber,
  22131. merge = U.merge,
  22132. objectEach = U.objectEach,
  22133. pick = U.pick;
  22134. /* eslint-disable no-invalid-this, valid-jsdoc */
  22135. /**
  22136. * The object wrapper for plot lines and plot bands
  22137. *
  22138. * @class
  22139. * @name Highcharts.PlotLineOrBand
  22140. *
  22141. * @param {Highcharts.Axis} axis
  22142. *
  22143. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  22144. */
  22145. var PlotLineOrBand = /** @class */ (function () {
  22146. function PlotLineOrBand(axis, options) {
  22147. this.axis = axis;
  22148. if (options) {
  22149. this.options = options;
  22150. this.id = options.id;
  22151. }
  22152. }
  22153. /**
  22154. * Render the plot line or plot band. If it is already existing,
  22155. * move it.
  22156. *
  22157. * @private
  22158. * @function Highcharts.PlotLineOrBand#render
  22159. * @return {Highcharts.PlotLineOrBand|undefined}
  22160. */
  22161. PlotLineOrBand.prototype.render = function () {
  22162. fireEvent(this, 'render');
  22163. var plotLine = this,
  22164. axis = plotLine.axis,
  22165. horiz = axis.horiz,
  22166. log = axis.logarithmic,
  22167. options = plotLine.options,
  22168. optionsLabel = options.label,
  22169. label = plotLine.label,
  22170. to = options.to,
  22171. from = options.from,
  22172. value = options.value,
  22173. isBand = defined(from) && defined(to),
  22174. isLine = defined(value),
  22175. svgElem = plotLine.svgElem,
  22176. isNew = !svgElem,
  22177. path = [],
  22178. color = options.color,
  22179. zIndex = pick(options.zIndex, 0),
  22180. events = options.events,
  22181. attribs = {
  22182. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  22183. (options.className || '')
  22184. },
  22185. groupAttribs = {},
  22186. renderer = axis.chart.renderer,
  22187. groupName = isBand ? 'bands' : 'lines',
  22188. group;
  22189. // logarithmic conversion
  22190. if (log) {
  22191. from = log.log2lin(from);
  22192. to = log.log2lin(to);
  22193. value = log.log2lin(value);
  22194. }
  22195. // Set the presentational attributes
  22196. if (!axis.chart.styledMode) {
  22197. if (isLine) {
  22198. attribs.stroke = color || palette.neutralColor40;
  22199. attribs['stroke-width'] = pick(options.width, 1);
  22200. if (options.dashStyle) {
  22201. attribs.dashstyle =
  22202. options.dashStyle;
  22203. }
  22204. }
  22205. else if (isBand) { // plot band
  22206. attribs.fill = color || palette.highlightColor10;
  22207. if (options.borderWidth) {
  22208. attribs.stroke = options.borderColor;
  22209. attribs['stroke-width'] = options.borderWidth;
  22210. }
  22211. }
  22212. }
  22213. // Grouping and zIndex
  22214. groupAttribs.zIndex = zIndex;
  22215. groupName += '-' + zIndex;
  22216. group = axis.plotLinesAndBandsGroups[groupName];
  22217. if (!group) {
  22218. axis.plotLinesAndBandsGroups[groupName] = group =
  22219. renderer.g('plot-' + groupName)
  22220. .attr(groupAttribs).add();
  22221. }
  22222. // Create the path
  22223. if (isNew) {
  22224. /**
  22225. * SVG element of the plot line or band.
  22226. *
  22227. * @name Highcharts.PlotLineOrBand#svgElement
  22228. * @type {Highcharts.SVGElement}
  22229. */
  22230. plotLine.svgElem = svgElem = renderer
  22231. .path()
  22232. .attr(attribs)
  22233. .add(group);
  22234. }
  22235. // Set the path or return
  22236. if (isLine) {
  22237. path = axis.getPlotLinePath({
  22238. value: value,
  22239. lineWidth: svgElem.strokeWidth(),
  22240. acrossPanes: options.acrossPanes
  22241. });
  22242. }
  22243. else if (isBand) { // plot band
  22244. path = axis.getPlotBandPath(from, to, options);
  22245. }
  22246. else {
  22247. return;
  22248. }
  22249. // common for lines and bands
  22250. // Add events only if they were not added before.
  22251. if (!plotLine.eventsAdded && events) {
  22252. objectEach(events, function (event, eventType) {
  22253. svgElem.on(eventType, function (e) {
  22254. events[eventType].apply(plotLine, [e]);
  22255. });
  22256. });
  22257. plotLine.eventsAdded = true;
  22258. }
  22259. if ((isNew || !svgElem.d) && path && path.length) {
  22260. svgElem.attr({ d: path });
  22261. }
  22262. else if (svgElem) {
  22263. if (path) {
  22264. svgElem.show(true);
  22265. svgElem.animate({ d: path });
  22266. }
  22267. else if (svgElem.d) {
  22268. svgElem.hide();
  22269. if (label) {
  22270. plotLine.label = label = label.destroy();
  22271. }
  22272. }
  22273. }
  22274. // the plot band/line label
  22275. if (optionsLabel &&
  22276. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  22277. path &&
  22278. path.length &&
  22279. axis.width > 0 &&
  22280. axis.height > 0 &&
  22281. !path.isFlat) {
  22282. // apply defaults
  22283. optionsLabel = merge({
  22284. align: horiz && isBand && 'center',
  22285. x: horiz ? !isBand && 4 : 10,
  22286. verticalAlign: !horiz && isBand && 'middle',
  22287. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  22288. rotation: horiz && !isBand && 90
  22289. }, optionsLabel);
  22290. this.renderLabel(optionsLabel, path, isBand, zIndex);
  22291. }
  22292. else if (label) { // move out of sight
  22293. label.hide();
  22294. }
  22295. // chainable
  22296. return plotLine;
  22297. };
  22298. /**
  22299. * Render and align label for plot line or band.
  22300. *
  22301. * @private
  22302. * @function Highcharts.PlotLineOrBand#renderLabel
  22303. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  22304. * @param {Highcharts.SVGPathArray} path
  22305. * @param {boolean} [isBand]
  22306. * @param {number} [zIndex]
  22307. * @return {void}
  22308. */
  22309. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  22310. var plotLine = this,
  22311. label = plotLine.label,
  22312. renderer = plotLine.axis.chart.renderer,
  22313. attribs,
  22314. xBounds,
  22315. yBounds,
  22316. x,
  22317. y,
  22318. labelText;
  22319. // add the SVG element
  22320. if (!label) {
  22321. attribs = {
  22322. align: optionsLabel.textAlign || optionsLabel.align,
  22323. rotation: optionsLabel.rotation,
  22324. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  22325. '-label ' + (optionsLabel.className || '')
  22326. };
  22327. attribs.zIndex = zIndex;
  22328. labelText = this.getLabelText(optionsLabel);
  22329. /**
  22330. * SVG element of the label.
  22331. *
  22332. * @name Highcharts.PlotLineOrBand#label
  22333. * @type {Highcharts.SVGElement}
  22334. */
  22335. plotLine.label = label = renderer
  22336. .text(labelText, 0, 0, optionsLabel.useHTML)
  22337. .attr(attribs)
  22338. .add();
  22339. if (!this.axis.chart.styledMode) {
  22340. label.css(optionsLabel.style);
  22341. }
  22342. }
  22343. // get the bounding box and align the label
  22344. // #3000 changed to better handle choice between plotband or plotline
  22345. xBounds = path.xBounds ||
  22346. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  22347. yBounds = path.yBounds ||
  22348. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  22349. x = arrayMin(xBounds);
  22350. y = arrayMin(yBounds);
  22351. label.align(optionsLabel, false, {
  22352. x: x,
  22353. y: y,
  22354. width: arrayMax(xBounds) - x,
  22355. height: arrayMax(yBounds) - y
  22356. });
  22357. label.show(true);
  22358. };
  22359. /**
  22360. * Get label's text content.
  22361. *
  22362. * @private
  22363. * @function Highcharts.PlotLineOrBand#getLabelText
  22364. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  22365. * @return {string}
  22366. */
  22367. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  22368. return defined(optionsLabel.formatter) ?
  22369. optionsLabel.formatter
  22370. .call(this) :
  22371. optionsLabel.text;
  22372. };
  22373. /**
  22374. * Remove the plot line or band.
  22375. *
  22376. * @function Highcharts.PlotLineOrBand#destroy
  22377. * @return {void}
  22378. */
  22379. PlotLineOrBand.prototype.destroy = function () {
  22380. // remove it from the lookup
  22381. erase(this.axis.plotLinesAndBands, this);
  22382. delete this.axis;
  22383. destroyObjectProperties(this);
  22384. };
  22385. return PlotLineOrBand;
  22386. }());
  22387. /* eslint-enable no-invalid-this, valid-jsdoc */
  22388. // Object with members for extending the Axis prototype
  22389. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  22390. /**
  22391. * An array of colored bands stretching across the plot area marking an
  22392. * interval on the axis.
  22393. *
  22394. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  22395. * class in addition to the `className` option.
  22396. *
  22397. * @productdesc {highcharts}
  22398. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  22399. * perimeter of the gauge.
  22400. *
  22401. * @type {Array<*>}
  22402. * @product highcharts highstock gantt
  22403. * @apioption xAxis.plotBands
  22404. */
  22405. /**
  22406. * Flag to decide if plotBand should be rendered across all panes.
  22407. *
  22408. * @since 7.1.2
  22409. * @product highstock
  22410. * @type {boolean}
  22411. * @default true
  22412. * @apioption xAxis.plotBands.acrossPanes
  22413. */
  22414. /**
  22415. * Border color for the plot band. Also requires `borderWidth` to be set.
  22416. *
  22417. * @type {Highcharts.ColorString}
  22418. * @apioption xAxis.plotBands.borderColor
  22419. */
  22420. /**
  22421. * Border width for the plot band. Also requires `borderColor` to be set.
  22422. *
  22423. * @type {number}
  22424. * @default 0
  22425. * @apioption xAxis.plotBands.borderWidth
  22426. */
  22427. /**
  22428. * A custom class name, in addition to the default `highcharts-plot-band`,
  22429. * to apply to each individual band.
  22430. *
  22431. * @type {string}
  22432. * @since 5.0.0
  22433. * @apioption xAxis.plotBands.className
  22434. */
  22435. /**
  22436. * The color of the plot band.
  22437. *
  22438. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22439. * Color band
  22440. * @sample {highstock} stock/xaxis/plotbands/
  22441. * Plot band on Y axis
  22442. *
  22443. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22444. * @default ${palette.highlightColor10}
  22445. * @apioption xAxis.plotBands.color
  22446. */
  22447. /**
  22448. * An object defining mouse events for the plot band. Supported properties
  22449. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  22450. *
  22451. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  22452. * Mouse events demonstrated
  22453. *
  22454. * @since 1.2
  22455. * @apioption xAxis.plotBands.events
  22456. */
  22457. /**
  22458. * Click event on a plot band.
  22459. *
  22460. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22461. * @apioption xAxis.plotBands.events.click
  22462. */
  22463. /**
  22464. * Mouse move event on a plot band.
  22465. *
  22466. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22467. * @apioption xAxis.plotBands.events.mousemove
  22468. */
  22469. /**
  22470. * Mouse out event on the corner of a plot band.
  22471. *
  22472. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22473. * @apioption xAxis.plotBands.events.mouseout
  22474. */
  22475. /**
  22476. * Mouse over event on a plot band.
  22477. *
  22478. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22479. * @apioption xAxis.plotBands.events.mouseover
  22480. */
  22481. /**
  22482. * The start position of the plot band in axis units.
  22483. *
  22484. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22485. * Datetime axis
  22486. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22487. * Categorized axis
  22488. * @sample {highstock} stock/xaxis/plotbands/
  22489. * Plot band on Y axis
  22490. *
  22491. * @type {number}
  22492. * @apioption xAxis.plotBands.from
  22493. */
  22494. /**
  22495. * An id used for identifying the plot band in Axis.removePlotBand.
  22496. *
  22497. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  22498. * Remove plot band by id
  22499. * @sample {highstock} highcharts/xaxis/plotbands-id/
  22500. * Remove plot band by id
  22501. *
  22502. * @type {string}
  22503. * @apioption xAxis.plotBands.id
  22504. */
  22505. /**
  22506. * The end position of the plot band in axis units.
  22507. *
  22508. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22509. * Datetime axis
  22510. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22511. * Categorized axis
  22512. * @sample {highstock} stock/xaxis/plotbands/
  22513. * Plot band on Y axis
  22514. *
  22515. * @type {number}
  22516. * @apioption xAxis.plotBands.to
  22517. */
  22518. /**
  22519. * The z index of the plot band within the chart, relative to other
  22520. * elements. Using the same z index as another element may give
  22521. * unpredictable results, as the last rendered element will be on top.
  22522. * Values from 0 to 20 make sense.
  22523. *
  22524. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22525. * Behind plot lines by default
  22526. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  22527. * Above plot lines
  22528. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  22529. * Above plot lines and series
  22530. *
  22531. * @type {number}
  22532. * @since 1.2
  22533. * @apioption xAxis.plotBands.zIndex
  22534. */
  22535. /**
  22536. * Text labels for the plot bands
  22537. *
  22538. * @product highcharts highstock gantt
  22539. * @apioption xAxis.plotBands.label
  22540. */
  22541. /**
  22542. * Horizontal alignment of the label. Can be one of "left", "center" or
  22543. * "right".
  22544. *
  22545. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22546. * Aligned to the right
  22547. * @sample {highstock} stock/xaxis/plotbands-label/
  22548. * Plot band with labels
  22549. *
  22550. * @type {Highcharts.AlignValue}
  22551. * @default center
  22552. * @since 2.1
  22553. * @apioption xAxis.plotBands.label.align
  22554. */
  22555. /**
  22556. * Rotation of the text label in degrees .
  22557. *
  22558. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22559. * Vertical text
  22560. *
  22561. * @type {number}
  22562. * @default 0
  22563. * @since 2.1
  22564. * @apioption xAxis.plotBands.label.rotation
  22565. */
  22566. /**
  22567. * CSS styles for the text label.
  22568. *
  22569. * In styled mode, the labels are styled by the
  22570. * `.highcharts-plot-band-label` class.
  22571. *
  22572. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  22573. * Blue and bold label
  22574. *
  22575. * @type {Highcharts.CSSObject}
  22576. * @since 2.1
  22577. * @apioption xAxis.plotBands.label.style
  22578. */
  22579. /**
  22580. * The string text itself. A subset of HTML is supported.
  22581. *
  22582. * @type {string}
  22583. * @since 2.1
  22584. * @apioption xAxis.plotBands.label.text
  22585. */
  22586. /**
  22587. * The text alignment for the label. While `align` determines where the
  22588. * texts anchor point is placed within the plot band, `textAlign` determines
  22589. * how the text is aligned against its anchor point. Possible values are
  22590. * "left", "center" and "right". Defaults to the same as the `align` option.
  22591. *
  22592. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22593. * Vertical text in center position but text-aligned left
  22594. *
  22595. * @type {Highcharts.AlignValue}
  22596. * @since 2.1
  22597. * @apioption xAxis.plotBands.label.textAlign
  22598. */
  22599. /**
  22600. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22601. * to render the labels.
  22602. *
  22603. * @type {boolean}
  22604. * @default false
  22605. * @since 3.0.3
  22606. * @apioption xAxis.plotBands.label.useHTML
  22607. */
  22608. /**
  22609. * Vertical alignment of the label relative to the plot band. Can be one of
  22610. * "top", "middle" or "bottom".
  22611. *
  22612. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  22613. * Vertically centered label
  22614. * @sample {highstock} stock/xaxis/plotbands-label/
  22615. * Plot band with labels
  22616. *
  22617. * @type {Highcharts.VerticalAlignValue}
  22618. * @default top
  22619. * @since 2.1
  22620. * @apioption xAxis.plotBands.label.verticalAlign
  22621. */
  22622. /**
  22623. * Horizontal position relative the alignment. Default varies by
  22624. * orientation.
  22625. *
  22626. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22627. * Aligned 10px from the right edge
  22628. * @sample {highstock} stock/xaxis/plotbands-label/
  22629. * Plot band with labels
  22630. *
  22631. * @type {number}
  22632. * @since 2.1
  22633. * @apioption xAxis.plotBands.label.x
  22634. */
  22635. /**
  22636. * Vertical position of the text baseline relative to the alignment. Default
  22637. * varies by orientation.
  22638. *
  22639. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  22640. * Label on x axis
  22641. * @sample {highstock} stock/xaxis/plotbands-label/
  22642. * Plot band with labels
  22643. *
  22644. * @type {number}
  22645. * @since 2.1
  22646. * @apioption xAxis.plotBands.label.y
  22647. */
  22648. /**
  22649. * An array of lines stretching across the plot area, marking a specific
  22650. * value on one of the axes.
  22651. *
  22652. * In styled mode, the plot lines are styled by the
  22653. * `.highcharts-plot-line` class in addition to the `className` option.
  22654. *
  22655. * @type {Array<*>}
  22656. * @product highcharts highstock gantt
  22657. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22658. * Basic plot line
  22659. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  22660. * Solid gauge plot line
  22661. * @apioption xAxis.plotLines
  22662. */
  22663. /**
  22664. * Flag to decide if plotLine should be rendered across all panes.
  22665. *
  22666. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  22667. * Plot lines on different panes
  22668. *
  22669. * @since 7.1.2
  22670. * @product highstock
  22671. * @type {boolean}
  22672. * @default true
  22673. * @apioption xAxis.plotLines.acrossPanes
  22674. */
  22675. /**
  22676. * A custom class name, in addition to the default `highcharts-plot-line`,
  22677. * to apply to each individual line.
  22678. *
  22679. * @type {string}
  22680. * @since 5.0.0
  22681. * @apioption xAxis.plotLines.className
  22682. */
  22683. /**
  22684. * The color of the line.
  22685. *
  22686. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22687. * A red line from X axis
  22688. * @sample {highstock} stock/xaxis/plotlines/
  22689. * Plot line on Y axis
  22690. *
  22691. * @type {Highcharts.ColorString}
  22692. * @default ${palette.neutralColor40}
  22693. * @apioption xAxis.plotLines.color
  22694. */
  22695. /**
  22696. * The dashing or dot style for the plot line. For possible values see
  22697. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  22698. *
  22699. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  22700. * Dash and dot pattern
  22701. * @sample {highstock} stock/xaxis/plotlines/
  22702. * Plot line on Y axis
  22703. *
  22704. * @type {Highcharts.DashStyleValue}
  22705. * @default Solid
  22706. * @since 1.2
  22707. * @apioption xAxis.plotLines.dashStyle
  22708. */
  22709. /**
  22710. * An object defining mouse events for the plot line. Supported
  22711. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  22712. *
  22713. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  22714. * Mouse events demonstrated
  22715. *
  22716. * @since 1.2
  22717. * @apioption xAxis.plotLines.events
  22718. */
  22719. /**
  22720. * Click event on a plot band.
  22721. *
  22722. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22723. * @apioption xAxis.plotLines.events.click
  22724. */
  22725. /**
  22726. * Mouse move event on a plot band.
  22727. *
  22728. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22729. * @apioption xAxis.plotLines.events.mousemove
  22730. */
  22731. /**
  22732. * Mouse out event on the corner of a plot band.
  22733. *
  22734. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22735. * @apioption xAxis.plotLines.events.mouseout
  22736. */
  22737. /**
  22738. * Mouse over event on a plot band.
  22739. *
  22740. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22741. * @apioption xAxis.plotLines.events.mouseover
  22742. */
  22743. /**
  22744. * An id used for identifying the plot line in Axis.removePlotLine.
  22745. *
  22746. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  22747. * Remove plot line by id
  22748. *
  22749. * @type {string}
  22750. * @apioption xAxis.plotLines.id
  22751. */
  22752. /**
  22753. * The position of the line in axis units.
  22754. *
  22755. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22756. * Between two categories on X axis
  22757. * @sample {highstock} stock/xaxis/plotlines/
  22758. * Plot line on Y axis
  22759. *
  22760. * @type {number}
  22761. * @apioption xAxis.plotLines.value
  22762. */
  22763. /**
  22764. * The width or thickness of the plot line.
  22765. *
  22766. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22767. * 2px wide line from X axis
  22768. * @sample {highstock} stock/xaxis/plotlines/
  22769. * Plot line on Y axis
  22770. *
  22771. * @type {number}
  22772. * @default 2
  22773. * @apioption xAxis.plotLines.width
  22774. */
  22775. /**
  22776. * The z index of the plot line within the chart.
  22777. *
  22778. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  22779. * Behind plot lines by default
  22780. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  22781. * Above plot lines
  22782. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  22783. * Above plot lines and series
  22784. *
  22785. * @type {number}
  22786. * @since 1.2
  22787. * @apioption xAxis.plotLines.zIndex
  22788. */
  22789. /**
  22790. * Text labels for the plot bands
  22791. *
  22792. * @apioption xAxis.plotLines.label
  22793. */
  22794. /**
  22795. * Horizontal alignment of the label. Can be one of "left", "center" or
  22796. * "right".
  22797. *
  22798. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22799. * Aligned to the right
  22800. * @sample {highstock} stock/xaxis/plotlines/
  22801. * Plot line on Y axis
  22802. *
  22803. * @type {Highcharts.AlignValue}
  22804. * @default left
  22805. * @since 2.1
  22806. * @apioption xAxis.plotLines.label.align
  22807. */
  22808. /**
  22809. * Callback JavaScript function to format the label. Useful properties like
  22810. * the value of plot line or the range of plot band (`from` & `to`
  22811. * properties) can be found in `this.options` object.
  22812. *
  22813. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  22814. * Label formatters for plot line and plot band.
  22815. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  22816. * @apioption xAxis.plotLines.label.formatter
  22817. */
  22818. /**
  22819. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  22820. * lines and 90 for vertical lines.
  22821. *
  22822. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22823. * Slanted text
  22824. *
  22825. * @type {number}
  22826. * @since 2.1
  22827. * @apioption xAxis.plotLines.label.rotation
  22828. */
  22829. /**
  22830. * CSS styles for the text label.
  22831. *
  22832. * In styled mode, the labels are styled by the
  22833. * `.highcharts-plot-line-label` class.
  22834. *
  22835. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  22836. * Blue and bold label
  22837. *
  22838. * @type {Highcharts.CSSObject}
  22839. * @since 2.1
  22840. * @apioption xAxis.plotLines.label.style
  22841. */
  22842. /**
  22843. * The text itself. A subset of HTML is supported.
  22844. *
  22845. * @type {string}
  22846. * @since 2.1
  22847. * @apioption xAxis.plotLines.label.text
  22848. */
  22849. /**
  22850. * The text alignment for the label. While `align` determines where the
  22851. * texts anchor point is placed within the plot band, `textAlign` determines
  22852. * how the text is aligned against its anchor point. Possible values are
  22853. * "left", "center" and "right". Defaults to the same as the `align` option.
  22854. *
  22855. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  22856. * Text label in bottom position
  22857. *
  22858. * @type {Highcharts.AlignValue}
  22859. * @since 2.1
  22860. * @apioption xAxis.plotLines.label.textAlign
  22861. */
  22862. /**
  22863. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22864. * to render the labels.
  22865. *
  22866. * @type {boolean}
  22867. * @default false
  22868. * @since 3.0.3
  22869. * @apioption xAxis.plotLines.label.useHTML
  22870. */
  22871. /**
  22872. * Vertical alignment of the label relative to the plot line. Can be
  22873. * one of "top", "middle" or "bottom".
  22874. *
  22875. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22876. * Vertically centered label
  22877. *
  22878. * @type {Highcharts.VerticalAlignValue}
  22879. * @default {highcharts} top
  22880. * @default {highstock} top
  22881. * @since 2.1
  22882. * @apioption xAxis.plotLines.label.verticalAlign
  22883. */
  22884. /**
  22885. * Horizontal position relative the alignment. Default varies by
  22886. * orientation.
  22887. *
  22888. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22889. * Aligned 10px from the right edge
  22890. * @sample {highstock} stock/xaxis/plotlines/
  22891. * Plot line on Y axis
  22892. *
  22893. * @type {number}
  22894. * @since 2.1
  22895. * @apioption xAxis.plotLines.label.x
  22896. */
  22897. /**
  22898. * Vertical position of the text baseline relative to the alignment. Default
  22899. * varies by orientation.
  22900. *
  22901. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  22902. * Label below the plot line
  22903. * @sample {highstock} stock/xaxis/plotlines/
  22904. * Plot line on Y axis
  22905. *
  22906. * @type {number}
  22907. * @since 2.1
  22908. * @apioption xAxis.plotLines.label.y
  22909. */
  22910. /**
  22911. *
  22912. * @type {Array<*>}
  22913. * @extends xAxis.plotBands
  22914. * @apioption yAxis.plotBands
  22915. */
  22916. /**
  22917. * In a gauge chart, this option determines the inner radius of the
  22918. * plot band that stretches along the perimeter. It can be given as
  22919. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22920. * By default, the inner radius is controlled by the [thickness](
  22921. * #yAxis.plotBands.thickness) option.
  22922. *
  22923. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22924. * Gauge plot band
  22925. *
  22926. * @type {number|string}
  22927. * @since 2.3
  22928. * @product highcharts
  22929. * @apioption yAxis.plotBands.innerRadius
  22930. */
  22931. /**
  22932. * In a gauge chart, this option determines the outer radius of the
  22933. * plot band that stretches along the perimeter. It can be given as
  22934. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22935. *
  22936. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22937. * Gauge plot band
  22938. *
  22939. * @type {number|string}
  22940. * @default 100%
  22941. * @since 2.3
  22942. * @product highcharts
  22943. * @apioption yAxis.plotBands.outerRadius
  22944. */
  22945. /**
  22946. * In a gauge chart, this option sets the width of the plot band
  22947. * stretching along the perimeter. It can be given as a percentage
  22948. * string, like `"10%"`, or as a pixel number, like `10`. The default
  22949. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  22950. * thus making the plot band act as a background for the tick markers.
  22951. *
  22952. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22953. * Gauge plot band
  22954. *
  22955. * @type {number|string}
  22956. * @default 10
  22957. * @since 2.3
  22958. * @product highcharts
  22959. * @apioption yAxis.plotBands.thickness
  22960. */
  22961. /**
  22962. * @type {Array<*>}
  22963. * @extends xAxis.plotLines
  22964. * @apioption yAxis.plotLines
  22965. */
  22966. /* eslint-disable no-invalid-this, valid-jsdoc */
  22967. /**
  22968. * Internal function to create the SVG path definition for a plot band.
  22969. *
  22970. * @function Highcharts.Axis#getPlotBandPath
  22971. *
  22972. * @param {number} from
  22973. * The axis value to start from.
  22974. *
  22975. * @param {number} to
  22976. * The axis value to end on.
  22977. *
  22978. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22979. * The plotBand or plotLine configuration object.
  22980. *
  22981. * @return {Highcharts.SVGPathArray}
  22982. * The SVG path definition in array form.
  22983. */
  22984. getPlotBandPath: function (from, to, options) {
  22985. if (options === void 0) { options = this.options; }
  22986. var toPath = this.getPlotLinePath({
  22987. value: to,
  22988. force: true,
  22989. acrossPanes: options.acrossPanes
  22990. }),
  22991. path = this.getPlotLinePath({
  22992. value: from,
  22993. force: true,
  22994. acrossPanes: options.acrossPanes
  22995. }),
  22996. result = [],
  22997. i,
  22998. // #4964 check if chart is inverted or plotband is on yAxis
  22999. horiz = this.horiz,
  23000. plus = 1,
  23001. isFlat,
  23002. outside = !isNumber(this.min) ||
  23003. !isNumber(this.max) ||
  23004. (from < this.min && to < this.min) ||
  23005. (from > this.max && to > this.max);
  23006. if (path && toPath) {
  23007. // Flat paths don't need labels (#3836)
  23008. if (outside) {
  23009. isFlat = path.toString() === toPath.toString();
  23010. plus = 0;
  23011. }
  23012. // Go over each subpath - for panes in Highcharts Stock
  23013. for (i = 0; i < path.length; i += 2) {
  23014. var pathStart = path[i],
  23015. pathEnd = path[i + 1],
  23016. toPathStart = toPath[i],
  23017. toPathEnd = toPath[i + 1];
  23018. // Type checking all affected path segments. Consider something
  23019. // smarter.
  23020. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  23021. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  23022. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  23023. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  23024. // Add 1 pixel when coordinates are the same
  23025. if (horiz && toPathStart[1] === pathStart[1]) {
  23026. toPathStart[1] += plus;
  23027. toPathEnd[1] += plus;
  23028. }
  23029. else if (!horiz && toPathStart[2] === pathStart[2]) {
  23030. toPathStart[2] += plus;
  23031. toPathEnd[2] += plus;
  23032. }
  23033. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  23034. }
  23035. result.isFlat = isFlat;
  23036. }
  23037. }
  23038. else { // outside the axis area
  23039. path = null;
  23040. }
  23041. return result;
  23042. },
  23043. /**
  23044. * Add a plot band after render time.
  23045. *
  23046. * @sample highcharts/members/axis-addplotband/
  23047. * Toggle the plot band from a button
  23048. *
  23049. * @function Highcharts.Axis#addPlotBand
  23050. *
  23051. * @param {Highcharts.AxisPlotBandsOptions} options
  23052. * A configuration object for the plot band, as defined in
  23053. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  23054. *
  23055. * @return {Highcharts.PlotLineOrBand|undefined}
  23056. * The added plot band.
  23057. */
  23058. addPlotBand: function (options) {
  23059. return this.addPlotBandOrLine(options, 'plotBands');
  23060. },
  23061. /**
  23062. * Add a plot line after render time.
  23063. *
  23064. * @sample highcharts/members/axis-addplotline/
  23065. * Toggle the plot line from a button
  23066. *
  23067. * @function Highcharts.Axis#addPlotLine
  23068. *
  23069. * @param {Highcharts.AxisPlotLinesOptions} options
  23070. * A configuration object for the plot line, as defined in
  23071. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  23072. *
  23073. * @return {Highcharts.PlotLineOrBand|undefined}
  23074. * The added plot line.
  23075. */
  23076. addPlotLine: function (options) {
  23077. return this.addPlotBandOrLine(options, 'plotLines');
  23078. },
  23079. /**
  23080. * Add a plot band or plot line after render time. Called from addPlotBand
  23081. * and addPlotLine internally.
  23082. *
  23083. * @private
  23084. * @function Highcharts.Axis#addPlotBandOrLine
  23085. *
  23086. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  23087. * The plotBand or plotLine configuration object.
  23088. *
  23089. * @param {"plotBands"|"plotLines"} [coll]
  23090. *
  23091. * @return {Highcharts.PlotLineOrBand|undefined}
  23092. */
  23093. addPlotBandOrLine: function (options, coll) {
  23094. var _this = this;
  23095. var obj = new PlotLineOrBand(this,
  23096. options),
  23097. userOptions = this.userOptions;
  23098. if (this.visible) {
  23099. obj = obj.render();
  23100. }
  23101. if (obj) { // #2189
  23102. if (!this._addedPlotLB) {
  23103. this._addedPlotLB = true;
  23104. (userOptions.plotLines || [])
  23105. .concat(userOptions.plotBands || [])
  23106. .forEach(function (plotLineOptions) {
  23107. _this.addPlotBandOrLine(plotLineOptions);
  23108. });
  23109. }
  23110. // Add it to the user options for exporting and Axis.update
  23111. if (coll) {
  23112. // Workaround Microsoft/TypeScript issue #32693
  23113. var updatedOptions = (userOptions[coll] || []);
  23114. updatedOptions.push(options);
  23115. userOptions[coll] = updatedOptions;
  23116. }
  23117. this.plotLinesAndBands.push(obj);
  23118. }
  23119. return obj;
  23120. },
  23121. /**
  23122. * Remove a plot band or plot line from the chart by id. Called internally
  23123. * from `removePlotBand` and `removePlotLine`.
  23124. *
  23125. * @private
  23126. * @function Highcharts.Axis#removePlotBandOrLine
  23127. * @param {string} id
  23128. * @return {void}
  23129. */
  23130. removePlotBandOrLine: function (id) {
  23131. var plotLinesAndBands = this.plotLinesAndBands,
  23132. options = this.options,
  23133. userOptions = this.userOptions;
  23134. if (plotLinesAndBands) { // #15639
  23135. var i_1 = plotLinesAndBands.length;
  23136. while (i_1--) {
  23137. if (plotLinesAndBands[i_1].id === id) {
  23138. plotLinesAndBands[i_1].destroy();
  23139. }
  23140. }
  23141. ([
  23142. options.plotLines || [],
  23143. userOptions.plotLines || [],
  23144. options.plotBands || [],
  23145. userOptions.plotBands || []
  23146. ]).forEach(function (arr) {
  23147. i_1 = arr.length;
  23148. while (i_1--) {
  23149. if ((arr[i_1] || {}).id === id) {
  23150. erase(arr, arr[i_1]);
  23151. }
  23152. }
  23153. });
  23154. }
  23155. },
  23156. /**
  23157. * Remove a plot band by its id.
  23158. *
  23159. * @sample highcharts/members/axis-removeplotband/
  23160. * Remove plot band by id
  23161. * @sample highcharts/members/axis-addplotband/
  23162. * Toggle the plot band from a button
  23163. *
  23164. * @function Highcharts.Axis#removePlotBand
  23165. *
  23166. * @param {string} id
  23167. * The plot band's `id` as given in the original configuration
  23168. * object or in the `addPlotBand` option.
  23169. *
  23170. * @return {void}
  23171. */
  23172. removePlotBand: function (id) {
  23173. this.removePlotBandOrLine(id);
  23174. },
  23175. /**
  23176. * Remove a plot line by its id.
  23177. *
  23178. * @sample highcharts/xaxis/plotlines-id/
  23179. * Remove plot line by id
  23180. * @sample highcharts/members/axis-addplotline/
  23181. * Toggle the plot line from a button
  23182. *
  23183. * @function Highcharts.Axis#removePlotLine
  23184. *
  23185. * @param {string} id
  23186. * The plot line's `id` as given in the original configuration
  23187. * object or in the `addPlotLine` option.
  23188. */
  23189. removePlotLine: function (id) {
  23190. this.removePlotBandOrLine(id);
  23191. }
  23192. });
  23193. return PlotLineOrBand;
  23194. });
  23195. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Utilities.js']], function (F, H, palette, RendererRegistry, U) {
  23196. /* *
  23197. *
  23198. * (c) 2010-2021 Torstein Honsi
  23199. *
  23200. * License: www.highcharts.com/license
  23201. *
  23202. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23203. *
  23204. * */
  23205. var format = F.format;
  23206. var doc = H.doc;
  23207. var clamp = U.clamp,
  23208. css = U.css,
  23209. defined = U.defined,
  23210. discardElement = U.discardElement,
  23211. extend = U.extend,
  23212. fireEvent = U.fireEvent,
  23213. isArray = U.isArray,
  23214. isNumber = U.isNumber,
  23215. isString = U.isString,
  23216. merge = U.merge,
  23217. pick = U.pick,
  23218. splat = U.splat,
  23219. syncTimeout = U.syncTimeout,
  23220. timeUnits = U.timeUnits;
  23221. /**
  23222. * Callback function to format the text of the tooltip from scratch.
  23223. *
  23224. * In case of single or shared tooltips, a string should be be returned. In case
  23225. * of splitted tooltips, it should return an array where the first item is the
  23226. * header, and subsequent items are mapped to the points. Return `false` to
  23227. * disable tooltip for a specific point on series.
  23228. *
  23229. * @callback Highcharts.TooltipFormatterCallbackFunction
  23230. *
  23231. * @param {Highcharts.TooltipFormatterContextObject} this
  23232. * Context to format
  23233. *
  23234. * @param {Highcharts.Tooltip} tooltip
  23235. * The tooltip instance
  23236. *
  23237. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  23238. * Formatted text or false
  23239. */
  23240. /**
  23241. * @interface Highcharts.TooltipFormatterContextObject
  23242. */ /**
  23243. * @name Highcharts.TooltipFormatterContextObject#color
  23244. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  23245. */ /**
  23246. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  23247. * @type {number|undefined}
  23248. */ /**
  23249. * @name Highcharts.TooltipFormatterContextObject#key
  23250. * @type {number}
  23251. */ /**
  23252. * @name Highcharts.TooltipFormatterContextObject#percentage
  23253. * @type {number|undefined}
  23254. */ /**
  23255. * @name Highcharts.TooltipFormatterContextObject#point
  23256. * @type {Highcharts.Point}
  23257. */ /**
  23258. * @name Highcharts.TooltipFormatterContextObject#points
  23259. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  23260. */ /**
  23261. * @name Highcharts.TooltipFormatterContextObject#series
  23262. * @type {Highcharts.Series}
  23263. */ /**
  23264. * @name Highcharts.TooltipFormatterContextObject#total
  23265. * @type {number|undefined}
  23266. */ /**
  23267. * @name Highcharts.TooltipFormatterContextObject#x
  23268. * @type {number}
  23269. */ /**
  23270. * @name Highcharts.TooltipFormatterContextObject#y
  23271. * @type {number}
  23272. */
  23273. /**
  23274. * A callback function to place the tooltip in a specific position.
  23275. *
  23276. * @callback Highcharts.TooltipPositionerCallbackFunction
  23277. *
  23278. * @param {Highcharts.Tooltip} this
  23279. * Tooltip context of the callback.
  23280. *
  23281. * @param {number} labelWidth
  23282. * Width of the tooltip.
  23283. *
  23284. * @param {number} labelHeight
  23285. * Height of the tooltip.
  23286. *
  23287. * @param {Highcharts.TooltipPositionerPointObject} point
  23288. * Point information for positioning a tooltip.
  23289. *
  23290. * @return {Highcharts.PositionObject}
  23291. * New position for the tooltip.
  23292. */
  23293. /**
  23294. * Point information for positioning a tooltip.
  23295. *
  23296. * @interface Highcharts.TooltipPositionerPointObject
  23297. * @extends Highcharts.Point
  23298. */ /**
  23299. * If `tooltip.split` option is enabled and positioner is called for each of the
  23300. * boxes separately, this property indicates the call on the xAxis header, which
  23301. * is not a point itself.
  23302. * @name Highcharts.TooltipPositionerPointObject#isHeader
  23303. * @type {boolean}
  23304. */ /**
  23305. * The reference point relative to the plot area. Add chart.plotLeft to get the
  23306. * full coordinates.
  23307. * @name Highcharts.TooltipPositionerPointObject#plotX
  23308. * @type {number}
  23309. */ /**
  23310. * The reference point relative to the plot area. Add chart.plotTop to get the
  23311. * full coordinates.
  23312. * @name Highcharts.TooltipPositionerPointObject#plotY
  23313. * @type {number}
  23314. */
  23315. /**
  23316. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  23317. */
  23318. ''; // separates doclets above from variables below
  23319. /* eslint-disable no-invalid-this, valid-jsdoc */
  23320. /**
  23321. * Tooltip of a chart.
  23322. *
  23323. * @class
  23324. * @name Highcharts.Tooltip
  23325. *
  23326. * @param {Highcharts.Chart} chart
  23327. * The chart instance.
  23328. *
  23329. * @param {Highcharts.TooltipOptions} options
  23330. * Tooltip options.
  23331. */
  23332. var Tooltip = /** @class */ (function () {
  23333. /* *
  23334. *
  23335. * Constructors
  23336. *
  23337. * */
  23338. function Tooltip(chart, options) {
  23339. this.container = void 0;
  23340. this.crosshairs = [];
  23341. this.distance = 0;
  23342. this.isHidden = true;
  23343. this.isSticky = false;
  23344. this.now = {};
  23345. this.options = {};
  23346. this.outside = false;
  23347. this.chart = chart;
  23348. this.init(chart, options);
  23349. }
  23350. /* *
  23351. *
  23352. * Functions
  23353. *
  23354. * */
  23355. /**
  23356. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  23357. * needs to have an id specific to the chart, otherwise there will be issues
  23358. * when one tooltip adopts the filter of a different chart, specifically one
  23359. * where the container is hidden.
  23360. *
  23361. * @private
  23362. * @function Highcharts.Tooltip#applyFilter
  23363. */
  23364. Tooltip.prototype.applyFilter = function () {
  23365. var chart = this.chart;
  23366. chart.renderer.definition({
  23367. tagName: 'filter',
  23368. attributes: {
  23369. id: 'drop-shadow-' + chart.index,
  23370. opacity: 0.5
  23371. },
  23372. children: [{
  23373. tagName: 'feGaussianBlur',
  23374. attributes: {
  23375. 'in': 'SourceAlpha',
  23376. stdDeviation: 1
  23377. }
  23378. }, {
  23379. tagName: 'feOffset',
  23380. attributes: {
  23381. dx: 1,
  23382. dy: 1
  23383. }
  23384. }, {
  23385. tagName: 'feComponentTransfer',
  23386. children: [{
  23387. tagName: 'feFuncA',
  23388. attributes: {
  23389. type: 'linear',
  23390. slope: 0.3
  23391. }
  23392. }]
  23393. }, {
  23394. tagName: 'feMerge',
  23395. children: [{
  23396. tagName: 'feMergeNode'
  23397. }, {
  23398. tagName: 'feMergeNode',
  23399. attributes: {
  23400. 'in': 'SourceGraphic'
  23401. }
  23402. }]
  23403. }]
  23404. });
  23405. chart.renderer.definition({
  23406. tagName: 'style',
  23407. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  23408. 'filter:url(#drop-shadow-' + chart.index + ')' +
  23409. '}'
  23410. });
  23411. };
  23412. /**
  23413. * Build the body (lines) of the tooltip by iterating over the items and
  23414. * returning one entry for each item, abstracting this functionality allows
  23415. * to easily overwrite and extend it.
  23416. *
  23417. * @private
  23418. * @function Highcharts.Tooltip#bodyFormatter
  23419. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  23420. * @return {Array<string>}
  23421. */
  23422. Tooltip.prototype.bodyFormatter = function (items) {
  23423. return items.map(function (item) {
  23424. var tooltipOptions = item.series.tooltipOptions;
  23425. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  23426. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  23427. });
  23428. };
  23429. /**
  23430. * Destroy the single tooltips in a split tooltip.
  23431. * If the tooltip is active then it is not destroyed, unless forced to.
  23432. *
  23433. * @private
  23434. * @function Highcharts.Tooltip#cleanSplit
  23435. *
  23436. * @param {boolean} [force]
  23437. * Force destroy all tooltips.
  23438. */
  23439. Tooltip.prototype.cleanSplit = function (force) {
  23440. this.chart.series.forEach(function (series) {
  23441. var tt = series && series.tt;
  23442. if (tt) {
  23443. if (!tt.isActive || force) {
  23444. series.tt = tt.destroy();
  23445. }
  23446. else {
  23447. tt.isActive = false;
  23448. }
  23449. }
  23450. });
  23451. };
  23452. /**
  23453. * In case no user defined formatter is given, this will be used. Note that
  23454. * the context here is an object holding point, series, x, y etc.
  23455. *
  23456. * @function Highcharts.Tooltip#defaultFormatter
  23457. *
  23458. * @param {Highcharts.Tooltip} tooltip
  23459. *
  23460. * @return {Array<string>}
  23461. */
  23462. Tooltip.prototype.defaultFormatter = function (tooltip) {
  23463. var items = this.points || splat(this),
  23464. s;
  23465. // Build the header
  23466. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  23467. // build the values
  23468. s = s.concat(tooltip.bodyFormatter(items));
  23469. // footer
  23470. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  23471. return s;
  23472. };
  23473. /**
  23474. * Removes and destroys the tooltip and its elements.
  23475. *
  23476. * @function Highcharts.Tooltip#destroy
  23477. */
  23478. Tooltip.prototype.destroy = function () {
  23479. // Destroy and clear local variables
  23480. if (this.label) {
  23481. this.label = this.label.destroy();
  23482. }
  23483. if (this.split && this.tt) {
  23484. this.cleanSplit(this.chart, true);
  23485. this.tt = this.tt.destroy();
  23486. }
  23487. if (this.renderer) {
  23488. this.renderer = this.renderer.destroy();
  23489. discardElement(this.container);
  23490. }
  23491. U.clearTimeout(this.hideTimer);
  23492. U.clearTimeout(this.tooltipTimeout);
  23493. };
  23494. /**
  23495. * Extendable method to get the anchor position of the tooltip
  23496. * from a point or set of points
  23497. *
  23498. * @private
  23499. * @function Highcharts.Tooltip#getAnchor
  23500. *
  23501. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  23502. *
  23503. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23504. *
  23505. * @return {Array<number>}
  23506. */
  23507. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  23508. var ret,
  23509. chart = this.chart,
  23510. pointer = chart.pointer,
  23511. inverted = chart.inverted,
  23512. plotTop = chart.plotTop,
  23513. plotLeft = chart.plotLeft,
  23514. plotX = 0,
  23515. plotY = 0,
  23516. yAxis,
  23517. xAxis;
  23518. points = splat(points);
  23519. // When tooltip follows mouse, relate the position to the mouse
  23520. if (this.followPointer && mouseEvent) {
  23521. if (typeof mouseEvent.chartX === 'undefined') {
  23522. mouseEvent = pointer.normalize(mouseEvent);
  23523. }
  23524. ret = [
  23525. mouseEvent.chartX - plotLeft,
  23526. mouseEvent.chartY - plotTop
  23527. ];
  23528. // Some series types use a specificly calculated tooltip position for
  23529. // each point
  23530. }
  23531. else if (points[0].tooltipPos) {
  23532. ret = points[0].tooltipPos;
  23533. // Calculate the average position and adjust for axis positions
  23534. }
  23535. else {
  23536. points.forEach(function (point) {
  23537. yAxis = point.series.yAxis;
  23538. xAxis = point.series.xAxis;
  23539. plotX += point.plotX || 0;
  23540. plotY += (point.plotLow ?
  23541. (point.plotLow + (point.plotHigh || 0)) / 2 :
  23542. (point.plotY || 0));
  23543. // Adjust position for positioned axes (top/left settings)
  23544. if (xAxis && yAxis) {
  23545. if (!inverted) { // #1151
  23546. plotX += xAxis.pos - plotLeft;
  23547. plotY += yAxis.pos - plotTop;
  23548. }
  23549. else { // #14771
  23550. plotX += plotTop + chart.plotHeight - xAxis.len - xAxis.pos;
  23551. plotY += plotLeft + chart.plotWidth - yAxis.len - yAxis.pos;
  23552. }
  23553. }
  23554. });
  23555. plotX /= points.length;
  23556. plotY /= points.length;
  23557. // Use the average position for multiple points
  23558. ret = [
  23559. inverted ? chart.plotWidth - plotY : plotX,
  23560. inverted ? chart.plotHeight - plotX : plotY
  23561. ];
  23562. // When shared, place the tooltip next to the mouse (#424)
  23563. if (this.shared && points.length > 1 && mouseEvent) {
  23564. if (inverted) {
  23565. ret[0] = mouseEvent.chartX - plotLeft;
  23566. }
  23567. else {
  23568. ret[1] = mouseEvent.chartY - plotTop;
  23569. }
  23570. }
  23571. }
  23572. return ret.map(Math.round);
  23573. };
  23574. /**
  23575. * Get the optimal date format for a point, based on a range.
  23576. *
  23577. * @private
  23578. * @function Highcharts.Tooltip#getDateFormat
  23579. *
  23580. * @param {number} range
  23581. * The time range
  23582. *
  23583. * @param {number} date
  23584. * The date of the point in question
  23585. *
  23586. * @param {number} startOfWeek
  23587. * An integer representing the first day of the week, where 0 is
  23588. * Sunday.
  23589. *
  23590. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  23591. * A map of time units to formats.
  23592. *
  23593. * @return {string}
  23594. * The optimal date format for a point.
  23595. */
  23596. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  23597. var time = this.chart.time, dateStr = time.dateFormat('%m-%d %H:%M:%S.%L', date), format, n, blank = '01-01 00:00:00.000', strpos = {
  23598. millisecond: 15,
  23599. second: 12,
  23600. minute: 9,
  23601. hour: 6,
  23602. day: 3
  23603. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  23604. for (n in timeUnits) { // eslint-disable-line guard-for-in
  23605. // If the range is exactly one week and we're looking at a
  23606. // Sunday/Monday, go for the week format
  23607. if (range === timeUnits.week &&
  23608. +time.dateFormat('%w', date) === startOfWeek &&
  23609. dateStr.substr(6) === blank.substr(6)) {
  23610. n = 'week';
  23611. break;
  23612. }
  23613. // The first format that is too great for the range
  23614. if (timeUnits[n] > range) {
  23615. n = lastN;
  23616. break;
  23617. }
  23618. // If the point is placed every day at 23:59, we need to show
  23619. // the minutes as well. #2637.
  23620. if (strpos[n] &&
  23621. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  23622. break;
  23623. }
  23624. // Weeks are outside the hierarchy, only apply them on
  23625. // Mondays/Sundays like in the first condition
  23626. if (n !== 'week') {
  23627. lastN = n;
  23628. }
  23629. }
  23630. if (n) {
  23631. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  23632. }
  23633. return format;
  23634. };
  23635. /**
  23636. * Creates the Tooltip label element if it does not exist, then returns it.
  23637. *
  23638. * @function Highcharts.Tooltip#getLabel
  23639. * @return {Highcharts.SVGElement}
  23640. */
  23641. Tooltip.prototype.getLabel = function () {
  23642. var tooltip = this,
  23643. renderer = this.chart.renderer,
  23644. styledMode = this.chart.styledMode,
  23645. options = this.options,
  23646. className = ('tooltip' + (defined(options.className) ?
  23647. ' ' + options.className :
  23648. '')),
  23649. pointerEvents = ((options.style && options.style.pointerEvents) ||
  23650. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  23651. container,
  23652. onMouseEnter = function () {
  23653. tooltip.inContact = true;
  23654. }, onMouseLeave = function () {
  23655. var series = tooltip.chart.hoverSeries;
  23656. tooltip.inContact = false;
  23657. if (series &&
  23658. series.onMouseOut) {
  23659. series.onMouseOut();
  23660. }
  23661. };
  23662. if (!this.label) {
  23663. if (this.outside) {
  23664. var chartStyle = this.chart.options.chart.style,
  23665. Renderer = RendererRegistry.getRendererType();
  23666. /**
  23667. * Reference to the tooltip's container, when
  23668. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23669. * it's undefined.
  23670. *
  23671. * @name Highcharts.Tooltip#container
  23672. * @type {Highcharts.HTMLDOMElement|undefined}
  23673. */
  23674. this.container = container = H.doc.createElement('div');
  23675. container.className = 'highcharts-tooltip-container';
  23676. css(container, {
  23677. position: 'absolute',
  23678. top: '1px',
  23679. pointerEvents: pointerEvents,
  23680. zIndex: Math.max((this.options.style && this.options.style.zIndex || 0), (chartStyle && chartStyle.zIndex || 0) + 3)
  23681. });
  23682. H.doc.body.appendChild(container);
  23683. /**
  23684. * Reference to the tooltip's renderer, when
  23685. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23686. * it's undefined.
  23687. *
  23688. * @name Highcharts.Tooltip#renderer
  23689. * @type {Highcharts.SVGRenderer|undefined}
  23690. */
  23691. this.renderer = renderer = new Renderer(container, 0, 0, chartStyle, void 0, void 0, renderer.styledMode);
  23692. }
  23693. // Create the label
  23694. if (this.split) {
  23695. this.label = renderer.g(className);
  23696. }
  23697. else {
  23698. this.label = renderer
  23699. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  23700. .attr({
  23701. padding: options.padding,
  23702. r: options.borderRadius
  23703. });
  23704. if (!styledMode) {
  23705. this.label
  23706. .attr({
  23707. fill: options.backgroundColor,
  23708. 'stroke-width': options.borderWidth
  23709. })
  23710. // #2301, #2657
  23711. .css(options.style)
  23712. .css({ pointerEvents: pointerEvents })
  23713. .shadow(options.shadow);
  23714. }
  23715. }
  23716. if (styledMode) {
  23717. // Apply the drop-shadow filter
  23718. this.applyFilter();
  23719. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  23720. }
  23721. // Split tooltip use updateTooltipContainer to position the tooltip
  23722. // container.
  23723. if (tooltip.outside && !tooltip.split) {
  23724. var label_1 = this.label;
  23725. var xSetter_1 = label_1.xSetter,
  23726. ySetter_1 = label_1.ySetter;
  23727. label_1.xSetter = function (value) {
  23728. xSetter_1.call(label_1, tooltip.distance);
  23729. container.style.left = value + 'px';
  23730. };
  23731. label_1.ySetter = function (value) {
  23732. ySetter_1.call(label_1, tooltip.distance);
  23733. container.style.top = value + 'px';
  23734. };
  23735. }
  23736. this.label
  23737. .on('mouseenter', onMouseEnter)
  23738. .on('mouseleave', onMouseLeave)
  23739. .attr({ zIndex: 8 })
  23740. .add();
  23741. }
  23742. return this.label;
  23743. };
  23744. /**
  23745. * Place the tooltip in a chart without spilling over
  23746. * and not covering the point it self.
  23747. *
  23748. * @private
  23749. * @function Highcharts.Tooltip#getPosition
  23750. *
  23751. * @param {number} boxWidth
  23752. *
  23753. * @param {number} boxHeight
  23754. *
  23755. * @param {Highcharts.Point} point
  23756. *
  23757. * @return {Highcharts.PositionObject}
  23758. */
  23759. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  23760. var chart = this.chart,
  23761. distance = this.distance,
  23762. ret = {},
  23763. // Don't use h if chart isn't inverted (#7242) ???
  23764. h = (chart.inverted && point.h) || 0, // #4117 ???
  23765. swapped,
  23766. outside = this.outside,
  23767. outerWidth = outside ?
  23768. // substract distance to prevent scrollbars
  23769. doc.documentElement.clientWidth - 2 * distance :
  23770. chart.chartWidth,
  23771. outerHeight = outside ?
  23772. Math.max(doc.body.scrollHeight,
  23773. doc.documentElement.scrollHeight,
  23774. doc.body.offsetHeight,
  23775. doc.documentElement.offsetHeight,
  23776. doc.documentElement.clientHeight) :
  23777. chart.chartHeight,
  23778. chartPosition = chart.pointer.getChartPosition(),
  23779. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23780. val * chartPosition.scaleX); },
  23781. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23782. val * chartPosition.scaleY); },
  23783. // Build parameter arrays for firstDimension()/secondDimension()
  23784. buildDimensionArray = function (dim) {
  23785. var isX = dim === 'x';
  23786. return [
  23787. dim,
  23788. isX ? outerWidth : outerHeight,
  23789. isX ? boxWidth : boxHeight
  23790. ].concat(outside ? [
  23791. // If we are using tooltip.outside, we need to scale the
  23792. // position to match scaling of the container in case there
  23793. // is a transform/zoom on the container. #11329
  23794. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  23795. isX ? chartPosition.left - distance +
  23796. scaleX(point.plotX + chart.plotLeft) :
  23797. chartPosition.top - distance +
  23798. scaleY(point.plotY + chart.plotTop),
  23799. 0,
  23800. isX ? outerWidth : outerHeight
  23801. ] : [
  23802. // Not outside, no scaling is needed
  23803. isX ? boxWidth : boxHeight,
  23804. isX ? point.plotX + chart.plotLeft :
  23805. point.plotY + chart.plotTop,
  23806. isX ? chart.plotLeft : chart.plotTop,
  23807. isX ? chart.plotLeft + chart.plotWidth :
  23808. chart.plotTop + chart.plotHeight
  23809. ]);
  23810. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  23811. // The far side is right or bottom
  23812. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  23813. /*
  23814. * Handle the preferred dimension. When the preferred dimension is
  23815. * tooltip on top or bottom of the point, it will look for space
  23816. * there.
  23817. *
  23818. * @private
  23819. */
  23820. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23821. point, min, max) {
  23822. var scaledDist = outside ?
  23823. (dim === 'y' ? scaleY(distance) : scaleX(distance)) :
  23824. distance,
  23825. scaleDiff = (innerSize - scaledInnerSize) / 2,
  23826. roomLeft = scaledInnerSize < point - distance,
  23827. roomRight = point + distance + scaledInnerSize < outerSize,
  23828. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  23829. alignedRight = point + scaledDist - scaleDiff;
  23830. if (preferFarSide && roomRight) {
  23831. ret[dim] = alignedRight;
  23832. }
  23833. else if (!preferFarSide && roomLeft) {
  23834. ret[dim] = alignedLeft;
  23835. }
  23836. else if (roomLeft) {
  23837. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  23838. }
  23839. else if (roomRight) {
  23840. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  23841. alignedRight :
  23842. alignedRight + h);
  23843. }
  23844. else {
  23845. return false;
  23846. }
  23847. },
  23848. /*
  23849. * Handle the secondary dimension. If the preferred dimension is
  23850. * tooltip on top or bottom of the point, the second dimension is to
  23851. * align the tooltip above the point, trying to align center but
  23852. * allowing left or right align within the chart box.
  23853. *
  23854. * @private
  23855. */
  23856. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23857. point) {
  23858. var retVal;
  23859. // Too close to the edge, return false and swap dimensions
  23860. if (point < distance || point > outerSize - distance) {
  23861. retVal = false;
  23862. // Align left/top
  23863. }
  23864. else if (point < innerSize / 2) {
  23865. ret[dim] = 1;
  23866. // Align right/bottom
  23867. }
  23868. else if (point > outerSize - scaledInnerSize / 2) {
  23869. ret[dim] = outerSize - scaledInnerSize - 2;
  23870. // Align center
  23871. }
  23872. else {
  23873. ret[dim] = point - innerSize / 2;
  23874. }
  23875. return retVal;
  23876. },
  23877. /*
  23878. * Swap the dimensions
  23879. */
  23880. swap = function (count) {
  23881. var temp = first;
  23882. first = second;
  23883. second = temp;
  23884. swapped = count;
  23885. }, run = function () {
  23886. if (firstDimension.apply(0, first) !== false) {
  23887. if (secondDimension.apply(0, second) === false &&
  23888. !swapped) {
  23889. swap(true);
  23890. run();
  23891. }
  23892. }
  23893. else if (!swapped) {
  23894. swap(true);
  23895. run();
  23896. }
  23897. else {
  23898. ret.x = ret.y = 0;
  23899. }
  23900. };
  23901. // Under these conditions, prefer the tooltip on the side of the point
  23902. if (chart.inverted || this.len > 1) {
  23903. swap();
  23904. }
  23905. run();
  23906. return ret;
  23907. };
  23908. /**
  23909. * Get the best X date format based on the closest point range on the axis.
  23910. *
  23911. * @private
  23912. * @function Highcharts.Tooltip#getXDateFormat
  23913. *
  23914. * @param {Highcharts.Point} point
  23915. *
  23916. * @param {Highcharts.TooltipOptions} options
  23917. *
  23918. * @param {Highcharts.Axis} xAxis
  23919. *
  23920. * @return {string}
  23921. */
  23922. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  23923. var xDateFormat,
  23924. dateTimeLabelFormats = options.dateTimeLabelFormats,
  23925. closestPointRange = xAxis && xAxis.closestPointRange;
  23926. if (closestPointRange) {
  23927. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  23928. }
  23929. else {
  23930. xDateFormat = dateTimeLabelFormats.day;
  23931. }
  23932. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  23933. };
  23934. /**
  23935. * Hides the tooltip with a fade out animation.
  23936. *
  23937. * @function Highcharts.Tooltip#hide
  23938. *
  23939. * @param {number} [delay]
  23940. * The fade out in milliseconds. If no value is provided the value
  23941. * of the tooltip.hideDelay option is used. A value of 0 disables
  23942. * the fade out animation.
  23943. */
  23944. Tooltip.prototype.hide = function (delay) {
  23945. var tooltip = this;
  23946. // disallow duplicate timers (#1728, #1766)
  23947. U.clearTimeout(this.hideTimer);
  23948. delay = pick(delay, this.options.hideDelay, 500);
  23949. if (!this.isHidden) {
  23950. this.hideTimer = syncTimeout(function () {
  23951. // If there is a delay, do fadeOut with the default duration. If
  23952. // the hideDelay is 0, we assume no animation is wanted, so we
  23953. // pass 0 duration. #12994.
  23954. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  23955. tooltip.isHidden = true;
  23956. }, delay);
  23957. }
  23958. };
  23959. /**
  23960. * @private
  23961. * @function Highcharts.Tooltip#init
  23962. *
  23963. * @param {Highcharts.Chart} chart
  23964. * The chart instance.
  23965. *
  23966. * @param {Highcharts.TooltipOptions} options
  23967. * Tooltip options.
  23968. */
  23969. Tooltip.prototype.init = function (chart, options) {
  23970. /**
  23971. * Chart of the tooltip.
  23972. *
  23973. * @readonly
  23974. * @name Highcharts.Tooltip#chart
  23975. * @type {Highcharts.Chart}
  23976. */
  23977. this.chart = chart;
  23978. /**
  23979. * Used tooltip options.
  23980. *
  23981. * @readonly
  23982. * @name Highcharts.Tooltip#options
  23983. * @type {Highcharts.TooltipOptions}
  23984. */
  23985. this.options = options;
  23986. /**
  23987. * List of crosshairs.
  23988. *
  23989. * @private
  23990. * @readonly
  23991. * @name Highcharts.Tooltip#crosshairs
  23992. * @type {Array<null>}
  23993. */
  23994. this.crosshairs = [];
  23995. /**
  23996. * Current values of x and y when animating.
  23997. *
  23998. * @private
  23999. * @readonly
  24000. * @name Highcharts.Tooltip#now
  24001. * @type {Highcharts.PositionObject}
  24002. */
  24003. this.now = { x: 0, y: 0 };
  24004. /**
  24005. * Tooltips are initially hidden.
  24006. *
  24007. * @private
  24008. * @readonly
  24009. * @name Highcharts.Tooltip#isHidden
  24010. * @type {boolean}
  24011. */
  24012. this.isHidden = true;
  24013. /**
  24014. * True, if the tooltip is split into one label per series, with the
  24015. * header close to the axis.
  24016. *
  24017. * @readonly
  24018. * @name Highcharts.Tooltip#split
  24019. * @type {boolean|undefined}
  24020. */
  24021. this.split = options.split && !chart.inverted && !chart.polar;
  24022. /**
  24023. * When the tooltip is shared, the entire plot area will capture mouse
  24024. * movement or touch events.
  24025. *
  24026. * @readonly
  24027. * @name Highcharts.Tooltip#shared
  24028. * @type {boolean|undefined}
  24029. */
  24030. this.shared = options.shared || this.split;
  24031. /**
  24032. * Whether to allow the tooltip to render outside the chart's SVG
  24033. * element box. By default (false), the tooltip is rendered within the
  24034. * chart's SVG element, which results in the tooltip being aligned
  24035. * inside the chart area.
  24036. *
  24037. * @readonly
  24038. * @name Highcharts.Tooltip#outside
  24039. * @type {boolean}
  24040. *
  24041. * @todo
  24042. * Split tooltip does not support outside in the first iteration. Should
  24043. * not be too complicated to implement.
  24044. */
  24045. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  24046. };
  24047. /**
  24048. * Returns true, if the pointer is in contact with the tooltip tracker.
  24049. */
  24050. Tooltip.prototype.isStickyOnContact = function () {
  24051. return !!(!this.followPointer &&
  24052. this.options.stickOnContact &&
  24053. this.inContact);
  24054. };
  24055. /**
  24056. * Moves the tooltip with a soft animation to a new position.
  24057. *
  24058. * @private
  24059. * @function Highcharts.Tooltip#move
  24060. *
  24061. * @param {number} x
  24062. *
  24063. * @param {number} y
  24064. *
  24065. * @param {number} anchorX
  24066. *
  24067. * @param {number} anchorY
  24068. */
  24069. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  24070. var tooltip = this,
  24071. now = tooltip.now,
  24072. animate = tooltip.options.animation !== false &&
  24073. !tooltip.isHidden &&
  24074. // When we get close to the target position, abort animation and
  24075. // land on the right place (#3056)
  24076. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  24077. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  24078. // Get intermediate values for animation
  24079. extend(now, {
  24080. x: animate ? (2 * now.x + x) / 3 : x,
  24081. y: animate ? (now.y + y) / 2 : y,
  24082. anchorX: skipAnchor ?
  24083. void 0 :
  24084. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  24085. anchorY: skipAnchor ?
  24086. void 0 :
  24087. animate ? (now.anchorY + anchorY) / 2 : anchorY
  24088. });
  24089. // Move to the intermediate value
  24090. tooltip.getLabel().attr(now);
  24091. tooltip.drawTracker();
  24092. // Run on next tick of the mouse tracker
  24093. if (animate) {
  24094. // Never allow two timeouts
  24095. U.clearTimeout(this.tooltipTimeout);
  24096. // Set the fixed interval ticking for the smooth tooltip
  24097. this.tooltipTimeout = setTimeout(function () {
  24098. // The interval function may still be running during destroy,
  24099. // so check that the chart is really there before calling.
  24100. if (tooltip) {
  24101. tooltip.move(x, y, anchorX, anchorY);
  24102. }
  24103. }, 32);
  24104. }
  24105. };
  24106. /**
  24107. * Refresh the tooltip's text and position.
  24108. *
  24109. * @function Highcharts.Tooltip#refresh
  24110. *
  24111. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  24112. * Either a point or an array of points.
  24113. *
  24114. * @param {Highcharts.PointerEventObject} [mouseEvent]
  24115. * Mouse event, that is responsible for the refresh and should be
  24116. * used for the tooltip update.
  24117. */
  24118. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  24119. var tooltip = this,
  24120. chart = this.chart,
  24121. options = tooltip.options,
  24122. x,
  24123. y,
  24124. points = splat(pointOrPoints),
  24125. point = points[0],
  24126. anchor,
  24127. textConfig = {},
  24128. text,
  24129. pointConfig = [],
  24130. formatter = options.formatter || tooltip.defaultFormatter,
  24131. shared = tooltip.shared,
  24132. styledMode = chart.styledMode;
  24133. if (!options.enabled) {
  24134. return;
  24135. }
  24136. U.clearTimeout(this.hideTimer);
  24137. // get the reference point coordinates (pie charts use tooltipPos)
  24138. tooltip.followPointer = !tooltip.split && point.series.tooltipOptions.followPointer;
  24139. anchor = tooltip.getAnchor(pointOrPoints, mouseEvent);
  24140. x = anchor[0];
  24141. y = anchor[1];
  24142. // shared tooltip, array is sent over
  24143. if (shared &&
  24144. !(!isArray(pointOrPoints) &&
  24145. pointOrPoints.series &&
  24146. pointOrPoints.series.noSharedTooltip)) {
  24147. chart.pointer.applyInactiveState(points);
  24148. // Now set hover state for the choosen ones:
  24149. points.forEach(function (item) {
  24150. item.setState('hover');
  24151. pointConfig.push(item.getLabelConfig());
  24152. });
  24153. textConfig = {
  24154. x: point.category,
  24155. y: point.y
  24156. };
  24157. textConfig.points = pointConfig;
  24158. // single point tooltip
  24159. }
  24160. else {
  24161. textConfig = point.getLabelConfig();
  24162. }
  24163. this.len = pointConfig.length; // #6128
  24164. text = formatter.call(textConfig, tooltip);
  24165. // register the current series
  24166. var currentSeries = point.series;
  24167. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  24168. // update the inner HTML
  24169. if (text === false) {
  24170. this.hide();
  24171. }
  24172. else {
  24173. // update text
  24174. if (tooltip.split) {
  24175. this.renderSplit(text, points);
  24176. }
  24177. else {
  24178. var checkX = x;
  24179. var checkY = y;
  24180. if (mouseEvent && chart.pointer.isDirectTouch) {
  24181. checkX = mouseEvent.chartX - chart.plotLeft;
  24182. checkY = mouseEvent.chartY - chart.plotTop;
  24183. }
  24184. // #11493, #13095
  24185. if (chart.polar ||
  24186. currentSeries.options.clip === false ||
  24187. currentSeries.shouldShowTooltip(checkX, checkY)) {
  24188. var label = tooltip.getLabel();
  24189. // Prevent the tooltip from flowing over the chart box
  24190. // (#6659)
  24191. if (!options.style.width || styledMode) {
  24192. label.css({
  24193. width: this.chart.spacingBox.width + 'px'
  24194. });
  24195. }
  24196. label.attr({
  24197. text: text && text.join ?
  24198. text.join('') :
  24199. text
  24200. });
  24201. // Set the stroke color of the box to reflect the point
  24202. label.removeClass(/highcharts-color-[\d]+/g)
  24203. .addClass('highcharts-color-' +
  24204. pick(point.colorIndex, currentSeries.colorIndex));
  24205. if (!styledMode) {
  24206. label.attr({
  24207. stroke: (options.borderColor ||
  24208. point.color ||
  24209. currentSeries.color ||
  24210. palette.neutralColor60)
  24211. });
  24212. }
  24213. tooltip.updatePosition({
  24214. plotX: x,
  24215. plotY: y,
  24216. negative: point.negative,
  24217. ttBelow: point.ttBelow,
  24218. h: anchor[2] || 0
  24219. });
  24220. }
  24221. else {
  24222. tooltip.hide();
  24223. return;
  24224. }
  24225. }
  24226. // show it
  24227. if (tooltip.isHidden && tooltip.label) {
  24228. tooltip.label.attr({
  24229. opacity: 1
  24230. }).show();
  24231. }
  24232. tooltip.isHidden = false;
  24233. }
  24234. fireEvent(this, 'refresh');
  24235. };
  24236. /**
  24237. * Render the split tooltip. Loops over each point's text and adds
  24238. * a label next to the point, then uses the distribute function to
  24239. * find best non-overlapping positions.
  24240. *
  24241. * @private
  24242. * @function Highcharts.Tooltip#renderSplit
  24243. *
  24244. * @param {string|Array<(boolean|string)>} labels
  24245. *
  24246. * @param {Array<Highcharts.Point>} points
  24247. */
  24248. Tooltip.prototype.renderSplit = function (labels, points) {
  24249. var tooltip = this;
  24250. var chart = tooltip.chart,
  24251. _a = tooltip.chart,
  24252. chartWidth = _a.chartWidth,
  24253. chartHeight = _a.chartHeight,
  24254. plotHeight = _a.plotHeight,
  24255. plotLeft = _a.plotLeft,
  24256. plotTop = _a.plotTop,
  24257. pointer = _a.pointer,
  24258. _b = _a.scrollablePixelsY,
  24259. scrollablePixelsY = _b === void 0 ? 0 : _b,
  24260. scrollablePixelsX = _a.scrollablePixelsX,
  24261. _c = _a.scrollingContainer,
  24262. _d = _c === void 0 ? { scrollLeft: 0,
  24263. scrollTop: 0 } : _c,
  24264. scrollLeft = _d.scrollLeft,
  24265. scrollTop = _d.scrollTop,
  24266. styledMode = _a.styledMode,
  24267. distance = tooltip.distance,
  24268. options = tooltip.options,
  24269. positioner = tooltip.options.positioner;
  24270. // The area which the tooltip should be limited to. Limit to scrollable
  24271. // plot area if enabled, otherwise limit to the chart container.
  24272. // If outside is true it should be the whole viewport
  24273. var bounds = tooltip.outside && typeof scrollablePixelsX !== 'number' ?
  24274. doc.documentElement.getBoundingClientRect() : {
  24275. left: scrollLeft,
  24276. right: scrollLeft + chartWidth,
  24277. top: scrollTop,
  24278. bottom: scrollTop + chartHeight
  24279. };
  24280. var tooltipLabel = tooltip.getLabel();
  24281. var ren = this.renderer || chart.renderer;
  24282. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  24283. var _e = pointer.getChartPosition(),
  24284. chartLeft = _e.left,
  24285. chartTop = _e.top;
  24286. var distributionBoxTop = plotTop + scrollTop;
  24287. var headerHeight = 0;
  24288. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  24289. /**
  24290. * Calculates the anchor position for the partial tooltip
  24291. *
  24292. * @private
  24293. * @param {Highcharts.Point} point The point related to the tooltip
  24294. * @return {object} Returns an object with anchorX and anchorY
  24295. */
  24296. function getAnchor(point) {
  24297. var isHeader = point.isHeader,
  24298. _a = point.plotX,
  24299. plotX = _a === void 0 ? 0 : _a,
  24300. _b = point.plotY,
  24301. plotY = _b === void 0 ? 0 : _b,
  24302. series = point.series;
  24303. var anchorX;
  24304. var anchorY;
  24305. if (isHeader) {
  24306. // Set anchorX to plotX
  24307. anchorX = plotLeft + plotX;
  24308. // Set anchorY to center of visible plot area.
  24309. anchorY = plotTop + plotHeight / 2;
  24310. }
  24311. else {
  24312. var xAxis = series.xAxis,
  24313. yAxis = series.yAxis;
  24314. // Set anchorX to plotX. Limit to within xAxis.
  24315. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  24316. // Set anchorY, limit to the scrollable plot area
  24317. if (series.shouldShowTooltip(0, yAxis.pos - plotTop + plotY, {
  24318. ignoreX: true
  24319. })) {
  24320. anchorY = yAxis.pos + plotY;
  24321. }
  24322. }
  24323. // Limit values to plot area
  24324. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  24325. return { anchorX: anchorX, anchorY: anchorY };
  24326. }
  24327. /**
  24328. * Calculates the position of the partial tooltip
  24329. *
  24330. * @private
  24331. * @param {number} anchorX The partial tooltip anchor x position
  24332. * @param {number} anchorY The partial tooltip anchor y position
  24333. * @param {boolean} isHeader Whether the partial tooltip is a header
  24334. * @param {number} boxWidth Width of the partial tooltip
  24335. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  24336. * y position
  24337. */
  24338. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  24339. if (alignedLeft === void 0) { alignedLeft = true; }
  24340. var y;
  24341. var x;
  24342. if (isHeader) {
  24343. y = headerTop ? 0 : adjustedPlotHeight;
  24344. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth - (tooltip.outside ? chartLeft : 0));
  24345. }
  24346. else {
  24347. y = anchorY - distributionBoxTop;
  24348. x = alignedLeft ?
  24349. anchorX - boxWidth - distance :
  24350. anchorX + distance;
  24351. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  24352. }
  24353. // NOTE: y is relative to distributionBoxTop
  24354. return { x: x, y: y };
  24355. }
  24356. /**
  24357. * Updates the attributes and styling of the partial tooltip. Creates a
  24358. * new partial tooltip if it does not exists.
  24359. *
  24360. * @private
  24361. * @param {Highcharts.SVGElement|undefined} partialTooltip
  24362. * The partial tooltip to update
  24363. * @param {Highcharts.Point} point
  24364. * The point related to the partial tooltip
  24365. * @param {boolean|string} str The text for the partial tooltip
  24366. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  24367. */
  24368. function updatePartialTooltip(partialTooltip, point, str) {
  24369. var tt = partialTooltip;
  24370. var isHeader = point.isHeader,
  24371. series = point.series;
  24372. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  24373. if (!tt) {
  24374. var attribs = {
  24375. padding: options.padding,
  24376. r: options.borderRadius
  24377. };
  24378. if (!styledMode) {
  24379. attribs.fill = options.backgroundColor;
  24380. attribs['stroke-width'] = options.borderWidth;
  24381. }
  24382. tt = ren
  24383. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  24384. 'callout', void 0, void 0, options.useHTML)
  24385. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  24386. 'highcharts-tooltip-box ' +
  24387. colorClass)
  24388. .attr(attribs)
  24389. .add(tooltipLabel);
  24390. }
  24391. tt.isActive = true;
  24392. tt.attr({
  24393. text: str
  24394. });
  24395. if (!styledMode) {
  24396. tt.css(options.style)
  24397. .shadow(options.shadow)
  24398. .attr({
  24399. stroke: (options.borderColor ||
  24400. point.color ||
  24401. series.color ||
  24402. palette.neutralColor80)
  24403. });
  24404. }
  24405. return tt;
  24406. }
  24407. // Graceful degradation for legacy formatters
  24408. if (isString(labels)) {
  24409. labels = [false, labels];
  24410. }
  24411. // Create the individual labels for header and points, ignore footer
  24412. var boxes = labels.slice(0,
  24413. points.length + 1).reduce(function (boxes,
  24414. str,
  24415. i) {
  24416. if (str !== false && str !== '') {
  24417. var point = (points[i - 1] ||
  24418. {
  24419. // Item 0 is the header. Instead of this, we could also
  24420. // use the crosshair label
  24421. isHeader: true,
  24422. plotX: points[0].plotX,
  24423. plotY: plotHeight,
  24424. series: {}
  24425. });
  24426. var isHeader = point.isHeader;
  24427. // Store the tooltip label referance on the series
  24428. var owner = isHeader ? tooltip : point.series;
  24429. var tt = owner.tt = updatePartialTooltip(owner.tt,
  24430. point,
  24431. str.toString());
  24432. // Get X position now, so we can move all to the other side in
  24433. // case of overflow
  24434. var bBox = tt.getBBox();
  24435. var boxWidth = bBox.width + tt.strokeWidth();
  24436. if (isHeader) {
  24437. headerHeight = bBox.height;
  24438. adjustedPlotHeight += headerHeight;
  24439. if (headerTop) {
  24440. distributionBoxTop -= headerHeight;
  24441. }
  24442. }
  24443. var _a = getAnchor(point),
  24444. anchorX = _a.anchorX,
  24445. anchorY = _a.anchorY;
  24446. if (typeof anchorY === 'number') {
  24447. var size = bBox.height + 1;
  24448. var boxPosition = (positioner ?
  24449. positioner.call(tooltip,
  24450. boxWidth,
  24451. size,
  24452. point) :
  24453. defaultPositioner(anchorX,
  24454. anchorY,
  24455. isHeader,
  24456. boxWidth));
  24457. boxes.push({
  24458. // 0-align to the top, 1-align to the bottom
  24459. align: positioner ? 0 : void 0,
  24460. anchorX: anchorX,
  24461. anchorY: anchorY,
  24462. boxWidth: boxWidth,
  24463. point: point,
  24464. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  24465. size: size,
  24466. target: boxPosition.y,
  24467. tt: tt,
  24468. x: boxPosition.x
  24469. });
  24470. }
  24471. else {
  24472. // Hide tooltips which anchorY is outside the visible plot
  24473. // area
  24474. tt.isActive = false;
  24475. }
  24476. }
  24477. return boxes;
  24478. }, []);
  24479. // Realign the tooltips towards the right if there is not enough
  24480. // space to the left and there is space to to the right
  24481. if (!positioner && boxes.some(function (box) {
  24482. // Always realign if the beginning of a label is outside bounds
  24483. var outside = tooltip.outside;
  24484. var boxStart = (outside ? chartLeft : 0) + box.anchorX;
  24485. if (boxStart < bounds.left && boxStart + box.boxWidth < bounds.right) {
  24486. return true;
  24487. }
  24488. // Otherwise, check if there is more space available to the right
  24489. return boxStart < (chartLeft - bounds.left) + box.boxWidth &&
  24490. bounds.right - boxStart > boxStart;
  24491. })) {
  24492. boxes = boxes.map(function (box) {
  24493. var _a = defaultPositioner(box.anchorX,
  24494. box.anchorY,
  24495. box.point.isHeader,
  24496. box.boxWidth,
  24497. false),
  24498. x = _a.x,
  24499. y = _a.y;
  24500. return extend(box, {
  24501. target: y,
  24502. x: x
  24503. });
  24504. });
  24505. }
  24506. // Clean previous run (for missing points)
  24507. tooltip.cleanSplit();
  24508. // Distribute and put in place
  24509. H.distribute(boxes, adjustedPlotHeight);
  24510. var boxExtremes = {
  24511. left: chartLeft,
  24512. right: chartLeft
  24513. };
  24514. // Get the extremes from series tooltips
  24515. boxes.forEach(function (box) {
  24516. var x = box.x,
  24517. boxWidth = box.boxWidth,
  24518. isHeader = box.isHeader;
  24519. if (!isHeader) {
  24520. if (tooltip.outside && chartLeft + x < boxExtremes.left) {
  24521. boxExtremes.left = chartLeft + x;
  24522. }
  24523. if (!isHeader && tooltip.outside && boxExtremes.left + boxWidth > boxExtremes.right) {
  24524. boxExtremes.right = chartLeft + x;
  24525. }
  24526. }
  24527. });
  24528. boxes.forEach(function (box) {
  24529. var x = box.x,
  24530. anchorX = box.anchorX,
  24531. anchorY = box.anchorY,
  24532. pos = box.pos,
  24533. isHeader = box.point.isHeader;
  24534. var attributes = {
  24535. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  24536. x: x,
  24537. /* NOTE: y should equal pos to be consistent with !split
  24538. * tooltip,
  24539. but is currently relative to plotTop. Is left as is
  24540. * to avoid breaking change. Remove distributionBoxTop to make
  24541. * it consistent.
  24542. */
  24543. y: pos + distributionBoxTop,
  24544. anchorX: anchorX,
  24545. anchorY: anchorY
  24546. };
  24547. // Handle left-aligned tooltips overflowing the chart area
  24548. if (tooltip.outside && x < anchorX) {
  24549. var offset = chartLeft - boxExtremes.left;
  24550. // Skip this if there is no overflow
  24551. if (offset > 0) {
  24552. if (!isHeader) {
  24553. attributes.x = x + offset;
  24554. attributes.anchorX = anchorX + offset;
  24555. }
  24556. if (isHeader) {
  24557. attributes.x = (boxExtremes.right - boxExtremes.left) / 2;
  24558. attributes.anchorX = anchorX + offset;
  24559. }
  24560. }
  24561. }
  24562. // Put the label in place
  24563. box.tt.attr(attributes);
  24564. });
  24565. /* If we have a seperate tooltip container, then update the necessary
  24566. * container properties.
  24567. * Test that tooltip has its own container and renderer before executing
  24568. * the operation.
  24569. */
  24570. var container = tooltip.container,
  24571. outside = tooltip.outside,
  24572. renderer = tooltip.renderer;
  24573. if (outside && container && renderer) {
  24574. // Set container size to fit the bounds
  24575. var _f = tooltipLabel.getBBox(),
  24576. width = _f.width,
  24577. height = _f.height,
  24578. x = _f.x,
  24579. y = _f.y;
  24580. renderer.setSize(width + x, height + y, false);
  24581. // Position the tooltip container to the chart container
  24582. container.style.left = boxExtremes.left + 'px';
  24583. container.style.top = chartTop + 'px';
  24584. }
  24585. };
  24586. /**
  24587. * If the `stickOnContact` option is active, this will add a tracker shape.
  24588. *
  24589. * @private
  24590. * @function Highcharts.Tooltip#drawTracker
  24591. */
  24592. Tooltip.prototype.drawTracker = function () {
  24593. var tooltip = this;
  24594. if (tooltip.followPointer ||
  24595. !tooltip.options.stickOnContact) {
  24596. if (tooltip.tracker) {
  24597. tooltip.tracker.destroy();
  24598. }
  24599. return;
  24600. }
  24601. var chart = tooltip.chart;
  24602. var label = tooltip.label;
  24603. var point = chart.hoverPoint;
  24604. if (!label || !point) {
  24605. return;
  24606. }
  24607. var box = {
  24608. x: 0,
  24609. y: 0,
  24610. width: 0,
  24611. height: 0
  24612. };
  24613. // Combine anchor and tooltip
  24614. var anchorPos = this.getAnchor(point);
  24615. var labelBBox = label.getBBox();
  24616. anchorPos[0] += chart.plotLeft - label.translateX;
  24617. anchorPos[1] += chart.plotTop - label.translateY;
  24618. // When the mouse pointer is between the anchor point and the label,
  24619. // the label should stick.
  24620. box.x = Math.min(0, anchorPos[0]);
  24621. box.y = Math.min(0, anchorPos[1]);
  24622. box.width = (anchorPos[0] < 0 ?
  24623. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  24624. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  24625. box.height = (anchorPos[1] < 0 ?
  24626. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  24627. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  24628. if (tooltip.tracker) {
  24629. tooltip.tracker.attr(box);
  24630. }
  24631. else {
  24632. tooltip.tracker = label.renderer
  24633. .rect(box)
  24634. .addClass('highcharts-tracker')
  24635. .add(label);
  24636. if (!chart.styledMode) {
  24637. tooltip.tracker.attr({
  24638. fill: 'rgba(0,0,0,0)'
  24639. });
  24640. }
  24641. }
  24642. };
  24643. /**
  24644. * @private
  24645. */
  24646. Tooltip.prototype.styledModeFormat = function (formatString) {
  24647. return formatString
  24648. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  24649. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  24650. };
  24651. /**
  24652. * Format the footer/header of the tooltip
  24653. * #3397: abstraction to enable formatting of footer and header
  24654. *
  24655. * @private
  24656. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  24657. * @param {Highcharts.PointLabelObject} labelConfig
  24658. * @param {boolean} [isFooter]
  24659. * @return {string}
  24660. */
  24661. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  24662. var footOrHead = isFooter ? 'footer' : 'header',
  24663. series = labelConfig.series,
  24664. tooltipOptions = series.tooltipOptions,
  24665. xDateFormat = tooltipOptions.xDateFormat,
  24666. xAxis = series.xAxis,
  24667. isDateTime = (xAxis &&
  24668. xAxis.options.type === 'datetime' &&
  24669. isNumber(labelConfig.key)),
  24670. formatString = tooltipOptions[footOrHead + 'Format'],
  24671. e = {
  24672. isFooter: isFooter,
  24673. labelConfig: labelConfig
  24674. };
  24675. fireEvent(this, 'headerFormatter', e, function (e) {
  24676. // Guess the best date format based on the closest point distance
  24677. // (#568, #3418)
  24678. if (isDateTime && !xDateFormat) {
  24679. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  24680. }
  24681. // Insert the footer date format if any
  24682. if (isDateTime && xDateFormat) {
  24683. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  24684. ['key']).forEach(function (key) {
  24685. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  24686. });
  24687. }
  24688. // Replace default header style with class name
  24689. if (series.chart.styledMode) {
  24690. formatString = this.styledModeFormat(formatString);
  24691. }
  24692. e.text = format(formatString, {
  24693. point: labelConfig,
  24694. series: series
  24695. }, this.chart);
  24696. });
  24697. return e.text;
  24698. };
  24699. /**
  24700. * Updates the tooltip with the provided tooltip options.
  24701. *
  24702. * @function Highcharts.Tooltip#update
  24703. *
  24704. * @param {Highcharts.TooltipOptions} options
  24705. * The tooltip options to update.
  24706. */
  24707. Tooltip.prototype.update = function (options) {
  24708. this.destroy();
  24709. // Update user options (#6218)
  24710. merge(true, this.chart.options.tooltip.userOptions, options);
  24711. this.init(this.chart, merge(true, this.options, options));
  24712. };
  24713. /**
  24714. * Find the new position and perform the move
  24715. *
  24716. * @private
  24717. * @function Highcharts.Tooltip#updatePosition
  24718. *
  24719. * @param {Highcharts.Point} point
  24720. */
  24721. Tooltip.prototype.updatePosition = function (point) {
  24722. var chart = this.chart,
  24723. pointer = chart.pointer,
  24724. label = this.getLabel(),
  24725. pos,
  24726. anchorX = point.plotX + chart.plotLeft,
  24727. anchorY = point.plotY + chart.plotTop,
  24728. pad;
  24729. // Needed for outside: true (#11688)
  24730. var chartPosition = pointer.getChartPosition();
  24731. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  24732. // Set the renderer size dynamically to prevent document size to change
  24733. if (this.outside) {
  24734. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  24735. this.renderer.setSize(label.width + pad, label.height + pad, false);
  24736. // Anchor and tooltip container need scaling if chart container has
  24737. // scale transform/css zoom. #11329.
  24738. if (chartPosition.scaleX !== 1 || chartPosition.scaleY !== 1) {
  24739. css(this.container, {
  24740. transform: "scale(" + chartPosition.scaleX + ", " + chartPosition.scaleY + ")"
  24741. });
  24742. anchorX *= chartPosition.scaleX;
  24743. anchorY *= chartPosition.scaleY;
  24744. }
  24745. anchorX += chartPosition.left - pos.x;
  24746. anchorY += chartPosition.top - pos.y;
  24747. }
  24748. // do the move
  24749. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  24750. anchorX, anchorY);
  24751. };
  24752. return Tooltip;
  24753. }());
  24754. H.Tooltip = Tooltip;
  24755. return H.Tooltip;
  24756. });
  24757. _registerModule(_modules, 'Core/Pointer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (Color, H, Palette, Tooltip, U) {
  24758. /* *
  24759. *
  24760. * (c) 2010-2021 Torstein Honsi
  24761. *
  24762. * License: www.highcharts.com/license
  24763. *
  24764. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24765. *
  24766. * */
  24767. var color = Color.parse;
  24768. var charts = H.charts,
  24769. noop = H.noop;
  24770. var addEvent = U.addEvent,
  24771. attr = U.attr,
  24772. css = U.css,
  24773. defined = U.defined,
  24774. extend = U.extend,
  24775. find = U.find,
  24776. fireEvent = U.fireEvent,
  24777. isNumber = U.isNumber,
  24778. isObject = U.isObject,
  24779. objectEach = U.objectEach,
  24780. offset = U.offset,
  24781. pick = U.pick,
  24782. splat = U.splat;
  24783. /* *
  24784. *
  24785. * Class
  24786. *
  24787. * */
  24788. /* eslint-disable no-invalid-this, valid-jsdoc */
  24789. /**
  24790. * The mouse and touch tracker object. Each {@link Chart} item has one
  24791. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  24792. * property.
  24793. *
  24794. * @class
  24795. * @name Highcharts.Pointer
  24796. *
  24797. * @param {Highcharts.Chart} chart
  24798. * The chart instance.
  24799. *
  24800. * @param {Highcharts.Options} options
  24801. * The root options object. The pointer uses options from the chart and tooltip
  24802. * structures.
  24803. */
  24804. var Pointer = /** @class */ (function () {
  24805. /* *
  24806. *
  24807. * Constructors
  24808. *
  24809. * */
  24810. function Pointer(chart, options) {
  24811. this.lastValidTouch = {};
  24812. this.pinchDown = [];
  24813. this.runChartClick = false;
  24814. this.eventsToUnbind = [];
  24815. this.chart = chart;
  24816. this.hasDragged = false;
  24817. this.options = options;
  24818. this.init(chart, options);
  24819. }
  24820. /* *
  24821. *
  24822. * Functions
  24823. *
  24824. * */
  24825. /**
  24826. * Set inactive state to all series that are not currently hovered,
  24827. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  24828. * all points within that series.
  24829. *
  24830. * @private
  24831. * @function Highcharts.Pointer#applyInactiveState
  24832. *
  24833. * @param {Array<Highcharts.Point>} points
  24834. * Currently hovered points
  24835. */
  24836. Pointer.prototype.applyInactiveState = function (points) {
  24837. var activeSeries = [],
  24838. series;
  24839. // Get all active series from the hovered points
  24840. (points || []).forEach(function (item) {
  24841. series = item.series;
  24842. // Include itself
  24843. activeSeries.push(series);
  24844. // Include parent series
  24845. if (series.linkedParent) {
  24846. activeSeries.push(series.linkedParent);
  24847. }
  24848. // Include all child series
  24849. if (series.linkedSeries) {
  24850. activeSeries = activeSeries.concat(series.linkedSeries);
  24851. }
  24852. // Include navigator series
  24853. if (series.navigatorSeries) {
  24854. activeSeries.push(series.navigatorSeries);
  24855. }
  24856. });
  24857. // Now loop over all series, filtering out active series
  24858. this.chart.series.forEach(function (inactiveSeries) {
  24859. if (activeSeries.indexOf(inactiveSeries) === -1) {
  24860. // Inactive series
  24861. inactiveSeries.setState('inactive', true);
  24862. }
  24863. else if (inactiveSeries.options.inactiveOtherPoints) {
  24864. // Active series, but other points should be inactivated
  24865. inactiveSeries.setAllPointsToState('inactive');
  24866. }
  24867. });
  24868. };
  24869. /**
  24870. * Destroys the Pointer object and disconnects DOM events.
  24871. *
  24872. * @function Highcharts.Pointer#destroy
  24873. */
  24874. Pointer.prototype.destroy = function () {
  24875. var pointer = this;
  24876. this.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  24877. this.eventsToUnbind = [];
  24878. if (!H.chartCount) {
  24879. if (Pointer.unbindDocumentMouseUp) {
  24880. Pointer.unbindDocumentMouseUp = Pointer.unbindDocumentMouseUp();
  24881. }
  24882. if (Pointer.unbindDocumentTouchEnd) {
  24883. Pointer.unbindDocumentTouchEnd = Pointer.unbindDocumentTouchEnd();
  24884. }
  24885. }
  24886. // memory and CPU leak
  24887. clearInterval(pointer.tooltipTimeout);
  24888. objectEach(pointer, function (_val, prop) {
  24889. pointer[prop] = void 0;
  24890. });
  24891. };
  24892. /**
  24893. * Perform a drag operation in response to a mousemove event while the mouse
  24894. * is down.
  24895. * @private
  24896. * @function Highcharts.Pointer#drag
  24897. */
  24898. Pointer.prototype.drag = function (e) {
  24899. var chart = this.chart,
  24900. chartOptions = chart.options.chart,
  24901. zoomHor = this.zoomHor,
  24902. zoomVert = this.zoomVert,
  24903. plotLeft = chart.plotLeft,
  24904. plotTop = chart.plotTop,
  24905. plotWidth = chart.plotWidth,
  24906. plotHeight = chart.plotHeight,
  24907. mouseDownX = (this.mouseDownX || 0),
  24908. mouseDownY = (this.mouseDownY || 0),
  24909. panningEnabled = isObject(chartOptions.panning) ?
  24910. chartOptions.panning && chartOptions.panning.enabled :
  24911. chartOptions.panning,
  24912. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  24913. var chartX = e.chartX,
  24914. chartY = e.chartY,
  24915. clickedInside,
  24916. size,
  24917. selectionMarker = this.selectionMarker;
  24918. // If the device supports both touch and mouse (like IE11), and we are
  24919. // touch-dragging inside the plot area, don't handle the mouse event.
  24920. // #4339.
  24921. if (selectionMarker && selectionMarker.touch) {
  24922. return;
  24923. }
  24924. // If the mouse is outside the plot area, adjust to cooordinates
  24925. // inside to prevent the selection marker from going outside
  24926. if (chartX < plotLeft) {
  24927. chartX = plotLeft;
  24928. }
  24929. else if (chartX > plotLeft + plotWidth) {
  24930. chartX = plotLeft + plotWidth;
  24931. }
  24932. if (chartY < plotTop) {
  24933. chartY = plotTop;
  24934. }
  24935. else if (chartY > plotTop + plotHeight) {
  24936. chartY = plotTop + plotHeight;
  24937. }
  24938. // determine if the mouse has moved more than 10px
  24939. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  24940. Math.pow(mouseDownY - chartY, 2));
  24941. if (this.hasDragged > 10) {
  24942. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop, {
  24943. visiblePlotOnly: true
  24944. });
  24945. // make a selection
  24946. if (chart.hasCartesianSeries &&
  24947. (this.zoomX || this.zoomY) &&
  24948. clickedInside &&
  24949. !panKey) {
  24950. if (!selectionMarker) {
  24951. this.selectionMarker = selectionMarker =
  24952. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  24953. .attr({
  24954. 'class': 'highcharts-selection-marker',
  24955. zIndex: 7
  24956. })
  24957. .add();
  24958. if (!chart.styledMode) {
  24959. selectionMarker.attr({
  24960. fill: (chartOptions.selectionMarkerFill ||
  24961. color(Palette.highlightColor80)
  24962. .setOpacity(0.25).get())
  24963. });
  24964. }
  24965. }
  24966. }
  24967. // adjust the width of the selection marker
  24968. if (selectionMarker && zoomHor) {
  24969. size = chartX - mouseDownX;
  24970. selectionMarker.attr({
  24971. width: Math.abs(size),
  24972. x: (size > 0 ? 0 : size) + mouseDownX
  24973. });
  24974. }
  24975. // adjust the height of the selection marker
  24976. if (selectionMarker && zoomVert) {
  24977. size = chartY - mouseDownY;
  24978. selectionMarker.attr({
  24979. height: Math.abs(size),
  24980. y: (size > 0 ? 0 : size) + mouseDownY
  24981. });
  24982. }
  24983. // panning
  24984. if (clickedInside &&
  24985. !selectionMarker &&
  24986. panningEnabled) {
  24987. chart.pan(e, chartOptions.panning);
  24988. }
  24989. }
  24990. };
  24991. /**
  24992. * Start a drag operation.
  24993. * @private
  24994. * @function Highcharts.Pointer#dragStart
  24995. */
  24996. Pointer.prototype.dragStart = function (e) {
  24997. var chart = this.chart;
  24998. // Record the start position
  24999. chart.mouseIsDown = e.type;
  25000. chart.cancelClick = false;
  25001. chart.mouseDownX = this.mouseDownX = e.chartX;
  25002. chart.mouseDownY = this.mouseDownY = e.chartY;
  25003. };
  25004. /**
  25005. * On mouse up or touch end across the entire document, drop the selection.
  25006. * @private
  25007. * @function Highcharts.Pointer#drop
  25008. */
  25009. Pointer.prototype.drop = function (e) {
  25010. var pointer = this,
  25011. chart = this.chart,
  25012. hasPinched = this.hasPinched;
  25013. if (this.selectionMarker) {
  25014. var selectionData_1 = {
  25015. originalEvent: e,
  25016. xAxis: [],
  25017. yAxis: []
  25018. },
  25019. selectionBox = this.selectionMarker,
  25020. selectionLeft_1 = selectionBox.attr ?
  25021. selectionBox.attr('x') :
  25022. selectionBox.x,
  25023. selectionTop_1 = selectionBox.attr ?
  25024. selectionBox.attr('y') :
  25025. selectionBox.y,
  25026. selectionWidth_1 = selectionBox.attr ?
  25027. selectionBox.attr('width') :
  25028. selectionBox.width,
  25029. selectionHeight_1 = selectionBox.attr ?
  25030. selectionBox.attr('height') :
  25031. selectionBox.height;
  25032. var runZoom_1;
  25033. // a selection has been made
  25034. if (this.hasDragged || hasPinched) {
  25035. // record each axis' min and max
  25036. chart.axes.forEach(function (axis) {
  25037. if (axis.zoomEnabled &&
  25038. defined(axis.min) &&
  25039. (hasPinched ||
  25040. pointer[{
  25041. xAxis: 'zoomX',
  25042. yAxis: 'zoomY'
  25043. }[axis.coll]]) &&
  25044. isNumber(selectionLeft_1) &&
  25045. isNumber(selectionTop_1)) { // #859, #3569
  25046. var horiz = axis.horiz,
  25047. minPixelPadding = e.type === 'touchend' ?
  25048. axis.minPixelPadding :
  25049. 0, // #1207, #3075
  25050. selectionMin = axis.toValue((horiz ? selectionLeft_1 : selectionTop_1) +
  25051. minPixelPadding),
  25052. selectionMax = axis.toValue((horiz ?
  25053. selectionLeft_1 + selectionWidth_1 :
  25054. selectionTop_1 + selectionHeight_1) - minPixelPadding);
  25055. selectionData_1[axis.coll].push({
  25056. axis: axis,
  25057. // Min/max for reversed axes
  25058. min: Math.min(selectionMin, selectionMax),
  25059. max: Math.max(selectionMin, selectionMax)
  25060. });
  25061. runZoom_1 = true;
  25062. }
  25063. });
  25064. if (runZoom_1) {
  25065. fireEvent(chart, 'selection', selectionData_1, function (args) {
  25066. chart.zoom(extend(args, hasPinched ?
  25067. { animation: false } :
  25068. null));
  25069. });
  25070. }
  25071. }
  25072. if (isNumber(chart.index)) {
  25073. this.selectionMarker = this.selectionMarker.destroy();
  25074. }
  25075. // Reset scaling preview
  25076. if (hasPinched) {
  25077. this.scaleGroups();
  25078. }
  25079. }
  25080. // Reset all. Check isNumber because it may be destroyed on mouse up
  25081. // (#877)
  25082. if (chart && isNumber(chart.index)) {
  25083. css(chart.container, { cursor: chart._cursor });
  25084. chart.cancelClick = this.hasDragged > 10; // #370
  25085. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  25086. this.pinchDown = [];
  25087. }
  25088. };
  25089. /**
  25090. * Finds the closest point to a set of coordinates, using the k-d-tree
  25091. * algorithm.
  25092. *
  25093. * @function Highcharts.Pointer#findNearestKDPoint
  25094. *
  25095. * @param {Array<Highcharts.Series>} series
  25096. * All the series to search in.
  25097. *
  25098. * @param {boolean|undefined} shared
  25099. * Whether it is a shared tooltip or not.
  25100. *
  25101. * @param {Highcharts.PointerEventObject} e
  25102. * The pointer event object, containing chart coordinates of the pointer.
  25103. *
  25104. * @return {Highcharts.Point|undefined}
  25105. * The point closest to given coordinates.
  25106. */
  25107. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  25108. var chart = this.chart;
  25109. var hoverPoint = chart.hoverPoint;
  25110. var tooltip = chart.tooltip;
  25111. if (hoverPoint &&
  25112. tooltip &&
  25113. tooltip.isStickyOnContact()) {
  25114. return hoverPoint;
  25115. }
  25116. var closest;
  25117. /** @private */
  25118. function sort(p1, p2) {
  25119. var isCloserX = p1.distX - p2.distX,
  25120. isCloser = p1.dist - p2.dist,
  25121. isAbove = ((p2.series.group && p2.series.group.zIndex) -
  25122. (p1.series.group && p1.series.group.zIndex));
  25123. var result;
  25124. // We have two points which are not in the same place on xAxis
  25125. // and shared tooltip:
  25126. if (isCloserX !== 0 && shared) { // #5721
  25127. result = isCloserX;
  25128. // Points are not exactly in the same place on x/yAxis:
  25129. }
  25130. else if (isCloser !== 0) {
  25131. result = isCloser;
  25132. // The same xAxis and yAxis position, sort by z-index:
  25133. }
  25134. else if (isAbove !== 0) {
  25135. result = isAbove;
  25136. // The same zIndex, sort by array index:
  25137. }
  25138. else {
  25139. result =
  25140. p1.series.index > p2.series.index ?
  25141. -1 :
  25142. 1;
  25143. }
  25144. return result;
  25145. }
  25146. series.forEach(function (s) {
  25147. var noSharedTooltip = s.noSharedTooltip && shared,
  25148. compareX = (!noSharedTooltip &&
  25149. s.options.findNearestPointBy.indexOf('y') < 0),
  25150. point = s.searchPoint(e,
  25151. compareX);
  25152. if ( // Check that we actually found a point on the series.
  25153. isObject(point, true) && point.series &&
  25154. // Use the new point if it is closer.
  25155. (!isObject(closest, true) ||
  25156. (sort(closest, point) > 0))) {
  25157. closest = point;
  25158. }
  25159. });
  25160. return closest;
  25161. };
  25162. /**
  25163. * @private
  25164. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  25165. */
  25166. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  25167. var series = point.series,
  25168. xAxis = series.xAxis,
  25169. yAxis = series.yAxis,
  25170. shapeArgs = point.shapeArgs;
  25171. if (xAxis && yAxis) {
  25172. var x = pick(point.clientX,
  25173. point.plotX);
  25174. var y = point.plotY || 0;
  25175. if (point.isNode &&
  25176. shapeArgs &&
  25177. isNumber(shapeArgs.x) &&
  25178. isNumber(shapeArgs.y)) {
  25179. x = shapeArgs.x;
  25180. y = shapeArgs.y;
  25181. }
  25182. return inverted ? {
  25183. chartX: yAxis.len + yAxis.pos - y,
  25184. chartY: xAxis.len + xAxis.pos - x
  25185. } : {
  25186. chartX: x + xAxis.pos,
  25187. chartY: y + yAxis.pos
  25188. };
  25189. }
  25190. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  25191. // E.g. pies do not have axes
  25192. return {
  25193. chartX: shapeArgs.x,
  25194. chartY: shapeArgs.y
  25195. };
  25196. }
  25197. };
  25198. /**
  25199. * Return the cached chartPosition if it is available on the Pointer,
  25200. * otherwise find it. Running offset is quite expensive, so it should be
  25201. * avoided when we know the chart hasn't moved.
  25202. *
  25203. * @function Highcharts.Pointer#getChartPosition
  25204. *
  25205. * @return {Highcharts.ChartPositionObject}
  25206. * The offset of the chart container within the page
  25207. */
  25208. Pointer.prototype.getChartPosition = function () {
  25209. if (this.chartPosition) {
  25210. return this.chartPosition;
  25211. }
  25212. var container = this.chart.container;
  25213. var pos = offset(container);
  25214. this.chartPosition = {
  25215. left: pos.left,
  25216. top: pos.top,
  25217. scaleX: 1,
  25218. scaleY: 1
  25219. };
  25220. var offsetWidth = container.offsetWidth;
  25221. var offsetHeight = container.offsetHeight;
  25222. // #13342 - tooltip was not visible in Chrome, when chart
  25223. // updates height.
  25224. if (offsetWidth > 2 && // #13342
  25225. offsetHeight > 2 // #13342
  25226. ) {
  25227. this.chartPosition.scaleX = pos.width / offsetWidth;
  25228. this.chartPosition.scaleY = pos.height / offsetHeight;
  25229. }
  25230. return this.chartPosition;
  25231. };
  25232. /**
  25233. * Get the click position in terms of axis values.
  25234. *
  25235. * @function Highcharts.Pointer#getCoordinates
  25236. *
  25237. * @param {Highcharts.PointerEventObject} e
  25238. * Pointer event, extended with `chartX` and `chartY` properties.
  25239. *
  25240. * @return {Highcharts.PointerAxisCoordinatesObject}
  25241. */
  25242. Pointer.prototype.getCoordinates = function (e) {
  25243. var coordinates = {
  25244. xAxis: [],
  25245. yAxis: []
  25246. };
  25247. this.chart.axes.forEach(function (axis) {
  25248. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  25249. axis: axis,
  25250. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  25251. });
  25252. });
  25253. return coordinates;
  25254. };
  25255. /**
  25256. * Calculates what is the current hovered point/points and series.
  25257. *
  25258. * @private
  25259. * @function Highcharts.Pointer#getHoverData
  25260. *
  25261. * @param {Highcharts.Point|undefined} existingHoverPoint
  25262. * The point currrently beeing hovered.
  25263. *
  25264. * @param {Highcharts.Series|undefined} existingHoverSeries
  25265. * The series currently beeing hovered.
  25266. *
  25267. * @param {Array<Highcharts.Series>} series
  25268. * All the series in the chart.
  25269. *
  25270. * @param {boolean} isDirectTouch
  25271. * Is the pointer directly hovering the point.
  25272. *
  25273. * @param {boolean|undefined} shared
  25274. * Whether it is a shared tooltip or not.
  25275. *
  25276. * @param {Highcharts.PointerEventObject} [e]
  25277. * The triggering event, containing chart coordinates of the pointer.
  25278. *
  25279. * @return {object}
  25280. * Object containing resulting hover data: hoverPoint, hoverSeries, and
  25281. * hoverPoints.
  25282. */
  25283. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  25284. var hoverPoints = [],
  25285. useExisting = !!(isDirectTouch && existingHoverPoint),
  25286. filter = function (s) {
  25287. return (s.visible &&
  25288. !(!shared && s.directTouch) && // #3821
  25289. pick(s.options.enableMouseTracking,
  25290. true));
  25291. };
  25292. var hoverSeries = existingHoverSeries,
  25293. // Which series to look in for the hover point
  25294. searchSeries,
  25295. // Parameters needed for beforeGetHoverData event.
  25296. eventArgs = {
  25297. chartX: e ? e.chartX : void 0,
  25298. chartY: e ? e.chartY : void 0,
  25299. shared: shared
  25300. };
  25301. // Find chart.hoverPane and update filter method in polar.
  25302. fireEvent(this, 'beforeGetHoverData', eventArgs);
  25303. var notSticky = hoverSeries && !hoverSeries.stickyTracking;
  25304. searchSeries = notSticky ?
  25305. // Only search on hovered series if it has stickyTracking false
  25306. [hoverSeries] :
  25307. // Filter what series to look in.
  25308. series.filter(function (s) {
  25309. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  25310. s.stickyTracking;
  25311. });
  25312. // Use existing hovered point or find the one closest to coordinates.
  25313. var hoverPoint = useExisting || !e ?
  25314. existingHoverPoint :
  25315. this.findNearestKDPoint(searchSeries,
  25316. shared,
  25317. e);
  25318. // Assign hover series
  25319. hoverSeries = hoverPoint && hoverPoint.series;
  25320. // If we have a hoverPoint, assign hoverPoints.
  25321. if (hoverPoint) {
  25322. // When tooltip is shared, it displays more than one point
  25323. if (shared && !hoverSeries.noSharedTooltip) {
  25324. searchSeries = series.filter(function (s) {
  25325. return eventArgs.filter ?
  25326. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  25327. });
  25328. // Get all points with the same x value as the hoverPoint
  25329. searchSeries.forEach(function (s) {
  25330. var point = find(s.points,
  25331. function (p) {
  25332. return p.x === hoverPoint.x && !p.isNull;
  25333. });
  25334. if (isObject(point)) {
  25335. /*
  25336. * Boost returns a minimal point. Convert it to a usable
  25337. * point for tooltip and states.
  25338. */
  25339. if (s.chart.isBoosting) {
  25340. point = s.getPoint(point);
  25341. }
  25342. hoverPoints.push(point);
  25343. }
  25344. });
  25345. }
  25346. else {
  25347. hoverPoints.push(hoverPoint);
  25348. }
  25349. }
  25350. // Check whether the hoverPoint is inside pane we are hovering over.
  25351. eventArgs = { hoverPoint: hoverPoint };
  25352. fireEvent(this, 'afterGetHoverData', eventArgs);
  25353. return {
  25354. hoverPoint: eventArgs.hoverPoint,
  25355. hoverSeries: hoverSeries,
  25356. hoverPoints: hoverPoints
  25357. };
  25358. };
  25359. /**
  25360. * @private
  25361. * @function Highcharts.Pointer#getPointFromEvent
  25362. */
  25363. Pointer.prototype.getPointFromEvent = function (e) {
  25364. var target = e.target,
  25365. point;
  25366. while (target && !point) {
  25367. point = target.point;
  25368. target = target.parentNode;
  25369. }
  25370. return point;
  25371. };
  25372. /**
  25373. * @private
  25374. * @function Highcharts.Pointer#onTrackerMouseOut
  25375. */
  25376. Pointer.prototype.onTrackerMouseOut = function (e) {
  25377. var chart = this.chart;
  25378. var relatedTarget = e.relatedTarget || e.toElement;
  25379. var series = chart.hoverSeries;
  25380. this.isDirectTouch = false;
  25381. if (series &&
  25382. relatedTarget &&
  25383. !series.stickyTracking &&
  25384. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  25385. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  25386. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  25387. series.onMouseOut();
  25388. }
  25389. };
  25390. /**
  25391. * Utility to detect whether an element has, or has a parent with, a
  25392. * specificclass name. Used on detection of tracker objects and on deciding
  25393. * whether hovering the tooltip should cause the active series to mouse out.
  25394. *
  25395. * @function Highcharts.Pointer#inClass
  25396. *
  25397. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  25398. * The element to investigate.
  25399. *
  25400. * @param {string} className
  25401. * The class name to look for.
  25402. *
  25403. * @return {boolean|undefined}
  25404. * True if either the element or one of its parents has the given class
  25405. * name.
  25406. */
  25407. Pointer.prototype.inClass = function (element, className) {
  25408. var elemClassName;
  25409. while (element) {
  25410. elemClassName = attr(element, 'class');
  25411. if (elemClassName) {
  25412. if (elemClassName.indexOf(className) !== -1) {
  25413. return true;
  25414. }
  25415. if (elemClassName.indexOf('highcharts-container') !== -1) {
  25416. return false;
  25417. }
  25418. }
  25419. element = element.parentNode;
  25420. }
  25421. };
  25422. /**
  25423. * Initialize the Pointer.
  25424. *
  25425. * @private
  25426. * @function Highcharts.Pointer#init
  25427. *
  25428. * @param {Highcharts.Chart} chart
  25429. * The Chart instance.
  25430. *
  25431. * @param {Highcharts.Options} options
  25432. * The root options object. The pointer uses options from the chart and
  25433. * tooltip structures.
  25434. */
  25435. Pointer.prototype.init = function (chart, options) {
  25436. // Store references
  25437. this.options = options;
  25438. this.chart = chart;
  25439. // Do we need to handle click on a touch device?
  25440. this.runChartClick = Boolean(options.chart.events && options.chart.events.click);
  25441. this.pinchDown = [];
  25442. this.lastValidTouch = {};
  25443. if (Tooltip) {
  25444. /**
  25445. * Tooltip object for points of series.
  25446. *
  25447. * @name Highcharts.Chart#tooltip
  25448. * @type {Highcharts.Tooltip}
  25449. */
  25450. chart.tooltip = new Tooltip(chart, options.tooltip);
  25451. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  25452. }
  25453. this.setDOMEvents();
  25454. };
  25455. /**
  25456. * Takes a browser event object and extends it with custom Highcharts
  25457. * properties `chartX` and `chartY` in order to work on the internal
  25458. * coordinate system.
  25459. *
  25460. * @function Highcharts.Pointer#normalize
  25461. *
  25462. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  25463. * Event object in standard browsers.
  25464. *
  25465. * @param {Highcharts.OffsetObject} [chartPosition]
  25466. * Additional chart offset.
  25467. *
  25468. * @return {Highcharts.PointerEventObject}
  25469. * A browser event with extended properties `chartX` and `chartY`.
  25470. */
  25471. Pointer.prototype.normalize = function (e, chartPosition) {
  25472. var touches = e.touches;
  25473. // iOS (#2757)
  25474. var ePos = (touches ?
  25475. touches.length ?
  25476. touches.item(0) :
  25477. (pick(// #13534
  25478. touches.changedTouches,
  25479. e.changedTouches))[0] :
  25480. e);
  25481. // Get mouse position
  25482. if (!chartPosition) {
  25483. chartPosition = this.getChartPosition();
  25484. }
  25485. var chartX = ePos.pageX - chartPosition.left,
  25486. chartY = ePos.pageY - chartPosition.top;
  25487. // #11329 - when there is scaling on a parent element, we need to take
  25488. // this into account
  25489. chartX /= chartPosition.scaleX;
  25490. chartY /= chartPosition.scaleY;
  25491. return extend(e, {
  25492. chartX: Math.round(chartX),
  25493. chartY: Math.round(chartY)
  25494. });
  25495. };
  25496. /**
  25497. * @private
  25498. * @function Highcharts.Pointer#onContainerClick
  25499. */
  25500. Pointer.prototype.onContainerClick = function (e) {
  25501. var chart = this.chart;
  25502. var hoverPoint = chart.hoverPoint;
  25503. var pEvt = this.normalize(e);
  25504. var plotLeft = chart.plotLeft;
  25505. var plotTop = chart.plotTop;
  25506. if (!chart.cancelClick) {
  25507. // On tracker click, fire the series and point events. #783, #1583
  25508. if (hoverPoint &&
  25509. this.inClass(pEvt.target, 'highcharts-tracker')) {
  25510. // the series click event
  25511. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  25512. point: hoverPoint
  25513. }));
  25514. // the point click event
  25515. if (chart.hoverPoint) { // it may be destroyed (#1844)
  25516. hoverPoint.firePointEvent('click', pEvt);
  25517. }
  25518. // When clicking outside a tracker, fire a chart event
  25519. }
  25520. else {
  25521. extend(pEvt, this.getCoordinates(pEvt));
  25522. // fire a click event in the chart
  25523. if (chart.isInsidePlot(pEvt.chartX - plotLeft, pEvt.chartY - plotTop, {
  25524. visiblePlotOnly: true
  25525. })) {
  25526. fireEvent(chart, 'click', pEvt);
  25527. }
  25528. }
  25529. }
  25530. };
  25531. /**
  25532. * @private
  25533. * @function Highcharts.Pointer#onContainerMouseDown
  25534. */
  25535. Pointer.prototype.onContainerMouseDown = function (e) {
  25536. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  25537. // Normalize before the 'if' for the legacy IE (#7850)
  25538. e = this.normalize(e);
  25539. // #11635, Firefox does not reliable fire move event after click scroll
  25540. if (H.isFirefox &&
  25541. e.button !== 0) {
  25542. this.onContainerMouseMove(e);
  25543. }
  25544. // #11635, limiting to primary button (incl. IE 8 support)
  25545. if (typeof e.button === 'undefined' ||
  25546. isPrimaryButton) {
  25547. this.zoomOption(e);
  25548. // #295, #13737 solve conflict between container drag and chart zoom
  25549. if (isPrimaryButton &&
  25550. e.preventDefault) {
  25551. e.preventDefault();
  25552. }
  25553. this.dragStart(e);
  25554. }
  25555. };
  25556. /**
  25557. * When mouse leaves the container, hide the tooltip.
  25558. * @private
  25559. * @function Highcharts.Pointer#onContainerMouseLeave
  25560. */
  25561. Pointer.prototype.onContainerMouseLeave = function (e) {
  25562. var chart = charts[pick(Pointer.hoverChartIndex, -1)];
  25563. var tooltip = this.chart.tooltip;
  25564. e = this.normalize(e);
  25565. // #4886, MS Touch end fires mouseleave but with no related target
  25566. if (chart &&
  25567. (e.relatedTarget || e.toElement)) {
  25568. chart.pointer.reset();
  25569. // Also reset the chart position, used in #149 fix
  25570. chart.pointer.chartPosition = void 0;
  25571. }
  25572. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  25573. tooltip &&
  25574. !tooltip.isHidden) {
  25575. this.reset();
  25576. }
  25577. };
  25578. /**
  25579. * When mouse enters the container, delete pointer's chartPosition.
  25580. * @private
  25581. * @function Highcharts.Pointer#onContainerMouseEnter
  25582. */
  25583. Pointer.prototype.onContainerMouseEnter = function (e) {
  25584. delete this.chartPosition;
  25585. };
  25586. /**
  25587. * The mousemove, touchmove and touchstart event handler
  25588. * @private
  25589. * @function Highcharts.Pointer#onContainerMouseMove
  25590. */
  25591. Pointer.prototype.onContainerMouseMove = function (e) {
  25592. var chart = this.chart;
  25593. var pEvt = this.normalize(e);
  25594. this.setHoverChartIndex();
  25595. // In IE8 we apparently need this returnValue set to false in order to
  25596. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  25597. // plus we don't need to run e.preventDefault to prevent selected text
  25598. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  25599. // no longer needed. #2251, #3224.
  25600. if (!pEvt.preventDefault) {
  25601. pEvt.returnValue = false;
  25602. }
  25603. if (chart.mouseIsDown === 'mousedown' || this.touchSelect(pEvt)) {
  25604. this.drag(pEvt);
  25605. }
  25606. // Show the tooltip and run mouse over events (#977)
  25607. if (!chart.openMenu &&
  25608. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  25609. chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25610. visiblePlotOnly: true
  25611. }))) {
  25612. if (this.inClass(pEvt.target, 'highcharts-no-tooltip')) {
  25613. this.reset(false, 0);
  25614. }
  25615. else {
  25616. this.runPointActions(pEvt);
  25617. }
  25618. }
  25619. };
  25620. /**
  25621. * @private
  25622. * @function Highcharts.Pointer#onDocumentTouchEnd
  25623. */
  25624. Pointer.prototype.onDocumentTouchEnd = function (e) {
  25625. var hoverChart = charts[pick(Pointer.hoverChartIndex, -1)];
  25626. if (hoverChart) {
  25627. hoverChart.pointer.drop(e);
  25628. }
  25629. };
  25630. /**
  25631. * @private
  25632. * @function Highcharts.Pointer#onContainerTouchMove
  25633. */
  25634. Pointer.prototype.onContainerTouchMove = function (e) {
  25635. if (this.touchSelect(e)) {
  25636. this.onContainerMouseMove(e);
  25637. }
  25638. else {
  25639. this.touch(e);
  25640. }
  25641. };
  25642. /**
  25643. * @private
  25644. * @function Highcharts.Pointer#onContainerTouchStart
  25645. */
  25646. Pointer.prototype.onContainerTouchStart = function (e) {
  25647. if (this.touchSelect(e)) {
  25648. this.onContainerMouseDown(e);
  25649. }
  25650. else {
  25651. this.zoomOption(e);
  25652. this.touch(e, true);
  25653. }
  25654. };
  25655. /**
  25656. * Special handler for mouse move that will hide the tooltip when the mouse
  25657. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  25658. * always fire.
  25659. * @private
  25660. * @function Highcharts.Pointer#onDocumentMouseMove
  25661. */
  25662. Pointer.prototype.onDocumentMouseMove = function (e) {
  25663. var chart = this.chart;
  25664. var chartPosition = this.chartPosition;
  25665. var pEvt = this.normalize(e,
  25666. chartPosition);
  25667. var tooltip = chart.tooltip;
  25668. // If we're outside, hide the tooltip
  25669. if (chartPosition &&
  25670. (!tooltip ||
  25671. !tooltip.isStickyOnContact()) &&
  25672. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25673. visiblePlotOnly: true
  25674. }) &&
  25675. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  25676. this.reset();
  25677. }
  25678. };
  25679. /**
  25680. * @private
  25681. * @function Highcharts.Pointer#onDocumentMouseUp
  25682. */
  25683. Pointer.prototype.onDocumentMouseUp = function (e) {
  25684. var chart = charts[pick(Pointer.hoverChartIndex, -1)];
  25685. if (chart) {
  25686. chart.pointer.drop(e);
  25687. }
  25688. };
  25689. /**
  25690. * Handle touch events with two touches
  25691. * @private
  25692. * @function Highcharts.Pointer#pinch
  25693. */
  25694. Pointer.prototype.pinch = function (e) {
  25695. var self = this,
  25696. chart = self.chart,
  25697. pinchDown = self.pinchDown,
  25698. touches = (e.touches || []),
  25699. touchesLength = touches.length,
  25700. lastValidTouch = self.lastValidTouch,
  25701. hasZoom = self.hasZoom,
  25702. transform = {},
  25703. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  25704. chart.runTrackerClick) ||
  25705. self.runChartClick),
  25706. clip = {};
  25707. var selectionMarker = self.selectionMarker;
  25708. // Don't initiate panning until the user has pinched. This prevents us
  25709. // from blocking page scrolling as users scroll down a long page
  25710. // (#4210).
  25711. if (touchesLength > 1) {
  25712. self.initiated = true;
  25713. }
  25714. // On touch devices, only proceed to trigger click if a handler is
  25715. // defined
  25716. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  25717. e.preventDefault();
  25718. }
  25719. // Normalize each touch
  25720. [].map.call(touches, function (e) {
  25721. return self.normalize(e);
  25722. });
  25723. // Register the touch start position
  25724. if (e.type === 'touchstart') {
  25725. [].forEach.call(touches, function (e, i) {
  25726. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  25727. });
  25728. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  25729. pinchDown[1].chartX];
  25730. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  25731. pinchDown[1].chartY];
  25732. // Identify the data bounds in pixels
  25733. chart.axes.forEach(function (axis) {
  25734. if (axis.zoomEnabled) {
  25735. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  25736. minPixelPadding = axis.minPixelPadding,
  25737. min = axis.toPixels(Math.min(pick(axis.options.min,
  25738. axis.dataMin),
  25739. axis.dataMin)),
  25740. max = axis.toPixels(Math.max(pick(axis.options.max,
  25741. axis.dataMax),
  25742. axis.dataMax)),
  25743. absMin = Math.min(min,
  25744. max),
  25745. absMax = Math.max(min,
  25746. max);
  25747. // Store the bounds for use in the touchmove handler
  25748. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  25749. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  25750. }
  25751. });
  25752. self.res = true; // reset on next move
  25753. // Optionally move the tooltip on touchmove
  25754. }
  25755. else if (self.followTouchMove && touchesLength === 1) {
  25756. this.runPointActions(self.normalize(e));
  25757. // Event type is touchmove, handle panning and pinching
  25758. }
  25759. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  25760. // fires first
  25761. // Set the marker
  25762. if (!selectionMarker) {
  25763. // @todo It's a mock object, so maybe we need a separate
  25764. // interface
  25765. self.selectionMarker = selectionMarker = extend({
  25766. destroy: noop,
  25767. touch: true
  25768. }, chart.plotBox);
  25769. }
  25770. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25771. self.hasPinched = hasZoom;
  25772. // Scale and translate the groups to provide visual feedback during
  25773. // pinching
  25774. self.scaleGroups(transform, clip);
  25775. if (self.res) {
  25776. self.res = false;
  25777. this.reset(false, 0);
  25778. }
  25779. }
  25780. };
  25781. /**
  25782. * Run translation operations
  25783. * @private
  25784. * @function Highcharts.Pointer#pinchTranslate
  25785. */
  25786. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  25787. if (this.zoomHor) {
  25788. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25789. }
  25790. if (this.zoomVert) {
  25791. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25792. }
  25793. };
  25794. /**
  25795. * Run translation operations for each direction (horizontal and vertical)
  25796. * independently.
  25797. * @private
  25798. * @function Highcharts.Pointer#pinchTranslateDirection
  25799. */
  25800. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  25801. var chart = this.chart, xy = horiz ? 'x' : 'y', XY = horiz ? 'X' : 'Y', sChartXY = ('chart' + XY), wh = horiz ? 'width' : 'height', plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')], inverted = chart.inverted, bounds = chart.bounds[horiz ? 'h' : 'v'], singleTouch = pinchDown.length === 1, touch0Start = pinchDown[0][sChartXY], touch1Start = !singleTouch && pinchDown[1][sChartXY], setScale = function () {
  25802. // Don't zoom if fingers are too close on this axis
  25803. if (typeof touch1Now === 'number' &&
  25804. Math.abs(touch0Start - touch1Start) > 20) {
  25805. scale = forcedScale ||
  25806. Math.abs(touch0Now - touch1Now) /
  25807. Math.abs(touch0Start - touch1Start);
  25808. }
  25809. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  25810. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  25811. };
  25812. var selectionWH,
  25813. selectionXY,
  25814. clipXY,
  25815. scale = forcedScale || 1,
  25816. touch0Now = touches[0][sChartXY],
  25817. touch1Now = !singleTouch && touches[1][sChartXY],
  25818. outOfBounds;
  25819. // Set the scale, first pass
  25820. setScale();
  25821. // The clip position (x or y) is altered if out of bounds, the selection
  25822. // position is not
  25823. selectionXY = clipXY;
  25824. // Out of bounds
  25825. if (selectionXY < bounds.min) {
  25826. selectionXY = bounds.min;
  25827. outOfBounds = true;
  25828. }
  25829. else if (selectionXY + selectionWH > bounds.max) {
  25830. selectionXY = bounds.max - selectionWH;
  25831. outOfBounds = true;
  25832. }
  25833. // Is the chart dragged off its bounds, determined by dataMin and
  25834. // dataMax?
  25835. if (outOfBounds) {
  25836. // Modify the touchNow position in order to create an elastic drag
  25837. // movement. This indicates to the user that the chart is responsive
  25838. // but can't be dragged further.
  25839. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  25840. if (typeof touch1Now === 'number') {
  25841. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  25842. }
  25843. // Set the scale, second pass to adapt to the modified touchNow
  25844. // positions
  25845. setScale();
  25846. }
  25847. else {
  25848. lastValidTouch[xy] = [touch0Now, touch1Now];
  25849. }
  25850. // Set geometry for clipping, selection and transformation
  25851. if (!inverted) {
  25852. clip[xy] = clipXY - plotLeftTop;
  25853. clip[wh] = selectionWH;
  25854. }
  25855. var scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  25856. var transformScale = inverted ? 1 / scale : scale;
  25857. selectionMarker[wh] = selectionWH;
  25858. selectionMarker[xy] = selectionXY;
  25859. transform[scaleKey] = scale;
  25860. transform['translate' + XY] = (transformScale * plotLeftTop) +
  25861. (touch0Now - (transformScale * touch0Start));
  25862. };
  25863. /**
  25864. * Reset the tracking by hiding the tooltip, the hover series state and the
  25865. * hover point
  25866. *
  25867. * @function Highcharts.Pointer#reset
  25868. *
  25869. * @param {boolean} [allowMove]
  25870. * Instead of destroying the tooltip altogether, allow moving it if
  25871. * possible.
  25872. *
  25873. * @param {number} [delay]
  25874. */
  25875. Pointer.prototype.reset = function (allowMove, delay) {
  25876. var pointer = this,
  25877. chart = pointer.chart,
  25878. hoverSeries = chart.hoverSeries,
  25879. hoverPoint = chart.hoverPoint,
  25880. hoverPoints = chart.hoverPoints,
  25881. tooltip = chart.tooltip,
  25882. tooltipPoints = tooltip && tooltip.shared ?
  25883. hoverPoints :
  25884. hoverPoint;
  25885. // Check if the points have moved outside the plot area (#1003, #4736,
  25886. // #5101)
  25887. if (allowMove && tooltipPoints) {
  25888. splat(tooltipPoints).forEach(function (point) {
  25889. if (point.series.isCartesian &&
  25890. typeof point.plotX === 'undefined') {
  25891. allowMove = false;
  25892. }
  25893. });
  25894. }
  25895. // Just move the tooltip, #349
  25896. if (allowMove) {
  25897. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  25898. tooltip.refresh(tooltipPoints);
  25899. if (tooltip.shared && hoverPoints) { // #8284
  25900. hoverPoints.forEach(function (point) {
  25901. point.setState(point.state, true);
  25902. if (point.series.isCartesian) {
  25903. if (point.series.xAxis.crosshair) {
  25904. point.series.xAxis
  25905. .drawCrosshair(null, point);
  25906. }
  25907. if (point.series.yAxis.crosshair) {
  25908. point.series.yAxis
  25909. .drawCrosshair(null, point);
  25910. }
  25911. }
  25912. });
  25913. }
  25914. else if (hoverPoint) { // #2500
  25915. hoverPoint.setState(hoverPoint.state, true);
  25916. chart.axes.forEach(function (axis) {
  25917. if (axis.crosshair &&
  25918. hoverPoint.series[axis.coll] === axis) {
  25919. axis.drawCrosshair(null, hoverPoint);
  25920. }
  25921. });
  25922. }
  25923. }
  25924. // Full reset
  25925. }
  25926. else {
  25927. if (hoverPoint) {
  25928. hoverPoint.onMouseOut();
  25929. }
  25930. if (hoverPoints) {
  25931. hoverPoints.forEach(function (point) {
  25932. point.setState();
  25933. });
  25934. }
  25935. if (hoverSeries) {
  25936. hoverSeries.onMouseOut();
  25937. }
  25938. if (tooltip) {
  25939. tooltip.hide(delay);
  25940. }
  25941. if (pointer.unDocMouseMove) {
  25942. pointer.unDocMouseMove = pointer.unDocMouseMove();
  25943. }
  25944. // Remove crosshairs
  25945. chart.axes.forEach(function (axis) {
  25946. axis.hideCrosshair();
  25947. });
  25948. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  25949. }
  25950. };
  25951. /**
  25952. * With line type charts with a single tracker, get the point closest to the
  25953. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  25954. *
  25955. * @private
  25956. * @function Highcharts.Pointer#runPointActions
  25957. *
  25958. * @fires Highcharts.Point#event:mouseOut
  25959. * @fires Highcharts.Point#event:mouseOver
  25960. */
  25961. Pointer.prototype.runPointActions = function (e, p) {
  25962. var pointer = this,
  25963. chart = pointer.chart,
  25964. series = chart.series,
  25965. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  25966. chart.tooltip :
  25967. void 0),
  25968. shared = (tooltip ?
  25969. tooltip.shared :
  25970. false);
  25971. var hoverPoint = p || chart.hoverPoint,
  25972. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries;
  25973. var // onMouseOver or already hovering a series with directTouch
  25974. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  25975. pointer.isDirectTouch)),
  25976. hoverData = this.getHoverData(hoverPoint,
  25977. hoverSeries,
  25978. series,
  25979. isDirectTouch,
  25980. shared,
  25981. e);
  25982. // Update variables from hoverData.
  25983. hoverPoint = hoverData.hoverPoint;
  25984. hoverSeries = hoverData.hoverSeries;
  25985. var points = hoverData.hoverPoints,
  25986. followPointer = hoverSeries &&
  25987. hoverSeries.tooltipOptions.followPointer &&
  25988. !hoverSeries.tooltipOptions.split,
  25989. useSharedTooltip = (shared &&
  25990. hoverSeries &&
  25991. !hoverSeries.noSharedTooltip);
  25992. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  25993. // #3926, #4200
  25994. if (hoverPoint &&
  25995. // !(hoverSeries && hoverSeries.directTouch) &&
  25996. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  25997. (chart.hoverPoints || []).forEach(function (p) {
  25998. if (points.indexOf(p) === -1) {
  25999. p.setState();
  26000. }
  26001. });
  26002. // Set normal state to previous series
  26003. if (chart.hoverSeries !== hoverSeries) {
  26004. hoverSeries.onMouseOver();
  26005. }
  26006. pointer.applyInactiveState(points);
  26007. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  26008. (points || []).forEach(function (p) {
  26009. p.setState('hover');
  26010. });
  26011. // If tracking is on series in stead of on each point,
  26012. // fire mouseOver on hover point. // #4448
  26013. if (chart.hoverPoint) {
  26014. chart.hoverPoint.firePointEvent('mouseOut');
  26015. }
  26016. // Hover point may have been destroyed in the event handlers (#7127)
  26017. if (!hoverPoint.series) {
  26018. return;
  26019. }
  26020. /**
  26021. * Contains all hovered points.
  26022. *
  26023. * @name Highcharts.Chart#hoverPoints
  26024. * @type {Array<Highcharts.Point>|null}
  26025. */
  26026. chart.hoverPoints = points;
  26027. /**
  26028. * Contains the original hovered point.
  26029. *
  26030. * @name Highcharts.Chart#hoverPoint
  26031. * @type {Highcharts.Point|null}
  26032. */
  26033. chart.hoverPoint = hoverPoint;
  26034. /**
  26035. * Hover state should not be lost when axis is updated (#12569)
  26036. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  26037. * to apply state which does not exist in hoverPoint yet.
  26038. * The mouseOver event should be triggered when hoverPoint
  26039. * is correct.
  26040. */
  26041. hoverPoint.firePointEvent('mouseOver');
  26042. // Draw tooltip if necessary
  26043. if (tooltip) {
  26044. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  26045. }
  26046. // Update positions (regardless of kdpoint or hoverPoint)
  26047. }
  26048. else if (followPointer && tooltip && !tooltip.isHidden) {
  26049. var anchor = tooltip.getAnchor([{}],
  26050. e);
  26051. if (chart.isInsidePlot(anchor[0], anchor[1], {
  26052. visiblePlotOnly: true
  26053. })) {
  26054. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  26055. }
  26056. }
  26057. // Start the event listener to pick up the tooltip and crosshairs
  26058. if (!pointer.unDocMouseMove) {
  26059. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  26060. var chart = charts[Pointer.hoverChartIndex];
  26061. if (chart) {
  26062. chart.pointer.onDocumentMouseMove(e);
  26063. }
  26064. });
  26065. pointer.eventsToUnbind.push(pointer.unDocMouseMove);
  26066. }
  26067. // Issues related to crosshair #4927, #5269 #5066, #5658
  26068. chart.axes.forEach(function drawAxisCrosshair(axis) {
  26069. var snap = pick((axis.crosshair || {}).snap,
  26070. true);
  26071. var point;
  26072. if (snap) {
  26073. point = chart.hoverPoint; // #13002
  26074. if (!point || point.series[axis.coll] !== axis) {
  26075. point = find(points, function (p) {
  26076. return p.series[axis.coll] === axis;
  26077. });
  26078. }
  26079. }
  26080. // Axis has snapping crosshairs, and one of the hover points belongs
  26081. // to axis. Always call drawCrosshair when it is not snap.
  26082. if (point || !snap) {
  26083. axis.drawCrosshair(e, point);
  26084. // Axis has snapping crosshairs, but no hover point belongs to axis
  26085. }
  26086. else {
  26087. axis.hideCrosshair();
  26088. }
  26089. });
  26090. };
  26091. /**
  26092. * Scale series groups to a certain scale and translation.
  26093. * @private
  26094. * @function Highcharts.Pointer#scaleGroups
  26095. */
  26096. Pointer.prototype.scaleGroups = function (attribs, clip) {
  26097. var chart = this.chart;
  26098. // Scale each series
  26099. chart.series.forEach(function (series) {
  26100. var seriesAttribs = attribs || series.getPlotBox(); // #1701
  26101. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  26102. series.group.attr(seriesAttribs);
  26103. if (series.markerGroup) {
  26104. series.markerGroup.attr(seriesAttribs);
  26105. series.markerGroup.clip(clip ? chart.clipRect : null);
  26106. }
  26107. if (series.dataLabelsGroup) {
  26108. series.dataLabelsGroup.attr(seriesAttribs);
  26109. }
  26110. }
  26111. });
  26112. // Clip
  26113. chart.clipRect.attr(clip || chart.clipBox);
  26114. };
  26115. /**
  26116. * Set the JS DOM events on the container and document. This method should
  26117. * contain a one-to-one assignment between methods and their handlers. Any
  26118. * advanced logic should be moved to the handler reflecting the event's
  26119. * name.
  26120. * @private
  26121. * @function Highcharts.Pointer#setDOMEvents
  26122. */
  26123. Pointer.prototype.setDOMEvents = function () {
  26124. var _this = this;
  26125. var container = this.chart.container,
  26126. ownerDoc = container.ownerDocument;
  26127. container.onmousedown = this.onContainerMouseDown.bind(this);
  26128. container.onmousemove = this.onContainerMouseMove.bind(this);
  26129. container.onclick = this.onContainerClick.bind(this);
  26130. this.eventsToUnbind.push(addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this)));
  26131. this.eventsToUnbind.push(addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this)));
  26132. if (!Pointer.unbindDocumentMouseUp) {
  26133. Pointer.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  26134. }
  26135. // In case we are dealing with overflow, reset the chart position when
  26136. // scrolling parent elements
  26137. var parent = this.chart.renderTo.parentElement;
  26138. while (parent && parent.tagName !== 'BODY') {
  26139. this.eventsToUnbind.push(addEvent(parent, 'scroll', function () {
  26140. delete _this.chartPosition;
  26141. }));
  26142. parent = parent.parentElement;
  26143. }
  26144. if (H.hasTouch) {
  26145. this.eventsToUnbind.push(addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this), { passive: false }));
  26146. this.eventsToUnbind.push(addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this), { passive: false }));
  26147. if (!Pointer.unbindDocumentTouchEnd) {
  26148. Pointer.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this), { passive: false });
  26149. }
  26150. }
  26151. };
  26152. /**
  26153. * Sets the index of the hovered chart and leaves the previous hovered
  26154. * chart, to reset states like tooltip.
  26155. * @private
  26156. * @function Highcharts.Pointer#setHoverChartIndex
  26157. */
  26158. Pointer.prototype.setHoverChartIndex = function () {
  26159. var chart = this.chart;
  26160. var hoverChart = H.charts[pick(Pointer.hoverChartIndex, -1)];
  26161. if (hoverChart &&
  26162. hoverChart !== chart) {
  26163. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  26164. }
  26165. if (!hoverChart ||
  26166. !hoverChart.mouseIsDown) {
  26167. Pointer.hoverChartIndex = chart.index;
  26168. }
  26169. };
  26170. /**
  26171. * General touch handler shared by touchstart and touchmove.
  26172. * @private
  26173. * @function Highcharts.Pointer#touch
  26174. */
  26175. Pointer.prototype.touch = function (e, start) {
  26176. var chart = this.chart;
  26177. var hasMoved,
  26178. pinchDown,
  26179. isInside;
  26180. this.setHoverChartIndex();
  26181. if (e.touches.length === 1) {
  26182. e = this.normalize(e);
  26183. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop, {
  26184. visiblePlotOnly: true
  26185. });
  26186. if (isInside && !chart.openMenu) {
  26187. // Run mouse events and display tooltip etc
  26188. if (start) {
  26189. this.runPointActions(e);
  26190. }
  26191. // Android fires touchmove events after the touchstart even if
  26192. // the finger hasn't moved, or moved only a pixel or two. In iOS
  26193. // however, the touchmove doesn't fire unless the finger moves
  26194. // more than ~4px. So we emulate this behaviour in Android by
  26195. // checking how much it moved, and cancelling on small
  26196. // distances. #3450.
  26197. if (e.type === 'touchmove') {
  26198. pinchDown = this.pinchDown;
  26199. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  26200. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  26201. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  26202. }
  26203. if (pick(hasMoved, true)) {
  26204. this.pinch(e);
  26205. }
  26206. }
  26207. else if (start) {
  26208. // Hide the tooltip on touching outside the plot area (#1203)
  26209. this.reset();
  26210. }
  26211. }
  26212. else if (e.touches.length === 2) {
  26213. this.pinch(e);
  26214. }
  26215. };
  26216. /**
  26217. * Returns true if the chart is set up for zooming by single touch and the
  26218. * event is capable
  26219. * @private
  26220. * @function Highcharts.Pointer#touchSelect
  26221. */
  26222. Pointer.prototype.touchSelect = function (e) {
  26223. return Boolean(this.chart.options.chart.zoomBySingleTouch &&
  26224. e.touches &&
  26225. e.touches.length === 1);
  26226. };
  26227. /**
  26228. * Resolve the zoomType option, this is reset on all touch start and mouse
  26229. * down events.
  26230. * @private
  26231. * @function Highcharts.Pointer#zoomOption
  26232. */
  26233. Pointer.prototype.zoomOption = function (e) {
  26234. var chart = this.chart,
  26235. options = chart.options.chart,
  26236. inverted = chart.inverted;
  26237. var zoomType = options.zoomType || '',
  26238. zoomX,
  26239. zoomY;
  26240. // Look for the pinchType option
  26241. if (/touch/.test(e.type)) {
  26242. zoomType = pick(options.pinchType, zoomType);
  26243. }
  26244. this.zoomX = zoomX = /x/.test(zoomType);
  26245. this.zoomY = zoomY = /y/.test(zoomType);
  26246. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  26247. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  26248. this.hasZoom = zoomX || zoomY;
  26249. };
  26250. return Pointer;
  26251. }());
  26252. /* *
  26253. *
  26254. * Default Export
  26255. *
  26256. * */
  26257. /* *
  26258. *
  26259. * API Declarations
  26260. *
  26261. * */
  26262. /**
  26263. * One position in relation to an axis.
  26264. *
  26265. * @interface Highcharts.PointerAxisCoordinateObject
  26266. */ /**
  26267. * Related axis.
  26268. *
  26269. * @name Highcharts.PointerAxisCoordinateObject#axis
  26270. * @type {Highcharts.Axis}
  26271. */ /**
  26272. * Axis value.
  26273. *
  26274. * @name Highcharts.PointerAxisCoordinateObject#value
  26275. * @type {number}
  26276. */
  26277. /**
  26278. * Positions in terms of axis values.
  26279. *
  26280. * @interface Highcharts.PointerAxisCoordinatesObject
  26281. */ /**
  26282. * Positions on the x-axis.
  26283. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  26284. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  26285. */ /**
  26286. * Positions on the y-axis.
  26287. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  26288. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  26289. */
  26290. /**
  26291. * Pointer coordinates.
  26292. *
  26293. * @interface Highcharts.PointerCoordinatesObject
  26294. */ /**
  26295. * @name Highcharts.PointerCoordinatesObject#chartX
  26296. * @type {number}
  26297. */ /**
  26298. * @name Highcharts.PointerCoordinatesObject#chartY
  26299. * @type {number}
  26300. */
  26301. /**
  26302. * A native browser mouse or touch event, extended with position information
  26303. * relative to the {@link Chart.container}.
  26304. *
  26305. * @interface Highcharts.PointerEventObject
  26306. * @extends global.PointerEvent
  26307. */ /**
  26308. * The X coordinate of the pointer interaction relative to the chart.
  26309. *
  26310. * @name Highcharts.PointerEventObject#chartX
  26311. * @type {number}
  26312. */ /**
  26313. * The Y coordinate of the pointer interaction relative to the chart.
  26314. *
  26315. * @name Highcharts.PointerEventObject#chartY
  26316. * @type {number}
  26317. */
  26318. /**
  26319. * Axis-specific data of a selection.
  26320. *
  26321. * @interface Highcharts.SelectDataObject
  26322. */ /**
  26323. * @name Highcharts.SelectDataObject#axis
  26324. * @type {Highcharts.Axis}
  26325. */ /**
  26326. * @name Highcharts.SelectDataObject#max
  26327. * @type {number}
  26328. */ /**
  26329. * @name Highcharts.SelectDataObject#min
  26330. * @type {number}
  26331. */
  26332. /**
  26333. * Object for select events.
  26334. *
  26335. * @interface Highcharts.SelectEventObject
  26336. */ /**
  26337. * @name Highcharts.SelectEventObject#originalEvent
  26338. * @type {global.Event}
  26339. */ /**
  26340. * @name Highcharts.SelectEventObject#xAxis
  26341. * @type {Array<Highcharts.SelectDataObject>}
  26342. */ /**
  26343. * @name Highcharts.SelectEventObject#yAxis
  26344. * @type {Array<Highcharts.SelectDataObject>}
  26345. */
  26346. /**
  26347. * Chart position and scale.
  26348. *
  26349. * @interface Highcharts.ChartPositionObject
  26350. */ /**
  26351. * @name Highcharts.ChartPositionObject#left
  26352. * @type {number}
  26353. */ /**
  26354. * @name Highcharts.ChartPositionObject#scaleX
  26355. * @type {number}
  26356. */ /**
  26357. * @name Highcharts.ChartPositionObject#scaleY
  26358. * @type {number}
  26359. */ /**
  26360. * @name Highcharts.ChartPositionObject#top
  26361. * @type {number}
  26362. */
  26363. ''; // keeps doclets above in JS file
  26364. return Pointer;
  26365. });
  26366. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  26367. /* *
  26368. *
  26369. * (c) 2010-2021 Torstein Honsi
  26370. *
  26371. * License: www.highcharts.com/license
  26372. *
  26373. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26374. *
  26375. * */
  26376. var __extends = (this && this.__extends) || (function () {
  26377. var extendStatics = function (d,
  26378. b) {
  26379. extendStatics = Object.setPrototypeOf ||
  26380. ({ __proto__: [] } instanceof Array && function (d,
  26381. b) { d.__proto__ = b; }) ||
  26382. function (d,
  26383. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26384. return extendStatics(d, b);
  26385. };
  26386. return function (d, b) {
  26387. extendStatics(d, b);
  26388. function __() { this.constructor = d; }
  26389. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26390. };
  26391. })();
  26392. var charts = H.charts,
  26393. doc = H.doc,
  26394. noop = H.noop,
  26395. win = H.win;
  26396. var addEvent = U.addEvent,
  26397. css = U.css,
  26398. objectEach = U.objectEach,
  26399. removeEvent = U.removeEvent;
  26400. /* *
  26401. *
  26402. * Constants
  26403. *
  26404. * */
  26405. // The touches object keeps track of the points being touched at all times
  26406. var touches = {};
  26407. var hasPointerEvent = !!win.PointerEvent;
  26408. /* *
  26409. *
  26410. * Functions
  26411. *
  26412. * */
  26413. /* eslint-disable valid-jsdoc */
  26414. /** @private */
  26415. function getWebkitTouches() {
  26416. var fake = [];
  26417. fake.item = function (i) {
  26418. return this[i];
  26419. };
  26420. objectEach(touches, function (touch) {
  26421. fake.push({
  26422. pageX: touch.pageX,
  26423. pageY: touch.pageY,
  26424. target: touch.target
  26425. });
  26426. });
  26427. return fake;
  26428. }
  26429. /** @private */
  26430. function translateMSPointer(e, method, wktype, func) {
  26431. var chart = charts[Pointer.hoverChartIndex || NaN];
  26432. if ((e.pointerType === 'touch' ||
  26433. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && chart) {
  26434. var p = chart.pointer;
  26435. func(e);
  26436. p[method]({
  26437. type: wktype,
  26438. target: e.currentTarget,
  26439. preventDefault: noop,
  26440. touches: getWebkitTouches()
  26441. });
  26442. }
  26443. }
  26444. /* *
  26445. *
  26446. * Class
  26447. *
  26448. * */
  26449. /** @private */
  26450. var MSPointer = /** @class */ (function (_super) {
  26451. __extends(MSPointer, _super);
  26452. function MSPointer() {
  26453. return _super !== null && _super.apply(this, arguments) || this;
  26454. }
  26455. /* *
  26456. *
  26457. * Static Functions
  26458. *
  26459. * */
  26460. MSPointer.isRequired = function () {
  26461. return !!(!H.hasTouch && (win.PointerEvent || win.MSPointerEvent));
  26462. };
  26463. /* *
  26464. *
  26465. * Functions
  26466. *
  26467. * */
  26468. /**
  26469. * Add or remove the MS Pointer specific events
  26470. * @private
  26471. * @function Highcharts.Pointer#batchMSEvents
  26472. */
  26473. MSPointer.prototype.batchMSEvents = function (fn) {
  26474. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  26475. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  26476. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  26477. };
  26478. // Destroy MS events also
  26479. MSPointer.prototype.destroy = function () {
  26480. this.batchMSEvents(removeEvent);
  26481. _super.prototype.destroy.call(this);
  26482. };
  26483. // Disable default IE actions for pinch and such on chart element
  26484. MSPointer.prototype.init = function (chart, options) {
  26485. _super.prototype.init.call(this, chart, options);
  26486. if (this.hasZoom) { // #4014
  26487. css(chart.container, {
  26488. '-ms-touch-action': 'none',
  26489. 'touch-action': 'none'
  26490. });
  26491. }
  26492. };
  26493. /**
  26494. * @private
  26495. * @function Highcharts.Pointer#onContainerPointerDown
  26496. */
  26497. MSPointer.prototype.onContainerPointerDown = function (e) {
  26498. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  26499. touches[e.pointerId] = {
  26500. pageX: e.pageX,
  26501. pageY: e.pageY,
  26502. target: e.currentTarget
  26503. };
  26504. });
  26505. };
  26506. /**
  26507. * @private
  26508. * @function Highcharts.Pointer#onContainerPointerMove
  26509. */
  26510. MSPointer.prototype.onContainerPointerMove = function (e) {
  26511. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  26512. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  26513. if (!touches[e.pointerId].target) {
  26514. touches[e.pointerId].target = e.currentTarget;
  26515. }
  26516. });
  26517. };
  26518. /**
  26519. * @private
  26520. * @function Highcharts.Pointer#onDocumentPointerUp
  26521. */
  26522. MSPointer.prototype.onDocumentPointerUp = function (e) {
  26523. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  26524. delete touches[e.pointerId];
  26525. });
  26526. };
  26527. // Add IE specific touch events to chart
  26528. MSPointer.prototype.setDOMEvents = function () {
  26529. _super.prototype.setDOMEvents.call(this);
  26530. if (this.hasZoom || this.followTouchMove) {
  26531. this.batchMSEvents(addEvent);
  26532. }
  26533. };
  26534. return MSPointer;
  26535. }(Pointer));
  26536. /* *
  26537. *
  26538. * Default Export
  26539. *
  26540. * */
  26541. return MSPointer;
  26542. });
  26543. _registerModule(_modules, 'Core/Series/Point.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Utilities.js']], function (AST, A, F, H, D, U) {
  26544. /* *
  26545. *
  26546. * (c) 2010-2021 Torstein Honsi
  26547. *
  26548. * License: www.highcharts.com/license
  26549. *
  26550. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26551. *
  26552. * */
  26553. var animObject = A.animObject;
  26554. var format = F.format;
  26555. var defaultOptions = D.defaultOptions;
  26556. var addEvent = U.addEvent,
  26557. defined = U.defined,
  26558. erase = U.erase,
  26559. extend = U.extend,
  26560. fireEvent = U.fireEvent,
  26561. getNestedProperty = U.getNestedProperty,
  26562. isArray = U.isArray,
  26563. isFunction = U.isFunction,
  26564. isNumber = U.isNumber,
  26565. isObject = U.isObject,
  26566. merge = U.merge,
  26567. objectEach = U.objectEach,
  26568. pick = U.pick,
  26569. syncTimeout = U.syncTimeout,
  26570. removeEvent = U.removeEvent,
  26571. uniqueKey = U.uniqueKey;
  26572. /**
  26573. * Function callback when a series point is clicked. Return false to cancel the
  26574. * action.
  26575. *
  26576. * @callback Highcharts.PointClickCallbackFunction
  26577. *
  26578. * @param {Highcharts.Point} this
  26579. * The point where the event occured.
  26580. *
  26581. * @param {Highcharts.PointClickEventObject} event
  26582. * Event arguments.
  26583. */
  26584. /**
  26585. * Common information for a click event on a series point.
  26586. *
  26587. * @interface Highcharts.PointClickEventObject
  26588. * @extends Highcharts.PointerEventObject
  26589. */ /**
  26590. * Clicked point.
  26591. * @name Highcharts.PointClickEventObject#point
  26592. * @type {Highcharts.Point}
  26593. */
  26594. /**
  26595. * Configuration hash for the data label and tooltip formatters.
  26596. *
  26597. * @interface Highcharts.PointLabelObject
  26598. */ /**
  26599. * The point's current color.
  26600. * @name Highcharts.PointLabelObject#color
  26601. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26602. */ /**
  26603. * The point's current color index, used in styled mode instead of `color`. The
  26604. * color index is inserted in class names used for styling.
  26605. * @name Highcharts.PointLabelObject#colorIndex
  26606. * @type {number}
  26607. */ /**
  26608. * The name of the related point.
  26609. * @name Highcharts.PointLabelObject#key
  26610. * @type {string|undefined}
  26611. */ /**
  26612. * The percentage for related points in a stacked series or pies.
  26613. * @name Highcharts.PointLabelObject#percentage
  26614. * @type {number}
  26615. */ /**
  26616. * The related point. The point name, if defined, is available through
  26617. * `this.point.name`.
  26618. * @name Highcharts.PointLabelObject#point
  26619. * @type {Highcharts.Point}
  26620. */ /**
  26621. * The related series. The series name is available through `this.series.name`.
  26622. * @name Highcharts.PointLabelObject#series
  26623. * @type {Highcharts.Series}
  26624. */ /**
  26625. * The total of values in either a stack for stacked series, or a pie in a pie
  26626. * series.
  26627. * @name Highcharts.PointLabelObject#total
  26628. * @type {number|undefined}
  26629. */ /**
  26630. * For categorized axes this property holds the category name for the point. For
  26631. * other axes it holds the X value.
  26632. * @name Highcharts.PointLabelObject#x
  26633. * @type {number|string|undefined}
  26634. */ /**
  26635. * The y value of the point.
  26636. * @name Highcharts.PointLabelObject#y
  26637. * @type {number|undefined}
  26638. */
  26639. /**
  26640. * Gets fired when the mouse leaves the area close to the point.
  26641. *
  26642. * @callback Highcharts.PointMouseOutCallbackFunction
  26643. *
  26644. * @param {Highcharts.Point} this
  26645. * Point where the event occured.
  26646. *
  26647. * @param {global.PointerEvent} event
  26648. * Event that occured.
  26649. */
  26650. /**
  26651. * Gets fired when the mouse enters the area close to the point.
  26652. *
  26653. * @callback Highcharts.PointMouseOverCallbackFunction
  26654. *
  26655. * @param {Highcharts.Point} this
  26656. * Point where the event occured.
  26657. *
  26658. * @param {global.Event} event
  26659. * Event that occured.
  26660. */
  26661. /**
  26662. * The generic point options for all series.
  26663. *
  26664. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26665. * declaration to allow custom data options:
  26666. *
  26667. * ```
  26668. * declare interface PointOptionsObject {
  26669. * customProperty: string;
  26670. * }
  26671. * ```
  26672. *
  26673. * @interface Highcharts.PointOptionsObject
  26674. */
  26675. /**
  26676. * Possible option types for a data point. Use `null` to indicate a gap.
  26677. *
  26678. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26679. */
  26680. /**
  26681. * Gets fired when the point is removed using the `.remove()` method.
  26682. *
  26683. * @callback Highcharts.PointRemoveCallbackFunction
  26684. *
  26685. * @param {Highcharts.Point} this
  26686. * Point where the event occured.
  26687. *
  26688. * @param {global.Event} event
  26689. * Event that occured.
  26690. */
  26691. /**
  26692. * Possible key values for the point state options.
  26693. *
  26694. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26695. */
  26696. /**
  26697. * Gets fired when the point is updated programmatically through the `.update()`
  26698. * method.
  26699. *
  26700. * @callback Highcharts.PointUpdateCallbackFunction
  26701. *
  26702. * @param {Highcharts.Point} this
  26703. * Point where the event occured.
  26704. *
  26705. * @param {Highcharts.PointUpdateEventObject} event
  26706. * Event that occured.
  26707. */
  26708. /**
  26709. * Information about the update event.
  26710. *
  26711. * @interface Highcharts.PointUpdateEventObject
  26712. * @extends global.Event
  26713. */ /**
  26714. * Options data of the update event.
  26715. * @name Highcharts.PointUpdateEventObject#options
  26716. * @type {Highcharts.PointOptionsType}
  26717. */
  26718. /**
  26719. * @interface Highcharts.PointEventsOptionsObject
  26720. */ /**
  26721. * Fires when the point is selected either programmatically or following a click
  26722. * on the point. One parameter, `event`, is passed to the function. Returning
  26723. * `false` cancels the operation.
  26724. * @name Highcharts.PointEventsOptionsObject#select
  26725. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  26726. */ /**
  26727. * Fires when the point is unselected either programmatically or following a
  26728. * click on the point. One parameter, `event`, is passed to the function.
  26729. * Returning `false` cancels the operation.
  26730. * @name Highcharts.PointEventsOptionsObject#unselect
  26731. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  26732. */
  26733. /**
  26734. * Information about the select/unselect event.
  26735. *
  26736. * @interface Highcharts.PointInteractionEventObject
  26737. * @extends global.Event
  26738. */ /**
  26739. * @name Highcharts.PointInteractionEventObject#accumulate
  26740. * @type {boolean}
  26741. */
  26742. /**
  26743. * Gets fired when the point is selected either programmatically or following a
  26744. * click on the point.
  26745. *
  26746. * @callback Highcharts.PointSelectCallbackFunction
  26747. *
  26748. * @param {Highcharts.Point} this
  26749. * Point where the event occured.
  26750. *
  26751. * @param {Highcharts.PointInteractionEventObject} event
  26752. * Event that occured.
  26753. */
  26754. /**
  26755. * Fires when the point is unselected either programmatically or following a
  26756. * click on the point.
  26757. *
  26758. * @callback Highcharts.PointUnselectCallbackFunction
  26759. *
  26760. * @param {Highcharts.Point} this
  26761. * Point where the event occured.
  26762. *
  26763. * @param {Highcharts.PointInteractionEventObject} event
  26764. * Event that occured.
  26765. */
  26766. ''; // detach doclet above
  26767. /* eslint-disable no-invalid-this, valid-jsdoc */
  26768. /**
  26769. * The Point object. The point objects are generated from the `series.data`
  26770. * configuration objects or raw numbers. They can be accessed from the
  26771. * `Series.points` array. Other ways to instantiate points are through {@link
  26772. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26773. *
  26774. * @class
  26775. * @name Highcharts.Point
  26776. */
  26777. var Point = /** @class */ (function () {
  26778. function Point() {
  26779. /* *
  26780. *
  26781. * Properties
  26782. *
  26783. * */
  26784. /**
  26785. * For categorized axes this property holds the category name for the
  26786. * point. For other axes it holds the X value.
  26787. *
  26788. * @name Highcharts.Point#category
  26789. * @type {string}
  26790. */
  26791. this.category = void 0;
  26792. /**
  26793. * The point's current color index, used in styled mode instead of
  26794. * `color`. The color index is inserted in class names used for styling.
  26795. *
  26796. * @name Highcharts.Point#colorIndex
  26797. * @type {number}
  26798. */
  26799. this.colorIndex = void 0;
  26800. this.formatPrefix = 'point';
  26801. this.id = void 0;
  26802. this.isNull = false;
  26803. /**
  26804. * The name of the point. The name can be given as the first position of the
  26805. * point configuration array, or as a `name` property in the configuration:
  26806. *
  26807. * @example
  26808. * // Array config
  26809. * data: [
  26810. * ['John', 1],
  26811. * ['Jane', 2]
  26812. * ]
  26813. *
  26814. * // Object config
  26815. * data: [{
  26816. * name: 'John',
  26817. * y: 1
  26818. * }, {
  26819. * name: 'Jane',
  26820. * y: 2
  26821. * }]
  26822. *
  26823. * @name Highcharts.Point#name
  26824. * @type {string}
  26825. */
  26826. this.name = void 0;
  26827. /**
  26828. * The point's options as applied in the initial configuration, or
  26829. * extended through `Point.update`.
  26830. *
  26831. * In TypeScript you have to extend `PointOptionsObject` via an
  26832. * additional interface to allow custom data options:
  26833. *
  26834. * ```
  26835. * declare interface PointOptionsObject {
  26836. * customProperty: string;
  26837. * }
  26838. * ```
  26839. *
  26840. * @name Highcharts.Point#options
  26841. * @type {Highcharts.PointOptionsObject}
  26842. */
  26843. this.options = void 0;
  26844. /**
  26845. * The percentage for points in a stacked series or pies.
  26846. *
  26847. * @name Highcharts.Point#percentage
  26848. * @type {number|undefined}
  26849. */
  26850. this.percentage = void 0;
  26851. this.selected = false;
  26852. /**
  26853. * The series object associated with the point.
  26854. *
  26855. * @name Highcharts.Point#series
  26856. * @type {Highcharts.Series}
  26857. */
  26858. this.series = void 0;
  26859. /**
  26860. * The total of values in either a stack for stacked series, or a pie in a
  26861. * pie series.
  26862. *
  26863. * @name Highcharts.Point#total
  26864. * @type {number|undefined}
  26865. */
  26866. this.total = void 0;
  26867. /**
  26868. * For certain series types, like pie charts, where individual points can
  26869. * be shown or hidden.
  26870. *
  26871. * @name Highcharts.Point#visible
  26872. * @type {boolean}
  26873. * @default true
  26874. */
  26875. this.visible = true;
  26876. this.x = void 0;
  26877. }
  26878. /* *
  26879. *
  26880. * Functions
  26881. *
  26882. * */
  26883. /**
  26884. * Animate SVG elements associated with the point.
  26885. *
  26886. * @private
  26887. * @function Highcharts.Point#animateBeforeDestroy
  26888. */
  26889. Point.prototype.animateBeforeDestroy = function () {
  26890. var point = this,
  26891. animateParams = { x: point.startXPos,
  26892. opacity: 0 },
  26893. isDataLabel,
  26894. graphicalProps = point.getGraphicalProps();
  26895. graphicalProps.singular.forEach(function (prop) {
  26896. isDataLabel = prop === 'dataLabel';
  26897. point[prop] = point[prop].animate(isDataLabel ? {
  26898. x: point[prop].startXPos,
  26899. y: point[prop].startYPos,
  26900. opacity: 0
  26901. } : animateParams);
  26902. });
  26903. graphicalProps.plural.forEach(function (plural) {
  26904. point[plural].forEach(function (item) {
  26905. if (item.element) {
  26906. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26907. x: item.startXPos,
  26908. y: item.startYPos
  26909. } : {})));
  26910. }
  26911. });
  26912. });
  26913. };
  26914. /**
  26915. * Apply the options containing the x and y data and possible some extra
  26916. * properties. Called on point init or from point.update.
  26917. *
  26918. * @private
  26919. * @function Highcharts.Point#applyOptions
  26920. *
  26921. * @param {Highcharts.PointOptionsType} options
  26922. * The point options as defined in series.data.
  26923. *
  26924. * @param {number} [x]
  26925. * Optionally, the x value.
  26926. *
  26927. * @return {Highcharts.Point}
  26928. * The Point instance.
  26929. */
  26930. Point.prototype.applyOptions = function (options, x) {
  26931. var point = this,
  26932. series = point.series,
  26933. pointValKey = series.options.pointValKey || series.pointValKey;
  26934. options = Point.prototype.optionsToObject.call(this, options);
  26935. // copy options directly to point
  26936. extend(point, options);
  26937. point.options = point.options ? extend(point.options, options) : options;
  26938. // Since options are copied into the Point instance, some accidental
  26939. // options must be shielded (#5681)
  26940. if (options.group) {
  26941. delete point.group;
  26942. }
  26943. if (options.dataLabels) {
  26944. delete point.dataLabels;
  26945. }
  26946. /**
  26947. * The y value of the point.
  26948. * @name Highcharts.Point#y
  26949. * @type {number|undefined}
  26950. */
  26951. // For higher dimension series types. For instance, for ranges, point.y
  26952. // is mapped to point.low.
  26953. if (pointValKey) {
  26954. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26955. }
  26956. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26957. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26958. // The point is initially selected by options (#5777)
  26959. if (point.selected) {
  26960. point.state = 'select';
  26961. }
  26962. /**
  26963. * The x value of the point.
  26964. * @name Highcharts.Point#x
  26965. * @type {number}
  26966. */
  26967. // If no x is set by now, get auto incremented value. All points must
  26968. // have an x value, however the y value can be null to create a gap in
  26969. // the series
  26970. if ('name' in point &&
  26971. typeof x === 'undefined' &&
  26972. series.xAxis &&
  26973. series.xAxis.hasNames) {
  26974. point.x = series.xAxis.nameToX(point);
  26975. }
  26976. if (typeof point.x === 'undefined' && series) {
  26977. if (typeof x === 'undefined') {
  26978. point.x = series.autoIncrement(point);
  26979. }
  26980. else {
  26981. point.x = x;
  26982. }
  26983. }
  26984. return point;
  26985. };
  26986. /**
  26987. * Destroy a point to clear memory. Its reference still stays in
  26988. * `series.data`.
  26989. *
  26990. * @private
  26991. * @function Highcharts.Point#destroy
  26992. */
  26993. Point.prototype.destroy = function () {
  26994. var point = this,
  26995. series = point.series,
  26996. chart = series.chart,
  26997. dataSorting = series.options.dataSorting,
  26998. hoverPoints = chart.hoverPoints,
  26999. globalAnimation = point.series.chart.renderer.globalAnimation,
  27000. animation = animObject(globalAnimation),
  27001. prop;
  27002. /**
  27003. * Allow to call after animation.
  27004. * @private
  27005. */
  27006. function destroyPoint() {
  27007. // Remove all events and elements
  27008. if (point.graphic || point.dataLabel || point.dataLabels) {
  27009. removeEvent(point);
  27010. point.destroyElements();
  27011. }
  27012. for (prop in point) { // eslint-disable-line guard-for-in
  27013. point[prop] = null;
  27014. }
  27015. }
  27016. if (point.legendItem) { // pies have legend items
  27017. chart.legend.destroyItem(point);
  27018. }
  27019. if (hoverPoints) {
  27020. point.setState();
  27021. erase(hoverPoints, point);
  27022. if (!hoverPoints.length) {
  27023. chart.hoverPoints = null;
  27024. }
  27025. }
  27026. if (point === chart.hoverPoint) {
  27027. point.onMouseOut();
  27028. }
  27029. // Remove properties after animation
  27030. if (!dataSorting || !dataSorting.enabled) {
  27031. destroyPoint();
  27032. }
  27033. else {
  27034. this.animateBeforeDestroy();
  27035. syncTimeout(destroyPoint, animation.duration);
  27036. }
  27037. chart.pointCount--;
  27038. };
  27039. /**
  27040. * Destroy SVG elements associated with the point.
  27041. *
  27042. * @private
  27043. * @function Highcharts.Point#destroyElements
  27044. * @param {Highcharts.Dictionary<number>} [kinds]
  27045. */
  27046. Point.prototype.destroyElements = function (kinds) {
  27047. var point = this,
  27048. props = point.getGraphicalProps(kinds);
  27049. props.singular.forEach(function (prop) {
  27050. point[prop] = point[prop].destroy();
  27051. });
  27052. props.plural.forEach(function (plural) {
  27053. point[plural].forEach(function (item) {
  27054. if (item.element) {
  27055. item.destroy();
  27056. }
  27057. });
  27058. delete point[plural];
  27059. });
  27060. };
  27061. /**
  27062. * Fire an event on the Point object.
  27063. *
  27064. * @private
  27065. * @function Highcharts.Point#firePointEvent
  27066. *
  27067. * @param {string} eventType
  27068. * Type of the event.
  27069. *
  27070. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  27071. * Additional event arguments.
  27072. *
  27073. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  27074. * Default event handler.
  27075. *
  27076. * @fires Highcharts.Point#event:*
  27077. */
  27078. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  27079. var point = this,
  27080. series = this.series,
  27081. seriesOptions = series.options;
  27082. // load event handlers on demand to save time on mouseover/out
  27083. if (seriesOptions.point.events[eventType] ||
  27084. (point.options &&
  27085. point.options.events &&
  27086. point.options.events[eventType])) {
  27087. point.importEvents();
  27088. }
  27089. // add default handler if in selection mode
  27090. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  27091. defaultFunction = function (event) {
  27092. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  27093. // for Opera.
  27094. if (point.select) { // #2911
  27095. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  27096. }
  27097. };
  27098. }
  27099. fireEvent(point, eventType, eventArgs, defaultFunction);
  27100. };
  27101. /**
  27102. * Get the CSS class names for individual points. Used internally where the
  27103. * returned value is set on every point.
  27104. *
  27105. * @function Highcharts.Point#getClassName
  27106. *
  27107. * @return {string}
  27108. * The class names.
  27109. */
  27110. Point.prototype.getClassName = function () {
  27111. var point = this;
  27112. return 'highcharts-point' +
  27113. (point.selected ? ' highcharts-point-select' : '') +
  27114. (point.negative ? ' highcharts-negative' : '') +
  27115. (point.isNull ? ' highcharts-null-point' : '') +
  27116. (typeof point.colorIndex !== 'undefined' ?
  27117. ' highcharts-color-' + point.colorIndex : '') +
  27118. (point.options.className ? ' ' + point.options.className : '') +
  27119. (point.zone && point.zone.className ? ' ' +
  27120. point.zone.className.replace('highcharts-negative', '') : '');
  27121. };
  27122. /**
  27123. * Get props of all existing graphical point elements.
  27124. *
  27125. * @private
  27126. * @function Highcharts.Point#getGraphicalProps
  27127. * @param {Highcharts.Dictionary<number>} [kinds]
  27128. * @return {Highcharts.PointGraphicalProps}
  27129. */
  27130. Point.prototype.getGraphicalProps = function (kinds) {
  27131. var point = this,
  27132. props = [],
  27133. prop,
  27134. i,
  27135. graphicalProps = { singular: [],
  27136. plural: [] };
  27137. kinds = kinds || { graphic: 1, dataLabel: 1 };
  27138. if (kinds.graphic) {
  27139. props.push('graphic', 'upperGraphic', 'shadowGroup');
  27140. }
  27141. if (kinds.dataLabel) {
  27142. props.push('dataLabel', 'dataLabelUpper', 'connector');
  27143. }
  27144. i = props.length;
  27145. while (i--) {
  27146. prop = props[i];
  27147. if (point[prop]) {
  27148. graphicalProps.singular.push(prop);
  27149. }
  27150. }
  27151. ['dataLabel', 'connector'].forEach(function (prop) {
  27152. var plural = prop + 's';
  27153. if (kinds[prop] && point[plural]) {
  27154. graphicalProps.plural.push(plural);
  27155. }
  27156. });
  27157. return graphicalProps;
  27158. };
  27159. /**
  27160. * Return the configuration hash needed for the data label and tooltip
  27161. * formatters.
  27162. *
  27163. * @function Highcharts.Point#getLabelConfig
  27164. *
  27165. * @return {Highcharts.PointLabelObject}
  27166. * Abstract object used in formatters and formats.
  27167. */
  27168. Point.prototype.getLabelConfig = function () {
  27169. return {
  27170. x: this.category,
  27171. y: this.y,
  27172. color: this.color,
  27173. colorIndex: this.colorIndex,
  27174. key: this.name || this.category,
  27175. series: this.series,
  27176. point: this,
  27177. percentage: this.percentage,
  27178. total: this.total || this.stackTotal
  27179. };
  27180. };
  27181. /**
  27182. * Returns the value of the point property for a given value.
  27183. * @private
  27184. */
  27185. Point.prototype.getNestedProperty = function (key) {
  27186. if (!key) {
  27187. return;
  27188. }
  27189. if (key.indexOf('custom.') === 0) {
  27190. return getNestedProperty(key, this.options);
  27191. }
  27192. return this[key];
  27193. };
  27194. /**
  27195. * In a series with `zones`, return the zone that the point belongs to.
  27196. *
  27197. * @function Highcharts.Point#getZone
  27198. *
  27199. * @return {Highcharts.SeriesZonesOptionsObject}
  27200. * The zone item.
  27201. */
  27202. Point.prototype.getZone = function () {
  27203. var series = this.series,
  27204. zones = series.zones,
  27205. zoneAxis = series.zoneAxis || 'y',
  27206. i = 0,
  27207. zone;
  27208. zone = zones[i];
  27209. while (this[zoneAxis] >= zone.value) {
  27210. zone = zones[++i];
  27211. }
  27212. // For resetting or reusing the point (#8100)
  27213. if (!this.nonZonedColor) {
  27214. this.nonZonedColor = this.color;
  27215. }
  27216. if (zone && zone.color && !this.options.color) {
  27217. this.color = zone.color;
  27218. }
  27219. else {
  27220. this.color = this.nonZonedColor;
  27221. }
  27222. return zone;
  27223. };
  27224. /**
  27225. * Utility to check if point has new shape type. Used in column series and
  27226. * all others that are based on column series.
  27227. *
  27228. * @return boolean|undefined
  27229. */
  27230. Point.prototype.hasNewShapeType = function () {
  27231. var point = this;
  27232. var oldShapeType = point.graphic &&
  27233. (point.graphic.symbolName || point.graphic.element.nodeName);
  27234. return oldShapeType !== this.shapeType;
  27235. };
  27236. /**
  27237. * Initialize the point. Called internally based on the `series.data`
  27238. * option.
  27239. *
  27240. * @function Highcharts.Point#init
  27241. *
  27242. * @param {Highcharts.Series} series
  27243. * The series object containing this point.
  27244. *
  27245. * @param {Highcharts.PointOptionsType} options
  27246. * The data in either number, array or object format.
  27247. *
  27248. * @param {number} [x]
  27249. * Optionally, the X value of the point.
  27250. *
  27251. * @return {Highcharts.Point}
  27252. * The Point instance.
  27253. *
  27254. * @fires Highcharts.Point#event:afterInit
  27255. */
  27256. Point.prototype.init = function (series, options, x) {
  27257. this.series = series;
  27258. this.applyOptions(options, x);
  27259. // Add a unique ID to the point if none is assigned
  27260. this.id = defined(this.id) ? this.id : uniqueKey();
  27261. this.resolveColor();
  27262. series.chart.pointCount++;
  27263. fireEvent(this, 'afterInit');
  27264. return this;
  27265. };
  27266. /**
  27267. * Transform number or array configs into objects. Also called for object
  27268. * configs. Used internally to unify the different configuration formats for
  27269. * points. For example, a simple number `10` in a line series will be
  27270. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  27271. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  27272. *
  27273. * @function Highcharts.Point#optionsToObject
  27274. *
  27275. * @param {Highcharts.PointOptionsType} options
  27276. * The input option.
  27277. *
  27278. * @return {Highcharts.Dictionary<*>}
  27279. * Transformed options.
  27280. */
  27281. Point.prototype.optionsToObject = function (options) {
  27282. var ret = {},
  27283. series = this.series,
  27284. keys = series.options.keys,
  27285. pointArrayMap = keys || series.pointArrayMap || ['y'],
  27286. valueCount = pointArrayMap.length,
  27287. firstItemType,
  27288. i = 0,
  27289. j = 0;
  27290. if (isNumber(options) || options === null) {
  27291. ret[pointArrayMap[0]] = options;
  27292. }
  27293. else if (isArray(options)) {
  27294. // with leading x value
  27295. if (!keys && options.length > valueCount) {
  27296. firstItemType = typeof options[0];
  27297. if (firstItemType === 'string') {
  27298. ret.name = options[0];
  27299. }
  27300. else if (firstItemType === 'number') {
  27301. ret.x = options[0];
  27302. }
  27303. i++;
  27304. }
  27305. while (j < valueCount) {
  27306. // Skip undefined positions for keys
  27307. if (!keys || typeof options[i] !== 'undefined') {
  27308. if (pointArrayMap[j].indexOf('.') > 0) {
  27309. // Handle nested keys, e.g. ['color.pattern.image']
  27310. // Avoid function call unless necessary.
  27311. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  27312. }
  27313. else {
  27314. ret[pointArrayMap[j]] = options[i];
  27315. }
  27316. }
  27317. i++;
  27318. j++;
  27319. }
  27320. }
  27321. else if (typeof options === 'object') {
  27322. ret = options;
  27323. // This is the fastest way to detect if there are individual point
  27324. // dataLabels that need to be considered in drawDataLabels. These
  27325. // can only occur in object configs.
  27326. if (options.dataLabels) {
  27327. series._hasPointLabels = true;
  27328. }
  27329. // Same approach as above for markers
  27330. if (options.marker) {
  27331. series._hasPointMarkers = true;
  27332. }
  27333. }
  27334. return ret;
  27335. };
  27336. /**
  27337. * @private
  27338. * @function Highcharts.Point#resolveColor
  27339. * @return {void}
  27340. */
  27341. Point.prototype.resolveColor = function () {
  27342. var series = this.series,
  27343. colors,
  27344. optionsChart = series.chart.options.chart,
  27345. colorCount = optionsChart.colorCount,
  27346. styledMode = series.chart.styledMode,
  27347. colorIndex,
  27348. color;
  27349. // remove points nonZonedColor for later recalculation
  27350. delete this.nonZonedColor;
  27351. if (series.options.colorByPoint) {
  27352. if (!styledMode) {
  27353. colors = series.options.colors || series.chart.options.colors;
  27354. color = colors[series.colorCounter];
  27355. colorCount = colors.length;
  27356. }
  27357. colorIndex = series.colorCounter;
  27358. series.colorCounter++;
  27359. // loop back to zero
  27360. if (series.colorCounter === colorCount) {
  27361. series.colorCounter = 0;
  27362. }
  27363. }
  27364. else {
  27365. if (!styledMode) {
  27366. color = series.color;
  27367. }
  27368. colorIndex = series.colorIndex;
  27369. }
  27370. this.colorIndex = pick(this.options.colorIndex, colorIndex);
  27371. /**
  27372. * The point's current color.
  27373. *
  27374. * @name Highcharts.Point#color
  27375. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27376. */
  27377. this.color = pick(this.options.color, color);
  27378. };
  27379. /**
  27380. * Set a value in an object, on the property defined by key. The key
  27381. * supports nested properties using dot notation. The function modifies the
  27382. * input object and does not make a copy.
  27383. *
  27384. * @function Highcharts.Point#setNestedProperty<T>
  27385. *
  27386. * @param {T} object
  27387. * The object to set the value on.
  27388. *
  27389. * @param {*} value
  27390. * The value to set.
  27391. *
  27392. * @param {string} key
  27393. * Key to the property to set.
  27394. *
  27395. * @return {T}
  27396. * The modified object.
  27397. */
  27398. Point.prototype.setNestedProperty = function (object, value, key) {
  27399. var nestedKeys = key.split('.');
  27400. nestedKeys.reduce(function (result, key, i, arr) {
  27401. var isLastKey = arr.length - 1 === i;
  27402. result[key] = (isLastKey ?
  27403. value :
  27404. isObject(result[key], true) ?
  27405. result[key] :
  27406. {});
  27407. return result[key];
  27408. }, object);
  27409. return object;
  27410. };
  27411. /**
  27412. * Extendable method for formatting each point's tooltip line.
  27413. *
  27414. * @function Highcharts.Point#tooltipFormatter
  27415. *
  27416. * @param {string} pointFormat
  27417. * The point format.
  27418. *
  27419. * @return {string}
  27420. * A string to be concatenated in to the common tooltip text.
  27421. */
  27422. Point.prototype.tooltipFormatter = function (pointFormat) {
  27423. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27424. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27425. // Replace default point style with class name
  27426. if (series.chart.styledMode) {
  27427. pointFormat =
  27428. series.chart.tooltip.styledModeFormat(pointFormat);
  27429. }
  27430. // Loop over the point array map and replace unformatted values with
  27431. // sprintf formatting markup
  27432. (series.pointArrayMap || ['y']).forEach(function (key) {
  27433. key = '{point.' + key; // without the closing bracket
  27434. if (valuePrefix || valueSuffix) {
  27435. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27436. }
  27437. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27438. });
  27439. return format(pointFormat, {
  27440. point: this,
  27441. series: this.series
  27442. }, series.chart);
  27443. };
  27444. /**
  27445. * Update point with new options (typically x/y data) and optionally redraw
  27446. * the series.
  27447. *
  27448. * @sample highcharts/members/point-update-column/
  27449. * Update column value
  27450. * @sample highcharts/members/point-update-pie/
  27451. * Update pie slice
  27452. * @sample maps/members/point-update/
  27453. * Update map area value in Highmaps
  27454. *
  27455. * @function Highcharts.Point#update
  27456. *
  27457. * @param {Highcharts.PointOptionsType} options
  27458. * The point options. Point options are handled as described under
  27459. * the `series.type.data` item for each series type. For example
  27460. * for a line series, if options is a single number, the point will
  27461. * be given that number as the marin y value. If it is an array, it
  27462. * will be interpreted as x and y values respectively. If it is an
  27463. * object, advanced options are applied.
  27464. *
  27465. * @param {boolean} [redraw=true]
  27466. * Whether to redraw the chart after the point is updated. If doing
  27467. * more operations on the chart, it is best practice to set
  27468. * `redraw` to false and call `chart.redraw()` after.
  27469. *
  27470. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27471. * Whether to apply animation, and optionally animation
  27472. * configuration.
  27473. *
  27474. * @fires Highcharts.Point#event:update
  27475. */
  27476. Point.prototype.update = function (options, redraw, animation, runEvent) {
  27477. var point = this,
  27478. series = point.series,
  27479. graphic = point.graphic,
  27480. i,
  27481. chart = series.chart,
  27482. seriesOptions = series.options;
  27483. redraw = pick(redraw, true);
  27484. /**
  27485. * @private
  27486. */
  27487. function update() {
  27488. point.applyOptions(options);
  27489. // Update visuals, #4146
  27490. // Handle dummy graphic elements for a11y, #12718
  27491. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  27492. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  27493. if (graphic && shouldDestroyGraphic) {
  27494. point.graphic = graphic.destroy();
  27495. delete point.hasDummyGraphic;
  27496. }
  27497. if (isObject(options, true)) {
  27498. // Destroy so we can get new elements
  27499. if (graphic && graphic.element) {
  27500. // "null" is also a valid symbol
  27501. if (options &&
  27502. options.marker &&
  27503. typeof options.marker.symbol !== 'undefined') {
  27504. point.graphic = graphic.destroy();
  27505. }
  27506. }
  27507. if (options && options.dataLabels && point.dataLabel) {
  27508. point.dataLabel = point.dataLabel.destroy(); // #2468
  27509. }
  27510. if (point.connector) {
  27511. point.connector = point.connector.destroy(); // #7243
  27512. }
  27513. }
  27514. // record changes in the parallel arrays
  27515. i = point.index;
  27516. series.updateParallelArrays(point, i);
  27517. // Record the options to options.data. If the old or the new config
  27518. // is an object, use point options, otherwise use raw options
  27519. // (#4701, #4916).
  27520. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  27521. isObject(options, true)) ?
  27522. point.options :
  27523. pick(options, seriesOptions.data[i]);
  27524. // redraw
  27525. series.isDirty = series.isDirtyData = true;
  27526. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  27527. chart.isDirtyBox = true;
  27528. }
  27529. if (seriesOptions.legendType === 'point') { // #1831, #1885
  27530. chart.isDirtyLegend = true;
  27531. }
  27532. if (redraw) {
  27533. chart.redraw(animation);
  27534. }
  27535. }
  27536. // Fire the event with a default handler of doing the update
  27537. if (runEvent === false) { // When called from setData
  27538. update();
  27539. }
  27540. else {
  27541. point.firePointEvent('update', { options: options }, update);
  27542. }
  27543. };
  27544. /**
  27545. * Remove a point and optionally redraw the series and if necessary the axes
  27546. *
  27547. * @sample highcharts/plotoptions/series-point-events-remove/
  27548. * Remove point and confirm
  27549. * @sample highcharts/members/point-remove/
  27550. * Remove pie slice
  27551. * @sample maps/members/point-remove/
  27552. * Remove selected points in Highmaps
  27553. *
  27554. * @function Highcharts.Point#remove
  27555. *
  27556. * @param {boolean} [redraw=true]
  27557. * Whether to redraw the chart or wait for an explicit call. When
  27558. * doing more operations on the chart, for example running
  27559. * `point.remove()` in a loop, it is best practice to set `redraw`
  27560. * to false and call `chart.redraw()` after.
  27561. *
  27562. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  27563. * Whether to apply animation, and optionally animation
  27564. * configuration.
  27565. */
  27566. Point.prototype.remove = function (redraw, animation) {
  27567. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  27568. };
  27569. /**
  27570. * Toggle the selection status of a point.
  27571. *
  27572. * @see Highcharts.Chart#getSelectedPoints
  27573. *
  27574. * @sample highcharts/members/point-select/
  27575. * Select a point from a button
  27576. * @sample highcharts/chart/events-selection-points/
  27577. * Select a range of points through a drag selection
  27578. * @sample maps/series/data-id/
  27579. * Select a point in Highmaps
  27580. *
  27581. * @function Highcharts.Point#select
  27582. *
  27583. * @param {boolean} [selected]
  27584. * When `true`, the point is selected. When `false`, the point is
  27585. * unselected. When `null` or `undefined`, the selection state is toggled.
  27586. *
  27587. * @param {boolean} [accumulate=false]
  27588. * When `true`, the selection is added to other selected points.
  27589. * When `false`, other selected points are deselected. Internally in
  27590. * Highcharts, when
  27591. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  27592. * is `true`, selected points are accumulated on Control, Shift or Cmd
  27593. * clicking the point.
  27594. *
  27595. * @fires Highcharts.Point#event:select
  27596. * @fires Highcharts.Point#event:unselect
  27597. */
  27598. Point.prototype.select = function (selected, accumulate) {
  27599. var point = this,
  27600. series = point.series,
  27601. chart = series.chart;
  27602. selected = pick(selected, !point.selected);
  27603. this.selectedStaging = selected;
  27604. // fire the event with the default handler
  27605. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  27606. /**
  27607. * Whether the point is selected or not.
  27608. *
  27609. * @see Point#select
  27610. * @see Chart#getSelectedPoints
  27611. *
  27612. * @name Highcharts.Point#selected
  27613. * @type {boolean}
  27614. */
  27615. point.selected = point.options.selected = selected;
  27616. series.options.data[series.data.indexOf(point)] =
  27617. point.options;
  27618. point.setState(selected && 'select');
  27619. // unselect all other points unless Ctrl or Cmd + click
  27620. if (!accumulate) {
  27621. chart.getSelectedPoints().forEach(function (loopPoint) {
  27622. var loopSeries = loopPoint.series;
  27623. if (loopPoint.selected && loopPoint !== point) {
  27624. loopPoint.selected = loopPoint.options.selected =
  27625. false;
  27626. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  27627. // Programatically selecting a point should restore
  27628. // normal state, but when click happened on other
  27629. // point, set inactive state to match other points
  27630. loopPoint.setState(chart.hoverPoints &&
  27631. loopSeries.options.inactiveOtherPoints ?
  27632. 'inactive' : '');
  27633. loopPoint.firePointEvent('unselect');
  27634. }
  27635. });
  27636. }
  27637. });
  27638. delete this.selectedStaging;
  27639. };
  27640. /**
  27641. * Runs on mouse over the point. Called internally from mouse and touch
  27642. * events.
  27643. *
  27644. * @function Highcharts.Point#onMouseOver
  27645. *
  27646. * @param {Highcharts.PointerEventObject} [e]
  27647. * The event arguments.
  27648. */
  27649. Point.prototype.onMouseOver = function (e) {
  27650. var point = this,
  27651. series = point.series,
  27652. chart = series.chart,
  27653. pointer = chart.pointer;
  27654. e = e ?
  27655. pointer.normalize(e) :
  27656. // In cases where onMouseOver is called directly without an event
  27657. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  27658. pointer.runPointActions(e, point);
  27659. };
  27660. /**
  27661. * Runs on mouse out from the point. Called internally from mouse and touch
  27662. * events.
  27663. *
  27664. * @function Highcharts.Point#onMouseOut
  27665. * @fires Highcharts.Point#event:mouseOut
  27666. */
  27667. Point.prototype.onMouseOut = function () {
  27668. var point = this,
  27669. chart = point.series.chart;
  27670. point.firePointEvent('mouseOut');
  27671. if (!point.series.options.inactiveOtherPoints) {
  27672. (chart.hoverPoints || []).forEach(function (p) {
  27673. p.setState();
  27674. });
  27675. }
  27676. chart.hoverPoints = chart.hoverPoint = null;
  27677. };
  27678. /**
  27679. * Import events from the series' and point's options. Only do it on
  27680. * demand, to save processing time on hovering.
  27681. *
  27682. * @private
  27683. * @function Highcharts.Point#importEvents
  27684. */
  27685. Point.prototype.importEvents = function () {
  27686. if (!this.hasImportedEvents) {
  27687. var point_1 = this,
  27688. options = merge(point_1.series.options.point,
  27689. point_1.options),
  27690. events = options.events;
  27691. point_1.events = events;
  27692. objectEach(events, function (event, eventType) {
  27693. if (isFunction(event)) {
  27694. addEvent(point_1, eventType, event);
  27695. }
  27696. });
  27697. this.hasImportedEvents = true;
  27698. }
  27699. };
  27700. /**
  27701. * Set the point's state.
  27702. *
  27703. * @function Highcharts.Point#setState
  27704. *
  27705. * @param {Highcharts.PointStateValue|""} [state]
  27706. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  27707. * or `''` (an empty string), `'normal'` or `undefined` to set to
  27708. * normal state.
  27709. * @param {boolean} [move]
  27710. * State for animation.
  27711. *
  27712. * @fires Highcharts.Point#event:afterSetState
  27713. */
  27714. Point.prototype.setState = function (state, move) {
  27715. var point = this,
  27716. series = point.series,
  27717. previousState = point.state,
  27718. stateOptions = (series.options.states[state || 'normal'] ||
  27719. {}),
  27720. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  27721. series.options.marker),
  27722. normalDisabled = (markerOptions && markerOptions.enabled === false),
  27723. markerStateOptions = ((markerOptions &&
  27724. markerOptions.states &&
  27725. markerOptions.states[state || 'normal']) || {}),
  27726. stateDisabled = markerStateOptions.enabled === false,
  27727. stateMarkerGraphic = series.stateMarkerGraphic,
  27728. pointMarker = point.marker || {},
  27729. chart = series.chart,
  27730. halo = series.halo,
  27731. haloOptions,
  27732. markerAttribs,
  27733. pointAttribs,
  27734. pointAttribsAnimation,
  27735. hasMarkers = (markerOptions && series.markerAttribs),
  27736. newSymbol;
  27737. state = state || ''; // empty string
  27738. if (
  27739. // already has this state
  27740. (state === point.state && !move) ||
  27741. // selected points don't respond to hover
  27742. (point.selected && state !== 'select') ||
  27743. // series' state options is disabled
  27744. (stateOptions.enabled === false) ||
  27745. // general point marker's state options is disabled
  27746. (state && (stateDisabled ||
  27747. (normalDisabled &&
  27748. markerStateOptions.enabled === false))) ||
  27749. // individual point marker's state options is disabled
  27750. (state &&
  27751. pointMarker.states &&
  27752. pointMarker.states[state] &&
  27753. pointMarker.states[state].enabled === false) // #1610
  27754. ) {
  27755. return;
  27756. }
  27757. point.state = state;
  27758. if (hasMarkers) {
  27759. markerAttribs = series.markerAttribs(point, state);
  27760. }
  27761. // Apply hover styles to the existing point
  27762. // Prevent from dummy null points (#14966)
  27763. if (point.graphic && !point.hasDummyGraphic) {
  27764. if (previousState) {
  27765. point.graphic.removeClass('highcharts-point-' + previousState);
  27766. }
  27767. if (state) {
  27768. point.graphic.addClass('highcharts-point-' + state);
  27769. }
  27770. if (!chart.styledMode) {
  27771. pointAttribs = series.pointAttribs(point, state);
  27772. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  27773. // Some inactive points (e.g. slices in pie) should apply
  27774. // oppacity also for it's labels
  27775. if (series.options.inactiveOtherPoints && isNumber(pointAttribs.opacity)) {
  27776. (point.dataLabels || []).forEach(function (label) {
  27777. if (label) {
  27778. label.animate({
  27779. opacity: pointAttribs.opacity
  27780. }, pointAttribsAnimation);
  27781. }
  27782. });
  27783. if (point.connector) {
  27784. point.connector.animate({
  27785. opacity: pointAttribs.opacity
  27786. }, pointAttribsAnimation);
  27787. }
  27788. }
  27789. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  27790. }
  27791. if (markerAttribs) {
  27792. point.graphic.animate(markerAttribs, pick(
  27793. // Turn off globally:
  27794. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  27795. }
  27796. // Zooming in from a range with no markers to a range with markers
  27797. if (stateMarkerGraphic) {
  27798. stateMarkerGraphic.hide();
  27799. }
  27800. }
  27801. else {
  27802. // if a graphic is not applied to each point in the normal state,
  27803. // create a shared graphic for the hover state
  27804. if (state && markerStateOptions) {
  27805. newSymbol = pointMarker.symbol || series.symbol;
  27806. // If the point has another symbol than the previous one, throw
  27807. // away the state marker graphic and force a new one (#1459)
  27808. if (stateMarkerGraphic &&
  27809. stateMarkerGraphic.currentSymbol !== newSymbol) {
  27810. stateMarkerGraphic = stateMarkerGraphic.destroy();
  27811. }
  27812. // Add a new state marker graphic
  27813. if (markerAttribs) {
  27814. if (!stateMarkerGraphic) {
  27815. if (newSymbol) {
  27816. series.stateMarkerGraphic = stateMarkerGraphic =
  27817. chart.renderer
  27818. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  27819. .add(series.markerGroup);
  27820. stateMarkerGraphic.currentSymbol = newSymbol;
  27821. }
  27822. // Move the existing graphic
  27823. }
  27824. else {
  27825. stateMarkerGraphic[move ? 'animate' : 'attr']({
  27826. x: markerAttribs.x,
  27827. y: markerAttribs.y
  27828. });
  27829. }
  27830. }
  27831. if (!chart.styledMode && stateMarkerGraphic) {
  27832. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  27833. }
  27834. }
  27835. if (stateMarkerGraphic) {
  27836. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  27837. stateMarkerGraphic.element.point = point; // #4310
  27838. }
  27839. }
  27840. // Show me your halo
  27841. haloOptions = stateOptions.halo;
  27842. var markerGraphic = (point.graphic || stateMarkerGraphic);
  27843. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  27844. if (haloOptions &&
  27845. haloOptions.size &&
  27846. markerGraphic &&
  27847. markerVisibility !== 'hidden' &&
  27848. !point.isCluster) {
  27849. if (!halo) {
  27850. series.halo = halo = chart.renderer.path()
  27851. // #5818, #5903, #6705
  27852. .add(markerGraphic.parentGroup);
  27853. }
  27854. halo.show()[move ? 'animate' : 'attr']({
  27855. d: point.haloPath(haloOptions.size)
  27856. });
  27857. halo.attr({
  27858. 'class': 'highcharts-halo highcharts-color-' +
  27859. pick(point.colorIndex, series.colorIndex) +
  27860. (point.className ? ' ' + point.className : ''),
  27861. 'visibility': markerVisibility,
  27862. 'zIndex': -1 // #4929, #8276
  27863. });
  27864. halo.point = point; // #6055
  27865. if (!chart.styledMode) {
  27866. halo.attr(extend({
  27867. 'fill': point.color || series.color,
  27868. 'fill-opacity': haloOptions.opacity
  27869. }, AST.filterUserAttributes(haloOptions.attributes || {})));
  27870. }
  27871. }
  27872. else if (halo && halo.point && halo.point.haloPath) {
  27873. // Animate back to 0 on the current halo point (#6055)
  27874. halo.animate({ d: halo.point.haloPath(0) }, null,
  27875. // Hide after unhovering. The `complete` callback runs in the
  27876. // halo's context (#7681).
  27877. halo.hide);
  27878. }
  27879. fireEvent(point, 'afterSetState', { state: state });
  27880. };
  27881. /**
  27882. * Get the path definition for the halo, which is usually a shadow-like
  27883. * circle around the currently hovered point.
  27884. *
  27885. * @function Highcharts.Point#haloPath
  27886. *
  27887. * @param {number} size
  27888. * The radius of the circular halo.
  27889. *
  27890. * @return {Highcharts.SVGPathArray}
  27891. * The path definition.
  27892. */
  27893. Point.prototype.haloPath = function (size) {
  27894. var series = this.series,
  27895. chart = series.chart;
  27896. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  27897. };
  27898. return Point;
  27899. }());
  27900. H.Point = Point;
  27901. return Point;
  27902. });
  27903. _registerModule(_modules, 'Core/Legend.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, F, H, Point, U) {
  27904. /* *
  27905. *
  27906. * (c) 2010-2021 Torstein Honsi
  27907. *
  27908. * License: www.highcharts.com/license
  27909. *
  27910. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27911. *
  27912. * */
  27913. var animObject = A.animObject,
  27914. setAnimation = A.setAnimation;
  27915. var format = F.format;
  27916. var isFirefox = H.isFirefox,
  27917. marginNames = H.marginNames,
  27918. win = H.win;
  27919. var addEvent = U.addEvent,
  27920. createElement = U.createElement,
  27921. css = U.css,
  27922. defined = U.defined,
  27923. discardElement = U.discardElement,
  27924. find = U.find,
  27925. fireEvent = U.fireEvent,
  27926. isNumber = U.isNumber,
  27927. merge = U.merge,
  27928. pick = U.pick,
  27929. relativeLength = U.relativeLength,
  27930. stableSort = U.stableSort,
  27931. syncTimeout = U.syncTimeout,
  27932. wrap = U.wrap;
  27933. /**
  27934. * Gets fired when the legend item belonging to a point is clicked. The default
  27935. * action is to toggle the visibility of the point. This can be prevented by
  27936. * returning `false` or calling `event.preventDefault()`.
  27937. *
  27938. * @callback Highcharts.PointLegendItemClickCallbackFunction
  27939. *
  27940. * @param {Highcharts.Point} this
  27941. * The point on which the event occured.
  27942. *
  27943. * @param {Highcharts.PointLegendItemClickEventObject} event
  27944. * The event that occured.
  27945. */
  27946. /**
  27947. * Information about the legend click event.
  27948. *
  27949. * @interface Highcharts.PointLegendItemClickEventObject
  27950. */ /**
  27951. * Related browser event.
  27952. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  27953. * @type {Highcharts.PointerEvent}
  27954. */ /**
  27955. * Prevent the default action of toggle the visibility of the point.
  27956. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  27957. * @type {Function}
  27958. */ /**
  27959. * Related point.
  27960. * @name Highcharts.PointLegendItemClickEventObject#target
  27961. * @type {Highcharts.Point}
  27962. */ /**
  27963. * Event type.
  27964. * @name Highcharts.PointLegendItemClickEventObject#type
  27965. * @type {"legendItemClick"}
  27966. */
  27967. /**
  27968. * Gets fired when the legend item belonging to a series is clicked. The default
  27969. * action is to toggle the visibility of the series. This can be prevented by
  27970. * returning `false` or calling `event.preventDefault()`.
  27971. *
  27972. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  27973. *
  27974. * @param {Highcharts.Series} this
  27975. * The series where the event occured.
  27976. *
  27977. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  27978. * The event that occured.
  27979. */
  27980. /**
  27981. * Information about the legend click event.
  27982. *
  27983. * @interface Highcharts.SeriesLegendItemClickEventObject
  27984. */ /**
  27985. * Related browser event.
  27986. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  27987. * @type {Highcharts.PointerEvent}
  27988. */ /**
  27989. * Prevent the default action of toggle the visibility of the series.
  27990. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  27991. * @type {Function}
  27992. */ /**
  27993. * Related series.
  27994. * @name Highcharts.SeriesLegendItemClickEventObject#target
  27995. * @type {Highcharts.Series}
  27996. */ /**
  27997. * Event type.
  27998. * @name Highcharts.SeriesLegendItemClickEventObject#type
  27999. * @type {"legendItemClick"}
  28000. */
  28001. /* eslint-disable no-invalid-this, valid-jsdoc */
  28002. /**
  28003. * The overview of the chart's series. The legend object is instanciated
  28004. * internally in the chart constructor, and is available from the `chart.legend`
  28005. * property. Each chart has only one legend.
  28006. *
  28007. * @class
  28008. * @name Highcharts.Legend
  28009. *
  28010. * @param {Highcharts.Chart} chart
  28011. * The chart instance.
  28012. *
  28013. * @param {Highcharts.LegendOptions} options
  28014. * Legend options.
  28015. */
  28016. var Legend = /** @class */ (function () {
  28017. /* *
  28018. *
  28019. * Constructors
  28020. *
  28021. * */
  28022. function Legend(chart, options) {
  28023. /* *
  28024. *
  28025. * Properties
  28026. *
  28027. * */
  28028. this.allItems = [];
  28029. this.box = void 0;
  28030. this.contentGroup = void 0;
  28031. this.display = false;
  28032. this.group = void 0;
  28033. this.initialItemY = 0;
  28034. this.itemHeight = 0;
  28035. this.itemMarginBottom = 0;
  28036. this.itemMarginTop = 0;
  28037. this.itemX = 0;
  28038. this.itemY = 0;
  28039. this.lastItemY = 0;
  28040. this.lastLineHeight = 0;
  28041. this.legendHeight = 0;
  28042. this.legendWidth = 0;
  28043. this.maxItemWidth = 0;
  28044. this.maxLegendWidth = 0;
  28045. this.offsetWidth = 0;
  28046. this.options = {};
  28047. this.padding = 0;
  28048. this.pages = [];
  28049. this.proximate = false;
  28050. this.scrollGroup = void 0;
  28051. this.symbolHeight = 0;
  28052. this.symbolWidth = 0;
  28053. this.titleHeight = 0;
  28054. this.totalItemWidth = 0;
  28055. this.widthOption = 0;
  28056. this.chart = chart;
  28057. this.init(chart, options);
  28058. }
  28059. /* *
  28060. *
  28061. * Functions
  28062. *
  28063. * */
  28064. /**
  28065. * Initialize the legend.
  28066. *
  28067. * @private
  28068. * @function Highcharts.Legend#init
  28069. *
  28070. * @param {Highcharts.Chart} chart
  28071. * The chart instance.
  28072. *
  28073. * @param {Highcharts.LegendOptions} options
  28074. * Legend options.
  28075. */
  28076. Legend.prototype.init = function (chart, options) {
  28077. /**
  28078. * Chart of this legend.
  28079. *
  28080. * @readonly
  28081. * @name Highcharts.Legend#chart
  28082. * @type {Highcharts.Chart}
  28083. */
  28084. this.chart = chart;
  28085. this.setOptions(options);
  28086. if (options.enabled) {
  28087. // Render it
  28088. this.render();
  28089. // move checkboxes
  28090. addEvent(this.chart, 'endResize', function () {
  28091. this.legend.positionCheckboxes();
  28092. });
  28093. if (this.proximate) {
  28094. this.unchartrender = addEvent(this.chart, 'render', function () {
  28095. this.legend.proximatePositions();
  28096. this.legend.positionItems();
  28097. });
  28098. }
  28099. else if (this.unchartrender) {
  28100. this.unchartrender();
  28101. }
  28102. }
  28103. };
  28104. /**
  28105. * @private
  28106. * @function Highcharts.Legend#setOptions
  28107. * @param {Highcharts.LegendOptions} options
  28108. */
  28109. Legend.prototype.setOptions = function (options) {
  28110. var padding = pick(options.padding, 8);
  28111. /**
  28112. * Legend options.
  28113. *
  28114. * @readonly
  28115. * @name Highcharts.Legend#options
  28116. * @type {Highcharts.LegendOptions}
  28117. */
  28118. this.options = options;
  28119. if (!this.chart.styledMode) {
  28120. this.itemStyle = options.itemStyle;
  28121. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  28122. }
  28123. this.itemMarginTop = options.itemMarginTop || 0;
  28124. this.itemMarginBottom = options.itemMarginBottom || 0;
  28125. this.padding = padding;
  28126. this.initialItemY = padding - 5; // 5 is pixels above the text
  28127. this.symbolWidth = pick(options.symbolWidth, 16);
  28128. this.pages = [];
  28129. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  28130. this.baseline = void 0; // #12705: baseline has to be reset on every update
  28131. };
  28132. /**
  28133. * Update the legend with new options. Equivalent to running `chart.update`
  28134. * with a legend configuration option.
  28135. *
  28136. * @sample highcharts/legend/legend-update/
  28137. * Legend update
  28138. *
  28139. * @function Highcharts.Legend#update
  28140. *
  28141. * @param {Highcharts.LegendOptions} options
  28142. * Legend options.
  28143. *
  28144. * @param {boolean} [redraw=true]
  28145. * Whether to redraw the chart after the axis is altered. If doing more
  28146. * operations on the chart, it is a good idea to set redraw to false and
  28147. * call {@link Chart#redraw} after. Whether to redraw the chart.
  28148. *
  28149. * @fires Highcharts.Legends#event:afterUpdate
  28150. */
  28151. Legend.prototype.update = function (options, redraw) {
  28152. var chart = this.chart;
  28153. this.setOptions(merge(true, this.options, options));
  28154. this.destroy();
  28155. chart.isDirtyLegend = chart.isDirtyBox = true;
  28156. if (pick(redraw, true)) {
  28157. chart.redraw();
  28158. }
  28159. fireEvent(this, 'afterUpdate');
  28160. };
  28161. /**
  28162. * Set the colors for the legend item.
  28163. *
  28164. * @private
  28165. * @function Highcharts.Legend#colorizeItem
  28166. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28167. * A Series or Point instance
  28168. * @param {boolean} [visible=false]
  28169. * Dimmed or colored
  28170. *
  28171. * @todo
  28172. * Make events official: Fires the event `afterColorizeItem`.
  28173. */
  28174. Legend.prototype.colorizeItem = function (item, visible) {
  28175. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  28176. if (!this.chart.styledMode) {
  28177. var legend = this,
  28178. options = legend.options,
  28179. legendItem = item.legendItem,
  28180. legendLine = item.legendLine,
  28181. legendSymbol = item.legendSymbol,
  28182. hiddenColor = legend.itemHiddenStyle.color,
  28183. textColor = visible ?
  28184. options.itemStyle.color :
  28185. hiddenColor,
  28186. symbolColor = visible ?
  28187. (item.color || hiddenColor) :
  28188. hiddenColor,
  28189. markerOptions = item.options && item.options.marker,
  28190. symbolAttr = { fill: symbolColor };
  28191. if (legendItem) {
  28192. legendItem.css({
  28193. fill: textColor,
  28194. color: textColor // #1553, oldIE
  28195. });
  28196. }
  28197. if (legendLine) {
  28198. legendLine.attr({ stroke: symbolColor });
  28199. }
  28200. if (legendSymbol) {
  28201. // Apply marker options
  28202. if (markerOptions && legendSymbol.isMarker) { // #585
  28203. symbolAttr = item.pointAttribs();
  28204. if (!visible) {
  28205. // #6769
  28206. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  28207. }
  28208. }
  28209. legendSymbol.attr(symbolAttr);
  28210. }
  28211. }
  28212. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  28213. };
  28214. /**
  28215. * @private
  28216. * @function Highcharts.Legend#positionItems
  28217. */
  28218. Legend.prototype.positionItems = function () {
  28219. // Now that the legend width and height are established, put the items
  28220. // in the final position
  28221. this.allItems.forEach(this.positionItem, this);
  28222. if (!this.chart.isResizing) {
  28223. this.positionCheckboxes();
  28224. }
  28225. };
  28226. /**
  28227. * Position the legend item.
  28228. *
  28229. * @private
  28230. * @function Highcharts.Legend#positionItem
  28231. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28232. * The item to position
  28233. */
  28234. Legend.prototype.positionItem = function (item) {
  28235. var _this = this;
  28236. var legend = this,
  28237. options = legend.options,
  28238. symbolPadding = options.symbolPadding,
  28239. ltr = !options.rtl,
  28240. legendItemPos = item._legendItemPos,
  28241. itemX = legendItemPos[0],
  28242. itemY = legendItemPos[1],
  28243. checkbox = item.checkbox,
  28244. legendGroup = item.legendGroup;
  28245. if (legendGroup && legendGroup.element) {
  28246. var attribs = {
  28247. translateX: ltr ?
  28248. itemX :
  28249. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  28250. translateY: itemY
  28251. };
  28252. var complete = function () {
  28253. fireEvent(_this, 'afterPositionItem', { item: item });
  28254. };
  28255. if (defined(legendGroup.translateY)) {
  28256. legendGroup.animate(attribs, void 0, complete);
  28257. }
  28258. else {
  28259. legendGroup.attr(attribs);
  28260. complete();
  28261. }
  28262. }
  28263. if (checkbox) {
  28264. checkbox.x = itemX;
  28265. checkbox.y = itemY;
  28266. }
  28267. };
  28268. /**
  28269. * Destroy a single legend item, used internally on removing series items.
  28270. *
  28271. * @private
  28272. * @function Highcharts.Legend#destroyItem
  28273. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28274. * The item to remove
  28275. */
  28276. Legend.prototype.destroyItem = function (item) {
  28277. var checkbox = item.checkbox;
  28278. // destroy SVG elements
  28279. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  28280. if (item[key]) {
  28281. item[key] = item[key].destroy();
  28282. }
  28283. });
  28284. if (checkbox) {
  28285. discardElement(item.checkbox);
  28286. }
  28287. };
  28288. /**
  28289. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  28290. * must be called after destruction.
  28291. *
  28292. * @private
  28293. * @function Highcharts.Legend#destroy
  28294. */
  28295. Legend.prototype.destroy = function () {
  28296. /**
  28297. * @private
  28298. * @param {string} key
  28299. * @return {void}
  28300. */
  28301. function destroyItems(key) {
  28302. if (this[key]) {
  28303. this[key] = this[key].destroy();
  28304. }
  28305. }
  28306. // Destroy items
  28307. this.getAllItems().forEach(function (item) {
  28308. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  28309. });
  28310. // Destroy legend elements
  28311. [
  28312. 'clipRect',
  28313. 'up',
  28314. 'down',
  28315. 'pager',
  28316. 'nav',
  28317. 'box',
  28318. 'title',
  28319. 'group'
  28320. ].forEach(destroyItems, this);
  28321. this.display = null; // Reset in .render on update.
  28322. };
  28323. /**
  28324. * Position the checkboxes after the width is determined.
  28325. *
  28326. * @private
  28327. * @function Highcharts.Legend#positionCheckboxes
  28328. */
  28329. Legend.prototype.positionCheckboxes = function () {
  28330. var alignAttr = this.group && this.group.alignAttr,
  28331. translateY,
  28332. clipHeight = this.clipHeight || this.legendHeight,
  28333. titleHeight = this.titleHeight;
  28334. if (alignAttr) {
  28335. translateY = alignAttr.translateY;
  28336. this.allItems.forEach(function (item) {
  28337. var checkbox = item.checkbox,
  28338. top;
  28339. if (checkbox) {
  28340. top = translateY + titleHeight + checkbox.y +
  28341. (this.scrollOffset || 0) + 3;
  28342. css(checkbox, {
  28343. left: (alignAttr.translateX + item.checkboxOffset +
  28344. checkbox.x - 20) + 'px',
  28345. top: top + 'px',
  28346. display: this.proximate || (top > translateY - 6 &&
  28347. top < translateY + clipHeight - 6) ?
  28348. '' :
  28349. 'none'
  28350. });
  28351. }
  28352. }, this);
  28353. }
  28354. };
  28355. /**
  28356. * Render the legend title on top of the legend.
  28357. *
  28358. * @private
  28359. * @function Highcharts.Legend#renderTitle
  28360. */
  28361. Legend.prototype.renderTitle = function () {
  28362. var options = this.options,
  28363. padding = this.padding,
  28364. titleOptions = options.title,
  28365. titleHeight = 0,
  28366. bBox;
  28367. if (titleOptions.text) {
  28368. if (!this.title) {
  28369. /**
  28370. * SVG element of the legend title.
  28371. *
  28372. * @readonly
  28373. * @name Highcharts.Legend#title
  28374. * @type {Highcharts.SVGElement}
  28375. */
  28376. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  28377. .attr({ zIndex: 1 });
  28378. if (!this.chart.styledMode) {
  28379. this.title.css(titleOptions.style);
  28380. }
  28381. this.title.add(this.group);
  28382. }
  28383. // Set the max title width (#7253)
  28384. if (!titleOptions.width) {
  28385. this.title.css({
  28386. width: this.maxLegendWidth + 'px'
  28387. });
  28388. }
  28389. bBox = this.title.getBBox();
  28390. titleHeight = bBox.height;
  28391. this.offsetWidth = bBox.width; // #1717
  28392. this.contentGroup.attr({ translateY: titleHeight });
  28393. }
  28394. this.titleHeight = titleHeight;
  28395. };
  28396. /**
  28397. * Set the legend item text.
  28398. *
  28399. * @function Highcharts.Legend#setText
  28400. * @param {Highcharts.Point|Highcharts.Series} item
  28401. * The item for which to update the text in the legend.
  28402. */
  28403. Legend.prototype.setText = function (item) {
  28404. var options = this.options;
  28405. item.legendItem.attr({
  28406. text: options.labelFormat ?
  28407. format(options.labelFormat, item, this.chart) :
  28408. options.labelFormatter.call(item)
  28409. });
  28410. };
  28411. /**
  28412. * Render a single specific legend item. Called internally from the `render`
  28413. * function.
  28414. *
  28415. * @private
  28416. * @function Highcharts.Legend#renderItem
  28417. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28418. * The item to render.
  28419. */
  28420. Legend.prototype.renderItem = function (item) {
  28421. var legend = this,
  28422. chart = legend.chart,
  28423. renderer = chart.renderer,
  28424. options = legend.options,
  28425. horizontal = options.layout === 'horizontal',
  28426. symbolWidth = legend.symbolWidth,
  28427. symbolPadding = options.symbolPadding || 0,
  28428. itemStyle = legend.itemStyle,
  28429. itemHiddenStyle = legend.itemHiddenStyle,
  28430. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28431. ltr = !options.rtl,
  28432. bBox,
  28433. li = item.legendItem,
  28434. isSeries = !item.series,
  28435. series = !isSeries && item.series.drawLegendSymbol ?
  28436. item.series :
  28437. item,
  28438. seriesOptions = series.options,
  28439. showCheckbox = legend.createCheckboxForItem &&
  28440. seriesOptions &&
  28441. seriesOptions.showCheckbox,
  28442. // full width minus text width
  28443. itemExtraWidth = symbolWidth + symbolPadding +
  28444. itemDistance + (showCheckbox ? 20 : 0),
  28445. useHTML = options.useHTML,
  28446. itemClassName = item.options.className;
  28447. if (!li) { // generate it once, later move it
  28448. // Generate the group box, a group to hold the symbol and text. Text
  28449. // is to be appended in Legend class.
  28450. item.legendGroup = renderer
  28451. .g('legend-item')
  28452. .addClass('highcharts-' + series.type + '-series ' +
  28453. 'highcharts-color-' + item.colorIndex +
  28454. (itemClassName ? ' ' + itemClassName : '') +
  28455. (isSeries ?
  28456. ' highcharts-series-' + item.index :
  28457. ''))
  28458. .attr({ zIndex: 1 })
  28459. .add(legend.scrollGroup);
  28460. // Generate the list item text and add it to the group
  28461. item.legendItem = li = renderer.text('', ltr ?
  28462. symbolWidth + symbolPadding :
  28463. -symbolPadding, legend.baseline || 0, useHTML);
  28464. if (!chart.styledMode) {
  28465. // merge to prevent modifying original (#1021)
  28466. li.css(merge(item.visible ?
  28467. itemStyle :
  28468. itemHiddenStyle));
  28469. }
  28470. li
  28471. .attr({
  28472. align: ltr ? 'left' : 'right',
  28473. zIndex: 2
  28474. })
  28475. .add(item.legendGroup);
  28476. // Get the baseline for the first item - the font size is equal for
  28477. // all
  28478. if (!legend.baseline) {
  28479. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  28480. legend.baseline =
  28481. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  28482. li.attr('y', legend.baseline);
  28483. legend.symbolHeight =
  28484. options.symbolHeight || legend.fontMetrics.f;
  28485. if (options.squareSymbol) {
  28486. legend.symbolWidth = pick(options.symbolWidth, Math.max(legend.symbolHeight, 16));
  28487. itemExtraWidth = legend.symbolWidth + symbolPadding +
  28488. itemDistance + (showCheckbox ? 20 : 0);
  28489. if (ltr) {
  28490. li.attr('x', legend.symbolWidth + symbolPadding);
  28491. }
  28492. }
  28493. }
  28494. // Draw the legend symbol inside the group box
  28495. series.drawLegendSymbol(legend, item);
  28496. if (legend.setItemEvents) {
  28497. legend.setItemEvents(item, li, useHTML);
  28498. }
  28499. }
  28500. // Add the HTML checkbox on top
  28501. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  28502. legend.createCheckboxForItem(item);
  28503. }
  28504. // Colorize the items
  28505. legend.colorizeItem(item, item.visible);
  28506. // Take care of max width and text overflow (#6659)
  28507. if (chart.styledMode || !itemStyle.width) {
  28508. li.css({
  28509. width: ((options.itemWidth ||
  28510. legend.widthOption ||
  28511. chart.spacingBox.width) - itemExtraWidth) + 'px'
  28512. });
  28513. }
  28514. // Always update the text
  28515. legend.setText(item);
  28516. // calculate the positions for the next line
  28517. bBox = li.getBBox();
  28518. item.itemWidth = item.checkboxOffset =
  28519. options.itemWidth ||
  28520. item.legendItemWidth ||
  28521. bBox.width + itemExtraWidth;
  28522. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  28523. legend.totalItemWidth += item.itemWidth;
  28524. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  28525. };
  28526. /**
  28527. * Get the position of the item in the layout. We now know the
  28528. * maxItemWidth from the previous loop.
  28529. *
  28530. * @private
  28531. * @function Highcharts.Legend#layoutItem
  28532. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28533. */
  28534. Legend.prototype.layoutItem = function (item) {
  28535. var options = this.options,
  28536. padding = this.padding,
  28537. horizontal = options.layout === 'horizontal',
  28538. itemHeight = item.itemHeight,
  28539. itemMarginBottom = this.itemMarginBottom,
  28540. itemMarginTop = this.itemMarginTop,
  28541. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28542. maxLegendWidth = this.maxLegendWidth,
  28543. itemWidth = (options.alignColumns &&
  28544. this.totalItemWidth > maxLegendWidth) ?
  28545. this.maxItemWidth :
  28546. item.itemWidth;
  28547. // If the item exceeds the width, start a new line
  28548. if (horizontal &&
  28549. this.itemX - padding + itemWidth > maxLegendWidth) {
  28550. this.itemX = padding;
  28551. if (this.lastLineHeight) { // Not for the first line (#10167)
  28552. this.itemY += (itemMarginTop +
  28553. this.lastLineHeight +
  28554. itemMarginBottom);
  28555. }
  28556. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  28557. }
  28558. // Set the edge positions
  28559. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  28560. this.lastLineHeight = Math.max(// #915
  28561. itemHeight, this.lastLineHeight);
  28562. // cache the position of the newly generated or reordered items
  28563. item._legendItemPos = [this.itemX, this.itemY];
  28564. // advance
  28565. if (horizontal) {
  28566. this.itemX += itemWidth;
  28567. }
  28568. else {
  28569. this.itemY +=
  28570. itemMarginTop + itemHeight + itemMarginBottom;
  28571. this.lastLineHeight = itemHeight;
  28572. }
  28573. // the width of the widest item
  28574. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  28575. // decrease by itemDistance only when no checkbox #4853
  28576. 0 :
  28577. itemDistance) : itemWidth) + padding, this.offsetWidth);
  28578. };
  28579. /**
  28580. * Get all items, which is one item per series for most series and one
  28581. * item per point for pie series and its derivatives. Fires the event
  28582. * `afterGetAllItems`.
  28583. *
  28584. * @private
  28585. * @function Highcharts.Legend#getAllItems
  28586. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  28587. * The current items in the legend.
  28588. * @fires Highcharts.Legend#event:afterGetAllItems
  28589. */
  28590. Legend.prototype.getAllItems = function () {
  28591. var allItems = [];
  28592. this.chart.series.forEach(function (series) {
  28593. var seriesOptions = series && series.options;
  28594. // Handle showInLegend. If the series is linked to another series,
  28595. // defaults to false.
  28596. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  28597. // Use points or series for the legend item depending on
  28598. // legendType
  28599. allItems = allItems.concat(series.legendItems ||
  28600. (seriesOptions.legendType === 'point' ?
  28601. series.data :
  28602. series));
  28603. }
  28604. });
  28605. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  28606. return allItems;
  28607. };
  28608. /**
  28609. * Get a short, three letter string reflecting the alignment and layout.
  28610. *
  28611. * @private
  28612. * @function Highcharts.Legend#getAlignment
  28613. * @return {string}
  28614. * The alignment, empty string if floating
  28615. */
  28616. Legend.prototype.getAlignment = function () {
  28617. var options = this.options;
  28618. // Use the first letter of each alignment option in order to detect
  28619. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  28620. if (this.proximate) {
  28621. return options.align.charAt(0) + 'tv';
  28622. }
  28623. return options.floating ? '' : (options.align.charAt(0) +
  28624. options.verticalAlign.charAt(0) +
  28625. options.layout.charAt(0));
  28626. };
  28627. /**
  28628. * Adjust the chart margins by reserving space for the legend on only one
  28629. * side of the chart. If the position is set to a corner, top or bottom is
  28630. * reserved for horizontal legends and left or right for vertical ones.
  28631. *
  28632. * @private
  28633. * @function Highcharts.Legend#adjustMargins
  28634. * @param {Array<number>} margin
  28635. * @param {Array<number>} spacing
  28636. */
  28637. Legend.prototype.adjustMargins = function (margin, spacing) {
  28638. var chart = this.chart,
  28639. options = this.options,
  28640. alignment = this.getAlignment();
  28641. if (alignment) {
  28642. ([
  28643. /(lth|ct|rth)/,
  28644. /(rtv|rm|rbv)/,
  28645. /(rbh|cb|lbh)/,
  28646. /(lbv|lm|ltv)/
  28647. ]).forEach(function (alignments, side) {
  28648. if (alignments.test(alignment) && !defined(margin[side])) {
  28649. // Now we have detected on which side of the chart we should
  28650. // reserve space for the legend
  28651. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  28652. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  28653. pick(options.margin, 12) +
  28654. spacing[side] +
  28655. (chart.titleOffset[side] || 0)));
  28656. }
  28657. });
  28658. }
  28659. };
  28660. /**
  28661. * @private
  28662. * @function Highcharts.Legend#proximatePositions
  28663. */
  28664. Legend.prototype.proximatePositions = function () {
  28665. var chart = this.chart,
  28666. boxes = [],
  28667. alignLeft = this.options.align === 'left';
  28668. this.allItems.forEach(function (item) {
  28669. var lastPoint,
  28670. height,
  28671. useFirstPoint = alignLeft,
  28672. target,
  28673. top;
  28674. if (item.yAxis) {
  28675. if (item.xAxis.options.reversed) {
  28676. useFirstPoint = !useFirstPoint;
  28677. }
  28678. if (item.points) {
  28679. lastPoint = find(useFirstPoint ?
  28680. item.points :
  28681. item.points.slice(0).reverse(), function (item) {
  28682. return isNumber(item.plotY);
  28683. });
  28684. }
  28685. height = this.itemMarginTop +
  28686. item.legendItem.getBBox().height +
  28687. this.itemMarginBottom;
  28688. top = item.yAxis.top - chart.plotTop;
  28689. if (item.visible) {
  28690. target = lastPoint ?
  28691. lastPoint.plotY :
  28692. item.yAxis.height;
  28693. target += top - 0.3 * height;
  28694. }
  28695. else {
  28696. target = top + item.yAxis.height;
  28697. }
  28698. boxes.push({
  28699. target: target,
  28700. size: height,
  28701. item: item
  28702. });
  28703. }
  28704. }, this);
  28705. H.distribute(boxes, chart.plotHeight);
  28706. boxes.forEach(function (box) {
  28707. box.item._legendItemPos[1] =
  28708. chart.plotTop - chart.spacing[0] + box.pos;
  28709. });
  28710. };
  28711. /**
  28712. * Render the legend. This method can be called both before and after
  28713. * `chart.render`. If called after, it will only rearrange items instead
  28714. * of creating new ones. Called internally on initial render and after
  28715. * redraws.
  28716. *
  28717. * @private
  28718. * @function Highcharts.Legend#render
  28719. */
  28720. Legend.prototype.render = function () {
  28721. var legend = this,
  28722. chart = legend.chart,
  28723. renderer = chart.renderer,
  28724. legendGroup = legend.group,
  28725. allItems,
  28726. display,
  28727. legendWidth,
  28728. legendHeight,
  28729. box = legend.box,
  28730. options = legend.options,
  28731. padding = legend.padding,
  28732. allowedWidth;
  28733. legend.itemX = padding;
  28734. legend.itemY = legend.initialItemY;
  28735. legend.offsetWidth = 0;
  28736. legend.lastItemY = 0;
  28737. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  28738. // Compute how wide the legend is allowed to be
  28739. allowedWidth =
  28740. chart.spacingBox.width - 2 * padding - options.x;
  28741. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  28742. allowedWidth /= 2;
  28743. }
  28744. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  28745. if (!legendGroup) {
  28746. /**
  28747. * SVG group of the legend.
  28748. *
  28749. * @readonly
  28750. * @name Highcharts.Legend#group
  28751. * @type {Highcharts.SVGElement}
  28752. */
  28753. legend.group = legendGroup = renderer.g('legend')
  28754. .addClass(options.className || '')
  28755. .attr({ zIndex: 7 })
  28756. .add();
  28757. legend.contentGroup = renderer.g()
  28758. .attr({ zIndex: 1 }) // above background
  28759. .add(legendGroup);
  28760. legend.scrollGroup = renderer.g()
  28761. .add(legend.contentGroup);
  28762. }
  28763. legend.renderTitle();
  28764. // add each series or point
  28765. allItems = legend.getAllItems();
  28766. // sort by legendIndex
  28767. stableSort(allItems, function (a, b) {
  28768. return ((a.options && a.options.legendIndex) || 0) -
  28769. ((b.options && b.options.legendIndex) || 0);
  28770. });
  28771. // reversed legend
  28772. if (options.reversed) {
  28773. allItems.reverse();
  28774. }
  28775. /**
  28776. * All items for the legend, which is an array of series for most series
  28777. * and an array of points for pie series and its derivatives.
  28778. *
  28779. * @readonly
  28780. * @name Highcharts.Legend#allItems
  28781. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  28782. */
  28783. legend.allItems = allItems;
  28784. legend.display = display = !!allItems.length;
  28785. // Render the items. First we run a loop to set the text and properties
  28786. // and read all the bounding boxes. The next loop computes the item
  28787. // positions based on the bounding boxes.
  28788. legend.lastLineHeight = 0;
  28789. legend.maxItemWidth = 0;
  28790. legend.totalItemWidth = 0;
  28791. legend.itemHeight = 0;
  28792. allItems.forEach(legend.renderItem, legend);
  28793. allItems.forEach(legend.layoutItem, legend);
  28794. // Get the box
  28795. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  28796. legendHeight = legend.lastItemY + legend.lastLineHeight +
  28797. legend.titleHeight;
  28798. legendHeight = legend.handleOverflow(legendHeight);
  28799. legendHeight += padding;
  28800. // Draw the border and/or background
  28801. if (!box) {
  28802. /**
  28803. * SVG element of the legend box.
  28804. *
  28805. * @readonly
  28806. * @name Highcharts.Legend#box
  28807. * @type {Highcharts.SVGElement}
  28808. */
  28809. legend.box = box = renderer.rect()
  28810. .addClass('highcharts-legend-box')
  28811. .attr({
  28812. r: options.borderRadius
  28813. })
  28814. .add(legendGroup);
  28815. box.isNew = true;
  28816. }
  28817. // Presentational
  28818. if (!chart.styledMode) {
  28819. box
  28820. .attr({
  28821. stroke: options.borderColor,
  28822. 'stroke-width': options.borderWidth || 0,
  28823. fill: options.backgroundColor || 'none'
  28824. })
  28825. .shadow(options.shadow);
  28826. }
  28827. if (legendWidth > 0 && legendHeight > 0) {
  28828. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  28829. x: 0,
  28830. y: 0,
  28831. width: legendWidth,
  28832. height: legendHeight
  28833. }, box.strokeWidth()));
  28834. box.isNew = false;
  28835. }
  28836. // hide the border if no items
  28837. box[display ? 'show' : 'hide']();
  28838. // Open for responsiveness
  28839. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  28840. legendWidth = legendHeight = 0;
  28841. }
  28842. legend.legendWidth = legendWidth;
  28843. legend.legendHeight = legendHeight;
  28844. if (display) {
  28845. legend.align();
  28846. }
  28847. if (!this.proximate) {
  28848. this.positionItems();
  28849. }
  28850. fireEvent(this, 'afterRender');
  28851. };
  28852. /**
  28853. * Align the legend to chart's box.
  28854. *
  28855. * @private
  28856. * @function Highcharts.align
  28857. * @param {Highcharts.BBoxObject} alignTo
  28858. * @return {void}
  28859. */
  28860. Legend.prototype.align = function (alignTo) {
  28861. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  28862. var chart = this.chart,
  28863. options = this.options;
  28864. // If aligning to the top and the layout is horizontal, adjust for
  28865. // the title (#7428)
  28866. var y = alignTo.y;
  28867. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  28868. chart.titleOffset[0] > 0) {
  28869. y += chart.titleOffset[0];
  28870. }
  28871. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  28872. chart.titleOffset[2] > 0) {
  28873. y -= chart.titleOffset[2];
  28874. }
  28875. if (y !== alignTo.y) {
  28876. alignTo = merge(alignTo, { y: y });
  28877. }
  28878. this.group.align(merge(options, {
  28879. width: this.legendWidth,
  28880. height: this.legendHeight,
  28881. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  28882. }), true, alignTo);
  28883. };
  28884. /**
  28885. * Set up the overflow handling by adding navigation with up and down arrows
  28886. * below the legend.
  28887. *
  28888. * @private
  28889. * @function Highcharts.Legend#handleOverflow
  28890. * @param {number} legendHeight
  28891. * @return {number}
  28892. */
  28893. Legend.prototype.handleOverflow = function (legendHeight) {
  28894. var legend = this,
  28895. chart = this.chart,
  28896. renderer = chart.renderer,
  28897. options = this.options,
  28898. optionsY = options.y,
  28899. alignTop = options.verticalAlign === 'top',
  28900. padding = this.padding,
  28901. spaceHeight = (chart.spacingBox.height +
  28902. (alignTop ? -optionsY : optionsY) - padding),
  28903. maxHeight = options.maxHeight,
  28904. clipHeight,
  28905. clipRect = this.clipRect,
  28906. navOptions = options.navigation,
  28907. animation = pick(navOptions.animation,
  28908. true),
  28909. arrowSize = navOptions.arrowSize || 12,
  28910. nav = this.nav,
  28911. pages = this.pages,
  28912. lastY,
  28913. allItems = this.allItems,
  28914. clipToHeight = function (height) {
  28915. if (typeof height === 'number') {
  28916. clipRect.attr({
  28917. height: height
  28918. });
  28919. }
  28920. else if (clipRect) { // Reset (#5912)
  28921. legend.clipRect = clipRect.destroy();
  28922. legend.contentGroup.clip();
  28923. }
  28924. // useHTML
  28925. if (legend.contentGroup.div) {
  28926. legend.contentGroup.div.style.clip = height ?
  28927. 'rect(' + padding + 'px,9999px,' +
  28928. (padding + height) + 'px,0)' :
  28929. 'auto';
  28930. }
  28931. }, addTracker = function (key) {
  28932. legend[key] = renderer
  28933. .circle(0, 0, arrowSize * 1.3)
  28934. .translate(arrowSize / 2, arrowSize / 2)
  28935. .add(nav);
  28936. if (!chart.styledMode) {
  28937. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  28938. }
  28939. return legend[key];
  28940. };
  28941. // Adjust the height
  28942. if (options.layout === 'horizontal' &&
  28943. options.verticalAlign !== 'middle' &&
  28944. !options.floating) {
  28945. spaceHeight /= 2;
  28946. }
  28947. if (maxHeight) {
  28948. spaceHeight = Math.min(spaceHeight, maxHeight);
  28949. }
  28950. // Reset the legend height and adjust the clipping rectangle
  28951. pages.length = 0;
  28952. if (legendHeight &&
  28953. spaceHeight > 0 &&
  28954. legendHeight > spaceHeight &&
  28955. navOptions.enabled !== false) {
  28956. this.clipHeight = clipHeight =
  28957. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  28958. this.currentPage = pick(this.currentPage, 1);
  28959. this.fullHeight = legendHeight;
  28960. // Fill pages with Y positions so that the top of each a legend item
  28961. // defines the scroll top for each page (#2098)
  28962. allItems.forEach(function (item, i) {
  28963. var y = item._legendItemPos[1],
  28964. h = Math.round(item.legendItem.getBBox().height),
  28965. len = pages.length;
  28966. if (!len || (y - pages[len - 1] > clipHeight &&
  28967. (lastY || y) !== pages[len - 1])) {
  28968. pages.push(lastY || y);
  28969. len++;
  28970. }
  28971. // Keep track of which page each item is on
  28972. item.pageIx = len - 1;
  28973. if (lastY) {
  28974. allItems[i - 1].pageIx = len - 1;
  28975. }
  28976. if (i === allItems.length - 1 &&
  28977. y + h - pages[len - 1] > clipHeight &&
  28978. y !== lastY // #2617
  28979. ) {
  28980. pages.push(y);
  28981. item.pageIx = len;
  28982. }
  28983. if (y !== lastY) {
  28984. lastY = y;
  28985. }
  28986. });
  28987. // Only apply clipping if needed. Clipping causes blurred legend in
  28988. // PDF export (#1787)
  28989. if (!clipRect) {
  28990. clipRect = legend.clipRect =
  28991. renderer.clipRect(0, padding, 9999, 0);
  28992. legend.contentGroup.clip(clipRect);
  28993. }
  28994. clipToHeight(clipHeight);
  28995. // Add navigation elements
  28996. if (!nav) {
  28997. this.nav = nav = renderer.g()
  28998. .attr({ zIndex: 1 })
  28999. .add(this.group);
  29000. this.up = renderer
  29001. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  29002. .add(nav);
  29003. addTracker('upTracker')
  29004. .on('click', function () {
  29005. legend.scroll(-1, animation);
  29006. });
  29007. this.pager = renderer.text('', 15, 10)
  29008. .addClass('highcharts-legend-navigation');
  29009. if (!chart.styledMode) {
  29010. this.pager.css(navOptions.style);
  29011. }
  29012. this.pager.add(nav);
  29013. this.down = renderer
  29014. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  29015. .add(nav);
  29016. addTracker('downTracker')
  29017. .on('click', function () {
  29018. legend.scroll(1, animation);
  29019. });
  29020. }
  29021. // Set initial position
  29022. legend.scroll(0);
  29023. legendHeight = spaceHeight;
  29024. // Reset
  29025. }
  29026. else if (nav) {
  29027. clipToHeight();
  29028. this.nav = nav.destroy(); // #6322
  29029. this.scrollGroup.attr({
  29030. translateY: 1
  29031. });
  29032. this.clipHeight = 0; // #1379
  29033. }
  29034. return legendHeight;
  29035. };
  29036. /**
  29037. * Scroll the legend by a number of pages.
  29038. *
  29039. * @private
  29040. * @function Highcharts.Legend#scroll
  29041. *
  29042. * @param {number} scrollBy
  29043. * The number of pages to scroll.
  29044. *
  29045. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29046. * Whether and how to apply animation.
  29047. *
  29048. * @return {void}
  29049. */
  29050. Legend.prototype.scroll = function (scrollBy, animation) {
  29051. var _this = this;
  29052. var chart = this.chart,
  29053. pages = this.pages,
  29054. pageCount = pages.length,
  29055. currentPage = this.currentPage + scrollBy,
  29056. clipHeight = this.clipHeight,
  29057. navOptions = this.options.navigation,
  29058. pager = this.pager,
  29059. padding = this.padding;
  29060. // When resizing while looking at the last page
  29061. if (currentPage > pageCount) {
  29062. currentPage = pageCount;
  29063. }
  29064. if (currentPage > 0) {
  29065. if (typeof animation !== 'undefined') {
  29066. setAnimation(animation, chart);
  29067. }
  29068. this.nav.attr({
  29069. translateX: padding,
  29070. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  29071. visibility: 'visible'
  29072. });
  29073. [this.up, this.upTracker].forEach(function (elem) {
  29074. elem.attr({
  29075. 'class': currentPage === 1 ?
  29076. 'highcharts-legend-nav-inactive' :
  29077. 'highcharts-legend-nav-active'
  29078. });
  29079. });
  29080. pager.attr({
  29081. text: currentPage + '/' + pageCount
  29082. });
  29083. [this.down, this.downTracker].forEach(function (elem) {
  29084. elem.attr({
  29085. // adjust to text width
  29086. x: 18 + this.pager.getBBox().width,
  29087. 'class': currentPage === pageCount ?
  29088. 'highcharts-legend-nav-inactive' :
  29089. 'highcharts-legend-nav-active'
  29090. });
  29091. }, this);
  29092. if (!chart.styledMode) {
  29093. this.up
  29094. .attr({
  29095. fill: currentPage === 1 ?
  29096. navOptions.inactiveColor :
  29097. navOptions.activeColor
  29098. });
  29099. this.upTracker
  29100. .css({
  29101. cursor: currentPage === 1 ? 'default' : 'pointer'
  29102. });
  29103. this.down
  29104. .attr({
  29105. fill: currentPage === pageCount ?
  29106. navOptions.inactiveColor :
  29107. navOptions.activeColor
  29108. });
  29109. this.downTracker
  29110. .css({
  29111. cursor: currentPage === pageCount ?
  29112. 'default' :
  29113. 'pointer'
  29114. });
  29115. }
  29116. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  29117. this.scrollGroup.animate({
  29118. translateY: this.scrollOffset
  29119. });
  29120. this.currentPage = currentPage;
  29121. this.positionCheckboxes();
  29122. // Fire event after scroll animation is complete
  29123. var animOptions = animObject(pick(animation,
  29124. chart.renderer.globalAnimation,
  29125. true));
  29126. syncTimeout(function () {
  29127. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  29128. }, animOptions.duration);
  29129. }
  29130. };
  29131. /**
  29132. * @private
  29133. * @function Highcharts.Legend#setItemEvents
  29134. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  29135. * @param {Highcharts.SVGElement} legendItem
  29136. * @param {boolean} [useHTML=false]
  29137. * @fires Highcharts.Point#event:legendItemClick
  29138. * @fires Highcharts.Series#event:legendItemClick
  29139. */
  29140. Legend.prototype.setItemEvents = function (item, legendItem, useHTML) {
  29141. var legend = this,
  29142. boxWrapper = legend.chart.renderer.boxWrapper,
  29143. isPoint = item instanceof Point,
  29144. activeClass = 'highcharts-legend-' +
  29145. (isPoint ? 'point' : 'series') + '-active',
  29146. styledMode = legend.chart.styledMode,
  29147. // When `useHTML`, the symbol is rendered in other group, so
  29148. // we need to apply events listeners to both places
  29149. legendItems = useHTML ?
  29150. [legendItem,
  29151. item.legendSymbol] :
  29152. [item.legendGroup];
  29153. // Set the events on the item group, or in case of useHTML, the item
  29154. // itself (#1249)
  29155. legendItems.forEach(function (element) {
  29156. if (element) {
  29157. element
  29158. .on('mouseover', function () {
  29159. if (item.visible) {
  29160. legend.allItems.forEach(function (inactiveItem) {
  29161. if (item !== inactiveItem) {
  29162. inactiveItem.setState('inactive', !isPoint);
  29163. }
  29164. });
  29165. }
  29166. item.setState('hover');
  29167. // A CSS class to dim or hide other than the hovered
  29168. // series.
  29169. // Works only if hovered series is visible (#10071).
  29170. if (item.visible) {
  29171. boxWrapper.addClass(activeClass);
  29172. }
  29173. if (!styledMode) {
  29174. legendItem.css(legend.options.itemHoverStyle);
  29175. }
  29176. })
  29177. .on('mouseout', function () {
  29178. if (!legend.chart.styledMode) {
  29179. legendItem.css(merge(item.visible ?
  29180. legend.itemStyle :
  29181. legend.itemHiddenStyle));
  29182. }
  29183. legend.allItems.forEach(function (inactiveItem) {
  29184. if (item !== inactiveItem) {
  29185. inactiveItem.setState('', !isPoint);
  29186. }
  29187. });
  29188. // A CSS class to dim or hide other than the hovered
  29189. // series.
  29190. boxWrapper.removeClass(activeClass);
  29191. item.setState();
  29192. })
  29193. .on('click', function (event) {
  29194. var strLegendItemClick = 'legendItemClick',
  29195. fnLegendItemClick = function () {
  29196. if (item.setVisible) {
  29197. item.setVisible();
  29198. }
  29199. // Reset inactive state
  29200. legend.allItems.forEach(function (inactiveItem) {
  29201. if (item !== inactiveItem) {
  29202. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  29203. }
  29204. });
  29205. };
  29206. // A CSS class to dim or hide other than the hovered
  29207. // series. Event handling in iOS causes the activeClass
  29208. // to be added prior to click in some cases (#7418).
  29209. boxWrapper.removeClass(activeClass);
  29210. // Pass over the click/touch event. #4.
  29211. event = {
  29212. browserEvent: event
  29213. };
  29214. // click the name or symbol
  29215. if (item.firePointEvent) { // point
  29216. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  29217. }
  29218. else {
  29219. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  29220. }
  29221. });
  29222. }
  29223. });
  29224. };
  29225. /**
  29226. * @private
  29227. * @function Highcharts.Legend#createCheckboxForItem
  29228. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  29229. * @fires Highcharts.Series#event:checkboxClick
  29230. */
  29231. Legend.prototype.createCheckboxForItem = function (item) {
  29232. var legend = this;
  29233. item.checkbox = createElement('input', {
  29234. type: 'checkbox',
  29235. className: 'highcharts-legend-checkbox',
  29236. checked: item.selected,
  29237. defaultChecked: item.selected // required by IE7
  29238. }, legend.options.itemCheckboxStyle, legend.chart.container);
  29239. addEvent(item.checkbox, 'click', function (event) {
  29240. var target = event.target;
  29241. fireEvent(item.series || item, 'checkboxClick', {
  29242. checked: target.checked,
  29243. item: item
  29244. }, function () {
  29245. item.select();
  29246. });
  29247. });
  29248. };
  29249. return Legend;
  29250. }());
  29251. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  29252. // and for #2580, a similar drawing flaw in Firefox 26.
  29253. // Explore if there's a general cause for this. The problem may be related
  29254. // to nested group elements, as the legend item texts are within 4 group
  29255. // elements.
  29256. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  29257. isFirefox) {
  29258. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  29259. var legend = this,
  29260. // If chart destroyed in sync, this is undefined (#2030)
  29261. runPositionItem = function () {
  29262. if (item._legendItemPos) {
  29263. proceed.call(legend,
  29264. item);
  29265. }
  29266. };
  29267. // Do it now, for export and to get checkbox placement
  29268. runPositionItem();
  29269. // Do it after to work around the core issue
  29270. if (!legend.bubbleLegend) {
  29271. setTimeout(runPositionItem);
  29272. }
  29273. });
  29274. }
  29275. H.Legend = Legend;
  29276. return H.Legend;
  29277. });
  29278. _registerModule(_modules, 'Core/Series/SeriesRegistry.js', [_modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, D, Point, U) {
  29279. /* *
  29280. *
  29281. * (c) 2010-2021 Torstein Honsi
  29282. *
  29283. * License: www.highcharts.com/license
  29284. *
  29285. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29286. *
  29287. * */
  29288. var defaultOptions = D.defaultOptions;
  29289. var error = U.error,
  29290. extendClass = U.extendClass,
  29291. merge = U.merge;
  29292. /* *
  29293. *
  29294. * Namespace
  29295. *
  29296. * */
  29297. var SeriesRegistry;
  29298. (function (SeriesRegistry) {
  29299. /* *
  29300. *
  29301. * Static Properties
  29302. *
  29303. * */
  29304. /**
  29305. * @internal
  29306. * @todo Move `Globals.seriesTypes` code to her.
  29307. */
  29308. SeriesRegistry.seriesTypes = H.seriesTypes;
  29309. /* *
  29310. *
  29311. * Static Functions
  29312. *
  29313. * */
  29314. /* eslint-disable valid-jsdoc */
  29315. /**
  29316. * Internal function to initialize an individual series.
  29317. * @private
  29318. */
  29319. function getSeries(chart, options) {
  29320. if (options === void 0) { options = {}; }
  29321. var optionsChart = chart.options.chart,
  29322. type = (options.type ||
  29323. optionsChart.type ||
  29324. optionsChart.defaultSeriesType ||
  29325. ''),
  29326. SeriesClass = SeriesRegistry.seriesTypes[type];
  29327. // No such series type
  29328. if (!SeriesRegistry) {
  29329. error(17, true, chart, { missingModuleFor: type });
  29330. }
  29331. var series = new SeriesClass();
  29332. if (typeof series.init === 'function') {
  29333. series.init(chart, options);
  29334. }
  29335. return series;
  29336. }
  29337. SeriesRegistry.getSeries = getSeries;
  29338. /**
  29339. * Registers class pattern of a series.
  29340. *
  29341. * @private
  29342. */
  29343. function registerSeriesType(seriesType, seriesClass) {
  29344. var defaultPlotOptions = defaultOptions.plotOptions || {},
  29345. seriesOptions = seriesClass.defaultOptions;
  29346. if (!seriesClass.prototype.pointClass) {
  29347. seriesClass.prototype.pointClass = Point;
  29348. }
  29349. seriesClass.prototype.type = seriesType;
  29350. if (seriesOptions) {
  29351. defaultPlotOptions[seriesType] = seriesOptions;
  29352. }
  29353. SeriesRegistry.seriesTypes[seriesType] = seriesClass;
  29354. }
  29355. SeriesRegistry.registerSeriesType = registerSeriesType;
  29356. /**
  29357. * Old factory to create new series prototypes.
  29358. *
  29359. * @deprecated
  29360. * @function Highcharts.seriesType
  29361. *
  29362. * @param {string} type
  29363. * The series type name.
  29364. *
  29365. * @param {string} parent
  29366. * The parent series type name. Use `line` to inherit from the basic
  29367. * {@link Series} object.
  29368. *
  29369. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  29370. * The additional default options that are merged with the parent's options.
  29371. *
  29372. * @param {Highcharts.Dictionary<*>} [props]
  29373. * The properties (functions and primitives) to set on the new prototype.
  29374. *
  29375. * @param {Highcharts.Dictionary<*>} [pointProps]
  29376. * Members for a series-specific extension of the {@link Point} prototype if
  29377. * needed.
  29378. *
  29379. * @return {Highcharts.Series}
  29380. * The newly created prototype as extended from {@link Series} or its
  29381. * derivatives.
  29382. */
  29383. function seriesType(type, parent, options, seriesProto, pointProto) {
  29384. var defaultPlotOptions = defaultOptions.plotOptions || {};
  29385. parent = parent || '';
  29386. // Merge the options
  29387. defaultPlotOptions[type] = merge(defaultPlotOptions[parent], options);
  29388. // Create the class
  29389. registerSeriesType(type, extendClass(SeriesRegistry.seriesTypes[parent] || function () { }, seriesProto));
  29390. SeriesRegistry.seriesTypes[type].prototype.type = type;
  29391. // Create the point class if needed
  29392. if (pointProto) {
  29393. SeriesRegistry.seriesTypes[type].prototype.pointClass =
  29394. extendClass(Point, pointProto);
  29395. }
  29396. return SeriesRegistry.seriesTypes[type];
  29397. }
  29398. SeriesRegistry.seriesType = seriesType;
  29399. /* eslint-enable valid-jsdoc */
  29400. })(SeriesRegistry || (SeriesRegistry = {}));
  29401. /* *
  29402. *
  29403. * Compatibility
  29404. *
  29405. * */
  29406. H.seriesType = SeriesRegistry.seriesType;
  29407. /* *
  29408. *
  29409. * Export
  29410. *
  29411. * */
  29412. return SeriesRegistry;
  29413. });
  29414. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Pointer.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (A, Axis, FormatUtilities, Foundation, H, Legend, MSPointer, D, palette, Pointer, RendererRegistry, SeriesRegistry, Time, U, AST) {
  29415. /* *
  29416. *
  29417. * (c) 2010-2021 Torstein Honsi
  29418. *
  29419. * License: www.highcharts.com/license
  29420. *
  29421. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29422. *
  29423. * */
  29424. var animate = A.animate,
  29425. animObject = A.animObject,
  29426. setAnimation = A.setAnimation;
  29427. var numberFormat = FormatUtilities.numberFormat;
  29428. var registerEventOptions = Foundation.registerEventOptions;
  29429. var charts = H.charts,
  29430. doc = H.doc,
  29431. marginNames = H.marginNames,
  29432. win = H.win;
  29433. var defaultOptions = D.defaultOptions,
  29434. defaultTime = D.defaultTime;
  29435. var seriesTypes = SeriesRegistry.seriesTypes;
  29436. var addEvent = U.addEvent,
  29437. attr = U.attr,
  29438. cleanRecursively = U.cleanRecursively,
  29439. createElement = U.createElement,
  29440. css = U.css,
  29441. defined = U.defined,
  29442. discardElement = U.discardElement,
  29443. erase = U.erase,
  29444. error = U.error,
  29445. extend = U.extend,
  29446. find = U.find,
  29447. fireEvent = U.fireEvent,
  29448. getStyle = U.getStyle,
  29449. isArray = U.isArray,
  29450. isFunction = U.isFunction,
  29451. isNumber = U.isNumber,
  29452. isObject = U.isObject,
  29453. isString = U.isString,
  29454. merge = U.merge,
  29455. objectEach = U.objectEach,
  29456. pick = U.pick,
  29457. pInt = U.pInt,
  29458. relativeLength = U.relativeLength,
  29459. removeEvent = U.removeEvent,
  29460. splat = U.splat,
  29461. syncTimeout = U.syncTimeout,
  29462. uniqueKey = U.uniqueKey;
  29463. /* *
  29464. *
  29465. * Class
  29466. *
  29467. * */
  29468. /* eslint-disable no-invalid-this, valid-jsdoc */
  29469. /**
  29470. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  29471. *
  29472. * @example
  29473. * let chart = Highcharts.chart('container', {
  29474. * title: {
  29475. * text: 'My chart'
  29476. * },
  29477. * series: [{
  29478. * data: [1, 3, 2, 4]
  29479. * }]
  29480. * })
  29481. *
  29482. * @class
  29483. * @name Highcharts.Chart
  29484. *
  29485. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29486. * The DOM element to render to, or its id.
  29487. *
  29488. * @param {Highcharts.Options} options
  29489. * The chart options structure.
  29490. *
  29491. * @param {Highcharts.ChartCallbackFunction} [callback]
  29492. * Function to run when the chart has loaded and and all external images
  29493. * are loaded. Defining a
  29494. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29495. * handler is equivalent.
  29496. */
  29497. var Chart = /** @class */ (function () {
  29498. function Chart(a, b, c) {
  29499. this.axes = void 0;
  29500. this.axisOffset = void 0;
  29501. this.bounds = void 0;
  29502. this.chartHeight = void 0;
  29503. this.chartWidth = void 0;
  29504. this.clipBox = void 0;
  29505. this.colorCounter = void 0;
  29506. this.container = void 0;
  29507. this.eventOptions = void 0;
  29508. this.index = void 0;
  29509. this.isResizing = void 0;
  29510. this.labelCollectors = void 0;
  29511. this.legend = void 0;
  29512. this.margin = void 0;
  29513. this.numberFormatter = void 0;
  29514. this.options = void 0;
  29515. this.plotBox = void 0;
  29516. this.plotHeight = void 0;
  29517. this.plotLeft = void 0;
  29518. this.plotTop = void 0;
  29519. this.plotWidth = void 0;
  29520. this.pointCount = void 0;
  29521. this.pointer = void 0;
  29522. this.renderer = void 0;
  29523. this.renderTo = void 0;
  29524. this.series = void 0;
  29525. this.sharedClips = {};
  29526. this.spacing = void 0;
  29527. this.spacingBox = void 0;
  29528. this.symbolCounter = void 0;
  29529. this.time = void 0;
  29530. this.titleOffset = void 0;
  29531. this.userOptions = void 0;
  29532. this.xAxis = void 0;
  29533. this.yAxis = void 0;
  29534. this.getArgs(a, b, c);
  29535. }
  29536. /**
  29537. * Factory function for basic charts.
  29538. *
  29539. * @example
  29540. * // Render a chart in to div#container
  29541. * let chart = Highcharts.chart('container', {
  29542. * title: {
  29543. * text: 'My chart'
  29544. * },
  29545. * series: [{
  29546. * data: [1, 3, 2, 4]
  29547. * }]
  29548. * });
  29549. *
  29550. * @function Highcharts.chart
  29551. *
  29552. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29553. * The DOM element to render to, or its id.
  29554. *
  29555. * @param {Highcharts.Options} options
  29556. * The chart options structure.
  29557. *
  29558. * @param {Highcharts.ChartCallbackFunction} [callback]
  29559. * Function to run when the chart has loaded and and all external images are
  29560. * loaded. Defining a
  29561. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29562. * handler is equivalent.
  29563. *
  29564. * @return {Highcharts.Chart}
  29565. * Returns the Chart object.
  29566. */
  29567. Chart.chart = function (a, b, c) {
  29568. return new Chart(a, b, c);
  29569. };
  29570. /* *
  29571. *
  29572. * Functions
  29573. *
  29574. * */
  29575. /**
  29576. * Handle the arguments passed to the constructor.
  29577. *
  29578. * @private
  29579. * @function Highcharts.Chart#getArgs
  29580. *
  29581. * @param {...Array<*>} arguments
  29582. * All arguments for the constructor.
  29583. *
  29584. * @fires Highcharts.Chart#event:init
  29585. * @fires Highcharts.Chart#event:afterInit
  29586. */
  29587. Chart.prototype.getArgs = function (a, b, c) {
  29588. // Remove the optional first argument, renderTo, and
  29589. // set it on this.
  29590. if (isString(a) || a.nodeName) {
  29591. this.renderTo = a;
  29592. this.init(b, c);
  29593. }
  29594. else {
  29595. this.init(a, b);
  29596. }
  29597. };
  29598. /**
  29599. * Overridable function that initializes the chart. The constructor's
  29600. * arguments are passed on directly.
  29601. *
  29602. * @function Highcharts.Chart#init
  29603. *
  29604. * @param {Highcharts.Options} userOptions
  29605. * Custom options.
  29606. *
  29607. * @param {Function} [callback]
  29608. * Function to run when the chart has loaded and and all external
  29609. * images are loaded.
  29610. *
  29611. * @return {void}
  29612. *
  29613. * @fires Highcharts.Chart#event:init
  29614. * @fires Highcharts.Chart#event:afterInit
  29615. */
  29616. Chart.prototype.init = function (userOptions, callback) {
  29617. // Handle regular options
  29618. var userPlotOptions = userOptions.plotOptions || {};
  29619. // Fire the event with a default function
  29620. fireEvent(this, 'init', { args: arguments }, function () {
  29621. var options = merge(defaultOptions,
  29622. userOptions); // do the merge
  29623. var optionsChart = options.chart;
  29624. // Override (by copy of user options) or clear tooltip options
  29625. // in chart.options.plotOptions (#6218)
  29626. objectEach(options.plotOptions, function (typeOptions, type) {
  29627. if (isObject(typeOptions)) { // #8766
  29628. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  29629. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  29630. }
  29631. });
  29632. // User options have higher priority than default options
  29633. // (#6218). In case of exporting: path is changed
  29634. options.tooltip.userOptions = (userOptions.chart &&
  29635. userOptions.chart.forExport &&
  29636. userOptions.tooltip.userOptions) || userOptions.tooltip;
  29637. /**
  29638. * The original options given to the constructor or a chart factory
  29639. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  29640. *
  29641. * @name Highcharts.Chart#userOptions
  29642. * @type {Highcharts.Options}
  29643. */
  29644. this.userOptions = userOptions;
  29645. this.margin = [];
  29646. this.spacing = [];
  29647. // Pixel data bounds for touch zoom
  29648. this.bounds = { h: {}, v: {} };
  29649. // An array of functions that returns labels that should be
  29650. // considered for anti-collision
  29651. this.labelCollectors = [];
  29652. this.callback = callback;
  29653. this.isResizing = 0;
  29654. /**
  29655. * The options structure for the chart after merging
  29656. * {@link #defaultOptions} and {@link #userOptions}. It contains
  29657. * members for the sub elements like series, legend, tooltip etc.
  29658. *
  29659. * @name Highcharts.Chart#options
  29660. * @type {Highcharts.Options}
  29661. */
  29662. this.options = options;
  29663. /**
  29664. * All the axes in the chart.
  29665. *
  29666. * @see Highcharts.Chart.xAxis
  29667. * @see Highcharts.Chart.yAxis
  29668. *
  29669. * @name Highcharts.Chart#axes
  29670. * @type {Array<Highcharts.Axis>}
  29671. */
  29672. this.axes = [];
  29673. /**
  29674. * All the current series in the chart.
  29675. *
  29676. * @name Highcharts.Chart#series
  29677. * @type {Array<Highcharts.Series>}
  29678. */
  29679. this.series = [];
  29680. /**
  29681. * The `Time` object associated with the chart. Since v6.0.5,
  29682. * time settings can be applied individually for each chart. If
  29683. * no individual settings apply, the `Time` object is shared by
  29684. * all instances.
  29685. *
  29686. * @name Highcharts.Chart#time
  29687. * @type {Highcharts.Time}
  29688. */
  29689. this.time =
  29690. userOptions.time && Object.keys(userOptions.time).length ?
  29691. new Time(userOptions.time) :
  29692. H.time;
  29693. /**
  29694. * Callback function to override the default function that formats
  29695. * all the numbers in the chart. Returns a string with the formatted
  29696. * number.
  29697. *
  29698. * @name Highcharts.Chart#numberFormatter
  29699. * @type {Highcharts.NumberFormatterCallbackFunction}
  29700. */
  29701. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  29702. /**
  29703. * Whether the chart is in styled mode, meaning all presentatinoal
  29704. * attributes are avoided.
  29705. *
  29706. * @name Highcharts.Chart#styledMode
  29707. * @type {boolean}
  29708. */
  29709. this.styledMode = optionsChart.styledMode;
  29710. this.hasCartesianSeries = optionsChart.showAxes;
  29711. var chart = this;
  29712. /**
  29713. * Index position of the chart in the {@link Highcharts#charts}
  29714. * property.
  29715. *
  29716. * @name Highcharts.Chart#index
  29717. * @type {number}
  29718. * @readonly
  29719. */
  29720. chart.index = charts.length; // Add the chart to the global lookup
  29721. charts.push(chart);
  29722. H.chartCount++;
  29723. // Chart event handlers
  29724. registerEventOptions(this, optionsChart);
  29725. /**
  29726. * A collection of the X axes in the chart.
  29727. *
  29728. * @name Highcharts.Chart#xAxis
  29729. * @type {Array<Highcharts.Axis>}
  29730. */
  29731. chart.xAxis = [];
  29732. /**
  29733. * A collection of the Y axes in the chart.
  29734. *
  29735. * @name Highcharts.Chart#yAxis
  29736. * @type {Array<Highcharts.Axis>}
  29737. *
  29738. * @todo
  29739. * Make events official: Fire the event `afterInit`.
  29740. */
  29741. chart.yAxis = [];
  29742. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  29743. // Fire after init but before first render, before axes and series
  29744. // have been initialized.
  29745. fireEvent(chart, 'afterInit');
  29746. chart.firstRender();
  29747. });
  29748. };
  29749. /**
  29750. * Internal function to unitialize an individual series.
  29751. *
  29752. * @private
  29753. * @function Highcharts.Chart#initSeries
  29754. */
  29755. Chart.prototype.initSeries = function (options) {
  29756. var chart = this,
  29757. optionsChart = chart.options.chart,
  29758. type = (options.type ||
  29759. optionsChart.type ||
  29760. optionsChart.defaultSeriesType),
  29761. SeriesClass = seriesTypes[type];
  29762. // No such series type
  29763. if (!SeriesClass) {
  29764. error(17, true, chart, { missingModuleFor: type });
  29765. }
  29766. var series = new SeriesClass();
  29767. if (typeof series.init === 'function') {
  29768. series.init(chart, options);
  29769. }
  29770. return series;
  29771. };
  29772. /**
  29773. * Internal function to set data for all series with enabled sorting.
  29774. *
  29775. * @private
  29776. * @function Highcharts.Chart#setSeriesData
  29777. */
  29778. Chart.prototype.setSeriesData = function () {
  29779. this.getSeriesOrderByLinks().forEach(function (series) {
  29780. // We need to set data for series with sorting after series init
  29781. if (!series.points && !series.data && series.enabledDataSorting) {
  29782. series.setData(series.options.data, false);
  29783. }
  29784. });
  29785. };
  29786. /**
  29787. * Sort and return chart series in order depending on the number of linked
  29788. * series.
  29789. *
  29790. * @private
  29791. * @function Highcharts.Series#getSeriesOrderByLinks
  29792. * @return {Array<Highcharts.Series>}
  29793. */
  29794. Chart.prototype.getSeriesOrderByLinks = function () {
  29795. return this.series.concat().sort(function (a, b) {
  29796. if (a.linkedSeries.length || b.linkedSeries.length) {
  29797. return b.linkedSeries.length - a.linkedSeries.length;
  29798. }
  29799. return 0;
  29800. });
  29801. };
  29802. /**
  29803. * Order all series above a given index. When series are added and ordered
  29804. * by configuration, only the last series is handled (#248, #1123, #2456,
  29805. * #6112). This function is called on series initialization and destroy.
  29806. *
  29807. * @private
  29808. * @function Highcharts.Series#orderSeries
  29809. * @param {number} [fromIndex]
  29810. * If this is given, only the series above this index are handled.
  29811. */
  29812. Chart.prototype.orderSeries = function (fromIndex) {
  29813. var series = this.series;
  29814. for (var i = (fromIndex || 0), iEnd = series.length; i < iEnd; ++i) {
  29815. if (series[i]) {
  29816. /**
  29817. * Contains the series' index in the `Chart.series` array.
  29818. *
  29819. * @name Highcharts.Series#index
  29820. * @type {number}
  29821. * @readonly
  29822. */
  29823. series[i].index = i;
  29824. series[i].name = series[i].getName();
  29825. }
  29826. }
  29827. };
  29828. /**
  29829. * Check whether a given point is within the plot area.
  29830. *
  29831. * @function Highcharts.Chart#isInsidePlot
  29832. *
  29833. * @param {number} plotX
  29834. * Pixel x relative to the plot area.
  29835. *
  29836. * @param {number} plotY
  29837. * Pixel y relative to the plot area.
  29838. *
  29839. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  29840. * Options object.
  29841. *
  29842. * @return {boolean}
  29843. * Returns true if the given point is inside the plot area.
  29844. */
  29845. Chart.prototype.isInsidePlot = function (plotX, plotY, options) {
  29846. var _a;
  29847. if (options === void 0) { options = {}; }
  29848. var _b = this,
  29849. inverted = _b.inverted,
  29850. plotBox = _b.plotBox,
  29851. plotLeft = _b.plotLeft,
  29852. plotTop = _b.plotTop,
  29853. scrollablePlotBox = _b.scrollablePlotBox;
  29854. var scrollLeft = 0,
  29855. scrollTop = 0;
  29856. if (options.visiblePlotOnly && this.scrollingContainer) {
  29857. (_a = this.scrollingContainer, scrollLeft = _a.scrollLeft, scrollTop = _a.scrollTop);
  29858. }
  29859. var series = options.series,
  29860. box = (options.visiblePlotOnly && scrollablePlotBox) || plotBox,
  29861. x = options.inverted ? plotY : plotX,
  29862. y = options.inverted ? plotX : plotY,
  29863. e = {
  29864. x: x,
  29865. y: y,
  29866. isInsidePlot: true
  29867. };
  29868. if (!options.ignoreX) {
  29869. var xAxis = (series && (inverted ? series.yAxis : series.xAxis)) || {
  29870. pos: plotLeft,
  29871. len: Infinity
  29872. };
  29873. var chartX = options.paneCoordinates ? xAxis.pos + x : plotLeft + x;
  29874. if (!(chartX >= Math.max(scrollLeft + plotLeft, xAxis.pos) &&
  29875. chartX <= Math.min(scrollLeft + plotLeft + box.width, xAxis.pos + xAxis.len))) {
  29876. e.isInsidePlot = false;
  29877. }
  29878. }
  29879. if (!options.ignoreY && e.isInsidePlot) {
  29880. var yAxis = (series && (inverted ? series.xAxis : series.yAxis)) || {
  29881. pos: plotTop,
  29882. len: Infinity
  29883. };
  29884. var chartY = options.paneCoordinates ? yAxis.pos + y : plotTop + y;
  29885. if (!(chartY >= Math.max(scrollTop + plotTop, yAxis.pos) &&
  29886. chartY <= Math.min(scrollTop + plotTop + box.height, yAxis.pos + yAxis.len))) {
  29887. e.isInsidePlot = false;
  29888. }
  29889. }
  29890. fireEvent(this, 'afterIsInsidePlot', e);
  29891. return e.isInsidePlot;
  29892. };
  29893. /**
  29894. * Redraw the chart after changes have been done to the data, axis extremes
  29895. * chart size or chart elements. All methods for updating axes, series or
  29896. * points have a parameter for redrawing the chart. This is `true` by
  29897. * default. But in many cases you want to do more than one operation on the
  29898. * chart before redrawing, for example add a number of points. In those
  29899. * cases it is a waste of resources to redraw the chart for each new point
  29900. * added. So you add the points and call `chart.redraw()` after.
  29901. *
  29902. * @function Highcharts.Chart#redraw
  29903. *
  29904. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29905. * If or how to apply animation to the redraw.
  29906. *
  29907. * @fires Highcharts.Chart#event:afterSetExtremes
  29908. * @fires Highcharts.Chart#event:beforeRedraw
  29909. * @fires Highcharts.Chart#event:predraw
  29910. * @fires Highcharts.Chart#event:redraw
  29911. * @fires Highcharts.Chart#event:render
  29912. * @fires Highcharts.Chart#event:updatedData
  29913. */
  29914. Chart.prototype.redraw = function (animation) {
  29915. fireEvent(this, 'beforeRedraw');
  29916. var chart = this,
  29917. axes = chart.hasCartesianSeries ? chart.axes : chart.colorAxis || [],
  29918. series = chart.series,
  29919. pointer = chart.pointer,
  29920. legend = chart.legend,
  29921. legendUserOptions = chart.userOptions.legend,
  29922. renderer = chart.renderer,
  29923. isHiddenChart = renderer.isHidden(),
  29924. afterRedraw = [];
  29925. var hasDirtyStacks,
  29926. hasStackedSeries,
  29927. i,
  29928. isDirtyBox = chart.isDirtyBox,
  29929. redrawLegend = chart.isDirtyLegend,
  29930. serie;
  29931. // Handle responsive rules, not only on resize (#6130)
  29932. if (chart.setResponsive) {
  29933. chart.setResponsive(false);
  29934. }
  29935. // Set the global animation. When chart.hasRendered is not true, the
  29936. // redraw call comes from a responsive rule and animation should not
  29937. // occur.
  29938. setAnimation(chart.hasRendered ? animation : false, chart);
  29939. if (isHiddenChart) {
  29940. chart.temporaryDisplay();
  29941. }
  29942. // Adjust title layout (reflow multiline text)
  29943. chart.layOutTitles();
  29944. // link stacked series
  29945. i = series.length;
  29946. while (i--) {
  29947. serie = series[i];
  29948. if (serie.options.stacking || serie.options.centerInCategory) {
  29949. hasStackedSeries = true;
  29950. if (serie.isDirty) {
  29951. hasDirtyStacks = true;
  29952. break;
  29953. }
  29954. }
  29955. }
  29956. if (hasDirtyStacks) { // mark others as dirty
  29957. i = series.length;
  29958. while (i--) {
  29959. serie = series[i];
  29960. if (serie.options.stacking) {
  29961. serie.isDirty = true;
  29962. }
  29963. }
  29964. }
  29965. // Handle updated data in the series
  29966. series.forEach(function (serie) {
  29967. if (serie.isDirty) {
  29968. if (serie.options.legendType === 'point') {
  29969. if (typeof serie.updateTotals === 'function') {
  29970. serie.updateTotals();
  29971. }
  29972. redrawLegend = true;
  29973. }
  29974. else if (legendUserOptions &&
  29975. (legendUserOptions.labelFormatter ||
  29976. legendUserOptions.labelFormat)) {
  29977. redrawLegend = true; // #2165
  29978. }
  29979. }
  29980. if (serie.isDirtyData) {
  29981. fireEvent(serie, 'updatedData');
  29982. }
  29983. });
  29984. // handle added or removed series
  29985. if (redrawLegend && legend && legend.options.enabled) {
  29986. // draw legend graphics
  29987. legend.render();
  29988. chart.isDirtyLegend = false;
  29989. }
  29990. // reset stacks
  29991. if (hasStackedSeries) {
  29992. chart.getStacks();
  29993. }
  29994. // set axes scales
  29995. axes.forEach(function (axis) {
  29996. axis.updateNames();
  29997. axis.setScale();
  29998. });
  29999. chart.getMargins(); // #3098
  30000. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  30001. axes.forEach(function (axis) {
  30002. if (axis.isDirty) {
  30003. isDirtyBox = true;
  30004. }
  30005. });
  30006. // redraw axes
  30007. axes.forEach(function (axis) {
  30008. // Fire 'afterSetExtremes' only if extremes are set
  30009. var key = axis.min + ',' + axis.max;
  30010. if (axis.extKey !== key) { // #821, #4452
  30011. axis.extKey = key;
  30012. // prevent a recursive call to chart.redraw() (#1119)
  30013. afterRedraw.push(function () {
  30014. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  30015. delete axis.eventArgs;
  30016. });
  30017. }
  30018. if (isDirtyBox || hasStackedSeries) {
  30019. axis.redraw();
  30020. }
  30021. });
  30022. // the plot areas size has changed
  30023. if (isDirtyBox) {
  30024. chart.drawChartBox();
  30025. }
  30026. // Fire an event before redrawing series, used by the boost module to
  30027. // clear previous series renderings.
  30028. fireEvent(chart, 'predraw');
  30029. // redraw affected series
  30030. series.forEach(function (serie) {
  30031. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  30032. serie.redraw();
  30033. }
  30034. // Set it here, otherwise we will have unlimited 'updatedData' calls
  30035. // for a hidden series after setData(). Fixes #6012
  30036. serie.isDirtyData = false;
  30037. });
  30038. // move tooltip or reset
  30039. if (pointer) {
  30040. pointer.reset(true);
  30041. }
  30042. // redraw if canvas
  30043. renderer.draw();
  30044. // Fire the events
  30045. fireEvent(chart, 'redraw');
  30046. fireEvent(chart, 'render');
  30047. if (isHiddenChart) {
  30048. chart.temporaryDisplay(true);
  30049. }
  30050. // Fire callbacks that are put on hold until after the redraw
  30051. afterRedraw.forEach(function (callback) {
  30052. callback.call();
  30053. });
  30054. };
  30055. /**
  30056. * Get an axis, series or point object by `id` as given in the configuration
  30057. * options. Returns `undefined` if no item is found.
  30058. *
  30059. * @sample highcharts/plotoptions/series-id/
  30060. * Get series by id
  30061. *
  30062. * @function Highcharts.Chart#get
  30063. *
  30064. * @param {string} id
  30065. * The id as given in the configuration options.
  30066. *
  30067. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  30068. * The retrieved item.
  30069. */
  30070. Chart.prototype.get = function (id) {
  30071. var series = this.series;
  30072. /**
  30073. * @private
  30074. * @param {Highcharts.Axis|Highcharts.Series} item
  30075. * @return {boolean}
  30076. */
  30077. function itemById(item) {
  30078. return (item.id === id ||
  30079. (item.options && item.options.id === id));
  30080. }
  30081. var ret =
  30082. // Search axes
  30083. find(this.axes,
  30084. itemById) ||
  30085. // Search series
  30086. find(this.series,
  30087. itemById);
  30088. // Search points
  30089. for (var i = 0; !ret && i < series.length; i++) {
  30090. ret = find(series[i].points || [], itemById);
  30091. }
  30092. return ret;
  30093. };
  30094. /**
  30095. * Create the Axis instances based on the config options.
  30096. *
  30097. * @private
  30098. * @function Highcharts.Chart#getAxes
  30099. * @fires Highcharts.Chart#event:afterGetAxes
  30100. * @fires Highcharts.Chart#event:getAxes
  30101. */
  30102. Chart.prototype.getAxes = function () {
  30103. var chart = this,
  30104. options = this.options,
  30105. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  30106. yAxisOptions = options.yAxis = splat(options.yAxis || {});
  30107. fireEvent(this, 'getAxes');
  30108. // make sure the options are arrays and add some members
  30109. xAxisOptions.forEach(function (axis, i) {
  30110. axis.index = i;
  30111. axis.isX = true;
  30112. });
  30113. yAxisOptions.forEach(function (axis, i) {
  30114. axis.index = i;
  30115. });
  30116. // concatenate all axis options into one array
  30117. var optionsArray = xAxisOptions.concat(yAxisOptions);
  30118. optionsArray.forEach(function (axisOptions) {
  30119. new Axis(chart, axisOptions); // eslint-disable-line no-new
  30120. });
  30121. fireEvent(this, 'afterGetAxes');
  30122. };
  30123. /**
  30124. * Returns an array of all currently selected points in the chart. Points
  30125. * can be selected by clicking or programmatically by the
  30126. * {@link Highcharts.Point#select}
  30127. * function.
  30128. *
  30129. * @sample highcharts/plotoptions/series-allowpointselect-line/
  30130. * Get selected points
  30131. *
  30132. * @function Highcharts.Chart#getSelectedPoints
  30133. *
  30134. * @return {Array<Highcharts.Point>}
  30135. * The currently selected points.
  30136. */
  30137. Chart.prototype.getSelectedPoints = function () {
  30138. var points = [];
  30139. this.series.forEach(function (serie) {
  30140. // For one-to-one points inspect series.data in order to retrieve
  30141. // points outside the visible range (#6445). For grouped data,
  30142. // inspect the generated series.points.
  30143. points = points.concat(serie.getPointsCollection().filter(function (point) {
  30144. return pick(point.selectedStaging, point.selected);
  30145. }));
  30146. });
  30147. return points;
  30148. };
  30149. /**
  30150. * Returns an array of all currently selected series in the chart. Series
  30151. * can be selected either programmatically by the
  30152. * {@link Highcharts.Series#select}
  30153. * function or by checking the checkbox next to the legend item if
  30154. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  30155. * is true.
  30156. *
  30157. * @sample highcharts/members/chart-getselectedseries/
  30158. * Get selected series
  30159. *
  30160. * @function Highcharts.Chart#getSelectedSeries
  30161. *
  30162. * @return {Array<Highcharts.Series>}
  30163. * The currently selected series.
  30164. */
  30165. Chart.prototype.getSelectedSeries = function () {
  30166. return this.series.filter(function (serie) {
  30167. return serie.selected;
  30168. });
  30169. };
  30170. /**
  30171. * Set a new title or subtitle for the chart.
  30172. *
  30173. * @sample highcharts/members/chart-settitle/
  30174. * Set title text and styles
  30175. *
  30176. * @function Highcharts.Chart#setTitle
  30177. *
  30178. * @param {Highcharts.TitleOptions} [titleOptions]
  30179. * New title options. The title text itself is set by the
  30180. * `titleOptions.text` property.
  30181. *
  30182. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  30183. * New subtitle options. The subtitle text itself is set by the
  30184. * `subtitleOptions.text` property.
  30185. *
  30186. * @param {boolean} [redraw]
  30187. * Whether to redraw the chart or wait for a later call to
  30188. * `chart.redraw()`.
  30189. */
  30190. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  30191. this.applyDescription('title', titleOptions);
  30192. this.applyDescription('subtitle', subtitleOptions);
  30193. // The initial call also adds the caption. On update, chart.update will
  30194. // relay to Chart.setCaption.
  30195. this.applyDescription('caption', void 0);
  30196. this.layOutTitles(redraw);
  30197. };
  30198. /**
  30199. * Apply a title, subtitle or caption for the chart
  30200. *
  30201. * @private
  30202. * @function Highcharts.Chart#applyDescription
  30203. * @param name {string}
  30204. * Either title, subtitle or caption
  30205. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  30206. * The options to set, will be merged with default options.
  30207. */
  30208. Chart.prototype.applyDescription = function (name, explicitOptions) {
  30209. var chart = this;
  30210. // Default style
  30211. var style = name === 'title' ? {
  30212. color: palette.neutralColor80,
  30213. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  30214. } : {
  30215. color: palette.neutralColor60
  30216. };
  30217. // Merge default options with explicit options
  30218. var options = this.options[name] = merge(
  30219. // Default styles
  30220. (!this.styledMode && { style: style }),
  30221. this.options[name],
  30222. explicitOptions);
  30223. var elem = this[name];
  30224. if (elem && explicitOptions) {
  30225. this[name] = elem = elem.destroy(); // remove old
  30226. }
  30227. if (options && !elem) {
  30228. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  30229. .attr({
  30230. align: options.align,
  30231. 'class': 'highcharts-' + name,
  30232. zIndex: options.zIndex || 4
  30233. })
  30234. .add();
  30235. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  30236. // Chart.setCaption
  30237. elem.update = function (updateOptions) {
  30238. var fn = {
  30239. title: 'setTitle',
  30240. subtitle: 'setSubtitle',
  30241. caption: 'setCaption'
  30242. }[name];
  30243. chart[fn](updateOptions);
  30244. };
  30245. // Presentational
  30246. if (!this.styledMode) {
  30247. elem.css(options.style);
  30248. }
  30249. /**
  30250. * The chart title. The title has an `update` method that allows
  30251. * modifying the options directly or indirectly via
  30252. * `chart.update`.
  30253. *
  30254. * @sample highcharts/members/title-update/
  30255. * Updating titles
  30256. *
  30257. * @name Highcharts.Chart#title
  30258. * @type {Highcharts.TitleObject}
  30259. */
  30260. /**
  30261. * The chart subtitle. The subtitle has an `update` method that
  30262. * allows modifying the options directly or indirectly via
  30263. * `chart.update`.
  30264. *
  30265. * @name Highcharts.Chart#subtitle
  30266. * @type {Highcharts.SubtitleObject}
  30267. */
  30268. this[name] = elem;
  30269. }
  30270. };
  30271. /**
  30272. * Internal function to lay out the chart title, subtitle and caption, and
  30273. * cache the full offset height for use in `getMargins`. The result is
  30274. * stored in `this.titleOffset`.
  30275. *
  30276. * @private
  30277. * @function Highcharts.Chart#layOutTitles
  30278. *
  30279. * @param {boolean} [redraw=true]
  30280. * @fires Highcharts.Chart#event:afterLayOutTitles
  30281. */
  30282. Chart.prototype.layOutTitles = function (redraw) {
  30283. var titleOffset = [0, 0, 0],
  30284. renderer = this.renderer,
  30285. spacingBox = this.spacingBox;
  30286. // Lay out the title and the subtitle respectively
  30287. ['title', 'subtitle', 'caption'].forEach(function (key) {
  30288. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ?
  30289. verticalAlign === 'top' ? -3 : 0 :
  30290. // Floating subtitle (#6574)
  30291. verticalAlign === 'top' ? titleOffset[0] + 2 : 0;
  30292. var titleSize,
  30293. height;
  30294. if (title) {
  30295. if (!this.styledMode) {
  30296. titleSize = titleOptions.style && titleOptions.style.fontSize;
  30297. }
  30298. titleSize = renderer.fontMetrics(titleSize, title).b;
  30299. title
  30300. .css({
  30301. width: (titleOptions.width ||
  30302. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  30303. });
  30304. // Skip the cache for HTML (#3481, #11666)
  30305. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  30306. title.align(extend({
  30307. y: verticalAlign === 'bottom' ?
  30308. titleSize :
  30309. offset + titleSize,
  30310. height: height
  30311. }, titleOptions), false, 'spacingBox');
  30312. if (!titleOptions.floating) {
  30313. if (verticalAlign === 'top') {
  30314. titleOffset[0] = Math.ceil(titleOffset[0] +
  30315. height);
  30316. }
  30317. else if (verticalAlign === 'bottom') {
  30318. titleOffset[2] = Math.ceil(titleOffset[2] +
  30319. height);
  30320. }
  30321. }
  30322. }
  30323. }, this);
  30324. // Handle title.margin and caption.margin
  30325. if (titleOffset[0] &&
  30326. (this.options.title.verticalAlign || 'top') === 'top') {
  30327. titleOffset[0] += this.options.title.margin;
  30328. }
  30329. if (titleOffset[2] &&
  30330. this.options.caption.verticalAlign === 'bottom') {
  30331. titleOffset[2] += this.options.caption.margin;
  30332. }
  30333. var requiresDirtyBox = (!this.titleOffset ||
  30334. this.titleOffset.join(',') !== titleOffset.join(','));
  30335. // Used in getMargins
  30336. this.titleOffset = titleOffset;
  30337. fireEvent(this, 'afterLayOutTitles');
  30338. if (!this.isDirtyBox && requiresDirtyBox) {
  30339. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  30340. // Redraw if necessary (#2719, #2744)
  30341. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  30342. this.redraw();
  30343. }
  30344. }
  30345. };
  30346. /**
  30347. * Internal function to get the chart width and height according to options
  30348. * and container size. Sets {@link Chart.chartWidth} and
  30349. * {@link Chart.chartHeight}.
  30350. *
  30351. * @private
  30352. * @function Highcharts.Chart#getChartSize
  30353. */
  30354. Chart.prototype.getChartSize = function () {
  30355. var chart = this,
  30356. optionsChart = chart.options.chart,
  30357. widthOption = optionsChart.width,
  30358. heightOption = optionsChart.height,
  30359. renderTo = chart.renderTo;
  30360. // Get inner width and height
  30361. if (!defined(widthOption)) {
  30362. chart.containerWidth = getStyle(renderTo, 'width');
  30363. }
  30364. if (!defined(heightOption)) {
  30365. chart.containerHeight = getStyle(renderTo, 'height');
  30366. }
  30367. /**
  30368. * The current pixel width of the chart.
  30369. *
  30370. * @name Highcharts.Chart#chartWidth
  30371. * @type {number}
  30372. */
  30373. chart.chartWidth = Math.max(// #1393
  30374. 0, widthOption || chart.containerWidth || 600 // #1460
  30375. );
  30376. /**
  30377. * The current pixel height of the chart.
  30378. *
  30379. * @name Highcharts.Chart#chartHeight
  30380. * @type {number}
  30381. */
  30382. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  30383. (chart.containerHeight > 1 ?
  30384. chart.containerHeight :
  30385. 400));
  30386. };
  30387. /**
  30388. * If the renderTo element has no offsetWidth, most likely one or more of
  30389. * its parents are hidden. Loop up the DOM tree to temporarily display the
  30390. * parents, then save the original display properties, and when the true
  30391. * size is retrieved, reset them. Used on first render and on redraws.
  30392. *
  30393. * @private
  30394. * @function Highcharts.Chart#temporaryDisplay
  30395. *
  30396. * @param {boolean} [revert]
  30397. * Revert to the saved original styles.
  30398. */
  30399. Chart.prototype.temporaryDisplay = function (revert) {
  30400. var node = this.renderTo,
  30401. tempStyle;
  30402. if (!revert) {
  30403. while (node && node.style) {
  30404. // When rendering to a detached node, it needs to be temporarily
  30405. // attached in order to read styling and bounding boxes (#5783,
  30406. // #7024).
  30407. if (!doc.body.contains(node) && !node.parentNode) {
  30408. node.hcOrigDetached = true;
  30409. doc.body.appendChild(node);
  30410. }
  30411. if (getStyle(node, 'display', false) === 'none' ||
  30412. node.hcOricDetached) {
  30413. node.hcOrigStyle = {
  30414. display: node.style.display,
  30415. height: node.style.height,
  30416. overflow: node.style.overflow
  30417. };
  30418. tempStyle = {
  30419. display: 'block',
  30420. overflow: 'hidden'
  30421. };
  30422. if (node !== this.renderTo) {
  30423. tempStyle.height = 0;
  30424. }
  30425. css(node, tempStyle);
  30426. // If it still doesn't have an offset width after setting
  30427. // display to block, it probably has an !important priority
  30428. // #2631, 6803
  30429. if (!node.offsetWidth) {
  30430. node.style.setProperty('display', 'block', 'important');
  30431. }
  30432. }
  30433. node = node.parentNode;
  30434. if (node === doc.body) {
  30435. break;
  30436. }
  30437. }
  30438. }
  30439. else {
  30440. while (node && node.style) {
  30441. if (node.hcOrigStyle) {
  30442. css(node, node.hcOrigStyle);
  30443. delete node.hcOrigStyle;
  30444. }
  30445. if (node.hcOrigDetached) {
  30446. doc.body.removeChild(node);
  30447. node.hcOrigDetached = false;
  30448. }
  30449. node = node.parentNode;
  30450. }
  30451. }
  30452. };
  30453. /**
  30454. * Set the {@link Chart.container|chart container's} class name, in
  30455. * addition to `highcharts-container`.
  30456. *
  30457. * @function Highcharts.Chart#setClassName
  30458. *
  30459. * @param {string} [className]
  30460. * The additional class name.
  30461. */
  30462. Chart.prototype.setClassName = function (className) {
  30463. this.container.className = 'highcharts-container ' + (className || '');
  30464. };
  30465. /**
  30466. * Get the containing element, determine the size and create the inner
  30467. * container div to hold the chart.
  30468. *
  30469. * @private
  30470. * @function Highcharts.Chart#afterGetContainer
  30471. * @fires Highcharts.Chart#event:afterGetContainer
  30472. */
  30473. Chart.prototype.getContainer = function () {
  30474. var chart = this,
  30475. options = chart.options,
  30476. optionsChart = options.chart,
  30477. indexAttrName = 'data-highcharts-chart',
  30478. containerId = uniqueKey();
  30479. var containerStyle,
  30480. renderTo = chart.renderTo;
  30481. if (!renderTo) {
  30482. chart.renderTo = renderTo =
  30483. optionsChart.renderTo;
  30484. }
  30485. if (isString(renderTo)) {
  30486. chart.renderTo = renderTo =
  30487. doc.getElementById(renderTo);
  30488. }
  30489. // Display an error if the renderTo is wrong
  30490. if (!renderTo) {
  30491. error(13, true, chart);
  30492. }
  30493. // If the container already holds a chart, destroy it. The check for
  30494. // hasRendered is there because web pages that are saved to disk from
  30495. // the browser, will preserve the data-highcharts-chart attribute and
  30496. // the SVG contents, but not an interactive chart. So in this case,
  30497. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  30498. var oldChartIndex = pInt(attr(renderTo,
  30499. indexAttrName));
  30500. if (isNumber(oldChartIndex) &&
  30501. charts[oldChartIndex] &&
  30502. charts[oldChartIndex].hasRendered) {
  30503. charts[oldChartIndex].destroy();
  30504. }
  30505. // Make a reference to the chart from the div
  30506. attr(renderTo, indexAttrName, chart.index);
  30507. // remove previous chart
  30508. renderTo.innerHTML = '';
  30509. // If the container doesn't have an offsetWidth, it has or is a child of
  30510. // a node that has display:none. We need to temporarily move it out to a
  30511. // visible state to determine the size, else the legend and tooltips
  30512. // won't render properly. The skipClone option is used in sparklines as
  30513. // a micro optimization, saving about 1-2 ms each chart.
  30514. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  30515. chart.temporaryDisplay();
  30516. }
  30517. // get the width and height
  30518. chart.getChartSize();
  30519. var chartWidth = chart.chartWidth;
  30520. var chartHeight = chart.chartHeight;
  30521. // Allow table cells and flex-boxes to shrink without the chart blocking
  30522. // them out (#6427)
  30523. css(renderTo, { overflow: 'hidden' });
  30524. // Create the inner container
  30525. if (!chart.styledMode) {
  30526. containerStyle = extend({
  30527. position: 'relative',
  30528. // needed for context menu (avoidscrollbars) and content
  30529. // overflow in IE
  30530. overflow: 'hidden',
  30531. width: chartWidth + 'px',
  30532. height: chartHeight + 'px',
  30533. textAlign: 'left',
  30534. lineHeight: 'normal',
  30535. zIndex: 0,
  30536. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  30537. userSelect: 'none',
  30538. 'touch-action': 'manipulation',
  30539. outline: 'none'
  30540. }, optionsChart.style || {});
  30541. }
  30542. /**
  30543. * The containing HTML element of the chart. The container is
  30544. * dynamically inserted into the element given as the `renderTo`
  30545. * parameter in the {@link Highcharts#chart} constructor.
  30546. *
  30547. * @name Highcharts.Chart#container
  30548. * @type {Highcharts.HTMLDOMElement}
  30549. */
  30550. var container = createElement('div', {
  30551. id: containerId
  30552. },
  30553. containerStyle,
  30554. renderTo);
  30555. chart.container = container;
  30556. // cache the cursor (#1650)
  30557. chart._cursor = container.style.cursor;
  30558. // Initialize the renderer
  30559. var Renderer = RendererRegistry.getRendererType(optionsChart.renderer);
  30560. /**
  30561. * The renderer instance of the chart. Each chart instance has only one
  30562. * associated renderer.
  30563. *
  30564. * @name Highcharts.Chart#renderer
  30565. * @type {Highcharts.SVGRenderer}
  30566. */
  30567. chart.renderer = new Renderer(container, chartWidth, chartHeight, void 0, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  30568. // Set the initial animation from the options
  30569. setAnimation(void 0, chart);
  30570. chart.setClassName(optionsChart.className);
  30571. if (!chart.styledMode) {
  30572. chart.renderer.setStyle(optionsChart.style);
  30573. }
  30574. else {
  30575. // Initialize definitions
  30576. for (var key in options.defs) { // eslint-disable-line guard-for-in
  30577. this.renderer.definition(options.defs[key]);
  30578. }
  30579. }
  30580. // Add a reference to the charts index
  30581. chart.renderer.chartIndex = chart.index;
  30582. fireEvent(this, 'afterGetContainer');
  30583. };
  30584. /**
  30585. * Calculate margins by rendering axis labels in a preliminary position.
  30586. * Title, subtitle and legend have already been rendered at this stage, but
  30587. * will be moved into their final positions.
  30588. *
  30589. * @private
  30590. * @function Highcharts.Chart#getMargins
  30591. * @fires Highcharts.Chart#event:getMargins
  30592. */
  30593. Chart.prototype.getMargins = function (skipAxes) {
  30594. var _a = this,
  30595. spacing = _a.spacing,
  30596. margin = _a.margin,
  30597. titleOffset = _a.titleOffset;
  30598. this.resetMargins();
  30599. // Adjust for title and subtitle
  30600. if (titleOffset[0] && !defined(margin[0])) {
  30601. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  30602. }
  30603. if (titleOffset[2] && !defined(margin[2])) {
  30604. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  30605. }
  30606. // Adjust for legend
  30607. if (this.legend && this.legend.display) {
  30608. this.legend.adjustMargins(margin, spacing);
  30609. }
  30610. fireEvent(this, 'getMargins');
  30611. if (!skipAxes) {
  30612. this.getAxisMargins();
  30613. }
  30614. };
  30615. /**
  30616. * @private
  30617. * @function Highcharts.Chart#getAxisMargins
  30618. */
  30619. Chart.prototype.getAxisMargins = function () {
  30620. var chart = this,
  30621. // [top, right, bottom, left]
  30622. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  30623. colorAxis = chart.colorAxis,
  30624. margin = chart.margin,
  30625. getOffset = function (axes) {
  30626. axes.forEach(function (axis) {
  30627. if (axis.visible) {
  30628. axis.getOffset();
  30629. }
  30630. });
  30631. };
  30632. // pre-render axes to get labels offset width
  30633. if (chart.hasCartesianSeries) {
  30634. getOffset(chart.axes);
  30635. }
  30636. else if (colorAxis && colorAxis.length) {
  30637. getOffset(colorAxis);
  30638. }
  30639. // Add the axis offsets
  30640. marginNames.forEach(function (m, side) {
  30641. if (!defined(margin[side])) {
  30642. chart[m] += axisOffset[side];
  30643. }
  30644. });
  30645. chart.setChartSize();
  30646. };
  30647. /**
  30648. * Reflows the chart to its container. By default, the chart reflows
  30649. * automatically to its container following a `window.resize` event, as per
  30650. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  30651. * option. However, there are no reliable events for div resize, so if the
  30652. * container is resized without a window resize event, this must be called
  30653. * explicitly.
  30654. *
  30655. * @sample highcharts/members/chart-reflow/
  30656. * Resize div and reflow
  30657. * @sample highcharts/chart/events-container/
  30658. * Pop up and reflow
  30659. *
  30660. * @function Highcharts.Chart#reflow
  30661. *
  30662. * @param {global.Event} [e]
  30663. * Event arguments. Used primarily when the function is called
  30664. * internally as a response to window resize.
  30665. */
  30666. Chart.prototype.reflow = function (e) {
  30667. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  30668. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  30669. delete chart.pointer.chartPosition;
  30670. // Width and height checks for display:none. Target is doc in IE8 and
  30671. // Opera, win in Firefox, Chrome and IE9.
  30672. if (!hasUserSize &&
  30673. !chart.isPrinting &&
  30674. width &&
  30675. height &&
  30676. (target === win || target === doc)) {
  30677. if (width !== chart.containerWidth ||
  30678. height !== chart.containerHeight) {
  30679. U.clearTimeout(chart.reflowTimeout);
  30680. // When called from window.resize, e is set, else it's called
  30681. // directly (#2224)
  30682. chart.reflowTimeout = syncTimeout(function () {
  30683. // Set size, it may have been destroyed in the meantime
  30684. // (#1257)
  30685. if (chart.container) {
  30686. chart.setSize(void 0, void 0, false);
  30687. }
  30688. }, e ? 100 : 0);
  30689. }
  30690. chart.containerWidth = width;
  30691. chart.containerHeight = height;
  30692. }
  30693. };
  30694. /**
  30695. * Toggle the event handlers necessary for auto resizing, depending on the
  30696. * `chart.reflow` option.
  30697. *
  30698. * @private
  30699. * @function Highcharts.Chart#setReflow
  30700. */
  30701. Chart.prototype.setReflow = function (reflow) {
  30702. var chart = this;
  30703. if (reflow !== false && !this.unbindReflow) {
  30704. this.unbindReflow = addEvent(win, 'resize', function (e) {
  30705. // a removed event listener still runs in Edge and IE if the
  30706. // listener was removed while the event runs, so check if the
  30707. // chart is not destroyed (#11609)
  30708. if (chart.options) {
  30709. chart.reflow(e);
  30710. }
  30711. });
  30712. addEvent(this, 'destroy', this.unbindReflow);
  30713. }
  30714. else if (reflow === false && this.unbindReflow) {
  30715. // Unbind and unset
  30716. this.unbindReflow = this.unbindReflow();
  30717. }
  30718. // The following will add listeners to re-fit the chart before and after
  30719. // printing (#2284). However it only works in WebKit. Should have worked
  30720. // in Firefox, but not supported in IE.
  30721. /*
  30722. if (win.matchMedia) {
  30723. win.matchMedia('print').addListener(function reflow() {
  30724. chart.reflow();
  30725. });
  30726. }
  30727. //*/
  30728. };
  30729. /**
  30730. * Resize the chart to a given width and height. In order to set the width
  30731. * only, the height argument may be skipped. To set the height only, pass
  30732. * `undefined` for the width.
  30733. *
  30734. * @sample highcharts/members/chart-setsize-button/
  30735. * Test resizing from buttons
  30736. * @sample highcharts/members/chart-setsize-jquery-resizable/
  30737. * Add a jQuery UI resizable
  30738. * @sample stock/members/chart-setsize/
  30739. * Highcharts Stock with UI resizable
  30740. *
  30741. * @function Highcharts.Chart#setSize
  30742. *
  30743. * @param {number|null} [width]
  30744. * The new pixel width of the chart. Since v4.2.6, the argument can
  30745. * be `undefined` in order to preserve the current value (when
  30746. * setting height only), or `null` to adapt to the width of the
  30747. * containing element.
  30748. *
  30749. * @param {number|null} [height]
  30750. * The new pixel height of the chart. Since v4.2.6, the argument can
  30751. * be `undefined` in order to preserve the current value, or `null`
  30752. * in order to adapt to the height of the containing element.
  30753. *
  30754. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  30755. * Whether and how to apply animation.
  30756. *
  30757. * @return {void}
  30758. *
  30759. * @fires Highcharts.Chart#event:endResize
  30760. * @fires Highcharts.Chart#event:resize
  30761. */
  30762. Chart.prototype.setSize = function (width, height, animation) {
  30763. var chart = this,
  30764. renderer = chart.renderer;
  30765. // Handle the isResizing counter
  30766. chart.isResizing += 1;
  30767. // set the animation for the current process
  30768. setAnimation(animation, chart);
  30769. var globalAnimation = renderer.globalAnimation;
  30770. chart.oldChartHeight = chart.chartHeight;
  30771. chart.oldChartWidth = chart.chartWidth;
  30772. if (typeof width !== 'undefined') {
  30773. chart.options.chart.width = width;
  30774. }
  30775. if (typeof height !== 'undefined') {
  30776. chart.options.chart.height = height;
  30777. }
  30778. chart.getChartSize();
  30779. // Resize the container with the global animation applied if enabled
  30780. // (#2503)
  30781. if (!chart.styledMode) {
  30782. (globalAnimation ? animate : css)(chart.container, {
  30783. width: chart.chartWidth + 'px',
  30784. height: chart.chartHeight + 'px'
  30785. }, globalAnimation);
  30786. }
  30787. chart.setChartSize(true);
  30788. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  30789. // handle axes
  30790. chart.axes.forEach(function (axis) {
  30791. axis.isDirty = true;
  30792. axis.setScale();
  30793. });
  30794. chart.isDirtyLegend = true; // force legend redraw
  30795. chart.isDirtyBox = true; // force redraw of plot and chart border
  30796. chart.layOutTitles(); // #2857
  30797. chart.getMargins();
  30798. chart.redraw(globalAnimation);
  30799. chart.oldChartHeight = null;
  30800. fireEvent(chart, 'resize');
  30801. // Fire endResize and set isResizing back. If animation is disabled,
  30802. // fire without delay
  30803. syncTimeout(function () {
  30804. if (chart) {
  30805. fireEvent(chart, 'endResize', null, function () {
  30806. chart.isResizing -= 1;
  30807. });
  30808. }
  30809. }, animObject(globalAnimation).duration);
  30810. };
  30811. /**
  30812. * Set the public chart properties. This is done before and after the
  30813. * pre-render to determine margin sizes.
  30814. *
  30815. * @private
  30816. * @function Highcharts.Chart#setChartSize
  30817. * @fires Highcharts.Chart#event:afterSetChartSize
  30818. */
  30819. Chart.prototype.setChartSize = function (skipAxes) {
  30820. var chart = this,
  30821. inverted = chart.inverted,
  30822. renderer = chart.renderer,
  30823. chartWidth = chart.chartWidth,
  30824. chartHeight = chart.chartHeight,
  30825. optionsChart = chart.options.chart,
  30826. spacing = chart.spacing,
  30827. clipOffset = chart.clipOffset;
  30828. var plotLeft,
  30829. plotTop,
  30830. plotWidth,
  30831. plotHeight;
  30832. /**
  30833. * The current left position of the plot area in pixels.
  30834. *
  30835. * @name Highcharts.Chart#plotLeft
  30836. * @type {number}
  30837. */
  30838. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  30839. /**
  30840. * The current top position of the plot area in pixels.
  30841. *
  30842. * @name Highcharts.Chart#plotTop
  30843. * @type {number}
  30844. */
  30845. chart.plotTop = plotTop = Math.round(chart.plotTop);
  30846. /**
  30847. * The current width of the plot area in pixels.
  30848. *
  30849. * @name Highcharts.Chart#plotWidth
  30850. * @type {number}
  30851. */
  30852. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  30853. /**
  30854. * The current height of the plot area in pixels.
  30855. *
  30856. * @name Highcharts.Chart#plotHeight
  30857. * @type {number}
  30858. */
  30859. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  30860. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  30861. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  30862. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  30863. // Set boxes used for alignment
  30864. chart.spacingBox = renderer.spacingBox = {
  30865. x: spacing[3],
  30866. y: spacing[0],
  30867. width: chartWidth - spacing[3] - spacing[1],
  30868. height: chartHeight - spacing[0] - spacing[2]
  30869. };
  30870. chart.plotBox = renderer.plotBox = {
  30871. x: plotLeft,
  30872. y: plotTop,
  30873. width: plotWidth,
  30874. height: plotHeight
  30875. };
  30876. var plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2),
  30877. clipX = Math.ceil(Math.max(plotBorderWidth,
  30878. clipOffset[3]) / 2),
  30879. clipY = Math.ceil(Math.max(plotBorderWidth,
  30880. clipOffset[0]) / 2);
  30881. chart.clipBox = {
  30882. x: clipX,
  30883. y: clipY,
  30884. width: Math.floor(chart.plotSizeX -
  30885. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  30886. clipX),
  30887. height: Math.max(0, Math.floor(chart.plotSizeY -
  30888. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  30889. clipY))
  30890. };
  30891. if (!skipAxes) {
  30892. chart.axes.forEach(function (axis) {
  30893. axis.setAxisSize();
  30894. axis.setAxisTranslation();
  30895. });
  30896. renderer.alignElements();
  30897. }
  30898. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  30899. };
  30900. /**
  30901. * Initial margins before auto size margins are applied.
  30902. *
  30903. * @private
  30904. * @function Highcharts.Chart#resetMargins
  30905. */
  30906. Chart.prototype.resetMargins = function () {
  30907. fireEvent(this, 'resetMargins');
  30908. var chart = this,
  30909. chartOptions = chart.options.chart;
  30910. // Create margin and spacing array
  30911. ['margin', 'spacing'].forEach(function splashArrays(target) {
  30912. var value = chartOptions[target],
  30913. values = isObject(value) ? value : [value,
  30914. value,
  30915. value,
  30916. value];
  30917. [
  30918. 'Top',
  30919. 'Right',
  30920. 'Bottom',
  30921. 'Left'
  30922. ].forEach(function (sideName, side) {
  30923. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  30924. });
  30925. });
  30926. // Set margin names like chart.plotTop, chart.plotLeft,
  30927. // chart.marginRight, chart.marginBottom.
  30928. marginNames.forEach(function (m, side) {
  30929. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  30930. });
  30931. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  30932. chart.clipOffset = [0, 0, 0, 0];
  30933. };
  30934. /**
  30935. * Internal function to draw or redraw the borders and backgrounds for chart
  30936. * and plot area.
  30937. *
  30938. * @private
  30939. * @function Highcharts.Chart#drawChartBox
  30940. * @fires Highcharts.Chart#event:afterDrawChartBox
  30941. */
  30942. Chart.prototype.drawChartBox = function () {
  30943. var chart = this,
  30944. optionsChart = chart.options.chart,
  30945. renderer = chart.renderer,
  30946. chartWidth = chart.chartWidth,
  30947. chartHeight = chart.chartHeight,
  30948. styledMode = chart.styledMode,
  30949. plotBGImage = chart.plotBGImage,
  30950. chartBackgroundColor = optionsChart.backgroundColor,
  30951. plotBackgroundColor = optionsChart.plotBackgroundColor,
  30952. plotBackgroundImage = optionsChart.plotBackgroundImage,
  30953. plotLeft = chart.plotLeft,
  30954. plotTop = chart.plotTop,
  30955. plotWidth = chart.plotWidth,
  30956. plotHeight = chart.plotHeight,
  30957. plotBox = chart.plotBox,
  30958. clipRect = chart.clipRect,
  30959. clipBox = chart.clipBox;
  30960. var chartBackground = chart.chartBackground,
  30961. plotBackground = chart.plotBackground,
  30962. plotBorder = chart.plotBorder,
  30963. chartBorderWidth,
  30964. mgn,
  30965. bgAttr,
  30966. verb = 'animate';
  30967. // Chart area
  30968. if (!chartBackground) {
  30969. chart.chartBackground = chartBackground = renderer.rect()
  30970. .addClass('highcharts-background')
  30971. .add();
  30972. verb = 'attr';
  30973. }
  30974. if (!styledMode) {
  30975. // Presentational
  30976. chartBorderWidth = optionsChart.borderWidth || 0;
  30977. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  30978. bgAttr = {
  30979. fill: chartBackgroundColor || 'none'
  30980. };
  30981. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  30982. bgAttr.stroke = optionsChart.borderColor;
  30983. bgAttr['stroke-width'] = chartBorderWidth;
  30984. }
  30985. chartBackground
  30986. .attr(bgAttr)
  30987. .shadow(optionsChart.shadow);
  30988. }
  30989. else {
  30990. chartBorderWidth = mgn = chartBackground.strokeWidth();
  30991. }
  30992. chartBackground[verb]({
  30993. x: mgn / 2,
  30994. y: mgn / 2,
  30995. width: chartWidth - mgn - chartBorderWidth % 2,
  30996. height: chartHeight - mgn - chartBorderWidth % 2,
  30997. r: optionsChart.borderRadius
  30998. });
  30999. // Plot background
  31000. verb = 'animate';
  31001. if (!plotBackground) {
  31002. verb = 'attr';
  31003. chart.plotBackground = plotBackground = renderer.rect()
  31004. .addClass('highcharts-plot-background')
  31005. .add();
  31006. }
  31007. plotBackground[verb](plotBox);
  31008. if (!styledMode) {
  31009. // Presentational attributes for the background
  31010. plotBackground
  31011. .attr({
  31012. fill: plotBackgroundColor || 'none'
  31013. })
  31014. .shadow(optionsChart.plotShadow);
  31015. // Create the background image
  31016. if (plotBackgroundImage) {
  31017. if (!plotBGImage) {
  31018. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  31019. }
  31020. else {
  31021. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  31022. plotBGImage.attr('href', plotBackgroundImage);
  31023. }
  31024. plotBGImage.animate(plotBox);
  31025. }
  31026. }
  31027. }
  31028. // Plot clip
  31029. if (!clipRect) {
  31030. chart.clipRect = renderer.clipRect(clipBox);
  31031. }
  31032. else {
  31033. clipRect.animate({
  31034. width: clipBox.width,
  31035. height: clipBox.height
  31036. });
  31037. }
  31038. // Plot area border
  31039. verb = 'animate';
  31040. if (!plotBorder) {
  31041. verb = 'attr';
  31042. chart.plotBorder = plotBorder = renderer.rect()
  31043. .addClass('highcharts-plot-border')
  31044. .attr({
  31045. zIndex: 1 // Above the grid
  31046. })
  31047. .add();
  31048. }
  31049. if (!styledMode) {
  31050. // Presentational
  31051. plotBorder.attr({
  31052. stroke: optionsChart.plotBorderColor,
  31053. 'stroke-width': optionsChart.plotBorderWidth || 0,
  31054. fill: 'none'
  31055. });
  31056. }
  31057. plotBorder[verb](plotBorder.crisp({
  31058. x: plotLeft,
  31059. y: plotTop,
  31060. width: plotWidth,
  31061. height: plotHeight
  31062. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  31063. // reset
  31064. chart.isDirtyBox = false;
  31065. fireEvent(this, 'afterDrawChartBox');
  31066. };
  31067. /**
  31068. * Detect whether a certain chart property is needed based on inspecting its
  31069. * options and series. This mainly applies to the chart.inverted property,
  31070. * and in extensions to the chart.angular and chart.polar properties.
  31071. *
  31072. * @private
  31073. * @function Highcharts.Chart#propFromSeries
  31074. * @return {void}
  31075. */
  31076. Chart.prototype.propFromSeries = function () {
  31077. var chart = this,
  31078. optionsChart = chart.options.chart,
  31079. seriesOptions = chart.options.series;
  31080. var i,
  31081. klass,
  31082. value;
  31083. /**
  31084. * The flag is set to `true` if a series of the chart is inverted.
  31085. *
  31086. * @name Highcharts.Chart#inverted
  31087. * @type {boolean|undefined}
  31088. */
  31089. ['inverted', 'angular', 'polar'].forEach(function (key) {
  31090. // The default series type's class
  31091. klass = seriesTypes[(optionsChart.type || optionsChart.defaultSeriesType)];
  31092. // Get the value from available chart-wide properties
  31093. value =
  31094. // It is set in the options:
  31095. optionsChart[key] ||
  31096. // The default series class:
  31097. (klass && klass.prototype[key]);
  31098. // requires it
  31099. // 4. Check if any the chart's series require it
  31100. i = seriesOptions && seriesOptions.length;
  31101. while (!value && i--) {
  31102. klass = seriesTypes[seriesOptions[i].type];
  31103. if (klass && klass.prototype[key]) {
  31104. value = true;
  31105. }
  31106. }
  31107. // Set the chart property
  31108. chart[key] = value;
  31109. });
  31110. };
  31111. /**
  31112. * Internal function to link two or more series together, based on the
  31113. * `linkedTo` option. This is done from `Chart.render`, and after
  31114. * `Chart.addSeries` and `Series.remove`.
  31115. *
  31116. * @private
  31117. * @function Highcharts.Chart#linkSeries
  31118. * @fires Highcharts.Chart#event:afterLinkSeries
  31119. */
  31120. Chart.prototype.linkSeries = function () {
  31121. var chart = this,
  31122. chartSeries = chart.series;
  31123. // Reset links
  31124. chartSeries.forEach(function (series) {
  31125. series.linkedSeries.length = 0;
  31126. });
  31127. // Apply new links
  31128. chartSeries.forEach(function (series) {
  31129. var linkedTo = series.options.linkedTo;
  31130. if (isString(linkedTo)) {
  31131. if (linkedTo === ':previous') {
  31132. linkedTo = chart.series[series.index - 1];
  31133. }
  31134. else {
  31135. linkedTo = chart.get(linkedTo);
  31136. }
  31137. // #3341 avoid mutual linking
  31138. if (linkedTo && linkedTo.linkedParent !== series) {
  31139. linkedTo.linkedSeries.push(series);
  31140. series.linkedParent = linkedTo;
  31141. if (linkedTo.enabledDataSorting) {
  31142. series.setDataSortingOptions();
  31143. }
  31144. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  31145. }
  31146. }
  31147. });
  31148. fireEvent(this, 'afterLinkSeries');
  31149. };
  31150. /**
  31151. * Render series for the chart.
  31152. *
  31153. * @private
  31154. * @function Highcharts.Chart#renderSeries
  31155. */
  31156. Chart.prototype.renderSeries = function () {
  31157. this.series.forEach(function (serie) {
  31158. serie.translate();
  31159. serie.render();
  31160. });
  31161. };
  31162. /**
  31163. * Render labels for the chart.
  31164. *
  31165. * @private
  31166. * @function Highcharts.Chart#renderLabels
  31167. */
  31168. Chart.prototype.renderLabels = function () {
  31169. var chart = this,
  31170. labels = chart.options.labels;
  31171. if (labels.items) {
  31172. labels.items.forEach(function (label) {
  31173. var style = extend(labels.style,
  31174. label.style),
  31175. x = pInt(style.left) + chart.plotLeft,
  31176. y = pInt(style.top) + chart.plotTop + 12;
  31177. // delete to prevent rewriting in IE
  31178. delete style.left;
  31179. delete style.top;
  31180. chart.renderer.text(label.html, x, y)
  31181. .attr({ zIndex: 2 })
  31182. .css(style)
  31183. .add();
  31184. });
  31185. }
  31186. };
  31187. /**
  31188. * Render all graphics for the chart. Runs internally on initialization.
  31189. *
  31190. * @private
  31191. * @function Highcharts.Chart#render
  31192. */
  31193. Chart.prototype.render = function () {
  31194. var chart = this,
  31195. axes = chart.axes,
  31196. colorAxis = chart.colorAxis,
  31197. renderer = chart.renderer,
  31198. options = chart.options,
  31199. renderAxes = function (axes) {
  31200. axes.forEach(function (axis) {
  31201. if (axis.visible) {
  31202. axis.render();
  31203. }
  31204. });
  31205. };
  31206. var correction = 0; // correction for X axis labels
  31207. // Title
  31208. chart.setTitle();
  31209. /**
  31210. * The overview of the chart's series.
  31211. *
  31212. * @name Highcharts.Chart#legend
  31213. * @type {Highcharts.Legend}
  31214. */
  31215. chart.legend = new Legend(chart, options.legend);
  31216. // Get stacks
  31217. if (chart.getStacks) {
  31218. chart.getStacks();
  31219. }
  31220. // Get chart margins
  31221. chart.getMargins(true);
  31222. chart.setChartSize();
  31223. // Record preliminary dimensions for later comparison
  31224. var tempWidth = chart.plotWidth;
  31225. axes.some(function (axis) {
  31226. if (axis.horiz &&
  31227. axis.visible &&
  31228. axis.options.labels.enabled &&
  31229. axis.series.length) {
  31230. // 21 is the most common correction for X axis labels
  31231. correction = 21;
  31232. return true;
  31233. }
  31234. });
  31235. // use Math.max to prevent negative plotHeight
  31236. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  31237. var tempHeight = chart.plotHeight;
  31238. // Get margins by pre-rendering axes
  31239. axes.forEach(function (axis) {
  31240. axis.setScale();
  31241. });
  31242. chart.getAxisMargins();
  31243. // If the plot area size has changed significantly, calculate tick
  31244. // positions again
  31245. var redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  31246. // Height is more sensitive, use lower threshold
  31247. var redoVertical = tempHeight / chart.plotHeight > 1.05;
  31248. if (redoHorizontal || redoVertical) {
  31249. axes.forEach(function (axis) {
  31250. if ((axis.horiz && redoHorizontal) ||
  31251. (!axis.horiz && redoVertical)) {
  31252. // update to reflect the new margins
  31253. axis.setTickInterval(true);
  31254. }
  31255. });
  31256. chart.getMargins(); // second pass to check for new labels
  31257. }
  31258. // Draw the borders and backgrounds
  31259. chart.drawChartBox();
  31260. // Axes
  31261. if (chart.hasCartesianSeries) {
  31262. renderAxes(axes);
  31263. }
  31264. else if (colorAxis && colorAxis.length) {
  31265. renderAxes(colorAxis);
  31266. }
  31267. // The series
  31268. if (!chart.seriesGroup) {
  31269. chart.seriesGroup = renderer.g('series-group')
  31270. .attr({ zIndex: 3 })
  31271. .add();
  31272. }
  31273. chart.renderSeries();
  31274. // Labels
  31275. chart.renderLabels();
  31276. // Credits
  31277. chart.addCredits();
  31278. // Handle responsiveness
  31279. if (chart.setResponsive) {
  31280. chart.setResponsive();
  31281. }
  31282. // Set flag
  31283. chart.hasRendered = true;
  31284. };
  31285. /**
  31286. * Set a new credits label for the chart.
  31287. *
  31288. * @sample highcharts/credits/credits-update/
  31289. * Add and update credits
  31290. *
  31291. * @function Highcharts.Chart#addCredits
  31292. *
  31293. * @param {Highcharts.CreditsOptions} [credits]
  31294. * A configuration object for the new credits.
  31295. */
  31296. Chart.prototype.addCredits = function (credits) {
  31297. var chart = this,
  31298. creds = merge(true,
  31299. this.options.credits,
  31300. credits);
  31301. if (creds.enabled && !this.credits) {
  31302. /**
  31303. * The chart's credits label. The label has an `update` method that
  31304. * allows setting new options as per the
  31305. * [credits options set](https://api.highcharts.com/highcharts/credits).
  31306. *
  31307. * @name Highcharts.Chart#credits
  31308. * @type {Highcharts.SVGElement}
  31309. */
  31310. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  31311. .addClass('highcharts-credits')
  31312. .on('click', function () {
  31313. if (creds.href) {
  31314. win.location.href = creds.href;
  31315. }
  31316. })
  31317. .attr({
  31318. align: creds.position.align,
  31319. zIndex: 8
  31320. });
  31321. if (!chart.styledMode) {
  31322. this.credits.css(creds.style);
  31323. }
  31324. this.credits
  31325. .add()
  31326. .align(creds.position);
  31327. // Dynamically update
  31328. this.credits.update = function (options) {
  31329. chart.credits = chart.credits.destroy();
  31330. chart.addCredits(options);
  31331. };
  31332. }
  31333. };
  31334. /**
  31335. * Remove the chart and purge memory. This method is called internally
  31336. * before adding a second chart into the same container, as well as on
  31337. * window unload to prevent leaks.
  31338. *
  31339. * @sample highcharts/members/chart-destroy/
  31340. * Destroy the chart from a button
  31341. * @sample stock/members/chart-destroy/
  31342. * Destroy with Highcharts Stock
  31343. *
  31344. * @function Highcharts.Chart#destroy
  31345. *
  31346. * @fires Highcharts.Chart#event:destroy
  31347. */
  31348. Chart.prototype.destroy = function () {
  31349. var chart = this,
  31350. axes = chart.axes,
  31351. series = chart.series,
  31352. container = chart.container,
  31353. parentNode = container && container.parentNode;
  31354. var i;
  31355. // fire the chart.destoy event
  31356. fireEvent(chart, 'destroy');
  31357. // Delete the chart from charts lookup array
  31358. if (chart.renderer.forExport) {
  31359. erase(charts, chart); // #6569
  31360. }
  31361. else {
  31362. charts[chart.index] = void 0;
  31363. }
  31364. H.chartCount--;
  31365. chart.renderTo.removeAttribute('data-highcharts-chart');
  31366. // remove events
  31367. removeEvent(chart);
  31368. // ==== Destroy collections:
  31369. // Destroy axes
  31370. i = axes.length;
  31371. while (i--) {
  31372. axes[i] = axes[i].destroy();
  31373. }
  31374. // Destroy scroller & scroller series before destroying base series
  31375. if (this.scroller && this.scroller.destroy) {
  31376. this.scroller.destroy();
  31377. }
  31378. // Destroy each series
  31379. i = series.length;
  31380. while (i--) {
  31381. series[i] = series[i].destroy();
  31382. }
  31383. // ==== Destroy chart properties:
  31384. [
  31385. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  31386. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  31387. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  31388. 'renderer'
  31389. ].forEach(function (name) {
  31390. var prop = chart[name];
  31391. if (prop && prop.destroy) {
  31392. chart[name] = prop.destroy();
  31393. }
  31394. });
  31395. // Remove container and all SVG, check container as it can break in IE
  31396. // when destroyed before finished loading
  31397. if (container) {
  31398. container.innerHTML = '';
  31399. removeEvent(container);
  31400. if (parentNode) {
  31401. discardElement(container);
  31402. }
  31403. }
  31404. // clean it all up
  31405. objectEach(chart, function (val, key) {
  31406. delete chart[key];
  31407. });
  31408. };
  31409. /**
  31410. * Prepare for first rendering after all data are loaded.
  31411. *
  31412. * @private
  31413. * @function Highcharts.Chart#firstRender
  31414. * @fires Highcharts.Chart#event:beforeRender
  31415. */
  31416. Chart.prototype.firstRender = function () {
  31417. var chart = this,
  31418. options = chart.options;
  31419. // Hook for oldIE to check whether the chart is ready to render
  31420. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  31421. return;
  31422. }
  31423. // Create the container
  31424. chart.getContainer();
  31425. chart.resetMargins();
  31426. chart.setChartSize();
  31427. // Set the common chart properties (mainly invert) from the given series
  31428. chart.propFromSeries();
  31429. // get axes
  31430. chart.getAxes();
  31431. // Initialize the series
  31432. (isArray(options.series) ? options.series : []).forEach(
  31433. // #9680
  31434. function (serieOptions) {
  31435. chart.initSeries(serieOptions);
  31436. });
  31437. chart.linkSeries();
  31438. chart.setSeriesData();
  31439. // Run an event after axes and series are initialized, but before
  31440. // render. At this stage, the series data is indexed and cached in the
  31441. // xData and yData arrays, so we can access those before rendering. Used
  31442. // in Highcharts Stock.
  31443. fireEvent(chart, 'beforeRender');
  31444. // depends on inverted and on margins being set
  31445. if (Pointer) {
  31446. if (MSPointer.isRequired()) {
  31447. chart.pointer = new MSPointer(chart, options);
  31448. }
  31449. else {
  31450. /**
  31451. * The Pointer that keeps track of mouse and touch interaction.
  31452. *
  31453. * @memberof Highcharts.Chart
  31454. * @name pointer
  31455. * @type {Highcharts.Pointer}
  31456. * @instance
  31457. */
  31458. chart.pointer = new Pointer(chart, options);
  31459. }
  31460. }
  31461. chart.render();
  31462. chart.pointer.getChartPosition(); // #14973
  31463. // Fire the load event if there are no external images
  31464. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  31465. chart.onload();
  31466. }
  31467. // If the chart was rendered outside the top container, put it back in
  31468. // (#3679)
  31469. chart.temporaryDisplay(true);
  31470. };
  31471. /**
  31472. * Internal function that runs on chart load, async if any images are loaded
  31473. * in the chart. Runs the callbacks and triggers the `load` and `render`
  31474. * events.
  31475. *
  31476. * @private
  31477. * @function Highcharts.Chart#onload
  31478. * @fires Highcharts.Chart#event:load
  31479. * @fires Highcharts.Chart#event:render
  31480. */
  31481. Chart.prototype.onload = function () {
  31482. // Run callbacks, first the ones registered by modules, then user's one
  31483. this.callbacks.concat([this.callback]).forEach(function (fn) {
  31484. // Chart destroyed in its own callback (#3600)
  31485. if (fn && typeof this.index !== 'undefined') {
  31486. fn.apply(this, [this]);
  31487. }
  31488. }, this);
  31489. fireEvent(this, 'load');
  31490. fireEvent(this, 'render');
  31491. // Set up auto resize, check for not destroyed (#6068)
  31492. if (defined(this.index)) {
  31493. this.setReflow(this.options.chart.reflow);
  31494. }
  31495. // Don't run again
  31496. this.hasLoaded = true;
  31497. };
  31498. /**
  31499. * Add a series to the chart after render time. Note that this method should
  31500. * never be used when adding data synchronously at chart render time, as it
  31501. * adds expense to the calculations and rendering. When adding data at the
  31502. * same time as the chart is initialized, add the series as a configuration
  31503. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  31504. *
  31505. * @sample highcharts/members/chart-addseries/
  31506. * Add a series from a button
  31507. * @sample stock/members/chart-addseries/
  31508. * Add a series in Highcharts Stock
  31509. *
  31510. * @function Highcharts.Chart#addSeries
  31511. *
  31512. * @param {Highcharts.SeriesOptionsType} options
  31513. * The config options for the series.
  31514. *
  31515. * @param {boolean} [redraw=true]
  31516. * Whether to redraw the chart after adding.
  31517. *
  31518. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  31519. * Whether to apply animation, and optionally animation
  31520. * configuration.
  31521. *
  31522. * @return {Highcharts.Series}
  31523. * The newly created series object.
  31524. *
  31525. * @fires Highcharts.Chart#event:addSeries
  31526. * @fires Highcharts.Chart#event:afterAddSeries
  31527. */
  31528. Chart.prototype.addSeries = function (options, redraw, animation) {
  31529. var chart = this;
  31530. var series;
  31531. if (options) { // <- not necessary
  31532. redraw = pick(redraw, true); // defaults to true
  31533. fireEvent(chart, 'addSeries', { options: options }, function () {
  31534. series = chart.initSeries(options);
  31535. chart.isDirtyLegend = true;
  31536. chart.linkSeries();
  31537. if (series.enabledDataSorting) {
  31538. // We need to call `setData` after `linkSeries`
  31539. series.setData(options.data, false);
  31540. }
  31541. fireEvent(chart, 'afterAddSeries', { series: series });
  31542. if (redraw) {
  31543. chart.redraw(animation);
  31544. }
  31545. });
  31546. }
  31547. return series;
  31548. };
  31549. /**
  31550. * Add an axis to the chart after render time. Note that this method should
  31551. * never be used when adding data synchronously at chart render time, as it
  31552. * adds expense to the calculations and rendering. When adding data at the
  31553. * same time as the chart is initialized, add the axis as a configuration
  31554. * option instead.
  31555. *
  31556. * @sample highcharts/members/chart-addaxis/
  31557. * Add and remove axes
  31558. *
  31559. * @function Highcharts.Chart#addAxis
  31560. *
  31561. * @param {Highcharts.AxisOptions} options
  31562. * The axis options.
  31563. *
  31564. * @param {boolean} [isX=false]
  31565. * Whether it is an X axis or a value axis.
  31566. *
  31567. * @param {boolean} [redraw=true]
  31568. * Whether to redraw the chart after adding.
  31569. *
  31570. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31571. * Whether and how to apply animation in the redraw.
  31572. *
  31573. * @return {Highcharts.Axis}
  31574. * The newly generated Axis object.
  31575. */
  31576. Chart.prototype.addAxis = function (options, isX, redraw, animation) {
  31577. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  31578. };
  31579. /**
  31580. * Add a color axis to the chart after render time. Note that this method
  31581. * should never be used when adding data synchronously at chart render time,
  31582. * as it adds expense to the calculations and rendering. When adding data at
  31583. * the same time as the chart is initialized, add the axis as a
  31584. * configuration option instead.
  31585. *
  31586. * @sample highcharts/members/chart-addaxis/
  31587. * Add and remove axes
  31588. *
  31589. * @function Highcharts.Chart#addColorAxis
  31590. *
  31591. * @param {Highcharts.ColorAxisOptions} options
  31592. * The axis options.
  31593. *
  31594. * @param {boolean} [redraw=true]
  31595. * Whether to redraw the chart after adding.
  31596. *
  31597. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31598. * Whether and how to apply animation in the redraw.
  31599. *
  31600. * @return {Highcharts.ColorAxis}
  31601. * The newly generated Axis object.
  31602. */
  31603. Chart.prototype.addColorAxis = function (options, redraw, animation) {
  31604. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  31605. };
  31606. /**
  31607. * Factory for creating different axis types.
  31608. *
  31609. * @private
  31610. * @function Highcharts.Chart#createAxis
  31611. *
  31612. * @param {string} type
  31613. * An axis type.
  31614. *
  31615. * @param {...Array<*>} arguments
  31616. * All arguments for the constructor.
  31617. *
  31618. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  31619. * The newly generated Axis object.
  31620. */
  31621. Chart.prototype.createAxis = function (type, options) {
  31622. var isColorAxis = type === 'colorAxis',
  31623. axisOptions = options.axis,
  31624. redraw = options.redraw,
  31625. animation = options.animation,
  31626. userOptions = merge(axisOptions, {
  31627. index: this[type].length,
  31628. isX: type === 'xAxis'
  31629. });
  31630. var axis;
  31631. if (isColorAxis) {
  31632. axis = new H.ColorAxis(this, userOptions);
  31633. }
  31634. else {
  31635. axis = new Axis(this, userOptions);
  31636. }
  31637. if (isColorAxis) {
  31638. this.isDirtyLegend = true;
  31639. // Clear before 'bindAxes' (#11924)
  31640. this.axes.forEach(function (axis) {
  31641. axis.series = [];
  31642. });
  31643. this.series.forEach(function (series) {
  31644. series.bindAxes();
  31645. series.isDirtyData = true;
  31646. });
  31647. }
  31648. if (pick(redraw, true)) {
  31649. this.redraw(animation);
  31650. }
  31651. return axis;
  31652. };
  31653. /**
  31654. * Dim the chart and show a loading text or symbol. Options for the loading
  31655. * screen are defined in {@link
  31656. * https://api.highcharts.com/highcharts/loading|the loading options}.
  31657. *
  31658. * @sample highcharts/members/chart-hideloading/
  31659. * Show and hide loading from a button
  31660. * @sample highcharts/members/chart-showloading/
  31661. * Apply different text labels
  31662. * @sample stock/members/chart-show-hide-loading/
  31663. * Toggle loading in Highcharts Stock
  31664. *
  31665. * @function Highcharts.Chart#showLoading
  31666. *
  31667. * @param {string} [str]
  31668. * An optional text to show in the loading label instead of the
  31669. * default one. The default text is set in
  31670. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  31671. */
  31672. Chart.prototype.showLoading = function (str) {
  31673. var chart = this,
  31674. options = chart.options,
  31675. loadingOptions = options.loading,
  31676. setLoadingSize = function () {
  31677. if (loadingDiv) {
  31678. css(loadingDiv, {
  31679. left: chart.plotLeft + 'px',
  31680. top: chart.plotTop + 'px',
  31681. width: chart.plotWidth + 'px',
  31682. height: chart.plotHeight + 'px'
  31683. });
  31684. }
  31685. };
  31686. var loadingDiv = chart.loadingDiv,
  31687. loadingSpan = chart.loadingSpan;
  31688. // create the layer at the first call
  31689. if (!loadingDiv) {
  31690. chart.loadingDiv = loadingDiv = createElement('div', {
  31691. className: 'highcharts-loading highcharts-loading-hidden'
  31692. }, null, chart.container);
  31693. }
  31694. if (!loadingSpan) {
  31695. chart.loadingSpan = loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  31696. addEvent(chart, 'redraw', setLoadingSize); // #1080
  31697. }
  31698. loadingDiv.className = 'highcharts-loading';
  31699. // Update text
  31700. AST.setElementHTML(loadingSpan, pick(str, options.lang.loading, ''));
  31701. if (!chart.styledMode) {
  31702. // Update visuals
  31703. css(loadingDiv, extend(loadingOptions.style, {
  31704. zIndex: 10
  31705. }));
  31706. css(loadingSpan, loadingOptions.labelStyle);
  31707. // Show it
  31708. if (!chart.loadingShown) {
  31709. css(loadingDiv, {
  31710. opacity: 0,
  31711. display: ''
  31712. });
  31713. animate(loadingDiv, {
  31714. opacity: loadingOptions.style.opacity || 0.5
  31715. }, {
  31716. duration: loadingOptions.showDuration || 0
  31717. });
  31718. }
  31719. }
  31720. chart.loadingShown = true;
  31721. setLoadingSize();
  31722. };
  31723. /**
  31724. * Hide the loading layer.
  31725. *
  31726. * @see Highcharts.Chart#showLoading
  31727. *
  31728. * @sample highcharts/members/chart-hideloading/
  31729. * Show and hide loading from a button
  31730. * @sample stock/members/chart-show-hide-loading/
  31731. * Toggle loading in Highcharts Stock
  31732. *
  31733. * @function Highcharts.Chart#hideLoading
  31734. */
  31735. Chart.prototype.hideLoading = function () {
  31736. var options = this.options,
  31737. loadingDiv = this.loadingDiv;
  31738. if (loadingDiv) {
  31739. loadingDiv.className =
  31740. 'highcharts-loading highcharts-loading-hidden';
  31741. if (!this.styledMode) {
  31742. animate(loadingDiv, {
  31743. opacity: 0
  31744. }, {
  31745. duration: options.loading.hideDuration || 100,
  31746. complete: function () {
  31747. css(loadingDiv, { display: 'none' });
  31748. }
  31749. });
  31750. }
  31751. }
  31752. this.loadingShown = false;
  31753. };
  31754. /**
  31755. * A generic function to update any element of the chart. Elements can be
  31756. * enabled and disabled, moved, re-styled, re-formatted etc.
  31757. *
  31758. * A special case is configuration objects that take arrays, for example
  31759. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  31760. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  31761. * [series](https://api.highcharts.com/highcharts/series). For these
  31762. * collections, an `id` option is used to map the new option set to an
  31763. * existing object. If an existing object of the same id is not found, the
  31764. * corresponding item is updated. So for example, running `chart.update`
  31765. * with a series item without an id, will cause the existing chart's series
  31766. * with the same index in the series array to be updated. When the
  31767. * `oneToOne` parameter is true, `chart.update` will also take care of
  31768. * adding and removing items from the collection. Read more under the
  31769. * parameter description below.
  31770. *
  31771. * Note that when changing series data, `chart.update` may mutate the passed
  31772. * data options.
  31773. *
  31774. * See also the
  31775. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  31776. * Switching between `responsive.rules` basically runs `chart.update` under
  31777. * the hood.
  31778. *
  31779. * @sample highcharts/members/chart-update/
  31780. * Update chart geometry
  31781. *
  31782. * @function Highcharts.Chart#update
  31783. *
  31784. * @param {Highcharts.Options} options
  31785. * A configuration object for the new chart options.
  31786. *
  31787. * @param {boolean} [redraw=true]
  31788. * Whether to redraw the chart.
  31789. *
  31790. * @param {boolean} [oneToOne=false]
  31791. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  31792. * collections will be updated one to one, and items will be either
  31793. * added or removed to match the new updated options. For example,
  31794. * if the chart has two series and we call `chart.update` with a
  31795. * configuration containing three series, one will be added. If we
  31796. * call `chart.update` with one series, one will be removed. Setting
  31797. * an empty `series` array will remove all series, but leaving out
  31798. * the`series` property will leave all series untouched. If the
  31799. * series have id's, the new series options will be matched by id,
  31800. * and the remaining ones removed.
  31801. *
  31802. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31803. * Whether to apply animation, and optionally animation
  31804. * configuration.
  31805. *
  31806. * @fires Highcharts.Chart#event:update
  31807. * @fires Highcharts.Chart#event:afterUpdate
  31808. */
  31809. Chart.prototype.update = function (options, redraw, oneToOne, animation) {
  31810. var chart = this,
  31811. adders = {
  31812. credits: 'addCredits',
  31813. title: 'setTitle',
  31814. subtitle: 'setSubtitle',
  31815. caption: 'setCaption'
  31816. },
  31817. isResponsiveOptions = options.isResponsiveOptions,
  31818. itemsForRemoval = [];
  31819. var updateAllAxes,
  31820. updateAllSeries,
  31821. runSetSize;
  31822. fireEvent(chart, 'update', { options: options });
  31823. // If there are responsive rules in action, undo the responsive rules
  31824. // before we apply the updated options and replay the responsive rules
  31825. // on top from the chart.redraw function (#9617).
  31826. if (!isResponsiveOptions) {
  31827. chart.setResponsive(false, true);
  31828. }
  31829. options = cleanRecursively(options, chart.options);
  31830. chart.userOptions = merge(chart.userOptions, options);
  31831. // If the top-level chart option is present, some special updates are
  31832. // required
  31833. var optionsChart = options.chart;
  31834. if (optionsChart) {
  31835. merge(true, chart.options.chart, optionsChart);
  31836. // Setter function
  31837. if ('className' in optionsChart) {
  31838. chart.setClassName(optionsChart.className);
  31839. }
  31840. if ('reflow' in optionsChart) {
  31841. chart.setReflow(optionsChart.reflow);
  31842. }
  31843. if ('inverted' in optionsChart ||
  31844. 'polar' in optionsChart ||
  31845. 'type' in optionsChart) {
  31846. // Parse options.chart.inverted and options.chart.polar together
  31847. // with the available series.
  31848. chart.propFromSeries();
  31849. updateAllAxes = true;
  31850. }
  31851. if ('alignTicks' in optionsChart) { // #6452
  31852. updateAllAxes = true;
  31853. }
  31854. if ('events' in optionsChart) {
  31855. // Chart event handlers
  31856. registerEventOptions(this, optionsChart);
  31857. }
  31858. objectEach(optionsChart, function (val, key) {
  31859. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  31860. -1) {
  31861. updateAllSeries = true;
  31862. }
  31863. // Only dirty box
  31864. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  31865. chart.isDirtyBox = true;
  31866. }
  31867. // Chart setSize
  31868. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  31869. if (isResponsiveOptions) {
  31870. chart.isDirtyBox = true;
  31871. }
  31872. else {
  31873. runSetSize = true;
  31874. }
  31875. }
  31876. });
  31877. if (!chart.styledMode && 'style' in optionsChart) {
  31878. chart.renderer.setStyle(optionsChart.style);
  31879. }
  31880. }
  31881. // Moved up, because tooltip needs updated plotOptions (#6218)
  31882. if (!chart.styledMode && options.colors) {
  31883. this.options.colors = options.colors;
  31884. }
  31885. if (options.time) {
  31886. // Maintaining legacy global time. If the chart is instanciated
  31887. // first with global time, then updated with time options, we need
  31888. // to create a new Time instance to avoid mutating the global time
  31889. // (#10536).
  31890. if (this.time === defaultTime) {
  31891. this.time = new Time(options.time);
  31892. }
  31893. // If we're updating, the time class is different from other chart
  31894. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  31895. // about the chart. The other chart[something].update functions also
  31896. // set the chart.options[something]. For the time class however we
  31897. // need to update the chart options separately. #14230.
  31898. merge(true, chart.options.time, options.time);
  31899. }
  31900. // Some option stuctures correspond one-to-one to chart objects that
  31901. // have update methods, for example
  31902. // options.credits => chart.credits
  31903. // options.legend => chart.legend
  31904. // options.title => chart.title
  31905. // options.tooltip => chart.tooltip
  31906. // options.subtitle => chart.subtitle
  31907. // options.mapNavigation => chart.mapNavigation
  31908. // options.navigator => chart.navigator
  31909. // options.scrollbar => chart.scrollbar
  31910. objectEach(options, function (val, key) {
  31911. if (chart[key] &&
  31912. typeof chart[key].update === 'function') {
  31913. chart[key].update(val, false);
  31914. // If a one-to-one object does not exist, look for an adder function
  31915. }
  31916. else if (typeof chart[adders[key]] === 'function') {
  31917. chart[adders[key]](val);
  31918. // Else, just merge the options. For nodes like loading, noData,
  31919. // plotOptions
  31920. }
  31921. else if (key !== 'colors' &&
  31922. chart.collectionsWithUpdate.indexOf(key) === -1) {
  31923. merge(true, chart.options[key], options[key]);
  31924. }
  31925. if (key !== 'chart' &&
  31926. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  31927. updateAllSeries = true;
  31928. }
  31929. });
  31930. // Setters for collections. For axes and series, each item is referred
  31931. // by an id. If the id is not found, it defaults to the corresponding
  31932. // item in the collection, so setting one series without an id, will
  31933. // update the first series in the chart. Setting two series without
  31934. // an id will update the first and the second respectively (#6019)
  31935. // chart.update and responsive.
  31936. this.collectionsWithUpdate.forEach(function (coll) {
  31937. var indexMap;
  31938. if (options[coll]) {
  31939. // In stock charts, the navigator series are also part of the
  31940. // chart.series array, but those series should not be handled
  31941. // here (#8196) and neither should the navigator axis (#9671).
  31942. indexMap = [];
  31943. chart[coll].forEach(function (s, i) {
  31944. if (!s.options.isInternal) {
  31945. indexMap.push(pick(s.options.index, i));
  31946. }
  31947. });
  31948. splat(options[coll]).forEach(function (newOptions, i) {
  31949. var hasId = defined(newOptions.id);
  31950. var item;
  31951. // Match by id
  31952. if (hasId) {
  31953. item = chart.get(newOptions.id);
  31954. }
  31955. // No match by id found, match by index instead
  31956. if (!item && chart[coll]) {
  31957. item = chart[coll][indexMap ? indexMap[i] : i];
  31958. // Check if we grabbed an item with an exising but
  31959. // different id (#13541)
  31960. if (item && hasId && defined(item.options.id)) {
  31961. item = void 0;
  31962. }
  31963. }
  31964. if (item && item.coll === coll) {
  31965. item.update(newOptions, false);
  31966. if (oneToOne) {
  31967. item.touched = true;
  31968. }
  31969. }
  31970. // If oneToOne and no matching item is found, add one
  31971. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  31972. chart.collectionsWithInit[coll][0].apply(chart,
  31973. // [newOptions, ...extraArguments, redraw=false]
  31974. [
  31975. newOptions
  31976. ].concat(
  31977. // Not all initializers require extra args
  31978. chart.collectionsWithInit[coll][1] || []).concat([
  31979. false
  31980. ])).touched = true;
  31981. }
  31982. });
  31983. // Add items for removal
  31984. if (oneToOne) {
  31985. chart[coll].forEach(function (item) {
  31986. if (!item.touched && !item.options.isInternal) {
  31987. itemsForRemoval.push(item);
  31988. }
  31989. else {
  31990. delete item.touched;
  31991. }
  31992. });
  31993. }
  31994. }
  31995. });
  31996. itemsForRemoval.forEach(function (item) {
  31997. if (item.chart) { // #9097, avoid removing twice
  31998. item.remove(false);
  31999. }
  32000. });
  32001. if (updateAllAxes) {
  32002. chart.axes.forEach(function (axis) {
  32003. axis.update({}, false);
  32004. });
  32005. }
  32006. // Certain options require the whole series structure to be thrown away
  32007. // and rebuilt
  32008. if (updateAllSeries) {
  32009. chart.getSeriesOrderByLinks().forEach(function (series) {
  32010. // Avoid removed navigator series
  32011. if (series.chart) {
  32012. series.update({}, false);
  32013. }
  32014. }, this);
  32015. }
  32016. // Update size. Redraw is forced.
  32017. var newWidth = optionsChart && optionsChart.width;
  32018. var newHeight = optionsChart && (isString(optionsChart.height) ?
  32019. relativeLength(optionsChart.height,
  32020. newWidth || chart.chartWidth) :
  32021. optionsChart.height);
  32022. if (
  32023. // In this case, run chart.setSize with newWidth and newHeight which
  32024. // are undefined, only for reflowing chart elements because margin
  32025. // or spacing has been set (#8190)
  32026. runSetSize ||
  32027. // In this case, the size is actually set
  32028. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  32029. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  32030. chart.setSize(newWidth, newHeight, animation);
  32031. }
  32032. else if (pick(redraw, true)) {
  32033. chart.redraw(animation);
  32034. }
  32035. fireEvent(chart, 'afterUpdate', {
  32036. options: options,
  32037. redraw: redraw,
  32038. animation: animation
  32039. });
  32040. };
  32041. /**
  32042. * Shortcut to set the subtitle options. This can also be done from {@link
  32043. * Chart#update} or {@link Chart#setTitle}.
  32044. *
  32045. * @function Highcharts.Chart#setSubtitle
  32046. *
  32047. * @param {Highcharts.SubtitleOptions} options
  32048. * New subtitle options. The subtitle text itself is set by the
  32049. * `options.text` property.
  32050. */
  32051. Chart.prototype.setSubtitle = function (options, redraw) {
  32052. this.applyDescription('subtitle', options);
  32053. this.layOutTitles(redraw);
  32054. };
  32055. /**
  32056. * Set the caption options. This can also be done from {@link
  32057. * Chart#update}.
  32058. *
  32059. * @function Highcharts.Chart#setCaption
  32060. *
  32061. * @param {Highcharts.CaptionOptions} options
  32062. * New caption options. The caption text itself is set by the
  32063. * `options.text` property.
  32064. */
  32065. Chart.prototype.setCaption = function (options, redraw) {
  32066. this.applyDescription('caption', options);
  32067. this.layOutTitles(redraw);
  32068. };
  32069. /**
  32070. * Display the zoom button, so users can reset zoom to the default view
  32071. * settings.
  32072. *
  32073. * @function Highcharts.Chart#showResetZoom
  32074. *
  32075. * @fires Highcharts.Chart#event:afterShowResetZoom
  32076. * @fires Highcharts.Chart#event:beforeShowResetZoom
  32077. */
  32078. Chart.prototype.showResetZoom = function () {
  32079. var chart = this,
  32080. lang = defaultOptions.lang,
  32081. btnOptions = chart.options.chart.resetZoomButton,
  32082. theme = btnOptions.theme,
  32083. states = theme.states,
  32084. alignTo = (btnOptions.relativeTo === 'chart' ||
  32085. btnOptions.relativeTo === 'spacingBox' ?
  32086. null :
  32087. 'scrollablePlotBox');
  32088. /**
  32089. * @private
  32090. */
  32091. function zoomOut() {
  32092. chart.zoomOut();
  32093. }
  32094. fireEvent(this, 'beforeShowResetZoom', null, function () {
  32095. chart.resetZoomButton = chart.renderer
  32096. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  32097. .attr({
  32098. align: btnOptions.position.align,
  32099. title: lang.resetZoomTitle
  32100. })
  32101. .addClass('highcharts-reset-zoom')
  32102. .add()
  32103. .align(btnOptions.position, false, alignTo);
  32104. });
  32105. fireEvent(this, 'afterShowResetZoom');
  32106. };
  32107. /**
  32108. * Zoom the chart out after a user has zoomed in. See also
  32109. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  32110. *
  32111. * @function Highcharts.Chart#zoomOut
  32112. *
  32113. * @fires Highcharts.Chart#event:selection
  32114. */
  32115. Chart.prototype.zoomOut = function () {
  32116. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  32117. };
  32118. /**
  32119. * Zoom into a given portion of the chart given by axis coordinates.
  32120. *
  32121. * @private
  32122. * @function Highcharts.Chart#zoom
  32123. * @param {Highcharts.SelectEventObject} event
  32124. */
  32125. Chart.prototype.zoom = function (event) {
  32126. var chart = this,
  32127. pointer = chart.pointer,
  32128. mouseDownPos = (chart.inverted ? pointer.mouseDownX : pointer.mouseDownY);
  32129. var displayButton = false,
  32130. hasZoomed;
  32131. // If zoom is called with no arguments, reset the axes
  32132. if (!event || event.resetSelection) {
  32133. chart.axes.forEach(function (axis) {
  32134. hasZoomed = axis.zoom();
  32135. });
  32136. pointer.initiated = false; // #6804
  32137. }
  32138. else { // else, zoom in on all axes
  32139. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  32140. var axis = axisData.axis,
  32141. axisStartPos = chart.inverted ? axis.left : axis.top,
  32142. axisEndPos = chart.inverted ?
  32143. axisStartPos + axis.width : axisStartPos + axis.height,
  32144. isXAxis = axis.isXAxis;
  32145. var isWithinPane = false;
  32146. // Check if zoomed area is within the pane (#1289).
  32147. // In case of multiple panes only one pane should be zoomed.
  32148. if ((!isXAxis &&
  32149. mouseDownPos >= axisStartPos &&
  32150. mouseDownPos <= axisEndPos) ||
  32151. isXAxis ||
  32152. !defined(mouseDownPos)) {
  32153. isWithinPane = true;
  32154. }
  32155. // don't zoom more than minRange
  32156. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  32157. hasZoomed = axis.zoom(axisData.min, axisData.max);
  32158. if (axis.displayBtn) {
  32159. displayButton = true;
  32160. }
  32161. }
  32162. });
  32163. }
  32164. // Show or hide the Reset zoom button
  32165. var resetZoomButton = chart.resetZoomButton;
  32166. if (displayButton && !resetZoomButton) {
  32167. chart.showResetZoom();
  32168. }
  32169. else if (!displayButton && isObject(resetZoomButton)) {
  32170. chart.resetZoomButton = resetZoomButton.destroy();
  32171. }
  32172. // Redraw
  32173. if (hasZoomed) {
  32174. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  32175. }
  32176. };
  32177. /**
  32178. * Pan the chart by dragging the mouse across the pane. This function is
  32179. * called on mouse move, and the distance to pan is computed from chartX
  32180. * compared to the first chartX position in the dragging operation.
  32181. *
  32182. * @private
  32183. * @function Highcharts.Chart#pan
  32184. * @param {Highcharts.PointerEventObject} e
  32185. * @param {string} panning
  32186. */
  32187. Chart.prototype.pan = function (e, panning) {
  32188. var chart = this,
  32189. hoverPoints = chart.hoverPoints,
  32190. panningOptions = (typeof panning === 'object' ?
  32191. panning :
  32192. {
  32193. enabled: panning,
  32194. type: 'x'
  32195. }),
  32196. chartOptions = chart.options.chart,
  32197. hasMapNavigation = chart.options.mapNavigation &&
  32198. chart.options.mapNavigation.enabled;
  32199. if (chartOptions && chartOptions.panning) {
  32200. chartOptions.panning = panningOptions;
  32201. }
  32202. var type = panningOptions.type;
  32203. var doRedraw;
  32204. fireEvent(this, 'pan', { originalEvent: e }, function () {
  32205. // remove active points for shared tooltip
  32206. if (hoverPoints) {
  32207. hoverPoints.forEach(function (point) {
  32208. point.setState();
  32209. });
  32210. }
  32211. var axes = chart.xAxis;
  32212. if (type === 'xy') {
  32213. axes = axes.concat(chart.yAxis);
  32214. }
  32215. else if (type === 'y') {
  32216. axes = chart.yAxis;
  32217. }
  32218. var nextMousePos = {};
  32219. axes.forEach(function (axis) {
  32220. if (!axis.options.panningEnabled || axis.options.isInternal) {
  32221. return;
  32222. }
  32223. var horiz = axis.horiz, mousePos = e[horiz ? 'chartX' : 'chartY'], mouseDown = horiz ? 'mouseDownX' : 'mouseDownY', startPos = chart[mouseDown], halfPointRange = axis.minPointOffset || 0, pointRangeDirection = (axis.reversed && !chart.inverted) ||
  32224. (!axis.reversed && chart.inverted) ?
  32225. -1 :
  32226. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  32227. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  32228. ((halfPointRange * pointRangeDirection) ||
  32229. (axis.isXAxis && axis.pointRangePadding) ||
  32230. 0), flipped = panMax < panMin, hasVerticalPanning = axis.hasVerticalPanning();
  32231. var newMin = flipped ? panMax : panMin,
  32232. newMax = flipped ? panMin : panMax,
  32233. panningState = axis.panningState,
  32234. spill;
  32235. // General calculations of panning state.
  32236. // This is related to using vertical panning. (#11315).
  32237. if (hasVerticalPanning &&
  32238. !axis.isXAxis && (!panningState || panningState.isDirty)) {
  32239. axis.series.forEach(function (series) {
  32240. var processedData = series.getProcessedData(true),
  32241. dataExtremes = series.getExtremes(processedData.yData,
  32242. true);
  32243. if (!panningState) {
  32244. panningState = {
  32245. startMin: Number.MAX_VALUE,
  32246. startMax: -Number.MAX_VALUE
  32247. };
  32248. }
  32249. if (isNumber(dataExtremes.dataMin) &&
  32250. isNumber(dataExtremes.dataMax)) {
  32251. panningState.startMin = Math.min(pick(series.options.threshold, Infinity), dataExtremes.dataMin, panningState.startMin);
  32252. panningState.startMax = Math.max(pick(series.options.threshold, -Infinity), dataExtremes.dataMax, panningState.startMax);
  32253. }
  32254. });
  32255. }
  32256. var paddedMin = Math.min(pick(panningState && panningState.startMin,
  32257. extremes.dataMin),
  32258. halfPointRange ?
  32259. extremes.min :
  32260. axis.toValue(axis.toPixels(extremes.min) -
  32261. axis.minPixelPadding));
  32262. var paddedMax = Math.max(pick(panningState && panningState.startMax,
  32263. extremes.dataMax),
  32264. halfPointRange ?
  32265. extremes.max :
  32266. axis.toValue(axis.toPixels(extremes.max) +
  32267. axis.minPixelPadding));
  32268. axis.panningState = panningState;
  32269. // It is not necessary to calculate extremes on ordinal axis,
  32270. // because they are already calculated, so we don't want to
  32271. // override them.
  32272. if (!axis.isOrdinal) {
  32273. // If the new range spills over, either to the min or max,
  32274. // adjust the new range.
  32275. spill = paddedMin - newMin;
  32276. if (spill > 0) {
  32277. newMax += spill;
  32278. newMin = paddedMin;
  32279. }
  32280. spill = newMax - paddedMax;
  32281. if (spill > 0) {
  32282. newMax = paddedMax;
  32283. newMin -= spill;
  32284. }
  32285. // Set new extremes if they are actually new
  32286. if (axis.series.length &&
  32287. newMin !== extremes.min &&
  32288. newMax !== extremes.max &&
  32289. newMin >= paddedMin &&
  32290. newMax <= paddedMax) {
  32291. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  32292. if (!chart.resetZoomButton &&
  32293. !hasMapNavigation &&
  32294. // Show reset zoom button only when both newMin and
  32295. // newMax values are between padded axis range.
  32296. newMin !== paddedMin &&
  32297. newMax !== paddedMax &&
  32298. type.match('y')) {
  32299. chart.showResetZoom();
  32300. axis.displayBtn = false;
  32301. }
  32302. doRedraw = true;
  32303. }
  32304. // set new reference for next run:
  32305. nextMousePos[mouseDown] = mousePos;
  32306. }
  32307. });
  32308. objectEach(nextMousePos, function (pos, down) {
  32309. chart[down] = pos;
  32310. });
  32311. if (doRedraw) {
  32312. chart.redraw(false);
  32313. }
  32314. css(chart.container, { cursor: 'move' });
  32315. });
  32316. };
  32317. return Chart;
  32318. }());
  32319. extend(Chart.prototype, {
  32320. // Hook for adding callbacks in modules
  32321. callbacks: [],
  32322. /**
  32323. * These collections (arrays) implement `Chart.addSomethig` method used in
  32324. * chart.update() to create new object in the collection. Equivalent for
  32325. * deleting is resolved by simple `Somethig.remove()`.
  32326. *
  32327. * Note: We need to define these references after initializers are bound to
  32328. * chart's prototype.
  32329. */
  32330. collectionsWithInit: {
  32331. // collectionName: [ initializingMethod, [extraArguments] ]
  32332. xAxis: [Chart.prototype.addAxis, [true]],
  32333. yAxis: [Chart.prototype.addAxis, [false]],
  32334. series: [Chart.prototype.addSeries]
  32335. },
  32336. /**
  32337. * These collections (arrays) implement update() methods with support for
  32338. * one-to-one option.
  32339. */
  32340. collectionsWithUpdate: [
  32341. 'xAxis',
  32342. 'yAxis',
  32343. 'zAxis',
  32344. 'series'
  32345. ],
  32346. /**
  32347. * These properties cause isDirtyBox to be set to true when updating. Can be
  32348. * extended from plugins.
  32349. */
  32350. propsRequireDirtyBox: [
  32351. 'backgroundColor',
  32352. 'borderColor',
  32353. 'borderWidth',
  32354. 'borderRadius',
  32355. 'plotBackgroundColor',
  32356. 'plotBackgroundImage',
  32357. 'plotBorderColor',
  32358. 'plotBorderWidth',
  32359. 'plotShadow',
  32360. 'shadow'
  32361. ],
  32362. /**
  32363. * These properties require a full reflow of chart elements, best
  32364. * implemented through running `Chart.setSize` internally (#8190).
  32365. * @type {Array}
  32366. */
  32367. propsRequireReflow: [
  32368. 'margin',
  32369. 'marginTop',
  32370. 'marginRight',
  32371. 'marginBottom',
  32372. 'marginLeft',
  32373. 'spacing',
  32374. 'spacingTop',
  32375. 'spacingRight',
  32376. 'spacingBottom',
  32377. 'spacingLeft'
  32378. ],
  32379. /**
  32380. * These properties cause all series to be updated when updating. Can be
  32381. * extended from plugins.
  32382. */
  32383. propsRequireUpdateSeries: [
  32384. 'chart.inverted',
  32385. 'chart.polar',
  32386. 'chart.ignoreHiddenSeries',
  32387. 'chart.type',
  32388. 'colors',
  32389. 'plotOptions',
  32390. 'time',
  32391. 'tooltip'
  32392. ]
  32393. });
  32394. /* *
  32395. *
  32396. * Export
  32397. *
  32398. * */
  32399. /* *
  32400. *
  32401. * API Declarations
  32402. *
  32403. * */
  32404. /**
  32405. * Callback for chart constructors.
  32406. *
  32407. * @callback Highcharts.ChartCallbackFunction
  32408. *
  32409. * @param {Highcharts.Chart} chart
  32410. * Created chart.
  32411. */
  32412. /**
  32413. * Format a number and return a string based on input settings.
  32414. *
  32415. * @callback Highcharts.NumberFormatterCallbackFunction
  32416. *
  32417. * @param {number} number
  32418. * The input number to format.
  32419. *
  32420. * @param {number} decimals
  32421. * The amount of decimals. A value of -1 preserves the amount in the
  32422. * input number.
  32423. *
  32424. * @param {string} [decimalPoint]
  32425. * The decimal point, defaults to the one given in the lang options, or
  32426. * a dot.
  32427. *
  32428. * @param {string} [thousandsSep]
  32429. * The thousands separator, defaults to the one given in the lang
  32430. * options, or a space character.
  32431. *
  32432. * @return {string} The formatted number.
  32433. */
  32434. /**
  32435. * The chart title. The title has an `update` method that allows modifying the
  32436. * options directly or indirectly via `chart.update`.
  32437. *
  32438. * @interface Highcharts.TitleObject
  32439. * @extends Highcharts.SVGElement
  32440. */ /**
  32441. * Modify options for the title.
  32442. *
  32443. * @function Highcharts.TitleObject#update
  32444. *
  32445. * @param {Highcharts.TitleOptions} titleOptions
  32446. * Options to modify.
  32447. *
  32448. * @param {boolean} [redraw=true]
  32449. * Whether to redraw the chart after the title is altered. If doing more
  32450. * operations on the chart, it is a good idea to set redraw to false and
  32451. * call {@link Chart#redraw} after.
  32452. */
  32453. /**
  32454. * The chart subtitle. The subtitle has an `update` method that
  32455. * allows modifying the options directly or indirectly via
  32456. * `chart.update`.
  32457. *
  32458. * @interface Highcharts.SubtitleObject
  32459. * @extends Highcharts.SVGElement
  32460. */ /**
  32461. * Modify options for the subtitle.
  32462. *
  32463. * @function Highcharts.SubtitleObject#update
  32464. *
  32465. * @param {Highcharts.SubtitleOptions} subtitleOptions
  32466. * Options to modify.
  32467. *
  32468. * @param {boolean} [redraw=true]
  32469. * Whether to redraw the chart after the subtitle is altered. If doing
  32470. * more operations on the chart, it is a good idea to set redraw to false
  32471. * and call {@link Chart#redraw} after.
  32472. */
  32473. /**
  32474. * The chart caption. The caption has an `update` method that
  32475. * allows modifying the options directly or indirectly via
  32476. * `chart.update`.
  32477. *
  32478. * @interface Highcharts.CaptionObject
  32479. * @extends Highcharts.SVGElement
  32480. */ /**
  32481. * Modify options for the caption.
  32482. *
  32483. * @function Highcharts.CaptionObject#update
  32484. *
  32485. * @param {Highcharts.CaptionOptions} captionOptions
  32486. * Options to modify.
  32487. *
  32488. * @param {boolean} [redraw=true]
  32489. * Whether to redraw the chart after the caption is altered. If doing
  32490. * more operations on the chart, it is a good idea to set redraw to false
  32491. * and call {@link Chart#redraw} after.
  32492. */
  32493. /**
  32494. * @interface Highcharts.ChartIsInsideOptionsObject
  32495. */ /**
  32496. * @name Highcharts.ChartIsInsideOptionsObject#ignoreX
  32497. * @type {boolean|undefined}
  32498. */ /**
  32499. * @name Highcharts.ChartIsInsideOptionsObject#ignoreY
  32500. * @type {boolean|undefined}
  32501. */ /**
  32502. * @name Highcharts.ChartIsInsideOptionsObject#inverted
  32503. * @type {boolean|undefined}
  32504. */ /**
  32505. * @name Highcharts.ChartIsInsideOptionsObject#paneCoordinates
  32506. * @type {boolean|undefined}
  32507. */ /**
  32508. * @name Highcharts.ChartIsInsideOptionsObject#series
  32509. * @type {Highcharts.Series|undefined}
  32510. */ /**
  32511. * @name Highcharts.ChartIsInsideOptionsObject#visiblePlotOnly
  32512. * @type {boolean|undefined}
  32513. */
  32514. ''; // include doclets above in transpilat
  32515. return Chart;
  32516. });
  32517. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32518. /* *
  32519. *
  32520. * (c) 2010-2021 Torstein Honsi
  32521. *
  32522. * License: www.highcharts.com/license
  32523. *
  32524. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32525. *
  32526. * */
  32527. var merge = U.merge,
  32528. pick = U.pick;
  32529. /* eslint-disable valid-jsdoc */
  32530. /**
  32531. * Legend symbol mixin.
  32532. *
  32533. * @private
  32534. * @mixin Highcharts.LegendSymbolMixin
  32535. */
  32536. var LegendSymbolMixin = H.LegendSymbolMixin = {
  32537. /**
  32538. * Get the series' symbol in the legend
  32539. *
  32540. * @private
  32541. * @function Highcharts.LegendSymbolMixin.drawRectangle
  32542. *
  32543. * @param {Highcharts.Legend} legend
  32544. * The legend object
  32545. *
  32546. * @param {Highcharts.Point|Highcharts.Series} item
  32547. * The series (this) or point
  32548. */
  32549. drawRectangle: function (legend,
  32550. item) {
  32551. var options = legend.options,
  32552. symbolHeight = legend.symbolHeight,
  32553. square = options.squareSymbol,
  32554. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  32555. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  32556. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  32557. .addClass('highcharts-point')
  32558. .attr({
  32559. zIndex: 3
  32560. }).add(item.legendGroup);
  32561. },
  32562. /**
  32563. * Get the series' symbol in the legend. This method should be overridable
  32564. * to create custom symbols through
  32565. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  32566. *
  32567. * @private
  32568. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  32569. *
  32570. * @param {Highcharts.Legend} legend
  32571. * The legend object.
  32572. */
  32573. drawLineMarker: function (legend) {
  32574. var options = this.options,
  32575. markerOptions = options.marker,
  32576. radius,
  32577. legendSymbol,
  32578. symbolWidth = legend.symbolWidth,
  32579. symbolHeight = legend.symbolHeight,
  32580. generalRadius = symbolHeight / 2,
  32581. renderer = this.chart.renderer,
  32582. legendItemGroup = this.legendGroup,
  32583. verticalCenter = legend.baseline -
  32584. Math.round(legend.fontMetrics.b * 0.3),
  32585. attr = {};
  32586. // Draw the line
  32587. if (!this.chart.styledMode) {
  32588. attr = {
  32589. 'stroke-width': options.lineWidth || 0
  32590. };
  32591. if (options.dashStyle) {
  32592. attr.dashstyle = options.dashStyle;
  32593. }
  32594. }
  32595. this.legendLine = renderer
  32596. .path([
  32597. ['M', 0, verticalCenter],
  32598. ['L', symbolWidth, verticalCenter]
  32599. ])
  32600. .addClass('highcharts-graph')
  32601. .attr(attr)
  32602. .add(legendItemGroup);
  32603. // Draw the marker
  32604. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  32605. // Do not allow the marker to be larger than the symbolHeight
  32606. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  32607. // Restrict symbol markers size
  32608. if (this.symbol.indexOf('url') === 0) {
  32609. markerOptions = merge(markerOptions, {
  32610. width: symbolHeight,
  32611. height: symbolHeight
  32612. });
  32613. radius = 0;
  32614. }
  32615. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  32616. .addClass('highcharts-point')
  32617. .add(legendItemGroup);
  32618. legendSymbol.isMarker = true;
  32619. }
  32620. }
  32621. };
  32622. return LegendSymbolMixin;
  32623. });
  32624. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (A, F, H, LegendSymbolMixin, D, palette, Point, SeriesRegistry, SVGElement, U) {
  32625. /* *
  32626. *
  32627. * (c) 2010-2021 Torstein Honsi
  32628. *
  32629. * License: www.highcharts.com/license
  32630. *
  32631. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32632. *
  32633. * */
  32634. var animObject = A.animObject,
  32635. setAnimation = A.setAnimation;
  32636. var registerEventOptions = F.registerEventOptions;
  32637. var hasTouch = H.hasTouch,
  32638. svg = H.svg,
  32639. win = H.win;
  32640. var defaultOptions = D.defaultOptions;
  32641. var seriesTypes = SeriesRegistry.seriesTypes;
  32642. var addEvent = U.addEvent,
  32643. arrayMax = U.arrayMax,
  32644. arrayMin = U.arrayMin,
  32645. clamp = U.clamp,
  32646. cleanRecursively = U.cleanRecursively,
  32647. correctFloat = U.correctFloat,
  32648. defined = U.defined,
  32649. erase = U.erase,
  32650. error = U.error,
  32651. extend = U.extend,
  32652. find = U.find,
  32653. fireEvent = U.fireEvent,
  32654. getNestedProperty = U.getNestedProperty,
  32655. isArray = U.isArray,
  32656. isNumber = U.isNumber,
  32657. isString = U.isString,
  32658. merge = U.merge,
  32659. objectEach = U.objectEach,
  32660. pick = U.pick,
  32661. removeEvent = U.removeEvent,
  32662. splat = U.splat,
  32663. syncTimeout = U.syncTimeout;
  32664. /* *
  32665. *
  32666. * Class
  32667. *
  32668. * */
  32669. /**
  32670. * This is the base series prototype that all other series types inherit from.
  32671. * A new series is initialized either through the
  32672. * [series](https://api.highcharts.com/highcharts/series)
  32673. * option structure, or after the chart is initialized, through
  32674. * {@link Highcharts.Chart#addSeries}.
  32675. *
  32676. * The object can be accessed in a number of ways. All series and point event
  32677. * handlers give a reference to the `series` object. The chart object has a
  32678. * {@link Highcharts.Chart#series|series} property that is a collection of all
  32679. * the chart's series. The point objects and axis objects also have the same
  32680. * reference.
  32681. *
  32682. * Another way to reference the series programmatically is by `id`. Add an id
  32683. * in the series configuration options, and get the series object by
  32684. * {@link Highcharts.Chart#get}.
  32685. *
  32686. * Configuration options for the series are given in three levels. Options for
  32687. * all series in a chart are given in the
  32688. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  32689. * object. Then options for all series of a specific type
  32690. * are given in the plotOptions of that type, for example `plotOptions.line`.
  32691. * Next, options for one single series are given in the series array, or as
  32692. * arguments to `chart.addSeries`.
  32693. *
  32694. * The data in the series is stored in various arrays.
  32695. *
  32696. * - First, `series.options.data` contains all the original config options for
  32697. * each point whether added by options or methods like `series.addPoint`.
  32698. *
  32699. * - Next, `series.data` contains those values converted to points, but in case
  32700. * the series data length exceeds the `cropThreshold`, or if the data is
  32701. * grouped, `series.data` doesn't contain all the points. It only contains the
  32702. * points that have been created on demand.
  32703. *
  32704. * - Then there's `series.points` that contains all currently visible point
  32705. * objects. In case of cropping, the cropped-away points are not part of this
  32706. * array. The `series.points` array starts at `series.cropStart` compared to
  32707. * `series.data` and `series.options.data`. If however the series data is
  32708. * grouped, these can't be correlated one to one.
  32709. *
  32710. * - `series.xData` and `series.processedXData` contain clean x values,
  32711. * equivalent to `series.data` and `series.points`.
  32712. *
  32713. * - `series.yData` and `series.processedYData` contain clean y values,
  32714. * equivalent to `series.data` and `series.points`.
  32715. *
  32716. * @class
  32717. * @name Highcharts.Series
  32718. *
  32719. * @param {Highcharts.Chart} chart
  32720. * The chart instance.
  32721. *
  32722. * @param {Highcharts.SeriesOptionsType|object} options
  32723. * The series options.
  32724. */
  32725. var Series = /** @class */ (function () {
  32726. function Series() {
  32727. /* *
  32728. *
  32729. * Static Functions
  32730. *
  32731. * */
  32732. this._i = void 0;
  32733. this.chart = void 0;
  32734. this.data = void 0;
  32735. this.eventOptions = void 0;
  32736. this.eventsToUnbind = void 0;
  32737. this.index = void 0;
  32738. this.linkedSeries = void 0;
  32739. this.options = void 0;
  32740. this.points = void 0;
  32741. this.processedXData = void 0;
  32742. this.processedYData = void 0;
  32743. this.tooltipOptions = void 0;
  32744. this.userOptions = void 0;
  32745. this.xAxis = void 0;
  32746. this.yAxis = void 0;
  32747. this.zones = void 0;
  32748. /** eslint-enable valid-jsdoc */
  32749. }
  32750. /* *
  32751. *
  32752. * Functions
  32753. *
  32754. * */
  32755. /* eslint-disable valid-jsdoc */
  32756. Series.prototype.init = function (chart, userOptions) {
  32757. fireEvent(this, 'init', { options: userOptions });
  32758. var series = this,
  32759. chartSeries = chart.series;
  32760. // The 'eventsToUnbind' property moved from prototype into the
  32761. // Series init to avoid reference to the same array between
  32762. // the different series and charts. #12959, #13937
  32763. this.eventsToUnbind = [];
  32764. /**
  32765. * Read only. The chart that the series belongs to.
  32766. *
  32767. * @name Highcharts.Series#chart
  32768. * @type {Highcharts.Chart}
  32769. */
  32770. series.chart = chart;
  32771. /**
  32772. * Read only. The series' type, like "line", "area", "column" etc.
  32773. * The type in the series options anc can be altered using
  32774. * {@link Series#update}.
  32775. *
  32776. * @name Highcharts.Series#type
  32777. * @type {string}
  32778. */
  32779. /**
  32780. * Read only. The series' current options. To update, use
  32781. * {@link Series#update}.
  32782. *
  32783. * @name Highcharts.Series#options
  32784. * @type {Highcharts.SeriesOptionsType}
  32785. */
  32786. series.options = series.setOptions(userOptions);
  32787. var options = series.options;
  32788. series.linkedSeries = [];
  32789. // bind the axes
  32790. series.bindAxes();
  32791. extend(series, {
  32792. /**
  32793. * The series name as given in the options. Defaults to
  32794. * "Series {n}".
  32795. *
  32796. * @name Highcharts.Series#name
  32797. * @type {string}
  32798. */
  32799. name: options.name,
  32800. state: '',
  32801. /**
  32802. * Read only. The series' visibility state as set by {@link
  32803. * Series#show}, {@link Series#hide}, or in the initial
  32804. * configuration.
  32805. *
  32806. * @name Highcharts.Series#visible
  32807. * @type {boolean}
  32808. */
  32809. visible: options.visible !== false,
  32810. /**
  32811. * Read only. The series' selected state as set by {@link
  32812. * Highcharts.Series#select}.
  32813. *
  32814. * @name Highcharts.Series#selected
  32815. * @type {boolean}
  32816. */
  32817. selected: options.selected === true // false by default
  32818. });
  32819. registerEventOptions(this, options);
  32820. var events = options.events;
  32821. if ((events && events.click) ||
  32822. (options.point &&
  32823. options.point.events &&
  32824. options.point.events.click) ||
  32825. options.allowPointSelect) {
  32826. chart.runTrackerClick = true;
  32827. }
  32828. series.getColor();
  32829. series.getSymbol();
  32830. // Initialize the parallel data arrays
  32831. series.parallelArrays.forEach(function (key) {
  32832. if (!series[key + 'Data']) {
  32833. series[key + 'Data'] = [];
  32834. }
  32835. });
  32836. // Mark cartesian
  32837. if (series.isCartesian) {
  32838. chart.hasCartesianSeries = true;
  32839. }
  32840. // Get the index and register the series in the chart. The index is
  32841. // one more than the current latest series index (#5960).
  32842. var lastSeries;
  32843. if (chartSeries.length) {
  32844. lastSeries = chartSeries[chartSeries.length - 1];
  32845. }
  32846. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32847. series.opacity = series.options.opacity;
  32848. // Insert the series and re-order all series above the insertion
  32849. // point.
  32850. chart.orderSeries(this.insert(chartSeries));
  32851. // Set options for series with sorting and set data later.
  32852. if (options.dataSorting && options.dataSorting.enabled) {
  32853. series.setDataSortingOptions();
  32854. }
  32855. else if (!series.points && !series.data) {
  32856. series.setData(options.data, false);
  32857. }
  32858. fireEvent(this, 'afterInit');
  32859. };
  32860. /**
  32861. * Check whether the series item is itself or inherits from a certain
  32862. * series type.
  32863. *
  32864. * @function Highcharts.Series#is
  32865. * @param {string} type The type of series to check for, can be either
  32866. * featured or custom series types. For example `column`, `pie`,
  32867. * `ohlc` etc.
  32868. *
  32869. * @return {boolean}
  32870. * True if this item is or inherits from the given type.
  32871. */
  32872. Series.prototype.is = function (type) {
  32873. return seriesTypes[type] && this instanceof seriesTypes[type];
  32874. };
  32875. /**
  32876. * Insert the series in a collection with other series, either the chart
  32877. * series or yAxis series, in the correct order according to the index
  32878. * option. Used internally when adding series.
  32879. *
  32880. * @private
  32881. * @function Highcharts.Series#insert
  32882. * @param {Array<Highcharts.Series>} collection
  32883. * A collection of series, like `chart.series` or `xAxis.series`.
  32884. * @return {number}
  32885. * The index of the series in the collection.
  32886. */
  32887. Series.prototype.insert = function (collection) {
  32888. var indexOption = this.options.index,
  32889. i;
  32890. // Insert by index option
  32891. if (isNumber(indexOption)) {
  32892. i = collection.length;
  32893. while (i--) {
  32894. // Loop down until the interted element has higher index
  32895. if (indexOption >=
  32896. pick(collection[i].options.index, collection[i]._i)) {
  32897. collection.splice(i + 1, 0, this);
  32898. break;
  32899. }
  32900. }
  32901. if (i === -1) {
  32902. collection.unshift(this);
  32903. }
  32904. i = i + 1;
  32905. // Or just push it to the end
  32906. }
  32907. else {
  32908. collection.push(this);
  32909. }
  32910. return pick(i, collection.length - 1);
  32911. };
  32912. /**
  32913. * Set the xAxis and yAxis properties of cartesian series, and register
  32914. * the series in the `axis.series` array.
  32915. *
  32916. * @private
  32917. * @function Highcharts.Series#bindAxes
  32918. */
  32919. Series.prototype.bindAxes = function () {
  32920. var series = this,
  32921. seriesOptions = series.options,
  32922. chart = series.chart,
  32923. axisOptions;
  32924. fireEvent(this, 'bindAxes', null, function () {
  32925. // repeat for xAxis and yAxis
  32926. (series.axisTypes || []).forEach(function (AXIS) {
  32927. var index = 0;
  32928. // loop through the chart's axis objects
  32929. chart[AXIS].forEach(function (axis) {
  32930. axisOptions = axis.options;
  32931. // apply if the series xAxis or yAxis option mathches
  32932. // the number of the axis, or if undefined, use the
  32933. // first axis
  32934. if ((seriesOptions[AXIS] === index &&
  32935. !axisOptions.isInternal) ||
  32936. (typeof seriesOptions[AXIS] !==
  32937. 'undefined' &&
  32938. seriesOptions[AXIS] === axisOptions.id) ||
  32939. (typeof seriesOptions[AXIS] ===
  32940. 'undefined' &&
  32941. axisOptions.index === 0)) {
  32942. // register this series in the axis.series lookup
  32943. series.insert(axis.series);
  32944. // set this series.xAxis or series.yAxis reference
  32945. /**
  32946. * Read only. The unique xAxis object associated
  32947. * with the series.
  32948. *
  32949. * @name Highcharts.Series#xAxis
  32950. * @type {Highcharts.Axis}
  32951. */
  32952. /**
  32953. * Read only. The unique yAxis object associated
  32954. * with the series.
  32955. *
  32956. * @name Highcharts.Series#yAxis
  32957. * @type {Highcharts.Axis}
  32958. */
  32959. series[AXIS] = axis;
  32960. // mark dirty for redraw
  32961. axis.isDirty = true;
  32962. }
  32963. if (!axisOptions.isInternal) {
  32964. index++;
  32965. }
  32966. });
  32967. // The series needs an X and an Y axis
  32968. if (!series[AXIS] &&
  32969. series.optionalAxis !== AXIS) {
  32970. error(18, true, chart);
  32971. }
  32972. });
  32973. });
  32974. fireEvent(this, 'afterBindAxes');
  32975. };
  32976. /**
  32977. * For simple series types like line and column, the data values are
  32978. * held in arrays like xData and yData for quick lookup to find extremes
  32979. * and more. For multidimensional series like bubble and map, this can
  32980. * be extended with arrays like zData and valueData by adding to the
  32981. * `series.parallelArrays` array.
  32982. *
  32983. * @private
  32984. * @function Highcharts.Series#updateParallelArrays
  32985. */
  32986. Series.prototype.updateParallelArrays = function (point, i) {
  32987. var series = point.series,
  32988. args = arguments,
  32989. fn = isNumber(i) ?
  32990. // Insert the value in the given position
  32991. function (key) {
  32992. var val = key === 'y' && series.toYData ?
  32993. series.toYData(point) :
  32994. point[key];
  32995. series[key + 'Data'][i] = val;
  32996. } :
  32997. // Apply the method specified in i with the following
  32998. // arguments as arguments
  32999. function (key) {
  33000. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  33001. };
  33002. series.parallelArrays.forEach(fn);
  33003. };
  33004. /**
  33005. * Define hasData functions for series. These return true if there
  33006. * are data points on this series within the plot area.
  33007. *
  33008. * @private
  33009. * @function Highcharts.Series#hasData
  33010. * @return {boolean}
  33011. */
  33012. Series.prototype.hasData = function () {
  33013. return ((this.visible &&
  33014. typeof this.dataMax !== 'undefined' &&
  33015. typeof this.dataMin !== 'undefined') || ( // #3703
  33016. this.visible &&
  33017. this.yData &&
  33018. this.yData.length > 0) // #9758
  33019. );
  33020. };
  33021. /**
  33022. * Return an auto incremented x value based on the pointStart and
  33023. * pointInterval options. This is only used if an x value is not given
  33024. * for the point that calls autoIncrement.
  33025. *
  33026. * @private
  33027. * @function Highcharts.Series#autoIncrement
  33028. * @return {number}
  33029. */
  33030. Series.prototype.autoIncrement = function () {
  33031. var options = this.options,
  33032. xIncrement = this.xIncrement,
  33033. date,
  33034. pointInterval,
  33035. pointIntervalUnit = options.pointIntervalUnit,
  33036. time = this.chart.time;
  33037. xIncrement = pick(xIncrement, options.pointStart, 0);
  33038. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  33039. // Added code for pointInterval strings
  33040. if (pointIntervalUnit) {
  33041. date = new time.Date(xIncrement);
  33042. if (pointIntervalUnit === 'day') {
  33043. time.set('Date', date, time.get('Date', date) + pointInterval);
  33044. }
  33045. else if (pointIntervalUnit === 'month') {
  33046. time.set('Month', date, time.get('Month', date) + pointInterval);
  33047. }
  33048. else if (pointIntervalUnit === 'year') {
  33049. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  33050. }
  33051. pointInterval = date.getTime() - xIncrement;
  33052. }
  33053. this.xIncrement = xIncrement + pointInterval;
  33054. return xIncrement;
  33055. };
  33056. /**
  33057. * Internal function to set properties for series if data sorting is
  33058. * enabled.
  33059. *
  33060. * @private
  33061. * @function Highcharts.Series#setDataSortingOptions
  33062. */
  33063. Series.prototype.setDataSortingOptions = function () {
  33064. var options = this.options;
  33065. extend(this, {
  33066. requireSorting: false,
  33067. sorted: false,
  33068. enabledDataSorting: true,
  33069. allowDG: false
  33070. });
  33071. // To allow unsorted data for column series.
  33072. if (!defined(options.pointRange)) {
  33073. options.pointRange = 1;
  33074. }
  33075. };
  33076. /**
  33077. * Set the series options by merging from the options tree. Called
  33078. * internally on initializing and updating series. This function will
  33079. * not redraw the series. For API usage, use {@link Series#update}.
  33080. * @private
  33081. * @function Highcharts.Series#setOptions
  33082. *
  33083. * @param {Highcharts.SeriesOptionsType} itemOptions
  33084. * The series options.
  33085. *
  33086. * @return {Highcharts.SeriesOptionsType}
  33087. *
  33088. * @fires Highcharts.Series#event:afterSetOptions
  33089. */
  33090. Series.prototype.setOptions = function (itemOptions) {
  33091. var chart = this.chart,
  33092. chartOptions = chart.options,
  33093. plotOptions = chartOptions.plotOptions,
  33094. userOptions = chart.userOptions || {},
  33095. seriesUserOptions = merge(itemOptions),
  33096. options,
  33097. zones,
  33098. zone,
  33099. styledMode = chart.styledMode,
  33100. e = {
  33101. plotOptions: plotOptions,
  33102. userOptions: seriesUserOptions
  33103. };
  33104. fireEvent(this, 'setOptions', e);
  33105. // These may be modified by the event
  33106. var typeOptions = e.plotOptions[this.type],
  33107. userPlotOptions = (userOptions.plotOptions || {});
  33108. // use copy to prevent undetected changes (#9762)
  33109. /**
  33110. * Contains series options by the user without defaults.
  33111. * @name Highcharts.Series#userOptions
  33112. * @type {Highcharts.SeriesOptionsType}
  33113. */
  33114. this.userOptions = e.userOptions;
  33115. options = merge(typeOptions, plotOptions.series,
  33116. // #3881, chart instance plotOptions[type] should trump
  33117. // plotOptions.series
  33118. userOptions.plotOptions &&
  33119. userOptions.plotOptions[this.type], seriesUserOptions);
  33120. // The tooltip options are merged between global and series specific
  33121. // options. Importance order asscendingly:
  33122. // globals: (1)tooltip, (2)plotOptions.series,
  33123. // (3)plotOptions[this.type]
  33124. // init userOptions with possible later updates: 4-6 like 1-3 and
  33125. // (7)this series options
  33126. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  33127. defaultOptions.plotOptions.series &&
  33128. defaultOptions.plotOptions.series.tooltip, // 2
  33129. defaultOptions.plotOptions[this.type].tooltip, // 3
  33130. chartOptions.tooltip.userOptions, // 4
  33131. plotOptions.series &&
  33132. plotOptions.series.tooltip, // 5
  33133. plotOptions[this.type].tooltip, // 6
  33134. seriesUserOptions.tooltip // 7
  33135. );
  33136. // When shared tooltip, stickyTracking is true by default,
  33137. // unless user says otherwise.
  33138. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  33139. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  33140. true :
  33141. options.stickyTracking));
  33142. // Delete marker object if not allowed (#1125)
  33143. if (typeOptions.marker === null) {
  33144. delete options.marker;
  33145. }
  33146. // Handle color zones
  33147. this.zoneAxis = options.zoneAxis;
  33148. zones = this.zones = (options.zones || []).slice();
  33149. if ((options.negativeColor || options.negativeFillColor) &&
  33150. !options.zones) {
  33151. zone = {
  33152. value: options[this.zoneAxis + 'Threshold'] ||
  33153. options.threshold ||
  33154. 0,
  33155. className: 'highcharts-negative'
  33156. };
  33157. if (!styledMode) {
  33158. zone.color = options.negativeColor;
  33159. zone.fillColor = options.negativeFillColor;
  33160. }
  33161. zones.push(zone);
  33162. }
  33163. if (zones.length) { // Push one extra zone for the rest
  33164. if (defined(zones[zones.length - 1].value)) {
  33165. zones.push(styledMode ? {} : {
  33166. color: this.color,
  33167. fillColor: this.fillColor
  33168. });
  33169. }
  33170. }
  33171. fireEvent(this, 'afterSetOptions', { options: options });
  33172. return options;
  33173. };
  33174. /**
  33175. * Return series name in "Series {Number}" format or the one defined by
  33176. * a user. This method can be simply overridden as series name format
  33177. * can vary (e.g. technical indicators).
  33178. *
  33179. * @function Highcharts.Series#getName
  33180. *
  33181. * @return {string}
  33182. * The series name.
  33183. */
  33184. Series.prototype.getName = function () {
  33185. // #4119
  33186. return pick(this.options.name, 'Series ' + (this.index + 1));
  33187. };
  33188. /**
  33189. * @private
  33190. * @function Highcharts.Series#getCyclic
  33191. */
  33192. Series.prototype.getCyclic = function (prop, value, defaults) {
  33193. var i, chart = this.chart, userOptions = this.userOptions, indexName = prop + 'Index', counterName = prop + 'Counter', len = defaults ? defaults.length : pick(chart.options.chart[prop + 'Count'], chart[prop + 'Count']), setting;
  33194. if (!value) {
  33195. // Pick up either the colorIndex option, or the _colorIndex
  33196. // after Series.update()
  33197. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  33198. if (defined(setting)) { // after Series.update()
  33199. i = setting;
  33200. }
  33201. else {
  33202. // #6138
  33203. if (!chart.series.length) {
  33204. chart[counterName] = 0;
  33205. }
  33206. userOptions['_' + indexName] = i =
  33207. chart[counterName] % len;
  33208. chart[counterName] += 1;
  33209. }
  33210. if (defaults) {
  33211. value = defaults[i];
  33212. }
  33213. }
  33214. // Set the colorIndex
  33215. if (typeof i !== 'undefined') {
  33216. this[indexName] = i;
  33217. }
  33218. this[prop] = value;
  33219. };
  33220. /**
  33221. * Get the series' color based on either the options or pulled from
  33222. * global options.
  33223. *
  33224. * @private
  33225. * @function Highcharts.Series#getColor
  33226. */
  33227. Series.prototype.getColor = function () {
  33228. if (this.chart.styledMode) {
  33229. this.getCyclic('color');
  33230. }
  33231. else if (this.options.colorByPoint) {
  33232. this.color = palette.neutralColor20;
  33233. }
  33234. else {
  33235. this.getCyclic('color', this.options.color ||
  33236. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  33237. }
  33238. };
  33239. /**
  33240. * Get all points' instances created for this series.
  33241. *
  33242. * @private
  33243. * @function Highcharts.Series#getPointsCollection
  33244. * @return {Array<Highcharts.Point>}
  33245. */
  33246. Series.prototype.getPointsCollection = function () {
  33247. return (this.hasGroupedData ? this.points : this.data) || [];
  33248. };
  33249. /**
  33250. * Get the series' symbol based on either the options or pulled from
  33251. * global options.
  33252. *
  33253. * @private
  33254. * @function Highcharts.Series#getSymbol
  33255. * @return {void}
  33256. */
  33257. Series.prototype.getSymbol = function () {
  33258. var seriesMarkerOption = this.options.marker;
  33259. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  33260. };
  33261. /**
  33262. * Finds the index of an existing point that matches the given point
  33263. * options.
  33264. *
  33265. * @private
  33266. * @function Highcharts.Series#findPointIndex
  33267. * @param {Highcharts.PointOptionsObject} optionsObject
  33268. * The options of the point.
  33269. * @param {number} fromIndex
  33270. * The index to start searching from, used for optimizing
  33271. * series with required sorting.
  33272. * @returns {number|undefined}
  33273. * Returns the index of a matching point, or undefined if no
  33274. * match is found.
  33275. */
  33276. Series.prototype.findPointIndex = function (optionsObject, fromIndex) {
  33277. var id = optionsObject.id,
  33278. x = optionsObject.x,
  33279. oldData = this.points,
  33280. matchingPoint,
  33281. matchedById,
  33282. pointIndex,
  33283. matchKey,
  33284. dataSorting = this.options.dataSorting;
  33285. if (id) {
  33286. matchingPoint = this.chart.get(id);
  33287. }
  33288. else if (this.linkedParent || this.enabledDataSorting) {
  33289. matchKey = (dataSorting && dataSorting.matchByName) ?
  33290. 'name' : 'index';
  33291. matchingPoint = find(oldData, function (oldPoint) {
  33292. return !oldPoint.touched && oldPoint[matchKey] ===
  33293. optionsObject[matchKey];
  33294. });
  33295. // Add unmatched point as a new point
  33296. if (!matchingPoint) {
  33297. return void 0;
  33298. }
  33299. }
  33300. if (matchingPoint) {
  33301. pointIndex = matchingPoint && matchingPoint.index;
  33302. if (typeof pointIndex !== 'undefined') {
  33303. matchedById = true;
  33304. }
  33305. }
  33306. // Search for the same X in the existing data set
  33307. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  33308. pointIndex = this.xData.indexOf(x, fromIndex);
  33309. }
  33310. // Reduce pointIndex if data is cropped
  33311. if (pointIndex !== -1 &&
  33312. typeof pointIndex !== 'undefined' &&
  33313. this.cropped) {
  33314. pointIndex = (pointIndex >= this.cropStart) ?
  33315. pointIndex - this.cropStart : pointIndex;
  33316. }
  33317. if (!matchedById &&
  33318. oldData[pointIndex] && oldData[pointIndex].touched) {
  33319. pointIndex = void 0;
  33320. }
  33321. return pointIndex;
  33322. };
  33323. /**
  33324. * Internal function called from setData. If the point count is the same
  33325. * as is was, or if there are overlapping X values, just run
  33326. * Point.update which is cheaper, allows animation, and keeps references
  33327. * to points. This also allows adding or removing points if the X-es
  33328. * don't match.
  33329. *
  33330. * @private
  33331. * @function Highcharts.Series#updateData
  33332. */
  33333. Series.prototype.updateData = function (data, animation) {
  33334. var options = this.options,
  33335. dataSorting = options.dataSorting,
  33336. oldData = this.points,
  33337. pointsToAdd = [],
  33338. hasUpdatedByKey,
  33339. i,
  33340. point,
  33341. lastIndex,
  33342. requireSorting = this.requireSorting,
  33343. equalLength = data.length === oldData.length,
  33344. succeeded = true;
  33345. this.xIncrement = null;
  33346. // Iterate the new data
  33347. data.forEach(function (pointOptions, i) {
  33348. var id,
  33349. x,
  33350. pointIndex,
  33351. optionsObject = (defined(pointOptions) &&
  33352. this.pointClass.prototype.optionsToObject.call({ series: this },
  33353. pointOptions)) || {};
  33354. // Get the x of the new data point
  33355. x = optionsObject.x;
  33356. id = optionsObject.id;
  33357. if (id || isNumber(x)) {
  33358. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33359. // Matching X not found
  33360. // or used already due to ununique x values (#8995),
  33361. // add point (but later)
  33362. if (pointIndex === -1 ||
  33363. typeof pointIndex === 'undefined') {
  33364. pointsToAdd.push(pointOptions);
  33365. // Matching X found, update
  33366. }
  33367. else if (oldData[pointIndex] &&
  33368. pointOptions !== options.data[pointIndex]) {
  33369. oldData[pointIndex].update(pointOptions, false, null, false);
  33370. // Mark it touched, below we will remove all points that
  33371. // are not touched.
  33372. oldData[pointIndex].touched = true;
  33373. // Speed optimize by only searching after last known
  33374. // index. Performs ~20% bettor on large data sets.
  33375. if (requireSorting) {
  33376. lastIndex = pointIndex + 1;
  33377. }
  33378. // Point exists, no changes, don't remove it
  33379. }
  33380. else if (oldData[pointIndex]) {
  33381. oldData[pointIndex].touched = true;
  33382. }
  33383. // If the length is equal and some of the nodes had a
  33384. // match in the same position, we don't want to remove
  33385. // non-matches.
  33386. if (!equalLength ||
  33387. i !== pointIndex ||
  33388. (dataSorting && dataSorting.enabled) ||
  33389. this.hasDerivedData) {
  33390. hasUpdatedByKey = true;
  33391. }
  33392. }
  33393. else {
  33394. // Gather all points that are not matched
  33395. pointsToAdd.push(pointOptions);
  33396. }
  33397. }, this);
  33398. // Remove points that don't exist in the updated data set
  33399. if (hasUpdatedByKey) {
  33400. i = oldData.length;
  33401. while (i--) {
  33402. point = oldData[i];
  33403. if (point && !point.touched && point.remove) {
  33404. point.remove(false, animation);
  33405. }
  33406. }
  33407. // If we did not find keys (ids or x-values), and the length is the
  33408. // same, update one-to-one
  33409. }
  33410. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33411. data.forEach(function (point, i) {
  33412. // .update doesn't exist on a linked, hidden series (#3709)
  33413. // (#10187)
  33414. if (point !== oldData[i].y && oldData[i].update) {
  33415. oldData[i].update(point, false, null, false);
  33416. }
  33417. });
  33418. // Don't add new points since those configs are used above
  33419. pointsToAdd.length = 0;
  33420. // Did not succeed in updating data
  33421. }
  33422. else {
  33423. succeeded = false;
  33424. }
  33425. oldData.forEach(function (point) {
  33426. if (point) {
  33427. point.touched = false;
  33428. }
  33429. });
  33430. if (!succeeded) {
  33431. return false;
  33432. }
  33433. // Add new points
  33434. pointsToAdd.forEach(function (point) {
  33435. this.addPoint(point, false, null, null, false);
  33436. }, this);
  33437. if (this.xIncrement === null &&
  33438. this.xData &&
  33439. this.xData.length) {
  33440. this.xIncrement = arrayMax(this.xData);
  33441. this.autoIncrement();
  33442. }
  33443. return true;
  33444. };
  33445. /**
  33446. * Apply a new set of data to the series and optionally redraw it. The
  33447. * new data array is passed by reference (except in case of
  33448. * `updatePoints`), and may later be mutated when updating the chart
  33449. * data.
  33450. *
  33451. * Note the difference in behaviour when setting the same amount of
  33452. * points, or a different amount of points, as handled by the
  33453. * `updatePoints` parameter.
  33454. *
  33455. * @sample highcharts/members/series-setdata/
  33456. * Set new data from a button
  33457. * @sample highcharts/members/series-setdata-pie/
  33458. * Set data in a pie
  33459. * @sample stock/members/series-setdata/
  33460. * Set new data in Highcharts Stock
  33461. * @sample maps/members/series-setdata/
  33462. * Set new data in Highmaps
  33463. *
  33464. * @function Highcharts.Series#setData
  33465. *
  33466. * @param {Array<Highcharts.PointOptionsType>} data
  33467. * Takes an array of data in the same format as described under
  33468. * `series.{type}.data` for the given series type, for example a
  33469. * line series would take data in the form described under
  33470. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33471. *
  33472. * @param {boolean} [redraw=true]
  33473. * Whether to redraw the chart after the series is altered. If
  33474. * doing more operations on the chart, it is a good idea to set
  33475. * redraw to false and call {@link Chart#redraw} after.
  33476. *
  33477. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33478. * When the updated data is the same length as the existing data,
  33479. * points will be updated by default, and animation visualizes
  33480. * how the points are changed. Set false to disable animation, or
  33481. * a configuration object to set duration or easing.
  33482. *
  33483. * @param {boolean} [updatePoints=true]
  33484. * When this is true, points will be updated instead of replaced
  33485. * whenever possible. This occurs a) when the updated data is the
  33486. * same length as the existing data, b) when points are matched
  33487. * by their id's, or c) when points can be matched by X values.
  33488. * This allows updating with animation and performs better. In
  33489. * this case, the original array is not passed by reference. Set
  33490. * `false` to prevent.
  33491. */
  33492. Series.prototype.setData = function (data, redraw, animation, updatePoints) {
  33493. var series = this,
  33494. oldData = series.points,
  33495. oldDataLength = (oldData && oldData.length) || 0,
  33496. dataLength,
  33497. options = series.options,
  33498. chart = series.chart,
  33499. dataSorting = options.dataSorting,
  33500. firstPoint = null,
  33501. xAxis = series.xAxis,
  33502. i,
  33503. turboThreshold = options.turboThreshold,
  33504. pt,
  33505. xData = this.xData,
  33506. yData = this.yData,
  33507. pointArrayMap = series.pointArrayMap,
  33508. valueCount = pointArrayMap && pointArrayMap.length,
  33509. keys = options.keys,
  33510. indexOfX = 0,
  33511. indexOfY = 1,
  33512. updatedData;
  33513. data = data || [];
  33514. dataLength = data.length;
  33515. redraw = pick(redraw, true);
  33516. if (dataSorting && dataSorting.enabled) {
  33517. data = this.sortData(data);
  33518. }
  33519. // First try to run Point.update which is cheaper, allows animation,
  33520. // and keeps references to points.
  33521. if (updatePoints !== false &&
  33522. dataLength &&
  33523. oldDataLength &&
  33524. !series.cropped &&
  33525. !series.hasGroupedData &&
  33526. series.visible &&
  33527. // Soft updating has no benefit in boost, and causes JS error
  33528. // (#8355)
  33529. !series.isSeriesBoosting) {
  33530. updatedData = this.updateData(data, animation);
  33531. }
  33532. if (!updatedData) {
  33533. // Reset properties
  33534. series.xIncrement = null;
  33535. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33536. // Update parallel arrays
  33537. this.parallelArrays.forEach(function (key) {
  33538. series[key + 'Data'].length = 0;
  33539. });
  33540. // In turbo mode, only one- or twodimensional arrays of numbers
  33541. // are allowed. The first value is tested, and we assume that
  33542. // all the rest are defined the same way. Although the 'for'
  33543. // loops are similar, they are repeated inside each if-else
  33544. // conditional for max performance.
  33545. if (turboThreshold && dataLength > turboThreshold) {
  33546. firstPoint = series.getFirstValidPoint(data);
  33547. if (isNumber(firstPoint)) { // assume all points are numbers
  33548. for (i = 0; i < dataLength; i++) {
  33549. xData[i] = this.autoIncrement();
  33550. yData[i] = data[i];
  33551. }
  33552. // Assume all points are arrays when first point is
  33553. }
  33554. else if (isArray(firstPoint)) {
  33555. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33556. for (i = 0; i < dataLength; i++) {
  33557. pt = data[i];
  33558. xData[i] = pt[0];
  33559. yData[i] =
  33560. pt.slice(1, valueCount + 1);
  33561. }
  33562. }
  33563. else { // [x, y]
  33564. if (keys) {
  33565. indexOfX = keys.indexOf('x');
  33566. indexOfY = keys.indexOf('y');
  33567. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33568. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33569. }
  33570. for (i = 0; i < dataLength; i++) {
  33571. pt = data[i];
  33572. xData[i] = pt[indexOfX];
  33573. yData[i] = pt[indexOfY];
  33574. }
  33575. }
  33576. }
  33577. else {
  33578. // Highcharts expects configs to be numbers or arrays in
  33579. // turbo mode
  33580. error(12, false, chart);
  33581. }
  33582. }
  33583. else {
  33584. for (i = 0; i < dataLength; i++) {
  33585. // stray commas in oldIE:
  33586. if (typeof data[i] !== 'undefined') {
  33587. pt = { series: series };
  33588. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33589. series.updateParallelArrays(pt, i);
  33590. }
  33591. }
  33592. }
  33593. // Forgetting to cast strings to numbers is a common caveat when
  33594. // handling CSV or JSON
  33595. if (yData && isString(yData[0])) {
  33596. error(14, true, chart);
  33597. }
  33598. series.data = [];
  33599. series.options.data = series.userOptions.data = data;
  33600. // destroy old points
  33601. i = oldDataLength;
  33602. while (i--) {
  33603. if (oldData[i] && oldData[i].destroy) {
  33604. oldData[i].destroy();
  33605. }
  33606. }
  33607. // reset minRange (#878)
  33608. if (xAxis) {
  33609. xAxis.minRange = xAxis.userMinRange;
  33610. }
  33611. // redraw
  33612. series.isDirty = chart.isDirtyBox = true;
  33613. series.isDirtyData = !!oldData;
  33614. animation = false;
  33615. }
  33616. // Typically for pie series, points need to be processed and
  33617. // generated prior to rendering the legend
  33618. if (options.legendType === 'point') {
  33619. this.processData();
  33620. this.generatePoints();
  33621. }
  33622. if (redraw) {
  33623. chart.redraw(animation);
  33624. }
  33625. };
  33626. /**
  33627. * Internal function to sort series data
  33628. *
  33629. * @private
  33630. * @function Highcharts.Series#sortData
  33631. *
  33632. * @param {Array<Highcharts.PointOptionsType>} data
  33633. * Force data grouping.
  33634. *
  33635. * @return {Array<Highcharts.PointOptionsObject>}
  33636. */
  33637. Series.prototype.sortData = function (data) {
  33638. var series = this,
  33639. options = series.options,
  33640. dataSorting = options.dataSorting,
  33641. sortKey = dataSorting.sortKey || 'y',
  33642. sortedData,
  33643. getPointOptionsObject = function (series,
  33644. pointOptions) {
  33645. return (defined(pointOptions) &&
  33646. series.pointClass.prototype.optionsToObject.call({
  33647. series: series
  33648. },
  33649. pointOptions)) || {};
  33650. };
  33651. data.forEach(function (pointOptions, i) {
  33652. data[i] = getPointOptionsObject(series, pointOptions);
  33653. data[i].index = i;
  33654. }, this);
  33655. // Sorting
  33656. sortedData = data.concat().sort(function (a, b) {
  33657. var aValue = getNestedProperty(sortKey,
  33658. a);
  33659. var bValue = getNestedProperty(sortKey,
  33660. b);
  33661. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33662. });
  33663. // Set x value depending on the position in the array
  33664. sortedData.forEach(function (point, i) {
  33665. point.x = i;
  33666. }, this);
  33667. // Set the same x for linked series points if they don't have their
  33668. // own sorting
  33669. if (series.linkedSeries) {
  33670. series.linkedSeries.forEach(function (linkedSeries) {
  33671. var options = linkedSeries.options,
  33672. seriesData = options.data;
  33673. if ((!options.dataSorting ||
  33674. !options.dataSorting.enabled) &&
  33675. seriesData) {
  33676. seriesData.forEach(function (pointOptions, i) {
  33677. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33678. if (data[i]) {
  33679. seriesData[i].x = data[i].x;
  33680. seriesData[i].index = i;
  33681. }
  33682. });
  33683. linkedSeries.setData(seriesData, false);
  33684. }
  33685. });
  33686. }
  33687. return data;
  33688. };
  33689. /**
  33690. * Internal function to process the data by cropping away unused data
  33691. * points if the series is longer than the crop threshold. This saves
  33692. * computing time for large series.
  33693. *
  33694. * @private
  33695. * @function Highcharts.Series#getProcessedData
  33696. * @param {boolean} [forceExtremesFromAll]
  33697. * Force getting extremes of a total series data range.
  33698. * @return {Highcharts.SeriesProcessedDataObject}
  33699. */
  33700. Series.prototype.getProcessedData = function (forceExtremesFromAll) {
  33701. var series = this,
  33702. // copied during slice operation:
  33703. processedXData = series.xData,
  33704. processedYData = series.yData,
  33705. dataLength = processedXData.length,
  33706. croppedData,
  33707. cropStart = 0,
  33708. cropped,
  33709. distance,
  33710. closestPointRange,
  33711. xAxis = series.xAxis,
  33712. i, // loop variable
  33713. options = series.options,
  33714. cropThreshold = options.cropThreshold,
  33715. getExtremesFromAll = forceExtremesFromAll ||
  33716. series.getExtremesFromAll ||
  33717. options.getExtremesFromAll, // #4599
  33718. isCartesian = series.isCartesian,
  33719. xExtremes,
  33720. val2lin = xAxis && xAxis.val2lin,
  33721. isLog = !!(xAxis && xAxis.logarithmic),
  33722. throwOnUnsorted = series.requireSorting,
  33723. min,
  33724. max;
  33725. if (xAxis) {
  33726. // corrected for log axis (#3053)
  33727. xExtremes = xAxis.getExtremes();
  33728. min = xExtremes.min;
  33729. max = xExtremes.max;
  33730. }
  33731. // optionally filter out points outside the plot area
  33732. if (isCartesian &&
  33733. series.sorted &&
  33734. !getExtremesFromAll &&
  33735. (!cropThreshold ||
  33736. dataLength > cropThreshold ||
  33737. series.forceCrop)) {
  33738. // it's outside current extremes
  33739. if (processedXData[dataLength - 1] < min ||
  33740. processedXData[0] > max) {
  33741. processedXData = [];
  33742. processedYData = [];
  33743. // only crop if it's actually spilling out
  33744. }
  33745. else if (series.yData && (processedXData[0] < min ||
  33746. processedXData[dataLength - 1] > max)) {
  33747. croppedData = this.cropData(series.xData, series.yData, min, max);
  33748. processedXData = croppedData.xData;
  33749. processedYData = croppedData.yData;
  33750. cropStart = croppedData.start;
  33751. cropped = true;
  33752. }
  33753. }
  33754. // Find the closest distance between processed points
  33755. i = processedXData.length || 1;
  33756. while (--i) {
  33757. distance = (isLog ?
  33758. (val2lin(processedXData[i]) -
  33759. val2lin(processedXData[i - 1])) :
  33760. (processedXData[i] -
  33761. processedXData[i - 1]));
  33762. if (distance > 0 &&
  33763. (typeof closestPointRange === 'undefined' ||
  33764. distance < closestPointRange)) {
  33765. closestPointRange = distance;
  33766. // Unsorted data is not supported by the line tooltip, as well
  33767. // as data grouping and navigation in Stock charts (#725) and
  33768. // width calculation of columns (#1900)
  33769. }
  33770. else if (distance < 0 && throwOnUnsorted) {
  33771. error(15, false, series.chart);
  33772. throwOnUnsorted = false; // Only once
  33773. }
  33774. }
  33775. return {
  33776. xData: processedXData,
  33777. yData: processedYData,
  33778. cropped: cropped,
  33779. cropStart: cropStart,
  33780. closestPointRange: closestPointRange
  33781. };
  33782. };
  33783. /**
  33784. * Internal function to apply processed data.
  33785. * In Highcharts Stock, this function is extended to provide data grouping.
  33786. *
  33787. * @private
  33788. * @function Highcharts.Series#processData
  33789. * @param {boolean} [force]
  33790. * Force data grouping.
  33791. * @return {boolean|undefined}
  33792. */
  33793. Series.prototype.processData = function (force) {
  33794. var series = this,
  33795. xAxis = series.xAxis,
  33796. processedData;
  33797. // If the series data or axes haven't changed, don't go through
  33798. // this. Return false to pass the message on to override methods
  33799. // like in data grouping.
  33800. if (series.isCartesian &&
  33801. !series.isDirty &&
  33802. !xAxis.isDirty &&
  33803. !series.yAxis.isDirty &&
  33804. !force) {
  33805. return false;
  33806. }
  33807. processedData = series.getProcessedData();
  33808. // Record the properties
  33809. series.cropped = processedData.cropped; // undefined or true
  33810. series.cropStart = processedData.cropStart;
  33811. series.processedXData = processedData.xData;
  33812. series.processedYData = processedData.yData;
  33813. series.closestPointRange = series.basePointRange = processedData.closestPointRange;
  33814. };
  33815. /**
  33816. * Iterate over xData and crop values between min and max. Returns
  33817. * object containing crop start/end cropped xData with corresponding
  33818. * part of yData, dataMin and dataMax within the cropped range.
  33819. *
  33820. * @private
  33821. * @function Highcharts.Series#cropData
  33822. * @param {Array<number>} xData
  33823. * @param {Array<number>} yData
  33824. * @param {number} min
  33825. * @param {number} max
  33826. * @param {number} [cropShoulder]
  33827. * @return {Highcharts.SeriesCropDataObject}
  33828. */
  33829. Series.prototype.cropData = function (xData, yData, min, max, cropShoulder) {
  33830. var dataLength = xData.length,
  33831. cropStart = 0,
  33832. cropEnd = dataLength,
  33833. i,
  33834. j;
  33835. // line-type series need one point outside
  33836. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33837. // iterate up to find slice start
  33838. for (i = 0; i < dataLength; i++) {
  33839. if (xData[i] >= min) {
  33840. cropStart = Math.max(0, i - cropShoulder);
  33841. break;
  33842. }
  33843. }
  33844. // proceed to find slice end
  33845. for (j = i; j < dataLength; j++) {
  33846. if (xData[j] > max) {
  33847. cropEnd = j + cropShoulder;
  33848. break;
  33849. }
  33850. }
  33851. return {
  33852. xData: xData.slice(cropStart, cropEnd),
  33853. yData: yData.slice(cropStart, cropEnd),
  33854. start: cropStart,
  33855. end: cropEnd
  33856. };
  33857. };
  33858. /**
  33859. * Generate the data point after the data has been processed by cropping
  33860. * away unused points and optionally grouped in Highcharts Stock.
  33861. *
  33862. * @private
  33863. * @function Highcharts.Series#generatePoints
  33864. */
  33865. Series.prototype.generatePoints = function () {
  33866. var series = this,
  33867. options = series.options,
  33868. dataOptions = options.data,
  33869. data = series.data,
  33870. dataLength,
  33871. processedXData = series.processedXData,
  33872. processedYData = series.processedYData,
  33873. PointClass = series.pointClass,
  33874. processedDataLength = processedXData.length,
  33875. cropStart = series.cropStart || 0,
  33876. cursor,
  33877. hasGroupedData = series.hasGroupedData,
  33878. keys = options.keys,
  33879. point,
  33880. points = [],
  33881. i,
  33882. groupCropStartIndex = (options.dataGrouping &&
  33883. options.dataGrouping.groupAll ?
  33884. cropStart :
  33885. 0);
  33886. if (!data && !hasGroupedData) {
  33887. var arr = [];
  33888. arr.length = dataOptions.length;
  33889. data = series.data = arr;
  33890. }
  33891. if (keys && hasGroupedData) {
  33892. // grouped data has already applied keys (#6590)
  33893. series.options.keys = false;
  33894. }
  33895. for (i = 0; i < processedDataLength; i++) {
  33896. cursor = cropStart + i;
  33897. if (!hasGroupedData) {
  33898. point = data[cursor];
  33899. // #970:
  33900. if (!point &&
  33901. typeof dataOptions[cursor] !== 'undefined') {
  33902. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33903. }
  33904. }
  33905. else {
  33906. // splat the y data in case of ohlc data array
  33907. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33908. /**
  33909. * Highcharts Stock only. If a point object is created by data
  33910. * grouping, it doesn't reflect actual points in the raw
  33911. * data. In this case, the `dataGroup` property holds
  33912. * information that points back to the raw data.
  33913. *
  33914. * - `dataGroup.start` is the index of the first raw data
  33915. * point in the group.
  33916. *
  33917. * - `dataGroup.length` is the amount of points in the
  33918. * group.
  33919. *
  33920. * @product highstock
  33921. *
  33922. * @name Highcharts.Point#dataGroup
  33923. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33924. */
  33925. point.dataGroup = series.groupMap[groupCropStartIndex + i];
  33926. if (point.dataGroup.options) {
  33927. point.options = point.dataGroup.options;
  33928. extend(point, point.dataGroup.options);
  33929. // Collision of props and options (#9770)
  33930. delete point.dataLabels;
  33931. }
  33932. }
  33933. if (point) { // #6279
  33934. /**
  33935. * Contains the point's index in the `Series.points` array.
  33936. *
  33937. * @name Highcharts.Point#index
  33938. * @type {number}
  33939. * @readonly
  33940. */
  33941. // For faster access in Point.update
  33942. point.index = hasGroupedData ? (groupCropStartIndex + i) : cursor;
  33943. points[i] = point;
  33944. }
  33945. }
  33946. // restore keys options (#6590)
  33947. series.options.keys = keys;
  33948. // Hide cropped-away points - this only runs when the number of
  33949. // points is above cropThreshold, or when swithching view from
  33950. // non-grouped data to grouped data (#637)
  33951. if (data &&
  33952. (processedDataLength !== (dataLength = data.length) ||
  33953. hasGroupedData)) {
  33954. for (i = 0; i < dataLength; i++) {
  33955. // when has grouped data, clear all points
  33956. if (i === cropStart && !hasGroupedData) {
  33957. i += processedDataLength;
  33958. }
  33959. if (data[i]) {
  33960. data[i].destroyElements();
  33961. data[i].plotX = void 0; // #1003
  33962. }
  33963. }
  33964. }
  33965. /**
  33966. * Read only. An array containing those values converted to points.
  33967. * In case the series data length exceeds the `cropThreshold`, or if
  33968. * the data is grouped, `series.data` doesn't contain all the
  33969. * points. Also, in case a series is hidden, the `data` array may be
  33970. * empty. To access raw values, `series.options.data` will always be
  33971. * up to date. `Series.data` only contains the points that have been
  33972. * created on demand. To modify the data, use
  33973. * {@link Highcharts.Series#setData} or
  33974. * {@link Highcharts.Point#update}.
  33975. *
  33976. * @see Series.points
  33977. *
  33978. * @name Highcharts.Series#data
  33979. * @type {Array<Highcharts.Point>}
  33980. */
  33981. series.data = data;
  33982. /**
  33983. * An array containing all currently visible point objects. In case
  33984. * of cropping, the cropped-away points are not part of this array.
  33985. * The `series.points` array starts at `series.cropStart` compared
  33986. * to `series.data` and `series.options.data`. If however the series
  33987. * data is grouped, these can't be correlated one to one. To modify
  33988. * the data, use {@link Highcharts.Series#setData} or
  33989. * {@link Highcharts.Point#update}.
  33990. *
  33991. * @name Highcharts.Series#points
  33992. * @type {Array<Highcharts.Point>}
  33993. */
  33994. series.points = points;
  33995. fireEvent(this, 'afterGeneratePoints');
  33996. };
  33997. /**
  33998. * Get current X extremes for the visible data.
  33999. *
  34000. * @private
  34001. * @function Highcharts.Series#getXExtremes
  34002. *
  34003. * @param {Array<number>} xData
  34004. * The data to inspect. Defaults to the current data within the visible
  34005. * range.
  34006. *
  34007. * @return {Highcharts.RangeObject}
  34008. */
  34009. Series.prototype.getXExtremes = function (xData) {
  34010. return {
  34011. min: arrayMin(xData),
  34012. max: arrayMax(xData)
  34013. };
  34014. };
  34015. /**
  34016. * Calculate Y extremes for the visible data. The result is returned
  34017. * as an object with `dataMin` and `dataMax` properties.
  34018. *
  34019. * @private
  34020. * @function Highcharts.Series#getExtremes
  34021. *
  34022. * @param {Array<number>} [yData]
  34023. * The data to inspect. Defaults to the current data within the visible
  34024. * range.
  34025. * @param {boolean} [forceExtremesFromAll]
  34026. * Force getting extremes of a total series data range.
  34027. *
  34028. * @return {Highcharts.DataExtremesObject}
  34029. */
  34030. Series.prototype.getExtremes = function (yData, forceExtremesFromAll) {
  34031. var xAxis = this.xAxis,
  34032. yAxis = this.yAxis,
  34033. xData = this.processedXData || this.xData,
  34034. yDataLength,
  34035. activeYData = [],
  34036. activeCounter = 0,
  34037. // #2117, need to compensate for log X axis
  34038. xExtremes,
  34039. xMin = 0,
  34040. xMax = 0,
  34041. validValue,
  34042. withinRange,
  34043. // Handle X outside the viewed area. This does not work with
  34044. // non-sorted data like scatter (#7639).
  34045. shoulder = this.requireSorting ? this.cropShoulder : 0,
  34046. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  34047. x,
  34048. y,
  34049. i,
  34050. j;
  34051. yData = yData || this.stackedYData || this.processedYData || [];
  34052. yDataLength = yData.length;
  34053. if (xAxis) {
  34054. xExtremes = xAxis.getExtremes();
  34055. xMin = xExtremes.min;
  34056. xMax = xExtremes.max;
  34057. }
  34058. for (i = 0; i < yDataLength; i++) {
  34059. x = xData[i];
  34060. y = yData[i];
  34061. // For points within the visible range, including the first
  34062. // point outside the visible range (#7061), consider y extremes.
  34063. validValue = ((isNumber(y) || isArray(y)) &&
  34064. ((y.length || y > 0) || !positiveValuesOnly));
  34065. withinRange = (forceExtremesFromAll ||
  34066. this.getExtremesFromAll ||
  34067. this.options.getExtremesFromAll ||
  34068. this.cropped ||
  34069. !xAxis || // for colorAxis support
  34070. ((xData[i + shoulder] || x) >= xMin &&
  34071. (xData[i - shoulder] || x) <= xMax));
  34072. if (validValue && withinRange) {
  34073. j = y.length;
  34074. if (j) { // array, like ohlc or range data
  34075. while (j--) {
  34076. if (isNumber(y[j])) { // #7380, #11513
  34077. activeYData[activeCounter++] = y[j];
  34078. }
  34079. }
  34080. }
  34081. else {
  34082. activeYData[activeCounter++] = y;
  34083. }
  34084. }
  34085. }
  34086. var dataExtremes = {
  34087. dataMin: arrayMin(activeYData),
  34088. dataMax: arrayMax(activeYData)
  34089. };
  34090. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  34091. return dataExtremes;
  34092. };
  34093. /**
  34094. * Set the current data extremes as `dataMin` and `dataMax` on the
  34095. * Series item. Use this only when the series properties should be
  34096. * updated.
  34097. *
  34098. * @private
  34099. * @function Highcharts.Series#applyExtremes
  34100. */
  34101. Series.prototype.applyExtremes = function () {
  34102. var dataExtremes = this.getExtremes();
  34103. /**
  34104. * Contains the minimum value of the series' data point. Some series
  34105. * types like `networkgraph` do not support this property as they
  34106. * lack a `y`-value.
  34107. * @name Highcharts.Series#dataMin
  34108. * @type {number|undefined}
  34109. * @readonly
  34110. */
  34111. this.dataMin = dataExtremes.dataMin;
  34112. /**
  34113. * Contains the maximum value of the series' data point. Some series
  34114. * types like `networkgraph` do not support this property as they
  34115. * lack a `y`-value.
  34116. * @name Highcharts.Series#dataMax
  34117. * @type {number|undefined}
  34118. * @readonly
  34119. */
  34120. this.dataMax = dataExtremes.dataMax;
  34121. return dataExtremes;
  34122. };
  34123. /**
  34124. * Find and return the first non null point in the data
  34125. *
  34126. * @private
  34127. * @function Highcharts.Series.getFirstValidPoint
  34128. *
  34129. * @param {Array<Highcharts.PointOptionsType>} data
  34130. * Array of options for points
  34131. *
  34132. * @return {Highcharts.PointOptionsType}
  34133. */
  34134. Series.prototype.getFirstValidPoint = function (data) {
  34135. var firstPoint = null,
  34136. dataLength = data.length,
  34137. i = 0;
  34138. while (firstPoint === null && i < dataLength) {
  34139. firstPoint = data[i];
  34140. i++;
  34141. }
  34142. return firstPoint;
  34143. };
  34144. /**
  34145. * Translate data points from raw data values to chart specific
  34146. * positioning data needed later in the `drawPoints` and `drawGraph`
  34147. * functions. This function can be overridden in plugins and custom
  34148. * series type implementations.
  34149. *
  34150. * @function Highcharts.Series#translate
  34151. *
  34152. * @fires Highcharts.Series#events:translate
  34153. */
  34154. Series.prototype.translate = function () {
  34155. if (!this.processedXData) { // hidden series
  34156. this.processData();
  34157. }
  34158. this.generatePoints();
  34159. var series = this,
  34160. options = series.options,
  34161. stacking = options.stacking,
  34162. xAxis = series.xAxis,
  34163. categories = xAxis.categories,
  34164. enabledDataSorting = series.enabledDataSorting,
  34165. yAxis = series.yAxis,
  34166. points = series.points,
  34167. dataLength = points.length,
  34168. hasModifyValue = !!series.modifyValue,
  34169. i,
  34170. pointPlacement = series.pointPlacementToXValue(), // #7860
  34171. dynamicallyPlaced = Boolean(pointPlacement),
  34172. threshold = options.threshold,
  34173. stackThreshold = options.startFromThreshold ? threshold : 0,
  34174. plotX,
  34175. lastPlotX,
  34176. stackIndicator,
  34177. zoneAxis = this.zoneAxis || 'y',
  34178. closestPointRangePx = Number.MAX_VALUE;
  34179. /**
  34180. * Plotted coordinates need to be within a limited range. Drawing
  34181. * too far outside the viewport causes various rendering issues
  34182. * (#3201, #3923, #7555).
  34183. * @private
  34184. */
  34185. function limitedRange(val) {
  34186. return clamp(val, -1e5, 1e5);
  34187. }
  34188. // Translate each point
  34189. for (i = 0; i < dataLength; i++) {
  34190. var point = points[i],
  34191. xValue = point.x,
  34192. yValue = point.y,
  34193. yBottom = point.low,
  34194. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  34195. yValue <
  34196. (stackThreshold ? 0 : threshold) ?
  34197. '-' :
  34198. '') + series.stackKey],
  34199. pointStack = void 0,
  34200. stackValues = void 0;
  34201. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  34202. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  34203. point.isNull = true;
  34204. }
  34205. // Get the plotX translation
  34206. point.plotX = plotX = correctFloat(// #5236
  34207. limitedRange(xAxis.translate(// #3923
  34208. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  34209. );
  34210. // Calculate the bottom y value for stacked series
  34211. if (stacking &&
  34212. series.visible &&
  34213. stack &&
  34214. stack[xValue]) {
  34215. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  34216. if (!point.isNull) {
  34217. pointStack = stack[xValue];
  34218. stackValues =
  34219. pointStack.points[stackIndicator.key];
  34220. }
  34221. }
  34222. if (isArray(stackValues)) {
  34223. yBottom = stackValues[0];
  34224. yValue = stackValues[1];
  34225. if (yBottom === stackThreshold &&
  34226. stackIndicator.key ===
  34227. stack[xValue].base) {
  34228. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  34229. }
  34230. // #1200, #1232
  34231. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  34232. yBottom = null;
  34233. }
  34234. point.total = point.stackTotal = pointStack.total;
  34235. point.percentage =
  34236. pointStack.total &&
  34237. (point.y / pointStack.total * 100);
  34238. point.stackY = yValue;
  34239. // Place the stack label
  34240. // in case of variwide series (where widths of points are
  34241. // different in most cases), stack labels are positioned
  34242. // wrongly, so the call of the setOffset is omited here and
  34243. // labels are correctly positioned later, at the end of the
  34244. // variwide's translate function (#10962)
  34245. if (!series.irregularWidths) {
  34246. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  34247. }
  34248. }
  34249. // Set translated yBottom or remove it
  34250. point.yBottom = defined(yBottom) ?
  34251. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  34252. null;
  34253. // general hook, used for Highcharts Stock compare mode
  34254. if (hasModifyValue) {
  34255. yValue = series.modifyValue(yValue, point);
  34256. }
  34257. // Set the the plotY value, reset it for redraws
  34258. // #3201
  34259. point.plotY = void 0;
  34260. if (isNumber(yValue)) {
  34261. var translated = yAxis.translate(yValue,
  34262. false,
  34263. true,
  34264. false,
  34265. true);
  34266. if (typeof translated !== 'undefined') {
  34267. point.plotY = limitedRange(translated);
  34268. }
  34269. }
  34270. point.isInside = this.isPointInside(point);
  34271. // Set client related positions for mouse tracking
  34272. point.clientX = dynamicallyPlaced ?
  34273. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  34274. plotX; // #1514, #5383, #5518
  34275. // Negative points. For bubble charts, this means negative z
  34276. // values (#9728)
  34277. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  34278. threshold ||
  34279. 0);
  34280. // some API data
  34281. point.category = (categories &&
  34282. typeof categories[point.x] !== 'undefined' ?
  34283. categories[point.x] :
  34284. point.x);
  34285. // Determine auto enabling of markers (#3635, #5099)
  34286. if (!point.isNull && point.visible !== false) {
  34287. if (typeof lastPlotX !== 'undefined') {
  34288. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  34289. }
  34290. lastPlotX = plotX;
  34291. }
  34292. // Find point zone
  34293. point.zone = (this.zones.length && point.getZone());
  34294. // Animate new points with data sorting
  34295. if (!point.graphic && series.group && enabledDataSorting) {
  34296. point.isNew = true;
  34297. }
  34298. }
  34299. series.closestPointRangePx = closestPointRangePx;
  34300. fireEvent(this, 'afterTranslate');
  34301. };
  34302. /**
  34303. * Return the series points with null points filtered out.
  34304. *
  34305. * @function Highcharts.Series#getValidPoints
  34306. *
  34307. * @param {Array<Highcharts.Point>} [points]
  34308. * The points to inspect, defaults to {@link Series.points}.
  34309. *
  34310. * @param {boolean} [insideOnly=false]
  34311. * Whether to inspect only the points that are inside the visible view.
  34312. *
  34313. * @param {boolean} [allowNull=false]
  34314. * Whether to allow null points to pass as valid points.
  34315. *
  34316. * @return {Array<Highcharts.Point>}
  34317. * The valid points.
  34318. */
  34319. Series.prototype.getValidPoints = function (points, insideOnly, allowNull) {
  34320. var chart = this.chart;
  34321. // #3916, #5029, #5085
  34322. return (points || this.points || []).filter(function (point) {
  34323. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, { inverted: chart.inverted })) {
  34324. return false;
  34325. }
  34326. return point.visible !== false &&
  34327. (allowNull || !point.isNull);
  34328. });
  34329. };
  34330. /**
  34331. * Get the clipping for the series. Could be called for a series to
  34332. * initiate animating the clip or to set the final clip (only width
  34333. * and x).
  34334. *
  34335. * @private
  34336. * @function Highcharts.Series#getClip
  34337. *
  34338. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34339. * Initialize the animation.
  34340. *
  34341. * @param {boolean} [finalBox]
  34342. * Final size for the clip - end state for the animation.
  34343. *
  34344. * @return {Highcharts.Dictionary<number>}
  34345. */
  34346. Series.prototype.getClipBox = function (animation, finalBox) {
  34347. var series = this,
  34348. options = series.options,
  34349. chart = series.chart,
  34350. inverted = chart.inverted,
  34351. xAxis = series.xAxis,
  34352. yAxis = xAxis && series.yAxis,
  34353. clipBox,
  34354. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34355. if (animation && options.clip === false && yAxis) {
  34356. // support for not clipped series animation (#10450)
  34357. clipBox = inverted ? {
  34358. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34359. height: chart.chartWidth,
  34360. width: chart.chartHeight,
  34361. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34362. } : {
  34363. y: -yAxis.pos,
  34364. height: chart.chartHeight,
  34365. width: chart.chartWidth,
  34366. x: -xAxis.pos
  34367. };
  34368. // x and width will be changed later when setting for animation
  34369. // initial state in Series.setClip
  34370. }
  34371. else {
  34372. clipBox = series.clipBox || chart.clipBox;
  34373. if (finalBox) {
  34374. clipBox.width = chart.plotSizeX;
  34375. clipBox.x = (chart.scrollablePixelsX || 0) *
  34376. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34377. }
  34378. }
  34379. return !finalBox ? clipBox : {
  34380. width: clipBox.width,
  34381. x: clipBox.x
  34382. };
  34383. };
  34384. /**
  34385. * Get the shared clip key, creating it if it doesn't exist.
  34386. *
  34387. * @private
  34388. * @function Highcharts.Series#getSharedClipKey
  34389. */
  34390. Series.prototype.getSharedClipKey = function (animation) {
  34391. if (this.sharedClipKey) {
  34392. return this.sharedClipKey;
  34393. }
  34394. var sharedClipKey = [
  34395. animation && animation.duration,
  34396. animation && animation.easing,
  34397. animation && animation.defer,
  34398. this.getClipBox(animation).height,
  34399. this.options.xAxis,
  34400. this.options.yAxis
  34401. ].join(',');
  34402. if (this.options.clip !== false || animation) {
  34403. this.sharedClipKey = sharedClipKey;
  34404. }
  34405. return sharedClipKey;
  34406. };
  34407. /**
  34408. * Set the clipping for the series. For animated series it is called
  34409. * twice, first to initiate animating the clip then the second time
  34410. * without the animation to set the final clip.
  34411. *
  34412. * @private
  34413. * @function Highcharts.Series#setClip
  34414. */
  34415. Series.prototype.setClip = function (animation) {
  34416. var chart = this.chart,
  34417. options = this.options,
  34418. renderer = chart.renderer,
  34419. inverted = chart.inverted,
  34420. seriesClipBox = this.clipBox,
  34421. clipBox = this.getClipBox(animation),
  34422. sharedClipKey = this.getSharedClipKey(animation), // #4526
  34423. clipRect = chart.sharedClips[sharedClipKey],
  34424. markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34425. if (animation) {
  34426. clipBox.width = 0;
  34427. if (inverted) {
  34428. clipBox.x = chart.plotHeight +
  34429. (options.clip !== false ? 0 : chart.plotTop);
  34430. }
  34431. }
  34432. // If a clipping rectangle with the same properties is currently
  34433. // present in the chart, use that.
  34434. if (!clipRect) {
  34435. // When animation is set, prepare the initial positions
  34436. if (animation) {
  34437. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect =
  34438. renderer.clipRect(
  34439. // include the width of the first marker
  34440. inverted ? (chart.plotSizeX || 0) + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34441. }
  34442. chart.sharedClips[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34443. // Create hashmap for series indexes
  34444. clipRect.count = { length: 0 };
  34445. // When the series is rendered again before starting animating, in
  34446. // compliance to a responsive rule
  34447. }
  34448. else if (!chart.hasLoaded) {
  34449. clipRect.attr(clipBox);
  34450. }
  34451. if (animation) {
  34452. if (!clipRect.count[this.index]) {
  34453. clipRect.count[this.index] = true;
  34454. clipRect.count.length += 1;
  34455. }
  34456. }
  34457. if (options.clip !== false || animation) {
  34458. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34459. this.markerGroup.clip(markerClipRect);
  34460. }
  34461. // Remove the shared clipping rectangle when all series are shown
  34462. if (!animation) {
  34463. if (clipRect.count[this.index]) {
  34464. delete clipRect.count[this.index];
  34465. clipRect.count.length -= 1;
  34466. }
  34467. if (clipRect.count.length === 0) {
  34468. if (!seriesClipBox) {
  34469. chart.sharedClips[sharedClipKey] = clipRect.destroy();
  34470. }
  34471. if (markerClipRect) {
  34472. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect.destroy();
  34473. }
  34474. }
  34475. }
  34476. };
  34477. /**
  34478. * Animate in the series. Called internally twice. First with the `init`
  34479. * parameter set to true, which sets up the initial state of the
  34480. * animation. Then when ready, it is called with the `init` parameter
  34481. * undefined, in order to perform the actual animation. After the
  34482. * second run, the function is removed.
  34483. *
  34484. * @function Highcharts.Series#animate
  34485. *
  34486. * @param {boolean} [init]
  34487. * Initialize the animation.
  34488. */
  34489. Series.prototype.animate = function (init) {
  34490. var series = this,
  34491. chart = series.chart,
  34492. animation = animObject(series.options.animation),
  34493. sharedClipKey = this.sharedClipKey;
  34494. // Initialize the animation. Set up the clipping rectangle.
  34495. if (init) {
  34496. series.setClip(animation);
  34497. // Run the animation
  34498. }
  34499. else if (sharedClipKey) {
  34500. var clipRect = chart.sharedClips[sharedClipKey];
  34501. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34502. var finalBox = series.getClipBox(animation,
  34503. true);
  34504. if (clipRect) {
  34505. clipRect.animate(finalBox, animation);
  34506. }
  34507. if (markerClipRect) {
  34508. markerClipRect.animate({
  34509. width: finalBox.width + 99,
  34510. x: finalBox.x - (chart.inverted ? 0 : 99)
  34511. }, animation);
  34512. }
  34513. }
  34514. };
  34515. /**
  34516. * This runs after animation to land on the final plot clipping.
  34517. *
  34518. * @private
  34519. * @function Highcharts.Series#afterAnimate
  34520. *
  34521. * @fires Highcharts.Series#event:afterAnimate
  34522. */
  34523. Series.prototype.afterAnimate = function () {
  34524. this.setClip();
  34525. fireEvent(this, 'afterAnimate');
  34526. this.finishedAnimating = true;
  34527. };
  34528. /**
  34529. * Draw the markers for line-like series types, and columns or other
  34530. * graphical representation for {@link Point} objects for other series
  34531. * types. The resulting element is typically stored as
  34532. * {@link Point.graphic}, and is created on the first call and updated
  34533. * and moved on subsequent calls.
  34534. *
  34535. * @function Highcharts.Series#drawPoints
  34536. */
  34537. Series.prototype.drawPoints = function () {
  34538. var series = this,
  34539. points = series.points,
  34540. chart = series.chart,
  34541. i,
  34542. point,
  34543. graphic,
  34544. verb,
  34545. options = series.options,
  34546. seriesMarkerOptions = options.marker,
  34547. pointMarkerOptions,
  34548. hasPointMarker,
  34549. markerGroup = (series[series.specialGroup] ||
  34550. series.markerGroup),
  34551. xAxis = series.xAxis,
  34552. markerAttribs,
  34553. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34554. // Use larger or equal as radius is null in bubbles (#6321)
  34555. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34556. seriesMarkerOptions.radius));
  34557. if (seriesMarkerOptions.enabled !== false ||
  34558. series._hasPointMarkers) {
  34559. for (i = 0; i < points.length; i++) {
  34560. point = points[i];
  34561. graphic = point.graphic;
  34562. verb = graphic ? 'animate' : 'attr';
  34563. pointMarkerOptions = point.marker || {};
  34564. hasPointMarker = !!point.marker;
  34565. var shouldDrawMarker = ((globallyEnabled &&
  34566. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34567. // only draw the point if y is defined
  34568. if (shouldDrawMarker) {
  34569. // Shortcuts
  34570. var symbol = pick(pointMarkerOptions.symbol,
  34571. series.symbol, 'rect');
  34572. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34573. // Set starting position for point sliding animation.
  34574. if (series.enabledDataSorting) {
  34575. point.startXPos = xAxis.reversed ?
  34576. -(markerAttribs.width || 0) :
  34577. xAxis.width;
  34578. }
  34579. var isInside = point.isInside !== false;
  34580. if (graphic) { // update
  34581. // Since the marker group isn't clipped, each
  34582. // individual marker must be toggled
  34583. graphic[isInside ? 'show' : 'hide'](isInside)
  34584. .animate(markerAttribs);
  34585. }
  34586. else if (isInside &&
  34587. ((markerAttribs.width || 0) > 0 || point.hasImage)) {
  34588. /**
  34589. * The graphic representation of the point.
  34590. * Typically this is a simple shape, like a `rect`
  34591. * for column charts or `path` for line markers, but
  34592. * for some complex series types like boxplot or 3D
  34593. * charts, the graphic may be a `g` element
  34594. * containing other shapes. The graphic is generated
  34595. * the first time {@link Series#drawPoints} runs,
  34596. * and updated and moved on subsequent runs.
  34597. *
  34598. * @name Point#graphic
  34599. * @type {SVGElement}
  34600. */
  34601. point.graphic = graphic = chart.renderer
  34602. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34603. pointMarkerOptions :
  34604. seriesMarkerOptions)
  34605. .add(markerGroup);
  34606. // Sliding animation for new points
  34607. if (series.enabledDataSorting &&
  34608. chart.hasRendered) {
  34609. graphic.attr({
  34610. x: point.startXPos
  34611. });
  34612. verb = 'animate';
  34613. }
  34614. }
  34615. if (graphic && verb === 'animate') { // update
  34616. // Since the marker group isn't clipped, each
  34617. // individual marker must be toggled
  34618. graphic[isInside ? 'show' : 'hide'](isInside)
  34619. .animate(markerAttribs);
  34620. }
  34621. // Presentational attributes
  34622. if (graphic && !chart.styledMode) {
  34623. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34624. }
  34625. if (graphic) {
  34626. graphic.addClass(point.getClassName(), true);
  34627. }
  34628. }
  34629. else if (graphic) {
  34630. point.graphic = graphic.destroy(); // #1269
  34631. }
  34632. }
  34633. }
  34634. };
  34635. /**
  34636. * Get non-presentational attributes for a point. Used internally for
  34637. * both styled mode and classic. Can be overridden for different series
  34638. * types.
  34639. *
  34640. * @see Series#pointAttribs
  34641. *
  34642. * @function Highcharts.Series#markerAttribs
  34643. *
  34644. * @param {Highcharts.Point} point
  34645. * The Point to inspect.
  34646. *
  34647. * @param {string} [state]
  34648. * The state, can be either `hover`, `select` or undefined.
  34649. *
  34650. * @return {Highcharts.SVGAttributes}
  34651. * A hash containing those attributes that are not settable from CSS.
  34652. */
  34653. Series.prototype.markerAttribs = function (point, state) {
  34654. var seriesOptions = this.options,
  34655. seriesMarkerOptions = seriesOptions.marker,
  34656. seriesStateOptions,
  34657. pointMarkerOptions = point.marker || {},
  34658. symbol = (pointMarkerOptions.symbol ||
  34659. seriesMarkerOptions.symbol),
  34660. pointStateOptions,
  34661. radius = pick(pointMarkerOptions.radius,
  34662. seriesMarkerOptions.radius),
  34663. attribs;
  34664. // Handle hover and select states
  34665. if (state) {
  34666. seriesStateOptions = seriesMarkerOptions.states[state];
  34667. pointStateOptions = pointMarkerOptions.states &&
  34668. pointMarkerOptions.states[state];
  34669. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34670. 0));
  34671. }
  34672. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34673. if (point.hasImage) {
  34674. radius = 0; // and subsequently width and height is not set
  34675. }
  34676. attribs = {
  34677. // Math.floor for #1843:
  34678. x: seriesOptions.crisp ?
  34679. Math.floor(point.plotX - radius) :
  34680. point.plotX - radius,
  34681. y: point.plotY - radius
  34682. };
  34683. if (radius) {
  34684. attribs.width = attribs.height = 2 * radius;
  34685. }
  34686. return attribs;
  34687. };
  34688. /**
  34689. * Internal function to get presentational attributes for each point.
  34690. * Unlike {@link Series#markerAttribs}, this function should return
  34691. * those attributes that can also be set in CSS. In styled mode,
  34692. * `pointAttribs` won't be called.
  34693. *
  34694. * @private
  34695. * @function Highcharts.Series#pointAttribs
  34696. *
  34697. * @param {Highcharts.Point} [point]
  34698. * The point instance to inspect.
  34699. *
  34700. * @param {string} [state]
  34701. * The point state, can be either `hover`, `select` or 'normal'. If
  34702. * undefined, normal state is assumed.
  34703. *
  34704. * @return {Highcharts.SVGAttributes}
  34705. * The presentational attributes to be set on the point.
  34706. */
  34707. Series.prototype.pointAttribs = function (point, state) {
  34708. var seriesMarkerOptions = this.options.marker,
  34709. seriesStateOptions,
  34710. pointOptions = point && point.options,
  34711. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34712. pointStateOptions,
  34713. color = this.color,
  34714. pointColorOption = pointOptions && pointOptions.color,
  34715. pointColor = point && point.color,
  34716. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34717. seriesMarkerOptions.lineWidth),
  34718. zoneColor = point && point.zone && point.zone.color,
  34719. fill,
  34720. stroke,
  34721. opacity = 1;
  34722. color = (pointColorOption ||
  34723. zoneColor ||
  34724. pointColor ||
  34725. color);
  34726. fill = (pointMarkerOptions.fillColor ||
  34727. seriesMarkerOptions.fillColor ||
  34728. color);
  34729. stroke = (pointMarkerOptions.lineColor ||
  34730. seriesMarkerOptions.lineColor ||
  34731. color);
  34732. // Handle hover and select states
  34733. state = state || 'normal';
  34734. if (state) {
  34735. seriesStateOptions = seriesMarkerOptions.states[state];
  34736. pointStateOptions = (pointMarkerOptions.states &&
  34737. pointMarkerOptions.states[state]) || {};
  34738. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34739. fill = (pointStateOptions.fillColor ||
  34740. seriesStateOptions.fillColor ||
  34741. fill);
  34742. stroke = (pointStateOptions.lineColor ||
  34743. seriesStateOptions.lineColor ||
  34744. stroke);
  34745. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34746. }
  34747. return {
  34748. 'stroke': stroke,
  34749. 'stroke-width': strokeWidth,
  34750. 'fill': fill,
  34751. 'opacity': opacity
  34752. };
  34753. };
  34754. /**
  34755. * Clear DOM objects and free up memory.
  34756. *
  34757. * @private
  34758. * @function Highcharts.Series#destroy
  34759. *
  34760. * @fires Highcharts.Series#event:destroy
  34761. */
  34762. Series.prototype.destroy = function (keepEventsForUpdate) {
  34763. var series = this,
  34764. chart = series.chart,
  34765. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34766. destroy,
  34767. i,
  34768. data = series.data || [],
  34769. point,
  34770. axis;
  34771. // add event hook
  34772. fireEvent(series, 'destroy');
  34773. // remove events
  34774. this.removeEvents(keepEventsForUpdate);
  34775. // erase from axes
  34776. (series.axisTypes || []).forEach(function (AXIS) {
  34777. axis = series[AXIS];
  34778. if (axis && axis.series) {
  34779. erase(axis.series, series);
  34780. axis.isDirty = axis.forceRedraw = true;
  34781. }
  34782. });
  34783. // remove legend items
  34784. if (series.legendItem) {
  34785. series.chart.legend.destroyItem(series);
  34786. }
  34787. // destroy all points with their elements
  34788. i = data.length;
  34789. while (i--) {
  34790. point = data[i];
  34791. if (point && point.destroy) {
  34792. point.destroy();
  34793. }
  34794. }
  34795. if (series.clips) {
  34796. series.clips.forEach(function (clip) { return clip.destroy(); });
  34797. }
  34798. // Clear the animation timeout if we are destroying the series
  34799. // during initial animation
  34800. U.clearTimeout(series.animationTimeout);
  34801. // Destroy all SVGElements associated to the series
  34802. objectEach(series, function (val, prop) {
  34803. // Survive provides a hook for not destroying
  34804. if (val instanceof SVGElement && !val.survive) {
  34805. // issue 134 workaround
  34806. destroy = issue134 && prop === 'group' ?
  34807. 'hide' :
  34808. 'destroy';
  34809. val[destroy]();
  34810. }
  34811. });
  34812. // remove from hoverSeries
  34813. if (chart.hoverSeries === series) {
  34814. chart.hoverSeries = void 0;
  34815. }
  34816. erase(chart.series, series);
  34817. chart.orderSeries();
  34818. // clear all members
  34819. objectEach(series, function (val, prop) {
  34820. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34821. delete series[prop];
  34822. }
  34823. });
  34824. };
  34825. /**
  34826. * Clip the graphs into zones for colors and styling.
  34827. *
  34828. * @private
  34829. * @function Highcharts.Series#applyZones
  34830. */
  34831. Series.prototype.applyZones = function () {
  34832. var series = this,
  34833. chart = this.chart,
  34834. renderer = chart.renderer,
  34835. zones = this.zones,
  34836. translatedFrom,
  34837. translatedTo,
  34838. clips = (this.clips || []),
  34839. clipAttr,
  34840. graph = this.graph,
  34841. area = this.area,
  34842. chartSizeMax = Math.max(chart.chartWidth,
  34843. chart.chartHeight),
  34844. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  34845. extremes,
  34846. reversed,
  34847. inverted = chart.inverted,
  34848. horiz,
  34849. pxRange,
  34850. pxPosMin,
  34851. pxPosMax,
  34852. ignoreZones = false,
  34853. zoneArea,
  34854. zoneGraph;
  34855. if (zones.length &&
  34856. (graph || area) &&
  34857. axis &&
  34858. typeof axis.min !== 'undefined') {
  34859. reversed = axis.reversed;
  34860. horiz = axis.horiz;
  34861. // The use of the Color Threshold assumes there are no gaps
  34862. // so it is safe to hide the original graph and area
  34863. // unless it is not waterfall series, then use showLine property
  34864. // to set lines between columns to be visible (#7862)
  34865. if (graph && !this.showLine) {
  34866. graph.hide();
  34867. }
  34868. if (area) {
  34869. area.hide();
  34870. }
  34871. // Create the clips
  34872. extremes = axis.getExtremes();
  34873. zones.forEach(function (threshold, i) {
  34874. translatedFrom = reversed ?
  34875. (horiz ? chart.plotWidth : 0) :
  34876. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  34877. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  34878. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  34879. if (ignoreZones) {
  34880. translatedFrom = translatedTo =
  34881. axis.toPixels(extremes.max);
  34882. }
  34883. pxRange = Math.abs(translatedFrom - translatedTo);
  34884. pxPosMin = Math.min(translatedFrom, translatedTo);
  34885. pxPosMax = Math.max(translatedFrom, translatedTo);
  34886. if (axis.isXAxis) {
  34887. clipAttr = {
  34888. x: inverted ? pxPosMax : pxPosMin,
  34889. y: 0,
  34890. width: pxRange,
  34891. height: chartSizeMax
  34892. };
  34893. if (!horiz) {
  34894. clipAttr.x = chart.plotHeight - clipAttr.x;
  34895. }
  34896. }
  34897. else {
  34898. clipAttr = {
  34899. x: 0,
  34900. y: inverted ? pxPosMax : pxPosMin,
  34901. width: chartSizeMax,
  34902. height: pxRange
  34903. };
  34904. if (horiz) {
  34905. clipAttr.y = chart.plotWidth - clipAttr.y;
  34906. }
  34907. }
  34908. // VML SUPPPORT
  34909. if (inverted && renderer.isVML) {
  34910. if (axis.isXAxis) {
  34911. clipAttr = {
  34912. x: 0,
  34913. y: reversed ? pxPosMin : pxPosMax,
  34914. height: clipAttr.width,
  34915. width: chart.chartWidth
  34916. };
  34917. }
  34918. else {
  34919. clipAttr = {
  34920. x: (clipAttr.y -
  34921. chart.plotLeft -
  34922. chart.spacingBox.x),
  34923. y: 0,
  34924. width: clipAttr.height,
  34925. height: chart.chartHeight
  34926. };
  34927. }
  34928. }
  34929. // END OF VML SUPPORT
  34930. if (clips[i]) {
  34931. clips[i].animate(clipAttr);
  34932. }
  34933. else {
  34934. clips[i] = renderer.clipRect(clipAttr);
  34935. }
  34936. // when no data, graph zone is not applied and after setData
  34937. // clip was ignored. As a result, it should be applied each
  34938. // time.
  34939. zoneArea = series['zone-area-' + i];
  34940. zoneGraph = series['zone-graph-' + i];
  34941. if (graph && zoneGraph) {
  34942. zoneGraph.clip(clips[i]);
  34943. }
  34944. if (area && zoneArea) {
  34945. zoneArea.clip(clips[i]);
  34946. }
  34947. // if this zone extends out of the axis, ignore the others
  34948. ignoreZones = threshold.value > extremes.max;
  34949. // Clear translatedTo for indicators
  34950. if (series.resetZones && translatedTo === 0) {
  34951. translatedTo = void 0;
  34952. }
  34953. });
  34954. this.clips = clips;
  34955. }
  34956. else if (series.visible) {
  34957. // If zones were removed, restore graph and area
  34958. if (graph) {
  34959. graph.show(true);
  34960. }
  34961. if (area) {
  34962. area.show(true);
  34963. }
  34964. }
  34965. };
  34966. /**
  34967. * Initialize and perform group inversion on series.group and
  34968. * series.markerGroup.
  34969. *
  34970. * @private
  34971. * @function Highcharts.Series#invertGroups
  34972. */
  34973. Series.prototype.invertGroups = function (inverted) {
  34974. var series = this,
  34975. chart = series.chart;
  34976. /**
  34977. * @private
  34978. */
  34979. function setInvert() {
  34980. ['group', 'markerGroup'].forEach(function (groupName) {
  34981. if (series[groupName]) {
  34982. // VML/HTML needs explicit attributes for flipping
  34983. if (chart.renderer.isVML) {
  34984. series[groupName].attr({
  34985. width: series.yAxis.len,
  34986. height: series.xAxis.len
  34987. });
  34988. }
  34989. series[groupName].width = series.yAxis.len;
  34990. series[groupName].height = series.xAxis.len;
  34991. // If inverted polar, don't invert series group
  34992. series[groupName].invert(series.isRadialSeries ? false : inverted);
  34993. }
  34994. });
  34995. }
  34996. // Pie, go away (#1736)
  34997. if (!series.xAxis) {
  34998. return;
  34999. }
  35000. // A fixed size is needed for inversion to work
  35001. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  35002. // Do it now
  35003. setInvert();
  35004. // On subsequent render and redraw, just do setInvert without
  35005. // setting up events again
  35006. series.invertGroups = setInvert;
  35007. };
  35008. /**
  35009. * General abstraction for creating plot groups like series.group,
  35010. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  35011. * the group will only be adjusted to the updated plot size.
  35012. *
  35013. * @private
  35014. * @function Highcharts.Series#plotGroup
  35015. */
  35016. Series.prototype.plotGroup = function (prop, name, visibility, zIndex, parent) {
  35017. var group = this[prop];
  35018. var isNew = !group,
  35019. attrs = {
  35020. visibility: visibility,
  35021. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  35022. };
  35023. // Avoid setting undefined opacity, or in styled mode
  35024. if (typeof this.opacity !== 'undefined' &&
  35025. !this.chart.styledMode && this.state !== 'inactive' // #13719
  35026. ) {
  35027. attrs.opacity = this.opacity;
  35028. }
  35029. // Generate it on first call
  35030. if (isNew) {
  35031. this[prop] = group = this.chart.renderer
  35032. .g()
  35033. .add(parent);
  35034. }
  35035. // Add the class names, and replace existing ones as response to
  35036. // Series.update (#6660)
  35037. group.addClass(('highcharts-' + name +
  35038. ' highcharts-series-' + this.index +
  35039. ' highcharts-' + this.type + '-series ' +
  35040. (defined(this.colorIndex) ?
  35041. 'highcharts-color-' + this.colorIndex + ' ' :
  35042. '') +
  35043. (this.options.className || '') +
  35044. (group.hasClass('highcharts-tracker') ?
  35045. ' highcharts-tracker' :
  35046. '')), true);
  35047. // Place it on first and subsequent (redraw) calls
  35048. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  35049. return group;
  35050. };
  35051. /**
  35052. * Get the translation and scale for the plot area of this series.
  35053. *
  35054. * @function Highcharts.Series#getPlotBox
  35055. *
  35056. * @return {Highcharts.SeriesPlotBoxObject}
  35057. */
  35058. Series.prototype.getPlotBox = function () {
  35059. var chart = this.chart,
  35060. xAxis = this.xAxis,
  35061. yAxis = this.yAxis;
  35062. // Swap axes for inverted (#2339)
  35063. if (chart.inverted) {
  35064. xAxis = yAxis;
  35065. yAxis = this.xAxis;
  35066. }
  35067. return {
  35068. translateX: xAxis ? xAxis.left : chart.plotLeft,
  35069. translateY: yAxis ? yAxis.top : chart.plotTop,
  35070. scaleX: 1,
  35071. scaleY: 1
  35072. };
  35073. };
  35074. /**
  35075. * Removes the event handlers attached previously with addEvents.
  35076. * @private
  35077. * @function Highcharts.Series#removeEvents
  35078. */
  35079. Series.prototype.removeEvents = function (keepEventsForUpdate) {
  35080. var series = this;
  35081. if (!keepEventsForUpdate) {
  35082. // remove all events
  35083. removeEvent(series);
  35084. }
  35085. if (series.eventsToUnbind.length) {
  35086. // remove only internal events for proper update
  35087. // #12355 - solves problem with multiple destroy events
  35088. series.eventsToUnbind.forEach(function (unbind) {
  35089. unbind();
  35090. });
  35091. series.eventsToUnbind.length = 0;
  35092. }
  35093. };
  35094. /**
  35095. * Render the graph and markers. Called internally when first rendering
  35096. * and later when redrawing the chart. This function can be extended in
  35097. * plugins, but normally shouldn't be called directly.
  35098. *
  35099. * @function Highcharts.Series#render
  35100. *
  35101. * @fires Highcharts.Series#event:afterRender
  35102. */
  35103. Series.prototype.render = function () {
  35104. var series = this,
  35105. chart = series.chart,
  35106. group,
  35107. options = series.options,
  35108. animOptions = animObject(options.animation),
  35109. // Animation doesn't work in IE8 quirks when the group div is
  35110. // hidden, and looks bad in other oldIE
  35111. animDuration = (!series.finishedAnimating &&
  35112. chart.renderer.isSVG &&
  35113. animOptions.duration),
  35114. visibility = series.visible ?
  35115. 'inherit' : 'hidden', // #2597
  35116. zIndex = options.zIndex,
  35117. hasRendered = series.hasRendered,
  35118. chartSeriesGroup = chart.seriesGroup,
  35119. inverted = chart.inverted;
  35120. fireEvent(this, 'render');
  35121. // the group
  35122. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  35123. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  35124. // initiate the animation
  35125. if (animDuration && series.animate) {
  35126. series.animate(true);
  35127. }
  35128. // SVGRenderer needs to know this before drawing elements (#1089,
  35129. // #1795)
  35130. group.inverted = pick(series.invertible, series.isCartesian) ?
  35131. inverted : false;
  35132. // Draw the graph if any
  35133. if (series.drawGraph) {
  35134. series.drawGraph();
  35135. series.applyZones();
  35136. }
  35137. // Draw the points
  35138. if (series.visible) {
  35139. series.drawPoints();
  35140. }
  35141. /* series.points.forEach(function (point) {
  35142. if (point.redraw) {
  35143. point.redraw();
  35144. }
  35145. }); */
  35146. // Draw the data labels
  35147. if (series.drawDataLabels) {
  35148. series.drawDataLabels();
  35149. }
  35150. // In pie charts, slices are added to the DOM, but actual rendering
  35151. // is postponed until labels reserved their space
  35152. if (series.redrawPoints) {
  35153. series.redrawPoints();
  35154. }
  35155. // draw the mouse tracking area
  35156. if (series.drawTracker &&
  35157. series.options.enableMouseTracking !== false) {
  35158. series.drawTracker();
  35159. }
  35160. // Handle inverted series and tracker groups
  35161. series.invertGroups(inverted);
  35162. // Initial clipping, must be defined after inverting groups for VML.
  35163. // Applies to columns etc. (#3839).
  35164. if (options.clip !== false &&
  35165. !series.sharedClipKey &&
  35166. !hasRendered) {
  35167. group.clip(chart.clipRect);
  35168. }
  35169. // Run the animation
  35170. if (animDuration && series.animate) {
  35171. series.animate();
  35172. }
  35173. // Call the afterAnimate function on animation complete (but don't
  35174. // overwrite the animation.complete option which should be available
  35175. // to the user).
  35176. if (!hasRendered) {
  35177. // Additional time if defer is defined before afterAnimate
  35178. // will be triggered
  35179. if (animDuration && animOptions.defer) {
  35180. animDuration += animOptions.defer;
  35181. }
  35182. series.animationTimeout = syncTimeout(function () {
  35183. series.afterAnimate();
  35184. }, animDuration || 0);
  35185. }
  35186. // Means data is in accordance with what you see
  35187. series.isDirty = false;
  35188. // (See #322) series.isDirty = series.isDirtyData = false; // means
  35189. // data is in accordance with what you see
  35190. series.hasRendered = true;
  35191. fireEvent(series, 'afterRender');
  35192. };
  35193. /**
  35194. * Redraw the series. This function is called internally from
  35195. * `chart.redraw` and normally shouldn't be called directly.
  35196. * @private
  35197. * @function Highcharts.Series#redraw
  35198. */
  35199. Series.prototype.redraw = function () {
  35200. var series = this,
  35201. chart = series.chart,
  35202. // cache it here as it is set to false in render, but used after
  35203. wasDirty = series.isDirty || series.isDirtyData,
  35204. group = series.group,
  35205. xAxis = series.xAxis,
  35206. yAxis = series.yAxis;
  35207. // reposition on resize
  35208. if (group) {
  35209. if (chart.inverted) {
  35210. group.attr({
  35211. width: chart.plotWidth,
  35212. height: chart.plotHeight
  35213. });
  35214. }
  35215. group.animate({
  35216. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  35217. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  35218. });
  35219. }
  35220. series.translate();
  35221. series.render();
  35222. if (wasDirty) { // #3868, #3945
  35223. delete this.kdTree;
  35224. }
  35225. };
  35226. /**
  35227. * @private
  35228. * @function Highcharts.Series#searchPoint
  35229. */
  35230. Series.prototype.searchPoint = function (e, compareX) {
  35231. var series = this,
  35232. xAxis = series.xAxis,
  35233. yAxis = series.yAxis,
  35234. inverted = series.chart.inverted;
  35235. return this.searchKDTree({
  35236. clientX: inverted ?
  35237. xAxis.len - e.chartY + xAxis.pos :
  35238. e.chartX - xAxis.pos,
  35239. plotY: inverted ?
  35240. yAxis.len - e.chartX + yAxis.pos :
  35241. e.chartY - yAxis.pos
  35242. }, compareX, e);
  35243. };
  35244. /**
  35245. * Build the k-d-tree that is used by mouse and touch interaction to get
  35246. * the closest point. Line-like series typically have a one-dimensional
  35247. * tree where points are searched along the X axis, while scatter-like
  35248. * series typically search in two dimensions, X and Y.
  35249. *
  35250. * @private
  35251. * @function Highcharts.Series#buildKDTree
  35252. */
  35253. Series.prototype.buildKDTree = function (e) {
  35254. // Prevent multiple k-d-trees from being built simultaneously
  35255. // (#6235)
  35256. this.buildingKdTree = true;
  35257. var series = this,
  35258. dimensions = series.options.findNearestPointBy
  35259. .indexOf('y') > -1 ? 2 : 1;
  35260. /**
  35261. * Internal function
  35262. * @private
  35263. */
  35264. function _kdtree(points, depth, dimensions) {
  35265. var axis,
  35266. median,
  35267. length = points && points.length;
  35268. if (length) {
  35269. // alternate between the axis
  35270. axis = series.kdAxisArray[depth % dimensions];
  35271. // sort point array
  35272. points.sort(function (a, b) {
  35273. return a[axis] - b[axis];
  35274. });
  35275. median = Math.floor(length / 2);
  35276. // build and return nod
  35277. return {
  35278. point: points[median],
  35279. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  35280. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  35281. };
  35282. }
  35283. }
  35284. /**
  35285. * Start the recursive build process with a clone of the points
  35286. * array and null points filtered out. (#3873)
  35287. * @private
  35288. */
  35289. function startRecursive() {
  35290. series.kdTree = _kdtree(series.getValidPoints(null,
  35291. // For line-type series restrict to plot area, but
  35292. // column-type series not (#3916, #4511)
  35293. !series.directTouch), dimensions, dimensions);
  35294. series.buildingKdTree = false;
  35295. }
  35296. delete series.kdTree;
  35297. // For testing tooltips, don't build async. Also if touchstart, we
  35298. // may be dealing with click events on mobile, so don't delay
  35299. // (#6817).
  35300. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  35301. };
  35302. /**
  35303. * @private
  35304. * @function Highcharts.Series#searchKDTree
  35305. */
  35306. Series.prototype.searchKDTree = function (point, compareX, e) {
  35307. var series = this,
  35308. kdX = this.kdAxisArray[0],
  35309. kdY = this.kdAxisArray[1],
  35310. kdComparer = compareX ? 'distX' : 'dist',
  35311. kdDimensions = series.options.findNearestPointBy
  35312. .indexOf('y') > -1 ? 2 : 1;
  35313. /**
  35314. * Set the one and two dimensional distance on the point object.
  35315. * @private
  35316. */
  35317. function setDistance(p1, p2) {
  35318. var x = (defined(p1[kdX]) &&
  35319. defined(p2[kdX])) ?
  35320. Math.pow(p1[kdX] - p2[kdX], 2) :
  35321. null,
  35322. y = (defined(p1[kdY]) &&
  35323. defined(p2[kdY])) ?
  35324. Math.pow(p1[kdY] - p2[kdY], 2) :
  35325. null,
  35326. r = (x || 0) + (y || 0);
  35327. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  35328. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  35329. }
  35330. /**
  35331. * @private
  35332. */
  35333. function _search(search, tree, depth, dimensions) {
  35334. var point = tree.point,
  35335. axis = series.kdAxisArray[depth % dimensions],
  35336. tdist,
  35337. sideA,
  35338. sideB,
  35339. ret = point,
  35340. nPoint1,
  35341. nPoint2;
  35342. setDistance(search, point);
  35343. // Pick side based on distance to splitting point
  35344. tdist = search[axis] - point[axis];
  35345. sideA = tdist < 0 ? 'left' : 'right';
  35346. sideB = tdist < 0 ? 'right' : 'left';
  35347. // End of tree
  35348. if (tree[sideA]) {
  35349. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35350. ret = (nPoint1[kdComparer] <
  35351. ret[kdComparer] ?
  35352. nPoint1 :
  35353. point);
  35354. }
  35355. if (tree[sideB]) {
  35356. // compare distance to current best to splitting point to
  35357. // decide wether to check side B or not
  35358. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35359. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35360. ret = (nPoint2[kdComparer] <
  35361. ret[kdComparer] ?
  35362. nPoint2 :
  35363. ret);
  35364. }
  35365. }
  35366. return ret;
  35367. }
  35368. if (!this.kdTree && !this.buildingKdTree) {
  35369. this.buildKDTree(e);
  35370. }
  35371. if (this.kdTree) {
  35372. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35373. }
  35374. };
  35375. /**
  35376. * @private
  35377. * @function Highcharts.Series#pointPlacementToXValue
  35378. */
  35379. Series.prototype.pointPlacementToXValue = function () {
  35380. var _a = this,
  35381. _b = _a.options,
  35382. pointPlacement = _b.pointPlacement,
  35383. pointRange = _b.pointRange,
  35384. axis = _a.xAxis;
  35385. var factor = pointPlacement;
  35386. // Point placement is relative to each series pointRange (#5889)
  35387. if (factor === 'between') {
  35388. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35389. }
  35390. return isNumber(factor) ?
  35391. factor * (pointRange || axis.pointRange) :
  35392. 0;
  35393. };
  35394. /**
  35395. * @private
  35396. * @function Highcharts.Series#isPointInside
  35397. */
  35398. Series.prototype.isPointInside = function (point) {
  35399. var isInside = typeof point.plotY !== 'undefined' &&
  35400. typeof point.plotX !== 'undefined' &&
  35401. point.plotY >= 0 &&
  35402. point.plotY <= this.yAxis.len && // #3519
  35403. point.plotX >= 0 &&
  35404. point.plotX <= this.xAxis.len;
  35405. return isInside;
  35406. };
  35407. /**
  35408. * Draw the tracker object that sits above all data labels and markers to
  35409. * track mouse events on the graph or points. For the line type charts
  35410. * the tracker uses the same graphPath, but with a greater stroke width
  35411. * for better control.
  35412. * @private
  35413. */
  35414. Series.prototype.drawTracker = function () {
  35415. var series = this,
  35416. options = series.options,
  35417. trackByArea = options.trackByArea,
  35418. trackerPath = [].concat(trackByArea ?
  35419. series.areaPath :
  35420. series.graphPath),
  35421. // trackerPathLength = trackerPath.length,
  35422. chart = series.chart,
  35423. pointer = chart.pointer,
  35424. renderer = chart.renderer,
  35425. snap = chart.options.tooltip.snap,
  35426. tracker = series.tracker,
  35427. i,
  35428. onMouseOver = function (e) {
  35429. if (chart.hoverSeries !== series) {
  35430. series.onMouseOver();
  35431. }
  35432. },
  35433. /*
  35434. * Empirical lowest possible opacities for TRACKER_FILL for an
  35435. * element to stay invisible but clickable
  35436. * IE6: 0.002
  35437. * IE7: 0.002
  35438. * IE8: 0.002
  35439. * IE9: 0.00000000001 (unlimited)
  35440. * IE10: 0.0001 (exporting only)
  35441. * FF: 0.00000000001 (unlimited)
  35442. * Chrome: 0.000001
  35443. * Safari: 0.000001
  35444. * Opera: 0.00000000001 (unlimited)
  35445. */
  35446. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  35447. // Draw the tracker
  35448. if (tracker) {
  35449. tracker.attr({ d: trackerPath });
  35450. }
  35451. else if (series.graph) { // create
  35452. series.tracker = renderer.path(trackerPath)
  35453. .attr({
  35454. visibility: series.visible ? 'visible' : 'hidden',
  35455. zIndex: 2
  35456. })
  35457. .addClass(trackByArea ?
  35458. 'highcharts-tracker-area' :
  35459. 'highcharts-tracker-line')
  35460. .add(series.group);
  35461. if (!chart.styledMode) {
  35462. series.tracker.attr({
  35463. 'stroke-linecap': 'round',
  35464. 'stroke-linejoin': 'round',
  35465. stroke: TRACKER_FILL,
  35466. fill: trackByArea ? TRACKER_FILL : 'none',
  35467. 'stroke-width': series.graph.strokeWidth() +
  35468. (trackByArea ? 0 : 2 * snap)
  35469. });
  35470. }
  35471. // The tracker is added to the series group, which is clipped, but
  35472. // is covered by the marker group. So the marker group also needs to
  35473. // capture events.
  35474. [
  35475. series.tracker,
  35476. series.markerGroup,
  35477. series.dataLabelsGroup
  35478. ].forEach(function (tracker) {
  35479. if (tracker) {
  35480. tracker.addClass('highcharts-tracker')
  35481. .on('mouseover', onMouseOver)
  35482. .on('mouseout', function (e) {
  35483. pointer.onTrackerMouseOut(e);
  35484. });
  35485. if (options.cursor && !chart.styledMode) {
  35486. tracker.css({ cursor: options.cursor });
  35487. }
  35488. if (hasTouch) {
  35489. tracker.on('touchstart', onMouseOver);
  35490. }
  35491. }
  35492. });
  35493. }
  35494. fireEvent(this, 'afterDrawTracker');
  35495. };
  35496. /**
  35497. * Add a point to the series after render time. The point can be added at
  35498. * the end, or by giving it an X value, to the start or in the middle of the
  35499. * series.
  35500. *
  35501. * @sample highcharts/members/series-addpoint-append/
  35502. * Append point
  35503. * @sample highcharts/members/series-addpoint-append-and-shift/
  35504. * Append and shift
  35505. * @sample highcharts/members/series-addpoint-x-and-y/
  35506. * Both X and Y values given
  35507. * @sample highcharts/members/series-addpoint-pie/
  35508. * Append pie slice
  35509. * @sample stock/members/series-addpoint/
  35510. * Append 100 points in Highcharts Stock
  35511. * @sample stock/members/series-addpoint-shift/
  35512. * Append and shift in Highcharts Stock
  35513. * @sample maps/members/series-addpoint/
  35514. * Add a point in Highmaps
  35515. *
  35516. * @function Highcharts.Series#addPoint
  35517. *
  35518. * @param {Highcharts.PointOptionsType} options
  35519. * The point options. If options is a single number, a point with
  35520. * that y value is appended to the series. If it is an array, it will
  35521. * be interpreted as x and y values respectively. If it is an
  35522. * object, advanced options as outlined under `series.data` are
  35523. * applied.
  35524. *
  35525. * @param {boolean} [redraw=true]
  35526. * Whether to redraw the chart after the point is added. When adding
  35527. * more than one point, it is highly recommended that the redraw
  35528. * option be set to false, and instead {@link Chart#redraw} is
  35529. * explicitly called after the adding of points is finished.
  35530. * Otherwise, the chart will redraw after adding each point.
  35531. *
  35532. * @param {boolean} [shift=false]
  35533. * If true, a point is shifted off the start of the series as one is
  35534. * appended to the end.
  35535. *
  35536. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35537. * Whether to apply animation, and optionally animation
  35538. * configuration.
  35539. *
  35540. * @param {boolean} [withEvent=true]
  35541. * Used internally, whether to fire the series `addPoint` event.
  35542. *
  35543. * @fires Highcharts.Series#event:addPoint
  35544. */
  35545. Series.prototype.addPoint = function (options, redraw, shift, animation, withEvent) {
  35546. var series = this,
  35547. seriesOptions = series.options,
  35548. data = series.data,
  35549. chart = series.chart,
  35550. xAxis = series.xAxis,
  35551. names = xAxis && xAxis.hasNames && xAxis.names,
  35552. dataOptions = seriesOptions.data,
  35553. point,
  35554. xData = series.xData,
  35555. isInTheMiddle,
  35556. i,
  35557. x;
  35558. // Optional redraw, defaults to true
  35559. redraw = pick(redraw, true);
  35560. // Get options and push the point to xData, yData and series.options. In
  35561. // series.generatePoints the Point instance will be created on demand
  35562. // and pushed to the series.data array.
  35563. point = { series: series };
  35564. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35565. x = point.x;
  35566. // Get the insertion point
  35567. i = xData.length;
  35568. if (series.requireSorting && x < xData[i - 1]) {
  35569. isInTheMiddle = true;
  35570. while (i && xData[i - 1] > x) {
  35571. i--;
  35572. }
  35573. }
  35574. // Insert undefined item
  35575. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35576. // Update it
  35577. series.updateParallelArrays(point, i);
  35578. if (names && point.name) {
  35579. names[x] = point.name;
  35580. }
  35581. dataOptions.splice(i, 0, options);
  35582. if (isInTheMiddle) {
  35583. series.data.splice(i, 0, null);
  35584. series.processData();
  35585. }
  35586. // Generate points to be added to the legend (#1329)
  35587. if (seriesOptions.legendType === 'point') {
  35588. series.generatePoints();
  35589. }
  35590. // Shift the first point off the parallel arrays
  35591. if (shift) {
  35592. if (data[0] && data[0].remove) {
  35593. data[0].remove(false);
  35594. }
  35595. else {
  35596. data.shift();
  35597. series.updateParallelArrays(point, 'shift');
  35598. dataOptions.shift();
  35599. }
  35600. }
  35601. // Fire event
  35602. if (withEvent !== false) {
  35603. fireEvent(series, 'addPoint', { point: point });
  35604. }
  35605. // redraw
  35606. series.isDirty = true;
  35607. series.isDirtyData = true;
  35608. if (redraw) {
  35609. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35610. }
  35611. };
  35612. /**
  35613. * Remove a point from the series. Unlike the
  35614. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35615. * that is not instanciated because it is outside the view or subject to
  35616. * Highcharts Stock data grouping.
  35617. *
  35618. * @sample highcharts/members/series-removepoint/
  35619. * Remove cropped point
  35620. *
  35621. * @function Highcharts.Series#removePoint
  35622. *
  35623. * @param {number} i
  35624. * The index of the point in the {@link Highcharts.Series.data|data}
  35625. * array.
  35626. *
  35627. * @param {boolean} [redraw=true]
  35628. * Whether to redraw the chart after the point is added. When
  35629. * removing more than one point, it is highly recommended that the
  35630. * `redraw` option be set to `false`, and instead {@link
  35631. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35632. * points is finished.
  35633. *
  35634. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35635. * Whether and optionally how the series should be animated.
  35636. *
  35637. * @fires Highcharts.Point#event:remove
  35638. */
  35639. Series.prototype.removePoint = function (i, redraw, animation) {
  35640. var series = this,
  35641. data = series.data,
  35642. point = data[i],
  35643. points = series.points,
  35644. chart = series.chart,
  35645. remove = function () {
  35646. if (points && points.length === data.length) { // #4935
  35647. points.splice(i, 1);
  35648. }
  35649. data.splice(i, 1);
  35650. series.options.data.splice(i, 1);
  35651. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35652. if (point) {
  35653. point.destroy();
  35654. }
  35655. // redraw
  35656. series.isDirty = true;
  35657. series.isDirtyData = true;
  35658. if (redraw) {
  35659. chart.redraw();
  35660. }
  35661. };
  35662. setAnimation(animation, chart);
  35663. redraw = pick(redraw, true);
  35664. // Fire the event with a default handler of removing the point
  35665. if (point) {
  35666. point.firePointEvent('remove', null, remove);
  35667. }
  35668. else {
  35669. remove();
  35670. }
  35671. };
  35672. /**
  35673. * Remove a series and optionally redraw the chart.
  35674. *
  35675. * @sample highcharts/members/series-remove/
  35676. * Remove first series from a button
  35677. *
  35678. * @function Highcharts.Series#remove
  35679. *
  35680. * @param {boolean} [redraw=true]
  35681. * Whether to redraw the chart or wait for an explicit call to
  35682. * {@link Highcharts.Chart#redraw}.
  35683. *
  35684. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35685. * Whether to apply animation, and optionally animation
  35686. * configuration.
  35687. *
  35688. * @param {boolean} [withEvent=true]
  35689. * Used internally, whether to fire the series `remove` event.
  35690. *
  35691. * @fires Highcharts.Series#event:remove
  35692. */
  35693. Series.prototype.remove = function (redraw, animation, withEvent, keepEvents) {
  35694. var series = this,
  35695. chart = series.chart;
  35696. /**
  35697. * @private
  35698. */
  35699. function remove() {
  35700. // Destroy elements
  35701. series.destroy(keepEvents);
  35702. // Redraw
  35703. chart.isDirtyLegend = chart.isDirtyBox = true;
  35704. chart.linkSeries();
  35705. if (pick(redraw, true)) {
  35706. chart.redraw(animation);
  35707. }
  35708. }
  35709. // Fire the event with a default handler of removing the point
  35710. if (withEvent !== false) {
  35711. fireEvent(series, 'remove', null, remove);
  35712. }
  35713. else {
  35714. remove();
  35715. }
  35716. };
  35717. /**
  35718. * Update the series with a new set of options. For a clean and precise
  35719. * handling of new options, all methods and elements from the series are
  35720. * removed, and it is initialized from scratch. Therefore, this method is
  35721. * more performance expensive than some other utility methods like {@link
  35722. * Series#setData} or {@link Series#setVisible}.
  35723. *
  35724. * Note that `Series.update` may mutate the passed `data` options.
  35725. *
  35726. * @sample highcharts/members/series-update/
  35727. * Updating series options
  35728. * @sample maps/members/series-update/
  35729. * Update series options in Highmaps
  35730. *
  35731. * @function Highcharts.Series#update
  35732. *
  35733. * @param {Highcharts.SeriesOptionsType} options
  35734. * New options that will be merged with the series' existing options.
  35735. *
  35736. * @param {boolean} [redraw=true]
  35737. * Whether to redraw the chart after the series is altered. If doing
  35738. * more operations on the chart, it is a good idea to set redraw to
  35739. * false and call {@link Chart#redraw} after.
  35740. *
  35741. * @fires Highcharts.Series#event:update
  35742. * @fires Highcharts.Series#event:afterUpdate
  35743. */
  35744. Series.prototype.update = function (options, redraw) {
  35745. options = cleanRecursively(options, this.userOptions);
  35746. fireEvent(this, 'update', { options: options });
  35747. var series = this,
  35748. chart = series.chart,
  35749. // must use user options when changing type because series.options
  35750. // is merged in with type specific plotOptions
  35751. oldOptions = series.userOptions,
  35752. seriesOptions,
  35753. initialType = series.initialType || series.type,
  35754. plotOptions = chart.options.plotOptions,
  35755. newType = (options.type ||
  35756. oldOptions.type ||
  35757. chart.options.chart.type),
  35758. keepPoints = !(
  35759. // Indicators, histograms etc recalculate the data. It should be
  35760. // possible to omit this.
  35761. this.hasDerivedData ||
  35762. // New type requires new point classes
  35763. (newType && newType !== this.type) ||
  35764. // New options affecting how the data points are built
  35765. typeof options.pointStart !== 'undefined' ||
  35766. typeof options.pointInterval !== 'undefined' ||
  35767. // Changes to data grouping requires new points in new group
  35768. series.hasOptionChanged('dataGrouping') ||
  35769. series.hasOptionChanged('pointStart') ||
  35770. series.hasOptionChanged('pointInterval') ||
  35771. series.hasOptionChanged('pointIntervalUnit') ||
  35772. series.hasOptionChanged('keys')),
  35773. initialSeriesProto = seriesTypes[initialType].prototype,
  35774. n,
  35775. groups = [
  35776. 'group',
  35777. 'markerGroup',
  35778. 'dataLabelsGroup',
  35779. 'transformGroup'
  35780. ],
  35781. preserve = [
  35782. 'eventOptions',
  35783. 'navigatorSeries',
  35784. 'baseSeries'
  35785. ],
  35786. // Animation must be enabled when calling update before the initial
  35787. // animation has first run. This happens when calling update
  35788. // directly after chart initialization, or when applying responsive
  35789. // rules (#6912).
  35790. animation = series.finishedAnimating && { animation: false },
  35791. kinds = {};
  35792. newType = newType || initialType;
  35793. if (keepPoints) {
  35794. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels', 'clips', // #15420
  35795. // Networkgraph (#14397)
  35796. 'nodes', 'layout',
  35797. // Map specific, consider moving it to series-specific preserve-
  35798. // properties (#10617)
  35799. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35800. if (options.visible !== false) {
  35801. preserve.push('area', 'graph');
  35802. }
  35803. series.parallelArrays.forEach(function (key) {
  35804. preserve.push(key + 'Data');
  35805. });
  35806. if (options.data) {
  35807. // setData uses dataSorting options so we need to update them
  35808. // earlier
  35809. if (options.dataSorting) {
  35810. extend(series.options.dataSorting, options.dataSorting);
  35811. }
  35812. this.setData(options.data, false);
  35813. }
  35814. }
  35815. // Do the merge, with some forced options
  35816. options = merge(oldOptions, animation, {
  35817. // When oldOptions.index is null it should't be cleared.
  35818. // Otherwise navigator series will have wrong indexes (#10193).
  35819. index: typeof oldOptions.index === 'undefined' ?
  35820. series.index : oldOptions.index,
  35821. pointStart: pick(
  35822. // when updating from blank (#7933)
  35823. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  35824. // when updating after addPoint
  35825. series.xData[0])
  35826. }, (!keepPoints && { data: series.options.data }), options);
  35827. // Merge does not merge arrays, but replaces them. Since points were
  35828. // updated, `series.options.data` has correct merged options, use it:
  35829. if (keepPoints && options.data) {
  35830. options.data = series.options.data;
  35831. }
  35832. // Make sure preserved properties are not destroyed (#3094)
  35833. preserve = groups.concat(preserve);
  35834. preserve.forEach(function (prop) {
  35835. preserve[prop] = series[prop];
  35836. delete series[prop];
  35837. });
  35838. var casting = false;
  35839. if (seriesTypes[newType]) {
  35840. casting = newType !== series.type;
  35841. // Destroy the series and delete all properties, it will be
  35842. // reinserted within the `init` call below
  35843. series.remove(false, false, false, true);
  35844. if (casting) {
  35845. // Modern browsers including IE11
  35846. // @todo slow, consider alternatives mentioned:
  35847. // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
  35848. if (Object.setPrototypeOf) {
  35849. Object.setPrototypeOf(series, seriesTypes[newType].prototype);
  35850. // Legacy (IE < 11)
  35851. }
  35852. else {
  35853. var ownEvents = Object.hasOwnProperty.call(series, 'hcEvents') &&
  35854. series.hcEvents;
  35855. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35856. series[n] = void 0;
  35857. }
  35858. // Reinsert all methods and properties from the new type
  35859. // prototype (#2270, #3719).
  35860. extend(series, seriesTypes[newType].prototype);
  35861. // The events are tied to the prototype chain, don't copy if
  35862. // they're not the series' own
  35863. if (ownEvents) {
  35864. series.hcEvents = ownEvents;
  35865. }
  35866. else {
  35867. delete series.hcEvents;
  35868. }
  35869. }
  35870. }
  35871. }
  35872. else {
  35873. error(17, true, chart, { missingModuleFor: newType });
  35874. }
  35875. // Re-register groups (#3094) and other preserved properties
  35876. preserve.forEach(function (prop) {
  35877. series[prop] = preserve[prop];
  35878. });
  35879. series.init(chart, options);
  35880. // Remove particular elements of the points. Check `series.options`
  35881. // because we need to consider the options being set on plotOptions as
  35882. // well.
  35883. if (keepPoints && this.points) {
  35884. seriesOptions = series.options;
  35885. // What kind of elements to destroy
  35886. if (seriesOptions.visible === false) {
  35887. kinds.graphic = 1;
  35888. kinds.dataLabel = 1;
  35889. }
  35890. else if (!series._hasPointLabels) {
  35891. var marker = seriesOptions.marker,
  35892. dataLabels = seriesOptions.dataLabels;
  35893. if (marker && (marker.enabled === false ||
  35894. 'symbol' in marker // #10870
  35895. )) {
  35896. kinds.graphic = 1;
  35897. }
  35898. if (dataLabels &&
  35899. dataLabels.enabled === false) {
  35900. kinds.dataLabel = 1;
  35901. }
  35902. }
  35903. this.points.forEach(function (point) {
  35904. if (point && point.series) {
  35905. point.resolveColor();
  35906. // Destroy elements in order to recreate based on updated
  35907. // series options.
  35908. if (Object.keys(kinds).length) {
  35909. point.destroyElements(kinds);
  35910. }
  35911. if (seriesOptions.showInLegend === false &&
  35912. point.legendItem) {
  35913. chart.legend.destroyItem(point);
  35914. }
  35915. }
  35916. }, this);
  35917. }
  35918. series.initialType = initialType;
  35919. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35920. // #15383: Fire updatedData if the type has changed to keep linked
  35921. // series such as indicators updated
  35922. if (casting && series.linkedSeries.length) {
  35923. series.isDirtyData = true;
  35924. }
  35925. fireEvent(this, 'afterUpdate');
  35926. if (pick(redraw, true)) {
  35927. chart.redraw(keepPoints ? void 0 : false);
  35928. }
  35929. };
  35930. /**
  35931. * Used from within series.update
  35932. * @private
  35933. */
  35934. Series.prototype.setName = function (name) {
  35935. this.name = this.options.name = this.userOptions.name = name;
  35936. this.chart.isDirtyLegend = true;
  35937. };
  35938. /**
  35939. * Check if the option has changed.
  35940. * @private
  35941. */
  35942. Series.prototype.hasOptionChanged = function (optionName) {
  35943. var chart = this.chart,
  35944. option = this.options[optionName],
  35945. plotOptions = chart.options.plotOptions,
  35946. oldOption = this.userOptions[optionName];
  35947. if (oldOption) {
  35948. return option !== oldOption;
  35949. }
  35950. return option !==
  35951. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  35952. };
  35953. /**
  35954. * Runs on mouse over the series graphical items.
  35955. *
  35956. * @function Highcharts.Series#onMouseOver
  35957. * @fires Highcharts.Series#event:mouseOver
  35958. */
  35959. Series.prototype.onMouseOver = function () {
  35960. var series = this,
  35961. chart = series.chart,
  35962. hoverSeries = chart.hoverSeries,
  35963. pointer = chart.pointer;
  35964. pointer.setHoverChartIndex();
  35965. // set normal state to previous series
  35966. if (hoverSeries && hoverSeries !== series) {
  35967. hoverSeries.onMouseOut();
  35968. }
  35969. // trigger the event, but to save processing time,
  35970. // only if defined
  35971. if (series.options.events.mouseOver) {
  35972. fireEvent(series, 'mouseOver');
  35973. }
  35974. // hover this
  35975. series.setState('hover');
  35976. /**
  35977. * Contains the original hovered series.
  35978. *
  35979. * @name Highcharts.Chart#hoverSeries
  35980. * @type {Highcharts.Series|null}
  35981. */
  35982. chart.hoverSeries = series;
  35983. };
  35984. /**
  35985. * Runs on mouse out of the series graphical items.
  35986. *
  35987. * @function Highcharts.Series#onMouseOut
  35988. *
  35989. * @fires Highcharts.Series#event:mouseOut
  35990. */
  35991. Series.prototype.onMouseOut = function () {
  35992. // trigger the event only if listeners exist
  35993. var series = this,
  35994. options = series.options,
  35995. chart = series.chart,
  35996. tooltip = chart.tooltip,
  35997. hoverPoint = chart.hoverPoint;
  35998. // #182, set to null before the mouseOut event fires
  35999. chart.hoverSeries = null;
  36000. // trigger mouse out on the point, which must be in this series
  36001. if (hoverPoint) {
  36002. hoverPoint.onMouseOut();
  36003. }
  36004. // fire the mouse out event
  36005. if (series && options.events.mouseOut) {
  36006. fireEvent(series, 'mouseOut');
  36007. }
  36008. // hide the tooltip
  36009. if (tooltip &&
  36010. !series.stickyTracking &&
  36011. (!tooltip.shared || series.noSharedTooltip)) {
  36012. tooltip.hide();
  36013. }
  36014. // Reset all inactive states
  36015. chart.series.forEach(function (s) {
  36016. s.setState('', true);
  36017. });
  36018. };
  36019. /**
  36020. * Set the state of the series. Called internally on mouse interaction
  36021. * operations, but it can also be called directly to visually
  36022. * highlight a series.
  36023. *
  36024. * @function Highcharts.Series#setState
  36025. *
  36026. * @param {Highcharts.SeriesStateValue|""} [state]
  36027. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  36028. * or `''` (an empty string), `'normal'` or `undefined` to set to
  36029. * normal state.
  36030. * @param {boolean} [inherit]
  36031. * Determines if state should be inherited by points too.
  36032. */
  36033. Series.prototype.setState = function (state, inherit) {
  36034. var series = this,
  36035. options = series.options,
  36036. graph = series.graph,
  36037. inactiveOtherPoints = options.inactiveOtherPoints,
  36038. stateOptions = options.states,
  36039. lineWidth = options.lineWidth,
  36040. opacity = options.opacity,
  36041. // By default a quick animation to hover/inactive,
  36042. // slower to un-hover
  36043. stateAnimation = pick((stateOptions[state || 'normal'] &&
  36044. stateOptions[state || 'normal'].animation),
  36045. series.chart.options.chart.animation),
  36046. attribs,
  36047. i = 0;
  36048. state = state || '';
  36049. if (series.state !== state) {
  36050. // Toggle class names
  36051. [
  36052. series.group,
  36053. series.markerGroup,
  36054. series.dataLabelsGroup
  36055. ].forEach(function (group) {
  36056. if (group) {
  36057. // Old state
  36058. if (series.state) {
  36059. group.removeClass('highcharts-series-' + series.state);
  36060. }
  36061. // New state
  36062. if (state) {
  36063. group.addClass('highcharts-series-' + state);
  36064. }
  36065. }
  36066. });
  36067. series.state = state;
  36068. if (!series.chart.styledMode) {
  36069. if (stateOptions[state] &&
  36070. stateOptions[state].enabled === false) {
  36071. return;
  36072. }
  36073. if (state) {
  36074. lineWidth = (stateOptions[state].lineWidth ||
  36075. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  36076. opacity = pick(stateOptions[state].opacity, opacity);
  36077. }
  36078. if (graph && !graph.dashstyle) {
  36079. attribs = {
  36080. 'stroke-width': lineWidth
  36081. };
  36082. // Animate the graph stroke-width.
  36083. graph.animate(attribs, stateAnimation);
  36084. while (series['zone-graph-' + i]) {
  36085. series['zone-graph-' + i].animate(attribs, stateAnimation);
  36086. i = i + 1;
  36087. }
  36088. }
  36089. // For some types (pie, networkgraph, sankey) opacity is
  36090. // resolved on a point level
  36091. if (!inactiveOtherPoints) {
  36092. [
  36093. series.group,
  36094. series.markerGroup,
  36095. series.dataLabelsGroup,
  36096. series.labelBySeries
  36097. ].forEach(function (group) {
  36098. if (group) {
  36099. group.animate({
  36100. opacity: opacity
  36101. }, stateAnimation);
  36102. }
  36103. });
  36104. }
  36105. }
  36106. }
  36107. // Don't loop over points on a series that doesn't apply inactive state
  36108. // to siblings markers (e.g. line, column)
  36109. if (inherit && inactiveOtherPoints && series.points) {
  36110. series.setAllPointsToState(state || void 0);
  36111. }
  36112. };
  36113. /**
  36114. * Set the state for all points in the series.
  36115. *
  36116. * @function Highcharts.Series#setAllPointsToState
  36117. *
  36118. * @private
  36119. *
  36120. * @param {string} [state]
  36121. * Can be either `hover` or undefined to set to normal state.
  36122. */
  36123. Series.prototype.setAllPointsToState = function (state) {
  36124. this.points.forEach(function (point) {
  36125. if (point.setState) {
  36126. point.setState(state);
  36127. }
  36128. });
  36129. };
  36130. /**
  36131. * Show or hide the series.
  36132. *
  36133. * @function Highcharts.Series#setVisible
  36134. *
  36135. * @param {boolean} [visible]
  36136. * True to show the series, false to hide. If undefined, the visibility is
  36137. * toggled.
  36138. *
  36139. * @param {boolean} [redraw=true]
  36140. * Whether to redraw the chart after the series is altered. If doing more
  36141. * operations on the chart, it is a good idea to set redraw to false and
  36142. * call {@link Chart#redraw|chart.redraw()} after.
  36143. *
  36144. * @fires Highcharts.Series#event:hide
  36145. * @fires Highcharts.Series#event:show
  36146. */
  36147. Series.prototype.setVisible = function (vis, redraw) {
  36148. var series = this,
  36149. chart = series.chart,
  36150. legendItem = series.legendItem,
  36151. showOrHide,
  36152. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  36153. oldVisibility = series.visible;
  36154. // if called without an argument, toggle visibility
  36155. series.visible =
  36156. vis =
  36157. series.options.visible =
  36158. series.userOptions.visible =
  36159. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  36160. showOrHide = vis ? 'show' : 'hide';
  36161. // show or hide elements
  36162. [
  36163. 'group',
  36164. 'dataLabelsGroup',
  36165. 'markerGroup',
  36166. 'tracker',
  36167. 'tt'
  36168. ].forEach(function (key) {
  36169. if (series[key]) {
  36170. series[key][showOrHide]();
  36171. }
  36172. });
  36173. // hide tooltip (#1361)
  36174. if (chart.hoverSeries === series ||
  36175. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  36176. series.onMouseOut();
  36177. }
  36178. if (legendItem) {
  36179. chart.legend.colorizeItem(series, vis);
  36180. }
  36181. // rescale or adapt to resized chart
  36182. series.isDirty = true;
  36183. // in a stack, all other series are affected
  36184. if (series.options.stacking) {
  36185. chart.series.forEach(function (otherSeries) {
  36186. if (otherSeries.options.stacking && otherSeries.visible) {
  36187. otherSeries.isDirty = true;
  36188. }
  36189. });
  36190. }
  36191. // show or hide linked series
  36192. series.linkedSeries.forEach(function (otherSeries) {
  36193. otherSeries.setVisible(vis, false);
  36194. });
  36195. if (ignoreHiddenSeries) {
  36196. chart.isDirtyBox = true;
  36197. }
  36198. fireEvent(series, showOrHide);
  36199. if (redraw !== false) {
  36200. chart.redraw();
  36201. }
  36202. };
  36203. /**
  36204. * Show the series if hidden.
  36205. *
  36206. * @sample highcharts/members/series-hide/
  36207. * Toggle visibility from a button
  36208. *
  36209. * @function Highcharts.Series#show
  36210. * @fires Highcharts.Series#event:show
  36211. */
  36212. Series.prototype.show = function () {
  36213. this.setVisible(true);
  36214. };
  36215. /**
  36216. * Hide the series if visible. If the
  36217. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  36218. * option is true, the chart is redrawn without this series.
  36219. *
  36220. * @sample highcharts/members/series-hide/
  36221. * Toggle visibility from a button
  36222. *
  36223. * @function Highcharts.Series#hide
  36224. * @fires Highcharts.Series#event:hide
  36225. */
  36226. Series.prototype.hide = function () {
  36227. this.setVisible(false);
  36228. };
  36229. /**
  36230. * Select or unselect the series. This means its
  36231. * {@link Highcharts.Series.selected|selected}
  36232. * property is set, the checkbox in the legend is toggled and when selected,
  36233. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  36234. * function.
  36235. *
  36236. * @sample highcharts/members/series-select/
  36237. * Select a series from a button
  36238. *
  36239. * @function Highcharts.Series#select
  36240. *
  36241. * @param {boolean} [selected]
  36242. * True to select the series, false to unselect. If undefined, the selection
  36243. * state is toggled.
  36244. *
  36245. * @fires Highcharts.Series#event:select
  36246. * @fires Highcharts.Series#event:unselect
  36247. */
  36248. Series.prototype.select = function (selected) {
  36249. var series = this;
  36250. series.selected =
  36251. selected =
  36252. this.options.selected = (typeof selected === 'undefined' ?
  36253. !series.selected :
  36254. selected);
  36255. if (series.checkbox) {
  36256. series.checkbox.checked = selected;
  36257. }
  36258. fireEvent(series, selected ? 'select' : 'unselect');
  36259. };
  36260. /**
  36261. * Checks if a tooltip should be shown for a given point.
  36262. *
  36263. * @private
  36264. * @param {number} plotX
  36265. * @param {number} plotY
  36266. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  36267. * @return {boolean}
  36268. */
  36269. Series.prototype.shouldShowTooltip = function (plotX, plotY, options) {
  36270. if (options === void 0) { options = {}; }
  36271. options.series = this;
  36272. options.visiblePlotOnly = true;
  36273. return this.chart.isInsidePlot(plotX, plotY, options);
  36274. };
  36275. /**
  36276. * General options for all series types.
  36277. *
  36278. * @optionparent plotOptions.series
  36279. */
  36280. Series.defaultOptions = {
  36281. // base series options
  36282. /**
  36283. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  36284. * of a line graph. Round means that lines are rounded in the ends and
  36285. * bends.
  36286. *
  36287. * @type {Highcharts.SeriesLinecapValue}
  36288. * @default round
  36289. * @since 3.0.7
  36290. * @apioption plotOptions.line.linecap
  36291. */
  36292. /**
  36293. * Pixel width of the graph line.
  36294. *
  36295. * @see In styled mode, the line stroke-width can be set with the
  36296. * `.highcharts-graph` class name.
  36297. *
  36298. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  36299. * On all series
  36300. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  36301. * On one single series
  36302. *
  36303. * @product highcharts highstock
  36304. *
  36305. * @private
  36306. */
  36307. lineWidth: 2,
  36308. /**
  36309. * For some series, there is a limit that shuts down initial animation
  36310. * by default when the total number of points in the chart is too high.
  36311. * For example, for a column chart and its derivatives, animation does
  36312. * not run if there is more than 250 points totally. To disable this
  36313. * cap, set `animationLimit` to `Infinity`.
  36314. *
  36315. * @type {number}
  36316. * @apioption plotOptions.series.animationLimit
  36317. */
  36318. /**
  36319. * Allow this series' points to be selected by clicking on the graphic
  36320. * (columns, point markers, pie slices, map areas etc).
  36321. *
  36322. * The selected points can be handled by point select and unselect
  36323. * events, or collectively by the [getSelectedPoints
  36324. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  36325. *
  36326. * And alternative way of selecting points is through dragging.
  36327. *
  36328. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  36329. * Line
  36330. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  36331. * Column
  36332. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  36333. * Pie
  36334. * @sample {highcharts} highcharts/chart/events-selection-points/
  36335. * Select a range of points through a drag selection
  36336. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36337. * Map area
  36338. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36339. * Map bubble
  36340. *
  36341. * @since 1.2.0
  36342. *
  36343. * @private
  36344. */
  36345. allowPointSelect: false,
  36346. /**
  36347. * When true, each point or column edge is rounded to its nearest pixel
  36348. * in order to render sharp on screen. In some cases, when there are a
  36349. * lot of densely packed columns, this leads to visible difference
  36350. * in column widths or distance between columns. In these cases,
  36351. * setting `crisp` to `false` may look better, even though each column
  36352. * is rendered blurry.
  36353. *
  36354. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  36355. * Crisp is false
  36356. *
  36357. * @since 5.0.10
  36358. * @product highcharts highstock gantt
  36359. *
  36360. * @private
  36361. */
  36362. crisp: true,
  36363. /**
  36364. * If true, a checkbox is displayed next to the legend item to allow
  36365. * selecting the series. The state of the checkbox is determined by
  36366. * the `selected` option.
  36367. *
  36368. * @productdesc {highmaps}
  36369. * Note that if a `colorAxis` is defined, the color axis is represented
  36370. * in the legend, not the series.
  36371. *
  36372. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  36373. * Show select box
  36374. *
  36375. * @since 1.2.0
  36376. *
  36377. * @private
  36378. */
  36379. showCheckbox: false,
  36380. /**
  36381. * Enable or disable the initial animation when a series is displayed.
  36382. * The animation can also be set as a configuration object. Please
  36383. * note that this option only applies to the initial animation of the
  36384. * series itself. For other animations, see [chart.animation](
  36385. * #chart.animation) and the animation parameter under the API methods.
  36386. * The following properties are supported:
  36387. *
  36388. * - `defer`: The animation delay time in milliseconds.
  36389. *
  36390. * - `duration`: The duration of the animation in milliseconds.
  36391. *
  36392. * - `easing`: Can be a string reference to an easing function set on
  36393. * the `Math` object or a function. See the _Custom easing function_
  36394. * demo below.
  36395. *
  36396. * Due to poor performance, animation is disabled in old IE browsers
  36397. * for several chart types.
  36398. *
  36399. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  36400. * Animation disabled
  36401. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  36402. * Slower animation
  36403. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  36404. * Custom easing function
  36405. * @sample {highstock} stock/plotoptions/animation-slower/
  36406. * Slower animation
  36407. * @sample {highstock} stock/plotoptions/animation-easing/
  36408. * Custom easing function
  36409. * @sample {highmaps} maps/plotoptions/series-animation-true/
  36410. * Animation enabled on map series
  36411. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  36412. * Disabled on mapbubble series
  36413. *
  36414. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36415. * @default {highcharts} true
  36416. * @default {highstock} true
  36417. * @default {highmaps} false
  36418. *
  36419. * @private
  36420. */
  36421. animation: {
  36422. /** @internal */
  36423. duration: 1000
  36424. },
  36425. /**
  36426. * @default 0
  36427. * @type {number}
  36428. * @since 8.2.0
  36429. * @apioption plotOptions.series.animation.defer
  36430. */
  36431. /**
  36432. * An additional class name to apply to the series' graphical elements.
  36433. * This option does not replace default class names of the graphical
  36434. * element.
  36435. *
  36436. * @type {string}
  36437. * @since 5.0.0
  36438. * @apioption plotOptions.series.className
  36439. */
  36440. /**
  36441. * Disable this option to allow series rendering in the whole plotting
  36442. * area.
  36443. *
  36444. * **Note:** Clipping should be always enabled when
  36445. * [chart.zoomType](#chart.zoomType) is set
  36446. *
  36447. * @sample {highcharts} highcharts/plotoptions/series-clip/
  36448. * Disabled clipping
  36449. *
  36450. * @default true
  36451. * @type {boolean}
  36452. * @since 3.0.0
  36453. * @apioption plotOptions.series.clip
  36454. */
  36455. /**
  36456. * The main color of the series. In line type series it applies to the
  36457. * line and the point markers unless otherwise specified. In bar type
  36458. * series it applies to the bars unless a color is specified per point.
  36459. * The default value is pulled from the `options.colors` array.
  36460. *
  36461. * In styled mode, the color can be defined by the
  36462. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  36463. * color can be set with the `.highcharts-series`,
  36464. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  36465. * `.highcharts-series-{n}` class, or individual classes given by the
  36466. * `className` option.
  36467. *
  36468. * @productdesc {highmaps}
  36469. * In maps, the series color is rarely used, as most choropleth maps use
  36470. * the color to denote the value of each point. The series color can
  36471. * however be used in a map with multiple series holding categorized
  36472. * data.
  36473. *
  36474. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  36475. * General plot option
  36476. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  36477. * One specific series
  36478. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  36479. * Area color
  36480. * @sample {highcharts} highcharts/series/infographic/
  36481. * Pattern fill
  36482. * @sample {highmaps} maps/demo/category-map/
  36483. * Category map by multiple series
  36484. *
  36485. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36486. * @apioption plotOptions.series.color
  36487. */
  36488. /**
  36489. * Styled mode only. A specific color index to use for the series, so
  36490. * its graphic representations are given the class name
  36491. * `highcharts-color-{n}`.
  36492. *
  36493. * @type {number}
  36494. * @since 5.0.0
  36495. * @apioption plotOptions.series.colorIndex
  36496. */
  36497. /**
  36498. * Whether to connect a graph line across null points, or render a gap
  36499. * between the two points on either side of the null.
  36500. *
  36501. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  36502. * False by default
  36503. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  36504. * True
  36505. *
  36506. * @type {boolean}
  36507. * @default false
  36508. * @product highcharts highstock
  36509. * @apioption plotOptions.series.connectNulls
  36510. */
  36511. /**
  36512. * You can set the cursor to "pointer" if you have click events attached
  36513. * to the series, to signal to the user that the points and lines can
  36514. * be clicked.
  36515. *
  36516. * In styled mode, the series cursor can be set with the same classes
  36517. * as listed under [series.color](#plotOptions.series.color).
  36518. *
  36519. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  36520. * On line graph
  36521. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  36522. * On columns
  36523. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  36524. * On scatter markers
  36525. * @sample {highstock} stock/plotoptions/cursor/
  36526. * Pointer on a line graph
  36527. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36528. * Map area
  36529. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36530. * Map bubble
  36531. *
  36532. * @type {string|Highcharts.CursorValue}
  36533. * @apioption plotOptions.series.cursor
  36534. */
  36535. /**
  36536. * A reserved subspace to store options and values for customized
  36537. * functionality. Here you can add additional data for your own event
  36538. * callbacks and formatter callbacks.
  36539. *
  36540. * @sample {highcharts} highcharts/point/custom/
  36541. * Point and series with custom data
  36542. *
  36543. * @type {Highcharts.Dictionary<*>}
  36544. * @apioption plotOptions.series.custom
  36545. */
  36546. /**
  36547. * Name of the dash style to use for the graph, or for some series types
  36548. * the outline of each shape.
  36549. *
  36550. * In styled mode, the
  36551. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  36552. * can be set with the same classes as listed under
  36553. * [series.color](#plotOptions.series.color).
  36554. *
  36555. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  36556. * Possible values demonstrated
  36557. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  36558. * Chart suitable for printing in black and white
  36559. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  36560. * Possible values demonstrated
  36561. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  36562. * Possible values demonstrated
  36563. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  36564. * Dotted borders on a map
  36565. *
  36566. * @type {Highcharts.DashStyleValue}
  36567. * @default Solid
  36568. * @since 2.1
  36569. * @apioption plotOptions.series.dashStyle
  36570. */
  36571. /**
  36572. * A description of the series to add to the screen reader information
  36573. * about the series.
  36574. *
  36575. * @type {string}
  36576. * @since 5.0.0
  36577. * @requires modules/accessibility
  36578. * @apioption plotOptions.series.description
  36579. */
  36580. /**
  36581. * Options for the series data sorting.
  36582. *
  36583. * @type {Highcharts.DataSortingOptionsObject}
  36584. * @since 8.0.0
  36585. * @product highcharts highstock
  36586. * @apioption plotOptions.series.dataSorting
  36587. */
  36588. /**
  36589. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  36590. * #xAxis.reversed) to change the sorting order.
  36591. *
  36592. * @sample {highcharts} highcharts/datasorting/animation/
  36593. * Data sorting in scatter-3d
  36594. * @sample {highcharts} highcharts/datasorting/labels-animation/
  36595. * Axis labels animation
  36596. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  36597. * Dependent series sorting
  36598. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  36599. * Independent series sorting
  36600. *
  36601. * @type {boolean}
  36602. * @since 8.0.0
  36603. * @apioption plotOptions.series.dataSorting.enabled
  36604. */
  36605. /**
  36606. * Whether to allow matching points by name in an update. If this option
  36607. * is disabled, points will be matched by order.
  36608. *
  36609. * @sample {highcharts} highcharts/datasorting/match-by-name/
  36610. * Enabled match by name
  36611. *
  36612. * @type {boolean}
  36613. * @since 8.0.0
  36614. * @apioption plotOptions.series.dataSorting.matchByName
  36615. */
  36616. /**
  36617. * Determines what data value should be used to sort by.
  36618. *
  36619. * @sample {highcharts} highcharts/datasorting/sort-key/
  36620. * Sort key as `z` value
  36621. *
  36622. * @type {string}
  36623. * @since 8.0.0
  36624. * @default y
  36625. * @apioption plotOptions.series.dataSorting.sortKey
  36626. */
  36627. /**
  36628. * Enable or disable the mouse tracking for a specific series. This
  36629. * includes point tooltips and click events on graphs and points. For
  36630. * large datasets it improves performance.
  36631. *
  36632. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  36633. * No mouse tracking
  36634. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  36635. * No mouse tracking
  36636. *
  36637. * @type {boolean}
  36638. * @default true
  36639. * @apioption plotOptions.series.enableMouseTracking
  36640. */
  36641. /**
  36642. * Whether to use the Y extremes of the total chart width or only the
  36643. * zoomed area when zooming in on parts of the X axis. By default, the
  36644. * Y axis adjusts to the min and max of the visible data. Cartesian
  36645. * series only.
  36646. *
  36647. * @type {boolean}
  36648. * @default false
  36649. * @since 4.1.6
  36650. * @product highcharts highstock gantt
  36651. * @apioption plotOptions.series.getExtremesFromAll
  36652. */
  36653. /**
  36654. * An array specifying which option maps to which key in the data point
  36655. * array. This makes it convenient to work with unstructured data arrays
  36656. * from different sources.
  36657. *
  36658. * @see [series.data](#series.line.data)
  36659. *
  36660. * @sample {highcharts|highstock} highcharts/series/data-keys/
  36661. * An extended data array with keys
  36662. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  36663. * Nested keys used to access object properties
  36664. *
  36665. * @type {Array<string>}
  36666. * @since 4.1.6
  36667. * @apioption plotOptions.series.keys
  36668. */
  36669. /**
  36670. * The line cap used for line ends and line joins on the graph.
  36671. *
  36672. * @type {Highcharts.SeriesLinecapValue}
  36673. * @default round
  36674. * @product highcharts highstock
  36675. * @apioption plotOptions.series.linecap
  36676. */
  36677. /**
  36678. * The [id](#series.id) of another series to link to. Additionally,
  36679. * the value can be ":previous" to link to the previous series. When
  36680. * two series are linked, only the first one appears in the legend.
  36681. * Toggling the visibility of this also toggles the linked series.
  36682. *
  36683. * If master series uses data sorting and linked series does not have
  36684. * its own sorting definition, the linked series will be sorted in the
  36685. * same order as the master one.
  36686. *
  36687. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  36688. * Linked series
  36689. *
  36690. * @type {string}
  36691. * @since 3.0
  36692. * @product highcharts highstock gantt
  36693. * @apioption plotOptions.series.linkedTo
  36694. */
  36695. /**
  36696. * Options for the corresponding navigator series if `showInNavigator`
  36697. * is `true` for this series. Available options are the same as any
  36698. * series, documented at [plotOptions](#plotOptions.series) and
  36699. * [series](#series).
  36700. *
  36701. * These options are merged with options in [navigator.series](
  36702. * #navigator.series), and will take precedence if the same option is
  36703. * defined both places.
  36704. *
  36705. * @see [navigator.series](#navigator.series)
  36706. *
  36707. * @type {Highcharts.PlotSeriesOptions}
  36708. * @since 5.0.0
  36709. * @product highstock
  36710. * @apioption plotOptions.series.navigatorOptions
  36711. */
  36712. /**
  36713. * The color for the parts of the graph or points that are below the
  36714. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  36715. * precedence over the negative color. Using `negativeColor` is
  36716. * equivalent to applying a zone with value of 0.
  36717. *
  36718. * @see In styled mode, a negative color is applied by setting this option
  36719. * to `true` combined with the `.highcharts-negative` class name.
  36720. *
  36721. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  36722. * Spline, area and column
  36723. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  36724. * Arearange
  36725. * @sample {highcharts} highcharts/css/series-negative-color/
  36726. * Styled mode
  36727. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  36728. * Spline, area and column
  36729. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  36730. * Arearange
  36731. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  36732. * Spline, area and column
  36733. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  36734. * Arearange
  36735. *
  36736. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36737. * @since 3.0
  36738. * @apioption plotOptions.series.negativeColor
  36739. */
  36740. /**
  36741. * Same as
  36742. * [accessibility.series.descriptionFormatter](#accessibility.series.descriptionFormatter),
  36743. * but for an individual series. Overrides the chart wide configuration.
  36744. *
  36745. * @type {Function}
  36746. * @since 5.0.12
  36747. * @apioption plotOptions.series.pointDescriptionFormatter
  36748. */
  36749. /**
  36750. * If no x values are given for the points in a series, `pointInterval`
  36751. * defines the interval of the x values. For example, if a series
  36752. * contains one value every decade starting from year 0, set
  36753. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  36754. * is set in milliseconds.
  36755. *
  36756. * It can be also be combined with `pointIntervalUnit` to draw irregular
  36757. * time intervals.
  36758. *
  36759. * Please note that this options applies to the _series data_, not the
  36760. * interval of the axis ticks, which is independent.
  36761. *
  36762. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36763. * Datetime X axis
  36764. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36765. * Using pointStart and pointInterval
  36766. *
  36767. * @type {number}
  36768. * @default 1
  36769. * @product highcharts highstock gantt
  36770. * @apioption plotOptions.series.pointInterval
  36771. */
  36772. /**
  36773. * On datetime series, this allows for setting the
  36774. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  36775. * units, `day`, `month` and `year`. A day is usually the same as 24
  36776. * hours, but `pointIntervalUnit` also takes the DST crossover into
  36777. * consideration when dealing with local time. Combine this option with
  36778. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  36779. *
  36780. * Please note that this options applies to the _series data_, not the
  36781. * interval of the axis ticks, which is independent.
  36782. *
  36783. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  36784. * One point a month
  36785. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  36786. * One point a month
  36787. *
  36788. * @type {string}
  36789. * @since 4.1.0
  36790. * @product highcharts highstock gantt
  36791. * @validvalue ["day", "month", "year"]
  36792. * @apioption plotOptions.series.pointIntervalUnit
  36793. */
  36794. /**
  36795. * Possible values: `"on"`, `"between"`, `number`.
  36796. *
  36797. * In a column chart, when pointPlacement is `"on"`, the point will not
  36798. * create any padding of the X axis. In a polar column chart this means
  36799. * that the first column points directly north. If the pointPlacement is
  36800. * `"between"`, the columns will be laid out between ticks. This is
  36801. * useful for example for visualising an amount between two points in
  36802. * time or in a certain sector of a polar chart.
  36803. *
  36804. * Since Highcharts 3.0.2, the point placement can also be numeric,
  36805. * where 0 is on the axis value, -0.5 is between this value and the
  36806. * previous, and 0.5 is between this value and the next. Unlike the
  36807. * textual options, numeric point placement options won't affect axis
  36808. * padding.
  36809. *
  36810. * Note that pointPlacement needs a [pointRange](
  36811. * #plotOptions.series.pointRange) to work. For column series this is
  36812. * computed, but for line-type series it needs to be set.
  36813. *
  36814. * For the `xrange` series type and gantt charts, if the Y axis is a
  36815. * category axis, the `pointPlacement` applies to the Y axis rather than
  36816. * the (typically datetime) X axis.
  36817. *
  36818. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  36819. * charts.
  36820. *
  36821. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  36822. *
  36823. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  36824. * Between in a column chart
  36825. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  36826. * Numeric placement for custom layout
  36827. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  36828. * Placement in heatmap
  36829. *
  36830. * @type {string|number}
  36831. * @since 2.3.0
  36832. * @product highcharts highstock gantt
  36833. * @apioption plotOptions.series.pointPlacement
  36834. */
  36835. /**
  36836. * If no x values are given for the points in a series, pointStart
  36837. * defines on what value to start. For example, if a series contains one
  36838. * yearly value starting from 1945, set pointStart to 1945.
  36839. *
  36840. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  36841. * Linear
  36842. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36843. * Datetime
  36844. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36845. * Using pointStart and pointInterval
  36846. *
  36847. * @type {number}
  36848. * @default 0
  36849. * @product highcharts highstock gantt
  36850. * @apioption plotOptions.series.pointStart
  36851. */
  36852. /**
  36853. * Whether to select the series initially. If `showCheckbox` is true,
  36854. * the checkbox next to the series name in the legend will be checked
  36855. * for a selected series.
  36856. *
  36857. * @sample {highcharts} highcharts/plotoptions/series-selected/
  36858. * One out of two series selected
  36859. *
  36860. * @type {boolean}
  36861. * @default false
  36862. * @since 1.2.0
  36863. * @apioption plotOptions.series.selected
  36864. */
  36865. /**
  36866. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  36867. * shadow can be an object configuration containing `color`, `offsetX`,
  36868. * `offsetY`, `opacity` and `width`.
  36869. *
  36870. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  36871. * Shadow enabled
  36872. *
  36873. * @type {boolean|Highcharts.ShadowOptionsObject}
  36874. * @default false
  36875. * @apioption plotOptions.series.shadow
  36876. */
  36877. /**
  36878. * Whether to display this particular series or series type in the
  36879. * legend. Standalone series are shown in legend by default, and linked
  36880. * series are not. Since v7.2.0 it is possible to show series that use
  36881. * colorAxis by setting this option to `true`.
  36882. *
  36883. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  36884. * One series in the legend, one hidden
  36885. *
  36886. * @type {boolean}
  36887. * @apioption plotOptions.series.showInLegend
  36888. */
  36889. /**
  36890. * Whether or not to show the series in the navigator. Takes precedence
  36891. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  36892. *
  36893. * @type {boolean}
  36894. * @since 5.0.0
  36895. * @product highstock
  36896. * @apioption plotOptions.series.showInNavigator
  36897. */
  36898. /**
  36899. * If set to `true`, the accessibility module will skip past the points
  36900. * in this series for keyboard navigation.
  36901. *
  36902. * @type {boolean}
  36903. * @since 5.0.12
  36904. * @apioption plotOptions.series.skipKeyboardNavigation
  36905. */
  36906. /**
  36907. * Whether to stack the values of each series on top of each other.
  36908. * Possible values are `undefined` to disable, `"normal"` to stack by
  36909. * value or `"percent"`.
  36910. *
  36911. * When stacking is enabled, data must be sorted
  36912. * in ascending X order.
  36913. *
  36914. * Some stacking options are related to specific series types. In the
  36915. * streamgraph series type, the stacking option is set to `"stream"`.
  36916. * The second one is `"overlap"`, which only applies to waterfall
  36917. * series.
  36918. *
  36919. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  36920. *
  36921. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  36922. * Line
  36923. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  36924. * Column
  36925. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  36926. * Bar
  36927. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  36928. * Area
  36929. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  36930. * Line
  36931. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  36932. * Column
  36933. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  36934. * Bar
  36935. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  36936. * Area
  36937. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  36938. * Waterfall with normal stacking
  36939. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  36940. * Waterfall with overlap stacking
  36941. * @sample {highstock} stock/plotoptions/stacking/
  36942. * Area
  36943. *
  36944. * @type {string}
  36945. * @product highcharts highstock
  36946. * @validvalue ["normal", "overlap", "percent", "stream"]
  36947. * @apioption plotOptions.series.stacking
  36948. */
  36949. /**
  36950. * Whether to apply steps to the line. Possible values are `left`,
  36951. * `center` and `right`.
  36952. *
  36953. * @sample {highcharts} highcharts/plotoptions/line-step/
  36954. * Different step line options
  36955. * @sample {highcharts} highcharts/plotoptions/area-step/
  36956. * Stepped, stacked area
  36957. * @sample {highstock} stock/plotoptions/line-step/
  36958. * Step line
  36959. *
  36960. * @type {string}
  36961. * @since 1.2.5
  36962. * @product highcharts highstock
  36963. * @validvalue ["left", "center", "right"]
  36964. * @apioption plotOptions.series.step
  36965. */
  36966. /**
  36967. * The threshold, also called zero level or base level. For line type
  36968. * series this is only used in conjunction with
  36969. * [negativeColor](#plotOptions.series.negativeColor).
  36970. *
  36971. * @see [softThreshold](#plotOptions.series.softThreshold).
  36972. *
  36973. * @type {number|null}
  36974. * @default 0
  36975. * @since 3.0
  36976. * @product highcharts highstock
  36977. * @apioption plotOptions.series.threshold
  36978. */
  36979. /**
  36980. * Set the initial visibility of the series.
  36981. *
  36982. * @sample {highcharts} highcharts/plotoptions/series-visible/
  36983. * Two series, one hidden and one visible
  36984. * @sample {highstock} stock/plotoptions/series-visibility/
  36985. * Hidden series
  36986. *
  36987. * @type {boolean}
  36988. * @default true
  36989. * @apioption plotOptions.series.visible
  36990. */
  36991. /**
  36992. * Defines the Axis on which the zones are applied.
  36993. *
  36994. * @see [zones](#plotOptions.series.zones)
  36995. *
  36996. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  36997. * Zones on the X-Axis
  36998. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  36999. * Zones on the X-Axis
  37000. *
  37001. * @type {string}
  37002. * @default y
  37003. * @since 4.1.0
  37004. * @product highcharts highstock
  37005. * @apioption plotOptions.series.zoneAxis
  37006. */
  37007. /**
  37008. * General event handlers for the series items. These event hooks can
  37009. * also be attached to the series at run time using the
  37010. * `Highcharts.addEvent` function.
  37011. *
  37012. * @declare Highcharts.SeriesEventsOptionsObject
  37013. *
  37014. * @private
  37015. */
  37016. events: {},
  37017. /**
  37018. * Fires after the series has finished its initial animation, or in case
  37019. * animation is disabled, immediately as the series is displayed.
  37020. *
  37021. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  37022. * Show label after animate
  37023. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  37024. * Show label after animate
  37025. *
  37026. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  37027. * @since 4.0
  37028. * @product highcharts highstock gantt
  37029. * @context Highcharts.Series
  37030. * @apioption plotOptions.series.events.afterAnimate
  37031. */
  37032. /**
  37033. * Fires when the checkbox next to the series' name in the legend is
  37034. * clicked. One parameter, `event`, is passed to the function. The state
  37035. * of the checkbox is found by `event.checked`. The checked item is
  37036. * found by `event.item`. Return `false` to prevent the default action
  37037. * which is to toggle the select state of the series.
  37038. *
  37039. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  37040. * Alert checkbox status
  37041. *
  37042. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  37043. * @since 1.2.0
  37044. * @context Highcharts.Series
  37045. * @apioption plotOptions.series.events.checkboxClick
  37046. */
  37047. /**
  37048. * Fires when the series is clicked. One parameter, `event`, is passed
  37049. * to the function, containing common event information. Additionally,
  37050. * `event.point` holds a pointer to the nearest point on the graph.
  37051. *
  37052. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  37053. * Alert click info
  37054. * @sample {highstock} stock/plotoptions/series-events-click/
  37055. * Alert click info
  37056. * @sample {highmaps} maps/plotoptions/series-events-click/
  37057. * Display click info in subtitle
  37058. *
  37059. * @type {Highcharts.SeriesClickCallbackFunction}
  37060. * @context Highcharts.Series
  37061. * @apioption plotOptions.series.events.click
  37062. */
  37063. /**
  37064. * Fires when the series is hidden after chart generation time, either
  37065. * by clicking the legend item or by calling `.hide()`.
  37066. *
  37067. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  37068. * Alert when the series is hidden by clicking the legend item
  37069. *
  37070. * @type {Highcharts.SeriesHideCallbackFunction}
  37071. * @since 1.2.0
  37072. * @context Highcharts.Series
  37073. * @apioption plotOptions.series.events.hide
  37074. */
  37075. /**
  37076. * Fires when the legend item belonging to the series is clicked. One
  37077. * parameter, `event`, is passed to the function. The default action
  37078. * is to toggle the visibility of the series. This can be prevented
  37079. * by returning `false` or calling `event.preventDefault()`.
  37080. *
  37081. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  37082. * Confirm hiding and showing
  37083. *
  37084. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  37085. * @context Highcharts.Series
  37086. * @apioption plotOptions.series.events.legendItemClick
  37087. */
  37088. /**
  37089. * Fires when the mouse leaves the graph. One parameter, `event`, is
  37090. * passed to the function, containing common event information. If the
  37091. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  37092. * doesn't happen before the mouse enters another graph or leaves the
  37093. * plot area.
  37094. *
  37095. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  37096. * With sticky tracking by default
  37097. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  37098. * Without sticky tracking
  37099. *
  37100. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  37101. * @context Highcharts.Series
  37102. * @apioption plotOptions.series.events.mouseOut
  37103. */
  37104. /**
  37105. * Fires when the mouse enters the graph. One parameter, `event`, is
  37106. * passed to the function, containing common event information.
  37107. *
  37108. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  37109. * With sticky tracking by default
  37110. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  37111. * Without sticky tracking
  37112. *
  37113. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  37114. * @context Highcharts.Series
  37115. * @apioption plotOptions.series.events.mouseOver
  37116. */
  37117. /**
  37118. * Fires when the series is shown after chart generation time, either
  37119. * by clicking the legend item or by calling `.show()`.
  37120. *
  37121. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  37122. * Alert when the series is shown by clicking the legend item.
  37123. *
  37124. * @type {Highcharts.SeriesShowCallbackFunction}
  37125. * @since 1.2.0
  37126. * @context Highcharts.Series
  37127. * @apioption plotOptions.series.events.show
  37128. */
  37129. /**
  37130. * Options for the point markers of line-like series. Properties like
  37131. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  37132. * of the markers. Other series types, like column series, don't have
  37133. * markers, but have visual options on the series level instead.
  37134. *
  37135. * In styled mode, the markers can be styled with the
  37136. * `.highcharts-point`, `.highcharts-point-hover` and
  37137. * `.highcharts-point-select` class names.
  37138. *
  37139. * @declare Highcharts.PointMarkerOptionsObject
  37140. *
  37141. * @private
  37142. */
  37143. marker: {
  37144. /**
  37145. * Enable or disable the point marker. If `undefined`, the markers
  37146. * are hidden when the data is dense, and shown for more widespread
  37147. * data points.
  37148. *
  37149. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  37150. * Disabled markers
  37151. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  37152. * Disabled in normal state but enabled on hover
  37153. * @sample {highstock} stock/plotoptions/series-marker/
  37154. * Enabled markers
  37155. *
  37156. * @type {boolean}
  37157. * @default {highcharts} undefined
  37158. * @default {highstock} false
  37159. * @apioption plotOptions.series.marker.enabled
  37160. */
  37161. /**
  37162. * The threshold for how dense the point markers should be before
  37163. * they are hidden, given that `enabled` is not defined. The number
  37164. * indicates the horizontal distance between the two closest points
  37165. * in the series, as multiples of the `marker.radius`. In other
  37166. * words, the default value of 2 means points are hidden if
  37167. * overlapping horizontally.
  37168. *
  37169. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  37170. * A higher threshold
  37171. *
  37172. * @since 6.0.5
  37173. */
  37174. enabledThreshold: 2,
  37175. /**
  37176. * The fill color of the point marker. When `undefined`, the series'
  37177. * or point's color is used.
  37178. *
  37179. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37180. * White fill
  37181. *
  37182. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37183. * @apioption plotOptions.series.marker.fillColor
  37184. */
  37185. /**
  37186. * Image markers only. Set the image width explicitly. When using
  37187. * this option, a `width` must also be set.
  37188. *
  37189. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  37190. * Fixed width and height
  37191. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  37192. * Fixed width and height
  37193. *
  37194. * @type {number}
  37195. * @since 4.0.4
  37196. * @apioption plotOptions.series.marker.height
  37197. */
  37198. /**
  37199. * The color of the point marker's outline. When `undefined`, the
  37200. * series' or point's color is used.
  37201. *
  37202. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37203. * Inherit from series color (undefined)
  37204. *
  37205. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37206. */
  37207. lineColor: palette.backgroundColor,
  37208. /**
  37209. * The width of the point marker's outline.
  37210. *
  37211. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37212. * 2px blue marker
  37213. */
  37214. lineWidth: 0,
  37215. /**
  37216. * The radius of the point marker.
  37217. *
  37218. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  37219. * Bigger markers
  37220. *
  37221. * @default {highstock} 2
  37222. * @default {highcharts} 4
  37223. *
  37224. */
  37225. radius: 4,
  37226. /**
  37227. * A predefined shape or symbol for the marker. When undefined, the
  37228. * symbol is pulled from options.symbols. Other possible values are
  37229. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  37230. * `'triangle-down'`.
  37231. *
  37232. * Additionally, the URL to a graphic can be given on this form:
  37233. * `'url(graphic.png)'`. Note that for the image to be applied to
  37234. * exported charts, its URL needs to be accessible by the export
  37235. * server.
  37236. *
  37237. * Custom callbacks for symbol path generation can also be added to
  37238. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  37239. * used by its method name, as shown in the demo.
  37240. *
  37241. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  37242. * Predefined, graphic and custom markers
  37243. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  37244. * Predefined, graphic and custom markers
  37245. *
  37246. * @type {string}
  37247. * @apioption plotOptions.series.marker.symbol
  37248. */
  37249. /**
  37250. * Image markers only. Set the image width explicitly. When using
  37251. * this option, a `height` must also be set.
  37252. *
  37253. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  37254. * Fixed width and height
  37255. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  37256. * Fixed width and height
  37257. *
  37258. * @type {number}
  37259. * @since 4.0.4
  37260. * @apioption plotOptions.series.marker.width
  37261. */
  37262. /**
  37263. * States for a single point marker.
  37264. *
  37265. * @declare Highcharts.PointStatesOptionsObject
  37266. */
  37267. states: {
  37268. /**
  37269. * The normal state of a single point marker. Currently only
  37270. * used for setting animation when returning to normal state
  37271. * from hover.
  37272. *
  37273. * @declare Highcharts.PointStatesNormalOptionsObject
  37274. */
  37275. normal: {
  37276. /**
  37277. * Animation when returning to normal state after hovering.
  37278. *
  37279. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37280. */
  37281. animation: true
  37282. },
  37283. /**
  37284. * The hover state for a single point marker.
  37285. *
  37286. * @declare Highcharts.PointStatesHoverOptionsObject
  37287. */
  37288. hover: {
  37289. /**
  37290. * Animation when hovering over the marker.
  37291. *
  37292. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37293. */
  37294. animation: {
  37295. /** @internal */
  37296. duration: 50
  37297. },
  37298. /**
  37299. * Enable or disable the point marker.
  37300. *
  37301. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  37302. * Disabled hover state
  37303. */
  37304. enabled: true,
  37305. /**
  37306. * The fill color of the marker in hover state. When
  37307. * `undefined`, the series' or point's fillColor for normal
  37308. * state is used.
  37309. *
  37310. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37311. * @apioption plotOptions.series.marker.states.hover.fillColor
  37312. */
  37313. /**
  37314. * The color of the point marker's outline. When
  37315. * `undefined`, the series' or point's lineColor for normal
  37316. * state is used.
  37317. *
  37318. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  37319. * White fill color, black line color
  37320. *
  37321. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37322. * @apioption plotOptions.series.marker.states.hover.lineColor
  37323. */
  37324. /**
  37325. * The width of the point marker's outline. When
  37326. * `undefined`, the series' or point's lineWidth for normal
  37327. * state is used.
  37328. *
  37329. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  37330. * 3px line width
  37331. *
  37332. * @type {number}
  37333. * @apioption plotOptions.series.marker.states.hover.lineWidth
  37334. */
  37335. /**
  37336. * The radius of the point marker. In hover state, it
  37337. * defaults to the normal state's radius + 2 as per the
  37338. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  37339. * option.
  37340. *
  37341. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  37342. * 10px radius
  37343. *
  37344. * @type {number}
  37345. * @apioption plotOptions.series.marker.states.hover.radius
  37346. */
  37347. /**
  37348. * The number of pixels to increase the radius of the
  37349. * hovered point.
  37350. *
  37351. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37352. * 5 pixels greater radius on hover
  37353. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37354. * 5 pixels greater radius on hover
  37355. *
  37356. * @since 4.0.3
  37357. */
  37358. radiusPlus: 2,
  37359. /**
  37360. * The additional line width for a hovered point.
  37361. *
  37362. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37363. * 2 pixels wider on hover
  37364. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37365. * 2 pixels wider on hover
  37366. *
  37367. * @since 4.0.3
  37368. */
  37369. lineWidthPlus: 1
  37370. },
  37371. /**
  37372. * The appearance of the point marker when selected. In order to
  37373. * allow a point to be selected, set the
  37374. * `series.allowPointSelect` option to true.
  37375. *
  37376. * @declare Highcharts.PointStatesSelectOptionsObject
  37377. */
  37378. select: {
  37379. /**
  37380. * Enable or disable visible feedback for selection.
  37381. *
  37382. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  37383. * Disabled select state
  37384. *
  37385. * @type {boolean}
  37386. * @default true
  37387. * @apioption plotOptions.series.marker.states.select.enabled
  37388. */
  37389. /**
  37390. * The radius of the point marker. In hover state, it
  37391. * defaults to the normal state's radius + 2.
  37392. *
  37393. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  37394. * 10px radius for selected points
  37395. *
  37396. * @type {number}
  37397. * @apioption plotOptions.series.marker.states.select.radius
  37398. */
  37399. /**
  37400. * The fill color of the point marker.
  37401. *
  37402. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  37403. * Solid red discs for selected points
  37404. *
  37405. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37406. */
  37407. fillColor: palette.neutralColor20,
  37408. /**
  37409. * The color of the point marker's outline. When
  37410. * `undefined`, the series' or point's color is used.
  37411. *
  37412. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  37413. * Red line color for selected points
  37414. *
  37415. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37416. */
  37417. lineColor: palette.neutralColor100,
  37418. /**
  37419. * The width of the point marker's outline.
  37420. *
  37421. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  37422. * 3px line width for selected points
  37423. */
  37424. lineWidth: 2
  37425. }
  37426. }
  37427. },
  37428. /**
  37429. * Properties for each single point.
  37430. *
  37431. * @declare Highcharts.PlotSeriesPointOptions
  37432. *
  37433. * @private
  37434. */
  37435. point: {
  37436. /**
  37437. * Fires when a point is clicked. One parameter, `event`, is passed
  37438. * to the function, containing common event information.
  37439. *
  37440. * If the `series.allowPointSelect` option is true, the default
  37441. * action for the point's click event is to toggle the point's
  37442. * select state. Returning `false` cancels this action.
  37443. *
  37444. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  37445. * Click marker to alert values
  37446. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  37447. * Click column
  37448. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  37449. * Go to URL
  37450. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  37451. * Click marker to display values
  37452. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  37453. * Go to URL
  37454. *
  37455. * @type {Highcharts.PointClickCallbackFunction}
  37456. * @context Highcharts.Point
  37457. * @apioption plotOptions.series.point.events.click
  37458. */
  37459. /**
  37460. * Fires when the mouse leaves the area close to the point. One
  37461. * parameter, `event`, is passed to the function, containing common
  37462. * event information.
  37463. *
  37464. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37465. * Show values in the chart's corner on mouse over
  37466. *
  37467. * @type {Highcharts.PointMouseOutCallbackFunction}
  37468. * @context Highcharts.Point
  37469. * @apioption plotOptions.series.point.events.mouseOut
  37470. */
  37471. /**
  37472. * Fires when the mouse enters the area close to the point. One
  37473. * parameter, `event`, is passed to the function, containing common
  37474. * event information.
  37475. *
  37476. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37477. * Show values in the chart's corner on mouse over
  37478. *
  37479. * @type {Highcharts.PointMouseOverCallbackFunction}
  37480. * @context Highcharts.Point
  37481. * @apioption plotOptions.series.point.events.mouseOver
  37482. */
  37483. /**
  37484. * Fires when the point is removed using the `.remove()` method. One
  37485. * parameter, `event`, is passed to the function. Returning `false`
  37486. * cancels the operation.
  37487. *
  37488. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  37489. * Remove point and confirm
  37490. *
  37491. * @type {Highcharts.PointRemoveCallbackFunction}
  37492. * @since 1.2.0
  37493. * @context Highcharts.Point
  37494. * @apioption plotOptions.series.point.events.remove
  37495. */
  37496. /**
  37497. * Fires when the point is selected either programmatically or
  37498. * following a click on the point. One parameter, `event`, is passed
  37499. * to the function. Returning `false` cancels the operation.
  37500. *
  37501. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  37502. * Report the last selected point
  37503. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37504. * Report select and unselect
  37505. *
  37506. * @type {Highcharts.PointSelectCallbackFunction}
  37507. * @since 1.2.0
  37508. * @context Highcharts.Point
  37509. * @apioption plotOptions.series.point.events.select
  37510. */
  37511. /**
  37512. * Fires when the point is unselected either programmatically or
  37513. * following a click on the point. One parameter, `event`, is passed
  37514. * to the function.
  37515. * Returning `false` cancels the operation.
  37516. *
  37517. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  37518. * Report the last unselected point
  37519. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37520. * Report select and unselect
  37521. *
  37522. * @type {Highcharts.PointUnselectCallbackFunction}
  37523. * @since 1.2.0
  37524. * @context Highcharts.Point
  37525. * @apioption plotOptions.series.point.events.unselect
  37526. */
  37527. /**
  37528. * Fires when the point is updated programmatically through the
  37529. * `.update()` method. One parameter, `event`, is passed to the
  37530. * function. The new point options can be accessed through
  37531. * `event.options`. Returning `false` cancels the operation.
  37532. *
  37533. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  37534. * Confirm point updating
  37535. *
  37536. * @type {Highcharts.PointUpdateCallbackFunction}
  37537. * @since 1.2.0
  37538. * @context Highcharts.Point
  37539. * @apioption plotOptions.series.point.events.update
  37540. */
  37541. /**
  37542. * Events for each single point.
  37543. *
  37544. * @declare Highcharts.PointEventsOptionsObject
  37545. */
  37546. events: {}
  37547. },
  37548. /**
  37549. * Options for the series data labels, appearing next to each data
  37550. * point.
  37551. *
  37552. * Since v6.2.0, multiple data labels can be applied to each single
  37553. * point by defining them as an array of configs.
  37554. *
  37555. * In styled mode, the data labels can be styled with the
  37556. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  37557. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  37558. *
  37559. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  37560. * Data labels enabled
  37561. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  37562. * Multiple data labels on a bar series
  37563. * @sample {highcharts} highcharts/css/series-datalabels
  37564. * Style mode example
  37565. *
  37566. * @type {*|Array<*>}
  37567. * @product highcharts highstock highmaps gantt
  37568. *
  37569. * @private
  37570. */
  37571. dataLabels: {
  37572. /**
  37573. * Enable or disable the initial animation when a series is
  37574. * displayed for the `dataLabels`. The animation can also be set as
  37575. * a configuration object. Please note that this option only
  37576. * applies to the initial animation.
  37577. * For other animations, see [chart.animation](#chart.animation)
  37578. * and the animation parameter under the API methods.
  37579. * The following properties are supported:
  37580. *
  37581. * - `defer`: The animation delay time in milliseconds.
  37582. *
  37583. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  37584. * Animation defer settings
  37585. *
  37586. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37587. * @since 8.2.0
  37588. * @apioption plotOptions.series.dataLabels.animation
  37589. */
  37590. animation: {},
  37591. /**
  37592. * The animation delay time in milliseconds.
  37593. * Set to `0` renders dataLabel immediately.
  37594. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  37595. *
  37596. * @type {number}
  37597. * @since 8.2.0
  37598. * @apioption plotOptions.series.dataLabels.animation.defer
  37599. */
  37600. /**
  37601. * The alignment of the data label compared to the point. If
  37602. * `right`, the right side of the label should be touching the
  37603. * point. For points with an extent, like columns, the alignments
  37604. * also dictates how to align it inside the box, as given with the
  37605. * [inside](#plotOptions.column.dataLabels.inside)
  37606. * option. Can be one of `left`, `center` or `right`.
  37607. *
  37608. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  37609. * Left aligned
  37610. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37611. * Data labels inside the bar
  37612. *
  37613. * @type {Highcharts.AlignValue|null}
  37614. */
  37615. align: 'center',
  37616. /**
  37617. * Whether to allow data labels to overlap. To make the labels less
  37618. * sensitive for overlapping, the
  37619. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  37620. * can be set to 0.
  37621. *
  37622. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  37623. * Don't allow overlap
  37624. *
  37625. * @type {boolean}
  37626. * @default false
  37627. * @since 4.1.0
  37628. * @apioption plotOptions.series.dataLabels.allowOverlap
  37629. */
  37630. /**
  37631. * The background color or gradient for the data label.
  37632. *
  37633. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37634. * Data labels box options
  37635. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37636. * Data labels box options
  37637. *
  37638. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37639. * @since 2.2.1
  37640. * @apioption plotOptions.series.dataLabels.backgroundColor
  37641. */
  37642. /**
  37643. * The border color for the data label. Defaults to `undefined`.
  37644. *
  37645. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37646. * Data labels box options
  37647. *
  37648. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37649. * @since 2.2.1
  37650. * @apioption plotOptions.series.dataLabels.borderColor
  37651. */
  37652. /**
  37653. * The border radius in pixels for the data label.
  37654. *
  37655. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37656. * Data labels box options
  37657. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37658. * Data labels box options
  37659. *
  37660. * @type {number}
  37661. * @default 0
  37662. * @since 2.2.1
  37663. * @apioption plotOptions.series.dataLabels.borderRadius
  37664. */
  37665. /**
  37666. * The border width in pixels for the data label.
  37667. *
  37668. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37669. * Data labels box options
  37670. *
  37671. * @type {number}
  37672. * @default 0
  37673. * @since 2.2.1
  37674. * @apioption plotOptions.series.dataLabels.borderWidth
  37675. */
  37676. /**
  37677. * A class name for the data label. Particularly in styled mode,
  37678. * this can be used to give each series' or point's data label
  37679. * unique styling. In addition to this option, a default color class
  37680. * name is added so that we can give the labels a contrast text
  37681. * shadow.
  37682. *
  37683. * @sample {highcharts} highcharts/css/data-label-contrast/
  37684. * Contrast text shadow
  37685. * @sample {highcharts} highcharts/css/series-datalabels/
  37686. * Styling by CSS
  37687. *
  37688. * @type {string}
  37689. * @since 5.0.0
  37690. * @apioption plotOptions.series.dataLabels.className
  37691. */
  37692. /**
  37693. * The text color for the data labels. Defaults to `undefined`. For
  37694. * certain series types, like column or map, the data labels can be
  37695. * drawn inside the points. In this case the data label will be
  37696. * drawn with maximum contrast by default. Additionally, it will be
  37697. * given a `text-outline` style with the opposite color, to further
  37698. * increase the contrast. This can be overridden by setting the
  37699. * `text-outline` style to `none` in the `dataLabels.style` option.
  37700. *
  37701. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  37702. * Red data labels
  37703. * @sample {highmaps} maps/demo/color-axis/
  37704. * White data labels
  37705. *
  37706. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37707. * @apioption plotOptions.series.dataLabels.color
  37708. */
  37709. /**
  37710. * Whether to hide data labels that are outside the plot area. By
  37711. * default, the data label is moved inside the plot area according
  37712. * to the
  37713. * [overflow](#plotOptions.series.dataLabels.overflow)
  37714. * option.
  37715. *
  37716. * @type {boolean}
  37717. * @default true
  37718. * @since 2.3.3
  37719. * @apioption plotOptions.series.dataLabels.crop
  37720. */
  37721. /**
  37722. * Whether to defer displaying the data labels until the initial
  37723. * series animation has finished. Setting to `false` renders the
  37724. * data label immediately. If set to `true` inherits the defer
  37725. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  37726. * If set to a number, a defer time is specified in milliseconds.
  37727. *
  37728. * @sample highcharts/plotoptions/animation-defer
  37729. * Set defer time
  37730. *
  37731. * @since 4.0.0
  37732. * @type {boolean|number}
  37733. * @product highcharts highstock gantt
  37734. */
  37735. defer: true,
  37736. /**
  37737. * Enable or disable the data labels.
  37738. *
  37739. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  37740. * Data labels enabled
  37741. * @sample {highmaps} maps/demo/color-axis/
  37742. * Data labels enabled
  37743. *
  37744. * @type {boolean}
  37745. * @default false
  37746. * @apioption plotOptions.series.dataLabels.enabled
  37747. */
  37748. /**
  37749. * A declarative filter to control of which data labels to display.
  37750. * The declarative filter is designed for use when callback
  37751. * functions are not available, like when the chart options require
  37752. * a pure JSON structure or for use with graphical editors. For
  37753. * programmatic control, use the `formatter` instead, and return
  37754. * `undefined` to disable a single data label.
  37755. *
  37756. * @example
  37757. * filter: {
  37758. * property: 'percentage',
  37759. * operator: '>',
  37760. * value: 4
  37761. * }
  37762. *
  37763. * @sample {highcharts} highcharts/demo/pie-monochrome
  37764. * Data labels filtered by percentage
  37765. *
  37766. * @declare Highcharts.DataLabelsFilterOptionsObject
  37767. * @since 6.0.3
  37768. * @apioption plotOptions.series.dataLabels.filter
  37769. */
  37770. /**
  37771. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  37772. * `==`, and `===`.
  37773. *
  37774. * @type {string}
  37775. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  37776. * @apioption plotOptions.series.dataLabels.filter.operator
  37777. */
  37778. /**
  37779. * The point property to filter by. Point options are passed
  37780. * directly to properties, additionally there are `y` value,
  37781. * `percentage` and others listed under {@link Highcharts.Point}
  37782. * members.
  37783. *
  37784. * @type {string}
  37785. * @apioption plotOptions.series.dataLabels.filter.property
  37786. */
  37787. /**
  37788. * The value to compare against.
  37789. *
  37790. * @type {number}
  37791. * @apioption plotOptions.series.dataLabels.filter.value
  37792. */
  37793. /**
  37794. * A
  37795. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  37796. * for the data label. Available variables are the same as for
  37797. * `formatter`.
  37798. *
  37799. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37800. * Add a unit
  37801. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37802. * Formatted value in the data label
  37803. *
  37804. * @type {string}
  37805. * @default y
  37806. * @default point.value
  37807. * @since 3.0
  37808. * @apioption plotOptions.series.dataLabels.format
  37809. */
  37810. // eslint-disable-next-line valid-jsdoc
  37811. /**
  37812. * Callback JavaScript function to format the data label. Note that
  37813. * if a `format` is defined, the format takes precedence and the
  37814. * formatter is ignored.
  37815. *
  37816. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37817. * Formatted value
  37818. *
  37819. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37820. */
  37821. formatter: function () {
  37822. var numberFormatter = this.series.chart.numberFormatter;
  37823. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  37824. },
  37825. /**
  37826. * For points with an extent, like columns or map areas, whether to
  37827. * align the data label inside the box or to the actual value point.
  37828. * Defaults to `false` in most cases, `true` in stacked columns.
  37829. *
  37830. * @type {boolean}
  37831. * @since 3.0
  37832. * @apioption plotOptions.series.dataLabels.inside
  37833. */
  37834. /**
  37835. * Format for points with the value of null. Works analogously to
  37836. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  37837. * be applied only to series which support displaying null points.
  37838. *
  37839. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37840. * Format data label and tooltip for null point.
  37841. *
  37842. * @type {boolean|string}
  37843. * @since 7.1.0
  37844. * @apioption plotOptions.series.dataLabels.nullFormat
  37845. */
  37846. /**
  37847. * Callback JavaScript function that defines formatting for points
  37848. * with the value of null. Works analogously to
  37849. * [formatter](#plotOptions.series.dataLabels.formatter).
  37850. * `nullPointFormatter` can be applied only to series which support
  37851. * displaying null points.
  37852. *
  37853. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37854. * Format data label and tooltip for null point.
  37855. *
  37856. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37857. * @since 7.1.0
  37858. * @apioption plotOptions.series.dataLabels.nullFormatter
  37859. */
  37860. /**
  37861. * How to handle data labels that flow outside the plot area. The
  37862. * default is `"justify"`, which aligns them inside the plot area.
  37863. * For columns and bars, this means it will be moved inside the bar.
  37864. * To display data labels outside the plot area, set `crop` to
  37865. * `false` and `overflow` to `"allow"`.
  37866. *
  37867. * @type {Highcharts.DataLabelsOverflowValue}
  37868. * @default justify
  37869. * @since 3.0.6
  37870. * @apioption plotOptions.series.dataLabels.overflow
  37871. */
  37872. /**
  37873. * When either the `borderWidth` or the `backgroundColor` is set,
  37874. * this is the padding within the box.
  37875. *
  37876. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37877. * Data labels box options
  37878. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37879. * Data labels box options
  37880. *
  37881. * @since 2.2.1
  37882. */
  37883. padding: 5,
  37884. /**
  37885. * Aligns data labels relative to points. If `center` alignment is
  37886. * not possible, it defaults to `right`.
  37887. *
  37888. * @type {Highcharts.AlignValue}
  37889. * @default center
  37890. * @apioption plotOptions.series.dataLabels.position
  37891. */
  37892. /**
  37893. * Text rotation in degrees. Note that due to a more complex
  37894. * structure, backgrounds, borders and padding will be lost on a
  37895. * rotated data label.
  37896. *
  37897. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37898. * Vertical labels
  37899. *
  37900. * @type {number}
  37901. * @default 0
  37902. * @apioption plotOptions.series.dataLabels.rotation
  37903. */
  37904. /**
  37905. * The shadow of the box. Works best with `borderWidth` or
  37906. * `backgroundColor`. Since 2.3 the shadow can be an object
  37907. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  37908. * and `width`.
  37909. *
  37910. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37911. * Data labels box options
  37912. *
  37913. * @type {boolean|Highcharts.ShadowOptionsObject}
  37914. * @default false
  37915. * @since 2.2.1
  37916. * @apioption plotOptions.series.dataLabels.shadow
  37917. */
  37918. /**
  37919. * The name of a symbol to use for the border around the label.
  37920. * Symbols are predefined functions on the Renderer object.
  37921. *
  37922. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  37923. * A callout for annotations
  37924. *
  37925. * @type {string}
  37926. * @default square
  37927. * @since 4.1.2
  37928. * @apioption plotOptions.series.dataLabels.shape
  37929. */
  37930. /**
  37931. * Styles for the label. The default `color` setting is
  37932. * `"contrast"`, which is a pseudo color that Highcharts picks up
  37933. * and applies the maximum contrast to the underlying point item,
  37934. * for example the bar in a bar chart.
  37935. *
  37936. * The `textOutline` is a pseudo property that applies an outline of
  37937. * the given width with the given color, which by default is the
  37938. * maximum contrast to the text. So a bright text color will result
  37939. * in a black text outline for maximum readability on a mixed
  37940. * background. In some cases, especially with grayscale text, the
  37941. * text outline doesn't work well, in which cases it can be disabled
  37942. * by setting it to `"none"`. When `useHTML` is true, the
  37943. * `textOutline` will not be picked up. In this, case, the same
  37944. * effect can be acheived through the `text-shadow` CSS property.
  37945. *
  37946. * For some series types, where each point has an extent, like for
  37947. * example tree maps, the data label may overflow the point. There
  37948. * are two strategies for handling overflow. By default, the text
  37949. * will wrap to multiple lines. The other strategy is to set
  37950. * `style.textOverflow` to `ellipsis`, which will keep the text on
  37951. * one line plus it will break inside long words.
  37952. *
  37953. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  37954. * Bold labels
  37955. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  37956. * Long labels truncated with an ellipsis in a pie
  37957. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  37958. * Long labels are wrapped in a pie
  37959. * @sample {highmaps} maps/demo/color-axis/
  37960. * Bold labels
  37961. *
  37962. * @type {Highcharts.CSSObject}
  37963. * @since 4.1.0
  37964. * @apioption plotOptions.series.dataLabels.style
  37965. */
  37966. style: {
  37967. /** @internal */
  37968. fontSize: '11px',
  37969. /** @internal */
  37970. fontWeight: 'bold',
  37971. /** @internal */
  37972. color: 'contrast',
  37973. /** @internal */
  37974. textOutline: '1px contrast'
  37975. },
  37976. /**
  37977. * Options for a label text which should follow marker's shape.
  37978. * Border and background are disabled for a label that follows a
  37979. * path.
  37980. *
  37981. * **Note:** Only SVG-based renderer supports this option. Setting
  37982. * `useHTML` to true will disable this option.
  37983. *
  37984. * @declare Highcharts.DataLabelsTextPathOptionsObject
  37985. * @since 7.1.0
  37986. * @apioption plotOptions.series.dataLabels.textPath
  37987. */
  37988. /**
  37989. * Presentation attributes for the text path.
  37990. *
  37991. * @type {Highcharts.SVGAttributes}
  37992. * @since 7.1.0
  37993. * @apioption plotOptions.series.dataLabels.textPath.attributes
  37994. */
  37995. /**
  37996. * Enable or disable `textPath` option for link's or marker's data
  37997. * labels.
  37998. *
  37999. * @type {boolean}
  38000. * @since 7.1.0
  38001. * @apioption plotOptions.series.dataLabels.textPath.enabled
  38002. */
  38003. /**
  38004. * Whether to
  38005. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  38006. * to render the labels.
  38007. *
  38008. * @type {boolean}
  38009. * @default false
  38010. * @apioption plotOptions.series.dataLabels.useHTML
  38011. */
  38012. /**
  38013. * The vertical alignment of a data label. Can be one of `top`,
  38014. * `middle` or `bottom`. The default value depends on the data, for
  38015. * instance in a column chart, the label is above positive values
  38016. * and below negative values.
  38017. *
  38018. * @type {Highcharts.VerticalAlignValue|null}
  38019. * @since 2.3.3
  38020. */
  38021. verticalAlign: 'bottom',
  38022. /**
  38023. * The x position offset of the label relative to the point in
  38024. * pixels.
  38025. *
  38026. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  38027. * Vertical and positioned
  38028. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  38029. * Data labels inside the bar
  38030. */
  38031. x: 0,
  38032. /**
  38033. * The Z index of the data labels. The default Z index puts it above
  38034. * the series. Use a Z index of 2 to display it behind the series.
  38035. *
  38036. * @type {number}
  38037. * @default 6
  38038. * @since 2.3.5
  38039. * @apioption plotOptions.series.dataLabels.z
  38040. */
  38041. /**
  38042. * The y position offset of the label relative to the point in
  38043. * pixels.
  38044. *
  38045. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  38046. * Vertical and positioned
  38047. */
  38048. y: 0
  38049. },
  38050. /**
  38051. * When the series contains less points than the crop threshold, all
  38052. * points are drawn, even if the points fall outside the visible plot
  38053. * area at the current zoom. The advantage of drawing all points
  38054. * (including markers and columns), is that animation is performed on
  38055. * updates. On the other hand, when the series contains more points than
  38056. * the crop threshold, the series data is cropped to only contain points
  38057. * that fall within the plot area. The advantage of cropping away
  38058. * invisible points is to increase performance on large series.
  38059. *
  38060. * @since 2.2
  38061. * @product highcharts highstock
  38062. *
  38063. * @private
  38064. */
  38065. cropThreshold: 300,
  38066. /**
  38067. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  38068. *
  38069. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  38070. *
  38071. * @since 7.1.0
  38072. *
  38073. * @private
  38074. */
  38075. opacity: 1,
  38076. /**
  38077. * The width of each point on the x axis. For example in a column chart
  38078. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  38079. * * 1000 milliseconds). This is normally computed automatically, but
  38080. * this option can be used to override the automatic value.
  38081. *
  38082. * @product highstock
  38083. *
  38084. * @private
  38085. */
  38086. pointRange: 0,
  38087. /**
  38088. * When this is true, the series will not cause the Y axis to cross
  38089. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  38090. * unless the data actually crosses the plane.
  38091. *
  38092. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  38093. * 3 will make the Y axis show negative values according to the
  38094. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  38095. * at 0.
  38096. *
  38097. * @since 4.1.9
  38098. * @product highcharts highstock
  38099. *
  38100. * @private
  38101. */
  38102. softThreshold: true,
  38103. /**
  38104. * @declare Highcharts.SeriesStatesOptionsObject
  38105. *
  38106. * @private
  38107. */
  38108. states: {
  38109. /**
  38110. * The normal state of a series, or for point items in column, pie
  38111. * and similar series. Currently only used for setting animation
  38112. * when returning to normal state from hover.
  38113. *
  38114. * @declare Highcharts.SeriesStatesNormalOptionsObject
  38115. */
  38116. normal: {
  38117. /**
  38118. * Animation when returning to normal state after hovering.
  38119. *
  38120. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38121. */
  38122. animation: true
  38123. },
  38124. /**
  38125. * Options for the hovered series. These settings override the
  38126. * normal state options when a series is moused over or touched.
  38127. *
  38128. * @declare Highcharts.SeriesStatesHoverOptionsObject
  38129. */
  38130. hover: {
  38131. /**
  38132. * Enable separate styles for the hovered series to visualize
  38133. * that the user hovers either the series itself or the legend.
  38134. *
  38135. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  38136. * Line
  38137. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  38138. * Column
  38139. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  38140. * Pie
  38141. *
  38142. * @type {boolean}
  38143. * @default true
  38144. * @since 1.2
  38145. * @apioption plotOptions.series.states.hover.enabled
  38146. */
  38147. /**
  38148. * Animation setting for hovering the graph in line-type series.
  38149. *
  38150. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38151. * @since 5.0.8
  38152. * @product highcharts highstock
  38153. */
  38154. animation: {
  38155. /**
  38156. * The duration of the hover animation in milliseconds. By
  38157. * default the hover state animates quickly in, and slowly
  38158. * back to normal.
  38159. *
  38160. * @internal
  38161. */
  38162. duration: 50
  38163. },
  38164. /**
  38165. * Pixel width of the graph line. By default this property is
  38166. * undefined, and the `lineWidthPlus` property dictates how much
  38167. * to increase the linewidth from normal state.
  38168. *
  38169. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  38170. * 5px line on hover
  38171. *
  38172. * @type {number}
  38173. * @product highcharts highstock
  38174. * @apioption plotOptions.series.states.hover.lineWidth
  38175. */
  38176. /**
  38177. * The additional line width for the graph of a hovered series.
  38178. *
  38179. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  38180. * 5 pixels wider
  38181. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  38182. * 5 pixels wider
  38183. *
  38184. * @since 4.0.3
  38185. * @product highcharts highstock
  38186. */
  38187. lineWidthPlus: 1,
  38188. /**
  38189. * In Highcharts 1.0, the appearance of all markers belonging
  38190. * to the hovered series. For settings on the hover state of the
  38191. * individual point, see
  38192. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  38193. *
  38194. * @deprecated
  38195. *
  38196. * @extends plotOptions.series.marker
  38197. * @excluding states
  38198. * @product highcharts highstock
  38199. */
  38200. marker: {
  38201. // lineWidth: base + 1,
  38202. // radius: base + 1
  38203. },
  38204. /**
  38205. * Options for the halo appearing around the hovered point in
  38206. * line-type series as well as outside the hovered slice in pie
  38207. * charts. By default the halo is filled by the current point or
  38208. * series color with an opacity of 0.25\. The halo can be
  38209. * disabled by setting the `halo` option to `null`.
  38210. *
  38211. * In styled mode, the halo is styled with the
  38212. * `.highcharts-halo` class, with colors inherited from
  38213. * `.highcharts-color-{n}`.
  38214. *
  38215. * @sample {highcharts} highcharts/plotoptions/halo/
  38216. * Halo options
  38217. * @sample {highstock} highcharts/plotoptions/halo/
  38218. * Halo options
  38219. *
  38220. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  38221. * @type {null|*}
  38222. * @since 4.0
  38223. * @product highcharts highstock
  38224. */
  38225. halo: {
  38226. /**
  38227. * A collection of SVG attributes to override the appearance
  38228. * of the halo, for example `fill`, `stroke` and
  38229. * `stroke-width`.
  38230. *
  38231. * @type {Highcharts.SVGAttributes}
  38232. * @since 4.0
  38233. * @product highcharts highstock
  38234. * @apioption plotOptions.series.states.hover.halo.attributes
  38235. */
  38236. /**
  38237. * The pixel size of the halo. For point markers this is the
  38238. * radius of the halo. For pie slices it is the width of the
  38239. * halo outside the slice. For bubbles it defaults to 5 and
  38240. * is the width of the halo outside the bubble.
  38241. *
  38242. * @since 4.0
  38243. * @product highcharts highstock
  38244. */
  38245. size: 10,
  38246. /**
  38247. * Opacity for the halo unless a specific fill is overridden
  38248. * using the `attributes` setting. Note that Highcharts is
  38249. * only able to apply opacity to colors of hex or rgb(a)
  38250. * formats.
  38251. *
  38252. * @since 4.0
  38253. * @product highcharts highstock
  38254. */
  38255. opacity: 0.25
  38256. }
  38257. },
  38258. /**
  38259. * Specific options for point in selected states, after being
  38260. * selected by
  38261. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  38262. * or programmatically.
  38263. *
  38264. * @sample maps/plotoptions/series-allowpointselect/
  38265. * Allow point select demo
  38266. *
  38267. * @declare Highcharts.SeriesStatesSelectOptionsObject
  38268. * @extends plotOptions.series.states.hover
  38269. * @excluding brightness
  38270. */
  38271. select: {
  38272. animation: {
  38273. /** @internal */
  38274. duration: 0
  38275. }
  38276. },
  38277. /**
  38278. * The opposite state of a hover for series.
  38279. *
  38280. * @sample highcharts/plotoptions/series-states-inactive-disabled
  38281. * Disabled inactive state
  38282. *
  38283. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  38284. */
  38285. inactive: {
  38286. /**
  38287. * Enable or disable the inactive state for a series
  38288. *
  38289. * @sample highcharts/plotoptions/series-states-inactive-disabled
  38290. * Disabled inactive state
  38291. *
  38292. * @type {boolean}
  38293. * @default true
  38294. * @apioption plotOptions.series.states.inactive.enabled
  38295. */
  38296. /**
  38297. * The animation for entering the inactive state.
  38298. *
  38299. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38300. */
  38301. animation: {
  38302. /** @internal */
  38303. duration: 50
  38304. },
  38305. /**
  38306. * Opacity of series elements (dataLabels, line, area).
  38307. *
  38308. * @type {number}
  38309. */
  38310. opacity: 0.2
  38311. }
  38312. },
  38313. /**
  38314. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  38315. * series isn't triggered until the mouse moves over another series, or
  38316. * out of the plot area. When false, the `mouseOut` event on a series is
  38317. * triggered when the mouse leaves the area around the series' graph or
  38318. * markers. This also implies the tooltip when not shared. When
  38319. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  38320. * will be hidden when moving the mouse between series. Defaults to true
  38321. * for line and area type series, but to false for columns, pies etc.
  38322. *
  38323. * **Note:** The boost module will force this option because of
  38324. * technical limitations.
  38325. *
  38326. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  38327. * True by default
  38328. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  38329. * False
  38330. *
  38331. * @default {highcharts} true
  38332. * @default {highstock} true
  38333. * @default {highmaps} false
  38334. * @since 2.0
  38335. *
  38336. * @private
  38337. */
  38338. stickyTracking: true,
  38339. /**
  38340. * A configuration object for the tooltip rendering of each single
  38341. * series. Properties are inherited from [tooltip](#tooltip), but only
  38342. * the following properties can be defined on a series level.
  38343. *
  38344. * @declare Highcharts.SeriesTooltipOptionsObject
  38345. * @since 2.3
  38346. * @extends tooltip
  38347. * @excluding animation, backgroundColor, borderColor, borderRadius,
  38348. * borderWidth, className, crosshairs, enabled, formatter,
  38349. * headerShape, hideDelay, outside, padding, positioner,
  38350. * shadow, shape, shared, snap, split, stickOnContact,
  38351. * style, useHTML
  38352. * @apioption plotOptions.series.tooltip
  38353. */
  38354. /**
  38355. * When a series contains a data array that is longer than this, only
  38356. * one dimensional arrays of numbers, or two dimensional arrays with
  38357. * x and y values are allowed. Also, only the first point is tested,
  38358. * and the rest are assumed to be the same format. This saves expensive
  38359. * data checking and indexing in long series. Set it to `0` disable.
  38360. *
  38361. * Note:
  38362. * In boost mode turbo threshold is forced. Only array of numbers or
  38363. * two dimensional arrays are allowed.
  38364. *
  38365. * @since 2.2
  38366. * @product highcharts highstock gantt
  38367. *
  38368. * @private
  38369. */
  38370. turboThreshold: 1000,
  38371. /**
  38372. * An array defining zones within a series. Zones can be applied to the
  38373. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  38374. * option. The zone definitions have to be in ascending order regarding
  38375. * to the value.
  38376. *
  38377. * In styled mode, the color zones are styled with the
  38378. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  38379. * option
  38380. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  38381. *
  38382. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  38383. *
  38384. * @sample {highcharts} highcharts/series/color-zones-simple/
  38385. * Color zones
  38386. * @sample {highstock} highcharts/series/color-zones-simple/
  38387. * Color zones
  38388. *
  38389. * @declare Highcharts.SeriesZonesOptionsObject
  38390. * @type {Array<*>}
  38391. * @since 4.1.0
  38392. * @product highcharts highstock
  38393. * @apioption plotOptions.series.zones
  38394. */
  38395. /**
  38396. * Styled mode only. A custom class name for the zone.
  38397. *
  38398. * @sample highcharts/css/color-zones/
  38399. * Zones styled by class name
  38400. *
  38401. * @type {string}
  38402. * @since 5.0.0
  38403. * @apioption plotOptions.series.zones.className
  38404. */
  38405. /**
  38406. * Defines the color of the series.
  38407. *
  38408. * @see [series color](#plotOptions.series.color)
  38409. *
  38410. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38411. * @since 4.1.0
  38412. * @product highcharts highstock
  38413. * @apioption plotOptions.series.zones.color
  38414. */
  38415. /**
  38416. * A name for the dash style to use for the graph.
  38417. *
  38418. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  38419. *
  38420. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  38421. * Dashed line indicates prognosis
  38422. *
  38423. * @type {Highcharts.DashStyleValue}
  38424. * @since 4.1.0
  38425. * @product highcharts highstock
  38426. * @apioption plotOptions.series.zones.dashStyle
  38427. */
  38428. /**
  38429. * Defines the fill color for the series (in area type series)
  38430. *
  38431. * @see [fillColor](#plotOptions.area.fillColor)
  38432. *
  38433. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38434. * @since 4.1.0
  38435. * @product highcharts highstock
  38436. * @apioption plotOptions.series.zones.fillColor
  38437. */
  38438. /**
  38439. * The value up to where the zone extends, if undefined the zones
  38440. * stretches to the last value in the series.
  38441. *
  38442. * @type {number}
  38443. * @since 4.1.0
  38444. * @product highcharts highstock
  38445. * @apioption plotOptions.series.zones.value
  38446. */
  38447. /**
  38448. * When using dual or multiple color axes, this number defines which
  38449. * colorAxis the particular series is connected to. It refers to
  38450. * either the
  38451. * {@link #colorAxis.id|axis id}
  38452. * or the index of the axis in the colorAxis array, with 0 being the
  38453. * first. Set this option to false to prevent a series from connecting
  38454. * to the default color axis.
  38455. *
  38456. * Since v7.2.0 the option can also be an axis id or an axis index
  38457. * instead of a boolean flag.
  38458. *
  38459. * @sample highcharts/coloraxis/coloraxis-with-pie/
  38460. * Color axis with pie series
  38461. * @sample highcharts/coloraxis/multiple-coloraxis/
  38462. * Multiple color axis
  38463. *
  38464. * @type {number|string|boolean}
  38465. * @default 0
  38466. * @product highcharts highstock highmaps
  38467. * @apioption plotOptions.series.colorAxis
  38468. */
  38469. /**
  38470. * Determines what data value should be used to calculate point color
  38471. * if `colorAxis` is used. Requires to set `min` and `max` if some
  38472. * custom point property is used or if approximation for data grouping
  38473. * is set to `'sum'`.
  38474. *
  38475. * @sample highcharts/coloraxis/custom-color-key/
  38476. * Custom color key
  38477. * @sample highcharts/coloraxis/changed-default-color-key/
  38478. * Changed default color key
  38479. *
  38480. * @type {string}
  38481. * @default y
  38482. * @since 7.2.0
  38483. * @product highcharts highstock highmaps
  38484. * @apioption plotOptions.series.colorKey
  38485. */
  38486. /**
  38487. * Determines whether the series should look for the nearest point
  38488. * in both dimensions or just the x-dimension when hovering the series.
  38489. * Defaults to `'xy'` for scatter series and `'x'` for most other
  38490. * series. If the data has duplicate x-values, it is recommended to
  38491. * set this to `'xy'` to allow hovering over all points.
  38492. *
  38493. * Applies only to series types using nearest neighbor search (not
  38494. * direct hover) for tooltip.
  38495. *
  38496. * @sample {highcharts} highcharts/series/findnearestpointby/
  38497. * Different hover behaviors
  38498. * @sample {highstock} highcharts/series/findnearestpointby/
  38499. * Different hover behaviors
  38500. * @sample {highmaps} highcharts/series/findnearestpointby/
  38501. * Different hover behaviors
  38502. *
  38503. * @since 5.0.10
  38504. * @validvalue ["x", "xy"]
  38505. *
  38506. * @private
  38507. */
  38508. findNearestPointBy: 'x'
  38509. };
  38510. return Series;
  38511. }());
  38512. extend(Series.prototype, {
  38513. axisTypes: ['xAxis', 'yAxis'],
  38514. coll: 'series',
  38515. colorCounter: 0,
  38516. cropShoulder: 1,
  38517. directTouch: false,
  38518. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  38519. isCartesian: true,
  38520. kdAxisArray: ['clientX', 'plotY'],
  38521. // each point's x and y values are stored in this.xData and this.yData:
  38522. parallelArrays: ['x', 'y'],
  38523. pointClass: Point,
  38524. requireSorting: true,
  38525. // requires the data to be sorted:
  38526. sorted: true
  38527. });
  38528. /* *
  38529. *
  38530. * Registry
  38531. *
  38532. * */
  38533. SeriesRegistry.series = Series;
  38534. /* *
  38535. *
  38536. * Default Export
  38537. *
  38538. * */
  38539. /* *
  38540. *
  38541. * API Declarations
  38542. *
  38543. * */
  38544. /**
  38545. * This is a placeholder type of the possible series options for
  38546. * [Highcharts](../highcharts/series), [Highcharts Stock](../highstock/series),
  38547. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  38548. *
  38549. * In TypeScript is this dynamically generated to reference all possible types
  38550. * of series options.
  38551. *
  38552. * @ignore-declaration
  38553. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  38554. */
  38555. /**
  38556. * Options for `dataSorting`.
  38557. *
  38558. * @interface Highcharts.DataSortingOptionsObject
  38559. * @since 8.0.0
  38560. */ /**
  38561. * Enable or disable data sorting for the series.
  38562. * @name Highcharts.DataSortingOptionsObject#enabled
  38563. * @type {boolean|undefined}
  38564. */ /**
  38565. * Whether to allow matching points by name in an update.
  38566. * @name Highcharts.DataSortingOptionsObject#matchByName
  38567. * @type {boolean|undefined}
  38568. */ /**
  38569. * Determines what data value should be used to sort by.
  38570. * @name Highcharts.DataSortingOptionsObject#sortKey
  38571. * @type {string|undefined}
  38572. */
  38573. /**
  38574. * Function callback when a series has been animated.
  38575. *
  38576. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  38577. *
  38578. * @param {Highcharts.Series} this
  38579. * The series where the event occured.
  38580. *
  38581. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  38582. * Event arguments.
  38583. */
  38584. /**
  38585. * Event information regarding completed animation of a series.
  38586. *
  38587. * @interface Highcharts.SeriesAfterAnimateEventObject
  38588. */ /**
  38589. * Animated series.
  38590. * @name Highcharts.SeriesAfterAnimateEventObject#target
  38591. * @type {Highcharts.Series}
  38592. */ /**
  38593. * Event type.
  38594. * @name Highcharts.SeriesAfterAnimateEventObject#type
  38595. * @type {"afterAnimate"}
  38596. */
  38597. /**
  38598. * Function callback when the checkbox next to the series' name in the legend is
  38599. * clicked.
  38600. *
  38601. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  38602. *
  38603. * @param {Highcharts.Series} this
  38604. * The series where the event occured.
  38605. *
  38606. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  38607. * Event arguments.
  38608. */
  38609. /**
  38610. * Event information regarding check of a series box.
  38611. *
  38612. * @interface Highcharts.SeriesCheckboxClickEventObject
  38613. */ /**
  38614. * Whether the box has been checked.
  38615. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  38616. * @type {boolean}
  38617. */ /**
  38618. * Related series.
  38619. * @name Highcharts.SeriesCheckboxClickEventObject#item
  38620. * @type {Highcharts.Series}
  38621. */ /**
  38622. * Related series.
  38623. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38624. * @type {Highcharts.Series}
  38625. */ /**
  38626. * Event type.
  38627. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38628. * @type {"checkboxClick"}
  38629. */
  38630. /**
  38631. * Function callback when a series is clicked. Return false to cancel toogle
  38632. * actions.
  38633. *
  38634. * @callback Highcharts.SeriesClickCallbackFunction
  38635. *
  38636. * @param {Highcharts.Series} this
  38637. * The series where the event occured.
  38638. *
  38639. * @param {Highcharts.SeriesClickEventObject} event
  38640. * Event arguments.
  38641. */
  38642. /**
  38643. * Common information for a click event on a series.
  38644. *
  38645. * @interface Highcharts.SeriesClickEventObject
  38646. * @extends global.Event
  38647. */ /**
  38648. * Nearest point on the graph.
  38649. * @name Highcharts.SeriesClickEventObject#point
  38650. * @type {Highcharts.Point}
  38651. */
  38652. /**
  38653. * Gets fired when the series is hidden after chart generation time, either by
  38654. * clicking the legend item or by calling `.hide()`.
  38655. *
  38656. * @callback Highcharts.SeriesHideCallbackFunction
  38657. *
  38658. * @param {Highcharts.Series} this
  38659. * The series where the event occured.
  38660. *
  38661. * @param {global.Event} event
  38662. * The event that occured.
  38663. */
  38664. /**
  38665. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  38666. * graph.
  38667. *
  38668. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  38669. */
  38670. /**
  38671. * Gets fired when the legend item belonging to the series is clicked. The
  38672. * default action is to toggle the visibility of the series. This can be
  38673. * prevented by returning `false` or calling `event.preventDefault()`.
  38674. *
  38675. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  38676. *
  38677. * @param {Highcharts.Series} this
  38678. * The series where the event occured.
  38679. *
  38680. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  38681. * The event that occured.
  38682. */
  38683. /**
  38684. * Information about the event.
  38685. *
  38686. * @interface Highcharts.SeriesLegendItemClickEventObject
  38687. */ /**
  38688. * Related browser event.
  38689. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  38690. * @type {global.PointerEvent}
  38691. */ /**
  38692. * Prevent the default action of toggle the visibility of the series.
  38693. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  38694. * @type {Function}
  38695. */ /**
  38696. * Related series.
  38697. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38698. * @type {Highcharts.Series}
  38699. */ /**
  38700. * Event type.
  38701. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38702. * @type {"checkboxClick"}
  38703. */
  38704. /**
  38705. * Gets fired when the mouse leaves the graph.
  38706. *
  38707. * @callback Highcharts.SeriesMouseOutCallbackFunction
  38708. *
  38709. * @param {Highcharts.Series} this
  38710. * Series where the event occured.
  38711. *
  38712. * @param {global.PointerEvent} event
  38713. * Event that occured.
  38714. */
  38715. /**
  38716. * Gets fired when the mouse enters the graph.
  38717. *
  38718. * @callback Highcharts.SeriesMouseOverCallbackFunction
  38719. *
  38720. * @param {Highcharts.Series} this
  38721. * Series where the event occured.
  38722. *
  38723. * @param {global.PointerEvent} event
  38724. * Event that occured.
  38725. */
  38726. /**
  38727. * Translation and scale for the plot area of a series.
  38728. *
  38729. * @interface Highcharts.SeriesPlotBoxObject
  38730. */ /**
  38731. * @name Highcharts.SeriesPlotBoxObject#scaleX
  38732. * @type {number}
  38733. */ /**
  38734. * @name Highcharts.SeriesPlotBoxObject#scaleY
  38735. * @type {number}
  38736. */ /**
  38737. * @name Highcharts.SeriesPlotBoxObject#translateX
  38738. * @type {number}
  38739. */ /**
  38740. * @name Highcharts.SeriesPlotBoxObject#translateY
  38741. * @type {number}
  38742. */
  38743. /**
  38744. * Gets fired when the series is shown after chart generation time, either by
  38745. * clicking the legend item or by calling `.show()`.
  38746. *
  38747. * @callback Highcharts.SeriesShowCallbackFunction
  38748. *
  38749. * @param {Highcharts.Series} this
  38750. * Series where the event occured.
  38751. *
  38752. * @param {global.Event} event
  38753. * Event that occured.
  38754. */
  38755. /**
  38756. * Possible key values for the series state options.
  38757. *
  38758. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  38759. */
  38760. ''; // detach doclets above
  38761. /* *
  38762. *
  38763. * API Options
  38764. *
  38765. * */
  38766. /**
  38767. * Series options for specific data and the data itself. In TypeScript you
  38768. * have to cast the series options to specific series types, to get all
  38769. * possible options for a series.
  38770. *
  38771. * @example
  38772. * // TypeScript example
  38773. * Highcharts.chart('container', {
  38774. * series: [{
  38775. * color: '#06C',
  38776. * data: [[0, 1], [2, 3]]
  38777. * } as Highcharts.SeriesLineOptions ]
  38778. * });
  38779. *
  38780. * @type {Array<*>}
  38781. * @apioption series
  38782. */
  38783. /**
  38784. * An id for the series. This can be used after render time to get a pointer
  38785. * to the series object through `chart.get()`.
  38786. *
  38787. * @sample {highcharts} highcharts/plotoptions/series-id/
  38788. * Get series by id
  38789. *
  38790. * @type {string}
  38791. * @since 1.2.0
  38792. * @apioption series.id
  38793. */
  38794. /**
  38795. * The index of the series in the chart, affecting the internal index in the
  38796. * `chart.series` array, the visible Z index as well as the order in the
  38797. * legend.
  38798. *
  38799. * @type {number}
  38800. * @since 2.3.0
  38801. * @apioption series.index
  38802. */
  38803. /**
  38804. * The sequential index of the series in the legend.
  38805. *
  38806. * @see [legend.reversed](#legend.reversed),
  38807. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  38808. *
  38809. * @sample {highcharts|highstock} highcharts/series/legendindex/
  38810. * Legend in opposite order
  38811. *
  38812. * @type {number}
  38813. * @apioption series.legendIndex
  38814. */
  38815. /**
  38816. * The name of the series as shown in the legend, tooltip etc.
  38817. *
  38818. * @sample {highcharts} highcharts/series/name/
  38819. * Series name
  38820. * @sample {highmaps} maps/demo/category-map/
  38821. * Series name
  38822. *
  38823. * @type {string}
  38824. * @apioption series.name
  38825. */
  38826. /**
  38827. * This option allows grouping series in a stacked chart. The stack option
  38828. * can be a string or anything else, as long as the grouped series' stack
  38829. * options match each other after conversion into a string.
  38830. *
  38831. * @sample {highcharts} highcharts/series/stack/
  38832. * Stacked and grouped columns
  38833. *
  38834. * @type {number|string}
  38835. * @since 2.1
  38836. * @product highcharts highstock
  38837. * @apioption series.stack
  38838. */
  38839. /**
  38840. * The type of series, for example `line` or `column`. By default, the
  38841. * series type is inherited from [chart.type](#chart.type), so unless the
  38842. * chart is a combination of series types, there is no need to set it on the
  38843. * series level.
  38844. *
  38845. * @sample {highcharts} highcharts/series/type/
  38846. * Line and column in the same chart
  38847. * @sample highcharts/series/type-dynamic/
  38848. * Dynamic types with button selector
  38849. * @sample {highmaps} maps/demo/mapline-mappoint/
  38850. * Multiple types in the same map
  38851. *
  38852. * @type {string}
  38853. * @apioption series.type
  38854. */
  38855. /**
  38856. * When using dual or multiple x axes, this number defines which xAxis the
  38857. * particular series is connected to. It refers to either the
  38858. * {@link #xAxis.id|axis id}
  38859. * or the index of the axis in the xAxis array, with 0 being the first.
  38860. *
  38861. * @type {number|string}
  38862. * @default 0
  38863. * @product highcharts highstock
  38864. * @apioption series.xAxis
  38865. */
  38866. /**
  38867. * When using dual or multiple y axes, this number defines which yAxis the
  38868. * particular series is connected to. It refers to either the
  38869. * {@link #yAxis.id|axis id}
  38870. * or the index of the axis in the yAxis array, with 0 being the first.
  38871. *
  38872. * @sample {highcharts} highcharts/series/yaxis/
  38873. * Apply the column series to the secondary Y axis
  38874. *
  38875. * @type {number|string}
  38876. * @default 0
  38877. * @product highcharts highstock
  38878. * @apioption series.yAxis
  38879. */
  38880. /**
  38881. * Define the visual z index of the series.
  38882. *
  38883. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  38884. * With no z index, the series defined last are on top
  38885. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  38886. * With a z index, the series with the highest z index is on top
  38887. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  38888. * With no z index, the series defined last are on top
  38889. * @sample {highstock} highcharts/plotoptions/series-zindex/
  38890. * With a z index, the series with the highest z index is on top
  38891. *
  38892. * @type {number}
  38893. * @product highcharts highstock
  38894. * @apioption series.zIndex
  38895. */
  38896. ''; // include precedent doclets in transpilat
  38897. return Series;
  38898. });
  38899. _registerModule(_modules, 'Extensions/ScrollablePlotArea.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Series/Series.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Series, RendererRegistry, U) {
  38900. /* *
  38901. *
  38902. * (c) 2010-2021 Torstein Honsi
  38903. *
  38904. * License: www.highcharts.com/license
  38905. *
  38906. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38907. *
  38908. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  38909. * horizontally on mobile devices. Supports left and right side axes.
  38910. */
  38911. /*
  38912. WIP on vertical scrollable plot area (#9378). To do:
  38913. - Bottom axis positioning
  38914. - Test with Gantt
  38915. - Look for size optimizing the code
  38916. - API and demos
  38917. */
  38918. var stop = A.stop;
  38919. var addEvent = U.addEvent,
  38920. createElement = U.createElement,
  38921. merge = U.merge,
  38922. pick = U.pick;
  38923. /* eslint-disable no-invalid-this, valid-jsdoc */
  38924. addEvent(Chart, 'afterSetChartSize', function (e) {
  38925. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  38926. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  38927. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  38928. scrollablePixelsX,
  38929. scrollablePixelsY,
  38930. corrections;
  38931. if (!this.renderer.forExport) {
  38932. // The amount of pixels to scroll, the difference between chart
  38933. // width and scrollable width
  38934. if (scrollableMinWidth) {
  38935. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  38936. if (scrollablePixelsX) {
  38937. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38938. this.plotBox.width = this.plotWidth += scrollablePixelsX;
  38939. if (this.inverted) {
  38940. this.clipBox.height += scrollablePixelsX;
  38941. }
  38942. else {
  38943. this.clipBox.width += scrollablePixelsX;
  38944. }
  38945. corrections = {
  38946. // Corrections for right side
  38947. 1: { name: 'right', value: scrollablePixelsX }
  38948. };
  38949. }
  38950. // Currently we can only do either X or Y
  38951. }
  38952. else if (scrollableMinHeight) {
  38953. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  38954. if (scrollablePixelsY) {
  38955. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38956. this.plotBox.height = this.plotHeight += scrollablePixelsY;
  38957. if (this.inverted) {
  38958. this.clipBox.width += scrollablePixelsY;
  38959. }
  38960. else {
  38961. this.clipBox.height += scrollablePixelsY;
  38962. }
  38963. corrections = {
  38964. 2: { name: 'bottom', value: scrollablePixelsY }
  38965. };
  38966. }
  38967. }
  38968. if (corrections && !e.skipAxes) {
  38969. this.axes.forEach(function (axis) {
  38970. // For right and bottom axes, only fix the plot line length
  38971. if (corrections[axis.side]) {
  38972. // Get the plot lines right in getPlotLinePath,
  38973. // temporarily set it to the adjusted plot width.
  38974. axis.getPlotLinePath = function () {
  38975. var marginName = corrections[axis.side].name,
  38976. correctionValue = corrections[axis.side].value,
  38977. // axis.right or axis.bottom
  38978. margin = this[marginName],
  38979. path;
  38980. // Temporarily adjust
  38981. this[marginName] = margin - correctionValue;
  38982. path = Axis.prototype.getPlotLinePath.apply(this, arguments);
  38983. // Reset
  38984. this[marginName] = margin;
  38985. return path;
  38986. };
  38987. }
  38988. else {
  38989. // Apply the corrected plotWidth
  38990. axis.setAxisSize();
  38991. axis.setAxisTranslation();
  38992. }
  38993. });
  38994. }
  38995. }
  38996. });
  38997. addEvent(Chart, 'render', function () {
  38998. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  38999. if (this.setUpScrolling) {
  39000. this.setUpScrolling();
  39001. }
  39002. this.applyFixed();
  39003. }
  39004. else if (this.fixedDiv) { // Has been in scrollable mode
  39005. this.applyFixed();
  39006. }
  39007. });
  39008. /**
  39009. * @private
  39010. * @function Highcharts.Chart#setUpScrolling
  39011. * @return {void}
  39012. */
  39013. Chart.prototype.setUpScrolling = function () {
  39014. var _this = this;
  39015. var css = {
  39016. WebkitOverflowScrolling: 'touch',
  39017. overflowX: 'hidden',
  39018. overflowY: 'hidden'
  39019. };
  39020. if (this.scrollablePixelsX) {
  39021. css.overflowX = 'auto';
  39022. }
  39023. if (this.scrollablePixelsY) {
  39024. css.overflowY = 'auto';
  39025. }
  39026. // Insert a container with position relative
  39027. // that scrolling and fixed container renders to (#10555)
  39028. this.scrollingParent = createElement('div', {
  39029. className: 'highcharts-scrolling-parent'
  39030. }, {
  39031. position: 'relative'
  39032. }, this.renderTo);
  39033. // Add the necessary divs to provide scrolling
  39034. this.scrollingContainer = createElement('div', {
  39035. 'className': 'highcharts-scrolling'
  39036. }, css, this.scrollingParent);
  39037. // On scroll, reset the chart position because it applies to the scrolled
  39038. // container
  39039. addEvent(this.scrollingContainer, 'scroll', function () {
  39040. if (_this.pointer) {
  39041. delete _this.pointer.chartPosition;
  39042. }
  39043. });
  39044. this.innerContainer = createElement('div', {
  39045. 'className': 'highcharts-inner-container'
  39046. }, null, this.scrollingContainer);
  39047. // Now move the container inside
  39048. this.innerContainer.appendChild(this.container);
  39049. // Don't run again
  39050. this.setUpScrolling = null;
  39051. };
  39052. /**
  39053. * These elements are moved over to the fixed renderer and stay fixed when the
  39054. * user scrolls the chart
  39055. * @private
  39056. */
  39057. Chart.prototype.moveFixedElements = function () {
  39058. var container = this.container,
  39059. fixedRenderer = this.fixedRenderer,
  39060. fixedSelectors = [
  39061. '.highcharts-contextbutton',
  39062. '.highcharts-credits',
  39063. '.highcharts-legend',
  39064. '.highcharts-legend-checkbox',
  39065. '.highcharts-navigator-series',
  39066. '.highcharts-navigator-xaxis',
  39067. '.highcharts-navigator-yaxis',
  39068. '.highcharts-navigator',
  39069. '.highcharts-reset-zoom',
  39070. '.highcharts-drillup-button',
  39071. '.highcharts-scrollbar',
  39072. '.highcharts-subtitle',
  39073. '.highcharts-title'
  39074. ],
  39075. axisClass;
  39076. if (this.scrollablePixelsX && !this.inverted) {
  39077. axisClass = '.highcharts-yaxis';
  39078. }
  39079. else if (this.scrollablePixelsX && this.inverted) {
  39080. axisClass = '.highcharts-xaxis';
  39081. }
  39082. else if (this.scrollablePixelsY && !this.inverted) {
  39083. axisClass = '.highcharts-xaxis';
  39084. }
  39085. else if (this.scrollablePixelsY && this.inverted) {
  39086. axisClass = '.highcharts-yaxis';
  39087. }
  39088. if (axisClass) {
  39089. fixedSelectors.push(axisClass + ":not(.highcharts-radial-axis)", axisClass + "-labels:not(.highcharts-radial-axis-labels)");
  39090. }
  39091. fixedSelectors.forEach(function (className) {
  39092. [].forEach.call(container.querySelectorAll(className), function (elem) {
  39093. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  39094. fixedRenderer.box :
  39095. fixedRenderer.box.parentNode).appendChild(elem);
  39096. elem.style.pointerEvents = 'auto';
  39097. });
  39098. });
  39099. };
  39100. /**
  39101. * @private
  39102. * @function Highcharts.Chart#applyFixed
  39103. * @return {void}
  39104. */
  39105. Chart.prototype.applyFixed = function () {
  39106. var firstTime = !this.fixedDiv,
  39107. chartOptions = this.options.chart,
  39108. scrollableOptions = chartOptions.scrollablePlotArea,
  39109. Renderer = RendererRegistry.getRendererType();
  39110. var fixedRenderer,
  39111. scrollableWidth,
  39112. scrollableHeight;
  39113. // First render
  39114. if (firstTime) {
  39115. this.fixedDiv = createElement('div', {
  39116. className: 'highcharts-fixed'
  39117. }, {
  39118. position: 'absolute',
  39119. overflow: 'hidden',
  39120. pointerEvents: 'none',
  39121. zIndex: (chartOptions.style && chartOptions.style.zIndex || 0) + 2,
  39122. top: 0
  39123. }, null, true);
  39124. if (this.scrollingContainer) {
  39125. this.scrollingContainer.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  39126. }
  39127. this.renderTo.style.overflow = 'visible';
  39128. this.fixedRenderer = fixedRenderer = new Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, this.options.chart.style);
  39129. // Mask
  39130. this.scrollableMask = fixedRenderer
  39131. .path()
  39132. .attr({
  39133. fill: this.options.chart.backgroundColor || '#fff',
  39134. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  39135. zIndex: -1
  39136. })
  39137. .addClass('highcharts-scrollable-mask')
  39138. .add();
  39139. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  39140. addEvent(this, 'afterDrilldown', this.moveFixedElements);
  39141. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  39142. }
  39143. else {
  39144. // Set the size of the fixed renderer to the visible width
  39145. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  39146. }
  39147. if (this.scrollableDirty || firstTime) {
  39148. this.scrollableDirty = false;
  39149. this.moveFixedElements();
  39150. }
  39151. // Increase the size of the scrollable renderer and background
  39152. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  39153. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  39154. stop(this.container);
  39155. this.container.style.width = scrollableWidth + 'px';
  39156. this.container.style.height = scrollableHeight + 'px';
  39157. this.renderer.boxWrapper.attr({
  39158. width: scrollableWidth,
  39159. height: scrollableHeight,
  39160. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  39161. });
  39162. this.chartBackground.attr({
  39163. width: scrollableWidth,
  39164. height: scrollableHeight
  39165. });
  39166. this.scrollingContainer.style.height = this.chartHeight + 'px';
  39167. // Set scroll position
  39168. if (firstTime) {
  39169. if (scrollableOptions.scrollPositionX) {
  39170. this.scrollingContainer.scrollLeft =
  39171. this.scrollablePixelsX *
  39172. scrollableOptions.scrollPositionX;
  39173. }
  39174. if (scrollableOptions.scrollPositionY) {
  39175. this.scrollingContainer.scrollTop =
  39176. this.scrollablePixelsY *
  39177. scrollableOptions.scrollPositionY;
  39178. }
  39179. }
  39180. // Mask behind the left and right side
  39181. var axisOffset = this.axisOffset,
  39182. maskTop = this.plotTop - axisOffset[0] - 1,
  39183. maskLeft = this.plotLeft - axisOffset[3] - 1,
  39184. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  39185. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  39186. maskPlotRight = this.plotLeft + this.plotWidth -
  39187. (this.scrollablePixelsX || 0),
  39188. maskPlotBottom = this.plotTop + this.plotHeight -
  39189. (this.scrollablePixelsY || 0),
  39190. d;
  39191. if (this.scrollablePixelsX) {
  39192. d = [
  39193. // Left side
  39194. ['M', 0, maskTop],
  39195. ['L', this.plotLeft - 1, maskTop],
  39196. ['L', this.plotLeft - 1, maskBottom],
  39197. ['L', 0, maskBottom],
  39198. ['Z'],
  39199. // Right side
  39200. ['M', maskPlotRight, maskTop],
  39201. ['L', this.chartWidth, maskTop],
  39202. ['L', this.chartWidth, maskBottom],
  39203. ['L', maskPlotRight, maskBottom],
  39204. ['Z']
  39205. ];
  39206. }
  39207. else if (this.scrollablePixelsY) {
  39208. d = [
  39209. // Top side
  39210. ['M', maskLeft, 0],
  39211. ['L', maskLeft, this.plotTop - 1],
  39212. ['L', maskRight, this.plotTop - 1],
  39213. ['L', maskRight, 0],
  39214. ['Z'],
  39215. // Bottom side
  39216. ['M', maskLeft, maskPlotBottom],
  39217. ['L', maskLeft, this.chartHeight],
  39218. ['L', maskRight, this.chartHeight],
  39219. ['L', maskRight, maskPlotBottom],
  39220. ['Z']
  39221. ];
  39222. }
  39223. else {
  39224. d = [['M', 0, 0]];
  39225. }
  39226. if (this.redrawTrigger !== 'adjustHeight') {
  39227. this.scrollableMask.attr({ d: d });
  39228. }
  39229. };
  39230. addEvent(Axis, 'afterInit', function () {
  39231. this.chart.scrollableDirty = true;
  39232. });
  39233. addEvent(Series, 'show', function () {
  39234. this.chart.scrollableDirty = true;
  39235. });
  39236. /* *
  39237. *
  39238. * API Declarations
  39239. *
  39240. * */
  39241. /**
  39242. * Options for a scrollable plot area. This feature provides a minimum size for
  39243. * the plot area of the chart. If the size gets smaller than this, typically
  39244. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  39245. * provides smooth scrolling for the contents of the plot area, whereas the
  39246. * title, legend and unaffected axes are fixed.
  39247. *
  39248. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  39249. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  39250. * option is set.
  39251. *
  39252. * @sample highcharts/chart/scrollable-plotarea
  39253. * Scrollable plot area
  39254. * @sample highcharts/chart/scrollable-plotarea-vertical
  39255. * Vertically scrollable plot area
  39256. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  39257. * Gantt chart with vertically scrollable plot area
  39258. *
  39259. * @since 6.1.0
  39260. * @product highcharts gantt
  39261. * @apioption chart.scrollablePlotArea
  39262. */
  39263. /**
  39264. * The minimum height for the plot area. If it gets smaller than this, the plot
  39265. * area will become scrollable.
  39266. *
  39267. * @type {number}
  39268. * @apioption chart.scrollablePlotArea.minHeight
  39269. */
  39270. /**
  39271. * The minimum width for the plot area. If it gets smaller than this, the plot
  39272. * area will become scrollable.
  39273. *
  39274. * @type {number}
  39275. * @apioption chart.scrollablePlotArea.minWidth
  39276. */
  39277. /**
  39278. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  39279. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  39280. * Typically we would use 1 if the chart has right aligned Y axes.
  39281. *
  39282. * @type {number}
  39283. * @apioption chart.scrollablePlotArea.scrollPositionX
  39284. */
  39285. /**
  39286. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  39287. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  39288. *
  39289. * @type {number}
  39290. * @apioption chart.scrollablePlotArea.scrollPositionY
  39291. */
  39292. /**
  39293. * The opacity of mask applied on one of the sides of the plot
  39294. * area.
  39295. *
  39296. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  39297. * Disabled opacity for the mask
  39298. *
  39299. * @type {number}
  39300. * @default 0.85
  39301. * @since 7.1.1
  39302. * @apioption chart.scrollablePlotArea.opacity
  39303. */
  39304. (''); // keep doclets above in transpiled file
  39305. });
  39306. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  39307. /* *
  39308. *
  39309. * (c) 2010-2021 Torstein Honsi
  39310. *
  39311. * License: www.highcharts.com/license
  39312. *
  39313. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39314. *
  39315. * */
  39316. var getDeferredAnimation = A.getDeferredAnimation;
  39317. var addEvent = U.addEvent,
  39318. destroyObjectProperties = U.destroyObjectProperties,
  39319. fireEvent = U.fireEvent,
  39320. isNumber = U.isNumber,
  39321. objectEach = U.objectEach,
  39322. pick = U.pick;
  39323. /* eslint-disable valid-jsdoc */
  39324. /**
  39325. * Adds stacking support to axes.
  39326. * @private
  39327. * @class
  39328. */
  39329. var StackingAxisAdditions = /** @class */ (function () {
  39330. /* *
  39331. *
  39332. * Constructors
  39333. *
  39334. * */
  39335. function StackingAxisAdditions(axis) {
  39336. this.oldStacks = {};
  39337. this.stacks = {};
  39338. this.stacksTouched = 0;
  39339. this.axis = axis;
  39340. }
  39341. /* *
  39342. *
  39343. * Functions
  39344. *
  39345. * */
  39346. /**
  39347. * Build the stacks from top down
  39348. * @private
  39349. */
  39350. StackingAxisAdditions.prototype.buildStacks = function () {
  39351. var stacking = this;
  39352. var axis = stacking.axis;
  39353. var axisSeries = axis.series;
  39354. var reversedStacks = axis.options.reversedStacks;
  39355. var len = axisSeries.length;
  39356. var actualSeries,
  39357. i;
  39358. if (!axis.isXAxis) {
  39359. stacking.usePercentage = false;
  39360. i = len;
  39361. while (i--) {
  39362. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  39363. actualSeries.setStackedPoints();
  39364. actualSeries.setGroupedPoints();
  39365. }
  39366. // Loop up again to compute percent and stream stack
  39367. for (i = 0; i < len; i++) {
  39368. axisSeries[i].modifyStacks();
  39369. }
  39370. fireEvent(axis, 'afterBuildStacks');
  39371. }
  39372. };
  39373. /**
  39374. * @private
  39375. */
  39376. StackingAxisAdditions.prototype.cleanStacks = function () {
  39377. var stacking = this;
  39378. var axis = stacking.axis;
  39379. var stacks;
  39380. if (!axis.isXAxis) {
  39381. if (stacking.oldStacks) {
  39382. stacks = stacking.stacks = stacking.oldStacks;
  39383. }
  39384. // reset stacks
  39385. objectEach(stacks, function (type) {
  39386. objectEach(type, function (stack) {
  39387. stack.cumulative = stack.total;
  39388. });
  39389. });
  39390. }
  39391. };
  39392. /**
  39393. * Set all the stacks to initial states and destroy unused ones.
  39394. * @private
  39395. */
  39396. StackingAxisAdditions.prototype.resetStacks = function () {
  39397. var _this = this;
  39398. var _a = this,
  39399. axis = _a.axis,
  39400. stacks = _a.stacks;
  39401. if (!axis.isXAxis) {
  39402. objectEach(stacks, function (type) {
  39403. objectEach(type, function (stack, x) {
  39404. // Clean up memory after point deletion (#1044, #4320)
  39405. if (isNumber(stack.touched) &&
  39406. stack.touched < _this.stacksTouched) {
  39407. stack.destroy();
  39408. delete type[x];
  39409. // Reset stacks
  39410. }
  39411. else {
  39412. stack.total = null;
  39413. stack.cumulative = null;
  39414. }
  39415. });
  39416. });
  39417. }
  39418. };
  39419. /**
  39420. * @private
  39421. */
  39422. StackingAxisAdditions.prototype.renderStackTotals = function () {
  39423. var stacking = this;
  39424. var axis = stacking.axis;
  39425. var chart = axis.chart;
  39426. var renderer = chart.renderer;
  39427. var stacks = stacking.stacks;
  39428. var stackLabelsAnim = axis.options.stackLabels && axis.options.stackLabels.animation;
  39429. var animationConfig = getDeferredAnimation(chart,
  39430. stackLabelsAnim || false);
  39431. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  39432. renderer
  39433. .g('stack-labels')
  39434. .attr({
  39435. visibility: 'visible',
  39436. zIndex: 6,
  39437. opacity: 0
  39438. })
  39439. .add());
  39440. // plotLeft/Top will change when y axis gets wider so we need to
  39441. // translate the stackTotalGroup at every render call. See bug #506
  39442. // and #516
  39443. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  39444. // Render each stack total
  39445. objectEach(stacks, function (type) {
  39446. objectEach(type, function (stack) {
  39447. stack.render(stackTotalGroup);
  39448. });
  39449. });
  39450. stackTotalGroup.animate({
  39451. opacity: 1
  39452. }, animationConfig);
  39453. };
  39454. return StackingAxisAdditions;
  39455. }());
  39456. /**
  39457. * Axis with stacking support.
  39458. * @private
  39459. * @class
  39460. */
  39461. var StackingAxis = /** @class */ (function () {
  39462. function StackingAxis() {
  39463. }
  39464. /* *
  39465. *
  39466. * Static Functions
  39467. *
  39468. * */
  39469. /**
  39470. * Extends axis with stacking support.
  39471. * @private
  39472. */
  39473. StackingAxis.compose = function (AxisClass) {
  39474. var axisProto = AxisClass.prototype;
  39475. addEvent(AxisClass, 'init', StackingAxis.onInit);
  39476. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  39477. };
  39478. /**
  39479. * @private
  39480. */
  39481. StackingAxis.onDestroy = function () {
  39482. var stacking = this.stacking;
  39483. if (!stacking) {
  39484. return;
  39485. }
  39486. var stacks = stacking.stacks;
  39487. // Destroy each stack total
  39488. objectEach(stacks, function (stack, stackKey) {
  39489. destroyObjectProperties(stack);
  39490. stacks[stackKey] = null;
  39491. });
  39492. if (stacking &&
  39493. stacking.stackTotalGroup) {
  39494. stacking.stackTotalGroup.destroy();
  39495. }
  39496. };
  39497. /**
  39498. * @private
  39499. */
  39500. StackingAxis.onInit = function () {
  39501. var axis = this;
  39502. if (!axis.stacking) {
  39503. axis.stacking = new StackingAxisAdditions(axis);
  39504. }
  39505. };
  39506. return StackingAxis;
  39507. }());
  39508. return StackingAxis;
  39509. });
  39510. _registerModule(_modules, 'Extensions/Stacking.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Axis/StackingAxis.js'], _modules['Core/Utilities.js']], function (Axis, Chart, F, H, Series, StackingAxis, U) {
  39511. /* *
  39512. *
  39513. * (c) 2010-2021 Torstein Honsi
  39514. *
  39515. * License: www.highcharts.com/license
  39516. *
  39517. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39518. *
  39519. * */
  39520. var format = F.format;
  39521. var correctFloat = U.correctFloat,
  39522. defined = U.defined,
  39523. destroyObjectProperties = U.destroyObjectProperties,
  39524. isArray = U.isArray,
  39525. isNumber = U.isNumber,
  39526. objectEach = U.objectEach,
  39527. pick = U.pick;
  39528. /* *
  39529. *
  39530. * Class
  39531. *
  39532. * */
  39533. /* eslint-disable no-invalid-this, valid-jsdoc */
  39534. /**
  39535. * The class for stacks. Each stack, on a specific X value and either negative
  39536. * or positive, has its own stack item.
  39537. *
  39538. * @private
  39539. * @class
  39540. * @name Highcharts.StackItem
  39541. * @param {Highcharts.Axis} axis
  39542. * @param {Highcharts.YAxisStackLabelsOptions} options
  39543. * @param {boolean} isNegative
  39544. * @param {number} x
  39545. * @param {Highcharts.OptionsStackingValue} [stackOption]
  39546. */
  39547. var StackItem = /** @class */ (function () {
  39548. function StackItem(axis, options, isNegative, x, stackOption) {
  39549. var inverted = axis.chart.inverted;
  39550. this.axis = axis;
  39551. // Tells if the stack is negative
  39552. this.isNegative = isNegative;
  39553. // Save the options to be able to style the label
  39554. this.options = options = options || {};
  39555. // Save the x value to be able to position the label later
  39556. this.x = x;
  39557. // Initialize total value
  39558. this.total = null;
  39559. // This will keep each points' extremes stored by series.index and point
  39560. // index
  39561. this.points = {};
  39562. this.hasValidPoints = false;
  39563. // Save the stack option on the series configuration object,
  39564. // and whether to treat it as percent
  39565. this.stack = stackOption;
  39566. this.leftCliff = 0;
  39567. this.rightCliff = 0;
  39568. // The align options and text align varies on whether the stack is
  39569. // negative and if the chart is inverted or not.
  39570. // First test the user supplied value, then use the dynamic.
  39571. this.alignOptions = {
  39572. align: options.align ||
  39573. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  39574. verticalAlign: options.verticalAlign ||
  39575. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  39576. y: options.y,
  39577. x: options.x
  39578. };
  39579. this.textAlign = options.textAlign ||
  39580. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  39581. }
  39582. /**
  39583. * @private
  39584. * @function Highcharts.StackItem#destroy
  39585. */
  39586. StackItem.prototype.destroy = function () {
  39587. destroyObjectProperties(this, this.axis);
  39588. };
  39589. /**
  39590. * Renders the stack total label and adds it to the stack label group.
  39591. *
  39592. * @private
  39593. * @function Highcharts.StackItem#render
  39594. * @param {Highcharts.SVGElement} group
  39595. */
  39596. StackItem.prototype.render = function (group) {
  39597. var chart = this.axis.chart,
  39598. options = this.options,
  39599. formatOption = options.format,
  39600. attr = {},
  39601. str = formatOption ? // format the text in the label
  39602. format(formatOption,
  39603. this,
  39604. chart) :
  39605. options.formatter.call(this);
  39606. // Change the text to reflect the new total and set visibility to hidden
  39607. // in case the serie is hidden
  39608. if (this.label) {
  39609. this.label.attr({ text: str, visibility: 'hidden' });
  39610. }
  39611. else {
  39612. // Create new label
  39613. this.label = chart.renderer
  39614. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  39615. attr = {
  39616. r: options.borderRadius || 0,
  39617. text: str,
  39618. rotation: options.rotation,
  39619. padding: pick(options.padding, 5),
  39620. visibility: 'hidden' // hidden until setOffset is called
  39621. };
  39622. if (!chart.styledMode) {
  39623. attr.fill = options.backgroundColor;
  39624. attr.stroke = options.borderColor;
  39625. attr['stroke-width'] = options.borderWidth;
  39626. this.label.css(options.style);
  39627. }
  39628. this.label.attr(attr);
  39629. if (!this.label.added) {
  39630. this.label.add(group); // add to the labels-group
  39631. }
  39632. }
  39633. // Rank it higher than data labels (#8742)
  39634. this.label.labelrank = chart.plotSizeY;
  39635. };
  39636. /**
  39637. * Sets the offset that the stack has from the x value and repositions the
  39638. * label.
  39639. *
  39640. * @private
  39641. * @function Highcarts.StackItem#setOffset
  39642. * @param {number} xOffset
  39643. * @param {number} xWidth
  39644. * @param {number} [boxBottom]
  39645. * @param {number} [boxTop]
  39646. * @param {number} [defaultX]
  39647. */
  39648. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  39649. var stackItem = this,
  39650. axis = stackItem.axis,
  39651. chart = axis.chart,
  39652. // stack value translated mapped to chart coordinates
  39653. y = axis.translate(axis.stacking.usePercentage ?
  39654. 100 :
  39655. (boxTop ?
  39656. boxTop :
  39657. stackItem.total), 0, 0, 0, 1),
  39658. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  39659. // stack height:
  39660. h = defined(y) && Math.abs(y - yZero),
  39661. // x position:
  39662. x = pick(defaultX,
  39663. chart.xAxis[0].translate(stackItem.x)) +
  39664. xOffset,
  39665. stackBox = defined(y) && stackItem.getStackBox(chart,
  39666. stackItem,
  39667. x,
  39668. y,
  39669. xWidth,
  39670. h,
  39671. axis),
  39672. label = stackItem.label,
  39673. isNegative = stackItem.isNegative,
  39674. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  39675. textAlign = stackItem.textAlign,
  39676. visible;
  39677. if (label && stackBox) {
  39678. var bBox = label.getBBox(),
  39679. padding = label.padding,
  39680. boxOffsetX = void 0,
  39681. boxOffsetY = void 0;
  39682. if (textAlign === 'left') {
  39683. boxOffsetX = chart.inverted ? -padding : padding;
  39684. }
  39685. else if (textAlign === 'right') {
  39686. boxOffsetX = bBox.width;
  39687. }
  39688. else {
  39689. if (chart.inverted && textAlign === 'center') {
  39690. boxOffsetX = bBox.width / 2;
  39691. }
  39692. else {
  39693. boxOffsetX = chart.inverted ?
  39694. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  39695. }
  39696. }
  39697. boxOffsetY = chart.inverted ?
  39698. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  39699. // Reset alignOptions property after justify #12337
  39700. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  39701. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  39702. // Set the stackBox position
  39703. stackBox.x -= boxOffsetX;
  39704. stackBox.y -= boxOffsetY;
  39705. // Align the label to the box
  39706. label.align(stackItem.alignOptions, null, stackBox);
  39707. // Check if label is inside the plotArea #12294
  39708. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  39709. label.show();
  39710. }
  39711. else {
  39712. // Move label away to avoid the overlapping issues
  39713. label.alignAttr.y = -9999;
  39714. isJustify = false;
  39715. }
  39716. if (isJustify) {
  39717. // Justify stackLabel into the stackBox
  39718. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  39719. }
  39720. label.attr({
  39721. x: label.alignAttr.x,
  39722. y: label.alignAttr.y
  39723. });
  39724. if (pick(!isJustify && stackItem.options.crop, true)) {
  39725. visible =
  39726. isNumber(label.x) &&
  39727. isNumber(label.y) &&
  39728. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  39729. chart.isInsidePlot(label.x + padding, label.y);
  39730. if (!visible) {
  39731. label.hide();
  39732. }
  39733. }
  39734. }
  39735. };
  39736. /**
  39737. * @private
  39738. * @function Highcharts.StackItem#getStackBox
  39739. *
  39740. * @param {Highcharts.Chart} chart
  39741. *
  39742. * @param {Highcharts.StackItem} stackItem
  39743. *
  39744. * @param {number} x
  39745. *
  39746. * @param {number} y
  39747. *
  39748. * @param {number} xWidth
  39749. *
  39750. * @param {number} h
  39751. *
  39752. * @param {Highcharts.Axis} axis
  39753. *
  39754. * @return {Highcharts.BBoxObject}
  39755. */
  39756. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  39757. var reversed = stackItem.axis.reversed,
  39758. inverted = chart.inverted,
  39759. axisPos = axis.height + axis.pos -
  39760. (inverted ? chart.plotLeft : chart.plotTop),
  39761. neg = (stackItem.isNegative && !reversed) ||
  39762. (!stackItem.isNegative && reversed); // #4056
  39763. return {
  39764. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  39765. x + chart.xAxis[0].transB - chart.plotLeft,
  39766. y: inverted ?
  39767. axis.height - x - xWidth :
  39768. (neg ?
  39769. (axisPos - y - h) :
  39770. axisPos - y),
  39771. width: inverted ? h : xWidth,
  39772. height: inverted ? xWidth : h
  39773. };
  39774. };
  39775. return StackItem;
  39776. }());
  39777. /**
  39778. * Generate stacks for each series and calculate stacks total values
  39779. *
  39780. * @private
  39781. * @function Highcharts.Chart#getStacks
  39782. */
  39783. Chart.prototype.getStacks = function () {
  39784. var chart = this,
  39785. inverted = chart.inverted;
  39786. // reset stacks for each yAxis
  39787. chart.yAxis.forEach(function (axis) {
  39788. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  39789. axis.stacking.oldStacks = axis.stacking.stacks;
  39790. }
  39791. });
  39792. chart.series.forEach(function (series) {
  39793. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  39794. if (series.options.stacking &&
  39795. (series.visible === true ||
  39796. chart.options.chart.ignoreHiddenSeries === false)) {
  39797. series.stackKey = [
  39798. series.type,
  39799. pick(series.options.stack, ''),
  39800. inverted ? xAxisOptions.top : xAxisOptions.left,
  39801. inverted ? xAxisOptions.height : xAxisOptions.width
  39802. ].join(',');
  39803. }
  39804. });
  39805. };
  39806. // Stacking methods defined on the Axis prototype
  39807. StackingAxis.compose(Axis);
  39808. // Stacking methods defined for Series prototype
  39809. /**
  39810. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  39811. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  39812. * to handle grouping of points within the same category.
  39813. *
  39814. * @private
  39815. * @function Highcharts.Series#setStackedPoints
  39816. * @return {void}
  39817. */
  39818. Series.prototype.setGroupedPoints = function () {
  39819. var stacking = this.yAxis.stacking;
  39820. if (this.options.centerInCategory &&
  39821. (this.is('column') || this.is('columnrange')) &&
  39822. // With stacking enabled, we already have stacks that we can compute
  39823. // from
  39824. !this.options.stacking &&
  39825. // With only one series, we don't need to consider centerInCategory
  39826. this.chart.series.length > 1) {
  39827. Series.prototype.setStackedPoints.call(this, 'group');
  39828. // After updating, if we now have proper stacks, we must delete the group
  39829. // pseudo stacks (#14986)
  39830. }
  39831. else if (stacking) {
  39832. objectEach(stacking.stacks, function (type, key) {
  39833. if (key.slice(-5) === 'group') {
  39834. objectEach(type, function (stack) { return stack.destroy(); });
  39835. delete stacking.stacks[key];
  39836. }
  39837. });
  39838. }
  39839. };
  39840. /**
  39841. * Adds series' points value to corresponding stack
  39842. *
  39843. * @private
  39844. * @function Highcharts.Series#setStackedPoints
  39845. */
  39846. Series.prototype.setStackedPoints = function (stackingParam) {
  39847. var stacking = stackingParam || this.options.stacking;
  39848. if (!stacking || (this.visible !== true &&
  39849. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  39850. return;
  39851. }
  39852. var series = this, xData = series.processedXData, yData = series.processedYData, stackedYData = [], yDataLength = yData.length, seriesOptions = series.options, threshold = seriesOptions.threshold, stackThreshold = pick(seriesOptions.startFromThreshold && threshold, 0), stackOption = seriesOptions.stack, stackKey = stackingParam ? series.type + "," + stacking : series.stackKey, negKey = '-' + stackKey, negStacks = series.negStacks, yAxis = series.yAxis, stacks = yAxis.stacking.stacks, oldStacks = yAxis.stacking.oldStacks, stackIndicator, isNegative, stack, other, key, pointKey, i, x, y;
  39853. yAxis.stacking.stacksTouched += 1;
  39854. // loop over the non-null y values and read them into a local array
  39855. for (i = 0; i < yDataLength; i++) {
  39856. x = xData[i];
  39857. y = yData[i];
  39858. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  39859. pointKey = stackIndicator.key;
  39860. // Read stacked values into a stack based on the x value,
  39861. // the sign of y and the stack key. Stacking is also handled for null
  39862. // values (#739)
  39863. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  39864. key = isNegative ? negKey : stackKey;
  39865. // Create empty object for this stack if it doesn't exist yet
  39866. if (!stacks[key]) {
  39867. stacks[key] = {};
  39868. }
  39869. // Initialize StackItem for this x
  39870. if (!stacks[key][x]) {
  39871. if (oldStacks[key] &&
  39872. oldStacks[key][x]) {
  39873. stacks[key][x] = oldStacks[key][x];
  39874. stacks[key][x].total = null;
  39875. }
  39876. else {
  39877. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  39878. }
  39879. }
  39880. // If the StackItem doesn't exist, create it first
  39881. stack = stacks[key][x];
  39882. if (y !== null) {
  39883. stack.points[pointKey] = stack.points[series.index] =
  39884. [pick(stack.cumulative, stackThreshold)];
  39885. // Record the base of the stack
  39886. if (!defined(stack.cumulative)) {
  39887. stack.base = pointKey;
  39888. }
  39889. stack.touched = yAxis.stacking.stacksTouched;
  39890. // In area charts, if there are multiple points on the same X value,
  39891. // let the area fill the full span of those points
  39892. if (stackIndicator.index > 0 && series.singleStacks === false) {
  39893. stack.points[pointKey][0] =
  39894. stack.points[series.index + ',' + x + ',0'][0];
  39895. }
  39896. // When updating to null, reset the point stack (#7493)
  39897. }
  39898. else {
  39899. stack.points[pointKey] = stack.points[series.index] =
  39900. null;
  39901. }
  39902. // Add value to the stack total
  39903. if (stacking === 'percent') {
  39904. // Percent stacked column, totals are the same for the positive and
  39905. // negative stacks
  39906. other = isNegative ? stackKey : negKey;
  39907. if (negStacks && stacks[other] && stacks[other][x]) {
  39908. other = stacks[other][x];
  39909. stack.total = other.total =
  39910. Math.max(other.total, stack.total) +
  39911. Math.abs(y) ||
  39912. 0;
  39913. // Percent stacked areas
  39914. }
  39915. else {
  39916. stack.total =
  39917. correctFloat(stack.total + (Math.abs(y) || 0));
  39918. }
  39919. }
  39920. else if (stacking === 'group') {
  39921. if (isArray(y)) {
  39922. y = y[0];
  39923. }
  39924. // In this stack, the total is the number of valid points
  39925. if (y !== null) {
  39926. stack.total = (stack.total || 0) + 1;
  39927. }
  39928. }
  39929. else {
  39930. stack.total = correctFloat(stack.total + (y || 0));
  39931. }
  39932. if (stacking === 'group') {
  39933. // This point's index within the stack, pushed to stack.points[1]
  39934. stack.cumulative = (stack.total || 1) - 1;
  39935. }
  39936. else {
  39937. stack.cumulative =
  39938. pick(stack.cumulative, stackThreshold) + (y || 0);
  39939. }
  39940. if (y !== null) {
  39941. stack.points[pointKey].push(stack.cumulative);
  39942. stackedYData[i] = stack.cumulative;
  39943. stack.hasValidPoints = true;
  39944. }
  39945. }
  39946. if (stacking === 'percent') {
  39947. yAxis.stacking.usePercentage = true;
  39948. }
  39949. if (stacking !== 'group') {
  39950. this.stackedYData = stackedYData; // To be used in getExtremes
  39951. }
  39952. // Reset old stacks
  39953. yAxis.stacking.oldStacks = {};
  39954. };
  39955. /**
  39956. * Iterate over all stacks and compute the absolute values to percent
  39957. *
  39958. * @private
  39959. * @function Highcharts.Series#modifyStacks
  39960. */
  39961. Series.prototype.modifyStacks = function () {
  39962. var series = this,
  39963. yAxis = series.yAxis,
  39964. stackKey = series.stackKey,
  39965. stacks = yAxis.stacking.stacks,
  39966. processedXData = series.processedXData,
  39967. stackIndicator,
  39968. stacking = series.options.stacking;
  39969. if (series[stacking + 'Stacker']) { // Modifier function exists
  39970. [stackKey, '-' + stackKey].forEach(function (key) {
  39971. var i = processedXData.length,
  39972. x,
  39973. stack,
  39974. pointExtremes;
  39975. while (i--) {
  39976. x = processedXData[i];
  39977. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  39978. stack = stacks[key] && stacks[key][x];
  39979. pointExtremes =
  39980. stack && stack.points[stackIndicator.key];
  39981. if (pointExtremes) {
  39982. series[stacking + 'Stacker'](pointExtremes, stack, i);
  39983. }
  39984. }
  39985. });
  39986. }
  39987. };
  39988. /**
  39989. * Modifier function for percent stacks. Blows up the stack to 100%.
  39990. *
  39991. * @private
  39992. * @function Highcharts.Series#percentStacker
  39993. */
  39994. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  39995. var totalFactor = stack.total ? 100 / stack.total : 0;
  39996. // Y bottom value
  39997. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  39998. // Y value
  39999. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  40000. this.stackedYData[i] = pointExtremes[1];
  40001. };
  40002. /**
  40003. * Get stack indicator, according to it's x-value, to determine points with the
  40004. * same x-value
  40005. *
  40006. * @private
  40007. * @function Highcharts.Series#getStackIndicator
  40008. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  40009. * @param {number} x
  40010. * @param {number} index
  40011. * @param {string} [key]
  40012. * @return {Highcharts.StackItemIndicatorObject}
  40013. */
  40014. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  40015. // Update stack indicator, when:
  40016. // first point in a stack || x changed || stack type (negative vs positive)
  40017. // changed:
  40018. if (!defined(stackIndicator) ||
  40019. stackIndicator.x !== x ||
  40020. (key && stackIndicator.key !== key)) {
  40021. stackIndicator = {
  40022. x: x,
  40023. index: 0,
  40024. key: key
  40025. };
  40026. }
  40027. else {
  40028. (stackIndicator).index++;
  40029. }
  40030. stackIndicator.key =
  40031. [index, x, stackIndicator.index].join(',');
  40032. return stackIndicator;
  40033. };
  40034. H.StackItem = StackItem; // @todo -> master
  40035. /* *
  40036. *
  40037. * Default Export
  40038. *
  40039. * */
  40040. /**
  40041. * Stack of data points
  40042. *
  40043. * @product highcharts
  40044. *
  40045. * @interface Highcharts.StackItemObject
  40046. */ /**
  40047. * Alignment settings
  40048. * @name Highcharts.StackItemObject#alignOptions
  40049. * @type {Highcharts.AlignObject}
  40050. */ /**
  40051. * Related axis
  40052. * @name Highcharts.StackItemObject#axis
  40053. * @type {Highcharts.Axis}
  40054. */ /**
  40055. * Cumulative value of the stacked data points
  40056. * @name Highcharts.StackItemObject#cumulative
  40057. * @type {number}
  40058. */ /**
  40059. * True if on the negative side
  40060. * @name Highcharts.StackItemObject#isNegative
  40061. * @type {boolean}
  40062. */ /**
  40063. * Related SVG element
  40064. * @name Highcharts.StackItemObject#label
  40065. * @type {Highcharts.SVGElement}
  40066. */ /**
  40067. * Related stack options
  40068. * @name Highcharts.StackItemObject#options
  40069. * @type {Highcharts.YAxisStackLabelsOptions}
  40070. */ /**
  40071. * Total value of the stacked data points
  40072. * @name Highcharts.StackItemObject#total
  40073. * @type {number}
  40074. */ /**
  40075. * Shared x value of the stack
  40076. * @name Highcharts.StackItemObject#x
  40077. * @type {number}
  40078. */
  40079. ''; // keeps doclets above in JS file
  40080. return H.StackItem;
  40081. });
  40082. _registerModule(_modules, 'Series/Line/LineSeries.js', [_modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (palette, Series, SeriesRegistry, U) {
  40083. /* *
  40084. *
  40085. * (c) 2010-2021 Torstein Honsi
  40086. *
  40087. * License: www.highcharts.com/license
  40088. *
  40089. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40090. *
  40091. * */
  40092. var __extends = (this && this.__extends) || (function () {
  40093. var extendStatics = function (d,
  40094. b) {
  40095. extendStatics = Object.setPrototypeOf ||
  40096. ({ __proto__: [] } instanceof Array && function (d,
  40097. b) { d.__proto__ = b; }) ||
  40098. function (d,
  40099. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40100. return extendStatics(d, b);
  40101. };
  40102. return function (d, b) {
  40103. extendStatics(d, b);
  40104. function __() { this.constructor = d; }
  40105. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40106. };
  40107. })();
  40108. var defined = U.defined,
  40109. merge = U.merge;
  40110. /* *
  40111. *
  40112. * Class
  40113. *
  40114. * */
  40115. /**
  40116. * The line series is the base type and is therefor the series base prototype.
  40117. *
  40118. * @private
  40119. */
  40120. var LineSeries = /** @class */ (function (_super) {
  40121. __extends(LineSeries, _super);
  40122. function LineSeries() {
  40123. /* *
  40124. *
  40125. * Static Functions
  40126. *
  40127. * */
  40128. var _this = _super !== null && _super.apply(this,
  40129. arguments) || this;
  40130. /* *
  40131. *
  40132. * Properties
  40133. *
  40134. * */
  40135. _this.data = void 0;
  40136. _this.options = void 0;
  40137. _this.points = void 0;
  40138. return _this;
  40139. }
  40140. /* *
  40141. *
  40142. * Functions
  40143. *
  40144. * */
  40145. /**
  40146. * Draw the graph. Called internally when rendering line-like series
  40147. * types. The first time it generates the `series.graph` item and
  40148. * optionally other series-wide items like `series.area` for area
  40149. * charts. On subsequent calls these items are updated with new
  40150. * positions and attributes.
  40151. *
  40152. * @function Highcharts.Series#drawGraph
  40153. */
  40154. LineSeries.prototype.drawGraph = function () {
  40155. var series = this,
  40156. options = this.options,
  40157. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  40158. styledMode = this.chart.styledMode,
  40159. props = [[
  40160. 'graph',
  40161. 'highcharts-graph'
  40162. ]];
  40163. // Presentational properties
  40164. if (!styledMode) {
  40165. props[0].push((options.lineColor ||
  40166. this.color ||
  40167. palette.neutralColor20 // when colorByPoint = true
  40168. ), options.dashStyle);
  40169. }
  40170. props = series.getZonesGraphs(props);
  40171. // Draw the graph
  40172. props.forEach(function (prop, i) {
  40173. var graphKey = prop[0],
  40174. graph = series[graphKey],
  40175. verb = graph ? 'animate' : 'attr',
  40176. attribs;
  40177. if (graph) {
  40178. graph.endX = series.preventGraphAnimation ?
  40179. null :
  40180. graphPath.xMap;
  40181. graph.animate({ d: graphPath });
  40182. }
  40183. else if (graphPath.length) { // #1487
  40184. /**
  40185. * SVG element of area-based charts. Can be used for styling
  40186. * purposes. If zones are configured, this element will be
  40187. * hidden and replaced by multiple zone areas, accessible
  40188. * via `series['zone-area-x']` (where x is a number,
  40189. * starting with 0).
  40190. *
  40191. * @name Highcharts.Series#area
  40192. * @type {Highcharts.SVGElement|undefined}
  40193. */
  40194. /**
  40195. * SVG element of line-based charts. Can be used for styling
  40196. * purposes. If zones are configured, this element will be
  40197. * hidden and replaced by multiple zone lines, accessible
  40198. * via `series['zone-graph-x']` (where x is a number,
  40199. * starting with 0).
  40200. *
  40201. * @name Highcharts.Series#graph
  40202. * @type {Highcharts.SVGElement|undefined}
  40203. */
  40204. series[graphKey] = graph = series.chart.renderer
  40205. .path(graphPath)
  40206. .addClass(prop[1])
  40207. .attr({ zIndex: 1 }) // #1069
  40208. .add(series.group);
  40209. }
  40210. if (graph && !styledMode) {
  40211. attribs = {
  40212. 'stroke': prop[2],
  40213. 'stroke-width': options.lineWidth,
  40214. // Polygon series use filled graph
  40215. 'fill': (series.fillGraph && series.color) || 'none'
  40216. };
  40217. if (prop[3]) {
  40218. attribs.dashstyle = prop[3];
  40219. }
  40220. else if (options.linecap !== 'square') {
  40221. attribs['stroke-linecap'] =
  40222. attribs['stroke-linejoin'] = 'round';
  40223. }
  40224. graph[verb](attribs)
  40225. // Add shadow to normal series (0) or to first
  40226. // zone (1) #3932
  40227. .shadow((i < 2) && options.shadow);
  40228. }
  40229. // Helpers for animation
  40230. if (graph) {
  40231. graph.startX = graphPath.xMap;
  40232. graph.isArea = graphPath.isArea; // For arearange animation
  40233. }
  40234. });
  40235. };
  40236. // eslint-disable-next-line valid-jsdoc
  40237. /**
  40238. * Get the graph path.
  40239. *
  40240. * @private
  40241. */
  40242. LineSeries.prototype.getGraphPath = function (points, nullsAsZeroes, connectCliffs) {
  40243. var series = this,
  40244. options = series.options,
  40245. step = options.step,
  40246. reversed,
  40247. graphPath = [],
  40248. xMap = [],
  40249. gap;
  40250. points = points || series.points;
  40251. // Bottom of a stack is reversed
  40252. reversed = points.reversed;
  40253. if (reversed) {
  40254. points.reverse();
  40255. }
  40256. // Reverse the steps (#5004)
  40257. step = {
  40258. right: 1,
  40259. center: 2
  40260. }[step] || (step && 3);
  40261. if (step && reversed) {
  40262. step = 4 - step;
  40263. }
  40264. // Remove invalid points, especially in spline (#5015)
  40265. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  40266. // Build the line
  40267. points.forEach(function (point, i) {
  40268. var plotX = point.plotX,
  40269. plotY = point.plotY,
  40270. lastPoint = points[i - 1],
  40271. // the path to this point from the previous
  40272. pathToPoint;
  40273. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  40274. !connectCliffs) {
  40275. gap = true; // ... and continue
  40276. }
  40277. // Line series, nullsAsZeroes is not handled
  40278. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  40279. gap = !options.connectNulls;
  40280. // Area series, nullsAsZeroes is set
  40281. }
  40282. else if (point.isNull && !nullsAsZeroes) {
  40283. gap = true;
  40284. }
  40285. else {
  40286. if (i === 0 || gap) {
  40287. pathToPoint = [[
  40288. 'M',
  40289. point.plotX,
  40290. point.plotY
  40291. ]];
  40292. // Generate the spline as defined in the SplineSeries object
  40293. }
  40294. else if (series.getPointSpline) {
  40295. pathToPoint = [series.getPointSpline(points, point, i)];
  40296. }
  40297. else if (step) {
  40298. if (step === 1) { // right
  40299. pathToPoint = [[
  40300. 'L',
  40301. lastPoint.plotX,
  40302. plotY
  40303. ]];
  40304. }
  40305. else if (step === 2) { // center
  40306. pathToPoint = [[
  40307. 'L',
  40308. (lastPoint.plotX + plotX) / 2,
  40309. lastPoint.plotY
  40310. ], [
  40311. 'L',
  40312. (lastPoint.plotX + plotX) / 2,
  40313. plotY
  40314. ]];
  40315. }
  40316. else {
  40317. pathToPoint = [[
  40318. 'L',
  40319. plotX,
  40320. lastPoint.plotY
  40321. ]];
  40322. }
  40323. pathToPoint.push([
  40324. 'L',
  40325. plotX,
  40326. plotY
  40327. ]);
  40328. }
  40329. else {
  40330. // normal line to next point
  40331. pathToPoint = [[
  40332. 'L',
  40333. plotX,
  40334. plotY
  40335. ]];
  40336. }
  40337. // Prepare for animation. When step is enabled, there are
  40338. // two path nodes for each x value.
  40339. xMap.push(point.x);
  40340. if (step) {
  40341. xMap.push(point.x);
  40342. if (step === 2) { // step = center (#8073)
  40343. xMap.push(point.x);
  40344. }
  40345. }
  40346. graphPath.push.apply(graphPath, pathToPoint);
  40347. gap = false;
  40348. }
  40349. });
  40350. graphPath.xMap = xMap;
  40351. series.graphPath = graphPath;
  40352. return graphPath;
  40353. };
  40354. // eslint-disable-next-line valid-jsdoc
  40355. /**
  40356. * Get zones properties for building graphs. Extendable by series with
  40357. * multiple lines within one series.
  40358. *
  40359. * @private
  40360. */
  40361. LineSeries.prototype.getZonesGraphs = function (props) {
  40362. // Add the zone properties if any
  40363. this.zones.forEach(function (zone, i) {
  40364. var propset = [
  40365. 'zone-graph-' + i,
  40366. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  40367. (zone.className || '')
  40368. ];
  40369. if (!this.chart.styledMode) {
  40370. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  40371. }
  40372. props.push(propset);
  40373. }, this);
  40374. return props;
  40375. };
  40376. /**
  40377. * General options for all series types.
  40378. *
  40379. * @optionparent plotOptions.series
  40380. */
  40381. LineSeries.defaultOptions = merge(Series.defaultOptions, {
  40382. // nothing here yet
  40383. });
  40384. return LineSeries;
  40385. }(Series));
  40386. SeriesRegistry.registerSeriesType('line', LineSeries);
  40387. /* *
  40388. *
  40389. * Default Export
  40390. *
  40391. * */
  40392. /* *
  40393. *
  40394. * API Options
  40395. *
  40396. * */
  40397. /**
  40398. * A line series displays information as a series of data points connected by
  40399. * straight line segments.
  40400. *
  40401. * @sample {highcharts} highcharts/demo/line-basic/
  40402. * Line chart
  40403. * @sample {highstock} stock/demo/basic-line/
  40404. * Line chart
  40405. *
  40406. * @extends plotOptions.series
  40407. * @product highcharts highstock
  40408. * @apioption plotOptions.line
  40409. */
  40410. /**
  40411. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  40412. * of a line graph. Round means that lines are rounded in the ends and
  40413. * bends.
  40414. *
  40415. * @type {Highcharts.SeriesLinecapValue}
  40416. * @default round
  40417. * @since 3.0.7
  40418. * @apioption plotOptions.line.linecap
  40419. */
  40420. /**
  40421. * A `line` series. If the [type](#series.line.type) option is not
  40422. * specified, it is inherited from [chart.type](#chart.type).
  40423. *
  40424. * @extends series,plotOptions.line
  40425. * @excluding dataParser,dataURL
  40426. * @product highcharts highstock
  40427. * @apioption series.line
  40428. */
  40429. /**
  40430. * An array of data points for the series. For the `line` series type,
  40431. * points can be given in the following ways:
  40432. *
  40433. * 1. An array of numerical values. In this case, the numerical values will be
  40434. * interpreted as `y` options. The `x` values will be automatically
  40435. * calculated, either starting at 0 and incremented by 1, or from
  40436. * `pointStart` and `pointInterval` given in the series options. If the axis
  40437. * has categories, these will be used. Example:
  40438. * ```js
  40439. * data: [0, 5, 3, 5]
  40440. * ```
  40441. *
  40442. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40443. * `x,y`. If the first value is a string, it is applied as the name of the
  40444. * point, and the `x` value is inferred.
  40445. * ```js
  40446. * data: [
  40447. * [0, 1],
  40448. * [1, 2],
  40449. * [2, 8]
  40450. * ]
  40451. * ```
  40452. *
  40453. * 3. An array of objects with named values. The following snippet shows only a
  40454. * few settings, see the complete options set below. If the total number of
  40455. * data points exceeds the series'
  40456. * [turboThreshold](#series.line.turboThreshold),
  40457. * this option is not available.
  40458. * ```js
  40459. * data: [{
  40460. * x: 1,
  40461. * y: 9,
  40462. * name: "Point2",
  40463. * color: "#00FF00"
  40464. * }, {
  40465. * x: 1,
  40466. * y: 6,
  40467. * name: "Point1",
  40468. * color: "#FF00FF"
  40469. * }]
  40470. * ```
  40471. *
  40472. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  40473. * additional declaration to allow custom data types:
  40474. * ```ts
  40475. * declare module `highcharts` {
  40476. * interface PointOptionsObject {
  40477. * custom: Record<string, (boolean|number|string)>;
  40478. * }
  40479. * }
  40480. * ```
  40481. *
  40482. * @sample {highcharts} highcharts/chart/reflow-true/
  40483. * Numerical values
  40484. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40485. * Arrays of numeric x and y
  40486. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40487. * Arrays of datetime x and y
  40488. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40489. * Arrays of point.name and y
  40490. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40491. * Config objects
  40492. *
  40493. * @declare Highcharts.PointOptionsObject
  40494. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40495. * @apioption series.line.data
  40496. */
  40497. /**
  40498. * An additional, individual class name for the data point's graphic
  40499. * representation.
  40500. *
  40501. * @type {string}
  40502. * @since 5.0.0
  40503. * @product highcharts gantt
  40504. * @apioption series.line.data.className
  40505. */
  40506. /**
  40507. * Individual color for the point. By default the color is pulled from
  40508. * the global `colors` array.
  40509. *
  40510. * In styled mode, the `color` option doesn't take effect. Instead, use
  40511. * `colorIndex`.
  40512. *
  40513. * @sample {highcharts} highcharts/point/color/
  40514. * Mark the highest point
  40515. *
  40516. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40517. * @product highcharts highstock gantt
  40518. * @apioption series.line.data.color
  40519. */
  40520. /**
  40521. * A specific color index to use for the point, so its graphic representations
  40522. * are given the class name `highcharts-color-{n}`. In styled mode this will
  40523. * change the color of the graphic. In non-styled mode, the color by is set by
  40524. * the `fill` attribute, so the change in class name won't have a visual effect
  40525. * by default.
  40526. *
  40527. * @type {number}
  40528. * @since 5.0.0
  40529. * @product highcharts gantt
  40530. * @apioption series.line.data.colorIndex
  40531. */
  40532. /**
  40533. * A reserved subspace to store options and values for customized functionality.
  40534. * Here you can add additional data for your own event callbacks and formatter
  40535. * callbacks.
  40536. *
  40537. * @sample {highcharts} highcharts/point/custom/
  40538. * Point and series with custom data
  40539. *
  40540. * @type {Highcharts.Dictionary<*>}
  40541. * @apioption series.line.data.custom
  40542. */
  40543. /**
  40544. * Individual data label for each point. The options are the same as
  40545. * the ones for [plotOptions.series.dataLabels](
  40546. * #plotOptions.series.dataLabels).
  40547. *
  40548. * @sample highcharts/point/datalabels/
  40549. * Show a label for the last value
  40550. *
  40551. * @declare Highcharts.DataLabelsOptions
  40552. * @extends plotOptions.line.dataLabels
  40553. * @product highcharts highstock gantt
  40554. * @apioption series.line.data.dataLabels
  40555. */
  40556. /**
  40557. * A description of the point to add to the screen reader information
  40558. * about the point.
  40559. *
  40560. * @type {string}
  40561. * @since 5.0.0
  40562. * @requires modules/accessibility
  40563. * @apioption series.line.data.description
  40564. */
  40565. /**
  40566. * An id for the point. This can be used after render time to get a
  40567. * pointer to the point object through `chart.get()`.
  40568. *
  40569. * @sample {highcharts} highcharts/point/id/
  40570. * Remove an id'd point
  40571. *
  40572. * @type {string}
  40573. * @since 1.2.0
  40574. * @product highcharts highstock gantt
  40575. * @apioption series.line.data.id
  40576. */
  40577. /**
  40578. * The rank for this point's data label in case of collision. If two
  40579. * data labels are about to overlap, only the one with the highest `labelrank`
  40580. * will be drawn.
  40581. *
  40582. * @type {number}
  40583. * @apioption series.line.data.labelrank
  40584. */
  40585. /**
  40586. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  40587. *
  40588. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  40589. *
  40590. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40591. * Point names
  40592. *
  40593. * @type {string}
  40594. * @apioption series.line.data.name
  40595. */
  40596. /**
  40597. * Whether the data point is selected initially.
  40598. *
  40599. * @type {boolean}
  40600. * @default false
  40601. * @product highcharts highstock gantt
  40602. * @apioption series.line.data.selected
  40603. */
  40604. /**
  40605. * The x value of the point. For datetime axes, the X value is the timestamp
  40606. * in milliseconds since 1970.
  40607. *
  40608. * @type {number}
  40609. * @product highcharts highstock
  40610. * @apioption series.line.data.x
  40611. */
  40612. /**
  40613. * The y value of the point.
  40614. *
  40615. * @type {number|null}
  40616. * @product highcharts highstock
  40617. * @apioption series.line.data.y
  40618. */
  40619. /**
  40620. * The individual point events.
  40621. *
  40622. * @extends plotOptions.series.point.events
  40623. * @product highcharts highstock gantt
  40624. * @apioption series.line.data.events
  40625. */
  40626. /**
  40627. * Options for the point markers of line-like series.
  40628. *
  40629. * @declare Highcharts.PointMarkerOptionsObject
  40630. * @extends plotOptions.series.marker
  40631. * @product highcharts highstock
  40632. * @apioption series.line.data.marker
  40633. */
  40634. ''; // include precedent doclets in transpilat
  40635. return LineSeries;
  40636. });
  40637. _registerModule(_modules, 'Series/Area/AreaSeries.js', [_modules['Core/Color/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Color, LegendSymbolMixin, SeriesRegistry, U) {
  40638. /* *
  40639. *
  40640. * (c) 2010-2021 Torstein Honsi
  40641. *
  40642. * License: www.highcharts.com/license
  40643. *
  40644. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40645. *
  40646. * */
  40647. var __extends = (this && this.__extends) || (function () {
  40648. var extendStatics = function (d,
  40649. b) {
  40650. extendStatics = Object.setPrototypeOf ||
  40651. ({ __proto__: [] } instanceof Array && function (d,
  40652. b) { d.__proto__ = b; }) ||
  40653. function (d,
  40654. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40655. return extendStatics(d, b);
  40656. };
  40657. return function (d, b) {
  40658. extendStatics(d, b);
  40659. function __() { this.constructor = d; }
  40660. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40661. };
  40662. })();
  40663. var color = Color.parse;
  40664. var LineSeries = SeriesRegistry.seriesTypes.line;
  40665. var extend = U.extend,
  40666. merge = U.merge,
  40667. objectEach = U.objectEach,
  40668. pick = U.pick;
  40669. /* *
  40670. *
  40671. * Class
  40672. *
  40673. * */
  40674. /**
  40675. * Area series type.
  40676. *
  40677. * @private
  40678. * @class
  40679. * @name AreaSeries
  40680. *
  40681. * @augments LineSeries
  40682. */
  40683. var AreaSeries = /** @class */ (function (_super) {
  40684. __extends(AreaSeries, _super);
  40685. function AreaSeries() {
  40686. /* *
  40687. *
  40688. * Static Properties
  40689. *
  40690. * */
  40691. var _this = _super !== null && _super.apply(this,
  40692. arguments) || this;
  40693. _this.data = void 0;
  40694. _this.options = void 0;
  40695. _this.points = void 0;
  40696. return _this;
  40697. /* eslint-enable valid-jsdoc */
  40698. }
  40699. /* *
  40700. *
  40701. * Functions
  40702. *
  40703. * */
  40704. /* eslint-disable valid-jsdoc */
  40705. /**
  40706. * Draw the graph and the underlying area. This method calls the Series
  40707. * base function and adds the area. The areaPath is calculated in the
  40708. * getSegmentPath method called from Series.prototype.drawGraph.
  40709. * @private
  40710. */
  40711. AreaSeries.prototype.drawGraph = function () {
  40712. // Define or reset areaPath
  40713. this.areaPath = [];
  40714. // Call the base method
  40715. _super.prototype.drawGraph.apply(this);
  40716. // Define local variables
  40717. var series = this,
  40718. areaPath = this.areaPath,
  40719. options = this.options,
  40720. zones = this.zones,
  40721. props = [[
  40722. 'area',
  40723. 'highcharts-area',
  40724. this.color,
  40725. options.fillColor
  40726. ]]; // area name, main color, fill color
  40727. zones.forEach(function (zone,
  40728. i) {
  40729. props.push([
  40730. 'zone-area-' + i,
  40731. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  40732. zone.className,
  40733. zone.color || series.color,
  40734. zone.fillColor || options.fillColor
  40735. ]);
  40736. });
  40737. props.forEach(function (prop) {
  40738. var areaKey = prop[0],
  40739. area = series[areaKey],
  40740. verb = area ? 'animate' : 'attr',
  40741. attribs = {};
  40742. // Create or update the area
  40743. if (area) { // update
  40744. area.endX = series.preventGraphAnimation ?
  40745. null :
  40746. areaPath.xMap;
  40747. area.animate({ d: areaPath });
  40748. }
  40749. else { // create
  40750. attribs.zIndex = 0; // #1069
  40751. area = series[areaKey] = series.chart.renderer
  40752. .path(areaPath)
  40753. .addClass(prop[1])
  40754. .add(series.group);
  40755. area.isArea = true;
  40756. }
  40757. if (!series.chart.styledMode) {
  40758. attribs.fill = pick(prop[3], color(prop[2])
  40759. .setOpacity(pick(options.fillOpacity, 0.75))
  40760. .get());
  40761. }
  40762. area[verb](attribs);
  40763. area.startX = areaPath.xMap;
  40764. area.shiftUnit = options.step ? 2 : 1;
  40765. });
  40766. };
  40767. /**
  40768. * @private
  40769. */
  40770. AreaSeries.prototype.getGraphPath = function (points) {
  40771. var getGraphPath = LineSeries.prototype.getGraphPath, graphPath, options = this.options, stacking = options.stacking, yAxis = this.yAxis, topPath, bottomPath, bottomPoints = [], graphPoints = [], seriesIndex = this.index, i, areaPath, plotX, stacks = yAxis.stacking.stacks[this.stackKey], threshold = options.threshold, translatedThreshold = Math.round(// #10909
  40772. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  40773. options.connectNulls, stacking === 'percent'),
  40774. // To display null points in underlying stacked series, this
  40775. // series graph must be broken, and the area also fall down to
  40776. // fill the gap left by the null point. #2069
  40777. addDummyPoints = function (i, otherI, side) {
  40778. var point = points[i], stackedValues = stacking &&
  40779. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  40780. if (cliffVal || nullVal) {
  40781. top = (nullVal ?
  40782. stackedValues[0] :
  40783. stackedValues[1]) + cliffVal;
  40784. bottom = stackedValues[0] + cliffVal;
  40785. isNull = !!nullVal;
  40786. }
  40787. else if (!stacking &&
  40788. points[otherI] &&
  40789. points[otherI].isNull) {
  40790. top = bottom = threshold;
  40791. }
  40792. // Add to the top and bottom line of the area
  40793. if (typeof top !== 'undefined') {
  40794. graphPoints.push({
  40795. plotX: plotX,
  40796. plotY: top === null ?
  40797. translatedThreshold :
  40798. yAxis.getThreshold(top),
  40799. isNull: isNull,
  40800. isCliff: true
  40801. });
  40802. bottomPoints.push({
  40803. plotX: plotX,
  40804. plotY: bottom === null ?
  40805. translatedThreshold :
  40806. yAxis.getThreshold(bottom),
  40807. doCurve: false // #1041, gaps in areaspline areas
  40808. });
  40809. }
  40810. };
  40811. // Find what points to use
  40812. points = points || this.points;
  40813. // Fill in missing points
  40814. if (stacking) {
  40815. points = this.getStackPoints(points);
  40816. }
  40817. for (i = 0; i < points.length; i++) {
  40818. // Reset after series.update of stacking property (#12033)
  40819. if (!stacking) {
  40820. points[i].leftCliff = points[i].rightCliff =
  40821. points[i].leftNull = points[i].rightNull = void 0;
  40822. }
  40823. isNull = points[i].isNull;
  40824. plotX = pick(points[i].rectPlotX, points[i].plotX);
  40825. yBottom = stacking ? pick(points[i].yBottom, translatedThreshold) : translatedThreshold;
  40826. if (!isNull || connectNulls) {
  40827. if (!connectNulls) {
  40828. addDummyPoints(i, i - 1, 'left');
  40829. }
  40830. // Skip null point when stacking is false and connectNulls
  40831. // true
  40832. if (!(isNull && !stacking && connectNulls)) {
  40833. graphPoints.push(points[i]);
  40834. bottomPoints.push({
  40835. x: i,
  40836. plotX: plotX,
  40837. plotY: yBottom
  40838. });
  40839. }
  40840. if (!connectNulls) {
  40841. addDummyPoints(i, i + 1, 'right');
  40842. }
  40843. }
  40844. }
  40845. topPath = getGraphPath.call(this, graphPoints, true, true);
  40846. bottomPoints.reversed = true;
  40847. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  40848. var firstBottomPoint = bottomPath[0];
  40849. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  40850. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  40851. }
  40852. areaPath = topPath.concat(bottomPath);
  40853. if (areaPath.length) {
  40854. areaPath.push(['Z']);
  40855. }
  40856. // TODO: don't set leftCliff and rightCliff when connectNulls?
  40857. graphPath = getGraphPath
  40858. .call(this, graphPoints, false, connectNulls);
  40859. areaPath.xMap = topPath.xMap;
  40860. this.areaPath = areaPath;
  40861. return graphPath;
  40862. };
  40863. /**
  40864. * Return an array of stacked points, where null and missing points are
  40865. * replaced by dummy points in order for gaps to be drawn correctly in
  40866. * stacks.
  40867. * @private
  40868. */
  40869. AreaSeries.prototype.getStackPoints = function (points) {
  40870. var series = this,
  40871. segment = [],
  40872. keys = [],
  40873. xAxis = this.xAxis,
  40874. yAxis = this.yAxis,
  40875. stack = yAxis.stacking.stacks[this.stackKey],
  40876. pointMap = {},
  40877. yAxisSeries = yAxis.series,
  40878. seriesLength = yAxisSeries.length,
  40879. upOrDown = yAxis.options.reversedStacks ? 1 : -1,
  40880. seriesIndex = yAxisSeries.indexOf(series);
  40881. points = points || this.points;
  40882. if (this.options.stacking) {
  40883. for (var i = 0; i < points.length; i++) {
  40884. // Reset after point update (#7326)
  40885. points[i].leftNull = points[i].rightNull = void 0;
  40886. // Create a map where we can quickly look up the points by
  40887. // their X values.
  40888. pointMap[points[i].x] = points[i];
  40889. }
  40890. // Sort the keys (#1651)
  40891. objectEach(stack, function (stackX, x) {
  40892. // nulled after switching between
  40893. // grouping and not (#1651, #2336)
  40894. if (stackX.total !== null) {
  40895. keys.push(x);
  40896. }
  40897. });
  40898. keys.sort(function (a, b) {
  40899. return a - b;
  40900. });
  40901. var visibleSeries_1 = yAxisSeries.map(function (s) { return s.visible; });
  40902. keys.forEach(function (x, idx) {
  40903. var y = 0,
  40904. stackPoint,
  40905. stackedValues;
  40906. if (pointMap[x] && !pointMap[x].isNull) {
  40907. segment.push(pointMap[x]);
  40908. // Find left and right cliff. -1 goes left, 1 goes
  40909. // right.
  40910. [-1, 1].forEach(function (direction) {
  40911. var nullName = direction === 1 ?
  40912. 'rightNull' :
  40913. 'leftNull',
  40914. cliffName = direction === 1 ?
  40915. 'rightCliff' :
  40916. 'leftCliff',
  40917. cliff = 0,
  40918. otherStack = stack[keys[idx + direction]];
  40919. // If there is a stack next to this one,
  40920. // to the left or to the right...
  40921. if (otherStack) {
  40922. var i = seriesIndex;
  40923. // Can go either up or down,
  40924. // depending on reversedStacks
  40925. while (i >= 0 && i < seriesLength) {
  40926. var si = yAxisSeries[i].index;
  40927. stackPoint = otherStack.points[si];
  40928. if (!stackPoint) {
  40929. // If the next point in this series
  40930. // is missing, mark the point
  40931. // with point.leftNull or
  40932. // point.rightNull = true.
  40933. if (si === series.index) {
  40934. pointMap[x][nullName] = true;
  40935. // If there are missing points in
  40936. // the next stack in any of the
  40937. // series below this one, we need
  40938. // to substract the missing values
  40939. // and add a hiatus to the left or
  40940. // right.
  40941. }
  40942. else if (visibleSeries_1[i]) {
  40943. stackedValues =
  40944. stack[x].points[si];
  40945. if (stackedValues) {
  40946. cliff -= stackedValues[1] - stackedValues[0];
  40947. }
  40948. }
  40949. }
  40950. // When reversedStacks is true, loop up,
  40951. // else loop down
  40952. i += upOrDown;
  40953. }
  40954. }
  40955. pointMap[x][cliffName] = cliff;
  40956. });
  40957. // There is no point for this X value in this series, so we
  40958. // insert a dummy point in order for the areas to be drawn
  40959. // correctly.
  40960. }
  40961. else {
  40962. // Loop down the stack to find the series below this
  40963. // one that has a value (#1991)
  40964. var i = seriesIndex;
  40965. while (i >= 0 && i < seriesLength) {
  40966. var si = yAxisSeries[i].index;
  40967. stackPoint = stack[x].points[si];
  40968. if (stackPoint) {
  40969. y = stackPoint[1];
  40970. break;
  40971. }
  40972. // When reversedStacks is true, loop up, else loop
  40973. // down
  40974. i += upOrDown;
  40975. }
  40976. y = pick(y, 0);
  40977. y = yAxis.translate(// #6272
  40978. y, 0, 1, 0, 1);
  40979. segment.push({
  40980. isNull: true,
  40981. plotX: xAxis.translate(// #6272
  40982. x, 0, 0, 0, 1),
  40983. x: x,
  40984. plotY: y,
  40985. yBottom: y
  40986. });
  40987. }
  40988. });
  40989. }
  40990. return segment;
  40991. };
  40992. /**
  40993. * The area series type.
  40994. *
  40995. * @sample {highcharts} highcharts/demo/area-basic/
  40996. * Area chart
  40997. * @sample {highstock} stock/demo/area/
  40998. * Area chart
  40999. *
  41000. * @extends plotOptions.line
  41001. * @excluding useOhlcData
  41002. * @product highcharts highstock
  41003. * @optionparent plotOptions.area
  41004. */
  41005. AreaSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  41006. /**
  41007. * @see [fillColor](#plotOptions.area.fillColor)
  41008. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  41009. *
  41010. * @apioption plotOptions.area.color
  41011. */
  41012. /**
  41013. * Fill color or gradient for the area. When `null`, the series' `color`
  41014. * is used with the series' `fillOpacity`.
  41015. *
  41016. * In styled mode, the fill color can be set with the `.highcharts-area`
  41017. * class name.
  41018. *
  41019. * @see [color](#plotOptions.area.color)
  41020. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  41021. *
  41022. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  41023. * Null by default
  41024. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  41025. * Gradient
  41026. *
  41027. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41028. * @product highcharts highstock
  41029. * @apioption plotOptions.area.fillColor
  41030. */
  41031. /**
  41032. * Fill opacity for the area. When you set an explicit `fillColor`,
  41033. * the `fillOpacity` is not applied. Instead, you should define the
  41034. * opacity in the `fillColor` with an rgba color definition. The
  41035. * `fillOpacity` setting, also the default setting, overrides the alpha
  41036. * component of the `color` setting.
  41037. *
  41038. * In styled mode, the fill opacity can be set with the
  41039. * `.highcharts-area` class name.
  41040. *
  41041. * @see [color](#plotOptions.area.color)
  41042. * @see [fillColor](#plotOptions.area.fillColor)
  41043. *
  41044. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  41045. * Automatic fill color and fill opacity of 0.1
  41046. *
  41047. * @type {number}
  41048. * @default {highcharts} 0.75
  41049. * @default {highstock} 0.75
  41050. * @product highcharts highstock
  41051. * @apioption plotOptions.area.fillOpacity
  41052. */
  41053. /**
  41054. * A separate color for the graph line. By default the line takes the
  41055. * `color` of the series, but the lineColor setting allows setting a
  41056. * separate color for the line without altering the `fillColor`.
  41057. *
  41058. * In styled mode, the line stroke can be set with the
  41059. * `.highcharts-graph` class name.
  41060. *
  41061. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  41062. * Dark gray line
  41063. *
  41064. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41065. * @product highcharts highstock
  41066. * @apioption plotOptions.area.lineColor
  41067. */
  41068. /**
  41069. * A separate color for the negative part of the area.
  41070. *
  41071. * In styled mode, a negative color is set with the
  41072. * `.highcharts-negative` class name.
  41073. *
  41074. * @see [negativeColor](#plotOptions.area.negativeColor)
  41075. *
  41076. * @sample {highcharts} highcharts/css/series-negative-color/
  41077. * Negative color in styled mode
  41078. *
  41079. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41080. * @since 3.0
  41081. * @product highcharts
  41082. * @apioption plotOptions.area.negativeFillColor
  41083. */
  41084. /**
  41085. * Whether the whole area or just the line should respond to mouseover
  41086. * tooltips and other mouse or touch events.
  41087. *
  41088. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  41089. * Display the tooltip when the area is hovered
  41090. *
  41091. * @type {boolean}
  41092. * @default false
  41093. * @since 1.1.6
  41094. * @product highcharts highstock
  41095. * @apioption plotOptions.area.trackByArea
  41096. */
  41097. /**
  41098. * The Y axis value to serve as the base for the area, for
  41099. * distinguishing between values above and below a threshold. The area
  41100. * between the graph and the threshold is filled.
  41101. *
  41102. * * If a number is given, the Y axis will scale to the threshold.
  41103. * * If `null`, the scaling behaves like a line series with fill between
  41104. * the graph and the Y axis minimum.
  41105. * * If `Infinity` or `-Infinity`, the area between the graph and the
  41106. * corresponding Y axis extreme is filled (since v6.1.0).
  41107. *
  41108. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  41109. * A threshold of 100
  41110. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  41111. * A threshold of Infinity
  41112. *
  41113. * @type {number|null}
  41114. * @since 2.0
  41115. * @product highcharts highstock
  41116. */
  41117. threshold: 0
  41118. });
  41119. return AreaSeries;
  41120. }(LineSeries));
  41121. extend(AreaSeries.prototype, {
  41122. singleStacks: false,
  41123. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41124. });
  41125. SeriesRegistry.registerSeriesType('area', AreaSeries);
  41126. /* *
  41127. *
  41128. * Default Export
  41129. *
  41130. * */
  41131. /* *
  41132. *
  41133. * API Options
  41134. *
  41135. * */
  41136. /**
  41137. * A `area` series. If the [type](#series.area.type) option is not
  41138. * specified, it is inherited from [chart.type](#chart.type).
  41139. *
  41140. * @extends series,plotOptions.area
  41141. * @excluding dataParser, dataURL, useOhlcData
  41142. * @product highcharts highstock
  41143. * @apioption series.area
  41144. */
  41145. /**
  41146. * @see [fillColor](#series.area.fillColor)
  41147. * @see [fillOpacity](#series.area.fillOpacity)
  41148. *
  41149. * @apioption series.area.color
  41150. */
  41151. /**
  41152. * An array of data points for the series. For the `area` series type,
  41153. * points can be given in the following ways:
  41154. *
  41155. * 1. An array of numerical values. In this case, the numerical values will be
  41156. * interpreted as `y` options. The `x` values will be automatically
  41157. * calculated, either starting at 0 and incremented by 1, or from
  41158. * `pointStart` * and `pointInterval` given in the series options. If the
  41159. * axis has categories, these will be used. Example:
  41160. * ```js
  41161. * data: [0, 5, 3, 5]
  41162. * ```
  41163. *
  41164. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41165. * `x,y`. If the first value is a string, it is applied as the name of the
  41166. * point, and the `x` value is inferred.
  41167. * ```js
  41168. * data: [
  41169. * [0, 9],
  41170. * [1, 7],
  41171. * [2, 6]
  41172. * ]
  41173. * ```
  41174. *
  41175. * 3. An array of objects with named values. The following snippet shows only a
  41176. * few settings, see the complete options set below. If the total number of
  41177. * data points exceeds the series'
  41178. * [turboThreshold](#series.area.turboThreshold), this option is not
  41179. * available.
  41180. * ```js
  41181. * data: [{
  41182. * x: 1,
  41183. * y: 9,
  41184. * name: "Point2",
  41185. * color: "#00FF00"
  41186. * }, {
  41187. * x: 1,
  41188. * y: 6,
  41189. * name: "Point1",
  41190. * color: "#FF00FF"
  41191. * }]
  41192. * ```
  41193. *
  41194. * @sample {highcharts} highcharts/chart/reflow-true/
  41195. * Numerical values
  41196. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41197. * Arrays of numeric x and y
  41198. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41199. * Arrays of datetime x and y
  41200. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41201. * Arrays of point.name and y
  41202. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41203. * Config objects
  41204. *
  41205. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41206. * @extends series.line.data
  41207. * @product highcharts highstock
  41208. * @apioption series.area.data
  41209. */
  41210. /**
  41211. * @see [color](#series.area.color)
  41212. * @see [fillOpacity](#series.area.fillOpacity)
  41213. *
  41214. * @apioption series.area.fillColor
  41215. */
  41216. /**
  41217. * @see [color](#series.area.color)
  41218. * @see [fillColor](#series.area.fillColor)
  41219. *
  41220. * @default {highcharts} 0.75
  41221. * @default {highstock} 0.75
  41222. * @apioption series.area.fillOpacity
  41223. */
  41224. ''; // adds doclets above to transpilat
  41225. return AreaSeries;
  41226. });
  41227. _registerModule(_modules, 'Series/Spline/SplineSeries.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  41228. /* *
  41229. *
  41230. * (c) 2010-2021 Torstein Honsi
  41231. *
  41232. * License: www.highcharts.com/license
  41233. *
  41234. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41235. *
  41236. * */
  41237. var __extends = (this && this.__extends) || (function () {
  41238. var extendStatics = function (d,
  41239. b) {
  41240. extendStatics = Object.setPrototypeOf ||
  41241. ({ __proto__: [] } instanceof Array && function (d,
  41242. b) { d.__proto__ = b; }) ||
  41243. function (d,
  41244. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41245. return extendStatics(d, b);
  41246. };
  41247. return function (d, b) {
  41248. extendStatics(d, b);
  41249. function __() { this.constructor = d; }
  41250. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41251. };
  41252. })();
  41253. var LineSeries = SeriesRegistry.seriesTypes.line;
  41254. var merge = U.merge,
  41255. pick = U.pick;
  41256. /**
  41257. * Spline series type.
  41258. *
  41259. * @private
  41260. */
  41261. var SplineSeries = /** @class */ (function (_super) {
  41262. __extends(SplineSeries, _super);
  41263. function SplineSeries() {
  41264. /* *
  41265. *
  41266. * Static Properties
  41267. *
  41268. * */
  41269. var _this = _super !== null && _super.apply(this,
  41270. arguments) || this;
  41271. /* *
  41272. *
  41273. * Properties
  41274. *
  41275. * */
  41276. _this.data = void 0;
  41277. _this.options = void 0;
  41278. _this.points = void 0;
  41279. return _this;
  41280. /* eslint-enable valid-jsdoc */
  41281. }
  41282. /* *
  41283. *
  41284. * Functions
  41285. *
  41286. * */
  41287. /* eslint-disable valid-jsdoc */
  41288. /**
  41289. * Get the spline segment from a given point's previous neighbour to the
  41290. * given point.
  41291. *
  41292. * @private
  41293. * @function Highcharts.seriesTypes.spline#getPointSpline
  41294. *
  41295. * @param {Array<Highcharts.Point>}
  41296. *
  41297. * @param {Highcharts.Point} point
  41298. *
  41299. * @param {number} i
  41300. *
  41301. * @return {Highcharts.SVGPathArray}
  41302. */
  41303. SplineSeries.prototype.getPointSpline = function (points, point, i) {
  41304. var
  41305. // 1 means control points midway between points, 2 means 1/3
  41306. // from the point, 3 is 1/4 etc
  41307. smoothing = 1.5,
  41308. denom = smoothing + 1,
  41309. plotX = point.plotX || 0,
  41310. plotY = point.plotY || 0,
  41311. lastPoint = points[i - 1],
  41312. nextPoint = points[i + 1],
  41313. leftContX,
  41314. leftContY,
  41315. rightContX,
  41316. rightContY,
  41317. ret;
  41318. /**
  41319. * @private
  41320. */
  41321. function doCurve(otherPoint) {
  41322. return otherPoint &&
  41323. !otherPoint.isNull &&
  41324. otherPoint.doCurve !== false &&
  41325. // #6387, area splines next to null:
  41326. !point.isCliff;
  41327. }
  41328. // Find control points
  41329. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  41330. var lastX = lastPoint.plotX || 0,
  41331. lastY = lastPoint.plotY || 0,
  41332. nextX = nextPoint.plotX || 0,
  41333. nextY = nextPoint.plotY || 0,
  41334. correction = 0;
  41335. leftContX = (smoothing * plotX + lastX) / denom;
  41336. leftContY = (smoothing * plotY + lastY) / denom;
  41337. rightContX = (smoothing * plotX + nextX) / denom;
  41338. rightContY = (smoothing * plotY + nextY) / denom;
  41339. // Have the two control points make a straight line through main
  41340. // point
  41341. if (rightContX !== leftContX) { // #5016, division by zero
  41342. correction = (((rightContY - leftContY) *
  41343. (rightContX - plotX)) /
  41344. (rightContX - leftContX) + plotY - rightContY);
  41345. }
  41346. leftContY += correction;
  41347. rightContY += correction;
  41348. // to prevent false extremes, check that control points are
  41349. // between neighbouring points' y values
  41350. if (leftContY > lastY && leftContY > plotY) {
  41351. leftContY = Math.max(lastY, plotY);
  41352. // mirror of left control point
  41353. rightContY = 2 * plotY - leftContY;
  41354. }
  41355. else if (leftContY < lastY && leftContY < plotY) {
  41356. leftContY = Math.min(lastY, plotY);
  41357. rightContY = 2 * plotY - leftContY;
  41358. }
  41359. if (rightContY > nextY && rightContY > plotY) {
  41360. rightContY = Math.max(nextY, plotY);
  41361. leftContY = 2 * plotY - rightContY;
  41362. }
  41363. else if (rightContY < nextY && rightContY < plotY) {
  41364. rightContY = Math.min(nextY, plotY);
  41365. leftContY = 2 * plotY - rightContY;
  41366. }
  41367. // record for drawing in next point
  41368. point.rightContX = rightContX;
  41369. point.rightContY = rightContY;
  41370. }
  41371. // Visualize control points for debugging
  41372. /*
  41373. if (leftContX) {
  41374. this.chart.renderer.circle(
  41375. leftContX + this.chart.plotLeft,
  41376. leftContY + this.chart.plotTop,
  41377. 2
  41378. )
  41379. .attr({
  41380. stroke: 'red',
  41381. 'stroke-width': 2,
  41382. fill: 'none',
  41383. zIndex: 9
  41384. })
  41385. .add();
  41386. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  41387. leftContY + this.chart.plotTop,
  41388. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41389. .attr({
  41390. stroke: 'red',
  41391. 'stroke-width': 2,
  41392. zIndex: 9
  41393. })
  41394. .add();
  41395. }
  41396. if (rightContX) {
  41397. this.chart.renderer.circle(
  41398. rightContX + this.chart.plotLeft,
  41399. rightContY + this.chart.plotTop,
  41400. 2
  41401. )
  41402. .attr({
  41403. stroke: 'green',
  41404. 'stroke-width': 2,
  41405. fill: 'none',
  41406. zIndex: 9
  41407. })
  41408. .add();
  41409. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  41410. rightContY + this.chart.plotTop,
  41411. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41412. .attr({
  41413. stroke: 'green',
  41414. 'stroke-width': 2,
  41415. zIndex: 9
  41416. })
  41417. .add();
  41418. }
  41419. // */
  41420. ret = [
  41421. 'C',
  41422. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  41423. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  41424. pick(leftContX, plotX, 0),
  41425. pick(leftContY, plotY, 0),
  41426. plotX,
  41427. plotY
  41428. ];
  41429. // reset for updating series later
  41430. lastPoint.rightContX = lastPoint.rightContY = void 0;
  41431. return ret;
  41432. };
  41433. /**
  41434. * A spline series is a special type of line series, where the segments
  41435. * between the data points are smoothed.
  41436. *
  41437. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  41438. * Spline chart
  41439. * @sample {highstock} stock/demo/spline/
  41440. * Spline chart
  41441. *
  41442. * @extends plotOptions.series
  41443. * @excluding step, boostThreshold, boostBlending
  41444. * @product highcharts highstock
  41445. * @optionparent plotOptions.spline
  41446. */
  41447. SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
  41448. return SplineSeries;
  41449. }(LineSeries));
  41450. SeriesRegistry.registerSeriesType('spline', SplineSeries);
  41451. /* *
  41452. *
  41453. * Default Export
  41454. *
  41455. * */
  41456. /* *
  41457. *
  41458. * API Options
  41459. *
  41460. * */
  41461. /**
  41462. * A `spline` series. If the [type](#series.spline.type) option is
  41463. * not specified, it is inherited from [chart.type](#chart.type).
  41464. *
  41465. * @extends series,plotOptions.spline
  41466. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41467. * @product highcharts highstock
  41468. * @apioption series.spline
  41469. */
  41470. /**
  41471. * An array of data points for the series. For the `spline` series type,
  41472. * points can be given in the following ways:
  41473. *
  41474. * 1. An array of numerical values. In this case, the numerical values will be
  41475. * interpreted as `y` options. The `x` values will be automatically
  41476. * calculated, either starting at 0 and incremented by 1, or from
  41477. * `pointStart` and `pointInterval` given in the series options. If the axis
  41478. * has categories, these will be used. Example:
  41479. * ```js
  41480. * data: [0, 5, 3, 5]
  41481. * ```
  41482. *
  41483. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41484. * `x,y`. If the first value is a string, it is applied as the name of the
  41485. * point, and the `x` value is inferred.
  41486. * ```js
  41487. * data: [
  41488. * [0, 9],
  41489. * [1, 2],
  41490. * [2, 8]
  41491. * ]
  41492. * ```
  41493. *
  41494. * 3. An array of objects with named values. The following snippet shows only a
  41495. * few settings, see the complete options set below. If the total number of
  41496. * data points exceeds the series'
  41497. * [turboThreshold](#series.spline.turboThreshold),
  41498. * this option is not available.
  41499. * ```js
  41500. * data: [{
  41501. * x: 1,
  41502. * y: 9,
  41503. * name: "Point2",
  41504. * color: "#00FF00"
  41505. * }, {
  41506. * x: 1,
  41507. * y: 0,
  41508. * name: "Point1",
  41509. * color: "#FF00FF"
  41510. * }]
  41511. * ```
  41512. *
  41513. * @sample {highcharts} highcharts/chart/reflow-true/
  41514. * Numerical values
  41515. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41516. * Arrays of numeric x and y
  41517. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41518. * Arrays of datetime x and y
  41519. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41520. * Arrays of point.name and y
  41521. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41522. * Config objects
  41523. *
  41524. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41525. * @extends series.line.data
  41526. * @product highcharts highstock
  41527. * @apioption series.spline.data
  41528. */
  41529. ''; // adds doclets above intro transpilat
  41530. return SplineSeries;
  41531. });
  41532. _registerModule(_modules, 'Series/AreaSpline/AreaSplineSeries.js', [_modules['Series/Area/AreaSeries.js'], _modules['Series/Spline/SplineSeries.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (AreaSeries, SplineSeries, LegendSymbolMixin, SeriesRegistry, U) {
  41533. /* *
  41534. *
  41535. * (c) 2010-2021 Torstein Honsi
  41536. *
  41537. * License: www.highcharts.com/license
  41538. *
  41539. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41540. *
  41541. * */
  41542. var __extends = (this && this.__extends) || (function () {
  41543. var extendStatics = function (d,
  41544. b) {
  41545. extendStatics = Object.setPrototypeOf ||
  41546. ({ __proto__: [] } instanceof Array && function (d,
  41547. b) { d.__proto__ = b; }) ||
  41548. function (d,
  41549. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41550. return extendStatics(d, b);
  41551. };
  41552. return function (d, b) {
  41553. extendStatics(d, b);
  41554. function __() { this.constructor = d; }
  41555. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41556. };
  41557. })();
  41558. var areaProto = AreaSeries.prototype;
  41559. var extend = U.extend,
  41560. merge = U.merge;
  41561. /* *
  41562. *
  41563. * Class
  41564. *
  41565. * */
  41566. /**
  41567. * AreaSpline series type.
  41568. *
  41569. * @private
  41570. * @class
  41571. * @name Highcharts.seriesTypes.areaspline
  41572. *
  41573. * @augments Highcharts.Series
  41574. */
  41575. var AreaSplineSeries = /** @class */ (function (_super) {
  41576. __extends(AreaSplineSeries, _super);
  41577. function AreaSplineSeries() {
  41578. /* *
  41579. *
  41580. * Static properties
  41581. *
  41582. * */
  41583. var _this = _super !== null && _super.apply(this,
  41584. arguments) || this;
  41585. /* *
  41586. *
  41587. * Properties
  41588. *
  41589. * */
  41590. _this.data = void 0;
  41591. _this.points = void 0;
  41592. _this.options = void 0;
  41593. return _this;
  41594. }
  41595. /**
  41596. * The area spline series is an area series where the graph between the
  41597. * points is smoothed into a spline.
  41598. *
  41599. * @sample {highcharts} highcharts/demo/areaspline/
  41600. * Area spline chart
  41601. * @sample {highstock} stock/demo/areaspline/
  41602. * Area spline chart
  41603. *
  41604. * @extends plotOptions.area
  41605. * @excluding step, boostThreshold, boostBlending
  41606. * @product highcharts highstock
  41607. * @apioption plotOptions.areaspline
  41608. */
  41609. /**
  41610. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41611. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41612. *
  41613. * @apioption plotOptions.areaspline.color
  41614. */
  41615. /**
  41616. * @see [color](#plotOptions.areaspline.color)
  41617. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41618. *
  41619. * @apioption plotOptions.areaspline.fillColor
  41620. */
  41621. /**
  41622. * @see [color](#plotOptions.areaspline.color)
  41623. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41624. *
  41625. * @default {highcharts} 0.75
  41626. * @default {highstock} 0.75
  41627. * @apioption plotOptions.areaspline.fillOpacity
  41628. */
  41629. AreaSplineSeries.defaultOptions = merge(SplineSeries.defaultOptions, AreaSeries.defaultOptions);
  41630. return AreaSplineSeries;
  41631. }(SplineSeries));
  41632. extend(AreaSplineSeries.prototype, {
  41633. getGraphPath: areaProto.getGraphPath,
  41634. getStackPoints: areaProto.getStackPoints,
  41635. drawGraph: areaProto.drawGraph,
  41636. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41637. });
  41638. SeriesRegistry.registerSeriesType('areaspline', AreaSplineSeries);
  41639. /* *
  41640. *
  41641. * Default export
  41642. *
  41643. * */
  41644. /**
  41645. * A `areaspline` series. If the [type](#series.areaspline.type) option
  41646. * is not specified, it is inherited from [chart.type](#chart.type).
  41647. *
  41648. *
  41649. * @extends series,plotOptions.areaspline
  41650. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41651. * @product highcharts highstock
  41652. * @apioption series.areaspline
  41653. */
  41654. /**
  41655. * @see [fillColor](#series.areaspline.fillColor)
  41656. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41657. *
  41658. * @apioption series.areaspline.color
  41659. */
  41660. /**
  41661. * An array of data points for the series. For the `areaspline` series
  41662. * type, points can be given in the following ways:
  41663. *
  41664. * 1. An array of numerical values. In this case, the numerical values will be
  41665. * interpreted as `y` options. The `x` values will be automatically
  41666. * calculated, either starting at 0 and incremented by 1, or from
  41667. * `pointStart` and `pointInterval` given in the series options. If the axis
  41668. * has categories, these will be used. Example:
  41669. * ```js
  41670. * data: [0, 5, 3, 5]
  41671. * ```
  41672. *
  41673. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41674. * `x,y`. If the first value is a string, it is applied as the name of the
  41675. * point, and the `x` value is inferred.
  41676. * ```js
  41677. * data: [
  41678. * [0, 10],
  41679. * [1, 9],
  41680. * [2, 3]
  41681. * ]
  41682. * ```
  41683. *
  41684. * 3. An array of objects with named values. The following snippet shows only a
  41685. * few settings, see the complete options set below. If the total number of
  41686. * data points exceeds the series'
  41687. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  41688. * available.
  41689. * ```js
  41690. * data: [{
  41691. * x: 1,
  41692. * y: 4,
  41693. * name: "Point2",
  41694. * color: "#00FF00"
  41695. * }, {
  41696. * x: 1,
  41697. * y: 4,
  41698. * name: "Point1",
  41699. * color: "#FF00FF"
  41700. * }]
  41701. * ```
  41702. *
  41703. * @sample {highcharts} highcharts/chart/reflow-true/
  41704. * Numerical values
  41705. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41706. * Arrays of numeric x and y
  41707. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41708. * Arrays of datetime x and y
  41709. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41710. * Arrays of point.name and y
  41711. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41712. * Config objects
  41713. *
  41714. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41715. * @extends series.line.data
  41716. * @product highcharts highstock
  41717. * @apioption series.areaspline.data
  41718. */
  41719. /**
  41720. * @see [color](#series.areaspline.color)
  41721. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41722. *
  41723. * @apioption series.areaspline.fillColor
  41724. */
  41725. /**
  41726. * @see [color](#series.areaspline.color)
  41727. * @see [fillColor](#series.areaspline.fillColor)
  41728. *
  41729. * @default {highcharts} 0.75
  41730. * @default {highstock} 0.75
  41731. * @apioption series.areaspline.fillOpacity
  41732. */
  41733. ''; // adds doclets above into transpilat
  41734. return AreaSplineSeries;
  41735. });
  41736. _registerModule(_modules, 'Series/Column/ColumnSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, Color, H, LegendSymbolMixin, palette, Series, SeriesRegistry, U) {
  41737. /* *
  41738. *
  41739. * (c) 2010-2021 Torstein Honsi
  41740. *
  41741. * License: www.highcharts.com/license
  41742. *
  41743. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41744. *
  41745. * */
  41746. var __extends = (this && this.__extends) || (function () {
  41747. var extendStatics = function (d,
  41748. b) {
  41749. extendStatics = Object.setPrototypeOf ||
  41750. ({ __proto__: [] } instanceof Array && function (d,
  41751. b) { d.__proto__ = b; }) ||
  41752. function (d,
  41753. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41754. return extendStatics(d, b);
  41755. };
  41756. return function (d, b) {
  41757. extendStatics(d, b);
  41758. function __() { this.constructor = d; }
  41759. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41760. };
  41761. })();
  41762. var animObject = A.animObject;
  41763. var color = Color.parse;
  41764. var hasTouch = H.hasTouch,
  41765. noop = H.noop;
  41766. var clamp = U.clamp,
  41767. css = U.css,
  41768. defined = U.defined,
  41769. extend = U.extend,
  41770. fireEvent = U.fireEvent,
  41771. isArray = U.isArray,
  41772. isNumber = U.isNumber,
  41773. merge = U.merge,
  41774. pick = U.pick,
  41775. objectEach = U.objectEach;
  41776. /**
  41777. * The column series type.
  41778. *
  41779. * @private
  41780. * @class
  41781. * @name Highcharts.seriesTypes.column
  41782. *
  41783. * @augments Highcharts.Series
  41784. */
  41785. var ColumnSeries = /** @class */ (function (_super) {
  41786. __extends(ColumnSeries, _super);
  41787. function ColumnSeries() {
  41788. /* *
  41789. *
  41790. * Static Properties
  41791. *
  41792. * */
  41793. var _this = _super !== null && _super.apply(this,
  41794. arguments) || this;
  41795. /* *
  41796. *
  41797. * Properties
  41798. *
  41799. * */
  41800. _this.borderWidth = void 0;
  41801. _this.data = void 0;
  41802. _this.group = void 0;
  41803. _this.options = void 0;
  41804. _this.points = void 0;
  41805. return _this;
  41806. /* eslint-enable valid-jsdoc */
  41807. }
  41808. /* *
  41809. *
  41810. * Functions
  41811. *
  41812. * */
  41813. /* eslint-disable valid-jsdoc */
  41814. /**
  41815. * Animate the column heights one by one from zero.
  41816. *
  41817. * @private
  41818. * @function Highcharts.seriesTypes.column#animate
  41819. *
  41820. * @param {boolean} init
  41821. * Whether to initialize the animation or run it
  41822. */
  41823. ColumnSeries.prototype.animate = function (init) {
  41824. var series = this,
  41825. yAxis = this.yAxis,
  41826. options = series.options,
  41827. inverted = this.chart.inverted,
  41828. attr = {},
  41829. translateProp = inverted ? 'translateX' : 'translateY',
  41830. translateStart,
  41831. translatedThreshold;
  41832. if (init) {
  41833. attr.scaleY = 0.001;
  41834. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  41835. if (inverted) {
  41836. attr.translateX = translatedThreshold - yAxis.len;
  41837. }
  41838. else {
  41839. attr.translateY = translatedThreshold;
  41840. }
  41841. // apply finnal clipping (used in Highcharts Stock) (#7083)
  41842. // animation is done by scaleY, so cliping is for panes
  41843. if (series.clipBox) {
  41844. series.setClip();
  41845. }
  41846. series.group.attr(attr);
  41847. }
  41848. else { // run the animation
  41849. translateStart = Number(series.group.attr(translateProp));
  41850. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  41851. // Do the scale synchronously to ensure smooth
  41852. // updating (#5030, #7228)
  41853. step: function (val, fx) {
  41854. if (series.group) {
  41855. attr[translateProp] = translateStart +
  41856. fx.pos * (yAxis.pos - translateStart);
  41857. series.group.attr(attr);
  41858. }
  41859. }
  41860. }));
  41861. }
  41862. };
  41863. /**
  41864. * Initialize the series. Extends the basic Series.init method by
  41865. * marking other series of the same type as dirty.
  41866. *
  41867. * @private
  41868. * @function Highcharts.seriesTypes.column#init
  41869. */
  41870. ColumnSeries.prototype.init = function (chart, options) {
  41871. _super.prototype.init.apply(this, arguments);
  41872. var series = this;
  41873. chart = series.chart;
  41874. // if the series is added dynamically, force redraw of other
  41875. // series affected by a new column
  41876. if (chart.hasRendered) {
  41877. chart.series.forEach(function (otherSeries) {
  41878. if (otherSeries.type === series.type) {
  41879. otherSeries.isDirty = true;
  41880. }
  41881. });
  41882. }
  41883. };
  41884. /**
  41885. * Return the width and x offset of the columns adjusted for grouping,
  41886. * groupPadding, pointPadding, pointWidth etc.
  41887. *
  41888. * @private
  41889. * @function Highcharts.seriesTypes.column#getColumnMetrics
  41890. * @return {Highcharts.ColumnMetricsObject}
  41891. */
  41892. ColumnSeries.prototype.getColumnMetrics = function () {
  41893. var series = this,
  41894. options = series.options,
  41895. xAxis = series.xAxis,
  41896. yAxis = series.yAxis,
  41897. reversedStacks = xAxis.options.reversedStacks,
  41898. // Keep backward compatibility: reversed xAxis had reversed
  41899. // stacks
  41900. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  41901. (!xAxis.reversed && reversedStacks),
  41902. stackKey,
  41903. stackGroups = {},
  41904. columnCount = 0;
  41905. // Get the total number of column type series. This is called on
  41906. // every series. Consider moving this logic to a chart.orderStacks()
  41907. // function and call it on init, addSeries and removeSeries
  41908. if (options.grouping === false) {
  41909. columnCount = 1;
  41910. }
  41911. else {
  41912. series.chart.series.forEach(function (otherSeries) {
  41913. var otherYAxis = otherSeries.yAxis,
  41914. otherOptions = otherSeries.options,
  41915. columnIndex;
  41916. if (otherSeries.type === series.type &&
  41917. (otherSeries.visible ||
  41918. !series.chart.options.chart.ignoreHiddenSeries) &&
  41919. yAxis.len === otherYAxis.len &&
  41920. yAxis.pos === otherYAxis.pos) { // #642, #2086
  41921. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  41922. stackKey = otherSeries.stackKey;
  41923. if (typeof stackGroups[stackKey] ===
  41924. 'undefined') {
  41925. stackGroups[stackKey] = columnCount++;
  41926. }
  41927. columnIndex = stackGroups[stackKey];
  41928. }
  41929. else if (otherOptions.grouping !== false) { // #1162
  41930. columnIndex = columnCount++;
  41931. }
  41932. otherSeries.columnIndex = columnIndex;
  41933. }
  41934. });
  41935. }
  41936. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  41937. options.pointRange ||
  41938. xAxis.closestPointRange ||
  41939. xAxis.tickInterval ||
  41940. 1), // #2610
  41941. xAxis.len // #1535
  41942. ),
  41943. groupPadding = categoryWidth * options.groupPadding,
  41944. groupWidth = categoryWidth - 2 * groupPadding,
  41945. pointOffsetWidth = groupWidth / (columnCount || 1),
  41946. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  41947. pick(options.pointWidth,
  41948. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  41949. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  41950. // #1251, #3737
  41951. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  41952. pointXOffset = pointPadding +
  41953. (groupPadding +
  41954. colIndex * pointOffsetWidth -
  41955. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  41956. // Save it for reading in linked series (Error bars particularly)
  41957. series.columnMetrics = {
  41958. width: pointWidth,
  41959. offset: pointXOffset,
  41960. paddedWidth: pointOffsetWidth,
  41961. columnCount: columnCount
  41962. };
  41963. return series.columnMetrics;
  41964. };
  41965. /**
  41966. * Make the columns crisp. The edges are rounded to the nearest full
  41967. * pixel.
  41968. *
  41969. * @private
  41970. * @function Highcharts.seriesTypes.column#crispCol
  41971. */
  41972. ColumnSeries.prototype.crispCol = function (x, y, w, h) {
  41973. var chart = this.chart,
  41974. borderWidth = this.borderWidth,
  41975. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  41976. yCrisp = borderWidth % 2 ? 0.5 : 1,
  41977. right,
  41978. bottom,
  41979. fromTop;
  41980. if (chart.inverted && chart.renderer.isVML) {
  41981. yCrisp += 1;
  41982. }
  41983. // Horizontal. We need to first compute the exact right edge, then
  41984. // round it and compute the width from there.
  41985. if (this.options.crisp) {
  41986. right = Math.round(x + w) + xCrisp;
  41987. x = Math.round(x) + xCrisp;
  41988. w = right - x;
  41989. }
  41990. // Vertical
  41991. bottom = Math.round(y + h) + yCrisp;
  41992. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  41993. y = Math.round(y) + yCrisp;
  41994. h = bottom - y;
  41995. // Top edges are exceptions
  41996. if (fromTop && h) { // #5146
  41997. y -= 1;
  41998. h += 1;
  41999. }
  42000. return {
  42001. x: x,
  42002. y: y,
  42003. width: w,
  42004. height: h
  42005. };
  42006. };
  42007. /**
  42008. * Adjust for missing columns, according to the `centerInCategory`
  42009. * option. Missing columns are either single points or stacks where the
  42010. * point or points are either missing or null.
  42011. *
  42012. * @private
  42013. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  42014. * @param {number} x
  42015. * The x coordinate of the column, left side
  42016. *
  42017. * @param {number} pointWidth
  42018. * The pointWidth, already computed upstream
  42019. *
  42020. * @param {Highcharts.ColumnPoint} point
  42021. * The point instance
  42022. *
  42023. * @param {Highcharts.ColumnMetricsObject} metrics
  42024. * The series-wide column metrics
  42025. *
  42026. * @return {number}
  42027. * The adjusted x position, or the original if not adjusted
  42028. */
  42029. ColumnSeries.prototype.adjustForMissingColumns = function (x, pointWidth, point, metrics) {
  42030. var _this = this;
  42031. var stacking = this.options.stacking;
  42032. if (!point.isNull && metrics.columnCount > 1) {
  42033. var indexInCategory_1 = 0;
  42034. var totalInCategory_1 = 0;
  42035. // Loop over all the stacks on the Y axis. When stacking is
  42036. // enabled, these are real point stacks. When stacking is not
  42037. // enabled, but `centerInCategory` is true, there is one stack
  42038. // handling the grouping of points in each category. This is
  42039. // done in the `setGroupedPoints` function.
  42040. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  42041. if (typeof point.x === 'number') {
  42042. var stackItem = stack[point.x.toString()];
  42043. if (stackItem) {
  42044. var pointValues = stackItem.points[_this.index],
  42045. total = stackItem.total;
  42046. // If true `stacking` is enabled, count the
  42047. // total number of non-null stacks in the
  42048. // category, and note which index this point is
  42049. // within those stacks.
  42050. if (stacking) {
  42051. if (pointValues) {
  42052. indexInCategory_1 = totalInCategory_1;
  42053. }
  42054. if (stackItem.hasValidPoints) {
  42055. totalInCategory_1++;
  42056. }
  42057. // If `stacking` is not enabled, look for the
  42058. // index and total of the `group` stack.
  42059. }
  42060. else if (isArray(pointValues)) {
  42061. indexInCategory_1 = pointValues[1];
  42062. totalInCategory_1 = total || 0;
  42063. }
  42064. }
  42065. }
  42066. });
  42067. // Compute the adjusted x position
  42068. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  42069. pointWidth;
  42070. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  42071. indexInCategory_1 * metrics.paddedWidth;
  42072. }
  42073. return x;
  42074. };
  42075. /**
  42076. * Translate each point to the plot area coordinate system and find
  42077. * shape positions
  42078. *
  42079. * @private
  42080. * @function Highcharts.seriesTypes.column#translate
  42081. */
  42082. ColumnSeries.prototype.translate = function () {
  42083. var series = this,
  42084. chart = series.chart,
  42085. options = series.options,
  42086. dense = series.dense =
  42087. series.closestPointRange * series.xAxis.transA < 2,
  42088. borderWidth = series.borderWidth = pick(options.borderWidth,
  42089. dense ? 0 : 1 // #3635
  42090. ),
  42091. xAxis = series.xAxis,
  42092. yAxis = series.yAxis,
  42093. threshold = options.threshold,
  42094. translatedThreshold = series.translatedThreshold =
  42095. yAxis.getThreshold(threshold),
  42096. minPointLength = pick(options.minPointLength, 5),
  42097. metrics = series.getColumnMetrics(),
  42098. seriesPointWidth = metrics.width,
  42099. // postprocessed for border width
  42100. seriesBarW = series.barW =
  42101. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  42102. seriesXOffset = series.pointXOffset = metrics.offset,
  42103. dataMin = series.dataMin,
  42104. dataMax = series.dataMax;
  42105. if (chart.inverted) {
  42106. translatedThreshold -= 0.5; // #3355
  42107. }
  42108. // When the pointPadding is 0, we want the columns to be packed
  42109. // tightly, so we allow individual columns to have individual sizes.
  42110. // When pointPadding is greater, we strive for equal-width columns
  42111. // (#2694).
  42112. if (options.pointPadding) {
  42113. seriesBarW = Math.ceil(seriesBarW);
  42114. }
  42115. Series.prototype.translate.apply(series);
  42116. // Record the new values
  42117. series.points.forEach(function (point) {
  42118. var yBottom = pick(point.yBottom,
  42119. translatedThreshold),
  42120. safeDistance = 999 + Math.abs(yBottom),
  42121. pointWidth = seriesPointWidth,
  42122. plotX = point.plotX || 0,
  42123. // Don't draw too far outside plot area (#1303, #2241,
  42124. // #4264)
  42125. plotY = clamp(point.plotY, -safeDistance,
  42126. yAxis.len + safeDistance),
  42127. barX = plotX + seriesXOffset,
  42128. barW = seriesBarW,
  42129. barY = Math.min(plotY,
  42130. yBottom),
  42131. up,
  42132. barH = Math.max(plotY,
  42133. yBottom) - barY;
  42134. // Handle options.minPointLength
  42135. if (minPointLength && Math.abs(barH) < minPointLength) {
  42136. barH = minPointLength;
  42137. up = (!yAxis.reversed && !point.negative) ||
  42138. (yAxis.reversed && point.negative);
  42139. // Reverse zeros if there's no positive value in the series
  42140. // in visible range (#7046)
  42141. if (isNumber(threshold) &&
  42142. isNumber(dataMax) &&
  42143. point.y === threshold &&
  42144. dataMax <= threshold &&
  42145. // and if there's room for it (#7311)
  42146. (yAxis.min || 0) < threshold &&
  42147. // if all points are the same value (i.e zero) not draw
  42148. // as negative points (#10646), but only if there's room
  42149. // for it (#14876)
  42150. (dataMin !== dataMax || (yAxis.max || 0) <= threshold)) {
  42151. up = !up;
  42152. }
  42153. // If stacked...
  42154. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  42155. // ...keep position
  42156. yBottom - minPointLength :
  42157. // #1485, #4051
  42158. translatedThreshold -
  42159. (up ? minPointLength : 0));
  42160. }
  42161. // Handle point.options.pointWidth
  42162. // @todo Handle grouping/stacking too. Calculate offset properly
  42163. if (defined(point.options.pointWidth)) {
  42164. pointWidth = barW =
  42165. Math.ceil(point.options.pointWidth);
  42166. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  42167. }
  42168. // Adjust for null or missing points
  42169. if (options.centerInCategory) {
  42170. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  42171. }
  42172. // Cache for access in polar
  42173. point.barX = barX;
  42174. point.pointWidth = pointWidth;
  42175. // Fix the tooltip on center of grouped columns (#1216, #424,
  42176. // #3648)
  42177. point.tooltipPos = chart.inverted ?
  42178. [
  42179. clamp(yAxis.len + yAxis.pos - chart.plotLeft - plotY, yAxis.pos - chart.plotLeft, yAxis.len + yAxis.pos - chart.plotLeft),
  42180. xAxis.len + xAxis.pos - chart.plotTop - barX - barW / 2,
  42181. barH
  42182. ] :
  42183. [
  42184. xAxis.left - chart.plotLeft + barX + barW / 2,
  42185. clamp(plotY + yAxis.pos -
  42186. chart.plotTop, yAxis.pos - chart.plotTop, yAxis.len + yAxis.pos - chart.plotTop),
  42187. barH
  42188. ];
  42189. // Register shape type and arguments to be used in drawPoints
  42190. // Allow shapeType defined on pointClass level
  42191. point.shapeType = series.pointClass.prototype.shapeType || 'rect';
  42192. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  42193. // #3169, drilldown from null must have a position to work
  42194. // from #6585, dataLabel should be placed on xAxis, not
  42195. // floating in the middle of the chart
  42196. [barX, translatedThreshold, barW, 0] :
  42197. [barX, barY, barW, barH]);
  42198. });
  42199. };
  42200. /**
  42201. * Columns have no graph
  42202. *
  42203. * @private
  42204. * @function Highcharts.seriesTypes.column#drawGraph
  42205. */
  42206. ColumnSeries.prototype.drawGraph = function () {
  42207. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  42208. };
  42209. /**
  42210. * Get presentational attributes
  42211. *
  42212. * @private
  42213. * @function Highcharts.seriesTypes.column#pointAttribs
  42214. */
  42215. ColumnSeries.prototype.pointAttribs = function (point, state) {
  42216. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  42217. // set to fill when borderColor null:
  42218. stroke = ((point && point[strokeOption]) ||
  42219. options[strokeOption] ||
  42220. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  42221. options[strokeWidthOption] ||
  42222. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  42223. // Handle zone colors
  42224. if (point && this.zones.length) {
  42225. zone = point.getZone();
  42226. // When zones are present, don't use point.color (#4267).
  42227. // Changed order (#6527), added support for colorAxis (#10670)
  42228. fill = (point.options.color ||
  42229. (zone && (zone.color || point.nonZonedColor)) ||
  42230. this.color);
  42231. if (zone) {
  42232. stroke = zone.borderColor || stroke;
  42233. dashstyle = zone.dashStyle || dashstyle;
  42234. strokeWidth = zone.borderWidth || strokeWidth;
  42235. }
  42236. }
  42237. // Select or hover states
  42238. if (state && point) {
  42239. stateOptions = merge(options.states[state],
  42240. // #6401
  42241. point.options.states &&
  42242. point.options.states[state] ||
  42243. {});
  42244. brightness = stateOptions.brightness;
  42245. fill =
  42246. stateOptions.color || (typeof brightness !== 'undefined' &&
  42247. color(fill)
  42248. .brighten(stateOptions.brightness)
  42249. .get()) || fill;
  42250. stroke = stateOptions[strokeOption] || stroke;
  42251. strokeWidth =
  42252. stateOptions[strokeWidthOption] || strokeWidth;
  42253. dashstyle = stateOptions.dashStyle || dashstyle;
  42254. opacity = pick(stateOptions.opacity, opacity);
  42255. }
  42256. ret = {
  42257. fill: fill,
  42258. stroke: stroke,
  42259. 'stroke-width': strokeWidth,
  42260. opacity: opacity
  42261. };
  42262. if (dashstyle) {
  42263. ret.dashstyle = dashstyle;
  42264. }
  42265. return ret;
  42266. };
  42267. /**
  42268. * Draw the columns. For bars, the series.group is rotated, so the same
  42269. * coordinates apply for columns and bars. This method is inherited by
  42270. * scatter series.
  42271. *
  42272. * @private
  42273. * @function Highcharts.seriesTypes.column#drawPoints
  42274. */
  42275. ColumnSeries.prototype.drawPoints = function () {
  42276. var series = this,
  42277. chart = this.chart,
  42278. options = series.options,
  42279. renderer = chart.renderer,
  42280. animationLimit = options.animationLimit || 250,
  42281. shapeArgs;
  42282. // draw the columns
  42283. series.points.forEach(function (point) {
  42284. var plotY = point.plotY,
  42285. graphic = point.graphic,
  42286. hasGraphic = !!graphic,
  42287. verb = graphic && chart.pointCount < animationLimit ?
  42288. 'animate' : 'attr';
  42289. if (isNumber(plotY) && point.y !== null) {
  42290. shapeArgs = point.shapeArgs;
  42291. // When updating a series between 2d and 3d or cartesian and
  42292. // polar, the shape type changes.
  42293. if (graphic && point.hasNewShapeType()) {
  42294. graphic = graphic.destroy();
  42295. }
  42296. // Set starting position for point sliding animation.
  42297. if (series.enabledDataSorting) {
  42298. point.startXPos = series.xAxis.reversed ?
  42299. -(shapeArgs ? (shapeArgs.width || 0) : 0) :
  42300. series.xAxis.width;
  42301. }
  42302. if (!graphic) {
  42303. point.graphic = graphic =
  42304. renderer[point.shapeType](shapeArgs)
  42305. .add(point.group || series.group);
  42306. if (graphic &&
  42307. series.enabledDataSorting &&
  42308. chart.hasRendered &&
  42309. chart.pointCount < animationLimit) {
  42310. graphic.attr({
  42311. x: point.startXPos
  42312. });
  42313. hasGraphic = true;
  42314. verb = 'animate';
  42315. }
  42316. }
  42317. if (graphic && hasGraphic) { // update
  42318. graphic[verb](merge(shapeArgs));
  42319. }
  42320. // Border radius is not stylable (#6900)
  42321. if (options.borderRadius) {
  42322. graphic[verb]({
  42323. r: options.borderRadius
  42324. });
  42325. }
  42326. // Presentational
  42327. if (!chart.styledMode) {
  42328. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  42329. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  42330. }
  42331. if (graphic) {
  42332. graphic.addClass(point.getClassName(), true);
  42333. graphic.attr({
  42334. visibility: point.visible ? 'inherit' : 'hidden'
  42335. });
  42336. }
  42337. }
  42338. else if (graphic) {
  42339. point.graphic = graphic.destroy(); // #1269
  42340. }
  42341. });
  42342. };
  42343. /**
  42344. * Draw the tracker for a point.
  42345. * @private
  42346. */
  42347. ColumnSeries.prototype.drawTracker = function () {
  42348. var series = this,
  42349. chart = series.chart,
  42350. pointer = chart.pointer,
  42351. onMouseOver = function (e) {
  42352. var point = pointer.getPointFromEvent(e);
  42353. // undefined on graph in scatterchart
  42354. if (typeof point !== 'undefined') {
  42355. pointer.isDirectTouch = true;
  42356. point.onMouseOver(e);
  42357. }
  42358. }, dataLabels;
  42359. // Add reference to the point
  42360. series.points.forEach(function (point) {
  42361. dataLabels = (isArray(point.dataLabels) ?
  42362. point.dataLabels :
  42363. (point.dataLabel ? [point.dataLabel] : []));
  42364. if (point.graphic) {
  42365. point.graphic.element.point = point;
  42366. }
  42367. dataLabels.forEach(function (dataLabel) {
  42368. if (dataLabel.div) {
  42369. dataLabel.div.point = point;
  42370. }
  42371. else {
  42372. dataLabel.element.point = point;
  42373. }
  42374. });
  42375. });
  42376. // Add the event listeners, we need to do this only once
  42377. if (!series._hasTracking) {
  42378. series.trackerGroups.forEach(function (key) {
  42379. if (series[key]) {
  42380. // we don't always have dataLabelsGroup
  42381. series[key]
  42382. .addClass('highcharts-tracker')
  42383. .on('mouseover', onMouseOver)
  42384. .on('mouseout', function (e) {
  42385. pointer.onTrackerMouseOut(e);
  42386. });
  42387. if (hasTouch) {
  42388. series[key].on('touchstart', onMouseOver);
  42389. }
  42390. if (!chart.styledMode && series.options.cursor) {
  42391. series[key]
  42392. .css(css)
  42393. .css({ cursor: series.options.cursor });
  42394. }
  42395. }
  42396. });
  42397. series._hasTracking = true;
  42398. }
  42399. fireEvent(this, 'afterDrawTracker');
  42400. };
  42401. /**
  42402. * Remove this series from the chart
  42403. *
  42404. * @private
  42405. * @function Highcharts.seriesTypes.column#remove
  42406. */
  42407. ColumnSeries.prototype.remove = function () {
  42408. var series = this,
  42409. chart = series.chart;
  42410. // column and bar series affects other series of the same type
  42411. // as they are either stacked or grouped
  42412. if (chart.hasRendered) {
  42413. chart.series.forEach(function (otherSeries) {
  42414. if (otherSeries.type === series.type) {
  42415. otherSeries.isDirty = true;
  42416. }
  42417. });
  42418. }
  42419. Series.prototype.remove.apply(series, arguments);
  42420. };
  42421. /**
  42422. * Column series display one column per value along an X axis.
  42423. *
  42424. * @sample {highcharts} highcharts/demo/column-basic/
  42425. * Column chart
  42426. * @sample {highstock} stock/demo/column/
  42427. * Column chart
  42428. *
  42429. * @extends plotOptions.line
  42430. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  42431. * lineWidth, marker, step, useOhlcData
  42432. * @product highcharts highstock
  42433. * @optionparent plotOptions.column
  42434. */
  42435. ColumnSeries.defaultOptions = merge(Series.defaultOptions, {
  42436. /**
  42437. * The corner radius of the border surrounding each column or bar.
  42438. *
  42439. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  42440. * Rounded columns
  42441. *
  42442. * @product highcharts highstock gantt
  42443. *
  42444. * @private
  42445. */
  42446. borderRadius: 0,
  42447. /**
  42448. * When using automatic point colors pulled from the global
  42449. * [colors](colors) or series-specific
  42450. * [plotOptions.column.colors](series.colors) collections, this option
  42451. * determines whether the chart should receive one color per series or
  42452. * one color per point.
  42453. *
  42454. * In styled mode, the `colors` or `series.colors` arrays are not
  42455. * supported, and instead this option gives the points individual color
  42456. * class names on the form `highcharts-color-{n}`.
  42457. *
  42458. * @see [series colors](#plotOptions.column.colors)
  42459. *
  42460. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  42461. * False by default
  42462. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  42463. * True
  42464. *
  42465. * @type {boolean}
  42466. * @default false
  42467. * @since 2.0
  42468. * @product highcharts highstock gantt
  42469. * @apioption plotOptions.column.colorByPoint
  42470. */
  42471. /**
  42472. * A series specific or series type specific color set to apply instead
  42473. * of the global [colors](#colors) when [colorByPoint](
  42474. * #plotOptions.column.colorByPoint) is true.
  42475. *
  42476. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  42477. * @since 3.0
  42478. * @product highcharts highstock gantt
  42479. * @apioption plotOptions.column.colors
  42480. */
  42481. /**
  42482. * When `true`, the columns will center in the category, ignoring null
  42483. * or missing points. When `false`, space will be reserved for null or
  42484. * missing points.
  42485. *
  42486. * @sample {highcharts} highcharts/series-column/centerincategory/
  42487. * Center in category
  42488. *
  42489. * @since 8.0.1
  42490. * @product highcharts highstock gantt
  42491. *
  42492. * @private
  42493. */
  42494. centerInCategory: false,
  42495. /**
  42496. * Padding between each value groups, in x axis units.
  42497. *
  42498. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  42499. * 0.2 by default
  42500. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  42501. * No group padding - all columns are evenly spaced
  42502. *
  42503. * @product highcharts highstock gantt
  42504. *
  42505. * @private
  42506. */
  42507. groupPadding: 0.2,
  42508. /**
  42509. * Whether to group non-stacked columns or to let them render
  42510. * independent of each other. Non-grouped columns will be laid out
  42511. * individually and overlap each other.
  42512. *
  42513. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  42514. * Grouping disabled
  42515. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  42516. * Grouping disabled
  42517. *
  42518. * @type {boolean}
  42519. * @default true
  42520. * @since 2.3.0
  42521. * @product highcharts highstock gantt
  42522. * @apioption plotOptions.column.grouping
  42523. */
  42524. /**
  42525. * @ignore-option
  42526. * @private
  42527. */
  42528. marker: null,
  42529. /**
  42530. * The maximum allowed pixel width for a column, translated to the
  42531. * height of a bar in a bar chart. This prevents the columns from
  42532. * becoming too wide when there is a small number of points in the
  42533. * chart.
  42534. *
  42535. * @see [pointWidth](#plotOptions.column.pointWidth)
  42536. *
  42537. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  42538. * Limited to 50
  42539. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  42540. * Limited to 50
  42541. *
  42542. * @type {number}
  42543. * @since 4.1.8
  42544. * @product highcharts highstock gantt
  42545. * @apioption plotOptions.column.maxPointWidth
  42546. */
  42547. /**
  42548. * Padding between each column or bar, in x axis units.
  42549. *
  42550. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  42551. * 0.1 by default
  42552. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  42553. * 0.25
  42554. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  42555. * 0 for tightly packed columns
  42556. *
  42557. * @product highcharts highstock gantt
  42558. *
  42559. * @private
  42560. */
  42561. pointPadding: 0.1,
  42562. /**
  42563. * A pixel value specifying a fixed width for each column or bar point.
  42564. * When set to `undefined`, the width is calculated from the
  42565. * `pointPadding` and `groupPadding`. The width effects the dimension
  42566. * that is not based on the point value. For column series it is the
  42567. * hoizontal length and for bar series it is the vertical length.
  42568. *
  42569. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  42570. *
  42571. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  42572. * 20px wide columns regardless of chart width or the amount of
  42573. * data points
  42574. *
  42575. * @type {number}
  42576. * @since 1.2.5
  42577. * @product highcharts highstock gantt
  42578. * @apioption plotOptions.column.pointWidth
  42579. */
  42580. /**
  42581. * A pixel value specifying a fixed width for the column or bar.
  42582. * Overrides pointWidth on the series.
  42583. *
  42584. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42585. *
  42586. * @type {number}
  42587. * @default undefined
  42588. * @since 7.0.0
  42589. * @product highcharts highstock gantt
  42590. * @apioption series.column.data.pointWidth
  42591. */
  42592. /**
  42593. * The minimal height for a column or width for a bar. By default,
  42594. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  42595. * set the minimal point length to a pixel value like 3\. In stacked
  42596. * column charts, minPointLength might not be respected for tightly
  42597. * packed values.
  42598. *
  42599. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  42600. * Zero base value
  42601. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  42602. * Positive and negative close to zero values
  42603. *
  42604. * @product highcharts highstock gantt
  42605. *
  42606. * @private
  42607. */
  42608. minPointLength: 0,
  42609. /**
  42610. * When the series contains less points than the crop threshold, all
  42611. * points are drawn, event if the points fall outside the visible plot
  42612. * area at the current zoom. The advantage of drawing all points
  42613. * (including markers and columns), is that animation is performed on
  42614. * updates. On the other hand, when the series contains more points than
  42615. * the crop threshold, the series data is cropped to only contain points
  42616. * that fall within the plot area. The advantage of cropping away
  42617. * invisible points is to increase performance on large series.
  42618. *
  42619. * @product highcharts highstock gantt
  42620. *
  42621. * @private
  42622. */
  42623. cropThreshold: 50,
  42624. /**
  42625. * The X axis range that each point is valid for. This determines the
  42626. * width of the column. On a categorized axis, the range will be 1
  42627. * by default (one category unit). On linear and datetime axes, the
  42628. * range will be computed as the distance between the two closest data
  42629. * points.
  42630. *
  42631. * The default `null` means it is computed automatically, but this
  42632. * option can be used to override the automatic value.
  42633. *
  42634. * This option is set by default to 1 if data sorting is enabled.
  42635. *
  42636. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  42637. * Set the point range to one day on a data set with one week
  42638. * between the points
  42639. *
  42640. * @type {number|null}
  42641. * @since 2.3
  42642. * @product highcharts highstock gantt
  42643. *
  42644. * @private
  42645. */
  42646. pointRange: null,
  42647. states: {
  42648. /**
  42649. * Options for the hovered point. These settings override the normal
  42650. * state options when a point is moused over or touched.
  42651. *
  42652. * @extends plotOptions.series.states.hover
  42653. * @excluding halo, lineWidth, lineWidthPlus, marker
  42654. * @product highcharts highstock gantt
  42655. */
  42656. hover: {
  42657. /** @ignore-option */
  42658. halo: false,
  42659. /**
  42660. * A specific border color for the hovered point. Defaults to
  42661. * inherit the normal state border color.
  42662. *
  42663. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42664. * @product highcharts gantt
  42665. * @apioption plotOptions.column.states.hover.borderColor
  42666. */
  42667. /**
  42668. * A specific color for the hovered point.
  42669. *
  42670. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42671. * @product highcharts gantt
  42672. * @apioption plotOptions.column.states.hover.color
  42673. */
  42674. /**
  42675. * How much to brighten the point on interaction. Requires the
  42676. * main color to be defined in hex or rgb(a) format.
  42677. *
  42678. * In styled mode, the hover brightening is by default replaced
  42679. * with a fill-opacity set in the `.highcharts-point:hover`
  42680. * rule.
  42681. *
  42682. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  42683. * Brighten by 0.5
  42684. *
  42685. * @product highcharts highstock gantt
  42686. */
  42687. brightness: 0.1
  42688. },
  42689. /**
  42690. * Options for the selected point. These settings override the
  42691. * normal state options when a point is selected.
  42692. *
  42693. * @extends plotOptions.series.states.select
  42694. * @excluding halo, lineWidth, lineWidthPlus, marker
  42695. * @product highcharts highstock gantt
  42696. */
  42697. select: {
  42698. /**
  42699. * A specific color for the selected point.
  42700. *
  42701. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42702. * @default #cccccc
  42703. * @product highcharts highstock gantt
  42704. */
  42705. color: palette.neutralColor20,
  42706. /**
  42707. * A specific border color for the selected point.
  42708. *
  42709. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42710. * @default #000000
  42711. * @product highcharts highstock gantt
  42712. */
  42713. borderColor: palette.neutralColor100
  42714. }
  42715. },
  42716. dataLabels: {
  42717. align: void 0,
  42718. verticalAlign: void 0,
  42719. /**
  42720. * The y position offset of the label relative to the point in
  42721. * pixels.
  42722. *
  42723. * @type {number}
  42724. */
  42725. y: void 0
  42726. },
  42727. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  42728. /**
  42729. * @ignore-option
  42730. * @private
  42731. */
  42732. startFromThreshold: true,
  42733. stickyTracking: false,
  42734. tooltip: {
  42735. distance: 6
  42736. },
  42737. /**
  42738. * The Y axis value to serve as the base for the columns, for
  42739. * distinguishing between values above and below a threshold. If `null`,
  42740. * the columns extend from the padding Y axis minimum.
  42741. *
  42742. * @type {number|null}
  42743. * @since 2.0
  42744. * @product highcharts
  42745. *
  42746. * @private
  42747. */
  42748. threshold: 0,
  42749. /**
  42750. * The width of the border surrounding each column or bar. Defaults to
  42751. * `1` when there is room for a border, but to `0` when the columns are
  42752. * so dense that a border would cover the next column.
  42753. *
  42754. * In styled mode, the stroke width can be set with the
  42755. * `.highcharts-point` rule.
  42756. *
  42757. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42758. * 2px black border
  42759. *
  42760. * @type {number}
  42761. * @default undefined
  42762. * @product highcharts highstock gantt
  42763. * @apioption plotOptions.column.borderWidth
  42764. */
  42765. /**
  42766. * The color of the border surrounding each column or bar.
  42767. *
  42768. * In styled mode, the border stroke can be set with the
  42769. * `.highcharts-point` rule.
  42770. *
  42771. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42772. * Dark gray border
  42773. *
  42774. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42775. * @default #ffffff
  42776. * @product highcharts highstock gantt
  42777. *
  42778. * @private
  42779. */
  42780. borderColor: palette.backgroundColor
  42781. });
  42782. return ColumnSeries;
  42783. }(Series));
  42784. extend(ColumnSeries.prototype, {
  42785. cropShoulder: 0,
  42786. // When tooltip is not shared, this series (and derivatives) requires
  42787. // direct touch/hover. KD-tree does not apply.
  42788. directTouch: true,
  42789. /**
  42790. * Use a solid rectangle like the area series types
  42791. *
  42792. * @private
  42793. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  42794. *
  42795. * @param {Highcharts.Legend} legend
  42796. * The legend object
  42797. *
  42798. * @param {Highcharts.Series|Highcharts.Point} item
  42799. * The series (this) or point
  42800. */
  42801. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  42802. getSymbol: noop,
  42803. // use separate negative stacks, unlike area stacks where a negative
  42804. // point is substracted from previous (#1910)
  42805. negStacks: true,
  42806. trackerGroups: ['group', 'dataLabelsGroup']
  42807. });
  42808. SeriesRegistry.registerSeriesType('column', ColumnSeries);
  42809. /* *
  42810. *
  42811. * Export
  42812. *
  42813. * */
  42814. /* *
  42815. *
  42816. * API Declarations
  42817. *
  42818. * */
  42819. /**
  42820. * Adjusted width and x offset of the columns for grouping.
  42821. *
  42822. * @private
  42823. * @interface Highcharts.ColumnMetricsObject
  42824. */ /**
  42825. * Width of the columns.
  42826. * @name Highcharts.ColumnMetricsObject#width
  42827. * @type {number}
  42828. */ /**
  42829. * Offset of the columns.
  42830. * @name Highcharts.ColumnMetricsObject#offset
  42831. * @type {number}
  42832. */
  42833. ''; // detach doclets above
  42834. /* *
  42835. *
  42836. * API Options
  42837. *
  42838. * */
  42839. /**
  42840. * A `column` series. If the [type](#series.column.type) option is
  42841. * not specified, it is inherited from [chart.type](#chart.type).
  42842. *
  42843. * @extends series,plotOptions.column
  42844. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  42845. * lineWidth, marker, connectEnds, step
  42846. * @product highcharts highstock
  42847. * @apioption series.column
  42848. */
  42849. /**
  42850. * An array of data points for the series. For the `column` series type,
  42851. * points can be given in the following ways:
  42852. *
  42853. * 1. An array of numerical values. In this case, the numerical values will be
  42854. * interpreted as `y` options. The `x` values will be automatically
  42855. * calculated, either starting at 0 and incremented by 1, or from
  42856. * `pointStart` and `pointInterval` given in the series options. If the axis
  42857. * has categories, these will be used. Example:
  42858. * ```js
  42859. * data: [0, 5, 3, 5]
  42860. * ```
  42861. *
  42862. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42863. * `x,y`. If the first value is a string, it is applied as the name of the
  42864. * point, and the `x` value is inferred.
  42865. * ```js
  42866. * data: [
  42867. * [0, 6],
  42868. * [1, 2],
  42869. * [2, 6]
  42870. * ]
  42871. * ```
  42872. *
  42873. * 3. An array of objects with named values. The following snippet shows only a
  42874. * few settings, see the complete options set below. If the total number of
  42875. * data points exceeds the series'
  42876. * [turboThreshold](#series.column.turboThreshold), this option is not
  42877. * available.
  42878. * ```js
  42879. * data: [{
  42880. * x: 1,
  42881. * y: 9,
  42882. * name: "Point2",
  42883. * color: "#00FF00"
  42884. * }, {
  42885. * x: 1,
  42886. * y: 6,
  42887. * name: "Point1",
  42888. * color: "#FF00FF"
  42889. * }]
  42890. * ```
  42891. *
  42892. * @sample {highcharts} highcharts/chart/reflow-true/
  42893. * Numerical values
  42894. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42895. * Arrays of numeric x and y
  42896. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42897. * Arrays of datetime x and y
  42898. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42899. * Arrays of point.name and y
  42900. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42901. * Config objects
  42902. *
  42903. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42904. * @extends series.line.data
  42905. * @excluding marker
  42906. * @product highcharts highstock
  42907. * @apioption series.column.data
  42908. */
  42909. /**
  42910. * The color of the border surrounding the column or bar.
  42911. *
  42912. * In styled mode, the border stroke can be set with the `.highcharts-point`
  42913. * rule.
  42914. *
  42915. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42916. * Dark gray border
  42917. *
  42918. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42919. * @product highcharts highstock
  42920. * @apioption series.column.data.borderColor
  42921. */
  42922. /**
  42923. * The width of the border surrounding the column or bar.
  42924. *
  42925. * In styled mode, the stroke width can be set with the `.highcharts-point`
  42926. * rule.
  42927. *
  42928. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42929. * 2px black border
  42930. *
  42931. * @type {number}
  42932. * @product highcharts highstock
  42933. * @apioption series.column.data.borderWidth
  42934. */
  42935. /**
  42936. * A name for the dash style to use for the column or bar. Overrides
  42937. * dashStyle on the series.
  42938. *
  42939. * In styled mode, the stroke dash-array can be set with the same classes as
  42940. * listed under [data.color](#series.column.data.color).
  42941. *
  42942. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  42943. *
  42944. * @type {Highcharts.DashStyleValue}
  42945. * @apioption series.column.data.dashStyle
  42946. */
  42947. /**
  42948. * A pixel value specifying a fixed width for the column or bar. Overrides
  42949. * pointWidth on the series. The width effects the dimension that is not based
  42950. * on the point value.
  42951. *
  42952. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42953. *
  42954. * @type {number}
  42955. * @apioption series.column.data.pointWidth
  42956. */
  42957. /**
  42958. * @excluding halo, lineWidth, lineWidthPlus, marker
  42959. * @product highcharts highstock
  42960. * @apioption series.column.states.hover
  42961. */
  42962. /**
  42963. * @excluding halo, lineWidth, lineWidthPlus, marker
  42964. * @product highcharts highstock
  42965. * @apioption series.column.states.select
  42966. */
  42967. ''; // includes above doclets in transpilat
  42968. return ColumnSeries;
  42969. });
  42970. _registerModule(_modules, 'Series/Bar/BarSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  42971. /* *
  42972. *
  42973. * (c) 2010-2021 Torstein Honsi
  42974. *
  42975. * License: www.highcharts.com/license
  42976. *
  42977. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42978. *
  42979. * */
  42980. var __extends = (this && this.__extends) || (function () {
  42981. var extendStatics = function (d,
  42982. b) {
  42983. extendStatics = Object.setPrototypeOf ||
  42984. ({ __proto__: [] } instanceof Array && function (d,
  42985. b) { d.__proto__ = b; }) ||
  42986. function (d,
  42987. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42988. return extendStatics(d, b);
  42989. };
  42990. return function (d, b) {
  42991. extendStatics(d, b);
  42992. function __() { this.constructor = d; }
  42993. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42994. };
  42995. })();
  42996. var extend = U.extend,
  42997. merge = U.merge;
  42998. /* *
  42999. *
  43000. * Class
  43001. *
  43002. * */
  43003. /**
  43004. * Bar series type.
  43005. *
  43006. * @private
  43007. * @class
  43008. * @name Highcharts.seriesTypes.bar
  43009. *
  43010. * @augments Highcharts.Series
  43011. */
  43012. var BarSeries = /** @class */ (function (_super) {
  43013. __extends(BarSeries, _super);
  43014. function BarSeries() {
  43015. /* *
  43016. *
  43017. * Static Properties
  43018. *
  43019. * */
  43020. var _this = _super !== null && _super.apply(this,
  43021. arguments) || this;
  43022. /* *
  43023. *
  43024. * Properties
  43025. *
  43026. * */
  43027. _this.data = void 0;
  43028. _this.options = void 0;
  43029. _this.points = void 0;
  43030. return _this;
  43031. }
  43032. /**
  43033. * A bar series is a special type of column series where the columns are
  43034. * horizontal.
  43035. *
  43036. * @sample highcharts/demo/bar-basic/
  43037. * Bar chart
  43038. *
  43039. * @extends plotOptions.column
  43040. * @product highcharts
  43041. * @optionparent plotOptions.bar
  43042. */
  43043. BarSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  43044. // nothing here yet
  43045. });
  43046. return BarSeries;
  43047. }(ColumnSeries));
  43048. extend(BarSeries.prototype, {
  43049. inverted: true
  43050. });
  43051. SeriesRegistry.registerSeriesType('bar', BarSeries);
  43052. /* *
  43053. *
  43054. * Default Export
  43055. *
  43056. * */
  43057. /* *
  43058. *
  43059. * API Options
  43060. *
  43061. * */
  43062. /**
  43063. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  43064. * it is inherited from [chart.type](#chart.type).
  43065. *
  43066. * @extends series,plotOptions.bar
  43067. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  43068. * linecap, lineWidth, marker, connectEnds, step
  43069. * @product highcharts
  43070. * @apioption series.bar
  43071. */
  43072. /**
  43073. * An array of data points for the series. For the `bar` series type,
  43074. * points can be given in the following ways:
  43075. *
  43076. * 1. An array of numerical values. In this case, the numerical values will be
  43077. * interpreted as `y` options. The `x` values will be automatically
  43078. * calculated, either starting at 0 and incremented by 1, or from
  43079. * `pointStart` and `pointInterval` given in the series options. If the axis
  43080. * has categories, these will be used. Example:
  43081. * ```js
  43082. * data: [0, 5, 3, 5]
  43083. * ```
  43084. *
  43085. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43086. * `x,y`. If the first value is a string, it is applied as the name of the
  43087. * point, and the `x` value is inferred.
  43088. * ```js
  43089. * data: [
  43090. * [0, 5],
  43091. * [1, 10],
  43092. * [2, 3]
  43093. * ]
  43094. * ```
  43095. *
  43096. * 3. An array of objects with named values. The following snippet shows only a
  43097. * few settings, see the complete options set below. If the total number of
  43098. * data points exceeds the series'
  43099. * [turboThreshold](#series.bar.turboThreshold), this option is not
  43100. * available.
  43101. * ```js
  43102. * data: [{
  43103. * x: 1,
  43104. * y: 1,
  43105. * name: "Point2",
  43106. * color: "#00FF00"
  43107. * }, {
  43108. * x: 1,
  43109. * y: 10,
  43110. * name: "Point1",
  43111. * color: "#FF00FF"
  43112. * }]
  43113. * ```
  43114. *
  43115. * @sample {highcharts} highcharts/chart/reflow-true/
  43116. * Numerical values
  43117. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43118. * Arrays of numeric x and y
  43119. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43120. * Arrays of datetime x and y
  43121. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43122. * Arrays of point.name and y
  43123. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43124. * Config objects
  43125. *
  43126. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43127. * @extends series.column.data
  43128. * @product highcharts
  43129. * @apioption series.bar.data
  43130. */
  43131. /**
  43132. * @excluding halo,lineWidth,lineWidthPlus,marker
  43133. * @product highcharts highstock
  43134. * @apioption series.bar.states.hover
  43135. */
  43136. /**
  43137. * @excluding halo,lineWidth,lineWidthPlus,marker
  43138. * @product highcharts highstock
  43139. * @apioption series.bar.states.select
  43140. */
  43141. ''; // gets doclets above into transpilat
  43142. return BarSeries;
  43143. });
  43144. _registerModule(_modules, 'Series/Scatter/ScatterSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Series/Line/LineSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, LineSeries, SeriesRegistry, U) {
  43145. /* *
  43146. *
  43147. * (c) 2010-2021 Torstein Honsi
  43148. *
  43149. * License: www.highcharts.com/license
  43150. *
  43151. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43152. *
  43153. * */
  43154. var __extends = (this && this.__extends) || (function () {
  43155. var extendStatics = function (d,
  43156. b) {
  43157. extendStatics = Object.setPrototypeOf ||
  43158. ({ __proto__: [] } instanceof Array && function (d,
  43159. b) { d.__proto__ = b; }) ||
  43160. function (d,
  43161. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43162. return extendStatics(d, b);
  43163. };
  43164. return function (d, b) {
  43165. extendStatics(d, b);
  43166. function __() { this.constructor = d; }
  43167. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43168. };
  43169. })();
  43170. var addEvent = U.addEvent,
  43171. extend = U.extend,
  43172. merge = U.merge;
  43173. /* *
  43174. *
  43175. * Class
  43176. *
  43177. * */
  43178. /**
  43179. * Scatter series type.
  43180. *
  43181. * @private
  43182. */
  43183. var ScatterSeries = /** @class */ (function (_super) {
  43184. __extends(ScatterSeries, _super);
  43185. function ScatterSeries() {
  43186. var _this = _super !== null && _super.apply(this,
  43187. arguments) || this;
  43188. /* *
  43189. *
  43190. * Properties
  43191. *
  43192. * */
  43193. _this.data = void 0;
  43194. _this.options = void 0;
  43195. _this.points = void 0;
  43196. return _this;
  43197. /* eslint-enable valid-jsdoc */
  43198. }
  43199. /* *
  43200. *
  43201. * Functions
  43202. *
  43203. * */
  43204. /* eslint-disable valid-jsdoc */
  43205. /**
  43206. * Optionally add the jitter effect.
  43207. * @private
  43208. */
  43209. ScatterSeries.prototype.applyJitter = function () {
  43210. var series = this,
  43211. jitter = this.options.jitter,
  43212. len = this.points.length;
  43213. /**
  43214. * Return a repeatable, pseudo-random number based on an integer
  43215. * seed.
  43216. * @private
  43217. */
  43218. function unrandom(seed) {
  43219. var rand = Math.sin(seed) * 10000;
  43220. return rand - Math.floor(rand);
  43221. }
  43222. if (jitter) {
  43223. this.points.forEach(function (point, i) {
  43224. ['x', 'y'].forEach(function (dim, j) {
  43225. var axis,
  43226. plotProp = 'plot' + dim.toUpperCase(),
  43227. min,
  43228. max,
  43229. translatedJitter;
  43230. if (jitter[dim] && !point.isNull) {
  43231. axis = series[dim + 'Axis'];
  43232. translatedJitter =
  43233. jitter[dim] * axis.transA;
  43234. if (axis && !axis.isLog) {
  43235. // Identify the outer bounds of the jitter range
  43236. min = Math.max(0, point[plotProp] - translatedJitter);
  43237. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  43238. // Find a random position within this range
  43239. point[plotProp] = min +
  43240. (max - min) * unrandom(i + j * len);
  43241. // Update clientX for the tooltip k-d-tree
  43242. if (dim === 'x') {
  43243. point.clientX = point.plotX;
  43244. }
  43245. }
  43246. }
  43247. });
  43248. });
  43249. }
  43250. };
  43251. /**
  43252. * @private
  43253. * @function Highcharts.seriesTypes.scatter#drawGraph
  43254. */
  43255. ScatterSeries.prototype.drawGraph = function () {
  43256. if (this.options.lineWidth) {
  43257. _super.prototype.drawGraph.call(this);
  43258. }
  43259. else if (this.graph) {
  43260. this.graph = this.graph.destroy();
  43261. }
  43262. };
  43263. /**
  43264. * A scatter plot uses cartesian coordinates to display values for two
  43265. * variables for a set of data.
  43266. *
  43267. * @sample {highcharts} highcharts/demo/scatter/
  43268. * Scatter plot
  43269. *
  43270. * @extends plotOptions.line
  43271. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  43272. * @product highcharts highstock
  43273. * @optionparent plotOptions.scatter
  43274. */
  43275. ScatterSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  43276. /**
  43277. * The width of the line connecting the data points.
  43278. *
  43279. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  43280. * 0 by default
  43281. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  43282. * 1px
  43283. *
  43284. * @product highcharts highstock
  43285. */
  43286. lineWidth: 0,
  43287. findNearestPointBy: 'xy',
  43288. /**
  43289. * Apply a jitter effect for the rendered markers. When plotting
  43290. * discrete values, a little random noise may help telling the points
  43291. * apart. The jitter setting applies a random displacement of up to `n`
  43292. * axis units in either direction. So for example on a horizontal X
  43293. * axis, setting the `jitter.x` to 0.24 will render the point in a
  43294. * random position between 0.24 units to the left and 0.24 units to the
  43295. * right of the true axis position. On a category axis, setting it to
  43296. * 0.5 will fill up the bin and make the data appear continuous.
  43297. *
  43298. * When rendered on top of a box plot or a column series, a jitter value
  43299. * of 0.24 will correspond to the underlying series' default
  43300. * [groupPadding](
  43301. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  43302. * and [pointPadding](
  43303. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  43304. * settings.
  43305. *
  43306. * @sample {highcharts} highcharts/series-scatter/jitter
  43307. * Jitter on a scatter plot
  43308. *
  43309. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  43310. * Jittered scatter plot on top of a box plot
  43311. *
  43312. * @product highcharts highstock
  43313. * @since 7.0.2
  43314. */
  43315. jitter: {
  43316. /**
  43317. * The maximal X offset for the random jitter effect.
  43318. */
  43319. x: 0,
  43320. /**
  43321. * The maximal Y offset for the random jitter effect.
  43322. */
  43323. y: 0
  43324. },
  43325. marker: {
  43326. enabled: true // Overrides auto-enabling in line series (#3647)
  43327. },
  43328. /**
  43329. * Sticky tracking of mouse events. When true, the `mouseOut` event
  43330. * on a series isn't triggered until the mouse moves over another
  43331. * series, or out of the plot area. When false, the `mouseOut` event on
  43332. * a series is triggered when the mouse leaves the area around the
  43333. * series' graph or markers. This also implies the tooltip. When
  43334. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  43335. * will be hidden when moving the mouse between series.
  43336. *
  43337. * @type {boolean}
  43338. * @default false
  43339. * @product highcharts highstock
  43340. * @apioption plotOptions.scatter.stickyTracking
  43341. */
  43342. /**
  43343. * A configuration object for the tooltip rendering of each single
  43344. * series. Properties are inherited from [tooltip](#tooltip).
  43345. * Overridable properties are `headerFormat`, `pointFormat`,
  43346. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  43347. * series, in a scatter plot the series.name by default shows in the
  43348. * headerFormat and point.x and point.y in the pointFormat.
  43349. *
  43350. * @product highcharts highstock
  43351. */
  43352. tooltip: {
  43353. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  43354. '<span style="font-size: 10px"> {series.name}</span><br/>',
  43355. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  43356. }
  43357. });
  43358. return ScatterSeries;
  43359. }(LineSeries));
  43360. extend(ScatterSeries.prototype, {
  43361. drawTracker: ColumnSeries.prototype.drawTracker,
  43362. sorted: false,
  43363. requireSorting: false,
  43364. noSharedTooltip: true,
  43365. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  43366. takeOrdinalPosition: false // #2342
  43367. });
  43368. /* *
  43369. *
  43370. * Events
  43371. *
  43372. * */
  43373. /* eslint-disable no-invalid-this */
  43374. addEvent(ScatterSeries, 'afterTranslate', function () {
  43375. this.applyJitter();
  43376. });
  43377. SeriesRegistry.registerSeriesType('scatter', ScatterSeries);
  43378. /* *
  43379. *
  43380. * Default Export
  43381. *
  43382. * */
  43383. /* *
  43384. *
  43385. * API Options
  43386. *
  43387. * */
  43388. /**
  43389. * A `scatter` series. If the [type](#series.scatter.type) option is
  43390. * not specified, it is inherited from [chart.type](#chart.type).
  43391. *
  43392. * @extends series,plotOptions.scatter
  43393. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  43394. * @product highcharts highstock
  43395. * @apioption series.scatter
  43396. */
  43397. /**
  43398. * An array of data points for the series. For the `scatter` series
  43399. * type, points can be given in the following ways:
  43400. *
  43401. * 1. An array of numerical values. In this case, the numerical values will be
  43402. * interpreted as `y` options. The `x` values will be automatically
  43403. * calculated, either starting at 0 and incremented by 1, or from
  43404. * `pointStart` and `pointInterval` given in the series options. If the axis
  43405. * has categories, these will be used. Example:
  43406. * ```js
  43407. * data: [0, 5, 3, 5]
  43408. * ```
  43409. *
  43410. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43411. * `x,y`. If the first value is a string, it is applied as the name of the
  43412. * point, and the `x` value is inferred.
  43413. * ```js
  43414. * data: [
  43415. * [0, 0],
  43416. * [1, 8],
  43417. * [2, 9]
  43418. * ]
  43419. * ```
  43420. *
  43421. * 3. An array of objects with named values. The following snippet shows only a
  43422. * few settings, see the complete options set below. If the total number of
  43423. * data points exceeds the series'
  43424. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  43425. * available.
  43426. * ```js
  43427. * data: [{
  43428. * x: 1,
  43429. * y: 2,
  43430. * name: "Point2",
  43431. * color: "#00FF00"
  43432. * }, {
  43433. * x: 1,
  43434. * y: 4,
  43435. * name: "Point1",
  43436. * color: "#FF00FF"
  43437. * }]
  43438. * ```
  43439. *
  43440. * @sample {highcharts} highcharts/chart/reflow-true/
  43441. * Numerical values
  43442. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43443. * Arrays of numeric x and y
  43444. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43445. * Arrays of datetime x and y
  43446. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43447. * Arrays of point.name and y
  43448. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43449. * Config objects
  43450. *
  43451. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43452. * @extends series.line.data
  43453. * @product highcharts highstock
  43454. * @apioption series.scatter.data
  43455. */
  43456. ''; // adds doclets above to transpilat
  43457. return ScatterSeries;
  43458. });
  43459. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (H, Series, U) {
  43460. /* *
  43461. *
  43462. * (c) 2010-2021 Torstein Honsi
  43463. *
  43464. * License: www.highcharts.com/license
  43465. *
  43466. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43467. *
  43468. * */
  43469. /**
  43470. * @private
  43471. * @interface Highcharts.RadianAngles
  43472. */ /**
  43473. * @name Highcharts.RadianAngles#end
  43474. * @type {number}
  43475. */ /**
  43476. * @name Highcharts.RadianAngles#start
  43477. * @type {number}
  43478. */
  43479. var isNumber = U.isNumber,
  43480. pick = U.pick,
  43481. relativeLength = U.relativeLength;
  43482. var deg2rad = H.deg2rad;
  43483. /* eslint-disable valid-jsdoc */
  43484. /**
  43485. * @private
  43486. * @mixin Highcharts.CenteredSeriesMixin
  43487. */
  43488. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  43489. /**
  43490. * Get the center of the pie based on the size and center options relative
  43491. * to the plot area. Borrowed by the polar and gauge series types.
  43492. *
  43493. * @private
  43494. * @function Highcharts.CenteredSeriesMixin.getCenter
  43495. *
  43496. * @return {Array<number>}
  43497. */
  43498. getCenter: function () {
  43499. var options = this.options,
  43500. chart = this.chart,
  43501. slicingRoom = 2 * (options.slicedOffset || 0),
  43502. handleSlicingRoom,
  43503. plotWidth = chart.plotWidth - 2 * slicingRoom,
  43504. plotHeight = chart.plotHeight - 2 * slicingRoom,
  43505. centerOption = options.center,
  43506. smallestSize = Math.min(plotWidth,
  43507. plotHeight),
  43508. size = options.size,
  43509. innerSize = options.innerSize || 0,
  43510. positions,
  43511. i,
  43512. value;
  43513. if (typeof size === 'string') {
  43514. size = parseFloat(size);
  43515. }
  43516. if (typeof innerSize === 'string') {
  43517. innerSize = parseFloat(innerSize);
  43518. }
  43519. positions = [
  43520. pick(centerOption[0], '50%'),
  43521. pick(centerOption[1], '50%'),
  43522. // Prevent from negative values
  43523. pick(size && size < 0 ? void 0 : options.size, '100%'),
  43524. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  43525. ];
  43526. // No need for inner size in angular (gauges) series but still required
  43527. // for pie series
  43528. if (chart.angular && !(this instanceof Series)) {
  43529. positions[3] = 0;
  43530. }
  43531. for (i = 0; i < 4; ++i) {
  43532. value = positions[i];
  43533. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  43534. // i == 0: centerX, relative to width
  43535. // i == 1: centerY, relative to height
  43536. // i == 2: size, relative to smallestSize
  43537. // i == 3: innerSize, relative to size
  43538. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  43539. }
  43540. // innerSize cannot be larger than size (#3632)
  43541. if (positions[3] > positions[2]) {
  43542. positions[3] = positions[2];
  43543. }
  43544. return positions;
  43545. },
  43546. /**
  43547. * getStartAndEndRadians - Calculates start and end angles in radians.
  43548. * Used in series types such as pie and sunburst.
  43549. *
  43550. * @private
  43551. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  43552. *
  43553. * @param {number} [start]
  43554. * Start angle in degrees.
  43555. *
  43556. * @param {number} [end]
  43557. * Start angle in degrees.
  43558. *
  43559. * @return {Highcharts.RadianAngles}
  43560. * Returns an object containing start and end angles as radians.
  43561. */
  43562. getStartAndEndRadians: function (start, end) {
  43563. var startAngle = isNumber(start) ? start : 0, // must be a number
  43564. endAngle = ((isNumber(end) && // must be a number
  43565. end > startAngle && // must be larger than the start angle
  43566. // difference must be less than 360 degrees
  43567. (end - startAngle) < 360) ?
  43568. end :
  43569. startAngle + 360),
  43570. correction = -90;
  43571. return {
  43572. start: deg2rad * (startAngle + correction),
  43573. end: deg2rad * (endAngle + correction)
  43574. };
  43575. }
  43576. };
  43577. return centeredSeriesMixin;
  43578. });
  43579. _registerModule(_modules, 'Series/Pie/PiePoint.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, Point, U) {
  43580. /* *
  43581. *
  43582. * (c) 2010-2021 Torstein Honsi
  43583. *
  43584. * License: www.highcharts.com/license
  43585. *
  43586. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43587. *
  43588. * */
  43589. var __extends = (this && this.__extends) || (function () {
  43590. var extendStatics = function (d,
  43591. b) {
  43592. extendStatics = Object.setPrototypeOf ||
  43593. ({ __proto__: [] } instanceof Array && function (d,
  43594. b) { d.__proto__ = b; }) ||
  43595. function (d,
  43596. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43597. return extendStatics(d, b);
  43598. };
  43599. return function (d, b) {
  43600. extendStatics(d, b);
  43601. function __() { this.constructor = d; }
  43602. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43603. };
  43604. })();
  43605. var setAnimation = A.setAnimation;
  43606. var addEvent = U.addEvent,
  43607. defined = U.defined,
  43608. extend = U.extend,
  43609. isNumber = U.isNumber,
  43610. pick = U.pick,
  43611. relativeLength = U.relativeLength;
  43612. /* *
  43613. *
  43614. * Class
  43615. *
  43616. * */
  43617. var PiePoint = /** @class */ (function (_super) {
  43618. __extends(PiePoint, _super);
  43619. function PiePoint() {
  43620. /* *
  43621. *
  43622. * Properties
  43623. *
  43624. * */
  43625. var _this = _super !== null && _super.apply(this,
  43626. arguments) || this;
  43627. _this.labelDistance = void 0;
  43628. _this.options = void 0;
  43629. _this.series = void 0;
  43630. return _this;
  43631. }
  43632. /* *
  43633. *
  43634. * Functions
  43635. *
  43636. * */
  43637. /* eslint-disable valid-jsdoc */
  43638. /**
  43639. * Extendable method for getting the path of the connector between the
  43640. * data label and the pie slice.
  43641. * @private
  43642. */
  43643. PiePoint.prototype.getConnectorPath = function () {
  43644. var labelPosition = this.labelPosition,
  43645. options = this.series.options.dataLabels,
  43646. connectorShape = options.connectorShape,
  43647. predefinedShapes = this.connectorShapes;
  43648. // find out whether to use the predefined shape
  43649. if (predefinedShapes[connectorShape]) {
  43650. connectorShape = predefinedShapes[connectorShape];
  43651. }
  43652. return connectorShape.call(this, {
  43653. // pass simplified label position object for user's convenience
  43654. x: labelPosition.final.x,
  43655. y: labelPosition.final.y,
  43656. alignment: labelPosition.alignment
  43657. }, labelPosition.connectorPosition, options);
  43658. };
  43659. /**
  43660. * @private
  43661. */
  43662. PiePoint.prototype.getTranslate = function () {
  43663. return this.sliced ? this.slicedTranslation : {
  43664. translateX: 0,
  43665. translateY: 0
  43666. };
  43667. };
  43668. /**
  43669. * @private
  43670. */
  43671. PiePoint.prototype.haloPath = function (size) {
  43672. var shapeArgs = this.shapeArgs;
  43673. return this.sliced || !this.visible ?
  43674. [] :
  43675. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  43676. // Substract 1px to ensure the background is not bleeding
  43677. // through between the halo and the slice (#7495).
  43678. innerR: shapeArgs.r - 1,
  43679. start: shapeArgs.start,
  43680. end: shapeArgs.end
  43681. });
  43682. };
  43683. /**
  43684. * Initialize the pie slice.
  43685. * @private
  43686. */
  43687. PiePoint.prototype.init = function () {
  43688. Point.prototype.init.apply(this, arguments);
  43689. var point = this,
  43690. toggleSlice;
  43691. point.name = pick(point.name, 'Slice');
  43692. // add event listener for select
  43693. toggleSlice = function (e) {
  43694. point.slice(e.type === 'select');
  43695. };
  43696. addEvent(point, 'select', toggleSlice);
  43697. addEvent(point, 'unselect', toggleSlice);
  43698. return point;
  43699. };
  43700. /**
  43701. * Negative points are not valid (#1530, #3623, #5322)
  43702. * @private
  43703. */
  43704. PiePoint.prototype.isValid = function () {
  43705. return isNumber(this.y) && this.y >= 0;
  43706. };
  43707. /**
  43708. * Toggle the visibility of the pie slice.
  43709. * @private
  43710. *
  43711. * @param {boolean} vis
  43712. * Whether to show the slice or not. If undefined, the visibility is
  43713. * toggled.
  43714. */
  43715. PiePoint.prototype.setVisible = function (vis, redraw) {
  43716. var point = this,
  43717. series = point.series,
  43718. chart = series.chart,
  43719. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  43720. redraw = pick(redraw, ignoreHiddenPoint);
  43721. if (vis !== point.visible) {
  43722. // If called without an argument, toggle visibility
  43723. point.visible = point.options.visible = vis =
  43724. typeof vis === 'undefined' ? !point.visible : vis;
  43725. // update userOptions.data
  43726. series.options.data[series.data.indexOf(point)] =
  43727. point.options;
  43728. // Show and hide associated elements. This is performed
  43729. // regardless of redraw or not, because chart.redraw only
  43730. // handles full series.
  43731. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  43732. if (point[key]) {
  43733. point[key][vis ? 'show' : 'hide'](vis);
  43734. }
  43735. });
  43736. if (point.legendItem) {
  43737. chart.legend.colorizeItem(point, vis);
  43738. }
  43739. // #4170, hide halo after hiding point
  43740. if (!vis && point.state === 'hover') {
  43741. point.setState('');
  43742. }
  43743. // Handle ignore hidden slices
  43744. if (ignoreHiddenPoint) {
  43745. series.isDirty = true;
  43746. }
  43747. if (redraw) {
  43748. chart.redraw();
  43749. }
  43750. }
  43751. };
  43752. /**
  43753. * Set or toggle whether the slice is cut out from the pie.
  43754. * @private
  43755. *
  43756. * @param {boolean} sliced
  43757. * When undefined, the slice state is toggled.
  43758. *
  43759. * @param {boolean} redraw
  43760. * Whether to redraw the chart. True by default.
  43761. *
  43762. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  43763. * Animation options.
  43764. */
  43765. PiePoint.prototype.slice = function (sliced, redraw, animation) {
  43766. var point = this,
  43767. series = point.series,
  43768. chart = series.chart;
  43769. setAnimation(animation, chart);
  43770. // redraw is true by default
  43771. redraw = pick(redraw, true);
  43772. /**
  43773. * Pie series only. Whether to display a slice offset from the
  43774. * center.
  43775. * @name Highcharts.Point#sliced
  43776. * @type {boolean|undefined}
  43777. */
  43778. // if called without an argument, toggle
  43779. point.sliced = point.options.sliced = sliced =
  43780. defined(sliced) ? sliced : !point.sliced;
  43781. // update userOptions.data
  43782. series.options.data[series.data.indexOf(point)] =
  43783. point.options;
  43784. if (point.graphic) {
  43785. point.graphic.animate(this.getTranslate());
  43786. }
  43787. if (point.shadowGroup) {
  43788. point.shadowGroup.animate(this.getTranslate());
  43789. }
  43790. };
  43791. return PiePoint;
  43792. }(Point));
  43793. extend(PiePoint.prototype, {
  43794. connectorShapes: {
  43795. // only one available before v7.0.0
  43796. fixedOffset: function (labelPosition, connectorPosition, options) {
  43797. var breakAt = connectorPosition.breakAt,
  43798. touchingSliceAt = connectorPosition.touchingSliceAt,
  43799. lineSegment = options.softConnector ? [
  43800. 'C',
  43801. // 1st control point (of the curve)
  43802. labelPosition.x +
  43803. // 5 gives the connector a little horizontal bend
  43804. (labelPosition.alignment === 'left' ? -5 : 5),
  43805. labelPosition.y,
  43806. 2 * breakAt.x - touchingSliceAt.x,
  43807. 2 * breakAt.y - touchingSliceAt.y,
  43808. breakAt.x,
  43809. breakAt.y //
  43810. ] : [
  43811. 'L',
  43812. breakAt.x,
  43813. breakAt.y
  43814. ];
  43815. // assemble the path
  43816. return ([
  43817. ['M', labelPosition.x, labelPosition.y],
  43818. lineSegment,
  43819. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43820. ]);
  43821. },
  43822. straight: function (labelPosition, connectorPosition) {
  43823. var touchingSliceAt = connectorPosition.touchingSliceAt;
  43824. // direct line to the slice
  43825. return [
  43826. ['M', labelPosition.x, labelPosition.y],
  43827. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43828. ];
  43829. },
  43830. crookedLine: function (labelPosition, connectorPosition, options) {
  43831. var touchingSliceAt = connectorPosition.touchingSliceAt,
  43832. series = this.series,
  43833. pieCenterX = series.center[0],
  43834. plotWidth = series.chart.plotWidth,
  43835. plotLeft = series.chart.plotLeft,
  43836. alignment = labelPosition.alignment,
  43837. radius = this.shapeArgs.r,
  43838. crookDistance = relativeLength(// % to fraction
  43839. options.crookDistance, 1),
  43840. crookX = alignment === 'left' ?
  43841. pieCenterX + radius + (plotWidth + plotLeft -
  43842. pieCenterX - radius) * (1 - crookDistance) :
  43843. plotLeft + (pieCenterX - radius) * crookDistance,
  43844. segmentWithCrook = [
  43845. 'L',
  43846. crookX,
  43847. labelPosition.y
  43848. ],
  43849. useCrook = true;
  43850. // crookedLine formula doesn't make sense if the path overlaps
  43851. // the label - use straight line instead in that case
  43852. if (alignment === 'left' ?
  43853. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  43854. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  43855. useCrook = false;
  43856. }
  43857. // assemble the path
  43858. var path = [
  43859. ['M',
  43860. labelPosition.x,
  43861. labelPosition.y]
  43862. ];
  43863. if (useCrook) {
  43864. path.push(segmentWithCrook);
  43865. }
  43866. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  43867. return path;
  43868. }
  43869. }
  43870. });
  43871. /* *
  43872. *
  43873. * Default Export
  43874. *
  43875. * */
  43876. return PiePoint;
  43877. });
  43878. _registerModule(_modules, 'Series/Pie/PieSeries.js', [_modules['Mixins/CenteredSeries.js'], _modules['Series/Column/ColumnSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Series/Pie/PiePoint.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/Symbols.js'], _modules['Core/Utilities.js']], function (CenteredSeriesMixin, ColumnSeries, H, LegendSymbolMixin, palette, PiePoint, Series, SeriesRegistry, Symbols, U) {
  43879. /* *
  43880. *
  43881. * (c) 2010-2021 Torstein Honsi
  43882. *
  43883. * License: www.highcharts.com/license
  43884. *
  43885. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43886. *
  43887. * */
  43888. var __extends = (this && this.__extends) || (function () {
  43889. var extendStatics = function (d,
  43890. b) {
  43891. extendStatics = Object.setPrototypeOf ||
  43892. ({ __proto__: [] } instanceof Array && function (d,
  43893. b) { d.__proto__ = b; }) ||
  43894. function (d,
  43895. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43896. return extendStatics(d, b);
  43897. };
  43898. return function (d, b) {
  43899. extendStatics(d, b);
  43900. function __() { this.constructor = d; }
  43901. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43902. };
  43903. })();
  43904. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  43905. var noop = H.noop;
  43906. var clamp = U.clamp,
  43907. extend = U.extend,
  43908. fireEvent = U.fireEvent,
  43909. merge = U.merge,
  43910. pick = U.pick,
  43911. relativeLength = U.relativeLength;
  43912. /* *
  43913. *
  43914. * Class
  43915. *
  43916. * */
  43917. /**
  43918. * Pie series type.
  43919. *
  43920. * @private
  43921. * @class
  43922. * @name Highcharts.seriesTypes.pie
  43923. *
  43924. * @augments Highcharts.Series
  43925. */
  43926. var PieSeries = /** @class */ (function (_super) {
  43927. __extends(PieSeries, _super);
  43928. function PieSeries() {
  43929. /* *
  43930. *
  43931. * Static Properties
  43932. *
  43933. * */
  43934. var _this = _super !== null && _super.apply(this,
  43935. arguments) || this;
  43936. /* *
  43937. *
  43938. * Properties
  43939. *
  43940. * */
  43941. _this.center = void 0;
  43942. _this.data = void 0;
  43943. _this.maxLabelDistance = void 0;
  43944. _this.options = void 0;
  43945. _this.points = void 0;
  43946. return _this;
  43947. /* eslint-enable valid-jsdoc */
  43948. }
  43949. /* *
  43950. *
  43951. * Functions
  43952. *
  43953. * */
  43954. /* eslint-disable valid-jsdoc */
  43955. /**
  43956. * Animates the pies in.
  43957. * @private
  43958. */
  43959. PieSeries.prototype.animate = function (init) {
  43960. var series = this,
  43961. points = series.points,
  43962. startAngleRad = series.startAngleRad;
  43963. if (!init) {
  43964. points.forEach(function (point) {
  43965. var graphic = point.graphic,
  43966. args = point.shapeArgs;
  43967. if (graphic && args) {
  43968. // start values
  43969. graphic.attr({
  43970. // animate from inner radius (#779)
  43971. r: pick(point.startR, (series.center && series.center[3] / 2)),
  43972. start: startAngleRad,
  43973. end: startAngleRad
  43974. });
  43975. // animate
  43976. graphic.animate({
  43977. r: args.r,
  43978. start: args.start,
  43979. end: args.end
  43980. }, series.options.animation);
  43981. }
  43982. });
  43983. }
  43984. };
  43985. /**
  43986. * Called internally to draw auxiliary graph in pie-like series in
  43987. * situtation when the default graph is not sufficient enough to present
  43988. * the data well. Auxiliary graph is saved in the same object as
  43989. * regular graph.
  43990. * @private
  43991. */
  43992. PieSeries.prototype.drawEmpty = function () {
  43993. var centerX,
  43994. centerY,
  43995. start = this.startAngleRad,
  43996. end = this.endAngleRad,
  43997. options = this.options;
  43998. // Draw auxiliary graph if there're no visible points.
  43999. if (this.total === 0 && this.center) {
  44000. centerX = this.center[0];
  44001. centerY = this.center[1];
  44002. if (!this.graph) {
  44003. this.graph = this.chart.renderer
  44004. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  44005. .addClass('highcharts-empty-series')
  44006. .add(this.group);
  44007. }
  44008. this.graph.attr({
  44009. d: Symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  44010. start: start,
  44011. end: end,
  44012. innerR: this.center[3] / 2
  44013. })
  44014. });
  44015. if (!this.chart.styledMode) {
  44016. this.graph.attr({
  44017. 'stroke-width': options.borderWidth,
  44018. fill: options.fillColor || 'none',
  44019. stroke: options.color || palette.neutralColor20
  44020. });
  44021. }
  44022. }
  44023. else if (this.graph) { // Destroy the graph object.
  44024. this.graph = this.graph.destroy();
  44025. }
  44026. };
  44027. /**
  44028. * Slices in pie chart are initialized in DOM, but it's shapes and
  44029. * animations are normally run in `drawPoints()`.
  44030. * @private
  44031. */
  44032. PieSeries.prototype.drawPoints = function () {
  44033. var renderer = this.chart.renderer;
  44034. this.points.forEach(function (point) {
  44035. // When updating a series between 2d and 3d or cartesian and
  44036. // polar, the shape type changes.
  44037. if (point.graphic && point.hasNewShapeType()) {
  44038. point.graphic = point.graphic.destroy();
  44039. }
  44040. if (!point.graphic) {
  44041. point.graphic = renderer[point.shapeType](point.shapeArgs)
  44042. .add(point.series.group);
  44043. point.delayedRendering = true;
  44044. }
  44045. });
  44046. };
  44047. /**
  44048. * Extend the generatePoints method by adding total and percentage
  44049. * properties to each point
  44050. * @private
  44051. */
  44052. PieSeries.prototype.generatePoints = function () {
  44053. _super.prototype.generatePoints.call(this);
  44054. this.updateTotals();
  44055. };
  44056. /**
  44057. * Utility for getting the x value from a given y, used for
  44058. * anticollision logic in data labels. Added point for using specific
  44059. * points' label distance.
  44060. * @private
  44061. */
  44062. PieSeries.prototype.getX = function (y, left, point) {
  44063. var center = this.center,
  44064. // Variable pie has individual radius
  44065. radius = this.radii ?
  44066. this.radii[point.index] || 0 :
  44067. center[2] / 2,
  44068. angle,
  44069. x;
  44070. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  44071. x = center[0] +
  44072. (left ? -1 : 1) *
  44073. (Math.cos(angle) * (radius + point.labelDistance)) +
  44074. (point.labelDistance > 0 ?
  44075. (left ? -1 : 1) * this.options.dataLabels.padding :
  44076. 0);
  44077. return x;
  44078. };
  44079. /**
  44080. * Define hasData function for non-cartesian series. Returns true if the
  44081. * series has points at all.
  44082. * @private
  44083. */
  44084. PieSeries.prototype.hasData = function () {
  44085. return !!this.processedXData.length; // != 0
  44086. };
  44087. /**
  44088. * Draw the data points
  44089. * @private
  44090. */
  44091. PieSeries.prototype.redrawPoints = function () {
  44092. var series = this,
  44093. chart = series.chart,
  44094. renderer = chart.renderer,
  44095. groupTranslation,
  44096. graphic,
  44097. pointAttr,
  44098. shapeArgs,
  44099. shadow = series.options.shadow;
  44100. this.drawEmpty();
  44101. if (shadow && !series.shadowGroup && !chart.styledMode) {
  44102. series.shadowGroup = renderer
  44103. .g('shadow')
  44104. .attr({ zIndex: -1 })
  44105. .add(series.group);
  44106. }
  44107. // draw the slices
  44108. series.points.forEach(function (point) {
  44109. var animateTo = {};
  44110. graphic = point.graphic;
  44111. if (!point.isNull && graphic) {
  44112. var shadowGroup = void 0;
  44113. shapeArgs = point.shapeArgs;
  44114. // If the point is sliced, use special translation, else use
  44115. // plot area translation
  44116. groupTranslation = point.getTranslate();
  44117. if (!chart.styledMode) {
  44118. // Put the shadow behind all points
  44119. shadowGroup = point.shadowGroup;
  44120. if (shadow && !shadowGroup) {
  44121. shadowGroup = point.shadowGroup = renderer
  44122. .g('shadow')
  44123. .add(series.shadowGroup);
  44124. }
  44125. if (shadowGroup) {
  44126. shadowGroup.attr(groupTranslation);
  44127. }
  44128. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  44129. }
  44130. // Draw the slice
  44131. if (!point.delayedRendering) {
  44132. graphic
  44133. .setRadialReference(series.center);
  44134. if (!chart.styledMode) {
  44135. merge(true, animateTo, pointAttr);
  44136. }
  44137. merge(true, animateTo, shapeArgs, groupTranslation);
  44138. graphic.animate(animateTo);
  44139. }
  44140. else {
  44141. graphic
  44142. .setRadialReference(series.center)
  44143. .attr(shapeArgs)
  44144. .attr(groupTranslation);
  44145. if (!chart.styledMode) {
  44146. graphic
  44147. .attr(pointAttr)
  44148. .attr({ 'stroke-linejoin': 'round' })
  44149. .shadow(shadow, shadowGroup);
  44150. }
  44151. point.delayedRendering = false;
  44152. }
  44153. graphic.attr({
  44154. visibility: point.visible ? 'inherit' : 'hidden'
  44155. });
  44156. graphic.addClass(point.getClassName(), true);
  44157. }
  44158. else if (graphic) {
  44159. point.graphic = graphic.destroy();
  44160. }
  44161. });
  44162. };
  44163. /**
  44164. * Utility for sorting data labels.
  44165. * @private
  44166. */
  44167. PieSeries.prototype.sortByAngle = function (points, sign) {
  44168. points.sort(function (a, b) {
  44169. return ((typeof a.angle !== 'undefined') &&
  44170. (b.angle - a.angle) * sign);
  44171. });
  44172. };
  44173. /**
  44174. * Do translation for pie slices
  44175. * @private
  44176. */
  44177. PieSeries.prototype.translate = function (positions) {
  44178. this.generatePoints();
  44179. var series = this,
  44180. cumulative = 0,
  44181. precision = 1000, // issue #172
  44182. options = series.options,
  44183. slicedOffset = options.slicedOffset,
  44184. connectorOffset = slicedOffset + (options.borderWidth || 0),
  44185. finalConnectorOffset,
  44186. start,
  44187. end,
  44188. angle,
  44189. radians = getStartAndEndRadians(options.startAngle,
  44190. options.endAngle),
  44191. startAngleRad = series.startAngleRad = radians.start,
  44192. endAngleRad = series.endAngleRad = radians.end,
  44193. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  44194. points = series.points,
  44195. // the x component of the radius vector for a given point
  44196. radiusX,
  44197. radiusY,
  44198. labelDistance = options.dataLabels.distance,
  44199. ignoreHiddenPoint = options.ignoreHiddenPoint,
  44200. i,
  44201. len = points.length,
  44202. point;
  44203. // Get positions - either an integer or a percentage string must be
  44204. // given. If positions are passed as a parameter, we're in a
  44205. // recursive loop for adjusting space for data labels.
  44206. if (!positions) {
  44207. series.center = positions = series.getCenter();
  44208. }
  44209. // Calculate the geometry for each point
  44210. for (i = 0; i < len; i++) {
  44211. point = points[i];
  44212. // set start and end angle
  44213. start = startAngleRad + (cumulative * circ);
  44214. if (point.isValid() &&
  44215. (!ignoreHiddenPoint || point.visible)) {
  44216. cumulative += point.percentage / 100;
  44217. }
  44218. end = startAngleRad + (cumulative * circ);
  44219. // set the shape
  44220. var shapeArgs = {
  44221. x: positions[0],
  44222. y: positions[1],
  44223. r: positions[2] / 2,
  44224. innerR: positions[3] / 2,
  44225. start: Math.round(start * precision) / precision,
  44226. end: Math.round(end * precision) / precision
  44227. };
  44228. point.shapeType = 'arc';
  44229. point.shapeArgs = shapeArgs;
  44230. // Used for distance calculation for specific point.
  44231. point.labelDistance = pick((point.options.dataLabels &&
  44232. point.options.dataLabels.distance), labelDistance);
  44233. // Compute point.labelDistance if it's defined as percentage
  44234. // of slice radius (#8854)
  44235. point.labelDistance = relativeLength(point.labelDistance, shapeArgs.r);
  44236. // Saved for later dataLabels distance calculation.
  44237. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  44238. // The angle must stay within -90 and 270 (#2645)
  44239. angle = (end + start) / 2;
  44240. if (angle > 1.5 * Math.PI) {
  44241. angle -= 2 * Math.PI;
  44242. }
  44243. else if (angle < -Math.PI / 2) {
  44244. angle += 2 * Math.PI;
  44245. }
  44246. // Center for the sliced out slice
  44247. point.slicedTranslation = {
  44248. translateX: Math.round(Math.cos(angle) * slicedOffset),
  44249. translateY: Math.round(Math.sin(angle) * slicedOffset)
  44250. };
  44251. // set the anchor point for tooltips
  44252. radiusX = Math.cos(angle) * positions[2] / 2;
  44253. radiusY = Math.sin(angle) * positions[2] / 2;
  44254. point.tooltipPos = [
  44255. positions[0] + radiusX * 0.7,
  44256. positions[1] + radiusY * 0.7
  44257. ];
  44258. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  44259. 1 :
  44260. 0;
  44261. point.angle = angle;
  44262. // Set the anchor point for data labels. Use point.labelDistance
  44263. // instead of labelDistance // #1174
  44264. // finalConnectorOffset - not override connectorOffset value.
  44265. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  44266. point.labelPosition = {
  44267. natural: {
  44268. // initial position of the data label - it's utilized for
  44269. // finding the final position for the label
  44270. x: positions[0] + radiusX + Math.cos(angle) *
  44271. point.labelDistance,
  44272. y: positions[1] + radiusY + Math.sin(angle) *
  44273. point.labelDistance
  44274. },
  44275. 'final': {
  44276. // used for generating connector path -
  44277. // initialized later in drawDataLabels function
  44278. // x: undefined,
  44279. // y: undefined
  44280. },
  44281. // left - pie on the left side of the data label
  44282. // right - pie on the right side of the data label
  44283. // center - data label overlaps the pie
  44284. alignment: point.labelDistance < 0 ?
  44285. 'center' : point.half ? 'right' : 'left',
  44286. connectorPosition: {
  44287. breakAt: {
  44288. x: positions[0] + radiusX + Math.cos(angle) *
  44289. finalConnectorOffset,
  44290. y: positions[1] + radiusY + Math.sin(angle) *
  44291. finalConnectorOffset
  44292. },
  44293. touchingSliceAt: {
  44294. x: positions[0] + radiusX,
  44295. y: positions[1] + radiusY
  44296. }
  44297. }
  44298. };
  44299. }
  44300. fireEvent(series, 'afterTranslate');
  44301. };
  44302. /**
  44303. * Recompute total chart sum and update percentages of points.
  44304. * @private
  44305. */
  44306. PieSeries.prototype.updateTotals = function () {
  44307. var i,
  44308. total = 0,
  44309. points = this.points,
  44310. len = points.length,
  44311. point,
  44312. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  44313. // Get the total sum
  44314. for (i = 0; i < len; i++) {
  44315. point = points[i];
  44316. if (point.isValid() &&
  44317. (!ignoreHiddenPoint || point.visible)) {
  44318. total += point.y;
  44319. }
  44320. }
  44321. this.total = total;
  44322. // Set each point's properties
  44323. for (i = 0; i < len; i++) {
  44324. point = points[i];
  44325. point.percentage =
  44326. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  44327. point.y / total * 100 :
  44328. 0;
  44329. point.total = total;
  44330. }
  44331. };
  44332. /**
  44333. * A pie chart is a circular graphic which is divided into slices to
  44334. * illustrate numerical proportion.
  44335. *
  44336. * @sample highcharts/demo/pie-basic/
  44337. * Pie chart
  44338. *
  44339. * @extends plotOptions.line
  44340. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  44341. * cropThreshold, dashStyle, dataSorting, dragDrop,
  44342. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  44343. * marker, negativeColor, pointInterval, pointIntervalUnit,
  44344. * pointPlacement, pointStart, softThreshold, stacking, step,
  44345. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  44346. * boostBlending
  44347. * @product highcharts
  44348. * @optionparent plotOptions.pie
  44349. */
  44350. PieSeries.defaultOptions = merge(Series.defaultOptions, {
  44351. /**
  44352. * @excluding legendItemClick
  44353. * @apioption plotOptions.pie.events
  44354. */
  44355. /**
  44356. * Fires when the checkbox next to the point name in the legend is
  44357. * clicked. One parameter, event, is passed to the function. The state
  44358. * of the checkbox is found by event.checked. The checked item is found
  44359. * by event.item. Return false to prevent the default action which is to
  44360. * toggle the select state of the series.
  44361. *
  44362. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  44363. * Alert checkbox status
  44364. *
  44365. * @type {Function}
  44366. * @since 1.2.0
  44367. * @product highcharts
  44368. * @context Highcharts.Point
  44369. * @apioption plotOptions.pie.events.checkboxClick
  44370. */
  44371. /**
  44372. * Fires when the legend item belonging to the pie point (slice) is
  44373. * clicked. The `this` keyword refers to the point itself. One
  44374. * parameter, `event`, is passed to the function, containing common
  44375. * event information. The default action is to toggle the visibility of
  44376. * the point. This can be prevented by calling `event.preventDefault()`.
  44377. *
  44378. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  44379. * Confirm toggle visibility
  44380. *
  44381. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  44382. * @since 1.2.0
  44383. * @product highcharts
  44384. * @apioption plotOptions.pie.point.events.legendItemClick
  44385. */
  44386. /**
  44387. * The center of the pie chart relative to the plot area. Can be
  44388. * percentages or pixel values. The default behaviour (as of 3.0) is to
  44389. * center the pie so that all slices and data labels are within the plot
  44390. * area. As a consequence, the pie may actually jump around in a chart
  44391. * with dynamic values, as the data labels move. In that case, the
  44392. * center should be explicitly set, for example to `["50%", "50%"]`.
  44393. *
  44394. * @sample {highcharts} highcharts/plotoptions/pie-center/
  44395. * Centered at 100, 100
  44396. *
  44397. * @type {Array<(number|string|null),(number|string|null)>}
  44398. * @default [null, null]
  44399. * @product highcharts
  44400. *
  44401. * @private
  44402. */
  44403. center: [null, null],
  44404. /**
  44405. * The color of the pie series. A pie series is represented as an empty
  44406. * circle if the total sum of its values is 0. Use this property to
  44407. * define the color of its border.
  44408. *
  44409. * In styled mode, the color can be defined by the
  44410. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  44411. * color can be set with the `.highcharts-series`,
  44412. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  44413. * `.highcharts-series-{n}` class, or individual classes given by the
  44414. * `className` option.
  44415. *
  44416. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44417. * Empty pie series
  44418. *
  44419. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44420. * @default ${palette.neutralColor20}
  44421. * @apioption plotOptions.pie.color
  44422. */
  44423. /**
  44424. * @product highcharts
  44425. *
  44426. * @private
  44427. */
  44428. clip: false,
  44429. /**
  44430. * @ignore-option
  44431. *
  44432. * @private
  44433. */
  44434. colorByPoint: true,
  44435. /**
  44436. * A series specific or series type specific color set to use instead
  44437. * of the global [colors](#colors).
  44438. *
  44439. * @sample {highcharts} highcharts/demo/pie-monochrome/
  44440. * Set default colors for all pies
  44441. *
  44442. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  44443. * @since 3.0
  44444. * @product highcharts
  44445. * @apioption plotOptions.pie.colors
  44446. */
  44447. /**
  44448. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  44449. * @extends plotOptions.series.dataLabels
  44450. * @excluding align, allowOverlap, inside, staggerLines, step
  44451. * @private
  44452. */
  44453. dataLabels: {
  44454. /**
  44455. * Alignment method for data labels. Possible values are:
  44456. *
  44457. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  44458. * the plot area.
  44459. *
  44460. * - `connectors`: Connectors have the same x position and the
  44461. * widest label of each half (left & right) touches the nearest
  44462. * vertical edge of the plot area.
  44463. *
  44464. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  44465. * alignTo: connectors
  44466. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  44467. * alignTo: plotEdges
  44468. *
  44469. * @type {string}
  44470. * @since 7.0.0
  44471. * @product highcharts
  44472. * @apioption plotOptions.pie.dataLabels.alignTo
  44473. */
  44474. allowOverlap: true,
  44475. /**
  44476. * The color of the line connecting the data label to the pie slice.
  44477. * The default color is the same as the point's color.
  44478. *
  44479. * In styled mode, the connector stroke is given in the
  44480. * `.highcharts-data-label-connector` class.
  44481. *
  44482. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  44483. * Blue connectors
  44484. * @sample {highcharts} highcharts/css/pie-point/
  44485. * Styled connectors
  44486. *
  44487. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44488. * @since 2.1
  44489. * @product highcharts
  44490. * @apioption plotOptions.pie.dataLabels.connectorColor
  44491. */
  44492. /**
  44493. * The distance from the data label to the connector. Note that
  44494. * data labels also have a default `padding`, so in order for the
  44495. * connector to touch the text, the `padding` must also be 0.
  44496. *
  44497. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  44498. * No padding
  44499. *
  44500. * @since 2.1
  44501. * @product highcharts
  44502. */
  44503. connectorPadding: 5,
  44504. /**
  44505. * Specifies the method that is used to generate the connector path.
  44506. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  44507. * (default), `'straight'` and `'crookedLine'`. Using
  44508. * `'crookedLine'` has the most sense (in most of the cases) when
  44509. * `'alignTo'` is set.
  44510. *
  44511. * Users can provide their own method by passing a function instead
  44512. * of a String. 3 arguments are passed to the callback:
  44513. *
  44514. * - Object that holds the information about the coordinates of the
  44515. * label (`x` & `y` properties) and how the label is located in
  44516. * relation to the pie (`alignment` property). `alignment` can by
  44517. * one of the following:
  44518. * `'left'` (pie on the left side of the data label),
  44519. * `'right'` (pie on the right side of the data label) or
  44520. * `'center'` (data label overlaps the pie).
  44521. *
  44522. * - Object that holds the information about the position of the
  44523. * connector. Its `touchingSliceAt` porperty tells the position
  44524. * of the place where the connector touches the slice.
  44525. *
  44526. * - Data label options
  44527. *
  44528. * The function has to return an SVG path definition in array form
  44529. * (see the example).
  44530. *
  44531. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  44532. * connectorShape is a String
  44533. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  44534. * connectorShape is a function
  44535. *
  44536. * @type {string|Function}
  44537. * @since 7.0.0
  44538. * @product highcharts
  44539. */
  44540. connectorShape: 'fixedOffset',
  44541. /**
  44542. * The width of the line connecting the data label to the pie slice.
  44543. *
  44544. * In styled mode, the connector stroke width is given in the
  44545. * `.highcharts-data-label-connector` class.
  44546. *
  44547. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  44548. * Disable the connector
  44549. * @sample {highcharts} highcharts/css/pie-point/
  44550. * Styled connectors
  44551. *
  44552. * @type {number}
  44553. * @default 1
  44554. * @since 2.1
  44555. * @product highcharts
  44556. * @apioption plotOptions.pie.dataLabels.connectorWidth
  44557. */
  44558. /**
  44559. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  44560. * far from the vertical plot edge the coonnector path should be
  44561. * crooked.
  44562. *
  44563. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  44564. * crookDistance set to 90%
  44565. *
  44566. * @since 7.0.0
  44567. * @product highcharts
  44568. */
  44569. crookDistance: '70%',
  44570. /**
  44571. * The distance of the data label from the pie's edge. Negative
  44572. * numbers put the data label on top of the pie slices. Can also be
  44573. * defined as a percentage of pie's radius. Connectors are only
  44574. * shown for data labels outside the pie.
  44575. *
  44576. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  44577. * Data labels on top of the pie
  44578. *
  44579. * @type {number|string}
  44580. * @since 2.1
  44581. * @product highcharts
  44582. */
  44583. distance: 30,
  44584. enabled: true,
  44585. /**
  44586. * A
  44587. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  44588. * for the data label. Available variables are the same as for
  44589. * `formatter`.
  44590. *
  44591. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  44592. * Add a unit
  44593. *
  44594. * @type {string}
  44595. * @default undefined
  44596. * @since 3.0
  44597. * @apioption plotOptions.pie.dataLabels.format
  44598. */
  44599. // eslint-disable-next-line valid-jsdoc
  44600. /**
  44601. * Callback JavaScript function to format the data label. Note that
  44602. * if a `format` is defined, the format takes precedence and the
  44603. * formatter is ignored.
  44604. *
  44605. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  44606. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  44607. */
  44608. formatter: function () {
  44609. return this.point.isNull ? void 0 : this.point.name;
  44610. },
  44611. /**
  44612. * Whether to render the connector as a soft arc or a line with
  44613. * sharp break. Works only if `connectorShape` equals to
  44614. * `fixedOffset`.
  44615. *
  44616. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  44617. * Soft
  44618. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  44619. * Non soft
  44620. *
  44621. * @since 2.1.7
  44622. * @product highcharts
  44623. */
  44624. softConnector: true,
  44625. /**
  44626. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  44627. * Long labels truncated with an ellipsis
  44628. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  44629. * Long labels are wrapped
  44630. *
  44631. * @type {Highcharts.CSSObject}
  44632. * @apioption plotOptions.pie.dataLabels.style
  44633. */
  44634. x: 0
  44635. },
  44636. /**
  44637. * If the total sum of the pie's values is 0, the series is represented
  44638. * as an empty circle . The `fillColor` option defines the color of that
  44639. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  44640. * the border thickness.
  44641. *
  44642. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44643. * Empty pie series
  44644. *
  44645. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44646. * @private
  44647. */
  44648. fillColor: void 0,
  44649. /**
  44650. * The end angle of the pie in degrees where 0 is top and 90 is right.
  44651. * Defaults to `startAngle` plus 360.
  44652. *
  44653. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  44654. * Semi-circle donut
  44655. *
  44656. * @type {number}
  44657. * @since 1.3.6
  44658. * @product highcharts
  44659. * @apioption plotOptions.pie.endAngle
  44660. */
  44661. /**
  44662. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  44663. * this option tells whether the series shall be redrawn as if the
  44664. * hidden point were `null`.
  44665. *
  44666. * The default value changed from `false` to `true` with Highcharts
  44667. * 3.0.
  44668. *
  44669. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  44670. * True, the hiddden point is ignored
  44671. *
  44672. * @since 2.3.0
  44673. * @product highcharts
  44674. *
  44675. * @private
  44676. */
  44677. ignoreHiddenPoint: true,
  44678. /**
  44679. * @ignore-option
  44680. *
  44681. * @private
  44682. */
  44683. inactiveOtherPoints: true,
  44684. /**
  44685. * The size of the inner diameter for the pie. A size greater than 0
  44686. * renders a donut chart. Can be a percentage or pixel value.
  44687. * Percentages are relative to the pie size. Pixel values are given as
  44688. * integers.
  44689. *
  44690. *
  44691. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  44692. * area, not the pie size.
  44693. *
  44694. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  44695. * 80px inner size
  44696. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  44697. * 50% of the plot area
  44698. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  44699. * 3D donut
  44700. *
  44701. * @type {number|string}
  44702. * @default 0
  44703. * @since 2.0
  44704. * @product highcharts
  44705. * @apioption plotOptions.pie.innerSize
  44706. */
  44707. /**
  44708. * @ignore-option
  44709. *
  44710. * @private
  44711. */
  44712. legendType: 'point',
  44713. /**
  44714. * @ignore-option
  44715. *
  44716. * @private
  44717. */
  44718. marker: null,
  44719. /**
  44720. * The minimum size for a pie in response to auto margins. The pie will
  44721. * try to shrink to make room for data labels in side the plot area,
  44722. * but only to this size.
  44723. *
  44724. * @type {number|string}
  44725. * @default 80
  44726. * @since 3.0
  44727. * @product highcharts
  44728. * @apioption plotOptions.pie.minSize
  44729. */
  44730. /**
  44731. * The diameter of the pie relative to the plot area. Can be a
  44732. * percentage or pixel value. Pixel values are given as integers. The
  44733. * default behaviour (as of 3.0) is to scale to the plot area and give
  44734. * room for data labels within the plot area.
  44735. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  44736. * default size calculation. As a consequence, the size of the pie may
  44737. * vary when points are updated and data labels more around. In that
  44738. * case it is best to set a fixed value, for example `"75%"`.
  44739. *
  44740. * @sample {highcharts} highcharts/plotoptions/pie-size/
  44741. * Smaller pie
  44742. *
  44743. * @type {number|string|null}
  44744. * @product highcharts
  44745. *
  44746. * @private
  44747. */
  44748. size: null,
  44749. /**
  44750. * Whether to display this particular series or series type in the
  44751. * legend. Since 2.1, pies are not shown in the legend by default.
  44752. *
  44753. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  44754. * One series in the legend, one hidden
  44755. *
  44756. * @product highcharts
  44757. *
  44758. * @private
  44759. */
  44760. showInLegend: false,
  44761. /**
  44762. * If a point is sliced, moved out from the center, how many pixels
  44763. * should it be moved?.
  44764. *
  44765. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  44766. * 20px offset
  44767. *
  44768. * @product highcharts
  44769. *
  44770. * @private
  44771. */
  44772. slicedOffset: 10,
  44773. /**
  44774. * The start angle of the pie slices in degrees where 0 is top and 90
  44775. * right.
  44776. *
  44777. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  44778. * Start from right
  44779. *
  44780. * @type {number}
  44781. * @default 0
  44782. * @since 2.3.4
  44783. * @product highcharts
  44784. * @apioption plotOptions.pie.startAngle
  44785. */
  44786. /**
  44787. * Sticky tracking of mouse events. When true, the `mouseOut` event
  44788. * on a series isn't triggered until the mouse moves over another
  44789. * series, or out of the plot area. When false, the `mouseOut` event on
  44790. * a series is triggered when the mouse leaves the area around the
  44791. * series' graph or markers. This also implies the tooltip. When
  44792. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  44793. * will be hidden when moving the mouse between series.
  44794. *
  44795. * @product highcharts
  44796. *
  44797. * @private
  44798. */
  44799. stickyTracking: false,
  44800. tooltip: {
  44801. followPointer: true
  44802. },
  44803. /**
  44804. * The color of the border surrounding each slice. When `null`, the
  44805. * border takes the same color as the slice fill. This can be used
  44806. * together with a `borderWidth` to fill drawing gaps created by
  44807. * antialiazing artefacts in borderless pies.
  44808. *
  44809. * In styled mode, the border stroke is given in the `.highcharts-point`
  44810. * class.
  44811. *
  44812. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  44813. * Black border
  44814. *
  44815. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44816. * @default #ffffff
  44817. * @product highcharts
  44818. *
  44819. * @private
  44820. */
  44821. borderColor: palette.backgroundColor,
  44822. /**
  44823. * The width of the border surrounding each slice.
  44824. *
  44825. * When setting the border width to 0, there may be small gaps between
  44826. * the slices due to SVG antialiasing artefacts. To work around this,
  44827. * keep the border width at 0.5 or 1, but set the `borderColor` to
  44828. * `null` instead.
  44829. *
  44830. * In styled mode, the border stroke width is given in the
  44831. * `.highcharts-point` class.
  44832. *
  44833. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  44834. * 3px border
  44835. *
  44836. * @product highcharts
  44837. *
  44838. * @private
  44839. */
  44840. borderWidth: 1,
  44841. /**
  44842. * @ignore-options
  44843. * @private
  44844. */
  44845. lineWidth: void 0,
  44846. states: {
  44847. /**
  44848. * @extends plotOptions.series.states.hover
  44849. * @excluding marker, lineWidth, lineWidthPlus
  44850. * @product highcharts
  44851. */
  44852. hover: {
  44853. /**
  44854. * How much to brighten the point on interaction. Requires the
  44855. * main color to be defined in hex or rgb(a) format.
  44856. *
  44857. * In styled mode, the hover brightness is by default replaced
  44858. * by a fill-opacity given in the `.highcharts-point-hover`
  44859. * class.
  44860. *
  44861. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  44862. * Brightened by 0.5
  44863. *
  44864. * @product highcharts
  44865. */
  44866. brightness: 0.1
  44867. }
  44868. }
  44869. });
  44870. return PieSeries;
  44871. }(Series));
  44872. extend(PieSeries.prototype, {
  44873. axisTypes: [],
  44874. directTouch: true,
  44875. drawGraph: void 0,
  44876. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  44877. drawTracker: ColumnSeries.prototype.drawTracker,
  44878. getCenter: CenteredSeriesMixin.getCenter,
  44879. getSymbol: noop,
  44880. isCartesian: false,
  44881. noSharedTooltip: true,
  44882. pointAttribs: ColumnSeries.prototype.pointAttribs,
  44883. pointClass: PiePoint,
  44884. requireSorting: false,
  44885. searchPoint: noop,
  44886. trackerGroups: ['group', 'dataLabelsGroup']
  44887. });
  44888. SeriesRegistry.registerSeriesType('pie', PieSeries);
  44889. /* *
  44890. *
  44891. * Default Export
  44892. *
  44893. * */
  44894. /* *
  44895. *
  44896. * API Options
  44897. *
  44898. * */
  44899. /**
  44900. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  44901. * it is inherited from [chart.type](#chart.type).
  44902. *
  44903. * @extends series,plotOptions.pie
  44904. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  44905. * dataSorting, step, boostThreshold, boostBlending
  44906. * @product highcharts
  44907. * @apioption series.pie
  44908. */
  44909. /**
  44910. * An array of data points for the series. For the `pie` series type,
  44911. * points can be given in the following ways:
  44912. *
  44913. * 1. An array of numerical values. In this case, the numerical values will be
  44914. * interpreted as `y` options. Example:
  44915. * ```js
  44916. * data: [0, 5, 3, 5]
  44917. * ```
  44918. *
  44919. * 2. An array of objects with named values. The following snippet shows only a
  44920. * few settings, see the complete options set below. If the total number of
  44921. * data points exceeds the series'
  44922. * [turboThreshold](#series.pie.turboThreshold),
  44923. * this option is not available.
  44924. * ```js
  44925. * data: [{
  44926. * y: 1,
  44927. * name: "Point2",
  44928. * color: "#00FF00"
  44929. * }, {
  44930. * y: 7,
  44931. * name: "Point1",
  44932. * color: "#FF00FF"
  44933. * }]
  44934. * ```
  44935. *
  44936. * @sample {highcharts} highcharts/chart/reflow-true/
  44937. * Numerical values
  44938. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  44939. * Arrays of numeric x and y
  44940. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  44941. * Arrays of datetime x and y
  44942. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  44943. * Arrays of point.name and y
  44944. * @sample {highcharts} highcharts/series/data-array-of-objects/
  44945. * Config objects
  44946. *
  44947. * @type {Array<number|Array<string,(number|null)>|null|*>}
  44948. * @extends series.line.data
  44949. * @excluding marker, x
  44950. * @product highcharts
  44951. * @apioption series.pie.data
  44952. */
  44953. /**
  44954. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  44955. * @product highcharts
  44956. * @apioption series.pie.data.dataLabels
  44957. */
  44958. /**
  44959. * The sequential index of the data point in the legend.
  44960. *
  44961. * @type {number}
  44962. * @product highcharts
  44963. * @apioption series.pie.data.legendIndex
  44964. */
  44965. /**
  44966. * Whether to display a slice offset from the center.
  44967. *
  44968. * @sample {highcharts} highcharts/point/sliced/
  44969. * One sliced point
  44970. *
  44971. * @type {boolean}
  44972. * @product highcharts
  44973. * @apioption series.pie.data.sliced
  44974. */
  44975. /**
  44976. * @extends plotOptions.pie.dataLabels
  44977. * @excluding align, allowOverlap, inside, staggerLines, step
  44978. * @product highcharts
  44979. * @apioption series.pie.dataLabels
  44980. */
  44981. /**
  44982. * @excluding legendItemClick
  44983. * @product highcharts
  44984. * @apioption series.pie.events
  44985. */
  44986. ''; // placeholder for transpiled doclets above
  44987. return PieSeries;
  44988. });
  44989. _registerModule(_modules, 'Core/Series/DataLabels.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, F, H, palette, Series, SeriesRegistry, U) {
  44990. /* *
  44991. *
  44992. * (c) 2010-2021 Torstein Honsi
  44993. *
  44994. * License: www.highcharts.com/license
  44995. *
  44996. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44997. *
  44998. * */
  44999. var getDeferredAnimation = A.getDeferredAnimation;
  45000. var format = F.format;
  45001. var noop = H.noop;
  45002. var seriesTypes = SeriesRegistry.seriesTypes;
  45003. var arrayMax = U.arrayMax,
  45004. clamp = U.clamp,
  45005. defined = U.defined,
  45006. extend = U.extend,
  45007. fireEvent = U.fireEvent,
  45008. isArray = U.isArray,
  45009. merge = U.merge,
  45010. objectEach = U.objectEach,
  45011. pick = U.pick,
  45012. relativeLength = U.relativeLength,
  45013. splat = U.splat,
  45014. stableSort = U.stableSort;
  45015. /**
  45016. * Callback JavaScript function to format the data label as a string. Note that
  45017. * if a `format` is defined, the format takes precedence and the formatter is
  45018. * ignored.
  45019. *
  45020. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  45021. *
  45022. * @param {Highcharts.PointLabelObject} this
  45023. * Data label context to format
  45024. *
  45025. * @param {Highcharts.DataLabelsOptions} options
  45026. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  45027. *
  45028. * @return {number|string|null|undefined}
  45029. * Formatted data label text
  45030. */
  45031. /**
  45032. * Values for handling data labels that flow outside the plot area.
  45033. *
  45034. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  45035. */
  45036. ''; // detach doclets above
  45037. /* eslint-disable valid-jsdoc */
  45038. /**
  45039. * General distribution algorithm for distributing labels of differing size
  45040. * along a confined length in two dimensions. The algorithm takes an array of
  45041. * objects containing a size, a target and a rank. It will place the labels as
  45042. * close as possible to their targets, skipping the lowest ranked labels if
  45043. * necessary.
  45044. *
  45045. * @private
  45046. * @function Highcharts.distribute
  45047. * @param {Highcharts.DataLabelsBoxArray} boxes
  45048. * @param {number} len
  45049. * @param {number} [maxDistance]
  45050. * @return {void}
  45051. */
  45052. H.distribute = function (boxes, len, maxDistance) {
  45053. var i,
  45054. overlapping = true,
  45055. origBoxes = boxes, // Original array will be altered with added .pos
  45056. restBoxes = [], // The outranked overshoot
  45057. box,
  45058. target,
  45059. total = 0,
  45060. reducedLen = origBoxes.reducedLen || len;
  45061. /**
  45062. * @private
  45063. */
  45064. function sortByTarget(a, b) {
  45065. return a.target - b.target;
  45066. }
  45067. // If the total size exceeds the len, remove those boxes with the lowest
  45068. // rank
  45069. i = boxes.length;
  45070. while (i--) {
  45071. total += boxes[i].size;
  45072. }
  45073. // Sort by rank, then slice away overshoot
  45074. if (total > reducedLen) {
  45075. stableSort(boxes, function (a, b) {
  45076. return (b.rank || 0) - (a.rank || 0);
  45077. });
  45078. i = 0;
  45079. total = 0;
  45080. while (total <= reducedLen) {
  45081. total += boxes[i].size;
  45082. i++;
  45083. }
  45084. restBoxes = boxes.splice(i - 1, boxes.length);
  45085. }
  45086. // Order by target
  45087. stableSort(boxes, sortByTarget);
  45088. // So far we have been mutating the original array. Now
  45089. // create a copy with target arrays
  45090. boxes = boxes.map(function (box) {
  45091. return {
  45092. size: box.size,
  45093. targets: [box.target],
  45094. align: pick(box.align, 0.5)
  45095. };
  45096. });
  45097. while (overlapping) {
  45098. // Initial positions: target centered in box
  45099. i = boxes.length;
  45100. while (i--) {
  45101. box = boxes[i];
  45102. // Composite box, average of targets
  45103. target = (Math.min.apply(0, box.targets) +
  45104. Math.max.apply(0, box.targets)) / 2;
  45105. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  45106. }
  45107. // Detect overlap and join boxes
  45108. i = boxes.length;
  45109. overlapping = false;
  45110. while (i--) {
  45111. // Overlap
  45112. if (i > 0 &&
  45113. boxes[i - 1].pos + boxes[i - 1].size >
  45114. boxes[i].pos) {
  45115. // Add this size to the previous box
  45116. boxes[i - 1].size += boxes[i].size;
  45117. boxes[i - 1].targets = boxes[i - 1]
  45118. .targets
  45119. .concat(boxes[i].targets);
  45120. boxes[i - 1].align = 0.5;
  45121. // Overlapping right, push left
  45122. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  45123. boxes[i - 1].pos = len - boxes[i - 1].size;
  45124. }
  45125. boxes.splice(i, 1); // Remove this item
  45126. overlapping = true;
  45127. }
  45128. }
  45129. }
  45130. // Add the rest (hidden boxes)
  45131. origBoxes.push.apply(origBoxes, restBoxes);
  45132. // Now the composite boxes are placed, we need to put the original boxes
  45133. // within them
  45134. i = 0;
  45135. boxes.some(function (box) {
  45136. var posInCompositeBox = 0;
  45137. if (box.targets.some(function () {
  45138. origBoxes[i].pos = box.pos + posInCompositeBox;
  45139. // If the distance between the position and the target exceeds
  45140. // maxDistance, abort the loop and decrease the length in increments
  45141. // of 10% to recursively reduce the number of visible boxes by
  45142. // rank. Once all boxes are within the maxDistance, we're good.
  45143. if (typeof maxDistance !== 'undefined' &&
  45144. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  45145. // Reset the positions that are already set
  45146. origBoxes.slice(0, i + 1).forEach(function (box) {
  45147. delete box.pos;
  45148. });
  45149. // Try with a smaller length
  45150. origBoxes.reducedLen =
  45151. (origBoxes.reducedLen || len) - (len * 0.1);
  45152. // Recurse
  45153. if (origBoxes.reducedLen > len * 0.1) {
  45154. H.distribute(origBoxes, len, maxDistance);
  45155. }
  45156. // Exceeded maxDistance => abort
  45157. return true;
  45158. }
  45159. posInCompositeBox += origBoxes[i].size;
  45160. i++;
  45161. })) {
  45162. // Exceeded maxDistance => abort
  45163. return true;
  45164. }
  45165. });
  45166. // Add the rest (hidden) boxes and sort by target
  45167. stableSort(origBoxes, sortByTarget);
  45168. };
  45169. /**
  45170. * Draw the data labels
  45171. *
  45172. * @private
  45173. * @function Highcharts.Series#drawDataLabels
  45174. * @return {void}
  45175. * @fires Highcharts.Series#event:afterDrawDataLabels
  45176. */
  45177. Series.prototype.drawDataLabels = function () {
  45178. var series = this,
  45179. chart = series.chart,
  45180. seriesOptions = series.options,
  45181. seriesDlOptions = seriesOptions.dataLabels,
  45182. points = series.points,
  45183. pointOptions,
  45184. hasRendered = series.hasRendered || 0,
  45185. dataLabelsGroup,
  45186. dataLabelAnim = seriesDlOptions.animation,
  45187. animationConfig = seriesDlOptions.defer ?
  45188. getDeferredAnimation(chart,
  45189. dataLabelAnim,
  45190. series) :
  45191. { defer: 0,
  45192. duration: 0 },
  45193. renderer = chart.renderer;
  45194. /**
  45195. * Handle the dataLabels.filter option.
  45196. * @private
  45197. */
  45198. function applyFilter(point, options) {
  45199. var filter = options.filter,
  45200. op,
  45201. prop,
  45202. val;
  45203. if (filter) {
  45204. op = filter.operator;
  45205. prop = point[filter.property];
  45206. val = filter.value;
  45207. if ((op === '>' && prop > val) ||
  45208. (op === '<' && prop < val) ||
  45209. (op === '>=' && prop >= val) ||
  45210. (op === '<=' && prop <= val) ||
  45211. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  45212. (op === '===' && prop === val)) {
  45213. return true;
  45214. }
  45215. return false;
  45216. }
  45217. return true;
  45218. }
  45219. /**
  45220. * Merge two objects that can be arrays. If one of them is an array, the
  45221. * other is merged into each element. If both are arrays, each element is
  45222. * merged by index. If neither are arrays, we use normal merge.
  45223. * @private
  45224. */
  45225. function mergeArrays(one, two) {
  45226. var res = [],
  45227. i;
  45228. if (isArray(one) && !isArray(two)) {
  45229. res = one.map(function (el) {
  45230. return merge(el, two);
  45231. });
  45232. }
  45233. else if (isArray(two) && !isArray(one)) {
  45234. res = two.map(function (el) {
  45235. return merge(one, el);
  45236. });
  45237. }
  45238. else if (!isArray(one) && !isArray(two)) {
  45239. res = merge(one, two);
  45240. }
  45241. else {
  45242. i = Math.max(one.length, two.length);
  45243. while (i--) {
  45244. res[i] = merge(one[i], two[i]);
  45245. }
  45246. }
  45247. return res;
  45248. }
  45249. // Merge in plotOptions.dataLabels for series
  45250. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  45251. chart.options.plotOptions.series &&
  45252. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  45253. chart.options.plotOptions[series.type] &&
  45254. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  45255. fireEvent(this, 'drawDataLabels');
  45256. if (isArray(seriesDlOptions) ||
  45257. seriesDlOptions.enabled ||
  45258. series._hasPointLabels) {
  45259. // Create a separate group for the data labels to avoid rotation
  45260. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  45261. seriesDlOptions.zIndex || 6);
  45262. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  45263. if (!hasRendered) {
  45264. var group = series.dataLabelsGroup;
  45265. if (group) {
  45266. if (series.visible) { // #2597, #3023, #3024
  45267. dataLabelsGroup.show(true);
  45268. }
  45269. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  45270. }
  45271. }
  45272. // Make the labels for each point
  45273. points.forEach(function (point) {
  45274. // Merge in series options for the point.
  45275. // @note dataLabelAttribs (like pointAttribs) would eradicate
  45276. // the need for dlOptions, and simplify the section below.
  45277. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  45278. (point.options && point.options.dataLabels)));
  45279. // Handle each individual data label for this point
  45280. pointOptions.forEach(function (labelOptions, i) {
  45281. // Options for one datalabel
  45282. var labelEnabled = (labelOptions.enabled &&
  45283. // #2282, #4641, #7112, #10049
  45284. (!point.isNull || point.dataLabelOnNull) &&
  45285. applyFilter(point,
  45286. labelOptions)),
  45287. labelConfig,
  45288. formatString,
  45289. labelText,
  45290. style,
  45291. rotation,
  45292. attr,
  45293. dataLabel = point.dataLabels ? point.dataLabels[i] :
  45294. point.dataLabel,
  45295. connector = point.connectors ? point.connectors[i] :
  45296. point.connector,
  45297. labelDistance = pick(labelOptions.distance,
  45298. point.labelDistance),
  45299. isNew = !dataLabel;
  45300. if (labelEnabled) {
  45301. // Create individual options structure that can be extended
  45302. // without affecting others
  45303. labelConfig = point.getLabelConfig();
  45304. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  45305. labelText = defined(formatString) ?
  45306. format(formatString, labelConfig, chart) :
  45307. (labelOptions[point.formatPrefix + 'Formatter'] ||
  45308. labelOptions.formatter).call(labelConfig, labelOptions);
  45309. style = labelOptions.style;
  45310. rotation = labelOptions.rotation;
  45311. if (!chart.styledMode) {
  45312. // Determine the color
  45313. style.color = pick(labelOptions.color, style.color, series.color, palette.neutralColor100);
  45314. // Get automated contrast color
  45315. if (style.color === 'contrast') {
  45316. point.contrastColor = renderer.getContrast((point.color || series.color));
  45317. style.color = (!defined(labelDistance) &&
  45318. labelOptions.inside) ||
  45319. labelDistance < 0 ||
  45320. !!seriesOptions.stacking ?
  45321. point.contrastColor :
  45322. palette.neutralColor100;
  45323. }
  45324. else {
  45325. delete point.contrastColor;
  45326. }
  45327. if (seriesOptions.cursor) {
  45328. style.cursor = seriesOptions.cursor;
  45329. }
  45330. }
  45331. attr = {
  45332. r: labelOptions.borderRadius || 0,
  45333. rotation: rotation,
  45334. padding: labelOptions.padding,
  45335. zIndex: 1
  45336. };
  45337. if (!chart.styledMode) {
  45338. attr.fill = labelOptions.backgroundColor;
  45339. attr.stroke = labelOptions.borderColor;
  45340. attr['stroke-width'] = labelOptions.borderWidth;
  45341. }
  45342. // Remove unused attributes (#947)
  45343. objectEach(attr, function (val, name) {
  45344. if (typeof val === 'undefined') {
  45345. delete attr[name];
  45346. }
  45347. });
  45348. }
  45349. // If the point is outside the plot area, destroy it. #678, #820
  45350. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  45351. point.dataLabel =
  45352. point.dataLabel && point.dataLabel.destroy();
  45353. if (point.dataLabels) {
  45354. // Remove point.dataLabels if this was the last one
  45355. if (point.dataLabels.length === 1) {
  45356. delete point.dataLabels;
  45357. }
  45358. else {
  45359. delete point.dataLabels[i];
  45360. }
  45361. }
  45362. if (!i) {
  45363. delete point.dataLabel;
  45364. }
  45365. if (connector) {
  45366. point.connector = point.connector.destroy();
  45367. if (point.connectors) {
  45368. // Remove point.connectors if this was the last one
  45369. if (point.connectors.length === 1) {
  45370. delete point.connectors;
  45371. }
  45372. else {
  45373. delete point.connectors[i];
  45374. }
  45375. }
  45376. }
  45377. // Individual labels are disabled if the are explicitly disabled
  45378. // in the point options, or if they fall outside the plot area.
  45379. }
  45380. else if (labelEnabled && defined(labelText)) {
  45381. if (!dataLabel) {
  45382. // Create new label element
  45383. point.dataLabels = point.dataLabels || [];
  45384. dataLabel = point.dataLabels[i] = rotation ?
  45385. // Labels don't rotate, use text element
  45386. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  45387. .addClass('highcharts-data-label') :
  45388. // We can use label
  45389. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  45390. // Store for backwards compatibility
  45391. if (!i) {
  45392. point.dataLabel = dataLabel;
  45393. }
  45394. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  45395. ' ' + (labelOptions.className || '') +
  45396. ( // #3398
  45397. labelOptions.useHTML ?
  45398. ' highcharts-tracker' :
  45399. ''));
  45400. }
  45401. else {
  45402. // Use old element and just update text
  45403. attr.text = labelText;
  45404. }
  45405. // Store data label options for later access
  45406. dataLabel.options = labelOptions;
  45407. dataLabel.attr(attr);
  45408. if (!chart.styledMode) {
  45409. // Styles must be applied before add in order to read
  45410. // text bounding box
  45411. dataLabel.css(style).shadow(labelOptions.shadow);
  45412. }
  45413. if (!dataLabel.added) {
  45414. dataLabel.add(dataLabelsGroup);
  45415. }
  45416. if (labelOptions.textPath && !labelOptions.useHTML) {
  45417. dataLabel.setTextPath((point.getDataLabelPath &&
  45418. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  45419. if (point.dataLabelPath &&
  45420. !labelOptions.textPath.enabled) {
  45421. // clean the DOM
  45422. point.dataLabelPath = point.dataLabelPath.destroy();
  45423. }
  45424. }
  45425. // Now the data label is created and placed at 0,0, so we
  45426. // need to align it
  45427. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  45428. }
  45429. });
  45430. });
  45431. }
  45432. fireEvent(this, 'afterDrawDataLabels');
  45433. };
  45434. /**
  45435. * Align each individual data label.
  45436. *
  45437. * @private
  45438. * @function Highcharts.Series#alignDataLabel
  45439. * @param {Highcharts.Point} point
  45440. * @param {Highcharts.SVGElement} dataLabel
  45441. * @param {Highcharts.DataLabelsOptions} options
  45442. * @param {Highcharts.BBoxObject} alignTo
  45443. * @param {boolean} [isNew]
  45444. * @return {void}
  45445. */
  45446. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45447. var series = this,
  45448. chart = this.chart,
  45449. inverted = this.isCartesian && chart.inverted,
  45450. enabledDataSorting = this.enabledDataSorting,
  45451. plotX = pick(point.dlBox && point.dlBox.centerX,
  45452. point.plotX, -9999),
  45453. plotY = pick(point.plotY, -9999),
  45454. bBox = dataLabel.getBBox(),
  45455. baseline,
  45456. rotation = options.rotation,
  45457. normRotation,
  45458. negRotation,
  45459. align = options.align,
  45460. rotCorr, // rotation correction
  45461. isInsidePlot = chart.isInsidePlot(plotX,
  45462. Math.round(plotY), {
  45463. inverted: inverted,
  45464. paneCoordinates: true,
  45465. series: series
  45466. }),
  45467. // Math.round for rounding errors (#2683), alignTo to allow column
  45468. // labels (#2700)
  45469. alignAttr, // the final position;
  45470. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  45471. point.visible !== false &&
  45472. (point.series.forceDL ||
  45473. (enabledDataSorting && !justify) ||
  45474. isInsidePlot ||
  45475. (
  45476. // If the data label is inside the align box, it is enough
  45477. // that parts of the align box is inside the plot area
  45478. // (#12370). When stacking, it is always inside regardless
  45479. // of the option (#15148).
  45480. pick(options.inside, !!this.options.stacking) &&
  45481. alignTo &&
  45482. chart.isInsidePlot(plotX, inverted ?
  45483. alignTo.x + 1 :
  45484. alignTo.y + alignTo.height - 1, {
  45485. inverted: inverted,
  45486. paneCoordinates: true,
  45487. series: series
  45488. }))), setStartPos = function (alignOptions) {
  45489. if (enabledDataSorting && series.xAxis && !justify) {
  45490. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  45491. }
  45492. };
  45493. if (visible) {
  45494. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  45495. // The alignment box is a singular point
  45496. alignTo = extend({
  45497. x: inverted ? this.yAxis.len - plotY : plotX,
  45498. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  45499. width: 0,
  45500. height: 0
  45501. }, alignTo);
  45502. // Add the text size for alignment calculation
  45503. extend(options, {
  45504. width: bBox.width,
  45505. height: bBox.height
  45506. });
  45507. // Allow a hook for changing alignment in the last moment, then do the
  45508. // alignment
  45509. if (rotation) {
  45510. justify = false; // Not supported for rotated text
  45511. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  45512. alignAttr = {
  45513. x: (alignTo.x +
  45514. (options.x || 0) +
  45515. alignTo.width / 2 +
  45516. rotCorr.x),
  45517. y: (alignTo.y +
  45518. (options.y || 0) +
  45519. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  45520. alignTo.height)
  45521. };
  45522. setStartPos(alignAttr); // data sorting
  45523. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  45524. .attr({
  45525. align: align
  45526. });
  45527. // Compensate for the rotated label sticking out on the sides
  45528. normRotation = (rotation + 720) % 360;
  45529. negRotation = normRotation > 180 && normRotation < 360;
  45530. if (align === 'left') {
  45531. alignAttr.y -= negRotation ? bBox.height : 0;
  45532. }
  45533. else if (align === 'center') {
  45534. alignAttr.x -= bBox.width / 2;
  45535. alignAttr.y -= bBox.height / 2;
  45536. }
  45537. else if (align === 'right') {
  45538. alignAttr.x -= bBox.width;
  45539. alignAttr.y -= negRotation ? 0 : bBox.height;
  45540. }
  45541. dataLabel.placed = true;
  45542. dataLabel.alignAttr = alignAttr;
  45543. }
  45544. else {
  45545. setStartPos(alignTo); // data sorting
  45546. dataLabel.align(options, void 0, alignTo);
  45547. alignAttr = dataLabel.alignAttr;
  45548. }
  45549. // Handle justify or crop
  45550. if (justify && alignTo.height >= 0) { // #8830
  45551. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  45552. // Now check that the data label is within the plot area
  45553. }
  45554. else if (pick(options.crop, true)) {
  45555. visible =
  45556. chart.isInsidePlot(alignAttr.x, alignAttr.y, {
  45557. paneCoordinates: true,
  45558. series: series
  45559. }) &&
  45560. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height, {
  45561. paneCoordinates: true,
  45562. series: series
  45563. });
  45564. }
  45565. // When we're using a shape, make it possible with a connector or an
  45566. // arrow pointing to thie point
  45567. if (options.shape && !rotation) {
  45568. dataLabel[isNew ? 'attr' : 'animate']({
  45569. anchorX: inverted ?
  45570. chart.plotWidth - point.plotY :
  45571. point.plotX,
  45572. anchorY: inverted ?
  45573. chart.plotHeight - point.plotX :
  45574. point.plotY
  45575. });
  45576. }
  45577. }
  45578. // To use alignAttr property in hideOverlappingLabels
  45579. if (isNew && enabledDataSorting) {
  45580. dataLabel.placed = false;
  45581. }
  45582. // Show or hide based on the final aligned position
  45583. if (!visible && (!enabledDataSorting || justify)) {
  45584. dataLabel.hide(true);
  45585. dataLabel.placed = false; // don't animate back in
  45586. }
  45587. };
  45588. /**
  45589. * Set starting position for data label sorting animation.
  45590. *
  45591. * @private
  45592. * @function Highcharts.Series#setDataLabelStartPos
  45593. * @param {Highcharts.SVGElement} dataLabel
  45594. * @param {Highcharts.ColumnPoint} point
  45595. * @param {boolean | undefined} [isNew]
  45596. * @param {boolean} [isInside]
  45597. * @param {Highcharts.AlignObject} [alignOptions]
  45598. *
  45599. * @return {void}
  45600. */
  45601. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  45602. var chart = this.chart,
  45603. inverted = chart.inverted,
  45604. xAxis = this.xAxis,
  45605. reversed = xAxis.reversed,
  45606. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  45607. pointWidth = point.pointWidth,
  45608. halfWidth = pointWidth ? pointWidth / 2 : 0,
  45609. startXPos,
  45610. startYPos;
  45611. startXPos = inverted ?
  45612. alignOptions.x :
  45613. (reversed ?
  45614. -labelCenter - halfWidth :
  45615. xAxis.width - labelCenter + halfWidth);
  45616. startYPos = inverted ?
  45617. (reversed ?
  45618. this.yAxis.height - labelCenter + halfWidth :
  45619. -labelCenter - halfWidth) : alignOptions.y;
  45620. dataLabel.startXPos = startXPos;
  45621. dataLabel.startYPos = startYPos;
  45622. // We need to handle visibility in case of sorting point outside plot area
  45623. if (!isInside) {
  45624. dataLabel
  45625. .attr({ opacity: 1 })
  45626. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  45627. }
  45628. else if (dataLabel.visibility === 'hidden') {
  45629. dataLabel.show();
  45630. dataLabel
  45631. .attr({ opacity: 0 })
  45632. .animate({ opacity: 1 });
  45633. }
  45634. // Save start position on first render, but do not change position
  45635. if (!chart.hasRendered) {
  45636. return;
  45637. }
  45638. // Set start position
  45639. if (isNew) {
  45640. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  45641. }
  45642. dataLabel.placed = true;
  45643. };
  45644. /**
  45645. * If data labels fall partly outside the plot area, align them back in, in a
  45646. * way that doesn't hide the point.
  45647. *
  45648. * @private
  45649. * @function Highcharts.Series#justifyDataLabel
  45650. * @param {Highcharts.SVGElement} dataLabel
  45651. * @param {Highcharts.DataLabelsOptions} options
  45652. * @param {Highcharts.SVGAttributes} alignAttr
  45653. * @param {Highcharts.BBoxObject} bBox
  45654. * @param {Highcharts.BBoxObject} [alignTo]
  45655. * @param {boolean} [isNew]
  45656. * @return {boolean|undefined}
  45657. */
  45658. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  45659. var chart = this.chart,
  45660. align = options.align,
  45661. verticalAlign = options.verticalAlign,
  45662. off,
  45663. justified,
  45664. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  45665. var _a = options.x,
  45666. x = _a === void 0 ? 0 : _a,
  45667. _b = options.y,
  45668. y = _b === void 0 ? 0 : _b;
  45669. // Off left
  45670. off = (alignAttr.x || 0) + padding;
  45671. if (off < 0) {
  45672. if (align === 'right' && x >= 0) {
  45673. options.align = 'left';
  45674. options.inside = true;
  45675. }
  45676. else {
  45677. x -= off;
  45678. }
  45679. justified = true;
  45680. }
  45681. // Off right
  45682. off = (alignAttr.x || 0) + bBox.width - padding;
  45683. if (off > chart.plotWidth) {
  45684. if (align === 'left' && x <= 0) {
  45685. options.align = 'right';
  45686. options.inside = true;
  45687. }
  45688. else {
  45689. x += chart.plotWidth - off;
  45690. }
  45691. justified = true;
  45692. }
  45693. // Off top
  45694. off = alignAttr.y + padding;
  45695. if (off < 0) {
  45696. if (verticalAlign === 'bottom' && y >= 0) {
  45697. options.verticalAlign = 'top';
  45698. options.inside = true;
  45699. }
  45700. else {
  45701. y -= off;
  45702. }
  45703. justified = true;
  45704. }
  45705. // Off bottom
  45706. off = (alignAttr.y || 0) + bBox.height - padding;
  45707. if (off > chart.plotHeight) {
  45708. if (verticalAlign === 'top' && y <= 0) {
  45709. options.verticalAlign = 'bottom';
  45710. options.inside = true;
  45711. }
  45712. else {
  45713. y += chart.plotHeight - off;
  45714. }
  45715. justified = true;
  45716. }
  45717. if (justified) {
  45718. options.x = x;
  45719. options.y = y;
  45720. dataLabel.placed = !isNew;
  45721. dataLabel.align(options, void 0, alignTo);
  45722. }
  45723. return justified;
  45724. };
  45725. if (seriesTypes.pie) {
  45726. seriesTypes.pie.prototype.dataLabelPositioners = {
  45727. // Based on the value computed in Highcharts' distribute algorithm.
  45728. radialDistributionY: function (point) {
  45729. return point.top + point.distributeBox.pos;
  45730. },
  45731. // get the x - use the natural x position for labels near the
  45732. // top and bottom, to prevent the top and botton slice
  45733. // connectors from touching each other on either side
  45734. // Based on the value computed in Highcharts' distribute algorithm.
  45735. radialDistributionX: function (series, point, y, naturalY) {
  45736. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  45737. naturalY :
  45738. y, point.half, point);
  45739. },
  45740. // dataLabels.distance determines the x position of the label
  45741. justify: function (point, radius, seriesCenter) {
  45742. return seriesCenter[0] + (point.half ? -1 : 1) *
  45743. (radius + point.labelDistance);
  45744. },
  45745. // Left edges of the left-half labels touch the left edge of the plot
  45746. // area. Right edges of the right-half labels touch the right edge of
  45747. // the plot area.
  45748. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  45749. var dataLabelWidth = dataLabel.getBBox().width;
  45750. return half ? dataLabelWidth + plotLeft :
  45751. plotWidth - dataLabelWidth - plotLeft;
  45752. },
  45753. // Connectors of each side end in the same x position. Labels are
  45754. // aligned to them. Left edge of the widest left-half label touches the
  45755. // left edge of the plot area. Right edge of the widest right-half label
  45756. // touches the right edge of the plot area.
  45757. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  45758. var maxDataLabelWidth = 0,
  45759. dataLabelWidth;
  45760. // find widest data label
  45761. points.forEach(function (point) {
  45762. dataLabelWidth = point.dataLabel.getBBox().width;
  45763. if (dataLabelWidth > maxDataLabelWidth) {
  45764. maxDataLabelWidth = dataLabelWidth;
  45765. }
  45766. });
  45767. return half ? maxDataLabelWidth + plotLeft :
  45768. plotWidth - maxDataLabelWidth - plotLeft;
  45769. }
  45770. };
  45771. /**
  45772. * Override the base drawDataLabels method by pie specific functionality
  45773. *
  45774. * @private
  45775. * @function Highcharts.seriesTypes.pie#drawDataLabels
  45776. * @return {void}
  45777. */
  45778. seriesTypes.pie.prototype.drawDataLabels = function () {
  45779. var series = this,
  45780. data = series.data,
  45781. point,
  45782. chart = series.chart,
  45783. options = series.options.dataLabels || {},
  45784. connectorPadding = options.connectorPadding,
  45785. connectorWidth,
  45786. plotWidth = chart.plotWidth,
  45787. plotHeight = chart.plotHeight,
  45788. plotLeft = chart.plotLeft,
  45789. maxWidth = Math.round(chart.chartWidth / 3),
  45790. connector,
  45791. seriesCenter = series.center,
  45792. radius = seriesCenter[2] / 2,
  45793. centerY = seriesCenter[1],
  45794. dataLabel,
  45795. dataLabelWidth,
  45796. // labelPos,
  45797. labelPosition,
  45798. labelHeight,
  45799. // divide the points into right and left halves for anti collision
  45800. halves = [
  45801. [],
  45802. [] // left
  45803. ],
  45804. x,
  45805. y,
  45806. visibility,
  45807. j,
  45808. overflow = [0, 0, 0, 0], // top, right, bottom, left
  45809. dataLabelPositioners = series.dataLabelPositioners,
  45810. pointDataLabelsOptions;
  45811. // get out if not enabled
  45812. if (!series.visible ||
  45813. (!options.enabled &&
  45814. !series._hasPointLabels)) {
  45815. return;
  45816. }
  45817. // Reset all labels that have been shortened
  45818. data.forEach(function (point) {
  45819. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  45820. point.dataLabel
  45821. .attr({
  45822. width: 'auto'
  45823. }).css({
  45824. width: 'auto',
  45825. textOverflow: 'clip'
  45826. });
  45827. point.dataLabel.shortened = false;
  45828. }
  45829. });
  45830. // run parent method
  45831. Series.prototype.drawDataLabels.apply(series);
  45832. data.forEach(function (point) {
  45833. if (point.dataLabel) {
  45834. if (point.visible) { // #407, #2510
  45835. // Arrange points for detection collision
  45836. halves[point.half].push(point);
  45837. // Reset positions (#4905)
  45838. point.dataLabel._pos = null;
  45839. // Avoid long labels squeezing the pie size too far down
  45840. if (!defined(options.style.width) &&
  45841. !defined(point.options.dataLabels &&
  45842. point.options.dataLabels.style &&
  45843. point.options.dataLabels.style.width)) {
  45844. if (point.dataLabel.getBBox().width > maxWidth) {
  45845. point.dataLabel.css({
  45846. // Use a fraction of the maxWidth to avoid
  45847. // wrapping close to the end of the string.
  45848. width: Math.round(maxWidth * 0.7) + 'px'
  45849. });
  45850. point.dataLabel.shortened = true;
  45851. }
  45852. }
  45853. }
  45854. else {
  45855. point.dataLabel = point.dataLabel.destroy();
  45856. // Workaround to make pies destroy multiple datalabels
  45857. // correctly. This logic needs rewriting to support multiple
  45858. // datalabels fully.
  45859. if (point.dataLabels && point.dataLabels.length === 1) {
  45860. delete point.dataLabels;
  45861. }
  45862. }
  45863. }
  45864. });
  45865. /* Loop over the points in each half, starting from the top and bottom
  45866. * of the pie to detect overlapping labels.
  45867. */
  45868. halves.forEach(function (points, i) {
  45869. var top,
  45870. bottom,
  45871. length = points.length,
  45872. positions = [],
  45873. naturalY,
  45874. sideOverflow,
  45875. size,
  45876. distributionLength;
  45877. if (!length) {
  45878. return;
  45879. }
  45880. // Sort by angle
  45881. series.sortByAngle(points, i - 0.5);
  45882. // Only do anti-collision when we have dataLabels outside the pie
  45883. // and have connectors. (#856)
  45884. if (series.maxLabelDistance > 0) {
  45885. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  45886. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  45887. points.forEach(function (point) {
  45888. // check if specific points' label is outside the pie
  45889. if (point.labelDistance > 0 && point.dataLabel) {
  45890. // point.top depends on point.labelDistance value
  45891. // Used for calculation of y value in getX method
  45892. point.top = Math.max(0, centerY - radius - point.labelDistance);
  45893. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  45894. size = point.dataLabel.getBBox().height || 21;
  45895. // point.positionsIndex is needed for getting index of
  45896. // parameter related to specific point inside positions
  45897. // array - not every point is in positions array.
  45898. point.distributeBox = {
  45899. target: point.labelPosition.natural.y -
  45900. point.top + size / 2,
  45901. size: size,
  45902. rank: point.y
  45903. };
  45904. positions.push(point.distributeBox);
  45905. }
  45906. });
  45907. distributionLength = bottom + size - top;
  45908. H.distribute(positions, distributionLength, distributionLength / 5);
  45909. }
  45910. // Now the used slots are sorted, fill them up sequentially
  45911. for (j = 0; j < length; j++) {
  45912. point = points[j];
  45913. // labelPos = point.labelPos;
  45914. labelPosition = point.labelPosition;
  45915. dataLabel = point.dataLabel;
  45916. visibility = point.visible === false ? 'hidden' : 'inherit';
  45917. naturalY = labelPosition.natural.y;
  45918. y = naturalY;
  45919. if (positions && defined(point.distributeBox)) {
  45920. if (typeof point.distributeBox.pos === 'undefined') {
  45921. visibility = 'hidden';
  45922. }
  45923. else {
  45924. labelHeight = point.distributeBox.size;
  45925. // Find label's y position
  45926. y = dataLabelPositioners
  45927. .radialDistributionY(point);
  45928. }
  45929. }
  45930. // It is needed to delete point.positionIndex for
  45931. // dynamically added points etc.
  45932. delete point.positionIndex; // @todo unused
  45933. // Find label's x position
  45934. // justify is undocumented in the API - preserve support for it
  45935. if (options.justify) {
  45936. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  45937. }
  45938. else {
  45939. switch (options.alignTo) {
  45940. case 'connectors':
  45941. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  45942. break;
  45943. case 'plotEdges':
  45944. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  45945. break;
  45946. default:
  45947. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  45948. }
  45949. }
  45950. // Record the placement and visibility
  45951. dataLabel._attr = {
  45952. visibility: visibility,
  45953. align: labelPosition.alignment
  45954. };
  45955. pointDataLabelsOptions = point.options.dataLabels || {};
  45956. dataLabel._pos = {
  45957. x: (x +
  45958. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  45959. ({
  45960. left: connectorPadding,
  45961. right: -connectorPadding
  45962. }[labelPosition.alignment] || 0)),
  45963. // 10 is for the baseline (label vs text)
  45964. y: (y +
  45965. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  45966. 10)
  45967. };
  45968. // labelPos.x = x;
  45969. // labelPos.y = y;
  45970. labelPosition.final.x = x;
  45971. labelPosition.final.y = y;
  45972. // Detect overflowing data labels
  45973. if (pick(options.crop, true)) {
  45974. dataLabelWidth = dataLabel.getBBox().width;
  45975. sideOverflow = null;
  45976. // Overflow left
  45977. if (x - dataLabelWidth < connectorPadding &&
  45978. i === 1 // left half
  45979. ) {
  45980. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  45981. overflow[3] = Math.max(sideOverflow, overflow[3]);
  45982. // Overflow right
  45983. }
  45984. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  45985. i === 0 // right half
  45986. ) {
  45987. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  45988. overflow[1] = Math.max(sideOverflow, overflow[1]);
  45989. }
  45990. // Overflow top
  45991. if (y - labelHeight / 2 < 0) {
  45992. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  45993. // Overflow left
  45994. }
  45995. else if (y + labelHeight / 2 > plotHeight) {
  45996. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  45997. }
  45998. dataLabel.sideOverflow = sideOverflow;
  45999. }
  46000. } // for each point
  46001. }); // for each half
  46002. // Do not apply the final placement and draw the connectors until we
  46003. // have verified that labels are not spilling over.
  46004. if (arrayMax(overflow) === 0 ||
  46005. this.verifyDataLabelOverflow(overflow)) {
  46006. // Place the labels in the final position
  46007. this.placeDataLabels();
  46008. this.points.forEach(function (point) {
  46009. // #8864: every connector can have individual options
  46010. pointDataLabelsOptions =
  46011. merge(options, point.options.dataLabels);
  46012. connectorWidth =
  46013. pick(pointDataLabelsOptions.connectorWidth, 1);
  46014. // Draw the connector
  46015. if (connectorWidth) {
  46016. var isNew = void 0;
  46017. connector = point.connector;
  46018. dataLabel = point.dataLabel;
  46019. if (dataLabel &&
  46020. dataLabel._pos &&
  46021. point.visible &&
  46022. point.labelDistance > 0) {
  46023. visibility = dataLabel._attr.visibility;
  46024. isNew = !connector;
  46025. if (isNew) {
  46026. point.connector = connector = chart.renderer
  46027. .path()
  46028. .addClass('highcharts-data-label-connector ' +
  46029. ' highcharts-color-' + point.colorIndex +
  46030. (point.className ?
  46031. ' ' + point.className :
  46032. ''))
  46033. .add(series.dataLabelsGroup);
  46034. if (!chart.styledMode) {
  46035. connector.attr({
  46036. 'stroke-width': connectorWidth,
  46037. 'stroke': (pointDataLabelsOptions.connectorColor ||
  46038. point.color ||
  46039. palette.neutralColor60)
  46040. });
  46041. }
  46042. }
  46043. connector[isNew ? 'attr' : 'animate']({
  46044. d: point.getConnectorPath()
  46045. });
  46046. connector.attr('visibility', visibility);
  46047. }
  46048. else if (connector) {
  46049. point.connector = connector.destroy();
  46050. }
  46051. }
  46052. });
  46053. }
  46054. };
  46055. /**
  46056. * Extendable method for getting the path of the connector between the data
  46057. * label and the pie slice.
  46058. *
  46059. * @private
  46060. * @function Highcharts.seriesTypes.pie#connectorPath
  46061. *
  46062. * @param {*} labelPos
  46063. *
  46064. * @return {Highcharts.SVGPathArray}
  46065. */
  46066. // TODO: depracated - remove it
  46067. /*
  46068. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  46069. let x = labelPos.x,
  46070. y = labelPos.y;
  46071. return pick(this.options.dataLabels.softConnector, true) ? [
  46072. 'M',
  46073. // end of the string at the label
  46074. x + (labelPos[6] === 'left' ? 5 : -5), y,
  46075. 'C',
  46076. x, y, // first break, next to the label
  46077. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  46078. labelPos[2], labelPos[3], // second break
  46079. 'L',
  46080. labelPos[4], labelPos[5] // base
  46081. ] : [
  46082. 'M',
  46083. // end of the string at the label
  46084. x + (labelPos[6] === 'left' ? 5 : -5), y,
  46085. 'L',
  46086. labelPos[2], labelPos[3], // second break
  46087. 'L',
  46088. labelPos[4], labelPos[5] // base
  46089. ];
  46090. };
  46091. */
  46092. /**
  46093. * Perform the final placement of the data labels after we have verified
  46094. * that they fall within the plot area.
  46095. *
  46096. * @private
  46097. * @function Highcharts.seriesTypes.pie#placeDataLabels
  46098. * @return {void}
  46099. */
  46100. seriesTypes.pie.prototype.placeDataLabels = function () {
  46101. this.points.forEach(function (point) {
  46102. var dataLabel = point.dataLabel,
  46103. _pos;
  46104. if (dataLabel && point.visible) {
  46105. _pos = dataLabel._pos;
  46106. if (_pos) {
  46107. // Shorten data labels with ellipsis if they still overflow
  46108. // after the pie has reached minSize (#223).
  46109. if (dataLabel.sideOverflow) {
  46110. dataLabel._attr.width =
  46111. Math.max(dataLabel.getBBox().width -
  46112. dataLabel.sideOverflow, 0);
  46113. dataLabel.css({
  46114. width: dataLabel._attr.width + 'px',
  46115. textOverflow: ((this.options.dataLabels.style || {})
  46116. .textOverflow ||
  46117. 'ellipsis')
  46118. });
  46119. dataLabel.shortened = true;
  46120. }
  46121. dataLabel.attr(dataLabel._attr);
  46122. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  46123. dataLabel.moved = true;
  46124. }
  46125. else if (dataLabel) {
  46126. dataLabel.attr({ y: -9999 });
  46127. }
  46128. }
  46129. // Clear for update
  46130. delete point.distributeBox;
  46131. }, this);
  46132. };
  46133. seriesTypes.pie.prototype.alignDataLabel = noop;
  46134. /**
  46135. * Verify whether the data labels are allowed to draw, or we should run more
  46136. * translation and data label positioning to keep them inside the plot area.
  46137. * Returns true when data labels are ready to draw.
  46138. *
  46139. * @private
  46140. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  46141. * @param {Array<number>} overflow
  46142. * @return {boolean}
  46143. */
  46144. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  46145. var center = this.center,
  46146. options = this.options,
  46147. centerOption = options.center,
  46148. minSize = options.minSize || 80,
  46149. newSize = minSize,
  46150. // If a size is set, return true and don't try to shrink the pie
  46151. // to fit the labels.
  46152. ret = options.size !== null;
  46153. if (!ret) {
  46154. // Handle horizontal size and center
  46155. if (centerOption[0] !== null) { // Fixed center
  46156. newSize = Math.max(center[2] -
  46157. Math.max(overflow[1], overflow[3]), minSize);
  46158. }
  46159. else { // Auto center
  46160. newSize = Math.max(
  46161. // horizontal overflow
  46162. center[2] - overflow[1] - overflow[3], minSize);
  46163. // horizontal center
  46164. center[0] += (overflow[3] - overflow[1]) / 2;
  46165. }
  46166. // Handle vertical size and center
  46167. if (centerOption[1] !== null) { // Fixed center
  46168. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  46169. }
  46170. else { // Auto center
  46171. newSize = clamp(newSize, minSize,
  46172. // vertical overflow
  46173. center[2] - overflow[0] - overflow[2]);
  46174. // vertical center
  46175. center[1] += (overflow[0] - overflow[2]) / 2;
  46176. }
  46177. // If the size must be decreased, we need to run translate and
  46178. // drawDataLabels again
  46179. if (newSize < center[2]) {
  46180. center[2] = newSize;
  46181. center[3] = Math.min(// #3632
  46182. relativeLength(options.innerSize || 0, newSize), newSize);
  46183. this.translate(center);
  46184. if (this.drawDataLabels) {
  46185. this.drawDataLabels();
  46186. }
  46187. // Else, return true to indicate that the pie and its labels is
  46188. // within the plot area
  46189. }
  46190. else {
  46191. ret = true;
  46192. }
  46193. }
  46194. return ret;
  46195. };
  46196. }
  46197. if (seriesTypes.column) {
  46198. /**
  46199. * Override the basic data label alignment by adjusting for the position of
  46200. * the column.
  46201. *
  46202. * @private
  46203. * @function Highcharts.seriesTypes.column#alignDataLabel
  46204. * @param {Highcharts.Point} point
  46205. * @param {Highcharts.SVGElement} dataLabel
  46206. * @param {Highcharts.DataLabelsOptions} options
  46207. * @param {Highcharts.BBoxObject} alignTo
  46208. * @param {boolean} [isNew]
  46209. * @return {void}
  46210. */
  46211. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  46212. var inverted = this.chart.inverted,
  46213. series = point.series,
  46214. // data label box for alignment
  46215. dlBox = point.dlBox || point.shapeArgs,
  46216. below = pick(point.below, // range series
  46217. point.plotY >
  46218. pick(this.translatedThreshold,
  46219. series.yAxis.len)),
  46220. // draw it inside the box?
  46221. inside = pick(options.inside, !!this.options.stacking),
  46222. overshoot;
  46223. // Align to the column itself, or the top of it
  46224. if (dlBox) { // Area range uses this method but not alignTo
  46225. alignTo = merge(dlBox);
  46226. if (alignTo.y < 0) {
  46227. alignTo.height += alignTo.y;
  46228. alignTo.y = 0;
  46229. }
  46230. // If parts of the box overshoots outside the plot area, modify the
  46231. // box to center the label inside
  46232. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  46233. if (overshoot > 0 && overshoot < alignTo.height) {
  46234. alignTo.height -= overshoot;
  46235. }
  46236. if (inverted) {
  46237. alignTo = {
  46238. x: series.yAxis.len - alignTo.y - alignTo.height,
  46239. y: series.xAxis.len - alignTo.x - alignTo.width,
  46240. width: alignTo.height,
  46241. height: alignTo.width
  46242. };
  46243. }
  46244. // Compute the alignment box
  46245. if (!inside) {
  46246. if (inverted) {
  46247. alignTo.x += below ? 0 : alignTo.width;
  46248. alignTo.width = 0;
  46249. }
  46250. else {
  46251. alignTo.y += below ? alignTo.height : 0;
  46252. alignTo.height = 0;
  46253. }
  46254. }
  46255. }
  46256. // When alignment is undefined (typically columns and bars), display the
  46257. // individual point below or above the point depending on the threshold
  46258. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  46259. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  46260. // Call the parent method
  46261. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  46262. // If label was justified and we have contrast, set it:
  46263. if (options.inside && point.contrastColor) {
  46264. dataLabel.css({
  46265. color: point.contrastColor
  46266. });
  46267. }
  46268. };
  46269. }
  46270. });
  46271. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  46272. /* *
  46273. *
  46274. * Highcharts module to hide overlapping data labels.
  46275. * This module is included in Highcharts.
  46276. *
  46277. * (c) 2009-2021 Torstein Honsi
  46278. *
  46279. * License: www.highcharts.com/license
  46280. *
  46281. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46282. *
  46283. * */
  46284. var addEvent = U.addEvent,
  46285. fireEvent = U.fireEvent,
  46286. isArray = U.isArray,
  46287. isNumber = U.isNumber,
  46288. objectEach = U.objectEach,
  46289. pick = U.pick;
  46290. /**
  46291. * Internal type
  46292. * @private
  46293. */
  46294. /* eslint-disable no-invalid-this */
  46295. // Collect potensial overlapping data labels. Stack labels probably don't need
  46296. // to be considered because they are usually accompanied by data labels that lie
  46297. // inside the columns.
  46298. addEvent(Chart, 'render', function collectAndHide() {
  46299. var chart = this,
  46300. labels = [];
  46301. // Consider external label collectors
  46302. (this.labelCollectors || []).forEach(function (collector) {
  46303. labels = labels.concat(collector());
  46304. });
  46305. (this.yAxis || []).forEach(function (yAxis) {
  46306. if (yAxis.stacking &&
  46307. yAxis.options.stackLabels &&
  46308. !yAxis.options.stackLabels.allowOverlap) {
  46309. objectEach(yAxis.stacking.stacks, function (stack) {
  46310. objectEach(stack, function (stackItem) {
  46311. if (stackItem.label &&
  46312. stackItem.label.visibility !== 'hidden' // #15607
  46313. ) {
  46314. labels.push(stackItem.label);
  46315. }
  46316. });
  46317. });
  46318. }
  46319. });
  46320. (this.series || []).forEach(function (series) {
  46321. var dlOptions = series.options.dataLabels;
  46322. if (series.visible &&
  46323. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  46324. var push = function (points) {
  46325. return points.forEach(function (point) {
  46326. if (point.visible) {
  46327. var dataLabels = (isArray(point.dataLabels) ?
  46328. point.dataLabels :
  46329. (point.dataLabel ? [point.dataLabel] : []));
  46330. dataLabels.forEach(function (label) {
  46331. var options = label.options;
  46332. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  46333. if (!options.allowOverlap) {
  46334. labels.push(label);
  46335. }
  46336. else { // #13449
  46337. label.oldOpacity = label.opacity;
  46338. label.newOpacity = 1;
  46339. hideOrShow(label, chart);
  46340. }
  46341. });
  46342. }
  46343. });
  46344. };
  46345. push(series.nodes || []);
  46346. push(series.points);
  46347. }
  46348. });
  46349. this.hideOverlappingLabels(labels);
  46350. });
  46351. /**
  46352. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  46353. * provide a smooth visual imression.
  46354. *
  46355. * @private
  46356. * @function Highcharts.Chart#hideOverlappingLabels
  46357. * @param {Array<Highcharts.SVGElement>} labels
  46358. * Rendered data labels
  46359. * @requires modules/overlapping-datalabels
  46360. */
  46361. Chart.prototype.hideOverlappingLabels = function (labels) {
  46362. var chart = this,
  46363. len = labels.length,
  46364. ren = chart.renderer,
  46365. label,
  46366. i,
  46367. j,
  46368. label1,
  46369. label2,
  46370. box1,
  46371. box2,
  46372. isLabelAffected = false,
  46373. isIntersectRect = function (box1,
  46374. box2) {
  46375. return !(box2.x >= box1.x + box1.width ||
  46376. box2.x + box2.width <= box1.x ||
  46377. box2.y >= box1.y + box1.height ||
  46378. box2.y + box2.height <= box1.y);
  46379. },
  46380. // Get the box with its position inside the chart, as opposed to getBBox
  46381. // that only reports the position relative to the parent.
  46382. getAbsoluteBox = function (label) {
  46383. var pos,
  46384. parent,
  46385. bBox,
  46386. // Substract the padding if no background or border (#4333)
  46387. padding = label.box ? 0 : (label.padding || 0),
  46388. lineHeightCorrection = 0,
  46389. xOffset = 0,
  46390. boxWidth,
  46391. alignValue;
  46392. if (label &&
  46393. (!label.alignAttr || label.placed)) {
  46394. pos = label.alignAttr || {
  46395. x: label.attr('x'),
  46396. y: label.attr('y')
  46397. };
  46398. parent = label.parentGroup;
  46399. // Get width and height if pure text nodes (stack labels)
  46400. if (!label.width) {
  46401. bBox = label.getBBox();
  46402. label.width = bBox.width;
  46403. label.height = bBox.height;
  46404. // Labels positions are computed from top left corner, so
  46405. // we need to substract the text height from text nodes too.
  46406. lineHeightCorrection = ren
  46407. .fontMetrics(null, label.element).h;
  46408. }
  46409. boxWidth = label.width - 2 * padding;
  46410. alignValue = {
  46411. left: '0',
  46412. center: '0.5',
  46413. right: '1'
  46414. }[label.alignValue];
  46415. if (alignValue) {
  46416. xOffset = +alignValue * boxWidth;
  46417. }
  46418. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  46419. xOffset = label.x - label.translateX;
  46420. }
  46421. return {
  46422. x: pos.x + (parent.translateX || 0) + padding -
  46423. (xOffset || 0),
  46424. y: pos.y + (parent.translateY || 0) + padding -
  46425. lineHeightCorrection,
  46426. width: label.width - 2 * padding,
  46427. height: label.height - 2 * padding
  46428. };
  46429. }
  46430. };
  46431. for (i = 0; i < len; i++) {
  46432. label = labels[i];
  46433. if (label) {
  46434. // Mark with initial opacity
  46435. label.oldOpacity = label.opacity;
  46436. label.newOpacity = 1;
  46437. label.absoluteBox = getAbsoluteBox(label);
  46438. }
  46439. }
  46440. // Prevent a situation in a gradually rising slope, that each label will
  46441. // hide the previous one because the previous one always has lower rank.
  46442. labels.sort(function (a, b) {
  46443. return (b.labelrank || 0) - (a.labelrank || 0);
  46444. });
  46445. // Detect overlapping labels
  46446. for (i = 0; i < len; i++) {
  46447. label1 = labels[i];
  46448. box1 = label1 && label1.absoluteBox;
  46449. for (j = i + 1; j < len; ++j) {
  46450. label2 = labels[j];
  46451. box2 = label2 && label2.absoluteBox;
  46452. if (box1 &&
  46453. box2 &&
  46454. label1 !== label2 && // #6465, polar chart with connectEnds
  46455. label1.newOpacity !== 0 &&
  46456. label2.newOpacity !== 0) {
  46457. if (isIntersectRect(box1, box2)) {
  46458. (label1.labelrank < label2.labelrank ? label1 : label2)
  46459. .newOpacity = 0;
  46460. }
  46461. }
  46462. }
  46463. }
  46464. // Hide or show
  46465. labels.forEach(function (label) {
  46466. if (hideOrShow(label, chart)) {
  46467. isLabelAffected = true;
  46468. }
  46469. });
  46470. if (isLabelAffected) {
  46471. fireEvent(chart, 'afterHideAllOverlappingLabels');
  46472. }
  46473. };
  46474. /**
  46475. * Hide or show labels based on opacity.
  46476. *
  46477. * @private
  46478. * @function hideOrShow
  46479. * @param {Highcharts.SVGElement} label
  46480. * The label.
  46481. * @param {Highcharts.Chart} chart
  46482. * The chart that contains the label.
  46483. * @return {boolean}
  46484. */
  46485. function hideOrShow(label, chart) {
  46486. var complete,
  46487. newOpacity,
  46488. isLabelAffected = false;
  46489. if (label) {
  46490. newOpacity = label.newOpacity;
  46491. if (label.oldOpacity !== newOpacity) {
  46492. // Make sure the label is completely hidden to avoid catching
  46493. // clicks (#4362)
  46494. if (label.alignAttr && label.placed) { // data labels
  46495. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  46496. complete = function () {
  46497. if (!chart.styledMode) {
  46498. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  46499. }
  46500. };
  46501. isLabelAffected = true;
  46502. // Animate or set the opacity
  46503. label.alignAttr.opacity = newOpacity;
  46504. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  46505. fireEvent(chart, 'afterHideOverlappingLabel');
  46506. }
  46507. else { // other labels, tick labels
  46508. label.attr({
  46509. opacity: newOpacity
  46510. });
  46511. }
  46512. }
  46513. label.isOld = true;
  46514. }
  46515. return isLabelAffected;
  46516. }
  46517. });
  46518. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Utilities.js']], function (U) {
  46519. /* *
  46520. *
  46521. * (c) 2010-2021 Torstein Honsi
  46522. *
  46523. * License: www.highcharts.com/license
  46524. *
  46525. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46526. *
  46527. * */
  46528. var extend = U.extend,
  46529. find = U.find,
  46530. isArray = U.isArray,
  46531. isObject = U.isObject,
  46532. merge = U.merge,
  46533. objectEach = U.objectEach,
  46534. pick = U.pick,
  46535. splat = U.splat,
  46536. uniqueKey = U.uniqueKey;
  46537. /* *
  46538. *
  46539. * Class
  46540. *
  46541. * */
  46542. /* eslint-disable no-invalid-this, valid-jsdoc */
  46543. var ResponsiveChart = /** @class */ (function () {
  46544. function ResponsiveChart() {
  46545. }
  46546. /* *
  46547. *
  46548. * Functions
  46549. *
  46550. * */
  46551. /**
  46552. * Get the current values for a given set of options. Used before we update
  46553. * the chart with a new responsiveness rule.
  46554. *
  46555. * @todo Restore axis options (by id?). The matching of items in collections
  46556. * bears resemblance to the oneToOne matching in Chart.update. Probably we
  46557. * can refactor out that matching and reuse it in both functions.
  46558. *
  46559. * @private
  46560. * @function Highcharts.Chart#currentOptions
  46561. */
  46562. ResponsiveChart.prototype.currentOptions = function (options) {
  46563. var chart = this, ret = {};
  46564. /**
  46565. * Recurse over a set of options and its current values,
  46566. * and store the current values in the ret object.
  46567. */
  46568. function getCurrent(options, curr, ret, depth) {
  46569. var i;
  46570. objectEach(options, function (val, key) {
  46571. if (!depth &&
  46572. chart.collectionsWithUpdate.indexOf(key) > -1 &&
  46573. curr[key]) {
  46574. val = splat(val);
  46575. ret[key] = [];
  46576. // Iterate over collections like series, xAxis or yAxis and
  46577. // map the items by index.
  46578. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  46579. // Item exists in current data (#6347)
  46580. if (curr[key][i]) {
  46581. // If the item is missing from the new data, we need
  46582. // to save the whole config structure. Like when
  46583. // responsively updating from a dual axis layout to
  46584. // a single axis and back (#13544).
  46585. if (val[i] === void 0) {
  46586. ret[key][i] = curr[key][i];
  46587. // Otherwise, proceed
  46588. }
  46589. else {
  46590. ret[key][i] = {};
  46591. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  46592. }
  46593. }
  46594. }
  46595. }
  46596. else if (isObject(val)) {
  46597. ret[key] = isArray(val) ? [] : {};
  46598. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  46599. }
  46600. else if (typeof curr[key] === 'undefined') { // #10286
  46601. ret[key] = null;
  46602. }
  46603. else {
  46604. ret[key] = curr[key];
  46605. }
  46606. });
  46607. }
  46608. getCurrent(options, this.options, ret, 0);
  46609. return ret;
  46610. };
  46611. /**
  46612. * Handle a single responsiveness rule.
  46613. *
  46614. * @private
  46615. * @function Highcharts.Chart#matchResponsiveRule
  46616. * @param {Highcharts.ResponsiveRulesOptions} rule
  46617. * @param {Array<string>} matches
  46618. */
  46619. ResponsiveChart.prototype.matchResponsiveRule = function (rule, matches) {
  46620. var condition = rule.condition,
  46621. fn = condition.callback || function () {
  46622. return (this.chartWidth <= pick(condition.maxWidth,
  46623. Number.MAX_VALUE) &&
  46624. this.chartHeight <=
  46625. pick(condition.maxHeight,
  46626. Number.MAX_VALUE) &&
  46627. this.chartWidth >= pick(condition.minWidth, 0) &&
  46628. this.chartHeight >= pick(condition.minHeight, 0));
  46629. };
  46630. if (fn.call(this)) {
  46631. matches.push(rule._id);
  46632. }
  46633. };
  46634. /**
  46635. * Update the chart based on the current chart/document size and options for
  46636. * responsiveness.
  46637. *
  46638. * @private
  46639. * @function Highcharts.Chart#setResponsive
  46640. * @param {boolean} [redraw=true]
  46641. * @param {boolean} [reset=false]
  46642. * Reset by un-applying all rules. Chart.update resets all rules before
  46643. * applying updated options.
  46644. */
  46645. ResponsiveChart.prototype.setResponsive = function (redraw, reset) {
  46646. var options = this.options.responsive,
  46647. currentResponsive = this.currentResponsive;
  46648. var ruleIds = [],
  46649. undoOptions;
  46650. if (!reset && options && options.rules) {
  46651. options.rules.forEach(function (rule) {
  46652. if (typeof rule._id === 'undefined') {
  46653. rule._id = uniqueKey();
  46654. }
  46655. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  46656. }, this);
  46657. }
  46658. // Merge matching rules
  46659. var mergedOptions = merge.apply(void 0,
  46660. ruleIds
  46661. .map(function (ruleId) { return find((options || {}).rules || [],
  46662. function (rule) { return (rule._id === ruleId); }); })
  46663. .map(function (rule) { return (rule && rule.chartOptions); }));
  46664. mergedOptions.isResponsiveOptions = true;
  46665. // Stringified key for the rules that currently apply.
  46666. ruleIds = (ruleIds.toString() || void 0);
  46667. var currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  46668. // Changes in what rules apply
  46669. if (ruleIds !== currentRuleIds) {
  46670. // Undo previous rules. Before we apply a new set of rules, we need
  46671. // to roll back completely to base options (#6291).
  46672. if (currentResponsive) {
  46673. this.update(currentResponsive.undoOptions, redraw, true);
  46674. }
  46675. if (ruleIds) {
  46676. // Get undo-options for matching rules
  46677. undoOptions = this.currentOptions(mergedOptions);
  46678. undoOptions.isResponsiveOptions = true;
  46679. this.currentResponsive = {
  46680. ruleIds: ruleIds,
  46681. mergedOptions: mergedOptions,
  46682. undoOptions: undoOptions
  46683. };
  46684. this.update(mergedOptions, redraw, true);
  46685. }
  46686. else {
  46687. this.currentResponsive = void 0;
  46688. }
  46689. }
  46690. };
  46691. return ResponsiveChart;
  46692. }());
  46693. /* *
  46694. *
  46695. * Composition
  46696. *
  46697. * */
  46698. var ResponsiveComposition = /** @class */ (function () {
  46699. function ResponsiveComposition() {
  46700. }
  46701. /* *
  46702. *
  46703. * Static Functions
  46704. *
  46705. * */
  46706. ResponsiveComposition.compose = function (ChartClass) {
  46707. extend(ChartClass.prototype, ResponsiveChart.prototype);
  46708. return ChartClass;
  46709. };
  46710. return ResponsiveComposition;
  46711. }());
  46712. /* *
  46713. *
  46714. * Default Export
  46715. *
  46716. * */
  46717. /* *
  46718. *
  46719. * API Declarations
  46720. *
  46721. * */
  46722. /**
  46723. * A callback function to gain complete control on when the responsive rule
  46724. * applies.
  46725. *
  46726. * @callback Highcharts.ResponsiveCallbackFunction
  46727. *
  46728. * @param {Highcharts.Chart} this
  46729. * Chart context.
  46730. *
  46731. * @return {boolean}
  46732. * Return `true` if it applies.
  46733. */
  46734. (''); // detached doclets above
  46735. /* *
  46736. *
  46737. * API Options
  46738. *
  46739. * */
  46740. /**
  46741. * Allows setting a set of rules to apply for different screen or chart
  46742. * sizes. Each rule specifies additional chart options.
  46743. *
  46744. * @sample {highstock} stock/demo/responsive/
  46745. * Stock chart
  46746. * @sample highcharts/responsive/axis/
  46747. * Axis
  46748. * @sample highcharts/responsive/legend/
  46749. * Legend
  46750. * @sample highcharts/responsive/classname/
  46751. * Class name
  46752. *
  46753. * @since 5.0.0
  46754. * @apioption responsive
  46755. */
  46756. /**
  46757. * A set of rules for responsive settings. The rules are executed from
  46758. * the top down.
  46759. *
  46760. * @sample {highcharts} highcharts/responsive/axis/
  46761. * Axis changes
  46762. * @sample {highstock} highcharts/responsive/axis/
  46763. * Axis changes
  46764. * @sample {highmaps} highcharts/responsive/axis/
  46765. * Axis changes
  46766. *
  46767. * @type {Array<*>}
  46768. * @since 5.0.0
  46769. * @apioption responsive.rules
  46770. */
  46771. /**
  46772. * A full set of chart options to apply as overrides to the general
  46773. * chart options. The chart options are applied when the given rule
  46774. * is active.
  46775. *
  46776. * A special case is configuration objects that take arrays, for example
  46777. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  46778. * collections, an `id` option is used to map the new option set to
  46779. * an existing object. If an existing object of the same id is not found,
  46780. * the item of the same indexupdated. So for example, setting `chartOptions`
  46781. * with two series items without an `id`, will cause the existing chart's
  46782. * two series to be updated with respective options.
  46783. *
  46784. * @sample {highstock} stock/demo/responsive/
  46785. * Stock chart
  46786. * @sample highcharts/responsive/axis/
  46787. * Axis
  46788. * @sample highcharts/responsive/legend/
  46789. * Legend
  46790. * @sample highcharts/responsive/classname/
  46791. * Class name
  46792. *
  46793. * @type {Highcharts.Options}
  46794. * @since 5.0.0
  46795. * @apioption responsive.rules.chartOptions
  46796. */
  46797. /**
  46798. * Under which conditions the rule applies.
  46799. *
  46800. * @since 5.0.0
  46801. * @apioption responsive.rules.condition
  46802. */
  46803. /**
  46804. * A callback function to gain complete control on when the responsive
  46805. * rule applies. Return `true` if it applies. This opens for checking
  46806. * against other metrics than the chart size, for example the document
  46807. * size or other elements.
  46808. *
  46809. * @type {Highcharts.ResponsiveCallbackFunction}
  46810. * @since 5.0.0
  46811. * @context Highcharts.Chart
  46812. * @apioption responsive.rules.condition.callback
  46813. */
  46814. /**
  46815. * The responsive rule applies if the chart height is less than this.
  46816. *
  46817. * @type {number}
  46818. * @since 5.0.0
  46819. * @apioption responsive.rules.condition.maxHeight
  46820. */
  46821. /**
  46822. * The responsive rule applies if the chart width is less than this.
  46823. *
  46824. * @sample highcharts/responsive/axis/
  46825. * Max width is 500
  46826. *
  46827. * @type {number}
  46828. * @since 5.0.0
  46829. * @apioption responsive.rules.condition.maxWidth
  46830. */
  46831. /**
  46832. * The responsive rule applies if the chart height is greater than this.
  46833. *
  46834. * @type {number}
  46835. * @default 0
  46836. * @since 5.0.0
  46837. * @apioption responsive.rules.condition.minHeight
  46838. */
  46839. /**
  46840. * The responsive rule applies if the chart width is greater than this.
  46841. *
  46842. * @type {number}
  46843. * @default 0
  46844. * @since 5.0.0
  46845. * @apioption responsive.rules.condition.minWidth
  46846. */
  46847. (''); // keeps doclets above in JS file
  46848. return ResponsiveComposition;
  46849. });
  46850. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Renderer/HTML/HTMLElement.js'], _modules['Core/Renderer/HTML/HTMLRenderer.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Axis/PlotLineOrBand.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Pointer.js'], _modules['Core/MSPointer.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Series/Series.js'], _modules['Core/Responsive.js'], _modules['Core/Color/Color.js'], _modules['Core/Time.js']], function (Highcharts, Utilities, DefaultOptions, Fx, Animation, AST, FormatUtilities, SVGElement, SVGRenderer, HTMLElement, HTMLRenderer, Axis, PlotLineOrBand, Tick, Pointer, MSPointer, Chart, Series, Responsive, Color, Time) {
  46851. var G = Highcharts;
  46852. // Animation
  46853. G.animate = Animation.animate;
  46854. G.animObject = Animation.animObject;
  46855. G.getDeferredAnimation = Animation.getDeferredAnimation;
  46856. G.setAnimation = Animation.setAnimation;
  46857. G.stop = Animation.stop;
  46858. G.timers = Fx.timers;
  46859. // Classes
  46860. G.AST = AST;
  46861. G.Axis = Axis;
  46862. G.Chart = Chart;
  46863. G.chart = Chart.chart;
  46864. G.Fx = Fx;
  46865. G.PlotLineOrBand = PlotLineOrBand;
  46866. G.Pointer = (MSPointer.isRequired() ? MSPointer : Pointer);
  46867. G.Series = Series;
  46868. G.SVGElement = SVGElement;
  46869. G.SVGRenderer = SVGRenderer;
  46870. G.Tick = Tick;
  46871. G.Time = Time;
  46872. // Color
  46873. G.Color = Color;
  46874. G.color = Color.parse;
  46875. // Compositions
  46876. HTMLRenderer.compose(SVGRenderer);
  46877. HTMLElement.compose(SVGElement);
  46878. // DefaultOptions
  46879. G.defaultOptions = DefaultOptions.defaultOptions;
  46880. G.getOptions = DefaultOptions.getOptions;
  46881. G.time = DefaultOptions.defaultTime;
  46882. G.setOptions = DefaultOptions.setOptions;
  46883. // Format Utilities
  46884. G.dateFormat = FormatUtilities.dateFormat;
  46885. G.format = FormatUtilities.format;
  46886. G.numberFormat = FormatUtilities.numberFormat;
  46887. // Utilities
  46888. G.addEvent = Utilities.addEvent;
  46889. G.arrayMax = Utilities.arrayMax;
  46890. G.arrayMin = Utilities.arrayMin;
  46891. G.attr = Utilities.attr;
  46892. G.clearTimeout = Utilities.clearTimeout;
  46893. G.correctFloat = Utilities.correctFloat;
  46894. G.createElement = Utilities.createElement;
  46895. G.css = Utilities.css;
  46896. G.defined = Utilities.defined;
  46897. G.destroyObjectProperties = Utilities.destroyObjectProperties;
  46898. G.discardElement = Utilities.discardElement;
  46899. G.erase = Utilities.erase;
  46900. G.error = Utilities.error;
  46901. G.extend = Utilities.extend;
  46902. G.extendClass = Utilities.extendClass;
  46903. G.find = Utilities.find;
  46904. G.fireEvent = Utilities.fireEvent;
  46905. G.getMagnitude = Utilities.getMagnitude;
  46906. G.getStyle = Utilities.getStyle;
  46907. G.inArray = Utilities.inArray;
  46908. G.isArray = Utilities.isArray;
  46909. G.isClass = Utilities.isClass;
  46910. G.isDOMElement = Utilities.isDOMElement;
  46911. G.isFunction = Utilities.isFunction;
  46912. G.isNumber = Utilities.isNumber;
  46913. G.isObject = Utilities.isObject;
  46914. G.isString = Utilities.isString;
  46915. G.keys = Utilities.keys;
  46916. G.merge = Utilities.merge;
  46917. G.normalizeTickInterval = Utilities.normalizeTickInterval;
  46918. G.objectEach = Utilities.objectEach;
  46919. G.offset = Utilities.offset;
  46920. G.pad = Utilities.pad;
  46921. G.pick = Utilities.pick;
  46922. G.pInt = Utilities.pInt;
  46923. G.relativeLength = Utilities.relativeLength;
  46924. G.removeEvent = Utilities.removeEvent;
  46925. G.splat = Utilities.splat;
  46926. G.stableSort = Utilities.stableSort;
  46927. G.syncTimeout = Utilities.syncTimeout;
  46928. G.timeUnits = Utilities.timeUnits;
  46929. G.uniqueKey = Utilities.uniqueKey;
  46930. G.useSerialIds = Utilities.useSerialIds;
  46931. G.wrap = Utilities.wrap;
  46932. // Compositions
  46933. Responsive.compose(Chart);
  46934. // Default Export
  46935. return G;
  46936. });
  46937. _modules['masters/highcharts.src.js']._modules = _modules;
  46938. return _modules['masters/highcharts.src.js'];
  46939. }));